PluginProbe
Property Hive / 1.4.61
Property Hive v1.4.61
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / includes / class-ph-elementor.php

class-ph-elementor.php in Property Hive 1.4.61, at includes/class-ph-elementor.php

106 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 class PH_Elementor {
8
9 public function __construct()
10 {
11 add_action( 'plugins_loaded', array( $this, 'setup_propertyhive_elementor_functionality' ) );
12 }
13
14 public function setup_propertyhive_elementor_functionality()
15 {
16 add_filter( 'elementor_pro/utils/get_public_post_types', array( $this, 'register_public_post_type' ) );
17
18 add_action( 'elementor/elements/categories_registered', array( $this, 'add_elementor_widget_category' ) );
19
20 add_action( 'elementor/preview/enqueue_scripts', array( 'PH_Frontend_Scripts', 'load_scripts' ) );
21 add_action( 'elementor/preview/enqueue_scripts', array( $this, 'load_elementor_scripts' ) );
22
23 if ( did_action( 'elementor/loaded' ) )
24 {
25 // Widgets
26 add_action( 'init', array( $this, 'register_widgets' ) );
27 }
28 }
29
30 public function load_elementor_scripts()
31 {
32 $suffix = '';
33 $assets_path = str_replace( array( 'http:', 'https:' ), '', PH()->plugin_url() ) . '/assets/';
34
35 wp_enqueue_script( 'propertyhive_fancybox' );
36 wp_enqueue_style( 'propertyhive_fancybox_css' );
37
38 wp_enqueue_script( 'flexslider', $assets_path . 'js/flexslider/jquery.flexslider' . $suffix . '.js', array( 'jquery' ), '2.2.2', true );
39 wp_enqueue_script( 'flexslider-init', $assets_path . 'js/flexslider/jquery.flexslider.init' . $suffix . '.js', array( 'jquery','flexslider' ), PH_VERSION, true );
40 wp_enqueue_style( 'flexslider_css', $assets_path . 'css/flexslider.css' );
41
42 $api_key = get_option('propertyhive_google_maps_api_key');
43 wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ( ( $api_key != '' && $api_key !== FALSE ) ? 'key=' . $api_key : '' ), false, '3');
44 wp_enqueue_script('googlemaps');
45
46 wp_enqueue_script( 'propertyhive_elementor', $assets_path . 'js/elementor/elementor.js', array( 'jquery','flexslider' ), PH_VERSION, true );
47 }
48
49 public function add_elementor_widget_category( $elements_manager )
50 {
51 $elements_manager->add_category(
52 'property-hive',
53 [
54 'title' => __( 'Property Hive', 'propertyhive' ),
55 'icon' => 'fa fa-home',
56 ]
57 );
58 }
59
60 public function register_widgets()
61 {
62 $widgets = array(
63 'Property Price',
64 'Property Images',
65 'Property Features',
66 'Property Summary Description',
67 'Property Full Description',
68 'Property Actions',
69 'Property Meta',
70 'Property Availability',
71 'Property Type',
72 'Property Bedrooms',
73 'Property Bathrooms',
74 'Property Reception Rooms',
75 'Property Map',
76 'Property Street View',
77 );
78
79 $widgets = apply_filters( 'propertyhive_elementor_widgets', $widgets );
80
81 foreach ( $widgets as $widget )
82 {
83 if ( file_exists( dirname(__FILE__) . "/elementor-widgets/" . sanitize_title($widget) . ".php" ) )
84 {
85 require_once( dirname(__FILE__) . "/elementor-widgets/" . sanitize_title($widget) . ".php" );
86 $class_name = '\Elementor_' . str_replace(" ", "_", $widget) . '_Widget';
87 \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new $class_name() );
88 }
89 }
90 }
91
92 public function register_public_post_type( $post_types ) {
93
94 if ( isset($post_types['property']) )
95 {
96 return $post_types;
97 }
98
99 $post_types['property'] = __( 'Property', 'propertyhive' );
100
101 return $post_types;
102 }
103
104 }
105
106 new PH_Elementor();