| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | defined('ABSPATH') or die('Jog on!'); |
| 4 | 4 | |
| 5 | 5 | function sh_cd_pages_your_shortcodes_edit( $action = 'add' ) { |
| 6 | 6 | |
| 7 | - if ( false === in_array( $action, [ 'add', 'edit', 'save' ] ) ) { | |
| 7 | + if ( false === in_array( $action, [ 'add', 'edit', 'save' ] ) ) { | |
| 8 | 8 | return; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | if ( false === current_user_can( 'manage_options' ) ) { |
| @@ -11,8 +11,10 @@ | ||
| 11 | 11 | if ( false === current_user_can( 'manage_options' ) ) { |
| 12 | 12 | wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | + $save_result = false; | |
| 16 | + | |
| 15 | 17 | // Saving / Inserting a shortcode? |
| 16 | 18 | if ( $action == 'save' ) { |
| 17 | 19 | |
| 18 | 20 | $save_result = sh_cd_shortcodes_save_post(); |
| @@ -20,13 +22,14 @@ | ||
| 20 | 22 | $message = ( true === $save_result ) ? 'Your shortcode has been saved!' : 'There was an error saving your shortcode!'; |
| 21 | 23 | |
| 22 | 24 | sh_cd_message_display( $message, ! $save_result ); |
| 23 | 25 | } |
| 26 | + global $wpdb; | |
| 24 | 27 | |
| 25 | 28 | // Load |
| 26 | 29 | $shortcode = ( false === empty( $_GET['id'] ) ) ? |
| 27 | 30 | sh_cd_db_shortcodes_by_id( (int) $_GET['id'] ) : |
| 28 | - sh_cd_get_values_from_post( [ 'id', 'slug', 'data', 'disabled' ] ); | |
| 31 | + sh_cd_get_values_from_post( [ 'id', 'slug', 'previous_slug', 'data', 'disabled', 'multisite' ] ); | |
| 29 | 32 | |
| 30 | 33 | $shortcode['data'] = stripslashes( $shortcode['data'] ); |
| 31 | 34 | |
| 32 | 35 | ?> |
| @@ -53,16 +56,21 @@ | ||
| 53 | 56 | <input type="hidden" id="id" name="id" value="<?php echo esc_attr( $shortcode['id'] ); ?>" /> |
| 54 | 57 | <h4>Slug</h4> |
| 55 | 58 | <p><small>Specify the unique identifier for this shortcode.</small></p> |
| 56 | 59 | <input type="text" required class="regular-text" size="100" id="slug" name="slug" |
| 57 | - <?php echo ( ('edit' === $action) ? ' disabled' : ''); ?> placeholder="Slug" | |
| 60 | + placeholder="Slug" | |
| 58 | 61 | value="<?php echo esc_attr( $shortcode['slug'] )?>" /> |
| 59 | - <?php if ('edit' == $action): ?> | |
| 60 | - <p><small>Note: You can not edit a slug name. Editing a slug name may cause issues throughout your site. Please delete this shortcode and create another.</small></p> | |
| 61 | - <?php endif; ?> | |
| 62 | + <?php | |
| 63 | + | |
| 64 | + $previous_slug = ( false === empty( $shortcode['previous_slug'] ) ) ? $shortcode['previous_slug'] : $shortcode['slug']; | |
| 65 | + | |
| 66 | + ?> | |
| 67 | + <input type="hidden" id="previous_slug" name="previous_slug" value="<?php echo esc_attr( $previous_slug )?>" /> | |
| 68 | + | |
| 62 | 69 | <h4>Shortcode content</h4> |
| 63 | 70 | <p><small>Specify the text, HTML, media, data, etc that should be rendered wherever the shortcode is placed.</small></p> |
| 64 | 71 | <?php wp_editor( $shortcode['data'], 'data', [ 'textarea_name' => 'data' ] ); ?> |
| 72 | + | |
| 65 | 73 | <h4>Disable?</h4> |
| 66 | 74 | <p>If disabled, nothing will be rendered where the shortcode has been placed.</p> |
| 67 | 75 | <select id="disabled" name="disabled"> |
| 68 | 76 | <option value="0" <?php selected( $shortcode['disabled'], 0 ); ?>>No</option> |
| @@ -67,8 +75,25 @@ | ||
| 67 | 75 | <select id="disabled" name="disabled"> |
| 68 | 76 | <option value="0" <?php selected( $shortcode['disabled'], 0 ); ?>>No</option> |
| 69 | 77 | <option value="1" <?php selected( $shortcode['disabled'], 1 ); ?>>Yes</option> |
| 70 | 78 | </select> |
| 79 | + | |
| 80 | + <h4>Global?</h4> | |
| 81 | + | |
| 82 | + <p>Can this be used by all sites within your multi-site? If Yes, your shortcode will be promoted so it can be used across your entire multi site. Please note, shortcode slugs are not unique across a multi site. Therefore, if you have two Global shortcodes with the same slug, the shortcode created or updated most recently shall be the one rendered. It is best practice to give all Global shortcodes a unique slug. A Global shortcode with always be displayed before a local shortcode with the same slug. Upon saving, it may take a Global shortcode upto 30 seconds to update across all your sites.</p> | |
| 83 | + <select id="multisite" name="multisite" <?php if ( false === sh_cd_license_is_premium() ) { echo 'disabled="disabled"'; } ?>> | |
| 84 | + <option value="0" <?php selected( $shortcode['multisite'], 0 ); ?>>No</option> | |
| 85 | + <option value="1" <?php selected( $shortcode['multisite'], 1 ); ?>>Yes</option> | |
| 86 | + </select> | |
| 87 | + <?php if ( false === sh_cd_license_is_premium() ) : ?> | |
| 88 | + <p> | |
| 89 | + <i class="far fa-credit-card"></i> | |
| 90 | + <a href="<?php echo sh_cd_license_upgrade_link(); ?>"> | |
| 91 | + Multi site support is for Premium users. Upgrade now. | |
| 92 | + </a> | |
| 93 | + </p> | |
| 94 | + <?php endif; ?> | |
| 95 | + | |
| 71 | 96 | <div class="sh-cd-button-row"> |
| 72 | 97 | <a class="comment-submit button" href="<?php echo sh_cd_link_your_shortcodes(); ?>">Cancel</a> |
| 73 | 98 | <input name="submit_button" type="submit" value="Save Shortcode" class="comment-submit button button-primary"> |
| 74 | 99 | </div> |