Carbon_Fields\Field\Choose_Sidebar_Field::get_custom_sidebars PHP Method

get_custom_sidebars() public method

Retrieve all custom sidebars from the database.
public get_custom_sidebars ( ) : array
return array
    public function get_custom_sidebars()
    {
        global $wpdb;
        if (!empty($this->custom_sidebars)) {
            return $this->custom_sidebars;
        }
        $sidebars = array();
        $query_string = '';
        switch ($this->context) {
            case 'Post_Meta':
                $query_string = 'SELECT meta_value AS sidebar FROM ' . $wpdb->postmeta . ' WHERE meta_key = "' . esc_sql($this->name) . '"';
                break;
            case 'Term_Meta':
                $query_string = 'SELECT meta_value AS sidebar FROM ' . $wpdb->termmeta . ' WHERE meta_key = "' . esc_sql($this->name) . '"';
                break;
            case 'Theme_Options':
                $query_string = 'SELECT option_value AS sidebar FROM ' . $wpdb->options . ' WHERE option_name = "' . esc_sql($this->name) . '"';
                break;
            case 'User_Meta':
                $query_string = 'SELECT meta_value AS sidebar FROM ' . $wpdb->usermeta . ' WHERE meta_key = "' . esc_sql($this->name) . '"';
                break;
        }
        $sidebar_names = array_filter($wpdb->get_col($query_string));
        foreach ($sidebar_names as $sidebar_name) {
            $sidebars[$sidebar_name] = 1;
        }
        $this->custom_sidebars = array_keys($sidebars);
        return $this->custom_sidebars;
    }