Hi Roger,
The Code Manager does not support custom parameters. You can use URL parameters, but no custom shortcode parameters. But it looks like a good change request! 😊 Let me see if I can add them…
Thanks,
Peter
Hi Peter,
Do you have an example of Php Shortcode to access URL parameters, please ?
This code could complete the Code Manager sandbox…
Thanks in advance,
Roger
Hi Roger,
Suppose you add URL parameter my_param to your request:
?my_param=test
To get the value for my_param:
$my_param = isset( $_REQUEST['my_param'] ) ? sanitize_text_field( $_REQUEST['my_param'] ) : null;
if ( null !== $my_param ) {
// Argument available for use...
} else {
// Argument available not available...
}
BE CAREFULL!!! If you want to use these values in your queries, make sure to sanitize.
Don’t use this:
$sql = “SELECT * FROM “.$tablename.” WHERE “.$whereclause.”;”;
For the table name add at least backticks:
$sql = “SELECT * FROM ".str_replace('‘,”,$tablename).”`;
For the where clause you should use wpdb prepare.
I will add the posibility to add custom parameters to your shortcode anyway. Great idea! 😊
Hope this helps,
Peter
Thank you so much Peter !!!
I’m aware of Sql injection.
Thank you again even for code to sanitize 😉
Hi Roger,
I just released an update of the Code Manager which supports custom shortcode parameters. The new feature is documentated here:
https://code-manager.com/blog/docs/index/shortcodes/php-shortcodes/
There are a few other new features. I hope you like them. I’ll try to create a small video next week to present them.
Best regards,
Peter