���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home/rickpfrv/dr.rickard.co/wp-content/themes/caster/include/functions/theme-functions.php
���ѧ٧ѧ�
<?php /* * Return value for key * */ if ( ! function_exists( 'caster_get_option' ) ) { function caster_get_option( $key ) { global $caster_theme_settings; if ( class_exists( 'Caster_Theme_Options' ) && isset( $caster_theme_settings[ $key ] ) ) { $output = $caster_theme_settings[ $key ]; } else { $default_options = caster_theme_default_options(); if( isset( $default_options[ $key ] ) ) { $output = $default_options[ $key ]; } else { $output = ''; } } return $output; } } if ( ! function_exists( 'caster_build_data_attr' ) ) { function caster_build_data_attr( $data_attr ) { $data_attrs_array = array(); foreach ( $data_attr as $key => $value ) { if ( ! empty( $value ) ) { $data_attrs_array[] = $key . '="' . esc_attr( $value ) . '"'; } } return implode( ' ', $data_attrs_array ); } } if ( ! function_exists( 'caster_build_inline_style' ) ) { function caster_build_inline_style( $css_properties ) { $inline_style = array(); foreach ( $css_properties as $key => $value ) { if ( ! empty( $value ) ) { $inline_style[] = $key . ':' . $value; } } if ( ! empty( $inline_style ) ) { $inline_style = implode( ';', $inline_style ); return ' style="'. esc_attr( $inline_style ) .';"'; } else { return ''; } } } if ( ! function_exists( 'caster_get_category_ids' ) ) { function caster_get_category_ids( $category_slugs ) { $exclude_categories = array(); if( !empty( $category_slugs ) ) { foreach ( $category_slugs as $slug ) { $idObj = get_category_by_slug( $slug ); $exclude_categories[] = $idObj->term_id; } } return $exclude_categories; } } if ( ! function_exists( 'caster_get_post_meta' ) ) { function caster_get_post_meta( $meta_key, $multiple = false, $post_id = null ) { if( class_exists( 'RWMB_Core' ) ) { $meta_value = rwmb_meta( 'caster_meta_' . $meta_key, array( 'multiple' => $multiple ), $post_id ); } else { return false; } return $meta_value; } } if ( ! function_exists( 'caster_theme_default_options' ) ) { function caster_theme_default_options() { return array( //General 'minify-js-switch' => '1', 'multilingual-switch' => '1', 'page-bg-circle-switch' => '0', //Branding 'menu-logo' => array( 'url' => get_theme_file_uri( 'assets/images/logo.png' ) ), 'menu-retina-logo' => array( 'url' => get_theme_file_uri( 'assets/images/logo2x.png' ) ), //Menu 'menu-style' => 'standard', 'menu-layout-switch' => 'boxed', 'menu-display-switch' => 'solid', 'menu-sticky-switch' => '0', //Blog 'blog-title' => esc_html__( 'Our Blog', 'caster' ), 'blog-post-slider-navigation' => '0', 'blog-post-slider-pagination' => '1', //Footer 'footer-layout-switch' => 'boxed', 'footer-copyright' => esc_html__( '© 2020 CaliberThemes', 'caster' ), ); } } if ( ! function_exists( 'caster_is_blog' ) ) { function caster_is_blog() { $taxonomy = ''; if( get_query_var( 'taxonomy' ) == 'portfolio_category' ) { return false; } if( get_query_var( 'taxonomy' ) == 'portfolio_tag' ) { return false; } if ( is_home() || is_singular( 'post' ) || is_search() || is_category() || is_archive() || is_author() || is_date() || is_attachment() ) { return true; } else { return false; } } } /** * Adds custom classes to the array of body classes. * * @param array $classes Classes for the body element. * @return array */ if ( ! function_exists( 'caster_body_classes' ) ) { function caster_body_classes( $classes ) { $color_scheme = caster_get_option( 'color-scheme' ); $menu_style_class = caster_get_option( 'menu-style' ); $classes[] = $color_scheme; if ( caster_is_blog() ) { if ( is_active_sidebar( 'sidebar-blog' ) ) { $classes[] = 'has-sidebar'; } } if ( is_singular( 'portfolio' ) ) { $page_layout = caster_get_post_meta( 'portfolio_page_layout' ); $page_details_placement = caster_get_post_meta( 'details_placement' ); $portfolio_project_type = caster_get_post_meta( 'portfolio_project_type' ); if( $portfolio_project_type == 'lightbox' ) { $page_details_placement = 'details-bottom'; } $classes[] = $page_layout; $classes[] = 'portfolio-' . $page_details_placement; } if( is_singular( 'portfolio' ) || is_singular( 'page' ) || is_singular( 'post' ) ) { $page_menu_type = caster_get_post_meta( 'page_menu_type' ); if( $page_menu_type == 'custom' ) { $menu_style_class = caster_get_post_meta( 'page_menu_style' ); } } $classes[] = 'has-' . $menu_style_class; return $classes; } } add_filter( 'body_class', 'caster_body_classes' ); /** * Disable theme update notification */ if ( ! function_exists( 'caster_disable_theme_update_notification' ) ) { function caster_disable_theme_update_notification( $value ) { if ( isset( $value ) && is_object( $value ) ) { unset( $value->response[ 'caster' ] ); } return $value; } } add_filter( 'site_transient_update_themes', 'caster_disable_theme_update_notification' ); /** * Register custom fonts. */ if ( ! function_exists( 'caster_fonts_url' ) ) { function caster_fonts_url() { $fonts_url = ''; $font_families = array(); if ( ! class_exists( 'Caster_Theme_Options' ) ) { $font_families[] = 'Roboto:300,400,500,700'; $font_families[] = 'Poppins:300,400,500,600,700'; } else { $body_font_family = caster_get_option( 'body-font' ); $body_font_style = caster_get_option( 'body-font-style' ); $heading_font_family = caster_get_option( 'heading-font' ); $heading_font_style = caster_get_option( 'heading-font-style' ); $menu_font = caster_get_option( 'menu-font' ); $body_font_style_list = array(); $heading_font_style_list = array(); if( !empty( $body_font_style ) ) { foreach ( $body_font_style as $key => $value ) { if( $value == 1 ) { $body_font_style_list[] = $key; } } if( empty( $body_font_style_list ) ) { $body_font_style_list = array( '300', '400', '500', '700' ); } } else { $body_font_style_list = array( '300', '400', '500', '700' ); } if( !empty( $heading_font_style ) ) { foreach ( $heading_font_style as $key => $value ) { if( $value == 1 ) { $heading_font_style_list[] = $key; } } if( empty( $heading_font_style_list ) ) { $heading_font_style_list = array( '300', '400', '500', '600', '700' ); } } else { $heading_font_style_list = array( '300', '400', '500', '600', '700' ); } if( isset( $body_font_family[ 'font-family' ] ) ) { $font_families[] = $body_font_family[ 'font-family' ] . ':' . implode( ',', $body_font_style_list ); } else { $font_families[] = 'Roboto:300,400,500,700'; } if( isset( $heading_font_family[ 'font-family' ] ) ) { $font_families[] = $heading_font_family[ 'font-family' ] . ':' . implode( ',', $heading_font_style_list ); } else { $font_families[] = 'Poppins:300,400,500,600,700'; } if( !empty( $menu_font ) ) { $font_families[] = $menu_font[ 'font-family' ] . ':' . $menu_font[ 'font-weight' ]; } } $query_args = array( 'family' => urlencode( implode( '|', $font_families ) ), 'subset' => urlencode( 'latin,latin-ext' ), ); $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); return esc_url_raw( $fonts_url ); } } if ( ! function_exists( 'caster_get_youtube_id_from_url' ) ) { function caster_get_youtube_id_from_url( $url ) { $url_string = parse_url( $url, PHP_URL_QUERY ); parse_str( $url_string, $args ); return isset( $args['v'] ) ? $args['v'] : false; } } if ( ! function_exists( 'caster_header_classes' ) ) { function caster_header_classes() { $classes = array( 'site-header' ); $menu_style_class = caster_get_option( 'menu-style' ); $menu_layout_class = caster_get_option( 'menu-layout-switch' ); $menu_display_class = caster_get_option( 'menu-display-switch' ); $menu_sticky_switch = caster_get_option( 'menu-sticky-switch' ); $page_menu_type = 'inherit'; if( is_singular( 'portfolio' ) || is_singular( 'page' ) || is_singular( 'post' ) ) { $page_menu_type = caster_get_post_meta( 'page_menu_type' ); if( $page_menu_type == 'custom' ) { $menu_style_class = caster_get_post_meta( 'page_menu_style' ); $menu_layout_class = caster_get_post_meta( 'page_menu_layout' ); $menu_display_class = caster_get_post_meta( 'page_menu_display' ); $menu_sticky_switch = caster_get_post_meta( 'page_menu_sticky' ); } } $classes[] = $menu_style_class; if( $menu_style_class == 'standard' || $menu_style_class == 'fullscreen-hamburger-menu' ) { $classes[] = $menu_layout_class; $classes[] = $menu_display_class; if( $menu_sticky_switch == 1 ) { $classes[] = 'sticky'; } } else { $classes[] = 'full-width'; } return implode( ' ', $classes ); } } if ( ! function_exists( 'caster_footer_classes' ) ) { function caster_footer_classes() { $classes = array( 'site-footer' ); $classes[] = 'standard'; return implode( ' ', $classes ); } } if ( ! function_exists( 'caster_menu_style' ) ) { function caster_menu_style() { $menu_style = caster_get_option( 'menu-style' ); if( is_singular( 'portfolio' ) || is_singular( 'page' ) || is_singular( 'post' ) ) { $page_menu_type = caster_get_post_meta( 'page_menu_type' ); if( $page_menu_type == 'custom' ) { $menu_style = caster_get_post_meta( 'page_menu_style' ); } } return $menu_style; } } if ( ! function_exists( 'caster_page_vertical_text' ) ) { function caster_page_vertical_text() { $page_vertical_text = caster_get_option( 'page-vertical-text' ); if( is_singular( 'portfolio' ) || is_singular( 'page' ) || is_singular( 'post' ) ) { $page_bgcolor_type = caster_get_post_meta( 'page_bgcolor_type' ); if( $page_bgcolor_type == 'custom' ) { $page_vertical_text = caster_get_post_meta( 'page_vertical_text' ); } } return $page_vertical_text; } } if ( ! function_exists( 'caster_page_bg_circle' ) ) { function caster_page_bg_circle() { $page_bg_circle_switch = caster_get_option( 'page-bg-circle-switch' ); if( is_singular( 'portfolio' ) || is_singular( 'page' ) || is_singular( 'post' ) ) { $page_bgcolor_type = caster_get_post_meta( 'page_bgcolor_type' ); if( $page_bgcolor_type == 'custom' ) { $page_bg_circle_switch = caster_get_post_meta( 'page_circle' ); } } return $page_bg_circle_switch; } } if ( ! function_exists( 'caster_page_footer_display' ) ) { function caster_page_footer_display() { $page_footer_display = true; if( is_singular( 'portfolio' ) || is_singular( 'page' ) || is_singular( 'post' ) ) { $page_footer_type = caster_get_post_meta( 'page_footer_type' ); if( $page_footer_type == 'custom' ) { $page_footer_display = caster_get_post_meta( 'footer_display' ); } } return $page_footer_display; } } /** * Get an attachment ID given a URL. */ if ( ! function_exists( 'caster_get_attachment_id' ) ) { function caster_get_attachment_id( $url ) { $attachment_id = 0; $dir = wp_upload_dir(); if ( false !== strpos( $url, $dir['baseurl'] . '/' ) ) { // Is URL in uploads directory? $file = basename( $url ); $query_args = array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'fields' => 'ids', 'meta_query' => array( array( 'value' => $file, 'compare' => 'LIKE', 'key' => '_wp_attachment_metadata', ), ) ); $query = new WP_Query( $query_args ); if ( $query->have_posts() ) { foreach ( $query->posts as $post_id ) { $meta = wp_get_attachment_metadata( $post_id ); $original_file = basename( $meta['file'] ); $cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' ); if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) { $attachment_id = $post_id; break; } } } } return $attachment_id; } } if ( ! function_exists( 'caster_check_portfolio_categories' ) ) { function caster_check_portfolio_categories( $categories_flag, $category, $exclude_categories ) { $show_category = false; if( !empty( $exclude_categories ) ) { if( $categories_flag == 'exclude' ) { if( !in_array( $category, $exclude_categories ) ) { $show_category = true; } } else { if( in_array( $category, $exclude_categories ) ) { $show_category = true; } } } else { $show_category = true; } return $show_category; } } if ( ! function_exists( 'caster_get_social_url' ) ) { function caster_get_social_url( $url_key ) { $social_url = caster_get_option( $url_key ); if ( !empty( $social_url ) ) { if( $url_key == 'url-envelope-o' && is_email( sanitize_email( $social_url ) )) { return 'mailto:' . sanitize_email( $social_url ); } elseif( $url_key == 'url-skype' ) { return 'skype:' . $social_url . '?userinfo'; } else { return esc_url( $social_url ); } } else { return "#"; } } } if ( ! function_exists( 'caster_page_404_heading' ) ) { function caster_page_404_heading() { $multilingual_switch = caster_get_option( 'multilingual-switch' ); $page_title = caster_get_option( 'page-title' ); $page_subtitle = caster_get_option( 'page-subtitle' ); $page_heading_markup = ''; if( $multilingual_switch == 1 ) { $page_heading_markup .= '<h1 class="page-title">' . esc_html__( '404', 'caster' ) . '</h1>'; $page_heading_markup .= '<div>' . esc_html__( 'Sorry, the page requested couldn\'t be found.', 'caster' ) . '</div>'; } else { $page_heading_markup .= '<h1 class="page-title">' . $page_title . '</h1>'; $page_heading_markup .= '<div>' . $page_subtitle . '</div>'; } echo apply_filters( 'caster_page_404_heading', $page_heading_markup ); } } if ( ! function_exists( 'caster_page_404_content' ) ) { function caster_page_404_content() { $multilingual_switch = caster_get_option( 'multilingual-switch' ); $page_desc = caster_get_option( 'page-desc' ); $page_btn_text = caster_get_option( 'page-btn-text' ); $page_content_markup = ''; if( $multilingual_switch == 1 ) { $page_content_markup .= '<p>' . esc_html__( 'Sorry, the page The page you are looking for might have been removed had its name changed or its temporarily unavailable.', 'caster' ) . '</p>'; $page_content_markup .= '<a href="' . esc_url( home_url('/') ) . '" >' . esc_html__( 'Back to home', 'caster' ) . '</a>'; } else { $page_content_markup .= '<p>' . $page_desc . '</p>'; $page_content_markup .= '<a href="' . esc_url( home_url('/') ) . '" >' . $page_btn_text . '</a>'; } echo apply_filters( 'caster_page_404_content', $page_content_markup ); } } if ( ! function_exists( 'caster_get_slider_attachment_image' ) ) { function caster_get_slider_attachment_image( $image_id, $size = 'post-thumbnail' ) { $attachment_html = ''; $attachment_html = wp_get_attachment_image( $image_id, $size ); $attachment_html = preg_replace( '/src/', 'data-src', $attachment_html, 1 ); $attachment_html = preg_replace( '/srcset/', 'data-srcset', $attachment_html, 1 ); $attachment_html = preg_replace( '/class="/', 'class="swiper-lazy ', $attachment_html, 1 ); $attachment_html .= '<div class="swiper-lazy-preloader"></div>'; return $attachment_html; } } if ( ! function_exists( 'caster_override_wp_video_shortcode' ) ) { function caster_override_wp_video_shortcode( $output ) { preg_match( '@src="([^"]+)"@' , $output, $match ); $src = array_pop( $match ); $src = preg_replace( '/\?.*/', '', $src ); $output = str_replace( "<video", "<video muted playsinline ", $output ); $output = str_replace( "controls=", "data-controls=", $output ); $str = preg_replace( '/\<[\/]{0,1}div[^\>]*\>/i', '', $output ); $wrap = "<div class='flex-video'>" . $str . "</div>"; $output = $wrap; return $output; } } add_filter( 'wp_video_shortcode', 'caster_override_wp_video_shortcode' ); if ( ! function_exists( 'caster_custom_footer_socials' ) ) { function caster_custom_footer_socials() { $social_link_target = ''; $footer_social_target = caster_get_option( 'footer-social-target' ); if( $footer_social_target == '_blank' ) { $social_link_target = 'target="_blank"'; } $footer_social_icon_1 = caster_get_option( 'custom-footer-social-icon-1' ); $footer_social_text_1 = caster_get_option( 'custom-footer-social-text-1' ); $footer_social_url_1 = caster_get_option( 'custom-footer-social-url-1' ); $footer_social_icon_2 = caster_get_option( 'custom-footer-social-icon-2' ); $footer_social_text_2 = caster_get_option( 'custom-footer-social-text-2' ); $footer_social_url_2 = caster_get_option( 'custom-footer-social-url-2' ); $footer_custom_social_markup = ''; if ( $footer_social_icon_1 ) { $footer_custom_social_markup .= '<li>'; $footer_custom_social_markup .= '<a href="' . $footer_social_url_1 . '" ' . esc_attr( $social_link_target ) . ' >'; $footer_custom_social_markup .= '<span>'; $footer_custom_social_markup .= esc_html( $footer_social_text_1 ); $footer_custom_social_markup .= '</span>'; $footer_custom_social_markup .= '<i class="' . esc_attr( $footer_social_icon_1 ) . '"></i>'; $footer_custom_social_markup .= '</a>'; $footer_custom_social_markup .= '</li>'; } if ( $footer_social_icon_2 ) { $footer_custom_social_markup .= '<li>'; $footer_custom_social_markup .= '<a href="' . $footer_social_url_2 . '" ' . esc_attr( $social_link_target ) . ' >'; $footer_custom_social_markup .= '<span>'; $footer_custom_social_markup .= esc_html( $footer_social_text_2 ); $footer_custom_social_markup .= '</span>'; $footer_custom_social_markup .= '<i class="' . esc_attr( $footer_social_icon_2 ) . '"></i>'; $footer_custom_social_markup .= '</a>'; $footer_custom_social_markup .= '</li>'; } echo apply_filters( 'caster_custom_footer_socials', $footer_custom_social_markup ); } } if ( ! function_exists( 'caster_custom_menu_socials' ) ) { function caster_custom_menu_socials() { $social_link_target = ''; $menu_social_target = caster_get_option( 'menu-social-target' ); if( $menu_social_target == '_blank' ) { $social_link_target = 'target="_blank"'; } $menu_social_icon_1 = caster_get_option( 'custom-menu-social-icon-1' ); $menu_social_url_1 = caster_get_option( 'custom-menu-social-url-1' ); $menu_social_icon_2 = caster_get_option( 'custom-menu-social-icon-2' ); $menu_social_url_2 = caster_get_option( 'custom-menu-social-url-2' ); $menu_custom_social_markup = ''; if ( $menu_social_icon_1 ) { $menu_custom_social_markup .= '<li>'; $menu_custom_social_markup .= '<a href="' . $menu_social_url_1 . '" ' . esc_attr( $social_link_target ) . ' >'; $menu_custom_social_markup .= '<i class="' . esc_attr( $menu_social_icon_1 ) . '"></i>'; $menu_custom_social_markup .= '</a>'; $menu_custom_social_markup .= '</li>'; } if ( $menu_social_icon_2 ) { $menu_custom_social_markup .= '<li>'; $menu_custom_social_markup .= '<a href="' . $menu_social_url_2 . '" ' . esc_attr( $social_link_target ) . ' >'; $menu_custom_social_markup .= '<i class="' . esc_attr( $menu_social_icon_2 ) . '"></i>'; $menu_custom_social_markup .= '</a>'; $menu_custom_social_markup .= '</li>'; } echo apply_filters( 'caster_custom_menu_socials', $menu_custom_social_markup ); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�