get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->prefix . 'redirection_items' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Checks that the Redirection plugin's table exists; cached below. wp_cache_set( 'cfsp_has_redirection', $found, 'cfsp', HOUR_IN_SECONDS ); } return '' !== $found; } /** Plain URL redirects from the Redirection plugin, as Cloudflare Pages _redirects lines. */ public static function redirection_rules() { if ( ! CFSP_Settings::get( 'int_redirection' ) || ! self::has_redirection() ) { return array(); } global $wpdb; // The Redirection plugin's own table (it has no public API for listing redirects). $rows = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- Read once per push to build _redirects. "SELECT url, action_data, action_code FROM {$wpdb->prefix}redirection_items WHERE status = 'enabled' AND action_type = 'url' AND match_type = 'url' AND regex = 0 ORDER BY position ASC LIMIT 2000" ); $lines = array(); foreach ( (array) $rows as $row ) { $from = trim( $row->url ); $to = trim( $row->action_data ); $code = in_array( (int) $row->action_code, array( 301, 302, 303, 307, 308 ), true ) ? (int) $row->action_code : 301; if ( '' === $from || '' === $to || '/' !== $from[0] || preg_match( '#\s#', $from . $to ) ) { continue; } $lines[] = $from . ' ' . CFSP_Exporter::replace_origin( $to ) . ' ' . $code; } return $lines; } /** * Status of known plugins for the Plugins screen. * * @return array[] [ name, active, note, setting|null ] */ public static function report() { $items = array( array( 'name' => 'Yoast SEO', 'active' => defined( 'WPSEO_VERSION' ), 'note' => 'sitemap_index.xml and its sub-sitemaps are exported. Schema and the "optimized with Yoast" comment can be removed under HTML Clean-up.', 'setting' => 'int_seo_sitemaps', ), array( 'name' => 'Rank Math', 'active' => class_exists( 'RankMath' ), 'note' => 'sitemap_index.xml and its sub-sitemaps are exported.', 'setting' => 'int_seo_sitemaps', ), array( 'name' => 'All in One SEO', 'active' => defined( 'AIOSEO_VERSION' ), 'note' => 'sitemap.xml is exported.', 'setting' => 'int_seo_sitemaps', ), array( 'name' => 'Redirection', 'active' => defined( 'REDIRECTION_VERSION' ), 'note' => 'Plain (non-regex) URL redirects are added to Cloudflare Pages\' _redirects file on every push.', 'setting' => 'int_redirection', ), array( 'name' => 'Jetpack', 'active' => defined( 'JETPACK__VERSION' ), 'note' => 'Assets served from Jetpack\'s CDN (c0.wp.com / i0.wp.com) stay on that CDN. Jetpack features that need WordPress (likes, comments, contact forms) won\'t work on the static site. Related Posts can be built into each page instead (Related Posts screen).', 'setting' => null, ), array( 'name' => 'Ad Inserter', 'active' => defined( 'AD_INSERTER_VERSION' ) || function_exists( 'ai_wp_head_hook' ), 'note' => 'Ads inserted in the HTML are exported. Its admin toolbar CSS is removed by HTML Clean-up → Remove admin-bar / toolbar CSS.', 'setting' => null, ), array( 'name' => 'Contact Form 7 / WPForms / Gravity Forms', 'active' => defined( 'WPCF7_VERSION' ) || defined( 'WPFORMS_VERSION' ) || class_exists( 'GFForms' ), 'note' => 'These submit through WordPress with JavaScript, which doesn\'t exist on the static site. Use a form service and Forms → external endpoint, or embed the provider\'s form.', 'setting' => null, ), array( 'name' => 'WooCommerce', 'active' => class_exists( 'WooCommerce' ), 'note' => 'Carts, checkout and accounts are dynamic and can\'t be made static. Product pages export as catalogue pages only.', 'setting' => null, ), array( 'name' => 'Page cache (WP Rocket, LiteSpeed, W3TC, WP Super Cache…)', 'active' => defined( 'WP_ROCKET_VERSION' ) || defined( 'LSCWP_V' ) || defined( 'W3TC' ) || defined( 'WPCACHEHOME' ), 'note' => 'Exports request pages with a cache-busting parameter so fresh content is used. Minified/combined assets are exported as served.', 'setting' => null, ), ); return $items; } }