Ticket #20266: 20266.diff
| File 20266.diff, 5.6 KB (added by nacin, 14 months ago) |
|---|
-
wp-admin/includes/plugin.php
65 65 * @since 1.5.0 66 66 * 67 67 * @param string $plugin_file Path to the plugin file 68 * @param bool $markup If the returned data should have HTML markup applied69 * @param bool $translate If the returned data should be translated68 * @param bool $markup Optional. If the returned data should have HTML markup applied. Defaults to true. 69 * @param bool $translate Optional. If the returned data should be translated. Defaults to true. 70 70 * @return array See above for description. 71 71 */ 72 72 function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { … … 88 88 $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' ); 89 89 90 90 // Site Wide Only is the old header for Network 91 if ( empty( $plugin_data['Network'] ) && ! empty( $plugin_data['_sitewide'] )) {91 if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) { 92 92 _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The <code>%1$s</code> plugin header is deprecated. Use <code>%2$s</code> instead.' ), 'Site Wide Only: true', 'Network: true' ) ); 93 93 $plugin_data['Network'] = $plugin_data['_sitewide']; 94 94 } 95 95 $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ); 96 96 unset( $plugin_data['_sitewide'] ); 97 97 98 // For backward compatibility by default Title is the same as Name.99 $plugin_data ['Title'] = $plugin_data['Name'];98 // Sanitize, maybe markup, maybe translate 99 $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); 100 100 101 if ( $markup || $translate )102 $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );103 else104 $plugin_data['AuthorName'] = $plugin_data['Author'];105 106 101 return $plugin_data; 107 102 } 108 103 109 function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) { 104 /** 105 * Sanitizes plugin data, optionally adds markup, optionally translates. 106 * 107 * @since 2.7.0 108 * @access private 109 * @see get_plugin_data() 110 */ 111 function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) { 110 112 111 // Translate fields113 // Translate fields 112 114 if ( $translate ) { 113 115 if ( $textdomain = $plugin_data['TextDomain'] ) { 114 if ( ! empty( $plugin_data['DomainPath'] ))116 if ( $plugin_data['DomainPath'] ) 115 117 load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] ); 116 118 else 117 119 load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) ); … … 124 126 } 125 127 } 126 128 127 $plugins_allowedtags = array( 128 'a' => array( 'href' => array(), 'title' => array() ), 129 'abbr' => array( 'title' => array() ), 130 'acronym' => array( 'title' => array() ), 131 'code' => array(), 132 'em' => array(), 133 'strong' => array(), 129 $allowed_tags = $allowed_tags_in_links = array( 130 'abbr' => array( 'title' => true ), 131 'acronym' => array( 'title' => true ), 132 'code' => true, 133 'em' => true, 134 'strong' => true, 134 135 ); 136 $allowed_tags['a'] = array( 'href' => true, 'title' => true ); 135 137 136 $plugin_data['AuthorName'] = $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $plugins_allowedtags );138 // Sanitized all displayed data. 137 139 138 //Apply Markup 140 // Author and Name are marked up inside <a> tags. Don't allow these. 141 $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags_in_links ); 142 $plugin_data['AuthorName'] = $plugin_data['Author']; 143 144 $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links ); 145 $plugin_data['Title'] = $plugin_data['Name']; 146 147 $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags ); 148 $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $allowed_tags ); 149 150 $plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] ); 151 $plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] ); 152 153 // Apply markup 139 154 if ( $markup ) { 140 if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']))155 if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) 141 156 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . esc_attr__( 'Visit plugin homepage' ) . '">' . $plugin_data['Name'] . '</a>'; 142 else143 $plugin_data['Title'] = $plugin_data['Name'];144 157 145 if ( ! empty($plugin_data['AuthorURI']) && ! empty($plugin_data['Author']))158 if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) 146 159 $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 147 160 148 161 $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); 149 if ( ! empty($plugin_data['Author']) ) 150 $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>'; 162 163 if ( $plugin_data['Author'] ) 164 $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s.'), $plugin_data['Author'] ) . '</cite>'; 151 165 } 152 166 153 // Sanitize all displayed data. Author and AuthorName sanitized above.154 $plugin_data['Title'] = wp_kses( $plugin_data['Title'], $plugins_allowedtags );155 $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $plugins_allowedtags );156 $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $plugins_allowedtags );157 $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $plugins_allowedtags );158 159 167 return $plugin_data; 160 168 } 161 169
