choices)) { return; } if (!empty($this->label)) { ?> label); ?> description)) { ?> description; ?> value()); $choices = $this->choices; /* If values exist, use it. */ $options = array(); if ($values) { /* get individual item */ foreach ($values as $value) { /* separate item with option */ $value = explode(':', $value); /* build the array. remove options not listed on choices. */ if (array_key_exists($value[0], $choices)) { $options[$value[0]] = $value[1] ? '1' : '0'; } } } /* if there's new options (not saved yet), add it in the end. */ foreach ($choices as $key => $val) { /* if not exist, add it in the end. */ if (!array_key_exists($key, $options)) { $options[$key] = '0'; // use zero to deactivate as default for new items. } } ?> palette)) { $palette = implode('|', $this->palette); } else { // Default to true. $palette = ( false === $this->palette || 'false' === $this->palette ) ? 'false' : 'true'; } // Support passing show_opacity as string or boolean. Default to true. $show_opacity = ( false === $this->show_opacity || 'false' === $this->show_opacity ) ? 'false' : 'true'; // Begin the output. ?> 'service_section', 'label' => __('Service Section', 'one-page'), 'callback' => 'onepage_service_section', ); $sections['blog_section'] = array( 'id' => 'blog_section', 'label' => __('Blog Section', 'one-page'), 'callback' => 'onepage_blog_section', ); $sections['gallery_section'] = array( 'id' => 'gallery_section', 'label' => __('Video Section', 'one-page'), 'callback' => 'onepage_video_section', ); $sections['portfolio_section'] = array( 'id' => 'portfolio_section', 'label' => __('Portfolio Section', 'one-page'), 'callback' => 'onepage_portfolio_section', ); $sections['testimonial_section'] = array( 'id' => 'testimonial_section', 'label' => __('Testimonials Section', 'one-page'), 'callback' => 'onepage_testimonial_section', ); $sections['price_section'] = array( 'id' => 'price_section', 'label' => __('Price Section', 'one-page'), 'callback' => 'onepage_price_section', ); $sections['team_section'] = array( 'id' => 'team_section', 'label' => __('Team Section', 'one-page'), 'callback' => 'onepage_team_section', ); $sections['contact_section'] = array( 'id' => 'contact_section', 'label' => __('Contact Us Section', 'one-page'), 'callback' => 'onepage_contact_section', ); return apply_filters('onepage_sections', $sections); } /** * Utility: Default Services to use in customizer default value * @return string */ function onepage_sections_default() { $default = array(); $sections = onepage_sections(); foreach ($sections as $section) { $default[] = $section['id'] . ':1'; /* activate all as default. */ } return apply_filters('onepage_sections_default', implode(',', $default)); } /** * Share Template Tags * the final function with the conditional. */ function onepage_section_show() { /* Get the options */ $option = get_option('onepage_options'); /* Check Services */ $sections = onepage_sections_default(); if (isset($option['onepage_sort'])) { $sections = $option['onepage_sort']; } if (!$sections) return; /* render button */ return apply_filters('onepage_section_show', onepage_get_section($sections)); } /** * Return Share buttons HTML based on Options * @param $options string formatted active services */ function onepage_get_section($options) { /* bail if empty. */ if (!$options) return; /* available services */ $sections = onepage_sections(); /* var. */ $buttons = array(); /* make array */ $options = explode(',', $options); /* loop load */ foreach ($options as $option) { $option = explode(':', $option); if (isset($option[0]) && isset($option[1]) && array_key_exists($option[0], $sections) && '1' == $option[1]) { $buttons[] = $option[0]; } } /* bail if not found. */ if (!$buttons) return; foreach ($buttons as $button) { $fn_callback = $sections[$button]['callback']; if (function_exists($fn_callback)) { call_user_func($fn_callback); } } } function onepage_service_section() { get_template_part('templates/homepage', 'services'); } function onepage_blog_section() { get_template_part('templates/homepage', 'blogs'); } function onepage_video_section() { get_template_part('templates/homepage', 'videos'); } function onepage_testimonial_section() { get_template_part('templates/homepage', 'testimonials'); } function onepage_portfolio_section() { get_template_part('templates/homepage', 'hexGallery'); } function onepage_price_section() { get_template_part('templates/homepage', 'pricing'); } function onepage_team_section() { get_template_part('templates/homepage', 'teams'); } function onepage_contact_section() { get_template_part('templates/homepage', 'contactUs'); }