Version Description
(20/12/2015) = Bug Fixes
- Fixed issues with older version of WordPress.
- Fixed issues with older version of PHP.
Download this release
Release Info
| Developer | joelcj91 |
| Plugin | |
| Version | 2.1.1 |
| Comparing to | |
| See all releases | |
Code changes from version 2.1.0 to 2.1.1
404-to-301.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* Plugin Name: 404 to 301
|
| 4 |
* Plugin URI: http://iscode.co/products/404-to-301/
|
| 5 |
* Description: Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.
|
| 6 |
-
* Version: 2.1.
|
| 7 |
* Author: Joel James
|
| 8 |
* Author URI: http://iscode.co/
|
| 9 |
* Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
|
|
@@ -52,7 +52,7 @@ if(!defined('I4T3_DB_VERSION')) {
|
|
| 52 |
define( 'I4T3_DB_VERSION', '3' );
|
| 53 |
}
|
| 54 |
if(!defined('I4T3_VERSION')) {
|
| 55 |
-
define( 'I4T3_VERSION', '2.1.
|
| 56 |
}
|
| 57 |
// Set who all can access 404 settings. You can change this if you want to give others access.
|
| 58 |
if(!defined('I4T3_ADMIN_PERMISSION')) {
|
| 3 |
* Plugin Name: 404 to 301
|
| 4 |
* Plugin URI: http://iscode.co/products/404-to-301/
|
| 5 |
* Description: Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.
|
| 6 |
+
* Version: 2.1.1
|
| 7 |
* Author: Joel James
|
| 8 |
* Author URI: http://iscode.co/
|
| 9 |
* Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
|
| 52 |
define( 'I4T3_DB_VERSION', '3' );
|
| 53 |
}
|
| 54 |
if(!defined('I4T3_VERSION')) {
|
| 55 |
+
define( 'I4T3_VERSION', '2.1.1' );
|
| 56 |
}
|
| 57 |
// Set who all can access 404 settings. You can change this if you want to give others access.
|
| 58 |
if(!defined('I4T3_ADMIN_PERMISSION')) {
|
admin/class-404-to-301-admin.php
CHANGED
|
@@ -215,11 +215,11 @@ class _404_To_301_Admin {
|
|
| 215 |
public function screen_option() {
|
| 216 |
|
| 217 |
$option = 'per_page';
|
| 218 |
-
$args =
|
| 219 |
'label' => __( 'Error Logs', '404-to-301' ),
|
| 220 |
'default' => 5,
|
| 221 |
'option' => 'logs_per_page'
|
| 222 |
-
|
| 223 |
|
| 224 |
add_screen_option( $option, $args );
|
| 225 |
|
| 215 |
public function screen_option() {
|
| 216 |
|
| 217 |
$option = 'per_page';
|
| 218 |
+
$args = array(
|
| 219 |
'label' => __( 'Error Logs', '404-to-301' ),
|
| 220 |
'default' => 5,
|
| 221 |
'option' => 'logs_per_page'
|
| 222 |
+
);
|
| 223 |
|
| 224 |
add_screen_option( $option, $args );
|
| 225 |
|
admin/class-404-to-301-logs.php
CHANGED
|
@@ -10,7 +10,13 @@ if ( ! defined( 'WPINC' ) ) {
|
|
| 10 |
* So we have copied this class and using independently to avoid future issues.
|
| 11 |
*/
|
| 12 |
if( ! class_exists( 'WP_List_Table_404' ) ) {
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
|
| 16 |
/**
|
|
@@ -335,14 +341,14 @@ class _404_To_301_Logs extends WP_List_Table_404 {
|
|
| 335 |
*/
|
| 336 |
function get_columns() {
|
| 337 |
|
| 338 |
-
$columns =
|
| 339 |
'cb' => '<input type="checkbox" style="width: 5%;" />',
|
| 340 |
'date'=> __( 'Date and Time', '404-to-301' ),
|
| 341 |
'url' => __( '404 Path', '404-to-301' ),
|
| 342 |
'ref' => __( 'Came From', '404-to-301' ), // referer
|
| 343 |
'ip' => __( 'IP Address', '404-to-301' ),
|
| 344 |
'ua' => __( 'User Agent', '404-to-301' )
|
| 345 |
-
|
| 346 |
|
| 347 |
return $columns;
|
| 348 |
}
|
|
@@ -383,10 +389,10 @@ class _404_To_301_Logs extends WP_List_Table_404 {
|
|
| 383 |
*/
|
| 384 |
public function get_bulk_actions() {
|
| 385 |
|
| 386 |
-
$actions =
|
| 387 |
'bulk-delete' => __('Delete Selected', '404-to-301' ),
|
| 388 |
'bulk-all-delete' => __( 'Delete All', '404-to-301' )
|
| 389 |
-
|
| 390 |
|
| 391 |
return $actions;
|
| 392 |
}
|
|
@@ -418,10 +424,10 @@ class _404_To_301_Logs extends WP_List_Table_404 {
|
|
| 418 |
$current_page = $this->get_pagenum();
|
| 419 |
$total_items = self::record_count();
|
| 420 |
|
| 421 |
-
$this->set_pagination_args(
|
| 422 |
'total_items' => $total_items, //WE have to calculate the total number of items
|
| 423 |
'per_page' => $per_page //WE have to determine how many items to show on a page
|
| 424 |
-
|
| 425 |
|
| 426 |
$this->items = self::i4t3_get_log_data( $per_page, $current_page );
|
| 427 |
}
|
| 10 |
* So we have copied this class and using independently to avoid future issues.
|
| 11 |
*/
|
| 12 |
if( ! class_exists( 'WP_List_Table_404' ) ) {
|
| 13 |
+
|
| 14 |
+
global $wp_version;
|
| 15 |
+
if ( $wp_version >= 4.4 ) {
|
| 16 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/core/class-wp-list-table-4.4.php';
|
| 17 |
+
} else {
|
| 18 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/core/class-wp-list-table-old.php';
|
| 19 |
+
}
|
| 20 |
}
|
| 21 |
|
| 22 |
/**
|
| 341 |
*/
|
| 342 |
function get_columns() {
|
| 343 |
|
| 344 |
+
$columns = array(
|
| 345 |
'cb' => '<input type="checkbox" style="width: 5%;" />',
|
| 346 |
'date'=> __( 'Date and Time', '404-to-301' ),
|
| 347 |
'url' => __( '404 Path', '404-to-301' ),
|
| 348 |
'ref' => __( 'Came From', '404-to-301' ), // referer
|
| 349 |
'ip' => __( 'IP Address', '404-to-301' ),
|
| 350 |
'ua' => __( 'User Agent', '404-to-301' )
|
| 351 |
+
);
|
| 352 |
|
| 353 |
return $columns;
|
| 354 |
}
|
| 389 |
*/
|
| 390 |
public function get_bulk_actions() {
|
| 391 |
|
| 392 |
+
$actions = array(
|
| 393 |
'bulk-delete' => __('Delete Selected', '404-to-301' ),
|
| 394 |
'bulk-all-delete' => __( 'Delete All', '404-to-301' )
|
| 395 |
+
);
|
| 396 |
|
| 397 |
return $actions;
|
| 398 |
}
|
| 424 |
$current_page = $this->get_pagenum();
|
| 425 |
$total_items = self::record_count();
|
| 426 |
|
| 427 |
+
$this->set_pagination_args( array(
|
| 428 |
'total_items' => $total_items, //WE have to calculate the total number of items
|
| 429 |
'per_page' => $per_page //WE have to determine how many items to show on a page
|
| 430 |
+
) );
|
| 431 |
|
| 432 |
$this->items = self::i4t3_get_log_data( $per_page, $current_page );
|
| 433 |
}
|
admin/core/{class-wp-list-table.php → class-wp-list-table-4.4.php}
RENAMED
|
File without changes
|
admin/core/class-wp-list-table-old.php
ADDED
|
@@ -0,0 +1,1143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Base class for displaying a list of items in an ajaxified HTML table.
|
| 4 |
+
* We are not using this class from core WordPress since it is not
|
| 5 |
+
* recommended by WordPress itself.
|
| 6 |
+
*
|
| 7 |
+
* @since 3.1.0
|
| 8 |
+
* @access private
|
| 9 |
+
*
|
| 10 |
+
* @package I4T3
|
| 11 |
+
* @subpackage I4T3/List_Table
|
| 12 |
+
*/
|
| 13 |
+
class WP_List_Table_404 {
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* The current list of items
|
| 17 |
+
*
|
| 18 |
+
* @since 3.1.0
|
| 19 |
+
* @var array
|
| 20 |
+
* @access public
|
| 21 |
+
*/
|
| 22 |
+
public $items;
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Various information about the current table
|
| 26 |
+
*
|
| 27 |
+
* @since 3.1.0
|
| 28 |
+
* @var array
|
| 29 |
+
* @access protected
|
| 30 |
+
*/
|
| 31 |
+
protected $_args;
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Various information needed for displaying the pagination
|
| 35 |
+
*
|
| 36 |
+
* @since 3.1.0
|
| 37 |
+
* @var array
|
| 38 |
+
*/
|
| 39 |
+
protected $_pagination_args = array();
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* The current screen
|
| 43 |
+
*
|
| 44 |
+
* @since 3.1.0
|
| 45 |
+
* @var object
|
| 46 |
+
* @access protected
|
| 47 |
+
*/
|
| 48 |
+
protected $screen;
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Cached bulk actions
|
| 52 |
+
*
|
| 53 |
+
* @since 3.1.0
|
| 54 |
+
* @var array
|
| 55 |
+
* @access private
|
| 56 |
+
*/
|
| 57 |
+
private $_actions;
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Cached pagination output
|
| 61 |
+
*
|
| 62 |
+
* @since 3.1.0
|
| 63 |
+
* @var string
|
| 64 |
+
* @access private
|
| 65 |
+
*/
|
| 66 |
+
private $_pagination;
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* The view switcher modes.
|
| 70 |
+
*
|
| 71 |
+
* @since 4.1.0
|
| 72 |
+
* @var array
|
| 73 |
+
* @access protected
|
| 74 |
+
*/
|
| 75 |
+
protected $modes = array();
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* Stores the value returned by ->get_column_info()
|
| 79 |
+
*
|
| 80 |
+
* @var array
|
| 81 |
+
*/
|
| 82 |
+
protected $_column_headers;
|
| 83 |
+
|
| 84 |
+
protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' );
|
| 85 |
+
|
| 86 |
+
protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions',
|
| 87 |
+
'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination',
|
| 88 |
+
'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav',
|
| 89 |
+
'single_row_columns' );
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Constructor.
|
| 93 |
+
*
|
| 94 |
+
* The child class should call this constructor from its own constructor to override
|
| 95 |
+
* the default $args.
|
| 96 |
+
*
|
| 97 |
+
* @since 3.1.0
|
| 98 |
+
* @access public
|
| 99 |
+
*
|
| 100 |
+
* @param array|string $args {
|
| 101 |
+
* Array or string of arguments.
|
| 102 |
+
*
|
| 103 |
+
* @type string $plural Plural value used for labels and the objects being listed.
|
| 104 |
+
* This affects things such as CSS class-names and nonces used
|
| 105 |
+
* in the list table, e.g. 'posts'. Default empty.
|
| 106 |
+
* @type string $singular Singular label for an object being listed, e.g. 'post'.
|
| 107 |
+
* Default empty
|
| 108 |
+
* @type bool $ajax Whether the list table supports AJAX. This includes loading
|
| 109 |
+
* and sorting data, for example. If true, the class will call
|
| 110 |
+
* the {@see _js_vars()} method in the footer to provide variables
|
| 111 |
+
* to any scripts handling AJAX events. Default false.
|
| 112 |
+
* @type string $screen String containing the hook name used to determine the current
|
| 113 |
+
* screen. If left null, the current screen will be automatically set.
|
| 114 |
+
* Default null.
|
| 115 |
+
* }
|
| 116 |
+
*/
|
| 117 |
+
public function __construct( $args = array() ) {
|
| 118 |
+
$args = wp_parse_args( $args, array(
|
| 119 |
+
'plural' => '',
|
| 120 |
+
'singular' => '',
|
| 121 |
+
'ajax' => false,
|
| 122 |
+
'screen' => null,
|
| 123 |
+
) );
|
| 124 |
+
|
| 125 |
+
$this->screen = convert_to_screen( $args['screen'] );
|
| 126 |
+
|
| 127 |
+
add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
|
| 128 |
+
|
| 129 |
+
if ( !$args['plural'] )
|
| 130 |
+
$args['plural'] = $this->screen->base;
|
| 131 |
+
|
| 132 |
+
$args['plural'] = sanitize_key( $args['plural'] );
|
| 133 |
+
$args['singular'] = sanitize_key( $args['singular'] );
|
| 134 |
+
|
| 135 |
+
$this->_args = $args;
|
| 136 |
+
|
| 137 |
+
if ( $args['ajax'] ) {
|
| 138 |
+
// wp_enqueue_script( 'list-table' );
|
| 139 |
+
add_action( 'admin_footer', array( $this, '_js_vars' ) );
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
if ( empty( $this->modes ) ) {
|
| 143 |
+
$this->modes = array(
|
| 144 |
+
'list' => __( 'List View', '404-to-301' ),
|
| 145 |
+
'excerpt' => __( 'Excerpt View', '404-to-301' )
|
| 146 |
+
);
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/**
|
| 151 |
+
* Make private properties readable for backwards compatibility.
|
| 152 |
+
*
|
| 153 |
+
* @since 4.0.0
|
| 154 |
+
* @access public
|
| 155 |
+
*
|
| 156 |
+
* @param string $name Property to get.
|
| 157 |
+
* @return mixed Property.
|
| 158 |
+
*/
|
| 159 |
+
public function __get( $name ) {
|
| 160 |
+
if ( in_array( $name, $this->compat_fields ) ) {
|
| 161 |
+
return $this->$name;
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* Make private properties settable for backwards compatibility.
|
| 167 |
+
*
|
| 168 |
+
* @since 4.0.0
|
| 169 |
+
* @access public
|
| 170 |
+
*
|
| 171 |
+
* @param string $name Property to check if set.
|
| 172 |
+
* @param mixed $value Property value.
|
| 173 |
+
* @return mixed Newly-set property.
|
| 174 |
+
*/
|
| 175 |
+
public function __set( $name, $value ) {
|
| 176 |
+
if ( in_array( $name, $this->compat_fields ) ) {
|
| 177 |
+
return $this->$name = $value;
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* Make private properties checkable for backwards compatibility.
|
| 183 |
+
*
|
| 184 |
+
* @since 4.0.0
|
| 185 |
+
* @access public
|
| 186 |
+
*
|
| 187 |
+
* @param string $name Property to check if set.
|
| 188 |
+
* @return bool Whether the property is set.
|
| 189 |
+
*/
|
| 190 |
+
public function __isset( $name ) {
|
| 191 |
+
if ( in_array( $name, $this->compat_fields ) ) {
|
| 192 |
+
return isset( $this->$name );
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
/**
|
| 197 |
+
* Make private properties un-settable for backwards compatibility.
|
| 198 |
+
*
|
| 199 |
+
* @since 4.0.0
|
| 200 |
+
* @access public
|
| 201 |
+
*
|
| 202 |
+
* @param string $name Property to unset.
|
| 203 |
+
*/
|
| 204 |
+
public function __unset( $name ) {
|
| 205 |
+
if ( in_array( $name, $this->compat_fields ) ) {
|
| 206 |
+
unset( $this->$name );
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
* Make private/protected methods readable for backwards compatibility.
|
| 212 |
+
*
|
| 213 |
+
* @since 4.0.0
|
| 214 |
+
* @access public
|
| 215 |
+
*
|
| 216 |
+
* @param callable $name Method to call.
|
| 217 |
+
* @param array $arguments Arguments to pass when calling.
|
| 218 |
+
* @return mixed|bool Return value of the callback, false otherwise.
|
| 219 |
+
*/
|
| 220 |
+
public function __call( $name, $arguments ) {
|
| 221 |
+
if ( in_array( $name, $this->compat_methods ) ) {
|
| 222 |
+
return call_user_func_array( array( $this, $name ), $arguments );
|
| 223 |
+
}
|
| 224 |
+
return false;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
/**
|
| 228 |
+
* Checks the current user's permissions
|
| 229 |
+
*
|
| 230 |
+
* @since 3.1.0
|
| 231 |
+
* @access public
|
| 232 |
+
* @abstract
|
| 233 |
+
*/
|
| 234 |
+
public function ajax_user_can() {
|
| 235 |
+
die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' );
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
/**
|
| 239 |
+
* Prepares the list of items for displaying.
|
| 240 |
+
* @uses WP_List_Table::set_pagination_args()
|
| 241 |
+
*
|
| 242 |
+
* @since 3.1.0
|
| 243 |
+
* @access public
|
| 244 |
+
* @abstract
|
| 245 |
+
*/
|
| 246 |
+
public function prepare_items() {
|
| 247 |
+
die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' );
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
* An internal method that sets all the necessary pagination arguments
|
| 252 |
+
*
|
| 253 |
+
* @param array $args An associative array with information about the pagination
|
| 254 |
+
* @access protected
|
| 255 |
+
*/
|
| 256 |
+
protected function set_pagination_args( $args ) {
|
| 257 |
+
$args = wp_parse_args( $args, array(
|
| 258 |
+
'total_items' => 0,
|
| 259 |
+
'total_pages' => 0,
|
| 260 |
+
'per_page' => 0,
|
| 261 |
+
) );
|
| 262 |
+
|
| 263 |
+
if ( !$args['total_pages'] && $args['per_page'] > 0 )
|
| 264 |
+
$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
|
| 265 |
+
|
| 266 |
+
// Redirect if page number is invalid and headers are not already sent.
|
| 267 |
+
if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
|
| 268 |
+
wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
|
| 269 |
+
exit;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
$this->_pagination_args = $args;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
* Access the pagination args.
|
| 277 |
+
*
|
| 278 |
+
* @since 3.1.0
|
| 279 |
+
* @access public
|
| 280 |
+
*
|
| 281 |
+
* @param string $key Pagination argument to retrieve. Common values include 'total_items',
|
| 282 |
+
* 'total_pages', 'per_page', or 'infinite_scroll'.
|
| 283 |
+
* @return int Number of items that correspond to the given pagination argument.
|
| 284 |
+
*/
|
| 285 |
+
public function get_pagination_arg( $key ) {
|
| 286 |
+
if ( 'page' == $key )
|
| 287 |
+
return $this->get_pagenum();
|
| 288 |
+
|
| 289 |
+
if ( isset( $this->_pagination_args[$key] ) )
|
| 290 |
+
return $this->_pagination_args[$key];
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
/**
|
| 294 |
+
* Whether the table has items to display or not
|
| 295 |
+
*
|
| 296 |
+
* @since 3.1.0
|
| 297 |
+
* @access public
|
| 298 |
+
*
|
| 299 |
+
* @return bool
|
| 300 |
+
*/
|
| 301 |
+
public function has_items() {
|
| 302 |
+
return !empty( $this->items );
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
/**
|
| 306 |
+
* Message to be displayed when there are no items
|
| 307 |
+
*
|
| 308 |
+
* @since 3.1.0
|
| 309 |
+
* @access public
|
| 310 |
+
*/
|
| 311 |
+
public function no_items() {
|
| 312 |
+
_e( 'No items found.' );
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
/**
|
| 316 |
+
* Display the search box.
|
| 317 |
+
*
|
| 318 |
+
* @since 3.1.0
|
| 319 |
+
* @access public
|
| 320 |
+
*
|
| 321 |
+
* @param string $text The search button text
|
| 322 |
+
* @param string $input_id The search input id
|
| 323 |
+
*/
|
| 324 |
+
public function search_box( $text, $input_id ) {
|
| 325 |
+
if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
|
| 326 |
+
return;
|
| 327 |
+
|
| 328 |
+
$input_id = $input_id . '-search-input';
|
| 329 |
+
|
| 330 |
+
if ( ! empty( $_REQUEST['orderby'] ) )
|
| 331 |
+
echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
|
| 332 |
+
if ( ! empty( $_REQUEST['order'] ) )
|
| 333 |
+
echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
|
| 334 |
+
if ( ! empty( $_REQUEST['post_mime_type'] ) )
|
| 335 |
+
echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
|
| 336 |
+
if ( ! empty( $_REQUEST['detached'] ) )
|
| 337 |
+
echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
|
| 338 |
+
?>
|
| 339 |
+
<p class="search-box">
|
| 340 |
+
<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
|
| 341 |
+
<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
|
| 342 |
+
<?php submit_button( $text, 'button', '', false, array('id' => 'search-submit') ); ?>
|
| 343 |
+
</p>
|
| 344 |
+
<?php
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
/**
|
| 348 |
+
* Get an associative array ( id => link ) with the list
|
| 349 |
+
* of views available on this table.
|
| 350 |
+
*
|
| 351 |
+
* @since 3.1.0
|
| 352 |
+
* @access protected
|
| 353 |
+
*
|
| 354 |
+
* @return array
|
| 355 |
+
*/
|
| 356 |
+
protected function get_views() {
|
| 357 |
+
return array();
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
/**
|
| 361 |
+
* Display the list of views available on this table.
|
| 362 |
+
*
|
| 363 |
+
* @since 3.1.0
|
| 364 |
+
* @access public
|
| 365 |
+
*/
|
| 366 |
+
public function views() {
|
| 367 |
+
$views = $this->get_views();
|
| 368 |
+
/**
|
| 369 |
+
* Filter the list of available list table views.
|
| 370 |
+
*
|
| 371 |
+
* The dynamic portion of the hook name, `$this->screen->id`, refers
|
| 372 |
+
* to the ID of the current screen, usually a string.
|
| 373 |
+
*
|
| 374 |
+
* @since 3.5.0
|
| 375 |
+
*
|
| 376 |
+
* @param array $views An array of available list table views.
|
| 377 |
+
*/
|
| 378 |
+
$views = apply_filters( "views_{$this->screen->id}", $views );
|
| 379 |
+
|
| 380 |
+
if ( empty( $views ) )
|
| 381 |
+
return;
|
| 382 |
+
|
| 383 |
+
echo "<ul class='subsubsub'>\n";
|
| 384 |
+
foreach ( $views as $class => $view ) {
|
| 385 |
+
$views[ $class ] = "\t<li class='$class'>$view";
|
| 386 |
+
}
|
| 387 |
+
echo implode( " |</li>\n", $views ) . "</li>\n";
|
| 388 |
+
echo "</ul>";
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
/**
|
| 392 |
+
* Get an associative array ( option_name => option_title ) with the list
|
| 393 |
+
* of bulk actions available on this table.
|
| 394 |
+
*
|
| 395 |
+
* @since 3.1.0
|
| 396 |
+
* @access protected
|
| 397 |
+
*
|
| 398 |
+
* @return array
|
| 399 |
+
*/
|
| 400 |
+
protected function get_bulk_actions() {
|
| 401 |
+
return array();
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
/**
|
| 405 |
+
* Display the bulk actions dropdown.
|
| 406 |
+
*
|
| 407 |
+
* @since 3.1.0
|
| 408 |
+
* @access protected
|
| 409 |
+
*
|
| 410 |
+
* @param string $which The location of the bulk actions: 'top' or 'bottom'.
|
| 411 |
+
* This is designated as optional for backwards-compatibility.
|
| 412 |
+
*/
|
| 413 |
+
protected function bulk_actions( $which = '' ) {
|
| 414 |
+
if ( is_null( $this->_actions ) ) {
|
| 415 |
+
$no_new_actions = $this->_actions = $this->get_bulk_actions();
|
| 416 |
+
/**
|
| 417 |
+
* Filter the list table Bulk Actions drop-down.
|
| 418 |
+
*
|
| 419 |
+
* The dynamic portion of the hook name, `$this->screen->id`, refers
|
| 420 |
+
* to the ID of the current screen, usually a string.
|
| 421 |
+
*
|
| 422 |
+
* This filter can currently only be used to remove bulk actions.
|
| 423 |
+
*
|
| 424 |
+
* @since 3.5.0
|
| 425 |
+
*
|
| 426 |
+
* @param array $actions An array of the available bulk actions.
|
| 427 |
+
*/
|
| 428 |
+
$this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
|
| 429 |
+
$this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
|
| 430 |
+
$two = '';
|
| 431 |
+
} else {
|
| 432 |
+
$two = '2';
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
if ( empty( $this->_actions ) )
|
| 436 |
+
return;
|
| 437 |
+
|
| 438 |
+
echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . __( 'Select bulk action', '404-to-301' ) . "</label>";
|
| 439 |
+
echo "<select name='action$two' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n";
|
| 440 |
+
echo "<option value='-1' selected='selected'>" . __( 'Bulk Actions', '404-to-301' ) . "</option>\n";
|
| 441 |
+
|
| 442 |
+
foreach ( $this->_actions as $name => $title ) {
|
| 443 |
+
$class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
|
| 444 |
+
|
| 445 |
+
echo "\t<option value='$name'$class>$title</option>\n";
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
echo "</select>\n";
|
| 449 |
+
|
| 450 |
+
submit_button( __( 'Apply', '404-to-301' ), 'action', '', false, array( 'id' => "doaction$two" ) );
|
| 451 |
+
echo "\n";
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
/**
|
| 455 |
+
* Get the current action selected from the bulk actions dropdown.
|
| 456 |
+
*
|
| 457 |
+
* @since 3.1.0
|
| 458 |
+
* @access public
|
| 459 |
+
*
|
| 460 |
+
* @return string|bool The action name or False if no action was selected
|
| 461 |
+
*/
|
| 462 |
+
public function current_action() {
|
| 463 |
+
if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) )
|
| 464 |
+
return false;
|
| 465 |
+
|
| 466 |
+
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
|
| 467 |
+
return $_REQUEST['action'];
|
| 468 |
+
|
| 469 |
+
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
|
| 470 |
+
return $_REQUEST['action2'];
|
| 471 |
+
|
| 472 |
+
return false;
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
/**
|
| 476 |
+
* Generate row actions div
|
| 477 |
+
*
|
| 478 |
+
* @since 3.1.0
|
| 479 |
+
* @access protected
|
| 480 |
+
*
|
| 481 |
+
* @param array $actions The list of actions
|
| 482 |
+
* @param bool $always_visible Whether the actions should be always visible
|
| 483 |
+
* @return string
|
| 484 |
+
*/
|
| 485 |
+
protected function row_actions( $actions, $always_visible = false ) {
|
| 486 |
+
$action_count = count( $actions );
|
| 487 |
+
$i = 0;
|
| 488 |
+
|
| 489 |
+
if ( !$action_count )
|
| 490 |
+
return '';
|
| 491 |
+
|
| 492 |
+
$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
|
| 493 |
+
foreach ( $actions as $action => $link ) {
|
| 494 |
+
++$i;
|
| 495 |
+
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
| 496 |
+
$out .= "<span class='$action'>$link$sep</span>";
|
| 497 |
+
}
|
| 498 |
+
$out .= '</div>';
|
| 499 |
+
|
| 500 |
+
return $out;
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
/**
|
| 504 |
+
* Display a monthly dropdown for filtering items
|
| 505 |
+
*
|
| 506 |
+
* @since 3.1.0
|
| 507 |
+
* @access protected
|
| 508 |
+
*
|
| 509 |
+
* @param string $post_type
|
| 510 |
+
*/
|
| 511 |
+
protected function months_dropdown( $post_type ) {
|
| 512 |
+
global $wpdb, $wp_locale;
|
| 513 |
+
|
| 514 |
+
/**
|
| 515 |
+
* Filter whether to remove the 'Months' drop-down from the post list table.
|
| 516 |
+
*
|
| 517 |
+
* @since 4.2.0
|
| 518 |
+
*
|
| 519 |
+
* @param bool $disable Whether to disable the drop-down. Default false.
|
| 520 |
+
* @param string $post_type The post type.
|
| 521 |
+
*/
|
| 522 |
+
if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) {
|
| 523 |
+
return;
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
$months = $wpdb->get_results( $wpdb->prepare( "
|
| 527 |
+
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
| 528 |
+
FROM $wpdb->posts
|
| 529 |
+
WHERE post_type = %s
|
| 530 |
+
ORDER BY post_date DESC
|
| 531 |
+
", $post_type ) );
|
| 532 |
+
|
| 533 |
+
/**
|
| 534 |
+
* Filter the 'Months' drop-down results.
|
| 535 |
+
*
|
| 536 |
+
* @since 3.7.0
|
| 537 |
+
*
|
| 538 |
+
* @param object $months The months drop-down query results.
|
| 539 |
+
* @param string $post_type The post type.
|
| 540 |
+
*/
|
| 541 |
+
$months = apply_filters( 'months_dropdown_results', $months, $post_type );
|
| 542 |
+
|
| 543 |
+
$month_count = count( $months );
|
| 544 |
+
|
| 545 |
+
if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
|
| 546 |
+
return;
|
| 547 |
+
|
| 548 |
+
$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
|
| 549 |
+
?>
|
| 550 |
+
<label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label>
|
| 551 |
+
<select name="m" id="filter-by-date">
|
| 552 |
+
<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
|
| 553 |
+
<?php
|
| 554 |
+
foreach ( $months as $arc_row ) {
|
| 555 |
+
if ( 0 == $arc_row->year )
|
| 556 |
+
continue;
|
| 557 |
+
|
| 558 |
+
$month = zeroise( $arc_row->month, 2 );
|
| 559 |
+
$year = $arc_row->year;
|
| 560 |
+
|
| 561 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
| 562 |
+
selected( $m, $year . $month, false ),
|
| 563 |
+
esc_attr( $arc_row->year . $month ),
|
| 564 |
+
/* translators: 1: month name, 2: 4-digit year */
|
| 565 |
+
sprintf( __( '%1$s %2$d', '404-to-301' ), $wp_locale->get_month( $month ), $year )
|
| 566 |
+
);
|
| 567 |
+
}
|
| 568 |
+
?>
|
| 569 |
+
</select>
|
| 570 |
+
<?php
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
/**
|
| 574 |
+
* Display a view switcher
|
| 575 |
+
*
|
| 576 |
+
* @since 3.1.0
|
| 577 |
+
* @access protected
|
| 578 |
+
*
|
| 579 |
+
* @param string $current_mode
|
| 580 |
+
*/
|
| 581 |
+
protected function view_switcher( $current_mode ) {
|
| 582 |
+
?>
|
| 583 |
+
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
|
| 584 |
+
<div class="view-switch">
|
| 585 |
+
<?php
|
| 586 |
+
foreach ( $this->modes as $mode => $title ) {
|
| 587 |
+
$classes = array( 'view-' . $mode );
|
| 588 |
+
if ( $current_mode == $mode )
|
| 589 |
+
$classes[] = 'current';
|
| 590 |
+
printf(
|
| 591 |
+
"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
|
| 592 |
+
esc_url( add_query_arg( 'mode', $mode ) ),
|
| 593 |
+
implode( ' ', $classes ),
|
| 594 |
+
$title
|
| 595 |
+
);
|
| 596 |
+
}
|
| 597 |
+
?>
|
| 598 |
+
</div>
|
| 599 |
+
<?php
|
| 600 |
+
}
|
| 601 |
+
|
| 602 |
+
/**
|
| 603 |
+
* Display a comment count bubble
|
| 604 |
+
*
|
| 605 |
+
* @since 3.1.0
|
| 606 |
+
* @access protected
|
| 607 |
+
*
|
| 608 |
+
* @param int $post_id The post ID.
|
| 609 |
+
* @param int $pending_comments Number of pending comments.
|
| 610 |
+
*/
|
| 611 |
+
protected function comments_bubble( $post_id, $pending_comments ) {
|
| 612 |
+
$pending_phrase = sprintf( __( '%s pending', '404-to-301' ), number_format( $pending_comments ) );
|
| 613 |
+
|
| 614 |
+
if ( $pending_comments )
|
| 615 |
+
echo '<strong>';
|
| 616 |
+
|
| 617 |
+
echo "<a href='" . esc_url( add_query_arg( 'p', $post_id, admin_url( 'edit-comments.php' ) ) ) . "' title='" . esc_attr( $pending_phrase ) . "' class='post-com-count'><span class='comment-count'>" . number_format_i18n( get_comments_number() ) . "</span></a>";
|
| 618 |
+
|
| 619 |
+
if ( $pending_comments )
|
| 620 |
+
echo '</strong>';
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
/**
|
| 624 |
+
* Get the current page number
|
| 625 |
+
*
|
| 626 |
+
* @since 3.1.0
|
| 627 |
+
* @access public
|
| 628 |
+
*
|
| 629 |
+
* @return int
|
| 630 |
+
*/
|
| 631 |
+
public function get_pagenum() {
|
| 632 |
+
$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
|
| 633 |
+
|
| 634 |
+
if( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
|
| 635 |
+
$pagenum = $this->_pagination_args['total_pages'];
|
| 636 |
+
|
| 637 |
+
return max( 1, $pagenum );
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
/**
|
| 641 |
+
* Get number of items to display on a single page
|
| 642 |
+
*
|
| 643 |
+
* @since 3.1.0
|
| 644 |
+
* @access protected
|
| 645 |
+
*
|
| 646 |
+
* @param string $option
|
| 647 |
+
* @param int $default
|
| 648 |
+
* @return int
|
| 649 |
+
*/
|
| 650 |
+
protected function get_items_per_page( $option, $default = 20 ) {
|
| 651 |
+
$per_page = (int) get_user_option( $option );
|
| 652 |
+
if ( empty( $per_page ) || $per_page < 1 )
|
| 653 |
+
$per_page = $default;
|
| 654 |
+
|
| 655 |
+
/**
|
| 656 |
+
* Filter the number of items to be displayed on each page of the list table.
|
| 657 |
+
*
|
| 658 |
+
* The dynamic hook name, $option, refers to the `per_page` option depending
|
| 659 |
+
* on the type of list table in use. Possible values include: 'edit_comments_per_page',
|
| 660 |
+
* 'sites_network_per_page', 'site_themes_network_per_page', 'themes_network_per_page',
|
| 661 |
+
* 'users_network_per_page', 'edit_post_per_page', 'edit_page_per_page',
|
| 662 |
+
* 'edit_{$post_type}_per_page', etc.
|
| 663 |
+
*
|
| 664 |
+
* @since 2.9.0
|
| 665 |
+
*
|
| 666 |
+
* @param int $per_page Number of items to be displayed. Default 20.
|
| 667 |
+
*/
|
| 668 |
+
return (int) apply_filters( $option, $per_page );
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
/**
|
| 672 |
+
* Display the pagination.
|
| 673 |
+
*
|
| 674 |
+
* @since 3.1.0
|
| 675 |
+
* @access protected
|
| 676 |
+
*
|
| 677 |
+
* @param string $which
|
| 678 |
+
*/
|
| 679 |
+
protected function pagination( $which ) {
|
| 680 |
+
if ( empty( $this->_pagination_args ) ) {
|
| 681 |
+
return;
|
| 682 |
+
}
|
| 683 |
+
|
| 684 |
+
$total_items = $this->_pagination_args['total_items'];
|
| 685 |
+
$total_pages = $this->_pagination_args['total_pages'];
|
| 686 |
+
$infinite_scroll = false;
|
| 687 |
+
if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
|
| 688 |
+
$infinite_scroll = $this->_pagination_args['infinite_scroll'];
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
+
$output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
|
| 692 |
+
|
| 693 |
+
$current = $this->get_pagenum();
|
| 694 |
+
|
| 695 |
+
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
|
| 696 |
+
|
| 697 |
+
$current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
|
| 698 |
+
|
| 699 |
+
$page_links = array();
|
| 700 |
+
|
| 701 |
+
$disable_first = $disable_last = '';
|
| 702 |
+
if ( $current == 1 ) {
|
| 703 |
+
$disable_first = ' disabled';
|
| 704 |
+
}
|
| 705 |
+
if ( $current == $total_pages ) {
|
| 706 |
+
$disable_last = ' disabled';
|
| 707 |
+
}
|
| 708 |
+
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
| 709 |
+
'first-page' . $disable_first,
|
| 710 |
+
esc_attr__( 'Go to the first page', '404-to-301' ),
|
| 711 |
+
esc_url( remove_query_arg( 'paged', $current_url ) ),
|
| 712 |
+
'«'
|
| 713 |
+
);
|
| 714 |
+
|
| 715 |
+
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
| 716 |
+
'prev-page' . $disable_first,
|
| 717 |
+
esc_attr__( 'Go to the previous page', '404-to-301' ),
|
| 718 |
+
esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
|
| 719 |
+
'‹'
|
| 720 |
+
);
|
| 721 |
+
|
| 722 |
+
if ( 'bottom' == $which ) {
|
| 723 |
+
$html_current_page = $current;
|
| 724 |
+
} else {
|
| 725 |
+
$html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' title='%s' type='text' name='paged' value='%s' size='%d' />",
|
| 726 |
+
'<label for="current-page-selector" class="screen-reader-text">' . __( 'Select Page', '404-to-301' ) . '</label>',
|
| 727 |
+
esc_attr__( 'Current page', '404-to-301' ),
|
| 728 |
+
$current,
|
| 729 |
+
strlen( $total_pages )
|
| 730 |
+
);
|
| 731 |
+
}
|
| 732 |
+
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
| 733 |
+
$page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
|
| 734 |
+
|
| 735 |
+
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
| 736 |
+
'next-page' . $disable_last,
|
| 737 |
+
esc_attr__( 'Go to the next page', '404-to-301' ),
|
| 738 |
+
esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
|
| 739 |
+
'›'
|
| 740 |
+
);
|
| 741 |
+
|
| 742 |
+
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
| 743 |
+
'last-page' . $disable_last,
|
| 744 |
+
esc_attr__( 'Go to the last page', '404-to-301' ),
|
| 745 |
+
esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
|
| 746 |
+
'»'
|
| 747 |
+
);
|
| 748 |
+
|
| 749 |
+
$pagination_links_class = 'pagination-links';
|
| 750 |
+
if ( ! empty( $infinite_scroll ) ) {
|
| 751 |
+
$pagination_links_class = ' hide-if-js';
|
| 752 |
+
}
|
| 753 |
+
$output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
|
| 754 |
+
|
| 755 |
+
if ( $total_pages ) {
|
| 756 |
+
$page_class = $total_pages < 2 ? ' one-page' : '';
|
| 757 |
+
} else {
|
| 758 |
+
$page_class = ' no-pages';
|
| 759 |
+
}
|
| 760 |
+
$this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
|
| 761 |
+
|
| 762 |
+
echo $this->_pagination;
|
| 763 |
+
}
|
| 764 |
+
|
| 765 |
+
/**
|
| 766 |
+
* Get a list of columns. The format is:
|
| 767 |
+
* 'internal-name' => 'Title'
|
| 768 |
+
*
|
| 769 |
+
* @since 3.1.0
|
| 770 |
+
* @access public
|
| 771 |
+
* @abstract
|
| 772 |
+
*
|
| 773 |
+
* @return array
|
| 774 |
+
*/
|
| 775 |
+
public function get_columns() {
|
| 776 |
+
die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
|
| 777 |
+
}
|
| 778 |
+
|
| 779 |
+
/**
|
| 780 |
+
* Get a list of sortable columns. The format is:
|
| 781 |
+
* 'internal-name' => 'orderby'
|
| 782 |
+
* or
|
| 783 |
+
* 'internal-name' => array( 'orderby', true )
|
| 784 |
+
*
|
| 785 |
+
* The second format will make the initial sorting order be descending
|
| 786 |
+
*
|
| 787 |
+
* @since 3.1.0
|
| 788 |
+
* @access protected
|
| 789 |
+
*
|
| 790 |
+
* @return array
|
| 791 |
+
*/
|
| 792 |
+
protected function get_sortable_columns() {
|
| 793 |
+
return array();
|
| 794 |
+
}
|
| 795 |
+
|
| 796 |
+
/**
|
| 797 |
+
* Get a list of all, hidden and sortable columns, with filter applied
|
| 798 |
+
*
|
| 799 |
+
* @since 3.1.0
|
| 800 |
+
* @access protected
|
| 801 |
+
*
|
| 802 |
+
* @return array
|
| 803 |
+
*/
|
| 804 |
+
protected function get_column_info() {
|
| 805 |
+
if ( isset( $this->_column_headers ) )
|
| 806 |
+
return $this->_column_headers;
|
| 807 |
+
|
| 808 |
+
$columns = get_column_headers( $this->screen );
|
| 809 |
+
$hidden = get_hidden_columns( $this->screen );
|
| 810 |
+
|
| 811 |
+
$sortable_columns = $this->get_sortable_columns();
|
| 812 |
+
/**
|
| 813 |
+
* Filter the list table sortable columns for a specific screen.
|
| 814 |
+
*
|
| 815 |
+
* The dynamic portion of the hook name, `$this->screen->id`, refers
|
| 816 |
+
* to the ID of the current screen, usually a string.
|
| 817 |
+
*
|
| 818 |
+
* @since 3.5.0
|
| 819 |
+
*
|
| 820 |
+
* @param array $sortable_columns An array of sortable columns.
|
| 821 |
+
*/
|
| 822 |
+
$_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
|
| 823 |
+
|
| 824 |
+
$sortable = array();
|
| 825 |
+
foreach ( $_sortable as $id => $data ) {
|
| 826 |
+
if ( empty( $data ) )
|
| 827 |
+
continue;
|
| 828 |
+
|
| 829 |
+
$data = (array) $data;
|
| 830 |
+
if ( !isset( $data[1] ) )
|
| 831 |
+
$data[1] = false;
|
| 832 |
+
|
| 833 |
+
$sortable[$id] = $data;
|
| 834 |
+
}
|
| 835 |
+
|
| 836 |
+
$this->_column_headers = array( $columns, $hidden, $sortable );
|
| 837 |
+
|
| 838 |
+
return $this->_column_headers;
|
| 839 |
+
}
|
| 840 |
+
|
| 841 |
+
/**
|
| 842 |
+
* Return number of visible columns
|
| 843 |
+
*
|
| 844 |
+
* @since 3.1.0
|
| 845 |
+
* @access public
|
| 846 |
+
*
|
| 847 |
+
* @return int
|
| 848 |
+
*/
|
| 849 |
+
public function get_column_count() {
|
| 850 |
+
list ( $columns, $hidden ) = $this->get_column_info();
|
| 851 |
+
$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
|
| 852 |
+
return count( $columns ) - count( $hidden );
|
| 853 |
+
}
|
| 854 |
+
|
| 855 |
+
/**
|
| 856 |
+
* Print column headers, accounting for hidden and sortable columns.
|
| 857 |
+
*
|
| 858 |
+
* @since 3.1.0
|
| 859 |
+
* @access public
|
| 860 |
+
*
|
| 861 |
+
* @param bool $with_id Whether to set the id attribute or not
|
| 862 |
+
*/
|
| 863 |
+
public function print_column_headers( $with_id = true ) {
|
| 864 |
+
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
| 865 |
+
|
| 866 |
+
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
|
| 867 |
+
$current_url = remove_query_arg( 'paged', $current_url );
|
| 868 |
+
|
| 869 |
+
if ( isset( $_GET['orderby'] ) )
|
| 870 |
+
$current_orderby = $_GET['orderby'];
|
| 871 |
+
else
|
| 872 |
+
$current_orderby = '';
|
| 873 |
+
|
| 874 |
+
if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] )
|
| 875 |
+
$current_order = 'desc';
|
| 876 |
+
else
|
| 877 |
+
$current_order = 'asc';
|
| 878 |
+
|
| 879 |
+
if ( ! empty( $columns['cb'] ) ) {
|
| 880 |
+
static $cb_counter = 1;
|
| 881 |
+
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', '404-to-301' ) . '</label>'
|
| 882 |
+
. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
|
| 883 |
+
$cb_counter++;
|
| 884 |
+
}
|
| 885 |
+
|
| 886 |
+
foreach ( $columns as $column_key => $column_display_name ) {
|
| 887 |
+
$class = array( 'manage-column', "column-$column_key" );
|
| 888 |
+
|
| 889 |
+
$style = '';
|
| 890 |
+
if ( in_array( $column_key, $hidden ) )
|
| 891 |
+
$style = 'display:none;';
|
| 892 |
+
|
| 893 |
+
$style = ' style="' . $style . '"';
|
| 894 |
+
|
| 895 |
+
if ( 'cb' == $column_key )
|
| 896 |
+
$class[] = 'check-column';
|
| 897 |
+
elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
|
| 898 |
+
$class[] = 'num';
|
| 899 |
+
|
| 900 |
+
if ( isset( $sortable[$column_key] ) ) {
|
| 901 |
+
list( $orderby, $desc_first ) = $sortable[$column_key];
|
| 902 |
+
|
| 903 |
+
if ( $current_orderby == $orderby ) {
|
| 904 |
+
$order = 'asc' == $current_order ? 'desc' : 'asc';
|
| 905 |
+
$class[] = 'sorted';
|
| 906 |
+
$class[] = $current_order;
|
| 907 |
+
} else {
|
| 908 |
+
$order = $desc_first ? 'desc' : 'asc';
|
| 909 |
+
$class[] = 'sortable';
|
| 910 |
+
$class[] = $desc_first ? 'asc' : 'desc';
|
| 911 |
+
}
|
| 912 |
+
|
| 913 |
+
$column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
|
| 914 |
+
}
|
| 915 |
+
|
| 916 |
+
$id = $with_id ? "id='$column_key'" : '';
|
| 917 |
+
|
| 918 |
+
if ( !empty( $class ) )
|
| 919 |
+
$class = "class='" . join( ' ', $class ) . "'";
|
| 920 |
+
|
| 921 |
+
echo "<th scope='col' $id $class $style>$column_display_name</th>";
|
| 922 |
+
}
|
| 923 |
+
}
|
| 924 |
+
|
| 925 |
+
/**
|
| 926 |
+
* Display the table
|
| 927 |
+
*
|
| 928 |
+
* @since 3.1.0
|
| 929 |
+
* @access public
|
| 930 |
+
*/
|
| 931 |
+
public function display() {
|
| 932 |
+
$singular = $this->_args['singular'];
|
| 933 |
+
|
| 934 |
+
$this->display_tablenav( 'top' );
|
| 935 |
+
|
| 936 |
+
?>
|
| 937 |
+
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
|
| 938 |
+
<thead>
|
| 939 |
+
<tr>
|
| 940 |
+
<?php $this->print_column_headers(); ?>
|
| 941 |
+
</tr>
|
| 942 |
+
</thead>
|
| 943 |
+
|
| 944 |
+
<tbody id="the-list"<?php
|
| 945 |
+
if ( $singular ) {
|
| 946 |
+
echo " data-wp-lists='list:$singular'";
|
| 947 |
+
} ?>>
|
| 948 |
+
<?php $this->display_rows_or_placeholder(); ?>
|
| 949 |
+
</tbody>
|
| 950 |
+
|
| 951 |
+
<tfoot>
|
| 952 |
+
<tr>
|
| 953 |
+
<?php $this->print_column_headers( false ); ?>
|
| 954 |
+
</tr>
|
| 955 |
+
</tfoot>
|
| 956 |
+
|
| 957 |
+
</table>
|
| 958 |
+
<?php
|
| 959 |
+
$this->display_tablenav( 'bottom' );
|
| 960 |
+
}
|
| 961 |
+
|
| 962 |
+
/**
|
| 963 |
+
* Get a list of CSS classes for the list table table tag.
|
| 964 |
+
*
|
| 965 |
+
* @since 3.1.0
|
| 966 |
+
* @access protected
|
| 967 |
+
*
|
| 968 |
+
* @return array List of CSS classes for the table tag.
|
| 969 |
+
*/
|
| 970 |
+
protected function get_table_classes() {
|
| 971 |
+
return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] );
|
| 972 |
+
}
|
| 973 |
+
|
| 974 |
+
/**
|
| 975 |
+
* Generate the table navigation above or below the table
|
| 976 |
+
*
|
| 977 |
+
* @since 3.1.0
|
| 978 |
+
* @access protected
|
| 979 |
+
* @param string $which
|
| 980 |
+
*/
|
| 981 |
+
protected function display_tablenav( $which ) {
|
| 982 |
+
if ( 'top' == $which )
|
| 983 |
+
wp_nonce_field( 'bulk-' . $this->_args['plural'] );
|
| 984 |
+
?>
|
| 985 |
+
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
| 986 |
+
|
| 987 |
+
<div class="alignleft actions bulkactions">
|
| 988 |
+
<?php $this->bulk_actions( $which ); ?>
|
| 989 |
+
</div>
|
| 990 |
+
<?php
|
| 991 |
+
$this->extra_tablenav( $which );
|
| 992 |
+
$this->pagination( $which );
|
| 993 |
+
?>
|
| 994 |
+
|
| 995 |
+
<br class="clear" />
|
| 996 |
+
</div>
|
| 997 |
+
<?php
|
| 998 |
+
}
|
| 999 |
+
|
| 1000 |
+
/**
|
| 1001 |
+
* Extra controls to be displayed between bulk actions and pagination
|
| 1002 |
+
*
|
| 1003 |
+
* @since 3.1.0
|
| 1004 |
+
* @access protected
|
| 1005 |
+
*
|
| 1006 |
+
* @param string $which
|
| 1007 |
+
*/
|
| 1008 |
+
protected function extra_tablenav( $which ) {}
|
| 1009 |
+
|
| 1010 |
+
/**
|
| 1011 |
+
* Generate the tbody element for the list table.
|
| 1012 |
+
*
|
| 1013 |
+
* @since 3.1.0
|
| 1014 |
+
* @access public
|
| 1015 |
+
*/
|
| 1016 |
+
public function display_rows_or_placeholder() {
|
| 1017 |
+
if ( $this->has_items() ) {
|
| 1018 |
+
$this->display_rows();
|
| 1019 |
+
} else {
|
| 1020 |
+
echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
|
| 1021 |
+
$this->no_items();
|
| 1022 |
+
echo '</td></tr>';
|
| 1023 |
+
}
|
| 1024 |
+
}
|
| 1025 |
+
|
| 1026 |
+
/**
|
| 1027 |
+
* Generate the table rows
|
| 1028 |
+
*
|
| 1029 |
+
* @since 3.1.0
|
| 1030 |
+
* @access public
|
| 1031 |
+
*/
|
| 1032 |
+
public function display_rows() {
|
| 1033 |
+
foreach ( $this->items as $item )
|
| 1034 |
+
$this->single_row( $item );
|
| 1035 |
+
}
|
| 1036 |
+
|
| 1037 |
+
/**
|
| 1038 |
+
* Generates content for a single row of the table
|
| 1039 |
+
*
|
| 1040 |
+
* @since 3.1.0
|
| 1041 |
+
* @access public
|
| 1042 |
+
*
|
| 1043 |
+
* @param object $item The current item
|
| 1044 |
+
*/
|
| 1045 |
+
public function single_row( $item ) {
|
| 1046 |
+
echo '<tr>';
|
| 1047 |
+
$this->single_row_columns( $item );
|
| 1048 |
+
echo '</tr>';
|
| 1049 |
+
}
|
| 1050 |
+
|
| 1051 |
+
protected function column_default( $item, $column_name ) {}
|
| 1052 |
+
|
| 1053 |
+
protected function column_cb( $item ) {}
|
| 1054 |
+
|
| 1055 |
+
/**
|
| 1056 |
+
* Generates the columns for a single row of the table
|
| 1057 |
+
*
|
| 1058 |
+
* @since 3.1.0
|
| 1059 |
+
* @access protected
|
| 1060 |
+
*
|
| 1061 |
+
* @param object $item The current item
|
| 1062 |
+
*/
|
| 1063 |
+
protected function single_row_columns( $item ) {
|
| 1064 |
+
list( $columns, $hidden ) = $this->get_column_info();
|
| 1065 |
+
|
| 1066 |
+
foreach ( $columns as $column_name => $column_display_name ) {
|
| 1067 |
+
$class = "class='$column_name column-$column_name'";
|
| 1068 |
+
|
| 1069 |
+
$style = '';
|
| 1070 |
+
if ( in_array( $column_name, $hidden ) )
|
| 1071 |
+
$style = ' style="display:none;"';
|
| 1072 |
+
|
| 1073 |
+
$attributes = "$class$style";
|
| 1074 |
+
|
| 1075 |
+
if ( 'cb' == $column_name ) {
|
| 1076 |
+
echo '<th scope="row" class="check-column">';
|
| 1077 |
+
echo $this->column_cb( $item );
|
| 1078 |
+
echo '</th>';
|
| 1079 |
+
}
|
| 1080 |
+
elseif ( method_exists( $this, 'column_' . $column_name ) ) {
|
| 1081 |
+
echo "<td $attributes>";
|
| 1082 |
+
echo call_user_func( array( $this, 'column_' . $column_name ), $item );
|
| 1083 |
+
echo "</td>";
|
| 1084 |
+
}
|
| 1085 |
+
else {
|
| 1086 |
+
echo "<td $attributes>";
|
| 1087 |
+
echo $this->column_default( $item, $column_name );
|
| 1088 |
+
echo "</td>";
|
| 1089 |
+
}
|
| 1090 |
+
}
|
| 1091 |
+
}
|
| 1092 |
+
|
| 1093 |
+
/**
|
| 1094 |
+
* Handle an incoming ajax request (called from admin-ajax.php)
|
| 1095 |
+
*
|
| 1096 |
+
* @since 3.1.0
|
| 1097 |
+
* @access public
|
| 1098 |
+
*/
|
| 1099 |
+
public function ajax_response() {
|
| 1100 |
+
$this->prepare_items();
|
| 1101 |
+
|
| 1102 |
+
ob_start();
|
| 1103 |
+
if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
|
| 1104 |
+
$this->display_rows();
|
| 1105 |
+
} else {
|
| 1106 |
+
$this->display_rows_or_placeholder();
|
| 1107 |
+
}
|
| 1108 |
+
|
| 1109 |
+
$rows = ob_get_clean();
|
| 1110 |
+
|
| 1111 |
+
$response = array( 'rows' => $rows );
|
| 1112 |
+
|
| 1113 |
+
if ( isset( $this->_pagination_args['total_items'] ) ) {
|
| 1114 |
+
$response['total_items_i18n'] = sprintf(
|
| 1115 |
+
_n( '1 item', '%s items', $this->_pagination_args['total_items'] ),
|
| 1116 |
+
number_format_i18n( $this->_pagination_args['total_items'] )
|
| 1117 |
+
);
|
| 1118 |
+
}
|
| 1119 |
+
if ( isset( $this->_pagination_args['total_pages'] ) ) {
|
| 1120 |
+
$response['total_pages'] = $this->_pagination_args['total_pages'];
|
| 1121 |
+
$response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
|
| 1122 |
+
}
|
| 1123 |
+
|
| 1124 |
+
die( wp_json_encode( $response ) );
|
| 1125 |
+
}
|
| 1126 |
+
|
| 1127 |
+
/**
|
| 1128 |
+
* Send required variables to JavaScript land
|
| 1129 |
+
*
|
| 1130 |
+
* @access public
|
| 1131 |
+
*/
|
| 1132 |
+
public function _js_vars() {
|
| 1133 |
+
$args = array(
|
| 1134 |
+
'class' => get_class( $this ),
|
| 1135 |
+
'screen' => array(
|
| 1136 |
+
'id' => $this->screen->id,
|
| 1137 |
+
'base' => $this->screen->base,
|
| 1138 |
+
)
|
| 1139 |
+
);
|
| 1140 |
+
|
| 1141 |
+
printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );
|
| 1142 |
+
}
|
| 1143 |
+
}
|
includes/class-404-to-301.php
CHANGED
|
@@ -67,7 +67,7 @@ class _404_To_301 {
|
|
| 67 |
public function __construct() {
|
| 68 |
|
| 69 |
$this->plugin_name = '404-to-301';
|
| 70 |
-
$this->version = '2.1.
|
| 71 |
$this->table = $GLOBALS['wpdb']->prefix . '404_to_301';
|
| 72 |
$this->load_dependencies();
|
| 73 |
$this->set_locale();
|
| 67 |
public function __construct() {
|
| 68 |
|
| 69 |
$this->plugin_name = '404-to-301';
|
| 70 |
+
$this->version = '2.1.1';
|
| 71 |
$this->table = $GLOBALS['wpdb']->prefix . '404_to_301';
|
| 72 |
$this->load_dependencies();
|
| 73 |
$this->set_locale();
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Tags: 404, 301, 302, 307, not found, 404 redirect, 404 to 301, 301 redirect, seo
|
|
| 4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
|
| 5 |
Requires at least: 3.0
|
| 6 |
Tested up to: 4.4
|
| 7 |
-
Stable tag: 2.1.
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -112,6 +112,12 @@ Bug reports for 404 to 301 are always welcome. [Report here](http://iscode.co/bu
|
|
| 112 |
|
| 113 |
== Changelog ==
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
= 2.1.0 (20/12/2015) =
|
| 116 |
**New Feature**
|
| 117 |
|
|
@@ -229,16 +235,8 @@ Bug reports for 404 to 301 are always welcome. [Report here](http://iscode.co/bu
|
|
| 229 |
|
| 230 |
== Upgrade Notice ==
|
| 231 |
|
| 232 |
-
= 2.1.
|
| 233 |
-
**New Feature**
|
| 234 |
-
|
| 235 |
-
- New option to set items per page from error log listing page.
|
| 236 |
-
- New option to show or hide items from listing table (Screen option).
|
| 237 |
-
|
| 238 |
-
**Improvements**
|
| 239 |
-
|
| 240 |
-
- Improved error listing page table structure.
|
| 241 |
-
|
| 242 |
**Bug Fixes**
|
| 243 |
|
| 244 |
-
- Fixed
|
|
|
| 4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
|
| 5 |
Requires at least: 3.0
|
| 6 |
Tested up to: 4.4
|
| 7 |
+
Stable tag: 2.1.1
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 112 |
|
| 113 |
== Changelog ==
|
| 114 |
|
| 115 |
+
= 2.1.1 (20/12/2015) =
|
| 116 |
+
**Bug Fixes**
|
| 117 |
+
|
| 118 |
+
- Fixed issues with older version of WordPress.
|
| 119 |
+
- Fixed issues with older version of PHP.
|
| 120 |
+
|
| 121 |
= 2.1.0 (20/12/2015) =
|
| 122 |
**New Feature**
|
| 123 |
|
| 235 |
|
| 236 |
== Upgrade Notice ==
|
| 237 |
|
| 238 |
+
= 2.1.1 (20/12/2015) =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
**Bug Fixes**
|
| 240 |
|
| 241 |
+
- Fixed issues with older version of WordPress.
|
| 242 |
+
- Fixed issues with older version of PHP.
|
