api-calls.php
5 years ago
index.php
5 years ago
logger.php
5 years ago
plugins-themes-sync.php
5 years ago
scheduled-crons.php
11 months ago
scheduled-crons.php
148 lines
| 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 | $is_fs_debug_page = ( isset( $VARS['is_fs_debug_page'] ) && $VARS['is_fs_debug_page'] ); |
| 17 | |
| 18 | $module_types = array( |
| 19 | WP_FS__MODULE_TYPE_PLUGIN, |
| 20 | WP_FS__MODULE_TYPE_THEME |
| 21 | ); |
| 22 | |
| 23 | foreach ( $module_types as $module_type ) { |
| 24 | $modules = fs_get_entities( $fs_options->get_option( $module_type . 's' ), FS_Plugin::get_class_name() ); |
| 25 | if ( is_array( $modules ) && count( $modules ) > 0 ) { |
| 26 | foreach ( $modules as $slug => $data ) { |
| 27 | if ( WP_FS__MODULE_TYPE_THEME === $module_type ) { |
| 28 | $current_theme = wp_get_theme(); |
| 29 | $is_active = ( $current_theme->stylesheet === $data->file ); |
| 30 | } else { |
| 31 | $is_active = is_plugin_active( $data->file ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @author Vova Feldman |
| 36 | * |
| 37 | * @since 1.2.1 Don't load data from inactive modules. |
| 38 | */ |
| 39 | if ( $is_active ) { |
| 40 | $fs = freemius( $data->id ); |
| 41 | |
| 42 | $next_execution = $fs->next_sync_cron(); |
| 43 | $last_execution = $fs->last_sync_cron(); |
| 44 | |
| 45 | if ( false !== $next_execution ) { |
| 46 | $scheduled_crons[ $slug ][] = array( |
| 47 | 'name' => $fs->get_plugin_name(), |
| 48 | 'slug' => $slug, |
| 49 | 'module_type' => $fs->get_module_type(), |
| 50 | 'type' => 'sync_cron', |
| 51 | 'last' => $last_execution, |
| 52 | 'next' => $next_execution, |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | $next_install_execution = $fs->next_install_sync(); |
| 57 | $last_install_execution = $fs->last_install_sync(); |
| 58 | |
| 59 | if (false !== $next_install_execution || |
| 60 | false !== $last_install_execution |
| 61 | ) { |
| 62 | $scheduled_crons[ $slug ][] = array( |
| 63 | 'name' => $fs->get_plugin_name(), |
| 64 | 'slug' => $slug, |
| 65 | 'module_type' => $fs->get_module_type(), |
| 66 | 'type' => 'install_sync', |
| 67 | 'last' => $last_install_execution, |
| 68 | 'next' => $next_install_execution, |
| 69 | ); |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | $sec_text = fs_text_x_inline( 'sec', 'seconds' ); |
| 77 | ?> |
| 78 | <?php if ( $is_fs_debug_page ) : ?> |
| 79 | <h2> |
| 80 | <button class="fs-debug-table-toggle-button" aria-expanded="true"> |
| 81 | <span class="fs-debug-table-toggle-icon">▼</span> |
| 82 | </button> |
| 83 | <?php fs_esc_html_echo_inline( 'Scheduled Crons' ) ?> |
| 84 | </h2> |
| 85 | <?php else : ?> |
| 86 | <h1><?php fs_esc_html_echo_inline( 'Scheduled Crons' ) ?></h1> |
| 87 | <?php endif ?> |
| 88 | <table class="widefat fs-debug-table"> |
| 89 | <thead> |
| 90 | <tr> |
| 91 | <th><?php fs_esc_html_echo_inline( 'Slug' ) ?></th> |
| 92 | <th><?php fs_esc_html_echo_inline( 'Module' ) ?></th> |
| 93 | <th><?php fs_esc_html_echo_inline( 'Module Type' ) ?></th> |
| 94 | <th><?php fs_esc_html_echo_inline( 'Cron Type' ) ?></th> |
| 95 | <th><?php fs_esc_html_echo_inline( 'Last' ) ?></th> |
| 96 | <th><?php fs_esc_html_echo_inline( 'Next' ) ?></th> |
| 97 | </tr> |
| 98 | </thead> |
| 99 | <tbody> |
| 100 | <?php |
| 101 | /* translators: %s: time period (e.g. In "2 hours") */ |
| 102 | $in_x_text = fs_text_inline( 'In %s', 'in-x' ); |
| 103 | /* translators: %s: time period (e.g. "2 hours" ago) */ |
| 104 | $x_ago_text = fs_text_inline( '%s ago', 'x-ago' ); |
| 105 | ?> |
| 106 | <?php foreach ( $scheduled_crons as $slug => $crons ) : ?> |
| 107 | <?php foreach ( $crons as $cron ) : ?> |
| 108 | <tr> |
| 109 | <td><?php echo $slug ?></td> |
| 110 | <td><?php echo $cron['name'] ?></td> |
| 111 | <td><?php echo $cron['module_type'] ?></td> |
| 112 | <td><?php echo $cron['type'] ?></td> |
| 113 | <td><?php |
| 114 | if ( is_numeric( $cron['last'] ) ) { |
| 115 | $diff = abs( WP_FS__SCRIPT_START_TIME - $cron['last'] ); |
| 116 | $human_diff = ( $diff < MINUTE_IN_SECONDS ) ? |
| 117 | $diff . ' ' . $sec_text : |
| 118 | human_time_diff( WP_FS__SCRIPT_START_TIME, $cron['last'] ); |
| 119 | |
| 120 | echo esc_html( sprintf( |
| 121 | ( ( WP_FS__SCRIPT_START_TIME < $cron['last'] ) ? |
| 122 | $in_x_text : |
| 123 | $x_ago_text ), |
| 124 | $human_diff |
| 125 | ) ); |
| 126 | } |
| 127 | ?></td> |
| 128 | <td><?php |
| 129 | if ( is_numeric( $cron['next'] ) ) { |
| 130 | $diff = abs( WP_FS__SCRIPT_START_TIME - $cron['next'] ); |
| 131 | $human_diff = ( $diff < MINUTE_IN_SECONDS ) ? |
| 132 | $diff . ' ' . $sec_text : |
| 133 | human_time_diff( WP_FS__SCRIPT_START_TIME, $cron['next'] ); |
| 134 | |
| 135 | echo esc_html( sprintf( |
| 136 | ( ( WP_FS__SCRIPT_START_TIME < $cron['next'] ) ? |
| 137 | $in_x_text : |
| 138 | $x_ago_text ), |
| 139 | $human_diff |
| 140 | ) ); |
| 141 | } |
| 142 | ?></td> |
| 143 | </tr> |
| 144 | <?php endforeach ?> |
| 145 | <?php endforeach ?> |
| 146 | </tbody> |
| 147 | </table> |
| 148 |