I don't know if this is the right way to go about this, but we noticed that the 1.8.0 update broke our custom elements and we believe the root of it is because of the explicit model update and the check for tailor:tailor_[element] inside of class-models.php.
There are couple things to note for our usage of Tailor:
We apply the filter add_filter( 'tailor_save_content_as_html', '__return_false' ); in order to make sure that the post_content stores the shortcodes as apposed to the rendered HTML.
We namespace our components ss_[element] (for Sprout Social) which has always worked since we've started to use Tailor. Heres some example code for our plugin:
then initializing inside of our tailor-sprout-components.php:
protected function add_actions() {
// Load element definitions
add_action( 'tailor_load_elements', array( $this, 'load_elements' ), 20 );
// Register custom elements
add_action( 'tailor_register_elements', array( $this, 'register_elements' ), 99 );
}
/**
* Loads and registers the new Tailor elements and shortcodes.
*/
public function load_elements() {
require_once $this->plugin_dir() . 'components/class-avatar.php';
}
/**
* Loads and registers the new Tailor elements and shortcodes.
*
* @param $element_manager Tailor_Elements
*/
public function register_elements( $element_manager ) {
$element_manager->add_element( 'ss_avatar', array(
'label' => __( 'Avatar' ),
'description' => __( '' ),
'badge' => __( 'Sprout' ),
'type' => 'content',
) );
}
Without the proposed changes we noticed that the canvas isn't rendering anything:
But with the changes we see that it actually runs the generate_models_from_html function:
This PR does not break any existing default Tailor components and will continue let us use our namespaced elements, I'd love to be able to update all of our custom elements to be tailor_[our element] but we have 300 pages already built with our existing components and don't want to break those.
Do let me know if this makes sense, or if you need more clarification. We have a very odd way of using Tailor, haha.
I don't know if this is the right way to go about this, but we noticed that the 1.8.0 update broke our custom elements and we believe the root of it is because of the explicit model update and the check for
tailor:tailor_[element]
inside ofclass-models.php
.There are couple things to note for our usage of Tailor:
We apply the filter
add_filter( 'tailor_save_content_as_html', '__return_false' );
in order to make sure that the post_content stores the shortcodes as apposed to the rendered HTML.We namespace our components
ss_[element]
(for Sprout Social) which has always worked since we've started to use Tailor. Heres some example code for our plugin:class-avatar.php
then initializing inside of our
tailor-sprout-components.php
:Without the proposed changes we noticed that the canvas isn't rendering anything:
But with the changes we see that it actually runs the
generate_models_from_html
function:This PR does not break any existing default Tailor components and will continue let us use our namespaced elements, I'd love to be able to update all of our custom elements to be
tailor_[our element]
but we have 300 pages already built with our existing components and don't want to break those.Do let me know if this makes sense, or if you need more clarification. We have a very odd way of using Tailor, haha.