Exemplo n.º 1
0
function hocwp_sidebar_has_widget($sidebar, $widget)
{
    $sidebar_name = $sidebar;
    $sidebars = hocwp_get_sidebars();
    $sidebar = isset($sidebars[$sidebar]) ? $sidebars[$sidebar] : '';
    if (!empty($sidebar)) {
        $widgets = hocwp_get_sidebar_widgets($sidebar_name);
        foreach ($widgets as $widget_name) {
            if (hocwp_string_contain($widget_name, $widget)) {
                return true;
            }
        }
    }
    return false;
}
Exemplo n.º 2
0
function hocwp_field_select_sidebar($args = array())
{
    $sidebars = hocwp_get_sidebars();
    $choose_text = __('Choose sidebar', 'hocwp-theme');
    $choose_text = apply_filters('hocwp_theme_select_sidebar_text', $choose_text);
    $all_option = '<option value="0">-- ' . $choose_text . ' --</option>';
    $value = isset($args['value']) ? $args['value'] : '';
    foreach ($sidebars as $key => $sidebar) {
        $sidebar_name = hocwp_get_value_by_key($sidebar, 'name', $key);
        $all_option .= '<option value="' . esc_attr($key) . '" ' . selected($value, $key, false) . '>' . $sidebar_name . '</option>';
    }
    $args['all_option'] = $all_option;
    hocwp_field_select($args);
}