[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/ -> edit-link-form.php (source)

   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  
  14  if ( ! empty( $link_id ) ) {
  15      /* translators: %s: URL to Links screen. */
  16      $heading      = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' );
  17      $submit_text  = __( 'Update Link' );
  18      $form_name    = 'editlink';
  19      $nonce_action = 'update-bookmark_' . $link_id;
  20  } else {
  21      /* translators: %s: URL to Links screen. */
  22      $heading      = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), 'link-manager.php' );
  23      $submit_text  = __( 'Add Link' );
  24      $form_name    = 'addlink';
  25      $nonce_action = 'add-bookmark';
  26  }
  27  
  28  require_once  ABSPATH . 'wp-admin/includes/meta-boxes.php';
  29  
  30  add_meta_box( 'linksubmitdiv', __( 'Save' ), 'link_submit_meta_box', null, 'side', 'core' );
  31  add_meta_box( 'linkcategorydiv', __( 'Categories' ), 'link_categories_meta_box', null, 'normal', 'core' );
  32  add_meta_box( 'linktargetdiv', __( 'Target' ), 'link_target_meta_box', null, 'normal', 'core' );
  33  add_meta_box( 'linkxfndiv', __( 'Link Relationship (XFN)' ), 'link_xfn_meta_box', null, 'normal', 'core' );
  34  add_meta_box( 'linkadvanceddiv', __( 'Advanced' ), 'link_advanced_meta_box', null, 'normal', 'core' );
  35  
  36  /** This action is documented in wp-admin/includes/meta-boxes.php */
  37  do_action( 'add_meta_boxes', 'link', $link );
  38  
  39  /**
  40   * Fires when link-specific meta boxes are added.
  41   *
  42   * @since 3.0.0
  43   *
  44   * @param object $link Link object.
  45   */
  46  do_action( 'add_meta_boxes_link', $link );
  47  
  48  /** This action is documented in wp-admin/includes/meta-boxes.php */
  49  do_action( 'do_meta_boxes', 'link', 'normal', $link );
  50  /** This action is documented in wp-admin/includes/meta-boxes.php */
  51  do_action( 'do_meta_boxes', 'link', 'advanced', $link );
  52  /** This action is documented in wp-admin/includes/meta-boxes.php */
  53  do_action( 'do_meta_boxes', 'link', 'side', $link );
  54  
  55  add_screen_option(
  56      'layout_columns',
  57      array(
  58          'max'     => 2,
  59          'default' => 2,
  60      )
  61  );
  62  
  63  get_current_screen()->add_help_tab(
  64      array(
  65          'id'      => 'overview',
  66          'title'   => __( 'Overview' ),
  67          'content' =>
  68          '<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>' .
  69          '<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 do not use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '</p>' .
  70          '<p>' . __( 'XFN stands for <a href="https://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>',
  71      )
  72  );
  73  
  74  get_current_screen()->set_help_sidebar(
  75      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  76      '<p>' . __( '<a href="https://codex.wordpress.org/Links_Add_New_Screen">Documentation on Creating Links</a>' ) . '</p>' .
  77      '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
  78  );
  79  
  80  require_once  ABSPATH . 'wp-admin/admin-header.php';
  81  ?>
  82  
  83  <div class="wrap">
  84  <h1 class="wp-heading-inline">
  85  <?php
  86  echo esc_html( $title );
  87  ?>
  88  </h1>
  89  
  90  <a href="link-add.php" class="page-title-action"><?php echo esc_html__( 'Add New Link' ); ?></a>
  91  
  92  <hr class="wp-header-end">
  93  
  94  <?php
  95  if ( isset( $_GET['added'] ) ) {
  96      wp_admin_notice(
  97          __( 'Link added.' ),
  98          array(
  99              'id'                 => 'message',
 100              'additional_classes' => array( 'updated' ),
 101              'dismissible'        => true,
 102          )
 103      );
 104  }
 105  ?>
 106  
 107  <form name="<?php echo esc_attr( $form_name ); ?>" id="<?php echo esc_attr( $form_name ); ?>" method="post" action="link.php">
 108  <?php
 109  if ( ! empty( $link_added ) ) {
 110      echo $link_added;
 111  }
 112  
 113  wp_nonce_field( $nonce_action );
 114  wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
 115  wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
 116  ?>
 117  
 118  <div id="poststuff">
 119  
 120  <div id="post-body" class="metabox-holder columns-<?php echo ( 1 === get_current_screen()->get_columns() ) ? '1' : '2'; ?>">
 121  <div id="post-body-content">
 122  <div id="namediv" class="postbox">
 123  <h2 class="postbox-header"><label for="link_name"><?php _ex( 'Name', 'link name' ); ?></label></h2>
 124  <div class="inside">
 125      <input type="text" name="link_name" size="30" maxlength="255" value="<?php echo esc_attr( $link->link_name ); ?>" id="link_name" />
 126      <p><?php _e( 'Example: Nifty blogging software' ); ?></p>
 127  </div>
 128  </div>
 129  
 130  <div id="addressdiv" class="postbox">
 131  <h2 class="postbox-header"><label for="link_url"><?php _e( 'Web Address' ); ?></label></h2>
 132  <div class="inside">
 133      <input type="text" name="link_url" size="30" maxlength="255" class="code" value="<?php echo esc_url( $link->link_url ); ?>" id="link_url" />
 134      <p><?php _e( 'Example: <code>https://wordpress.org/</code> &#8212; do not forget the <code>https://</code>' ); ?></p>
 135  </div>
 136  </div>
 137  
 138  <div id="descriptiondiv" class="postbox">
 139  <h2 class="postbox-header"><label for="link_description"><?php _e( 'Description' ); ?></label></h2>
 140  <div class="inside">
 141      <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" />
 142      <p><?php _e( 'This will be shown when someone hovers over the link in the blogroll, or optionally below the link.' ); ?></p>
 143  </div>
 144  </div>
 145  </div><!-- /post-body-content -->
 146  
 147  <div id="postbox-container-1" class="postbox-container">
 148  <?php
 149  
 150  /** This action is documented in wp-admin/includes/meta-boxes.php */
 151  do_action( 'submitlink_box' );
 152  $side_meta_boxes = do_meta_boxes( 'link', 'side', $link );
 153  
 154  ?>
 155  </div>
 156  <div id="postbox-container-2" class="postbox-container">
 157  <?php
 158  
 159  do_meta_boxes( null, 'normal', $link );
 160  
 161  do_meta_boxes( null, 'advanced', $link );
 162  
 163  ?>
 164  </div>
 165  <?php
 166  
 167  if ( $link_id ) :
 168      ?>
 169  <input type="hidden" name="action" value="save" />
 170  <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
 171  <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id; ?>" />
 172  <?php else : ?>
 173  <input type="hidden" name="action" value="add" />
 174  <?php endif; ?>
 175  
 176  </div>
 177  </div>
 178  
 179  </form>
 180  </div>


Generated : Thu Apr 18 08:20:02 2024 Cross-referenced by PHPXref