| @@ -48,18 +48,16 @@ | ||
| 48 | 48 | * @return bool |
| 49 | 49 | */ |
| 50 | 50 | function sh_cd_shortcodes_save_post() { |
| 51 | 51 | |
| 52 | - $fields = apply_filters( 'sh-cd-post-field-keys', [ 'id', 'slug', 'previous_slug', 'data', 'disabled', 'multisite', 'editor' ] ); | |
| 53 | - | |
| 54 | 52 | // Capture the raw $_POST fields, the save functions will process and validate the data |
| 55 | - $shortcode = sh_cd_get_values_from_post( $fields ); | |
| 53 | + $shortcode = sh_cd_get_values_from_post( [ 'id', 'slug', 'previous_slug', 'data', 'disabled', 'multisite', 'editor' ] ); | |
| 56 | 54 | |
| 57 | 55 | // If we are not premium, then the user is not allowed to change the site slug (otherwise they could just re-use variables and by pass the limit) |
| 58 | 56 | if ( ! sh_cd_is_premium() && false === empty( $shortcode[ 'previous_slug' ] ) ) { |
| 59 | 57 | $shortcode[ 'slug' ] = $shortcode[ 'previous_slug' ]; |
| 60 | 58 | } |
| 61 | - | |
| 59 | + | |
| 62 | 60 | return sh_cd_db_shortcodes_save( $shortcode ); |
| 63 | 61 | } |
| 64 | 62 | |
| 65 | 63 | /** |
| @@ -189,10 +187,8 @@ | ||
| 189 | 187 | |
| 190 | 188 | $key = sh_cd_cache_generate_key( $key ); |
| 191 | 189 | |
| 192 | 190 | set_transient( $key, $data, $expire ); |
| 193 | - | |
| 194 | - do_action( 'sh-cd-global-cache-delete' ); | |
| 195 | 191 | } |
| 196 | 192 | |
| 197 | 193 | /** |
| 198 | 194 | * Delete cache for given shortcode slug / ID |
| @@ -224,20 +220,15 @@ | ||
| 224 | 220 | * @param $key |
| 225 | 221 | * |
| 226 | 222 | * @return mixed |
| 227 | 223 | */ |
| 228 | -function sh_cd_cache_delete( $key, $trigger_global_hook = true ) { | |
| 224 | +function sh_cd_cache_delete( $key ) { | |
| 229 | 225 | |
| 230 | 226 | $key = sh_cd_cache_generate_key( $key ); |
| 231 | 227 | |
| 232 | - if ( true === $trigger_global_hook ) { | |
| 233 | - do_action( 'sh-cd-global-cache-delete' ); | |
| 234 | - } | |
| 235 | - | |
| 236 | 228 | return delete_transient( $key ); |
| 237 | 229 | } |
| 238 | 230 | |
| 239 | - | |
| 240 | 231 | /** |
| 241 | 232 | * Generate cache key |
| 242 | 233 | * |
| 243 | 234 | * @param $key |
| @@ -284,8 +275,21 @@ | ||
| 284 | 275 | return esc_url( $link ); |
| 285 | 276 | } |
| 286 | 277 | |
| 287 | 278 | /** |
| 279 | + * Return link to delete own shortcode | |
| 280 | + * | |
| 281 | + * @param $id | |
| 282 | + * @return mixed | |
| 283 | + */ | |
| 284 | +function sh_cd_link_your_shortcodes_delete( $id ) { | |
| 285 | + | |
| 286 | + $link = admin_url('admin.php?page=sh-cd-shortcode-variables-your-shortcodes&action=delete&id=' . (int) $id ); | |
| 287 | + | |
| 288 | + return esc_url( $link ); | |
| 289 | +} | |
| 290 | + | |
| 291 | +/** | |
| 288 | 292 | * Either fetch data from the $_POST object or from the array passed in! |
| 289 | 293 | * |
| 290 | 294 | * @param $object |
| 291 | 295 | * @param $key |
| @@ -419,12 +423,8 @@ | ||
| 419 | 423 | * @return bool |
| 420 | 424 | */ |
| 421 | 425 | function sh_cd_is_multisite_enabled() { |
| 422 | 426 | |
| 423 | - if ( true === defined( 'YK_TEST_IS_MULTISITE' ) && true === YK_TEST_IS_MULTISITE ) { | |
| 424 | - return true; | |
| 425 | - } | |
| 426 | - | |
| 427 | 427 | if ( false === is_multisite() ) { |
| 428 | 428 | return false; |
| 429 | 429 | } |
| 430 | 430 | |
| @@ -540,21 +540,19 @@ | ||
| 540 | 540 | * Display upgrade notice |
| 541 | 541 | * |
| 542 | 542 | * @param bool $pro_plus |
| 543 | 543 | */ |
| 544 | -function sh_cd_display_pro_upgrade_notice( $title = NULL, $content = '', $class = '' ) { | |
| 545 | - | |
| 546 | - $title = ( true === empty( $title ) ) ? __( 'Upgrade Snippet Shortcodes and get more features!', SH_CD_SLUG ) : $title; | |
| 544 | +function sh_cd_display_pro_upgrade_notice( ) { | |
| 545 | + ?> | |
| 547 | 546 | |
| 548 | - ?> | |
| 549 | - <div class="postbox sh-cd-advertise-premium <?php echo esc_attr( $class ) ?>"> | |
| 550 | - <h3 class="hndle"><i class="fa-regular fa-star"></i> <?php echo esc_html( $title ) ?></h3> | |
| 547 | + <div class="postbox sh-cd-advertise-premium"> | |
| 548 | + <h3 class="hndle"><span><?php echo __( 'Upgrade Snippet Shortcodes and get more features!', SH_CD_SLUG ); ?> </span></h3> | |
| 551 | 549 | <div style="padding: 0px 15px 0px 15px"> |
| 552 | - <p><?php echo wp_kses( $content, [ 'ul' => [ 'class' ], 'li' => [], 'strong' => [], 'span' => [], 'div' => [] ] ); ?></p> | |
| 553 | 550 | <p><a href="<?php echo esc_url( admin_url('admin.php?page=sh-cd-shortcode-variables-upgrade') ); ?>" class="button-primary sh-cd-upgrade-button"><i class="fa-regular fa-star"></i> <?php echo __( 'Get Premium', SH_CD_SLUG ); ?></a></p> |
| 554 | 551 | </div> |
| 555 | 552 | </div> |
| 556 | -<?php | |
| 553 | + | |
| 554 | + <?php | |
| 557 | 555 | } |
| 558 | 556 | |
| 559 | 557 | /** |
| 560 | 558 | * Display a star to prompt for a Premioum upgrade |
| @@ -592,9 +590,11 @@ | ||
| 592 | 590 | * @return string |
| 593 | 591 | */ |
| 594 | 592 | function sh_cd_import_csv( $attachment_id, $dry_run = true ) { |
| 595 | 593 | |
| 596 | - sh_cd_permission_check(); | |
| 594 | + if ( false === sh_cd_permission_check() ) { | |
| 595 | + return 'You do not have the correct admin permissions'; | |
| 596 | + } | |
| 597 | 597 | |
| 598 | 598 | if ( false === sh_cd_is_premium() ) { |
| 599 | 599 | return 'This is a premium feature'; |
| 600 | 600 | } |
| @@ -713,10 +713,10 @@ | ||
| 713 | 713 | if ( true === empty( $csv_row[ 'slug' ] ) ) { |
| 714 | 714 | return 'Skipped: Missing slug: ' . implode( ',', $csv_row ); |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | - if ( true === empty( $csv_row[ 'content' ] ) ) { | |
| 718 | - return 'Skipped: Missing content: ' . implode( ',', $csv_row ); | |
| 717 | + if ( false === empty( $isset[ 'content' ] ) ) { | |
| 718 | + return 'Skipped: Content: ' . implode( ',', $csv_row ); | |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | $allowed_bools = [ 'yes', 'no', 'true', 'false', '1', '0' ]; |
| 722 | 722 | |
| @@ -802,54 +802,5 @@ | ||
| 802 | 802 | * Are tooltips enabled? |
| 803 | 803 | */ |
| 804 | 804 | function sh_cd_tooltips_is_enabled() { |
| 805 | 805 | return ( 'yes' === get_option( 'sh-cd-option-tool-tips-enabled', 'yes' ) ); |
| 806 | -} | |
| 807 | - | |
| 808 | -/** | |
| 809 | - * Fetch icons for given shortcode | |
| 810 | - * | |
| 811 | - * @param [type] $shortcode | |
| 812 | - * @param boolean $return_array | |
| 813 | - * @return void | |
| 814 | - */ | |
| 815 | -function sh_cd_icons_for_shortcode( $shortcode, $return_array = false ) { | |
| 816 | - | |
| 817 | - if ( true === empty( $shortcode ) ) { | |
| 818 | - return []; | |
| 819 | - } | |
| 820 | - | |
| 821 | - $icons = []; | |
| 822 | - | |
| 823 | - if ( false === empty( $shortcode[ 'header' ] ) ) { | |
| 824 | - $icons[] = sprintf( '<i class="fa-solid fa-heading sh-cd-option-icon sh-cd-tooltip" title="%s"></i>', esc_html( __( 'Insert into WP Header', SH_CD_SLUG ) ) ); | |
| 825 | - } | |
| 826 | - | |
| 827 | - if ( false === empty( $shortcode[ 'footer' ] ) ) { | |
| 828 | - $icons[] = sprintf( '<i class="fa-solid fa-shoe-prints sh-cd-option-icon sh-cd-tooltip" title="%s"></i>', esc_html( __( 'Insert into WP Footer', SH_CD_SLUG ) ) ); | |
| 829 | - } | |
| 830 | - | |
| 831 | - if ( false === empty( $shortcode[ 'device_type' ] ) ) { | |
| 832 | - $shortcode[ 'device_type' ] = json_decode( $shortcode[ 'device_type' ] ); | |
| 833 | - } | |
| 834 | - | |
| 835 | - if ( true === is_array( $shortcode[ 'device_type' ] ) ) { | |
| 836 | - | |
| 837 | - if ( true === in_array( 'desktop', $shortcode[ 'device_type' ] ) ) { | |
| 838 | - $icons[] = sprintf( '<i class="fa-solid fa-desktop sh-cd-option-icon sh-cd-tooltip" title="%s"></i>', esc_html( __( 'Display only on desktop devices', SH_CD_SLUG ) ) ); | |
| 839 | - } | |
| 840 | - | |
| 841 | - if ( true === in_array( 'mobile', $shortcode[ 'device_type' ] ) ) { | |
| 842 | - $icons[] = sprintf( '<i class="fa-solid fa-mobile-screen sh-cd-option-icon sh-cd-tooltip" title="%s"></i>', esc_html( __( 'Display only on mobile devices', SH_CD_SLUG ) ) ); | |
| 843 | - } | |
| 844 | - | |
| 845 | - if ( true === in_array( 'tablet', $shortcode[ 'device_type' ] ) ) { | |
| 846 | - $icons[] = sprintf( '<i class="fa-solid fa-tablet-screen-button sh-cd-option-icon sh-cd-tooltip" title="%s"></i>', esc_html( __( 'Display only on tablet devices', SH_CD_SLUG ) ) ); | |
| 847 | - } | |
| 848 | - } | |
| 849 | - | |
| 850 | - if ( true === $return_array ) { | |
| 851 | - return $icons; | |
| 852 | - } | |
| 853 | - | |
| 854 | - return ( false === empty( $icons ) ) ? implode( PHP_EOL, $icons ) : ''; | |
| 855 | 806 | } |