LittleDemon WebShell


Linux webm007.cluster106.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Path : /home/eglisebaa/www/wp-content/plugins/trx_addons2/components/shortcodes/osmap/
File Upload :
Command :
Current File : /home/eglisebaa/www/wp-content/plugins/trx_addons2/components/shortcodes/osmap/osmap.php

<?php
/**
 * Shortcode: OpenStreen Map
 *
 * @package WordPress
 * @subpackage ThemeREX Addons
 * @since v1.6.63
 */

// Don't load directly
if ( ! defined( 'TRX_ADDONS_VERSION' ) ) {
	die( '-1' );
}


// Load required styles and scripts for the frontend
if ( !function_exists( 'trx_addons_sc_osmap_load_scripts_front' ) ) {
	add_action("wp_enqueue_scripts", 'trx_addons_sc_osmap_load_scripts_front');
	function trx_addons_sc_osmap_load_scripts_front() {
		if (trx_addons_is_on(trx_addons_get_option('debug_mode'))){
			wp_enqueue_style( 'trx_addons-sc_osmap', trx_addons_get_file_url(TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap.css'), array(), null );
		}
	}
}

// Load responsive styles for the frontend
if ( !function_exists( 'trx_addons_sc_osmap_load_responsive_styles' ) ) {
	add_action("wp_enqueue_scripts", 'trx_addons_sc_osmap_load_responsive_styles', 2000);
	function trx_addons_sc_osmap_load_responsive_styles() {
		if (trx_addons_is_on(trx_addons_get_option('debug_mode'))) {
			wp_enqueue_style( 'trx_addons-sc_osmap-responsive', trx_addons_get_file_url(TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap.responsive.css'), array(), null );
		}
	}
}

	
// Merge shortcode's specific styles into single stylesheet
if ( !function_exists( 'trx_addons_sc_osmap_merge_styles' ) ) {
	add_filter("trx_addons_filter_merge_styles", 'trx_addons_sc_osmap_merge_styles');
	function trx_addons_sc_osmap_merge_styles($list) {
		$list[] = TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap.css';
		return $list;
	}
}


// Merge shortcode's specific styles to the single stylesheet (responsive)
if ( !function_exists( 'trx_addons_sc_osmap_merge_styles_responsive' ) ) {
	add_filter("trx_addons_filter_merge_styles_responsive", 'trx_addons_sc_osmap_merge_styles_responsive');
	function trx_addons_sc_osmap_merge_styles_responsive($list) {
		$list[] = TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap.responsive.css';
		return $list;
	}
}


// Merge osmap specific scripts to the single file
if ( !function_exists( 'trx_addons_sc_osmap_merge_scripts' ) ) {
	add_action("trx_addons_filter_merge_scripts", 'trx_addons_sc_osmap_merge_scripts');
	function trx_addons_sc_osmap_merge_scripts($list) {
		$list[] = TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap.js';
		return $list;
	}
}


// Load shortcode's specific scripts if current mode is Preview in the PageBuilder
if ( !function_exists( 'trx_addons_sc_osmap_load_scripts' ) ) {
	add_action("trx_addons_action_pagebuilder_preview_scripts", 'trx_addons_sc_osmap_load_scripts', 10, 1);
	function trx_addons_sc_osmap_load_scripts($editor='') {
		if (trx_addons_is_on(trx_addons_get_option('debug_mode'))){
			wp_enqueue_style( 'trx_addons-sc_osmap', trx_addons_get_file_url(TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap.css'), array(), null );
		}
		trx_addons_enqueue_osmap();
		if (trx_addons_is_on(trx_addons_get_option('debug_mode')) && $editor!='gutenberg' && (!function_exists('trx_addons_gutenberg_is_preview') || !trx_addons_gutenberg_is_preview())) {
			wp_enqueue_script( 'trx_addons-sc_osmap', trx_addons_get_file_url(TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap.js'), array('jquery'), null, true );
		}
	}
}

	
// Add messages for JS
if ( !function_exists( 'trx_addons_sc_osmap_localize_script' ) ) {
	add_filter("trx_addons_filter_localize_script", 'trx_addons_sc_osmap_localize_script');
	function trx_addons_sc_osmap_localize_script($vars) {
		if ( trx_addons_components_is_allowed('sc', 'osmap') ) {
			$vars['msg_sc_osmap_not_avail'] = esc_html__('OpenStreetMap service is not available', 'trx_addons');
			$vars['msg_sc_osmap_geocoder_error'] = esc_html__('Error while geocoding address', 'trx_addons');
			$vars['osmap_tiler'] = trx_addons_get_option('api_openstreet_tiler');
			$vars['osmap_tiler_styles'] = trx_addons_get_list_sc_osmap_styles( true );
			$vars['osmap_attribution'] = wp_kses_data( __( 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors', 'trx_addons' ) );
		}
		return $vars;
	}
}

// Add vars to the admin
if ( !function_exists( 'trx_addons_sc_osmap_localize_admin_script' ) ) {
	add_filter( 'trx_addons_filter_localize_script_admin',	'trx_addons_sc_osmap_localize_admin_script');
	function trx_addons_sc_osmap_localize_admin_script($vars = array()) {
		if ( trx_addons_components_is_allowed('sc', 'osmap') ) {
			$vars['osmap_tiler'] = trx_addons_get_option('api_openstreet_tiler');
			$vars['osmap_tiler_styles'] = trx_addons_get_list_sc_osmap_styles( true );
			$vars['osmap_attribution'] = wp_kses_data( __( 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors', 'trx_addons' ) );
		}
		return $vars;
	}
}


// trx_sc_osmap
//-------------------------------------------------------------
/*
[trx_sc_osmap id="unique_id" style="grey" zoom="16" markers="encoded json data"]
*/
if ( !function_exists( 'trx_addons_sc_osmap' ) ) {
	function trx_addons_sc_osmap($atts, $content=null){	
		$atts = trx_addons_sc_prepare_atts('trx_sc_osmap', $atts, trx_addons_sc_common_atts('id,title', array(
			// Individual params
			"type" => "default",
			"zoom" => 16,
			"center" => '',
			"style" => 'basic',
			"address" => '',
			"markers" => '',
			"cluster" => '',
			"width" => "100%",
			"height" => "400",
			"prevent_scroll" => 0,
			// Content from non-containers PageBuilder
			"content" => ""
			))
		);

		if (!is_array($atts['markers']) && function_exists('vc_param_group_parse_atts')) {
			$atts['markers'] = (array) vc_param_group_parse_atts( $atts['markers'] );
		}

		$output = '';
		if ( (is_array($atts['markers']) && count($atts['markers']) > 0) || !empty($atts['address'])) {
			if (!empty($atts['address'])) {
				$atts['markers'] = array(
										array(
											'title' => '',
											'description' => '',
											'address' => $atts['address'],
											'icon' => trx_addons_remove_protocol(trx_addons_get_option('api_openstreet_marker')),
											'icon_width' => '',
											'icon_height' => ''
										)
									);
			} else {
				foreach ($atts['markers'] as $k=>$v) {
					if (!empty($v['description']) && function_exists('vc_value_from_safe')) {
						$atts['markers'][$k]['description'] = trim( vc_value_from_safe( $v['description'] ) );
					}
					if (!empty($v['icon'])) {
						$atts['markers'][$k]['icon'] = trx_addons_get_attachment_url($v['icon'], 'full');
						if (empty($v['icon_width']) || empty($v['icon_height'])) {
							$attr = trx_addons_getimagesize($atts['markers'][$k]['icon']);
							$atts['markers'][$k]['icon_width'] = $attr[0];
							$atts['markers'][$k]['icon_height'] = $attr[1];
						}
					} else {
						$v['icon'] = trx_addons_remove_protocol(trx_addons_get_option('api_openstreet_marker'));
					}
					if (!empty($v['icon_retina']) && trx_addons_get_retina_multiplier() > 1) {
						$atts['markers'][$k]['icon'] = trx_addons_get_attachment_url($v['icon_retina'], 'full');
					}
				}
			}

			$atts['zoom'] = max(0, min(21, $atts['zoom']));
			$atts['center'] = trim($atts['center']);
	
			if (count($atts['markers']) > 1) {
				if (empty($atts['cluster'])) {
					$atts['cluster'] = trx_addons_remove_protocol(trx_addons_get_option('api_openstreet_cluster'));
				}
				if (empty($atts['cluster'])) {
					$atts['cluster'] = trx_addons_get_file_url(TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/cluster/cluster-icon.png');
				} else if ((int) $atts['cluster'] > 0) {
					$atts['cluster'] = trx_addons_get_attachment_url($atts['cluster'], apply_filters('trx_addons_filter_thumb_size', trx_addons_get_thumb_size('masonry'), 'osmap-cluster'));
				}
			} else if ($atts['zoom'] == 0) {
				$atts['zoom'] = 16;
			}
	
			$atts['class'] .= (!empty($atts['class']) ? ' ' : '') 
							. trx_addons_add_inline_css_class(trx_addons_get_css_dimensions_from_values($atts['width'], $atts['height']));
	
			if (empty($atts['style'])) $atts['style'] = 'basic';
	
			$atts['content'] = do_shortcode(empty($atts['content']) ? $content : $atts['content']);
			
			if (!function_exists('trx_addons_gutenberg_is_preview') || !trx_addons_gutenberg_is_preview()) {
				trx_addons_enqueue_osmap();
				if (trx_addons_is_on(trx_addons_get_option('debug_mode'))) {
					wp_enqueue_script( 'trx_addons-sc_osmap', trx_addons_get_file_url(TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap.js'), array('jquery'), null, true );
				}
			}

			ob_start();
			trx_addons_get_template_part(array(
											TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/tpl.'.trx_addons_esc($atts['type']).'.php',
											TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/tpl.default.php'
											),
											'trx_addons_args_sc_osmap', 
											$atts
										);
			$output = ob_get_contents();
			ob_end_clean();
		}
		
		return apply_filters('trx_addons_sc_output', $output, 'trx_sc_osmap', $atts, $content);
	}
}


// Add shortcode [trx_sc_osmap]
if (!function_exists('trx_addons_sc_osmap_add_shortcode')) {
	function trx_addons_sc_osmap_add_shortcode() {
		add_shortcode("trx_sc_osmap", "trx_addons_sc_osmap");
	}
	add_action('init', 'trx_addons_sc_osmap_add_shortcode', 20);
}


// Add shortcodes
//----------------------------------------------------------------------------

// Add shortcodes to Elementor
if ( trx_addons_exists_elementor() && function_exists('trx_addons_elm_init') ) {
	require_once TRX_ADDONS_PLUGIN_DIR . TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap-sc-elementor.php';
}

// Add shortcodes to Gutenberg
if ( trx_addons_exists_gutenberg() && function_exists( 'trx_addons_gutenberg_get_param_id' ) ) {
	require_once TRX_ADDONS_PLUGIN_DIR . TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap-sc-gutenberg.php';
}

// Add shortcodes to VC
if ( trx_addons_exists_vc() && function_exists( 'trx_addons_vc_add_id_param' ) ) {
	require_once TRX_ADDONS_PLUGIN_DIR . TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap-sc-vc.php';
}

// Create our widget
require_once TRX_ADDONS_PLUGIN_DIR . TRX_ADDONS_PLUGIN_SHORTCODES . 'osmap/osmap-widget.php';

LittleDemon - FACEBOOK
[ KELUAR ]