File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
classes/suggested-tasks/providers Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,11 @@ public function should_add_task() {
120120 public function print_popover_instructions () {
121121 $ detected_date_format = $ this ->get_date_format_type ();
122122
123+ if ( ! \function_exists ( 'wp_get_available_translations ' ) ) {
124+ // @phpstan-ignore-next-line requireOnce.fileNotFound
125+ require_once ABSPATH . 'wp-admin/includes/translation-install.php ' ;
126+ }
127+
123128 // Get the site default language name.
124129 $ available_languages = \wp_get_available_translations ();
125130 $ site_locale = \get_locale ();
Original file line number Diff line number Diff line change @@ -164,6 +164,11 @@ protected function get_allowed_interactive_options() {
164164 * @return void
165165 */
166166 public function add_popover () {
167+
168+ // Don't add the popover if the task is not published.
169+ if ( ! $ this ->is_task_published () ) {
170+ return ;
171+ }
167172 ?>
168173 <div id="prpl-popover-<?php echo \esc_attr ( static ::POPOVER_ID ); ?> " class="prpl-popover prpl-popover-interactive" popover>
169174 <?php $ this ->the_popover_content (); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
@@ -256,6 +261,11 @@ public function enqueue_scripts( $hook ) {
256261 return ;
257262 }
258263
264+ // Don't enqueue the script if the task is not published.
265+ if ( ! $ this ->is_task_published () ) {
266+ return ;
267+ }
268+
259269 // Enqueue the web component.
260270 \progress_planner ()->get_admin__enqueue ()->enqueue_script (
261271 'progress-planner/recommendations/ ' . $ this ->get_provider_id (),
@@ -271,4 +281,19 @@ public function enqueue_scripts( $hook ) {
271281 protected function get_enqueue_data () {
272282 return [];
273283 }
284+
285+ /**
286+ * Check if the task is published.
287+ *
288+ * @return bool
289+ */
290+ public function is_task_published () {
291+ $ tasks = \progress_planner ()->get_suggested_tasks_db ()->get_tasks_by (
292+ [
293+ 'provider ' => $ this ->get_provider_id (),
294+ 'post_status ' => 'publish ' ,
295+ ]
296+ );
297+ return ! empty ( $ tasks );
298+ }
274299}
You can’t perform that action at this time.
0 commit comments