function __construct() { self::$current_module_index++; if (self::$loading_backbone_templates || et_admin_backbone_templates_being_loaded()) { if (!self::$loading_backbone_templates) { self::$loading_backbone_templates = true; } $start_from = (int) sanitize_text_field($_POST['et_templates_start_from']); $post_type = sanitize_text_field($_POST['et_post_type']); if ('layout' === $post_type) { // need - 2 to include the et_pb_section and et_pb_row modules $start_from = ET_Builder_Element::get_modules_count('page') - 2; } $current_module_index = self::$current_module_index - 1; if (!($current_module_index >= $start_from && $current_module_index < ET_BUILDER_AJAX_TEMPLATES_AMOUNT + $start_from)) { return; } } $this->init(); $this->process_whitelisted_fields(); $this->set_fields(); $this->_additional_fields_options = array(); $this->_add_additional_fields(); $this->_add_custom_css_fields(); $this->_maybe_add_defaults(); if (!isset($this->main_css_element)) { $this->main_css_element = '%%order_class%%'; } $this->_shortcode_callback_num = 0; $this->type = isset($this->type) ? $this->type : ''; $this->decode_entities = isset($this->decode_entities) ? (bool) $this->decode_entities : false; $this->_style_priority = (int) self::DEFAULT_PRIORITY; if (isset($this->type) && 'child' === $this->type) { $this->_style_priority = $this->_style_priority + 1; } $this->main_tabs = $this->get_main_tabs(); $this->custom_css_tab = isset($this->custom_css_tab) ? $this->custom_css_tab : true; $post_types = !empty($this->post_types) ? $this->post_types : et_builder_get_builder_post_types(); // all modules should be assigned for et_pb_layout post type to work in the library if (!in_array('et_pb_layout', $post_types)) { $post_types[] = 'et_pb_layout'; } $this->post_types = apply_filters('et_builder_module_post_types', $post_types, $this->slug, $this->post_types); foreach ($this->post_types as $post_type) { if (!in_array($post_type, $this->post_types)) { $this->register_post_type($post_type); } if ('child' == $this->type) { self::$child_modules[$post_type][$this->slug] = $this; } else { self::$parent_modules[$post_type][$this->slug] = $this; } } if (!isset($this->no_shortcode_callback)) { $shortcode_slugs = array($this->slug); if (!empty($this->additional_shortcode_slugs)) { $shortcode_slugs = array_merge($shortcode_slugs, $this->additional_shortcode_slugs); } foreach ($shortcode_slugs as $shortcode_slug) { add_shortcode($shortcode_slug, array($this, '_shortcode_callback')); } if (isset($this->additional_shortcode)) { add_shortcode($this->additional_shortcode, array($this, 'additional_shortcode_callback')); } } }