Changeset 2621
- Timestamp:
- 02/25/2016 10:49:24 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 2 added
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
r2612 r2621 5 5 * All functionality related to the Administration interface. 6 6 * 7 * @package WordPressdotorg _Plugin_Directory7 * @package WordPressdotorg\Plugin_Directory\Admin 8 8 */ 9 class Admin_Customizations { 9 class Customizations { 10 10 11 /** 11 12 * Fetch the instance of the Plugin_Directory class. … … 13 14 public static function instance() { 14 15 static $instance = null; 15 return ! is_null( $instance ) ? $instance : $instance = new Admin_Customizations(); 16 17 return ! is_null( $instance ) ? $instance : $instance = new Customizations(); 16 18 } 17 19 20 /** 21 * 22 */ 18 23 private function __construct() { 19 24 add_action( 'add_meta_boxes', array( $this, 'register_admin_metaboxes' ) ); … … 31 36 ); 32 37 } 33 34 38 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.php
r2611 r2621 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Metabox; 3 3 4 use WordPressdotorg\Plugin_Directory\Tools; 4 5 … … 6 7 * The Plugin Committers admin metabox. 7 8 * 8 * @package WordPressdotorg _Plugin_Directory9 * @package WordPressdotorg\Plugin_Directory\Admin\Metabox 9 10 */ 10 11 class Committers { 12 13 /** 14 * 15 */ 11 16 static function display() { 12 $plugin_slug = get_post()->post_name;17 $plugin_slug = get_post()->post_name; 13 18 $existing_committers = Tools::get_plugin_committers( $plugin_slug ); 14 $existing_committers = array_map( function( $user ) { return new \WP_User( $user ); }, $existing_committers ); 19 $existing_committers = array_map( function ( $user ) { 20 return new \WP_User( $user ); 21 }, $existing_committers ); 15 22 16 23 $output = ''; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-autoloader.php
r2611 r2621 5 5 * An Autoloader which respects WordPress's filename standards. 6 6 * 7 * @package WordPressdotorg _Plugin_Directory7 * @package WordPressdotorg\Plugin_Directory\Autoloader 8 8 */ 9 9 class Autoloader { … … 27 27 $class = substr( $class, $this->prefix_length + 1 ); 28 28 $class = strtolower( $class ); 29 $file = '';29 $file = ''; 30 30 31 31 if ( false !== ( $last_ns_pos = strripos( $class, self::NS_SEPARATOR ) ) ) { … … 43 43 } 44 44 } 45 46 45 } 47 46 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r2611 r2621 5 5 * The main Plugin Directory class, it handles most of the bootstrap and basic operations of the plugin. 6 6 * 7 * @package WordPressdotorg _Plugin_Directory7 * @package WordPressdotorg\Plugin_Directory 8 8 */ 9 9 class Plugin_Directory { … … 14 14 public static function instance( $plugin_file = null ) { 15 15 static $instance = null; 16 16 17 return ! is_null( $instance ) ? $instance : $instance = new Plugin_Directory( $plugin_file ); 17 18 } 18 19 20 /** 21 * @param string $plugin_file 22 */ 19 23 private function __construct( $plugin_file ) { 20 24 add_action( 'init', array( $this, 'init' ) ); … … 25 29 add_filter( 'the_content', array( $this, 'filter_post_content_to_correct_page' ), 1 ); 26 30 27 // Load all Admin-specific items 28 add_action( 'admin_init', array( __NAMESPACE__ . '\\Admin\\ Admin_Customizations', 'instance' ) );31 // Load all Admin-specific items. 32 add_action( 'admin_init', array( __NAMESPACE__ . '\\Admin\\Customizations', 'instance' ) ); 29 33 30 34 register_activation_hook( $plugin_file, array( $this, 'activate' ) ); … … 95 99 // When this plugin is used in the context of a Rosetta site, handle it gracefully 96 100 if ( 'wordpress.org' != $_SERVER['HTTP_HOST'] && defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) { 97 $this->add_rosetta_network_filters(); 101 add_filter( 'option_home', array( $this, 'rosetta_network_localize_url' ) ); 102 add_filter( 'option_siteurl', array( $this, 'rosetta_network_localize_url' ) ); 98 103 } 99 104 } … … 109 114 110 115 /** 111 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.116 * @global \WP_Rewrite $wp_rewrite WordPress rewrite component. 112 117 */ 113 118 public function activate() { … … 151 156 152 157 /** 158 * Filter the URLs to use the current localized domain name, rather than WordPress.org. 159 * 153 160 * The Plugin Directory is available at multiple URLs (internationalised domains), this method allows 154 161 * for the one blog (a single blog_id) to be presented at multiple URLs yet have correct localised links. 155 */ 156 public function add_rosetta_network_filters() { 157 // Filter the URLs to use the current localised domain name, rather than WordPress.org. 158 foreach ( array( 'option_home', 'option_siteurl' ) as $filter ) { 159 add_filter( $filter, function( $url ) { 160 static $localized_url = null; 161 if ( is_null( $localized_url ) ) { 162 $localized_url = 'https://' . preg_replace( '![^a-z.-]+!', '', $_SERVER['HTTP_HOST'] ); 163 } 164 165 return preg_replace( '!^[https]+://wordpress\.org!i', $localized_url, $url ); 166 } ); 167 } 168 169 /* 170 // This method works in conjuction with a filter in sunrise.php, duplicated here for transparency: 171 172 // Make the Plugin Directory available at /plugins/ on all rosetta sites. 173 function wporg_plugins_on_rosetta_domains( $site, $domain, $path, $segments ) { 174 // All non-rosetta networks define DOMAIN_CURRENT_SITE in wp-config.php 175 if ( ! defined( 'DOMAIN_CURRENT_SITE' ) && 'wordpress.org' != $domain && '/plugins/' == substr( $path . '/', 0, 9 ) ) { 176 $site = get_blog_details( WPORG_PLUGIN_DIRECTORY_BLOGID ); 177 if ( $site ) { 178 $site = clone $site; 179 // 6 = The Rosetta network, this causes the site to be loaded as part of the Rosetta network 180 $site->site_id = 6; 181 return $site; 182 } 183 } 184 185 return $site; 186 } 187 add_filter( 'pre_get_site_by_path', 'wporg_plugins_on_rosetta_domains', 10, 4 ); 188 */ 162 * 163 * This method works in conjunction with a filter in sunrise.php, duplicated here for transparency: 164 * 165 * // Make the Plugin Directory available at /plugins/ on all rosetta sites. 166 * function wporg_plugins_on_rosetta_domains( $site, $domain, $path, $segments ) { 167 * // All non-rosetta networks define DOMAIN_CURRENT_SITE in wp-config.php 168 * if ( ! defined( 'DOMAIN_CURRENT_SITE' ) && 'wordpress.org' != $domain && '/plugins/' == substr( $path . '/', 0, 9 ) ) { 169 * $site = get_blog_details( WPORG_PLUGIN_DIRECTORY_BLOGID ); 170 * if ( $site ) { 171 * $site = clone $site; 172 * // 6 = The Rosetta network, this causes the site to be loaded as part of the Rosetta network 173 * $site->site_id = 6; 174 * return $site; 175 * } 176 * } 177 * 178 * return $site; 179 * } 180 * add_filter( 'pre_get_site_by_path', 'wporg_plugins_on_rosetta_domains', 10, 4 ); 181 * 182 * @param string $url The URL to be localized. 183 * @return string 184 */ 185 public function rosetta_network_localize_url( $url ) { 186 static $localized_url = null; 187 188 if ( is_null( $localized_url ) ) { 189 $localized_url = 'https://' . preg_replace( '![^a-z.-]+!', '', $_SERVER['HTTP_HOST'] ); 190 } 191 192 return preg_replace( '!^[https]+://wordpress\.org!i', $localized_url, $url ); 189 193 } 190 194 … … 192 196 * Filter the permalink for the Plugins to be /plugin-name/. 193 197 * 194 * @param string $link The generated permalink.195 * @param WP_Post $post The Plugin post object.198 * @param string $link The generated permalink. 199 * @param \WP_Post $post The Plugin post object. 196 200 * @return string 197 201 */ … … 208 212 * 209 213 * @param string $term The term to add or update. 210 * @return string| WP_Error The term to add or update or WP_Error on failure.214 * @return string|\WP_Error The term to add or update or WP_Error on failure. 211 215 */ 212 216 public function pre_insert_term_prevent( $term ) { 213 217 if ( ! is_super_admin() ) { 214 $term = new WP_Error( 'not-allowed', __( 'You are not allowed to add terms.', 'wporg-plugins' ) );218 $term = new \WP_Error( 'not-allowed', __( 'You are not allowed to add terms.', 'wporg-plugins' ) ); 215 219 } 216 220 … … 219 223 220 224 /** 221 * @param WP_Query $wp_query The WordPress Query object.225 * @param \WP_Query $wp_query The WordPress Query object. 222 226 */ 223 227 public function use_plugins_in_query( $wp_query ) { … … 299 303 */ 300 304 public function split_post_content_into_pages( $content ) { 301 $_pages = preg_split( "#<!--section=(.+?)-->#", $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );305 $_pages = preg_split( "#<!--section=(.+?)-->#", $content, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); 302 306 $content_pages = array( 303 307 'screenshots' => '[wporg-plugins-screenshots]', … … 318 322 319 323 /** 320 321 322 * @param $plugin_slug string|WP_Post The slug of the plugin to retrieve.323 * @return WP_Post|WP_Error324 324 * Retrieve the WP_Post object representing a given plugin. 325 * 326 * @param $plugin_slug string|\WP_Post The slug of the plugin to retrieve. 327 * @return \WP_Post|\WP_Error 328 */ 325 329 public function get_plugin_post( $plugin_slug ) { 326 330 if ( $plugin_slug instanceof \WP_Post ) { … … 332 336 'post_type' => 'plugin', 333 337 'name' => $plugin_slug, 334 'post_status' => 'any' 338 'post_status' => 'any', 335 339 ) ); 336 340 if ( ! $posts ) { … … 338 342 } 339 343 340 $plugin = reset( $posts ); 341 return $plugin; 342 } 343 344 /** 345 * Create a new post entry for a given plugin slug. 346 * 344 return reset( $posts ); 345 } 346 347 /** 348 * Create a new post entry for a given plugin slug. 349 * 347 350 * @param array $plugin_info { 348 351 * Array of initial plugin post data, all fields are optional. 349 352 * 350 353 * @type string $title The title of the plugin. 351 354 * @type string $slug The slug of the plugin. … … 354 357 * @type string $description The short description of the plugin. 355 358 * } 356 * @return WP_Post|WP_Error357 359 * @return \WP_Post|\WP_Error 360 */ 358 361 public function create_plugin_post( array $plugin_info ) { 359 362 $title = !empty( $plugin_info['title'] ) ? $plugin_info['title'] : ''; … … 377 380 } 378 381 379 $plugin = get_post( $id ); 380 return $plugin; 382 return get_post( $id ); 381 383 } 382 384 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-geopattern.php
r2611 r2621 7 7 * Generates Geopattern icons for Plugins. 8 8 * 9 * @package WordPressdotorg _Plugin_Directory9 * @package WordPressdotorg\Plugin_Directory 10 10 */ 11 11 class Plugin_Geopattern extends \RedeyeVentures\GeoPattern\GeoPattern { 12 12 13 var $slug; // Hashed to generate pattern 14 var $text; // Text to be overlaid 15 var $textcolor = 'black'; 13 /** 14 * Hashed to generate pattern. 15 * 16 * @var string 17 */ 18 public $slug; 16 19 17 function __construct($options=array()) { 20 /** 21 * Text to be overlaid. 22 * 23 * @var string 24 */ 25 public $text; 26 27 /** 28 * @var string 29 */ 30 public $textcolor = 'black'; 31 32 /** 33 * @param array $options 34 */ 35 function __construct( $options = array() ) { 18 36 parent::__construct( $options ); 19 37 20 if ( isset( $options['text'] ) ) 38 if ( isset( $options['text'] ) ) { 21 39 $this->text = $options['text']; 40 } 22 41 23 if ( isset( $options['textcolor'] ) ) 42 if ( isset( $options['textcolor'] ) ) { 24 43 $this->textcolor = $options['textcolor']; 44 } 25 45 26 46 // Replace the base SVG object with our own, so the dimensions are gettable. … … 28 48 } 29 49 50 /** 51 * @param $text 52 */ 30 53 function setText( $text ) { 31 54 $this->text = $text; 32 55 } 33 56 57 /** 58 * @param $color 59 */ 34 60 function setTextColor( $color ) { 35 61 $this->textcolor = $color; 36 62 } 37 63 64 /** 65 * 66 */ 38 67 function generateText() { 39 $size = min( $this->svg->getHeight(), $this->svg->getWidth() );68 $size = min( $this->svg->getHeight(), $this->svg->getWidth() ); 40 69 $text_height = floor( $size * 0.8 ) . 'px'; 41 70 … … 43 72 } 44 73 74 /** 75 * @param int $width 76 * @param int $height 77 * @return string 78 */ 45 79 public function toSVG( $width = 128, $height = 128 ) { 46 80 $this->svg = new Plugin_Geopattern_SVG(); 47 81 $this->generateBackground(); 48 82 49 // Work around a bug in 1.1.0: the hash-based pattern selection doesn't account for the size of the pattern array and can choose a null result. 50 $this->setGenerator( $this->patterns[$this->hexVal(20, 1) % count( $this->patterns )] ); 83 /* 84 * Work around a bug in 1.1.0: 85 * The hash-based pattern selection doesn't account for the size of the 86 * pattern array and can choose a null result. 87 */ 88 $this->setGenerator( $this->patterns[ $this->hexVal( 20, 1 ) % count( $this->patterns ) ] ); 51 89 52 90 $this->generatePattern(); … … 59 97 $inner = $this->svg; 60 98 61 // Outer SVG, containing the text and nested inner SVG. 62 // Needed because of aspect ratio problems with the background pattern. The outer is square, inner may be a different shape. 99 /* 100 * Outer SVG, containing the text and nested inner SVG. 101 * 102 * Needed because of aspect ratio problems with the background pattern. 103 * The outer is square, inner may be a different shape. 104 */ 63 105 $this->svg = new PluginSVG(); 64 106 $this->svg->setWidth( $width ); … … 69 111 70 112 return $this->svg->getString(); 71 72 }73 74 }75 76 // The base SVG class doesn't provide functions for getting dimensions, so..77 class Plugin_Geopattern_SVG extends \RedeyeVentures\GeoPattern\SVG {78 79 protected $viewbox;80 81 function getWidth() {82 return $this->width;83 }84 85 function getHeight() {86 return $this->height;87 }88 89 protected function getSvgHeader() {90 if ( $this->viewbox )91 return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{$this->width}\" height=\"{$this->height}\" viewbox=\"{$this->viewbox}\" preserveAspectRatio=\"none\">";92 else93 return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{$this->width}\" height=\"{$this->height}\">";94 }95 96 public function addText( $text, $x, $y, $text_anchor, $style, $args=array() ) {97 $element = new Plugin_Geopattern_SVGText($text, $x, $y, $text_anchor, $style, $args);98 $this->svgString .= $element;99 return $this;100 }101 102 public function addNested( $svg ) {103 if ( method_exists( $svg, 'getString' ) )104 $this->svgString .= $svg->getString();105 }106 107 public function setViewBox( $x, $y, $w, $h ) {108 $this->viewbox = esc_attr( "$x $y $w $h" );109 }110 111 }112 113 // Nor does it support text.114 class Plugin_Geopattern_SVGText extends \RedeyeVentures\GeoPattern\SVGElements\Base {115 protected $tag = 'text';116 protected $text;117 118 function __construct($text, $x, $y, $text_anchor, $style, $args=array()) {119 $this->elements = array(120 'x' => $x,121 'y' => $y,122 'text-anchor' => $text_anchor,123 'style' => $style,124 );125 $this->text = esc_html( $text );126 parent::__construct($args);127 }128 129 public function getString() {130 return "<{$this->tag}{$this->elementsToString()}{$this->argsToString()}>{$this->text}</{$this->tag}>";131 113 } 132 114 } 133 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r2611 r2621 5 5 * Various helpers to retrieve data not stored within WordPress. 6 6 * 7 * @package WordPressdotorg _Plugin_Directory7 * @package WordPressdotorg\Plugin_Directory 8 8 */ 9 9 class Template { … … 53 53 */ 54 54 static function get_plugin_sections() { 55 $plugin 56 $plugin_slug 55 $plugin = get_post(); 56 $plugin_slug = $plugin->post_name; 57 57 58 58 $default_sections = array( … … 71 71 $raw_sections = array_unique( array_merge( $raw_sections, $default_sections ) ); 72 72 73 $sections = array();74 $title 75 $permalink = get_permalink();73 $sections = array(); 74 $title = $url = ''; 75 $permalink = get_permalink(); 76 76 77 77 foreach ( $raw_sections as $section_slug ) { … … 145 145 * Retrieve the Plugin Icon details for a plugin. 146 146 * 147 * @param WP_Post|string $plugin An instance of a Plugin post, or the plugin slug.147 * @param \WP_Post|string $plugin An instance of a Plugin post, or the plugin slug. 148 148 * @return mixed 149 149 */ … … 163 163 $icon_2x = self::get_asset_url( $plugin_slug, $info ); 164 164 break; 165 165 166 case '128x128': 166 167 $icon = self::get_asset_url( $plugin_slug, $info ); 167 168 break; 169 168 170 case false && 'icon.svg' == $file: 169 $icon = self::get_asset_url( $plugin_slug, $info );171 $icon = self::get_asset_url( $plugin_slug, $info ); 170 172 $vector = true; 171 173 break; … … 191 193 switch ( $output ) { 192 194 case 'html': 193 $id = "plugin-icon-{$plugin_slug}";195 $id = "plugin-icon-{$plugin_slug}"; 194 196 $html = "<style type='text/css'>"; 195 197 $html .= "#{$id} { width:128px; height:128px; background-image: url('{$icon}'); background-size:128px 128px; }"; … … 202 204 return $html; 203 205 break; 206 204 207 case 'raw': 205 208 default: … … 211 214 * Retrieve the Plugin Icon details for a plugin. 212 215 * 213 * @param WP_Post|string $plugin An instance of a Plugin post, or the plugin slug.216 * @param \WP_Post|string $plugin An instance of a Plugin post, or the plugin slug. 214 217 * @return mixed 215 218 */ … … 229 232 $banner_2x = self::get_asset_url( $plugin_slug, $info ); 230 233 break; 234 231 235 case '772x250': 232 236 $banner = self::get_asset_url( $plugin_slug, $info ); … … 246 250 } 247 251 252 /** 253 * @param $plugin 254 * @param $asset 255 * @return string 256 */ 248 257 static function get_asset_url( $plugin, $asset ) { 249 258 if ( ! empty( $asset['location'] ) && 'plugin' == $asset['location'] ) { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php
r2611 r2621 5 5 * Various functions used by other processes, will make sense to move to specific classes. 6 6 * 7 * @package WordPressdotorg _Plugin_Directory7 * @package WordPressdotorg\Plugin_Directory 8 8 */ 9 9 class Tools { … … 54 54 55 55 $tonesque = new \Tonesque( $file_location ); 56 56 57 return $tonesque->color(); 57 58 } … … 72 73 * Grant a user RW access to a plugin. 73 74 * 74 * @param string $plugin_slug The plugin slug. 75 * @param string|WP_User $user The user to grant access to. 75 * @param string $plugin_slug The plugin slug. 76 * @param string|\WP_User $user The user to grant access to. 77 * @return bool 76 78 */ 77 79 public static function grant_plugin_committer( $plugin_slug, $user ) { 78 80 global $wpdb; 81 79 82 if ( ! $user instanceof \WP_User ) { 80 83 $user = new \WP_User( $user ); … … 91 94 } 92 95 93 return (bool) $wpdb->insert(96 return (bool) $wpdb->insert( 94 97 PLUGINS_TABLE_PREFIX . 'svn_access', 95 98 array( … … 104 107 * Revoke a users RW access to a plugin. 105 108 * 106 * @param string $plugin_slug The plugin slug. 107 * @param string|WP_User $user The user to revoke access of. 109 * @param string $plugin_slug The plugin slug. 110 * @param string|\WP_User $user The user to revoke access of. 111 * @return bool 108 112 */ 109 113 public static function revoke_plugin_committer( $plugin_slug, $user ) { 110 114 global $wpdb; 115 111 116 if ( ! $user instanceof \WP_User ) { 112 117 $user = new \WP_User( $user ); … … 120 125 PLUGINS_TABLE_PREFIX . 'svn_access', 121 126 array( 122 'path' 123 'user' => $user->user_login127 'path' => "/{$plugin_slug}", 128 'user' => $user->user_login, 124 129 ) 125 130 ); 126 131 } 127 128 129 132 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/plugin-directory.php
r2611 r2621 1 1 <?php 2 namespace WordPressdotorg\Plugin_Directory;3 2 /** 4 3 * Plugin Name: Plugin Directory … … 15 14 */ 16 15 16 namespace WordPressdotorg\Plugin_Directory; 17 17 18 // Register an Autoloader for all files 18 19 include __DIR__ . '/class-autoloader.php'; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme-parser/ReadmeParser.php
r2563 r2621 343 343 $text = str_replace( ''', "'", $text ); 344 344 345 345 if ( '<pre><code>' == $matches[1] ) { 346 346 $text = "\n$text\n"; 347 347 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme-parser/compat.php
r2501 r2621 40 40 } 41 41 42 $result = parent::parse_readme_contents( $contents );42 $result = parent::parse_readme_contents( $contents ); 43 43 $result->sections = array_map( array( 'WPorg_Readme', 'filter_text' ), $result->sections ); 44 44 … … 73 73 * @access protected 74 74 * 75 * @param string $desc 75 * @param string $description 76 76 * @return string 77 77 */ 78 protected static function trim_short_desc( &$desc ) {79 $desc = self::sanitize_text( $desc);80 parent::trim_short_desc( $desc );78 protected static function trim_short_desc( &$description ) { 79 $description = self::sanitize_text( $description ); 80 parent::trim_short_desc( $description ); 81 81 82 return $desc ;82 return $description; 83 83 } 84 84 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php
r2611 r2621 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 4 use WordPressdotorg\Plugin_Directory\Template; 4 5 … … 6 7 * The [wporg-plugins-screenshots] shortcode handler to display a plugins screenshots. 7 8 * 8 * @package WordPressdotorg _Plugin_Directory9 * @package WordPressdotorg\Plugin_Directory\Shortcodes 9 10 */ 10 11 class Screenshots { 12 13 /** 14 * @return string 15 */ 11 16 static function display() { 12 17 $plugin = get_post(); 18 $output = ''; 13 19 14 // All indexed from 1 20 // All indexed from 1. 15 21 $screenshot_descriptions = get_post_meta( $plugin->ID, 'screenshots', true ); 16 $assets_screenshots = get_post_meta( $plugin->ID, 'assets_screenshots', true );22 $assets_screenshots = get_post_meta( $plugin->ID, 'assets_screenshots', true ); 17 23 18 $output = '';19 24 foreach ( $screenshot_descriptions as $index => $description ) { 20 // Find the image that corresponds with the text. 21 // The image numbers are stored within the 'resolution' key. 22 $found = false; 25 26 /* 27 * Find the image that corresponds with the text. 28 * The image numbers are stored within the 'resolution' key. 29 */ 23 30 foreach ( $assets_screenshots as $image ) { 24 31 if ( $index == $image['resolution'] ) { 25 $found = true; 32 $output .= sprintf( 33 '<li> 34 <a href="%1$s" rel="nofollow"> 35 <img class="screenshot" src="%1$s"> 36 </a> 37 <p>%2$s</p> 38 </li>', 39 Template::get_asset_url( $plugin->post_name, $image ), 40 $description 41 ); 26 42 break; 27 43 } 28 44 } 29 if ( ! $found ) {30 continue;31 }32 33 $url = Template::get_asset_url( $plugin->post_name, $image );34 35 $output .= sprintf(36 '<li>37 <a href="%1$s" rel="nofollow">38 <img class="screenshot" src="%1$s">39 </a>40 <p>%2$s</p>41 </li>',42 $url,43 $description44 );45 45 } 46 46 47 47 return '<ol class="screenshots">' . $output . '</ol>'; 48 49 48 } 50 49 }
Note: See TracChangeset
for help on using the changeset viewer.