PluginProbe
果果推送 / 0.0.4
果果推送 v0.0.4
trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7
ggpush / ggpush.php

ggpush.php in 果果推送 0.0.4, at ggpush.php

95 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name:果果推送
4 * Plugin URI:https://www.ggdoc.cn/plugin/1.html
5 * Description:支持百度搜索引擎的普通、快速收录、微软Bing搜索引擎、以及IndexNow方式的Api提交链接功能,同时还支持定时提交链接功能。
6 * Version:0.0.4
7 * Requires at least: 5.0
8 * Requires PHP:5.3
9 * Author:果果开发
10 * Author URI:https://www.ggdoc.cn
11 * License:GPL v2 or later
12 */
13
14 // 直接访问报404错误
15 if (!function_exists('add_action')) {
16 http_response_code(404);
17 exit;
18 }
19 // 插件目录后面有 /
20 const GGPUSH_PLUGIN_FILE = __FILE__;
21 define('GGPUSH_PLUGIN_DIR', plugin_dir_path(GGPUSH_PLUGIN_FILE));
22 // 定义�
23 �置
24 $ggpush_options = get_option('ggpush_options', array());
25 // 定义上次错误信息
26 $ggpush_error = '';
27 // 保证时区正确
28 $timezone_string = get_option('timezone_string');
29 if (!empty($timezone_string)) {
30 date_default_timezone_set($timezone_string);
31 }
32 /**
33 * 自动加载
34 * @param string $class
35 * @return void
36 */
37 function ggpush_autoload($class)
38 {
39 $class_file = GGPUSH_PLUGIN_DIR . 'includes/class-' . strtolower(str_replace('_', '-', $class)) . '.php';
40 if (file_exists($class_file)) {
41 require_once $class_file;
42 }
43 }
44
45 spl_autoload_register('ggpush_autoload');
46 // 启用插件
47 register_activation_hook(GGPUSH_PLUGIN_FILE, array('Ggpush_Plugin', 'plugin_activation'));
48 // 删除插件
49 register_uninstall_hook(GGPUSH_PLUGIN_FILE, array('Ggpush_Plugin', 'plugin_uninstall'));
50 // 禁用插件
51 register_deactivation_hook(GGPUSH_PLUGIN_FILE, array('Ggpush_Plugin', 'plugin_deactivation'));
52 // 添加页面
53 add_action('admin_init', array('Ggpush_Plugin', 'admin_init'));
54 // 添加菜单
55 add_action('admin_menu', array('Ggpush_Plugin', 'admin_menu'));
56 // 在我的插件那添加设置的链接
57 add_filter('plugin_action_links_' . plugin_basename(GGPUSH_PLUGIN_FILE), array('Ggpush_Plugin', 'setups'));
58 // 定时任务执行时间间隔
59 add_filter('cron_schedules', array('Ggpush_Cron', 'cron_schedules'));
60 // 百度普通收录
61 if (!empty($ggpush_options['baidu_token']) && !empty($ggpush_options['baidu_interval']) && !empty($ggpush_options['baidu_num'])) {
62 define('GGPUSH_RUN_BAIDU_CRON', true);
63 add_action('ggpush_run_baidu_cron', array('Ggpush_Cron', 'ggpush_run_baidu_cron'));
64 } else {
65 define('GGPUSH_RUN_BAIDU_CRON', false);
66 }
67 // 百度快速收录
68 if (!empty($ggpush_options['baidu_token']) && !empty($ggpush_options['baidu_fast_interval']) && !empty($ggpush_options['baidu_fast_num'])) {
69 define('GGPUSH_RUN_BAIDU_FAST_CRON', true);
70 add_action('ggpush_run_baidu_fast_cron', array('Ggpush_Cron', 'ggpush_run_baidu_fast_cron'));
71 } else {
72 define('GGPUSH_RUN_BAIDU_FAST_CRON', false);
73 }
74 // �
75 应推送
76 if (!empty($ggpush_options['bing_token']) && !empty($ggpush_options['bing_interval']) && !empty($ggpush_options['bing_num'])) {
77 define('GGPUSH_RUN_BING_CRON', true);
78 add_action('ggpush_run_bing_cron', array('Ggpush_Cron', 'ggpush_run_bing_cron'));
79 } else {
80 define('GGPUSH_RUN_BING_CRON', false);
81 }
82 // indexnow推送
83 if (!empty($ggpush_options['indexnow_token']) && !empty($ggpush_options['indexnow_interval']) && !empty($ggpush_options['indexnow_num']) && !empty($ggpush_options['indexnow_search_engine'])) {
84 define('GGPUSH_RUN_INDEXNOW_CRON', true);
85 add_action('ggpush_run_indexnow_cron', array('Ggpush_Cron', 'ggpush_run_indexnow_cron'));
86 } else {
87 define('GGPUSH_RUN_INDEXNOW_CRON', false);
88 }
89 // 发布新文章时推送链接
90 if (!empty($ggpush_options['publish_article_platform'])) {
91 // 添加js文件:发布文章后推送
92 add_action('admin_enqueue_scripts', array('Ggpush_Plugin', 'admin_enqueue_scripts'));
93 // 添加发布文章后的处理动作
94 add_action('wp_ajax_ggpush_publish', array('Ggpush_Plugin', 'wp_ajax_ggpush_publish'));
95 }