Skip to content

Instantly share code, notes, and snippets.

@klhall1987
Created August 22, 2018 18:04
Show Gist options
  • Save klhall1987/48c63fb244f074bb2638dc55c2d7a908 to your computer and use it in GitHub Desktop.
Save klhall1987/48c63fb244f074bb2638dc55c2d7a908 to your computer and use it in GitHub Desktop.
Merge tag class with callback
<?php if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Class NF_MergeTagExample_MergeTags
*/
final class NF_MergeTagExample_MergeTags extends NF_Abstracts_MergeTags
{
protected $id = 'mergetag-example';
public function __construct()
{
parent::__construct();
$this->title = __( 'Merge Tag Example', 'ninja-forms-mergetag-example' );
$this->merge_tags = NF_MergeTagExample()->config( 'MergeTags' );
}
/**
* Example Tag Callback
*
* This is the call back method for our merge tag set in our config array.
*
* @return string
*/
public function example_tag()
{
// Do stuff
return __( 'Example Text', 'ninja-forms-mergetag-example' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment