Skip to content

Commit 2c12dbc

Browse files
Merge pull request #183 from xylusthemes/adde_cron_check_notice
added schedule working or not message
2 parents b29210b + c15a743 commit 2c12dbc

3 files changed

Lines changed: 107 additions & 70 deletions

File tree

assets/css/wizard.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,10 @@ button.ife-wizard-back-button:hover, button.ife-wizard-back-button:hover svg pat
196196

197197
.ife-wizard-wrap .ife-wizard-starter-video a:hover svg path, button.ife-wizard-import-box:hover svg path, button.ife-wizard-open-popup:hover svg path{
198198
fill: #0049b3;
199+
}
200+
.notice {
201+
display: none;
202+
}
203+
.ife_notice {
204+
display: block;
199205
}

includes/class-import-facebook-events-admin.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function __construct() {
5050
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
5151
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
5252
add_action( 'admin_action_ife_view_import_history', array( $this, 'ife_view_import_history_handler' ) );
53+
add_action( 'admin_init', array( $this, 'ife_wp_cron_check' ) );
5354
}
5455

5556
/**
@@ -104,6 +105,32 @@ public function enqueue_admin_scripts( $hook ) {
104105
wp_enqueue_script( 'ife-wizard-js' );
105106
}
106107
}
108+
109+
/**
110+
* Check if WP-Cron is enabled
111+
*
112+
* Checks if WP-Cron is enabled and if the current page is the scheduled imports page.
113+
* If WP-Cron is disabled, it will display an error message.
114+
*
115+
* @since 1.0
116+
* @return void
117+
*/
118+
public function ife_wp_cron_check() {
119+
global $ife_errors;
120+
121+
if ( ! is_admin() || empty($_GET['page']) || empty($_GET['tab']) || $_GET['page'] !== 'facebook_import' || $_GET['tab'] !== 'scheduled' ) {
122+
return;
123+
}
124+
125+
if ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) {
126+
$ife_errors[] = __(
127+
'<strong>Scheduled imports are paused.</strong> WP-Cron is currently disabled on your site, so Facebook scheduled imports will not run automatically. Please enable WP-Cron or set up a server cron job to keep imports running smoothly.',
128+
'import-facebook-events'
129+
);
130+
131+
}
132+
}
133+
107134

108135
/**
109136
* Load Admin Styles.
@@ -281,7 +308,7 @@ public function display_notices() {
281308
if ( ! empty( $ife_errors ) ) {
282309
foreach ( $ife_errors as $error ) :
283310
?>
284-
<div class="notice notice-error is-dismissible">
311+
<div class="notice notice-error ife_notice is-dismissible">
285312
<p><?php echo wp_kses_post( $error ); ?></p>
286313
</div>
287314
<?php
@@ -291,7 +318,7 @@ public function display_notices() {
291318
if ( ! empty( $ife_success_msg ) ) {
292319
foreach ( $ife_success_msg as $success ) :
293320
?>
294-
<div class="notice notice-success is-dismissible">
321+
<div class="notice notice-success ife_notice is-dismissible">
295322
<p><?php echo wp_kses_post( $success ); ?></p>
296323
</div>
297324
<?php
@@ -301,7 +328,7 @@ public function display_notices() {
301328
if ( ! empty( $ife_warnings ) ) {
302329
foreach ( $ife_warnings as $warning ) :
303330
?>
304-
<div class="notice notice-warning is-dismissible">
331+
<div class="notice notice-warning ife_notice is-dismissible">
305332
<p><?php echo wp_kses_post( $warning ); ?></p>
306333
</div>
307334
<?php
@@ -311,7 +338,7 @@ public function display_notices() {
311338
if ( ! empty( $ife_info_msg ) ) {
312339
foreach ( $ife_info_msg as $info ) :
313340
?>
314-
<div class="notice notice-info is-dismissible">
341+
<div class="notice notice-info ife_notice is-dismissible">
315342
<p><?php echo wp_kses_post( $info ); ?></p>
316343
</div>
317344
<?php

0 commit comments

Comments
 (0)