|
1
|
|
|
<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2
|
|
|
exit('No direct script access allowed'); |
|
3
|
|
|
} |
|
4
|
|
|
/** |
|
5
|
|
|
* Event Espresso |
|
6
|
|
|
* Event Registration and Management Plugin for WordPress |
|
7
|
|
|
* @ package Event Espresso |
|
8
|
|
|
* @ author Seth Shoultes |
|
9
|
|
|
* @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10
|
|
|
* @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11
|
|
|
* @ link http://www.eventespresso.com |
|
12
|
|
|
* @ version 4.0 |
|
13
|
|
|
* ------------------------------------------------------------------------ |
|
14
|
|
|
* Post Meta Model |
|
15
|
|
|
* Model for accessing the wp core postmeta table. Generally it's better to use the |
|
16
|
|
|
* built-in wp functions directly, but this is useful if you want to use the EE models |
|
17
|
|
|
* and need a query that factors in an EE custom post type's postmeta (eg, attendees, events or venues). |
|
18
|
|
|
* Currently, if applying caps to the queries, these are only accessible to site admins; |
|
19
|
|
|
* however we may devise some strategy for marking specified postmetas as public. |
|
20
|
|
|
* (Using the wp core convention of prefixing meta keys with an underscore might work, |
|
21
|
|
|
* see https://codex.wordpress.org/Function_Reference/add_post_meta, but when a postmeta is |
|
22
|
|
|
* "non-hidden" it's meant to show in the wp admin's post editing page, not necessarily on the frontend) |
|
23
|
|
|
* |
|
24
|
|
|
* @package Event Espresso |
|
25
|
|
|
* @subpackage includes/models/ |
|
26
|
|
|
* @author Michael Nelson |
|
27
|
|
|
* ------------------------------------------------------------------------ |
|
28
|
|
|
*/ |
|
29
|
|
|
require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
class EEM_Post_Meta extends EEM_Base |
|
34
|
|
|
{ |
|
35
|
|
|
|
|
36
|
|
|
// private instance of the EE_Post_Meta object |
|
37
|
|
|
protected static $_instance = null; |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
protected function __construct($timezone = null) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->singular_item = __('Post Meta', 'event_espresso'); |
|
44
|
|
|
$this->plural_item = __('Post Metas', 'event_espresso'); |
|
45
|
|
|
$this->_tables = array( |
|
46
|
|
|
'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'), |
|
47
|
|
|
); |
|
48
|
|
|
$models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
49
|
|
|
$this->_fields = array( |
|
50
|
|
|
'Post_Meta' => array( |
|
51
|
|
|
'meta_id' => new EE_Primary_Key_Int_Field( |
|
52
|
|
|
'meta_id', |
|
53
|
|
|
__("Meta ID", "event_espresso") |
|
54
|
|
|
), |
|
55
|
|
|
'post_id' => new EE_Foreign_Key_Int_Field( |
|
56
|
|
|
'post_id', |
|
57
|
|
|
__("Primary Key of Post", "event_espresso"), |
|
58
|
|
|
false, |
|
59
|
|
|
0, |
|
60
|
|
|
$models_this_can_attach_to |
|
61
|
|
|
), |
|
62
|
|
|
'meta_key' => new EE_Plain_Text_Field( |
|
63
|
|
|
'meta_key', |
|
64
|
|
|
__("Meta Key", "event_espresso"), |
|
65
|
|
|
false, |
|
66
|
|
|
'' |
|
67
|
|
|
), |
|
68
|
|
|
'meta_value' => new EE_Maybe_Serialized_Text_Field( |
|
69
|
|
|
'meta_value', |
|
70
|
|
|
__("Meta Value", "event_espresso"), |
|
71
|
|
|
true |
|
72
|
|
|
), |
|
73
|
|
|
), |
|
74
|
|
|
); |
|
75
|
|
|
$this->_model_relations = array(); |
|
76
|
|
|
foreach ($models_this_can_attach_to as $model) { |
|
77
|
|
|
$this->_model_relations[$model] = new EE_Belongs_To_Relation(); |
|
78
|
|
|
} |
|
79
|
|
|
foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
80
|
|
|
$this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta( |
|
81
|
|
|
'meta_key', |
|
82
|
|
|
'meta_value' |
|
83
|
|
|
); |
|
84
|
|
|
} |
|
85
|
|
|
parent::__construct($timezone); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
// End of file EEM_Post_Meta.model.php |
|
91
|
|
|
// Location: /includes/models/EEM_Post_Meta.model.php |
|
92
|
|
|
|