| 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 |
public function init() { |
| 10 |
|
| 11 |
$this->name = esc_html__( 'HB Accom. Services', 'mphb-divi' ); |
| 12 |
} |
| 13 |
|
| 14 |
public function get_fields() { |
| 15 |
|
| 16 |
return array( |
| 17 |
'ids' => array( |
| 18 |
'label' => esc_html__( 'IDs', 'mphb-divi' ), |
| 19 |
'description' => esc_html__( 'Comma-separated IDs of services that will be shown. All services by default.', 'mphb-divi' ), |
| 20 |
'type' => 'text', |
| 21 |
'default' => '', |
| 22 |
'computed_affects' => array( |
| 23 |
'__services', |
| 24 |
), |
| 25 |
), |
| 26 |
'posts_per_page' => array( |
| 27 |
'label' => esc_html__( 'Count per page', 'mphb-divi' ), |
| 28 |
'description' => esc_html__( 'Integer, -1 to display all, default: "Blog pages show at most"', 'mphb-divi' ), |
| 29 |
'type' => 'text', |
| 30 |
'default' => '', |
| 31 |
'computed_affects' => array( |
| 32 |
'__services', |
| 33 |
), |
| 34 |
), |
| 35 |
'orderby' => array( |
| 36 |
'label' => esc_html__( 'Sort by', 'mphb-divi' ), |
| 37 |
'description' => esc_html__( 'ID, title, date, menu_order...', 'mphb-divi' ), |
| 38 |
'type' => 'text', |
| 39 |
'default' => '', |
| 40 |
'computed_affects' => array( |
| 41 |
'__services', |
| 42 |
), |
| 43 |
), |
| 44 |
'order' => array( |
| 45 |
'label' => esc_html__( 'Order', 'mphb-divi' ), |
| 46 |
'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' ), |
| 47 |
'type' => 'select', |
| 48 |
'options' => array( |
| 49 |
'ASC' => esc_html__( 'ASC', 'mphb-divi' ), |
| 50 |
'DESC' => esc_html__( 'DESC', 'mphb-divi' ), |
| 51 |
), |
| 52 |
'default' => 'DESC', |
| 53 |
'computed_affects' => array( |
| 54 |
'__services', |
| 55 |
), |
| 56 |
), |
| 57 |
'meta_key' => array( |
| 58 |
'label' => esc_html__( 'Custom field name', 'mphb-divi' ), |
| 59 |
'description' => esc_html__( 'Required if "orderby" is one of the "meta_value", "meta_value_num" or "meta_value_*".', 'mphb-divi' ), |
| 60 |
'type' => 'text', |
| 61 |
'default' => '', |
| 62 |
'computed_affects' => array( |
| 63 |
'__services', |
| 64 |
), |
| 65 |
), |
| 66 |
'meta_type' => array( |
| 67 |
'label' => esc_html__( 'Custom field type', 'mphb-divi' ), |
| 68 |
'description' => esc_html__( 'Specified type of the custom field. Can be used in conjunction with orderby="meta_value".', 'mphb-divi' ), |
| 69 |
'type' => 'text', |
| 70 |
'default' => '', |
| 71 |
'computed_affects' => array( |
| 72 |
'__services', |
| 73 |
), |
| 74 |
), |
| 75 |
'class' => array( |
| 76 |
'label' => esc_html__( 'Class', 'mphb-divi' ), |
| 77 |
'description' => esc_html__( 'Custom CSS class for shortcode wrapper.', 'mphb-divi' ), |
| 78 |
'type' => 'text', |
| 79 |
'default' => '', |
| 80 |
'computed_affects' => array( |
| 81 |
'__services', |
| 82 |
), |
| 83 |
), |
| 84 |
'__services' => array( |
| 85 |
'type' => 'computed', |
| 86 |
'computed_callback' => array( 'MPHB_Divi_Services_Module', 'get_services' ), |
| 87 |
'computed_depends_on' => array( |
| 88 |
'ids', |
| 89 |
'posts_per_page', |
| 90 |
'orderby', |
| 91 |
'order', |
| 92 |
'meta_key', |
| 93 |
'meta_type', |
| 94 |
'class', |
| 95 |
), |
| 96 |
), |
| 97 |
|
| 98 |
); |
| 99 |
} |
| 100 |
|
| 101 |
public function render( $attrs, $content, $render_slug ) { |
| 102 |
|
| 103 |
return self::get_services( $this->props ); |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
public static function get_services( $args = array() ) { |
| 108 |
return MPHB_Divi_Renderers::services( $args ); |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
new MPHB_Divi_Services_Module(); |
| 113 |
|
| 114 |
endif; |
| 115 |
|