示例#1
0
 /**
  * Singleton pattern
  *
  * @return pspSeoCheck Singleton instance
  */
 public static function getInstance()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
示例#2
0
        public function print_main_table($items)
        {
            $html = array();
            $html[] = '<div id="psp-list-table-posts">';
            $html[] = '<table class="psp-table" style="border: none;border-bottom: 1px solid #dadada;">';
            $html[] = '<thead>';
            $html[] = '<tr>';
            foreach ($this->opt['columns'] as $key => $value) {
                if ($value['th'] == 'checkbox') {
                    $html[] = '<th class="checkbox-column" width="20"><input type="checkbox" id="psp-item-check-all" checked></th>';
                } else {
                    $html[] = '<th' . (isset($value['width']) && (int) $value['width'] > 0 ? ' width="' . $value['width'] . '"' : '') . '' . (isset($value['align']) && $value['align'] != "" ? ' align="' . $value['align'] . '"' : '') . '>' . $value['th'] . '</th>';
                }
            }
            $html[] = '</tr>';
            $html[] = '</thead>';
            $html[] = '<tbody>';
            if ($this->opt['id'] == 'pspPageOptimization') {
                //use to generate meta keywords, and description for your requested item
                require_once $this->the_plugin->cfg['paths']['scripts_dir_path'] . '/seo-check-class/seo.class.php';
                $seo = pspSeoCheck::getInstance();
            }
            foreach ($this->items as $post) {
                if (isset($post->ID)) {
                    $item_data = array('score' => get_post_meta($post->ID, 'psp_score', true));
                }
                $html[] = '<tr data-itemid="' . (isset($post->ID) ? $post->ID : $post['id']) . '">';
                foreach ($this->opt['columns'] as $key => $value) {
                    $html[] = '<td style="' . (isset($value['align']) && $value['align'] != "" ? 'text-align:' . $value['align'] . ';' : '') . '' . (isset($value['css']) && count($value['css']) > 0 ? $this->print_css_as_style($value['css']) : '') . '"
						class="' . (isset($value['class']) ? $value['class'] : '') . '"
						>';
                    if ($value['td'] == 'checkbox') {
                        $html[] = '<input type="checkbox" class="psp-item-checkbox" name="psp-item-checkbox-' . (isset($post->ID) ? $post->ID : $post['id']) . '" checked>';
                    } elseif ($value['td'] == '%score%') {
                        $score = (double) $item_data['score'];
                        $size_class = 'size_';
                        if ($score >= 20 && $score < 40) {
                            $size_class .= '20_40';
                        } elseif ($score >= 40 && $score < 60) {
                            $size_class .= '40_60';
                        } elseif ($score >= 60 && $score < 80) {
                            $size_class .= '60_80';
                        } elseif ($score >= 80 && $score <= 100) {
                            $size_class .= '80_100';
                        } else {
                            $size_class .= '0_20';
                        }
                        if (!isset($item_data['score']) || trim($item_data['score']) == "") {
                            $item_data['score'] = 0;
                        }
                        $html[] = '<div class="psp-progress">';
                        $html[] = '<div class="psp-progress-bar ' . $size_class . '" style="width:' . $score . '%"></div>';
                        $html[] = '<div class="psp-progress-score">' . $item_data['score'] . '%</div>';
                        $html[] = '</div>';
                    } elseif ($value['td'] == '%focus_keyword%') {
                        $focus_kw = get_post_meta($post->ID, 'psp_kw', true);
                        $html[] = '<div class="psp-focus-kw-box">';
                        $html[] = '<input type="text" class="psp-text-field-kw" id="psp-focus-kw-' . $post->ID . '" value="' . $focus_kw . '" />';
                        $html[] = '<input type="button" class="psp-auto-detect-kw-btn psp-button gray" value="' . __('Auto detect', $this->the_plugin->localizationName) . '" />';
                        /*$html[] = 	'<a class="psp-button green psp-suggest-kw-btn" href="#">
                              <img src="' . ( $this->the_plugin->cfg['paths']['freamwork_dir_url'] ) . 'images/light.png">
                          	Suggest
                          </a>';*/
                        $html[] = '</div>';
                    } elseif ($value['td'] == '%seo_report%') {
                        $html[] = '<a class="psp-button green psp-seo-report-btn" href="#" data-itemid="' . $post->ID . '">
                                        <img src="' . $this->the_plugin->cfg['paths']['freamwork_dir_url'] . 'images/light.png">
                                    	' . __('SEO Report', $this->the_plugin->localizationName) . '
                                    </a>';
                    } elseif (strtolower($value['td']) == '%id%') {
                        $html[] = is_object($post) ? isset($post->ID) ? $post->ID : $post->id : (isset($post['ID']) ? $post['ID'] : $post['id']);
                    } elseif ($value['td'] == '%title%') {
                        $html[] = '<input type="hidden" id="psp-item-title-' . $post->ID . '" value="' . str_replace('"', "'", $post->post_title) . '" />';
                        $html[] = '<a href="' . sprintf(admin_url('post.php?post=%s&action=edit'), $post->ID) . '">';
                        if ($post->post_status == 'inherit' && $post->post_type == 'attachment') {
                            // media image file
                            $html[] = $post->post_title . (isset($post->post_mime_type) && preg_match('/^image\\//i', $post->post_mime_type) > 0 ? ' <span class="item-state">- ' . strtoupper(str_replace('image/', '', $post->post_mime_type)) : '</span>');
                            $html[] = '</a>';
                            $html[] = '
							<span class="psp-inline-row-actions show" id="psp-inline-row-actions-' . $post->ID . '">
								<a href="' . sprintf(admin_url('post.php?post=%s&action=edit'), $post->ID) . '">Edit</a>
								 | <a href="' . wp_get_attachment_url($post->ID) . '" target="_blank">' . __('View', $this->the_plugin->localizationName) . '</a>
							</span>';
                        } else {
                            $html[] = $post->post_title . ($post->post_status != 'publish' ? ' <span class="item-state">- ' . ucfirst($post->post_status) : '</span>');
                            $html[] = '</a>';
                        }
                    } elseif ($value['td'] == '%title_and_actions%') {
                        $html[] = '<input type="hidden" id="psp-item-title-' . $post->ID . '" value="' . str_replace('"', "'", $post->post_title) . '" />';
                        $html[] = '<a href="' . sprintf(admin_url('post.php?post=%s&action=edit'), $post->ID) . '">';
                        $html[] = $post->post_title . ($post->post_status != 'publish' ? ' <span class="item-state">- ' . ucfirst($post->post_status) : '</span>');
                        $html[] = '</a>';
                        $__row_actions = $this->the_plugin->edit_post_inline_data($post->ID, $seo);
                        $html[] = '
						<span class="psp-inline-row-actions show" id="psp-inline-row-actions-' . $post->ID . '">
							<a href="' . sprintf(admin_url('post.php?post=%s&action=edit'), $post->ID) . '">Edit</a>
							 | <a href="#" class="editinline" title="' . __('Edit this item inline', $this->the_plugin->localizationName) . '">' . __('Quick Edit', $this->the_plugin->localizationName) . '</a>
							 | <a href="' . get_permalink($post->ID) . '" target="_blank">' . __('View', $this->the_plugin->localizationName) . '</a>
						</span>';
                        $html[] = '
						<div id="psp-inline-row-data-' . $post->ID . '" class="hide" style="display: none;">
							' . $__row_actions . '
						</div>
						';
                    } elseif ($value['td'] == '%custom_title%') {
                        $html[] = '<i>' . $post['title'] . '</i>';
                    } elseif ($value['td'] == '%button%') {
                        $value['option']['color'] = isset($value['option']['color']) ? $value['option']['color'] : 'gray';
                        $html[] = '<input type="button" value="' . $value['option']['value'] . '" class="psp-button ' . $value['option']['color'] . ' psp-' . $value['option']['action'] . '">';
                    } elseif ($value['td'] == '%button_publish%') {
                        $value['option']['color'] = isset($value['option']['color']) ? $value['option']['color'] : 'gray';
                        $html[] = '<input type="button" value="' . ($post['publish'] == 'Y' ? $value['option']['value'] : $value['option']['value_change']) . '" class="psp-button ' . $value['option']['color'] . ' psp-' . $value['option']['action'] . '">';
                    } elseif ($value['td'] == '%button_html5data%') {
                        $__html5data = array();
                        foreach ($value['html5_data'] as $ttk => $ttv) {
                            $__html5data[] = "data-" . $ttk . "=\"" . $ttv . "\"";
                        }
                        $__html5data = ' ' . implode(' ', $__html5data) . ' ';
                        $value['option']['color'] = isset($value['option']['color']) ? $value['option']['color'] : 'gray';
                        $html[] = '<input type="button" value="' . $value['option']['value'] . '" class="psp-button ' . $value['option']['color'] . ' psp-' . $value['option']['action'] . '"
						' . $__html5data . '
						>';
                    } elseif ($value['td'] == '%date%') {
                        $html[] = '<i>' . $post->post_date . '</i>';
                    } else {
                        if ($value['td'] == '%created%') {
                            $html[] = '<i>' . $post['created'] . '</i>';
                        } elseif ($value['td'] == '%hits%') {
                            $html[] = '<i>' . $post['hits'] . '</i>';
                        } elseif ($value['td'] == '%url%') {
                            $html[] = '<i>' . $post['url'] . '</i>';
                        } elseif ($value['td'] == '%bad_url%') {
                            $html[] = '<i>' . $post['url'] . '</i>';
                        } elseif ($value['td'] == '%phrase%') {
                            $html[] = '<i>' . $post['phrase'] . '</i>';
                        } elseif ($value['td'] == '%referrers%') {
                            $html[] = trim($post['referrers']) != "" ? '<a href="#referrers" class="psp-button gray psp-btn-referrers-lightbox" data-itemid="' . $post['id'] . '">' . __('Show All', $this->the_plugin->localizationName) . '</a>' : '-';
                        } elseif ($value['td'] == '%user_agents%') {
                            $html[] = trim($post['user_agents']) != "" ? '<a href="#user_agents" class="psp-button gray psp-btn-user_agents-lightbox" data-itemid="' . $post['id'] . '">' . __('Show All', $this->the_plugin->localizationName) . '</a>' : '-';
                        } elseif ($value['td'] == '%last_date%') {
                            $html[] = '<i>' . $post['data'] . '</i>';
                        }
                    }
                    if ($this->opt['id'] == 'pspSmushit') {
                        $id = intval($post->ID);
                        if ($value['td'] == '%thumbnail%') {
                            $attachment_img_thumb = wp_get_attachment_image($id, 'thumbnail');
                            $patterns = array('/<img(.*?)width="(.*?)"(.*?)>/', '/<img(.*?)height="(.*?)"(.*?)>/');
                            $replacements = array('<img\\1width="60"\\3>', '<img\\1height="60"\\3>');
                            $html[] = preg_replace($patterns, $replacements, $attachment_img_thumb);
                        } else {
                            if ($value['td'] == '%smushit_status%') {
                                //$html[] = '<div class="psp-message">';
                                //$html[] = 	'<span class="psp-smushit-loading"></span>';
                                // retrieve the existing value(s) for this meta field. This returns an array
                                $meta_new = wp_get_attachment_metadata($id);
                                if (isset($meta_new['psp_smushit']) && !empty($meta_new['psp_smushit'])) {
                                    $msg = (array) $this->the_plugin->smushit_show_sizes_msg_details($meta_new);
                                    $__msg = array();
                                    if (isset($meta_new['psp_smushit_errors']) && (int) $meta_new['psp_smushit_errors'] > 0) {
                                        $status = 'invalid';
                                        $msg_cssClass = 'psp-error';
                                        $__msg = array(__('errors occured during smushit operation!', $this->localizationName));
                                    } else {
                                        $status = 'valid';
                                        $msg_cssClass = 'psp-success';
                                    }
                                    $msg = implode('<br />', array_merge($__msg, $msg));
                                    $html[] = '<div id="' . ('psp-smushit-resp-' . $id) . '" class="psp-message ' . $msg_cssClass . '">' . $msg . '</div><br />';
                                } else {
                                    $html[] = '<div id="' . ('psp-smushit-resp-' . $id) . '" class="psp-message psp-info">' . __('not processed!', $this->localizationName) . '</div><br />';
                                }
                                //$html[] = '</div>';
                            }
                        }
                    }
                    if ($this->opt['id'] == 'pspPageSpeed') {
                        if ($value['td'] == '%mobile_score%') {
                            $mobile = get_post_meta($post->ID, 'psp_mobile_pagespeed', true);
                            if (isset($mobile['score'])) {
                                $score = (int) $mobile['score'];
                                $size_class = 'size_';
                                if ($score >= 20 && $score < 40) {
                                    $size_class .= '20_40';
                                } elseif ($score >= 40 && $score < 60) {
                                    $size_class .= '40_60';
                                } elseif ($score >= 60 && $score < 80) {
                                    $size_class .= '60_80';
                                } elseif ($score >= 80 && $score <= 100) {
                                    $size_class .= '80_100';
                                } else {
                                    $size_class .= '0_20';
                                }
                                $html[] = '<div class="psp-progress" style="margin-right:4px">';
                                $html[] = '<div class="psp-progress-bar ' . $size_class . '" style="width:' . $score . '%"></div>';
                                $html[] = '</div>';
                            } else {
                                $html[] = '<i>Never Checked</i>';
                            }
                        }
                        if ($value['td'] == '%desktop_score%') {
                            $desktop = get_post_meta($post->ID, 'psp_desktop_pagespeed', true);
                            if (isset($desktop['score'])) {
                                $score = (int) $desktop['score'];
                                $size_class = 'size_';
                                if ($score >= 20 && $score < 40) {
                                    $size_class .= '20_40';
                                } elseif ($score >= 40 && $score < 60) {
                                    $size_class .= '40_60';
                                } elseif ($score >= 60 && $score < 80) {
                                    $size_class .= '60_80';
                                } elseif ($score >= 80 && $score <= 100) {
                                    $size_class .= '80_100';
                                } else {
                                    $size_class .= '0_20';
                                }
                                $html[] = '<div class="psp-progress" style="margin-right:4px">';
                                $html[] = '<div class="psp-progress-bar ' . $size_class . '" style="width:' . $score . '%"></div>';
                                $html[] = '</div>';
                            } else {
                                $html[] = '<i>Never Checked</i>';
                            }
                        }
                    }
                    if ($this->opt['id'] == 'pspProxyLists') {
                        if ($value['td'] == '%ip_address%') {
                            $html[] = '<strong>' . $post['ip'] . '</strong>';
                        } else {
                            if ($value['td'] == '%port%') {
                                $html[] = '<strong>' . $post['port'] . '</strong>';
                            } elseif ($value['td'] == '%speed%') {
                                $score = (double) $post['speed'];
                                $size_class = 'size_';
                                if ($score >= 20 && $score < 40) {
                                    $size_class .= '20_40';
                                } elseif ($score >= 40 && $score < 60) {
                                    $size_class .= '40_60';
                                } elseif ($score >= 60 && $score < 80) {
                                    $size_class .= '60_80';
                                } elseif ($score >= 80 && $score <= 100) {
                                    $size_class .= '80_100';
                                } else {
                                    $size_class .= '0_20';
                                }
                                $html[] = '<div class="psp-progress" style="margin-right:4px">';
                                $html[] = '<div class="psp-progress-bar ' . $size_class . '" style="width:' . $score . '%"></div>';
                                $html[] = '</div>';
                            }
                        }
                        /*elseif( $value['td'] == '%connection_time%' ){
                        							$score = (float)$post['connection_time'];
                        							$size_class = 'size_';
                        							if ( $score >= 20 && $score < 40 ){
                        								$size_class .= '20_40';
                        							}elseif ( $score >= 40 && $score < 60 ){
                        								$size_class .= '40_60';
                        							}
                        							elseif ( $score >= 60 && $score < 80 ){
                        								$size_class .= '60_80';
                        							}elseif ( $score >= 80 && $score <= 100 ){
                        								$size_class .= '80_100';
                        							}else{
                        								$size_class .= '0_20';
                        							}
                        	
                        							$html[] = '<div class="psp-progress" style="margin-right:4px">';
                        							$html[] = 	'<div class="psp-progress-bar ' . ( $size_class ) . '" style="width:' . ( $score ) . '%"></div>';
                        							$html[] = '</div>';
                        						}*/
                    }
                    if ($this->opt['id'] == 'pspLinkBuilder') {
                        if ($value['td'] == '%builder_phrase%') {
                            $html[] = '<input type="text" value="' . $post['phrase'] . '" readonly />';
                        } else {
                            if ($value['td'] == '%builder_url%') {
                                $html[] = '<input type="text" value="' . $post['url'] . '" readonly />';
                            } else {
                                if ($value['td'] == '%builder_rel%') {
                                    $html[] = '<i>' . $post['rel'] . '</i>';
                                } else {
                                    if ($value['td'] == '%builder_target%') {
                                        $html[] = '<i>' . $post['target'] . '</i>';
                                    } else {
                                        if ($value['td'] == '%url_attributes%') {
                                            $html[] = 1 == 1 ? '<a href="#url_attributes" class="psp-button gray psp-btn-url-attributes-lightbox" data-itemid="' . $post['id'] . '">' . __('Show All', $this->the_plugin->localizationName) . '</a>' : '-';
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($this->opt['id'] == 'pspLinkRedirect') {
                        if ($value['td'] == '%linkred_url%') {
                            $html[] = '<input type="text" value="' . $post['url'] . '" readonly />';
                        } else {
                            if ($value['td'] == '%linkred_url_redirect%') {
                                $html[] = '<input type="text" value="' . $post['url_redirect'] . '" readonly />';
                            }
                        }
                    }
                    if ($this->opt['id'] == 'pspSocialStats') {
                        $page_permalink = get_permalink($post->ID);
                        $social_data = $this->get_page_social_stats($post->ID, $page_permalink);
                        $dashboard_module_url = $this->the_plugin->cfg['paths']['plugin_dir_url'] . 'modules/dashboard/';
                        if ($value['td'] == '%ss_facebook%') {
                            $html[] = '<div class="psp-social-status" style="color: #3c5b9b">';
                            $html[] = '<img src="' . $dashboard_module_url . 'assets/stats/facebook-icon.png" class="psp-lists-icon">';
                            $html[] = '<span>' . (isset($social_data['facebook']['share_count']) ? number_format($social_data['facebook']['share_count'], 0) : '&ndash;') . '</span>';
                            $html[] = '<label>' . __("shares", $this->the_plugin->localizationName) . '</label>';
                            $html[] = '</div>';
                            /*
                            							$html[] = '<div class="psp-social-status" style="color: #3c5b9b">';
                            							$html[] = 	'<img src="' . ( $dashboard_module_url ) . 'assets/stats/facebook-like-icon.png" class="psp-lists-icon">';
                            							$html[] = 	'<span>' . ( isset($social_data['facebook']['like_count']) ? number_format($social_data['facebook']['like_count'], 0) : '&ndash;' ) . '</span>';
                            							$html[] = 	'<label>' . ( __("likes", $this->the_plugin->localizationName) ) . '</label>';
                            							$html[] = '</div>';
                            							
                            							$html[] = '<div class="psp-social-status" style="color: #3c5b9b">';
                            							$html[] = 	'<img src="' . ( $dashboard_module_url ) . 'assets/stats/facebook-comments-icon.png" class="psp-lists-icon">';
                            							$html[] = 	'<span>' . ( isset($social_data['facebook']['comment_count']) ? number_format($social_data['facebook']['comment_count'], 0) : '&ndash;' ) . '</span>';
                            							$html[] = 	'<label>' . ( __("comments", $this->the_plugin->localizationName) ) . '</label>';
                            							$html[] = '</div>';
                            							
                            							$html[] = '<div class="psp-social-status" style="color: #3c5b9b">';
                            							$html[] = 	'<img src="' . ( $dashboard_module_url ) . 'assets/stats/facebook-icon.png" class="psp-lists-icon">';
                            							$html[] = 	'<span>' . ( isset($social_data['facebook']['click_count']) ? number_format($social_data['facebook']['click_count'], 0) : '&ndash;' ) . '</span>';
                            							$html[] = 	'<label>' . ( __("clicks", $this->the_plugin->localizationName) ) . '</label>';
                            							$html[] = '</div>';*/
                        } elseif ($value['td'] == '%ss_stumbleupon%') {
                            $html[] = '<div class="psp-social-status" style="color: #3fbd46">';
                            $html[] = '<img src="' . $dashboard_module_url . 'assets/stats/stumbleupon-icon.png" class="psp-lists-icon">';
                            $html[] = '<label>' . __("views", $this->the_plugin->localizationName) . '</label>';
                            $html[] = '<span>' . (isset($social_data['stumbleupon']) ? number_format($social_data['stumbleupon'], 0) : '&ndash;') . '</span>';
                            $html[] = '</div>';
                        } elseif ($value['td'] == '%ss_twitter%') {
                            $html[] = '<div class="psp-social-status" style="color: #00aced">';
                            $html[] = '<img src="' . $dashboard_module_url . 'assets/stats/twitter-icon.png" class="psp-lists-icon">';
                            $html[] = '<label>' . __("retweets", $this->the_plugin->localizationName) . '</label>';
                            $html[] = '<span>' . (isset($social_data['twitter']) ? number_format($social_data['twitter'], 0) : '&ndash;') . '</span>';
                            $html[] = '</div>';
                        } elseif ($value['td'] == '%ss_google%') {
                            $html[] = '<div class="psp-social-status" style="color: #d23e2b">';
                            $html[] = '<img src="' . $dashboard_module_url . 'assets/stats/google-icon.png" class="psp-lists-icon">';
                            $html[] = '<label>' . __("share", $this->the_plugin->localizationName) . '</label>';
                            $html[] = '<span>' . (isset($social_data['google']) ? number_format($social_data['google'], 0) : '&ndash;') . '</span>';
                            $html[] = '</div>';
                        } elseif ($value['td'] == '%ss_digg%') {
                            $html[] = '<div class="psp-social-status" style="color: #2c2c2c">';
                            $html[] = '<img src="' . $dashboard_module_url . 'assets/stats/delicious-icon.png" class="psp-lists-icon">';
                            $html[] = '<label>' . __("posts", $this->the_plugin->localizationName) . '</label>';
                            $html[] = '<span>' . (isset($social_data['delicious']) ? number_format($social_data['delicious'], 0) : '&ndash;') . '</span>';
                            $html[] = '</div>';
                        } elseif ($value['td'] == '%ss_pinterest%') {
                            $html[] = '<div class="psp-social-status" style="color: #ca4638">';
                            $html[] = '<img src="' . $dashboard_module_url . 'assets/stats/pinterest-icon.png" class="psp-lists-icon">';
                            $html[] = '<label>' . __("pins", $this->the_plugin->localizationName) . '</label>';
                            $html[] = '<span>' . (isset($social_data['pinterest']) ? number_format($social_data['pinterest'], 0) : '&ndash;') . '</span>';
                            $html[] = '</div>';
                        } elseif ($value['td'] == '%ss_linkedin%') {
                            $html[] = '<div class="psp-social-status" style="color: #007ab9">';
                            $html[] = '<img src="' . $dashboard_module_url . 'assets/stats/linkedin-icon.png" class="psp-lists-icon">';
                            $html[] = '<label>' . __("backlinks", $this->the_plugin->localizationName) . '</label>';
                            $html[] = '<span>' . (isset($social_data['linkedin']) ? number_format($social_data['linkedin'], 0) : '&ndash;') . '</span>';
                            $html[] = '</div>';
                        }
                    }
                    if ($this->opt['id'] == 'pspWebDirectories') {
                        if ($value['td'] == '%directory_name%') {
                            $html[] = '<a href="' . $post['submit_url'] . '" target="_blank">' . $post['directory_name'] . '</a>';
                        } elseif ($value['td'] == '%pagerank%' || $value['td'] == '%alexa%') {
                            $html[] = '<code>' . $post[$key] . '</code>';
                        } elseif ($value['td'] == '%submit_btn%') {
                            $html[] = '<a href="' . $post['submit_url'] . '" target="_blank" class="psp-button blue psp-btn-submit-website" data-itemid="' . $post['id'] . '">' . __('Submit website', $this->the_plugin->localizationName) . '</a>';
                        } elseif ($value['td'] == '%submit_status%') {
                            // never submited / $post['status'] = 2;
                            $html_status = '<div class="psp-message" style="padding: 5px;">' . __('Never submit', $this->the_plugin->localizationName) . '</div>';
                            if ($post['status'] == 2) {
                                $html_status = '<div class="psp-message psp-info" style="padding: 5px;background-image: none;">' . __('Submit in progress', $this->the_plugin->localizationName) . '</div>';
                            } elseif ($post['status'] == 3) {
                                $html_status = '<div class="psp-message psp-error" style="padding: 5px;background-image: none;">' . __('Error on submit', $this->the_plugin->localizationName) . '</div>';
                            } elseif ($post['status'] == 1) {
                                $html_status = '<div class="psp-message psp-success" style="padding: 5px;background-image: none;">' . __('Submit successfully', $this->the_plugin->localizationName) . '</div>';
                            }
                            $html[] = $html_status;
                        }
                    }
                    if ($this->opt['id'] == 'pspPageHTMLValidation') {
                        // get html verify data
                        $html_verify_details = get_post_meta($post->ID, 'psp_w3c_validation', true);
                        if ($value['td'] == '%nr_of_errors%') {
                            $html[] = '<i class="' . $key . '">' . (isset($html_verify_details['nr_of_errors']) ? $html_verify_details['nr_of_errors'] : $value['def']) . '</i>';
                        } elseif ($value['td'] == '%nr_of_warning%') {
                            $html[] = '<i class="' . $key . '">' . (isset($html_verify_details['nr_of_warning']) ? $html_verify_details['nr_of_warning'] : $value['def']) . '</i>';
                        } elseif ($value['td'] == '%status%') {
                            $html[] = '<strong class="' . $key . '" style="' . (isset($html_verify_details['status']) && $html_verify_details['status'] == 'Invalid' ? 'color: red;' : 'color: green') . '">' . (isset($html_verify_details['status']) ? $html_verify_details['status'] : $value['def']) . '</strong>';
                        } elseif ($value['td'] == '%last_check_at%') {
                            $html[] = '<i class="' . $key . '">' . (isset($html_verify_details['last_check_at']) ? $html_verify_details['last_check_at'] : $value['def']) . '</i>';
                        } elseif ($value['td'] == '%view_full_report%') {
                            $html[] = '<a target="_blank" href="' . ('http://validator.w3.org/check?uri=' . get_permalink($post->ID)) . '" class="psp-button gray">' . __('View report', $this->the_plugin->localizationName) . '</a>';
                        }
                    }
                    if ($this->opt['id'] == 'pspSERPKeywords') {
                        $rank_data = $post;
                        if ($value['td'] == '%serp_focus_keyword%') {
                            $html[] = '<input type="text" value="' . $post['focus_keyword'] . '" />';
                        } else {
                            if ($value['td'] == '%serp_url%') {
                                $html[] = '<input type="text" value="' . $post['url'] . '" />';
                            } elseif ($value['td'] == '%serp_location%') {
                                $html[] = '<i>' . $post['engine_location'] . '</i>';
                            } else {
                                if ($value['td'] == '%serp_google%') {
                                    if (isset($rank_data) && is_array($rank_data) && count($rank_data) > 0) {
                                        // get best rank
                                        $best_pos = (int) $post['position_best'];
                                        // get worst
                                        $worst_pos = (int) $post['position_worst'];
                                        // current rank
                                        $current_pos = (int) $rank_data['position'];
                                        // previous rank
                                        $previous_pos = (int) $rank_data['position_prev'];
                                        //direction icon!
                                        $icon = 'same';
                                        if ($current_pos > $previous_pos) {
                                            $icon = 'down';
                                        }
                                        if ($current_pos < $previous_pos) {
                                            $icon = 'up';
                                        }
                                        $__notInTop100 = __('Not in top', $this->the_plugin->localizationName);
                                        $__icon_not100 = '<i class="serp-icon notintop100" title="' . $__notInTop100 . '"></i>';
                                        $__icon = '<i class="serp-icon ' . $icon . '"></i>';
                                        $__iconExtra = '';
                                        if ($icon == 'up') {
                                            $__iconExtra .= '(' . ($previous_pos == 999 ? '~' : '') . '&#43;' . ($previous_pos == 999 ? (int) (100 - $current_pos) : (int) ($previous_pos - $current_pos)) . ')';
                                        } else {
                                            if ($icon == 'down') {
                                                $__iconExtra .= '(' . ($current_pos == 999 ? '~' : '') . '&minus;' . ($current_pos == 999 ? (int) (100 - $previous_pos) : (int) ($current_pos - $previous_pos)) . ')';
                                            }
                                        }
                                        $__icon .= $__iconExtra;
                                        $html[] = '<div class="serp-rank-container">';
                                        $html[] = '<table class="serp-tbody-rank">';
                                        $html[] = '<tbody>';
                                        $html[] = '<tr>';
                                        $html[] = '<td width="57">';
                                        if ($current_pos == 999) {
                                            $html[] = '<div class="psp-rank-container-block-extra">' . $__icon_not100 . '</div>';
                                        } else {
                                            $html[] = '<div class="psp-rank-container-block">';
                                            $html[] = '<span class="the_pos">' . ('#' . $current_pos) . '</span>';
                                            $cur_pos_dir = $previous_pos - $current_pos;
                                            $cur_pos_dir_symbol = '';
                                            if ($cur_pos_dir > 0) {
                                                $cur_pos_dir_symbol = '+';
                                            } elseif ($cur_pos_dir < 0) {
                                                $cur_pos_dir_symbol = '-';
                                            }
                                            $html[] = '<span class="the_status ' . $icon . '">' . $cur_pos_dir_symbol . abs($cur_pos_dir) . '</span>';
                                            $html[] = '</div>';
                                        }
                                        $html[] = '</td>';
                                        $html[] = '<td width="35"><div class="psp-rank-container-block-extra">' . ($best_pos == 999 ? $__icon_not100 : '#' . $best_pos) . '</div></td>';
                                        $html[] = '<td><div class="psp-rank-container-block-extra">' . ($worst_pos == 999 ? $__icon_not100 : '#' . $worst_pos) . '</div></td>';
                                        $html[] = '</tr>';
                                        $html[] = '</tbody>';
                                        $html[] = '</table>';
                                        $html[] = '</div>';
                                    }
                                } else {
                                    if ($value['td'] == '%serp_start_date%') {
                                        $html[] = '<i>' . $post['created'] . '</i>';
                                    } else {
                                        if ($value['td'] == '%serp_visits%') {
                                            $html[] = '<i>' . $post['visits'] . '</i>';
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($this->opt['id'] == 'pspFacebookPlanner') {
                        if ($value['td'] == '%post_id%') {
                            $html[] = $post['id_post'];
                        } elseif ($value['td'] == '%post_name%') {
                            $__postInfo = get_post($post['id_post'], OBJECT);
                            $html[] = '<input type="hidden" id="psp-item-title-' . $post['id'] . '" value="' . str_replace('"', "'", $__postInfo->post_title) . '" />';
                            $html[] = '<a href="' . sprintf(admin_url('post.php?post=%s&action=edit'), $__postInfo->ID) . '">';
                            $html[] = $__postInfo->post_title . ($__postInfo->post_status != 'publish' ? ' <span class="item-state">- ' . ucfirst($__postInfo->post_status) : '</span>');
                            $html[] = '</a>';
                            $html[] = '
							<span class="psp-inline-row-actions show" id="psp-inline-row-actions-' . $post['id'] . '">
								<a href="' . sprintf(admin_url('post.php?post=%s&action=edit'), $__postInfo->ID) . '">Edit</a>
								 | <a href="' . get_permalink($__postInfo->ID) . '" target="_blank">' . __('View', $this->the_plugin->localizationName) . '</a>
							</span>';
                        } else {
                            if ($value['td'] == '%status%') {
                                $__statusVals = array(0 => __("New", $this->the_plugin->localizationName), 1 => __("Finished", $this->the_plugin->localizationName), 2 => __("Running", $this->the_plugin->localizationName), 3 => __("Error", $this->the_plugin->localizationName));
                                $html[] = $__statusVals[$post['status']];
                            } else {
                                if ($value['td'] == '%attempts%') {
                                    $html[] = $post['attempts'];
                                } else {
                                    if ($value['td'] == '%response%') {
                                        $html[] = $post['response'];
                                    } else {
                                        if ($value['td'] == '%post_to%') {
                                            $pg = get_option('psp_fb_planner_user_pages');
                                            if (trim($pg) != "") {
                                                $pg = @json_decode($pg);
                                            }
                                            $post_to = '';
                                            $serialize = $post['post_to'];
                                            $arr = unserialize($serialize);
                                            if (trim($arr['profile']) == 'on') {
                                                $post_to = '- Profile';
                                            }
                                            if (trim($arr['page_group']) != '') {
                                                $page_group = explode('##', $arr['page_group']);
                                                $post_to .= trim($post_to) != '' ? '<br />' : '';
                                                if ($page_group[0] == 'page') {
                                                    foreach ($pg->pages as $k => $v) {
                                                        if ($v->id == $page_group[1]) {
                                                            $post_to_title = $v->name;
                                                        }
                                                    }
                                                } else {
                                                    if ($page_group[0] == 'group') {
                                                        foreach ($pg->groups as $k => $v) {
                                                            if ($v->id == $page_group[1]) {
                                                                $post_to_title = $v->name;
                                                            }
                                                        }
                                                    }
                                                }
                                                $post_to .= "- " . ucfirst($page_group[0]) . ": " . $post_to_title;
                                            }
                                            $html[] = $post_to;
                                        } else {
                                            if ($value['td'] == '%email_at_post%') {
                                                $__statusVals = array('on' => __('ON', $this->the_plugin->localizationName), 'off' => __('OFF', $this->the_plugin->localizationName));
                                                $html[] = $__statusVals[$post['email_at_post']];
                                            } else {
                                                if ($value['td'] == '%repeat_status%') {
                                                    $__statusVals = array('on' => __('ON', $this->the_plugin->localizationName), 'off' => __('OFF', $this->the_plugin->localizationName));
                                                    $html[] = $__statusVals[$post['repeat_status']];
                                                } else {
                                                    if ($value['td'] == '%repeat_interval%') {
                                                        $html[] = $post['repeat_interval'];
                                                    } else {
                                                        if ($value['td'] == '%run_date%') {
                                                            $html[] = $post['run_date'];
                                                        } else {
                                                            if ($value['td'] == '%started_at%') {
                                                                $html[] = $post['started_at'];
                                                            } else {
                                                                if ($value['td'] == '%ended_at%') {
                                                                    $html[] = $post['ended_at'];
                                                                } else {
                                                                    if ($value['td'] == '%post_privacy%') {
                                                                        $__statusVals = array("EVERYONE" => __('Everyone', $this->the_plugin->localizationName), "ALL_FRIENDS" => __('All Friends', $this->the_plugin->localizationName), "NETWORKS_FRIENDS" => __('Networks Friends', $this->the_plugin->localizationName), "FRIENDS_OF_FRIENDS" => __('Friends of Friends', $this->the_plugin->localizationName), "CUSTOM" => __('Private (only me)', $this->the_plugin->localizationName));
                                                                        //$html[] = $__statusVals[ $post['post_privacy'] ];
                                                                        $html[] = $post['post_privacy'];
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $html[] = '</td>';
                }
                $html[] = '</tr>';
            }
            $html[] = '</tbody>';
            $html[] = '';
            $html[] = '</table>';
            if (trim($this->opt["custom_table"]) == "" || $this->opt["custom_table_force_action"]) {
                if (isset($this->opt['mass_actions']) && $this->opt['mass_actions'] === false) {
                    $html[] = '<div class="psp-list-table-left-col" style="padding-top: 5px;">&nbsp;</div>';
                } elseif (isset($this->opt['mass_actions']) && count($this->opt['mass_actions']) > 0) {
                    $html[] = '<div class="psp-list-table-left-col" style="padding-top: 5px;">&nbsp;';
                    foreach ($this->opt['mass_actions'] as $key => $value) {
                        $html[] = '<input type="button" value="' . $value['value'] . '" id="psp-' . $value['action'] . '" class="psp-button ' . $value['color'] . '">';
                    }
                    $html[] = '</div>';
                } else {
                    $html[] = '<div class="psp-list-table-left-col" style="padding-top: 5px;">&nbsp;';
                    $html[] = '<input type="button" value="' . __('Auto detect focus keyword for All', $this->the_plugin->localizationName) . '" id="psp-all-auto-detect-kw" class="psp-button blue">';
                    $html[] = '<input type="button" value="' . __('Optimize All', $this->the_plugin->localizationName) . '" id="psp-all-optimize" class="psp-button blue">';
                    $html[] = '</div>';
                }
                if ($this->opt['id'] == 'pspPageOptimization') {
                    $html[] = '<div id="psp-inline-editpost-boxtpl" style="display: none;">';
                    $html[] = $this->the_plugin->edit_post_inline_boxtpl();
                    $html[] = '</div>';
                }
            } else {
                $html[] = '<div class="psp-list-table-left-col" style="padding-top: 5px;">&nbsp;';
                $html[] = '</div>';
            }
            $html[] = $this->get_pagination();
            $html[] = '</div>';
            echo implode("\n", $html);
            return $this;
        }
示例#3
0
 public function edit_post_inline_data($post_id, $seo = null)
 {
     $post = get_post($post_id, ARRAY_A);
     $post_metas = get_post_meta($post_id, 'psp_meta', true);
     $post_title = $post['post_title'];
     $post_content = $post['post_content'];
     if (is_null($seo) || !is_object($seo)) {
         //use to generate meta keywords, and description for your requested item
         require_once $this->cfg['paths']['scripts_dir_path'] . '/seo-check-class/seo.class.php';
         $seo = pspSeoCheck::getInstance();
     }
     // meta description
     $first_ph = $seo->get_first_paragraph($post_content);
     $gen_meta_desc = $seo->gen_meta_desc($first_ph);
     // meta keywords
     $gen_meta_keywords = array();
     //if ( !empty($post_metas['focus_keyword']) )
     //	$gen_meta_keywords[] = $post_metas['focus_keyword'];
     // focus keyword add to keywords is implemented in js file!
     $__tmp = $seo->gen_meta_keywords($post_content);
     if (!empty($__tmp)) {
         $gen_meta_keywords[] = $__tmp;
     }
     $gen_meta_keywords = implode(', ', $gen_meta_keywords);
     $post_metas['robots_index'] = isset($post_metas['robots_index']) && !empty($post_metas['robots_index']) ? $post_metas['robots_index'] : 'default';
     $post_metas['robots_follow'] = isset($post_metas['robots_follow']) && !empty($post_metas['robots_follow']) ? $post_metas['robots_follow'] : 'default';
     $html = array();
     $html[] = '<div class="psp-post-title">' . $post_title . '</div>';
     $html[] = '<div class="psp-post-gen-desc">' . $gen_meta_desc . '</div>';
     $html[] = '<div class="psp-post-gen-keywords">' . $gen_meta_keywords . '</div>';
     $html[] = '<div class="psp-post-meta-title">' . $post_metas['title'] . '</div>';
     $html[] = '<div class="psp-post-meta-description">' . $post_metas['description'] . '</div>';
     $html[] = '<div class="psp-post-meta-keywords">' . $post_metas['keywords'] . '</div>';
     $html[] = '<div class="psp-post-meta-focus-kw">' . $post_metas['focus_keyword'] . '</div>';
     $html[] = '<div class="psp-post-meta-canonical">' . $post_metas['canonical'] . '</div>';
     $html[] = '<div class="psp-post-meta-robots-index">' . $post_metas['robots_index'] . '</div>';
     $html[] = '<div class="psp-post-meta-robots-follow">' . $post_metas['robots_follow'] . '</div>';
     return implode(PHP_EOL, $html);
 }
示例#4
0
 public function optimize_page($id = "", $kw = "")
 {
     $request = array('action' => isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default', 'id' => isset($_REQUEST['id']) ? $_REQUEST['id'] : $id, 'kw' => isset($_REQUEST['kw']) ? $_REQUEST['kw'] : $kw, 'meta_title' => isset($_REQUEST['psp-editpost-meta-title']) ? trim($_REQUEST['psp-editpost-meta-title']) : '', 'meta_description' => isset($_REQUEST['psp-editpost-meta-description']) ? trim($_REQUEST['psp-editpost-meta-description']) : '', 'meta_keywords' => isset($_REQUEST['psp-editpost-meta-keywords']) ? trim($_REQUEST['psp-editpost-meta-keywords']) : '', 'meta_canonical' => isset($_REQUEST['psp-editpost-meta-canonical']) ? trim($_REQUEST['psp-editpost-meta-canonical']) : '', 'meta_robots_index' => isset($_REQUEST['psp-editpost-meta-robots-index']) ? trim($_REQUEST['psp-editpost-meta-robots-index']) : '', 'meta_robots_follow' => isset($_REQUEST['psp-editpost-meta-robots-follow']) ? trim($_REQUEST['psp-editpost-meta-robots-follow']) : '');
     foreach ($request as $k => $v) {
         if (in_array($k, array('id'))) {
             continue 1;
         }
         $request[$k] = trim($v);
     }
     foreach ($request as $k => $v) {
         if (in_array($k, array('id', 'action', 'meta_title', 'meta_description', 'meta_canonical'))) {
             continue 1;
         }
         $request[$k] = strtolower($v);
         $request[$k] = strip_tags($v);
         $request[$k] = stripslashes($v);
         /*if ( $k == 'kw' )
         		$request[ $k ] = preg_replace('/[^a-zA-Z0-9\s]/', '', $v);*/
     }
     // Step 1, generate meta keywords, and description for your requested item
     $seo = pspSeoCheck::getInstance();
     if ($this->the_plugin->__tax_istax($request['id'])) {
         //taxonomy data!
         $psp_current_taxseo = $this->the_plugin->__tax_get_post_meta(null, $request['id']);
         if (is_null($psp_current_taxseo) || !is_array($psp_current_taxseo)) {
             $psp_current_taxseo = array();
         }
         $post_metas = $this->the_plugin->__tax_get_post_meta($psp_current_taxseo, $request['id'], 'psp_meta');
         $post = $this->the_plugin->__tax_get_post($request['id'], ARRAY_A);
         $post_title = $post['name'];
         $post_content = $post['description'];
     } else {
         $request['id'] = (int) $request['id'];
         $post_metas = get_post_meta($request['id'], 'psp_meta', true);
         $post = get_post($request['id'], ARRAY_A);
         $post_title = $post['post_title'];
         $post_content = $post['post_content'];
     }
     if (!isset($post_metas) || count($post_metas) <= 0 || !is_array($post_metas)) {
         $post_metas = array();
     }
     $post_metas = array_merge(array('title' => '', 'description' => '', 'keywords' => '', 'focus_keyword' => '', 'facebook_isactive' => '', 'facebook_titlu' => '', 'facebook_desc' => '', 'facebook_image' => '', 'facebook_opengraph_type' => '', 'robots_index' => '', 'robots_follow' => '', 'priority' => '', 'canonical' => ''), $post_metas);
     // get info!
     if (!is_null($post) && count($post) > 0) {
         // if post don't have meta, setup the one
         if (!isset($post_metas['focus_keyword']) || trim($post_metas['focus_keyword']) == "") {
             $post_metas['focus_keyword'] = $post_title;
         }
         if (!isset($post_metas['title']) || trim($post_metas['title']) == "") {
             $post_metas['title'] = $post_title;
         }
         if (!isset($post_metas['description']) || trim($post_metas['description']) == "") {
             // meta description
             $first_ph = $seo->get_first_paragraph($post_content);
             $gen_meta_desc = $seo->gen_meta_desc($first_ph);
             $post_metas['description'] = $gen_meta_desc;
         }
         if (!isset($post_metas['keywords']) || trim($post_metas['keywords']) == "") {
             // meta keywords
             $gen_meta_keywords = array();
             if (!empty($post_metas['focus_keyword'])) {
                 $gen_meta_keywords[] = $post_metas['focus_keyword'];
             }
             $__tmp = $seo->gen_meta_keywords($post_content);
             if (!empty($__tmp)) {
                 $gen_meta_keywords[] = $__tmp;
             }
             $post_metas['keywords'] = implode(', ', $gen_meta_keywords);
         }
         if ($request['action'] == 'pspOptimizePage') {
             //ajax request from plugin module!
             if (isset($request['kw']) && trim($request['kw']) != "") {
                 $post_metas['focus_keyword'] = $request['kw'];
             }
         } else {
             if ($request['action'] == 'pspQuickEdit') {
                 //ajax request from plugin module!
                 $post_metas = array_merge($post_metas, array('title' => $request['meta_title'], 'description' => $request['meta_description'], 'keywords' => $request['meta_keywords'], 'focus_keyword' => $request['kw'], 'robots_index' => $request['meta_robots_index'], 'robots_follow' => $request['meta_robots_follow'], 'canonical' => $request['meta_canonical']));
             } else {
                 //new or edit post/tax action - from meta_box!
                 //$__cleanFocusKW = preg_replace('/[^a-zA-Z0-9\s]/', '', $_REQUEST['psp-field-focuskw']); // clean focus keyword
                 $__cleanFocusKW = $_REQUEST['psp-field-focuskw'];
                 // clean focus keyword
                 $post_metas = array_merge($post_metas, array('title' => trim($_REQUEST['psp-field-title']), 'description' => trim($_REQUEST['psp-field-metadesc']), 'keywords' => trim($_REQUEST['psp-field-metakewords']), 'focus_keyword' => trim($__cleanFocusKW), 'facebook_isactive' => trim($_REQUEST['psp-field-facebook-isactive']), 'facebook_titlu' => trim($_REQUEST['psp-field-facebook-titlu']), 'facebook_desc' => trim($_REQUEST['psp-field-facebook-desc']), 'facebook_image' => trim($_REQUEST['psp-field-facebook-image']), 'facebook_opengraph_type' => trim($_REQUEST['psp-field-facebook-opengraph-type']), 'robots_index' => trim($_REQUEST['psp-field-meta_robots_index']), 'robots_follow' => trim($_REQUEST['psp-field-meta_robots_follow']), 'priority' => trim($_REQUEST['psp-field-priority-sitemap']), 'canonical' => trim($_REQUEST['psp-field-canonical'])));
                 if (!$this->the_plugin->__tax_istax($request['id'])) {
                     //not taxonomy data!
                     update_post_meta($request['id'], 'psp_sitemap_isincluded', trim($_REQUEST['psp-field-include-sitemap']));
                 }
             }
         }
         // update post/tax meta data!
         if ($this->the_plugin->__tax_istax($request['id'])) {
             //taxonomy data!
             $this->the_plugin->__tax_update_post_meta($request['id'], array('psp_kw' => $post_metas['focus_keyword'], 'psp_meta' => $post_metas));
         } else {
             update_post_meta($request['id'], 'psp_kw', $post_metas['focus_keyword']);
             update_post_meta($request['id'], 'psp_meta', $post_metas);
         }
         // get SEO score
         $retType = 'array';
         $post_seo_status = $seo->get_seo_score($request['id'], $post_metas['focus_keyword'], $retType);
         $__seo_status = $post_seo_status;
         $this->save_seo_score($request['id'], $__seo_status['data'], $__seo_status['score'], $__seo_status['kw']);
         if ($request['action'] == 'pspQuickEdit' || $request['action'] == 'pspOptimizePage') {
             $__editInline = $this->the_plugin->edit_post_inline_data($request['id'], $seo);
             $post_seo_status = array_merge($post_seo_status, array('status' => 'valid', 'edit_inline_new' => $__editInline));
             die(json_encode($post_seo_status));
         }
         if ($retType == 'array') {
             $post_seo_status = $post_seo_status['data'];
         }
         return $post_seo_status;
     }
 }