[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Link Management Administration Screen.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  /** Load WordPress Administration Bootstrap */
  10  require_once( dirname( __FILE__ ) . '/admin.php' );
  11  if ( ! current_user_can( 'manage_links' ) ) {
  12      wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) );
  13  }
  14  
  15  $wp_list_table = _get_list_table( 'WP_Links_List_Table' );
  16  
  17  // Handle bulk deletes
  18  $doaction = $wp_list_table->current_action();
  19  
  20  if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) {
  21      check_admin_referer( 'bulk-bookmarks' );
  22  
  23      $redirect_to = admin_url( 'link-manager.php' );
  24      $bulklinks   = (array) $_REQUEST['linkcheck'];
  25  
  26      if ( 'delete' == $doaction ) {
  27          foreach ( $bulklinks as $link_id ) {
  28              $link_id = (int) $link_id;
  29  
  30              wp_delete_link( $link_id );
  31          }
  32  
  33          $redirect_to = add_query_arg( 'deleted', count( $bulklinks ), $redirect_to );
  34      } else {
  35          $screen = get_current_screen()->id;
  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
  39      }
  40      wp_redirect( $redirect_to );
  41      exit;
  42  } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
  43      wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
  44      exit;
  45  }
  46  
  47  $wp_list_table->prepare_items();
  48  
  49  $title       = __( 'Links' );
  50  $this_file   = 'link-manager.php';
  51  $parent_file = $this_file;
  52  
  53  get_current_screen()->add_help_tab(
  54      array(
  55          'id'      => 'overview',
  56          'title'   => __( 'Overview' ),
  57          'content' =>
  58              '<p>' . sprintf(
  59                  /* translators: %s: URL to Widgets screen. */
  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>',
  65      )
  66  );
  67  get_current_screen()->add_help_tab(
  68      array(
  69          'id'      => 'deleting-links',
  70          'title'   => __( 'Deleting Links' ),
  71          'content' =>
  72              '<p>' . __( 'If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.' ) . '</p>',
  73      )
  74  );
  75  
  76  get_current_screen()->set_help_sidebar(
  77      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  78      '<p>' . __( '<a href="https://codex.wordpress.org/Links_Screen">Documentation on Managing Links</a>' ) . '</p>' .
  79      '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
  80  );
  81  
  82  get_current_screen()->set_screen_reader_content(
  83      array(
  84          'heading_list' => __( 'Links list' ),
  85      )
  86  );
  87  
  88  include_once( ABSPATH . 'wp-admin/admin-header.php' );
  89  
  90  if ( ! current_user_can( 'manage_links' ) ) {
  91      wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) );
  92  }
  93  
  94  ?>
  95  
  96  <div class="wrap nosubsub">
  97  <h1 class="wp-heading-inline">
  98  <?php
  99  echo esc_html( $title );
 100  ?>
 101  </h1>
 102  
 103  <a href="link-add.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'link' ); ?></a>
 104  
 105  <?php
 106  if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
 107      /* translators: %s: Search query. */
 108      printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) );
 109  }
 110  ?>
 111  
 112  <hr class="wp-header-end">
 113  
 114  <?php
 115  if ( isset( $_REQUEST['deleted'] ) ) {
 116      echo '<div id="message" class="updated notice is-dismissible"><p>';
 117      $deleted = (int) $_REQUEST['deleted'];
 118      /* translators: %s: Number of links. */
 119      printf( _n( '%s link deleted.', '%s links deleted.', $deleted ), $deleted );
 120      echo '</p></div>';
 121      $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'deleted' ), $_SERVER['REQUEST_URI'] );
 122  }
 123  ?>
 124  
 125  <form id="posts-filter" method="get">
 126  
 127  <?php $wp_list_table->search_box( __( 'Search Links' ), 'link' ); ?>
 128  
 129  <?php $wp_list_table->display(); ?>
 130  
 131  <div id="ajax-response"></div>
 132  </form>
 133  
 134  </div>
 135  
 136  <?php
 137  include( ABSPATH . 'wp-admin/admin-footer.php' );


Generated: Mon Dec 9 01:00:03 2019 Cross-referenced by PHPXref 0.7.1