5 * @package WordPress |
5 * @package WordPress |
6 * @subpackage Administration |
6 * @subpackage Administration |
7 */ |
7 */ |
8 |
8 |
9 /** Load WordPress Administration Bootstrap */ |
9 /** Load WordPress Administration Bootstrap */ |
10 require_once( dirname( __FILE__ ) . '/admin.php' ); |
10 require_once __DIR__ . '/admin.php'; |
11 if ( ! current_user_can( 'manage_links' ) ) { |
11 if ( ! current_user_can( 'manage_links' ) ) { |
12 wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) ); |
12 wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) ); |
13 } |
13 } |
14 |
14 |
15 $wp_list_table = _get_list_table( 'WP_Links_List_Table' ); |
15 $wp_list_table = _get_list_table( 'WP_Links_List_Table' ); |
16 |
16 |
17 // Handle bulk deletes |
17 // Handle bulk deletes. |
18 $doaction = $wp_list_table->current_action(); |
18 $doaction = $wp_list_table->current_action(); |
19 |
19 |
20 if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) { |
20 if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) { |
21 check_admin_referer( 'bulk-bookmarks' ); |
21 check_admin_referer( 'bulk-bookmarks' ); |
22 |
22 |
23 $redirect_to = admin_url( 'link-manager.php' ); |
23 $redirect_to = admin_url( 'link-manager.php' ); |
24 $bulklinks = (array) $_REQUEST['linkcheck']; |
24 $bulklinks = (array) $_REQUEST['linkcheck']; |
25 |
25 |
26 if ( 'delete' == $doaction ) { |
26 if ( 'delete' === $doaction ) { |
27 foreach ( $bulklinks as $link_id ) { |
27 foreach ( $bulklinks as $link_id ) { |
28 $link_id = (int) $link_id; |
28 $link_id = (int) $link_id; |
29 |
29 |
30 wp_delete_link( $link_id ); |
30 wp_delete_link( $link_id ); |
31 } |
31 } |
32 |
32 |
33 $redirect_to = add_query_arg( 'deleted', count( $bulklinks ), $redirect_to ); |
33 $redirect_to = add_query_arg( 'deleted', count( $bulklinks ), $redirect_to ); |
34 } else { |
34 } else { |
35 /** This action is documented in wp-admin/edit-comments.php */ |
35 $screen = get_current_screen()->id; |
36 $redirect_to = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $bulklinks ); |
36 |
|
37 /** This action is documented in wp-admin/edit.php */ |
|
38 $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $bulklinks ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
37 } |
39 } |
38 wp_redirect( $redirect_to ); |
40 wp_redirect( $redirect_to ); |
39 exit; |
41 exit; |
40 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { |
42 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { |
41 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
43 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
42 exit; |
44 exit; |
43 } |
45 } |
44 |
46 |
45 $wp_list_table->prepare_items(); |
47 $wp_list_table->prepare_items(); |
46 |
48 |
47 $title = __( 'Links' ); |
49 $title = __( 'Links' ); |
48 $this_file = $parent_file = 'link-manager.php'; |
50 $this_file = 'link-manager.php'; |
|
51 $parent_file = $this_file; |
49 |
52 |
50 get_current_screen()->add_help_tab( |
53 get_current_screen()->add_help_tab( |
51 array( |
54 array( |
52 'id' => 'overview', |
55 'id' => 'overview', |
53 'title' => __( 'Overview' ), |
56 'title' => __( 'Overview' ), |
54 'content' => |
57 'content' => |
55 '<p>' . sprintf( __( 'You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.' ), 'widgets.php' ) . '</p>' . |
58 '<p>' . sprintf( |
56 '<p>' . __( 'Links may be separated into Link Categories; these are different than the categories used on your posts.' ) . '</p>' . |
59 /* translators: %s: URL to Widgets screen. */ |
57 '<p>' . __( 'You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.' ) . '</p>', |
60 __( 'You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.' ), |
|
61 'widgets.php' |
|
62 ) . '</p>' . |
|
63 '<p>' . __( 'Links may be separated into Link Categories; these are different than the categories used on your posts.' ) . '</p>' . |
|
64 '<p>' . __( 'You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.' ) . '</p>', |
58 ) |
65 ) |
59 ); |
66 ); |
60 get_current_screen()->add_help_tab( |
67 get_current_screen()->add_help_tab( |
61 array( |
68 array( |
62 'id' => 'deleting-links', |
69 'id' => 'deleting-links', |
63 'title' => __( 'Deleting Links' ), |
70 'title' => __( 'Deleting Links' ), |
64 'content' => |
71 'content' => |
65 '<p>' . __( 'If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.' ) . '</p>', |
72 '<p>' . __( 'If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.' ) . '</p>', |
66 ) |
73 ) |
67 ); |
74 ); |
68 |
75 |
69 get_current_screen()->set_help_sidebar( |
76 get_current_screen()->set_help_sidebar( |
70 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
77 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
95 |
102 |
96 <a href="link-add.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'link' ); ?></a> |
103 <a href="link-add.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'link' ); ?></a> |
97 |
104 |
98 <?php |
105 <?php |
99 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
106 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
100 /* translators: %s: search keywords */ |
107 /* translators: %s: Search query. */ |
101 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) ); |
108 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) ); |
102 } |
109 } |
103 ?> |
110 ?> |
104 |
111 |
105 <hr class="wp-header-end"> |
112 <hr class="wp-header-end"> |
106 |
113 |
107 <?php |
114 <?php |
108 if ( isset( $_REQUEST['deleted'] ) ) { |
115 if ( isset( $_REQUEST['deleted'] ) ) { |
109 echo '<div id="message" class="updated notice is-dismissible"><p>'; |
116 echo '<div id="message" class="updated notice is-dismissible"><p>'; |
110 $deleted = (int) $_REQUEST['deleted']; |
117 $deleted = (int) $_REQUEST['deleted']; |
111 printf( _n( '%s link deleted.', '%s links deleted', $deleted ), $deleted ); |
118 /* translators: %s: Number of links. */ |
|
119 printf( _n( '%s link deleted.', '%s links deleted.', $deleted ), $deleted ); |
112 echo '</p></div>'; |
120 echo '</p></div>'; |
113 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'deleted' ), $_SERVER['REQUEST_URI'] ); |
121 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'deleted' ), $_SERVER['REQUEST_URI'] ); |
114 } |
122 } |
115 ?> |
123 ?> |
116 |
124 |