//Class Theme Helper
require_once ( get_template_directory() . '/core/class/theme-helper.php' );
//Class Theme Cache
require_once ( get_template_directory() . '/core/class/theme-cache.php' );
//Class Walker comments
require_once ( get_template_directory() . '/core/class/walker-comment.php' );
//Class Walker Mega Menu
require_once ( get_template_directory() . '/core/class/walker-mega-menu.php' );
//Class Theme Likes
require_once ( get_template_directory() . '/core/class/theme-likes.php' );
//Class Theme Cats Meta
require_once ( get_template_directory() . '/core/class/theme-cat-meta.php' );
//Class Single Post
require_once ( get_template_directory() . '/core/class/single-post.php' );
//Class Theme Autoload
require_once ( get_template_directory() . '/core/class/theme-autoload.php' );
//Class Tinymce
require_once(get_template_directory() . "/core/class/tinymce-icon.php");
function ebrima_editor() {
/* This theme styles the visual editor with editor-style.css to match the theme style. */
add_editor_style( 'css/editor-styles.css' );
add_editor_style('fonts/flaticon/flaticon.css');
add_theme_support( 'editor-styles' );
}
add_action( 'after_setup_theme', 'ebrima_editor' );
function ebrima_content_width() {
if ( ! isset( $content_width ) ) {
$content_width = 940;
}
}
add_action( 'after_setup_theme', 'ebrima_content_width', 0 );
function ebrima_theme_slug_setup() {
add_theme_support('title-tag');
}
add_action('after_setup_theme', 'ebrima_theme_slug_setup');
require_once(get_template_directory() . '/wpb/wpb-init.php');
add_action('init', 'ebrima_page_init');
if (!function_exists('ebrima_page_init')) {
function ebrima_page_init()
{
add_post_type_support('page', 'excerpt');
}
}
if (!function_exists('ebrima_main_menu')) {
function ebrima_main_menu ($location = ''){
wp_nav_menu( array(
'theme_location' => 'main_menu',
'menu' => $location,
'container' => '',
'container_class' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'walker' => new Ebrima_Mega_Menu_Waker()
) );
}
}
// return all sidebars
if (!function_exists('ebrima_get_all_sidebar')) {
function ebrima_get_all_sidebar() {
global $wp_registered_sidebars;
$out = array();
if ( empty( $wp_registered_sidebars ) )
return;
foreach ( $wp_registered_sidebars as $sidebar_id => $sidebar) :
$out[$sidebar_id] = $sidebar['name'];
endforeach;
return $out;
}
}
if (!function_exists('ebrima_get_custom_preset')) {
function ebrima_get_custom_preset() {
$custom_preset = get_option('ebrima_set_preset');
$presets = ebrima_default_preset();
$out = array();
$out['default'] = esc_html__( 'Default', 'ebrima' );
$i = 1;
if(is_array($presets)){
foreach ($presets as $key => $value) {
$out[$key] = $key;
$i++;
}
}
if(is_array($custom_preset)){
foreach ( $custom_preset as $preset_id => $preset) :
$out[$preset_id] = $preset_id;
endforeach;
}
return $out;
}
}
if (!function_exists('ebrima_get_custom_menu')) {
function ebrima_get_custom_menu() {
$taxonomies = array();
$menus = get_terms('nav_menu');
foreach ($menus as $key => $value) {
$taxonomies[$value->name] = $value->name;
}
return $taxonomies;
}
}
function ebrima_get_attachment( $attachment_id ) {
$attachment = get_post( $attachment_id );
return array(
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'href' => get_permalink( $attachment->ID ),
'src' => $attachment->guid,
'title' => $attachment->post_title
);
}
if (!function_exists('ebrima_reorder_comment_fields')) {
function ebrima_reorder_comment_fields($fields ) {
$new_fields = array();
$myorder = array('author', 'email', 'url', 'comment');
foreach( $myorder as $key ){
$new_fields[ $key ] = isset($fields[ $key ]) ? $fields[ $key ] : '';
unset( $fields[ $key ] );
}
if( $fields ) {
foreach( $fields as $key => $val ) {
$new_fields[ $key ] = $val;
}
}
return $new_fields;
}
}
add_filter('comment_form_fields', 'ebrima_reorder_comment_fields');
function ebrima_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter( 'mce_buttons_2', 'ebrima_mce_buttons_2' );
function ebrima_tiny_mce_before_init( $settings ) {
$settings['theme_advanced_blockformats'] = 'p,h1,h2,h3,h4';
$style_formats = array(
array(
'title' => esc_html__( 'Dropcap', 'ebrima' ),
'items' => array(
array(
'title' => esc_html__( 'Dropcap', 'ebrima' ),
'inline' => 'span',
'classes' => 'dropcap',
'styles' => array( 'color' => esc_attr( Ebrima_Theme_Helper::get_option('theme-custom-color') )),
),
array(
'title' => esc_html__( 'Dropcap with background', 'ebrima' ),
'inline' => 'span',
'classes' => 'dropcap-bg',
'styles' => array( 'background-color' => esc_attr( Ebrima_Theme_Helper::get_option('theme-custom-color') )),
),
),
),
array(
'title' => esc_html__( 'Highlighter', 'ebrima' ),
'inline' => 'span',
'classes' => 'highlighter',
'styles' => array( 'color' => '#ffffff', 'background-color' => esc_attr( Ebrima_Theme_Helper::get_option('theme-custom-color') )),
),
array(
'title' => esc_html__( 'Double Heading Font', 'ebrima' ),
'inline' => 'span',
'classes' => 'dbl_font',
),
array(
'title' => esc_html__( 'Font Weight', 'ebrima' ),
'items' => array(
array( 'title' => esc_html__( 'Default', 'ebrima' ), 'inline' => 'span', 'classes' => '', 'styles' => array( 'font-weight' => 'inherit' ) ),
array( 'title' => esc_html__( 'Lightest (100)', 'ebrima' ), 'inline' => 'span', 'classes' => '', 'styles' => array( 'font-weight' => '100' ) ),
array( 'title' => esc_html__( 'Lighter (200)', 'ebrima' ), 'inline' => 'span', 'classes' => '', 'styles' => array( 'font-weight' => '200' ) ),
array( 'title' => esc_html__( 'Light (300)', 'ebrima' ), 'inline' => 'span', 'classes' => '', 'styles' => array( 'font-weight' => '300' ) ),
array( 'title' => esc_html__( 'Normal (400)', 'ebrima' ), 'inline' => 'span', 'classes' => '', 'styles' => array( 'font-weight' => '400' ) ),
array( 'title' => esc_html__( 'Medium (500)', 'ebrima' ), 'inline' => 'span', 'classes' => '', 'styles' => array( 'font-weight' => '500' ) ),
array( 'title' => esc_html__( 'Semi-Bold (600)', 'ebrima' ), 'inline' => 'span', 'classes' => '', 'styles' => array( 'font-weight' => '600' ) ),
array( 'title' => esc_html__( 'Bold (700)', 'ebrima' ), 'inline' => 'span', 'classes' => '', 'styles' => array( 'font-weight' => '700' ) ),
array( 'title' => esc_html__( 'Bolder (800)', 'ebrima' ), 'inline' => 'span', 'classes' => '', 'styles' => array( 'font-weight' => '800' ) ),
array( 'title' => esc_html__( 'Extra Bold (900)', 'ebrima' ), 'inline' => 'span', 'classes' => '', 'styles' => array( 'font-weight' => '900' ) ),
)
),
array(
'title' => esc_html__( 'List Style', 'ebrima' ),
'items' => array(
array( 'title' => esc_html__( 'Check', 'ebrima' ), 'selector' => 'ul', 'classes' => 'ebrima_check' ),
array( 'title' => esc_html__( 'Plus', 'ebrima' ), 'selector' => 'ul', 'classes' => 'ebrima_plus' ),
array( 'title' => esc_html__( 'Dash', 'ebrima' ), 'selector' => 'ul', 'classes' => 'ebrima_dash' ),
array( 'title' => esc_html__( 'Slash', 'ebrima' ), 'selector' => 'ul', 'classes' => 'ebrima_slash' ),
array( 'title' => esc_html__( 'No List Style', 'ebrima' ), 'selector' => 'ul', 'classes' => 'no-list-style' ),
)
),
);
$settings['style_formats'] = str_replace( '"', "'", json_encode( $style_formats ) );
$settings['extended_valid_elements'] = 'span[*],a[*],i[*]';
return $settings;
}
add_filter( 'tiny_mce_before_init', 'ebrima_tiny_mce_before_init' );
function ebrima_theme_add_editor_styles() {
add_editor_style( 'css/font-awesome.min.css' );
}
add_action( 'current_screen', 'ebrima_theme_add_editor_styles' );
function ebrima_categories_postcount_filter ($variable) {
if(strpos($variable,' (')){
$variable = str_replace(' (', ' (', $variable);
$variable = str_replace(' (', ' (', $variable);
$variable = str_replace(')', ')', $variable);
}
else{
$variable = str_replace(' (', '(', $variable);
}
$pattern1 = '/cat-item-\d+/';
preg_match_all( $pattern1, $variable,$matches );
if(isset($matches[0])){
foreach ($matches[0] as $key => $value) {
$int = (int) str_replace('cat-item-','', $value);
$icon_image_id = get_term_meta ( $int, 'category-icon-image-id', true );
if(!empty($icon_image_id)){
$icon_image = wp_get_attachment_image_src ( $icon_image_id, 'full' );
$icon_image_alt = get_post_meta($icon_image_id, '_wp_attachment_image_alt', true);
$replacement = '$1';
$pattern = '/(cat-item-'.$int.'+.*?>
are you struggling to get comments on your blog?
]]>are you struggling to get comments on your blog?
]]>