PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
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
← All changes | inc/Databases/class-lp-post-db.php +103 -103 4.3.9.14.4.8 View file →
@@ -1,103 +1,103 @@
1 -<?php
2 -/**
3 - * Class LP_Post_DB
4 - *
5 - * @since 4.2.6.9
6 - * @version 1.0.1
7 - */
8 -class LP_Post_DB extends LP_Database {
9 -
10 - private static $_instance;
11 -
12 - protected function __construct() {
13 - parent::__construct();
14 - }
15 -
16 - public static function getInstance() {
17 - if ( is_null( self::$_instance ) ) {
18 - self::$_instance = new self();
19 - }
20 -
21 - return self::$_instance;
22 - }
23 -
24 - /**
25 - * Get questions
26 - *
27 - * @return array|null|int|string
28 - * @throws Exception
29 - * @since 4.1.6
30 - * @version 1.0.0
31 - */
32 - public function get_posts( $filter, int &$total_rows = 0 ) {
33 - $filter->fields = array_merge( $filter->all_fields, $filter->fields );
34 -
35 - if ( empty( $filter->collection ) ) {
36 - $filter->collection = $this->tb_posts;
37 - }
38 -
39 - if ( empty( $filter->collection_alias ) ) {
40 - $filter->collection_alias = 'p';
41 - }
42 -
43 - $ca = $filter->collection_alias;
44 -
45 - // Where
46 - $filter->where[] = $this->wpdb->prepare( "AND $ca.post_type = %s", $filter->post_type );
47 -
48 - // Find ID
49 - if ( isset( $filter->ID ) ) {
50 - $filter->where[] = $this->wpdb->prepare( "AND $ca.ID = %d", $filter->ID );
51 - }
52 -
53 - // Status
54 - $filter->post_status = (array) $filter->post_status;
55 - if ( ! empty( $filter->post_status ) ) {
56 - $post_status_format = LP_Helper::db_format_array( $filter->post_status, '%s' );
57 - $filter->where[] = $this->wpdb->prepare( "AND $ca.post_status IN (" . $post_status_format . ')', $filter->post_status );
58 - }
59 -
60 - // Term ids
61 - if ( ! empty( $filter->term_ids ) ) {
62 - // Sanitize term ids
63 - $filter->term_ids = array_map( 'absint', $filter->term_ids );
64 - $term_ids_format = join( ',', $filter->term_ids );
65 - $filter->join[] = "INNER JOIN $this->tb_term_relationships AS r_term_p ON $ca.ID = r_term_p.object_id";
66 - $filter->join[] = "INNER JOIN $this->tb_term_taxonomy AS tx_p ON r_term_p.term_taxonomy_id = tx_p.term_taxonomy_id";
67 - $filter->where[] = "AND r_term_p.term_taxonomy_id IN ($term_ids_format)";
68 - $filter->where[] = $this->wpdb->prepare( 'AND tx_p.taxonomy = %s', $filter->taxonomy );
69 - }
70 -
71 - // Post ids
72 - if ( ! empty( $filter->post_ids ) ) {
73 - $post_ids = array_map( 'absint', $filter->post_ids );
74 - $post_ids_format = join( ',', $post_ids );
75 - $filter->where[] = "AND $ca.ID IN ($post_ids_format)";
76 - }
77 -
78 - // Title
79 - if ( $filter->post_title ) {
80 - $filter->where[] = $this->wpdb->prepare( "AND $ca.post_title LIKE %s", '%' . $filter->post_title . '%' );
81 - }
82 -
83 - // Name(slug)
84 - if ( $filter->post_name ) {
85 - $filter->where[] = $this->wpdb->prepare( "AND $ca.post_name = %s", $filter->post_name );
86 - }
87 -
88 - // Author
89 - if ( isset( $filter->post_author ) ) {
90 - $filter->where[] = $this->wpdb->prepare( "AND $ca.post_author = %d", $filter->post_author );
91 - }
92 -
93 - // Authors
94 - if ( ! empty( $filter->post_authors ) ) {
95 - $post_authors_format = LP_Helper::db_format_array( $filter->post_authors, '%d' );
96 - $filter->where[] = $this->wpdb->prepare( "AND $ca.ID IN (" . $post_authors_format . ')', $filter->post_authors );
97 - }
98 -
99 - $filter = apply_filters( 'lp/post/query/filter', $filter );
100 -
101 - return $this->execute( $filter, $total_rows );
102 - }
103 -}
1 +<?php
2 +/**
3 + * Class LP_Post_DB
4 + *
5 + * @since 4.2.6.9
6 + * @version 1.0.1
7 + */
8 +class LP_Post_DB extends LP_Database {
9 +
10 + private static $_instance;
11 +
12 + protected function __construct() {
13 + parent::__construct();
14 + }
15 +
16 + public static function getInstance() {
17 + if ( is_null( self::$_instance ) ) {
18 + self::$_instance = new self();
19 + }
20 +
21 + return self::$_instance;
22 + }
23 +
24 + /**
25 + * Get questions
26 + *
27 + * @return array|null|int|string
28 + * @throws Exception
29 + * @since 4.1.6
30 + * @version 1.0.0
31 + */
32 + public function get_posts( $filter, int &$total_rows = 0 ) {
33 + $filter->fields = array_merge( $filter->all_fields, $filter->fields );
34 +
35 + if ( empty( $filter->collection ) ) {
36 + $filter->collection = $this->tb_posts;
37 + }
38 +
39 + if ( empty( $filter->collection_alias ) ) {
40 + $filter->collection_alias = 'p';
41 + }
42 +
43 + $ca = $filter->collection_alias;
44 +
45 + // Where
46 + $filter->where[] = $this->wpdb->prepare( "AND $ca.post_type = %s", $filter->post_type );
47 +
48 + // Find ID
49 + if ( isset( $filter->ID ) ) {
50 + $filter->where[] = $this->wpdb->prepare( "AND $ca.ID = %d", $filter->ID );
51 + }
52 +
53 + // Status
54 + $filter->post_status = (array) $filter->post_status;
55 + if ( ! empty( $filter->post_status ) ) {
56 + $post_status_format = LP_Helper::db_format_array( $filter->post_status, '%s' );
57 + $filter->where[] = $this->wpdb->prepare( "AND $ca.post_status IN (" . $post_status_format . ')', $filter->post_status );
58 + }
59 +
60 + // Term ids
61 + if ( ! empty( $filter->term_ids ) ) {
62 + // Sanitize term ids
63 + $filter->term_ids = array_map( 'absint', $filter->term_ids );
64 + $term_ids_format = join( ',', $filter->term_ids );
65 + $filter->join[] = "INNER JOIN $this->tb_term_relationships AS r_term_p ON $ca.ID = r_term_p.object_id";
66 + $filter->join[] = "INNER JOIN $this->tb_term_taxonomy AS tx_p ON r_term_p.term_taxonomy_id = tx_p.term_taxonomy_id";
67 + $filter->where[] = "AND r_term_p.term_taxonomy_id IN ($term_ids_format)";
68 + $filter->where[] = $this->wpdb->prepare( 'AND tx_p.taxonomy = %s', $filter->taxonomy );
69 + }
70 +
71 + // Post ids
72 + if ( ! empty( $filter->post_ids ) ) {
73 + $post_ids = array_map( 'absint', $filter->post_ids );
74 + $post_ids_format = join( ',', $post_ids );
75 + $filter->where[] = "AND $ca.ID IN ($post_ids_format)";
76 + }
77 +
78 + // Title
79 + if ( $filter->post_title ) {
80 + $filter->where[] = $this->wpdb->prepare( "AND $ca.post_title LIKE %s", '%' . $filter->post_title . '%' );
81 + }
82 +
83 + // Name(slug)
84 + if ( $filter->post_name ) {
85 + $filter->where[] = $this->wpdb->prepare( "AND $ca.post_name = %s", $filter->post_name );
86 + }
87 +
88 + // Author
89 + if ( isset( $filter->post_author ) ) {
90 + $filter->where[] = $this->wpdb->prepare( "AND $ca.post_author = %d", $filter->post_author );
91 + }
92 +
93 + // Authors
94 + if ( ! empty( $filter->post_authors ) ) {
95 + $post_authors_format = LP_Helper::db_format_array( $filter->post_authors, '%d' );
96 + $filter->where[] = $this->wpdb->prepare( "AND $ca.ID IN (" . $post_authors_format . ')', $filter->post_authors );
97 + }
98 +
99 + $filter = apply_filters( 'lp/post/query/filter', $filter );
100 +
101 + return $this->execute( $filter, $total_rows );
102 + }
103 +}