Current Path : /var/www/ooareogundevinitiative/wp-content/themes/pain/framework/ |
Current File : /var/www/ooareogundevinitiative/wp-content/themes/pain/framework/template-functions.php |
<?php if ( ! isset( $content_width ) ) $content_width = 900; if ( is_singular() ) wp_enqueue_script( "comment-reply" ); if ( ! function_exists( 'jwstheme_setup' ) ) { function jwstheme_setup() { global $jwstheme_options; load_theme_textdomain( 'jwsthemes', get_template_directory() . '/languages' ); // Add Custom Header. add_theme_support('custom-header'); // Add RSS feed links to <head> for posts and comments. add_theme_support( 'automatic-feed-links' ); // Enable support for Post Thumbnails, and declare sizes. add_theme_support( 'post-thumbnails' ); //Enable support for Title Tag add_theme_support( "title-tag" ); // This theme uses wp_nav_menu() in locations. register_nav_menus( array( 'main_navigation' => __( 'Main Navigation','pain' ), ) ); // Add support for Block Styles. add_theme_support( 'wp-block-styles' ); // Add support for full and wide align images. add_theme_support( 'align-wide' ); // Add support for editor styles. add_theme_support( 'editor-styles' ); // Add support for responsive embedded content. add_theme_support( 'responsive-embeds' ); // This theme styles the visual editor to resemble the theme style. add_editor_style(array('css/editor-style.css')); // Add RSS feed links to <head> for posts and comments. /* * 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' ) ); /* * Enable support for Post Formats. * See http://codex.wordpress.org/Post_Formats */ add_theme_support( 'post-formats', array( 'video', 'audio', 'quote', 'link', 'gallery', ) ); // This theme allows users to set a custom background. add_theme_support( 'custom-background', apply_filters( 'jwstheme_custom_background_args', array( 'default-color' => 'f5f5f5', ) ) ); // Add support for featured content. add_theme_support( 'featured-content', array( 'featured_content_filter' => 'jwstheme_get_featured_posts', 'max_posts' => 6, ) ); // This theme uses its own gallery styles. add_filter( 'use_default_gallery_style', '__return_false' ); //woocommercle thumbanil gallery. add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); // Register a new image size add_image_size( 'jwstheme_custom_blog_archive_size', 770, 532, true ); add_image_size( 'jwstheme_custom_blog_single_size', 870, 432, true ); add_image_size( 'imge-crop-testimonial', 200, 220, true ); add_image_size( 'imge-crop-thumbnail-click-show-content', 270, 290, true ); add_image_size( 'jws-imge-crop-thumbnail-event-grid', 370, 410, true ); add_image_size( 'jws-imge-crop-thumbnail-team', 270, 465, true ); add_image_size( 'jws-imge-crop-thumbnail-team-single', 370, 480, true ); add_image_size( 'jws-imge-crop-thumbnail-story', 485,620, true ); add_image_size( 'jws-imge-crop-thumbnail-gallery', 370,380, true ); add_image_size( 'jws-imge-crop-thumbnail-donors', 250,290, true ); add_image_size( 'jwstheme_custom_blog_grid', 570, 770, true ); add_image_size( 'jwstheme_custom_casemenus', 100, 82, true ); } } add_action( 'after_setup_theme', 'jwstheme_setup' ); /* Style Inline */ function jwstheme_add_style_inline() { global $jwstheme_options; $custom_style = null; if (isset($jwstheme_options['custom_css_code']) && $jwstheme_options['custom_css_code']) { $custom_style .= "{$jwstheme_options['custom_css_code']}"; } wp_enqueue_style('wp_custom_style', URI_PATH . '/assets/css/wp_custom_style.css',array('style')); /* Body background */ $tb_background_color =& $jwstheme_options['tb_background']['background-color']; $tb_background_image =& $jwstheme_options['tb_background']['background-image']; $tb_background_repeat =& $jwstheme_options['tb_background']['background-repeat']; $tb_background_position =& $jwstheme_options['tb_background']['background-position']; $tb_background_size =& $jwstheme_options['tb_background']['background-size']; $tb_background_attachment =& $jwstheme_options['tb_background']['background-attachment']; $custom_style .= "body{ background-color: $tb_background_color;}"; if($tb_background_image){ $custom_style .= "body{ background: url('$tb_background_image') $tb_background_repeat $tb_background_attachment $tb_background_position;background-size: $tb_background_size;}"; } /* Title bar background */ $tb_title_bar_bg_color =& $jwstheme_options['tb_title_bar_bg']['background-color']; $title_bar_bg_image =& $jwstheme_options['tb_title_bar_bg']['background-image']; $title_bar_bg_repeat =& $jwstheme_options['tb_title_bar_bg']['background-repeat']; $title_bar_bg_position =& $jwstheme_options['tb_title_bar_bg']['background-position']; $title_bar_bg_size =& $jwstheme_options['tb_title_bar_bg']['background-size']; $title_bar_bg_attachment =& $jwstheme_options['tb_title_bar_bg']['background-attachment']; $custom_style .= ".ro-blog-header { background-color: $tb_title_bar_bg_color;}"; if($title_bar_bg_image){ $custom_style .= ".ro-blog-header { background: url('$title_bar_bg_image') $title_bar_bg_repeat $title_bar_bg_attachment $title_bar_bg_position;background-size: $title_bar_bg_size;}"; } wp_add_inline_style( 'wp_custom_style', $custom_style ); /*End Font*/ } add_action( 'wp_enqueue_scripts', 'jwstheme_add_style_inline' ); /* Header */ function jwstheme_Header() { global $jwstheme_options, $post; $header_layout = ( isset( $jwstheme_options["tb_header_layout"] ) && ! empty( $jwstheme_options["tb_header_layout"] ) ) ? $jwstheme_options["tb_header_layout"] : 'header-v2'; if( $post ){ $tb_header = get_post_meta( $post->ID, 'tb_header', true ) ? get_post_meta( $post->ID, 'tb_header', true ) : 'global'; $header_layout = ( $tb_header == 'global' ) ? $header_layout : $tb_header; } require sprintf( __DIR__ . '/headers/%s.php', $header_layout ); } if( ! function_exists( 'jwsthemes_Footer' ) ) : function jwsthemes_Footer() { global $jwstheme_options, $post; $footer_layout = ( isset( $jwstheme_options["tb_footer_layout"] ) && ! empty( $jwstheme_options["tb_footer_layout"] ) ) ? $jwstheme_options["tb_footer_layout"] : 'footer-v1'; # if( $post ){ # $tb_footer = get_post_meta( $post->ID, 'tb_header', true ) ? get_post_meta( $post->ID, 'tb_footer', true ) : 'global'; # $footer_layout = ( $tb_footer == 'global' ) ? $footer_layout : $tb_footer; # } require sprintf( __DIR__ . '/footers/%s.php', $footer_layout ); } endif; /* Logo */ if (!function_exists('jwstheme_logo')) { function jwstheme_logo($lg) { global $jwstheme_options; if($lg == 'v1') $logo = isset($jwstheme_options['tb_logo_image_hv1']['url']) && $jwstheme_options['tb_logo_image_hv1']['url'] ? $jwstheme_options['tb_logo_image_hv1']['url'] : URI_PATH.'/assets/images/logo-dark.png'; if($lg == 'v2') $logo = isset($jwstheme_options['tb_logo_image_hv2']['url']) && $jwstheme_options['tb_logo_image_hv2']['url'] ? $jwstheme_options['tb_logo_image_hv2']['url'] : URI_PATH.'/assets/images/logo-white.png'; if($lg == 'v3') $logo = isset($jwstheme_options['tb_logo_image_hv3']['url']) && $jwstheme_options['tb_logo_image_hv3']['url'] ? $jwstheme_options['tb_logo_image_hv3']['url'] : URI_PATH.'/assets/images/logo-big.png'; # style $style = array(); # logo height if( isset( $jwstheme_options['tb_logo_height'] ) && ! empty( $jwstheme_options['tb_logo_height'] ) ) array_push( $style , "height: {$jwstheme_options['tb_logo_height']}" ); echo '<img style="'. implode( ';', $style ) .'" src="'.esc_url($logo).'" alt="Logo"/>'; } } /* Page title */ if (!function_exists('jwstheme_page_title')) { function jwstheme_page_title() { ob_start(); if( is_home() ){ _e('Home', 'pain'); }elseif(is_search()){ _e('Search Keyword: ', 'pain'). '<span class="keywork">'. get_search_query( false ). '</span>'; }elseif(is_post_type_archive( 'tribe_events' )){ _e('Events', 'pain'); }elseif (!is_archive()) { if(is_singular( 'tribe_events' )) { _e('Event Detail', 'pain'); } else { the_title(); } } else { if (is_category()){ single_cat_title(); }elseif(get_post_type() == 'tribe_events' || get_post_type() == 'give_forms' || get_post_type() == 'team' || get_post_type() == 'testimonial' || get_post_type() == 'product'){ single_term_title(); }elseif (is_tag()){ single_tag_title(); }elseif (is_author()){ printf(__('Author: %s', 'pain'), '<span class="vcard">' . get_the_author() . '</span>'); }elseif (is_day()){ printf(__('Day: %s', 'pain'), '<span>' . get_the_date() . '</span>'); }elseif (is_month()){ printf(__('Month: %s', 'pain'), '<span>' . get_the_date() . '</span>'); }elseif (is_year()){ printf(__('Year: %s', 'pain'), '<span>' . get_the_date() . '</span>'); }elseif (is_tax('post_format', 'post-format-aside')){ _e('Asides', 'pain'); }elseif (is_tax('post_format', 'post-format-gallery')){ _e('Galleries', 'pain'); }elseif (is_tax('post_format', 'post-format-image')){ _e('Images', 'pain'); }elseif (is_tax('post_format', 'post-format-video')){ _e('Videos', 'pain'); }elseif (is_tax('post_format', 'post-format-quote')){ _e('Quotes', 'pain'); }elseif (is_tax('post_format', 'post-format-link')){ _e('Links', 'pain'); }elseif (is_tax('post_format', 'post-format-status')){ _e('Statuses', 'pain'); }elseif (is_tax('post_format', 'post-format-audio')){ _e('Audios', 'pain'); }elseif (is_tax('post_format', 'post-format-chat')){ _e('Chats', 'pain'); }else{ _e('Archives', 'pain'); } } return ob_get_clean(); } } /* Page breadcrumb */ if (!function_exists('jwstheme_page_breadcrumb')) { function jwstheme_page_breadcrumb($delimiter) { ob_start(); $home = __('Home', 'pain'); global $post; $homeLink = home_url(); if( is_home() ){ _e('Home', 'pain'); }else{ echo '<a href="' . $homeLink . '">' . $home . '</a> ' . '<span class="delimiter">'. $delimiter . '</span>' . ' '; } if ( is_category() ) { $thisCat = get_category(get_query_var('cat'), false); if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' '); echo '<span class="current">' . __('Archive by category: ', 'pain') . single_cat_title('', false) . '</span>'; } elseif ( is_search() ) { echo '<span class="current">' . __('Search results for: ', 'pain') . get_search_query() . '</span>'; } elseif ( is_post_type_archive( 'tribe_events' ) ) { echo '<span class="current">' . __('Events', 'pain') . '</span>'; } elseif ( is_day() ) { echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F').' '. get_the_time('Y') . '</a> ' . $delimiter . ' '; echo '<span class="current">' . get_the_time('d') . '</span>'; } elseif ( is_post_type_archive( 'give_forms' ) ) { echo '<span class="current">' . __('Causes Slide', 'pain') . '</span>'; }elseif(is_tax( 'give_forms_category' )){ echo '<span class="current">' . __('Causes Slide', 'pain') . '</span>'; }elseif ( is_month() ) { echo '<span class="current">' . get_the_time('F'). ' '. get_the_time('Y') . '</span>'; } elseif ( is_single() && !is_attachment() ) { if ( get_post_type() != 'post' ) { if(get_post_type() == 'portfolio'){ $terms = get_the_terms(get_the_ID(), 'portfolio_category', '' , '' ); if($terms) { the_terms(get_the_ID(), 'portfolio_category', '' , ', ' ); echo '' . '<span class="current">' . get_the_title() . '</span>'; }else{ echo '<span class="current">' .esc_html('Portfolio Details', 'pain'). '</span>'; } }elseif(get_post_type() == 'give_forms'){ $terms = get_the_terms(get_the_ID(), 'recipe_category', '' , '' ); if($terms) { the_terms(get_the_ID(), 'recipe_category', '' , ', ' ); echo ' ' . '<span class="current">' .esc_html('Causes Details', 'pain'). '</span>'; }else{ echo '<span class="current">' . get_the_title() . '</span>'; } }elseif(get_post_type() == 'team'){ $terms = get_the_terms(get_the_ID(), 'team_category', '' , '' ); if($terms) { the_terms(get_the_ID(), 'team_category', '' , ', ' ); echo '' . '<span class="current">'.esc_html('Team Details', 'pain'). '</span>'; }else{ echo '<span class="current">' . get_the_title() . '</span>'; } }elseif(get_post_type() == 'testimonial'){ $terms = get_the_terms(get_the_ID(), 'testimonial_category', '' , '' ); if($terms) { the_terms(get_the_ID(), 'testimonial_category', '' , ', ' ); echo '' . '<span class="current">' .esc_html('Testimonial Details', 'pain'). '</span>'; }else{ echo '<span class="current">' . get_the_title() . '</span>'; } }elseif(get_post_type() == 'story'){ echo '<span class="current">' . get_the_title() . '</span>'; }elseif(get_post_type() == 'product'){ $terms = get_the_terms(get_the_ID(), 'product_cat', '' , '' ); if($terms) { //the_terms(get_the_ID(), 'product_cat', '' , ', ' ); echo '' . '<span class="current">' .esc_html('Product Details', 'pain'). '</span>'; }else{ echo '<span class="current">'.esc_html('Product Details', 'pain').'</span>'; } }else{ if(is_singular( 'tribe_events' )) { echo '<span class="current">'.esc_html('Event Details', 'pain').'</span>'; } else { $post_type = get_post_type_object(get_post_type()); $slug = $post_type->rewrite; echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>'; echo ' ' . $delimiter . ' ' . '<span class="current">' . get_the_title() . '</span>'; } } } else { echo '<span class="current">' .esc_html('Blog Details', 'pain'). '</span>'; } } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) { $post_type = get_post_type_object(get_post_type()); if($post_type) echo '<span class="current">' . $post_type->labels->singular_name . '</span>'; } elseif ( is_attachment() ) { $parent = get_post($post->post_parent); echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>'; echo ' ' . $delimiter . ' ' . '<span class="current">' . get_the_title() . '</span>'; } elseif ( is_page() && !$post->post_parent ) { echo '<span class="current">' . get_the_title() . '</span>'; } elseif ( is_page() && $post->post_parent ) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>'; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); for ($i = 0; $i < count($breadcrumbs); $i++) { echo ''.$breadcrumbs[$i]; if ($i != count($breadcrumbs) - 1) echo ' ' . $delimiter . ' '; } echo ' ' . $delimiter . ' ' . '<span class="current">' . get_the_title() . '</span>'; } elseif ( is_tag() ) { echo '<span class="current">' . __('Posts tagged: ', 'pain') . single_tag_title('', false) . '</span>'; } elseif ( is_author() ) { global $author; $userdata = get_userdata($author); echo '<span class="current">' . __('Articles posted by ', 'pain') . $userdata->display_name . '</span>'; } elseif ( is_404() ) { echo '<span class="current">' . __('Error 404', 'pain') . '</span>'; } if ( get_query_var('paged') ) { if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' ('; echo ' '.'<span class="delimiter">'.$delimiter.'</span> ' . ' '.'<span class="paged-number">'.__('Page', 'pain') . ' ' . get_query_var('paged').'</span>'; if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')'; } return ob_get_clean(); } } /* Custom excerpt */ function jwstheme_custom_excerpt($limit, $more) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt) >= $limit) { array_pop($excerpt); $excerpt = implode(" ", $excerpt) . $more; } else { $excerpt = implode(" ", $excerpt); } $excerpt = preg_replace('`\[[^\]]*\]`', '', $excerpt); return $excerpt; } /* Display navigation to next/previous set of posts */ if ( ! function_exists( 'jwstheme_paging_nav' ) ) { function jwstheme_paging_nav() { if ( $GLOBALS['wp_query']->max_num_pages < 2 ) { return; } $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; $pagenum_link = html_entity_decode( get_pagenum_link() ); $query_args = array(); $url_parts = explode( '?', $pagenum_link ); if ( isset( $url_parts[1] ) ) { wp_parse_str( $url_parts[1], $query_args ); } $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%'; // Set up paginated links. $links = paginate_links( array( 'base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map( 'urlencode', $query_args ), 'prev_text' => __( '<i class="fa fa-angle-double-left"></i>', 'pain' ), 'next_text' => __( '<i class="fa fa-angle-double-right"></i>', 'pain' ), ) ); if ( $links ) { ?> <nav class="jw-pagination" role="navigation"> <?php echo ''.$links; ?> </nav> <?php } } } /* Display navigation to next/previous post */ if ( ! function_exists( 'jwstheme_post_nav' ) ) { function jwstheme_post_nav() { $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); if ( ! $next && ! $previous ) { return; } ?> <nav class="jw-blog-article-nav clearfix"> <?php previous_post_link( '%link', __( 'NEWEST POSTS', 'pain' ) ); next_post_link( '%link', __( 'OLDER POSTS', 'pain' ) ); ?> </nav> <?php } } /* Title Bar */ if ( ! function_exists( 'jwstheme_title_bar' ) ) { function jwstheme_title_bar($tb_show_page_title, $tb_show_page_breadcrumb) { global $jwstheme_options; $sujwext = isset($jwstheme_options['title_bar_sujwext']) ? $jwstheme_options['title_bar_sujwext'] : ''; $delimiter = isset($jwstheme_options['page_breadcrumb_delimiter']) ? $jwstheme_options['page_breadcrumb_delimiter'] : '/'; ?> <div class="jw-title-bar-wrap"> <div class="container"> <div class="row"> <div class="col-md-12"> <div class="jw-title-bar"> <?php if($tb_show_page_title){ ?> <h2 class="jw-text-ellipsis"><?php echo jwstheme_page_title(); ?></h2> <?php if($sujwext) echo '<h6>'.$sujwext.'</h6>'; ?> <?php } ?> <?php if($tb_show_page_breadcrumb){ ?> <div class="jw-path"> <div class="jw-path-inner"> <?php echo jwstheme_page_breadcrumb($delimiter); ?> </div> </div> <?php } ?> </div> </div> </div> </div> </div> <?php } } /* Cout View */ // function to count views. // function to display number of posts. function getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Views'; } // function to count views. function setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } }