'default value'] * * @return array */ public static function get_presets(): array { // phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript -- strings are preset code templates, not enqueued scripts. return [ 'analytics' => [ 'label' => __( 'Analytics & Tracking', 'admin-optimizer' ), 'items' => [ [ 'id' => 'google-analytics-4', 'title' => 'Google Analytics 4', 'type' => 'js', 'position' => 'wp_head', 'locations' => [ 'sitewide' ], 'content' => "\n\n", 'notes' => 'Replace GA_MEASUREMENT_ID with your actual Google Analytics 4 Measurement ID (e.g. G-XXXXXXXXXX).', 'placeholders' => [ 'GA_MEASUREMENT_ID' => 'G-XXXXXXXXXX' ], ], [ 'id' => 'google-tag-manager', 'title' => 'Google Tag Manager', 'type' => 'js', 'position' => 'wp_head', 'locations' => [ 'sitewide' ], 'content' => "\n\n", 'notes' => 'Replace GTM_ID with your Google Tag Manager container ID (e.g. GTM-XXXXXXX). Add a matching noscript snippet to wp_body_open for full coverage.', 'placeholders' => [ 'GTM_ID' => 'GTM-XXXXXXX' ], ], [ 'id' => 'facebook-pixel', 'title' => 'Facebook / Meta Pixel', 'type' => 'js', 'position' => 'wp_head', 'locations' => [ 'sitewide' ], 'content' => "\n\n\n", 'notes' => 'Replace PIXEL_ID with your Meta Pixel ID.', 'placeholders' => [ 'PIXEL_ID' => '000000000000000' ], ], [ 'id' => 'plausible-analytics', 'title' => 'Plausible Analytics', 'type' => 'js', 'position' => 'wp_head', 'locations' => [ 'sitewide' ], 'content' => '', 'notes' => "Replace DOMAIN with your site's domain (e.g. yourdomain.com).", 'placeholders' => [ 'DOMAIN' => 'yourdomain.com' ], ], [ 'id' => 'fathom-analytics', 'title' => 'Fathom Analytics', 'type' => 'js', 'position' => 'wp_head', 'locations' => [ 'sitewide' ], 'content' => '', 'notes' => 'Replace SITE_CODE with your Fathom site code.', 'placeholders' => [ 'SITE_CODE' => 'XXXXXXXX' ], ], [ 'id' => 'microsoft-clarity', 'title' => 'Microsoft Clarity', 'type' => 'js', 'position' => 'wp_head', 'locations' => [ 'sitewide' ], 'content' => "", 'notes' => 'Replace PROJECT_ID with your Microsoft Clarity project ID.', 'placeholders' => [ 'PROJECT_ID' => 'xxxxxxxxxx' ], ], ], ], 'verification' => [ 'label' => __( 'Verification Tags', 'admin-optimizer' ), 'items' => [ [ 'id' => 'google-search-console', 'title' => 'Google Search Console', 'type' => 'html', 'position' => 'wp_head', 'locations' => [ 'sitewide' ], 'content' => '', 'notes' => 'Replace VERIFICATION_CODE with the code from Google Search Console.', 'placeholders' => [ 'VERIFICATION_CODE' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ], ], [ 'id' => 'bing-webmaster', 'title' => 'Bing Webmaster Tools', 'type' => 'html', 'position' => 'wp_head', 'locations' => [ 'sitewide' ], 'content' => '', 'notes' => 'Replace VERIFICATION_CODE with the code from Bing Webmaster Tools.', 'placeholders' => [ 'VERIFICATION_CODE' => '00000000000000000000000000000000' ], ], [ 'id' => 'pinterest-verification', 'title' => 'Pinterest Verification', 'type' => 'html', 'position' => 'wp_head', 'locations' => [ 'sitewide' ], 'content' => '', 'notes' => 'Replace VERIFICATION_CODE with your Pinterest domain verification code.', 'placeholders' => [ 'VERIFICATION_CODE' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ], ], [ 'id' => 'facebook-domain-verification', 'title' => 'Facebook Domain Verification', 'type' => 'html', 'position' => 'wp_head', 'locations' => [ 'sitewide' ], 'content' => '', 'notes' => 'Replace VERIFICATION_CODE with your Facebook domain verification code.', 'placeholders' => [ 'VERIFICATION_CODE' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ], ], ], ], 'scripts' => [ 'label' => __( 'Common Frontend Scripts', 'admin-optimizer' ), 'items' => [ [ 'id' => 'cookie-banner', 'title' => 'Cookie Banner (Basic)', 'type' => 'html', 'position' => 'wp_footer', 'locations' => [ 'sitewide' ], 'content' => "
\n", 'notes' => 'A minimal cookie notice. Customise the text and styling to match your site. Ensure this complies with applicable privacy laws.', 'placeholders' => [], ], [ 'id' => 'intercom', 'title' => 'Intercom Live Chat', 'type' => 'js', 'position' => 'wp_footer', 'locations' => [ 'sitewide' ], 'content' => "\n", 'notes' => 'Replace APP_ID with your Intercom app ID.', 'placeholders' => [ 'APP_ID' => 'xxxxxxxx' ], ], ], ], 'css' => [ 'label' => __( 'CSS Tweaks', 'admin-optimizer' ), 'items' => [ [ 'id' => 'hide-page-title', 'title' => 'Hide Page Title', 'type' => 'css', 'display' => 'inline', 'locations' => [ 'sitewide' ], 'content' => ".entry-title,\n.page-title,\nh1.title {\n\tdisplay: none;\n}", 'notes' => 'Hides the main page/post title. Adjust the selectors to match your theme.', 'placeholders' => [], ], [ 'id' => 'disable-text-selection', 'title' => 'Disable Text Selection', 'type' => 'css', 'display' => 'inline', 'locations' => [ 'sitewide' ], 'content' => "body {\n\t-webkit-user-select: none;\n\t-moz-user-select: none;\n\t-ms-user-select: none;\n\tuser-select: none;\n}", 'notes' => 'Prevents users from selecting text on the page.', 'placeholders' => [], ], [ 'id' => 'smooth-scrolling', 'title' => 'Smooth Scrolling', 'type' => 'css', 'display' => 'inline', 'locations' => [ 'sitewide' ], 'content' => "html {\n\tscroll-behavior: smooth;\n}", 'notes' => 'Enables CSS smooth scrolling for anchor links.', 'placeholders' => [], ], [ 'id' => 'custom-scrollbar', 'title' => 'Custom Scrollbar', 'type' => 'css', 'display' => 'inline', 'locations' => [ 'sitewide' ], 'content' => "::-webkit-scrollbar {\n\twidth: 8px;\n}\n::-webkit-scrollbar-track {\n\tbackground: #f1f1f1;\n}\n::-webkit-scrollbar-thumb {\n\tbackground: {{SCROLLBAR_COLOR}};\n\tborder-radius: 4px;\n}\n::-webkit-scrollbar-thumb:hover {\n\tbackground: {{SCROLLBAR_HOVER_COLOR}};\n}", 'notes' => 'Webkit-only custom scrollbar. Replace the colour values to match your brand.', 'placeholders' => [ 'SCROLLBAR_COLOR' => '#888888', 'SCROLLBAR_HOVER_COLOR' => '#555555', ], ], [ 'id' => 'hide-recaptcha-badge', 'title' => 'Hide reCAPTCHA Badge', 'type' => 'css', 'display' => 'inline', 'locations' => [ 'sitewide' ], 'content' => ".grecaptcha-badge {\n\tvisibility: hidden !important;\n}", 'notes' => 'Hides the reCAPTCHA v3 floating badge. Ensure you add the required disclosure text elsewhere on your site.', 'placeholders' => [], ], ], ], ]; // phpcs:enable WordPress.WP.EnqueuedResources.NonEnqueuedScript } /** * Find a single preset by its id field across all categories. * * @param string $id Preset id. * @return array|null */ public static function get_preset_by_id( string $id ): ?array { foreach ( self::get_presets() as $category ) { foreach ( $category['items'] as $item ) { if ( $item['id'] === $id ) { return $item; } } } return null; } }