get_option_settings_keys(); foreach ($settings as $key) { $options[$key] = isset($options[$key]) ? $options[$key] : ''; } $old_data = ultimate_post()->get_setting(); $options = array_merge($old_data, $options); } return $options; } /** * Settings Fields Key Return */ public function get_option_settings_keys() { $attr = array(); $data = $this->get_option_settings(); if (!empty($data)) { foreach ($data as $key => $inner_data) { if (isset($inner_data['attr'])) { foreach ($inner_data['attr'] as $k => $val) { $attr[] = $k; } } } } return $attr; } /** * Settings Field Return */ public function get_option_settings(){ return apply_filters('ultp_settings', array( 'general' => array( 'label' => __('General Settings', 'ultimate-post'), 'attr' => array( 'general_heading' => array( 'type' => 'heading', 'label' => __('General Settings', 'ultimate-post'), ), 'css_save_as' => array( 'type' => 'select', 'label' => __('CSS Add Via', 'ultimate-post'), 'options' => array( 'wp_head' => __( 'Header - (Internal)','ultimate-post' ), 'filesystem' => __( 'File System - (External)','ultimate-post' ), ), 'default' => 'wp_head', 'desc' => __('Select where you want to save CSS.', 'ultimate-post') ), 'preloader_style' => array( 'type' => 'select', 'label' => __('Preloader Style', 'ultimate-post'), 'options' => array( 'style1' => __( 'Preloader Style 1','ultimate-post' ), 'style2' => __( 'Preloader Style 2','ultimate-post' ), ), 'default' => 'style1', 'desc' => __('Select Preloader Style.', 'ultimate-post') ), 'container_width' => array( 'type' => 'number', 'label' => __('Container Width', 'ultimate-post'), 'default' => '1140', 'desc' => __('Change Container Width of the Page Template(PostX Template).', 'ultimate-post') ), 'editor_container' => array( 'type' => 'select', 'label' => __('Editor Container', 'ultimate-post'), 'options' => array( 'full_width' => __( 'Full Width','ultimate-post' ), 'theme_default' => __( 'Theme Default','ultimate-post' ) ), 'default' => 'full_width', 'desc' => __('Select Editor Container Width.', 'ultimate-post') ), 'hide_import_btn' => array( 'type' => 'switch', 'label' => __('Hide Import Button', 'ultimate-post'), 'default' => '', 'desc' => __('Hide Import Layout Button from the Gutenberg Editor.', 'ultimate-post') ), 'disable_image_size' => array( 'type' => 'switch', 'label' => __('Disable Image Size', 'ultimate-post'), 'default' => '', 'desc' => __('Disable Image Size of the Plugins.', 'ultimate-post') ), ) ) )); } /** * Changelog Data */ public function get_changelog_data() { $html = ''; $resource_data = file_get_contents(ULTP_PATH.'/readme.txt', "r"); $data = array(); if ($resource_data) { $resource_data = explode('== Changelog ==', $resource_data); if (isset($resource_data[1])) { $resource_data = $resource_data[1]; $resource_data = explode("\n", $resource_data); $inner = false; $count = -1; foreach ($resource_data as $element) { if ($element){ if (substr_count($element, '=') > 1) { $count++; $temp = trim(str_replace('=', '', $element)); if (strpos($temp, '-') !== false) { $temp = explode('-', $temp); $data[$count]['date'] = trim($temp[1]); $data[$count]['version'] = trim($temp[0]); } } if (strpos($element, '* New:') !== false) { $data[$count]['new'][] = trim(str_replace('* New:', '', $element)); } if (strpos($element, '* Fix:') !== false) { $data[$count]['fix'][] = trim(str_replace('* Fix:', '', $element)); } if (strpos($element, '* Update:') !== false) { $data[$count]['update'][] = trim(str_replace('* Update:', '', $element)); } } } } } if (!empty($data)) { foreach ($data as $k => $inner_data) { $html .= '
'; foreach ($inner_data as $key => $changelog) { if ($key == 'date') { $html .= '
'.__('Released on ', 'ultimate-post').' '.date_i18n( 'd F Y', strtotime($changelog) ).'
'; } elseif($key == 'version') { $html .= '
'.__('Version', 'ultimate-post').' : '.$changelog.'
'; } else { foreach ($changelog as $keyword => $val) { $html .= '
'.$key.''.$val.'
'; } } } $html .= '
'; } } echo $html; } /** * Settings page output */ public function get_settings_data( $data ) { $html = ''; $option_data = ultimate_post()->get_setting(); foreach ($data as $key => $value) { if ($value['type'] == 'hidden') { $html .= ''; } else { if ($value['type'] == 'heading') { $html .= '

'.$value['label'].'

'; if ( isset($value['desc']) ) { $html .= '
'.$value['desc'].'
'; } } $html .= '
'; if ($value['type'] != 'heading') { if (isset($value['label'])) { $html .= '
'.$value['label'].'
'; } } $html .= '
'; switch ($value['type']) { case 'select': $html .= '
'; $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : ''); $html .= ''; $html .= '

'.$value['desc'].'

'; $html .= '
'; break; case 'color': $html .= '
'; $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : ''); $html .= ''; $html .= '

'.$value['desc'].'

'; $html .= '
'; break; case 'number': $html .= '
'; $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : ''); $html .= ''; $html .= '

'.$value['desc'].'

'; $html .= '
'; break; case 'switch': $html .= '
'; $val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : ''); $html .= ''; $html .= '

'.$value['desc'].'

'; $html .= '
'; break; case 'multiselect': $html .= '
'; $saved_val = isset($option_data[$key]) ? $option_data[$key] : (isset($value['default']) ? $value['default'] : []); $html .= ''; $html .= '
'; break; default: # code... break; } $html .= '
'; $html .= '
'; } } echo $html; } /** * Settings page output */ public function create_admin_page() { $data = self::get_option_settings(); ?>
$value) { if (isset($value['label'])) { ?>
$value) { if (isset($value['attr'])) { ?>
get_settings_data( $value['attr'] ); ?>
get_changelog_data(); ?>