← All changes
|
inc/freemius/templates/debug/scheduled-crons.php
+147
-136
4.2.13
→
4.3.17
View file →
| @@ -1,136 +1,147 @@ | ||
| 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> | |
| 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> | |