function gce_print_grid($feed_ids, $title_text, $max_events, $ajaxified = false, $month = null, $year = null)
{
    require_once 'inc/gce-parser.php';
    $ids = explode('-', $feed_ids);
    //Create new GCE_Parser object, passing array of feed id(s) returned from gce_get_feed_ids()
    $grid = new GCE_Parser($ids, $title_text, $max_events);
    $num_errors = $grid->get_num_errors();
    //If there are less errors than feeds parsed, at least one feed must have parsed successfully so continue to display the grid
    if ($num_errors < count($ids)) {
        $feed_ids = esc_attr($feed_ids);
        $title_text = isset($title_text) ? esc_html($title_text) : 'null';
        $markup = '<div class="gce-page-grid" id="gce-page-grid-' . $feed_ids . '">';
        //Add AJAX script if required
        if ($ajaxified) {
            $markup .= '<script type="text/javascript">jQuery(document).ready(function($){gce_ajaxify("gce-page-grid-' . $feed_ids . '", "' . $feed_ids . '", "' . absint($max_events) . '", "' . $title_text . '", "page");});</script>';
        }
        $markup .= $grid->get_grid($year, $month, $ajaxified) . '</div>';
        //If there was at least one error, return the grid markup with an error message (for admins only)
        if ($num_errors > 0 && current_user_can('manage_options')) {
            return $grid->error_messages() . $markup;
        }
        //Otherwise just return the grid markup
        return $markup;
    } else {
        //If current user is an admin, display an error message explaining problem. Otherwise, display a 'nice' error messsage
        if (current_user_can('manage_options')) {
            return $grid->error_messages();
        } else {
            $options = get_option(GCE_GENERAL_OPTIONS_NAME);
            return wp_kses_post($options['error']);
        }
    }
}
Beispiel #2
0
function gce_widget_content_list($feed_ids, $title_text, $max_events, $sort_order, $grouped = false)
{
    require_once WP_PLUGIN_DIR . '/' . GCE_PLUGIN_NAME . '/inc/gce-parser.php';
    $ids = explode('-', $feed_ids);
    //Create new GCE_Parser object, passing array of feed id(s)
    $list = new GCE_Parser($ids, $title_text, $max_events, $sort_order);
    $num_errors = $list->get_num_errors();
    //If there are less errors than feeds parsed, at least one feed must have parsed successfully so continue to display the list
    if ($num_errors < count($ids)) {
        //If there was at least one error, and user is an admin, output error messages
        if ($num_errors > 0 && current_user_can('manage_options')) {
            echo $list->error_messages();
        }
        echo $list->get_list($grouped);
    } else {
        //If current user is an admin, display an error message explaining problem(s). Otherwise, display a 'nice' error messsage
        if (current_user_can('manage_options')) {
            echo $list->error_messages();
        } else {
            $options = get_option(GCE_GENERAL_OPTIONS_NAME);
            echo $options['error'];
        }
    }
}