RTMediaComment::comment_nonce_generator PHP Method

comment_nonce_generator() static public method

static public comment_nonce_generator ( $echo = true )
    static function comment_nonce_generator($echo = true)
    {
        if ($echo) {
            wp_nonce_field('rtmedia_comment_nonce', 'rtmedia_comment_nonce');
        } else {
            $token = array('action' => 'rtmedia_comment_nonce', 'nonce' => wp_create_nonce('rtmedia_comment_nonce'));
            return wp_json_encode($token);
        }
    }

Usage Example

function rtmedia_comment_form()
{
    if (is_user_logged_in()) {
        ?>
		<form method="post" id="rt_media_comment_form" class="rt_media_comment_form"
			  action="<?php 
        echo esc_url(get_rtmedia_permalink(rtmedia_id()));
        ?>
comment/">

			<textarea style="width:100%" placeholder="<?php 
        _e('Type Comment...', 'rtmedia');
        ?>
" name="comment_content" id="comment_content"></textarea>
			<input type="submit" id="rt_media_comment_submit" class="rt_media_comment_submit" value="<?php 
        _e('Comment', 'rtmedia');
        ?>
">

			<?php 
        RTMediaComment::comment_nonce_generator();
        ?>
		</form>
		<?php 
    }
}