$setting) { if (!empty($key)) { $options[$key] = isset($options[$key]) ? sanitize_text_field($options[$key]) : ''; } } } return $options; } /** * Settings Field Return */ public static function get_option_settings(){ return apply_filters('ultp_settings', array( '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(Gutenberg Post Blocks 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') ), )); } /** * Changelog Data */ public static 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').' '.$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 static function get_settings_data() { $html = ''; $option_data = ultimate_post()->get_setting(); $data = self::get_option_settings(); $html .= '
'; $html .= ''; $html .= ''; $html .= wp_nonce_field( "ultp_options-options" ); foreach ($data as $key => $value) { $html .= '
'; $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; default: # code... break; } $html .= '
'; $html .= '
'; } $html .= '
'; $html .= '
'.get_submit_button(); $html .= '
'; $html .= '
'; echo '
'.$html.'
'; } /** * Settings page output */ public static function create_admin_page() { ?>