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


Generated : Thu Apr 25 08:20:02 2024 Cross-referenced by PHPXref