• Resolved evobenno

    (@evobenno)


    i have the extra bit of code on the functions.php file in the child theme so i can list events as “upcoming”

    meaning all events after today

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    <?php
    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    function my_em_scope_conditions($conditions, $args){
    	if( !empty($args['scope']) && $args['scope']=='upcoming' ){
    		$start_date = date('Y-m-d',strtotime("+1 days", current_time('timestamp')));
    		$end_date = date('Y-m-d',strtotime("+2 years", current_time('timestamp')));
    		$conditions['scope'] = " (event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE)) OR (event_end_date BETWEEN CAST('$end_date' AS DATE) AND CAST('$start_date' AS DATE))";
    	}
    	return $conditions;
    }
    ?>

    anyways its been working great, but every time i test other themes, then return to my current theme, this functions.php file in the child theme keeps getting rejected, and my whole website crashes with the following error…

    Fatal error: Cannot redeclare _verify_activeatewidgets() (previously declared in /home/676687666/public_html/wp-content/themes/CarZilla-Child/functions.php:19) in /home/676687666/public_html/wp-content/themes/CarZilla/functions.php on line 92

    all i do is delete my functions.php, and website works again, but i want to be able to use my UPCOMING events scope

    any ideas whats going wrong? thanks for any help 🙁

    https://wordpress.org/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m pretty sure this is a WordPress bug / feature, rather than something specific to Events Manager. It’s caused when widgets are re-used between themes.

    If you clear out your widgets before switching themes that should stop the problem.

    Thread Starter evobenno

    (@evobenno)

    hmm yeah thankyou

    i put a work around the scope code by putting an if function doesnt exists before the code, but this seems stupid to me cos the function does exist…

    if(!function_exists(‘_verify_activeatewidgets()’)):

    full code…

    <?php
    
    if(!function_exists('_verify_activeatewidgets()')):
    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    function my_em_scope_conditions($conditions, $args){
    	if( !empty($args['scope']) && $args['scope']=='upcoming' ){
    		$start_date = date('Y-m-d',strtotime("+1 days", current_time('timestamp')));
    		$end_date = date('Y-m-d',strtotime("+2 years", current_time('timestamp')));
    		$conditions['scope'] = " (event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE)) OR (event_end_date BETWEEN CAST('$end_date' AS DATE) AND CAST('$start_date' AS DATE))";
    	}
    	return $conditions;
    }
    
    endif;
    ?>

    havnt faced the error since, websites functioning normally – strange to me

    Actually, that’s the problem – !function_exists is meant for exactly this type of scenario and to stop errors cropping up.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Cannot redeclare _verify_activeatewidgets()’ is closed to new replies.