theme_location || ! $item->description ) {
return $item_output;
}
$descr_enabled = get_theme_mod(
'header_menu_attributes',
bikes2ride_theme()->customizer->get_default( 'header_menu_attributes' )
);
if ( ! $descr_enabled ) {
return $item_output;
}
$current = $args->link_after . '';
$description = '
';
$item_output = str_replace( $current, $description . $current, $item_output );
return $item_output;
}
/**
* Set layout classes for sidebars.
*
* @since 1.0.0
* @uses bikes2ride_get_layout_classes.
*
* @param array $classes Additional classes.
* @param string $area_id Sidebar ID.
*
* @return array
*/
function bikes2ride_set_sidebar_classes( $classes, $area_id ) {
if ( 'sidebar' == $area_id ) {
return bikes2ride_get_layout_classes( 'sidebar', $classes );
}
if ( 'footer-area' == $area_id ) {
$columns = get_theme_mod( 'footer_widget_columns', bikes2ride_theme()->customizer->get_default( 'footer_widget_columns' ) );
if ( '1' !== $columns ) {
$classes[] = sprintf( 'footer-area--%s-cols', $columns );
} else {
$classes[] = 'footer-area--fullwidth';
}
$classes[] = 'row';
}
return $classes;
}
/**
* Get footer widgets layout class
*
* @since 1.0.0
*
* @param string $params Existing widget classes.
*
* @return string
*/
function bikes2ride_get_footer_widget_layout( $params ) {
if ( is_admin() ) {
return $params;
}
if ( empty( $params[0]['id'] ) || 'footer-area' !== $params[0]['id'] ) {
return $params;
}
if ( empty( $params[0]['before_widget'] ) ) {
return $params;
}
$columns = get_theme_mod(
'footer_widget_columns',
bikes2ride_theme()->customizer->get_default( 'footer_widget_columns' )
);
$columns = intval( $columns );
$classes = 'class="col-xs-12 col-sm-%3$s col-md-%2$s col-lg-%1$s %4$s ';
switch ( $columns ) {
case 4:
$lg_col = 3;
$md_col = 6;
$sm_col = 12;
$extra = '';
break;
case 3:
$lg_col = 4;
$md_col = 4;
$sm_col = 12;
$extra = '';
break;
case 2:
$lg_col = 6;
$md_col = 6;
$sm_col = 12;
$extra = '';
break;
default:
$lg_col = 12;
$md_col = 12;
$sm_col = 12;
$extra = '';
break;
}
$params[0]['before_widget'] = str_replace(
'class="',
sprintf( $classes, $lg_col, $md_col, $sm_col, $extra ),
$params[0]['before_widget']
);
return $params;
}
/**
* Filter image CSS model
*
* @param array $css_model Default CSS model.
* @param array $args Post formats module arguments.
*
* @return array
*/
function bikes2ride_add_image_format_classes( $css_model, $args ) {
$blog_featured_image = get_theme_mod( 'blog_featured_image', bikes2ride_theme()->customizer->get_default( 'blog_featured_image' ) );
$blog_layout = get_theme_mod( 'blog_layout_type', bikes2ride_theme()->customizer->get_default( 'blog_layout_type' ) );
$suffix = ( 'default' !== $blog_layout ) ? 'fullwidth' : $blog_featured_image;
$css_model['link'] .= ' post-thumbnail--' . $suffix;
return $css_model;
}
/**
* Enqueue misc js script.
*
* @param array $depends Default dependencies.
* @return array
*/
function bikes2ride_enqueue_misc( $depends ) {
global $is_IE;
if ( $is_IE ) {
$depends[] = 'object-fit-images';
}
return $depends;
}
/**
* Add to toTop and stickUp properties if required.
*
* @param array $vars Default variables.
*
* @return array
*/
function bikes2ride_js_vars( $vars ) {
$header_menu_sticky = get_theme_mod( 'header_menu_sticky', bikes2ride_theme()->customizer->get_default( 'header_menu_sticky' ) );
if ( $header_menu_sticky && ! wp_is_mobile() ) {
$vars['stickUp'] = true;
}
$totop_visibility = get_theme_mod( 'totop_visibility', bikes2ride_theme()->customizer->get_default( 'totop_visibility' ) );
if ( $totop_visibility ) {
$vars['toTop'] = true;
}
return $vars;
}
/**
* Add has/no thumbnail classes for posts
*
* @param array $classes Existing classes.
*
* @return array
*/
function bikes2ride_post_thumb_classes( $classes ) {
$thumb = 'no-thumb';
if ( has_post_thumbnail() ) {
$thumb = 'has-thumb';
}
$classes[] = $thumb;
return $classes;
}
/**
* Add placeholder attributes for comment form fields.
*
* @param array $args Arguments for comment form.
*
* @return array
*/
function bikes2ride_modify_comment_form( $args ) {
$args = wp_parse_args( $args );
if ( ! isset( $args['format'] ) ) {
$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
}
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$html_req = ( $req ? " required='required'" : '' );
$html5 = 'html5' === $args['format'];
$commenter = wp_get_current_commenter();
$args['label_submit'] = esc_html__( 'Submit Comment', 'bikes2ride' );
$args['fields']['author'] = '';
$args['fields']['email'] = '';
$args['fields']['url'] = '';
$args['comment_field'] = '';
$args['title_reply_before'] = '';
$args['title_reply'] = esc_html__( 'Leave a reply', 'bikes2ride' );
return $args;
}
/**
* Reorder comment fields
*
* @param array $fields Comment fields.
*
* @return array
*/
function bikes2ride_reorder_comment_fields( $fields ) {
if ( is_singular( 'product' ) ) {
return $fields;
}
$new_fields_order = array();
$new_order = array( 'author', 'email', 'url', 'comment' );
foreach ( $new_order as $key ) {
$new_fields_order[ $key ] = $fields[ $key ];
unset( $fields[ $key ] );
}
return $new_fields_order;
}
/**
* Add extra body classes
*
* @param array $classes Existing classes.
*
* @return array
*/
function bikes2ride_extra_body_classes( $classes ) {
global $is_IE;
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
// Adds a class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
// Adds a class of ie to browsers IE.
if ( $is_IE ) {
$classes[] = 'ie';
}
// Adds a options-based classes.
$header_layout = get_theme_mod( 'header_container_type', bikes2ride_theme()->customizer->get_default( 'header_container_type' ) );
$content_layout = get_theme_mod( 'content_container_type', bikes2ride_theme()->customizer->get_default( 'content_container_type' ) );
$footer_layout = get_theme_mod( 'footer_container_type', bikes2ride_theme()->customizer->get_default( 'footer_container_type' ) );
$blog_layout = get_theme_mod( 'blog_layout_type', bikes2ride_theme()->customizer->get_default( 'blog_layout_type' ) );
$sb_position = get_theme_mod( 'sidebar_position', bikes2ride_theme()->customizer->get_default( 'sidebar_position' ) );
$sidebar = get_theme_mod( 'sidebar_width', bikes2ride_theme()->customizer->get_default( 'sidebar_width' ) );
$single_type = get_theme_mod( 'single_post_type', bikes2ride_theme()->customizer->get_default( 'single_post_type' ) );
$header_type = get_theme_mod( 'header_layout_type', bikes2ride_theme()->customizer->get_default( 'header_layout_type' ) );
$footer_type = get_theme_mod( 'footer_layout_type', bikes2ride_theme()->customizer->get_default( 'footer_layout_type' ) );
if ( is_singular( 'post' ) ) {
$classes[] = 'single-post-' . sanitize_html_class( $single_type );;
}
if ( function_exists( 'tm_pb_is_pagebuilder_used' ) ) {
if ( tm_pb_is_pagebuilder_used( get_the_ID() ) && ! is_search() ) {
$classes[] = 'use-tm-pb-builder';
}
}
return array_merge( $classes, array(
'header-layout-' . $header_layout,
'content-layout-' . $content_layout,
'footer-layout-' . $footer_layout,
'blog-' . $blog_layout,
'position-' . $sb_position,
'sidebar-' . str_replace( '/', '-', $sidebar ),
'header-' . $header_type,
'footer-' . $footer_type,
) );
}
/**
* Replace macroses in text widget.
*
* @param string $widget_text The widget content.
* @param array $instance Array of settings for the current widget.
* @param WP_Widget_Text $this Current Text widget instance.
* @return string
*/
function bikes2ride_render_widget_macros( $widget_text, $instance, $this ) {
$uploads = wp_upload_dir();
$data = array(
'/%%uploads_url%%/' => $uploads['baseurl'],
'/%%home_url%%/' => esc_url( home_url( '/' ) ),
'/%%theme_url%%/' => get_template_directory_uri(),
);
return preg_replace( array_keys( $data ), array_values( $data ), $widget_text );
}
/**
* Adds the meta viewport to the header.
*
* @since 1.0.1
*/
function bikes2ride_meta_viewport() {
echo '' . "\n";
}
/**
* Customization for `Tag Cloud` widget.
*
* @since 1.0.1
*
* @param array $args Widget arguments.
*
* @return array
*/
function bikes2ride_customize_tag_cloud( $args ) {
$args['smallest'] = 12;
$args['largest'] = 12;
$args['unit'] = 'px';
return $args;
}
/**
* Replaces `[...]` (appended to automatically generated excerpts) with `...`.
*
* @since 1.0.1
*
* @param string $more The string shown within the more link.
*
* @return string
*/
function bikes2ride_excerpt_more( $more ) {
if ( is_admin() ) {
return $more;
}
return ' …';
}
/**
* Creating wrappers for audio shortcode.
*/
function bikes2ride_audio_shortcode( $html, $atts, $audio, $post_id, $library ) {
$html = '' . $html . '
';
return $html;
}
/**
* Set specific content classes for blog listing
*/
function bikes2ride_set_specific_content_classes( $layout_classes ) {
$sidebar_position = get_theme_mod( 'sidebar_position' );
if ( ( 'fullwidth' === $sidebar_position && is_single() && ! is_singular( array( 'product', 'mp_menu_item' ) ) ) ) {
$layout_classes = array( 'col-xs-12', 'col-md-12', 'col-xl-8', 'col-xl-push-2' );
}
return $layout_classes;
}
/**
* Add template to cherry-team-members templates list.
*
* @param array $tmpl_list Templates list.
*
* @return array
*/
function bikes2ride_add_template_to_cherry_team_templates_list( $tmpl_list ) {
$tmpl_list['grid-boxes-2'] = 'grid-boxes-2.tmpl';
return $tmpl_list;
}
/**
* Landing main menu location.
*/
function bikes2ride_landing_main_menu_location( $args ) {
if ( 'page-templates/landing.php' === get_page_template_slug() ) {
$args['theme_location'] = 'main_landing';
}
return $args;
}
/**
* Invisible button read more in module post
*/
function bikes2ride_function_module_post_btn_settings_layout_1( $args ) {
$args = array(
'visible' => false,
'text' => esc_html__( 'Read More', 'bikes2ride' ),
'icon' => '',
'class' => 'bikes2rideposts_more-btn link',
'html' => '%4$s%5$s',
'echo' => true,
);
return $args;
}
function bikes2ride_add_imeges_size_filter() {
add_filter( 'tm_pg_get_sizes', 'bikes2ride_images_sizes' );
}
function bikes2ride_images_sizes( $args ) {
$args['grid-small'] = array(
'width' => '427',
'height' => '330',
'type' => 'grid',
);
$args['grid-small-2'] = array(
'width' => '370',
'height' => '270',
'type' => 'grid',
);
return $args;
}
function bikes2ride_disable_wporg_request( $r, $url ) {
// If it's not a theme update request, bail.
if ( 0 !== strpos( $url, 'https://api.wordpress.org/themes/update-check/1.1/' ) ) {
return $r;
}
// Decode the JSON response.
$themes = json_decode( $r['body']['themes'] );
// Remove the active parent and child themes from the check.
$parent = get_option( 'template' );
$child = get_option( 'stylesheet' );
unset( $themes->themes->$parent );
unset( $themes->themes->$child );
// Encode the updated JSON response.
$r['body']['themes'] = json_encode( $themes );
return $r;
}