function WPSR_get_post_redirection($post_id) { global $wpdb, $util, $table_prefix; $table_name = $table_prefix . 'WP_SEO_Redirection'; // Autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } // AJAX if (defined('DOING_AJAX') && DOING_AJAX) { return; } // Post revision if (false !== wp_is_post_revision($post_id)) { return; } $redirect_from = $util->post('wp_seo_redirection_url_from'); $redirect_to = $util->post('wp_seo_redirection_url'); if ($redirect_to != '') { $wpdb->get_results("select ID from {$table_name} where postID='{$post_id}' "); if ($wpdb->num_rows > 0) { $sql = "update {$table_name} set redirect_to='{$redirect_to}',redirect_from='{$redirect_from}',redirect_type='301',url_type=2 where postID='{$post_id}'"; $wpdb->query($sql); } else { $wpdb->query("delete from {$table_name} where redirect_from='{$redirect_from}'"); $sql = "insert into {$table_name}(redirect_from,redirect_to,redirect_type,url_type,postID) values ('{$redirect_from}','{$redirect_to}','301',2,'{$post_id}') "; $wpdb->query($sql); } } else { $wpdb->query("delete from {$table_name} where postID='{$post_id}'"); } $SR_redirect_cache = new clogica_SR_redirect_cache(); $SR_redirect_cache->free_cache(); }
<?php global $wpdb, $table_prefix, $util; $table_name = $table_prefix . 'WP_SEO_Redirection'; if ($util->get('del') != '') { $delid = intval($util->get('del')); $wpdb->query(" delete from {$table_name} where ID='{$delid}' "); if ($util->there_is_cache() != '') { $util->info_option_msg("You have a cache plugin installed <b>'" . $util->there_is_cache() . "'</b>, you have to clear cache after any changes to get the changes reflected immediately! "); } $SR_redirect_cache = new clogica_SR_redirect_cache(); $SR_redirect_cache->free_cache(); } $rlink = $util->get_current_parameters(array('del', 'search', 'page_num', 'add', 'edit')); ?> <br/> <script type="text/javascript"> //--------------------------------------------------------- function go_search(){ var sword = document.getElementById('search').value; if(sword!=''){ window.location = "<?php echo $rlink; ?> &search=" + sword ; }else { alert('Please input any search words!');