diff --git a/includes/class-elements.php b/includes/class-elements.php index 3374def..c2eb3a3 100644 --- a/includes/class-elements.php +++ b/includes/class-elements.php @@ -336,9 +336,42 @@ public function add_element( $tag, $args = array() ) { if ( isset( $element ) ) { $this->elements[ $element->tag ] = $element; + $this->register_shortcode_if_not_exists( $tag ); } } + /** + * Create shortcode if it doesn't exists, based on element tag. + * + * @access public + * + * @param string $tag + * + * @return array + */ + public function register_shortcode_if_not_exists( $tag ) { + global $shortcode_tags; + + if ( ! array_key_exists( $tag, $shortcode_tags ) ) { + add_shortcode( $tag, array( $this, 'print_element_shortcode') ); + } + } + + /** + * Render the shortcode. + * + * @access public + * + * @param array $atts + * @param string $content + * @param string $tag + * + * @return array + */ + public function print_element_shortcode( $atts, $content = '', $tag ) { + return apply_filters( "tailor_render_element_shortcode_{$tag}", '', $atts, $content ); + } + /** * Returns the registered elements. * diff --git a/includes/class-models.php b/includes/class-models.php index 8942c85..8ca2b4e 100644 --- a/includes/class-models.php +++ b/includes/class-models.php @@ -881,7 +881,7 @@ public function print_models() { public function generate_element_regex() { $element_types = array(); foreach ( tailor_elements()->get_elements() as $element ) { - $element_types[] = str_replace( 'tailor_', '', $element->tag ); + $element_types[] = $element->tag; } $this->regex = sprintf( "/