arbron
New Member
I have created a global settings page in which I write telephone number, email, city and other company data and I would like this data to be visible throughout the page simply by filling in the data on this settings page. For this I have also created custom dynamic tags so that the data from the options page comes up on a list in the footer and header for example.
I'm missing the final part of the code and don't know how to complete it to make the data pop up on the dynamic tags.
How do I do this?
...
public function render() {
$value = $this->get_settings( 'kb_theme_options' );
if ( ! $value ) {
return;
}
if ( ! isset( $_SERVER[ $value ] ) ) {
return;
}
$value = $_SERVER[ $value ];
echo wp_kses_post( $value );
}
}
$dynamic_tags->register_tag( 'Custom_ACF_Avg_Tag' );
} );
Complete code here:
// custom Custom_Avg_Tag dynamic tag
add_action( 'elementor/dynamic_tags/register_tags', function( $dynamic_tags ) {
class Custom_ACF_Avg_Tag extends \Elementor\Core\DynamicTags\Tag {
public function get_name() {
return 'Custom_ACF_Avg_Tag';
}
public function get_categories() {
return [ 'text' ];
}
public function get_group() {
return [ 'site' ];
}
public function get_title() {
return 'ACF Average';
}
protected function _register_controls() {
$this->add_control(
'fields',
[
'label' => __( 'Fields', 'text-domain' ),
'type' => 'text',
]
);
}
public function render() {
$value = $this->get_settings( 'kb_theme_options' );
if ( ! $value ) {
return;
}
if ( ! isset( $_SERVER[ $value ] ) ) {
return;
}
$value = $_SERVER[ $value ];
echo wp_kses_post( $value );
}
}
$dynamic_tags->register_tag( 'Custom_ACF_Avg_Tag' );
} );
I'm missing the final part of the code and don't know how to complete it to make the data pop up on the dynamic tags.
How do I do this?
...
public function render() {
$value = $this->get_settings( 'kb_theme_options' );
if ( ! $value ) {
return;
}
if ( ! isset( $_SERVER[ $value ] ) ) {
return;
}
$value = $_SERVER[ $value ];
echo wp_kses_post( $value );
}
}
$dynamic_tags->register_tag( 'Custom_ACF_Avg_Tag' );
} );
Complete code here:
// custom Custom_Avg_Tag dynamic tag
add_action( 'elementor/dynamic_tags/register_tags', function( $dynamic_tags ) {
class Custom_ACF_Avg_Tag extends \Elementor\Core\DynamicTags\Tag {
public function get_name() {
return 'Custom_ACF_Avg_Tag';
}
public function get_categories() {
return [ 'text' ];
}
public function get_group() {
return [ 'site' ];
}
public function get_title() {
return 'ACF Average';
}
protected function _register_controls() {
$this->add_control(
'fields',
[
'label' => __( 'Fields', 'text-domain' ),
'type' => 'text',
]
);
}
public function render() {
$value = $this->get_settings( 'kb_theme_options' );
if ( ! $value ) {
return;
}
if ( ! isset( $_SERVER[ $value ] ) ) {
return;
}
$value = $_SERVER[ $value ];
echo wp_kses_post( $value );
}
}
$dynamic_tags->register_tag( 'Custom_ACF_Avg_Tag' );
} );