Commit b98eed15 authored by Kyle B. Johnson's avatar Kyle B. Johnson Committed by Kevin Stover

Add new merge tags (#1658)

* add new merge tags. Closes #1645.

* Added is_object check to post_author and post_author_email methods.
parent dd1b1813
......@@ -41,4 +41,30 @@ return apply_filters( 'ninja_forms_merge_tags_post', array(
'callback' => 'post_url'
),
/*
|--------------------------------------------------------------------------
| Post Author
|--------------------------------------------------------------------------
*/
'author' => array(
'id' => 'author',
'tag' => '{post:author}',
'label' => __( 'Post Author', 'ninja_forms' ),
'callback' => 'post_author'
),
/*
|--------------------------------------------------------------------------
| Post Author Email
|--------------------------------------------------------------------------
*/
'author_email' => array(
'id' => 'author_email',
'tag' => '{post:author_email}',
'label' => __( 'Post Author Email', 'ninja_forms' ),
'callback' => 'post_author_email'
),
));
\ No newline at end of file
......@@ -41,4 +41,30 @@ return apply_filters( 'ninja_forms_merge_tags_system', array(
'callback' => 'system_ip'
),
/*
|--------------------------------------------------------------------------
| Site Title
|--------------------------------------------------------------------------
*/
'site_title' => array(
'id' => 'site_title',
'tag' => '{site:title}',
'label' => __( 'Site Title', 'ninja_forms' ),
'callback' => 'site_title'
),
/*
|--------------------------------------------------------------------------
| Site URL
|--------------------------------------------------------------------------
*/
'site_url' => array(
'id' => 'site_url',
'tag' => '{site:url}',
'label' => __( 'Site URL', 'ninja_forms' ),
'callback' => 'site_url'
),
));
\ No newline at end of file
......@@ -32,4 +32,20 @@ final class NF_MergeTags_Post extends NF_Abstracts_MergeTags
return ( is_object ( $post ) ) ? get_permalink( $post->ID ) : '';
}
protected function post_author()
{
global $post;
if( ! is_object( $post ) ) return;
$author = get_user_by('id', $post->post_author);
return $author->display_name;
}
protected function post_author_email()
{
global $post;
if( ! is_object( $post ) ) return;
$author = get_user_by( 'id', $post->post_author );
return $author->user_email;
}
} // END CLASS NF_MergeTags_System
......@@ -44,4 +44,14 @@ final class NF_MergeTags_System extends NF_Abstracts_MergeTags
return get_option( 'admin_email' );
}
protected function site_title()
{
return get_bloginfo( 'name' );
}
protected function site_url()
{
return get_bloginfo( 'url' );
}
} // END CLASS NF_MergeTags_System
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment