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 / ggpush.php

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

90 lines 3.6 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.7
7 * Requires at least:5.3
8 * Requires PHP:7.0
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 * 自动加载
29 * @param string $class
30 * @return void
31 */
32 function ggpush_autoload($class)
33 {
34 $class_file = GGPUSH_PLUGIN_DIR . 'includes/class-' . strtolower(str_replace('_', '-', $class)) . '.php';
35 if (file_exists($class_file)) {
36 require_once $class_file;
37 }
38 }
39
40 spl_autoload_register('ggpush_autoload');
41 // 启用插件
42 register_activation_hook(GGPUSH_PLUGIN_FILE, array('Ggpush_Plugin', 'plugin_activation'));
43 // 删除插件
44 register_uninstall_hook(GGPUSH_PLUGIN_FILE, array('Ggpush_Plugin', 'plugin_uninstall'));
45 // 禁用插件
46 register_deactivation_hook(GGPUSH_PLUGIN_FILE, array('Ggpush_Plugin', 'plugin_deactivation'));
47 // 添加页面
48 add_action('admin_init', array('Ggpush_Plugin', 'admin_init'));
49 // 添加菜单
50 add_action('admin_menu', array('Ggpush_Plugin', 'admin_menu'));
51 // 在我的插件那添加设置的链接
52 add_filter('plugin_action_links_' . plugin_basename(GGPUSH_PLUGIN_FILE), array('Ggpush_Plugin', 'setups'));
53 // 定时任务执行时间间隔
54 add_filter('cron_schedules', array('Ggpush_Cron', 'cron_schedules'));
55 // 百度普通收录
56 if (!empty($ggpush_options['baidu_token']) && !empty($ggpush_options['baidu_interval']) && !empty($ggpush_options['baidu_num'])) {
57 define('GGPUSH_RUN_BAIDU_CRON', true);
58 add_action('ggpush_run_baidu_cron', array('Ggpush_Cron', 'ggpush_run_baidu_cron'));
59 } else {
60 define('GGPUSH_RUN_BAIDU_CRON', false);
61 }
62 // 百度快速抓取
63 if (!empty($ggpush_options['baidu_token']) && !empty($ggpush_options['baidu_fast_interval']) && !empty($ggpush_options['baidu_fast_num'])) {
64 define('GGPUSH_RUN_BAIDU_FAST_CRON', true);
65 add_action('ggpush_run_baidu_fast_cron', array('Ggpush_Cron', 'ggpush_run_baidu_fast_cron'));
66 } else {
67 define('GGPUSH_RUN_BAIDU_FAST_CRON', false);
68 }
69 // �
70 应推送
71 if (!empty($ggpush_options['bing_token']) && !empty($ggpush_options['bing_interval']) && !empty($ggpush_options['bing_num'])) {
72 define('GGPUSH_RUN_BING_CRON', true);
73 add_action('ggpush_run_bing_cron', array('Ggpush_Cron', 'ggpush_run_bing_cron'));
74 } else {
75 define('GGPUSH_RUN_BING_CRON', false);
76 }
77 // indexnow推送
78 if (!empty($ggpush_options['indexnow_token']) && !empty($ggpush_options['indexnow_interval']) && !empty($ggpush_options['indexnow_num']) && !empty($ggpush_options['indexnow_search_engine'])) {
79 define('GGPUSH_RUN_INDEXNOW_CRON', true);
80 add_action('ggpush_run_indexnow_cron', array('Ggpush_Cron', 'ggpush_run_indexnow_cron'));
81 } else {
82 define('GGPUSH_RUN_INDEXNOW_CRON', false);
83 }
84 // 发布新文章时推送链接
85 if (!empty($ggpush_options['publish_article_platform'])) {
86 // 添加js文件:发布文章后推送
87 add_action('admin_enqueue_scripts', array('Ggpush_Plugin', 'admin_enqueue_scripts'));
88 // 添加发布文章后的处理动作
89 add_action('wp_ajax_ggpush_publish', array('Ggpush_Plugin', 'wp_ajax_ggpush_publish'));
90 }