| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The public-facing functionality of the plugin. |
| 5 |
* |
| 6 |
* @link listing-themes.com |
| 7 |
* @since 1.0.0 |
| 8 |
* |
| 9 |
* @package Wpdirectorykit |
| 10 |
* @subpackage Wpdirectorykit/public |
| 11 |
*/ |
| 12 |
|
| 13 |
/** |
| 14 |
* The public-facing functionality of the plugin. |
| 15 |
* |
| 16 |
* Defines the plugin name, version, and two examples hooks for how to |
| 17 |
* enqueue the public-facing stylesheet and JavaScript. |
| 18 |
* |
| 19 |
* @package Wpdirectorykit |
| 20 |
* @subpackage Wpdirectorykit/public |
| 21 |
* @author listing-themes.com <dev@listing-themes.com> |
| 22 |
*/ |
| 23 |
|
| 24 |
if ( ! defined( 'ABSPATH' ) ) { |
| 25 |
exit; // Exit if accessed directly. |
| 26 |
} |
| 27 |
class Wpdirectorykit_Public { |
| 28 |
|
| 29 |
/** |
| 30 |
* The ID of this plugin. |
| 31 |
* |
| 32 |
* @since 1.0.0 |
| 33 |
* @access private |
| 34 |
* @var string $plugin_name The ID of this plugin. |
| 35 |
*/ |
| 36 |
private $plugin_name; |
| 37 |
|
| 38 |
/** |
| 39 |
* The version of this plugin. |
| 40 |
* |
| 41 |
* @since 1.0.0 |
| 42 |
* @access private |
| 43 |
* @var string $version The current version of this plugin. |
| 44 |
*/ |
| 45 |
private $version; |
| 46 |
|
| 47 |
/** |
| 48 |
* Initialize the class and set its properties. |
| 49 |
* |
| 50 |
* @since 1.0.0 |
| 51 |
* @param string $plugin_name The name of the plugin. |
| 52 |
* @param string $version The version of this plugin. |
| 53 |
*/ |
| 54 |
public function __construct( $plugin_name, $version ) { |
| 55 |
|
| 56 |
$this->plugin_name = $plugin_name; |
| 57 |
$this->version = $version; |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Register the stylesheets for the public-facing side of the site. |
| 63 |
* |
| 64 |
* @since 1.0.0 |
| 65 |
*/ |
| 66 |
public function enqueue_styles() { |
| 67 |
|
| 68 |
/** |
| 69 |
* This function is provided for demonstration purposes only. |
| 70 |
* |
| 71 |
* An instance of this class should be passed to the run() function |
| 72 |
* defined in Wpdirectorykit_Loader as all of the hooks are defined |
| 73 |
* in that particular class. |
| 74 |
* |
| 75 |
* The Wpdirectorykit_Loader will then create the relationship |
| 76 |
* between the defined hooks and the functions defined in this |
| 77 |
* class. |
| 78 |
*/ |
| 79 |
|
| 80 |
/* load tree dropdown */ |
| 81 |
wp_register_style( 'wdk-listing-carousel', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listing-carousel.css', array(), $this->version, 'all' ); |
| 82 |
wp_register_style( 'wdk-listing-sliders-carousel', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listing-sliders-carousel.css', array(), $this->version, 'all' ); |
| 83 |
wp_register_style( 'wdk-listing-sliders-more-grid-images', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listing-sliders-more-grid-images.css', array(), $this->version, 'all' ); |
| 84 |
wp_register_style( 'wdk-listing-sliders-grid-images', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listing-sliders-grid-images.css', array(), $this->version, 'all' ); |
| 85 |
wp_register_style( 'wdk-listing-sliders', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listing-sliders.css', array(), $this->version, 'all' ); |
| 86 |
|
| 87 |
wp_register_style( 'wdk-suggestion', plugin_dir_url( __FILE__ ) . 'js/wdk_suggestion/wdk_suggestion.css', array(), '1.0.0' ); |
| 88 |
wp_register_style( 'wdk-treefield', plugin_dir_url( __FILE__ ) . 'js/wdk_treefield/treefield.css', array(), '1.0.0' ); |
| 89 |
wp_register_style( 'wdk-treefield-checkboxes', plugin_dir_url( __FILE__ ) . 'js/wdk_treefield_checkboxes/wdk_treefield_checkboxes.css', array(), '1.0.0' ); |
| 90 |
|
| 91 |
wp_register_style( 'wdk-element-button', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-element-button.css', array(), $this->version, 'all' ); |
| 92 |
wp_register_style( 'wdk-listing-agent-listings', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listing-agent-listings.css', array(), $this->version, 'all' ); |
| 93 |
wp_register_style( 'wdk-listing-agent', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listing-agent.css', array(), $this->version, 'all' ); |
| 94 |
wp_register_style( 'wdk-listings-list', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listings-list.css', array(), $this->version, 'all' ); |
| 95 |
wp_register_style( 'wdk-listing-fields-section', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listing-fields-section.css', array(), $this->version, 'all' ); |
| 96 |
wp_register_style( 'wdk-listing-slider', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listing-slider.css', array(), $this->version, 'all' ); |
| 97 |
wp_register_style( 'wdk-locations-carousel', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-locations-carousel.css', array(), $this->version, 'all' ); |
| 98 |
wp_register_style( 'wdk-categories-carousel', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-categories-carousel.css', array(), $this->version, 'all' ); |
| 99 |
wp_register_style( 'wdk-field-files', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-field-files.css', array(), $this->version, 'all' ); |
| 100 |
wp_register_style( 'wdk-field-files-list', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-field-files-list.css', array(), $this->version, 'all' ); |
| 101 |
wp_register_style( 'wdk-field-images', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-field-images.css', array(), $this->version, 'all' ); |
| 102 |
wp_register_style( 'wdk-locations-grid', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-locations-grid.css', array(), $this->version, 'all' ); |
| 103 |
wp_register_style( 'wdk-categories-grid-cover', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-categories-grid-cover.css', array(), $this->version, 'all' ); |
| 104 |
wp_register_style( 'wdk-locations-grid-cover', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-locations-grid-cover.css', array(), $this->version, 'all' ); |
| 105 |
wp_register_style( 'wdk-categories-grid', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-categories-grid.css', array(), $this->version, 'all' ); |
| 106 |
wp_register_style( 'wdk-categories-list', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-categories-list.css', array(), $this->version, 'all' ); |
| 107 |
wp_register_style( 'wdk-locations-tree', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-locations-tree.css', array(), $this->version, 'all' ); |
| 108 |
wp_register_style( 'wdk-categories-tree', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-categories-tree.css', array(), $this->version, 'all' ); |
| 109 |
wp_register_style( 'wdk-categories-tree-top', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-categories-tree-top.css', array(), $this->version, 'all' ); |
| 110 |
wp_register_style( 'wdk-locations-list', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-locations-list.css', array(), $this->version, 'all' ); |
| 111 |
wp_register_style( 'wdk-listings-map', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-map.css', array(), $this->version, 'all' ); |
| 112 |
wp_register_style( 'wdk-listings-carousel', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listings-carousel.css', array(), $this->version, 'all' ); |
| 113 |
wp_register_style( 'wdk-listing-related-listings-table', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/widgets/wdk-listing-related-listings-table.css', array(), $this->version, 'all' ); |
| 114 |
wp_register_style( 'wdk-notify', plugin_dir_url( __FILE__ ) . 'css/wdk-notify.css', array(), $this->version, 'all' ); |
| 115 |
wp_register_style( 'wdk-modal', plugin_dir_url( __FILE__ ) . 'css/wdk-modal.css', array(), $this->version, 'all' ); |
| 116 |
wp_register_style( 'wdk-hover', plugin_dir_url( __FILE__ ) . 'css/wdk-hover.css', array(), $this->version, 'all' ); |
| 117 |
wp_register_style( 'leaflet', plugin_dir_url( __FILE__ ) . 'js/openstreetmap/leaflet.css', array(), '1.7.1', 'all' ); |
| 118 |
wp_register_style( 'leaflet-cluster-def', plugin_dir_url( __FILE__ ) . 'js/openstreetmap/MarkerCluster.Default.css', array(), '1.7.1', 'all' ); |
| 119 |
wp_register_style( 'leaflet-cluster', plugin_dir_url( __FILE__ ) . 'js/openstreetmap/MarkerCluster.css', array(), '1.7.1', 'all' ); |
| 120 |
wp_register_style( 'leaflet-fullscreen', plugin_dir_url( __FILE__ ) . 'js/openstreetmap/leaflet.fullscreen.css', array(), '1.7.1', 'all' ); |
| 121 |
wp_register_style( 'ion.range-slider', plugin_dir_url( __FILE__ ) . 'js/ion.range-slider/css/ion.range-slider.min.css', array(), '2.3.1', 'all' ); |
| 122 |
wp_register_style( 'wdk-slider-range', plugin_dir_url( __FILE__ ) . 'css/wdk-slider-range.css', array(), '1.0', 'all' ); |
| 123 |
wp_register_style( 'select2', plugin_dir_url( __FILE__ ) . 'js/select2/css/select2.min.css', array(), '4.0.13', 'all' ); |
| 124 |
wp_register_style( 'wdk-treefield-dropdown', plugin_dir_url( __FILE__ ) . 'js/wdk_treefield_dropdown/wdk_treefield_dropdown.css', array(), '1.0', 'all' ); |
| 125 |
|
| 126 |
wp_register_style('blueimp-gallery', plugin_dir_url( __FILE__ ).'js/blueimp-gallery/css/blueimp-gallery.min.css', array(), '1.8', 'all'); |
| 127 |
|
| 128 |
wp_register_style('slick', plugin_dir_url( __FILE__ ).'js/slick/slick.css', array(), '1.8', 'all'); |
| 129 |
wp_register_style('slick-theme', plugin_dir_url( __FILE__ ).'js/slick/slick-theme.css', array(), '1.8', 'all'); |
| 130 |
|
| 131 |
wp_register_style('jquery-confirm', plugin_dir_url( __FILE__ ).'js/jquery-confirm/css/jquery-confirm.css', array(), '3.3.4', 'all'); |
| 132 |
wp_register_style('wdk-scroll-mobile-swipe', plugin_dir_url( __FILE__ ).'css/wdk-scroll-mobile-swipe.css', array(), '1.0.2', 'all'); |
| 133 |
wp_enqueue_style('wdk-scroll-mobile-swipe'); |
| 134 |
|
| 135 |
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpdirectorykit-public.css', array(), $this->version, 'all' ); |
| 136 |
wp_enqueue_style( $this->plugin_name.'-responsive', plugin_dir_url( __FILE__ ) . 'css/wpdirectorykit-public-responsive.css', array(), $this->version, 'all' ); |
| 137 |
wp_enqueue_style( $this->plugin_name.'-conflicts', plugin_dir_url( __FILE__ ) . 'css/wpdirectorykit-public-conflicts.css', array(), $this->version, 'all' ); |
| 138 |
|
| 139 |
if(is_rtl()) |
| 140 |
wp_enqueue_style( $this->plugin_name.'-rtl', plugin_dir_url( __FILE__ ) . 'css/wpdirectorykit-public-rtl.css', array(), $this->version, 'all' ); |
| 141 |
|
| 142 |
global $Winter_MVC_WDK; |
| 143 |
$Winter_MVC_WDK->model('category_m'); |
| 144 |
$categories = $Winter_MVC_WDK->category_m->get_by(array('(category_color IS NOT NULL AND category_color !="")'=>NULL)); |
| 145 |
|
| 146 |
/* categories colors special */ |
| 147 |
$custom_css = ''; |
| 148 |
foreach ($categories as $category) { |
| 149 |
/* marker map */ |
| 150 |
$custom_css .= " |
| 151 |
.wdk-element .wdk-map .wdk_marker-container.category_id_".esc_attr(wmvc_show_data('idcategory', $category),'',TRUE, TRUE)." .wdk_face.front i { |
| 152 |
color: ".esc_attr(wmvc_show_data('category_color', $category),'',TRUE, TRUE)."; |
| 153 |
} |
| 154 |
.wdk-element .wdk-map .wdk_marker-container.category_id_".esc_attr(wmvc_show_data('idcategory', $category),'',TRUE, TRUE)." .wdk_marker-container:hover .wdk_marker-card::after, |
| 155 |
.wdk-element .wdk-map .wdk_marker-container.category_id_".esc_attr(wmvc_show_data('idcategory', $category),'',TRUE, TRUE)." .wdk_marker-card::before { |
| 156 |
background: ".esc_attr(wmvc_show_data('category_color', $category),'',TRUE, TRUE)."; |
| 157 |
} |
| 158 |
"; |
| 159 |
/* marker map (label) */ |
| 160 |
$custom_css .= " |
| 161 |
.wdk-element .wdk-map .wdk_marker-container.category_id_".esc_attr(wmvc_show_data('idcategory', $category),'',TRUE, TRUE).".wdk_marker_label:not(.wdk_marker_clear) { |
| 162 |
border-color: ".esc_attr(wmvc_show_data('category_color', $category),'',TRUE, TRUE)."; |
| 163 |
background: ".esc_attr(wmvc_show_data('category_color', $category),'',TRUE, TRUE)."; |
| 164 |
} |
| 165 |
"; |
| 166 |
} |
| 167 |
wp_add_inline_style( $this->plugin_name, $custom_css); |
| 168 |
|
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* Register the JavaScript for the public-facing side of the site. |
| 173 |
* |
| 174 |
* @since 1.0.0 |
| 175 |
*/ |
| 176 |
public function enqueue_scripts() { |
| 177 |
|
| 178 |
/** |
| 179 |
* This function is provided for demonstration purposes only. |
| 180 |
* |
| 181 |
* An instance of this class should be passed to the run() function |
| 182 |
* defined in Wpdirectorykit_Loader as all of the hooks are defined |
| 183 |
* in that particular class. |
| 184 |
* |
| 185 |
* The Wpdirectorykit_Loader will then create the relationship |
| 186 |
* between the defined hooks and the functions defined in this |
| 187 |
* class. |
| 188 |
*/ |
| 189 |
|
| 190 |
wp_register_script( 'wdk-dependfields-submitform', plugin_dir_url( __FILE__ ) . 'js/wdk-dependfields-submitform.js', array( 'jquery' ), false, false ); |
| 191 |
wp_register_script( 'wdk-dependfields-search', plugin_dir_url( __FILE__ ) . 'js/wdk-dependfields-search.js', array( 'jquery' ), false, false ); |
| 192 |
|
| 193 |
/* load tree dropdown */ |
| 194 |
wp_register_script( 'wdk-suggestion', plugin_dir_url( __FILE__ ) . 'js/wdk_suggestion/wdk_suggestion.js', array( 'jquery' ), false, false ); |
| 195 |
wp_register_script( 'wdk-treefield', plugin_dir_url( __FILE__ ) . 'js/wdk_treefield/treefield.js', array( 'jquery' ), false, false ); |
| 196 |
wp_register_script( 'wdk-treefield-checkboxes', plugin_dir_url( __FILE__ ) . 'js/wdk_treefield_checkboxes/wdk_treefield_checkboxes.js', array( 'jquery' ), false, false ); |
| 197 |
|
| 198 |
wp_register_script( 'wdk-notify', plugin_dir_url( __FILE__ ) . 'js/wdk-notify.js', array( 'jquery' ), $this->version, false ); |
| 199 |
wp_register_script( 'wdk-modal', plugin_dir_url( __FILE__ ) . 'js/wdk-modal.js', array( 'jquery' ), $this->version, false ); |
| 200 |
wp_register_script( 'leaflet', plugin_dir_url( __FILE__ ) . 'js/openstreetmap/leaflet.js', array( 'jquery' ), '1.7.1', false ); |
| 201 |
wp_register_script( 'leaflet-cluster', plugin_dir_url( __FILE__ ) . 'js/openstreetmap/leaflet.markercluster.js', array( 'jquery' ), '1.7.1', false ); |
| 202 |
wp_register_script( 'leaflet-fullscreen', plugin_dir_url( __FILE__ ) . 'js/openstreetmap/leaflet.fullscreen.js', array( 'jquery' ), '1.7.1', false ); |
| 203 |
wp_register_script('blueimp-gallery', plugin_dir_url( __FILE__ ).'js/blueimp-gallery/js/blueimp-gallery.min.js', array( 'jquery' ), '3.4', false ); |
| 204 |
wp_register_script('wdk-blueimp-gallery', plugin_dir_url( __FILE__ ).'js/wdk-blueimp-gallery.js', array( 'jquery' ), '1.0', false ); |
| 205 |
wp_register_script('wdk-blueimp-slider', plugin_dir_url( __FILE__ ).'js/wdk-blueimp-slider.js', array( 'jquery' ), '1.0', false ); |
| 206 |
wp_register_script('slick', plugin_dir_url( __FILE__ ).'js/slick/slick.min.js', array( 'jquery' ), '1.8', false ); |
| 207 |
wp_register_script('ion.range-slider', plugin_dir_url( __FILE__ ).'js/ion.range-slider/js/ion.range-slider.min.js', array( 'jquery' ), '2.3.1', false ); |
| 208 |
wp_register_script('wdk-slider-range', plugin_dir_url( __FILE__ ).'js/wdk-slider-range.js', array( 'jquery' ), '1.0', false ); |
| 209 |
wp_register_script('select2', plugin_dir_url( __FILE__ ).'js/select2/js/select2.min.js', array( 'jquery' ), '4.0.13', false ); |
| 210 |
wp_register_script('wdk-select2', plugin_dir_url( __FILE__ ).'js/wdk-select2.js', array( 'jquery' ), '4.0.13', false ); |
| 211 |
|
| 212 |
|
| 213 |
$params = array( |
| 214 |
'ajax_url' => admin_url( 'admin-ajax.php' ) |
| 215 |
); |
| 216 |
wp_register_script('wdk-treefield-dropdown', plugin_dir_url( __FILE__ ).'js/wdk_treefield_dropdown/wdk_treefield_dropdown.js', array( 'jquery' ), '1.0', false ); |
| 217 |
wp_localize_script( 'wdk-treefield-dropdown', 'script_parameters', $params); |
| 218 |
|
| 219 |
wp_register_script('jquery-confirm', plugin_dir_url( __FILE__ ).'js/jquery-confirm/js/jquery-confirm.js', array( 'jquery' ), '3.3.4', false ); |
| 220 |
|
| 221 |
$params = array( |
| 222 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 223 |
'text' =>array( |
| 224 |
'price' => esc_html__('Price', 'wpdirectorykit'), |
| 225 |
'total_price' => esc_html__('Total', 'wpdirectorykit'), |
| 226 |
'loading' => esc_html__('Price loading...', 'wpdirectorykit'), |
| 227 |
), |
| 228 |
); |
| 229 |
wp_register_script('wdk-booking-calculator-price', plugin_dir_url( __FILE__ ).'js/wdk-booking-calculator-price.js', array( 'jquery' ), '1.0', false ); |
| 230 |
wp_localize_script('wdk-booking-calculator-price', 'wdk_booking_script_parameters', $params); |
| 231 |
|
| 232 |
wp_deregister_script('wdk-scroll-mobile-swipe'); |
| 233 |
wp_register_script('wdk-scroll-mobile-swipe', plugin_dir_url( __FILE__ ).'js/wdk-scroll-mobile-swipe.js', array( 'jquery' ), '1.1', false ); |
| 234 |
wp_enqueue_script('wdk-scroll-mobile-swipe'); |
| 235 |
|
| 236 |
$params = array( |
| 237 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 238 |
'format_date' => wdk_convert_date_format_js(get_option('date_format')), |
| 239 |
'format_datetime' => wdk_convert_date_format_js(get_option('date_format').' '.get_option('time_format')), |
| 240 |
'format_date_js' => wdk_convert_date_format_jquery(get_option('date_format')), |
| 241 |
'format_datetime_js' => wdk_convert_date_format_jquery(get_option('date_format').' '.get_option('time_format')), |
| 242 |
); |
| 243 |
|
| 244 |
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wpdirectorykit-public.js', array( 'jquery' ), $this->version, false ); |
| 245 |
wp_localize_script( $this->plugin_name, 'script_parameters', $params); |
| 246 |
|
| 247 |
wp_register_style('jquery-ui', WPDIRECTORYKIT_URL. 'public/css/jquery-ui.css', array(), '1.12.1' ); |
| 248 |
|
| 249 |
$custom_css = '.wdk-image:not(.media):not(.jsplaceholder){background-image: url('.esc_url(wdk_placeholder_image_src()).');background-size: cover;background-position: center; }'; |
| 250 |
wp_add_inline_style( $this->plugin_name, $custom_css); |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
public function ajax_public() |
| 255 |
{ |
| 256 |
$page = ''; |
| 257 |
$function = ''; |
| 258 |
|
| 259 |
if(isset($_POST['page']))$page = sanitize_text_field($_POST['page']); |
| 260 |
if(isset($_POST['function']))$function = sanitize_text_field($_POST['function']); |
| 261 |
|
| 262 |
/* protect access only to ajax controller */ |
| 263 |
if($page != 'wdk_frontendajax') { |
| 264 |
exit(esc_html__('Access denied','wdk-bookings')); |
| 265 |
} |
| 266 |
|
| 267 |
$WMVC = &wdk_get_instance(); |
| 268 |
$WMVC->load_controller($page, $function, array()); |
| 269 |
} |
| 270 |
|
| 271 |
} |
| 272 |
|