Changeset 7072
- Timestamp:
- 04/10/2018 02:42:42 AM (7 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/rebuild-update_source-table.php
r7071 r7072 40 40 41 41 $slugs = $wpdb->get_col( $sql ); 42 if ( ! $slugs ) { 43 fwrite( STDERR, "Error! The plugin(s) could not be located.\n" ); 44 die(); 45 } 42 46 43 47 foreach ( $slugs as $i => $slug ) { 48 echo ++$i . '/' . count( $slugs ) . "\t" . $slug . "\n"; 44 49 45 $post = Plugin_Directory::get_plugin_post( $slug ); 46 if ( ! $post ) { 47 continue; 48 } 49 50 echo $i . '/' . count( $slugs ) . "\t" . $post->post_name . "\n"; 51 52 update_post_meta( 53 $post->ID, 54 'rating', 55 \WPORG_Ratings::get_avg_rating( 'plugin', $post->post_name ) 56 ); 57 58 update_post_meta( 59 $post->ID, 60 'ratings', 61 \WPORG_Ratings::get_rating_counts( 'plugin', $post->post_name ) 62 ); 50 Jobs\API_Update_Updater::update_single_plugin( $slug ); 63 51 64 52 clear_memory_caches(); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r7048 r7072 390 390 if ( ! $icon || 'publish' !== $plugin->post_status ) { 391 391 $generated = true; 392 $icon = self::get_geopattern_icon_url( $plugin );392 $icon = $svg = self::get_geopattern_icon_url( $plugin ); 393 393 } 394 394 … … 441 441 * 442 442 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 443 * @param string $output Optional. Output type. 'html' or 'raw'. Default: 'raw'.443 * @param string $output Optional. Output type. 'html', 'raw', or 'raw_with_rtl'. Default: 'raw'. 444 444 * @return mixed 445 445 */ … … 473 473 } 474 474 475 if ( is_rtl() ) {475 if ( is_rtl() || 'raw_with_rtl' == $output ) { 476 476 foreach ( $rtl_banners as $info ) { 477 477 switch ( $info['resolution'] ) { 478 478 case '1544x500': 479 $banner_2x = self::get_asset_url( $plugin, $info ); 479 $field = 'raw_with_rtl' == $output ? 'banner_2x_rtl' : 'banner_2x'; 480 $$field = self::get_asset_url( $plugin, $info ); 480 481 break; 481 482 482 483 case '772x250': 483 $banner = self::get_asset_url( $plugin, $info ); 484 $field = 'raw_with_rtl' == $output ? 'banner_rtl' : 'banner'; 485 $$field = self::get_asset_url( $plugin, $info ); 484 486 break; 485 487 } … … 506 508 507 509 case 'raw': 510 case 'raw_with_rtl': 508 511 default: 509 return compact( 'banner', 'banner_2x' );512 return compact( 'banner', 'banner_2x', 'banner_rtl', 'banner_2x_rtl' ); 510 513 } 511 514 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-api-update-updater.php
r6287 r7072 3 3 4 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 5 use WordPressdotorg\Plugin_Directory\Template; 5 6 6 7 /** … … 62 63 } 63 64 64 $data 65 $data = array( 65 66 'plugin_id' => $post->ID, 66 67 'plugin_slug' => $post->post_name, … … 75 76 'requires_php' => get_post_meta( $post->ID, 'requires_php', true ), 76 77 'upgrade_notice' => '', 78 'assets' => serialize( self::get_plugin_assets( $post ) ), 77 79 'last_updated' => $post->post_modified, 78 80 ); … … 112 114 } 113 115 116 static function get_plugin_assets( $post ) { 117 $icons = $banners = $banners_rtl = array(); 118 119 $raw_icons = Template::get_plugin_icon( $post, 'raw' ); 120 $raw_banners = Template::get_plugin_banner( $post, 'raw_with_rtl' ); 121 122 // Banners 123 if ( !empty( $raw_banners['banner_2x'] ) ) { 124 $banners['2x'] = $raw_banners['banner_2x']; 125 } 126 if ( !empty( $raw_banners['banner'] ) ) { 127 $banners['1x'] = $raw_banners['banner']; 128 } 129 if ( $banners ) { 130 $banners['default'] = $banners['2x'] ?? $banners['1x']; 131 } 132 133 // RTL Banners (get_plugin_banner 'raw_with_rtl' returns these) 134 if ( !empty( $raw_banners['banner_2x_rtl'] ) ) { 135 $banners_rtl['2x'] = $raw_banners['banner_2x_rtl']; 136 } 137 if ( !empty( $raw_banners['banner_rtl'] ) ) { 138 $banners_rtl['1x'] = $raw_banners['banner_rtl']; 139 } 140 if ( $banners_rtl ) { 141 $banners_rtl['default'] = $banners_rtl['2x'] ?? $banners_rtl['1x']; 142 } 143 144 // Icons. 145 if ( !empty( $raw_icons['icon_2x'] ) ) { 146 $icons['2x'] = $raw_icons['icon_2x']; 147 } 148 if ( !empty( $raw_icons['icon'] ) ) { 149 $icons['1x'] = $raw_icons['icon']; 150 } 151 if ( !empty( $raw_icons['svg'] ) ) { 152 $icons['svg'] = $raw_icons['svg']; 153 154 // We don't need to set the 1x field when it's the SVG. 155 if ( isset( $icons['1x'] ) && $icons['1x'] == $icons['svg'] ) { 156 unset( $icons['1x'] ); 157 } 158 } 159 if ( $icons ) { 160 $icons['default'] = $icons['svg'] ?? ( $icons['2x'] ?? $icons['1x'] ); 161 } 162 163 return (object) compact( 'icons', 'banners', 'banners_rtl' ); 164 } 165 114 166 } 115 167 … … 128 180 `requires_php` varchar(128) NOT NULL DEFAULT '', 129 181 `upgrade_notice` text, 182 `assets` text NOT NULL DEFAULT '', 130 183 `last_updated` datetime NOT NULL, 131 184 PRIMARY KEY (`plugin_id`),
Note: See TracChangeset
for help on using the changeset viewer.