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