Exemplo n.º 1
0
 /**
  * Static Singleton Factory Method
  *
  * @return Tribe__Admin__Helpers
  */
 public static function instance()
 {
     if (empty(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemplo n.º 2
0
 /**
  * Add ratings nudge in admin footer
  *
  * @param $footer_text
  *
  * @return string
  */
 public function rating_nudge($footer_text)
 {
     $admin_helpers = Tribe__Admin__Helpers::instance();
     // only display custom text on Tribe Admin Pages
     if ($admin_helpers->is_screen() || $admin_helpers->is_post_type_screen()) {
         $review_url = 'http://wordpress.org/support/view/plugin-reviews/the-events-calendar?filter=5';
         $footer_text = sprintf(esc_html__('Rate %3$sThe Events Calendar%4$s %1$s on %2$s to keep this plugin free.  Thanks from the friendly folks at Modern Tribe.', 'tribe-common'), '<a href="' . $review_url . '" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>', '<a href="' . $review_url . '" target="_blank">WordPress.org</a>', '<strong>', '</strong>');
     }
     return $footer_text;
 }
Exemplo n.º 3
0
 /**
  * Add ratings nudge in admin footer
  *
  * @param $footer_text
  *
  * @return string
  */
 public function rating_nudge($footer_text)
 {
     $admin_helpers = Tribe__Admin__Helpers::instance();
     add_filter('tribe_tickets_post_types', array($this, 'tmp_return_tribe_events'), 99);
     // only display custom text on Tribe Admin Pages
     if ($admin_helpers->is_screen() || $admin_helpers->is_post_type_screen()) {
         if (class_exists('Tribe__Events__Main')) {
             $review_url = 'https://wordpress.org/support/view/plugin-reviews/the-events-calendar?filter=5';
             $footer_text = sprintf(esc_html__('Rate %1$sThe Events Calendar%2$s %3$s', 'tribe-common'), '<strong>', '</strong>', '<a href="' . $review_url . '" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>');
         } else {
             $review_url = 'https://wordpress.org/support/view/plugin-reviews/event-tickets?filter=5';
             $footer_text = sprintf(esc_html__('Rate %1$sEvent Tickets%2$s %3$s', 'tribe-common'), '<strong>', '</strong>', '<a href="' . $review_url . '" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>');
         }
     }
     remove_filter('tribe_tickets_post_types', array($this, 'tmp_return_tribe_events'), 99);
     return $footer_text;
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 public function admin_enqueue_scripts()
 {
     wp_enqueue_script('tribe-inline-bumpdown');
     wp_enqueue_script('tribe-notice-dismiss');
     wp_enqueue_style('tribe-common-admin');
     $helper = Tribe__Admin__Helpers::instance();
     if ($helper->is_post_type_screen()) {
         wp_enqueue_style('tribe-jquery-ui-datepicker');
     }
 }
Exemplo n.º 6
0
 /**
  * Registers resources that can/should be enqueued
  */
 public function load_assets()
 {
     // These ones are only registred
     tribe_assets($this, array(array('tribe-clipboard', 'vendor/clipboard/clipboard.js'), array('datatables', 'vendor/datatables/media/js/jquery.dataTables.js', array('jquery')), array('datatables-css', 'datatables.css'), array('datatables-responsive', 'vendor/datatables/extensions/Responsive/js/dataTables.responsive.js', array('jquery', 'datatables')), array('datatables-responsive-css', 'vendor/datatables/extensions/Responsive/css/responsive.dataTables.css'), array('datatables-select', 'vendor/datatables/extensions/Select/js/dataTables.select.js', array('jquery', 'datatables')), array('datatables-select-css', 'vendor/datatables/extensions/Select/css/select.dataTables.css'), array('datatables-scroller', 'vendor/datatables/extensions/Scroller/js/dataTables.scroller.js', array('jquery', 'datatables')), array('datatables-scroller-css', 'vendor/datatables/extensions/Scroller/css/scroller.dataTables.css'), array('datatables-fixedheader', 'vendor/datatables/extensions/FixedHeader/js/dataTables.fixedHeader.js', array('jquery', 'datatables')), array('datatables-fixedheader-css', 'vendor/datatables/extensions/FixedHeader/css/fixedHeader.dataTables.css'), array('tribe-datatables', 'tribe-datatables.js', array('datatables', 'datatables-select')), array('tribe-bumpdown', 'bumpdown.js', array('jquery', 'underscore', 'hoverIntent')), array('tribe-bumpdown-css', 'bumpdown.css')));
     // These ones will be enqueued on `admin_enqueue_scripts` if the conditional method on filter is met
     tribe_assets($this, array(array('tribe-common-admin', 'tribe-common-admin.css', array('tribe-dependency-style', 'tribe-bumpdown-css')), array('tribe-dependency', 'dependency.js', array('jquery', 'underscore')), array('tribe-dependency-style', 'dependency.css'), array('tribe-pue-notices', 'pue-notices.js', array('jquery')), array('tribe-jquery-ui-theme', 'vendor/jquery/ui.theme.css'), array('tribe-jquery-ui-datepicker', 'vendor/jquery/ui.datepicker.css')), 'admin_enqueue_scripts', array('filter' => array(Tribe__Admin__Helpers::instance(), 'is_post_type_screen'), 'localize' => (object) array('name' => 'tribe_system_info', 'data' => array('sysinfo_optin_nonce' => wp_create_nonce('sysinfo_optin_nonce'), 'clipboard_btn_text' => __('Copy to clipboard', 'tribe-common'), 'clipboard_copied_text' => __('System info copied', 'tribe-common'), 'clipboard_fail_text' => __('Press "Cmd + C" to copy', 'tribe-common')))));
     tribe_asset($this, 'tribe-common', 'tribe-common.js', array('tribe-clipboard'), 'admin_enqueue_scripts', array('localize' => array('name' => 'tribe_l10n_datatables', 'data' => array('aria' => array('sort_ascending' => __(': activate to sort column ascending', 'tribe-common'), 'sort_descending' => __(': activate to sort column descending', 'tribe-common')), 'length_menu' => __('Show _MENU_ entries', 'tribe-common'), 'empty_table' => __('No data available in table', 'tribe-common'), 'info' => __('Showing _START_ to _END_ of _TOTAL_ entries', 'tribe-common'), 'info_empty' => __('Showing 0 to 0 of 0 entries', 'tribe-common'), 'info_filtered' => __('(filtered from _MAX_ total entries)', 'tribe-common'), 'zero_records' => __('No matching records found', 'tribe-common'), 'search' => __('Search:', 'tribe-common'), 'pagination' => array('all' => __('All', 'tribe-common'), 'next' => __('Next', 'tribe-common'), 'previous' => __('Previous', 'tribe-common')), 'select' => array('rows' => array(0 => '', '_' => __(': Selected %d rows', 'tribe-common'), 1 => __(': Selected 1 row', 'tribe-common')))))));
 }
Exemplo n.º 7
0
 /**
  * When the edit-tags.php screen loads, setup filters
  * to fix the tagcloud links
  *
  */
 public function prepare_to_fix_tagcloud_links()
 {
     if (Tribe__Admin__Helpers::instance()->is_post_type_screen(self::POSTTYPE)) {
         add_filter('get_edit_term_link', array($this, 'add_post_type_to_edit_term_link'), 10, 4);
     }
 }
Exemplo n.º 8
0
    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);
    }
 /**
  * Determine if the event can use the default organizer setting
  *
  * @param array $current_organizers
  *
  * @return bool
  */
 protected function use_default_organizer($current_organizers)
 {
     if (!empty($current_organizers)) {
         return false;
         // the event already has organizers
     }
     if (!empty($this->event->ID) && get_post_status($this->event->ID) != 'auto-draft') {
         return false;
         // the event has already been saved
     }
     if (is_admin()) {
         return Tribe__Admin__Helpers::instance()->is_action('add');
     } else {
         return true;
         // a front-end submission form (e.g., community)
     }
 }
 /**
  * Returns whether or not the event date & upcoming filters should be removed from the query
  *
  * @since 4.0
  * @param WP_Query $query WP_Query object
  * @return boolean
  */
 public static function should_remove_date_filters($query)
 {
     // if we're doing ajax, let's keep the date filters
     if (Tribe__Main::instance()->doing_ajax()) {
         return false;
     }
     // otherwise, let's remove the date filters if we're in the admin dashboard and the query is
     // and event query on the tribe_events edit page
     return is_admin() && $query->tribe_is_event_query && Tribe__Admin__Helpers::instance()->is_screen('edit-' . Tribe__Events__Main::POSTTYPE);
 }
Exemplo n.º 11
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);
    }
 /**
  * Allows Bulk Actions to Work it's magic (more Complex than it needs to be)
  *
  * @return void|false
  */
 public function action_restore_ignored()
 {
     if (!Tribe__Admin__Helpers::instance()->is_post_type_screen(Tribe__Events__Main::POSTTYPE)) {
         return false;
     }
     if (!isset($_GET['ids'])) {
         return false;
     }
     if (!isset($_GET['tribe-action']) || 'tribe-restore' !== $_GET['tribe-action']) {
         return false;
     }
     if (!isset($_GET['_wpnonce']) || !wp_verify_nonce($_GET['_wpnonce'], 'tribe-restore')) {
         return false;
     }
     $ids = (array) explode(',', $_GET['ids']);
     $restored = array();
     foreach ($ids as $id) {
         if (!current_user_can('delete_post', $id)) {
             wp_die(esc_html__('You do not have permission to restore this post.', 'the-events-calendar'));
         }
         $restore = $this->restore_event($id);
         if (!$restore) {
             wp_die(esc_html__('Error restoring from Ignored Events.', 'the-events-calendar'));
         }
         $restored[] = $restore;
     }
     $count_restored = count($restored);
     $message = '<p>' . sprintf(_n('%s post restored.', '%s posts restored.', $count_restored, 'the-events-calendar'), $count_restored) . '</p>';
     if (!empty($_SERVER['REQUEST_URI'])) {
         $_SERVER['REQUEST_URI'] = remove_query_arg(array('tribe-action', '_wpnonce'), $_SERVER['REQUEST_URI']);
     } elseif (!empty($_REQUEST['_wp_http_referer'])) {
         $_REQUEST['_wp_http_referer'] = remove_query_arg(array('tribe-action', '_wpnonce'), $_REQUEST['_wp_http_referer']);
     } elseif (!empty($_SERVER['HTTP_REFERER'])) {
         $_SERVER['HTTP_REFERER'] = remove_query_arg(array('tribe-action', '_wpnonce'), $_SERVER['HTTP_REFERER']);
     }
     return tribe_notice('restored-events', $message, 'dismiss=1&type=success');
 }