File: /home/f/r/e/frenchy/refonte2023/wordpress/wp-content/plugins/ova-dir/inc/class-ova-assets.php
<?php
defined( 'ABSPATH' ) || exit();
if( !class_exists( 'OVADIR_assets' ) ){
class OVADIR_assets{
public function __construct(){
add_action( 'admin_enqueue_scripts', array( $this, 'ovadir_admin_enqueue_scripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'ovadir_frontend_enqueue_scripts' ) );
add_action( 'elementor/frontend/after_register_scripts', array( $this, 'ova_enqueue_scripts_elementor' ) );
}
public function ovadir_admin_enqueue_scripts() {
// Map
global $pagenow;
if ( ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) && 'ova_dir' === get_post_type() ) {
if ( get_option( 'ova_dir_google_map_api', false ) ) {
wp_enqueue_script( 'google','https://maps.googleapis.com/maps/api/js?key='.get_option( 'ova_dir_google_map_api', '' ).'&callback=Function.prototype&libraries=places', false, true );
} else {
wp_enqueue_script( 'google_map','https://maps.googleapis.com/maps/api/js?sensor=false&callback=Function.prototype&libraries=places', array('jquery'), false, true );
}
}
wp_enqueue_script('ova_dir_admin_scripts', OVADIR_PLUGIN_URI . 'assets/js/admin/scripts.js', array('jquery'),false, true);
wp_enqueue_style( 'ovadir_admin_styles', OVADIR_PLUGIN_URI.'assets/css/admin/styles.css');
}
public function ovadir_frontend_enqueue_scripts(){
if ( is_singular( 'ova_dir' ) || is_post_type_archive( 'ova_dir' ) || is_tax( 'tag_dir' ) || is_tax( 'cat_dir' ) ) {
if ( get_option( 'ova_dir_google_map_api', false ) ) {
wp_enqueue_script('markerclusterer','https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js', array('jquery'),false, true);
wp_enqueue_script( 'google','https://maps.googleapis.com/maps/api/js?key='.get_option( 'ova_dir_google_map_api', '' ).'&callback=Function.prototype&libraries=places', false, true );
} else {
wp_enqueue_script( 'google_map','https://maps.googleapis.com/maps/api/js?sensor=false&callback=Function.prototype&libraries=places', array('jquery'), false, true );
}
}
wp_enqueue_style( 'ova_dir_fancybox_style', OVADIR_PLUGIN_URI.'assets/libs/fancybox/fancybox.css');
wp_enqueue_script('ova_dir_fancybox_script', OVADIR_PLUGIN_URI . 'assets/libs/fancybox/fancybox.umd.js', array('jquery'),false, true);
wp_enqueue_style( 'ovadir_frontend_styles', OVADIR_PLUGIN_URI.'assets/css/frontend/styles.css');
wp_enqueue_script('ova_dir_frontend_scripts', OVADIR_PLUGIN_URI . 'assets/js/frontend/scripts.js', array('jquery'),false, true);
wp_localize_script( 'ova_dir_frontend_scripts', 'ova_dir_ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
}
public function ova_enqueue_scripts_elementor(){
wp_enqueue_script( 'script-elementor-dir', OVADIR_PLUGIN_URI. 'assets/js/frontend/script-elementor.js', [ 'jquery' ], false, true );
}
}
new OVADIR_assets();
}