edit-link-form.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * Edit links form for inclusion in administration panels.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. // don't load directly
  9. if ( !defined('ABSPATH') )
  10. die('-1');
  11. if ( ! empty($link_id) ) {
  12. $heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' );
  13. $submit_text = __('Update Link');
  14. $form_name = 'editlink';
  15. $nonce_action = 'update-bookmark_' . $link_id;
  16. } else {
  17. $heading = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), 'link-manager.php' );
  18. $submit_text = __('Add Link');
  19. $form_name = 'addlink';
  20. $nonce_action = 'add-bookmark';
  21. }
  22. require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' );
  23. add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', null, 'side', 'core');
  24. add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', null, 'normal', 'core');
  25. add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', null, 'normal', 'core');
  26. add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', null, 'normal', 'core');
  27. add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', null, 'normal', 'core');
  28. /** This action is documented in wp-admin/edit-form-advanced.php */
  29. do_action( 'add_meta_boxes', 'link', $link );
  30. /**
  31. * Fires when link-specific meta boxes are added.
  32. *
  33. * @since 3.0.0
  34. *
  35. * @param object $link Link object.
  36. */
  37. do_action( 'add_meta_boxes_link', $link );
  38. /** This action is documented in wp-admin/edit-form-advanced.php */
  39. do_action( 'do_meta_boxes', 'link', 'normal', $link );
  40. /** This action is documented in wp-admin/edit-form-advanced.php */
  41. do_action( 'do_meta_boxes', 'link', 'advanced', $link );
  42. /** This action is documented in wp-admin/edit-form-advanced.php */
  43. do_action( 'do_meta_boxes', 'link', 'side', $link );
  44. add_screen_option('layout_columns', array('max' => 2, 'default' => 2) );
  45. get_current_screen()->add_help_tab( array(
  46. 'id' => 'overview',
  47. 'title' => __('Overview'),
  48. 'content' =>
  49. '<p>' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link&#8217;s web address and name (the text you want to display on your site as the link) are required fields.' ) . '</p>' .
  50. '<p>' . __( 'The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you don&#8217;t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '</p>' .
  51. '<p>' . __( 'XFN stands for <a href="http://gmpg.org/xfn/">XHTML Friends Network</a>, which is optional. WordPress allows the generation of XFN attributes to show how you are related to the authors/owners of the site to which you are linking.' ) . '</p>'
  52. ) );
  53. get_current_screen()->set_help_sidebar(
  54. '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  55. '<p>' . __( '<a href="https://codex.wordpress.org/Links_Add_New_Screen">Documentation on Creating Links</a>' ) . '</p>' .
  56. '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
  57. );
  58. require_once( ABSPATH . 'wp-admin/admin-header.php' );
  59. ?>
  60. <div class="wrap">
  61. <h1 class="wp-heading-inline"><?php
  62. echo esc_html( $title );
  63. ?></h1>
  64. <a href="link-add.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'link' ); ?></a>
  65. <hr class="wp-header-end">
  66. <?php if ( isset( $_GET['added'] ) ) : ?>
  67. <div id="message" class="updated notice is-dismissible"><p><?php _e('Link added.'); ?></p></div>
  68. <?php endif; ?>
  69. <form name="<?php echo esc_attr( $form_name ); ?>" id="<?php echo esc_attr( $form_name ); ?>" method="post" action="link.php">
  70. <?php
  71. if ( ! empty( $link_added ) ) {
  72. echo $link_added;
  73. }
  74. wp_nonce_field( $nonce_action );
  75. wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
  76. wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
  77. <div id="poststuff">
  78. <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
  79. <div id="post-body-content">
  80. <div id="namediv" class="stuffbox">
  81. <h2><label for="link_name"><?php _ex( 'Name', 'link name' ) ?></label></h2>
  82. <div class="inside">
  83. <input type="text" name="link_name" size="30" maxlength="255" value="<?php echo esc_attr($link->link_name); ?>" id="link_name" />
  84. <p><?php _e('Example: Nifty blogging software'); ?></p>
  85. </div>
  86. </div>
  87. <div id="addressdiv" class="stuffbox">
  88. <h2><label for="link_url"><?php _e( 'Web Address' ) ?></label></h2>
  89. <div class="inside">
  90. <input type="text" name="link_url" size="30" maxlength="255" class="code" value="<?php echo esc_attr($link->link_url); ?>" id="link_url" />
  91. <p><?php _e('Example: <code>http://wordpress.org/</code> &#8212; don&#8217;t forget the <code>http://</code>'); ?></p>
  92. </div>
  93. </div>
  94. <div id="descriptiondiv" class="stuffbox">
  95. <h2><label for="link_description"><?php _e( 'Description' ) ?></label></h2>
  96. <div class="inside">
  97. <input type="text" name="link_description" size="30" maxlength="255" value="<?php echo isset($link->link_description) ? esc_attr($link->link_description) : ''; ?>" id="link_description" />
  98. <p><?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?></p>
  99. </div>
  100. </div>
  101. </div><!-- /post-body-content -->
  102. <div id="postbox-container-1" class="postbox-container">
  103. <?php
  104. /** This action is documented in wp-admin/includes/meta-boxes.php */
  105. do_action( 'submitlink_box' );
  106. $side_meta_boxes = do_meta_boxes( 'link', 'side', $link );
  107. ?>
  108. </div>
  109. <div id="postbox-container-2" class="postbox-container">
  110. <?php
  111. do_meta_boxes(null, 'normal', $link);
  112. do_meta_boxes(null, 'advanced', $link);
  113. ?>
  114. </div>
  115. <?php
  116. if ( $link_id ) : ?>
  117. <input type="hidden" name="action" value="save" />
  118. <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
  119. <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
  120. <?php else: ?>
  121. <input type="hidden" name="action" value="add" />
  122. <?php endif; ?>
  123. </div>
  124. </div>
  125. </form>
  126. </div>