?> " value="<?php echo $this->density; ?> " size="25" /> </div> <?php } else { ?> <div class="right-info wdf-normal"> <span class="unit"><?php echo __('WDF', 'wtb_seo'); ?> </span> <span class="number"><?php echo wtb_seo_helper::formatNumber($this->wdf); ?> %</span> <input type="hidden" name="<?php echo $this->getInfoKey('wdf'); ?> " value="<?php echo $this->score; ?> " /> </div> <?php } ?> </div>
/** * calc section params by keyword * @param string $keyword * @return array */ protected function calcParams($keyword) { $params = array('title' => 0, 'h1' => 0, 'h2' => 0, 'h3' => 0, 'bold' => 0, 'italic' => 0, 'underline' => 0, 'alt' => 0); $title = wtb_seo_helper::strtolower($this->post['title']); $content = $this->post['content']; $html = str_get_html($content); // h1 if (strpos($title, $keyword) !== false) { $params['h1'] = 1; } if ($html) { foreach ($html->find('h1') as $h1) { if (strpos($h1->plaintext, $keyword) !== false) { $params['h1'] = 1; break; } } // h2 foreach ($html->find('h2') as $h2) { if (strpos($h2->plaintext, $keyword) !== false) { $params['h2'] = 1; break; } } // h3 foreach ($html->find('h3') as $h3) { if (strpos($h3->plaintext, $keyword) !== false) { $params['h3'] = 1; break; } } // bold foreach ($html->find('strong') as $strong) { if (strpos($strong->plaintext, $keyword) !== false) { $params['bold'] = 1; break; } } foreach ($html->find('b') as $strong) { if (strpos($strong->plaintext, $keyword) !== false) { $params['bold'] = 1; break; } } // italic foreach ($html->find('i') as $strong) { if (strpos($strong->plaintext, $keyword) !== false) { $params['italic'] = 1; break; } } foreach ($html->find('em') as $strong) { if (strpos($strong->plaintext, $keyword) !== false) { $params['italic'] = 1; break; } } // underline foreach ($html->find('u') as $strong) { if (strpos($strong->plaintext, $keyword) !== false) { $params['underline'] = 1; break; } } foreach ($html->find('span') as $strong) { if (strpos($strong->__toString(), 'text-decoration: underline') !== false and strpos($strong->plaintext, $keyword) !== false) { $params['underline'] = 1; break; } } // img alt foreach ($html->find('img') as $img) { // because bug on vendor lib $imgAsString = $img->__toString(); if (strpos($imgAsString, $keyword) !== false and strpos($imgAsString, $keyword, (int) strpos($imgAsString, ' alt=')) > (int) strpos($imgAsString, ' alt=')) { $params['alt'] = 1; break; } } } // title $post = wp_get_post_autosave($this->post['id']); if (!$post) { $post = get_post($this->post['id']); } // try to simulate wp_title() if (isset($post->post_title)) { $metaTitle = apply_filters('single_post_title', $this->post['title'], $post); } else { $metaTitle = apply_filters('single_post_title', $this->post['title']); } $t_sep = '%WP_TITILE_SEP%'; $prefix = ''; if (!empty($metaTitle)) { $prefix = " | "; } $title_array = explode($t_sep, $metaTitle); $title_array = array_reverse($title_array); $metaTitle = implode(" | ", $title_array) . $prefix; $metaTitle = apply_filters('wp_title', $metaTitle, '|', 'right'); if (strpos(wtb_seo_helper::strtolower($metaTitle), $keyword) !== false) { $params['title'] = 1; } return $params; }
?> </table> <?php $score = 0; if (count($this->_sections) > 0) { foreach ($this->_sections as $sect) { $score += $sect->score; } $score /= count($this->_sections); } ?> <div class="main-info"> <div class="<?php echo $this->getScoreColor($score); ?> "> <span class="unit"><?php echo __('Total score', 'wtb_seo'); ?> </span> <span class="number"><?php echo wtb_seo_helper::formatNumber($score); ?> %</span> </div> </div> </div> </div>