本文整理匯總了PHP中BigTree::colorMesh方法的典型用法代碼示例。如果您正苦於以下問題:PHP BigTree::colorMesh方法的具體用法?PHP BigTree::colorMesh怎麽用?PHP BigTree::colorMesh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BigTree
的用法示例。
在下文中一共展示了BigTree::colorMesh方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getPageSEORating
//.........這裏部分代碼省略.........
}
// Check for meta description
if ($page["meta_description"]) {
$score += 5;
// They have a meta description, let's see if it's no more than 165 characters.
if (mb_strlen($page["meta_description"]) <= 165) {
$score += 5;
} else {
$recommendations[] = "Your meta description should be no more than 165 characters. It is currently " . mb_strlen($page["meta_description"]) . " characters.";
}
} else {
$recommendations[] = "You should enter a meta description.";
}
// Check for an H1
if (!$h1_field || $content[$h1_field]) {
$score += 10;
} else {
$recommendations[] = "You should enter a page header.";
}
// Check the content!
if (!count($body_fields)) {
// If this template doesn't for some reason have a seo body resource, give the benefit of the doubt.
$score += 65;
} else {
$regular_text = "";
$stripped_text = "";
foreach ($body_fields as $field) {
if (!is_array($content[$field])) {
$regular_text .= $content[$field] . " ";
$stripped_text .= strip_tags($content[$field]) . " ";
}
}
// Check to see if there is any content
if ($stripped_text) {
$score += 5;
$words = $textStats->word_count($stripped_text);
$readability = $textStats->flesch_kincaid_reading_ease($stripped_text);
if ($readability < 0) {
$readability = 0;
}
$number_of_links = substr_count($regular_text, "<a ");
$number_of_external_links = substr_count($regular_text, 'href="http://');
// See if there are at least 300 words.
if ($words >= 300) {
$score += 15;
} else {
$recommendations[] = "You should enter at least 300 words of page content. You currently have " . $words . " word(s).";
}
// See if we have any links
if ($number_of_links) {
$score += 5;
// See if we have at least one link per 120 words.
if (floor($words / 120) <= $number_of_links) {
$score += 5;
} else {
$recommendations[] = "You should have at least one link for every 120 words of page content. You currently have {$number_of_links} link(s). You should have at least " . floor($words / 120) . ".";
}
// See if we have any external links.
if ($number_of_external_links) {
$score += 5;
} else {
$recommendations[] = "Having an external link helps build Page Rank.";
}
} else {
$recommendations[] = "You should have at least one link in your content.";
}
// Check on our readability score.
if ($readability >= 90) {
$score += 20;
} else {
$read_score = round($readability / 90, 2);
$recommendations[] = "Your readability score is " . $read_score * 100 . "%. Using shorter sentences and words with fewer syllables will make your site easier to read by search engines and users.";
$score += ceil($read_score * 20);
}
} else {
$recommendations[] = "You should enter page content.";
}
// Check page freshness
$updated = strtotime($page["updated_at"]);
$age = time() - $updated - 60 * 24 * 60 * 60;
// See how much older it is than 2 months.
if ($age > 0) {
$age_score = 10 - floor(2 * ($age / (30 * 24 * 60 * 60)));
if ($age_score < 0) {
$age_score = 0;
}
$score += $age_score;
$recommendations[] = "Your content is around " . ceil(2 + $age / (30 * 24 * 60 * 60)) . " months old. Updating your page more frequently will make it rank higher.";
} else {
$score += 10;
}
}
$color = "#008000";
if ($score <= 50) {
$color = BigTree::colorMesh("#CCAC00", "#FF0000", 100 - 100 * $score / 50);
} elseif ($score <= 80) {
$color = BigTree::colorMesh("#008000", "#CCAC00", 100 - 100 * ($score - 50) / 30);
}
return array("score" => $score, "recommendations" => $recommendations, "color" => $color);
}