Ticket #7479: 7479.diff
File 7479.diff, 6.4 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 99 function get_plugins($plugin_folder = '') { 100 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 143 function get_plugins( $plugin_folder = '' ) { 144 101 145 if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') ) 102 146 $cache_plugins = array(); 103 147 104 148 if ( isset($cache_plugins[ $plugin_folder ]) ) 105 149 return $cache_plugins[ $plugin_folder ]; 106 150 107 151 $wp_plugins = array (); 108 152 $plugin_root = WP_PLUGIN_DIR; 109 153 if( !empty($plugin_folder) ) … … 141 185 if ( !is_readable( "$plugin_root/$plugin_file" ) ) 142 186 continue; 143 187 144 $plugin_data = get_plugin_data( "$plugin_root/$plugin_file" );188 $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. 145 189 146 190 if ( empty ( $plugin_data['Name'] ) ) 147 191 continue; -
wp-admin/plugins.php
212 212 if( $recently_activated != get_option('recently_activated') ) //If array changed, update it. 213 213 update_option('recently_activated', $recently_activated); 214 214 215 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());216 217 215 foreach( (array)$all_plugins as $plugin_file => $plugin_data) { 218 216 219 //Translate fields 220 if( !empty($plugin_data['TextDomain']) ) { 221 if( !empty( $plugin_data['DomainPath'] ) ) 222 load_plugin_textdomain($plugin_data['TextDomain'], dirname($plugin_file). $plugin_data['DomainPath']); 223 else 224 load_plugin_textdomain($plugin_data['TextDomain'], dirname($plugin_file)); 217 //Translate, Apply Markup, Sanitize HTML 218 $plugin_data = _get_plugin_data_markup_translate($plugin_data, true, true); 225 219 226 foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field )227 $plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']);228 }229 230 //Apply Markup231 $plugin_data['Title'] = $plugin_data['Name'];232 if ( !empty($plugin_data['PluginURI']) && !empty($plugin_data['Name']) )233 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="'.__( 'Visit plugin homepage' ).'">' . $plugin_data['Name'] . '</a>';234 235 if ( ! empty($plugin_data['AuthorURI']) )236 $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="'.__( 'Visit author homepage' ).'">' . $plugin_data['Author'] . '</a>';237 238 $plugin_data['Description'] = wptexturize( $plugin_data['Description'] );239 240 // Sanitize all displayed data241 $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags);242 $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags);243 $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags);244 $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags);245 if( ! empty($plugin_data['Author']) )246 $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>';247 248 220 //Filter into individual sections 249 221 if ( is_plugin_active($plugin_file) ) { 250 222 $active_plugins[ $plugin_file ] = $plugin_data;