Skip to content

Commit

Permalink
ss5 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jellygnite committed Nov 3, 2024
1 parent c5a25fe commit 5e888ce
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"keywords": ["silverstripe", "seo", "facebook", "twitter", "opengraph", "search", "optimization", "optimisation"],
"license": "BSD-3-Clause",
"require": {
"silverstripe/cms": "^4.1",
"jonom/silverstripe-text-target-length": "^2",
"wilr/silverstripe-googlesitemaps": "^2.1",
"kub-at/php-simple-html-dom-parser": "^1.7",
"axllent/silverstripe-trailing-slash": "^2.1"
"silverstripe/framework": "^5.0",
"silverstripe/admin": "^2.0",
"jonom/silverstripe-text-target-length": "^2",
"wilr/silverstripe-googlesitemaps": "^3.1",
"kub-at/php-simple-html-dom-parser": "^1.9",
"axllent/silverstripe-trailing-slash": "^2.2"
},
"autoload": {
"psr-4": {
Expand All @@ -21,7 +22,7 @@
"client/dist"
],
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "5.x-dev"
}
},
"minimum-stability": "dev",
Expand Down
4 changes: 2 additions & 2 deletions src/Analysis/FocusKeywordContentAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public function getContentFromDom()
{
$dom = $this->getPage()->getRenderedHtmlDomParser();
$result = $dom->find(PageSeoExtension::config()->get('content_holder'), 0);
return strtolower(strip_tags($result ? $result->innertext() : ''));
return strtolower(strip_tags($result ? $result->innertext() : '')?? '');
}

/**
* @return string
*/
public function getKeyword()
{
return strtolower($this->getPage()->FocusKeyword);
return strtolower($this->getPage()->FocusKeyword ?? '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analysis/FocusKeywordUniqueAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FocusKeywordUniqueAnalysis extends Analysis
*/
public function getKeyword()
{
return strtolower($this->getPage()->FocusKeyword);
return strtolower($this->getPage()->FocusKeyword ?? '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analysis/FocusKeywordUrlAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FocusKeywordUrlAnalysis extends Analysis
*/
public function getKeyword()
{
return strtolower($this->getPage()->FocusKeyword);
return strtolower($this->getPage()->FocusKeyword ?? '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Analysis/MetaDescAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function run()
return static::META_DESC_TOO_LONG;
}

if ($keyword && !strstr(strtolower($desc), strtolower($keyword))) {
if ($keyword && !strstr(strtolower($desc ?? ''), strtolower($keyword ?? ''))) {
return static::META_DESC_NO_FOCUS_KEYWORD;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Analysis/TitleAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public function run()
return static::TITLE_TOO_LONG;
}

if ($keyword && !strstr(strtolower($title), strtolower($keyword))) {
if ($keyword && !strstr(strtolower($title ?? ''), strtolower($keyword ?? ''))) {
return static::TITLE_NO_FOCUS_KEYWORD;
}

if ($keyword && strtolower(substr($title, 0, strlen($keyword))) !== strtolower($keyword)) {
if ($keyword && strtolower(substr($title, 0, strlen($keyword)) ?? '') !== strtolower($keyword ?? '')) {
return static::TITLE_FOCUS_KEYWORD_POSITION;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Analysis/WordCountAnalysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class WordCountAnalysis extends Analysis
*/
public function getWordCount()
{
$content = strtolower(strip_tags($this->getContentFromDom()));
$content = strtolower(strip_tags($this->getContentFromDom()) ?? '');
return str_word_count($content);
//return count(array_filter(explode(' ', $content )));
}
Expand All @@ -31,7 +31,7 @@ public function getContentFromDom()

$result = $dom->find(PageSeoExtension::config()->get('content_holder'), 0);

return strtolower(strip_tags($result ? $result->innertext() : ''));
return strtolower(strip_tags($result ? $result->innertext() : '') ?? '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function collateContentFields($owner)

$content = implode(' ', $content);

return strtolower(strip_tags($content));
return strtolower(strip_tags($content)?? '');
}

/**
Expand Down

0 comments on commit 5e888ce

Please sign in to comment.