meom/meom-scheduled-removal 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

meom/meom-scheduled-removal

Composer 安装命令:

composer require meom/meom-scheduled-removal

包简介

Schedule automatic unpublishing of posts.

README 文档

README

Schedule automatic unpublishing of posts. An editor picks a date and time in the post sidebar, and when that moment arrives the post is automatically set to draft. The date is stored in native post meta and edited with the core Gutenberg DateTimePicker — no ACF required.

Installation

Use Composer to install the package.

composer require meom/meom-scheduled-removal

How editors use it

  1. Open a post in the block editor.
  2. In the document settings sidebar, find the Scheduled removal panel.
  3. Pick the date and time the post should be unpublished, then save.
  4. To cancel, press Clear and save again.

When the scheduled time passes, the post is set to draft (it is not deleted), so the content is preserved and can be re-published at any time.

Supported post types

By default the field appears on the built-in Posts only. Extend it to other post types with the meom_scheduled_removal_post_types filter:

add_filter(
    'meom_scheduled_removal_post_types',
    function ( $post_types ) {
        $post_types[] = 'page';
        return $post_types;
    }
);

The same list is used everywhere: the meta is registered for those post types, the editor panel renders for them, and the hourly sweep checks them.

How it works

  • Meta key: meom_scheduled_removal — an ISO Y-m-d\TH:i:s datetime string (the DateTimePicker output), interpreted in the site timezone (wp_timezone()).
  • Scheduling is driven by metadata-change hooks (added_post_meta, updated_post_meta, deleted_post_meta), so it reacts to any save source — the block editor, quick edit, WP-CLI, or programmatic updates.
  • Each change reconciles a single WP-Cron event (meom_scheduled_removal_event). If the chosen time is already in the past, the post is unpublished immediately.
  • An hourly sweep (meom_scheduled_removal_sweep) is a safety net: it catches any past-due published post whose single event was missed (WP-Cron is best-effort, not guaranteed).

Hooks

Hook Type Purpose
meom_scheduled_removal_post_types filter Post types the field applies to (default ['post']).
meom_scheduled_removal_event action (cron) Per-post single event that unpublishes the post.
meom_scheduled_removal_sweep action (cron) Hourly backstop for missed events.

Notes & limitations

  • Removal sets the post to draft; it never trashes or deletes content.
  • A post is only acted on while it is publish; manually changing the status makes the scheduled event a no-op.
  • If WP-Cron is entirely disabled on the site, neither the single event nor the hourly sweep can fire.
  • The sweep processes up to 100 past-due posts per run; any overflow is handled on the next hourly run.

Development

Built with @wordpress/scripts. Node is managed via nvm — run nvm use first.

nvm use
npm install
npm run build      # production build to build/
npm run start      # development watch build
npm run lint:js    # ESLint

PHP is checked with the project's MEOM-default PHPCS standard:

# from the project root
vendor/bin/phpcs --standard=htdocs/wp-content/plugins/meom-scheduled-removal/.phpcs.xml.dist htdocs/wp-content/plugins/meom-scheduled-removal/

The build/ directory is committed so the plugin deploys without a build step.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-06-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固