author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Manage link administration actions. |
|
4 |
* |
|
5 |
* This page is accessed by the link management pages and handles the forms and |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6 |
* Ajax processes for link actions. |
0 | 7 |
* |
8 |
* @package WordPress |
|
9 |
* @subpackage Administration |
|
10 |
*/ |
|
11 |
||
12 |
/** Load WordPress Administration Bootstrap */ |
|
16 | 13 |
require_once __DIR__ . '/admin.php'; |
0 | 14 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
15 |
$action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
16 |
$cat_id = ! empty( $_REQUEST['cat_id'] ) ? absint( $_REQUEST['cat_id'] ) : 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
17 |
$link_id = ! empty( $_REQUEST['link_id'] ) ? absint( $_REQUEST['link_id'] ) : 0; |
0 | 18 |
|
9 | 19 |
if ( ! current_user_can( 'manage_links' ) ) { |
0 | 20 |
wp_link_manager_disabled_message(); |
9 | 21 |
} |
0 | 22 |
|
9 | 23 |
if ( ! empty( $_POST['deletebookmarks'] ) ) { |
0 | 24 |
$action = 'deletebookmarks'; |
9 | 25 |
} |
26 |
if ( ! empty( $_POST['move'] ) ) { |
|
0 | 27 |
$action = 'move'; |
9 | 28 |
} |
29 |
if ( ! empty( $_POST['linkcheck'] ) ) { |
|
0 | 30 |
$linkcheck = $_POST['linkcheck']; |
9 | 31 |
} |
0 | 32 |
|
9 | 33 |
$this_file = admin_url( 'link-manager.php' ); |
0 | 34 |
|
9 | 35 |
switch ( $action ) { |
36 |
case 'deletebookmarks': |
|
37 |
check_admin_referer( 'bulk-bookmarks' ); |
|
0 | 38 |
|
5 | 39 |
// For each link id (in $linkcheck[]) change category to selected value. |
16 | 40 |
if ( count( $linkcheck ) === 0 ) { |
9 | 41 |
wp_redirect( $this_file ); |
0 | 42 |
exit; |
43 |
} |
|
44 |
||
45 |
$deleted = 0; |
|
9 | 46 |
foreach ( $linkcheck as $link_id ) { |
0 | 47 |
$link_id = (int) $link_id; |
48 |
||
9 | 49 |
if ( wp_delete_link( $link_id ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
50 |
++$deleted; |
9 | 51 |
} |
0 | 52 |
} |
53 |
||
9 | 54 |
wp_redirect( "$this_file?deleted=$deleted" ); |
0 | 55 |
exit; |
56 |
||
9 | 57 |
case 'move': |
58 |
check_admin_referer( 'bulk-bookmarks' ); |
|
0 | 59 |
|
5 | 60 |
// For each link id (in $linkcheck[]) change category to selected value. |
16 | 61 |
if ( count( $linkcheck ) === 0 ) { |
9 | 62 |
wp_redirect( $this_file ); |
0 | 63 |
exit; |
64 |
} |
|
18 | 65 |
$all_links = implode( ',', $linkcheck ); |
5 | 66 |
/* |
67 |
* Should now have an array of links we can change: |
|
68 |
* $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)"); |
|
69 |
*/ |
|
0 | 70 |
|
9 | 71 |
wp_redirect( $this_file ); |
0 | 72 |
exit; |
73 |
||
9 | 74 |
case 'add': |
75 |
check_admin_referer( 'add-bookmark' ); |
|
0 | 76 |
|
77 |
$redir = wp_get_referer(); |
|
9 | 78 |
if ( add_link() ) { |
0 | 79 |
$redir = add_query_arg( 'added', 'true', $redir ); |
9 | 80 |
} |
0 | 81 |
|
82 |
wp_redirect( $redir ); |
|
83 |
exit; |
|
84 |
||
9 | 85 |
case 'save': |
0 | 86 |
$link_id = (int) $_POST['link_id']; |
9 | 87 |
check_admin_referer( 'update-bookmark_' . $link_id ); |
0 | 88 |
|
9 | 89 |
edit_link( $link_id ); |
0 | 90 |
|
9 | 91 |
wp_redirect( $this_file ); |
0 | 92 |
exit; |
93 |
||
9 | 94 |
case 'delete': |
0 | 95 |
$link_id = (int) $_GET['link_id']; |
9 | 96 |
check_admin_referer( 'delete-bookmark_' . $link_id ); |
0 | 97 |
|
9 | 98 |
wp_delete_link( $link_id ); |
0 | 99 |
|
9 | 100 |
wp_redirect( $this_file ); |
0 | 101 |
exit; |
102 |
||
9 | 103 |
case 'edit': |
104 |
wp_enqueue_script( 'link' ); |
|
105 |
wp_enqueue_script( 'xfn' ); |
|
0 | 106 |
|
9 | 107 |
if ( wp_is_mobile() ) { |
0 | 108 |
wp_enqueue_script( 'jquery-touch-punch' ); |
9 | 109 |
} |
0 | 110 |
|
9 | 111 |
$parent_file = 'link-manager.php'; |
0 | 112 |
$submenu_file = 'link-manager.php'; |
19 | 113 |
// Used in the HTML title tag. |
114 |
$title = __( 'Edit Link' ); |
|
0 | 115 |
|
116 |
$link_id = (int) $_GET['link_id']; |
|
117 |
||
16 | 118 |
$link = get_link_to_edit( $link_id ); |
119 |
if ( ! $link ) { |
|
9 | 120 |
wp_die( __( 'Link not found.' ) ); |
121 |
} |
|
0 | 122 |
|
16 | 123 |
require ABSPATH . 'wp-admin/edit-link-form.php'; |
124 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |
|
0 | 125 |
break; |
126 |
||
9 | 127 |
default: |
0 | 128 |
break; |
129 |
} |