PluginProbe
MotoPress Hotel Booking for Divi / trunk
MotoPress Hotel Booking for Divi vtrunk
trunk 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 2.0.0
mphb-divi / divi-5 / php / bootstrap.php

bootstrap.php in MotoPress Hotel Booking for Divi trunk, at divi-5/php/bootstrap.php

173 lines 4.5 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;
5 }
6
7 if ( ! function_exists( 'mphb_divi_5_get_accommodation_attribute_options' ) ) {
8 function mphb_divi_5_get_accommodation_attribute_options() {
9 $attributes = array(
10 array(
11 'slug' => 'adults',
12 'title' => __( 'Adults', 'mphb-divi' ),
13 ),
14 array(
15 'slug' => 'children',
16 'title' => __( 'Children', 'mphb-divi' ),
17 ),
18 array(
19 'slug' => 'capacity',
20 'title' => __( 'Capacity', 'mphb-divi' ),
21 ),
22 array(
23 'slug' => 'amenities',
24 'title' => __( 'Amenities', 'mphb-divi' ),
25 ),
26 array(
27 'slug' => 'view',
28 'title' => __( 'View', 'mphb-divi' ),
29 ),
30 array(
31 'slug' => 'size',
32 'title' => __( 'Size', 'mphb-divi' ),
33 ),
34 array(
35 'slug' => 'bed-types',
36 'title' => __( 'Bed Types', 'mphb-divi' ),
37 ),
38 array(
39 'slug' => 'categories',
40 'title' => __( 'Categories', 'mphb-divi' ),
41 ),
42 );
43
44 global $mphbAttributes; // phpcs:ignore
45
46 foreach ( (array) $mphbAttributes as $custom_attribute ) { // phpcs:ignore
47 if ( empty( $custom_attribute['attributeName'] ) ) {
48 continue;
49 }
50
51 $item = array(
52 'slug' => (string) $custom_attribute['attributeName'],
53 'title' => isset( $custom_attribute['title'] ) ? (string) $custom_attribute['title'] : (string) $custom_attribute['attributeName'],
54 );
55
56 $attributes[] = $item;
57 }
58
59 return $attributes;
60 }
61 }
62
63 if ( ! function_exists( 'mphb_divi_5_get_accommodation_type_options' ) ) {
64 function mphb_divi_5_get_accommodation_type_options() {
65 $posts = get_posts(
66 array(
67 'post_type' => 'mphb_room_type',
68 'post_status' => 'publish',
69 'posts_per_page' => -1,
70 'orderby' => array(
71 'menu_order' => 'ASC',
72 'title' => 'ASC',
73 ),
74 )
75 );
76
77 return array_map(
78 static function ( $post ) {
79 return array(
80 'id' => (int) $post->ID,
81 'title' => get_the_title( $post ),
82 );
83 },
84 $posts
85 );
86 }
87 }
88
89 if ( ! function_exists( 'mphb_divi_5_get_image_size_options' ) ) {
90 function mphb_divi_5_get_image_size_options() {
91 global $_wp_additional_image_sizes;
92
93 $sizes = array();
94
95 foreach ( get_intermediate_image_sizes() as $size ) {
96 if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
97 $width = (int) $_wp_additional_image_sizes[ $size ]['width'];
98 $height = (int) $_wp_additional_image_sizes[ $size ]['height'];
99 } else {
100 $width = (int) get_option( "{$size}_size_w" );
101 $height = (int) get_option( "{$size}_size_h" );
102 }
103
104 $sizes[ $size ] = sprintf(
105 '%1$s - %2$d x %3$d',
106 ucwords( strtolower( preg_replace( '/[-_]/', ' ', $size ) ) ),
107 $width,
108 $height
109 );
110 }
111
112 $sizes['full'] = __( 'Full Size', 'mphb-divi' );
113
114 return $sizes;
115 }
116 }
117
118 $mphb_divi_5_module_map = require __DIR__ . '/module-map.php';
119
120 add_action(
121 'divi_module_library_modules_dependency_tree',
122 static function ( $dependency_tree ) use ( $mphb_divi_5_module_map ) {
123 if ( ! interface_exists( 'ET\\Builder\\Framework\\DependencyManagement\\Interfaces\\DependencyInterface' ) ) {
124 return;
125 }
126
127 require_once __DIR__ . '/modules.php';
128
129 $dependency_tree->add_dependency( new MPHB_Divi_5_Modules( $mphb_divi_5_module_map ) );
130 }
131 );
132
133 add_action(
134 'divi_visual_builder_assets_before_enqueue_scripts',
135 static function () {
136 if ( ! function_exists( 'et_core_is_fb_enabled' ) || ! et_core_is_fb_enabled() || ! function_exists( 'et_builder_d5_enabled' ) || ! et_builder_d5_enabled() ) {
137 return;
138 }
139
140 $build = dirname( __DIR__ ) . '/visual-builder/build/mphb-divi-d5.js';
141
142 if ( ! file_exists( $build ) || ! class_exists( '\ET\Builder\VisualBuilder\Assets\PackageBuildManager' ) ) {
143 return;
144 }
145
146 \ET\Builder\VisualBuilder\Assets\PackageBuildManager::register_package_build(
147 array(
148 'name' => 'mphb-divi-d5-visual-builder',
149 'version' => MPHB_DIVI_VERSION,
150 'script' => array(
151 'src' => plugin_dir_url( dirname( __DIR__ ) ) . 'divi-5/visual-builder/build/mphb-divi-d5.js',
152 'deps' => array(
153 'jquery',
154 'divi-module-library',
155 'divi-vendor-wp-hooks',
156 'divi-rest',
157 ),
158 'enqueue_top_window' => false,
159 'enqueue_app_window' => true,
160 'data_app_window' => array(
161 'accommodationAttributes' => mphb_divi_5_get_accommodation_attribute_options(),
162 'accommodationTypes' => mphb_divi_5_get_accommodation_type_options(),
163 'imageSizes' => mphb_divi_5_get_image_size_options(),
164 ),
165 ),
166 )
167 );
168
169 wp_enqueue_script( 'mphb-flexslider' );
170 wp_enqueue_style( 'mphb-flexslider-css' );
171 }
172 );
173