0, 'sliders_show' => 3, 'services_show' => 3, 'testimonials_show' => 3, 'projects_show' => 1 ); /** * Constructor. */ public function __construct() { add_action('admin_menu', array(&$this, 'addThemeAdminMenu')); add_action('admin_action_submit_bbt_theme_action', array(&$this, 'submit_bbt_theme_options')); } /** * initialize theme add all options to options table. */ public static function initThemeOptions() { if (!get_option("bbt_theme_setting")) { add_option('bbt_theme_setting', static::$theme_options); } } /** * Add Theme menu into admin theme sidebar. */ public function addThemeAdminMenu() { static::initThemeOptions(); $page = add_theme_page(__('Bussiness Bootatrap Theme', 'bussiness-bootstrap-by-ifour-technolab'), __('Bussiness Bootatrap Theme', 'bussiness-bootstrap-by-ifour-technolab'), 'edit_theme_options', $this->theme_page, array(&$this, 'bbtThemePage')); add_action('load-' . $page, array(&$this, 'themePageLoad')); } /** * Business Bootstrap Theme Admin Configuration page. * @global array $bbt_theme_options */ public function bbtThemePage() { if (!current_user_can('edit_theme_options')) { wp_die('You do not have suggicient permission to access this page.'); } global $bbt_theme_options; require_once( 'partials/bbt-form-admin-display.php'); } /** * Admin All Theme Options. */ public function submit_bbt_theme_options() { $nonce = $_REQUEST['_wpnonce']; if (wp_verify_nonce($nonce, 'bbt_theme_options_nonce')) { $services_show = esc_html($_POST['services_show']); $sliders_show = esc_html($_POST['sliders_show']); $testimonials_show = esc_html($_POST['testimonials_show']); $projects_show = esc_html($_POST['projects_show']); $addOptions = array('services_show' => $services_show, 'sliders_show' => $sliders_show, 'testimonials_show' => $testimonials_show, 'projects_show' => $projects_show); if(isset($_POST['front_page_half_width'])): $addOptions['front_page_half_width'] = esc_html($_POST['front_page_half_width']); else : $addOptions['front_page_half_width'] = 0; endif; array_walk($addOptions, function ($v, $k) use (&$addOptions) { if ($v == '' || empty($v) || is_null($v) || ($v < 0)) { $v = static::$theme_options[$k]; } $addOptions[$k] = intval($v); }); update_option('bbt_theme_setting', $addOptions); } wp_redirect($this->bbt_admin_theme_page_url()); } /** * Theme admin page url. * @return URL. */ public function bbt_admin_theme_page_url() { return admin_url("themes.php?page=$this->theme_page"); } public function bbt_admin_head() { wp_enqueue_script('bbt-theme-admin-js', get_template_directory_uri().'/admin/js/bbt-app.js' , array('jquery'), 'alpha-6',true); wp_localize_script('bbt-theme-admin-js', 'bbt_admin_ajax_object', array('ajax_url'=> admin_url( 'admin-ajax.php' ))); } public function themePageLoad() { add_action('admin_head', array(&$this, 'bbt_admin_head')); } } new Bussiness_Bootstrap_Theme_Admin(); endif;