D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
proc
/
thread-self
/
root
/
proc
/
self
/
cwd
/
wp-content
/
themes
/
aeen
/
inc
/
Filename :
helper.php
back
Copy
<?php /** * @author RadiusTheme * @since 1.0 * @version 1.1 */ namespace radiustheme\aeen\inc; use \WP_Query; use radiustheme\aeen\IconTrait; use radiustheme\aeen\CustomQueryTrait; use radiustheme\aeen\ResourceLoadTrait; use radiustheme\aeen\UtilityTrait; use radiustheme\aeen\DataTrait; use radiustheme\aeen\LayoutTrait; use radiustheme\aeen\Asset_Loader_Trait; class Helper { use IconTrait; use CustomQueryTrait; use ResourceLoadTrait; use UtilityTrait; use DataTrait; use LayoutTrait; public static function rt_the_logo_light() { if ( has_custom_logo() ) { $custom_logo_id = get_theme_mod( 'custom_logo' ); $customizer_logo = wp_get_attachment_image( $custom_logo_id , 'full' ); $logo_light = $customizer_logo; } elseif( RDTheme::$options['logo'] ) { $logo_light = wp_get_attachment_image( RDTheme::$options['logo'], 'full'); }else{ $logo_light = Helper::get_img( 'logo-light.png' ); $logo_light = "<img src='". esc_url( $logo_light ) ."' alt='". esc_attr( get_bloginfo( 'name' ) ). "'>"; } return $logo_light; } public static function rt_the_logo_dark() { if ( has_custom_logo() ) { $custom_logo_id = get_theme_mod( 'custom_logo' ); $customizer_logo = wp_get_attachment_image( $custom_logo_id , 'full' ); $logo_dark = $customizer_logo; }elseif( RDTheme::$options['logo_dark'] ){ $logo_dark = wp_get_attachment_image( RDTheme::$options['logo_dark'], 'full'); } else { $logo_dark = Helper::get_img( 'logo.png' ); $logo_dark = "<img src='". esc_url( $logo_dark ) ."' alt='". esc_attr( get_bloginfo( 'name' ) ). "'>"; } return $logo_dark; } public static function aeen_generate_excerpt($post, $length = 55, $dot = false) { if (has_excerpt($post)) { $final_content = wp_trim_words( get_the_excerpt($post), $length, ''); } $post = get_post($post); $content = wp_strip_all_tags($post->post_content); $final_content = wp_trim_words( $content, $length, '' ); if ($dot) { $final_content = "$final_content $dot"; } return $final_content; } public static function aeen_excerpt( $limit ) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt)>=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).''; } else { $excerpt = implode(" ",$excerpt); } $excerpt = preg_replace('`[[^]]*]`','',$excerpt); return $excerpt; } public static function aeen_get_attachment_alt( $attachment_ID ) { // Get ALT $thumb_alt = get_post_meta( $attachment_ID, '_wp_attachment_image_alt', true ); // No ALT supplied get attachment info if ( empty( $thumb_alt ) ) $attachment = get_post( $attachment_ID ); // Use caption if no ALT supplied if ( empty( $thumb_alt ) ) $thumb_alt = $attachment->post_excerpt; // Use title if no caption supplied either if ( empty( $thumb_alt ) ) $thumb_alt = $attachment->post_title; // Return ALT return esc_attr( trim( strip_tags( $thumb_alt ) ) ); } public static function generate_elementor_anchor($anchor, $anchor_text="Read More", $classes='') { if ( ! empty( $anchor['url'] ) ) { $class_attribute = ''; if ( $classes ) { $class_attribute = "class='{$classes}'"; } $target_attribute = ""; if ( $anchor['is_external'] ) { $target_attribute = 'target="_blank"'; } $rel_attribute = ""; if ( $anchor['nofollow'] ) { $rel_attribute = 'rel="nofollow"'; } $anchor_url = $anchor['url']; $href_attributes = "href='{$anchor_url}'"; $all_attributes = "$class_attribute $target_attribute $rel_attribute $href_attributes"; $a = sprintf( '<%1$s %2$s>%3$s</%1$s>', 'a', $all_attributes, $anchor_text ); return $a; }; return null; } public static function custom_sidebar_fields() { $aeen = AEEN_THEME_PREFIX_VAR; $sidebar_fields = array(); $sidebar_fields['sidebar'] = esc_html__( 'Sidebar', 'aeen' ); $sidebar_fields['sidebar-project'] = esc_html__( 'Project Sidebar ', 'aeen' ); $sidebars = get_option( "{$aeen}_custom_sidebars", array() ); if ( $sidebars ) { foreach ( $sidebars as $sidebar ) { $sidebar_fields[$sidebar['id']] = $sidebar['name']; } } return $sidebar_fields; } public static function aeen_get_primary_category() { if( get_post_type() != 'post' ) { return; } # Get the first assigned category ---------- $get_the_category = get_the_category(); $primary_category = array( $get_the_category[0] ); if( ! empty( $primary_category[0] )) { return $primary_category; } } public static function filter_content( $content ){ // wp filters $content = wptexturize( $content ); $content = convert_smilies( $content ); $content = convert_chars( $content ); $content = wpautop( $content ); $content = shortcode_unautop( $content ); // remove shortcodes $pattern= '/\[(.+?)\]/'; $content = preg_replace( $pattern,'',$content ); // remove tags $content = strip_tags( $content ); return $content; } public static function get_current_post_content( $post = false ) { if ( !$post ) { $post = get_post(); } $content = has_excerpt( $post->ID ) ? $post->post_excerpt : $post->post_content; $content = self::filter_content( $content ); return $content; } public static function pagination( $max_num_pages = false ) { global $wp_query; $max = $max_num_pages ? $max_num_pages : $wp_query->max_num_pages; $max = intval( $max ); /** Stop execution if there's only 1 page */ if( $max <= 1 ) return; $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; /** Add current page to the array */ if ( $paged >= 1 ) $links[] = $paged; /** Add the pages around the current page to the array */ if ( $paged >= 3 ) { $links[] = $paged - 1; $links[] = $paged - 2; } if ( ( $paged + 2 ) <= $max ) { $links[] = $paged + 2; $links[] = $paged + 1; } include AEEN_THEME_VIEW_DIR . 'pagination.php'; } public static function comments_callback( $comment, $args, $depth ){ include AEEN_THEME_VIEW_DIR . 'comments-callback.php'; } public static function nav_menu_args(){ $aeen = AEEN_THEME_PREFIX_VAR; $pagemenu = false; if ( ( is_single() || is_page() ) ) { $menuid = get_post_meta( get_the_id(), "{$aeen}_page_menu", true ); if ( !empty( $menuid ) && $menuid != 'default' ) { $pagemenu = $menuid; } } if ( $pagemenu ) { $nav_menu_args = array( 'menu' => $pagemenu,'container' => 'nav' ); } else { $nav_menu_args = array( 'theme_location' => 'primary','container' => 'nav' ); } return $nav_menu_args; } public static function offcanvas_menu_args(){ $nav_menu_args = array( 'theme_location' => 'offcanvas', 'container' => 'ul', 'menu_class' => 'offcanvas-menu', ); return $nav_menu_args; } public static function footer_menu_args(){ $nav_menu_args = array( 'menu_class' => 'footer-menu', 'theme_location' => 'footer', ); return $nav_menu_args; } public static function requires( $filename, $dir = false ){ if ( $dir) { $child_file = get_stylesheet_directory() . '/' . $dir . '/' . $filename; if ( file_exists( $child_file ) ) { $file = $child_file; } else { $file = get_template_directory() . '/' . $dir . '/' . $filename; } } else { $child_file = get_stylesheet_directory() . '/inc/' . $filename; if ( file_exists( $child_file ) ) { $file = $child_file; } else { $file = AEEN_THEME_INC_DIR . $filename; } } require_once $file; } public static function the_breadcrumb() { if ( function_exists( 'bcn_display') ) { bcn_display(); } else { Helper::requires( 'breadcrumbs.php' ); $args = array( 'show_browse' => false, 'post_taxonomy' => array( 'product' =>'product_cat' ) ); $breadcrumb = new RDTheme_Breadcrumb( $args ); return $breadcrumb->trail(); } } public static function rt_registered_post_type(){ $args = array( 'public' => true, ); $post_types = get_post_types( $args, 'objects' ); unset( $post_types['page'] ); unset( $post_types['attachment'] ); if(!empty($post_types)){ $posttypes = array(); foreach ($post_types as $key => $post_type_obj) { $labels = get_post_type_labels( $post_type_obj ); $posttypes[$post_type_obj->name] = $labels->name; } $posttypes = array( 'post' => 'post' ) + $posttypes; return $posttypes; } } public static function has_practice_sidebar() { $has_sidebar_widgets = false; if ( is_active_sidebar( 'practice-sidebar' ) ){ return $has_sidebar_widgets = true; } } // Header Socials public static function socials(){ $rdtheme_socials = [ 'social_facebook' => [ 'icon' => 'fab fa-facebook-f', 'url' => RDTheme::$options['social_facebook'], ], 'social_twitter' => [ 'icon' => 'fab fa-twitter', 'url' => RDTheme::$options['social_twitter'], ], 'social_behance' => [ 'icon' => 'fab fa-behance', 'url' => RDTheme::$options['social_behance'], ], 'social_pinterest' => [ 'icon' => 'fab fa-pinterest-p', 'url' => RDTheme::$options['social_pinterest'], ], 'social_gplus' => [ 'icon' => 'fab fa-google-plus-g', 'url' => RDTheme::$options['social_gplus'], ], 'social_linkedin' => [ 'icon' => 'fab fa-linkedin-in', 'url' => RDTheme::$options['social_linkedin'], ], 'social_dribbble' => [ 'icon' => 'fab fa-dribbble', 'url' => RDTheme::$options['social_dribbble'], ], 'social_youtube' => [ 'icon' => 'fab fa-youtube', 'url' => RDTheme::$options['social_youtube'], ], 'social_instagram' => [ 'icon' => 'fab fa-instagram', 'url' => RDTheme::$options['social_instagram'], ], 'social_skype' => [ 'icon' => 'fab fa-skype', 'url' => RDTheme::$options['social_skype'], ], ]; return array_filter( $rdtheme_socials, [__CLASS__ , 'filter_social']); } public static function filter_social( $args ){ return ( $args['url'] != '' ); } // Team Social Method public static function team_socials(){ $team_socials = array( 'facebook' => array( 'label' => __( 'Facebook', 'aeen' ), 'type' => 'text', 'icon' => 'fa-facebook-f', ), 'twitter' => array( 'label' => __( 'Twitter', 'aeen' ), 'type' => 'text', 'icon' => 'fa-twitter', ), 'linkedin' => array( 'label' => __( 'Linkedin', 'aeen' ), 'type' => 'text', 'icon' => 'fa-linkedin', ), 'gplus' => array( 'label' => __( 'Google Plus', 'aeen' ), 'type' => 'text', 'icon' => 'fa-google-plus', ), 'behance' => array( 'label' => __( 'Behance', 'aeen' ), 'type' => 'text', 'icon' => 'fa-behance', ), 'dribbble' => array( 'label' => __( 'Dribbble', 'aeen' ), 'type' => 'text', 'icon' => 'fa-dribbble', ), 'skype' => array( 'label' => __( 'Skype', 'aeen' ), 'type' => 'text', 'icon' => 'fa-skype', ), 'youtube' => array( 'label' => __( 'Youtube', 'aeen' ), 'type' => 'text', 'icon' => 'fa-youtube-play', ), 'pinterest' => array( 'label' => __( 'Pinterest', 'aeen' ), 'type' => 'text', 'icon' => 'fa-pinterest-p', ), 'instagram' => array( 'label' => __( 'Instagram', 'aeen' ), 'type' => 'text', 'icon' => 'fa-instagram', ), 'github' => array( 'label' => __( 'Github', 'aeen' ), 'type' => 'text', 'icon' => 'fa-github', ), 'stackoverflow' => array( 'label' => __( 'Stackoverflow', 'aeen' ), 'type' => 'text', 'icon' => 'fa-stack-overflow', ), ); return apply_filters( 'AeenTheme_Helper', $team_socials ); } }