'font-awesome-4',
'file' => '/v4-shims',
'version' => '4.7.0',
),
array(
'handle' => 'font-awesome-all',
'file' => '/all',
'version' => '6.7.2',
),
array(
'handle' => 'font-awesome-solid',
'file' => '/solid',
'version' => '6.7.2',
),
array(
'handle' => 'font-awesome-regular',
'file' => '/regular',
'version' => '6.7.2',
),
array(
'handle' => 'font-awesome-brands',
'file' => '/brands',
'version' => '6.7.2',
),
);
foreach ( $font_awesome_styles as $style ) {
wp_register_style(
$style['handle'],
get_template_directory_uri() . '/font-awesome/css' . $style['file'] . $suffix . '.css',
false,
$style['version']
);
wp_enqueue_style( $style['handle'] );
}
// wp_enqueue_style( 'ample-fontawesome', get_template_directory_uri() . '/font-awesome/css/font-awesome.min.css', array(), '4.7.0' );
/**
* Loads our main stylesheet.
*/
wp_enqueue_style( 'ample-style', get_stylesheet_uri() );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
// Register bxslider Script
wp_register_script( 'ample-bxslider', get_template_directory_uri() . '/js/jquery.bxslider/jquery.bxslider.min.js', array( 'jquery' ), false, true );
$slider = 0;
for ( $i = 1; $i <= 4; $i ++ ) {
$slider_image = ample_option( 'ample_slider_image' . $i, '' );
if ( ! empty( $slider_image ) ) {
$slider ++;
}
}
if ( ( $slider > 1 ) && is_front_page() && ample_option( 'ample_activate_slider', '0' ) == '1' ) {
wp_enqueue_script( 'ample-bxslider' );
}
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 );
// Skip link focus fix JS enqueue.
wp_enqueue_script( 'ample-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), false, true );
}
function ample_block_editor_styles() {
wp_enqueue_style( 'ample-editor-googlefonts', '//fonts.googleapis.com/css?family=Roboto:400,300&display=swap' );
wp_enqueue_style( 'ample-block-editor-styles', get_template_directory_uri() . '/style-editor-block.css' );
}
add_action( 'enqueue_block_editor_assets', 'ample_block_editor_styles', 1, 1 );
/**************************************************************************************/
// 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 .= '
';
}
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 = '' . esc_html__( 'WordPress', 'ample' ) . ' ';
$tg_link = '' . esc_html__( 'Ample', 'ample' ) . ' ';
$default_footer_value = sprintf( esc_html__( 'Copyright © %1$s %2$s. All rights reserved.', 'ample' ), date( 'Y' ), $site_link ) . ' ' . sprintf( esc_html__( 'Theme: %1$s by %2$s.', 'ample' ), $tg_link, 'ThemeGrill' ) . ' ' . sprintf( esc_html__( 'Powered by %s.', 'ample' ), $wp_link );
$ample_footer_copyright = '' . $default_footer_value . '
';
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( str_replace( '#', '', $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[] = 'boxed';
}
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 .= '
%4$s ';
}
$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-">
';
}
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();
}
}
}
if ( ! function_exists( 'ample_pingback_header' ) ) :
/**
* Add a pingback url auto-discovery header for single posts, pages, or attachments.
*/
function ample_pingback_header() {
if ( is_singular() && pings_open() ) {
printf( ' ', esc_url( get_bloginfo( 'pingback_url' ) ) );
}
}
endif;
add_action( 'wp_head', 'ample_pingback_header' );
/**
* 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;
}
}
/**
* Compare user's current version of plugin.
*/
if ( ! function_exists( 'ample_plugin_version_compare' ) ) {
function ample_plugin_version_compare( $plugin_slug, $version_to_compare ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$installed_plugins = get_plugins();
// Plugin not installed.
if ( ! isset( $installed_plugins[ $plugin_slug ] ) ) {
return false;
}
$tdi_user_version = $installed_plugins[ $plugin_slug ]['Version'];
return version_compare( $tdi_user_version, $version_to_compare, '<' );
}
}