$wpdb->insert & $wpdb->get_row in function.php
-
Hy i have insert and get_row in function.php but they don’t work there is my code :
########################### // SIGNALEMENT DE LIEN MORT add_action('wp_ajax_signalement_dead_link', 'callback_signalement_dead_link'); add_action('wp_ajax_nopriv_signalement_dead_link', 'callback_signalement_dead_link'); function callback_signalement_dead_link() { global $_REQUEST; global $post; if (!wp_verify_nonce($_REQUEST['nonce'], 'ajax_nonce')) die(); $response = array( 'error' => '' ); $post_id = $_REQUEST['post_id']; $post_title = get_the_title( $post_id ); $category = get_the_category($post->$post_id); $category_name = $category[0]->name; $post_category = $category_name; $nom_bouton = $_REQUEST['nom_bouton']; $dead_link = $_REQUEST['dead_link']; $edit_url = '<a href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . $post_category . $post_title . '</a>'; $name_dead_link = '<a href="' . $dead_link . '">' . $nom_bouton . '</a>'; if (!empty($post_id) || !empty($nom_bouton) || !empty($link)) { global $wpdb; $tablename = $wpdb->prefix . "dead_link"; $check_if_exist = $wpdb->get_results("SELECT link FROM $tablename WHERE link = $name_dead_link"); if ($check_if_exist != null) { $wpdb->insert('$tablename', array( 'episode' => $edit_url, 'link' => $name_dead_link, ) , array( '%s', '%s', )); } else { $response['error'] = 'Lien déjà signalé.'; } echo json_encode($response); die(); } else { die(); } }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘$wpdb->insert & $wpdb->get_row in function.php’ is closed to new replies.