PluginProbe
MotoPress Hotel Booking for Divi / 1.0.3
MotoPress Hotel Booking for Divi v1.0.3
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 / includes / modules / mphb-services / mphb-services.php

mphb-services.php in MotoPress Hotel Booking for Divi 1.0.3, at includes/modules/mphb-services/mphb-services.php

139 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if(!class_exists('MPHB_Divi_Services_Module') && class_exists('ET_Builder_Module')):
3
4 class MPHB_Divi_Services_Module extends ET_Builder_Module{
5
6 public $slug = 'mphb-divi-services';
7 public $vb_support = 'on';
8
9 function init(){
10
11 $this->name = esc_html__( 'HB Accom. Services', 'mphb-divi' );
12
13 }
14
15 function get_fields(){
16
17 return array(
18 'ids' => array(
19 'label' => esc_html__( 'IDs', 'mphb-divi' ),
20 'description' => esc_html__( 'Comma-separated IDs of services that will be shown. All services by default.', 'mphb-divi' ),
21 'type' => 'text',
22 'default' => '',
23 'computed_affects' => array(
24 '__services',
25 ),
26 ),
27 'posts_per_page' => array(
28 'label' => esc_html__( 'Count per page', 'mphb-divi' ),
29 'description' => esc_html__( 'Integer, -1 to display all, default: "Blog pages show at most"', 'mphb-divi' ),
30 'type' => 'text',
31 'default' => '',
32 'computed_affects' => array(
33 '__services',
34 ),
35 ),
36 'orderby' => array(
37 'label' => esc_html__( 'Sort by', 'mphb-divi' ),
38 'description' => esc_html__( 'ID, title, date, menu_order...', 'mphb-divi' ),
39 'type' => 'text',
40 'default' => '',
41 'computed_affects' => array(
42 '__services',
43 ),
44 ),
45 'order' => array(
46 'label' => esc_html__( 'Order', 'mphb-divi' ),
47 'description' => esc_html__( 'Designates the ascending or descending order of sorting. ASC - from lowest to highest values (1, 2, 3). DESC - from highest to lowest values (3, 2, 1).', 'mphb-divi' ),
48 'type' => 'select',
49 'options' => array(
50 'ASC' => esc_html__( 'ASC', 'mphb-divi' ),
51 'DESC' => esc_html__( 'DESC', 'mphb-divi' ),
52 ),
53 'default' => 'DESC',
54 'computed_affects' => array(
55 '__services',
56 ),
57 ),
58 'meta_key' => array(
59 'label' => esc_html__( 'Custom field name', 'mphb-divi' ),
60 'description' => esc_html__( 'Required if "orderby" is one of the "meta_value", "meta_value_num" or "meta_value_*".', 'mphb-divi' ),
61 'type' => 'text',
62 'default' => '',
63 'computed_affects' => array(
64 '__services',
65 ),
66 ),
67 'meta_type' => array(
68 'label' => esc_html__( 'Custom field type', 'mphb-divi' ),
69 'description' => esc_html__( 'Specified type of the custom field. Can be used in conjunction with orderby="meta_value".', 'mphb-divi' ),
70 'type' => 'text',
71 'default' => '',
72 'computed_affects' => array(
73 '__services',
74 ),
75 ),
76 'class' => array(
77 'label' => esc_html__( 'Class', 'mphb-divi' ),
78 'description' => esc_html__( 'Custom CSS class for shortcode wrapper.', 'mphb-divi' ),
79 'type' => 'text',
80 'default' => '',
81 'computed_affects' => array(
82 '__services',
83 ),
84 ),
85 '__services' => array(
86 'type' => 'computed',
87 'computed_callback' => array( 'MPHB_Divi_Services_Module', 'get_services' ),
88 'computed_depends_on' => array(
89 'ids',
90 'posts_per_page',
91 'orderby',
92 'order',
93 'meta_key',
94 'meta_type',
95 'class'
96 ),
97 )
98
99 );
100
101 }
102
103 function render($attrs, $content = null, $render_slug){
104
105 return self::get_services($this->props);
106
107 }
108
109
110 static function get_services($args = array()){
111
112 $defaults = array(
113 'ids' => '',
114 'class' => '',
115 'posts_per_page' => '',
116 'orderby' => '',
117 'order' => '',
118 'meta_key' => '',
119 'meta_type' => ''
120 );
121
122 $args = wp_parse_args($args, $defaults);
123
124 return do_shortcode('[mphb_services class="'.$args['class'].'" ids="'.$args['ids'].'"
125 posts_per_page="'.$args['posts_per_page'].'"
126 orderby="'.$args['orderby'].'"
127 order="'.$args['order'].'"
128 meta_key="'.$args['meta_key'].'"
129 meta_type="'.$args['meta_type'].'"
130 ]');
131
132 }
133
134 }
135
136 new MPHB_Divi_Services_Module();
137
138 endif;
139