_localise_settings(); } foreach ($this->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;//($page_type === 'category' || $page_type === 'tag') ? 'term' : 'post'; /** * Id of the current $post * @var int */ $this->id = $this->_get_id($this->type); // wp_die($this->id); $this->age = $this->get_age($this->id, $this->type); $this->js = $this->settings['advanced']['use_js']; if(self::$language && self::$language->current['language_code'] !== self::$language->default['language_code']){ $lang = self::$language->current['language_code']; if(isset($this->restrictions->lang[$lang]['date_format']) && !empty($this->restrictions->lang[$lang]['date_format'])){ $this->restrictions->date_format = $this->restrictions->lang[$lang]['date_format']; } } } /** * 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') . '

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

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

'; } return $data; } /** * Choose the lanuage for the Settings * @return @mixed * @since 2.1.0 */ private function _localise_settings() { foreach ($this->settings['messages'] as $key => $value) { if($key !== 'lang'){ $this->settings['messages'][$key] = $this->_get_translated_setting('messages', $key, self::$language->current['language_code']); } // code...self::$language->current['language_code'] } // if(!isset($this->settings['messages']['lang'])) return; // if(self::$language->current['language_code'] === self::$language->default['language_code']) return; // // $language = $this->settings['messages']['lang'][self::$language->current['language_code']]; // unset($this->settings['messages']['lang']); // $this->settings['messages'] = array_merge($this->settings['messages'], $language); // return $this->settings; } } $agegate = new Age_Gate_Output; $agegate->render();