PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.35
Code Manager v1.0.35
1.0.48 1.0.47 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.3 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.4 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
code-manager / freemius / templates / debug / scheduled-crons.php
code-manager / freemius / templates / debug Last commit date
api-calls.php 2 years ago index.php 2 years ago logger.php 2 years ago plugins-themes-sync.php 2 years ago scheduled-crons.php 2 years ago
scheduled-crons.php
137 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 $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