public function display_rows()
    {
        $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(), 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array());
        list($columns, $hidden) = $this->get_column_info();
        $style = array();
        foreach ($columns as $column_name => $column_display_name) {
            $style[$column_name] = in_array($column_name, $hidden) ? 'style="display:none;"' : '';
        }
        $nonce_login = wp_create_nonce('installer-login-link');
        foreach ((array) $this->items as $plugin) {
            //echo '<pre>'; print_r($plugin); echo '</pre>';
            if (is_object($plugin)) {
                $plugin = (array) $plugin;
            }
            $title = wp_kses($plugin['name'], $plugins_allowedtags);
            //Limit description to 400char, and remove any HTML.
            $description = strip_tags($plugin['description']);
            if (strlen($description) > 400) {
                $description = mb_substr($description, 0, 400) . '&#8230;';
            }
            //remove any trailing entities
            $description = preg_replace('/&[^;\\s]{0,6}$/', '', $description);
            //strip leading/trailing & multiple consecutive lines
            $description = trim($description);
            $description = preg_replace("|(\r?\n)+|", "\n", $description);
            //\n => <br>
            $description = nl2br($description);
            $version = wp_kses($plugin['version'], $plugins_allowedtags);
            $name = strip_tags($title . ' ' . $version);
            $author = $plugin['author'];
            if (!empty($plugin['author'])) {
                $author = ' <cite>' . sprintf(__('By %s', 'installer'), $author) . '.</cite>';
            }
            $author = wp_kses($author, $plugins_allowedtags);
            $action_links = array();
            $action_links[] = '<a href="' . self_admin_url('plugin-install.php?tab=plugin-information&amp;repository_id=' . $plugin['repository']->id . '&amp;plugin=' . $plugin['slug'] . '&amp;TB_iframe=true&amp;width=600&amp;height=550') . '" class="thickbox" title="' . esc_attr(sprintf(__('More information about %s', 'installer'), $name)) . '">' . __('Details', 'installer') . '</a>';
            // set price
            $no_price_value = __('Free', 'installer');
            $plugin_price = $no_price_value;
            if (array_key_exists('price', $plugin)) {
                $plugin_price = $plugin['price'] != 0 && isset($plugin['price']) ? $plugin['currency']->symbol . $plugin['price'] . ' (' . $plugin['currency']->name . ')' : $no_price_value;
            }
            $plugin_source = '';
            if (array_key_exists('repository', $plugin)) {
                $plugin_source = $plugin['repository']->repository_name;
            }
            if (current_user_can('install_plugins') || current_user_can('update_plugins')) {
                //$plugin['purchase_url'] = 'http://wpml.org/shop/checkout/?buy_now=2'; // DEBUG
                WPRC_Loader::includeListTable('wprc-plugin-information');
                $status = WPRC_PluginInformation::wprc_install_plugin_install_status($plugin);
                //$action_links[]=$status['status'];
                if ($status['status'] != 'latest_installed' && $status['status'] != 'newer_installed') {
                    if (isset($plugin['purchase_link']) && !empty($plugin['purchase_link']) && $plugin_price != $no_price_value) {
                        $purl = WPRC_Functions::sanitizeURL($plugin['purchase_link']);
                        $return_url = rawurlencode(admin_url('plugin-install.php?tab=plugin-information&repository_id=' . $plugin['repository']->id . '&plugin=' . $plugin['slug']));
                        $salt = rawurlencode($plugin['salt']);
                        if (strpos($purl, '?')) {
                            $url_glue = '&';
                        } else {
                            $url_glue = '?';
                        }
                        $purl .= $url_glue . 'return_to=' . $return_url . '&rsalt=' . $salt;
                        $status = array('status' => 'paid', 'url' => $purl, 'version' => $plugin['version']);
                    }
                    /*else
                                 {
                                     WPRC_Loader::includeListTable('wprc-plugin-information');
                    		$status = WPRC_PluginInformation::wprc_install_plugin_install_status( $plugin );    
                                 }*/
                }
                $url_glue = false === strpos($status['url'], '?') ? '?' : '&';
                $status['url'] .= $url_glue . 'repository_id=' . $plugin['repository']->id;
                $showedmessage = false;
                switch ($status['status']) {
                    case 'install':
                        if ($status['url']) {
                            $action_links[] = '<a class="install-now" href="' . $status['url'] . '" title="' . esc_attr(sprintf(__('Install %s', 'installer'), $name)) . '">' . __('Install Now', 'installer') . '</a>';
                        }
                        break;
                    case 'update_available':
                        if ($status['url']) {
                            $action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr(sprintf(__('Update to version %s', 'installer'), $status['version'])) . '">' . sprintf(__('Update Now', 'installer'), $status['version']) . '</a>';
                        }
                        break;
                    case 'paid':
                        //$action_links[] = '<a href="' . $status['url'] . '" class="thickbox">' . __('Buy' , 'installer') . ' (' . $plugin['currency'] . $plugin['price'].')</a>';
                        if (isset($plugin['message']) && !empty($plugin['message'])) {
                            $action_links[] = WPRC_Functions::formatMessage($plugin['message']);
                            $showedmessage = true;
                        } else {
                            //$action_links[] = '<a href=" ' . admin_url('admin.php?wprc_c=repository-login&wprc_action=RepositoryLogin&repository_id=' . $plugin['repository']->id) . '&buyurl='.rawurlencode($status['url']).'" class="thickbox" title="' . __('Buy', 'installer') . '">' . __('Buy ' , 'installer') . ' (' . $plugin['currency'] . $plugin['price'].')</a>';
                            //$action_links[] = '<a href=" ' . $status['url']  . '" class="thickbox" title="' . __('Buy', 'installer') . '">' . __('Buy' , 'installer') . ' (' . $plugin['currency'] . $plugin['price'].')</a>';
                            $action_links[] = '<a href=" ' . $status['url'] . '&TB_iframe=true' . '" class="thickbox" title="' . sprintf(__('Buy %s', 'installer'), $name) . '">' . sprintf(__('Buy %s', 'installer'), '(' . $plugin['currency']->symbol . $plugin['price'] . ' ' . $plugin['currency']->name . ')') . '</a>';
                        }
                        if (empty($plugin['repository']->repository_username) && empty($plugin['repository']->repository_password)) {
                            $action_links[] = '<a href=" ' . admin_url('admin.php?wprc_c=repository-login&amp;wprc_action=RepositoryLogin&amp;repository_id=' . $plugin['repository']->id . '&amp;_wpnonce=' . $nonce_login) . '" class="thickbox" title="' . __('Log in', 'installer') . '">' . __('Login', 'installer') . '</a>';
                        }
                        break;
                    case 'latest_installed':
                    case 'newer_installed':
                        $action_links[] = '<span title="' . esc_attr__('This plugin is already installed and is up to date', 'installer') . ' ">' . __('Installed', 'installer') . '</span>';
                        break;
                }
                if (isset($plugin['message']) && !empty($plugin['message'])) {
                    $message = WPRC_Functions::formatMessage($plugin['message']);
                    if (isset($plugin['message_type']) && $plugin['message_type'] == 'notify') {
                        WPRC_AdminNotifier::addMessage('wprc-plugin-info-' . $plugin['slug'], $message);
                    } elseif (!$showedmessage) {
                        $action_links[] = $message;
                    }
                }
            }
            // add check compatibility link
            //            $action_links[] = '<a href="' . self_admin_url( 'plugin-install.php?tab=plugin-information&amp;repository_id='. $plugin['repository']->id .'&amp;plugin=' . $plugin['slug'] .
            //                '&amp;TB_iframe=true&amp;width=600&amp;height=550' ) . '" class="thickbox" title="' .
            //                esc_attr( sprintf( __( 'Check compatibility of "%s" plugin with activated extensions', 'installer' ), $name ) ) . '">' . __( 'Check compatibility', 'installer' ) . '</a>';
            $slug = isset($plugin['slug']) ? '&amp;extension_slug=' . $plugin['slug'] : '';
            $action_links[] = '<a href="' . self_admin_url('admin.php?wprc_c=repository-reporter&amp;wprc_action=checkCompatibility&amp;repository_id=' . $plugin['repository']->id . '&amp;repository_url=' . $plugin['repository']->repository_endpoint_url . '&amp;extension_name=' . $plugin['name'] . '&amp;extension_version=' . $plugin['version'] . $slug . '&amp;extension_type_singular=plugin&amp;extension_type=plugins&amp;TB_iframe=true&amp;width=300&amp;height=400') . '" class="thickbox" title="' . esc_attr(sprintf(__('Check compatibility status for "%s" plugin', 'installer'), $name)) . '">' . __('Check compatibility', 'installer') . '</a>';
            $action_links = apply_filters('plugin_install_action_links', $action_links, $plugin);
            if (!isset($plugin['num_ratings']) || empty($plugin['num_ratings'])) {
                $plugin['num_ratings'] = 0;
            }
            if (!isset($plugin['rating']) || empty($plugin['rating'])) {
                $plugin['rating'] = 0;
            }
            ?>
		<tr>
			<td class="name column-name"<?php 
            echo $style['name'];
            ?>
><strong><?php 
            echo $title;
            ?>
</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 $version;
            ?>
</td>
			<td class="vers column-rating"<?php 
            echo $style['rating'];
            ?>
>
				<?php 
            global $wp_version;
            if (version_compare($wp_version, "3.4", "<")) {
                ?>
				<div class="star-holder" title="<?php 
                printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin['num_ratings'], 'installer'), number_format_i18n(intval($plugin['num_ratings'])));
                ?>
">
					<div class="star star-rating" style="width: <?php 
                echo esc_attr($plugin['rating']);
                ?>
px"></div>
					<?php 
                $color = get_user_option('admin_color');
                if (empty($color) || 'fresh' == $color) {
                    $star_url = admin_url('images/gray-star.png?v=20110615');
                } else {
                    $star_url = admin_url('images/star.png?v=20110615');
                }
                // 'Classic' Blue star
                ?>
					<div class="star star5"><img src="<?php 
                echo $star_url;
                ?>
" alt="<?php 
                esc_attr_e('5 stars');
                ?>
" /></div>
					<div class="star star4"><img src="<?php 
                echo $star_url;
                ?>
" alt="<?php 
                esc_attr_e('4 stars');
                ?>
" /></div>
					<div class="star star3"><img src="<?php 
                echo $star_url;
                ?>
" alt="<?php 
                esc_attr_e('3 stars');
                ?>
" /></div>
					<div class="star star2"><img src="<?php 
                echo $star_url;
                ?>
" alt="<?php 
                esc_attr_e('2 stars');
                ?>
" /></div>
					<div class="star star1"><img src="<?php 
                echo $star_url;
                ?>
" alt="<?php 
                esc_attr_e('1 star');
                ?>
" /></div>
				</div>
			<?php 
            } else {
                ?>
				<div class="star-holder" title="<?php 
                printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin['num_ratings'], 'installer'), number_format_i18n(intval($plugin['num_ratings'])));
                ?>
">
					<div class="star star-rating" style="width: <?php 
                echo esc_attr(str_replace(',', '.', $plugin['rating']));
                ?>
px"></div>
				</div>
			<?php 
            }
            ?>
			</td>
			<td class="desc column-description"<?php 
            echo $style['description'];
            ?>
><?php 
            echo $description, $author;
            ?>
</td>
            <td class="source column-source" align="left"><?php 
            echo $plugin_source;
            ?>
</td>
            <td class="price column-price" align="left"><?php 
            echo $plugin_price;
            ?>
</td>
		</tr>
		<?php 
        }
    }
Example #2
0
 public static function wprc_plugin_update_rows()
 {
     WPRC_Loader::includeListTable('wprc-plugin-information');
     WPRC_PluginInformation::wprc_plugin_update_rows();
 }