/**
  * Static Singleton Factory Method
  *
  * @return self
  */
 public static function instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Checks if there are existing settings from the Old iCal or Facebook Plugins
  * and displays a notice with a button to migrated those using AJAX
  *
  * @return string
  */
 public function notice()
 {
     if (!Tribe__Events__Aggregator__Page::instance()->is_screen()) {
         return false;
     }
     if (($this->is_facebook_migrated() || !$this->has_facebook_setting()) && ($this->is_ical_migrated() || !$this->has_ical_setting())) {
         return false;
     }
     $aggregator = Tribe__Events__Aggregator::instance();
     $html = '<p>' . esc_html__('Thanks for activating Event Aggregator! It looks like you have some settings and imports configured on our legacy importer plugins. To complete your transition, we need to transfer those options to our new system.', 'the-events-calendar');
     if (!$this->is_facebook_migrated() && $this->has_facebook_setting()) {
         $html .= '<p style="display:inline-block;">' . get_submit_button(esc_html__('Migrate Facebook Events settings', 'the-events-calendar'), 'secondary', 'tribe-migrate-facebook-settings', false) . '<span class="spinner"></span></p>';
     }
     if (!$this->is_ical_migrated() && $this->has_ical_setting()) {
         $html .= '<p style="display:inline-block;">' . get_submit_button(esc_html__('Migrate iCal Importer settings', 'the-events-calendar'), 'secondary', 'tribe-migrate-ical-settings', false) . '<span class="spinner"></span></p>';
     }
     return Tribe__Admin__Notices::instance()->render('tribe-aggregator-migrate-legacy-settings', $html);
 }
Example #3
0
 /**
  * Renders failed import messages
  */
 public function render_notice_import_failed()
 {
     if (empty($this->messages['error'])) {
         return null;
     }
     $html = '<p>' . implode(' ', $this->messages['error']) . '</p>';
     return Tribe__Admin__Notices::instance()->render('tribe-aggregator-import-failed', $html);
 }
    public function notice_facebook_token_expired()
    {
        if (!Tribe__Admin__Helpers::instance()->is_screen()) {
            return false;
        }
        $expires = tribe_get_option('fb_token_expires');
        // Empty Token
        if (empty($expires)) {
            return false;
        }
        /**
         * Allow developers to filter how many seconds they want to be warned about FB token expiring
         * @param int
         */
        $boundary = apply_filters('tribe_aggregator_facebook_token_expire_notice_boundary', 4 * DAY_IN_SECONDS);
        // Creates a Boundary for expire warning to appear, before the actual expiring of the token
        $boundary = $expires - $boundary;
        if (time() < $boundary) {
            return false;
        }
        $diff = human_time_diff(time(), $boundary);
        $passed = time() - $expires;
        $original = date('Y-m-d H:i:s', $expires);
        $time[] = '<span title="' . esc_attr($original) . '">';
        if ($passed > 0) {
            $time[] = sprintf(esc_html_x('about %s ago', 'human readable time ago', 'the-events-calendar'), $diff);
        } else {
            $time[] = sprintf(esc_html_x('in about %s', 'in human readable time', 'the-events-calendar'), $diff);
        }
        $time[] = '</span>';
        $time = implode('', $time);
        ob_start();
        ?>
		<p>
			<?php 
        if ($passed > 0) {
            echo sprintf(__('Your Event Aggregator Facebook token has expired %s.', 'the-events-calendar'), $time);
        } else {
            echo sprintf(__('Your Event Aggregator Facebook token will expire %s.', 'the-events-calendar'), $time);
        }
        ?>
		</p>
		<p>
			<a href="<?php 
        echo esc_url(Tribe__Settings::instance()->get_url(array('tab' => 'addons')));
        ?>
" class="tribe-license-link"><?php 
        esc_html_e('Renew your Event Aggregator Facebook token', 'the-events-calendar');
        ?>
</a>
		</p>
		<?php 
        $html = ob_get_clean();
        return Tribe__Admin__Notices::instance()->render('tribe-aggregator-facebook-token-expired', $html);
    }
Example #5
0
 /**
  * Displays the Archive confict notice using Tribe__Admin__Notices code
  *
  * @return string
  */
 public function render_notice_archive_slug_conflict()
 {
     $archive_slug = Tribe__Settings_Manager::get_option('eventsSlug', 'events');
     $conflict_query = new WP_Query(array('name' => $archive_slug, 'post_type' => 'any', 'post_status' => array('publish', 'private', 'inherit'), 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'posts_per_page' => 1));
     if (!$conflict_query->have_posts()) {
         return false;
     }
     // Set the Conflicted Post
     $conflict = $conflict_query->post;
     // Fetch the Post Type and Post Name
     $post_type = get_post_type_object($conflict->post_type);
     $name = empty($post_type->labels->singular_name) ? ucfirst($conflict->post_type) : $post_type->labels->singular_name;
     // What's happening?
     $page_title = apply_filters('the_title', $conflict->post_title, $conflict->ID);
     $line_1 = sprintf(__('The %3$s "%1$s" uses the "/%2$s" slug: the Events Calendar plugin will show its calendar in place of the page.', 'the-events-calendar'), $page_title, $archive_slug, $name);
     // What the user can do
     $edit_post_link = sprintf(__('Ask the site administrator to edit the %s slug', 'the-events-calendar'), $name);
     if (isset($post_type->cap->edit_posts) && current_user_can($post_type->cap->edit_posts)) {
         $edit_post_link = sprintf(__('<a href="%s">Edit the %s slug</a>', 'the-events-calendar'), get_edit_post_link($conflict->ID), $name);
     }
     $settings_cap = apply_filters('tribe_settings_req_cap', 'manage_options');
     $edit_settings_link = __(' ask the site administrator set a different Events URL slug.', 'the-events-calendar');
     if (current_user_can($settings_cap)) {
         $admin_slug = apply_filters('tribe_settings_admin_slug', 'tribe-common');
         $setting_page_link = apply_filters('tribe_settings_url', admin_url('edit.php?page=' . $admin_slug . '#tribe-field-eventsSlug'));
         $edit_settings_link = sprintf(__('<a href="%s">edit Events settings</a>.', 'the-events-calendar'), $setting_page_link);
     }
     $line_2 = sprintf(__('%1$s or %2$s', 'the-events-calendar'), $edit_post_link, $edit_settings_link);
     return Tribe__Admin__Notices::instance()->render('archive-slug-conflict', sprintf('<p>%s</p><p>%s</p>', $line_1, $line_2));
 }
    /**
     * Renders the notice itself (the provided HTML will be wrapped in a suitable container div).
     *
     * @param string $slug
     * @param string $inner_html
     */
    protected function render_notice($slug, $inner_html)
    {
        $spirit_animal = esc_url(Tribe__Main::instance()->plugin_url . 'src/resources/images/spirit-animal.png');
        $html = '<div class="api-check">
				<div class="tribe-spirit-animal">
					<img src="' . $spirit_animal . '"/>
				</div>
				<div class="notice-content">' . $inner_html . '</div>
			</div>';
        Tribe__Admin__Notices::instance()->render($slug, $html);
    }
    public function render_update_message()
    {
        if (!Tribe__Events__Aggregator__Page::instance()->is_screen()) {
            return;
        }
        $processor = Tribe__Events__Aggregator::instance()->queue_processor;
        if (!($this->record_id = $processor->next_waiting_record(true))) {
            return false;
        }
        $this->queue = $this->queue ? $this->queue : new Tribe__Events__Aggregator__Record__Queue($this->record_id);
        if ($this->queue->is_empty()) {
            return false;
        }
        $this->update_loop_vars();
        ob_start();
        $percent = $this->sanitize_progress($this->queue->progress_percentage());
        $spinner = '<img src="' . get_admin_url(null, '/images/spinner.gif') . '">';
        ?>
		<div class="tribe-message">
			<p>
				<?php 
        esc_html_e('Your import is currently in progress. Don\'t worry, you can safely navigate away&ndash;the import will continue in the background.', 'the-events-calendar');
        ?>
			</p>
		</div>
		<ul class="tracker">
			<li class="tracked-item track-created"><strong><?php 
        esc_html_e('Created:', 'the-events-calendar');
        ?>
</strong> <span class="value"></span></li>
			<li class="tracked-item track-updated"><strong><?php 
        esc_html_e('Updated:', 'the-events-calendar');
        ?>
</strong> <span class="value"></span></li>
			<li class="tracked-item track-skipped"><strong><?php 
        esc_html_e('Skipped:', 'the-events-calendar');
        ?>
</strong> <span class="value"></span></li>
		</ul>
		<div class="progress-container">
			<div class="progress" title="<?php 
        echo esc_html(sprintf(__('%d%% complete', 'the-events-calendar'), $percent));
        ?>
">
				<div class="bar"></div>
			</div>
			<img src="<?php 
        echo esc_url(get_admin_url(null, '/images/spinner.gif'));
        ?>
">
		</div>
		<?php 
        $html = ob_get_clean();
        return Tribe__Admin__Notices::instance()->render('aggregator-update-msg', $html);
    }
/**
 * Shortcut for Tribe__Admin__Notices::register(), create a Admin Notice easily
 *
 * @param  string          $slug      Slug to save the notice
 * @param  callable|string $callback  A callable Method/Fuction to actually display the notice
 * @param  array           $arguments Arguments to Setup a notice
 *
 * @return stdClass        Which notice was registered
 */
function tribe_notice($slug, $callback, $arguments = array())
{
    return Tribe__Admin__Notices::instance()->register($slug, $callback, $arguments);
}
Example #9
0
    public function notice_legacy_plugins()
    {
        if (!Tribe__Admin__Helpers::instance()->is_screen()) {
            return false;
        }
        $aggregator = Tribe__Events__Aggregator::instance();
        if (!$aggregator->is_service_active()) {
            return false;
        }
        $ical_active = $aggregator->is_legacy_ical_active();
        $facebook_active = $aggregator->is_legacy_facebook_active();
        if (!$ical_active && !$facebook_active) {
            return false;
        }
        $active = array();
        if ($facebook_active) {
            $active[] = '<b>' . esc_html__('Facebook Events', 'the-events-calendar') . '</b>';
        }
        if ($ical_active) {
            $active[] = '<b>' . esc_html__('iCal Importer', 'the-events-calendar') . '</b>';
        }
        ob_start();
        ?>
		<p>
			<?php 
        printf(esc_html(_n('It looks like you are using our legacy plugin, %1$s, along with our new Event Aggregator service. Event Aggregator includes all the features of the legacy plugin plus enhanced functionality. For best results, please deactivate %1$s.', 'It looks like you are using our legacy plugins, %1$s and %2$s, along with our new Event Aggregator service. Event Aggregator includes all the features of the legacy plugins plus enhanced functionality. For best results, please deactivate %1$s and %2$s.', count($active), 'the-events-calendar')), $active[0], isset($active[1]) ? $active[1] : '');
        ?>
		</p>
		<p>
			<a href="<?php 
        echo esc_url(admin_url('plugins.php?plugin_status=active'));
        ?>
"><?php 
        esc_html_e('Manage Active Plugins', 'the-events-calendar');
        ?>
</a>
		</p>
		<?php 
        $html = ob_get_clean();
        return Tribe__Admin__Notices::instance()->render('tribe-aggregator-legacy-import-plugins-active', $html);
    }
Example #10
0
 public static function render_notice_created_recurrences()
 {
     if (!Tribe__Admin__Helpers::instance()->is_post_type_screen(Tribe__Events__Main::POSTTYPE)) {
         return false;
     }
     if (empty($_REQUEST['post']) || !tribe_is_recurring_event($_REQUEST['post'])) {
         return false;
     }
     $pending = get_post_meta(get_the_ID(), '_EventNextPendingRecurrence', true);
     if (!$pending) {
         return false;
     }
     $start_dates = tribe_get_recurrence_start_dates(get_the_ID());
     $count = count($start_dates);
     $last = end($start_dates);
     $pending_message = __('%d instances of this event have been created through %s. <a href="%s">Learn more.</a>', 'tribe-events-calendar-pro');
     $pending_message = '<p>' . sprintf($pending_message, $count, date_i18n(tribe_get_date_format(true), strtotime($last)), 'http://m.tri.be/lq') . '</p>';
     return Tribe__Admin__Notices::instance()->render('created-recurrences', $pending_message);
 }
 /**
  * Returns the HTML for a notice depending on the if we have Legacy Items to be Migrated
  *
  * @return string
  */
 public function render_notice_legacy()
 {
     if (!Tribe__Admin__Helpers::instance()->is_post_type_screen(Tribe__Events__Main::POSTTYPE)) {
         return false;
     }
     if (empty($_GET['post_status']) || $_GET['post_status'] !== self::$ignored_status) {
         return false;
     }
     if (!$this->has_legacy_deleted_posts()) {
         return false;
     }
     $html = '<p>' . esc_html__('Event Aggregator includes a new, better system for removing unwanted imported events from your calendar. Click the button below to transition previously deleted events. This process will remove unwanted records from your database and include recent or upcoming trashed events in your Ignored archive.', 'the-events-calendar');
     $html .= ' <a href="https://theeventscalendar.com/knowledgebase/ignored-events/" target="_blank">' . esc_html_x('Read more about Ignored Events.', 'link to knowlegebase article', 'the-events-calendar') . '</a></p>';
     $html .= '<p style="display:inline-block;">' . get_submit_button(esc_html__('Migrate Legacy Ignored Events'), 'secondary', 'tribe-migrate-legacy-events', false) . '<span class="spinner"></span></p>';
     return Tribe__Admin__Notices::instance()->render('legacy-ignored-events', $html);
 }