plugin_name, 'Age Gate Restriction Settings', 'Restrictions', AGE_GATE_CAP_RESTRICTIONS, $this->plugin_name, array($this, 'display_options_page') ); } /** * Display restriction settings options * @since 2.0.0 */ public function display_options_page() { $values = $this->_filter_values( get_option('wp_age_gate_restrictions', array()), null); include AGE_GATE_PATH . 'admin/partials/age-gate-admin-restriction.php'; } /** * Handle settings post from form * @return mixed * @since 2.0.0 */ public function handle_form_submission() { // Sanitize the post data $post = $this->validation->sanitize($_POST); if ( ! isset( $post['nonce'] ) || ! wp_verify_nonce( $post['nonce'], 'age_gate_update_restrictions' ) ) { $this->_set_admin_notice( array('message' => __('Sorry, your nonce did not verify.', AGE_GATE_TEXT_DOMAIN), 'status' => 'error') ); // set_transient( 'age_gate_admin_notice', ); wp_redirect($post['_wp_http_referer']); exit; } // set empty values so everything is stored // this will fix the issue of some settings getting // overwritten on update $values = $this->_filter_values( $post['ag_settings'], 0); update_option('wp_age_gate_restrictions', $values); $this->_set_admin_notice( array('message' => __('Settings saved successfully.', AGE_GATE_TEXT_DOMAIN), 'status' => 'success') ); if($this->settings['advanced']['use_js']){ $this->_set_admin_notice( array('message' => __('You are using the JavaScript implementation of Age Gate, if you have caching enabled ensure you purge it to see your changes.', AGE_GATE_TEXT_DOMAIN), 'status' => 'info') ); } // set_transient( 'age_gate_admin_notice', ); wp_redirect($post['_wp_http_referer']); } /** * Filter to ensure all fields get sent to the DB * @param [type] $data [description] * @param [type] $fill [description] * @return [type] [description] * @since 2.0.0 */ private function _filter_values($data, $fill) { $empties = array_fill_keys([ 'min_age', 'restriction_type', 'multi_age', 'restrict_register', 'input_type', 'remember', 'remember_days', 'remember_timescale', 'remember_auto_check', 'date_format', 'ignore_logged', 'rechallenge', 'fail_link_title', 'fail_link', ], $fill); return array_merge($empties, $data); } }