Exemplo n.º 1
0
function hocwp_add_ads_position($args = array())
{
    $positions = hocwp_get_ads_positions();
    $id = hocwp_get_value_by_key($args, 'id');
    $positions[$id] = $args;
    $GLOBALS['hocwp_ads_positions'] = $positions;
}
Exemplo n.º 2
0
function hocwp_theme_meta_box_ads_information($post_type, $post)
{
    global $pagenow;
    if ('hocwp_ads' == $post_type) {
        if (hocwp_is_post($post)) {
            $post_id = $post->ID;
        } else {
            $post_id = 0;
        }
        $meta = new HOCWP_Meta('post');
        $meta->add_post_type('hocwp_ads');
        $meta->set_id('hocwp_ads_information');
        $meta->set_title(__('Ads Information', 'hocwp-theme'));
        $meta->add_field(array('id' => 'image', 'label' => __('Image:', 'hocwp-theme'), 'container' => true, 'field_callback' => 'hocwp_field_media_upload'));
        $meta->add_field(array('id' => 'url', 'label' => __('Url:', 'hocwp-theme')));
        $positions = hocwp_get_ads_positions();
        if (hocwp_array_has_value($positions)) {
            $all_option = hocwp_field_get_option(array('text' => '--Choose Position--'));
            $selected = get_post_meta($post_id, 'position', true);
            foreach ($positions as $position) {
                $all_option .= hocwp_field_get_option(array('text' => $position['name'], 'value' => $position['id'], 'selected' => $selected));
            }
            $field_args = array('id' => 'position', 'label' => __('Position:', 'hocwp-theme'), 'field_callback' => 'hocwp_field_select', 'all_option' => $all_option);
            $meta->add_field($field_args);
        }
        $meta->add_field(array('id' => 'expire', 'label' => __('Expire:', 'hocwp-theme'), 'field_callback' => 'hocwp_field_datetime_picker'));
        do_action('hocwp_meta_box_ads_fields', $meta, $post);
        $meta->init();
        $args = array('id' => 'code_box', 'title' => __('Code:', 'hocwp-theme'), 'field_id' => 'code', 'post_type' => $post_type, 'field_args' => array('teeny' => true));
        hocwp_meta_box_editor($args);
    }
}
function hocwp_theme_post_column_content_ads($column, $post_id)
{
    if ('ads_position' == $column) {
        $positions = hocwp_get_ads_positions();
        $position = hocwp_get_post_meta('position', $post_id);
        if (isset($positions[$position])) {
            $position = $positions[$position];
            echo $position['name'];
        }
    } elseif ('ads_expire' == $column) {
        $expire = hocwp_get_post_meta('expire', $post_id);
        if (!empty($expire)) {
            if (is_numeric($expire)) {
                $expire = date(hocwp_get_date_format(), $expire);
            }
            echo $expire;
        }
    }
}