PluginProbe
WANotifier for Forms and Actions / 1.0.3
WANotifier for Forms and Actions v1.0.3
3.1.1 3.1.0 3.0.4 2.7.10 2.7.11 2.7.12 2.7.13 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 3.0.0 3.0.1 3.0.2 3.0.3 trunk 0.1.0 0.1.1 1.0.0 1.0.1 1.0.2 All 67 releases
notifier / libraries / action-scheduler / classes / ActionScheduler_AdminView.php

ActionScheduler_AdminView.php in WANotifier for Forms and Actions 1.0.3, at libraries/action-scheduler/classes/ActionScheduler_AdminView.php

155 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class ActionScheduler_AdminView
5 * @codeCoverageIgnore
6 */
7 class ActionScheduler_AdminView extends ActionScheduler_AdminView_Deprecated {
8
9 private static $admin_view = NULL;
10
11 private static $screen_id = 'tools_page_action-scheduler';
12
13 /** @var ActionScheduler_ListTable */
14 protected $list_table;
15
16 /**
17 * @return ActionScheduler_AdminView
18 * @codeCoverageIgnore
19 */
20 public static function instance() {
21
22 if ( empty( self::$admin_view ) ) {
23 $class = apply_filters('action_scheduler_admin_view_class', 'ActionScheduler_AdminView');
24 self::$admin_view = new $class();
25 }
26
27 return self::$admin_view;
28 }
29
30 /**
31 * @codeCoverageIgnore
32 */
33 public function init() {
34 if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || false == DOING_AJAX ) ) {
35
36 if ( class_exists( 'WooCommerce' ) ) {
37 add_action( 'woocommerce_admin_status_content_action-scheduler', array( $this, 'render_admin_ui' ) );
38 add_action( 'woocommerce_system_status_report', array( $this, 'system_status_report' ) );
39 add_filter( 'woocommerce_admin_status_tabs', array( $this, 'register_system_status_tab' ) );
40 }
41
42 add_action( 'admin_menu', array( $this, 'register_menu' ) );
43
44 add_action( 'current_screen', array( $this, 'add_help_tabs' ) );
45 }
46 }
47
48 public function system_status_report() {
49 $table = new ActionScheduler_wcSystemStatus( ActionScheduler::store() );
50 $table->render();
51 }
52
53 /**
54 * Registers action-scheduler into WooCommerce > System status.
55 *
56 * @param array $tabs An associative array of tab key => label.
57 * @return array $tabs An associative array of tab key => label, including Action Scheduler's tabs
58 */
59 public function register_system_status_tab( array $tabs ) {
60 $tabs['action-scheduler'] = __( 'Scheduled Actions', 'action-scheduler' );
61
62 return $tabs;
63 }
64
65 /**
66 * Include Action Scheduler's administration under the Tools menu.
67 *
68 * A menu under the Tools menu is important for backward compatibility (as that's
69 * where it started), and also provides more convenient access than the WooCommerce
70 * System Status page, and for sites where WooCommerce isn't active.
71 */
72 public function register_menu() {
73 $hook_suffix = add_submenu_page(
74 'tools.php',
75 __( 'Scheduled Actions', 'action-scheduler' ),
76 __( 'Scheduled Actions', 'action-scheduler' ),
77 'manage_options',
78 'action-scheduler',
79 array( $this, 'render_admin_ui' )
80 );
81 add_action( 'load-' . $hook_suffix , array( $this, 'process_admin_ui' ) );
82 }
83
84 /**
85 * Triggers processing of any pending actions.
86 */
87 public function process_admin_ui() {
88 $this->get_list_table();
89 }
90
91 /**
92 * Renders the Admin UI
93 */
94 public function render_admin_ui() {
95 $table = $this->get_list_table();
96 $table->display_page();
97 }
98
99 /**
100 * Get the admin UI object and process any requested actions.
101 *
102 * @return ActionScheduler_ListTable
103 */
104 protected function get_list_table() {
105 if ( null === $this->list_table ) {
106 $this->list_table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner() );
107 $this->list_table->process_actions();
108 }
109
110 return $this->list_table;
111 }
112
113 /**
114 * Provide more information about the screen and its data in the help tab.
115 */
116 public function add_help_tabs() {
117 $screen = get_current_screen();
118
119 if ( ! $screen || self::$screen_id != $screen->id ) {
120 return;
121 }
122
123 $as_version = ActionScheduler_Versions::instance()->latest_version();
124 $screen->add_help_tab(
125 array(
126 'id' => 'action_scheduler_about',
127 'title' => __( 'About', 'action-scheduler' ),
128 'content' =>
129 '<h2>' . sprintf( __( 'About Action Scheduler %s', 'action-scheduler' ), $as_version ) . '</h2>' .
130 '<p>' .
131 __( 'Action Scheduler is a scalable, traceable job queue for background processing large sets of actions. Action Scheduler works by triggering an action hook to run at some time in the future. Scheduled actions can also be scheduled to run on a recurring schedule.', 'action-scheduler' ) .
132 '</p>',
133 )
134 );
135
136 $screen->add_help_tab(
137 array(
138 'id' => 'action_scheduler_columns',
139 'title' => __( 'Columns', 'action-scheduler' ),
140 'content' =>
141 '<h2>' . __( 'Scheduled Action Columns', 'action-scheduler' ) . '</h2>' .
142 '<ul>' .
143 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Hook', 'action-scheduler' ), __( 'Name of the action hook that will be triggered.', 'action-scheduler' ) ) .
144 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Status', 'action-scheduler' ), __( 'Action statuses are Pending, Complete, Canceled, Failed', 'action-scheduler' ) ) .
145 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Arguments', 'action-scheduler' ), __( 'Optional data array passed to the action hook.', 'action-scheduler' ) ) .
146 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Group', 'action-scheduler' ), __( 'Optional action group.', 'action-scheduler' ) ) .
147 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Recurrence', 'action-scheduler' ), __( 'The action\'s schedule frequency.', 'action-scheduler' ) ) .
148 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Scheduled', 'action-scheduler' ), __( 'The date/time the action is/was scheduled to run.', 'action-scheduler' ) ) .
149 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Log', 'action-scheduler' ), __( 'Activity log for the action.', 'action-scheduler' ) ) .
150 '</ul>',
151 )
152 );
153 }
154 }
155