Нет описания

link-manager.php 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. echo '<span class="subtitle">';
  88. printf(
  89. /* translators: %s: Search query. */
  90. __( 'Search results for: %s' ),
  91. '<strong>' . esc_html( wp_unslash( $_REQUEST['s'] ) ) . '</strong>'
  92. );
  93. echo '</span>';
  94. }
  95. ?>
  96. <hr class="wp-header-end">
  97. <?php
  98. if ( isset( $_REQUEST['deleted'] ) ) {
  99. echo '<div id="message" class="updated notice is-dismissible"><p>';
  100. $deleted = (int) $_REQUEST['deleted'];
  101. /* translators: %s: Number of links. */
  102. printf( _n( '%s link deleted.', '%s links deleted.', $deleted ), $deleted );
  103. echo '</p></div>';
  104. $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'deleted' ), $_SERVER['REQUEST_URI'] );
  105. }
  106. ?>
  107. <form id="posts-filter" method="get">
  108. <?php $wp_list_table->search_box( __( 'Search Links' ), 'link' ); ?>
  109. <?php $wp_list_table->display(); ?>
  110. <div id="ajax-response"></div>
  111. </form>
  112. </div>
  113. <?php
  114. require_once ABSPATH . 'wp-admin/admin-footer.php';