Skip to content
4 changes: 4 additions & 0 deletions src/integrations/admin/indexing-notification-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ protected function should_show_notification() {
if ( ! $this->environment_helper->is_production_mode() ) {
return false;
}
// Do not show optimization notification if the number of unindexed objects is less than 10 or less than 4% of the total objects number.
if ( ! $this->indexing_helper->should_show_optimization_button() ) {
return false;
}
// Don't show a notification if the indexing has already been started earlier.
if ( $this->indexing_helper->get_started() > 0 ) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ public function test_create_notification_no_unindexed_items() {
->expects( 'is_production_mode' )
->andReturn( true );

$this->indexing_helper
->expects( 'should_show_optimization_button' )
->andReturn( true );

$this->indexing_helper
->expects( 'get_started' )
->andReturn( 0 );
Expand Down Expand Up @@ -293,6 +297,11 @@ public function test_create_notification_with_having_indexing_started() {
->expects( 'is_production_mode' )
->andReturn( true );

$this->indexing_helper
->expects( 'should_show_optimization_button' )
->andReturn( true );


$this->indexing_helper
->expects( 'get_started' )
->andReturn( 123456789 );
Expand Down Expand Up @@ -320,6 +329,10 @@ public function test_maybe_create_notification_with_indexing_failed_reason() {
->expects( 'is_production_mode' )
->andReturn( true );

$this->indexing_helper
->expects( 'should_show_optimization_button' )
->andReturn( true );

$this->indexing_helper
->expects( 'get_started' )
->andReturn( 0 );
Expand Down Expand Up @@ -371,6 +384,10 @@ public function test_maybe_create_notification_with_indexing_reasons( $reason )
->expects( 'is_production_mode' )
->andReturn( true );

$this->indexing_helper
->expects( 'should_show_optimization_button' )
->andReturn( true );

$this->indexing_helper
->expects( 'get_started' )
->andReturn( 0 );
Expand Down Expand Up @@ -454,6 +471,10 @@ public function test_maybe_cleanup_notification_when_there_is_something_to_index
->expects( 'is_production_mode' )
->andReturn( true );

$this->indexing_helper
->expects( 'should_show_optimization_button' )
->andReturn( true );

$this->notification_center
->expects( 'get_notification_by_id' )
->once()
Expand Down Expand Up @@ -489,6 +510,11 @@ public function test_maybe_cleanup_notification_when_the_user_has_started_indexi
->expects( 'is_production_mode' )
->andReturn( true );

$this->indexing_helper
->expects( 'should_show_optimization_button' )
->andReturn( true );


$this->notification_center
->expects( 'get_notification_by_id' )
->once()
Expand Down Expand Up @@ -521,6 +547,10 @@ public function test_maybe_cleanup_notification() {
->expects( 'is_production_mode' )
->andReturn( true );

$this->indexing_helper
->expects( 'should_show_optimization_button' )
->andReturn( true );

$this->notification_center
->expects( 'get_notification_by_id' )
->once()
Expand Down Expand Up @@ -556,6 +586,7 @@ public function test_create_notification_no_prod_site() {
->expects( 'is_production_mode' )
->andReturn( false );


$this->notification_center
->expects( 'add_notification' )
->never();
Expand Down