File: /home/dh_5jabqq/bermudashipwreckarchive.com/wp-content/themes/loquet/includes/theme-setup.php
<?php
/*======
*
* Theme After Setup Start
*
======*/
if( !function_exists( 'loquet_setup' ) ) {
function loquet_setup() {
load_theme_textdomain( 'loquet', get_template_directory() . '/languages' );
add_theme_support( 'align-wide' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'custom-background' );
add_theme_support( 'dark-editor-style' );
add_theme_support( 'editor-styles' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'title-tag' );
add_theme_support( 'wp-block-styles' );
/*====== Widgets Block Editor ======*/
$widgets_block_editor = get_theme_mod( 'loquet_widgets_block_editor' );
if( $widgets_block_editor !== "1" ) {
remove_theme_support( 'widgets-block-editor' );
}
if( function_exists( 'add_image_size' ) ) {
add_image_size( 'loquet-full', 2000, 1200, true );
add_image_size( 'loquet-thumbnail-1', 100, 100, true );
add_image_size( 'loquet-thumbnail-2', 350, 350, true );
add_image_size( 'loquet-thumbnail-3', 650, 650, true );
add_image_size( 'loquet-thumbnail-4', 500, 500, true );
add_image_size( 'loquet-event-1', 640, 480, true );
add_image_size( 'loquet-event-2', 345, 245, true );
add_image_size( 'loquet-post-1', 1200, 825, true );
add_image_size( 'loquet-post-2', 640, 555, true );
add_image_size( 'loquet-post-3', 1200, 700, true );
add_image_size( 'loquet-post-4', 1900, 700, true );
add_image_size( 'loquet-post-5', 960, 660, true );
add_image_size( 'loquet-museum-1', 590, 440, true );
add_image_size( 'loquet-museum-2', 768, 1092, true );
add_image_size( 'loquet-museum-3', 527, 580, true );
add_image_size( 'loquet-museum-4', 640, 770, true );
add_image_size( 'loquet-museum-5', 380, 540, true );
add_image_size( 'loquet-magazine-1', 415, 9999, false );
add_image_size( 'loquet-magazine-2', 650, 9999, false );
add_image_size( 'loquet-magazine-3', 250, 9999, false );
}
if( !isset( $content_width ) ) {
$content_width = 600;
}
}
add_action( 'after_setup_theme', 'loquet_setup' );
}
/*======
*
* Scripts & Styles
*
======*/
if( !function_exists( 'loquet_scripts' ) ) {
function loquet_scripts() {
/*====== Scripts ======*/
wp_enqueue_script( 'tweenmax', get_template_directory_uri() . '/includes/assets/js/gsap.min.js', array(), false, true );
wp_enqueue_script( 'swiper', get_template_directory_uri() . '/includes/assets/js/swiper.min.js', array(), false, true );
wp_enqueue_script( 'sifter', get_template_directory_uri() . '/includes/assets/js/sifter.min.js', array(), false, true );
wp_enqueue_script( 'microplugin', get_template_directory_uri() . '/includes/assets/js/microplugin.min.js', array(), false, true );
wp_enqueue_script( 'selectize', get_template_directory_uri() . '/includes/assets/js/selectize.min.js', array(), false, true );
wp_enqueue_script( 'jquery-ui-datepicker', true, array(), false, true );
wp_enqueue_script( 'loquet-timeline', get_template_directory_uri() . '/includes/assets/js/gt-timeline.min.js', array(), false, true );
wp_enqueue_script( 'waypoints', get_template_directory_uri() . '/includes/assets/js/waypoints.min.js', array(), false, true );
wp_enqueue_script( 'counterup', get_template_directory_uri() . '/includes/assets/js/counterup.min.js', array(), false, true );
wp_enqueue_script( 'foundation', get_template_directory_uri() . '/includes/assets/js/foundation.min.js', array(), false, true );
wp_enqueue_script( 'simplebar', get_template_directory_uri() . '/includes/assets/js/simplebar.min.js', array(), false, true );
wp_enqueue_script( 'countdown', get_template_directory_uri() . '/includes/assets/js/countdown.min.js', array(), false, true );
wp_enqueue_script( 'loquet', get_template_directory_uri() . '/includes/assets/js/gt-scripts.min.js', array(), false, true );
/*====== Comment Support ======*/
if( is_singular() ) {
wp_enqueue_script( 'comment-reply' );
}
/*====== InstantClick ======*/
$instant_click = get_theme_mod( 'loquet_instant_click' );
if( $instant_click == "1" ) {
wp_enqueue_script( 'instantclick', get_template_directory_uri() . '/includes/assets/js/instantclick.min.js', array(), false, true );
}
/*====== Google Maps ======*/
$google_maps_api = get_theme_mod( 'loquet_google_maps_api' );
if( !empty( $google_maps_api ) ) {
wp_enqueue_style( 'loquet-google-maps', get_template_directory_uri() . '/includes/assets/css/gt-google-maps.min.css' );
wp_enqueue_script( 'loquet-google-maps-api', esc_url( 'https://maps.googleapis.com/maps/api/js' ) . '?v=3&key=' . esc_attr( $google_maps_api ) . '&libraries=places', array(), false, true );
wp_enqueue_script( 'loquet-google-maps-infobox', get_template_directory_uri() . '/includes/assets/js/google-maps-infobox.min.js', array(), false, true );
wp_enqueue_script( 'markerclusterer', get_template_directory_uri() . '/includes/assets/js/markerclusterer.min.js', array(), false, true );
wp_enqueue_script( 'loquet-google-maps', get_template_directory_uri() . '/includes/assets/js/google-maps.min.js', array(), false, true );
}
/*====== Styles ======*/
wp_enqueue_style( 'foundation', get_template_directory_uri() . '/includes/assets/css/foundation.min.css' );
wp_enqueue_style( 'simplebar', get_template_directory_uri() . '/includes/assets/css/simplebar.min.css' );
wp_enqueue_style( 'swiper', get_template_directory_uri() . '/includes/assets/css/swiper.min.css' );
wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/includes/assets/css/fontawesome.min.css' );
wp_enqueue_style( 'selectize', get_template_directory_uri() . '/includes/assets/css/selectize.min.css' );
wp_enqueue_style( 'loquet-social-media', get_template_directory_uri() . '/includes/assets/css/gt-social-media.min.css' );
wp_enqueue_style( 'loquet-core', get_template_directory_uri() . '/includes/assets/css/gt-core.min.css' );
wp_enqueue_style( 'loquet-theme', get_template_directory_uri() . '/includes/assets/css/gt-style.min.css' );
wp_enqueue_style( 'loquet', get_stylesheet_uri() );
/*====== Skin ======*/
$theme_skin = get_theme_mod( 'loquet_colors_theme_skin', 'light' );
if( $theme_skin == "dark" ) {
wp_enqueue_style( 'loquet-dark', get_template_directory_uri() . '/includes/assets/css/gt-dark.min.css' );
}
/*====== RTL Support ======*/
$loquet_rtl = get_theme_mod( 'loquet_rtl' );
if( $loquet_rtl == "1" ) {
wp_enqueue_style( 'loquet-rtl', get_template_directory_uri() . '/includes/assets/css/gt-rtl.min.css' );
wp_enqueue_style( 'loquet-social-media-rtl', get_template_directory_uri() . '/includes/assets/css/gt-social-media-rtl.min.css' );
}
}
add_action( 'wp_enqueue_scripts', 'loquet_scripts' );
}
/*======
*
* Admin Scripts & Styles
*
======*/
if( !function_exists( 'loquet_admin_scripts' ) ) {
function loquet_admin_scripts() {
wp_enqueue_style( 'loquet-admin', get_template_directory_uri() . '/includes/assets/css/gt-admin.min.css' );
wp_enqueue_style( 'lqouet-gutenberg', get_template_directory_uri() . '/includes/assets/css/gt-gutenberg.min.css', false, '1.0' );
}
add_action( 'admin_enqueue_scripts', 'loquet_admin_scripts' );
}
/*======
*
* Body Classes
*
======*/
if( !function_exists( 'loquet_class_names' ) ) {
function loquet_class_names( $classes ) {
$classes[] = 'loquet-theme';
return $classes;
}
add_filter( 'body_class', 'loquet_class_names' );
}
/*======
*
* Excerpt Support for Pages
*
======*/
if( !function_exists( 'loquet_excerpts_for_pages' ) ) {
function loquet_excerpts_for_pages() {
add_post_type_support( 'page', 'excerpt' );
}
add_action( 'init', 'loquet_excerpts_for_pages' );
}
/*======
*
* Excerpt More
*
======*/
if( !function_exists( 'loquet_excerpt_more' ) ) {
function loquet_excerpt_more( $more ) {
return '...';
}
add_filter( 'excerpt_more', 'loquet_excerpt_more' );
}
/*======
*
* Excerpt Length
*
======*/
if( !function_exists( 'loquet_excerpt_excerpt_length' ) ) {
function loquet_excerpt_excerpt_length( $length ) {
$excerpt_length = get_theme_mod( 'loquet_blog_excerpt_length', '25' );
return $excerpt_length;
}
add_filter( 'excerpt_length', 'loquet_excerpt_excerpt_length', 999 );
}
/*======
*
* Search Form
*
======*/
if( !function_exists( 'loquet_search_form' ) ) {
function loquet_search_form( $button = "true", $placeholder = "", $autocomplete = "on", $input_class = "", $button_class = "", $button_type = "text" ) {
$output = "";
$output .= '<form role="search" method="get" action="' . esc_url( home_url( '/' ) ) . '">';
$output .= '<input type="text" value="' . esc_attr( get_search_query() ) . '" placeholder="' . esc_attr( $placeholder ) . '" autocomplete="' . esc_attr( $autocomplete ) . '" name="s" ' . ( !empty( $input_class ) ? ' class="' . esc_attr( $input_class ) . '"' : '' ) . '/>';
if( $button == "true" ) {
$output .= '<button' . ( !empty( $button_class ) ? ' class="' . esc_attr( $button_class ) . '"' : '' ) . '>';
if( $button_type == "text" ) {
$output .= esc_html__( 'Search', 'loquet' );
} elseif( $button_type == "svg-icon" ) {
$output .= '<svg xmlns="https://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';
}
$output .= '</button>';
}
$output .= '</form>';
return $output;
}
}
/*======
*
* Find Attachment Details from Guid
*
======*/
if( !function_exists( 'loquet_attachment_details' ) ) {
function loquet_attachment_details( $attachment_id = "" ) {
if( !empty( $attachment_id ) ) {
$attachment = get_post( esc_attr( $attachment_id ) );
return array(
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'href' => get_permalink( $attachment->ID ),
'src' => $attachment->guid,
'title' => $attachment->post_title
);
}
}
}
/*======
*
* Find Attachment ID from Guid
*
======*/
if( !function_exists( 'loquet_attachment_id' ) ) {
function loquet_attachment_id( $url ) {
$attachment_id = 0;
$dir = wp_upload_dir();
if( false !== strpos( $url, $dir['baseurl'] . '/' ) ) {
$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;
}
}
/*======
*
* Date Converter
*
======*/
if( !function_exists( 'loquet_date_converter' ) ) {
function loquet_date_converter( $date = "", $format = "" ) {
if( empty( $format ) ) {
$format = get_option( 'date_format' );
}
$date = date_i18n( $format, strtotime( $date ) );
return $date;
}
}
/*======
*
* Time Converter
*
======*/
if( !function_exists( 'loquet_time_converter' ) ) {
function loquet_time_converter( $time = "", $format = "" ) {
if( empty( $format ) ) {
$format = get_option( 'time_format' );
}
$time = date_i18n( $format, strtotime( $time ) );
return $time;
}
}
/*======
*
* Word Cutter
*
======*/
if( !function_exists( 'loquet_word_cutter' ) ) {
function loquet_word_cutter( $string, $word_limit ) {
$words = explode( ' ', $string, ( $word_limit + 1 ) );
if( count( $words ) > $word_limit ) {
array_pop( $words );
}
return implode( ' ', $words );
}
}
/*======
*
* Add Pingback to Header
*
======*/
if( !function_exists( 'loquet_pingback_add_header' ) ) {
function loquet_pingback_add_header() {
if( is_singular() && pings_open() ) {
echo '<link rel="pingback" href="' . esc_url( get_bloginfo( 'pingback_url' ) ) . '">';
}
}
add_action( 'wp_head', 'loquet_pingback_add_header' );
}
/*======
*
* Get Post Terms
*
======*/
if( !function_exists( 'loquet_get_post_terms' ) ) {
function loquet_get_post_terms( $post_id = "", $taxonomy = "", $post_type = "" ) {
if( !empty( $post_id ) ) {
/*====== Settings ======*/
$terms = wp_get_post_terms( esc_attr( $post_id ), esc_attr( $taxonomy ) );
/*====== HTML Output ======*/
$output = "";
if( !empty( $terms ) ) {
$output .= '<ul>';
foreach( $terms as $term ) {
if( !empty( $term ) ) {
if( !empty( $term->name ) ) {
$output .= '<li>';
$output .= '<a href="' . get_term_link( $term->term_id ) . '?post_type=' . esc_attr( $post_type ) . '">' . esc_attr( $term->name ) . '</a>';
$output .= '</li>';
}
}
}
$output .= '</ul>';
}
return $output;
}
}
}
/*======
*
* Get Taxonomy Terms
*
======*/
if( !function_exists( 'loquet_get_taxonomy_terms' ) ) {
function loquet_get_taxonomy_terms( $post_type = "", $taxonomy = "", $count = "", $exclude_terms = "", $include_terms = "", $empty_terms = "", $childless = "", $hide_children = "", $order = "", $order_type = "", $style = "style-1", $show_count = "false" ) {
$output = "";
if( !empty( $taxonomy ) ) {
/*====== Childless ======*/
if( $childless == "false" ) {
$childless = false;
} else {
$childless = true;
}
/*====== Hide Children ======*/
if( $hide_children == "false" ) {
$hide_children = '';
} else {
$hide_children = 0;
}
/*====== Empty Terms ======*/
if( $empty_terms == "false" ) {
$empty_terms = false;
} else {
$empty_terms = true;
}
/*====== Exclude Terms ======*/
if( !empty( $exclude_terms ) ) {
$exclude_terms = explode( ',', $exclude_terms );
}
/*====== Include Terms ======*/
if( !empty( $include_terms ) ) {
$include_terms = explode( ',', $include_terms );
}
/*====== Taxonomy Order Type ======*/
if( $order_type == "name" ) {
$order_type == "name";
} elseif( $order_type == "slug" ) {
$order_type == "slug";
} elseif( $order_type == "term-group" ) {
$order_type == "term_group";
} elseif( $order_type == "term-id" ) {
$order_type == "term_id";
} elseif( $order_type == "id" ) {
$order_type == "id";
} elseif( $order_type == "description" ) {
$order_type == "description";
} elseif( $order_type == "parent" ) {
$order_type == "parent";
} elseif( $order_type == "count" ) {
$order_type == "count";
}
/*====== Query ======*/
$terms = get_terms(
array(
'number' => $count,
'taxonomy' => $taxonomy,
'exclude' => $exclude_terms,
'include' => $include_terms,
'hide_empty' => $empty_terms,
'childless' => $childless,
'parent' => $hide_children,
'order' => $order,
'orderby' => $order_type,
)
);
/*====== HTML Output ======*/
if( !empty( $terms ) ) {
$output .= '<div class="gt-term-listing gt-' . esc_attr( $style ) . '">';
$output .= '<ul>';
foreach( $terms as $term ) {
if( !empty( $term ) ) {
$output .= '<li>';
$output .= '<a href="' . esc_url( get_term_link( $term->term_id ) . ( !empty( $post_type ) ? '?post_type=' . esc_attr( $post_type ) : '' ) ) . '" class="gt-category-' . esc_attr( $term->term_id ) . '">';
$output .= esc_attr( $term->name );
if( $show_count == "true" ) {
$output .= '<span>';
$output .= loquet_taxonomy_post_count( $cat_id = esc_attr( $term->term_id ), $taxonomy = esc_attr( $taxonomy ) );
$output .= '</span>';
}
$output .= '</a>';
$output .= '</li>';
}
}
$output .= '</ul>';
$output .= '</div>';
}
return $output;
}
}
}
/*======
*
* Get Taxonomy Post Count
*
======*/
if( !function_exists( 'loquet_taxonomy_post_count' ) ) {
function loquet_taxonomy_post_count( $term_id = "", $taxonomy = "category" ) {
$main_count = 0;
$child_count = 0;
$main_args = array(
'include' => $term_id,
'child_of' => 0,
);
$main_terms = get_terms( esc_attr( $taxonomy ), $main_args );
$child_args = array(
'child_of' => $term_id,
);
$child_terms = get_terms( esc_attr( $taxonomy ), $child_args );
if( !empty( $main_terms ) ) {
foreach( $main_terms as $main_term ) {
if( !empty( $main_term ) ) {
$main_count += esc_attr( $main_term->count );
}
}
}
if( !empty( $child_terms ) ) {
foreach( $child_terms as $child_term ) {
if( !empty( $child_term ) ) {
$child_count += esc_attr( $child_term->count );
}
}
}
$total = $main_count + $child_count;
return $total;
}
}
/*======
*
* Item Group Item Count
*
======*/
if( !function_exists( 'loquet_item_group_item_count' ) ) {
function loquet_item_group_item_count( $item_id = "", $field = "" ) {
if( !empty( $item_id ) and !empty( $field ) ) {
$output = "";
if( function_exists( 'rwmb_meta' ) ) {
$meta_field = rwmb_meta( esc_attr( $field ), '', esc_attr( $item_id ) );
if( !empty( $meta_field ) ) {
$output .= count( $meta_field );
}
}
return $output;
}
}
}
/*======
*
* Sanitize HTML
*
======*/
function loquet_sanitize_html( $string ) {
$allowed_tags = array(
'a' => array(
'href' => array(),
'title' => array(),
'class' => array(),
'style' => array(),
'data-image' => array(),
'data-zoom-image' => array(),
'productid' => array(),
'data-tinv-wl-list' => array(),
'data-tinv-wl-product' => array(),
'data-tinv-wl-productvariation' => array(),
'data-tinv-wl-action' => array(),
'data-tinv-wl-producttype' => array(),
'target' => array('_blank', '_top'),
'id' => array(),
'rel' => array(),
),
'br' => array(),
'em' => array(),
'strong' => array(
'class' => array(),
),
'div' => array(
'class' => array(),
'id' => array(),
'tabindex' => array(),
'role' => array(),
'style' => array('display'),
),
'figcaption' => array(),
'p' => array(
'class' => array(),
),
'li' => array(
'class' => array(),
),
'ul' => array(
'class' => array(),
),
'ol' => array(
'class' => array(),
'id' => array(),
),
'span' => array(
'class' => array(),
'data-countdown' => array(),
'style' => array(),
),
'h1' => array(
'class' => array(),
),
'h2' => array(
'class' => array(),
),
'h3' => array(
'class' => array(),
),
'h4' => array(
'class' => array(),
),
'h5' => array(
'class' => array(),
),
'h6' => array(
'class' => array(),
),
'i' => array(
'class' => array(),
),
'img' => array(
'id' => array(),
'class' => array(),
'src' => array(),
'width' => array(),
'height' => array(),
'alt' => array(),
'data-zoom-image' => array(),
'data-image' => array(),
'srcset' => array(),
),
'figure' => array(
'class' => array(),
'data-bg-img' => array(),
),
'del' => array(),
'ins' => array(),
'script' => array(),
'input' => array(
'type' => array(),
'name' => array(),
'placeholder' => array(),
'required' => array(),
'value' => array(),
'class' => array(),
'id' => array(),
'tabindex' => array(),
'autocomplete' => array(),
'max' => array(),
),
'button' => array(
'class' => array(),
'data-toggle' => array(),
'data-target' => array(),
'onclick' => array(),
'aria-label' => array(),
'data-dismiss' => array(),
'type' => array(),
'name' => array(),
'value' => array(),
),
'form' => array(
'class' => array(),
'id' => array(),
'method' => array(),
'data-id' => array(),
'data-name' => array(),
'action' => array(),
'enctype' => array(),
),
'label' => array(
'style' => array(),
),
'nav' => array(
'class' => array(),
),
);
return wp_kses( $string, $allowed_tags );
}