| 248 | | $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()), |
| 249 | | 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), |
| 250 | | 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), |
| 251 | | 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), |
| 252 | | 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), |
| 253 | | 'img' => array('src' => array(), 'class' => array(), 'alt' => array())); |
| 254 | | //Sanitize HTML |
| 255 | | foreach ( (array)$api->sections as $section_name => $content ) |
| 256 | | $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags); |
| 257 | | foreach ( array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key ) |
| 258 | | $api->$key = wp_kses($api->$key, $plugins_allowedtags); |
| | 249 | if ( is_wp_error($api) ) |
| | 250 | wp_die($api); |
| 260 | | $section = isset($_REQUEST['section']) ? stripslashes( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English. |
| 261 | | if ( empty($section) || ! isset($api->sections[ $section ]) ) |
| 262 | | $section = array_shift( $section_titles = array_keys((array)$api->sections) ); |
| | 252 | $plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()), |
| | 253 | 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), |
| | 254 | 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), |
| | 255 | 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), |
| | 256 | 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), |
| | 257 | 'img' => array('src' => array(), 'class' => array(), 'alt' => array())); |
| | 258 | //Sanitize HTML |
| | 259 | foreach ( (array)$api->sections as $section_name => $content ) |
| | 260 | $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags); |
| | 261 | foreach ( array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key ) |
| | 262 | $api->$key = wp_kses($api->$key, $plugins_allowedtags); |
| 272 | | $class = ( $section_name == $section ) ? ' class="current"' : ''; |
| 273 | | $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) ); |
| 274 | | $href = esc_url($href); |
| 275 | | $san_title = esc_attr(sanitize_title_with_dashes($title)); |
| 276 | | echo "\t<li><a name='$san_title' target='' href='$href'$class>$title</a></li>\n"; |
| 277 | | } |
| 278 | | echo "</ul>\n"; |
| 279 | | echo "</div>\n"; |
| 280 | | ?> |
| 281 | | <div class="alignright fyi"> |
| 282 | | <?php if ( ! empty($api->download_link) && ( current_user_can('install_plugins') || current_user_can('update_plugins') ) ) : ?> |
| 283 | | <p class="action-button"> |
| 284 | | <?php |
| 285 | | $status = install_plugin_install_status($api); |
| 286 | | switch ( $status['status'] ) { |
| 287 | | case 'install': |
| 288 | | if ( $status['url'] ) |
| 289 | | echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>'; |
| 290 | | break; |
| 291 | | case 'update_available': |
| 292 | | if ( $status['url'] ) |
| 293 | | echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') .'</a>'; |
| 294 | | break; |
| 295 | | case 'newer_installed': |
| 296 | | echo '<a>' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>'; |
| 297 | | break; |
| 298 | | case 'latest_installed': |
| 299 | | echo '<a>' . __('Latest Version Installed') . '</a>'; |
| 300 | | break; |
| 301 | | } |
| 302 | | ?> |
| 303 | | </p> |
| 304 | | <?php endif; ?> |
| 305 | | <h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI') ?></h2> |
| 306 | | <ul> |
| 307 | | <?php if ( ! empty($api->version) ) : ?> |
| 308 | | <li><strong><?php _e('Version:') ?></strong> <?php echo $api->version ?></li> |
| 309 | | <?php endif; if ( ! empty($api->author) ) : ?> |
| 310 | | <li><strong><?php _e('Author:') ?></strong> <?php echo links_add_target($api->author, '_blank') ?></li> |
| 311 | | <?php endif; if ( ! empty($api->last_updated) ) : ?> |
| 312 | | <li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php |
| 313 | | printf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li> |
| 314 | | <?php endif; if ( ! empty($api->requires) ) : ?> |
| 315 | | <li><strong><?php _e('Requires WordPress Version:') ?></strong> <?php printf(__('%s or higher'), $api->requires) ?></li> |
| 316 | | <?php endif; if ( ! empty($api->tested) ) : ?> |
| 317 | | <li><strong><?php _e('Compatible up to:') ?></strong> <?php echo $api->tested ?></li> |
| 318 | | <?php endif; if ( ! empty($api->downloaded) ) : ?> |
| 319 | | <li><strong><?php _e('Downloaded:') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded), number_format_i18n($api->downloaded)) ?></li> |
| 320 | | <?php endif; if ( ! empty($api->slug) && empty($api->external) ) : ?> |
| 321 | | <li><a target="_blank" href="http://wordpress.org/extend/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page »') ?></a></li> |
| 322 | | <?php endif; if ( ! empty($api->homepage) ) : ?> |
| 323 | | <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage »') ?></a></li> |
| 324 | | <?php endif; ?> |
| 325 | | </ul> |
| 326 | | <?php if ( ! empty($api->rating) ) : ?> |
| 327 | | <h2><?php _e('Average Rating') ?></h2> |
| 328 | | <div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?>"> |
| 329 | | <div class="star star-rating" style="width: <?php echo esc_attr($api->rating) ?>px"></div> |
| 330 | | <div class="star star5"><img src="<?php echo admin_url('images/star.png?v=20110615'); ?>" alt="<?php _e('5 stars') ?>" /></div> |
| 331 | | <div class="star star4"><img src="<?php echo admin_url('images/star.png?v=20110615'); ?>" alt="<?php _e('4 stars') ?>" /></div> |
| 332 | | <div class="star star3"><img src="<?php echo admin_url('images/star.png?v=20110615'); ?>" alt="<?php _e('3 stars') ?>" /></div> |
| 333 | | <div class="star star2"><img src="<?php echo admin_url('images/star.png?v=20110615'); ?>" alt="<?php _e('2 stars') ?>" /></div> |
| 334 | | <div class="star star1"><img src="<?php echo admin_url('images/star.png?v=20110615'); ?>" alt="<?php _e('1 star') ?>" /></div> |
| 335 | | </div> |
| 336 | | <small><?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></small> |
| 337 | | <?php endif; ?> |
| 338 | | </div> |
| 339 | | <div id="section-holder" class="wrap"> |
| 340 | | <?php |
| 341 | | if ( !empty($api->tested) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') ) |
| 342 | | echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>'; |
| | 270 | $contents .= "<div id='$tab-header'>\n"; |
| | 271 | $contents .= "<ul id='sidemenu'>\n"; |
| | 272 | foreach ( (array)$api->sections as $section_name => $content ) { |
| 355 | | $san_title = esc_attr(sanitize_title_with_dashes($title)); |
| | 289 | $contents .= '<p class="action-button">'; |
| | 290 | $status = install_plugin_install_status($api); |
| | 291 | switch ( $status['status'] ) { |
| | 292 | case 'install': |
| | 293 | if ( $status['url'] ) |
| | 294 | $contents .= '<a href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>'; |
| | 295 | break; |
| | 296 | case 'update_available': |
| | 297 | if ( $status['url'] ) |
| | 298 | $contents .= '<a href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') .'</a>'; |
| | 299 | break; |
| | 300 | case 'newer_installed': |
| | 301 | $contents .= '<a>' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>'; |
| | 302 | break; |
| | 303 | case 'latest_installed': |
| | 304 | $contents .= '<a>' . __('Latest Version Installed') . '</a>'; |
| | 305 | break; |
| | 306 | } |
| | 307 | $contents .= '</p>'; |
| | 308 | |
| | 309 | } |
| | 310 | |
| | 311 | $contents .= '<h2 class="mainheader">' . /* translators: For Your Information */ __('FYI') . '</h2>'; |
| | 312 | $contents .= '<ul>'; |
| | 313 | if ( ! empty($api->version) ) { |
| | 314 | $contents .= '<li><strong>' . __('Version:') . '</strong> ' . $api->version . '</li>'; |
| | 315 | } |
| | 316 | if ( ! empty($api->author) ) { |
| | 317 | $contents .= '<li><strong>' . __('Author:') . '</strong> ' . links_add_target($api->author, '_blank') . '</li>'; |
| | 318 | } |
| | 319 | if ( ! empty($api->last_updated) ) { |
| | 320 | $contents .= '<li><strong>' . __('Last Updated:') . '</strong> <span title="' . $api->last_updated . '">' . |
| | 321 | sprintf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) . '</span></li>'; |
| | 322 | } |
| | 323 | if ( ! empty($api->requires) ) { |
| | 324 | $contents .= '<li><strong>' . __('Requires WordPress Version:') . '</strong> ' . sprintf(__('%s or higher'), $api->requires) . '</li>'; |
| | 325 | } |
| | 326 | if ( ! empty($api->tested) ) { |
| | 327 | $contents .= '<li><strong>' . __('Compatible up to:') . '</strong> ' . $api->tested . '</li>'; |
| | 328 | } |
| | 329 | if ( ! empty($api->downloaded) ) { |
| | 330 | $contents .= '<li><strong>' . __('Downloaded:') . '</strong> ' . sprintf(_n('%s time', '%s times', $api->downloaded), number_format_i18n($api->downloaded)) . '</li>'; |
| | 331 | } |
| | 332 | if ( ! empty($api->slug) && empty($api->external) ) { |
| | 333 | $contents .= '<li><a target="_blank" href="http://wordpress.org/extend/plugins/' . $api->slug . '">' . __('WordPress.org Plugin Page »') . '</a></li>'; |
| | 334 | } |
| | 335 | if ( ! empty($api->homepage) ) { |
| | 336 | $contents .= '<li><a target="_blank" href="' . $api->homepage . '">' . __('Plugin Homepage »') . '</a></li>'; |
| | 337 | } |
| | 338 | $contents .= '</ul>'; |
| | 339 | |
| | 340 | if ( ! empty($api->rating) ) { |
| | 341 | $contents .= '<h2>' . __('Average Rating') . '</h2>'; |
| | 342 | $contents .= '<div class="star-holder" title="' . sprintf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)) . '">'; |
| 366 | | iframe_footer(); |
| 367 | | exit; |
| | 357 | if ( !empty($api->tested) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') ) |
| | 358 | $contents .= '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>'; |
| | 359 | |
| | 360 | else if ( !empty($api->requires) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<') ) |
| | 361 | $contents .= '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>'; |
| | 362 | |
| | 363 | foreach ( (array)$api->sections as $section_name => $content ) { |
| | 364 | $title = $section_name; |
| | 365 | $title[0] = strtoupper($title[0]); |
| | 366 | $title = str_replace('_', ' ', $title); |
| | 367 | |
| | 368 | $content = links_add_base_url($content, 'http://wordpress.org/extend/plugins/' . $api->slug . '/'); |
| | 369 | $content = links_add_target($content, '_blank'); |
| | 370 | |
| | 371 | $san_title = esc_attr(sanitize_title_with_dashes($title)); |
| | 372 | |
| | 373 | $display = ( $section_name == $section ) ? 'block' : 'none'; |
| | 374 | |
| | 375 | $contents .= "\t<div id='section-{$san_title}' class='section' style='display: {$display};'>\n"; |
| | 376 | $contents .= "\t\t<h2 class='long-header'>$title</h2>"; |
| | 377 | $contents .= $content; |
| | 378 | $contents .= "\t</div>\n"; |
| | 379 | } |
| | 380 | $contents .= "</div>\n"; |
| | 381 | |
| | 382 | if($framed) { |
| | 383 | iframe_header( __('Plugin Install') ); |
| | 384 | echo $contents; |
| | 385 | iframe_footer(); |
| | 386 | exit; |
| | 387 | } |
| | 388 | else { |
| | 389 | $data['contents'] = $contents; |
| | 390 | $data['title'] = $api->name; |
| | 391 | return $data; |
| | 392 | } |