'Softvolt_Ai_Bodyguard_Duplicate', 'ordering' => 'Softvolt_Ai_Bodyguard_Ordering', 'redirects' => 'Softvolt_Ai_Bodyguard_Redirects', 'permalinks' => 'Softvolt_Ai_Bodyguard_Permalinks', 'links' => 'Softvolt_Ai_Bodyguard_Link_Checker', 'comments' => 'Softvolt_Ai_Bodyguard_Comments_Off', 'maintenance' => 'Softvolt_Ai_Bodyguard_Maintenance', 'recaptcha' => 'Softvolt_Ai_Bodyguard_Recaptcha', 'posttypes' => 'Softvolt_Ai_Bodyguard_Post_Types', ); /** * The modules. * * @return array id => title, desc, where, icon, class, tab */ public static function registry() { return array( 'duplicate' => array( 'title' => __( 'Duplicate posts and pages', 'ai-guardwall' ), 'desc' => __( 'Copies a post, page or product with its content, featured image, categories, tags, custom fields and page-builder data into a new draft.', 'ai-guardwall' ), 'where' => __( 'A "Duplicate" link under every item in Posts, Pages and the other lists, a "Duplicate" bulk action, and "Duplicate this" in the admin bar.', 'ai-guardwall' ), 'icon' => 'dashicons-admin-page', 'class' => 'Softvolt_Ai_Bodyguard_Duplicate', 'tab' => '', ), 'ordering' => array( 'title' => __( 'Drag-and-drop ordering', 'ai-guardwall' ), 'desc' => __( 'Put pages, posts or any custom type in order by dragging the rows of the list; the order is saved at once.', 'ai-guardwall' ), 'where' => __( 'In the lists you choose below, drag a row by its title. Menus, page lists and themes that sort by "menu order" follow it.', 'ai-guardwall' ), 'icon' => 'dashicons-sort', 'class' => 'Softvolt_Ai_Bodyguard_Ordering', 'tab' => '', ), 'redirects' => array( 'title' => __( 'Redirects', 'ai-guardwall' ), 'desc' => __( '301, 302, 307 and 410 redirects for old addresses, with regular expressions, hit counts and a log of the addresses visitors get a 404 on.', 'ai-guardwall' ), 'where' => __( 'Managed on the Redirects tab of this page.', 'ai-guardwall' ), 'icon' => 'dashicons-randomize', 'class' => 'Softvolt_Ai_Bodyguard_Redirects', 'tab' => 'redirects', ), 'permalinks' => array( 'title' => __( 'Custom permalinks', 'ai-guardwall' ), 'desc' => __( 'Give any post, page or product its own address, such as shop/summer-sale or about.html, independent of the permalink structure. The old address redirects to the new one.', 'ai-guardwall' ), 'where' => __( 'A "Custom permalink" box in the editor of the types you choose below.', 'ai-guardwall' ), 'icon' => 'dashicons-admin-links', 'class' => 'Softvolt_Ai_Bodyguard_Permalinks', 'tab' => '', ), 'links' => array( 'title' => __( 'Broken link checker', 'ai-guardwall' ), 'desc' => __( 'Finds every link (and optionally image) in your content, checks it in the background and lists the broken ones, with one-click unlink or replace.', 'ai-guardwall' ), 'where' => __( 'Results on the Broken links tab of this page; checked again every day.', 'ai-guardwall' ), 'icon' => 'dashicons-editor-unlink', 'class' => 'Softvolt_Ai_Bodyguard_Link_Checker', 'tab' => 'links', ), 'comments' => array( 'title' => __( 'Disable comments', 'ai-guardwall' ), 'desc' => __( 'Switch comments off everywhere or for the post types you choose: no comment forms, no old comments shown, no Comments menu, comment feeds, REST or XML-RPC comment methods.', 'ai-guardwall' ), 'where' => __( 'Settings below. Existing comments can also be deleted in bulk, after a backup copy.', 'ai-guardwall' ), 'icon' => 'dashicons-admin-comments', 'class' => 'Softvolt_Ai_Bodyguard_Comments_Off', 'tab' => '', ), 'maintenance' => array( 'title' => __( 'Maintenance mode', 'ai-guardwall' ), 'desc' => __( 'Show visitors a maintenance or coming-soon page with your logo, message and a countdown, while you and the roles you choose see the site as usual.', 'ai-guardwall' ), 'where' => __( 'Page and options on the Maintenance tab of this page; a red notice in the admin bar while it is on.', 'ai-guardwall' ), 'icon' => 'dashicons-hammer', 'class' => 'Softvolt_Ai_Bodyguard_Maintenance', 'tab' => 'maintenance', ), 'recaptcha' => array( 'title' => __( 'reCAPTCHA v3', 'ai-guardwall' ), 'desc' => __( 'Google\'s invisible reCAPTCHA v3 on login, registration, lost password and comment forms, WooCommerce, Contact Form 7, WPForms and Elementor Pro forms.', 'ai-guardwall' ), 'where' => __( 'Keys and forms below; the same keys and forms as Security Wall › Brute force › CAPTCHA.', 'ai-guardwall' ), 'icon' => 'dashicons-shield-alt', 'class' => 'Softvolt_Ai_Bodyguard_Recaptcha', 'tab' => '', ), 'posttypes' => array( 'title' => __( 'Custom post types', 'ai-guardwall' ), 'desc' => __( 'Create post types (Products, Team, Portfolio…) and taxonomies (Genres, Locations…) with their labels, menu icon, archive and editor features, without code.', 'ai-guardwall' ), 'where' => __( 'On the Post types tab of this page; export them as PHP for a theme at any time.', 'ai-guardwall' ), 'icon' => 'dashicons-layout', 'class' => 'Softvolt_Ai_Bodyguard_Post_Types', 'tab' => 'posttypes', ), ); } public static function defaults() { return array( 'enabled' => array( 'duplicate' => 0, 'ordering' => 0, 'redirects' => 0, 'permalinks' => 0, 'links' => 0, 'comments' => 0, 'maintenance' => 0, 'recaptcha' => 0, 'posttypes' => 0, ), 'duplicate_types' => array( 'post', 'page', 'product' ), 'duplicate_status' => 'draft', 'duplicate_suffix' => '', 'ordering_types' => array( 'page' ), 'ordering_front' => array(), 'permalink_types' => array( 'post', 'page', 'product' ), 'redirect_log_404' => 1, 'links_types' => array( 'post', 'page' ), 'links_images' => 0, 'links_recheck' => 3, 'comments_mode' => 'all', 'comments_types' => array( 'post' ), 'comments_hide_existing' => 1, ); } public static function get( $key = null ) { if ( null === self::$cache ) { $saved = get_option( self::OPTION, array() ); $saved = is_array( $saved ) ? $saved : array(); $defaults = self::defaults(); self::$cache = array_merge( $defaults, $saved ); self::$cache['enabled'] = array_merge( $defaults['enabled'], isset( $saved['enabled'] ) && is_array( $saved['enabled'] ) ? $saved['enabled'] : array() ); } if ( null === $key ) { return self::$cache; } return isset( self::$cache[ $key ] ) ? self::$cache[ $key ] : null; } public static function enabled( $id ) { $enabled = self::get( 'enabled' ); return ! empty( $enabled[ $id ] ); } /** * Save changes (only known keys, cleaned). * * @param array $pairs key => value; 'enabled' may be a partial map. * @return array The saved state. */ public static function update( array $pairs ) { $state = self::get(); $defaults = self::defaults(); $types = array_keys( self::post_types() ); foreach ( $pairs as $key => $value ) { switch ( $key ) { case 'enabled': foreach ( (array) $value as $id => $on ) { if ( isset( $defaults['enabled'][ $id ] ) ) { $state['enabled'][ $id ] = empty( $on ) || 'false' === $on ? 0 : 1; } } break; case 'duplicate_types': case 'ordering_types': case 'ordering_front': case 'permalink_types': case 'links_types': $state[ $key ] = array_values( array_intersect( array_map( 'sanitize_key', (array) $value ), $types ) ); break; case 'duplicate_status': $state[ $key ] = in_array( $value, array( 'draft', 'pending', 'private', 'same' ), true ) ? $value : 'draft'; break; case 'duplicate_suffix': $state[ $key ] = sanitize_text_field( (string) $value ); break; case 'redirect_log_404': case 'links_images': $state[ $key ] = empty( $value ) || 'false' === $value ? 0 : 1; break; case 'links_recheck': $state[ $key ] = max( 1, min( 30, (int) $value ) ); break; case 'comments_mode': $state[ $key ] = 'types' === $value ? 'types' : 'all'; break; case 'comments_types': $state[ $key ] = array_values( array_intersect( array_map( 'sanitize_key', (array) $value ), array_keys( get_post_types() ) ) ); break; case 'comments_hide_existing': $state[ $key ] = empty( $value ) || 'false' === $value ? 0 : 1; break; // The reCAPTCHA card edits the CAPTCHA settings of Security Wall › Brute force. case 'captcha_site_key': Softvolt_Ai_Bodyguard_Settings::set( 'captcha_site_key', (string) preg_replace( '/[^\x21-\x7E]/', '', substr( trim( (string) $value ), 0, 400 ) ) ); break; case 'captcha_secret_new': $secret = (string) preg_replace( '/[^\x21-\x7E]/', '', substr( trim( (string) $value ), 0, 400 ) ); if ( '' !== $secret ) { Softvolt_Ai_Bodyguard_Settings::set_secret( 'captcha_secret', $secret ); } break; case 'captcha_v3_threshold': Softvolt_Ai_Bodyguard_Settings::set( 'captcha_v3_threshold', max( 1, min( 9, (int) $value ) ) ); break; case 'captcha_forms': Softvolt_Ai_Bodyguard_Settings::set( 'captcha_forms', array_values( array_intersect( array_map( 'sanitize_key', (array) $value ), array_keys( Softvolt_Ai_Bodyguard_Captcha::forms() ) ) ) ); break; case 'captcha_hide_badge': Softvolt_Ai_Bodyguard_Settings::set( 'captcha_hide_badge', empty( $value ) || 'false' === $value ? 0 : 1 ); break; } } update_option( self::OPTION, $state ); self::$cache = null; return self::get(); } /** * Copy a table to _svabg_bak_