false, 'bypass_all' => false, 'debug' => false, ]; if (isset($wpdb) && $wpdb->options) { // Each option: read the new aieo_ key first; fall back to the legacy om_ // key when the new key is missing. This is forward-compatible (operator // toggles via the AS Cleanup admin page write to the new key) and lets // any pre-rename stored setting persist without a separate migration. // Emergency blocker toggle $row = $wpdb->get_row($wpdb->prepare( "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", 'aieo_as_emergency_blocker_enabled' )); if (!$row) { $row = $wpdb->get_row($wpdb->prepare( "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", 'om_as_emergency_blocker_enabled' )); } if ($row) { $aieo_as_config['emergency_blocker_enabled'] = (bool) $row->option_value; } // Master bypass switch (disables ALL our AS interventions) $row = $wpdb->get_row($wpdb->prepare( "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", 'aieo_as_bypass_all_optimizations' )); if (!$row) { $row = $wpdb->get_row($wpdb->prepare( "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", 'om_as_bypass_all_optimizations' )); } if ($row) { $aieo_as_config['bypass_all'] = (bool) $row->option_value; } } // Define constants for other files to check define('AIEO_AS_BYPASS_ALL', $aieo_as_config['bypass_all']); define('AIEO_AS_DEBUG', $aieo_as_config['debug']); // ============================================================================ // HELPER FUNCTIONS // ============================================================================ function aieo_as_is_bypass_enabled() { return AIEO_AS_BYPASS_ALL; } function aieo_as_is_emergency_blocker_enabled() { global $aieo_as_config; if (AIEO_AS_BYPASS_ALL) { return false; } return (bool) $aieo_as_config['emergency_blocker_enabled']; } /** * Detect request type for conditional logic */ function aieo_as_get_request_type() { static $type = null; if ($type !== null) { return $type; } $uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ) ); if (defined('WP_CLI') && WP_CLI) { $type = 'cli'; } elseif (defined('DOING_CRON') && DOING_CRON) { $type = 'cron'; } elseif (strpos($uri, '/wp-cron.php') !== false) { $type = 'cron'; } elseif (isset($_GET['wc-ajax'])) { $type = 'wc_ajax'; } elseif (strpos($uri, 'admin-ajax.php') !== false) { $type = 'admin_ajax'; } elseif (strpos($uri, '/wp-json/') !== false) { $type = 'rest_api'; } elseif (strpos($uri, '/wp-admin/') !== false) { $type = 'admin'; } else { $type = 'frontend'; } return $type; } /** * Check if this request needs Action Scheduler to run */ function aieo_as_request_needs_as() { $type = aieo_as_get_request_type(); // CLI and Cron ALWAYS need AS if (in_array($type, ['cli', 'cron'], true)) { return true; } $uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only inspection of $_REQUEST['action'] to decide whether to short-circuit Action Scheduler boot; no state mutation. $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ?? '' ) ); // WC Admin pages need AS for order imports if (strpos($uri, 'page=wc-admin') !== false) { return true; } // Action Scheduler admin page if (strpos($uri, 'page=action-scheduler') !== false) { return true; } // AS Cleanup page — both legacy slug (tools.php?page=om-as-cleanup) and // the AIEO DMM subtab (admin.php?page=ai-eshop-dmm&dmm_tab=as_cleanup). if (strpos($uri, 'page=om-as-cleanup') !== false) { return true; } if (strpos($uri, 'dmm_tab=as_cleanup') !== false) { return true; } // Specific AJAX actions that need AS $as_needed_actions = [ 'action_scheduler_run_scheduled_actions', 'action_scheduler_run_queue', 'as_async_request_queue_runner', 'wc-admin', 'woocommerce_run_update', 'woocommerce_run_db_update', 'om_profiler_get_analysis', 'om_as_cleanup_step', // legacy AS Dashboard cleanup AJAX (retired) 'aieo_dmm_as_cleanup_step', // AIEO DMM AS Cleanup module AJAX ]; if (in_array($action, $as_needed_actions, true)) { return true; } return false; } // ============================================================================ // QUERY CLASSIFIER — the single source of truth (see v3.0.0 note in header) // ============================================================================ // Every AS query filter in this file AND in aieo-as-ajax-query-protection.php // goes through these three functions. Do not hand-roll another LIMIT regex. if (!defined('AIEO_AS_MAX_ROWS_FRONTEND')) { define('AIEO_AS_MAX_ROWS_FRONTEND', 10); } if (!defined('AIEO_AS_MAX_ROWS_BACKEND')) { define('AIEO_AS_MAX_ROWS_BACKEND', 1000); } /** * Does this query actually READ the actions table, or merely mention its name? * * MENTIONING IS NOT READING, and the difference is not academic. Every filter in * these three files used to gate on a bare * `strpos($query, 'actionscheduler_actions') !== false`, which fires on any SQL * that contains the string ANYWHERE — including as a value in an `IN (…)` list. * * That is exactly what AIEO_Signal_Registry::probe_tables() does: it lists all * 143 catalogued table names plus `{prefix}actionscheduler_actions` in ONE * `information_schema.TABLES … WHERE TABLE_NAME IN (…)` lookup. The substring * test matched, the schema lookup was classified as an unbounded AS list read, * ` LIMIT 10` was stapled on — and 10 of 138 tables came back. The DMM Signals * card then reported 62 signals as "no storage on this site" and 19 as healthy, * in the browser only, while wp-cli (cap 1000, so no truncation at 138) read the * same site as 0 absent and 86 healthy. Diagnosed 2026-07-26 on roosterp. * * Anchoring on the FROM/JOIN/UPDATE/INTO target keeps every genuine AS query in * scope while letting schema lookups and IN-list mentions through untouched. * * @param string $query Raw SQL. * @return bool */ function aieo_as_query_reads_actions_table($query) { // Cheap reject first — most queries never mention the table at all. if (strpos($query, 'actionscheduler_actions') === false) { return false; } // Schema introspection is never the expensive row plan this file caps. if (stripos($query, 'information_schema') !== false) { return false; } return (bool) preg_match( '/\b(?:FROM|JOIN|UPDATE|INTO)\s+`?\w*actionscheduler_actions`?/i', $query ); } /** * How many rows can this query return at most? * * Handles all three LIMIT spellings. The historic bug here was reading * `LIMIT 0, 25` with /LIMIT\s+(\d+)/ and getting 0 (the OFFSET) instead of 25. * * @param string $normalized Whitespace-collapsed query. * @return int Row cap, or -1 when unbounded. */ function aieo_as_query_row_cap($normalized) { // `LIMIT , ` — the count is the SECOND number. if (preg_match('/\bLIMIT\s+\d+\s*,\s*(\d+)/i', $normalized, $m)) { return (int) $m[1]; } // `LIMIT ` and `LIMIT OFFSET `. if (preg_match('/\bLIMIT\s+(\d+)/i', $normalized, $m)) { return (int) $m[1]; } return -1; } /** * Is this AS read bounded and therefore always safe to run as-is? * * These shapes MUST reach the database. Returning an empty set for any of them * is what makes as_next_scheduled_action() / as_has_scheduled_action() report * "nothing scheduled" and mint a duplicate: * * 1. `… LIMIT 0, 1` query_action() — the existence probe * 2. `… WHERE a.action_id=N` fetch_action() — PK hydration, carries no LIMIT * 3. `SELECT count(…) …` count-based guards; one row by definition * 4. `… WHERE claim_id=` find_actions_by_claim_id(), bounded by batch size * * @param string $normalized Whitespace-collapsed query. * @return bool */ function aieo_as_query_is_safe($normalized) { // (1) At most one row back. $cap = aieo_as_query_row_cap($normalized); if ($cap >= 0 && $cap <= 1) { return true; } // (3) Aggregates collapse to a single row whatever the table size. if (preg_match('/^SELECT\s+(?:SQL_NO_CACHE\s+)?(?:COUNT|MIN|MAX)\s*\(/i', $normalized)) { return true; } // (2) Equality on a primary/unique id — at most one row, index lookup. if (preg_match('/\b(?:action_id|group_id)\s*=\s*\d+/i', $normalized)) { return true; } // (4) A specific NON-ZERO claim. `claim_id = 0` is deliberately excluded: // that is the unbounded "find claimable pending actions" list plan, // which is exactly the query this whole file exists to cap. if (preg_match('/\bclaim_id\s*=\s*[1-9]\d*/i', $normalized)) { return true; } // (5) An aggregate ROLLED UP over a low-cardinality key. Test (3) above only // fires when the aggregate is the FIRST select expression, so // `SELECT hook, MIN(scheduled_date_gmt) … GROUP BY hook` fell through to // the cap — and AIEO_Signal_Registry::probe_crons() uses exactly that // shape to ask "which of these ~90 hooks are scheduled?". Capped to 10, // it answered for 10 hooks and the Signals card reported six live // Action-Scheduler schedules as "not scheduled". // // Such a query returns one row per DISTINCT GROUP KEY, not one per // action, so it is bounded by the key's cardinality — hundreds of hooks // at worst, never the table size. Restricted to the low-cardinality // columns on purpose: `GROUP BY action_id` is one row per action and // must stay capped. if (preg_match('/\b(?:COUNT|MIN|MAX|SUM|AVG)\s*\(/i', $normalized) && preg_match('/\bGROUP\s+BY\s+(.+?)(?:\s+HAVING\b|\s+ORDER\s+BY\b|\s+LIMIT\b|$)/i', $normalized, $g)) { $bounded_keys = array('hook', 'status', 'claim_id', 'group_id'); $all_bounded = true; foreach (explode(',', $g[1]) as $col) { // Strip an optional `alias.` prefix and any backticks. $col = trim(strtolower($col)); $col = preg_replace('/^`?\w+`?\s*\./', '', $col); $col = trim($col, '` '); if (!in_array($col, $bounded_keys, true)) { $all_bounded = false; break; } } if ($all_bounded) { return true; } } return false; } /** * Cap an unbounded/oversized list read. Never returns an empty result set — * truncation is safe, fabricating "no rows" is not (see header). * * @param string $query Original query (untouched whitespace). * @param string $normalized Whitespace-collapsed copy. * @param int $max Row cap to enforce. * @return string */ function aieo_as_apply_row_cap($query, $normalized, $max) { $max = (int) $max; $cap = aieo_as_query_row_cap($normalized); if ($cap < 0) { return rtrim($query, "; \t\n\r") . ' LIMIT ' . $max; } if ($cap <= $max) { return $query; } // Rewrite the row-count component only, preserving any offset. return preg_replace_callback( '/\bLIMIT\s+(\d+)(\s*,\s*)(\d+)|\bLIMIT\s+(\d+)/i', function ($m) use ($max) { if (isset($m[3]) && $m[3] !== '') { return 'LIMIT ' . $m[1] . $m[2] . $max; // LIMIT offset, max } return 'LIMIT ' . $max; // LIMIT max [OFFSET n] }, $query, 1 ); } // ============================================================================ // BLOCKED HOOKS LIST (for emergency blocker) // ============================================================================ define('AIEO_AS_BLOCKED_HOOKS', [ // AutomateWoo 'automatewoo/jobs/clean_inactive_carts', 'automatewoo_midnight', 'automatewoo/jobs/abandoned_carts/start', 'automatewoo/jobs/run_queued_workflows/start', 'automatewoo/jobs/check_for_gmt_offset_change', 'automatewoo/jobs/products_goes_on_sale', 'automatewoo_scheduled_notifications', 'automatewoo/jobs/check_midnight_job', 'automatewoo/jobs/delete_failed_queued_workflows/start', 'automatewoo/jobs/setup_guest_customers/start', 'automatewoo/jobs/delete_expired_coupons/start', 'automatewoo/jobs/batched_workflows/process_item', 'automatewoo/jobs/batched_workflows/create_batch', // AIOSEO 'aioseo_search_statistics_get_latest_available_date', 'aioseo_search_statistics_objects_scan', 'aioseo_search_statistics_sitemap_sync', 'aioseo_search_statistics_site_check', 'aioseo_ai_get_access_token', 'aioseo_cache_prune', 'aioseo_redirects_clear_logs', 'aioseo_ai_update_credits', 'aioseo_redirects_clear_404_logs', 'aioseo_seo_analysis_terms_scan', 'aioseo_seo_analysis_posts_scan', 'aioseo_report_summary', 'aioseo_image_sitemap_scan', // WooCommerce 'woocommerce_cleanup_draft_orders', // Rocket Insights 'rocket_insights_auto_add_homepage', ]); define('AIEO_AS_BLOCKED_PATTERNS', [ 'automatewoo/', 'automatewoo_', 'aioseo_', 'rocket_insights_', ]); // ============================================================================ // LEGACY OM_AS_* ALIASES — back-compat for external code // ============================================================================ // `om-runtime/om-runtime-misc/fix-aioseo-frontend-performance.php` and any // other code that still checks `defined('OM_AS_BYPASS_ALL')` / // `OM_AS_BLOCKED_HOOKS` / `OM_AS_BLOCKED_PATTERNS` continues to work. // Function aliases are declared further down (need definitions first). if (!defined('OM_AS_CORE_LOADED')) { define('OM_AS_CORE_LOADED', AIEO_AS_CORE_LOADED); } if (!defined('OM_AS_BYPASS_ALL')) { define('OM_AS_BYPASS_ALL', AIEO_AS_BYPASS_ALL); } if (!defined('OM_AS_DEBUG')) { define('OM_AS_DEBUG', AIEO_AS_DEBUG); } if (!defined('OM_AS_BLOCKED_HOOKS')) { define('OM_AS_BLOCKED_HOOKS', AIEO_AS_BLOCKED_HOOKS); } if (!defined('OM_AS_BLOCKED_PATTERNS')){ define('OM_AS_BLOCKED_PATTERNS',AIEO_AS_BLOCKED_PATTERNS); } // ============================================================================ // SKIP MOST INTERVENTIONS IF BYPASS IS ENABLED // BUT KEEP MEMORY SAFETY (query limits) TO PREVENT CRASHES // ============================================================================ if (AIEO_AS_BYPASS_ALL) { // Set retention period if (!defined('ACTION_SCHEDULER_RETENTION_PERIOD')) { define('ACTION_SCHEDULER_RETENTION_PERIOD', 3 * HOUR_IN_SECONDS); } add_filter('action_scheduler_retention_period', function() { return ACTION_SCHEDULER_RETENTION_PERIOD; }); // CRITICAL: Block AS queries on admin pages to prevent AIOSEO isScheduled() crashes // AIOSEO runs getScheduledActions() during init which loads ALL pending actions $uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ) ); $is_admin = strpos($uri, '/wp-admin/') !== false; $is_as_page = strpos($uri, 'page=action-scheduler') !== false; $is_cron = strpos($uri, 'wp-cron.php') !== false || (defined('DOING_CRON') && DOING_CRON); $is_cli = defined('WP_CLI') && WP_CLI; // Block heavy AS queries on admin pages (except AS admin page, cron, CLI, // and contexts aieo_as_request_needs_as() flags — AIEO DMM AS Cleanup AJAX, // the AS Cleanup subtab page render, WC admin, etc.). if ($is_admin && !$is_as_page && !$is_cron && !$is_cli && !aieo_as_request_needs_as()) { add_filter('query', function($query) { // Only modify reads of the ACTIONS table. The groups table is tiny // and its lookups (get_group_id) must work or save_action() writes // the action against a stale/duplicate group. A query that merely // NAMES the table is not a read of it — see // aieo_as_query_reads_actions_table(). if (!aieo_as_query_reads_actions_table($query)) { return $query; } $normalized = trim(preg_replace('/\s+/', ' ', $query)); // Not a SELECT - allow INSERT/UPDATE/DELETE if (stripos($normalized, 'SELECT') !== 0) { return $query; } // Bounded reads (probe / PK fetch / COUNT) always run. if (aieo_as_query_is_safe($normalized)) { return $query; } // Memory safety only — bypass mode stays permissive by design, so // an operator can use it to prove whether OUR filters are the cause // of a scheduling problem. Cap, never blank out. return aieo_as_apply_row_cap($query, $normalized, 100); }, -999999); } // Block AS queue runner on non-processing request types to prevent crashes. // CRITICAL: Cron, CLI, and the AS async runner MUST be allowed through — // they are the contexts where Action Scheduler processes pending actions. // Blocking them globally causes infinite table growth (actions scheduled // but never processed/cleaned, leading to 100,000s of orphaned rows). // 2026-05-27: Re-enabled async runner dispatch so AS can process actions // BETWEEN 5-minute cron intervals. Without this, peak-traffic sites // accumulate 100+ overdue actions per cron gap. The async runner fires a // dedicated admin-ajax request that runs in the background — it doesn't // block page rendering. aieo-as-ajax-query-protection.php already // whitelists as_async_request_queue_runner. $is_as_runner = isset($_REQUEST['action']) && $_REQUEST['action'] === 'as_async_request_queue_runner'; if (!$is_cron && !$is_cli && !$is_as_runner) { add_filter('action_scheduler_queue_runner_concurrent_batches', '__return_zero', 999); add_filter('action_scheduler_run_schedule', '__return_false', 999); } // Limit query args add_filter('action_scheduler_query_actions_query_args', function($args) { $args['per_page'] = isset($args['per_page']) ? min($args['per_page'], 25) : 25; return $args; }, 999); // Skip hook blocking interventions (allow scheduling) return; } // ============================================================================ // LAYER 1: RETENTION PERIOD (always active unless bypassed) // ============================================================================ if (!defined('ACTION_SCHEDULER_RETENTION_PERIOD')) { define('ACTION_SCHEDULER_RETENTION_PERIOD', 3 * HOUR_IN_SECONDS); } add_filter('action_scheduler_retention_period', function() { return ACTION_SCHEDULER_RETENTION_PERIOD; }); // ============================================================================ // LAYER 2: QUERY-LEVEL PROTECTION (memory safety) // ============================================================================ /** * The ONLY Action Scheduler read filter in this file (v3.0.0). * * Deny-list, not allow-list: bounded reads run untouched, everything else is * capped. Nothing is ever rewritten to an empty result set — see the header * note for why that distinction is the whole bug. * * @param string $query Raw SQL about to run. * @return string */ function aieo_as_filter_query($query) { // Only the ACTIONS table is ever expensive. Leave `actionscheduler_groups` // alone: get_group_id() runs an unbounded-looking `SELECT group_id … WHERE // slug=%s`, and blanking it makes save_action() mint a duplicate group row // for every action it writes. And leave queries that merely NAME the actions // table alone too — see aieo_as_query_reads_actions_table(). if (!aieo_as_query_reads_actions_table($query)) { return $query; } $normalized = trim(preg_replace('/\s+/', ' ', $query)); // Writes are never touched here (the emergency blocker below handles those). if (stripos($normalized, 'SELECT') !== 0) { return $query; } // Probes, PK hydration, COUNTs, claim fetches — these MUST reach the table. if (aieo_as_query_is_safe($normalized)) { return $query; } // Everything left is a multi-row list read. Cap it by context. $max = aieo_as_request_needs_as() ? AIEO_AS_MAX_ROWS_BACKEND : AIEO_AS_MAX_ROWS_FRONTEND; return aieo_as_apply_row_cap($query, $normalized, $max); } // Registered ONCE. The old double registration (priority 1 AND -1000000) ran // the same regex work twice per query for no benefit. add_filter('query', 'aieo_as_filter_query', 1); // ============================================================================ // LAYER 3: EMERGENCY BLOCKER (blocks specific hooks from scheduling) // ============================================================================ /** * Block INSERT statements for problematic hooks */ add_filter('query', function($query) { if (!aieo_as_is_emergency_blocker_enabled()) { return $query; } if (stripos(trim($query), 'INSERT') !== 0) { return $query; } global $wpdb; $table = $wpdb->prefix . 'actionscheduler_actions'; if (strpos($query, $table) === false && strpos($query, 'actionscheduler_actions') === false) { return $query; } // Check blocked hooks foreach (AIEO_AS_BLOCKED_HOOKS as $hook) { if (strpos($query, "'{$hook}'") !== false || strpos($query, "\"{$hook}\"") !== false) { return "SELECT 1"; } } return $query; }, -999999); /** * Block via AS filters (backup layer) * Returns existing action_id (not 0) so plugin diagnostics see a valid response. */ add_filter('action_scheduler_pre_schedule_recurring_action', function($pre, $timestamp, $interval, $hook) { if (!aieo_as_is_emergency_blocker_enabled()) { return $pre; } $should_block = in_array($hook, AIEO_AS_BLOCKED_HOOKS, true); if (!$should_block) { foreach (AIEO_AS_BLOCKED_PATTERNS as $pattern) { if (strpos($hook, $pattern) === 0) { $should_block = true; break; } } } if ($should_block) { global $wpdb; $existing_id = $wpdb->get_var($wpdb->prepare( "SELECT action_id FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = %s AND status = 'pending' LIMIT 1", $hook )); return $existing_id ? (int) $existing_id : 1; } return $pre; }, -999999, 4); add_filter('action_scheduler_pre_schedule_single_action', function($pre, $timestamp, $hook) { if (!aieo_as_is_emergency_blocker_enabled()) { return $pre; } $should_block = in_array($hook, AIEO_AS_BLOCKED_HOOKS, true); if (!$should_block) { foreach (AIEO_AS_BLOCKED_PATTERNS as $pattern) { if (strpos($hook, $pattern) === 0) { $should_block = true; break; } } } if ($should_block) { global $wpdb; $existing_id = $wpdb->get_var($wpdb->prepare( "SELECT action_id FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = %s AND status = 'pending' LIMIT 1", $hook )); return $existing_id ? (int) $existing_id : 1; } return $pre; }, -999999, 3); // ============================================================================ // LAYER 4: DISABLE AS ASYNC RUNNER ON FRONTEND/AJAX // ============================================================================ add_filter('action_scheduler_allow_async_request_runner', function($allow) { if (aieo_as_request_needs_as()) { return $allow; } return false; }, 1); // ============================================================================ // LAYER 5: BLOCK AS ON ADMIN PAGES (except where needed) // ============================================================================ $request_type = aieo_as_get_request_type(); if ($request_type === 'admin' && !aieo_as_request_needs_as()) { add_filter('action_scheduler_queue_runner_concurrent_batches', '__return_zero', 999); add_filter('action_scheduler_run_schedule', '__return_false', 999); // NO `query` filter here any more. This layer used to add its own, testing // for /LIMIT\s+1\b/i — which matches none of AS's real query shapes (its // probe is `LIMIT 0, 1`), so it blanked EVERY AS read on EVERY wp-admin // page load and every recurring-job guard on the site duplicated. See the // v3.0.0 note in the header. aieo_as_filter_query() already covers this // context correctly, with the row cap rather than an empty result set. } // ============================================================================ // LAYER 6: BLOCK AS ON ADMIN AJAX (except where needed) // ============================================================================ if ($request_type === 'admin_ajax' && !aieo_as_request_needs_as()) { add_filter('action_scheduler_queue_runner_concurrent_batches', '__return_zero', 999); add_filter('action_scheduler_run_schedule', '__return_false', 999); add_filter('action_scheduler_allow_async_request_runner', '__return_false', 999); // NO `query` filter here any more — same /LIMIT\s+1\b/i defect as LAYER 5, // but firing on the admin-ajax heartbeat (every ~15s while any admin tab is // open), which is what produced the largest pileups on the fleet. The // legacy wp_posts-backed AS store is still short-circuited below, and // aieo-as-ajax-query-protection.php keeps the stricter custom-table rules // for this context. See the v3.0.0 note in the header. add_filter('pre_get_posts', function($query) { if (isset($query->query['post_type']) && $query->query['post_type'] === 'scheduled-action') { $query->set('post__in', [0]); } return $query; }, 1); } // ============================================================================ // LAYER 7: BLOCK AS ON WC-AJAX (cart operations) // ============================================================================ if ($request_type === 'wc_ajax') { add_filter('action_scheduler_allow_async_request_runner', '__return_false'); } // ============================================================================ // LAYER 8: LIMIT AS QUERY ARGS (per_page) // ============================================================================ add_filter('action_scheduler_query_actions_query_args', function($query) { if (!aieo_as_request_needs_as()) { $query['per_page'] = isset($query['per_page']) ? min($query['per_page'], 5) : 5; } return $query; }, 1); // ============================================================================ // LEGACY om_as_* FUNCTION ALIASES — back-compat for external code // ============================================================================ // Wrappers that delegate to the new aieo_as_* implementations. Same // rationale as the legacy constant aliases above — anything still calling // `om_as_is_bypass_enabled()` etc. keeps working without us auditing every // external mu-plugin in one go. // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Reason: legacy `om_as_*` aliases retained for external mu-plugins / old themes; the canonical implementations live in the aieo_as_* functions above. if (!function_exists('om_as_is_bypass_enabled')) { function om_as_is_bypass_enabled() { return aieo_as_is_bypass_enabled(); } } if (!function_exists('om_as_is_emergency_blocker_enabled')) { function om_as_is_emergency_blocker_enabled() { return aieo_as_is_emergency_blocker_enabled(); } } if (!function_exists('om_as_get_request_type')) { function om_as_get_request_type() { return aieo_as_get_request_type(); } } if (!function_exists('om_as_request_needs_as')) { function om_as_request_needs_as() { return aieo_as_request_needs_as(); } } if (!function_exists('om_as_filter_query')) { function om_as_filter_query($query) { return aieo_as_filter_query($query); } } // phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound /* --------------------------------------------------------------------------- * LAYER 9 (2026-10-25, the owner): the "past-due actions found; something may * be wrong" notice is off on every admin screen. Rooster One manages the queue * (the layers above), the count it reports is the backlog a site's cron leaves * (a development site on Local runs no real cron), and the warning on every * screen is noise. Return true from `aieo_as_show_pastdue_notice` to see it. * ------------------------------------------------------------------------- */ add_filter('action_scheduler_check_pastdue_actions', function ($check) { return (bool) apply_filters('aieo_as_show_pastdue_notice', false) ? $check : false; }, 999);