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
learnpress / inc / Databases / class-lp-post-meta-db.php

class-lp-post-meta-db.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.8, at inc/Databases/class-lp-post-meta-db.php

70 lines 1.6 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_Post_DB
5 *
6 * @since 4.2.6.9
7 * @version 1.0.0
8 */
9 class LP_Post_Meta_DB extends LP_Database {
10
11 private static $_instance;
12
13 protected function __construct() {
14 parent::__construct();
15 }
16
17 public static function getInstance() {
18 if ( is_null( self::$_instance ) ) {
19 self::$_instance = new self();
20 }
21
22 return self::$_instance;
23 }
24
25 /**
26 * Get questions
27 *
28 * @return array|object|null|int|string
29 * @throws Exception
30 * @since 4.2.6.9
31 * @version 1.0.1
32 */
33 public function get_post_metas( $filter, &$total_rows = 0 ) {
34 $filter->fields = array_merge( $filter->all_fields, $filter->fields );
35 $col_meta_id = LP_Post_Meta_Filter::COL_META_ID;
36 $col_post_id = LP_Post_Meta_Filter::COL_POST_ID;
37 $col_meta_key = LP_Post_Meta_Filter::COL_META_KEY;
38
39 if ( empty( $filter->collection ) ) {
40 $filter->collection = $this->tb_postmeta;
41 }
42
43 if ( empty( $filter->collection_alias ) ) {
44 $filter->collection_alias = 'pm';
45 }
46
47 $ca = $filter->collection_alias;
48
49 // Find meta_id
50 if ( isset( $filter->meta_id ) ) {
51 $filter->where[] = $this->wpdb->prepare( "AND {$ca}.{$col_meta_id} = %d", $filter->meta_id );
52 }
53
54 // Find post_id
55 if ( isset( $filter->post_id ) ) {
56 $filter->where[] = $this->wpdb->prepare( "AND {$ca}.{$col_post_id} = %d", $filter->post_id );
57 }
58
59 // Find meta_key
60 if ( isset( $filter->meta_key ) ) {
61 $filter->where[] = $this->wpdb->prepare( "AND {$ca}.{$col_meta_key} = %s", $filter->meta_key );
62 }
63
64 $filter = apply_filters( 'lp/post-meta/query/filter', $filter );
65
66 return $this->execute( $filter, $total_rows );
67 }
68 }
69
70