/** * Set Font Control Variables * * Sets the font control variables that are used throughout the * admin settings page. * * @since 1.2 * @version 1.3.9 * */ public function set_font_controls() { $this->font_controls = EGF_Posttype::get_all_font_controls(); $this->custom_controls = array(); // Set no control flag $this->no_controls = $this->font_controls ? false : true; if (!$this->no_controls) { $count = 0; while ($this->font_controls->have_posts()) { $this->font_controls->the_post(); // Add this control to the $custom_controls array $id = get_post_meta(get_the_ID(), 'control_id', true); $this->custom_controls[$id] = get_the_title(); // Set curent control id to the first control if (0 == $count) { $this->current_control_id = $id; $this->first_control = EGF_Posttype::get_font_control($id); } $count++; } // Restore original Post Data wp_reset_postdata(); } // Determine Screen via $_GET['action'] $action = isset($_GET['action']) ? esc_attr($_GET['action']) : false; // Update current control id if it is passed in the URL if (isset($_GET['control'])) { $this->current_control_id = esc_attr($_GET['control']); } // The control id of the current control being edited - Note this is a string representation of '0', not an integer $this->control_selected_id = isset($_GET['control']) ? esc_attr($_GET['control']) : '0'; // Attempt to get a control instance if it exists $this->control_instance = EGF_Posttype::get_font_control($this->control_selected_id); // Edit and and no control but has first control if ('edit' == $action) { if (!isset($_GET['control']) && $this->first_control) { $this->control_instance = $this->first_control; } } /** * Initialise screen action if no action has been set * in the parameter. */ if (!$action) { if ($this->first_control) { $this->control_instance = $this->first_control; $this->control_selected_id = get_post_meta($this->control_instance->ID, 'control_id', true); } } elseif ('create' == $action) { $this->control_selected_id = '0'; } }
/** * Get Custom Theme Font Option Parameters * * This function converts custom controls * in the admin section to the internal * font control. * * Array that holds parameters for all custom font options in this theme. * The 'type' key is used to generate the proper form field markup and to * sanitize the user-input data properly. The 'tab' key determines the * Settings Page on which the option appears, and the 'section' tab * determines the section of the Settings Page tab in which the option * appears. * * @uses EGF_Posttype::get_all_font_controls() defined in \includes\class-egf=posttype.php * * @return array $options array of arrays of option parameters * * @since 1.2 * @version 1.3.8 * */ public static function get_custom_option_parameters($options) { $query = EGF_Posttype::get_all_font_controls(); $custom_options = array(); if ($query) { while ($query->have_posts()) { $query->the_post(); // Extract font control properties $control_id = get_post_meta(get_the_ID(), 'control_id', true); $selectors_array = get_post_meta(get_the_ID(), 'control_selectors', true); $description = get_post_meta(get_the_ID(), 'control_description', true); $force_styles = get_post_meta(get_the_ID(), 'force_styles', true); if (empty($force_styles)) { $force_styles = false; } // Build selectors $selectors = ''; if (!$selectors_array) { $selectors_array = array(); } foreach ($selectors_array as $selector) { $selectors .= $selector . ','; } while (substr($selectors, -1) == ',') { $selectors = rtrim($selectors, ","); } // Add control if ($control_id) { $custom_options[$control_id] = array('name' => $control_id, 'title' => get_the_title(), 'type' => 'font', 'description' => $description, 'section' => 'default', 'tab' => 'theme-typography', 'transport' => 'postMessage', 'since' => '1.0', 'properties' => array('selector' => $selectors, 'force_styles' => $force_styles)); } } //endwhile // Reset the query globals wp_reset_postdata(); } // Parse with defaults foreach ($custom_options as $id => $control) { $custom_options[$id] = self::parse_font_control_array($control); } return array_merge($options, $custom_options); }