Ticket #7479: 7479.2.diff
File 7479.2.diff, 6.2 KB (added by , 16 years ago) |
---|
-
wp-admin/includes/plugin.php
61 61 * @since 1.5.0 62 62 * 63 63 * @param string $plugin_file Path to the plugin file 64 * @param bool $markup If the returned data should have HTML markup applied 65 * @param bool $translate If the returned data should be translated 64 66 * @return array See above for description. 65 67 */ 66 function get_plugin_data( $plugin_file ) {68 function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { 67 69 // We don't need to write to the file, so just open for reading. 68 70 $fp = fopen($plugin_file, 'r'); 69 71 … … 89 91 ${$field} = ''; 90 92 } 91 93 92 returnarray(93 'Name' => $name, ' PluginURI' => $uri, 'Description' => $description,94 $plugin_data = array( 95 'Name' => $name, 'Title' => $name, 'PluginURI' => $uri, 'Description' => $description, 94 96 'Author' => $author_name, 'AuthorURI' => $author_uri, 'Version' => $version, 95 97 'TextDomain' => $text_domain, 'DomainPath' => $domain_path 96 98 ); 99 if ( $markup || $translate ) 100 $plugin_data = _get_plugin_data_markup_translate($plugin_data, $markup, $translate); 101 return $plugin_data; 97 102 } 98 103 104 function _get_plugin_data_markup_translate($plugin_data, $markup = true, $translate = true) { 105 106 //Translate fields 107 if( $translate && ! empty($plugin_data['TextDomain']) ) { 108 if( ! empty( $plugin_data['DomainPath'] ) ) 109 load_plugin_textdomain($plugin_data['TextDomain'], dirname($plugin_file). $plugin_data['DomainPath']); 110 else 111 load_plugin_textdomain($plugin_data['TextDomain'], dirname($plugin_file)); 112 113 foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field ) 114 $plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']); 115 } 116 117 //Apply Markup 118 if ( $markup ) { 119 if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']) ) 120 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin homepage' ) . '">' . $plugin_data['Name'] . '</a>'; 121 else 122 $plugin_data['Title'] = $plugin_data['Name']; 123 124 if ( ! empty($plugin_data['AuthorURI']) ) 125 $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 126 127 $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); 128 if( ! empty($plugin_data['Author']) ) 129 $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>'; 130 } 131 132 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); 133 134 // Sanitize all displayed data 135 $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags); 136 $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags); 137 $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags); 138 $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags); 139 140 return $plugin_data; 141 } 142 99 143 /** 100 144 * Check the plugins directory and retrieve all plugin files with plugin data. 101 145 * … … 161 205 if ( !is_readable( "$plugin_root/$plugin_file" ) ) 162 206 continue; 163 207 164 $plugin_data = get_plugin_data( "$plugin_root/$plugin_file" );208 $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. 165 209 166 210 if ( empty ( $plugin_data['Name'] ) ) 167 211 continue; -
wp-admin/plugins.php
221 221 if( $recently_activated != get_option('recently_activated') ) //If array changed, update it. 222 222 update_option('recently_activated', $recently_activated); 223 223 224 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());225 226 224 foreach( (array)$all_plugins as $plugin_file => $plugin_data) { 227 225 228 //Translate fields 229 if( !empty($plugin_data['TextDomain']) ) { 230 if( !empty( $plugin_data['DomainPath'] ) ) 231 load_plugin_textdomain($plugin_data['TextDomain'], dirname($plugin_file). $plugin_data['DomainPath']); 232 else 233 load_plugin_textdomain($plugin_data['TextDomain'], dirname($plugin_file)); 226 //Translate, Apply Markup, Sanitize HTML 227 $plugin_data = _get_plugin_data_markup_translate($plugin_data, true, true); 234 228 235 foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field )236 $plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']);237 }238 239 //Apply Markup240 $plugin_data['Title'] = $plugin_data['Name'];241 if ( !empty($plugin_data['PluginURI']) && !empty($plugin_data['Name']) )242 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="'.__( 'Visit plugin homepage' ).'">' . $plugin_data['Name'] . '</a>';243 244 if ( ! empty($plugin_data['AuthorURI']) )245 $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="'.__( 'Visit author homepage' ).'">' . $plugin_data['Author'] . '</a>';246 247 $plugin_data['Description'] = wptexturize( $plugin_data['Description'] );248 249 // Sanitize all displayed data250 $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags);251 $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags);252 $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags);253 $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags);254 if( ! empty($plugin_data['Author']) )255 $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>';256 257 229 //Filter into individual sections 258 230 if ( is_plugin_active($plugin_file) ) { 259 231 $active_plugins[ $plugin_file ] = $plugin_data;