Viewing 3 replies - 1 through 3 (of 3 total)
  • use this function

    function trimStringToFullWord($length, $string) {
    if (mb_strlen($string) <= $length) {
    $string = $string; //do nothing
    }
    else {
    $string = preg_replace(‘/\s+?(\S+)?$/u’, ”, mb_substr($string, 0, $length));
    }
    return $string;
    }

    Thread Starter raskull

    (@raskull)

    Thanks for your help! I do need to know how to filter it for Events Manager. This is what I tried, and it seems to work. But I have no idea what I am doing. Can you let me know if the world will end:

    function my_em_event_placeholder( $replace, $EM_Event, $result ){
    	if ( $result == '#_EVENTLINK' ) {
    		$event_link = esc_url( $EM_Event->get_permalink() );
    		$event_shortname = substr($EM_Event->event_name, 0, 30 );
    		if ( strlen( $EM_Event->event_name ) > 30 ) $event_shortname .= '&hellip;';
    		$replace = '<a href="' . $event_link . '" title="' . esc_attr( $EM_Event->event_name ) . '">' . esc_attr( $event_shortname ) . '</a>';
    	}
    	return $replace;
    }
    add_filter( 'em_event_output_placeholder', 'my_em_event_placeholder', 1, 3 );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Events Manager] truncate string length for #_EVENTLINK’ is closed to new replies.