Carbon_Fields\Field\Choose_Sidebar_Field::set_sidebar_options PHP Method

set_sidebar_options() public method

Sets the Sidebar Options
public set_sidebar_options ( $sidebar_options )
    public function set_sidebar_options($sidebar_options)
    {
        // Make sure that all needed fields are in the options array
        $required_arguments = array('before_widget', 'after_widget', 'before_title', 'after_title');
        /**
         * Set default settings
         */
        $sidebar_options_first_element = array_values($sidebar_options);
        $sidebar_options_first_element = $sidebar_options_first_element[0];
        if (!is_array($sidebar_options_first_element)) {
            /**
             * Enters here, if one array with settings is passed
             * Makes the passed settings, the default ones
             */
            $sidebar_options = array('default' => $sidebar_options);
        } elseif (!isset($sidebar_options['default'])) {
            /**
             * Enters here, if the default settings are not passed
             * Sets the default settings
             *
             * @see get_default_sidebar_options()
             */
            $sidebar_options['default'] = $this->get_default_sidebar_options();
        }
        /**
         * Check if all required arguments are passed for each of the sidebars
         */
        foreach ($sidebar_options as $options) {
            foreach ($required_arguments as $arg) {
                if (!isset($options[$arg])) {
                    throw new Incorrect_Syntax_Exception('Provide all sidebar options for ' . $this->name . ': <code>' . implode(', ', $required_arguments) . '</code>');
                }
            }
        }
        $this->sidebar_options = $sidebar_options;
        return $this;
    }