metabox.php
41 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Metabox Functions |
| 4 | * |
| 5 | * @package Give |
| 6 | * @subpackage Admin/Forms |
| 7 | * @copyright Copyright (c) 2016, WordImpress |
| 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 = htmlentities( '[give_form id="' . $post->ID . '"]' ); |
| 34 | echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">' . esc_html__( 'Give Form Shortcode:', 'give' ) . '</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="' . $shortcode . '"></div>'; |
| 35 | |
| 36 | } |
| 37 | |
| 38 | } |
| 39 | |
| 40 | add_action( 'post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox' ); |
| 41 |