[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/ -> link.php (source)

   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  __DIR__ . '/admin.php';
  14  
  15  $action  = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
  16  $cat_id  = ! empty( $_REQUEST['cat_id'] ) ? absint( $_REQUEST['cat_id'] ) : 0;
  17  $link_id = ! empty( $_REQUEST['link_id'] ) ? absint( $_REQUEST['link_id'] ) : 0;
  18  
  19  if ( ! current_user_can( 'manage_links' ) ) {
  20      wp_link_manager_disabled_message();
  21  }
  22  
  23  if ( ! empty( $_POST['deletebookmarks'] ) ) {
  24      $action = 'deletebookmarks';
  25  }
  26  if ( ! empty( $_POST['move'] ) ) {
  27      $action = 'move';
  28  }
  29  if ( ! empty( $_POST['linkcheck'] ) ) {
  30      $linkcheck = $_POST['linkcheck'];
  31  }
  32  
  33  $this_file = admin_url( 'link-manager.php' );
  34  
  35  switch ( $action ) {
  36      case 'deletebookmarks':
  37          check_admin_referer( 'bulk-bookmarks' );
  38  
  39          // For each link id (in $linkcheck[]) change category to selected value.
  40          if ( count( $linkcheck ) === 0 ) {
  41              wp_redirect( $this_file );
  42              exit;
  43          }
  44  
  45          $deleted = 0;
  46          foreach ( $linkcheck as $link_id ) {
  47              $link_id = (int) $link_id;
  48  
  49              if ( wp_delete_link( $link_id ) ) {
  50                  ++$deleted;
  51              }
  52          }
  53  
  54          wp_redirect( "$this_file?deleted=$deleted" );
  55          exit;
  56  
  57      case 'move':
  58          check_admin_referer( 'bulk-bookmarks' );
  59  
  60          // For each link id (in $linkcheck[]) change category to selected value.
  61          if ( count( $linkcheck ) === 0 ) {
  62              wp_redirect( $this_file );
  63              exit;
  64          }
  65          $all_links = implode( ',', $linkcheck );
  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           */
  70  
  71          wp_redirect( $this_file );
  72          exit;
  73  
  74      case 'add':
  75          check_admin_referer( 'add-bookmark' );
  76  
  77          $redir = wp_get_referer();
  78          if ( add_link() ) {
  79              $redir = add_query_arg( 'added', 'true', $redir );
  80          }
  81  
  82          wp_redirect( $redir );
  83          exit;
  84  
  85      case 'save':
  86          $link_id = (int) $_POST['link_id'];
  87          check_admin_referer( 'update-bookmark_' . $link_id );
  88  
  89          edit_link( $link_id );
  90  
  91          wp_redirect( $this_file );
  92          exit;
  93  
  94      case 'delete':
  95          $link_id = (int) $_GET['link_id'];
  96          check_admin_referer( 'delete-bookmark_' . $link_id );
  97  
  98          wp_delete_link( $link_id );
  99  
 100          wp_redirect( $this_file );
 101          exit;
 102  
 103      case 'edit':
 104          wp_enqueue_script( 'link' );
 105          wp_enqueue_script( 'xfn' );
 106  
 107          if ( wp_is_mobile() ) {
 108              wp_enqueue_script( 'jquery-touch-punch' );
 109          }
 110  
 111          $parent_file  = 'link-manager.php';
 112          $submenu_file = 'link-manager.php';
 113          // Used in the HTML title tag.
 114          $title = __( 'Edit Link' );
 115  
 116          $link_id = (int) $_GET['link_id'];
 117  
 118          $link = get_link_to_edit( $link_id );
 119          if ( ! $link ) {
 120              wp_die( __( 'Link not found.' ) );
 121          }
 122  
 123          require  ABSPATH . 'wp-admin/edit-link-form.php';
 124          require_once  ABSPATH . 'wp-admin/admin-footer.php';
 125          break;
 126  
 127      default:
 128          break;
 129  }


Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref