PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.9
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / abstracts / abstract-object-query.php

abstract-object-query.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.3.9, at inc/abstracts/abstract-object-query.php

91 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class LP_Object_Query
5 *
6 * Base class for query functionality on post type object.
7 *
8 * @since 3.3.0
9 */
10 abstract class LP_Object_Query {
11 /**
12 * @var array
13 */
14 protected $query_vars = array();
15
16 /**
17 * LP_Object_Query constructor.
18 *
19 * @param array $args
20 */
21 public function __construct( $args = array() ) {
22
23 $this->query_vars = wp_parse_args( $args, $this->get_default_query_vars() );
24 }
25
26 /**
27 * Get all query vars.
28 *
29 * @return array
30 * @since 3.3.0
31 */
32 public function get_query_vars() {
33 return $this->query_vars;
34 }
35
36 /**
37 * Get value of a query var by key.
38 *
39 * @param string $var_name
40 * @param string $default
41 *
42 * @return mixed|string
43 * @since 3.3.0
44 */
45 public function get( $var_name, $default = '' ) {
46 if ( isset( $this->query_vars[ $var_name ] ) ) {
47 return $this->query_vars[ $var_name ];
48 }
49
50 return $default;
51 }
52
53 /**
54 * Set new value for query var.
55 *
56 * @param string $var_name
57 * @param mixed $value
58 * @param bool $overwrite
59 *
60 * @since 3.3.0
61 */
62 public function set( $var_name, $value, $overwrite = false ) {
63
64 if ( $overwrite || ! isset( $this->query_vars[ $var_name ] ) ) {
65 $this->query_vars[ $var_name ] = $value;
66 }
67 }
68
69 /**
70 * Get default query vars.
71 *
72 * @return array
73 * @since 3.3.0
74 */
75 protected function get_default_query_vars() {
76 return array(
77 'name' => '',
78 'parent' => '',
79 'parent_exclude' => '',
80 'exclude' => '',
81 'limit' => get_option( 'posts_per_page' ),
82 'paged' => 1,
83 'offset' => '',
84 'paginate' => false,
85 'order' => 'DESC',
86 'orderby' => 'date',
87 'return' => 'objects',
88 );
89 }
90 }
91