PKi"Ð\Fqx x module.phpnuW+A„¶register_groups(); add_action( 'elementor/dynamic_tags/register_tags', [ $this, 'register_tags' ] ); } /** * Get module name. * * Retrieve the dynamic tags module name. * * @since 2.0.0 * @access public * * @return string Module name. */ public function get_name() { return 'dynamic_tags'; } /** * Get classes names. * * Retrieve the dynamic tag classes names. * * @since 2.0.0 * @access public * * @return array Tag dynamic tag classes names. */ public function get_tag_classes_names() { return []; } /** * Get groups. * * Retrieve the dynamic tag groups. * * @since 2.0.0 * @access public * * @return array Tag dynamic tag groups. */ public function get_groups() { return [ self::BASE_GROUP => [ 'title' => 'Base Tags', ], ]; } /** * Register groups. * * Add all the available tag groups. * * @since 2.0.0 * @access private */ private function register_groups() { foreach ( $this->get_groups() as $group_name => $group_settings ) { Plugin::$instance->dynamic_tags->register_group( $group_name, $group_settings ); } } /** * Register tags. * * Add all the available dynamic tags. * * @since 2.0.0 * @access public * * @param Manager $dynamic_tags */ public function register_tags( $dynamic_tags ) { foreach ( $this->get_tag_classes_names() as $tag_class ) { /** @var Tag $class_name */ $class_name = $this->get_reflection()->getNamespaceName() . '\Tags\\' . $tag_class; $dynamic_tags->register_tag( $class_name ); } } } PKo<Ð\d@##tag.phpnuW+A„¶get_settings(); ob_start(); $this->render(); $value = ob_get_clean(); if ( ! Utils::is_empty( $value ) ) { // TODO: fix spaces in `before`/`after` if WRAPPED_TAG ( conflicted with .elementor-tag { display: inline-flex; } ); if ( ! Utils::is_empty( $settings, 'before' ) ) { $value = wp_kses_post( $settings['before'] ) . $value; } if ( ! Utils::is_empty( $settings, 'after' ) ) { $value .= wp_kses_post( $settings['after'] ); } if ( static::WRAPPED_TAG ) : $value = '' . $value . ''; endif; } elseif ( ! Utils::is_empty( $settings, 'fallback' ) ) { $value = $settings['fallback']; } return $value; } /** * @since 2.0.0 * @access public */ final public function get_content_type() { return 'ui'; } /** * @since 2.0.9 * @access public */ public function get_editor_config() { $config = parent::get_editor_config(); $config['wrapped_tag'] = $this::WRAPPED_TAG; return $config; } /** * @since 2.0.0 * @access protected */ protected function register_advanced_section() { $this->start_controls_section( 'advanced', [ 'label' => __( 'Advanced', 'elementor' ), ] ); $this->add_control( 'before', [ 'label' => __( 'Before', 'elementor' ), ] ); $this->add_control( 'after', [ 'label' => __( 'After', 'elementor' ), ] ); $this->add_control( 'fallback', [ 'label' => __( 'Fallback', 'elementor' ), ] ); $this->end_controls_section(); } } PKo<Ð\lÓSóó data-tag.phpnuW+A„¶get_value( $options ); } } PKo<Ð\†E¹ž(ž( manager.phpnuW+A„¶add_actions(); } /** * Localize settings. * * Add new localized settings for the dynamic module. * * Fired by `elementor/editor/localize_settings` filter. * * @access public * * @param array $settings Localized settings. * * @return array Localized settings. */ public function localize_settings( $settings ) { $settings = array_replace_recursive( $settings, [ 'i18n' => [ 'dynamic' => __( 'Dynamic', 'elementor' ), ], ] ); return $settings; } /** * Parse dynamic tags text. * * Receives the dynamic tag text, and returns a single value or multiple values * from the tag callback function. * * @since 2.0.0 * @access public * * @param string $text Dynamic tag text. * @param array $settings The dynamic tag settings. * @param callable $parse_callback The functions that renders the dynamic tag. * * @return string|string[]|mixed A single string or an array of strings with * the return values from each tag callback * function. */ public function parse_tags_text( $text, array $settings, callable $parse_callback ) { if ( ! empty( $settings['returnType'] ) && 'object' === $settings['returnType'] ) { $value = $this->parse_tag_text( $text, $settings, $parse_callback ); } else { $value = preg_replace_callback( '/\[' . self::TAG_LABEL . '.+?(?=\])\]/', function( $tag_text_match ) use ( $settings, $parse_callback ) { return $this->parse_tag_text( $tag_text_match[0], $settings, $parse_callback ); }, $text ); } return $value; } /** * Parse dynamic tag text. * * Receives the dynamic tag text, and returns the value from the callback * function. * * @since 2.0.0 * @access public * * @param string $tag_text Dynamic tag text. * @param array $settings The dynamic tag settings. * @param callable $parse_callback The functions that renders the dynamic tag. * * @return string|array|mixed If the tag was not found an empty string or an * empty array will be returned, otherwise the * return value from the tag callback function. */ public function parse_tag_text( $tag_text, array $settings, callable $parse_callback ) { $tag_data = $this->tag_text_to_tag_data( $tag_text ); if ( ! $tag_data ) { if ( ! empty( $settings['returnType'] ) && 'object' === $settings['returnType'] ) { return []; } return ''; } return call_user_func_array( $parse_callback, $tag_data ); } /** * @since 2.0.0 * @access public * * @param string $tag_text * * @return array|null */ public function tag_text_to_tag_data( $tag_text ) { preg_match( '/id="(.*?(?="))"/', $tag_text, $tag_id_match ); preg_match( '/name="(.*?(?="))"/', $tag_text, $tag_name_match ); preg_match( '/settings="(.*?(?="]))/', $tag_text, $tag_settings_match ); if ( ! $tag_id_match || ! $tag_name_match || ! $tag_settings_match ) { return null; } return [ 'id' => $tag_id_match[1], 'name' => $tag_name_match[1], 'settings' => json_decode( urldecode( $tag_settings_match[1] ), true ), ]; } /** * Dynamic tag to text. * * Retrieve the shortcode that represents the dynamic tag. * * @since 2.0.0 * @access public * * @param Base_Tag $tag An instance of the dynamic tag. * * @return string The shortcode that represents the dynamic tag. */ public function tag_to_text( Base_Tag $tag ) { return sprintf( '[%1$s id="%2$s" name="%3$s" settings="%4$s"]', self::TAG_LABEL, $tag->get_id(), $tag->get_name(), urlencode( wp_json_encode( $tag->get_settings(), JSON_FORCE_OBJECT ) ) ); } /** * @since 2.0.0 * @access public * @param string $tag_id * @param string $tag_name * @param array $settings * * @return string */ public function tag_data_to_tag_text( $tag_id, $tag_name, array $settings = [] ) { $tag = $this->create_tag( $tag_id, $tag_name, $settings ); if ( ! $tag ) { return ''; } return $this->tag_to_text( $tag ); } /** * @since 2.0.0 * @access public * @param string $tag_id * @param string $tag_name * @param array $settings * * @return Tag|null */ public function create_tag( $tag_id, $tag_name, array $settings = [] ) { $tag_info = $this->get_tag_info( $tag_name ); if ( ! $tag_info ) { return null; } $tag_class = $tag_info['class']; return new $tag_class( [ 'settings' => $settings, 'id' => $tag_id, ] ); } /** * @since 2.0.0 * @access public * * @param $tag_id * @param $tag_name * @param array $settings * * @return null|string */ public function get_tag_data_content( $tag_id, $tag_name, array $settings = [] ) { if ( self::MODE_REMOVE === $this->parsing_mode ) { return null; } $tag = $this->create_tag( $tag_id, $tag_name, $settings ); if ( ! $tag ) { return null; } return $tag->get_content(); } /** * @since 2.0.0 * @access public * * @param $tag_name * * @return mixed|null */ public function get_tag_info( $tag_name ) { $tags = $this->get_tags(); if ( empty( $tags[ $tag_name ] ) ) { return null; } return $tags[ $tag_name ]; } /** * @since 2.0.9 * @access public */ public function get_tags() { if ( ! did_action( 'elementor/dynamic_tags/register_tags' ) ) { /** * Register dynamic tags. * * Fires when Elementor registers dynamic tags. * * @since 2.0.9 * * @param Manager $this Dynamic tags manager. */ do_action( 'elementor/dynamic_tags/register_tags', $this ); } return $this->tags_info; } /** * @since 2.0.0 * @access public * * @param string $class */ public function register_tag( $class ) { /** @var Tag $tag */ $tag = new $class(); $this->tags_info[ $tag->get_name() ] = [ 'class' => $class, 'instance' => $tag, ]; } /** * @since 2.0.9 * @access public * * @param string $tag_name */ public function unregister_tag( $tag_name ) { unset( $this->tags_info[ $tag_name ] ); } /** * @since 2.0.0 * @access public * * @param $group_name * @param array $group_settings */ public function register_group( $group_name, array $group_settings ) { $default_group_settings = [ 'title' => '', ]; $group_settings = array_merge( $default_group_settings, $group_settings ); $this->tags_groups[ $group_name ] = $group_settings; } /** * @since 2.0.0 * @access public */ public function print_templates() { foreach ( $this->get_tags() as $tag_name => $tag_info ) { $tag = $tag_info['instance']; if ( ! $tag instanceof Tag ) { continue; } $tag->print_template(); } } /** * @since 2.0.0 * @access public */ public function get_tags_config() { $config = []; foreach ( $this->get_tags() as $tag_name => $tag_info ) { /** @var Tag $tag */ $tag = $tag_info['instance']; $config[ $tag_name ] = $tag->get_editor_config(); } return $config; } /** * @since 2.0.0 * @access public */ public function get_config() { return [ 'tags' => $this->get_tags_config(), 'groups' => $this->tags_groups, ]; } /** * @since 2.0.0 * @access public * * @throws \Exception If post ID is missing. * @throws \Exception If current user don't have permissions to edit the post. */ public function ajax_render_tags( $data ) { if ( empty( $data['post_id'] ) ) { throw new \Exception( 'Missing post id.' ); } if ( ! User::is_current_user_can_edit( $data['post_id'] ) ) { throw new \Exception( 'Access denied.' ); } Plugin::$instance->db->switch_to_post( $data['post_id'] ); /** * Before dynamic tags rendered. * * Fires before Elementor renders the dynamic tags. * * @since 2.0.0 */ do_action( 'elementor/dynamic_tags/before_render' ); $tags_data = []; foreach ( $data['tags'] as $tag_key ) { $tag_key_parts = explode( '-', $tag_key ); $tag_name = base64_decode( $tag_key_parts[0] ); $tag_settings = json_decode( urldecode( base64_decode( $tag_key_parts[1] ) ), true ); $tag = $this->create_tag( null, $tag_name, $tag_settings ); $tags_data[ $tag_key ] = $tag->get_content(); } /** * After dynamic tags rendered. * * Fires after Elementor renders the dynamic tags. * * @since 2.0.0 */ do_action( 'elementor/dynamic_tags/after_render' ); return $tags_data; } /** * @since 2.0.0 * @access public * * @param $mode */ public function set_parsing_mode( $mode ) { $this->parsing_mode = $mode; } /** * @since 2.0.0 * @access public */ public function get_parsing_mode() { return $this->parsing_mode; } /** * @since 2.1.0 * @access public * @param Post $css_file */ public function after_enqueue_post_css( $css_file ) { $post_id = $css_file->get_post_id(); if ( $css_file instanceof Post_Preview ) { $post_id_for_data = $css_file->get_preview_id(); } else { $post_id_for_data = $post_id; } $css_file = Dynamic_CSS::create( $post_id, $post_id_for_data ); $css_file->enqueue(); } /** * @since 2.3.0 * @access public */ public function register_ajax_actions( Ajax $ajax ) { $ajax->register_ajax_action( 'render_tags', [ $this, 'ajax_render_tags' ] ); } /** * @since 2.0.0 * @access private */ private function add_actions() { add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] ); add_action( 'elementor/css-file/post/enqueue', [ $this, 'after_enqueue_post_css' ] ); add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] ); } } PKo<Ð\Õ_YÒ Ò dynamic-css.phpnuW+A„¶post_id_for_data = $post_id_for_data; parent::__construct( $post_id ); } /** * @since 2.0.13 * @access public */ public function get_name() { return 'dynamic'; } /** * @since 2.0.13 * @access protected */ protected function use_external_file() { return false; } /** * @since 2.0.13 * @access protected */ protected function get_file_handle_id() { return 'elementor-post-dynamic-' . $this->post_id_for_data; } /** * @since 2.0.13 * @access protected */ protected function get_data() { $document = Plugin::$instance->documents->get( $this->post_id_for_data ); return $document ? $document->get_elements_data() : []; } /** * @since 2.0.13 * @access public */ public function get_meta( $property = null ) { // Parse CSS first, to get the fonts list. $css = $this->get_content(); $meta = [ 'status' => $css ? self::CSS_STATUS_INLINE : self::CSS_STATUS_EMPTY, 'fonts' => $this->get_fonts(), 'css' => $css, ]; if ( $property ) { return isset( $meta[ $property ] ) ? $meta[ $property ] : null; } return $meta; } /** * @since 2.0.13 * @access public */ public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, array $all_controls = null ) { $dynamic_settings = $controls_stack->get_settings( '__dynamic__' ); if ( ! empty( $dynamic_settings ) ) { $controls = array_intersect_key( $controls, $dynamic_settings ); $all_controls = $controls_stack->get_controls(); $parsed_dynamic_settings = $controls_stack->parse_dynamic_settings( $values, $controls ); foreach ( $controls as $control ) { if ( ! empty( $control['style_fields'] ) ) { $this->add_repeater_control_style_rules( $controls_stack, $control, $values[ $control['name'] ], $placeholders, $replacements ); } if ( empty( $control['selectors'] ) ) { continue; } $this->add_control_style_rules( $control, $parsed_dynamic_settings, $all_controls, $placeholders, $replacements ); } } if ( $controls_stack instanceof Element_Base ) { foreach ( $controls_stack->get_children() as $child_element ) { $this->render_styles( $child_element ); } } } } PKo<Ð\rMû͇‡ base-tag.phpnuW+A„¶print_panel_template(); $panel_template = ob_get_clean(); return [ 'name' => $this->get_name(), 'title' => $this->get_title(), 'panel_template' => $panel_template, 'categories' => $this->get_categories(), 'group' => $this->get_group(), 'controls' => $this->get_controls(), 'content_type' => $this->get_content_type(), 'settings_required' => $this->is_settings_required(), 'editable' => $this->is_editable(), ]; } /** * @since 2.0.0 * @access public */ public function print_panel_template() { $panel_template_setting_key = $this->get_panel_template_setting_key(); if ( ! $panel_template_setting_key ) { return; } ?><# var key = ; if ( key ) { var settingsKey = ""; /* * If the tag has controls, * and key is an existing control (and not an old one), * and the control has options (select/select2), * and the key is an existing option (and not in a group or an old one). */ if ( controls && controls[settingsKey] ) { var controlSettings = controls[settingsKey]; if ( controlSettings.options && controlSettings.options[ key ] ) { key = controlSettings.options[ key ]; } else if ( controlSettings.groups ) { var label = _.filter( _.pluck( _.pluck( controls.key.groups, 'options' ), key ) ); if ( label[0] ) { key = label[0]; } } } print( '(' + key + ')' ); } #> get_name(); } /** * @since 2.0.0 * @access protected */ protected function register_advanced_section() {} /** * @since 2.0.0 * @access protected */ final protected function init_controls() { Plugin::$instance->controls_manager->open_stack( $this ); $this->start_controls_section( 'settings', [ 'label' => __( 'Settings', 'elementor' ), ] ); $this->_register_controls(); $this->end_controls_section(); // If in fact no controls were registered, empty the stack if ( 1 === count( Plugin::$instance->controls_manager->get_stacks( $this->get_unique_name() )['controls'] ) ) { Plugin::$instance->controls_manager->open_stack( $this ); } $this->register_advanced_section(); } } PKi"Ð\Fqx x module.phpnuW+A„¶PKo<Ð\d@##² tag.phpnuW+A„¶PKo<Ð\lÓSóó  data-tag.phpnuW+A„¶PKo<Ð\†E¹ž(ž( ;manager.phpnuW+A„¶PKo<Ð\Õ_YÒ Ò @dynamic-css.phpnuW+A„¶PKo<Ð\rMû͇‡ %Kbase-tag.phpnuW+A„¶PKÃèY