Skip to content

Commit 0f5d8b4

Browse files
authored
Merge pull request #414 from ProgressPlanner/filip/author-feed-tweak
Yoast SEO tasks tweaks
2 parents fb7c007 + 388138e commit 0f5d8b4

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

classes/suggested-tasks/local-tasks/providers/integrations/yoast/class-add-yoast-providers.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ public function enqueue_assets( $hook ) {
4545
$focus_tasks = [];
4646

4747
foreach ( $this->providers as $provider ) {
48-
$focus_task = $provider->get_focus_tasks();
4948

50-
if ( $focus_task ) {
51-
$focus_tasks[] = $focus_task;
49+
// Add Ravi icon if the task is pending or completed.
50+
if ( $provider->should_add_task() ) {
51+
$focus_task = $provider->get_focus_tasks();
52+
53+
if ( $focus_task ) {
54+
$focus_tasks[] = $focus_task;
55+
}
5256
}
5357
}
5458

classes/suggested-tasks/local-tasks/providers/integrations/yoast/class-crawl-settings-feed-authors.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,40 @@
77

88
namespace Progress_Planner\Suggested_Tasks\Local_Tasks\Providers\Integrations\Yoast;
99

10+
use Progress_Planner\Suggested_Tasks\Data_Collector\Post_Author;
11+
1012
/**
1113
* Add task for Yoast SEO: Remove post authors feeds.
1214
*/
1315
class Crawl_Settings_Feed_Authors extends Yoast_Provider {
1416

17+
/**
18+
* The minimum number of posts with a post format to add the task.
19+
*
20+
* @var int
21+
*/
22+
protected const MINIMUM_AUTHOR_WITH_POSTS = 1;
23+
1524
/**
1625
* The provider ID.
1726
*
1827
* @var string
1928
*/
2029
protected const PROVIDER_ID = 'yoast-crawl-settings-feed-authors';
2130

31+
/**
32+
* The data collector.
33+
*
34+
* @var \Progress_Planner\Suggested_Tasks\Data_Collector\Post_Author
35+
*/
36+
protected $data_collector;
37+
2238
/**
2339
* Constructor.
2440
*/
2541
public function __construct() {
26-
$this->url = \admin_url( 'admin.php?page=wpseo_page_settings#/crawl-optimization#input-wpseo-remove_feed_authors' );
42+
$this->data_collector = new Post_Author();
43+
$this->url = \admin_url( 'admin.php?page=wpseo_page_settings#/crawl-optimization#input-wpseo-remove_feed_authors' );
2744
}
2845

2946
/**
@@ -71,6 +88,11 @@ public function get_focus_tasks() {
7188
* @return bool
7289
*/
7390
public function should_add_task() {
91+
// If there is more than one author, we don't need to add the task.
92+
if ( $this->data_collector->collect() > self::MINIMUM_AUTHOR_WITH_POSTS ) {
93+
return false;
94+
}
95+
7496
$yoast_options = \WPSEO_Options::get_instance()->get_all();
7597
foreach ( [ 'remove_feed_authors' ] as $option ) {
7698
// If the crawl settings are already optimized, we don't need to add the task.

0 commit comments

Comments
 (0)