I created a plugin which have a button, when the person click on within the button, my program ought to to place some informations contained in the desk, however my program simply don’t working, I don’t why.
My code:
operate add_favorite_shortcode() {
world $post_id;
$post_id = get_post();
$post_id = !empty( $post_id ) ? $post_id->ID : false;
if(is_user_logged_in()){ //Verifanco se o usuário está on-line
$output = '<div class="redimensionar"><a id="favoritar" href="?favoritar=sim" title="teste" rel="nofollow">♥ Favorito</a></div>';
}
return $output;
}
add_shortcode( 'favorito', 'add_favorite_shortcode' );
//Criando um banco de dados
world $jal_db_version;
$jal_db_version = '1.0';
operate jal_install() {
world $wpdb;
world $jal_db_version;
$table_name = $wpdb->prefix.'favoritos';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
person mediumint(9) NOT NULL,
post_id mediumint(9) NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/contains/improve.php' );
dbDelta( $sql );
add_option( 'jal_db_version', $jal_db_version );
}
if(isset($_GET['favoritar']) == "sim"){
world $wpdb;
$person = 1;
$post_id = get_post();
$table_name = $wpdb->prefix.'favoritos';
$wpdb->insert(
$table_name,
array(
'time' => current_time( 'mysql' ),
'person' => $person,
'post_id' => $post_id,
)
);
}
Within the half that isset($_GET['favoritar'])
enter inside appropriately, however when I’ll see the desk, don’t seem nothing, somebody may help me?