array( 'class' => array(), 'href' => array(), 'rel' => array(), 'title' => array(), ), 'abbr' => array( 'title' => array(), ), 'b' => array(), 'blockquote' => array( 'cite' => array(), ), 'cite' => array( 'title' => array(), ), 'code' => array(), 'del' => array( 'datetime' => array(), 'title' => array(), ), 'dd' => array(), 'div' => array( 'class' => array(), 'title' => array(), 'style' => array(), ), 'dl' => array(), 'dt' => array(), 'em' => array(), 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'i' => array( 'class' => array(), ), 'img' => array( 'alt' => array(), 'class' => array(), 'height' => array(), 'src' => array(), 'width' => array(), ), 'li' => array( 'class' => array(), ), 'ol' => array( 'class' => array(), ), 'p' => array( 'class' => array(), ), 'q' => array( 'cite' => array(), 'title' => array(), ), 'span' => array( 'class' => array(), 'title' => array(), 'style' => array(), ), 'iframe' => array( 'width' => array(), 'height' => array(), 'scrolling' => array(), 'frameborder' => array(), 'allow' => array(), 'src' => array(), ), 'strike' => array(), 'br' => array(), 'strong' => array(), 'ul' => array( 'class' => array(), ), ); if ( function_exists( 'wp_kses' ) ) { // WP is here $allowed = wp_kses( $raw, $allowed_tags ); } else { $allowed = $raw; } return $allowed; } // build google font url // ---------------------------------------------------------------------------------------- function bajaar_google_fonts_url($font_families = []) { $fonts_url = ''; /* Translators: If there are characters in your language that are not supported by chosen font(s), translate this to 'off'. Do not translate into your own language. */ if ( $font_families && 'off' !== _x( 'on', 'Google font: on or off', 'bajaar' ) ) { $query_args = array( 'family' => urlencode( implode( '|', $font_families ) ) ); $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); } return esc_url_raw( $fonts_url ); } // return cover image from an youtube video url // ---------------------------------------------------------------------------------------- function bajaar_youtube_cover( $e ) { $src = null; //get the url if ( $e != '' ){ $url = $e; $queryString = parse_url( $url, PHP_URL_QUERY ); parse_str( $queryString, $params ); $v = $params[ 'v' ]; //generate the src if ( strlen( $v ) > 0 ) { $src = "http://i3.ytimg.com/vi/$v/default.jpg"; } } return $src; } // return embed code for sound cloud // ---------------------------------------------------------------------------------------- function bajaar_soundcloud_embed( $url ) { return 'https://w.soundcloud.com/player/?url=' . urlencode($url) . '&auto_play=false&color=915f33&theme_color=00FF00'; } // return embed code video url // ---------------------------------------------------------------------------------------- function bajaar_video_embed($url){ //This is a general function for generating an embed link of an FB/Vimeo/Youtube Video. $embed_url = ''; if(strpos($url, 'facebook.com/') !== false) { //it is FB video $embed_url ='https://www.facebook.com/plugins/video.php?href='.rawurlencode($url).'&show_text=1&width=200'; }else if(strpos($url, 'vimeo.com/') !== false) { //it is Vimeo video $video_id = explode("vimeo.com/",$url)[1]; if(strpos($video_id, '&') !== false){ $video_id = explode("&",$video_id)[0]; } $embed_url ='https://player.vimeo.com/video/'.$video_id; }else if(strpos($url, 'youtube.com/') !== false) { //it is Youtube video $video_id = explode("v=",$url)[1]; if(strpos($video_id, '&') !== false){ $video_id = explode("&",$video_id)[0]; } $embed_url ='https://www.youtube.com/embed/'.$video_id; }else if(strpos($url, 'youtu.be/') !== false){ //it is Youtube video $video_id = explode("youtu.be/",$url)[1]; if(strpos($video_id, '&') !== false){ $video_id = explode("&",$video_id)[0]; } $embed_url ='https://www.youtube.com/embed/'.$video_id; } return $embed_url; } if ( !function_exists( 'bajaar_advanced_font_styles' ) ) : /** * Get shortcode advanced Font styles * */ function bajaar_advanced_font_styles( $data ) { $style = []; if (is_string($data)) { $style = json_decode($data, true); } else { $style = $data; } $font_styles = $font_weight = ''; $font_weight = (isset( $style[ 'weight' ] ) && $style[ 'weight' ]) ? 'font-weight:' . esc_attr( $style[ 'weight' ] ) . ';' : ''; $font_styles .= isset( $style[ 'family' ] ) ? 'font-family: ' . $style[ 'family' ] . ', sans-serif;' : ''; $font_styles .= isset($style[ 'style' ] ) && $style[ 'style' ] ? 'font-style:' . esc_attr( $style[ 'style' ] ) . ';' : ''; $font_styles .= isset( $style[ 'color' ] ) && !empty( $style[ 'color' ] ) ? 'color:' . esc_attr( $style[ 'color' ] ) . ';' : ''; $font_styles .= isset( $style[ 'line_height' ] ) && !empty( $style[ 'line_height' ] ) ? 'line-height:' . esc_attr( $style[ 'line_height' ] / $style[ 'size' ]) . ';' : ''; $font_styles .= isset( $style[ 'letter_spacing' ] ) && !empty( $style[ 'letter_spacing' ] ) ? 'letter-spacing:' . esc_attr( $style[ 'letter_spacing' ] / 1000 * 1 ) . 'rem;' : ''; $font_styles .= isset( $style[ 'size' ] ) && !empty( $style[ 'size' ] ) ? 'font-size:' . esc_attr( $style[ 'size' ] ) . 'px;' : ''; $font_styles .= !empty( $font_weight ) ? $font_weight : ''; return !empty( $font_styles ) ? $font_styles : ''; } endif; /** * hooks for wp blog part */ // if there is no excerpt, sets a defult placeholder // ---------------------------------------------------------------------------------------- function bajaar_excerpt( $words = 20 ) { $excerpt = get_the_excerpt(); $trimmed_content = wp_trim_words( $excerpt, $words ); echo bajaar_kses( $trimmed_content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } // change textarea position in comment form // ---------------------------------------------------------------------------------------- function bajaar_move_comment_textarea_to_bottom( $bajaar_fields ) { $comment_field = $bajaar_fields[ 'comment' ]; unset( $bajaar_fields[ 'comment' ] ); $bajaar_fields[ 'comment' ] = $comment_field; return $bajaar_fields; } add_filter( 'comment_form_fields', 'bajaar_move_comment_textarea_to_bottom' ); // change textarea position in comment form // ---------------------------------------------------------------------------------------- function bajaar_search_form( $form ) { $form = '
'; return $form; } add_filter( 'get_search_form', 'bajaar_search_form' ); function bajaar_body_classes( $bajaar_classes ) { if ( is_active_sidebar( 'sidebar-1' ) ) { $bajaar_classes[] = 'sidebar-active'; }else{ $bajaar_classes[] = 'sidebar-inactive'; } $box_class = bajaar_option('general_body_box_layout'); if(isset($box_class['style'])){ if($box_class['style']=='yes'){ $bajaar_classes[] = 'body-box-layout'; } } return $bajaar_classes; } add_filter( 'body_class','bajaar_body_classes' ); function bajaar_add_sub_menu_toggle( $output, $item, $depth, $args ) { if ( in_array( 'menu-item-has-children', $item->classes, true ) ) { // Add toggle button. $output .= ''; } return $output; } add_filter( 'walker_nav_menu_start_el', 'bajaar_add_sub_menu_toggle', 10, 4 );