(int)(!empty($_POST['ab_flag_spam'])), 'email_notify' => (int)(!empty($_POST['ab_email_notify'])), 'cronjob_enable' => (int)(!empty($_POST['ab_cronjob_enable'])), 'cronjob_interval' => (int)self::get_key($_POST, 'ab_cronjob_interval'), 'no_notice' => (int)(!empty($_POST['ab_no_notice'])), 'dashboard_count' => (int)(!empty($_POST['ab_dashboard_count'])), 'dashboard_chart' => (int)(!empty($_POST['ab_dashboard_chart'])), 'advanced_check' => (int)(!empty($_POST['ab_advanced_check'])), 'regexp_check' => (int)(!empty($_POST['ab_regexp_check'])), 'spam_ip' => (int)(!empty($_POST['ab_spam_ip'])), 'already_commented' => (int)(!empty($_POST['ab_already_commented'])), 'time_check' => (int)(!empty($_POST['ab_time_check'])), 'always_allowed' => (int)(!empty($_POST['ab_always_allowed'])), 'ignore_pings' => (int)(!empty($_POST['ab_ignore_pings'])), 'ignore_filter' => (int)(!empty($_POST['ab_ignore_filter'])), 'ignore_type' => (int)self::get_key($_POST, 'ab_ignore_type'), 'reasons_enable' => (int)(!empty($_POST['ab_reasons_enable'])), 'ignore_reasons' => (array)self::get_key($_POST, 'ab_ignore_reasons'), 'bbcode_check' => (int)(!empty($_POST['ab_bbcode_check'])), 'gravatar_check' => (int)(!empty($_POST['ab_gravatar_check'])), 'country_code' => (int)(!empty($_POST['ab_country_code'])), 'country_black' => sanitize_text_field( wp_unslash( self::get_key( $_POST, 'ab_country_black' ) ) ), 'country_white' => sanitize_text_field( wp_unslash( self::get_key( $_POST, 'ab_country_white' ) ) ), 'translate_api' => (int)(!empty($_POST['ab_translate_api'])), 'translate_lang' => $selected_languages, ); foreach( $options['ignore_reasons'] as $key => $val ) { if ( ! isset( self::$defaults['reasons'][ $val ] ) ) { unset( $options['ignore_reasons'][ $key ] ); } } // No number of days indicated? if ( empty($options['cronjob_interval']) ) { $options['cronjob_enable'] = 0; } // Translate API if ( empty($options['translate_lang']) ) { $options['translate_api'] = 0; } // List of spam reasons if ( empty($options['reasons_enable']) ) { $options['ignore_reasons'] = array(); } // Blacklist clean if ( !empty($options['country_black']) ) { $options['country_black'] = preg_replace( '/[^A-Z ,;]/', '', strtoupper($options['country_black']) ); } // Whitelist clean if ( !empty($options['country_white']) ) { $options['country_white'] = preg_replace( '/[^A-Z ,;]/', '', strtoupper($options['country_white']) ); } // Empty lists? if ( empty($options['country_black']) && empty($options['country_white']) ) { $options['country_code'] = 0; } // Stop Cron? if ( $options['cronjob_enable'] && !self::get_option('cronjob_enable') ) { self::init_scheduled_hook(); } else if ( !$options['cronjob_enable'] && self::get_option('cronjob_enable') ) { self::clear_scheduled_hook(); } // Save options self::update_options($options); // Redirect wp_safe_redirect( add_query_arg( array( 'updated' => 'true' ), wp_get_referer() ) ); die(); } /** * Generation of a selectbox * * @since 2.4.5 * @change 2.4.5 * * @param string $name Name of the Selectbox * @param array $data Array with values * @param string $selected Selected value * @return string $html Generated HTML */ private static function _build_select($name, $data, $selected) { // Start HTML $html = ''; return $html; } /** * Display the GUI * * @since 0.1 * @change 2.7.0 */ public static function options_page() { ?>