File tree Expand file tree Collapse file tree
classes/suggested-tasks/local-tasks/providers/integrations/yoast Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 77
88namespace 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 */
1315class 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.
You can’t perform that action at this time.
0 commit comments