PluginProbe
果果推送 / 0.0.2
果果推送 v0.0.2
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.2, at ggpush.php

64 lines 2.5 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://dev.ggdoc.cn/plugin/1.html
5 * Description:支持百度搜索引擎的普通、快速收录、微软Bing搜索引擎、以及IndexNow方式的Api提交链接功能,同时还支持定时提交链接功能。
6 * Version:0.0.2
7 * Requires at least: 5.0
8 * Requires PHP:5.3
9 * Author:果果开发
10 * Author URI:https://dev.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 if (defined('GGPUSH_PLUGIN_DIR')) {
20 // 在我的插件那添加重名插件说明
21 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array('Ggpush_Plugin', 'duplicate_name_ggpush'));
22 return;
23 }
24 // 插件目录后面有 /
25 define('GGPUSH_PLUGIN_DIR', plugin_dir_path(__FILE__));
26 // 保证时区正确
27 $timezone_string = get_option('timezone_string');
28 if (!empty($timezone_string)) {
29 date_default_timezone_set($timezone_string);
30 }
31 /**
32 * 自动加载
33 * @param string $class
34 * @return void
35 */
36 function ggpush_autoload($class)
37 {
38 $class_file = GGPUSH_PLUGIN_DIR . 'includes/class-' . strtolower(str_replace('_', '-', $class)) . '.php';
39 if (file_exists($class_file)) {
40 require_once $class_file;
41 }
42 }
43
44 spl_autoload_register('ggpush_autoload');
45 // 启用插件
46 register_activation_hook(__FILE__, array('Ggpush_Plugin', 'plugin_activation'));
47 // 删除插件
48 register_uninstall_hook(__FILE__, array('Ggpush_Plugin', 'plugin_uninstall'));
49 // 禁用插件
50 register_deactivation_hook(__FILE__, array('Ggpush_Plugin', 'plugin_deactivation'));
51 // 添加页面
52 add_action('admin_init', array('Ggpush_Plugin', 'admin_init'));
53 // 添加菜单
54 add_action('admin_menu', array('Ggpush_Plugin', 'admin_menu'));
55 // 在我的插件那添加设置的链接
56 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array('Ggpush_Plugin', 'link_ggpush'));
57 // 定时任务执行时间间隔
58 add_filter('cron_schedules', array('Ggpush_Cron', 'ggpush_cron_schedules'));
59 add_action('ggpush_run_baidu_cron', array('Ggpush_Cron', 'ggpush_run_baidu_cron'));
60 add_action('ggpush_run_baidu_fast_cron', array('Ggpush_Cron', 'ggpush_run_baidu_fast_cron'));
61 add_action('ggpush_run_bing_cron', array('Ggpush_Cron', 'ggpush_run_bing_cron'));
62 add_action('ggpush_run_indexnow_cron', array('Ggpush_Cron', 'ggpush_run_indexnow_cron'));
63 // 发布新文章时推送链接
64 add_action('wp_insert_post', array('Ggpush_Plugin', 'ggpush_to_publish'), 99, 3);