/** * Step callback */ public function callback() { $continue = filter_input(INPUT_POST, 'wpem_continue'); $log = new WPEM_Log(); $log->add_step_field('wpem_continue', $continue); if ('no' === $continue) { wpem_quit(); return; } if (isset($log->geodata)) { new WPEM_Smart_Defaults($log->geodata); } wpem_mark_as_started(); }
/** * Class constructor * * @return array */ public function __construct() { if (!empty($this->data)) { return; } $log = new WPEM_Log(); try { $this->data = $log->geodata; } catch (Exception $e) { $ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP); if ($this->is_public_ip($ip)) { $this->data = $this->get_geodata($ip); } $log->add('geodata', $this->data); } }
/** * Listen for POST requests and process them * * @action admin_init */ public function submit() { $nonce = filter_input(INPUT_POST, 'wpem_step_nonce'); $name = filter_input(INPUT_POST, 'wpem_step_name'); if (false === wp_verify_nonce($nonce, sprintf('wpem_step_nonce-%s-%d', $name, get_current_user_id()))) { return; } $step = $this->get_step_by('name', $name); if (!$step) { return; } $took = filter_input(INPUT_POST, 'wpem_step_took'); if ($took) { $log = new WPEM_Log(); $log->add_step_time($took); } $step->callback(); $next_step = wpem_get_next_step(); if ($next_step) { update_option('wpem_last_viewed', $next_step->name); wp_safe_redirect($next_step->url); exit; } new WPEM_Done(); wp_safe_redirect(wpem_get_customizer_url()); exit; }
/** * Is this a fresh WordPress install? * * @return bool */ private function is_fresh_wp() { $log = new WPEM_Log(); try { $is_fresh = $log->is_fresh_wp; } catch (Exception $e) { $is_fresh = $this->check_is_fresh_wp(); $log->add('is_fresh_wp', $is_fresh); } return $is_fresh; }
/** * Step callback */ public function callback() { $stylesheet = filter_input(INPUT_POST, 'wpem_selected_theme'); $stylesheet = !empty($stylesheet) ? sanitize_key($stylesheet) : WP_DEFAULT_THEME; $log = new WPEM_Log(); $log->add_step_field('wpem_selected_theme', $stylesheet); wpem_wp_cli_exec(array('theme', 'install', $stylesheet), array('activate' => true)); }
/** * Update options in bulk * * @param array $options */ private function bulk_update_options($options) { if (empty($options) || !is_array($options)) { return; } foreach ($options as $option) { $name = sanitize_key($option['name']); $label = !empty($option['label']) ? $option['label'] : $name; $value = filter_input(INPUT_POST, $name); // Validate if (!empty($option['required']) && '' === $value) { wp_safe_redirect(add_query_arg(array('step' => $this->name, 'error' => true), wpem_get_wizard_url())); exit; } // Sanitize if (!empty($option['sanitizer']) && function_exists($option['sanitizer'])) { $value = call_user_func($option['sanitizer'], $value); } update_option($name, $value); $log = new WPEM_Log(); $log->add_step_field($name, $value); } }