Exemple #1
0
            while ($objects->have_posts()) {
                $objects->the_post();
                $html .= $this->display_loop(get_the_id());
            }
        }
        wp_reset_postdata();
        return $html;
    }
    public function display_loop($pid)
    {
        $html = "";
        $end = get_post_meta($pid, otm_cmb_prefix($this->cptslug) . 'end_date', true);
        if (!$end || time() <= $end) {
            $html .= "<div class='" . $this->cptslug . "'>";
            $html .= "<{$title_tag}>" . get_the_title() . "</{$title_tag}>";
            $html .= apply_filters('the_content', get_the_content());
            $html .= "</div>";
        }
        return $html;
    }
    public function cmb_metaboxes(array $meta_boxes)
    {
        // Start with an underscore to hide fields from custom fields list
        $prefix = otm_cmb_prefix($this->cptslug);
        $meta_boxes[] = array('id' => $this->cptslug . '_metabox', 'title' => sprintf(__('%s Information', 'evans-mu'), $this->singular), 'object_types' => array($this->cptslug), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => array(array('name' => __('Active?', 'evans-mu'), 'desc' => __('Choose whether this ' . $this->cptslug . ' should be active or not', 'evans-mu'), 'id' => $prefix . 'active', 'type' => 'radio', 'options' => array('active' => __('Active', 'evans-mu'), 'inactive' => __('Inactive', 'evans-mu'))), array('name' => __('Start Date', 'evans-mu'), 'desc' => __('If you would like to schedule this ' . $this->cptslug . ', enter a start date.', 'evans-mu'), 'id' => $prefix . 'start_date', 'type' => 'text_datetime_timestamp', 'default' => time()), array('name' => __('End Date', 'evans-mu'), 'desc' => __('If you would like to schedule this ' . $this->cptslug . ', enter an end date.', 'evans-mu'), 'id' => $prefix . 'end_date', 'type' => 'text_datetime_timestamp')));
        return $meta_boxes;
    }
}
$alerts = new Alerts();
$alerts->hooks();