| 开发者 | djm56 |
|---|---|
| 更新时间 | 2026年8月27日 22:43 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPL-2.0+ |
| 版权网址: | 版权信息 |
/wp-content/plugins/.When editing a post or page, look for the "Post Expiry" panel in the block editor sidebar (or the metabox in the classic editor). Enter the date and time when you want the post to expire — the plugin takes care of the rest via WordPress cron.
Set an expiry date and choose the "Change to Draft" or "Change to Private" action — the post is unpublished automatically when the date passes, without deleting it. This is the simplest way to handle time-limited content expiration and scheduled unpublishing in WordPress.
The plugin performs one of six actions based on your settings:
Yes. Choose the "Redirect Only" action (or a Smart Rule with a redirect action), enable redirects in Settings, and expired posts will send visitors to the URL you set — great for pointing old offers at your current landing page. The SEO tab can additionally set a canonical URL for expired content.
Yes, both. The block editor gets a "Post Expiry" sidebar panel; the classic editor gets a metabox with date and time fields.
Yes. Enable email notifications in Settings. You can notify the post author, the site admin, or both, between 1 and 30 days before expiry. Each post triggers one reminder.
Smart Rules let expiry behaviour depend on the post itself. For example: "If a post is in the News category, move it to draft when it expires" or "If a post is older than 90 days, delete it permanently." Conditions include category, tag, author, post age, comment count, view count and custom fields. Rules run in priority order (lower number wins) and the first matching rule overrides the default action.
Yes. In the "Post Expiry" panel (block editor sidebar or classic metabox) you can override the action for that single post — including a redirect URL or a target category — which takes precedence over the global default. You can also vary the action automatically with Smart Rules (by category, tag, author, age and more).
When a post expires, the plugin can automatically add noindex/nofollow meta tags, set a canonical URL (to home or category), and return a 410 Gone status code so search engines drop the page cleanly. Configure these in the SEO tab.
Expired posts are checked every 5 minutes via WordPress cron. Note that WP-Cron runs on site traffic — on very low-traffic sites a scheduled task can run late. For exact timing, point a real cron job at wp-cron.php (your host's docs explain how) — the plugin then processes precisely on schedule.
Yes. Select posts in the Posts list and choose the "Set expiry using default window" bulk action — each selected post gets an expiry date of now plus your configured default window (Settings → Bulk Scheduling, 1–3650 days).
Yes. Configure any public post types in Settings, in include or exclude mode.
Yes, developers can use the helper functions:
mscpe_is_post_expired( $post_id ) - Check if a post is expiredmscpe_get_expiry_datetime( $post_id ) - Get the expiry date and timemscpe_get_expiry_status( $post_id ) - Get human-readable expiry statusmscpe_format_expiry_datetime( $date, $time ) - Format expiry date for displayNo data leaves your site. There are no external services, no CDN assets (Chart.js is bundled locally), and no tracking. Optional expiry-reminder emails are sent through your own WordPress mail.
Uninstalling deletes all plugin options, rules, the action log, the analytics table, and all expiry post meta. Log files under wp-content/uploads/msc-post-expiry-logs/ can be removed manually.
The plugin includes translations for 12 languages: German (Germany and Switzerland), Spanish (Spain and Mexico), French (France and Canada), Italian, Japanese, Dutch (Netherlands and Belgium), and Portuguese (Portugal and Brazil).
build_where_clause() SQL fragment assembly with flat associative array returning sanitized scalar values for direct $wpdb->prepare() parameterizationphpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared and WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare comments (no longer needed)$wpdb->prepare() with static SQL containing only %d/%s placeholders — no interpolated SQL fragmentsuse_block_editor_for_post() per-post check_mscpe_expiry_timestamp alongside date/time fields, ensuring cron processing works correctlywp_date() instead of gmdate() for local timestrtotime() false guards in mscpe_is_post_expired() and mscpe_get_expiry_status() to prevent incorrect expiry detectioncurrent_time('timestamp') with time() in expiry check functionsis_numeric() && >0) to prevent 1970-01-01 display from non-numeric meta values