PHP Integration - Get Data From PHP

You can integrate PHP in the widget editor, and get data from PHP snippet.

This functionality is available in the PRO version of the plugin.

For that you can press on "Code Examples" at the bottom of the page, and see the code example at the right panel.

And all the examples will appear here: 

So in twig side you call this function: {% set myData = apply_filters('get_my_data')  %}

After that you can call "showData" function in the editor for showing the actual data you get from PHP. 


So this is the simple code example you put in widget editor:

{% set myData = apply_filters('get_my_data') %}

In the PHP side you put this code: 
//get my custom data into widget editor
function getMyData(){
	$arrData = array();
	$arrData["name"] = "John";
	$arrData["family"] = "Smith";

add_filter( 'get_my_data', 'getMyData', 10, 3 );
Do preview widget and you should see this: 

You can pass parameters into the filter, like some attribute that you created. To pass parameters you write this in editor and PHP: 
{% set myData = apply_filters('get_my_data', name) %}
and in PHP you write this: 
function getMyData($name){
And you can use this parameter in your PHP function. 
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.