Changeset 20229
- Timestamp:
- 03/20/2012 11:04:59 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/plugin.php
r19965 r20229 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 */ … … 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']; … … 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']; 100 101 if ( $markup || $translate ) 98 if ( $markup || $translate ) { 102 99 $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); 103 else 100 } else { 101 $plugin_data['Title'] = $plugin_data['Name']; 104 102 $plugin_data['AuthorName'] = $plugin_data['Author']; 103 } 105 104 106 105 return $plugin_data; 107 106 } 108 107 109 function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) { 110 111 //Translate fields 108 /** 109 * Sanitizes plugin data, optionally adds markup, optionally translates. 110 * 111 * @since 2.7.0 112 * @access private 113 * @see get_plugin_data() 114 */ 115 function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) { 116 117 // Translate fields 112 118 if ( $translate ) { 113 119 if ( $textdomain = $plugin_data['TextDomain'] ) { 114 if ( ! empty( $plugin_data['DomainPath'] ))120 if ( $plugin_data['DomainPath'] ) 115 121 load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] ); 116 122 else … … 125 131 } 126 132 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(),133 // Sanitize fields 134 $allowed_tags = $allowed_tags_in_links = array( 135 'abbr' => array( 'title' => true ), 136 'acronym' => array( 'title' => true ), 137 'code' => true, 138 'em' => true, 139 'strong' => true, 134 140 ); 135 136 $plugin_data['AuthorName'] = $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $plugins_allowedtags ); 137 138 //Apply Markup 141 $allowed_tags['a'] = array( 'href' => true, 'title' => true ); 142 143 // Name is marked up inside <a> tags. Don't allow these. 144 // Author is too, but some plugins have used <a> here (omitting Author URI). 145 $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links ); 146 $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags ); 147 148 $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags ); 149 $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $allowed_tags ); 150 151 $plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] ); 152 $plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] ); 153 154 $plugin_data['Title'] = $plugin_data['Name']; 155 $plugin_data['AuthorName'] = $plugin_data['Author']; 156 157 // Apply markup 139 158 if ( $markup ) { 140 if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']))159 if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) 141 160 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . esc_attr__( 'Visit plugin homepage' ) . '">' . $plugin_data['Name'] . '</a>'; 142 else 143 $plugin_data['Title'] = $plugin_data['Name']; 144 145 if ( ! empty($plugin_data['AuthorURI']) && ! empty($plugin_data['Author']) ) 161 162 if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) 146 163 $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 147 164 148 165 $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>'; 151 } 152 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 ); 166 167 if ( $plugin_data['Author'] ) 168 $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s.'), $plugin_data['Author'] ) . '</cite>'; 169 } 158 170 159 171 return $plugin_data;
Note: See TracChangeset
for help on using the changeset viewer.