/** * Benue functions and definitions * * When using a child theme you can override certain functions (those wrapped * in a function_exists() call) by defining them first in your child theme's * functions.php file. The child theme's functions.php file is included before * the parent theme's file, so the child theme functions would be used. * * @link https://codex.wordpress.org/Theme_Development * @link https://codex.wordpress.org/Child_Themes * * Functions that are not pluggable (not wrapped in function_exists()) are * instead attached to a filter or action hook. * * For more information on hooks, actions, and filters, * {@link https://codex.wordpress.org/Plugin_API} * */ /*-----------------------------------------------------------------------------------*/ /* SETS UP THEME DEFAULTS AND REGISTERS SUPPORT FOR VARIOUS WORDPRESS FEATURES /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_theme_setup' ) ) { function kktfwp_theme_setup() { // Make theme available for translation load_theme_textdomain( 'benue', get_theme_file_uri( '/languages' ) ); // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); // Adding Gutenberg wide-images support add_theme_support( 'align-wide' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails */ add_theme_support( 'post-thumbnails' ); add_image_size( 'kktfwp-s', 1200, false ); add_image_size( 'kktfwp-l', 1424, false ); add_image_size( 'kktfwp-xl', 1920, false ); add_image_size( 'kktfwp-xxl', 2560, false ); add_image_size( 'kktfwp-s-s', 640, 480, true ); add_image_size( 'kktfwp-m-s', 960, 720, true ); add_image_size( 'kktfwp-l-s', 1424, 1068, true ); // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( 'primary' => esc_html__( 'Primary Menu', 'benue' ), ) ); // Switch default core markup for search form, comment form, and comments to output valid HTML5. add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); /* * This theme styles the visual editor to resemble the theme style, * specifically font, colors, icons, and column width. */ add_editor_style( '/css/editor-style.css' ); // Indicate widget sidebars can use selective refresh in the Customizer. add_theme_support( 'customize-selective-refresh-widgets' ); } } add_action( 'after_setup_theme', 'kktfwp_theme_setup' ); /*-----------------------------------------------------------------------------------*/ /* REGISTERING SIDEBARS /*-----------------------------------------------------------------------------------*/ function kktfwp_register_sidebars() { $sbopts=array( 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h6 class="widget-title">', 'after_title' => '</h6>', ); // Blog sidebar register_sidebar( array_merge($sbopts, array( 'name' => esc_html__( 'Blog Sidebar', 'benue' ), 'id' => 'kktfwp-sidebar-blog', 'description' => esc_html__( 'Appears at the right of the content on blog page and post', 'benue' ), ) ) ); // Page sidebar register_sidebar( array_merge($sbopts, array( 'name' => esc_html__( 'Page Sidebar', 'benue' ), 'id' => 'kktfwp-sidebar-page', 'description' => esc_html__( 'Appears at the right of the content on regular page', 'benue' ), ) ) ); } add_action('widgets_init', 'kktfwp_register_sidebars'); /*-----------------------------------------------------------------------------------*/ /* Register the image sizes for use in Add Media modal /*-----------------------------------------------------------------------------------*/ add_filter( 'image_size_names_choose', 'kktfwp_custom_sizes' ); function kktfwp_custom_sizes( $sizes ) { return array_merge( $sizes, array( 'kktfwp-s-s' => esc_html__( 'Small (4:3)', 'benue' ), 'kktfwp-m-s' => esc_html__( 'Medium (4:3)', 'benue' ), 'kktfwp-l-s' => esc_html__( 'Large (4:3)', 'benue' ), ) ); } /*-----------------------------------------------------------------------------------*/ /* POSTS ID HELPER /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_postid' ) ) { function kktfwp_postid() { if (is_home() || is_search() || is_category() || is_tag() || is_date() || is_author() || is_404()) { $postid = get_option( 'page_for_posts' ); } else if( function_exists('is_shop') && is_shop() ) { $postid = get_option( 'woocommerce_shop_page_id' ); } else if ( is_tax( 'portfolio-type' ) ) { $args = array( 'post_status' => 'publish', 'post_type' => 'page', 'order' => 'ASC', 'orderby' => 'ID', 'posts_per_page' => 1, 'meta_query' => array( array( 'key' => '_wp_page_template', 'value' => 'template-portfolio.php' ) ) ); $result = new WP_Query( $args ); if( $result->have_posts() ) : while( $result->have_posts() ) : $result->the_post(); $postid = get_the_ID(); endwhile; wp_reset_postdata(); endif; } else { $postid = get_the_ID(); } return $postid; } } /*-----------------------------------------------------------------------------------*/ /* INSTALLS REQUIRED PLUGINS /*-----------------------------------------------------------------------------------*/ require_once get_theme_file_path( '/inc/class-tgm-plugin-activation.php' ); add_action( 'tgmpa_register', 'kktfwp_register_required_plugins' ); function kktfwp_register_required_plugins() { /* * Array of plugin arrays. Required keys are name and slug. * If the source is NOT from the .org repo, then source is also required. */ $plugins = array( array( 'name' => esc_html__( 'Benue Meta Boxes', 'benue' ), // The plugin name. 'slug' => 'meta-box', // The plugin slug (typically the folder name). 'source' => get_template_directory() . '/inc/plugins/meta-box.zip', // The plugin source. 'required' => true, // If false, the plugin is only 'recommended' instead of required. 'version' => '16.0.0', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => esc_html__( 'Benue Meta Box Group', 'benue' ), // The plugin name. 'slug' => 'meta-box-group', // The plugin slug (typically the folder name). 'source' => get_template_directory() . '/inc/plugins/meta-box-group.zip', // The plugin source. 'required' => true, // If false, the plugin is only 'recommended' instead of required. 'version' => '1.2.13', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => esc_html__( 'Benue Meta Box Tabs', 'benue' ), // The plugin name. 'slug' => 'meta-box-tabs', // The plugin slug (typically the folder name). 'source' => get_template_directory() . '/inc/plugins/meta-box-tabs.zip', // The plugin source. 'required' => true, // If false, the plugin is only 'recommended' instead of required. 'version' => '1.0.3', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => esc_html__( 'Benue Meta Box Conditional Logic', 'benue' ), // The plugin name. 'slug' => 'meta-box-conditional-logic', // The plugin slug (typically the folder name). 'source' => get_template_directory() . '/inc/plugins/meta-box-conditional-logic.zip', // The plugin source. 'required' => true, // If false, the plugin is only 'recommended' instead of required. 'version' => '1.6.4', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => esc_html__( 'Benue Custom Post Types', 'benue' ), // The plugin name. 'slug' => 'kktfwp-benue-cpt', // The plugin slug (typically the folder name). 'source' => get_template_directory() . '/inc/plugins/kktfwp-benue-cpt.zip', // The plugin source. 'required' => true, // If false, the plugin is only 'recommended' instead of required. 'version' => '1.1', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => esc_html__( 'Kotofey Layout Helper', 'benue' ), // The plugin name. 'slug' => 'kotofey-layout-helper', // The plugin slug (typically the folder name). 'source' => get_template_directory() . '/inc/plugins/kotofey-layout-helper.zip', // The plugin source. 'required' => true, // If false, the plugin is only 'recommended' instead of required. 'version' => '2.1', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => esc_html__( 'Contact Form 7', 'benue' ), // The plugin name. 'slug' => 'contact-form-7', // The plugin slug (typically the folder name). 'required' => false, // If false, the plugin is only 'recommended' instead of required. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), ); $config = array( 'id' => 'kktfwp', // Unique ID for hashing notices for multiple instances of TGMPA. 'default_path' => '', // Default absolute path to bundled plugins. 'menu' => 'tgmpa-install-plugins', // Menu slug. 'has_notices' => true, // Show admin notices or not. 'dismissable' => false, // If false, a user cannot dismiss the nag message. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 'is_automatic' => true, // Automatically activate plugins after installation or not. 'message' => '', // Message to output right before the plugins table. ); tgmpa( $plugins, $config ); } /*-----------------------------------------------------------------------------------*/ /* SETS THE CONTENT WIDTH IN PIXELS /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_content_width' ) ) { function kktfwp_content_width() { $GLOBALS['content_width'] = apply_filters( 'kktfwp_content_width', 2560 ); } } add_action( 'after_setup_theme', 'kktfwp_content_width', 0 ); if ( ! function_exists( 'kktfwp_max_srcset_image_width' ) ) { function kktfwp_max_srcset_image_width( $w, $sizes = array() ) { return 2560; } } add_filter( 'max_srcset_image_width', 'kktfwp_max_srcset_image_width', 10, 2 ); /*-----------------------------------------------------------------------------------*/ /* CUSTOMIZER SETTINGS /*-----------------------------------------------------------------------------------*/ require_once get_theme_file_path( '/inc/customizer/class-kktfwp-settings.php' ); /*-----------------------------------------------------------------------------------*/ /* REGISTER GOOGLE FONTS /* Create your own kktfwp_fonts_url() function to override in a child theme /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_fonts_url' ) ) { function kktfwp_fonts_url( $fonts = array() ) { $fonts_url = ''; $fonts = $fonts; $subsets = 'latin,latin-ext'; $variants = ':100,200,300,400,500,600,700,800,900'; $bodyFont = get_theme_mod( 'kktfwp_body_font' ); $headersFont = get_theme_mod( 'kktfwp_headers_font' ); $menuFont = get_theme_mod( 'kktfwp_menu_font' ); $heroFont = get_theme_mod( 'kktfwp_hero_font' ); $portfolioFont = get_theme_mod( 'kktfwp_portfolio_font' ); $fonts[] = isset( $bodyFont['font'] ) ? $bodyFont['font'].$variants : 'Nunito'.$variants; $fonts[] = isset( $headersFont['font'] ) ? $headersFont['font'].$variants : 'Poppins'.$variants; $fonts[] = isset( $menuFont['font'] ) ? $menuFont['font'].$variants : 'Poppins'.$variants; $fonts[] = isset( $heroFont['font'] ) ? $heroFont['font'].$variants : 'Poppins'.$variants; $fonts[] = isset( $portfolioFont['font'] ) ? $portfolioFont['font'].$variants : 'Poppins'.$variants; $fonts = array_unique($fonts); if ( $fonts ) { $fonts_url = add_query_arg( array( 'family' => urlencode( implode( '|', $fonts ) ), 'subset' => urlencode( $subsets ), ), 'https://fonts.googleapis.com/css' ); } return esc_url( $fonts_url ); } } /*-----------------------------------------------------------------------------------*/ /* GET THEME INFO /*-----------------------------------------------------------------------------------*/ if ( !function_exists( 'kktfwp_themeData' ) ) { function kktfwp_themeData ( $arg='Version' ) { $themeData = wp_get_theme(get_template()); return $themeData->get( $arg ); } } /*-----------------------------------------------------------------------------------*/ /* DEFAULT COMMENT FORM FIELDS /*-----------------------------------------------------------------------------------*/ add_filter( 'comment_form_default_fields', 'kktfwp_form_default_fields' ); if ( ! function_exists( 'kktfwp_form_default_fields' ) ) { function kktfwp_form_default_fields($fields) { $commenter = wp_get_current_commenter(); $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); $fields['author'] = '<p class="comment-form-author">' . '<input placeholder="' . esc_attr_x( 'Name', 'placeholder', 'benue' ) . ( $req ? ' *' : '' ) . '" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>'; $fields['email'] = '<p class="comment-form-email">' . '<input placeholder="' . esc_attr_x( 'Email', 'placeholder', 'benue' ) . ( $req ? ' *' : '' ) . '" id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>'; $fields['url'] = '<p class="comment-form-url">' . '<input placeholder="' . esc_attr_x( 'Website', 'placeholder', 'benue' ) . '" id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>'; return $fields; } } /*-----------------------------------------------------------------------------------*/ /* CHECK IF META PLUGIN INSTALLED /*-----------------------------------------------------------------------------------*/ if ( !function_exists('rwmb_meta') ) { function rwmb_meta() { return false; } } else { function kktfwp_meta_style() { wp_enqueue_style( 'kktfwp-meta-style', get_theme_file_uri( '/css/meta-style.css' ), '', kktfwp_themeData() ); } add_action('admin_enqueue_scripts', 'kktfwp_meta_style'); } /*-----------------------------------------------------------------------------------*/ /* GET FILTER CATEGORIES /*-----------------------------------------------------------------------------------*/ if ( !function_exists( 'kktfwp_filter' ) ) { function kktfwp_filter ( $args, $id = NULL ) { $i = 0; if ( isset($id) ) { $id = $id; } else { $id = get_the_id(); } $homeStyle = rwmb_meta( '_kktfwp_homeStyle', 'type=select', $id ); $query = new WP_Query( $args ); while ( $query->have_posts() ) : $query->the_post(); $isFeatured = rwmb_meta( '_kktfwp_featured' ); if ( ( $homeStyle === 'featured' ) & ( $isFeatured == $id ) ) { $terms = get_the_terms( get_the_id(), 'portfolio-type' ); $i+=1; $ids[] = get_the_id(); } elseif ( $homeStyle === 'latest' ) { $terms = get_the_terms( get_the_id(), 'portfolio-type' ); $i+=1; $ids = ''; } else { unset($terms); } if( isset( $terms ) ) { if( is_array( $terms ) ) { foreach( $terms as $term ) { $termsArr[] = array ( 'slug' => $term->slug, 'name' => $term->name, 'id' => $term->term_id ); } } } endwhile; wp_reset_postdata(); if( isset( $termsArr ) ) { $num = array_count_values(array_map(function($item) { return $item['slug']; }, $termsArr)); $termsArr = array_map("unserialize", array_unique(array_map("serialize", $termsArr))); return array( $termsArr, $i, $num, $ids ); } return; } } /** * Handles JavaScript detection. * * Adds a `js` class to the root `<html>` element when JavaScript is detected. * * @since Benue 1.0 */ function kktfwp_javascript_detection() { echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n"; } add_action( 'wp_head', 'kktfwp_javascript_detection', 0 ); /*-----------------------------------------------------------------------------------*/ /* ENQUEUES SCRIPTS AND STYLES /*-----------------------------------------------------------------------------------*/ function kktfwp_scripts() { $postid = kktfwp_postid(); // Add custom fonts, used in the main stylesheet. wp_enqueue_style( 'kktfwp-fonts', kktfwp_fonts_url(), array(), null ); // Theme stylesheet. wp_enqueue_style( 'kktfwp-style', get_stylesheet_uri(), array(), kktfwp_themeData() ); /* Scripts */ if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } wp_enqueue_script( 'kktfwp-modernizr', get_theme_file_uri( '/js/jquery.modernizr.custom.js' ), array( 'jquery' ), kktfwp_themeData(), false ); wp_enqueue_script( 'isotope', get_theme_file_uri( '/js/isotope.min.js' ), array( 'jquery' ), kktfwp_themeData(), true ); wp_enqueue_script( 'kktfwp-helpers', get_theme_file_uri( '/js/jquery.helpers.js' ), array( 'jquery' ), kktfwp_themeData(), true ); wp_enqueue_script( 'photoswipe', get_theme_file_uri( '/js/photoswipe.min.js' ), array( 'jquery' ), kktfwp_themeData(), true ); wp_enqueue_script( 'kktfwp-scripts', get_theme_file_uri( '/js/jquery.scripts.js' ), array( 'jquery' ), kktfwp_themeData(), true ); wp_enqueue_script( 'kktfwp-lazysizes', get_theme_file_uri( '/js/lazysizes.min.js' ), array( 'jquery' ), kktfwp_themeData(), true ); $kktfwp_args = array(); $kktfwp_args['parallaxEffect'] = get_theme_mod('kktfwp_hero_parallax', 'on'); $kktfwp_args['scrollMonitor'] = rwmb_meta( '_kktfwp_pauseVid' ); $kktfwp_args['rightClick'] = array( 'click' => get_theme_mod('kktfwp_protection', '0'), 'message' => get_theme_mod( 'kktfwp_protection_message', '' ) ); $kktfwp_args['menuSettings'] = array( 'changeColor' => get_theme_mod('kktfwp_menu_change_color', '0'), 'onScrollUp' => get_theme_mod('kktfwp_menu_back', '0'), 'isSticky' => get_theme_mod('kktfwp_menu_sticky', '1'), ); $kktfwp_portfolio_style = ( rwmb_meta( '_kktfwp_portfolio_style' ) !== 'global' && !is_tax( 'portfolio-type' ) ) ? rwmb_meta( '_kktfwp_portfolio_style' ) : get_theme_mod( 'kktfwp_portfolio_style', 'grid'); $kktfwp_args['masonry'] = array( 'layout' => ( $kktfwp_portfolio_style === 'grid' ) ? 'masonry' : $kktfwp_portfolio_style ); $kktfwp_args['preloader'] = array( 'state' => ( get_theme_mod('kktfwp_preloader', '1') == 1 && rwmb_meta( '_kktfwp_preloader', 'type=select', $postid ) !== 'disable' || rwmb_meta( '_kktfwp_preloader', 'type=select', $postid ) === 'enable' ) ? true : false ); $kktfwp_args['layoutVis'] = array( 'style' => rwmb_meta( '_kktfwp_visibility' ) ); wp_localize_script( 'kktfwp-scripts', 'kktfwp', $kktfwp_args ); } add_action( 'wp_enqueue_scripts', 'kktfwp_scripts' ); /*-----------------------------------------------------------------------------------*/ /* ENQUEUE WORDPRESS THEME STYLES WITHIN GUTENBERG /*-----------------------------------------------------------------------------------*/ if ( !function_exists( 'kktfwp_gutenberg_styles' ) ) { function kktfwp_gutenberg_styles() { // Add custom fonts, used in the Gutenberg editor. wp_enqueue_style( 'kktfwp-fonts', kktfwp_fonts_url(), array(), null ); // Load the theme styles within Gutenberg. wp_enqueue_style( 'kktfwp-gutenberg', get_theme_file_uri( '/css/gutenberg.css' ), false, kktfwp_themeData(), 'all' ); } } add_action( 'enqueue_block_editor_assets', 'kktfwp_gutenberg_styles' ); /*-----------------------------------------------------------------------------------*/ /* GETS FEATURED IMAGE COLOR /*-----------------------------------------------------------------------------------*/ if ( !function_exists( 'kktfwp_setImageBg' ) ) { function kktfwp_setImageBg() { check_ajax_referer( 'bg-nonce', '_wpnonce' ); $color = array( 'r' => $_POST['r'], 'g' => $_POST['g'], 'b' => $_POST['b'], 't' => $_POST['t'] ); if ( ! add_post_meta( $_POST['post_id'], 'kktfwp_ImageBg', $color, true ) ) { update_post_meta( $_POST['post_id'], 'kktfwp_ImageBg', $color ); } wp_send_json_success(get_post_meta( $_POST['post_id'], 'kktfwp_ImageBg')); } } add_action('wp_ajax_kktfwp_setImageBg', 'kktfwp_setImageBg'); if ( !function_exists( 'kktfwp_enqueue_scripts_back_end' ) ) { function kktfwp_enqueue_scripts_back_end() { wp_enqueue_script( 'kktfwp-admin-script', get_theme_file_uri( '/js/jquery.admin-scripts.js' ), array( 'jquery' ), '1.0', true ); wp_enqueue_script( 'kktfwp-color-thief', get_theme_file_uri( '/js/jquery.color-thief.min.js' ), array( 'jquery' ), '1.0', true ); wp_localize_script( 'kktfwp-admin-script', 'kktfwp_ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'id' => get_the_ID(), 'ajax_nonce' => wp_create_nonce( 'bg-nonce' ) ) ); } } add_action('admin_enqueue_scripts','kktfwp_enqueue_scripts_back_end'); /*-----------------------------------------------------------------------------------*/ /* ADDS INLINE STYLE FOR PROJECTS OVERLAYS /*-----------------------------------------------------------------------------------*/ if ( !function_exists( 'kktfwp_inline_css' ) ) { function kktfwp_inline_css() { if ( is_page_template( 'template-portfolio.php' ) || is_tax( 'portfolio-type' ) ) { $args = array( 'post_type' => 'kktfwp_portfolio', 'posts_per_page' => -1, ); $inline_style = ''; $query = new WP_Query( $args ); while ( $query->have_posts() ) : $query->the_post(); $id = get_the_id(); $overlay_color = get_post_meta ( $id, 'kktfwp_ImageBg', true ); if ( get_theme_mod( 'kktfwp_portfolio_thumbs', 's-1' ) === 's-1' ) { $inline_style .= ( isset($overlay_color['t']) ) ? '#overlay_' .$id. ' .proj-content {color:'.$overlay_color['t'].';}' : '#overlay_'. $id .' .proj-content {color: #444;}'; } if ( is_array( $overlay_color ) ) { $inline_style .= '#overlay_'. $id .'{ color: rgb('.$overlay_color['r'].','.$overlay_color['g'].','.$overlay_color['b'].'); }'; } endwhile; wp_reset_postdata(); // Remove space after colons $inline_style = str_replace(': ', ':', $inline_style); // Remove whitespace $inline_style = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $inline_style); wp_add_inline_style( 'kktfwp-style', $inline_style ); } return; } } if ( get_theme_mod('kktfwp_portfolio_po', '1') === 1 ) { add_action( 'wp_enqueue_scripts', 'kktfwp_inline_css', 15 ); } /*-----------------------------------------------------------------------------------*/ /* ADDS CUSTOM CLASSES TO THE ARRAY OF BODY CLASSES * @param array $classes Classes for the body element. /*-----------------------------------------------------------------------------------*/ if ( !function_exists( 'kktfwp_body_classes' ) ) { function kktfwp_body_classes( $classes ) { $postid = kktfwp_postid(); $portfolioStyle = ( rwmb_meta( '_kktfwp_portfolio_style' ) != 'global' && !is_tax( 'portfolio-type' ) ) ? rwmb_meta( '_kktfwp_portfolio_style' ) : get_theme_mod( 'kktfwp_portfolio_style', 'grid'); $portfolioGaps = ( rwmb_meta( '_kktfwp_gaps' ) != 'global' && !is_tax( 'portfolio-type' ) ) ? rwmb_meta( '_kktfwp_gaps' ) : get_theme_mod( 'kktfwp_portfolio_gaps', 'normal' ); // Adds a class of group-blog to sites 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'; } if ( is_active_sidebar( 'kktfwp-sidebar-blog' ) && ( is_search() || is_archive() || is_singular( 'post' ) || is_front_page() && is_home() || is_home() ) ) { $classes[] = 'active-sidebar'; } if ( is_active_sidebar( 'kktfwp-sidebar-page' ) && ( is_page() ) ) { $classes[] = 'active-sidebar'; } if ( is_singular( 'kktfwp_portfolio' ) ) { $classes[] = 'portfolio-content-'.rwmb_meta( '_kktfwp_layout' ); } if ( ( is_page_template( 'template-portfolio.php' ) || is_tax( 'portfolio-type' ) ) & $portfolioGaps != 'disabled' ) { $classes[] = 'portfolio-gaps-'.$portfolioGaps; } if ( is_page_template( 'template-portfolio.php' ) || is_tax( 'portfolio-type' ) ) { $classes[] = sprintf( 'portfolio-columns-%s', ( rwmb_meta( '_kktfwp_portfolio_columns' ) != 'global' && !is_tax( 'portfolio-type' ) ) ? rwmb_meta( '_kktfwp_portfolio_columns' ) : get_theme_mod( 'kktfwp_portfolio_columns', '3' ) ); } if ( rwmb_meta( '_kktfwp_titleType' ) === 'hero' ) { $classes[] = 'hero-enabled'; } if ( rwmb_meta( '_kktfwp_herovid' ) ) { $classes[] = 'hero-video'; } if ( rwmb_meta( '_kktfwp_titleSource' ) ) { $classes[] = 'title-'.rwmb_meta( '_kktfwp_titleSource' ); } if ( in_array( rwmb_meta( '_kktfwp_layout' ), array( 'top', 'top-halfs' ) ) & !in_array( rwmb_meta( '_kktfwp_type' ), array( 'gallery', 'videos' ) ) ) { $classes[] = 'kktfwp-masonry'; } if ( in_array( rwmb_meta( '_kktfwp_type' ), array( 'videos' ) ) ) { $classes[] = 'kktfwp-video-project'; } if ( get_theme_mod('kktfwp_preloader', '1') == 1 && rwmb_meta( '_kktfwp_preloader', 'type=select', $postid ) !== 'disable' || rwmb_meta( '_kktfwp_preloader', 'type=select', $postid ) === 'enable' ) { $classes[] = 'kktfwp-preloader'; } if ( $portfolioStyle === 'masonry' ) { $classes[] = 'portfolio-masonry'; } else if ( $portfolioStyle === 'packery' ) { $classes[] = 'portfolio-mosaic'; } $portfolioWidth = ( rwmb_meta( '_kktfwp_portfolioWidth' ) != 'global' && !is_tax( 'portfolio-type' ) ) ? rwmb_meta( '_kktfwp_portfolioWidth' ) : get_theme_mod( 'kktfwp_portfolioWidth', 'narrow' ); if ( $portfolioWidth === 'wide' && ( is_page_template( 'template-portfolio.php' ) || is_tax( 'portfolio-type' ) ) ) { $classes[] = 'wide-portfolio'; } if ( $portfolioWidth === 'superwide' ) { $classes[] = 'wide-portfolio completely-wide-portfolio'; } if ( get_theme_mod('kktfwp_menu_width', '0' ) == 1 ) { $classes[] = 'wide-menu'; } if ( get_theme_mod('kktfwp_category', '0' ) == 1 ) { $classes[] = 'visible-category'; } $menuTransparency = rwmb_meta( '_kktfwp_headerScheme' ); $menuTransparency = isset( $menuTransparency['_kktfwp_menuTransparency'] ) ? $menuTransparency['_kktfwp_menuTransparency'] : 'global'; if ( get_theme_mod('kktfwp_menu_transparency', '0' ) == 1 && $menuTransparency !== 'disable' || $menuTransparency === 'enable' ) { $classes[] = 'transparent-menu'; } if ( get_theme_mod('kktfwp_footer_width', '0' ) == 1 ) { $classes[] = 'wide-footer'; } if ( get_theme_mod('kktfwp_menu_sticky', '1' ) != 1 ) { $classes[] = 'non-sticky-menu'; } if ( get_theme_mod('kktfwp_menu_back', '0' ) == 1 ) { $classes[] = 'onscroll-menu'; } if ( get_theme_mod('kktfwp_menu_underline', '1' ) == 1 ) { $classes[] = 'menu-underline'; } if ( get_theme_mod('kktfwp_filter_creative', '0' ) == 1 && get_theme_mod('kktfwp_filter', '0' ) == 1 ) { $classes[] = 'creative-filter'; } If ( is_page_template( 'template-portfolio.php' ) || is_tax( 'portfolio-type' ) ) { $thumbsStyle = get_theme_mod( 'kktfwp_portfolio_thumbs', 's-1' ); switch($thumbsStyle) { case 's-2': $classes[] = 'thumbs--2'; break; case 's-3': $classes[] = 'thumbs--3'; break; } } $menuStyle = get_theme_mod( 'kktfwp_menu_style', 'classic' ); if ( $menuStyle !== 'modern' ) { $classes[] = ( get_theme_mod( 'kktfwp_menu_reverse', '0' ) === 1 ) ? 'menu-reverse-order' : '' ; } switch($menuStyle) { case 'minimal': $classes[] = 'menu-ch'; break; case 'side': $classes[] = 'menu-sb'; break; case 'modern': $classes[] = 'menu-modern'; $classes[] = get_theme_mod( 'kktfwp_menu_order', 'm-l-s' ); break; } return $classes; } } add_filter( 'body_class', 'kktfwp_body_classes' ); /*-----------------------------------------------------------------------------------*/ /* ADDS ODD/EVEN CLASS TO BLOG POSTS /*-----------------------------------------------------------------------------------*/ add_filter( 'post_class', 'kktfwp_odd_even' ); if ( !function_exists( 'kktfwp_odd_even' ) ) { function kktfwp_odd_even( $classes ) { global $wp_query; if ( ! is_singular( 'post' ) ) { if($wp_query->current_post % 2 == 0) { $classes[] = 'odd'; } else { $classes[] = 'even'; } } return $classes; } } /*-----------------------------------------------------------------------------------*/ /* ADDS FACEBOOK OPEN GRAPH AND TWITTER CARD META TAGS TO WORDPRESS /*-----------------------------------------------------------------------------------*/ add_action( 'wp_head', 'kktfwp_sharing_meta_head', 10, 2 ); if ( !function_exists( 'kktfwp_sharing_meta_head' ) ) { function kktfwp_sharing_meta_head() { $shareArr = array(); // Get desired title, description and url for OG meta if ( is_feed() || is_search() || is_404() || post_password_required() ) return; global $post; $shareArr['url'] = is_front_page() ? esc_url( home_url( '/' ) ) : get_permalink( $post->ID ); $shareArr['description'] = wp_trim_words( strip_shortcodes( $post->post_content ) ); if ( is_archive() ) { $shareArr['title'] = get_the_archive_title(); global $wp_query; if ( is_author() ) { $author_id = get_query_var( 'author' ); $shareArr['url'] = get_author_posts_url( $author_id ); $shareArr['description'] = wp_trim_words( strip_tags( get_the_author_meta( 'description', $author_id ) ) ); } else { $shareArr['description'] = wp_trim_words( get_the_archive_description() ); } $queried_object = get_queried_object(); if ( isset( $queried_object->taxonomy ) ) { $shareArr['url'] = get_term_link( $queried_object->slug, $queried_object->taxonomy ); } elseif ( isset( $queried_object->query_var ) ) { $shareArr['url'] = get_post_type_archive_link( $queried_object->query_var ); } else { if ( isset( $wp_query->query_vars['year'] ) ) { if ( is_year() ) { $shareArr['url'] = get_year_link( $wp_query->query_vars['year'] ); } elseif ( is_month() ) { $shareArr['url'] = get_month_link( $wp_query->query_vars['year'], $wp_query->query_vars['monthnum'] ); } elseif ( is_day() ) { $shareArr['url'] = get_day_link( $wp_query->query_vars['year'], $wp_query->query_vars['monthnum'], $wp_query->query_vars['day'] ); } } } } elseif ( '' == $shareArr['description'] || is_front_page() ) { $shareArr['title'] = get_bloginfo( 'name' ); $shareArr['description'] = get_bloginfo( 'description' ); } else { $shareArr['title'] = get_the_title( $post->ID ); } $shareArr['title'] = strip_tags( $shareArr['title'] ); // Image if ( has_post_thumbnail( $post->ID ) ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'kktfwp-s-s' ); $image_url = $image[0]; $w = $image[1]; $h = $image[2]; printf( '<link rel="image_src" href="%s" />', esc_url( $image_url ) ); } else { $image_url = ''; $w = ''; $h = ''; } // Markup if ( is_single() ) { echo '<meta property="og:type" content="article" />'; } printf( '<meta property="og:title" content="%s" /> <meta property="og:image" content="%s" /> <meta property="og:image:width" content="%s" /> <meta property="og:image:height" content="%s" /> <meta property="og:description" content="%s" /> <meta property="og:url" content="%s" /> <meta property="og:site_name" content="%s" />', esc_attr( $shareArr['title'] ), esc_url( $image_url ), esc_attr( $w ), esc_attr( $h ), esc_attr( strip_tags( $shareArr['description'] ) ), esc_url( $shareArr['url'] ), esc_attr( get_bloginfo( 'name' ) ) ); printf( '<meta name="twitter:card" content="summary"> <meta name="twitter:url" content="%s"> <meta name="twitter:title" content="%s"> <meta name="twitter:description" content="%s"> <meta name="twitter:image" content="%s">', esc_url( $shareArr['url'] ), esc_attr( $shareArr['title'] ), esc_attr( strip_tags( $shareArr['description'] ) ), esc_url( $image_url ) ); } } /*-----------------------------------------------------------------------------------*/ /* POSTS/PROJECTS NAVIGATION /*-----------------------------------------------------------------------------------*/ add_action( 'kktfwp_nav', 'kktfwp_navigation' ); if ( !function_exists( 'kktfwp_navigation' ) ) { function kktfwp_navigation() { $prev_next_posts = array( get_previous_post(), get_next_post() ); foreach ( $prev_next_posts as $post ) { $postData[] = array( 'ID' => !empty( $post->ID ) ? $post->ID : 0, 'thumbnail' => '' !== $post ? get_the_post_thumbnail( $post->ID, 'thumbnail', array('class'=>'responsively-lazy', 'data-lazy-load' => 1) ) : '' ); } $backLink = rwmb_meta( '_kktfwp_backBtn' ); echo '<div class="kktfwp-nav"> <div class="kktfwp-prev">'. get_next_post_link( '%link', '<span class="n-desc" data-delay="0">'.( ( !is_singular( 'post' ) ) ? esc_html__( 'Previous', 'benue' ) : esc_html__( 'Previous entry', 'benue' ) ) .'</span><span class="n-title">%title</span>' ) .'</div> '. ( !is_singular( 'post' ) && $backLink !== '' ? '<div class="kktfwp-back"><a href="' . get_page_link( $backLink ) . '"><span></span></a></div>' : '') .' <div class="kktfwp-next">'. get_previous_post_link( '%link', '<span class="n-desc" data-delay="0">'.( ( !is_singular( 'post' ) ) ? esc_html__( 'Next', 'benue' ) : esc_html__( 'Next entry', 'benue' ) ) .'</span><span class="n-title">%title</span>' ) .'</div> </div>'; } } /*-----------------------------------------------------------------------------------*/ /* DISABLING COMMENTS BY DEFAULT ON PAGES /*-----------------------------------------------------------------------------------*/ add_filter( 'wp_insert_post_data', 'kk_default_page_comments_off' ); if ( ! function_exists( 'kk_default_page_comments_off' ) ) { function kk_default_page_comments_off( $data ) { if ( in_array( $data['post_type'], array( 'page', 'kktfwp_portfolio' ) ) && $data['post_status'] == 'auto-draft' ) { $data['comment_status'] = 0; $data['ping_status'] = 0; } return $data; } } /*-----------------------------------------------------------------------------------*/ /* INCLUDE NEEDED FILES /*-----------------------------------------------------------------------------------*/ require_once get_theme_file_path( '/inc/theme-meta-boxes.php' ); require_once get_theme_file_path( '/inc/img-filters.php' ); require_once get_theme_file_path( '/inc/template-tags.php' ); require_once get_theme_file_path( '/inc/class_check_ver.php' ); /** * One Click Import Demo Data */ require_once get_theme_file_path( '/inc/one-click-import.php' ); /*-----------------------------------------------------------------------------------*/ /* FOOTER COPYRIGHTS /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_copy' ) ) { function kktfwp_copy() { if ( !get_theme_mod('kktfwp_copyrights', 'Benue theme by <a target=\'_blank\' href=\'http://themeforest.net/user/kotofey?ref=kotofey\'>kotofey</a>. All Rights Reserved.') ) return; $allowed_html = array( 'a' => array( 'href' => array(), 'title' => array(), 'target'=> array() ), 'br' => array(), 'em' => array(), 'span' => array( 'style' => array() ), 'strong' => array(), 'img' => array( 'src' => array(), 'alt' => array(), 'style'=> array() ) ); echo wp_kses( stripslashes(get_theme_mod('kktfwp_copyrights', 'Benue theme by <a target=\'_blank\' href=\'http://themeforest.net/user/kotofey?ref=kotofey\'>kotofey</a>. All Rights Reserved.')), $allowed_html ); } } add_action( 'kktfwp_copy', 'kktfwp_copy' ); /*-----------------------------------------------------------------------------------*/ /* SOCIAL PROFILES /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_social_profiles' ) ) { function kktfwp_social_profiles() { $opArray = get_theme_mod( 'kktfwp_social' ); if ( !$opArray ) return; $output = ''; foreach( $opArray as $key => $value ) { if ( $value !== '' ) { $output .= '<li><a class="kktfwp-icon-'. esc_attr( $key ) .'" target="_blank" href="'. ( $key === 'skype' ? esc_attr( $value ) : esc_url( $value ) ) .'"></a></li>'; } } if ( $output !== '' ) { echo '<ul>' .$output. '</ul>'; } else { return; } } } add_action( 'kktfwp_social', 'kktfwp_social_profiles' ); /** * Modifies tag cloud widget arguments to have all tags in the widget same font size. * * @since Benue 1.1 * * @param array $args Arguments for tag cloud widget. * @return array A new modified arguments. */ function kktfwp_widget_tag_cloud_args( $args ) { $args['largest'] = 0.875; $args['smallest'] = 0.875; $args['unit'] = 'em'; return $args; } add_filter( 'widget_tag_cloud_args', 'kktfwp_widget_tag_cloud_args' ); /*-----------------------------------------------------------------------------------*/ /* ARCHIVE PAGE FILTER /*-----------------------------------------------------------------------------------*/ add_filter( 'get_the_archive_title', function ($title) { if ( is_category() ) { $title = single_cat_title( '', false ); } elseif ( is_tag() ) { $title = single_tag_title( '', false ); } elseif ( is_author() ) { $title = get_the_author(); } elseif ( function_exists('is_shop') && is_product_category() || function_exists('is_shop') && is_product_tag() ) { $title = single_cat_title( '', false ); } elseif ( is_tax( 'portfolio-type' ) ) { $title = single_cat_title( '', false ); } return $title; }); /*-----------------------------------------------------------------------------------*/ /* FILTER PROTECTED TITLE /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_remove_protected_title' ) ) { function kktfwp_remove_protected_title( $title ) { return '%s'; } } add_filter('protected_title_format', 'kktfwp_remove_protected_title'); /*-----------------------------------------------------------------------------------*/ /* PROTECTED PAGE TITLE /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_protected' ) ) { function kktfwp_protected() { if ( is_singular( 'post' ) ) { $title = esc_html_e( 'Protected post', 'benue' ); } else { $title = esc_html_e( 'Protected page', 'benue' ); } return $title; } } add_action( 'kktfwp_protected_title', 'kktfwp_protected' ); /*-----------------------------------------------------------------------------------*/ /* KSES ALLOWED ARGS /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_kses_allowed_args' ) ) { function kktfwp_kses_allowed_args() { $kses_args = array( 'h1' => array( 'style' => array(), 'class' => array(), 'id' => array() ), 'h2' => array( 'style' => array(), 'class' => array(), 'id' => array() ), 'h3' => array( 'style' => array(), 'class' => array(), 'id' => array() ), 'h4' => array( 'style' => array(), 'class' => array(), 'id' => array() ), 'h5' => array( 'style' => array(), 'class' => array(), 'id' => array() ), 'h6' => array( 'style' => array(), 'class' => array(), 'id' => array() ), 'p' => array( 'style' => array(), 'class' => array(), 'id' => array() ), 'a' => array( 'href' => array(), 'title' => array(), 'target'=> array() ), 'br' => array(), 'em' => array(), 'span' => array( 'style' => array(), 'class' => array(), 'id' => array() ), 'strong' => array(), 'img' => array( 'src' => array(), 'alt' => array(), 'style'=> array(), 'class' => array(), 'title' => array() ) ); return $kses_args; } } /*-----------------------------------------------------------------------------------*/ /* PAGE TITLE /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_getTitle' ) ) { function kktfwp_getTitle() { $source = rwmb_meta( '_kktfwp_titleSource', '', kktfwp_postid() ); $title = ''; if ( $source != 'custom' && $source != 'disabled' && !is_tax( 'portfolio-type' ) ) { $title = ( is_home() && ! is_front_page() ) ? '<h1>'. get_the_title(get_option( 'page_for_posts' )) .'</h1>': the_title( '<h1>', '</h1>', false ); } else if ( $source == 'custom' && !is_tax( 'portfolio-type' ) ) { $title = ( is_home() && ! is_front_page() ) ? rwmb_meta( '_kktfwp_description', '',get_option( 'page_for_posts' ) ) : rwmb_meta( '_kktfwp_description' ); } else if ( is_tax( 'portfolio-type' ) ) { $title = '<h1>'. get_the_archive_title() .'</h1>' . get_the_archive_description(); } return wp_kses( $title, kktfwp_kses_allowed_args()); } } add_action( 'kktfwp_pageTitle', 'kktfwp_pageTitle' ); if ( ! function_exists( 'kktfwp_pageTitle' ) ) { function kktfwp_pageTitle() { $source = rwmb_meta( '_kktfwp_titleSource', '', kktfwp_postid() ); if ( $source == 'disabled' || rwmb_meta( '_kktfwp_titleType', '', kktfwp_postid() ) == 'hero' ) { return; } printf( '<div class="kktfwp-title"><div class="kktfwp-title-wrapper">%s</div></div>', kktfwp_getTitle() ); } } /*-----------------------------------------------------------------------------------*/ /* HERO HEADER /*-----------------------------------------------------------------------------------*/ if ( ! function_exists( 'kktfwp_hero_func' ) ) { function kktfwp_hero_func() { $post_id = kktfwp_postid(); if ( rwmb_meta( '_kktfwp_titleType', '', $post_id ) != 'hero' ) { return; } $hero_bg_img = false; $hero_bg_vid = false; // BG Image $hero_bg_img = rwmb_meta( '_kktfwp_heroimg', '', $post_id ); if ( is_array ($hero_bg_img) ) { $hero_bg_img = array_shift($hero_bg_img); } // BG Video $hero_bg_vid = rwmb_meta( '_kktfwp_herovid', '', $post_id ); $muteVideo = 'muted'; if ( rwmb_meta( '_kktfwp_muteVid', '', $post_id ) != true ) $muteVideo = ''; if ( is_array($hero_bg_vid) ) { $hero_bg_vid = array_shift( $hero_bg_vid ); } $out = ''; $out .= '<div class="kktfwp-hero-wrapper">'; $out .= '<div id="hero--content" class="kktfwp-hero-content">'; $out .= '<div id="hero-title" class="kktfwp-hero-text">'; $out .= kktfwp_getTitle(); $out .= '</div>'; if ( (rwmb_meta('_kktfwp_heroH', '', kktfwp_postid()) !== 'global' ? rwmb_meta('_kktfwp_heroHV', '', kktfwp_postid()) : get_theme_mod( 'kktfwp_hero_height', '100' ) ) >= 96 ) { $out .= '<div class="kktfwp-scrollDown"></div>'; } $out .= '</div>'; if ( $hero_bg_vid || $hero_bg_img ) $out .= '<div id="hero" class="responsively-lazy responsively-lazy-hero">'; if ( $hero_bg_vid ) $out .= '<video id="kktfwp-html5-video" class="kktfwp-html5-video kktfwp-adjust-me" loop autoplay playsinline preload="none" '.esc_attr( $muteVideo ).'><source src="'. esc_url( $hero_bg_vid['url'] ).'" type="video/'.esc_attr( $hero_bg_vid['fileformat'] ).'" /></video>'; if ( $hero_bg_img ) $out .= wp_get_attachment_image( $hero_bg_img['ID'], 'full', '', array( 'class' => 'responsively-lazy-img kktfwp-hero-img kktfwp-adjust-me', 'data-lazy-load' => 1 ) ); if ( $hero_bg_vid || $hero_bg_img ) $out .= '</div>'; $out .= '<div class="kktfwp-hero-overlay"></div>'; $out .= '</div>'; $out .= '<div id="kktfwp-hero-placeholder" class="kktfwp-hero-placeholder"></div>'; return $out; } } /*-----------------------------------------------------------------------------------*/ /* OEMBED FILTER /*-----------------------------------------------------------------------------------*/ add_filter( 'embed_oembed_html', 'kktfwp_wrap_oembed_html', 99, 4 ); if ( ! function_exists( 'kktfwp_wrap_oembed_html' ) ) { function kktfwp_wrap_oembed_html( $cached_html, $url, $attr, $post_id ) { if ( ( strpos( $url, 'youtube.com' ) || strpos( $url, 'vimeo.com' ) ) == false ) return $cached_html; return '<div class="responsive-oembed-video">' . $cached_html . '</div>'; } } /*-----------------------------------------------------------------------------------*/ /* METABOXES FILTERS /*-----------------------------------------------------------------------------------*/ add_filter( 'rwmb_outside_conditions', function( $conditions ) { $conditions['.rwmb-tab-portfolio'] = array( 'visible' => array ( 'when' => array( array('page_template', 'template-portfolio.php'), array('template-selector-0', 'template-portfolio.php') ), 'relation' => 'or' ) ); return $conditions; } ); /*-----------------------------------------------------------------------------------*/ /* CUSTOM CUSTOMIZER SETTINGS -----------------------------------------------------------------------------------*/ require_once get_theme_file_path( '/inc/customizer/class-kktfwp-inline-css.php' ); // Enable font size & font family selects in the editor if ( ! function_exists( 'kktfwp_mce_buttons' ) ) { function kktfwp_mce_buttons( $buttons ) { array_unshift( $buttons, 'styleselect' ); return $buttons; } } add_filter( 'mce_buttons', 'kktfwp_mce_buttons' ); add_filter( 'tiny_mce_before_init', 'kktfwp_mce_formats', 10, 2 ); if ( ! function_exists( 'kktfwp_mce_formats' ) ) { function kktfwp_mce_formats( $args, $editor ){ $style_formats = array(); $items = array(); $line_height_items = array(); $c = 2; for ( $i = 12; $i <= 82; $i += $c) { $items[] = array( 'title' => $i.'px', 'inline' => 'span', 'attributes' => array( 'class' => 'kktfwp-fs-'.$i.'' ), 'style_formats_autohide' => true ); if ( $i >= 20 && $i < 50 ) { $c = 4; } else if ( $i >= 50 && $i < 60 ) { $c = 6; } } for ( $i = 1; $i <2.1; $i += 0.1 ) { $line_height_items[] = array ( 'title' => $i, 'selector' => 'p,h1,h2,h3,h4,h5,h6,td,th,ul,ol,li,table', 'styles' => array( 'line-height' => (string)$i ), 'style_formats_autohide' => true ); } $style_formats[] = array( 'title' => esc_html__( 'Font size', 'benue' ), 'items' => $items ); $style_formats[] = array( 'title' => esc_html__( 'Line Height', 'benue' ), 'items' => $line_height_items ); $args['style_formats'] = json_encode( $style_formats ); return $args; } } @ini_set( 'upload_max_size' , '64M' ); @ini_set( 'post_max_size', '64M'); @ini_set( 'max_execution_time', '300' );