2 Star 16 Fork 3

friend-nicen/nicen-localize-image

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
nicen-localize-image.php 2.58 KB
一键复制 编辑 原始数据 按行查看 历史
friend-nicen 提交于 2023-08-04 01:18 . v1.4.0
<?php
/**
* Plugin Name: nicen-localize-image
* Plugin URI:https://nicen.cn/2893.html
* Description: 用于本地化文章的外部图片的插件,支持文章发布前通过编辑器插件本地化、文章发布时自动本地化、定时发布文章时自动本地化、已发布的文章批量本地化。
* Version:1.4.0
* Author: 友人a丶
* Author URI: https://nicen.cn
* Text Domain: nicen-localize-image
* License: GPLv2 or later
*/
/**
* 定义全局命名空间
* */
namespace nicen\local\images;
define( 'nicen_local_image_path', plugin_dir_path( __FILE__ ) ); //插件目录
define( 'nicen_local_image_url', plugin_dir_url( __FILE__ ) ); //插件URL
//this is the root of website's path. call $_SERVER['DOCUMENT_ROOT'],I think it's safe;
//Think's
/*文件系统根目录*/
define( 'nicen_local_image_root', $_SERVER['DOCUMENT_ROOT'] );
/*站点根目录*/
define( 'nicen_local_image_site_root', str_replace( $_SERVER['DOCUMENT_ROOT'], "", WP_CONTENT_DIR ) );
/**
* 是否需要校准时区
* */
if ( get_option( "nicen_make_plugin_adjust" ) ) {
date_default_timezone_set( get_option( 'timezone_string' ) ); //设置时区
}
include_once nicen_local_image_path . '/admin/preload.php'; //加载插件配置
include_once nicen_local_image_path . '/config.php'; //加载插件配置
include_once nicen_local_image_path . '/admin/install.php'; //安装时触发
register_activation_hook( __FILE__, "nicen_make_install" );//初始化插件
register_deactivation_hook( __FILE__, 'nicen_make_end' ); //卸载插件
/*导入类库*/
include_once nicen_local_image_path . '/class/log.php'; //错误日志封装类
include_once nicen_local_image_path . '/class/local.php'; //图片本地化封装类
include_once nicen_local_image_path . '/class/crontab.php'; //定时任务封装类
include_once nicen_local_image_path . '/class/compress.php'; //图片压缩封装类
/*导入模块*/
include_once nicen_local_image_path . '/admin/common.php'; //公共变量和方法
include_once nicen_local_image_path . '/admin/when-post.php'; //文章保存时触发的钩子
include_once nicen_local_image_path . '/response/response.php'; //接口响应
/**
* 只在后台才触发
* */
if ( is_admin() ) {
include_once nicen_local_image_path . '/admin/load.php'; //加载后台插件资源
include_once nicen_local_image_path . '/admin/form.php'; //加载后台设置表单
include_once nicen_local_image_path . '/admin/setting.php';//渲染表单
include_once nicen_local_image_path . '/admin/initialize.php'; //初始化插件功能
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/friend-nicen/nicen-localize-image.git
git@gitee.com:friend-nicen/nicen-localize-image.git
friend-nicen
nicen-localize-image
nicen-localize-image
master

搜索帮助

A270a887 8829481 3d7a4017 8829481