*/ public static function all(): array { $found = []; $add = static function (string $id, string $name, string $icon, string $text, string $prompt) use (&$found): void { $found[] = ['icon' => $icon, 'id' => $id, 'name' => $name, 'prompt' => $prompt, 'text' => $text]; }; if (class_exists('\WooCommerce') || function_exists('wc_get_orders')) { $add('woocommerce', 'WooCommerce', 'dashicons-cart', __('Ask what sold this week, move orders along, change prices and stock, or fix the checkout.', 'sarcio'), __('What sold this week, and which orders are still processing?', 'sarcio')); } if (defined('ELEMENTOR_VERSION')) { $add('elementor', 'Elementor', 'dashicons-layout', __('Change the text of any Elementor page by asking, previewed before it goes live.', 'sarcio'), __('On the home page, change the hero heading to…', 'sarcio')); } if (function_exists('et_setup_theme') || defined('ET_BUILDER_VERSION') || (function_exists('wp_get_theme') && in_array((string) wp_get_theme()->get_template(), ['Divi', 'divi'], true))) { $add('divi', 'Divi', 'dashicons-layout', __('Change the text of Divi pages by asking, previewed before it goes live.', 'sarcio'), __('On the About page, fix the typo in the first paragraph.', 'sarcio')); } if (defined('WPSEO_VERSION') || class_exists('\WPSEO_Options')) { $add('yoast', 'Yoast SEO', 'dashicons-search', __('Set SEO titles and descriptions, or mark a page noindex, through Yoast.', 'sarcio'), __('Write a better SEO title and description for the Services page.', 'sarcio')); } if (class_exists('\RankMath') || defined('RANK_MATH_VERSION')) { $add('rank-math', 'Rank Math', 'dashicons-search', __('Set SEO titles and descriptions, or mark a page noindex, through Rank Math.', 'sarcio'), __('Write a better SEO title and description for the Services page.', 'sarcio')); } if (class_exists('\Red_Item')) { $add('redirection', 'Redirection', 'dashicons-randomize', __('Add or remove redirects by asking, with undo.', 'sarcio'), __('Redirect /old-pricing to /plans.', 'sarcio')); } if (class_exists('\GFAPI')) { $add('gravityforms', 'Gravity Forms', 'dashicons-feedback', __('See recent entries and change where a form’s emails go.', 'sarcio'), __('Who filled in the contact form this week?', 'sarcio')); } if (defined('MAINWP_PLUGIN_FILE') || class_exists('\MainWP\Dashboard\MainWP_System')) { $add('mainwp', 'MainWP', 'dashicons-networking', __('Ask about every child site from here: updates waiting, sites to sync, a plugin to update on one site, shown as a dry run first.', 'sarcio'), __('Which of my client sites have plugin updates waiting?', 'sarcio')); } foreach (self::caches() as $cache) { $add('cache', $cache, 'dashicons-performance', sprintf( /* translators: %s: the cache plugin. */ __('%s is cleared after every change the assistant applies, so visitors see it at once.', 'sarcio'), $cache, ), __('Clear the caches.', 'sarcio')); break; } return $found; } /** @return array */ public static function caches(): array { $caches = []; if (function_exists('rocket_clean_domain')) { $caches[] = 'WP Rocket'; } if (defined('LSCWP_V')) { $caches[] = 'LiteSpeed Cache'; } if (function_exists('w3tc_flush_all')) { $caches[] = 'W3 Total Cache'; } if (function_exists('wp_cache_clear_cache')) { $caches[] = 'WP Super Cache'; } if (class_exists('\Cache_Enabler')) { $caches[] = 'Cache Enabler'; } if (isset($GLOBALS['wp_fastest_cache'])) { $caches[] = 'WP Fastest Cache'; } if (class_exists('\autoptimizeCache')) { $caches[] = 'Autoptimize'; } if (function_exists('sg_cachepress_purge_cache')) { $caches[] = 'SiteGround Optimizer'; } if (function_exists('breeze_clear_all_cache')) { $caches[] = 'Breeze'; } return $caches; } /** Plugins that registered abilities of their own the assistant can offer, by namespace. */ public static function bridged(): array { if (!function_exists('wp_get_abilities')) { return []; } $namespaces = []; foreach ((array) wp_get_abilities() as $ability) { if (!is_object($ability) || !method_exists($ability, 'get_name')) { continue; } $name = (string) $ability->get_name(); [$namespace] = explode('/', $name, 2) + ['']; if ($namespace === '' || $namespace === 'sarcio' || $namespace === 'mcp-adapter' || in_array($name, Assistant\AbilitiesBridge::COVERED, true) || Assistant\AbilitiesBridge::runsCode($name)) { continue; } $namespaces[$namespace] = ($namespaces[$namespace] ?? 0) + 1; } arsort($namespaces); return $namespaces; } }