Changeset 9272
- Timestamp:
- 10/22/2008 12:08:22 AM (16 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/plugin.php
r9271 r9272 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'); … … 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; 102 } 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; 97 141 } 98 142 … … 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'] ) ) -
trunk/wp-admin/plugins.php
r9233 r9272 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)); 234 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 Markup 240 $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 data 250 $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>'; 226 //Translate, Apply Markup, Sanitize HTML 227 $plugin_data = _get_plugin_data_markup_translate($plugin_data, true, true); 256 228 257 229 //Filter into individual sections
Note: See TracChangeset
for help on using the changeset viewer.