当前位置: 首页>>代码示例>>PHP>>正文


PHP BigTree::colorMesh方法代码示例

本文整理汇总了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);
 }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:101,代码来源:admin.php


注:本文中的BigTree::colorMesh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。