1 ) && is_front_page() && ample_option( 'ample_activate_slider', '0' ) == '1' ) { wp_enqueue_script( 'ample-slider', get_template_directory_uri() . '/js/slider-setting.js', array( 'ample-bxslider' ), false, true ); } wp_enqueue_script( 'ample-custom', get_template_directory_uri() . '/js/theme-custom.js', array( 'jquery' ), false, true ); wp_enqueue_script( 'ample-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'jquery' ), false, true ); } /**************************************************************************************/ // Add admin scripts add_action( 'admin_enqueue_scripts', 'ample_image_uploader' ); function ample_image_uploader() { //For image uploader wp_enqueue_media(); wp_enqueue_script( 'ample-script', get_template_directory_uri() . '/js/image-uploader.js', false, '1.0', true ); wp_enqueue_style( 'wp-color-picker' ); //For Color Picker wp_enqueue_script( 'ample-color-picker', get_template_directory_uri() . '/js/color-picker.js', array( 'wp-color-picker' ), false ); } /**************************************************************************************/ add_action( 'pre_get_posts', 'ample_exclude_category' ); /** * Function to exclude category */ function ample_exclude_category( $query ) { $ample_hide_categories = array(); $ample_cat_num = ample_option( 'ample_hide_category', '' ); if ( ! empty( $ample_cat_num ) ) { if ( is_array( $ample_cat_num ) ) { foreach ( $ample_cat_num as $key => $value ) { if ( $value ) { array_push( $ample_hide_categories, $key ); } } } else { $ample_hide_categories = explode( ',', $ample_cat_num ); } } if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'category__not_in', $ample_hide_categories ); } } /**************************************************************************************/ // Adding the support for the entry-title tag for Google Rich Snippets function ample_add_mod_hatom_data( $content ) { $title = get_the_title(); if ( is_single() ) { $content .= '
' . $title . '
'; } return $content; } add_filter( 'the_content', 'ample_add_mod_hatom_data' ); /**************************************************************************************/ add_action( 'ample_footer_copyright', 'ample_footer_copyright', 10 ); /** * Function to show the footer info, copyright information */ if ( ! function_exists( 'ample_footer_copyright' ) ) : function ample_footer_copyright() { $site_link = '' . get_bloginfo( 'name', 'display' ) . ''; $wp_link = '' . __( 'WordPress', 'ample' ) . ''; $tg_link = ''; $default_footer_value = sprintf( __( 'Copyright © %1$s %2$s.', 'ample' ), date( 'Y' ), $site_link ) . ' ' . sprintf( __( 'Powered by %s.', 'ample' ), $wp_link ) . ' ' . sprintf( __( 'Theme: %1$s by %2$s.', 'ample' ), 'Ample', $tg_link ); $ample_footer_copyright = ''; echo $ample_footer_copyright; } endif; /**************************************************************************************/ /** * Change hex code to RGB * Source: https://css-tricks.com/snippets/php/convert-hex-to-rgb/#comment-1052011 */ function ample_hex2rgb( $hexstr ) { $int = hexdec( $hexstr ); $rgb = array( "red" => 0xFF & ( $int >> 0x10 ), "green" => 0xFF & ( $int >> 0x8 ), "blue" => 0xFF & $int ); $r = $rgb['red']; $g = $rgb['green']; $b = $rgb['blue']; return "rgba($r,$g,$b, 0.85)"; } /** * Generate darker color * Source: http://stackoverflow.com/questions/3512311/how-to-generate-lighter-darker-color-with-php */ function ample_darkcolor( $hex, $steps ) { // Steps should be between -255 and 255. Negative = darker, positive = lighter $steps = max( - 255, min( 255, $steps ) ); // Normalize into a six character long hex string $hex = str_replace( '#', '', $hex ); if ( strlen( $hex ) == 3 ) { $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 ); } // Split into three parts: R, G and B $color_parts = str_split( $hex, 2 ); $return = '#'; foreach ( $color_parts as $color ) { $color = hexdec( $color ); // Convert to decimal $color = max( 0, min( 255, $color + $steps ) ); // Adjust color $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code } return $return; } /**************************************************************************************/ add_action( 'wp_head', 'ample_custom_css', 100 ); /** * Hooks the Custom Internal CSS to head section */ function ample_custom_css() { $primary_color = ample_option( 'ample_primary_color', '#80abc8' ); $primary_opacity = ample_hex2rgb( $primary_color ); $primary_dark = ample_darkcolor( $primary_color, - 50 ); $ample_internal_css = ''; if ( $primary_color != '#80abc8' ) { $ample_internal_css = '.main-navigation .menu>ul>li.current_page_ancestor,.main-navigation .menu>ul>li.current_page_item,.main-navigation .menu>ul>li:hover,.main-navigation ul.menu>li.current-menu-ancestor,.main-navigation ul.menu>li.current-menu-item,.main-navigation ul.menu>li:hover,blockquote,.services-header h2,.slider-button:hover,.portfolio-button:hover,.call-to-action-button:hover,.read-btn a:hover, .single-page p a:hover, .single-page p a:hover,.read-btn a{border-color :' . $primary_color . '}a,.big-slider .entry-title a:hover,.main-navigation :hover, .main-navigation li.menu-item-has-children:hover>a:after,.main-navigation li.page_item_has_children:hover>a:after,.main-navigation ul li ul li a:hover,.main-navigation ul li ul li:hover>a,.main-navigation ul li.current-menu-ancestor a,.main-navigation ul li.current-menu-ancestor a:after,.main-navigation ul li.current-menu-item a,.main-navigation ul li.current-menu-item a:after,.main-navigation ul li.current-menu-item ul li a:hover,.main-navigation ul li.current_page_ancestor a,.main-navigation ul li.current_page_ancestor a:after,.main-navigation ul li.current_page_item a,.main-navigation ul li.current_page_item a:after,.main-navigation ul li:hover>a,.main-navigation ul.menu li.current-menu-ancestor ul li.current-menu-item> a,#secondary .widget li a,#tertiary .widget li a,.fa.search-top,.widget_service_block h5 a:hover,.single-post-content a,.single-post-content .entry-title a:hover,.single-header h2,.single-page p a,.single-service span i,#colophon .copyright-info a:hover,#colophon .footer-nav ul li a:hover,#colophon a:hover,.comment .comment-reply-link:before,.comments-area article header .comment-edit-link:before,.copyright-info ul li a:hover,.footer-widgets-area a:hover,.menu-toggle:before,a#scroll-up i{color:' . $primary_color . '}#site-title a:hover,.hentry .entry-title a:hover,#comments i,.comments-area .comment-author-link a:hover,.comments-area a.comment-edit-link:hover,.comments-area a.comment-permalink:hover,.comments-area article header cite a:hover,.entry-meta .fa,.entry-meta a:hover,.nav-next a,.nav-previous a,.next a,.previous a{color:' . $primary_color . '}.ample-button,button,input[type=button],input[type=reset],input[type=submit],.comments-area .comment-author-link span,.slide-next,.slide-prev,.header-post-title-container,.read-btn a:hover,.single-service:hover .icons,.moving-box a,.slider-button:hover,.portfolio-button:hover,.call-to-action-button:hover,.ample-button, input[type="reset"], input[type="button"], input[type="submit"], button{background-color:' . $primary_color . '}.ample-button:hover, input[type="reset"]:hover, input[type="button"]:hover, input[type="submit"]:hover, button:hover{background-color:' . $primary_dark . '} .read-btn a:hover,.single-page p a:hover,.single-page p a:hover,.previous a:hover, .next a:hover,.tags a:hover,.fa.search-top:hover{color:' . $primary_dark . '}.single-service:hover .icons, .moving-box a{background:' . $primary_opacity . '}.read-btn a:hover{color:#ffffff}.woocommerce ul.products li.product .onsale,.woocommerce span.onsale,.woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt{ background-color: ' . $primary_color . ';}.woocommerce ul.products li.product .price .amount, .entry-summary .price .amount, .woocommerce .woocommerce-message::before{color: ' . $primary_color . ';} .woocommerce .woocommerce-message{border-top-color: ' . $primary_color . ';}.better-responsive-menu .sub-toggle{background:' . $primary_dark . '}'; } if ( ample_option( 'ample_header_title_background_image' ) ) { $ample_internal_css .= ' .header-post-title-container { background-image: url("' . ample_option( 'ample_header_title_background_image' ) . '");background-size:cover; }'; } if ( ample_option( 'ample_title_bar_background_color', '#80abc8' ) != '#80abc8' ) { $ample_internal_css .= ' .header-post-title-container { background-color: ' . ample_option( 'ample_title_bar_background_color', '#80abc8' ) . '; }'; } if ( ample_option( 'ample_header_title_color', '#ffffff' ) != '#ffffff' ) { $ample_internal_css .= ' .header-post-title-class, .breadcrumb, .breadcrumb a { color: ' . ample_option( 'ample_header_title_color', '#ffffff' ) . '; }'; } if ( ! empty( $ample_internal_css ) ) { ?> 'medium', ), $atts ); $out['size'] = $atts['size']; return $out; } add_filter( 'shortcode_atts_gallery', 'ample_gallery_atts', 10, 3 ); /**************************************************************************************/ add_filter( 'body_class', 'ample_body_class' ); /** * Filter the body_class * * Throwing different body class for the different layouts in the body tag */ function ample_body_class( $classes ) { global $post; if ( $post ) { $layout_meta = get_post_meta( $post->ID, 'ample_page_layout', true ); } if ( is_home() ) { $queried_id = get_option( 'page_for_posts' ); $layout_meta = get_post_meta( $queried_id, 'ample_page_layout', true ); } if ( empty( $layout_meta ) || is_archive() || is_search() ) { $layout_meta = 'default_layout'; } $ample_default_layout = ample_option( 'ample_default_layout', 'right_sidebar' ); $ample_default_page_layout = ample_option( 'ample_pages_default_layout', 'right_sidebar' ); $ample_default_post_layout = ample_option( 'ample_single_posts_default_layout', 'right_sidebar' ); if ( $layout_meta == 'default_layout' ) { if ( is_page() ) { if ( $ample_default_page_layout == 'right_sidebar' ) { $classes[] = ''; } elseif ( $ample_default_page_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif ( $ample_default_page_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif ( $ample_default_page_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } elseif ( $ample_default_page_layout == 'both_sidebar' ) { $classes[] = 'both-sidebar'; } } elseif ( is_single() ) { if ( $ample_default_post_layout == 'right_sidebar' ) { $classes[] = ''; } elseif ( $ample_default_post_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif ( $ample_default_post_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif ( $ample_default_post_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } elseif ( $ample_default_post_layout == 'both_sidebar' ) { $classes[] = 'both-sidebar'; } } elseif ( $ample_default_layout == 'right_sidebar' ) { $classes[] = ''; } elseif ( $ample_default_layout == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif ( $ample_default_layout == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif ( $ample_default_layout == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } elseif ( $ample_default_layout == 'both_sidebar' ) { $classes[] = 'both-sidebar'; } } elseif ( $layout_meta == 'right_sidebar' ) { $classes[] = ''; } elseif ( $layout_meta == 'left_sidebar' ) { $classes[] = 'left-sidebar'; } elseif ( $layout_meta == 'no_sidebar_full_width' ) { $classes[] = 'no-sidebar-full-width'; } elseif ( $layout_meta == 'no_sidebar_content_centered' ) { $classes[] = 'no-sidebar'; } elseif ( $layout_meta == 'both_sidebar' ) { $classes[] = 'both-sidebar'; } if ( ample_option( 'ample_new_menu_enable', '1' ) == '1' ) { $classes[] = 'better-responsive-menu'; } if ( ample_option( 'ample_site_layout', 'wide' ) == 'wide' ) { $classes[] = 'wide'; } else { $classes[] = ''; } if ( is_page_template( 'page-templates/template-business.php' ) ) { $classes[] = 'business-template'; } return $classes; } /****************************************************************************************/ if ( ! function_exists( 'ample_both_sidebar_select' ) ) : /** * Fucntion to select the sidebar */ function ample_both_sidebar_select() { global $post; if ( $post ) { $layout_meta = get_post_meta( $post->ID, 'ample_page_layout', true ); } if ( is_home() ) { $queried_id = get_option( 'page_for_posts' ); $layout_meta = get_post_meta( $queried_id, 'ample_page_layout', true ); } if ( empty( $layout_meta ) || is_archive() || is_search() ) { $layout_meta = 'default_layout'; } $ample_default_layout = ample_option( 'ample_default_layout', 'right_sidebar' ); $ample_default_page_layout = ample_option( 'ample_pages_default_layout', 'right_sidebar' ); $ample_default_post_layout = ample_option( 'ample_single_posts_default_layout', 'right_sidebar' ); if ( $layout_meta == 'default_layout' ) { if ( is_page() ) { if ( $ample_default_page_layout == 'both_sidebar' ) { get_sidebar( 'left' ); } } if ( is_single() ) { if ( $ample_default_post_layout == 'both_sidebar' ) { get_sidebar( 'left' ); } } elseif ( $ample_default_layout == 'both_sidebar' ) { get_sidebar( 'left' ); } } elseif ( $layout_meta == 'both_sidebar' ) { get_sidebar( 'left' ); } } endif; /****************************************************************************************/ if ( ! function_exists( 'ample_sidebar_select' ) ) : /** * Fucntion to select the sidebar */ function ample_sidebar_select() { global $post; if ( $post ) { $layout_meta = get_post_meta( $post->ID, 'ample_page_layout', true ); } if ( is_home() ) { $queried_id = get_option( 'page_for_posts' ); $layout_meta = get_post_meta( $queried_id, 'ample_page_layout', true ); } if ( empty( $layout_meta ) || is_archive() || is_search() ) { $layout_meta = 'default_layout'; } $ample_default_layout = ample_option( 'ample_default_layout', 'right_sidebar' ); $ample_default_page_layout = ample_option( 'ample_pages_default_layout', 'right_sidebar' ); $ample_default_post_layout = ample_option( 'ample_single_posts_default_layout', 'right_sidebar' ); if ( $layout_meta == 'default_layout' ) { if ( is_page() ) { if ( $ample_default_page_layout == 'right_sidebar' || $ample_default_page_layout == 'both_sidebar' ) { get_sidebar(); } elseif ( $ample_default_page_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } if ( is_single() ) { if ( $ample_default_post_layout == 'right_sidebar' || $ample_default_post_layout == 'both_sidebar' ) { get_sidebar(); } elseif ( $ample_default_post_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } elseif ( $ample_default_layout == 'right_sidebar' || $ample_default_layout == 'both_sidebar' ) { get_sidebar(); } elseif ( $ample_default_layout == 'left_sidebar' ) { get_sidebar( 'left' ); } } elseif ( $layout_meta == 'right_sidebar' || $layout_meta == 'both_sidebar' ) { get_sidebar(); } elseif ( $layout_meta == 'left_sidebar' ) { get_sidebar( 'left' ); } } endif; /**************************************************************************************/ if ( ! function_exists( 'ample_meta_select' ) ) : /** * Fucntion to select Meta */ function ample_meta_select() { if ( 'post' == get_post_type() ) : ?>
%2$s'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string .= ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); printf( __( ' %3$s', 'ample' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), $time_string ); ?>
comment_type ) : case 'pingback' : case 'trackback' : // Display trackbacks differently than normal comments. ?>
  • id="comment-">

    ', '' ); ?>

  • id="li-comment-">
    %1$s%2$s', get_comment_author_link(), // If current post author is also comment author, make it known visually. ( $comment->user_id === $post->post_author ) ? '' . __( 'Post author', 'ample' ) . '' : '' ); printf( '
    %1$s
    ', sprintf( __( '%1$s at %2$s', 'ample' ), get_comment_date(), get_comment_time() ) ); printf( 'Permalink', esc_url( get_comment_link( $comment->comment_ID ) ) ); edit_comment_link(); ?>
    comment_approved ) : ?>

    __( 'Reply', 'ample' ), 'after' => '', 'depth' => $depth, 'max_depth' => $args['max_depth'], ) ) ); ?>
    '; } function ample_inner_wrapper_start() { echo '
    '; } function ample_inner_wrapper_end() { echo '
    '; ample_both_sidebar_select(); echo '
    '; } function ample_wrapper_end() { ample_sidebar_select(); echo '
    '; } // Displays the site logo if ( ! function_exists( 'ample_the_custom_logo' ) ) { /** * Displays the optional custom logo. */ function ample_the_custom_logo() { if ( function_exists( 'the_custom_logo' ) ) { the_custom_logo(); } } } /** * Migrate any existing theme CSS codes added in Customize Options to the core option added in WordPress 4.7 */ function ample_custom_css_migrate() { if ( function_exists( 'wp_update_custom_css_post' ) ) { $custom_css = ample_option( 'ample_custom_css' ); if ( $custom_css ) { $core_css = wp_get_custom_css(); // Preserve any CSS already added to the core option. $return = wp_update_custom_css_post( $core_css . $custom_css ); if ( ! is_wp_error( $return ) ) { $theme_options = get_option( 'ample' ); // Remove the old theme_mod, so that the CSS is stored in only one place moving forward. foreach ( $theme_options as $option_key => $option_value ) { if ( in_array( $option_key, array( 'ample_custom_css' ) ) ) { unset( $theme_options[ $option_key ] ); } } // Finally, update ample theme options. update_option( 'ample', $theme_options ); } } } } add_action( 'after_setup_theme', 'ample_custom_css_migrate' ); /** * Load Jetpack compatibility file. */ if ( defined( 'JETPACK__VERSION' ) ) { require_once get_template_directory() . '/inc/jetpack.php'; } if ( ! function_exists( 'ample_related_posts_function' ) ) { /** * Display the related posts. */ function ample_related_posts_function() { wp_reset_postdata(); global $post; // Define shared post arguments. $args = array( 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'ignore_sticky_posts' => 1, 'orderby' => 'rand', 'post__not_in' => array( $post->ID ), 'posts_per_page' => 3, ); // Related by categories. if ( ample_option( 'ample_related_posts', 'categories' ) == 'categories' ) { $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'ids' ) ); $args['category__in'] = $cats; } // Related by tags. if ( ample_option( 'ample_related_posts', 'categories' ) == 'tags' ) { $tags = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) ); $args['tag__in'] = $tags; // If no tags added, return. if ( ! $tags ) { $break = true; } } $query = ! isset( $break ) ? new WP_Query( $args ) : new WP_Query; return $query; } }