PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-admin/link-manager.php

http://github.com/markjaquith/WordPress
PHP | 137 lines | 97 code | 28 blank | 12 comment | 10 complexity | c37eadf1d183fbfbc221268363e6106d MD5 | raw file
Possible License(s): 0BSD
  1. <?php
  2. /**
  3. * Link Management Administration Screen.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** Load WordPress Administration Bootstrap */
  9. require_once __DIR__ . '/admin.php';
  10. if ( ! current_user_can( 'manage_links' ) ) {
  11. wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) );
  12. }
  13. $wp_list_table = _get_list_table( 'WP_Links_List_Table' );
  14. // Handle bulk deletes.
  15. $doaction = $wp_list_table->current_action();
  16. if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) {
  17. check_admin_referer( 'bulk-bookmarks' );
  18. $redirect_to = admin_url( 'link-manager.php' );
  19. $bulklinks = (array) $_REQUEST['linkcheck'];
  20. if ( 'delete' == $doaction ) {
  21. foreach ( $bulklinks as $link_id ) {
  22. $link_id = (int) $link_id;
  23. wp_delete_link( $link_id );
  24. }
  25. $redirect_to = add_query_arg( 'deleted', count( $bulklinks ), $redirect_to );
  26. } else {
  27. $screen = get_current_screen()->id;
  28. /** This action is documented in wp-admin/edit.php */
  29. $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $bulklinks ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  30. }
  31. wp_redirect( $redirect_to );
  32. exit;
  33. } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
  34. wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
  35. exit;
  36. }
  37. $wp_list_table->prepare_items();
  38. $title = __( 'Links' );
  39. $this_file = 'link-manager.php';
  40. $parent_file = $this_file;
  41. get_current_screen()->add_help_tab(
  42. array(
  43. 'id' => 'overview',
  44. 'title' => __( 'Overview' ),
  45. 'content' =>
  46. '<p>' . sprintf(
  47. /* translators: %s: URL to Widgets screen. */
  48. __( '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.' ),
  49. 'widgets.php'
  50. ) . '</p>' .
  51. '<p>' . __( 'Links may be separated into Link Categories; these are different than the categories used on your posts.' ) . '</p>' .
  52. '<p>' . __( 'You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.' ) . '</p>',
  53. )
  54. );
  55. get_current_screen()->add_help_tab(
  56. array(
  57. 'id' => 'deleting-links',
  58. 'title' => __( 'Deleting Links' ),
  59. 'content' =>
  60. '<p>' . __( 'If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.' ) . '</p>',
  61. )
  62. );
  63. get_current_screen()->set_help_sidebar(
  64. '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  65. '<p>' . __( '<a href="https://codex.wordpress.org/Links_Screen">Documentation on Managing Links</a>' ) . '</p>' .
  66. '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
  67. );
  68. get_current_screen()->set_screen_reader_content(
  69. array(
  70. 'heading_list' => __( 'Links list' ),
  71. )
  72. );
  73. require_once ABSPATH . 'wp-admin/admin-header.php';
  74. if ( ! current_user_can( 'manage_links' ) ) {
  75. wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) );
  76. }
  77. ?>
  78. <div class="wrap nosubsub">
  79. <h1 class="wp-heading-inline">
  80. <?php
  81. echo esc_html( $title );
  82. ?>
  83. </h1>
  84. <a href="link-add.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'link' ); ?></a>
  85. <?php
  86. if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
  87. /* translators: %s: Search query. */
  88. printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) );
  89. }
  90. ?>
  91. <hr class="wp-header-end">
  92. <?php
  93. if ( isset( $_REQUEST['deleted'] ) ) {
  94. echo '<div id="message" class="updated notice is-dismissible"><p>';
  95. $deleted = (int) $_REQUEST['deleted'];
  96. /* translators: %s: Number of links. */
  97. printf( _n( '%s link deleted.', '%s links deleted.', $deleted ), $deleted );
  98. echo '</p></div>';
  99. $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'deleted' ), $_SERVER['REQUEST_URI'] );
  100. }
  101. ?>
  102. <form id="posts-filter" method="get">
  103. <?php $wp_list_table->search_box( __( 'Search Links' ), 'link' ); ?>
  104. <?php $wp_list_table->display(); ?>
  105. <div id="ajax-response"></div>
  106. </form>
  107. </div>
  108. <?php
  109. require_once ABSPATH . 'wp-admin/admin-footer.php';