| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Freemius |
| 4 |
* @copyright Copyright (c) 2015, Freemius, Inc. |
| 5 |
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 |
| 6 |
* @since 1.1.7.3 |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
$fs_options = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true ); |
| 14 |
$scheduled_crons = array(); |
| 15 |
|
| 16 |
$module_types = array( |
| 17 |
WP_FS__MODULE_TYPE_PLUGIN, |
| 18 |
WP_FS__MODULE_TYPE_THEME |
| 19 |
); |
| 20 |
|
| 21 |
foreach ( $module_types as $module_type ) { |
| 22 |
$modules = fs_get_entities( $fs_options->get_option( $module_type . 's' ), FS_Plugin::get_class_name() ); |
| 23 |
if ( is_array( $modules ) && count( $modules ) > 0 ) { |
| 24 |
foreach ( $modules as $slug => $data ) { |
| 25 |
if ( WP_FS__MODULE_TYPE_THEME === $module_type ) { |
| 26 |
$current_theme = wp_get_theme(); |
| 27 |
$is_active = ( $current_theme->stylesheet === $data->file ); |
| 28 |
} else { |
| 29 |
$is_active = is_plugin_active( $data->file ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* @author Vova Feldman |
| 34 |
* |
| 35 |
* @since 1.2.1 Don't load data from inactive modules. |
| 36 |
*/ |
| 37 |
if ( $is_active ) { |
| 38 |
$fs = freemius( $data->id ); |
| 39 |
|
| 40 |
$next_execution = $fs->next_sync_cron(); |
| 41 |
$last_execution = $fs->last_sync_cron(); |
| 42 |
|
| 43 |
if ( false !== $next_execution ) { |
| 44 |
$scheduled_crons[ $slug ][] = array( |
| 45 |
'name' => $fs->get_plugin_name(), |
| 46 |
'slug' => $slug, |
| 47 |
'module_type' => $fs->get_module_type(), |
| 48 |
'type' => 'sync_cron', |
| 49 |
'last' => $last_execution, |
| 50 |
'next' => $next_execution, |
| 51 |
); |
| 52 |
} |
| 53 |
|
| 54 |
$next_install_execution = $fs->next_install_sync(); |
| 55 |
$last_install_execution = $fs->last_install_sync(); |
| 56 |
|
| 57 |
if (false !== $next_install_execution || |
| 58 |
false !== $last_install_execution |
| 59 |
) { |
| 60 |
$scheduled_crons[ $slug ][] = array( |
| 61 |
'name' => $fs->get_plugin_name(), |
| 62 |
'slug' => $slug, |
| 63 |
'module_type' => $fs->get_module_type(), |
| 64 |
'type' => 'install_sync', |
| 65 |
'last' => $last_install_execution, |
| 66 |
'next' => $next_install_execution, |
| 67 |
); |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
$sec_text = fs_text_x_inline( 'sec', 'seconds' ); |
| 75 |
?> |
| 76 |
<h1><?php fs_esc_html_echo_inline( 'Scheduled Crons' ) ?></h1> |
| 77 |
<table class="widefat"> |
| 78 |
<thead> |
| 79 |
<tr> |
| 80 |
<th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th> |
| 81 |
<th><?php fs_esc_html_echo_inline( 'Module' ) ?></th> |
| 82 |
<th><?php fs_esc_html_echo_inline( 'Module Type' ) ?></th> |
| 83 |
<th><?php fs_esc_html_echo_inline( 'Cron Type' ) ?></th> |
| 84 |
<th><?php fs_esc_html_echo_inline( 'Last' ) ?></th> |
| 85 |
<th><?php fs_esc_html_echo_inline( 'Next' ) ?></th> |
| 86 |
</tr> |
| 87 |
</thead> |
| 88 |
<tbody> |
| 89 |
<?php |
| 90 |
/* translators: %s: time period (e.g. In "2 hours") */ |
| 91 |
$in_x_text = fs_text_inline( 'In %s', 'in-x' ); |
| 92 |
/* translators: %s: time period (e.g. "2 hours" ago) */ |
| 93 |
$x_ago_text = fs_text_inline( '%s ago', 'x-ago' ); |
| 94 |
?> |
| 95 |
<?php foreach ( $scheduled_crons as $slug => $crons ) : ?> |
| 96 |
<?php foreach ( $crons as $cron ) : ?> |
| 97 |
<tr> |
| 98 |
<td><?php echo $slug ?></td> |
| 99 |
<td><?php echo $cron['name'] ?></td> |
| 100 |
<td><?php echo $cron['module_type'] ?></td> |
| 101 |
<td><?php echo $cron['type'] ?></td> |
| 102 |
<td><?php |
| 103 |
if ( is_numeric( $cron['last'] ) ) { |
| 104 |
$diff = abs( WP_FS__SCRIPT_START_TIME - $cron['last'] ); |
| 105 |
$human_diff = ( $diff < MINUTE_IN_SECONDS ) ? |
| 106 |
$diff . ' ' . $sec_text : |
| 107 |
human_time_diff( WP_FS__SCRIPT_START_TIME, $cron['last'] ); |
| 108 |
|
| 109 |
echo esc_html( sprintf( |
| 110 |
( ( WP_FS__SCRIPT_START_TIME < $cron['last'] ) ? |
| 111 |
$in_x_text : |
| 112 |
$x_ago_text ), |
| 113 |
$human_diff |
| 114 |
) ); |
| 115 |
} |
| 116 |
?></td> |
| 117 |
<td><?php |
| 118 |
if ( is_numeric( $cron['next'] ) ) { |
| 119 |
$diff = abs( WP_FS__SCRIPT_START_TIME - $cron['next'] ); |
| 120 |
$human_diff = ( $diff < MINUTE_IN_SECONDS ) ? |
| 121 |
$diff . ' ' . $sec_text : |
| 122 |
human_time_diff( WP_FS__SCRIPT_START_TIME, $cron['next'] ); |
| 123 |
|
| 124 |
echo esc_html( sprintf( |
| 125 |
( ( WP_FS__SCRIPT_START_TIME < $cron['next'] ) ? |
| 126 |
$in_x_text : |
| 127 |
$x_ago_text ), |
| 128 |
$human_diff |
| 129 |
) ); |
| 130 |
} |
| 131 |
?></td> |
| 132 |
</tr> |
| 133 |
<?php endforeach ?> |
| 134 |
<?php endforeach ?> |
| 135 |
</tbody> |
| 136 |
</table> |
| 137 |
|