Files
WordPress/wp-admin/link.php
T

126 lines
2.7 KiB
PHP
Raw Normal View History

2006-02-27 04:57:30 +00:00
<?php
/**
* Manage link administration actions.
*
* This page is accessed by the link management pages and handles the forms and
* Ajax processes for link actions.
*
* @package WordPress
* @subpackage Administration
*/
/** Load WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
2006-02-27 04:57:30 +00:00
wp_reset_vars( array( 'action', 'cat_id', 'link_id' ) );
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
if ( ! current_user_can( 'manage_links' ) ) {
wp_link_manager_disabled_message();
2017-11-30 23:11:00 +00:00
}
2017-11-30 23:11:00 +00:00
if ( ! empty( $_POST['deletebookmarks'] ) ) {
2006-02-27 04:57:30 +00:00
$action = 'deletebookmarks';
2017-11-30 23:11:00 +00:00
}
if ( ! empty( $_POST['move'] ) ) {
2006-02-27 04:57:30 +00:00
$action = 'move';
2017-11-30 23:11:00 +00:00
}
if ( ! empty( $_POST['linkcheck'] ) ) {
$linkcheck = $_POST['linkcheck'];
2017-11-30 23:11:00 +00:00
}
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
$this_file = admin_url( 'link-manager.php' );
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
switch ( $action ) {
case 'deletebookmarks':
check_admin_referer( 'bulk-bookmarks' );
2006-02-27 04:57:30 +00:00
// For each link id (in $linkcheck[]) change category to selected value.
2017-11-30 23:11:00 +00:00
if ( count( $linkcheck ) == 0 ) {
wp_redirect( $this_file );
2006-02-27 04:57:30 +00:00
exit;
}
$deleted = 0;
2017-11-30 23:11:00 +00:00
foreach ( $linkcheck as $link_id ) {
2006-02-27 04:57:30 +00:00
$link_id = (int) $link_id;
2017-11-30 23:11:00 +00:00
if ( wp_delete_link( $link_id ) ) {
2006-02-27 04:57:30 +00:00
$deleted++;
2017-11-30 23:11:00 +00:00
}
2006-02-27 04:57:30 +00:00
}
2017-11-30 23:11:00 +00:00
wp_redirect( "$this_file?deleted=$deleted" );
2006-11-15 00:02:28 +00:00
exit;
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
case 'move':
check_admin_referer( 'bulk-bookmarks' );
2006-02-27 04:57:30 +00:00
// For each link id (in $linkcheck[]) change category to selected value.
2017-11-30 23:11:00 +00:00
if ( count( $linkcheck ) == 0 ) {
wp_redirect( $this_file );
2006-02-27 04:57:30 +00:00
exit;
}
2017-11-30 23:11:00 +00:00
$all_links = join( ',', $linkcheck );
/*
* Should now have an array of links we can change:
* $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
*/
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
wp_redirect( $this_file );
2006-11-15 00:02:28 +00:00
exit;
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
case 'add':
check_admin_referer( 'add-bookmark' );
2006-02-27 04:57:30 +00:00
$redir = wp_get_referer();
2017-11-30 23:11:00 +00:00
if ( add_link() ) {
$redir = add_query_arg( 'added', 'true', $redir );
2017-11-30 23:11:00 +00:00
}
2006-02-27 04:57:30 +00:00
wp_redirect( $redir );
2006-11-15 00:02:28 +00:00
exit;
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
case 'save':
2006-02-27 04:57:30 +00:00
$link_id = (int) $_POST['link_id'];
2017-11-30 23:11:00 +00:00
check_admin_referer( 'update-bookmark_' . $link_id );
2006-05-02 22:36:06 +00:00
2017-11-30 23:11:00 +00:00
edit_link( $link_id );
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
wp_redirect( $this_file );
2006-02-27 04:57:30 +00:00
exit;
2017-11-30 23:11:00 +00:00
case 'delete':
2006-05-02 22:36:06 +00:00
$link_id = (int) $_GET['link_id'];
2017-11-30 23:11:00 +00:00
check_admin_referer( 'delete-bookmark_' . $link_id );
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
wp_delete_link( $link_id );
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
wp_redirect( $this_file );
2006-11-15 00:02:28 +00:00
exit;
2006-02-27 04:57:30 +00:00
2017-11-30 23:11:00 +00:00
case 'edit':
wp_enqueue_script( 'link' );
wp_enqueue_script( 'xfn' );
2017-11-30 23:11:00 +00:00
if ( wp_is_mobile() ) {
wp_enqueue_script( 'jquery-touch-punch' );
2017-11-30 23:11:00 +00:00
}
2017-11-30 23:11:00 +00:00
$parent_file = 'link-manager.php';
2006-02-27 04:57:30 +00:00
$submenu_file = 'link-manager.php';
2017-11-30 23:11:00 +00:00
$title = __( 'Edit Link' );
2006-02-27 04:57:30 +00:00
$link_id = (int) $_GET['link_id'];
2017-11-30 23:11:00 +00:00
if ( ! $link = get_link_to_edit( $link_id ) ) {
wp_die( __( 'Link not found.' ) );
}
2006-02-27 04:57:30 +00:00
include( ABSPATH . 'wp-admin/edit-link-form.php' );
include( ABSPATH . 'wp-admin/admin-footer.php' );
2006-02-27 04:57:30 +00:00
break;
2017-11-30 23:11:00 +00:00
default:
2006-02-27 04:57:30 +00:00
break;
}