mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Manage link administration actions.
mp-wp_genesis 4 *
mp-wp_genesis 5 * This page is accessed by the link management pages and handles the forms and
mp-wp_genesis 6 * AJAX processes for link actions.
mp-wp_genesis 7 *
mp-wp_genesis 8 * @package WordPress
mp-wp_genesis 9 * @subpackage Administration
mp-wp_genesis 10 */
mp-wp_genesis 11
mp-wp_genesis 12 /** Load WordPress Administration Bootstrap */
mp-wp_genesis 13 require_once ('admin.php');
mp-wp_genesis 14
mp-wp_genesis 15 wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
mp-wp_genesis 16
mp-wp_genesis 17 if ( ! current_user_can('manage_links') )
mp-wp_genesis 18 wp_die( __('You do not have sufficient permissions to edit the links for this blog.') );
mp-wp_genesis 19
mp-wp_genesis 20 if ( !empty($_POST['deletebookmarks']) )
mp-wp_genesis 21 $action = 'deletebookmarks';
mp-wp_genesis 22 if ( !empty($_POST['move']) )
mp-wp_genesis 23 $action = 'move';
mp-wp_genesis 24 if ( !empty($_POST['linkcheck']) )
mp-wp_genesis 25 $linkcheck = $_POST['linkcheck'];
mp-wp_genesis 26
mp-wp_genesis 27 $this_file = 'link-manager.php';
mp-wp_genesis 28
mp-wp_genesis 29 switch ($action) {
mp-wp_genesis 30 case 'deletebookmarks' :
mp-wp_genesis 31 check_admin_referer('bulk-bookmarks');
mp-wp_genesis 32
mp-wp_genesis 33 //for each link id (in $linkcheck[]) change category to selected value
mp-wp_genesis 34 if (count($linkcheck) == 0) {
mp-wp_genesis 35 wp_redirect($this_file);
mp-wp_genesis 36 exit;
mp-wp_genesis 37 }
mp-wp_genesis 38
mp-wp_genesis 39 $deleted = 0;
mp-wp_genesis 40 foreach ($linkcheck as $link_id) {
mp-wp_genesis 41 $link_id = (int) $link_id;
mp-wp_genesis 42
mp-wp_genesis 43 if ( wp_delete_link($link_id) )
mp-wp_genesis 44 $deleted++;
mp-wp_genesis 45 }
mp-wp_genesis 46
mp-wp_genesis 47 wp_redirect("$this_file?deleted=$deleted");
mp-wp_genesis 48 exit;
mp-wp_genesis 49 break;
mp-wp_genesis 50
mp-wp_genesis 51 case 'move' :
mp-wp_genesis 52 check_admin_referer('bulk-bookmarks');
mp-wp_genesis 53
mp-wp_genesis 54 //for each link id (in $linkcheck[]) change category to selected value
mp-wp_genesis 55 if (count($linkcheck) == 0) {
mp-wp_genesis 56 wp_redirect($this_file);
mp-wp_genesis 57 exit;
mp-wp_genesis 58 }
mp-wp_genesis 59 $all_links = join(',', $linkcheck);
mp-wp_genesis 60 // should now have an array of links we can change
mp-wp_genesis 61 //$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
mp-wp_genesis 62
mp-wp_genesis 63 wp_redirect($this_file);
mp-wp_genesis 64 exit;
mp-wp_genesis 65 break;
mp-wp_genesis 66
mp-wp_genesis 67 case 'add' :
mp-wp_genesis 68 check_admin_referer('add-bookmark');
mp-wp_genesis 69
mp-wp_genesis 70 add_link();
mp-wp_genesis 71
mp-wp_genesis 72 wp_redirect( wp_get_referer() . '?added=true' );
mp-wp_genesis 73 exit;
mp-wp_genesis 74 break;
mp-wp_genesis 75
mp-wp_genesis 76 case 'save' :
mp-wp_genesis 77 $link_id = (int) $_POST['link_id'];
mp-wp_genesis 78 check_admin_referer('update-bookmark_' . $link_id);
mp-wp_genesis 79
mp-wp_genesis 80 edit_link($link_id);
mp-wp_genesis 81
mp-wp_genesis 82 wp_redirect($this_file);
mp-wp_genesis 83 exit;
mp-wp_genesis 84 break;
mp-wp_genesis 85
mp-wp_genesis 86 case 'delete' :
mp-wp_genesis 87 $link_id = (int) $_GET['link_id'];
mp-wp_genesis 88 check_admin_referer('delete-bookmark_' . $link_id);
mp-wp_genesis 89
mp-wp_genesis 90 wp_delete_link($link_id);
mp-wp_genesis 91
mp-wp_genesis 92 wp_redirect($this_file);
mp-wp_genesis 93 exit;
mp-wp_genesis 94 break;
mp-wp_genesis 95
mp-wp_genesis 96 case 'edit' :
mp-wp_genesis 97 wp_enqueue_script('link');
mp-wp_genesis 98 wp_enqueue_script('xfn');
mp-wp_genesis 99
mp-wp_genesis 100 $parent_file = 'link-manager.php';
mp-wp_genesis 101 $submenu_file = 'link-manager.php';
mp-wp_genesis 102 $title = __('Edit Link');
mp-wp_genesis 103
mp-wp_genesis 104 $link_id = (int) $_GET['link_id'];
mp-wp_genesis 105
mp-wp_genesis 106 if (!$link = get_link_to_edit($link_id))
mp-wp_genesis 107 wp_die(__('Link not found.'));
mp-wp_genesis 108
mp-wp_genesis 109 include ('edit-link-form.php');
mp-wp_genesis 110 include ('admin-footer.php');
mp-wp_genesis 111 break;
mp-wp_genesis 112
mp-wp_genesis 113 default :
mp-wp_genesis 114 break;
mp-wp_genesis 115 }
mp-wp_genesis 116 ?>