Skip to content

Commit

Permalink
Add secret to shortcode hint.
Browse files Browse the repository at this point in the history
  • Loading branch information
doekenorg committed Feb 6, 2024
1 parent 92ba666 commit 2a7f903
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions includes/admin/metaboxes/views/shortcode-hint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@
*/

global $post;

$view = \GV\View::from_post( $post );
$secret = $view->get_validation_secret();
$atts = [ sprintf( "id='%d'", $post->ID ) ];
if ( $secret ) {
$atts[] = sprintf( "secret='%s'", $secret );
}

$shortcode = sprintf( '[gravityview %s]', implode( ' ', $atts ) );
?>
<div class="misc-pub-section gv-shortcode misc-pub-section-last">
<i class="dashicons dashicons-editor-code"></i>
<span><?php esc_html_e( 'Embed Shortcode', 'gk-gravityview' ); ?></span>
<div>
<input type="text" readonly="readonly" value="[gravityview id='<?php echo $post->ID; ?>']" class="code widefat" />
<input type="text" readonly="readonly" value="<?php echo esc_attr($shortcode) ?>" class="code widefat" />
<span class="howto"><?php esc_html_e( 'Add this shortcode to a post or page to embed this view.', 'gk-gravityview' ); ?></span>
</div>
</div>
</div>

0 comments on commit 2a7f903

Please sign in to comment.