author | Anthony Ly <anthonyly.com@gmail.com> |
Wed, 19 Dec 2012 17:46:52 -0800 | |
changeset 204 | 09a1c134465b |
parent 194 | 32102edaa81b |
permissions | -rw-r--r-- |
136 | 1 |
<?php |
2 |
/** |
|
3 |
* Manage link administration actions. |
|
4 |
* |
|
5 |
* This page is accessed by the link management pages and handles the forms and |
|
6 |
* AJAX processes for link actions. |
|
7 |
* |
|
8 |
* @package WordPress |
|
9 |
* @subpackage Administration |
|
10 |
*/ |
|
11 |
||
12 |
/** Load WordPress Administration Bootstrap */ |
|
13 |
require_once ('admin.php'); |
|
14 |
||
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[]')); |
|
16 |
||
17 |
if ( ! current_user_can('manage_links') ) |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
18 |
wp_link_manager_disabled_message(); |
136 | 19 |
|
20 |
if ( !empty($_POST['deletebookmarks']) ) |
|
21 |
$action = 'deletebookmarks'; |
|
22 |
if ( !empty($_POST['move']) ) |
|
23 |
$action = 'move'; |
|
24 |
if ( !empty($_POST['linkcheck']) ) |
|
25 |
$linkcheck = $_POST['linkcheck']; |
|
26 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
27 |
$this_file = admin_url('link-manager.php'); |
136 | 28 |
|
29 |
switch ($action) { |
|
30 |
case 'deletebookmarks' : |
|
31 |
check_admin_referer('bulk-bookmarks'); |
|
32 |
||
33 |
//for each link id (in $linkcheck[]) change category to selected value |
|
34 |
if (count($linkcheck) == 0) { |
|
35 |
wp_redirect($this_file); |
|
36 |
exit; |
|
37 |
} |
|
38 |
||
39 |
$deleted = 0; |
|
40 |
foreach ($linkcheck as $link_id) { |
|
41 |
$link_id = (int) $link_id; |
|
42 |
||
43 |
if ( wp_delete_link($link_id) ) |
|
44 |
$deleted++; |
|
45 |
} |
|
46 |
||
47 |
wp_redirect("$this_file?deleted=$deleted"); |
|
48 |
exit; |
|
49 |
break; |
|
50 |
||
51 |
case 'move' : |
|
52 |
check_admin_referer('bulk-bookmarks'); |
|
53 |
||
54 |
//for each link id (in $linkcheck[]) change category to selected value |
|
55 |
if (count($linkcheck) == 0) { |
|
56 |
wp_redirect($this_file); |
|
57 |
exit; |
|
58 |
} |
|
59 |
$all_links = join(',', $linkcheck); |
|
60 |
// should now have an array of links we can change |
|
61 |
//$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)"); |
|
62 |
||
63 |
wp_redirect($this_file); |
|
64 |
exit; |
|
65 |
break; |
|
66 |
||
67 |
case 'add' : |
|
68 |
check_admin_referer('add-bookmark'); |
|
69 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
70 |
$redir = wp_get_referer(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
71 |
if ( add_link() ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
72 |
$redir = add_query_arg( 'added', 'true', $redir ); |
136 | 73 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
74 |
wp_redirect( $redir ); |
136 | 75 |
exit; |
76 |
break; |
|
77 |
||
78 |
case 'save' : |
|
79 |
$link_id = (int) $_POST['link_id']; |
|
80 |
check_admin_referer('update-bookmark_' . $link_id); |
|
81 |
||
82 |
edit_link($link_id); |
|
83 |
||
84 |
wp_redirect($this_file); |
|
85 |
exit; |
|
86 |
break; |
|
87 |
||
88 |
case 'delete' : |
|
89 |
$link_id = (int) $_GET['link_id']; |
|
90 |
check_admin_referer('delete-bookmark_' . $link_id); |
|
91 |
||
92 |
wp_delete_link($link_id); |
|
93 |
||
94 |
wp_redirect($this_file); |
|
95 |
exit; |
|
96 |
break; |
|
97 |
||
98 |
case 'edit' : |
|
99 |
wp_enqueue_script('link'); |
|
100 |
wp_enqueue_script('xfn'); |
|
101 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
102 |
if ( wp_is_mobile() ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
103 |
wp_enqueue_script( 'jquery-touch-punch' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
104 |
|
136 | 105 |
$parent_file = 'link-manager.php'; |
106 |
$submenu_file = 'link-manager.php'; |
|
107 |
$title = __('Edit Link'); |
|
108 |
||
109 |
$link_id = (int) $_GET['link_id']; |
|
110 |
||
111 |
if (!$link = get_link_to_edit($link_id)) |
|
112 |
wp_die(__('Link not found.')); |
|
113 |
||
114 |
include ('edit-link-form.php'); |
|
115 |
include ('admin-footer.php'); |
|
116 |
break; |
|
117 |
||
118 |
default : |
|
119 |
break; |
|
120 |
} |