Jimmylet
4/10/2019 - 7:45 AM

add_to_filters.php

/* Add these lines to /sage/app/filters.php */

/**
 * Use a custom vue for search form in Wordpress when call function get_search_form()
 * Create also a view searchform in "partials" for make the form.
 * 
 */
add_filter('get_search_form', function () {
  return \App\template( 'partials.searchform' );
});

/*
 * Detects if a sentence is longer than the value given and replaces the end words.
 */

function str_limit( $value, $limit = 100, $end = '…' )
{
  if (mb_strwidth($value, 'UTF-8') <= $limit) {
    return $value;
  }
  return rtrim( mb_strimwidth( $value, 0, $limit, '', 'UTF-8') ) . $end;
}