• Resolved gleanreport

    (@gleanreport)


    Hi, thanks again for a wonderful plugin.

    {is_newpost}*NEW*{/is_newpost} is not working following upgrade with the following code, can anyone assist?

    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']=='newposts' ){
                    $start_date = date('Y-m-d H:i:s',strtotime("-2 days", current_time('timestamp')));
                    $conditions['scope'] = " ( event_date_modified >= '$start_date') OR ( event_date_created >= '$start_date')";
            }
            return $conditions;
    }
    
    add_filter( 'em_get_scopes','my_em_scopes',1,1);
    function my_em_scopes($scopes){
    	$my_scopes = array(
    		'newposts' => 'New Posts'
    	);
    	return $scopes + $my_scopes;
    }
    
    add_action('em_event_output_condition', 'my_em_styles_event_output_condition', 1, 4);
    function my_em_styles_event_output_condition($replacement, $condition, $match, $EM_Event){
          if( is_object($EM_Event) && preg_match('/^is_newpost$/',$condition, $matches) ){
            if( strtotime($EM_Event->event_date_created) >= strtotime("-3 days", current_time('timestamp'))){
                $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
            }else{
                $replacement = '';
            }
        }
        return $replacement;
    }

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Change the fucntion my_em_styles_event_output_condition to this:

    function my_em_styles_event_output_condition($replacement, $condition, $match, $EM_Event){
          if( is_object($EM_Event) && preg_match('/^is_newpost$/',$condition, $matches) ){
            $date_created = get_the_date( '', $EM_Event->post_id);
            if( strtotime($date_created) >= strtotime("-3 days", current_time('timestamp'))){
                $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
            }else{
                $replacement = '';
            }
        }
        return $replacement;
    }
    
    Thread Starter gleanreport

    (@gleanreport)

    That works! Thank you so much.

    Thread Starter gleanreport

    (@gleanreport)

    Actually, this is is bringing up every event as newposts! Is there a way to only bring up the ones that are -3 days old?

    Thread Starter gleanreport

    (@gleanreport)

    Apologies, this is a conditional placeholder not custom shortcode. Any chance that it will be fixed in the next update for Events Manager?

    I have no idea if or when the plugin owner plans to fix this.

    Thread Starter gleanreport

    (@gleanreport)

    This conditional placeholder is still not working – any ideas when this might be fixed?

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

The topic ‘Custom shortcode not working after upgrade’ is closed to new replies.