Disabling the plugin brings down my site

Home Forums Calendar Products Events Calendar PRO Disabling the plugin brings down my site

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1284808
    Mark
    Participant

    Hi,

    I’ve noticed that when I disable the plugin it completely brings down my site http://www.financialtrainingassociates.com, which is surprising me.

    I have tried disabling all the plugins but the site remains down. It’s only when I enable the calendar plugin that the site comes back up.

    Any ideas about what could be causing this? Is this a known issue?

    Obviously I like the plugin but I am not sure I want it for life and I would like to be able to disable it without bringing down the website!

    Thanks a lot,

    #1285204
    Cliff
    Member

    Hi. This definitely shouldn’t be happening. I’m guessing you have some custom code that isn’t checking if our plugin exists and, when it doesn’t, it fails. It might be in your active theme’s functions.php file…

    Please enable WP_DEBUG and WP_DEBUG_LOG (which will create a file on your server at /wp-content/debug.log if there are any WP_DEBUG messages) and share any debug messages you see during normal operation of your site (hopefully none) and then deactivate The Events Calendar plugin and you should definitely get at least one debug message.

    Please let me know how this goes for you.

    #1285352
    Mark
    Participant

    Thank you thank you thank you! You solved my problem: you mentioned the word “functions”. I totally forgot that I had modded my functions.php to add some extra functionality to the calendar. When I took out those pieces of code the world fell back into order.

    For the record, these were the instructions I followed/ code I used. It seems that you need to take these out of functions.php if you want to disable the calendar. Otherwise, as I found, your site will fall over. This was the code involved. It needed to be removed from functions.php ahead of disabling the calendar:
    https://theeventscalendar.com/knowledgebase/fast-forward-list-widget-to-next-upcoming-event/
    https://theeventscalendar.com/knowledgebase/make-links-event-go-straight-event-website/
    https://github.com/Automattic/amp-wp/blob/master/readme.md#custom-post-type-support
    https://theeventscalendar.com/support/forums/topic/will-you-support-amp-accelerated-mobile-pages/

    Thanks once more – you are a genius!

    • This reply was modified 6 years, 11 months ago by Mark.
    #1285889
    Cliff
    Member

    I’m very glad to hear this!

    Could you please post your active theme’s full functions.php file in a Secret gist and share it here in a Private reply?

    Also, enabling WP_DEBUG and WP_DEBUG_LOG (which will create a file on your server at /wp-content/debug.log if there are any WP_DEBUG messages) will reveal any errors in case something drastic like this happens in the future.

    #1286313
    Mark
    Participant

    Here is the code that needed to be removed from my child functions.php. Once I took this out I could disable the Calendar plugin safely (it no longer brought down my site)

    /* Below here added 15Dec16 as per code at https://theeventscalendar.com/knowledgebase/fast-forward-list-widget-to-next-upcoming-event/ */
    /**
     * Plugin name: The Events Calendar: Advance Mini Calendar Widget
     * Description: Tries to force the minicalendar widget to show the month of the next upcoming event by default, rather than simply showing the current month (which might be empty).
     * Author:      Modern Tribe, Inc
     * Author URI:  http://theeventscalendar.com
     * Version:     1.0
     * License:     GPL v3 - see http://www.gnu.org/licenses/gpl.html
     *
     * The Events Calendar: Advance Mini Calendar Widget
     * Copyright (C) 2016 Modern Tribe, Inc
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */
    
    class Tribe_Advance_Minical {
    
    	protected $target_date = false;
    
    	/**
    	 * Sets up auto advance for minicalendar widgets. If an optional target date is provided that will be used to
    	 * set the month.
    	 *
    	 * @param bool $target_date
    	 */
    	public function __construct( $target_date = false ) {
    		
    		if ( is_admin() )
    			return;
    		
    		$this->target_date = $target_date;
    		
    		add_action( 'wp_loaded', array( $this, 'set_target_date' ) );
    		add_filter( 'widget_display_callback', array( $this, 'advance_minical' ), 20, 2 );
    	}
    
    	/**
    	 * Basic check to help filter out spurious date formats or automatically determine
    	 * the next most appropriate date to use.
    	 */
    	public function set_target_date() {
    
    		if ( ! is_string($this->target_date) || 1 !== preg_match( '#^\d{4}-\d{2}(-\d{2})?$# ', $this->target_date ) )
    			$this->target_date = $this->next_upcoming_date();
    	}
    
    	public function advance_minical( $instance, $widget ) {
    		
    		if ( 'tribe-mini-calendar' !== $widget->id_base || isset( $instance['eventDate'] ) )
    			return $instance;
    		
    		if ( date( 'Y-m' ) === $this->target_date )
    			return;
    		
    		add_action( 'tribe_before_get_template_part', array( $this, 'modify_list_query' ), 5 );
    		
    		$instance['eventDate'] = $this->target_date;
    		
    		return $instance;
    	}
    
    	public function modify_list_query( $template ) {
    
    		if ( false === strpos( $template, 'mini-calendar/list.php' ) )
    			return;
    		
    		add_action( 'parse_query', array( $this, 'amend_list_query' ) );
    	}
    
    	public function amend_list_query( $query ) {
    
    		// Run this once only.
    		remove_action( 'parse_query', array( $this, 'amend_list_query' ) );
    		
    		$the_query = $query->query_vars;
    
    		$the_query['start_date'] = $this->target_date . '-01';
    		$last_day = Tribe__Date_Utils::get_last_day_of_month( strtotime( $the_query['start_date'] ) );
    		$the_query['end_date'] = substr_replace( $the_query['start_date'], $last_day, -2 );
    		$the_query['end_date'] = tribe_end_of_day( $the_query['end_date'] );
    
    		$query->query_vars = $the_query;
    	}
    
    	protected function next_upcoming_date() {
    		$next_event = tribe_get_events( array(
    			'eventDisplay'   => 'list',
    			'posts_per_page' => 1,
    			'start_date'     => date( 'Y-m-d' )
    		));
    
    		$start_date = date( 'Y-m' );
    
    		if ( !empty( $next_event ) || isset( $next_event[0] ) ) {
    			$next_event_date = tribe_get_start_date( $next_event[0]->ID, false, 'Y-m' );
    
    			// Prevent calendar from rewinding to the start of a currently ongoing event
    			$start_date = ( $next_event_date > $start_date ) ? $next_event_date : $start_date;
    		}
    
    		return $start_date;
    	}
    }
    
    // Brings the mini calendar to the next month with events.
    new Tribe_Advance_Minical();
    /* Above here added 15Dec16 as per code at https://theeventscalendar.com/knowledgebase/fast-forward-list-widget-to-next-upcoming-event/ */
    
    /* Below here added 15Dec16 as per https://theeventscalendar.com/knowledgebase/make-links-event-go-straight-event-website/ */
    /*
     * This changes the event link to the event website URL if that is set.
     * NOTE: Comment out the add_filter() line to disable this function.
     */
    /*function tribe_set_link_website ( $link, $postId ) {
     * 	$website_url = tribe_get_event_website_url( $postId );
     * 	// Only swaps link if set
     * 	if ( !empty( $website_url ) ) {
     * 		$link = $website_url;
     * 	}
     * 	return $link;
     * }
     * add_filter( 'tribe_get_event_link', 'tribe_set_link_website', 100, 2 );
     */
    /* Above here added 15Dec16 as per https://theeventscalendar.com/knowledgebase/make-links-event-go-straight-event-website/ */
    
    // Adds regular categories to tribe events
    function mytribecalendar_settings() {   
    // Add category metabox to page
    register_taxonomy_for_object_type('category', 'tribe_events');  
    }
    
    //-------------------------------------------------
    //
    // GOOGLE AMP FOR TRIBE CALENDAR
    //
    //-------------------------------------------------
    //Added 10Mar17 as per https://github.com/Automattic/amp-wp/blob/master/readme.md#custom-post-type-support
    // And also https://theeventscalendar.com/support/forums/topic/will-you-support-amp-accelerated-mobile-pages/
    
    add_action( 'amp_init', 'amp_add_tribe_events_cpt' );
    function amp_add_tribe_events_cpt() {
        add_post_type_support( 'tribe_events', AMP_QUERY_VAR );
    }
    
    
    #1287162
    Cliff
    Member

    Thanks. I see you moved the code from https://theeventscalendar.com/knowledgebase/fast-forward-list-widget-to-next-upcoming-event/, which is a fully-functioning, standalone plugin, into your theme’s functions.php file. This could be the cause of it but not necessarily.

    Please enable WP_DEBUG and WP_DEBUG_LOG, as I shared in my initial reply, and then deactivate The Events Calendar again, and see what your WP_DEBUG message says. It’ll likely tell you the exact line from your functions.php file that is causing the issue.

    If you tell me that, I can possibly help resolve this to avoid the potential for this issue in the future.

    #1287180
    Mark
    Participant

    Thanks Cliff,

    I thought I had marked this as “solved” because it is now!

    As soon as I took that code out of my functions.php I could disable the
    plugin.

    So all is good thanks!

    Thanks for your help on this…

    #1287193
    Cliff
    Member

    You did mark it as Resolved, and I appreciated you sharing so much detail.

    It sounded like you were still using the code above, in which case, I was going to make it more robust so as to not mess with your site if The Events Calendar got deactivated. To do so, I’d need to know the line number your WP_DEBUG was calling out.

    However, I tested your code snippet on my own site and determined that, within public function __construct( $target_date = false ) {, this line:

    if ( is_admin() )

    should be replaced with this line:

    if ( is_admin() || ! function_exists( 'tribe_get_events' ) )

    This KB’s plugin will eventually get transferred to our Extensions framework, which will avoid this issue for future installs. Thanks for helping us discover this bug.

    To be clear, our plugins should never cause your site to have such errors, whether our plugins are activated or deactivated/uninstalled.

    #1297265
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Disabling the plugin brings down my site’ is closed to new replies.