Changeset 7072 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-api-update-updater.php
- Timestamp:
- 04/10/2018 02:42:42 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.