| 1 |
<?php |
| 2 |
/** |
| 3 |
* Log Table class. |
| 4 |
* |
| 5 |
* @package WPZinc\Social |
| 6 |
* @author WP Zinc |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace WPZinc\Social; |
| 10 |
|
| 11 |
/** |
| 12 |
* Controls the Log WP_List_Table. |
| 13 |
* |
| 14 |
* @package WPZinc\Social |
| 15 |
* @author WP Zinc |
| 16 |
* @version 3.9.6 |
| 17 |
*/ |
| 18 |
class Log_Table extends \WP_List_Table { |
| 19 |
|
| 20 |
/** |
| 21 |
* Holds the base class object. |
| 22 |
* |
| 23 |
* @since 3.9.6 |
| 24 |
* |
| 25 |
* @var object |
| 26 |
*/ |
| 27 |
public $base; |
| 28 |
|
| 29 |
/** |
| 30 |
* Holds the bulk actions. |
| 31 |
* |
| 32 |
* @since 3.9.6 |
| 33 |
* |
| 34 |
* @var array |
| 35 |
*/ |
| 36 |
protected $_actions; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore |
| 37 |
|
| 38 |
/** |
| 39 |
* Constructor. |
| 40 |
* |
| 41 |
* @since 3.9.6 |
| 42 |
* |
| 43 |
* @param object $base Base Plugin Class. |
| 44 |
*/ |
| 45 |
public function __construct( $base ) { |
| 46 |
|
| 47 |
// Store base class. |
| 48 |
$this->base = $base; |
| 49 |
|
| 50 |
parent::__construct( |
| 51 |
array( |
| 52 |
'singular' => 'wpzinc-social-log', // Singular label. |
| 53 |
'plural' => 'wpzinc-social-log', // plural label, also this well be one of the table css class. |
| 54 |
'ajax' => false, // We won't support Ajax for this table. |
| 55 |
) |
| 56 |
); |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Display dropdowns for Bulk Actions and Filtering. |
| 62 |
* |
| 63 |
* @since 3.9.6 |
| 64 |
* |
| 65 |
* @param string $which The location of the bulk actions: 'top' or 'bottom'. |
| 66 |
* This is designated as optional for backward compatibility. |
| 67 |
*/ |
| 68 |
protected function bulk_actions( $which = '' ) { |
| 69 |
|
| 70 |
// Get Bulk Actions. |
| 71 |
$this->_actions = $this->get_bulk_actions(); |
| 72 |
|
| 73 |
// Define <select> name. |
| 74 |
$bulk_actions_name = 'bulk_action' . ( $which !== 'top' ? '2' : '' ); |
| 75 |
?> |
| 76 |
<label for="bulk-action-selector-<?php echo esc_attr( $which ); ?>" class="screen-reader-text"> |
| 77 |
<?php esc_html_e( 'Select bulk action', 'wp-to-buffer' ); ?> |
| 78 |
</label> |
| 79 |
<select name="<?php echo esc_attr( $bulk_actions_name ); ?>" id="bulk-action-selector-<?php echo esc_attr( $which ); ?>" size="1"> |
| 80 |
<option value="-1"><?php esc_attr_e( 'Bulk Actions', 'wp-to-buffer' ); ?></option> |
| 81 |
|
| 82 |
<?php |
| 83 |
foreach ( $this->_actions as $name => $title ) { |
| 84 |
?> |
| 85 |
<option value="<?php echo esc_attr( $name ); ?>"><?php echo esc_attr( $title ); ?></option> |
| 86 |
<?php |
| 87 |
} |
| 88 |
?> |
| 89 |
</select> |
| 90 |
|
| 91 |
<?php |
| 92 |
// Output our custom filters to the top only. |
| 93 |
if ( $which === 'top' ) { |
| 94 |
$profiles = $this->base->get_class( 'log' )->get_profile_id_names(); |
| 95 |
?> |
| 96 |
<!-- Custom Filters --> |
| 97 |
<select name="action" size="1"> |
| 98 |
<option value=""<?php selected( $this->get_action(), '' ); ?>><?php esc_attr_e( 'Filter by Action', 'wp-to-buffer' ); ?></option> |
| 99 |
<?php |
| 100 |
foreach ( $this->base->get_class( 'common' )->get_post_actions() as $action => $label ) { |
| 101 |
?> |
| 102 |
<option value="<?php echo esc_attr( $action ); ?>"<?php selected( $this->get_action(), $action ); ?>><?php echo esc_attr( $label ); ?></option> |
| 103 |
<?php |
| 104 |
} |
| 105 |
?> |
| 106 |
</select> |
| 107 |
<select name="profile_id" size="1"> |
| 108 |
<option value=""<?php selected( $this->get_profile_id(), '' ); ?>><?php esc_attr_e( 'Filter by Profile', 'wp-to-buffer' ); ?></option> |
| 109 |
<?php |
| 110 |
foreach ( $profiles as $profile_id => $label ) { |
| 111 |
?> |
| 112 |
<option value="<?php echo esc_attr( $profile_id ); ?>"<?php selected( $this->get_profile_id(), $profile_id ); ?>><?php echo esc_attr( $label ); ?></option> |
| 113 |
<?php |
| 114 |
} |
| 115 |
?> |
| 116 |
</select> |
| 117 |
<select name="result" size="1"> |
| 118 |
<option value=""<?php selected( $this->get_result(), '' ); ?>><?php esc_attr_e( 'Filter by Result', 'wp-to-buffer' ); ?></option> |
| 119 |
<?php |
| 120 |
foreach ( $this->base->get_class( 'log' )->get_result_options() as $result_option => $label ) { |
| 121 |
?> |
| 122 |
<option value="<?php echo esc_attr( $result_option ); ?>"<?php selected( $this->get_result(), $result_option ); ?>> |
| 123 |
<?php echo esc_attr( $label ); ?> |
| 124 |
</option> |
| 125 |
<?php |
| 126 |
} |
| 127 |
?> |
| 128 |
</select> |
| 129 |
|
| 130 |
<input type="date" name="request_sent_start_date" value="<?php echo esc_attr( $this->get_request_sent_start_date() ); ?>" /> |
| 131 |
- |
| 132 |
<input type="date" name="request_sent_end_date" value="<?php echo esc_attr( $this->get_request_sent_end_date() ); ?>"/> |
| 133 |
<?php |
| 134 |
} |
| 135 |
|
| 136 |
submit_button( __( 'Apply', 'wp-to-buffer' ), 'action', '', false, array( 'id' => 'doaction' ) ); |
| 137 |
|
| 138 |
$clear_logs_url = add_query_arg( |
| 139 |
array( |
| 140 |
'page' => $this->base->plugin->name . '-log', |
| 141 |
'bulk_action3' => 'delete_all', |
| 142 |
'_wpnonce' => wp_create_nonce( 'bulk-wpzinc-social-log' ), |
| 143 |
), |
| 144 |
admin_url( 'admin.php' ) |
| 145 |
); |
| 146 |
?> |
| 147 |
|
| 148 |
<a href="<?php echo esc_url( $clear_logs_url ); ?>" class="<?php echo esc_attr( $this->base->plugin->name ); ?>-clear-log button wpzinc-button-red" data-message="<?php esc_html_e( 'Are you sure you want to clear ALL logs?', 'wp-to-buffer' ); ?>"> |
| 149 |
<?php esc_html_e( 'Clear Log', 'wp-to-buffer' ); ?> |
| 150 |
</a> |
| 151 |
<?php |
| 152 |
|
| 153 |
} |
| 154 |
|
| 155 |
/** |
| 156 |
* Defines the message to display when no items exist in the table |
| 157 |
* |
| 158 |
* @since 3.9.6 |
| 159 |
*/ |
| 160 |
public function no_items() { |
| 161 |
|
| 162 |
esc_html_e( 'No log entries found based on the given search and filter criteria.', 'wp-to-buffer' ); |
| 163 |
|
| 164 |
} |
| 165 |
|
| 166 |
/** |
| 167 |
* Displays the search box. |
| 168 |
* |
| 169 |
* @since 3.1.0 |
| 170 |
* |
| 171 |
* @param string $text The 'submit' button label. |
| 172 |
* @param string $input_id ID attribute value for the search input field. |
| 173 |
*/ |
| 174 |
public function search_box( $text, $input_id ) { |
| 175 |
|
| 176 |
// Build default values for filters. |
| 177 |
$filters_values = array(); |
| 178 |
foreach ( $this->base->get_class( 'common' )->get_log_filters() as $filter ) { |
| 179 |
$filters_values[ $filter ] = false; |
| 180 |
} |
| 181 |
|
| 182 |
// If a nonce is present, read the request. |
| 183 |
if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bulk-wpzinc-social-log' ) ) { |
| 184 |
foreach ( $this->base->get_class( 'common' )->get_log_filters() as $filter ) { |
| 185 |
if ( ! array_key_exists( $filter, $_REQUEST ) ) { |
| 186 |
continue; |
| 187 |
} |
| 188 |
$filters_values[ $filter ] = sanitize_text_field( wp_unslash( $_REQUEST[ $filter ] ) ); |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
$input_id = $input_id . '-search-input'; |
| 193 |
|
| 194 |
// Preserve Filters by storing any defined as hidden form values. |
| 195 |
foreach ( $this->base->get_class( 'common' )->get_log_filters() as $filter ) { |
| 196 |
if ( $filters_values[ $filter ] !== false ) { |
| 197 |
?> |
| 198 |
<input type="hidden" name="<?php echo esc_attr( $filter ); ?>" value="<?php echo esc_attr( $filters_values[ $filter ] ); ?>" /> |
| 199 |
<?php |
| 200 |
} |
| 201 |
} |
| 202 |
?> |
| 203 |
<p class="search-box"> |
| 204 |
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_attr( $text ); ?>:</label> |
| 205 |
<input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" placeholder="<?php esc_attr_e( 'Post ID or Title', 'wp-to-buffer' ); ?>" /> |
| 206 |
<?php submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); ?> |
| 207 |
</p> |
| 208 |
<?php |
| 209 |
} |
| 210 |
|
| 211 |
/** |
| 212 |
* Define the columns that are going to be used in the table |
| 213 |
* |
| 214 |
* @since 3.9.6 |
| 215 |
* |
| 216 |
* @return array Columns to use with the table |
| 217 |
*/ |
| 218 |
public function get_columns() { |
| 219 |
|
| 220 |
return array( |
| 221 |
'cb' => '<input type="checkbox" class="toggle" />', |
| 222 |
'post_id' => __( 'Post ID', 'wp-to-buffer' ), |
| 223 |
'request_sent' => __( 'Request Sent', 'wp-to-buffer' ), |
| 224 |
'action' => __( 'Action', 'wp-to-buffer' ), |
| 225 |
'profile_name' => __( 'Profile', 'wp-to-buffer' ), |
| 226 |
'status_text' => __( 'Status Text', 'wp-to-buffer' ), |
| 227 |
'result' => __( 'Result', 'wp-to-buffer' ), |
| 228 |
'result_message' => __( 'Response', 'wp-to-buffer' ), |
| 229 |
'status_created_at' => sprintf( |
| 230 |
/* translators: Social Media Service Name (Buffer, Hootsuite) */ |
| 231 |
__( '%s: Status Created At', 'wp-to-buffer' ), |
| 232 |
$this->base->plugin->account |
| 233 |
), |
| 234 |
'status_due_at' => sprintf( |
| 235 |
/* translators: Social Media Service Name (Buffer, Hootsuite) */ |
| 236 |
__( '%s: Status Scheduled For', 'wp-to-buffer' ), |
| 237 |
$this->base->plugin->account |
| 238 |
), |
| 239 |
); |
| 240 |
|
| 241 |
} |
| 242 |
|
| 243 |
/** |
| 244 |
* Decide which columns to activate the sorting functionality on |
| 245 |
* |
| 246 |
* @since 3.9.6 |
| 247 |
* |
| 248 |
* @return array Columns that can be sorted by the user |
| 249 |
*/ |
| 250 |
public function get_sortable_columns() { |
| 251 |
|
| 252 |
return array( |
| 253 |
'post_id' => array( 'post_id', true ), |
| 254 |
'request_sent' => array( 'request_sent', true ), |
| 255 |
'action' => array( 'action', true ), |
| 256 |
'profile_name' => array( 'profile_name', true ), |
| 257 |
'status_text' => array( 'status_text', true ), |
| 258 |
'result' => array( 'result', true ), |
| 259 |
'result_message' => array( 'result_message', true ), |
| 260 |
'status_created_at' => array( 'status_created_at', true ), |
| 261 |
'status_due_at' => array( 'status_due_at', true ), |
| 262 |
); |
| 263 |
|
| 264 |
} |
| 265 |
|
| 266 |
/** |
| 267 |
* Overrides the list of bulk actions in the select dropdowns above and below the table |
| 268 |
* |
| 269 |
* @since 3.9.6 |
| 270 |
* |
| 271 |
* @return array Bulk Actions |
| 272 |
*/ |
| 273 |
public function get_bulk_actions() { |
| 274 |
|
| 275 |
return array( |
| 276 |
'delete' => __( 'Delete', 'wp-to-buffer' ), |
| 277 |
); |
| 278 |
|
| 279 |
} |
| 280 |
|
| 281 |
/** |
| 282 |
* Prepare the table with different parameters, pagination, columns and table elements |
| 283 |
* |
| 284 |
* @since 3.9.6 |
| 285 |
*/ |
| 286 |
public function prepare_items() { |
| 287 |
|
| 288 |
global $_wp_column_headers; |
| 289 |
|
| 290 |
$screen = get_current_screen(); |
| 291 |
|
| 292 |
// Get params. |
| 293 |
$params = $this->get_search_params(); |
| 294 |
$order_by = $this->get_order_by(); |
| 295 |
$order = $this->get_order(); |
| 296 |
$page = $this->get_page(); |
| 297 |
$per_page = $this->get_items_per_page( $this->base->plugin->filter_name . '_logs_per_page', 20 ); |
| 298 |
|
| 299 |
// Get total records for this query. |
| 300 |
$total = $this->base->get_class( 'log' )->total( $params ); |
| 301 |
|
| 302 |
// Define pagination. |
| 303 |
$this->set_pagination_args( |
| 304 |
array( |
| 305 |
'total_items' => $total, |
| 306 |
'total_pages' => (int) ceil( $total / $per_page ), |
| 307 |
'per_page' => $per_page, |
| 308 |
) |
| 309 |
); |
| 310 |
|
| 311 |
// Set column headers. |
| 312 |
$this->_column_headers = $this->get_column_info(); |
| 313 |
|
| 314 |
// Set rows. |
| 315 |
$this->items = $this->base->get_class( 'log' )->search( $order_by, $order, $page, $per_page, $params ); |
| 316 |
|
| 317 |
} |
| 318 |
|
| 319 |
/** |
| 320 |
* Generate the table navigation above or below the table |
| 321 |
* |
| 322 |
* @since 3.1.0 |
| 323 |
* |
| 324 |
* @param string $which The location of the bulk actions: 'top' or 'bottom'. |
| 325 |
* This is designated as optional for backward compatibility. |
| 326 |
*/ |
| 327 |
protected function display_tablenav( $which ) { |
| 328 |
|
| 329 |
if ( 'top' === $which ) { |
| 330 |
wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
| 331 |
} |
| 332 |
?> |
| 333 |
<div class="tablenav <?php echo esc_attr( $which ); ?>"> |
| 334 |
<div class="alignleft actions bulkactions"> |
| 335 |
<?php $this->bulk_actions( $which ); ?> |
| 336 |
</div> |
| 337 |
<?php |
| 338 |
$this->extra_tablenav( $which ); |
| 339 |
$this->pagination( $which ); |
| 340 |
?> |
| 341 |
|
| 342 |
<br class="clear" /> |
| 343 |
</div> |
| 344 |
<?php |
| 345 |
|
| 346 |
} |
| 347 |
|
| 348 |
/** |
| 349 |
* Display the rows of records in the table |
| 350 |
* |
| 351 |
* @since 3.9.6 |
| 352 |
*/ |
| 353 |
public function display_rows() { |
| 354 |
|
| 355 |
echo wp_kses( |
| 356 |
$this->base->get_class( 'log' )->build_log_table_output( $this->items, true, $this->_column_headers ), |
| 357 |
array( |
| 358 |
'tr' => array( |
| 359 |
'class' => array(), |
| 360 |
), |
| 361 |
'th' => array( |
| 362 |
'scope' => array(), |
| 363 |
'class' => array(), |
| 364 |
), |
| 365 |
'td' => array( |
| 366 |
'class' => array(), |
| 367 |
), |
| 368 |
'a' => array( |
| 369 |
'href' => array(), |
| 370 |
'target' => array(), |
| 371 |
), |
| 372 |
'br' => array(), |
| 373 |
'input' => array( |
| 374 |
'type' => array( |
| 375 |
'checkbox', |
| 376 |
), |
| 377 |
'name' => array(), |
| 378 |
'value' => array(), |
| 379 |
), |
| 380 |
) |
| 381 |
); |
| 382 |
|
| 383 |
} |
| 384 |
|
| 385 |
/** |
| 386 |
* Get search parameters. |
| 387 |
* |
| 388 |
* @since 3.9.6 |
| 389 |
* |
| 390 |
* @return array Search Parameters |
| 391 |
*/ |
| 392 |
private function get_search_params() { |
| 393 |
|
| 394 |
// Build search params. |
| 395 |
$params = array( |
| 396 |
'action' => $this->get_action(), |
| 397 |
'profile_id' => $this->get_profile_id(), |
| 398 |
'result' => $this->get_result(), |
| 399 |
'request_sent_start_date' => $this->get_request_sent_start_date(), |
| 400 |
'request_sent_end_date' => $this->get_request_sent_end_date(), |
| 401 |
); |
| 402 |
|
| 403 |
// Return params if freeform search isn't supplied. |
| 404 |
if ( ! filter_has_var( INPUT_GET, 's' ) ) { |
| 405 |
return $params; |
| 406 |
} |
| 407 |
|
| 408 |
// Get search. |
| 409 |
$search = filter_input( INPUT_GET, 's', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 410 |
|
| 411 |
// If search is a number, add it as the Post ID and return. |
| 412 |
if ( is_numeric( $search ) ) { |
| 413 |
$params['post_id'] = absint( $search ); |
| 414 |
return $params; |
| 415 |
} |
| 416 |
|
| 417 |
// Add it as the Post Title and return. |
| 418 |
$params['post_title'] = $search; |
| 419 |
|
| 420 |
return $params; |
| 421 |
|
| 422 |
} |
| 423 |
|
| 424 |
/** |
| 425 |
* Returns whether a search has been performed on the table. |
| 426 |
* |
| 427 |
* @since 3.9.0 |
| 428 |
* |
| 429 |
* @return bool Search has been performed. |
| 430 |
*/ |
| 431 |
public function is_search() { |
| 432 |
|
| 433 |
return filter_has_var( INPUT_GET, 's' ); |
| 434 |
|
| 435 |
} |
| 436 |
|
| 437 |
/** |
| 438 |
* Get the Search requested by the user |
| 439 |
* |
| 440 |
* @since 3.9.0 |
| 441 |
* |
| 442 |
* @return string |
| 443 |
*/ |
| 444 |
public function get_search() { |
| 445 |
|
| 446 |
// Bail if nonce is not valid. |
| 447 |
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bulk-wpzinc-social-log' ) ) { |
| 448 |
return ''; |
| 449 |
} |
| 450 |
|
| 451 |
if ( ! array_key_exists( 's', $_REQUEST ) ) { |
| 452 |
return ''; |
| 453 |
} |
| 454 |
|
| 455 |
return urldecode( sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) ); |
| 456 |
|
| 457 |
} |
| 458 |
|
| 459 |
/** |
| 460 |
* Get the Action Filter requested by the user |
| 461 |
* |
| 462 |
* @since 3.9.7 |
| 463 |
* |
| 464 |
* @return string |
| 465 |
*/ |
| 466 |
private function get_action() { |
| 467 |
|
| 468 |
// Bail if nonce is not valid. |
| 469 |
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bulk-wpzinc-social-log' ) ) { |
| 470 |
return ''; |
| 471 |
} |
| 472 |
|
| 473 |
if ( ! array_key_exists( 'action', $_REQUEST ) ) { |
| 474 |
return ''; |
| 475 |
} |
| 476 |
|
| 477 |
return sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); |
| 478 |
|
| 479 |
} |
| 480 |
|
| 481 |
/** |
| 482 |
* Get the Profile ID Filter requested by the user |
| 483 |
* |
| 484 |
* @since 3.9.7 |
| 485 |
* |
| 486 |
* @return string |
| 487 |
*/ |
| 488 |
private function get_profile_id() { |
| 489 |
|
| 490 |
// Bail if nonce is not valid. |
| 491 |
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bulk-wpzinc-social-log' ) ) { |
| 492 |
return ''; |
| 493 |
} |
| 494 |
|
| 495 |
if ( ! array_key_exists( 'profile_id', $_REQUEST ) ) { |
| 496 |
return ''; |
| 497 |
} |
| 498 |
|
| 499 |
return sanitize_text_field( wp_unslash( $_REQUEST['profile_id'] ) ); |
| 500 |
|
| 501 |
} |
| 502 |
|
| 503 |
/** |
| 504 |
* Get the Status Result Filter requested by the user |
| 505 |
* |
| 506 |
* @since 3.9.7 |
| 507 |
* |
| 508 |
* @return string |
| 509 |
*/ |
| 510 |
private function get_result() { |
| 511 |
|
| 512 |
// Bail if nonce is not valid. |
| 513 |
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bulk-wpzinc-social-log' ) ) { |
| 514 |
return ''; |
| 515 |
} |
| 516 |
|
| 517 |
if ( ! array_key_exists( 'result', $_REQUEST ) ) { |
| 518 |
return ''; |
| 519 |
} |
| 520 |
|
| 521 |
return sanitize_text_field( wp_unslash( $_REQUEST['result'] ) ); |
| 522 |
|
| 523 |
} |
| 524 |
|
| 525 |
/** |
| 526 |
* Get the Request Sent Start Date Filter requested by the user |
| 527 |
* |
| 528 |
* @since 3.9.8 |
| 529 |
* |
| 530 |
* @return string |
| 531 |
*/ |
| 532 |
private function get_request_sent_start_date() { |
| 533 |
|
| 534 |
// Bail if nonce is not valid. |
| 535 |
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bulk-wpzinc-social-log' ) ) { |
| 536 |
return ''; |
| 537 |
} |
| 538 |
|
| 539 |
if ( ! array_key_exists( 'request_sent_start_date', $_REQUEST ) ) { |
| 540 |
return ''; |
| 541 |
} |
| 542 |
|
| 543 |
return sanitize_text_field( wp_unslash( $_REQUEST['request_sent_start_date'] ) ); |
| 544 |
|
| 545 |
} |
| 546 |
|
| 547 |
/** |
| 548 |
* Get the Request Sent End Date Filter requested by the user |
| 549 |
* |
| 550 |
* @since 3.9.8 |
| 551 |
* |
| 552 |
* @return string |
| 553 |
*/ |
| 554 |
private function get_request_sent_end_date() { |
| 555 |
|
| 556 |
// Bail if nonce is not valid. |
| 557 |
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bulk-wpzinc-social-log' ) ) { |
| 558 |
return ''; |
| 559 |
} |
| 560 |
|
| 561 |
if ( ! array_key_exists( 'get_request_sent_end_date', $_REQUEST ) ) { |
| 562 |
return ''; |
| 563 |
} |
| 564 |
|
| 565 |
return sanitize_text_field( wp_unslash( $_REQUEST['get_request_sent_end_date'] ) ); |
| 566 |
|
| 567 |
} |
| 568 |
|
| 569 |
/** |
| 570 |
* Get the Order By requested by the user |
| 571 |
* |
| 572 |
* @since 3.9.7 |
| 573 |
* |
| 574 |
* @return string |
| 575 |
*/ |
| 576 |
private function get_order_by() { |
| 577 |
|
| 578 |
// Don't nonce check because order by may not include a nonce if no search performed. |
| 579 |
if ( ! filter_has_var( INPUT_GET, 'orderby' ) ) { |
| 580 |
return 'request_sent'; |
| 581 |
} |
| 582 |
|
| 583 |
return filter_input( INPUT_GET, 'orderby', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 584 |
|
| 585 |
} |
| 586 |
|
| 587 |
/** |
| 588 |
* Get the Order requested by the user |
| 589 |
* |
| 590 |
* @since 3.9.7 |
| 591 |
* |
| 592 |
* @return string |
| 593 |
*/ |
| 594 |
private function get_order() { |
| 595 |
|
| 596 |
// Don't nonce check because order may not include a nonce if no search performed. |
| 597 |
if ( ! filter_has_var( INPUT_GET, 'order' ) ) { |
| 598 |
return 'DESC'; |
| 599 |
} |
| 600 |
|
| 601 |
return filter_input( INPUT_GET, 'order', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 602 |
|
| 603 |
} |
| 604 |
|
| 605 |
/** |
| 606 |
* Get the Pagination Page requested by the user |
| 607 |
* |
| 608 |
* @since 3.9.7 |
| 609 |
* |
| 610 |
* @return int |
| 611 |
*/ |
| 612 |
private function get_page() { |
| 613 |
|
| 614 |
// Don't nonce check because pagination may not include a nonce if no search performed. |
| 615 |
if ( ! filter_has_var( INPUT_GET, 'paged' ) ) { |
| 616 |
return 1; |
| 617 |
} |
| 618 |
|
| 619 |
return absint( filter_input( INPUT_GET, 'paged', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) ); |
| 620 |
|
| 621 |
} |
| 622 |
|
| 623 |
} |
| 624 |
|