/wp-admin/edit-link-form.php

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