';
$wrapped = '';
if ( $with_wrapper ) {
$wrapped .= '
';
}
if ( apply_filters( 'vamtam_enable_image_lazyload', true ) ) {
$new_srcset = 'srcset="data:image/svg+xml;utf8,' . esc_attr( str_replace( ' ', '%20', $svg ) ) . '"';
$wrapped .= str_replace( 'srcset=', $new_srcset . ' data-srcset=', $html, $replacements );
if ( $replacements === 0 ) {
$wrapped = preg_replace( '/src="([^"]+)"/', 'src="$1" data-srcset="$1" ' . $new_srcset, $wrapped, 1 );
}
} else {
$wrapped .= $html;
}
if ( $with_wrapper ) {
$wrapped .= '
';
}
return $wrapped;
}
public static function widget_title( $title = '', $instance = null, $id_base = null ) {
if ( ! is_null( $instance ) && $id_base === 'recent-posts' && empty( $instance['title'] ) ) {
return '';
}
return $title;
}
public static function unlimited_image_sizes() {
add_filter( 'wp_calculate_image_sizes', array( __CLASS__, 'wp_calculate_image_sizes' ), 10, 5 );
}
public static function limit_image_sizes() {
remove_filter( 'wp_calculate_image_sizes', array( __CLASS__, 'wp_calculate_image_sizes' ), 10, 5 );
}
public static function wp_calculate_image_sizes( $sizes, $size, $image_src, $image_meta, $attachment_id ) {
return '(min-width: 900px) 50vw, 100vw';
}
public static function post_siblings() {
if ( VamtamTemplates::has_post_siblings_buttons() ) {
get_template_part( 'templates/post-siblings-links' );
}
}
public static function prepare_excerpt( $text = '', $raw_excerpt ) {
if ( '' == $raw_excerpt ) {
$text = get_the_content( '' );
$text = VamtamTemplates::remove_outer_columns( $text );
$text = strip_shortcodes( $text );
/** This filter is documented in wp-includes/post-template.php */
$text = apply_filters( 'the_content', $text );
$text = str_replace( ']]>', ']]>', $text );
$excerpt_length = apply_filters( 'excerpt_length', 40 );
$excerpt_more = apply_filters( 'excerpt_more', ' […]' );
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
return $text;
}
public static function jetpack_remove_share() {
remove_filter( 'the_content', 'sharing_display',19 );
remove_filter( 'the_excerpt', 'sharing_display',19 );
if ( class_exists( 'Jetpack_Likes' ) ) {
remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
}
}
public static function header_layout( $layout ) {
$logo_type = rd_vamtam_get_option( 'header-logo-type' );
if ( $logo_type === 'names' ) {
return 'standard';
}
return $layout;
}
public static function wp_title( $title ) {
if ( empty( $title ) && ( is_home() || is_front_page() ) ) {
$description = get_bloginfo( 'description' );
return get_bloginfo( 'name' ) . ( ! empty( $description ) ? ' | ' . $description : '' );
}
return $title;
}
/**
* enable any shortcodes in CF7
* @param string $form original html
* @return string parsed with do_shortcode
*/
public static function shortcodes_in_cf7( $form ) {
return do_shortcode( vamtam_fix_shortcodes( $form ) );
}
/**
* Show a splash screen on some pages
*/
public static function vamtam_splash_screen() {
$local = vamtam_post_meta( null, 'show-splash-screen-local', true );
$enabled = $local === 'default' ? rd_vamtam_get_option( 'show-splash-screen' ) : vamtam_sanitize_bool( $local );
$style = '';
if ( ! $enabled ) {
if ( ! is_customize_preview() ) {
return;
}
$style = 'style="display: none"'; // we need the html for the customizer preview, but there is no need to show it on the first load
}
$logo = rd_vamtam_get_option( 'splash-screen-logo' );
echo ''; // xss ok
echo '
';
if ( ! empty( $logo ) ) {
vamtam_url_to_image( $logo, 'full' );
}
echo '
';
echo '';
wp_enqueue_script( 'vamtam-splash-screen' );
}
/**
* Remove unnecessary menu item classes
*
* @param array $classes current menu item classes
* @param object $item menu item
* @param object $args menu item args
* @return array filtered classes
*/
public static function nav_menu_css_class( $classes, $item ) {
if ( isset( $item->url ) && strpos( $item->url, '#' ) !== false && ( $key = array_search( 'mega-current-menu-item', $classes ) ) !== false ) {
unset( $classes[ $key ] );
$classes[] = 'maybe-current-menu-item';
$GLOBALS['vamtam_menu_had_hash'] = true;
}
if ( isset( $GLOBALS['vamtam_menu_had_hash'] ) && $GLOBALS['vamtam_menu_had_hash'] ) {
$classes = array_diff( $classes, array( 'mega-current-menu-item', 'mega-current-menu-ancestor', 'mega-current-menu-parent' ) );
}
return $classes;
}
/**
* Wrap oEmbeds in .vamtam-video-frame
*
* @param string $output original oembed output
* @param object $data data from the oEmbed provider
* @param string $url original embed url
* @return string $output wrapped in additional html
*/
public static function oembed_dataparse( $output, $data, $url ) {
if ( $data->type == 'video' )
return '' . $output . '
';
return $output;
}
/**
* Implements .swf oEmbeds
*
* @param array $matches preg_match matches
* @param array $attr embed attributes
* @param string $url embed url
* @param array $rawattr raw attributes
* @return string output html
*/
public static function embed_handler_swf( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'
',
esc_attr( $matches[0] ),
esc_attr( $attr['width'] ),
esc_attr( $attr['height'] )
);
return apply_filters( 'vamtam_embed_swf', $embed, $matches, $attr, $url, $rawattr );
}
/**
* Sets the excerpt length
*
* @param int $length original length
* @return int excerpt length
*/
public static function excerpt_length( $length ) {
global $vamtam_loop_vars;
if ( isset( $vamtam_loop_vars ) && $vamtam_loop_vars['news'] )
return 15;
return $length;
}
/**
* Sets the excerpt ending
*
* @param string $more original ending
* @return string excerpt ending
*/
public static function excerpt_more( $more ) {
return '...';
}
}