| 1 |
<?php |
| 2 |
/** |
| 3 |
* The admin-specific functionality of the plugin. |
| 4 |
* |
| 5 |
* @link listing-themes.com |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @package Wpdirectorykit |
| 9 |
* @subpackage Wpdirectorykit/admin |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* The admin-specific functionality of the plugin. |
| 14 |
* |
| 15 |
* Defines the plugin name, version, and two examples hooks for how to |
| 16 |
* enqueue the admin-specific stylesheet and JavaScript. |
| 17 |
* |
| 18 |
* @package Wpdirectorykit |
| 19 |
* @subpackage Wpdirectorykit/admin |
| 20 |
* @author listing-themes.com <dev@listing-themes.com> |
| 21 |
*/ |
| 22 |
|
| 23 |
if ( ! defined( 'ABSPATH' ) ) { |
| 24 |
exit; // Exit if accessed directly. |
| 25 |
} |
| 26 |
|
| 27 |
class Wdk_Elementor { |
| 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 |
* The name of Elementor Category. |
| 49 |
* |
| 50 |
* @since 1.0.0 |
| 51 |
* @access private |
| 52 |
* @var string $version The current version of this plugin. |
| 53 |
*/ |
| 54 |
private $elementor_category_name = 'wdk-elementor'; |
| 55 |
private $elementor_category_name_listing_preview = 'wdk-elementor-listing-preview'; |
| 56 |
|
| 57 |
/** |
| 58 |
* Initialize the class and set its properties. |
| 59 |
* |
| 60 |
* @since 1.0.0 |
| 61 |
* @param string $plugin_name The name of this plugin. |
| 62 |
* @param string $version The version of this plugin. |
| 63 |
*/ |
| 64 |
public function __construct( $plugin_name='wpdirectorykit', $version='1.0' ) { |
| 65 |
$this->plugin_name = $plugin_name; |
| 66 |
$this->version = $version; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Register the stylesheets for the admin area. |
| 71 |
* |
| 72 |
* @since 1.0.0 |
| 73 |
*/ |
| 74 |
public function enqueue_styles() { |
| 75 |
/** |
| 76 |
* This function is provided for demonstration purposes only. |
| 77 |
* |
| 78 |
* An instance of this class should be passed to the run() function |
| 79 |
* defined in Wpdirectorykit_Loader as all of the hooks are defined |
| 80 |
* in that particular class. |
| 81 |
* |
| 82 |
* The Wpdirectorykit_Loader will then create the relationship |
| 83 |
* between the defined hooks and the functions defined in this |
| 84 |
* class. |
| 85 |
*/ |
| 86 |
|
| 87 |
wp_enqueue_style( 'font-awesome' ); |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Register the JavaScript for the admin area. |
| 92 |
* |
| 93 |
* @since 1.0.0 |
| 94 |
*/ |
| 95 |
public function enqueue_scripts() { |
| 96 |
/** |
| 97 |
* This function is provided for demonstration purposes only. |
| 98 |
* |
| 99 |
* An instance of this class should be passed to the run() function |
| 100 |
* defined in Wpdirectorykit_Loader as all of the hooks are defined |
| 101 |
* in that particular class. |
| 102 |
* |
| 103 |
* The Wpdirectorykit_Loader will then create the relationship |
| 104 |
* between the defined hooks and the functions defined in this |
| 105 |
* class. |
| 106 |
*/ |
| 107 |
wp_enqueue_script( 'wdk-elementor-main', plugin_dir_url( __FILE__ ) . 'assets/js/wdk-main.js', array(), $this->version, true ); |
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* Load class/script files |
| 112 |
* |
| 113 |
* @since 1.0.0 |
| 114 |
*/ |
| 115 |
public function loader() { |
| 116 |
|
| 117 |
} |
| 118 |
|
| 119 |
/** |
| 120 |
* Includes |
| 121 |
* |
| 122 |
* @since 1.0.0 |
| 123 |
* |
| 124 |
* @access private |
| 125 |
*/ |
| 126 |
private function includes() { |
| 127 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-elementor-base.php'; |
| 128 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-label.php'; |
| 129 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-value.php'; |
| 130 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-images.php'; |
| 131 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-field-icon.php'; |
| 132 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-similar-listings.php'; |
| 133 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-grid.php'; |
| 134 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-grid-cover.php'; |
| 135 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-grid-cover.php'; |
| 136 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-grid.php'; |
| 137 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-list.php'; |
| 138 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-list.php'; |
| 139 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listings-results.php'; |
| 140 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listings-carousel.php'; |
| 141 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-slider.php'; |
| 142 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-categories-carousel.php'; |
| 143 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-locations-carousel.php'; |
| 144 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-map.php'; |
| 145 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-search.php'; |
| 146 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-fields-section.php'; |
| 147 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listings-list.php'; |
| 148 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-map.php'; |
| 149 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-agent.php'; |
| 150 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-agent-field.php'; |
| 151 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-listing-agent-avatar.php'; |
| 152 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-button.php'; |
| 153 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-button-login.php'; |
| 154 |
require_once plugin_dir_path( __FILE__ ) . 'classes/wdk-button-addlisting.php'; |
| 155 |
|
| 156 |
do_action('wpdirectorykit/elementor-elements/includes'); |
| 157 |
} |
| 158 |
|
| 159 |
/** |
| 160 |
* Register Widget |
| 161 |
* |
| 162 |
* @since 1.0.0 |
| 163 |
* |
| 164 |
* @access private |
| 165 |
*/ |
| 166 |
private function register_widget() { |
| 167 |
|
| 168 |
$listing_page_id = get_option('wdk_listing_page'); |
| 169 |
|
| 170 |
if(!empty($listing_page_id)) |
| 171 |
{ |
| 172 |
if(isset($_GET['post']) && $_GET['post'] == $listing_page_id) |
| 173 |
{ |
| 174 |
$this->add_widget('Wdk\Elementor\Widgets\WdkFieldLabel'); |
| 175 |
$this->add_widget('Wdk\Elementor\Widgets\WdkFieldValue'); |
| 176 |
$this->add_widget('Wdk\Elementor\Widgets\WdkFieldImages'); |
| 177 |
$this->add_widget('Wdk\Elementor\Widgets\WdkFieldIcon'); |
| 178 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingSimilarListings'); |
| 179 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingSlider'); |
| 180 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingFieldsSection'); |
| 181 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingMap'); |
| 182 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListinAgent'); |
| 183 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentField'); |
| 184 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentAvatar'); |
| 185 |
do_action('wpdirectorykit/elementor-elements/register_widget/listing', $this); |
| 186 |
} |
| 187 |
else if(isset($_GET['post'])) |
| 188 |
{ |
| 189 |
|
| 190 |
} |
| 191 |
else |
| 192 |
{ |
| 193 |
$this->add_widget('Wdk\Elementor\Widgets\WdkFieldLabel'); |
| 194 |
$this->add_widget('Wdk\Elementor\Widgets\WdkFieldValue'); |
| 195 |
$this->add_widget('Wdk\Elementor\Widgets\WdkFieldImages'); |
| 196 |
$this->add_widget('Wdk\Elementor\Widgets\WdkFieldIcon'); |
| 197 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingSimilarListings'); |
| 198 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingSlider'); |
| 199 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingFieldsSection'); |
| 200 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingMap'); |
| 201 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListinAgent'); |
| 202 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentField'); |
| 203 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingAgentAvatar'); |
| 204 |
do_action('wpdirectorykit/elementor-elements/register_widget/listing', $this); |
| 205 |
} |
| 206 |
|
| 207 |
//POST data[elementor_post_lock][post_ID] |
| 208 |
} |
| 209 |
|
| 210 |
$this->add_widget('Wdk\Elementor\Widgets\WdkLocationsList'); |
| 211 |
$this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesList'); |
| 212 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingsResults'); |
| 213 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingsCarousel'); |
| 214 |
$this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesCarousel'); |
| 215 |
$this->add_widget('Wdk\Elementor\Widgets\WdkLocationsCarousel'); |
| 216 |
$this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesGrid'); |
| 217 |
$this->add_widget('Wdk\Elementor\Widgets\WdkLocationsGrid'); |
| 218 |
$this->add_widget('Wdk\Elementor\Widgets\WdkCategoriesGridCover'); |
| 219 |
$this->add_widget('Wdk\Elementor\Widgets\WdkLocationsGridCover'); |
| 220 |
$this->add_widget('Wdk\Elementor\Widgets\WdkSearch'); |
| 221 |
$this->add_widget('Wdk\Elementor\Widgets\WdkMap'); |
| 222 |
$this->add_widget('Wdk\Elementor\Widgets\WdkListingsList'); |
| 223 |
$this->add_widget('Wdk\Elementor\Widgets\WdkButton'); |
| 224 |
$this->add_widget('Wdk\Elementor\Widgets\WdkButtonLogin'); |
| 225 |
$this->add_widget('Wdk\Elementor\Widgets\WdkButtonAddlisting'); |
| 226 |
|
| 227 |
do_action('wpdirectorykit/elementor-elements/register_widget', $this); |
| 228 |
} |
| 229 |
|
| 230 |
public function add_widget($class = ''){ |
| 231 |
if(class_exists($class)) |
| 232 |
{ |
| 233 |
$object = new $class(); |
| 234 |
\Elementor\Plugin::instance()->widgets_manager->register( $object ); |
| 235 |
}; |
| 236 |
} |
| 237 |
|
| 238 |
/** |
| 239 |
* Register Widget |
| 240 |
* |
| 241 |
* @since 1.0.0 |
| 242 |
* |
| 243 |
* @access private |
| 244 |
*/ |
| 245 |
private function register_modules() { |
| 246 |
|
| 247 |
} |
| 248 |
|
| 249 |
/** |
| 250 |
* On Widgets Registered |
| 251 |
* |
| 252 |
* @since 1.0.0 |
| 253 |
* |
| 254 |
* @access public |
| 255 |
*/ |
| 256 |
public function on_widgets_registered() { |
| 257 |
$this->includes(); |
| 258 |
$this->register_widget(); |
| 259 |
$this->register_modules(); |
| 260 |
} |
| 261 |
|
| 262 |
/** |
| 263 |
* Add elementor category |
| 264 |
* |
| 265 |
* @since 1.0.0 |
| 266 |
* |
| 267 |
* @access public |
| 268 |
*/ |
| 269 |
function load_category( $elements_manager ) { |
| 270 |
$elements_manager->add_category( |
| 271 |
$this->elementor_category_name, |
| 272 |
[ |
| 273 |
'title' => esc_html__( 'Wdk', 'wpdirectorykit' ), |
| 274 |
'icon' => 'fa fa-plug', |
| 275 |
] |
| 276 |
); |
| 277 |
|
| 278 |
$elements_manager->add_category( |
| 279 |
$this->elementor_category_name_listing_preview, |
| 280 |
[ |
| 281 |
'title' => esc_html__( 'Wdk Listing Preview', 'wpdirectorykit' ), |
| 282 |
'icon' => 'fa fa-plug', |
| 283 |
] |
| 284 |
); |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
/** |
| 289 |
* Start Elementor Addon |
| 290 |
*/ |
| 291 |
public function run() { |
| 292 |
|
| 293 |
add_action( 'wp_enqueue_scripts',[ $this, 'enqueue_styles' ]); |
| 294 |
add_action( 'wp_enqueue_scripts',[ $this, 'enqueue_scripts' ]); |
| 295 |
|
| 296 |
add_action( 'elementor/elements/categories_registered', [ $this, 'load_category' ] ); |
| 297 |
add_action( 'elementor/widgets/widgets_registered', [ $this, 'on_widgets_registered' ] ); |
| 298 |
|
| 299 |
do_action('wpdirectorykit/elementor-elements/run'); |
| 300 |
|
| 301 |
/* load module */ |
| 302 |
$this->loader(); |
| 303 |
//wmvc_dump($meta); |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
} |
| 308 |
|
| 309 |
/* Init lib after elementor loaded */ |
| 310 |
add_action( 'elementor/init', function() { |
| 311 |
$wdk_elementor = new Wdk_Elementor( ); |
| 312 |
$wdk_elementor->run(); |
| 313 |
do_action('wpdirectorykit/elementor-elements/init'); |
| 314 |
}); |
| 315 |
|
| 316 |
/* example extension for wdk elements |
| 317 |
add_action('wpdirectorykit/elementor-elements/includes', function(){ |
| 318 |
require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-contact-form.php'; |
| 319 |
}); |
| 320 |
|
| 321 |
add_action('wpdirectorykit/elementor-elements/register_widget/listing', function(){ |
| 322 |
$object = new Wdk\Elementor\Widgets\WdkContactFormExt(); |
| 323 |
\Elementor\Plugin::instance()->widgets_manager->register( $object ); |
| 324 |
}); |
| 325 |
*/ |
| 326 |
|
| 327 |
/* load extension */ |
| 328 |
|
| 329 |
add_action('wpdirectorykit/elementor-elements/register_widget/listing', function(){ |
| 330 |
add_action('eli/includes', function(){ |
| 331 |
require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-contact-form.php'; |
| 332 |
}); |
| 333 |
|
| 334 |
add_action('eli/register_widget', function(){ |
| 335 |
$object = new Wdk\Elementor\Extensions\WdkContactFormExt(); |
| 336 |
\Elementor\Plugin::instance()->widgets_manager->register( $object ); |
| 337 |
}); |
| 338 |
|
| 339 |
}); |
| 340 |
|
| 341 |
require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-ajax-handler.php'; |
| 342 |
$object = new Wdk\Elementor\Extensions\AjaxHandler(); |
| 343 |
|
| 344 |
require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-hider.php'; |
| 345 |
require_once WPDIRECTORYKIT_PATH . '/elementor-extensions/class-hider-addons.php'; |
| 346 |
|