install_plugin_information

Definition:
function install_plugin_information() {}

Display plugin information in dialog box form.

Source code

function install_plugin_information() {

	global $tab;



	$api = plugins_api('plugin_information', array('slug' => stripslashes( $_REQUEST['plugin'] ) ));



	if ( is_wp_error($api) )

		wp_die($api);



	$plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),

								'abbr' => array('title' => array()), 'acronym' => array('title' => array()),

								'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),

								'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),

								'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),

								'img' => array('src' => array(), 'class' => array(), 'alt' => array()));

	//Sanitize HTML

	foreach ( (array)$api->sections as $section_name => $content )

		$api->sections[$section_name] = wp_kses($content, $plugins_allowedtags);

	foreach ( array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key )

		$api->$key = wp_kses($api->$key, $plugins_allowedtags);



	$section = isset($_REQUEST['section']) ? stripslashes( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English.

	if ( empty($section) || ! isset($api->sections[ $section ]) )

		$section = array_shift( $section_titles = array_keys((array)$api->sections) );



	iframe_header( __('Plugin Install') );

	echo "<div id='$tab-header'>\n";

	echo "<ul id='sidemenu'>\n";

	foreach ( (array)$api->sections as $section_name => $content ) {



		$title = $section_name;

		$title = ucwords(str_replace('_', ' ', $title));



		$class = ( $section_name == $section ) ? ' class="current"' : '';

		$href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );

		$href = esc_url($href);

		$san_title = esc_attr(sanitize_title_with_dashes($title));

		echo "\t<li><a name='$san_title' target='' href='$href'$class>$title</a></li>\n";

	}

	echo "</ul>\n";

	echo "</div>\n";

	?>

	<div class="alignright fyi">

		<?php if ( ! empty($api->download_link) && ( current_user_can('install_plugins') || current_user_can('update_plugins') ) ) : ?>

		<p class="action-button">

		<?php

		$status = install_plugin_install_status($api);

		switch ( $status['status'] ) {

			case 'install':

				if ( $status['url'] )

					echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>';

				break;

			case 'update_available':

				if ( $status['url'] )

					echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') .'</a>';

				break;

			case 'newer_installed':

				echo '<a>' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>';

				break;

			case 'latest_installed':

				echo '<a>' . __('Latest Version Installed') . '</a>';

				break;

		}

		?>

		</p>

		<?php endif; ?>

		<h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI') ?></h2>

		<ul>

<?php if ( ! empty($api->version) ) : ?>

			<li><strong><?php _e('Version:') ?></strong> <?php echo $api->version ?></li>

<?php endif; if ( ! empty($api->author) ) : ?>

			<li><strong><?php _e('Author:') ?></strong> <?php echo links_add_target($api->author, '_blank') ?></li>

<?php endif; if ( ! empty($api->last_updated) ) : ?>

			<li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php

							printf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>

<?php endif; if ( ! empty($api->requires) ) : ?>

			<li><strong><?php _e('Requires WordPress Version:') ?></strong> <?php printf(__('%s or higher'), $api->requires) ?></li>

<?php endif; if ( ! empty($api->tested) ) : ?>

			<li><strong><?php _e('Compatible up to:') ?></strong> <?php echo $api->tested ?></li>

<?php endif; if ( ! empty($api->downloaded) ) : ?>

			<li><strong><?php _e('Downloaded:') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded), number_format_i18n($api->downloaded)) ?></li>

<?php endif; if ( ! empty($api->slug) && empty($api->external) ) : ?>

			<li><a target="_blank" href="http://wordpress.org/extend/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page »') ?></a></li>

<?php endif; if ( ! empty($api->homepage) ) : ?>

			<li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage  »') ?></a></li>

<?php endif; ?>

		</ul>

		<?php if ( ! empty($api->rating) ) : ?>

		<h2><?php _e('Average Rating') ?></h2>

		<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)); ?>">

			<div class="star star-rating" style="width: <?php echo esc_attr($api->rating) ?>px"></div>

			<div class="star star5"><img src="<?php echo admin_url('images/star.png?v=20110615'); ?>" alt="<?php _e('5 stars') ?>" /></div>

			<div class="star star4"><img src="<?php echo admin_url('images/star.png?v=20110615'); ?>" alt="<?php _e('4 stars') ?>" /></div>

			<div class="star star3"><img src="<?php echo admin_url('images/star.png?v=20110615'); ?>" alt="<?php _e('3 stars') ?>" /></div>

			<div class="star star2"><img src="<?php echo admin_url('images/star.png?v=20110615'); ?>" alt="<?php _e('2 stars') ?>" /></div>

			<div class="star star1"><img src="<?php echo admin_url('images/star.png?v=20110615'); ?>" alt="<?php _e('1 star') ?>" /></div>

		</div>

		<small><?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></small>

		<?php endif; ?>

	</div>

	<div id="section-holder" class="wrap">

	<?php

		if ( !empty($api->tested) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') )

			echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';



		else if ( !empty($api->requires) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<') )

			echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>';



		foreach ( (array)$api->sections as $section_name => $content ) {

			$title = $section_name;

			$title[0] = strtoupper($title[0]);

			$title = str_replace('_', ' ', $title);



			$content = links_add_base_url($content, 'http://wordpress.org/extend/plugins/' . $api->slug . '/');

			$content = links_add_target($content, '_blank');



			$san_title = esc_attr(sanitize_title_with_dashes($title));



			$display = ( $section_name == $section ) ? 'block' : 'none';



			echo "\t<div id='section-{$san_title}' class='section' style='display: {$display};'>\n";

2039

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: