示例#1
0
$plugin = Arlo_For_Wordpress::get_instance();
$plugin_slug = $plugin->get_plugin_slug();
// output the widget title
$title = apply_filters('widget_title', empty($instance['title']) ? __('Upcoming event', $plugin_slug) : $instance['title'], $instance, $this->id_base);
echo $before_title . $title . $after_title;
// number of events to list
$num = $instance['number'];
// event data
$events = $this->arlo_widget_get_upcoming_list($num);
$qty = is_array($events) ? count($events) : 0;
if ($qty > 0) {
    // start the list
    $output = '<ul class="arlo-list arlo-widget-upcoming">';
    for ($i = 0; $i < $qty; $i++) {
        $date = new DateTime($events[$i]->e_startdatetime);
        $id = arlo_get_post_by_name($events[$i]->et_post_name, 'arlo_event');
        $link = get_permalink($id->ID);
        // the event link
        $output .= '<li class="arlo-cf">';
        $output .= '<div class="arlo-left arlo-cal">';
        $output .= '<span class="arlo-cal-month">' . $date->format('M') . '</span>';
        $output .= '<span class="arlo-cal-day">' . $date->format('d') . '</span>';
        $output .= '</div>';
        $output .= '<p><a href="' . $link . '">' . $events[$i]->et_name . '</a></p>';
        $output .= '<p>' . $events[$i]->e_locationname . '</p>';
        $output .= '</li>';
    }
    // end the list
    $output .= '</ul>';
} else {
    $output = '<p>' . __('No upcoming events found', $plugin_slug) . '</p>';
    public static function load_demo_notice($error = [])
    {
        global $wpdb;
        $settings = get_option('arlo_settings');
        $timestamp = get_option('arlo_last_import');
        $events = arlo_get_post_by_name('events', 'page');
        $upcoming = arlo_get_post_by_name('upcoming', 'page');
        $presenters = arlo_get_post_by_name('presenters', 'page');
        $venues = arlo_get_post_by_name('venues', 'page');
        $notice_id = self::$dismissible_notices['newpages'];
        $user = wp_get_current_user();
        $meta = get_user_meta($user->ID, $notice_id, true);
        if (count($error)) {
            echo '
				<div class="' . (count($error) ? "error" : "") . ' notice is-dismissible" id="' . $notice_id . '">
		        	<p>' . sprintf(__('Couldn\'t set the following post types: %s', self::get_instance()->plugin_slug), implode(', ', $error)) . '</p>
		        	<button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
			 	</div>';
        } else {
            if ($meta !== '0') {
                if (!empty($settings['platform_name']) && $events !== false && $upcoming !== false && $presenters !== false && $venues !== false) {
                    //Get the first event template wich has event
                    $sql = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tID\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$wpdb->prefix}arlo_events AS e\n\t\t\t\t\tLEFT JOIN \t\t\n\t\t\t\t\t\t{$wpdb->prefix}arlo_eventtemplates AS et\t\t\n\t\t\t\t\tON\n\t\t\t\t\t\te.et_arlo_id = et.et_arlo_id\n\t\t\t\t\tAND\n\t\t\t\t\t\te.active = '{$timestamp}'\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$wpdb->prefix}posts\n\t\t\t\t\tON\n\t\t\t\t\t\tet_post_name = post_name\t\t\n\t\t\t\t\tAND\n\t\t\t\t\t\tpost_status = 'publish'\n\t\t\t\t\tWHERE \n\t\t\t\t\t\tet.active = '{$timestamp}'\n\t\t\t\t\tLIMIT \n\t\t\t\t\t\t1\n\t\t\t\t\t";
                    $event = $wpdb->get_results($sql, ARRAY_A);
                    $event_link = '';
                    if (count($event)) {
                        $event_link = sprintf('<a href="%s" target="_blank">%s</a>,', get_post_permalink($event[0]['ID']), __('Event', self::get_instance()->plugin_slug));
                    }
                    //Get the first presenter
                    $sql = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tID\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$wpdb->prefix}arlo_presenters AS p\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$wpdb->prefix}posts\n\t\t\t\t\tON\n\t\t\t\t\t\tp_post_name = post_name\t\t\n\t\t\t\t\tAND\n\t\t\t\t\t\tpost_status = 'publish'\n\t\t\t\t\tWHERE \n\t\t\t\t\t\tp.active = '{$timestamp}'\n\t\t\t\t\tLIMIT \n\t\t\t\t\t\t1\n\t\t\t\t\t";
                    $presenter = $wpdb->get_results($sql, ARRAY_A);
                    $presenter_link = '';
                    if (count($event)) {
                        $presenter_link = sprintf('<a href="%s" target="_blank">%s</a>,', get_post_permalink($presenter[0]['ID']), __('Presenter profile', self::get_instance()->plugin_slug));
                    }
                    //Get the first venue
                    $sql = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tID\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$wpdb->prefix}arlo_venues AS v\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t{$wpdb->prefix}posts\n\t\t\t\t\tON\n\t\t\t\t\t\tv_post_name = post_name\t\t\n\t\t\t\t\tAND\n\t\t\t\t\t\tpost_status = 'publish'\n\t\t\t\t\tWHERE \n\t\t\t\t\t\tv.active = '{$timestamp}'\n\t\t\t\t\tLIMIT \n\t\t\t\t\t\t1\n\t\t\t\t\t";
                    $venue = $wpdb->get_results($sql, ARRAY_A);
                    $venue_link = '';
                    if (count($event)) {
                        $venue_link = sprintf('<a href="%s" target="_blank">%s</a>,', get_post_permalink($venue[0]['ID']), __('Venue information', self::get_instance()->plugin_slug));
                    }
                    $message = '<h3>' . __('Start editing your new pages', self::get_instance()->plugin_slug) . '</h3><p>' . sprintf(__('View %s <a href="%s" target="_blank">%s</a>, <a href="%s" target="_blank">%s</a>, %s <a href="%s" target="_blank">%s</a> %s or <a href="%s" target="_blank">%s</a> pages', self::get_instance()->plugin_slug), $event_link, $events->guid, __('Catalogue', self::get_instance()->plugin_slug), $upcoming->guid, $upcoming->post_title, $presenter_link, $presenters->guid, __('Presenters list', self::get_instance()->plugin_slug), $venue_link, $venues->guid, __('Venues list', self::get_instance()->plugin_slug)) . '</p><p>' . __('Edit the page <a href="#pages" class="arlo-pages-setup">templates</a> for each of these websites pages below.') . '</p>';
                    echo '
					<div class="' . (count($error) ? "error" : "") . ' notice is-dismissible" id="' . $notice_id . '">
			        	' . $message . '
			        	<button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
				 	</div>
				 	';
                    unset($_SESSION['arlo-demo']);
                }
            }
        }
    }
示例#3
0
// presenter events list shortcode
$shortcodes->add('presenter_events_list', function ($content = '', $atts, $shortcode_name) {
    global $post, $wpdb, $arlo_plugin;
    $slug = get_post($post)->post_name;
    $active = $arlo_plugin->get_import_id();
    $slug_a = explode('-', $slug);
    $p_id = $slug_a[0];
    $t1 = "{$wpdb->prefix}arlo_eventtemplates";
    $t2 = "{$wpdb->prefix}arlo_events";
    $t3 = "{$wpdb->prefix}arlo_events_presenters";
    $items = $wpdb->get_results("SELECT \n\t\t\tet.et_name, et.et_post_name \n\t\tFROM \n\t\t\t{$t1} et\n\t\tLEFT JOIN \n\t\t\t{$t2} e \n\t\tON  \n\t\t\te.et_arlo_id = et.et_arlo_id\n\t\tAND\n\t\t\te.active = et.active\n\t\tINNER JOIN \n\t\t\t{$t3} exp \n\t\tON \n\t\t\texp.e_id = e.e_id\n\t\tAND \n\t\t\texp.active = e.active\n\t\tWHERE \n\t\t\texp.p_arlo_id = {$p_id} \n\t\tAND \n\t\t\te_parent_arlo_id = 0\n\t\tAND\n\t\t\te.active = {$active}\n\t\tGROUP BY \n\t\t\tet.et_name\n\t\tORDER BY \n\t\t\tet.et_name ASC", ARRAY_A);
    $events = '';
    if ($wpdb->num_rows > 0) {
        $events .= '<ul class="presenter-events">';
        foreach ($items as $item) {
            $et_id = arlo_get_post_by_name($item['et_post_name'], 'arlo_event');
            $permalink = get_permalink($et_id);
            $events .= '<li><a href="' . $permalink . '">' . htmlentities($item['et_name'], ENT_QUOTES, "UTF-8") . '</a></li>';
        }
        $events .= '</ul>';
    }
    return $events;
});
// timezones
$shortcodes->add('timezones', function ($content = '', $atts, $shortcode_name) {
    global $post, $wpdb, $arlo_plugin;
    $active = $arlo_plugin->get_import_id();
    // only allow this to be used on the eventtemplate page
    if ($post->post_type != 'arlo_event') {
        return '';
    }