PluginProbe
果果推送 / trunk
果果推送 vtrunk
trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7
ggpush / includes / class-ggpush-task-table.php

class-ggpush-task-table.php in 果果推送 trunk, at includes/class-ggpush-task-table.php

140 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!class_exists('WP_List_Table')) {
4 require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
5 }
6
7 /**
8 * 定时任务类
9 */
10 class Ggpush_Task_Table extends WP_List_Table
11 {
12
13 public function get_columns()
14 {
15 return array(
16 'title' => '任务名称',
17 'interval' => '推送间隔',
18 'num' => '每次推送链接数量',
19 'type' => '推送文章',
20 'status' => '状态'
21 );
22 }
23
24 public function column_default($item, $column_name)
25 {
26 if (!empty($item[$column_name])) {
27 return $item[$column_name];
28 }
29 return '';
30 }
31
32 public function prepare_items()
33 {
34 // 启用定时任务
35 Ggpush_Cron::update_cron();
36 $columns = $this->get_columns();
37 $hidden = array();
38 $sortable = array();
39 $this->_column_headers = array($columns, $hidden, $sortable);
40 $this->items = array(
41 array(
42 'title' => '百度搜索引擎普通收录',
43 'interval' => Ggpush_Plugin::get_option('baidu_interval'),
44 'num' => Ggpush_Plugin::get_option('baidu_num'),
45 'type' => Ggpush_Plugin::get_option('baidu_type'),
46 'status' => wp_next_scheduled('ggpush_run_baidu_cron')
47 ),
48 array(
49 'title' => '百度搜索引擎快速抓取',
50 'interval' => Ggpush_Plugin::get_option('baidu_fast_interval'),
51 'num' => Ggpush_Plugin::get_option('baidu_fast_num'),
52 'type' => Ggpush_Plugin::get_option('baidu_fast_type'),
53 'status' => wp_next_scheduled('ggpush_run_baidu_fast_cron')
54 ),
55 array(
56 'title' => '�
57 应搜索引擎推送',
58 'interval' => Ggpush_Plugin::get_option('bing_interval'),
59 'num' => Ggpush_Plugin::get_option('bing_num'),
60 'type' => Ggpush_Plugin::get_option('bing_type'),
61 'status' => wp_next_scheduled('ggpush_run_bing_cron')
62 ),
63 array(
64 'title' => 'IndexNow推送',
65 'interval' => Ggpush_Plugin::get_option('indexnow_interval'),
66 'num' => Ggpush_Plugin::get_option('indexnow_num'),
67 'type' => Ggpush_Plugin::get_option('indexnow_type'),
68 'status' => wp_next_scheduled('ggpush_run_indexnow_cron')
69 )
70 );
71 $this->set_pagination_args(array(
72 'total_items' => count($this->items),
73 'per_page' => count($this->items),
74 'total_pages' => 1
75 ));
76 }
77
78 /**
79 * 格式化状态
80 * @param $item
81 * @return string
82 */
83 public static function column_status($item)
84 {
85 if (empty($item['status'])) {
86 return '未运行';
87 } else {
88 return '下次运行时间:' . wp_date('Y-m-d H:i:s', $item['status']);
89 }
90 }
91
92 public static function column_interval($item)
93 {
94 if (empty($item['interval'])) {
95 return '';
96 } else {
97 return $item['interval'] . '分钟';
98 }
99 }
100
101 public static function column_type($item)
102 {
103 if (empty($item['type'])) {
104 return '';
105 } else {
106 switch ($item['type']) {
107 case 1:
108 return '最新';
109 case 2:
110 return '随机';
111 case 3:
112 return '伪随机';
113 }
114 return $item['type'];
115 }
116 }
117
118 public static function column_num($item)
119 {
120 if (empty($item['num'])) {
121 return '';
122 } else {
123 return $item['num'] . '';
124 }
125 }
126
127 public function extra_tablenav($which)
128 {
129 if ('top' === $which) {
130 ?>
131 <div class="alignleft actions">
132 <label>
133 为了确保定时任务稳定运行,您需要定时访问:<a href="<?php echo esc_url(get_home_url() . '/wp-cron.php'); ?>"
134 target="_blank"><?php echo esc_url(get_home_url() . '/wp-cron.php'); ?></a>
135 </label>
136 </div>
137 <?php
138 }
139 }
140 }