wp/wp-admin/includes/class-wp-links-list-table.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    56 		$args = array(
    56 		$args = array(
    57 			'hide_invisible' => 0,
    57 			'hide_invisible' => 0,
    58 			'hide_empty'     => 0,
    58 			'hide_empty'     => 0,
    59 		);
    59 		);
    60 
    60 
    61 		if ( 'all' != $cat_id ) {
    61 		if ( 'all' !== $cat_id ) {
    62 			$args['category'] = $cat_id;
    62 			$args['category'] = $cat_id;
    63 		}
    63 		}
    64 		if ( ! empty( $s ) ) {
    64 		if ( ! empty( $s ) ) {
    65 			$args['search'] = $s;
    65 			$args['search'] = $s;
    66 		}
    66 		}
    95 	 * @param string $which
    95 	 * @param string $which
    96 	 */
    96 	 */
    97 	protected function extra_tablenav( $which ) {
    97 	protected function extra_tablenav( $which ) {
    98 		global $cat_id;
    98 		global $cat_id;
    99 
    99 
   100 		if ( 'top' != $which ) {
   100 		if ( 'top' !== $which ) {
   101 			return;
   101 			return;
   102 		}
   102 		}
   103 		?>
   103 		?>
   104 		<div class="alignleft actions">
   104 		<div class="alignleft actions">
   105 		<?php
   105 			<?php
   106 			$dropdown_options = array(
   106 			$dropdown_options = array(
   107 				'selected'        => $cat_id,
   107 				'selected'        => $cat_id,
   108 				'name'            => 'cat_id',
   108 				'name'            => 'cat_id',
   109 				'taxonomy'        => 'link_category',
   109 				'taxonomy'        => 'link_category',
   110 				'show_option_all' => get_taxonomy( 'link_category' )->labels->all_items,
   110 				'show_option_all' => get_taxonomy( 'link_category' )->labels->all_items,
   115 			);
   115 			);
   116 
   116 
   117 			echo '<label class="screen-reader-text" for="cat_id">' . __( 'Filter by category' ) . '</label>';
   117 			echo '<label class="screen-reader-text" for="cat_id">' . __( 'Filter by category' ) . '</label>';
   118 			wp_dropdown_categories( $dropdown_options );
   118 			wp_dropdown_categories( $dropdown_options );
   119 			submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
   119 			submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
   120 		?>
   120 			?>
   121 		</div>
   121 		</div>
   122 		<?php
   122 		<?php
   123 	}
   123 	}
   124 
   124 
   125 	/**
   125 	/**
   167 	 *
   167 	 *
   168 	 * @param object $link The current link object.
   168 	 * @param object $link The current link object.
   169 	 */
   169 	 */
   170 	public function column_cb( $link ) {
   170 	public function column_cb( $link ) {
   171 		?>
   171 		?>
   172 		<label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf( __( 'Select %s' ), $link->link_name ); ?></label>
   172 		<label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>">
       
   173 			<?php
       
   174 			/* translators: %s: Link name. */
       
   175 			printf( __( 'Select %s' ), $link->link_name );
       
   176 			?>
       
   177 		</label>
   173 		<input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />
   178 		<input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />
   174 		<?php
   179 		<?php
   175 	}
   180 	}
   176 
   181 
   177 	/**
   182 	/**
   184 	public function column_name( $link ) {
   189 	public function column_name( $link ) {
   185 		$edit_link = get_edit_bookmark_link( $link );
   190 		$edit_link = get_edit_bookmark_link( $link );
   186 		printf(
   191 		printf(
   187 			'<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong>',
   192 			'<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong>',
   188 			$edit_link,
   193 			$edit_link,
   189 			/* translators: %s: link name */
   194 			/* translators: %s: Link name. */
   190 			esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $link->link_name ) ),
   195 			esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $link->link_name ) ),
   191 			$link->link_name
   196 			$link->link_name
   192 		);
   197 		);
   193 	}
   198 	}
   194 
   199 
   221 			$cat = get_term( $category, 'link_category', OBJECT, 'display' );
   226 			$cat = get_term( $category, 'link_category', OBJECT, 'display' );
   222 			if ( is_wp_error( $cat ) ) {
   227 			if ( is_wp_error( $cat ) ) {
   223 				echo $cat->get_error_message();
   228 				echo $cat->get_error_message();
   224 			}
   229 			}
   225 			$cat_name = $cat->name;
   230 			$cat_name = $cat->name;
   226 			if ( $cat_id != $category ) {
   231 			if ( (int) $cat_id !== $category ) {
   227 				$cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
   232 				$cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
   228 			}
   233 			}
   229 			$cat_names[] = $cat_name;
   234 			$cat_names[] = $cat_name;
   230 		}
   235 		}
   231 		echo implode( ', ', $cat_names );
   236 		echo implode( ', ', $cat_names );
   307 	 * @since 4.3.0
   312 	 * @since 4.3.0
   308 	 *
   313 	 *
   309 	 * @param object $link        Link being acted upon.
   314 	 * @param object $link        Link being acted upon.
   310 	 * @param string $column_name Current column name.
   315 	 * @param string $column_name Current column name.
   311 	 * @param string $primary     Primary column name.
   316 	 * @param string $primary     Primary column name.
   312 	 * @return string Row action output for links.
   317 	 * @return string Row actions output for links, or an empty string
       
   318 	 *                if the current column is not the primary column.
   313 	 */
   319 	 */
   314 	protected function handle_row_actions( $link, $column_name, $primary ) {
   320 	protected function handle_row_actions( $link, $column_name, $primary ) {
   315 		if ( $primary !== $column_name ) {
   321 		if ( $primary !== $column_name ) {
   316 			return '';
   322 			return '';
   317 		}
   323 		}
   318 
   324 
   319 		$edit_link = get_edit_bookmark_link( $link );
   325 		$edit_link = get_edit_bookmark_link( $link );
   320 
   326 
   321 		$actions           = array();
   327 		$actions           = array();
   322 		$actions['edit']   = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
   328 		$actions['edit']   = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
   323 		$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( "You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ) . "' ) ) { return true;}return false;\">" . __( 'Delete' ) . '</a>';
   329 		$actions['delete'] = sprintf(
       
   330 			'<a class="submitdelete" href="%s" onclick="return confirm( \'%s\' );">%s</a>',
       
   331 			wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ),
       
   332 			/* translators: %s: Link name. */
       
   333 			esc_js( sprintf( __( "You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ),
       
   334 			__( 'Delete' )
       
   335 		);
       
   336 
   324 		return $this->row_actions( $actions );
   337 		return $this->row_actions( $actions );
   325 	}
   338 	}
   326 }
   339 }