settings as $key => $setting) { if($key !== 'access' && $key !== 'advanced'){ $this->{$key} = (object) $setting; } } $this->messages = $this->_format_options($this->messages); $page_type = $this->_screen_type(); $this->type = ($page_type === 'category' || $page_type === 'tag') ? 'term' : 'post'; /** * Id of the current $post * @var int */ $this->id = $this->_get_id($this->type); $this->age = $this->get_age($this->id, $this->type); $this->js = $this->settings['advanced']['use_js']; } /** * Display the HTML for user messaging * @return string HTML content */ public function display_messages(){ $html = ''; if($this->messages->headline) $html .= '

'. sprintf(esc_html($this->messages->headline), $this->age) . '

'; if($this->messages->subheadline) $html .= '

' . sprintf(esc_html($this->messages->subheadline), $this->age) .'

'; // $html .= 'Hi'; return $html; } /** * Display the Logo registered * @return string HTML content */ public function display_logo(){ $logo = wp_get_attachment_url($this->appearance->logo); $class = ($logo) ? ' age-gate-logo' : ''; $content = ($logo ? ''. get_bloginfo('name') .'' : get_bloginfo('name')); return sprintf('

%s

', $class, $content); } /** * Rendee the final template * @return [type] [description] */ public function render(){ include_once AGE_GATE_PATH . 'public/partials/age-gate-public-display.php'; } private function _format_options($options) { $msgs = [ 'headline' => $options->instruction, 'subheadline' => $options->messaging, 'errors' => (object) [ 'invalid' => $options->invalid_input_msg, 'failed' => $options->under_age_msg, 'generic' => $options->generic_error_msg, ], 'remember' => $options->remember_me_text, 'buttons' => (object) [ 'message' => $options->yes_no_message, 'yes' => $options->yes_text, 'no' => $options->no_text, ], 'additional' => $options->additional, 'submit' => $options->button_text ]; return (object) $msgs; } private function _check_filtered($data){ if(gettype($data) !== 'string') { return '

' . __('Incorrect content type. String expected.', AGE_GATE_TEXT_DOMAIN) . '

'; } if(strpos($data, 'name="age_gate') !== false) { return '

' . __('Content contains disallowed inputs. Do not use age_gate as a name.', AGE_GATE_TEXT_DOMAIN) . '

'; } return $data; } } $agegate = new Age_Gate_Output; $agegate->render();