protected static function display_as_grid($plugin, $style) { $name = strip_tags($plugin->name); $action_links = array(); $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true)) . '" class="thickbox button info" title="' . esc_attr(sprintf(__('More information about %s', 'wp-e-commerce'), $name)) . '">' . __('Details', 'wp-e-commerce') . '</a>'; $purchase_link = $plugin->price; if (current_user_can('install_plugins') || current_user_can('update_plugins')) { $status = Sputnik_Admin::install_status($plugin); switch ($status['status']) { case 'purchase': if ($status['url']) { $purchase_link = '<a id="' . $plugin->slug . '" class="button-primary buy status" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Buy %s', 'wp-e-commerce'), $name)) . '">' . __('Buy Now', 'wp-e-commerce') . '</a>'; } break; case 'install': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']); $purchase_link = '<a class="button install status" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Install %s', 'wp-e-commerce'), $name)) . '">' . __('Install', 'wp-e-commerce') . '</a>'; } else { $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wp-e-commerce') . '">' . __('Install', 'wp-e-commerce') . '</span>'; } break; case 'update_available': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']); $purchase_link = '<a class="button install" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Update to version %s', 'wp-e-commerce'), $status['version'])) . '">' . __('Update', 'wp-e-commerce') . '</a>'; } else { $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wp-e-commerce') . '">' . __('Update', 'wp-e-commerce') . '</span>'; } break; case 'latest_installed': case 'newer_installed': $purchase_link = '<span class="status" title="' . esc_attr__('This plugin is already installed and is up to date', 'wp-e-commerce') . ' ">' . __('Installed', 'wp-e-commerce') . '</span>'; break; } } $action_links = apply_filters('sputnik_install_grid_action_links', $action_links, $plugin); $thumb = ''; if (!empty($plugin->thumb)) { $thumb = $plugin->thumb; } $thumb = apply_filters('wpsc_marketplace_plugin_thumbnail_img_src', $thumb, $plugin); ?> <div> <div class="sputnik-plugin<?php if (!empty($plugin->thumb)) { echo ' has-thumb'; } ?> "> <div class="sputnik-card"> <h4><?php echo $name; ?> <span class="price"><?php echo $plugin->price; ?> </span></h4> <?php if (!empty($thumb)) { ?> <div class="sputnik-plugin-thumb"> <img src="<?php echo esc_url($thumb); ?> " alt="<?php echo esc_attr($name); ?> Thumbnail"> </div> <?php } ?> <div class="sputnik-plugin-details"> <p><?php echo $plugin->description; ?> </p> <?php if (isset($plugin->rating) && isset($plugin->rating->count)) { ?> <div class="footer" style="display:none"> <div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'wp-e-commerce'), number_format_i18n($plugin->rating->count)); ?> "> <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average); ?> px"></div> <?php $color = get_user_option('admin_color'); if (empty($color) || 'fresh' == $color) { $star_url = admin_url('images/stars.png?v=20110615'); } else { $star_url = admin_url('images/stars.png?v=20110615'); } // 'Classic' Blue star ?> <div class="star star5"><img src="<?php echo $star_url; ?> " alt="" /></div> <div class="star star4"><img src="<?php echo $star_url; ?> " alt="" /></div> <div class="star star3"><img src="<?php echo $star_url; ?> " alt="" /></div> <div class="star star2"><img src="<?php echo $star_url; ?> " alt="" /></div> <div class="star star1"><img src="<?php echo $star_url; ?> " alt="" /></div> </div> </div> <?php } ?> </div> </div> <div class="sputnik-plugin-actions"> <?php if (!empty($action_links)) { echo implode(' ', $action_links); } ?> <?php echo $purchase_link; ?> </div> </div> </div> <?php }
public function display() { global $tab; require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $api = $this->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())); $plugins_section_titles = array('description' => _x('Description', 'Plugin installer section title', 'sputnik'), 'installation' => _x('Installation', 'Plugin installer section title', 'sputnik'), 'faq' => _x('FAQ', 'Plugin installer section title', 'sputnik'), 'screenshots' => _x('Screenshots', 'Plugin installer section title', 'sputnik'), 'changelog' => _x('Changelog', 'Plugin installer section title', 'sputnik'), 'other_notes' => _x('Other Notes', 'Plugin installer section title', 'sputnik')); //Sanitize HTML $api->sections = (array) $api->sections; $api->author = links_add_target($api->author, '_blank'); foreach ($api->sections as $section_name => $content) { $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags); } $api->screenshots = (array) $api->screenshots; foreach ($api->screenshots as &$data) { if (!isset($data->caption) || !isset($data->location)) { continue; } $data->caption = wp_kses($data->caption, $plugins_allowedtags); $data->location = esc_url($data->location, array('http', 'https')); } unset($data); foreach (array('version', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key) { if (isset($api->{$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 !== 'screenshots' || empty($api->screenshots))) { $section = array_shift($section_titles = array_keys((array) $api->sections)); } ?> <div class="alignleft fyi"> <h1><?php echo $api->name; ?> </h1> <?php if (!empty($api->download_link) && (current_user_can('install_plugins') || current_user_can('update_plugins'))) { ?> <p class="action-button"> <?php $status = Sputnik_Admin::install_status($api); switch ($status['status']) { case 'purchase': default: if ($status['url']) { echo '<a href="' . $status['url'] . '" target="_parent" class="button-primary buy">' . sprintf(__('<span>$%.2f</span> Buy & Install', 'sputnik'), $api->price) . '</a>'; } break; case 'install': if ($status['url']) { echo '<a href="' . $status['url'] . '" class="button-primary install" title="' . __('You have already purchased, install now', 'sputnik') . '">' . __('Install Now', 'sputnik') . '</a>'; } break; case 'update_available': if ($status['url']) { echo '<a href="' . $status['url'] . '" class="button-primary install">' . __('Install Update Now', 'sputnik') . '</a>'; } break; case 'newer_installed': echo '<a>' . sprintf(__('Newer Version (%s) Installed', 'sputnik'), $status['version']) . '</a>'; break; case 'latest_installed': echo '<a>' . __('Latest Version Installed', 'sputnik') . '</a>'; break; } ?> </p> <?php } echo "<div id='plugin-information-header'>\n"; echo "<ul id='sidemenu'>\n"; foreach ((array) $api->sections as $section_name => $content) { if (isset($plugins_section_titles[$section_name])) { $title = $plugins_section_titles[$section_name]; } else { $title = ucwords(str_replace('_', ' ', $section_name)); } $class = $section_name == $section ? ' class="current"' : ''; $href = add_query_arg(array('tab' => $tab, 'section' => $section_name)); $href = esc_url($href); $san_section = esc_attr($section_name); echo "\t<li><a name='{$san_section}' href='{$href}'{$class}>{$title}</a></li>\n"; } if (!empty($api->screenshots)) { $title = $plugins_section_titles['screenshots']; $class = 'screenshots' == $section ? ' class="current"' : ''; $href = add_query_arg(array('tab' => $tab, 'section' => 'screenshots')); $href = esc_url($href); echo "\t<li><a name='screenshots' href='{$href}'{$class}>{$title}</a></li>\n"; } echo "</ul>\n"; echo "</div>\n"; ?> <h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI', 'sputnik'); ?> </h2> <ul> <?php if (!empty($api->version)) { ?> <li><strong><?php _e('Version:', 'sputnik'); ?> </strong> <?php echo $api->version; ?> </li> <?php } if (!empty($api->author)) { ?> <li><strong><?php _e('Author:', 'sputnik'); ?> </strong> <?php echo $api->author; ?> </li> <?php } if (!empty($api->last_updated)) { ?> <li><strong><?php _e('Last Updated:', 'sputnik'); ?> </strong> <span title="<?php echo $api->last_updated; ?> "><?php printf(__('%s ago', 'sputnik'), human_time_diff(strtotime($api->last_updated))); ?> </span></li> <?php } if (!empty($api->requires)) { ?> <li><strong><?php _e('Requires WordPress Version:', 'sputnik'); ?> </strong> <?php printf(__('%s or higher', 'sputnik'), $api->requires); ?> </li> <?php } if (!empty($api->tested)) { ?> <li><strong><?php _e('Compatible up to:', 'sputnik'); ?> </strong> <?php echo $api->tested; ?> </li> <?php } if (!empty($api->downloaded)) { ?> <li><strong><?php _e('Downloaded:', 'sputnik'); ?> </strong> <?php printf(_n('%s time', '%s times', $api->downloaded, 'sputnik'), number_format_i18n($api->downloaded)); ?> </li> <?php } if (!empty($api->homepage)) { ?> <li><a target="_blank" href="<?php echo $api->homepage; ?> "><?php _e('Plugin Homepage »', 'sputnik'); ?> </a></li> <?php } ?> </ul> </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.', 'sputnik') . '</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.', 'sputnik') . '</p></div>'; } } foreach ($api->sections as $section_name => $content) { if (isset($plugins_section_titles[$section_name])) { $title = $plugins_section_titles[$section_name]; } else { $title = ucwords(str_replace('_', ' ', $section_name)); } $content = links_add_base_url($content, $api->permalink); $content = links_add_target($content, '_blank'); $san_section = esc_attr($title); $display = $section_name == $section ? 'block' : 'none'; echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n"; echo "\t\t<h2 class='long-header'>{$title}</h2>"; echo $content; echo "\t</div>\n"; } if (!empty($api->screenshots)) { $display = 'screenshots' == $section ? 'block' : 'none'; echo "\t<div id='section-screenshots' class='section' style='display: {$display};'>\n"; echo "\t\t<h2 class='long-header'>Screenshots</h2>\n"; echo "\t\t<ol>\n"; foreach ($api->screenshots as $data) { echo "\t\t\t<li><img src='{$data->location}' class='screenshot' /><p>{$data->caption}</p></li>\n"; } echo "\t\t</ol>\n"; echo "\t</div>\n"; } echo "</div>\n"; }
protected function display_row($plugin, $style) { $name = strip_tags($plugin->name . ' ' . $plugin->version); $action_links = array(); $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true)) . '" class="button thickbox info" title="' . esc_attr(sprintf(__('More information about %s', 'wpsc'), $name)) . '">' . __('Details') . '</a>'; $purchase_link = $plugin->price; if ($plugin->slug === '__add_new') { $status = 'addown'; $style['name'] .= ' class="addown"'; $action_links = array(); $action_links[] = '<a href="http://developer.renku.me/" class="thickbox button info">' . __('Documentation', 'wpsc') . '</a>'; $purchase_link = '<a class="button-primary addown" href="' . Sputnik::SITE_BASE . '/plugins/add/" title="Add New Plugin">' . esc_html__('Add Now', 'wpsc') . '</a>'; } elseif (current_user_can('install_plugins') || current_user_can('update_plugins')) { $status = Sputnik_Admin::install_status($plugin); switch ($status['status']) { case 'purchase': if ($status['url']) { $purchase_link = '<a id="' . $plugin->slug . '" class="button-primary buy" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Buy %s', 'wpsc'), $name)) . '">' . sprintf(__('<span>%s</span> Buy Now</a>', 'wpsc'), $plugin->price); } break; case 'install': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']); $purchase_link = '<a class="button install" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Install %s', 'wpsc'), $name)) . '">' . __('Install', 'wpsc') . '</a>'; } else { $purchase_link = '<span title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc') . '">' . __('Install', 'wpsc') . '</span>'; } break; case 'update_available': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 800, 'height' => 600), $status['url']); $purchase_link = '<a class="button install" href="' . esc_url($status['url']) . '" title="' . esc_attr(sprintf(__('Update to version %s', 'wpsc'), $status['version'])) . '">' . __('Update', 'wpsc') . '</a>'; } else { $purchase_link = '<span title="' . esc_attr__('Cannot auto-install, report this as a bug', 'wpsc') . '">' . __('Update', 'wpsc') . '</span>'; } break; case 'latest_installed': case 'newer_installed': $purchase_link = '<span title="' . esc_attr__('This plugin is already installed and is up to date', 'wpsc') . ' ">' . __('Installed', 'wpsc') . '</span>'; break; } } $action_links = apply_filters('sputnik_install_row_action_links', $action_links, $plugin); ?> <tr> <td class="name column-name"<?php echo $style['name']; ?> ><strong><?php echo $plugin->name; ?> </strong> <div class="action-links"><?php if (!empty($action_links)) { echo implode(' ', $action_links); } ?> </div> </td> <td class="vers column-version"<?php echo $style['version']; ?> ><?php echo $plugin->version; ?> </td> <td class="vers column-price"<?php echo $style['price']; ?> ><?php echo $purchase_link; ?> </td> <td class="vers column-rating"<?php echo $style['rating']; ?> > <div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'wpsc'), number_format_i18n($plugin->rating->count)); ?> "> <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average); ?> px"></div> </div> </td> <td class="desc column-description"<?php echo $style['description']; ?> ><?php echo $plugin->description, $plugin->author; ?> </td> </tr> <?php }
protected function display_row($plugin, $style) { $name = strip_tags($plugin->name . ' ' . $plugin->version); $action_links = array(); $action_links[] = '<a href="' . Sputnik_Admin::build_url(array('info' => $plugin->slug, 'TB_iframe' => true)) . '" class="thickbox button info" title="' . esc_attr(sprintf(__('More information about %s', 'sputnik'), $name)) . '">' . __('Details', 'sputnik') . '</a>'; $purchase_link = $plugin->price; if ($plugin->slug === '__add_new') { $status = 'addown'; $name = $plugin->name; $action_links = array(); $action_links[] = '<a href="http://developer.renku.me/" class="thickbox button info">' . __('Documentation', 'sputnik') . '</a>'; $purchase_link = '<a class="button-primary addown status" href="' . Sputnik::SITE_BASE . '/plugins/add/">' . esc_html__('Add Now', 'sputnik') . '</a>'; } elseif (current_user_can('install_plugins') || current_user_can('update_plugins')) { $status = Sputnik_Admin::install_status($plugin); switch ($status['status']) { case 'purchase': if ($status['url']) { $purchase_link = '<a id="' . $plugin->slug . '" class="button-primary buy status" href="' . $status['url'] . '" title="' . esc_attr(sprintf(__('Buy %s', 'sputnik'), $name)) . '">' . __('Buy Now', 'sputnik') . '</a>'; } break; case 'install': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), $status['url']); $purchase_link = '<a class="button install status" href="' . $status['url'] . '" title="' . esc_attr(sprintf(__('Install %s', 'sputnik'), $name)) . '">' . __('Install', 'sputnik') . '</a>'; } else { $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'sputnik') . '">' . __('Install', 'sputnik') . '</span>'; } break; case 'update_available': if ($status['url']) { $status['url'] = add_query_arg(array('TB_iframe' => true, 'width' => 700, 'height' => 550), $status['url']); $purchase_link = '<a class="button install" href="' . $status['url'] . '" title="' . esc_attr(sprintf(__('Update to version %s', 'sputnik'), $status['version'])) . '">' . __('Update', 'sputnik') . '</a>'; } else { $purchase_link = '<span class="status" title="' . esc_attr__('Cannot auto-install, report this as a bug', 'sputnik') . '">' . __('Update', 'sputnik') . '</span>'; } break; case 'latest_installed': case 'newer_installed': $purchase_link = '<span class="status" title="' . esc_attr__('This plugin is already installed and is up to date', 'sputnik') . ' ">' . __('Installed', 'sputnik') . '</span>'; break; } } $action_links = apply_filters('sputnik_install_grid_action_links', $action_links, $plugin); $thumb = false; if (isset($plugin->thumb) && $plugin->thumb !== false) { $thumb = $plugin->thumb; } ?> <div> <div class="sputnik-plugin<?php if ($thumb !== false) { echo ' has-thumb'; } if ($status === 'addown') { echo ' addown'; } ?> "> <div class="sputnik-card"> <?php if ($thumb !== false) { ?> <div class="sputnik-plugin-thumb"> <img src="<?php echo esc_url($thumb); ?> " alt="<?php echo esc_attr($name); ?> Thumbnail"> </div> <?php } ?> <div class="sputnik-plugin-details"> <h4><?php echo $name; ?> </h4> <span class="price"><?php echo $plugin->price; ?> </span> <p><?php echo $plugin->description; ?> </p> <div class="footer"> <div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin->rating->count, 'sputnik'), number_format_i18n($plugin->rating->count)); ?> "> <div class="star star-rating" style="width: <?php echo (int) (20 * $plugin->rating->average); ?> px"></div> </div> </div> </div> </div> </div> <div class="sputnik-plugin-actions"> <?php if (!empty($action_links)) { echo implode(' ', $action_links); } ?> <?php echo $purchase_link; ?> </div> </div> <?php }