git pull 排除拉取某个文件夹 / 只拉取某个文件夹 作者: Chuwen 时间: 2021-07-24 分类: Linux 评论 ## 序言 公司项目,把 `vendor` 上传到 `git` 了,导致每次本地执行 `composer update` 等相关 `composer` 命令,再使用 `git pull` 就会冲突... ## 使用方法 > 参考的是:https://zhgcao.github.io/2016/05/11/git-sparse-checkout/ ```shell git config core.sparsecheckout true # 表示只拉取 /path1 目录 echo "/path1" >> .git/info/sparse-checkout # 加个感叹号表示,排除拉取 /path1 目录 echo "!/path1" >> .git/info/sparse-checkout git checkout master ```
WordPress 使用 wp 命令创建 .opt 文件用以支持多语言 作者: Chuwen 时间: 2021-07-20 分类: PHP 评论 ## 前言 > 个人所理解,如有错误请指正 首先需要明白一件事情,创建 `.opt` 文件前,首先在你的插件注释里添加以下关键注释(**Text Domain** 和 **Domain Path** 字段): - **Text Domain**:文本域(个人理解),这个比较关键 - **Domain Path**:翻译文件存放的路径 ``` /** * Plugin Name: 插件的名字 * Plugin URI: https://nowtime.cc/ * Description: 插件简介 * Version: 0.0.1 * Author: Chuwen * Author URI: https://nowtime.cc * Text Domain: chuwen * Domain Path: /i18n/languages/ * Requires at least: 5.5 * Requires PHP: 7.0 * * @package Chuwen * @date 2021/7/20 14:50 */ ``` 以上工作完成后,就可以接着往下看了 ## 安装 wp 命令 > WP-CLI 是一款用于管理 WordPress 的命令行交互界面,无需浏览器即可完成插件更新,多站点设置等许多操作。 官网地址:https://wp-cli.org/zh-cn/ [官方]安装文档:[https://wp-cli.org/zh-cn/#安装](https://wp-cli.org/zh-cn/#安装 "https://wp-cli.org/zh-cn/#安装") ### 本文主要介绍 macOS 以及 Linux 系统安装 #### Linux 安装教程 ```shell cd ~ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar # 检查 Phar 文件确保其正常运行: php wp-cli.phar --info # 要使用 wp 执行 WP-CLI 命令,必须有执行权限并且 PATH 已在环境变量中注册,例如: chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp # 最后再次验证 wp --info ``` #### macOS 可以借助 Homebrew 进行安装 > Homebrew 官方安装文档:https://docs.brew.sh/Installation > 其安装教程可参照:https://zhuanlan.zhihu.com/p/111014448 Homebrew 安装完成后,执行 `brew install wp-cli` 即可 #### Windows 安装教程 > 自行网上搜索,因为**某些功能在 Windows 中将受到限制**,所以我推荐在 Windows 10 以及以上的系统,安装 WSL(Windows 子系统),然后参照 Linux 系统安装 `wp` 命令即可 ### 验证安装 wp 命令 输入 `wp --info` 即可验证  ```shell chuwen@MiBook# wp --info OS: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64 Shell: /bin/zsh PHP binary: /usr/local/Cellar/php@7.3/7.3.28/bin/php PHP version: 7.3.28 php.ini used: /usr/local/etc/php/7.3/php.ini MySQL binary: MySQL version: SQL modes: WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli WP-CLI vendor dir: phar://wp-cli.phar/vendor WP_CLI phar path: /Users/chuwen WP-CLI packages dir: WP-CLI global config: WP-CLI project config: WP-CLI version: 2.5.0 ``` ## 生成 `.pot` 文件 - 假设你的 WordPress 根目录是:`/www/wwwroot/wordpress.com` - 假设你的 WordPress 插件目录:`/www/wwwroot/wordpress.com/wp-content/plugins/chuwen` 首先进入的你的**插件目录** ```shell cd /www/wwwroot/wordpress.com/wp-content/plugins/chuwen ``` 然后生成 `.opt` 文件 ```shell # 如果你是按照最开头的做法做的,那么会自动将生成的 `.opt` 文件放到 `Domain Path` 文件夹下 wp i18n make-pot . # 如果你想指定文件存放路径、文件名 wp i18n make-pot . i18n/languages/chuwen.pot ``` 最后生成结果查看你插件目录下的 `i18n/languages/` 里面的文件即可 ### 生成多语言 将生成的比如 `chuwen.pot` 复制一份,将其命名为 `en_US.pot`,然后使用工具进行翻译即可
WordPress 使用 CloudFlare 后,后台无法进入、重定向次数过多、提示 Sorry, you are not allowed to access this page. 作者: Chuwen 时间: 2021-07-10 分类: PHP 评论 ## 具体原因 1. CloudFlare 那边 SSL 配置的是“灵活”  2. WordPress 后台配置的又是 https  最终就会导致浏览器一直报“重定向次数过多”,或者 WordPress 直接报 `Sorry, you are not allowed to access this page.` CloudFlare SSL 配置“灵活”,指的是 **源站**(也就是你的 WordPress)博客不支持 https,然后 CloudFlare 可以实现: 浏览器 --https--> CloudFlare --http--> 你的服务器(WordPress) **但是**,你在 WordPress 后台配置的了你的 WordPress 地址是 `https` 地址开头的,所以当 CloudFlare 访问你的 WordPress 时,你的 WordPress 告诉 CloudFlare 你只能通过 https 访问,CloudFlare 又告诉你的浏览器你只能访问 https 这样就造成了循环.... ## 解决办法 将 CloudFlare 的 SSL 配置改为“完全”或“完全(严格)”,**推荐选择完全**具体看: 
目录/时间线 Typecho 自定义模板 作者: Chuwen 时间: 2021-07-04 分类: PHP 1 条评论 ## 使用说明 如果你使用的是 Typecho 默认主题,那么你可以在你博客目录下 `/www/wwwroot/nowtime.cc/usr/themes/default` 新建一个文件名为 `time-line.php` 然后将下述**模板源码**粘贴进去保存 > 其它主题可以参照着你主题目录下的 `page.php` 源码来修改我下面写的**模板源码** 然后去博客后台 -> 管理 -> 独立页面 -> 新增,选择模板  然后“发布页面即可” ### 效果预览 https://nowtime.cc/time-line.html  ## 模板源码 ```php need('header.php'); ?> title() ?> content(); ?> need('comments.php'); ?> widget("Widget_Contents_Post_Recent", "pageSize=100000000000000")->to($post); $recentPost = array(); while ($post->next()) { $recentPost[] = array( "title" => $post->title, "link" => $post->permalink, "time" => $post->created, ); } ?> need('sidebar.php'); ?> need('footer.php'); ?> ```
PandoraBox / OpenWRT 等系统路由器流量统计不准确、实时带宽信息不准确 作者: Chuwen 时间: 2021-07-04 分类: 路由器 评论 ## 解决办法 **关闭相关硬件加速**,因为这些会影响到流量统计、QoS 等软件,看自己取舍了 ### Shortcut FE 转发加速引擎 (Fast Path)  关闭后好像还是不能停止,那就需要手动关闭  ### 硬件加速  ## 实时带宽信息和流量统计就正常了  