function hocwp_theme_check_load_facebook_javascript_sdk($use)
{
    $data = apply_filters('hocwp_load_facebook_javascript_sdk_on_page_sidebar', array());
    foreach ($data as $value) {
        $conditional_functions = isset($value['condition']) ? $value['condition'] : '';
        $conditional_functions = hocwp_sanitize_array($conditional_functions);
        $condition_result = false;
        foreach ($conditional_functions as $function) {
            if (!hocwp_callback_exists($function)) {
                continue;
            }
            if (call_user_func($function)) {
                $condition_result = true;
                break;
            }
        }
        $sidebar = isset($value['sidebar']) ? $value['sidebar'] : '';
        $sidebars = hocwp_sanitize_array($sidebar);
        foreach ($sidebars as $sidebar) {
            if (is_active_sidebar($sidebar) && $condition_result && hocwp_sidebar_has_widget($sidebar, 'hocwp_widget_facebook_box')) {
                return true;
            }
        }
    }
    $comment_system = hocwp_theme_get_option('comment_system', 'discussion');
    if ('facebook' == $comment_system || 'default_and_facebook' == $comment_system || 'tabs' == $comment_system) {
        if (is_singular()) {
            $post_id = get_the_ID();
            if (comments_open($post_id) || get_comments_number($post_id)) {
                return true;
            }
        }
    }
    return $use;
}
示例#2
0
function hocwp_dashboard_widget_cache($widget_id, $callback, $args = array())
{
    $loading = hocwp_dashboard_widget_loading();
    $locale = get_locale();
    $transient_name = 'hocwp_dashboard_%s';
    $transient_name = hocwp_build_transient_name($transient_name, $widget_id . '_' . $locale);
    if (false !== ($output = get_transient($transient_name)) && !empty($output)) {
        echo $output;
        return true;
    }
    if (!HOCWP_DOING_AJAX) {
        echo $loading;
    }
    if (hocwp_callback_exists($callback)) {
        ob_start();
        call_user_func($callback, $args);
        $html_data = ob_get_clean();
        if (!empty($html_data)) {
            set_transient($transient_name, $html_data, 12 * HOUR_IN_SECONDS);
        }
    } else {
        echo hocwp_build_message(__('Please set a valid callback for this widget!', 'hocwp-theme'), '');
    }
    return true;
}
示例#3
0
function hocwp_term_meta_add_field($args = array())
{
    $callback = hocwp_get_value_by_key($args, 'callback');
    if (!hocwp_callback_exists($callback)) {
        $callback = hocwp_get_value_by_key($args, 'field_callback');
    }
    $field_args = hocwp_get_value_by_key($args, 'field_args');
    $field_args = wp_parse_args($field_args, $args);
    $class = hocwp_get_value_by_key($args, 'class');
    $name = hocwp_get_value_by_key($args, 'name');
    $id = hocwp_get_value_by_key($args, 'id');
    hocwp_transmit_id_and_name($id, $name);
    $tmp = hocwp_sanitize_html_class($name);
    hocwp_add_string_with_space_before($class, 'form-field term-' . $name . '-wrap hocwp');
    ?>
	<div class="<?php 
    echo $class;
    ?>
">
		<?php 
    if (hocwp_callback_exists($callback)) {
        call_user_func($callback, $field_args);
    } else {
        _e('Please set a valid callback for this field', 'hocwp-theme');
    }
    ?>
	</div>
	<?php 
}
示例#4
0
function hocwp_dashboard_widget_ajax_callback()
{
    $result = array('html_data' => '');
    $widget = hocwp_get_method_value('widget');
    if (!empty($widget)) {
        $widgets = explode('_', $widget);
        array_shift($widgets);
        $widget = implode('_', $widgets);
        $callback = 'hocwp_theme_dashboard_widget_' . $widget;
        if (hocwp_callback_exists($callback)) {
            ob_start();
            call_user_func($callback);
            $result['html_data'] = ob_get_clean();
        }
    }
    wp_send_json($result);
}
 public function add_field($args = array())
 {
     $data_type = hocwp_get_value_by_key($args, 'data_type', 'default');
     $callback = hocwp_get_value_by_key($args, 'field_callback');
     if (hocwp_callback_exists($callback)) {
         if ('hocwp_field_input_checkbox' == $callback) {
             $data_type = 'checkbox';
         } elseif ('hocwp_field_color_picker' == $callback) {
             $this->set_use_color_picker(true);
         }
     }
     $args['data_type'] = $data_type;
     $id = isset($args['id']) ? $args['id'] : '';
     $name = isset($args['name']) ? $args['name'] : '';
     $class = isset($args['class']) ? $args['class'] : '';
     if (!isset($args['field_class'])) {
         $args['field_class'] = $class;
     }
     hocwp_transmit_id_and_name($id, $name);
     $args['id'] = $id;
     $args['name'] = $name;
     if (isset($args['default'])) {
         $args['field_args']['default'] = $args['default'];
     }
     $this->fields[] = $args;
 }
    public function post_meta_box_callback()
    {
        $class = 'hocwp-meta-box';
        hocwp_add_string_with_space_before($class, $this->get_context());
        hocwp_add_string_with_space_before($class, $this->get_priority());
        foreach ($this->get_post_types() as $post_type) {
            hocwp_add_string_with_space_before($class, 'post-type-' . $post_type);
        }
        ?>
		<div class="<?php 
        echo $class;
        ?>
">
			<?php 
        if (hocwp_callback_exists($this->get_callback())) {
            call_user_func($this->get_callback());
        } else {
            global $post;
            $post_id = $post->ID;
            foreach ($this->get_fields() as $field) {
                $field_args = isset($field['field_args']) ? $field['field_args'] : array();
                $callback = isset($field['field_callback']) ? $field['field_callback'] : 'hocwp_field_input';
                if (!isset($field_args['value'])) {
                    $name = $field_args['name'];
                    $value = hocwp_get_post_meta($name, $post_id);
                    $field_args['value'] = $value;
                }
                if (hocwp_callback_exists($callback)) {
                    call_user_func($callback, $field_args);
                } else {
                    echo '<p>' . sprintf(__('The callback function %s does not exists!', 'hocwp-theme'), '<strong>' . $callback . '</strong>') . '</p>';
                }
            }
        }
        do_action('hocwp_post_meta_box_field', $this);
        $current_post_type = hocwp_get_current_post_type();
        if (!empty($current_post_type)) {
            do_action('hocwp_' . $current_post_type . '_meta_box_field');
        }
        do_action('hocwp_meta_box_' . $this->get_id() . '_field');
        ?>
		</div>
		<?php 
    }
示例#7
0
function hocwp_tab_content_bootstrap($args = array())
{
    $class = hocwp_get_value_by_key($args, 'class');
    hocwp_add_string_with_space_before($class, 'product-tabs');
    $tabs = hocwp_get_value_by_key($args, 'tabs');
    $callback = hocwp_get_value_by_key($args, 'callback');
    if (!hocwp_callback_exists($callback)) {
        return;
    }
    ?>
	<div class="<?php 
    echo $class;
    ?>
">
		<?php 
    if (hocwp_array_has_value($tabs)) {
        ?>
			<ul class="nav nav-tabs" data-tabs="tabs">
				<?php 
        $count = 0;
        foreach ($tabs as $tab) {
            $href = hocwp_get_value_by_key($tab, 'href');
            if (empty($href)) {
                continue;
            }
            $text = hocwp_get_value_by_key($tab, 'text');
            $class = 'tab-item';
            if (0 === $count) {
                hocwp_add_string_with_space_before($class, 'active');
            }
            $custom_link = hocwp_get_value_by_key($tab, 'custom_link');
            $data_toggle = 'tab';
            if (!empty($custom_link)) {
                $href = $custom_link;
                $data_toggle = '';
            } else {
                $href = '#' . $href;
            }
            ?>
					<li class="<?php 
            echo $class;
            ?>
">
						<a href="<?php 
            echo $href;
            ?>
"
						   data-toggle="<?php 
            echo $data_toggle;
            ?>
"><?php 
            echo $text;
            ?>
</a>
					</li>
					<?php 
            $count++;
        }
        ?>
			</ul>
		<?php 
    }
    ?>
		<?php 
    $after_nav_tabs = hocwp_get_value_by_key($args, 'after_nav_tabs');
    if (!empty($after_nav_tabs)) {
        echo '<div class="after-nav-tabs">';
        hocwp_the_custom_content($after_nav_tabs);
        echo '</div>';
    }
    ?>
		<div class="tab-content">
			<?php 
    call_user_func($callback, $args);
    ?>
		</div>
	</div>
	<?php 
}
function hocwp_theme_add_setting_field_hotline($field_callback = '')
{
    $args = array('id' => 'hotline', 'title' => __('Hotline', 'hocwp-theme'));
    if (hocwp_callback_exists($field_callback)) {
        $args['field_callback'] = $field_callback;
    }
    hocwp_theme_add_setting_field($args);
}
示例#9
0
function hocwp_widget_field($callback, $args)
{
    if (hocwp_callback_exists($callback)) {
        $hidden = isset($args['hidden']) ? $args['hidden'] : false;
        $container_class = '';
        if ($hidden) {
            hocwp_add_string_with_space_before($container_class, 'hidden');
        }
        hocwp_field_widget_before($container_class, true);
        $args = hocwp_field_sanitize_widget_args($args);
        if ('hocwp_field_select_chosen' == $callback) {
            $args['before'] = '<div class="hocwp-widget-field">';
            $args['after'] = '</div>';
        }
        call_user_func($callback, $args);
        hocwp_field_widget_after();
    }
}