Changeset 2555 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-wporg-plugin-directory.php
- Timestamp:
- 02/23/2016 04:12:32 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-wporg-plugin-directory.php
r2501 r2555 236 236 $_pages = preg_split( "#<!--section=(.+?)-->#", $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); 237 237 $content_pages = array( 238 'stats' => '[wporg-plugins-stats]', 239 'developers' => '[wporg-plugins-developer]', 238 'screenshots' => '[wporg-plugins-screenshots]', 239 'stats' => '[wporg-plugins-stats]', 240 'developers' => '[wporg-plugins-developer]', 240 241 ); 241 242 … … 250 251 return $content_pages; 251 252 } 253 254 /** 255 * Retrieve the WP_Post object representing a given plugin. 256 * 257 * @param $plugin_slug string|WP_Post The slug of the plugin to retrieve. 258 * @return WP_Post|WP_Error 259 */ 260 public function get_or_create_plugin_post( $plugin_slug ) { 261 if ( $plugin_slug instanceof WP_Post ) { 262 return $plugin_slug; 263 } 264 265 // get_post_by_slug(); 266 $posts = get_posts( array( 'post_type' => 'plugin', 'name' => $plugin_slug, 'post_status' => 'any', 'fields' => 'ids' ) ); 267 268 if ( $posts ) { 269 $id = reset( $posts ); 270 } else { 271 $id = wp_insert_post( array( 272 'post_type' => 'plugin', 273 'post_status' => 'pending', 274 'post_name' => $plugin_slug, 275 'post_title' => $plugin_slug, 276 'post_content' => '', 277 ), true ); 278 279 if ( is_wp_error( $id ) ) { 280 return $id; 281 } 282 } 283 284 $plugin = get_post( $id ); 285 return $plugin; 286 } 252 287 }
Note: See TracChangeset
for help on using the changeset viewer.