Skip to content

Commit 71b8382

Browse files
committed
update the conditions
1 parent 8496e23 commit 71b8382

2 files changed

Lines changed: 28 additions & 15 deletions

File tree

classes/suggested-tasks/providers/class-improve-pdf-handling.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,21 @@ public function init() {
8585
* @return bool
8686
*/
8787
public function should_add_task() {
88-
// Detect if there are more than 10 PDF files.
89-
$query = new \WP_Query(
90-
[
91-
'post_type' => 'attachment',
92-
'post_mime_type' => 'application/pdf',
93-
'post_status' => 'publish',
94-
'posts_per_page' => static::MIN_PDF_FILES + 1, // We want to get at least 11 PDF files to be sure we have enough.
95-
'fields' => 'ids',
96-
]
97-
);
98-
$pdf_files_count = $query->found_posts;
88+
$pdf_files_count = \progress_planner()->get_utils__cache()->get( 'pdf_files_count' );
89+
if ( false === $pdf_files_count ) {
90+
// Detect if there are more than 10 PDF files.
91+
$query = new \WP_Query(
92+
[
93+
'post_type' => 'attachment',
94+
'post_mime_type' => 'application/pdf',
95+
'post_status' => 'publish',
96+
'posts_per_page' => static::MIN_PDF_FILES + 1, // We want to get at least 11 PDF files to be sure we have enough.
97+
'fields' => 'ids',
98+
]
99+
);
100+
$pdf_files_count = $query->found_posts;
101+
\progress_planner()->get_utils__cache()->set( 'pdf_count', $pdf_files_count, DAY_IN_SECONDS );
102+
}
99103

100104
return static::MIN_PDF_FILES < $pdf_files_count;
101105
}

views/popovers/improve-pdf-handling.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,19 @@
3131
</p>
3232

3333
<div class="prpl-steps-nav-wrapper">
34-
<button class="prpl-button prpl-button-step" data-action="showPdfXmlSitemapStep">
35-
<?php /* translators: %s is a forward arrow icon. */ ?>
36-
<?php \printf( \esc_html__( 'Next step %s', 'progress-planner' ), '<span class="dashicons dashicons-arrow-right-alt2"></span>' ); ?>
37-
</button>
34+
<?php /* If the user has the necessary permissions and Yoast SEO is active, but PDF Library is not activated, show the next step button. */ ?>
35+
<?php
36+
if ( ! \is_multisite() && \current_user_can( 'install_plugins' )
37+
&& \progress_planner()->get_plugin_installer()->is_plugin_activated( 'wordpress-seo' )
38+
&& ! \progress_planner()->get_plugin_installer()->is_plugin_activated( 'pdf-library' ) ) :
39+
?>
40+
<button class="prpl-button prpl-button-step" data-action="showPdfXmlSitemapStep">
41+
<?php /* translators: %s is a forward arrow icon. */ ?>
42+
<?php \printf( \esc_html__( 'Next step %s', 'progress-planner' ), '<span class="dashicons dashicons-arrow-right-alt2"></span>' ); ?>
43+
</button>
44+
<?php else : ?>
45+
<button class="prpl-button prpl-button-step" data-action="completeTask"><?php \esc_html_e( 'Collect your point!', 'progress-planner' ); ?></button>
46+
<?php endif; ?>
3847
</div>
3948
</div>
4049
</div>

0 commit comments

Comments
 (0)