| @@ -49,16 +49,10 @@ | ||
| 49 | 49 | |
| 50 | 50 | if ( false === sh_cd_is_premium_plugin_activated() ) { |
| 51 | 51 | return; |
| 52 | 52 | } |
| 53 | - | |
| 54 | - $latest_version = sh_cd_get_latest_premium_version(); | |
| 55 | - | |
| 56 | - if ( true === empty( $latest_version ) ) { | |
| 57 | - return; | |
| 58 | - } | |
| 59 | 53 | |
| 60 | - if ( false === version_compare( $latest_version, YK_SS_PLUGIN_VERSION, '>' ) ) { | |
| 54 | + if ( SH_CD_PREMIUM_PLUGIN_LATEST_VERSION === YK_SS_PLUGIN_VERSION ) { | |
| 61 | 55 | return; |
| 62 | 56 | } |
| 63 | 57 | |
| 64 | 58 | if ( false === empty( $_GET[ 'dismiss-premium-upgrade' ] ) ) { |
| @@ -67,13 +61,13 @@ | ||
| 67 | 61 | } |
| 68 | 62 | |
| 69 | 63 | $version_dismissed = sh_cd_marketing_prompt_been_dismissed( '_yeken_shortcode_variables_upgrade_premium_has_been_dismissed' ); |
| 70 | 64 | |
| 71 | - if ( false === empty( $version_dismissed ) && $version_dismissed === $latest_version ) { | |
| 65 | + if ( false !== empty( $version_dimissed ) && $version_dismissed === SH_CD_PREMIUM_PLUGIN_LATEST_VERSION ) { | |
| 72 | 66 | return; |
| 73 | 67 | } |
| 74 | 68 | |
| 75 | - $dismiss_url = add_query_arg( [ 'dismiss-premium-upgrade' => $latest_version ], sh_cd_get_current_url() ); | |
| 69 | + $dismiss_url = add_query_arg( [ 'dismiss-premium-upgrade' => SH_CD_PREMIUM_PLUGIN_LATEST_VERSION ], sh_cd_get_current_url() ); | |
| 76 | 70 | |
| 77 | 71 | printf('<div class="notice notice-warning"> |
| 78 | 72 | <p><strong>%1$s</strong>: %2$s</p> |
| 79 | 73 | <p> |
| @@ -86,9 +80,9 @@ | ||
| 86 | 80 | __( 'A newer version of <strong>"Snippet Shortcodes – Premium"</strong> is available. Please update it from the Plugins screen to access the latest features and bug fixes.', SH_CD_SLUG ), |
| 87 | 81 | esc_url( admin_url('plugins.php') ), |
| 88 | 82 | $dismiss_url, |
| 89 | 83 | __( 'Dismiss', SH_CD_SLUG ), |
| 90 | - __( 'Update both plugins via plugin screen', SH_CD_SLUG ), | |
| 84 | + __( 'Update to ', SH_CD_SLUG ) . SH_CD_PREMIUM_PLUGIN_LATEST_VERSION, | |
| 91 | 85 | sh_cd_premium_shortcode_download( true ), |
| 92 | 86 | ); |
| 93 | 87 | } |
| 94 | 88 | add_action( 'admin_notices', 'sh_cd_prompt_to_upgrade_premium' ); |
| @@ -123,24 +117,17 @@ | ||
| 123 | 117 | */ |
| 124 | 118 | function sh_cd_premium_features_list() { |
| 125 | 119 | |
| 126 | 120 | return [ |
| 127 | - [ 'title' => 'Insert into header or footer', 'description' => 'Automaically insert your custom shortcode’s content into either your site’s header and/or footer.', 'read-more-url' => '' ], | |
| 128 | - [ 'title' => 'Limit header/footer to specific pages', 'description' => 'Restrict an auto-inserted header/footer shortcode to a chosen list of page slugs, instead of it appearing on every page.', 'read-more-url' => 'https://yeken.gitbook.io/snippet-shortcodes/features/interactive-blocks/auto-insert-into-header-footer' ], | |
| 129 | - [ 'title' => 'Limit to certain device types', 'description' => 'Specify whether your custom shortcode should only be visible on Mobile, Tablet, Desktop or all three.', 'read-more-url' => '' ], | |
| 130 | - [ 'title' => 'Limit to user roles', 'description' => 'Show a custom shortcode only to guests or to specific WordPress user roles.', 'read-more-url' => 'https://yeken.gitbook.io/snippet-shortcodes/features/role-targeting' ], | |
| 131 | - [ 'title' => 'Schedule visibility', 'description' => 'Optionally limit a custom shortcode to a start/end date and time window.', 'read-more-url' => 'https://yeken.gitbook.io/snippet-shortcodes/features/visibility-scheduling' ], | |
| 132 | - [ 'title' => 'Render-count analytics', 'description' => 'See how many times each custom shortcode has been rendered, right on the edit screen.', 'read-more-url' => 'https://yeken.gitbook.io/snippet-shortcodes/features/render-analytics' ], | |
| 133 | - [ 'title' => 'Content revision history', 'description' => 'Every save is kept as a revision (last 20 per shortcode), with one-click restore.', 'read-more-url' => 'https://yeken.gitbook.io/snippet-shortcodes/features/revision-history' ], | |
| 134 | 121 | [ 'title' => 'No limits', 'description' => 'Create unlimited custom shortcodes.', 'read-more-url' => '' ], |
| 135 | 122 | [ 'title' => 'Inline editor', 'description' => 'Ability to edit custom shortcodes without having to use a full editor.', 'read-more-url' => '' ], |
| 136 | 123 | [ 'title' => 'Duplicator', 'description' => 'Ability to duplicate custom shortcodes.', 'read-more-url' => '' ], |
| 137 | 124 | [ 'title' => 'Enable/Disable', 'description' => 'Ability to enable or disable custom shortcodes.', 'read-more-url' => '' ], |
| 138 | 125 | [ 'title' => 'Multi-site', 'description' => 'Use custom shortcodes throughout your entire multi-site, not just limited to the one child site', 'read-more-url' => '' ], |
| 139 | - [ 'title' => 'CSV import & export', 'description' => 'Bulk import your custom shortcodes, or export your entire collection to CSV.', 'read-more-url' => 'https://yeken.gitbook.io/snippet-shortcodes/features/csv-import' ], | |
| 140 | - [ 'title' => 'WooCommerce fields', 'description' => 'A ready-made shortcode to display WooCommerce fields.', 'read-more-url' => 'https://yeken.gitbook.io/snippet-shortcodes/features/ready-made/premium/woocommerce-meta-fields' ], | |
| 141 | - [ 'title' => 'Fetch values from database', 'description' => 'A ready-made shortcode to fetch a value from any database table', 'read-more-url' => 'https://yeken.gitbook.io/snippet-shortcodes/features/ready-made/premium/database-values-by-id' ], | |
| 142 | - [ 'title' => 'More ready-made shortcodes', 'description' => 'Display additional WordPress fields, as well as wrapping around PHP functionality like GET/POST values, number of users, etc', 'read-more-url' => 'https://yeken.gitbook.io/snippet-shortcodes/features/ready-made/premium' ] | |
| 126 | + [ 'title' => 'CSV import', 'description' => 'Bulk import your custom shortcodes.', 'read-more-url' => 'https://snippet-shortcodes.yeken.uk/csv-import.html' ], | |
| 127 | + [ 'title' => 'WooCommerce fields', 'description' => 'A ready-made shortcode to display WooCommerce fields.', 'read-more-url' => 'https://snippet-shortcodes.yeken.uk/shortcodes/sc-woocommerce.html' ], | |
| 128 | + [ 'title' => 'Fetch values from database', 'description' => 'A ready-made shortcode to fetch a value from any database table', 'read-more-url' => 'https://snippet-shortcodes.yeken.uk/shortcodes/sc-db-value-by-id.html' ], | |
| 129 | + [ 'title' => 'More out-of-the-box shortcodes', 'description' => 'Display additional WordPress fields, as well as wrapping around PHP functionality like GET/POST values, number of users, etc', 'read-more-url' => 'https://snippet-shortcodes.yeken.uk/shortcodes-premium.html' ] | |
| 143 | 130 | |
| 144 | 131 | // [ 'title' => '', 'description' => '', 'read-more-url' => '' ], |
| 145 | 132 | ]; |
| 146 | 133 | |
| @@ -151,9 +138,9 @@ | ||
| 151 | 138 | */ |
| 152 | 139 | function sh_cd_shortcode_presets_premium_list() { |
| 153 | 140 | |
| 154 | 141 | return [ |
| 155 | - 'db-value-by-id' => [ 'class' => 'SC_DB_VALUE_BY_ID', 'description' => __( 'Return a column value from a MySQL database for the given ID of search criteria e.g. <a href="https://yeken.gitbook.io/snippet-shortcodes/features/ready-made/premium/database-values-by-id" rel="noopener" target="_blank">[sv slug="db-value-by-id" table="users" column="user_login" column-to-search="id" key="3" key-format="%d"]</a>', SH_CD_SLUG ), 'premium' => true, 'args' => [ '_sh_cd_func' => 'by-id' ] ], | |
| 142 | + 'db-value-by-id' => [ 'class' => 'SC_DB_VALUE_BY_ID', 'description' => __( 'Return a column value from a MySQL database for the given ID of search criteria e.g. <a href="https://snippet-shortcodes.yeken.uk/shortcodes/sc-db-value-by-id.html" rel="noopener" target="_blank">[sv slug="db-value-by-id" table="users" column="user_login" column-to-search="id" key="3" key-format="%d"]</a>', SH_CD_SLUG ), 'premium' => true, 'args' => [ '_sh_cd_func' => 'by-id' ] ], | |
| 156 | 143 | 'date' => [ 'class' => 'SC_DATE', 'description' => __( 'A shortcode that displays today\'s date with the ability to add or subtract days, months and years. To specify an interval to add or subtract onto the date use the parameter "interval" e.g. [sv slug="date" interval="-1 year"], [sv slug="date" interval="+5 days"], [sv slug="date" interval="+3 months"]. Intervals are based upon PHP intervals and are outlined here <a href="https://www.php.net/manual/en/dateinterval.createfromdatestring.php" target="_blank">https://www.php.net/manual/en/dateinterval.createfromdatestring.php</a>. Default is UK format (DD/MM/YYYY). Format can be changed by adding the parameter format="m/d/Y" onto the shortcode. Format syntax is based upon PHP date: <a href="http://php.net/manual/en/function.date.php" target="_blank">http://php.net/manual/en/function.date.php</a>', SH_CD_SLUG ), 'premium' => true ], |
| 157 | 144 | 'site-language' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'Language code for the current site', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'language' ], 'premium' => true ], |
| 158 | 145 | 'site-description' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'Site tagline (set in Settings > General)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'description' ], 'premium' => true ], |
| 159 | 146 | 'site-wp-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The WordPress address (URL) (set in Settings > General)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'wpurl' ], 'premium' => true ], |
| @@ -184,12 +171,10 @@ | ||
| 184 | 171 | 'post-author' => [ 'class' => 'SC_POST_AUTHOR', 'description' => __( 'Display the author\'s display name or ID. The optional argument "field" allows you to specify whether you wish to display the author\'s "display-name" or "id". [sv slug="post-author" field="id" ]', SH_CD_SLUG ), 'premium' => true ], |
| 185 | 172 | 'post-counts' => [ 'class' => 'SC_POST_COUNTS', 'description' => __( 'Display a count of posts for certain statuses. Using the argument status, specify whether to return a count for all posts that have a status of "publish" (default), "future", "draft", "pending" or "private". [sv slug="post-counts" status="draft"]', SH_CD_SLUG ), 'premium' => true ], |
| 186 | 173 | 'user-counts' => [ 'class' => 'SC_USER_COUNTS', 'description' => __( 'Display a count of all WordPress users or the number of WordPress users for a given role e.g. [sv slug="user-counts" role="subscriber"] or [sv slug="user-counts"]', SH_CD_SLUG ), 'premium' => true ], |
| 187 | 174 | 'user-profile-photo' => [ 'class' => 'SC_AVATAR', 'description' => __( 'Display the WordPress profile photo for the logged in user e.g. [sv slug="user-profile-photo" width="150"] or [sv slug="user-profile-photo"]. Please note, width defaults to 96px.', SH_CD_SLUG ), 'premium' => true ], |
| 188 | - 'user-meta' => [ 'class' => 'SC_USER_META', 'description' => __( 'Display a WordPress user meta field (wraps get_user_meta) field e.g. last_name. Read more: <a href="https://yeken.gitbook.io/snippet-shortcodes/features/ready-made/premium/wordpress-user-fields" rel="noopener" target="_blank">[sv slug="user-meta" field="last_name"]</a>', SH_CD_SLUG ), 'premium' => true ], | |
| 189 | - 'woocommerce' => [ 'class' => 'SC_USER_META', 'description' => __( 'Display a Woocommerce user profile field e.g. billing_phone. Read more: <a href="https://yeken.gitbook.io/snippet-shortcodes/features/ready-made/premium/woocommerce-meta-fields" rel="noopener" target="_blank">[sv slug="woocommerce" field="billing_phone"]</a>', SH_CD_SLUG ), 'premium' => true ], | |
| 190 | - 'copy-code' => [ 'class' => 'SC_COPY_CODE', 'description' => __( 'A ready-made, styled code snippet with a "Copy" button. Add the text to display via the "code" attribute e.g. [sv slug="copy-code" code="npm install my-package"]', SH_CD_SLUG ), 'premium' => true ], | |
| 191 | - 'countdown' => [ 'class' => 'SC_COUNTDOWN', 'description' => __( 'A countdown timer counting down to a given date/time. Specify the target via the "date" attribute (e.g. date="2026-12-31T23:59:59") and an optional "label" attribute for the heading text e.g. [sv slug="countdown" date="2026-12-31T23:59:59" label="Sale ends in"]', SH_CD_SLUG ), 'premium' => true ] | |
| 175 | + 'user-meta' => [ 'class' => 'SC_USER_META', 'description' => __( 'Display a WordPress user meta field (wraps get_user_meta) field e.g. last_name. Read more: <a href="https://snippet-shortcodes.yeken.uk/shortcodes/sc-user-meta" rel="noopener" target="_blank">[sv slug="user-meta" field="last_name"]</a>', SH_CD_SLUG ), 'premium' => true ], | |
| 176 | + 'woocommerce' => [ 'class' => 'SC_USER_META', 'description' => __( 'Display a Woocommerce user profile field e.g. billing_phone. Read more: <a href="https://snippet-shortcodes.yeken.uk/shortcodes/sc-woocommerce" rel="noopener" target="_blank">[sv slug="woocommerce" field="billing_phone"]</a>', SH_CD_SLUG ), 'premium' => true ] | |
| 192 | 177 | |
| 193 | 178 | // '' => [ 'class' => '', 'description' => '', 'premium' => true ] |
| 194 | 179 | ]; |
| 195 | 180 | } |
| @@ -337,43 +322,13 @@ | ||
| 337 | 322 | return $html; |
| 338 | 323 | } |
| 339 | 324 | |
| 340 | 325 | /** |
| 341 | - * Fetch the latest version of the premium plugin | |
| 342 | - */ | |
| 343 | -function sh_cd_get_latest_premium_version() { | |
| 344 | - | |
| 345 | - if ( $cache = get_transient( '_yeken_shortcode_variables_latest_premium_version' ) ) { | |
| 346 | - return $cache; | |
| 347 | - } | |
| 348 | - | |
| 349 | - $response = wp_remote_get( SH_CD_YEKEN_PREMIUM_RELEASE_MANIFEST ); | |
| 350 | - $version = NULL; | |
| 351 | - | |
| 352 | - // All ok? | |
| 353 | - if ( 200 === wp_remote_retrieve_response_code( $response ) ) { | |
| 354 | - | |
| 355 | - $body = wp_remote_retrieve_body( $response ); | |
| 356 | - | |
| 357 | - if ( false === empty( $body ) ) { | |
| 358 | - | |
| 359 | - $body = json_decode( $body, true ); | |
| 360 | - | |
| 361 | - $version = ( false === empty( $body[ 'version' ] ) ) ? $body[ 'version' ] : NULL; | |
| 362 | - | |
| 363 | - set_transient( '_yeken_shortcode_variables_latest_premium_version', $version, DAY_IN_SECONDS ); | |
| 364 | - } | |
| 365 | - } | |
| 366 | - | |
| 367 | - return $version; | |
| 368 | -} | |
| 369 | - | |
| 370 | -/** | |
| 371 | 326 | * Display admin notice for notification from yeken.uk |
| 372 | 327 | */ |
| 373 | 328 | function sh_cd_get_marketing_message() { |
| 374 | 329 | |
| 375 | - if ( $cache = get_transient( '_yeken_shortcode_variables_update' ) ) { | |
| 330 | + if ( $cache = get_transient( '_yeken_shortcode_variables_update1' ) ) { | |
| 376 | 331 | return $cache; |
| 377 | 332 | } |
| 378 | 333 | |
| 379 | 334 | $response = wp_remote_get( SH_CD_YEKEN_UPDATES_URL ); |
| @@ -383,11 +338,12 @@ | ||
| 383 | 338 | |
| 384 | 339 | $body = wp_remote_retrieve_body( $response ); |
| 385 | 340 | |
| 386 | 341 | if ( false === empty( $body ) ) { |
| 342 | + | |
| 387 | 343 | $body = json_decode( $body, true ); |
| 388 | 344 | |
| 389 | - set_transient( '_yeken_shortcode_variables_update', $body, DAY_IN_SECONDS ); | |
| 345 | + set_transient( '_yeken_shortcode_variables_update', $body, HOUR_IN_SECONDS ); | |
| 390 | 346 | |
| 391 | 347 | return $body; |
| 392 | 348 | } |
| 393 | 349 | } |
| @@ -479,9 +435,9 @@ | ||
| 479 | 435 | |
| 480 | 436 | /** |
| 481 | 437 | * Text to display on upgrade and license page |
| 482 | 438 | */ |
| 483 | -function sh_cd_marketing_upgrade_page_text() { | |
| 439 | + function sh_cd_marketing_upgrade_page_text() { | |
| 484 | 440 | ?> |
| 485 | 441 | <h4 class="sh-cd-promo"><i class="fa-regular fa-star"></i> <?php echo __( 'Unlock these extra features when you upgrade:', SH_CD_SLUG ); ?></h4> |
| 486 | 442 | <?php echo sh_cd_display_premium(); ?> |
| 487 | 443 | <h4 class="sh-cd-promo"><i class="fa-regular fa-star"></i> <?php echo __( 'Extra Premium shortcodes', SH_CD_SLUG ); ?>:</h4> |
| @@ -487,36 +443,5 @@ | ||
| 487 | 443 | <h4 class="sh-cd-promo"><i class="fa-regular fa-star"></i> <?php echo __( 'Extra Premium shortcodes', SH_CD_SLUG ); ?>:</h4> |
| 488 | 444 | <p><?php echo __( 'Upgrade to the Premium version of Snippet Shortcodes to unlock these additional shortcodes.', SH_CD_SLUG ); ?>:</p> |
| 489 | 445 | <?php echo sh_cd_display_premade_shortcodes( 'premium' ); ?> |
| 490 | 446 | <?php |
| 491 | -} | |
| 492 | - | |
| 493 | -/** | |
| 494 | - * Marketing prompt to upgrade on Edit page to get additional shortcode options | |
| 495 | - * | |
| 496 | - * @return void | |
| 497 | - */ | |
| 498 | -function sh_cd_marketing_page_edit_additional_options() { | |
| 499 | - | |
| 500 | - $title = __( 'Unlock these additional settings by upgrading to Premium', SH_CD_SLUG ) ; | |
| 501 | - | |
| 502 | - // A plain list rather than a fixed sprintf() placeholder count, so adding/removing an | |
| 503 | - // item later doesn't also require recounting %s tokens - see CLAUDE.md's note on keeping | |
| 504 | - // this in sync with new features. | |
| 505 | - $items = [ | |
| 506 | - __( '<span>Insert into Header / Footer</span> - specify whether to automatically insert the shortcode content into the WP Header or Footer.', SH_CD_SLUG ), | |
| 507 | - __( '<span>Limit header/footer to specific pages</span> - restrict automatic header/footer insertion to a chosen list of page slugs, instead of it appearing on every page.', SH_CD_SLUG ), | |
| 508 | - __( '<span>Limit to mobile or desktop</span> - specify whether a shortcode should only appear on mobile or desktop devices.', SH_CD_SLUG ), | |
| 509 | - __( '<span>Limit to user roles</span> - show a shortcode only to guests or to specific WordPress user roles.', SH_CD_SLUG ), | |
| 510 | - __( '<span>Schedule visibility</span> - limit a shortcode to a start and/or end date and time window.', SH_CD_SLUG ), | |
| 511 | - __( '<span>Global shortcodes</span> - specify whether a shortcode should be available across all sites in your multisite network.', SH_CD_SLUG ), | |
| 512 | - __( '<span>Disable shortcodes</span> - have the ability to disable shortcodes so content will not appear at the location of the shortcode in the public facing site.', SH_CD_SLUG ), | |
| 513 | - __( '<span>Edit Slug</span> - have the ability to change the slug of an existing shortcode.', SH_CD_SLUG ), | |
| 514 | - __( '<span>Render-count analytics</span> - see how many times each shortcode has been rendered, right on this screen.', SH_CD_SLUG ), | |
| 515 | - __( '<span>Revision history</span> - restore a previous version of a shortcode\'s content, with the last 20 revisions kept automatically.', SH_CD_SLUG ), | |
| 516 | - ]; | |
| 517 | - | |
| 518 | - $content = '<ul><li>' . implode( '</li><li>', $items ) . '</li></ul>'; | |
| 519 | - | |
| 520 | - sh_cd_display_pro_upgrade_notice( $title, $content, 'sh-cd-page-edit-marketing-prompt' ); | |
| 521 | -} | |
| 522 | - | |
| 447 | + } | |