PluginProbe
Posts Table with Search & Sort / 1.2
Posts Table with Search & Sort v1.2
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 / includes / class-settings.php

class-settings.php in Posts Table with Search & Sort 1.2, at includes/class-settings.php

53 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Barn2\Plugin\Posts_Table_Search_Sort;
4
5 // Prevent direct file access
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 /**
11 * Responsible for fetching and sanitizing the plugin settings.
12 *
13 * @author Barn2 Media <info@barn2.co.uk>
14 * @license GPL-3.0
15 * @copyright Barn2 Media Ltd
16 */
17 class Settings {
18
19 const TABLE_ARGS_SETTING = 'ptss_table_args';
20
21 public static function get_table_args() {
22 return get_option( self::TABLE_ARGS_SETTING, array() );
23 }
24
25 public static function sanitize_table_args( $args ) {
26 if ( isset( $args['columns'] ) ) {
27 $args['columns'] = sanitize_text_field( $args['columns'] );
28 }
29 if ( isset( $args['content_length'] ) ) {
30 $args['content_length'] = filter_var( $args['content_length'], FILTER_VALIDATE_INT, array(
31 'options' => array(
32 'min' => -1
33 )
34 ) );
35 }
36 if ( isset( $args['rows_per_page'] ) ) {
37 $args['rows_per_page'] = filter_var( $args['rows_per_page'], FILTER_VALIDATE_INT, array(
38 'options' => array(
39 'min' => -1
40 )
41 ) );
42 }
43 if ( isset( $args['sort_by'] ) ) {
44 $args['sort_by'] = sanitize_key( $args['sort_by'] );
45 }
46 if ( isset( $args['sort_order'] ) && ! in_array( $args['sort_order'], array( 'asc', 'desc', '' ) ) ) {
47 $args['sort_order'] = '';
48 }
49
50 return $args;
51 }
52 }
53