Skip to content

Added filter for content in Element_Base#6433

Closed
thenovacreator wants to merge 3 commits intoelementor:release/2.4.0from
thenovacreator:master
Closed

Added filter for content in Element_Base#6433
thenovacreator wants to merge 3 commits intoelementor:release/2.4.0from
thenovacreator:master

Conversation

@thenovacreator
Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

What kind of change does this PR introduce?

  • Feature

Summary

This PR can be summarized in the following changelog entry:

  • Added render content filter for childs of Base_Element using print_element (e.x. Section / Column)

Description

An explanation of what is done in this PR

  • Added render content filter for childs of Base_Element using print_element

Test instructions

This PR can be tested by following these steps:

  • Use the filter "elementor/{$element_type}/render_content" for e.x. a section to manipulate its content

Quality assurance

@thenovacreator
Copy link
Copy Markdown
Contributor Author

We need this to implement a cache buster for our "splittest for elementor" plugin.

@ramiy
Copy link
Copy Markdown
Contributor

ramiy commented Dec 18, 2018

@thenovacreator The correct syntax should be:

/**
 * Render element content.
 *
 * Fires when Elementor renders the element content.
 *
 * The dynamic portion of the hook name, `$element_type`, refers to the element type.
 *
 * @since 1.0.0
 *
 * @param string $content The content of the element.
 * @param Element_Base $this The element.
 */
$content = apply_filters( "elementor/{$element_type}/render_content", $content, $this );
echo $content;

You should apply filter on the variable you are filtering.

Also, it would be better to move this filter to line 663, where you define the $content.

@thenovacreator
Copy link
Copy Markdown
Contributor Author

thenovacreator commented Dec 19, 2018

Do you recommend it like this?

@ramiy ramiy mentioned this pull request Dec 27, 2018
12 tasks
@thenovacreator
Copy link
Copy Markdown
Contributor Author

What about this to be merged?

@shilo-ey shilo-ey requested review from KingYes and bainternet April 1, 2019 15:20
@thenovacreator
Copy link
Copy Markdown
Contributor Author

thenovacreator commented Apr 25, 2019

Is there something new going on here? Wo really need this as it stops us from developing your plugins further.

@HandyGadget
Copy link
Copy Markdown

+1 -- without this is not possible to exclude test content from the site's caching

@hosting-io
Copy link
Copy Markdown

+1 - without this, the plugin is almost useless for most sites that are interested in performance as well as marketing. Almost all users that are looking at A/B testing will have some sort of caching in place i would guess

@hsk-it
Copy link
Copy Markdown

hsk-it commented May 13, 2019

Would love this, too!
+1 here!

@WebZenStudio
Copy link
Copy Markdown

+1 Have been waiting forever for there to be a split testing option for Elementor. I have been using Thrive Themes specifically because of their A / B split testing functionality. I was thrilled to see a plugin for split testing with Elementor... and then disappointed that it won't work with WP Rocket or other caching plugins enabled. Disabling caching is not an option. Looking forward to being able to split test with Elementor.

@backpackerstoday
Copy link
Copy Markdown

+1 Please Elementor Team, make our lifes even easier..

@KingYes KingYes removed their request for review July 8, 2019 06:45
@KingYes KingYes closed this Jul 18, 2019
@thenovacreator
Copy link
Copy Markdown
Contributor Author

thenovacreator commented Jul 18, 2019

I can not understand how things went here. Except of the syntax correction there were almost no comments of the elementor team here. In contrast to the other users posting here that they would love to have this. And then without any comment or hint for a solution (how ever this solution could look like) and any word about why this request is closed it is closed.

That is really sad because without this we have really big issues to develop our plugin further. We may stop developing it since really useful features would be depend on this and without that ... well what should we develop. And do not think that we did not care about this. But instead of bugging we think that the users voices in here would be enough.

@HandyGadget
Copy link
Copy Markdown

It could be that just nobody noticed or, more likely, they want to save the solution for themselves, and rather than help you, end up as your competitor. I don't know this is true, its just an idea, so just saying what I think might be what's happening.

@RichardUUU
Copy link
Copy Markdown

I'm also interested in seeing this implemented.

@hsk-it
Copy link
Copy Markdown

hsk-it commented Jul 19, 2019

We really need this to be implemented, too.
Closing this topic is not the right way to work on this feature.
Really disappointed at this moment.
Please rethink this point.

@bainternet
Copy link
Copy Markdown
Contributor

@hsk-it commented on Jul 19, 2019, 10:30 PM GMT+3:

We really need this to be implemented, too.
Closing this topic is not the right way to work on this feature.
Really disappointed at this moment.
Please rethink this point.

@RichardUUU commented on Jul 19, 2019, 10:21 PM GMT+3:

I'm also interested in seeing this implemented.

@TerenceMilbourn commented on Jul 19, 2019, 4:17 PM GMT+3:

It could be that just nobody noticed or, more likely, they want to save the solution for themselves, and rather than help you, end up as your competitor. I don't know this is true, its just an idea, so just saying what I think might be what's happening.

@thenovacreator commented on Jul 19, 2019, 12:56 AM GMT+3:

I can not understand how things went here. Except of the syntax correction there were almost no comments of the elementor team here. In contrast to the other users posting here that they would love to have this. And then without any comment or hint for a solution (how ever this solution could look like) and any word about why this request is closed it is closed.

That is really sad because without this we have really big issues to develop our plugin further. We may stop developing it since really useful features would be depend on this and without that ... well what should we develop. And do not think that we did not care about this. But instead of bugging we think that the users voices in here would be enough.

@backpackerstoday commented on Jul 6, 2019, 2:12 PM GMT+3:

+1 Please Elementor Team, make our lifes even easier..

@WebZenStudio commented on Jun 28, 2019, 8:59 PM GMT+3:

+1 Have been waiting forever for there to be a split testing option for Elementor. I have been using Thrive Themes specifically because of their A / B split testing functionality. I was thrilled to see a plugin for split testing with Elementor... and then disappointed that it won't work with WP Rocket or other caching plugins enabled. Disabling caching is not an option. Looking forward to being able to split test with Elementor.

Hi everyone,

This was closed via External Software, hence the lack of explanation, but not by accident. We closed this Mainly for the performance and resources hit it would cause passing each and every element ( section, column, widget) output via a filter.

Also, there are already hooks in place that allow manipulating the output:

/**
* Before frontend element render.
*
* Fires before Elementor element is rendered in the frontend.
*
* @since 2.2.0
*
* @param Element_Base $this The element.
*/
do_action( 'elementor/frontend/before_render', $this );

/**
* Before frontend element render.
*
* Fires before Elementor element is rendered in the frontend.
*
* The dynamic portion of the hook name, `$element_type`, refers to the element type.
*
* @since 1.0.0
*
* @param Element_Base $this The element.
*/
do_action( "elementor/frontend/{$element_type}/before_render", $this );

/**
* After frontend element render.
*
* Fires after Elementor element is rendered in the frontend.
*
* The dynamic portion of the hook name, `$element_type`, refers to the element type.
*
* @since 1.0.0
*
* @param Element_Base $this The element.
*/
do_action( "elementor/frontend/{$element_type}/after_render", $this );

/**
* After frontend element render.
*
* Fires after Elementor element is rendered in the frontend.
*
* @since 2.3.0
*
* @param Element_Base $this The element.
*/
do_action( 'elementor/frontend/after_render', $this );

@thenovacreator
Copy link
Copy Markdown
Contributor Author

thenovacreator commented Nov 23, 2019

@bainternet

Thanks for the comment. The inital Problem is that all the hooks you are presenting here are not working for this case. I need to manipulate the html content directly.

So now i have to use the "elementor/frontend/section/should_render" event and this code


if ($element->get_name() != "section") {
	return true;
}

if ($globalRenderingSection) {
	return true;
}

$globalRenderingSection = true;
ob_start();
$element->print_element();
$content = ob_get_contents();
ob_end_clean();

echo $this->cacheBuster->renderContent($content, $element);

$globalRenderingSection = false;

return false;

To get things working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants