Changeset 3189611
- Timestamp:
- 11/15/2024 01:50:14 PM (17 months ago)
- Location:
- shortcode-variables
- Files:
-
- 2 added
- 6 edited
- 1 copied
-
tags/4.1.6 (copied) (copied from shortcode-variables/trunk)
-
tags/4.1.6/includes/shortcode.presets.premium.php (modified) (5 diffs)
-
tags/4.1.6/readme.txt (modified) (2 diffs)
-
tags/4.1.6/shortcode-variables.code-workspace (added)
-
tags/4.1.6/shortcode-variables.php (modified) (2 diffs)
-
trunk/includes/shortcode.presets.premium.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/shortcode-variables.code-workspace (added)
-
trunk/shortcode-variables.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shortcode-variables/tags/4.1.6/includes/shortcode.presets.premium.php
r3032812 r3189611 405 405 * Full example: 406 406 * 407 * [sv slug="sc-db-value-by-id" table="users" column="user_login" column-to-search="id" key="3" key-format="%d" message-not-found="User not found" cache=false cache-duration=3600 ] 408 * 407 * [sv slug="sc-db-value-by-id" table="wp_users" column="user_login" column-to-search="id" key="3" key-format="%d" message-not-found="User not found" cache=false cache-duration=3600 ] 408 * 409 * Another example is to fetch the key we're searching for from the query string: 410 * 411 * e.g. https://[url]/?user-id=3 412 * 413 * [sv slug="sc-db-value-by-id" table="wp_users" column="user_login" column-to-search="id" key-query-string="user-id" key-format="%d" message-not-found="User not found" cache=false cache-duration=3600 ] 414 * 409 415 * SC_DB_VALUE_BY_ID 410 416 */ … … 413 419 protected function unsanitised() { 414 420 415 $args = wp_parse_args( $this->get_arguments(), [ 'key-format' => '%d', ' message-not-found' => '', 'cache' => true, 'cache-duration' => 1 * HOUR_IN_SECONDS ] );421 $args = wp_parse_args( $this->get_arguments(), [ 'key-format' => '%d', 'key-query-string' => NULL, 'message-not-found' => '', 'cache' => true, 'cache-duration' => 1 * HOUR_IN_SECONDS ] ); 416 422 417 423 if ( $validation_error = $this->validate_arguments( $args ) ) { … … 427 433 428 434 global $wpdb; 435 436 // Load key to look for from querystring? 437 $key = ( false === empty( $args['key-query-string'] ) ) ? 438 $_GET[ $args['key-query-string'] ] : $args['key']; 429 439 430 440 $sql = sprintf( 'Select %s from %s where %s = %s', … … 435 445 ); 436 446 437 $sql = $wpdb->prepare( $sql, $ args['key']);447 $sql = $wpdb->prepare( $sql, $key ); 438 448 $value = $wpdb->get_var( $sql ); 439 449 … … 465 475 } 466 476 467 if ( true === empty( $args['key'] ) ) { 468 return 'No key has been specified (i.e. "key" argument is missing).'; 477 if ( false === empty( $args['key-query-string'] ) ) { 478 if( true === empty( $_GET[ $args['key-query-string'] ] ) ) { 479 return sprintf('A querystring key ( "%1$s" ) has been specified but no value was been passed within the URL? (e.g. https://[website-address]/?%1$s=some-value).', esc_html( $args['key-query-string'] ) ); 480 } 481 } elseif ( true === empty( $args['key'] ) ) { 482 return 'No key has been specified (i.e. the "key" and "key-query-string" arguments are both missing).'; 469 483 } 470 484 -
shortcode-variables/tags/4.1.6/readme.txt
r3110951 r3189611 4 4 Tags: shortcode, variable, php, text, html, parameter, javascript, embed, reuse 5 5 Requires at least: 6.0 6 Tested up to: 6. 57 Stable tag: 4.1. 56 Tested up to: 6.7 7 Stable tag: 4.1.6 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 148 148 == Changelog == 149 149 150 = 4.1.6 = 151 152 * New Feature: Extended [sv slug="sc-db-value-by-id"] shortcode to include the new argument "key-query-string". This allows a key to be read from the matching querystring value. Read more: https://snippet-shortcodes.yeken.uk/shortcodes/sc-db-value-by-id.html 153 150 154 = 4.1.5 = 151 155 -
shortcode-variables/tags/4.1.6/shortcode-variables.php
r3110951 r3189611 6 6 * Plugin Name: Snippet Shortcodes 7 7 * Description: Create your own shortcodes and assign text / variables to it or use our premade ones. You can then embed these shortcodes throughout your entire site and only have to change the value in one place. 8 * Version: 4.1. 58 * Version: 4.1.6 9 9 * Requires at least: 6.0 10 10 * Tested up to: 6.5 … … 35 35 define( 'SH_CD_ABSPATH', plugin_dir_path( __FILE__ ) ); 36 36 37 define( 'SH_CD_PLUGIN_VERSION', '4.1. 5' );37 define( 'SH_CD_PLUGIN_VERSION', '4.1.6' ); 38 38 define( 'SH_CD_PLUGIN_NAME', 'Snippet Shortcodes' ); 39 39 define( 'SH_CD_TABLE', 'SH_CD_SHORTCODES' ); -
shortcode-variables/trunk/includes/shortcode.presets.premium.php
r3032812 r3189611 405 405 * Full example: 406 406 * 407 * [sv slug="sc-db-value-by-id" table="users" column="user_login" column-to-search="id" key="3" key-format="%d" message-not-found="User not found" cache=false cache-duration=3600 ] 408 * 407 * [sv slug="sc-db-value-by-id" table="wp_users" column="user_login" column-to-search="id" key="3" key-format="%d" message-not-found="User not found" cache=false cache-duration=3600 ] 408 * 409 * Another example is to fetch the key we're searching for from the query string: 410 * 411 * e.g. https://[url]/?user-id=3 412 * 413 * [sv slug="sc-db-value-by-id" table="wp_users" column="user_login" column-to-search="id" key-query-string="user-id" key-format="%d" message-not-found="User not found" cache=false cache-duration=3600 ] 414 * 409 415 * SC_DB_VALUE_BY_ID 410 416 */ … … 413 419 protected function unsanitised() { 414 420 415 $args = wp_parse_args( $this->get_arguments(), [ 'key-format' => '%d', ' message-not-found' => '', 'cache' => true, 'cache-duration' => 1 * HOUR_IN_SECONDS ] );421 $args = wp_parse_args( $this->get_arguments(), [ 'key-format' => '%d', 'key-query-string' => NULL, 'message-not-found' => '', 'cache' => true, 'cache-duration' => 1 * HOUR_IN_SECONDS ] ); 416 422 417 423 if ( $validation_error = $this->validate_arguments( $args ) ) { … … 427 433 428 434 global $wpdb; 435 436 // Load key to look for from querystring? 437 $key = ( false === empty( $args['key-query-string'] ) ) ? 438 $_GET[ $args['key-query-string'] ] : $args['key']; 429 439 430 440 $sql = sprintf( 'Select %s from %s where %s = %s', … … 435 445 ); 436 446 437 $sql = $wpdb->prepare( $sql, $ args['key']);447 $sql = $wpdb->prepare( $sql, $key ); 438 448 $value = $wpdb->get_var( $sql ); 439 449 … … 465 475 } 466 476 467 if ( true === empty( $args['key'] ) ) { 468 return 'No key has been specified (i.e. "key" argument is missing).'; 477 if ( false === empty( $args['key-query-string'] ) ) { 478 if( true === empty( $_GET[ $args['key-query-string'] ] ) ) { 479 return sprintf('A querystring key ( "%1$s" ) has been specified but no value was been passed within the URL? (e.g. https://[website-address]/?%1$s=some-value).', esc_html( $args['key-query-string'] ) ); 480 } 481 } elseif ( true === empty( $args['key'] ) ) { 482 return 'No key has been specified (i.e. the "key" and "key-query-string" arguments are both missing).'; 469 483 } 470 484 -
shortcode-variables/trunk/readme.txt
r3110951 r3189611 4 4 Tags: shortcode, variable, php, text, html, parameter, javascript, embed, reuse 5 5 Requires at least: 6.0 6 Tested up to: 6. 57 Stable tag: 4.1. 56 Tested up to: 6.7 7 Stable tag: 4.1.6 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 148 148 == Changelog == 149 149 150 = 4.1.6 = 151 152 * New Feature: Extended [sv slug="sc-db-value-by-id"] shortcode to include the new argument "key-query-string". This allows a key to be read from the matching querystring value. Read more: https://snippet-shortcodes.yeken.uk/shortcodes/sc-db-value-by-id.html 153 150 154 = 4.1.5 = 151 155 -
shortcode-variables/trunk/shortcode-variables.php
r3110951 r3189611 6 6 * Plugin Name: Snippet Shortcodes 7 7 * Description: Create your own shortcodes and assign text / variables to it or use our premade ones. You can then embed these shortcodes throughout your entire site and only have to change the value in one place. 8 * Version: 4.1. 58 * Version: 4.1.6 9 9 * Requires at least: 6.0 10 10 * Tested up to: 6.5 … … 35 35 define( 'SH_CD_ABSPATH', plugin_dir_path( __FILE__ ) ); 36 36 37 define( 'SH_CD_PLUGIN_VERSION', '4.1. 5' );37 define( 'SH_CD_PLUGIN_VERSION', '4.1.6' ); 38 38 define( 'SH_CD_PLUGIN_NAME', 'Snippet Shortcodes' ); 39 39 define( 'SH_CD_TABLE', 'SH_CD_SHORTCODES' );
Note: See TracChangeset
for help on using the changeset viewer.