I have a plugin on a page update-data which has a shortcode on the page of [updatedata]
here is what an update row looks like
<td><a href="<?php echo admin_url('http://localhost/update-data&id='.$id); ?>">UPDATE</a></td>
Here is what the plugin code is
<?php
/*
plugin name: deano plugin update
description: deano test database to update data into books table
author: Dean-O
*/
$path = preg_replace('/wp-content.*$/', '', __DIR__);
require_once($path.'/wp-load.php');
error_log("here"); // echos to log file
error_log(var_dump($id)); // echos a blank line to the log file
error_log("here 2"); // echos to the log file
function deanoupdatedata($atts, $content = null ) {
$a = shortcode_atts( array(
'id' => 'id'
), $atts );
return '<a id="' . esc_attr($a['id']) . '</a>'; // never displays
}
add_shortcode('updatedata','deanoupdatedata');
?>
How can I get the url parameter id in the plugin when I click on update link?
2
Answers
Try
if($_GET['id'])
instead ofisset
and istead oferror_log
usevar_dump
to get the exact valueIt is a bad practice. You should pass the data to a shortcode using the shortcode’s attributes.