PluginProbe
Posts Table with Search & Sort / 1.3.5
Posts Table with Search & Sort v1.3.5
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 1.3.8 All 39 releases
posts-data-table / src / Settings.php

Settings.php in Posts Table with Search & Sort 1.3.5, at src/Settings.php

49 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Barn2\Plugin\Posts_Table_Search_Sort;
3
4 /**
5 * Responsible for fetching and sanitizing the plugin settings.
6 *
7 * @package Barn2\posts-table-search-sort
8 * @author Barn2 Plugins <support@barn2.co.uk>
9 * @license GPL-3.0
10 * @copyright Barn2 Media Ltd
11 */
12 class Settings {
13
14 const TABLE_ARGS_SETTING = 'ptss_table_args';
15
16 public static function get_table_args() {
17 return get_option( self::TABLE_ARGS_SETTING, array() );
18 }
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 }
44
45 return $args;
46 }
47
48 }
49