PluginProbe
WP Ultimate Post Grid / 3.5.0
WP Ultimate Post Grid v3.5.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / includes / public / class-wpupg-filter.php

class-wpupg-filter.php in WP Ultimate Post Grid 3.5.0, at includes/public/class-wpupg-filter.php

85 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Responsible for grid filters.
4 *
5 * @link https://bootstrapped.ventures
6 * @since 3.0.0
7 *
8 * @package WP_Ultimate_Post_Grid
9 * @subpackage WP_Ultimate_Post_Grid/includes/public
10 */
11
12 /**
13 * Responsible for grid filters.
14 *
15 * @since 3.0.0
16 * @package WP_Ultimate_Post_Grid
17 * @subpackage WP_Ultimate_Post_Grid/includes/public
18 * @author Brecht Vandersmissen <brecht@bootstrapped.ventures>
19 */
20 class WPUPG_Filter {
21 /**
22 * Get filter defaults.
23 *
24 * @since 3.0.0
25 * @param mixed $type Optional filter type to get the defaults for.
26 */
27 public static function get_defaults( $type = false ) {
28 $defaults = apply_filters( 'wpupg_filter_defaults', array() );
29
30 if ( false === $type ) {
31 return $defaults;
32 } else {
33 if ( isset( $defaults[ $type ] ) ) {
34 return $defaults[ $type ];
35 } else {
36 return false;
37 }
38 }
39 }
40
41 /**
42 * Get filter with defaults.
43 *
44 * @since 3.0.0
45 * @param mixed $filter Filter to get the defaults for.
46 */
47 public static function filter_with_defaults( $filter ) {
48 if ( $filter && isset( $filter['type'] ) ) {
49 // Set default options.
50 $defaults = self::get_defaults( $filter['type'] );
51 if ( $defaults ) {
52 $filter['options'] = array_replace_recursive( $defaults, $filter['options'] );
53 }
54
55 // Set default label.
56 if ( ! isset( $filter['label'] ) ) {
57 $filter['label'] = '';
58 }
59 }
60
61 return $filter;
62 }
63
64 /**
65 * Get general filter style defaults.
66 *
67 * @since 3.1.0
68 */
69 public static function get_general_style_defaults() {
70 $defaults = apply_filters( 'wpupg_filter_general_style_defaults', array(
71 'display' => 'block',
72 'alignment' => 'left',
73 'spacing_vertical' => 10,
74 'spacing_horizontal' => 10,
75 'width' => 250,
76 'label_display' => 'block',
77 'label_alignment' => 'left',
78 'label_font_size' => 14,
79 'label_style' => 'bold',
80 ) );
81
82 return $defaults;
83 }
84 }
85