| 1 |
<?php |
| 2 |
/** |
| 3 |
* Metabox Functions |
| 4 |
* |
| 5 |
* @package Give |
| 6 |
* @subpackage Admin/Forms |
| 7 |
* @copyright Copyright (c) 2016, GiveWP |
| 8 |
* @license https://opensource.org/licenses/gpl-license GNU Public License |
| 9 |
* @since 1.0 |
| 10 |
*/ |
| 11 |
|
| 12 |
// Exit if accessed directly. |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
/** |
| 19 |
* Add Shortcode Copy Field to Publish Metabox |
| 20 |
* |
| 21 |
* @since: 1.0 |
| 22 |
*/ |
| 23 |
function give_add_shortcode_to_publish_metabox() { |
| 24 |
|
| 25 |
if ( 'give_forms' !== get_post_type() ) { |
| 26 |
return false; |
| 27 |
} |
| 28 |
global $post; |
| 29 |
|
| 30 |
// Only enqueue scripts for CPT on post type screen |
| 31 |
if ( 'give_forms' === $post->post_type ) { |
| 32 |
// Shortcode column with select all input |
| 33 |
$shortcode = sprintf( '[give_form id="%s"]', absint( $post->ID ) ); |
| 34 |
printf( |
| 35 |
'<div class="misc-pub-section"><button type="button" class="button hint-tooltip hint--top js-give-shortcode-button" aria-label="%1$s" data-give-shortcode="%2$s"><span class="dashicons dashicons-admin-page"></span> %3$s</button></div>', |
| 36 |
esc_attr( $shortcode ), |
| 37 |
esc_attr( $shortcode ), |
| 38 |
esc_html__( 'Copy Shortcode', 'give' ) |
| 39 |
); |
| 40 |
} |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
add_action( 'post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox' ); |
| 45 |
|