PluginProbe
Posts Table with Search & Sort / 1.4.11
Posts Table with Search & Sort v1.4.11
1.4.13 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2 1.3 1.3.1 1.3.1-v2 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 40 releases
← All changes | src/Settings.php +40 -32 1.31.4.11 View file →
@@ -1,48 +1,56 @@
1 1 <?php
2 -
3 2 namespace Barn2\Plugin\Posts_Table_Search_Sort;
4 3
5 4 /**
6 5 * Responsible for fetching and sanitizing the plugin settings.
7 6 *
8 - * @author Barn2 Media <info@barn2.co.uk>
7 + * @package Barn2\posts-table-search-sort
8 + * @author Barn2 Plugins <support@barn2.com>
9 9 * @license GPL-3.0
10 10 * @copyright Barn2 Media Ltd
11 11 */
12 12 class Settings {
13 13
14 - const TABLE_ARGS_SETTING = 'ptss_table_args';
14 + const TABLE_ARGS_SETTING = 'ptss_table_args';
15 15
16 - public static function get_table_args() {
17 - return \get_option( self::TABLE_ARGS_SETTING, array() );
18 - }
16 + public static function get_table_args() {
17 + return get_option( self::TABLE_ARGS_SETTING, [] );
18 + }
19 19
20 - public static function sanitize_table_args( $args ) {
21 - if ( isset( $args['columns'] ) ) {
22 - $args['columns'] = \sanitize_text_field( $args['columns'] );
23 - }
24 - if ( isset( $args['content_length'] ) ) {
25 - $args['content_length'] = \filter_var( $args['content_length'], \FILTER_VALIDATE_INT, array(
26 - 'options' => array(
27 - 'min' => -1
28 - )
29 - ) );
30 - }
31 - if ( isset( $args['rows_per_page'] ) ) {
32 - $args['rows_per_page'] = \filter_var( $args['rows_per_page'], \FILTER_VALIDATE_INT, array(
33 - 'options' => array(
34 - 'min' => -1
35 - )
36 - ) );
37 - }
38 - if ( isset( $args['sort_by'] ) ) {
39 - $args['sort_by'] = \sanitize_key( $args['sort_by'] );
40 - }
41 - if ( isset( $args['sort_order'] ) && ! \in_array( $args['sort_order'], array( 'asc', 'desc', '' ) ) ) {
42 - $args['sort_order'] = '';
43 - }
20 + public static function sanitize_table_args( $args ) {
21 + if ( isset( $args['columns'] ) ) {
22 + $args['columns'] = sanitize_text_field( $args['columns'] );
23 + }
24 + if ( isset( $args['content_length'] ) ) {
25 + $args['content_length'] = filter_var(
26 + $args['content_length'],
27 + FILTER_VALIDATE_INT,
28 + [
29 + 'options' => [
30 + 'min' => -1
31 + ]
32 + ]
33 + );
34 + }
35 + if ( isset( $args['rows_per_page'] ) ) {
36 + $args['rows_per_page'] = filter_var(
37 + $args['rows_per_page'],
38 + FILTER_VALIDATE_INT,
39 + [
40 + 'options' => [
41 + 'min' => -1
42 + ]
43 + ]
44 + );
45 + }
46 + if ( isset( $args['sort_by'] ) ) {
47 + $args['sort_by'] = sanitize_key( $args['sort_by'] );
48 + }
49 + if ( isset( $args['sort_order'] ) && ! in_array( $args['sort_order'], [ 'asc', 'desc', '' ] ) ) {
50 + $args['sort_order'] = '';
51 + }
44 52
45 - return $args;
46 - }
53 + return $args;
54 + }
47 55
48 56 }