{"id":15375313,"url":"https://github.com/sy-records/wordpress-tools","last_synced_at":"2025-04-15T15:13:21.006Z","repository":{"id":98040587,"uuid":"136256085","full_name":"sy-records/WordPress-tools","owner":"sy-records","description":":zap:WordPress实用代码段","archived":false,"fork":false,"pushed_at":"2020-02-23T04:40:12.000Z","size":130,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-15T15:13:14.051Z","etag":null,"topics":["code","functions","wordpress"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sy-records.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://donate.qq52o.me","github":"sy-records"}},"created_at":"2018-06-06T01:44:19.000Z","updated_at":"2024-04-10T10:39:40.000Z","dependencies_parsed_at":"2023-06-27T04:16:59.443Z","dependency_job_id":null,"html_url":"https://github.com/sy-records/WordPress-tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sy-records%2FWordPress-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sy-records%2FWordPress-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sy-records%2FWordPress-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sy-records%2FWordPress-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sy-records","download_url":"https://codeload.github.com/sy-records/WordPress-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249094933,"owners_count":21211837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code","functions","wordpress"],"created_at":"2024-10-01T14:02:36.912Z","updated_at":"2025-04-15T15:13:20.998Z","avatar_url":"https://github.com/sy-records.png","language":"PHP","funding_links":["https://donate.qq52o.me","https://github.com/sponsors/sy-records"],"categories":[],"sub_categories":[],"readme":"# WordPress-tools\n\n:zap:总结一下平时在 WordPress 使用中的实用代码段，欢迎提交PR\n\n## 更新 WordPress\n\n[推荐使用 WP-CLI 更新 WordPress](https://qq52o.me/2599.html)\n\n### 安装\n\n```bash\ncurl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar\nphp wp-cli.phar --info # 检查是否可用\nchmod +x wp-cli.phar\nsudo mv wp-cli.phar /usr/local/bin/wp # 简化命令\n```\n\n### 更新\n\n```bash\nwp core update  # 更新核心\nwp core update-db  # 更新数据库\n```\n\n## 短代码使用方式\n\n为了防止主题更新覆盖 functions.php 文件造成自定义代码丢失，将下面的内容保存为 utf-8 格式的 php 文件，并起名为 `functions-diy.php`，放入跟主题的`functions.php` 文件同目录\n\n```php\n\u003c?php\n/*\n你可以把本来要写在 function.php 中的代码写在这里，\n而无须担心更新主题时 function.php 被覆盖。\n*/\n\n```\n\n在 `functions.php` 中引入该文件\n\n```php\nrequire get_template_directory() . '/functions-diy.php';\n```\n\n找到你需要的对应代码，放入 `functio-diy.php` 中保存即可\n\n## 代码段\n\n1、友链管理  \n2、显示评论@回复了谁 不入数据库  \n3、让WordPress小工具文本支持PHP  \n4、最热文章  \n5、防止作者信息泄露  \n6、后台登陆数学验证码  \n7、完全禁用 wp-json  \n8、移除头部 wp-json 标签和 HTTP header 中的 link  \n\u003cdel\u003e 9、防止 WordPress 任意文件删除漏洞\u003c/del\u003e  7月6日推送的 4.9.7 版本已修复  \n10、博客后台登录失败时发送邮件通知管理员  \n11、页面伪静态加上.html  \n12、禁用所有文章类型的修订版本  \n13、禁用自动保存  \n14、纯代码实现熊掌号 H5 页面结构化改造添加 JSON_LD 数据  \n15、防止网站被别人 iframe 框架调用的方法  \n16、优化熊掌号主页显示 防止标题中的 - 被转义为实体符号  \n17、纯代码屏蔽垃圾评论  \n18、标题变为 |  \n19、彻底禁 止WordPress 缩略图  \n20、评论作者链接新窗口打开  \n21、给外部链接加上跳转  \n22、文章外链跳转伪静态版  \n23、添加随便看看  \n24、WordPress 有新评论微信提醒管理员 使用方糖服务  \n25、WordPress 文章版权申明  \n26、移除登录页面标题中的“ — WordPress”  \n27、移除后台页面标题中的“ — WordPress”  \n28、WordPress 禁止可视化编辑模式  \n29、WordPress 移除管理员后台添加用户权限  \n30、同时删除 head 和 feed 中的 WP 版本号  \n31、移除 WordPress 文章标题前的“私密/密码保护”提示文字  \n32、WordPress 中文名、数字名图片上传自动重命名  \n33、移除 WordPress 头部加载 DNS 预获取（dns-prefetch）  \n34、禁止 WordPress 动态文章 ID 访问  \n35、为 WordPress Feed 订阅源添加 utm_source 跟踪参数  \n36、使用 smtp 发邮件  \n37、WordPress 首页排除隐藏指定分类文章  \n38、去掉评论中网址超链接  \n39、移除 Wordpress 后台顶部左上角的 W 图标  \n40、替换 WordPress 默认 Emoji 资源地址  \n41、WordPress 4.6 新增 SVG 格式资源  \n42-47、WordPress RSS/Feed 源的一些设置  \n48、搜索词为空跳转首页  \n49、关闭文章的标签功能  \n50、自定义代码高亮按钮  \n51、清理 WordPress 菜单中的 classes  \n52、修改 Gravatar 地址  \n53、移除后台 Privacy 隐私政策设置页面及功能  \n54、WordPress 上传文件重命名  \n55、给评论框加上图片按钮，可评论回复图片  \n56、一键实现 Wordpress 点维护功能  \n57、防止在 WordPress 别人冒充博主发表评论  \n58、增加评论字数限制  \n59、允许非管理员用户在评论中插入图片等标签  \n60、禁用 admin 用户名尝试登录  \n61、禁止 WordPress5.0 使用 Gutenberg 块编辑器  \n62、删除子菜单  \n63、另一种随便看看代码  \n64、删除文章时删除图片附件  \n65、文章内容添加文章目录  \n66、移除 img 的 width、height、class 属性  \n67、WordPress 文章发布时弹出确认发布对话框  \n68、禁止通过 id 访问 author 页面  \n69、获取 bing 美图，设置为头图  \n70、在文章内引用评论  \n71、评论作者链接新窗口打开 评论不超过30条不展示链接  \n72、禁用 WordPress 附件页面  \n73、修改小工具分类目录排序  \n74、修改登录页面logo、跳转地址  \n75、[纯代码屏蔽WordPress后台无用项让你的后台更加简洁](https://qq52o.me/2684.html)  \n76、搜索结果为一个的时候跳转页面  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsy-records%2Fwordpress-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsy-records%2Fwordpress-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsy-records%2Fwordpress-tools/lists"}