Changeset 5200 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php
- Timestamp:
- 03/29/2017 11:04:05 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php
r5147 r5200 57 57 $plugin = Plugin_Directory::get_plugin_post( $plugin_slug ); 58 58 if ( ! $plugin ) { 59 // TODOthrow new Exception( "Unknown Plugin" );59 throw new Exception( "Unknown Plugin" ); 60 60 } 61 61 62 62 $data = $this->export_and_parse_plugin( $plugin_slug ); 63 64 // TODO: During development while the bbPress variant is still running, we'll pull details from it and allow importing of any plugin.65 $topic = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . PLUGINS_TABLE_PREFIX . 'topics WHERE topic_slug = %s', $plugin_slug ) );66 67 if ( ! $plugin && ! $topic ) {68 throw new Exception( "Unknown Plugin" );69 }70 71 // TODO: During development we're just going to import status from bbPress.72 $status = 'publish';73 if ( 2 == $topic->topic_open ) {74 $status = 'approved';75 } elseif ( 2 == $topic->forum_id ) {76 $status = 'pending';77 } elseif ( 4 == $topic->forum_id || 'rejected-' == substr( $topic->topic_slug, 0, 9 ) ) {78 $status = 'rejected';79 } elseif ( 1 == $topic->forum_id && 0 == $topic->topic_open ) {80 $status = 'closed';81 } elseif ( 3 == $topic->topic_open ) {82 $status = 'disabled';83 }84 85 $plugin_existed_already = (bool) $plugin;86 if ( ! $plugin ) {87 $author_ip = $wpdb->get_var( $wpdb->prepare( 'SELECT poster_ip FROM ' . PLUGINS_TABLE_PREFIX . 'posts WHERE topic_id = %s', $topic->topic_id ) );88 89 add_filter( 'wp_insert_post_data', array( $this, 'filter_wp_insert_post_data' ), 10, 2 );90 $plugin = Plugin_Directory::create_plugin_post( array(91 'post_name' => $plugin_slug,92 'post_status' => $status,93 'post_author' => $topic->topic_poster,94 'post_date_gmt' => $topic->topic_start_time,95 'post_date' => $topic->topic_start_time,96 'post_modified' => $topic->topic_time,97 'post_modified_gmt' => $topic->topic_time,98 'meta_input' => array(99 '_author_ip' => $author_ip,100 ),101 ) );102 remove_filter( 'wp_insert_post_data', array( $this, 'filter_wp_insert_post_data' ) );103 }104 $plugin->post_status = $status;105 63 106 64 $readme = $data['readme']; … … 129 87 $plugin->post_modified = $plugin->post_modified_gmt = current_time( 'mysql' ); 130 88 } 89 } 90 91 // Plugins should move from 'approved' to 'publish' on first parse 92 // `export_and_parse_plugin()` will throw an exception in the case where plugin files cannot be found, 93 // so by this time the plugin should be live. 94 if ( 'approved' === $plugin->post_status ) { 95 $plugin->post_status = 'publish'; 131 96 } 132 97
Note: See TracChangeset
for help on using the changeset viewer.