PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.8.23.4
Pods – Custom Content Types and Fields v2.8.23.4
2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / includes / classes.php
pods / includes Last commit date
compatibility 2 weeks ago access.php 2 weeks ago classes.php 2 weeks ago data.php 2 weeks ago forms.php 2 weeks ago general.php 2 weeks ago media.php 2 weeks ago
classes.php
270 lines
1 <?php
2 /**
3 * @package Pods
4 * @category Utilities
5 */
6
7 use Pods\Whatsit\Pod;
8
9 /**
10 * Include and Init the Pods class
11 *
12 * @see Pods
13 *
14 * @param string $type The pod name
15 * @param mixed $id (optional) The ID or slug, to load a single record; Provide array of $params to run 'find'
16 * @param bool $strict (optional) If set to true, return false instead of an object if the Pod doesn't exist
17 *
18 * @return bool|\Pods returns false if $strict, WP_DEBUG, PODS_STRICT or (PODS_DEPRECATED && PODS_STRICT_MODE) are true
19 * @since 2.0.0
20 * @link https://docs.pods.io/code/pods/
21 */
22 function pods( $type = null, $id = null, $strict = null ) {
23 $pod = new Pods( $type, $id );
24
25 if ( null === $strict ) {
26 $strict = pods_strict();
27 }
28
29 if ( true === $strict && null !== $type && ! $pod->valid() ) {
30 return false;
31 }
32
33 return $pod;
34 }
35
36 /**
37 * Easily create content admin screens with in-depth customization. This is the primary interface function that Pods
38 * runs off of. It's also the only function required to be run in order to have a fully functional Manage interface.
39 *
40 * @see PodsUI
41 *
42 * @param array|string|Pods $obj (optional) Configuration options for the UI
43 * @param boolean $deprecated (optional) Whether to enable deprecated options (used by pods_ui_manage)
44 *
45 * @return PodsUI
46 *
47 * @since 2.0.0
48 * @link https://docs.pods.io/code/pods-ui/
49 */
50 function pods_ui( $obj, $deprecated = false ) {
51 return new PodsUI( $obj, $deprecated );
52 }
53
54 /**
55 * Include and get the PodsAPI object, for use with all calls that Pods makes for add, save, delete, and more.
56 *
57 * @see PodsAPI
58 *
59 * @param string $pod (optional) (deprecated) The Pod name
60 * @param string $format (optional) (deprecated) Format used in import() and export()
61 *
62 * @return PodsAPI
63 *
64 * @since 2.0.0
65 * @link https://docs.pods.io/code/pods-api/
66 */
67 function pods_api( $pod = null, $format = null ) {
68 return PodsAPI::init( $pod, $format );
69 }
70
71 /**
72 * Include and Init the PodsData class.
73 *
74 * @see PodsData
75 *
76 * @param string|Pod $pod The pod object to load.
77 * @param null|null|string $id (optional) Id of the pod to fetch.
78 * @param bool $strict (optional) If true throw an error if the pod does not exist.
79 * @param bool $unique (optional) If true always return a unique class.
80 *
81 * @return PodsData
82 *
83 * @since 2.0.0
84 *
85 * @throws Exception
86 */
87 function pods_data( $pod = null, $id = null, $strict = true, $unique = true ) {
88 if ( $unique ) {
89 if ( $pod instanceof Pod || $pod instanceof Pods ) {
90 return new PodsData( $pod, $id, $strict );
91 }
92
93 if ( ! in_array( $pod, array( null, false ), true ) ) {
94 return new PodsData( $pod, $id, $strict );
95 }
96
97 return new PodsData;
98 }
99
100 return PodsData::init( $pod, $id, $strict );
101 }
102
103 /**
104 * Include and Init the PodsFormUI class
105 *
106 * @see PodsForm
107 *
108 * @return PodsForm
109 *
110 * @since 2.0.0
111 */
112 function pods_form() {
113 return PodsForm::init();
114 }
115
116 /**
117 * Include and Init the Pods class
118 *
119 * @see PodsInit
120 *
121 * @return PodsInit
122 *
123 * @since 2.0.0
124 */
125 function pods_init() {
126 return PodsInit::init();
127 }
128
129 /**
130 * Include and Init the Pods Components class
131 *
132 * @see PodsComponents
133 *
134 * @return PodsComponents
135 *
136 * @since 2.0.0
137 */
138 function pods_components() {
139 return PodsComponents::init();
140 }
141
142 /**
143 * Include and Init the PodsAdmin class
144 *
145 * @see PodsAdmin
146 *
147 * @return PodsAdmin
148 *
149 * @since 2.0.0
150 */
151 function pods_admin() {
152 return PodsAdmin::init();
153 }
154
155 /**
156 * Include and Init the PodsMeta class
157 *
158 * @see PodsMeta
159 *
160 * @return PodsMeta
161 *
162 * @since 2.0.0
163 */
164 function pods_meta() {
165 return PodsMeta::init();
166 }
167
168 /**
169 * Include and Init the PodsArray class
170 *
171 * @see PodsArray
172 *
173 * @param mixed $container Object (or existing Array)
174 *
175 * @return PodsArray
176 *
177 * @since 2.0.0
178 */
179 function pods_array( $container ) {
180 return new PodsArray( $container );
181 }
182
183 /**
184 * @since 2.7.0
185 */
186 function pods_i18n() {
187 return PodsI18n::get_instance();
188 }
189
190 /**
191 * Include a file that's child/parent theme-aware, and can be cached into object cache or transients
192 *
193 * @see PodsView::view
194 *
195 * @param string $view Path of the file to be included, this is relative to the current theme
196 * @param array|null $data (optional) Data to pass on to the template, using variable => value format
197 * @param int|bool $expires (optional) Time in seconds for the cache to expire, if false caching is disabled.
198 * @param string $cache_mode (optional) Specify the caching method to use for the view, available options include
199 * cache, transient, or site-transient
200 * @param bool $return (optional) Whether to return the view or not, defaults to false and will echo it
201 * @param bool $limited (optional) Whether to limit the view to only the theme directory, defaults to false
202 *
203 * @return string|bool The view output
204 *
205 * @since 2.0.0
206 * @link https://docs.pods.io/code/pods-view/
207 */
208 function pods_view( $view, $data = null, $expires = false, $cache_mode = 'cache', $return = false, $limited = false ) {
209 $view = PodsView::view( $view, $data, $expires, $cache_mode, $limited );
210
211 if ( $return ) {
212 return $view;
213 }
214
215 echo $view;
216 }
217
218 /**
219 * Include and Init the PodsMigrate class
220 *
221 * @see PodsMigrate
222 *
223 * @param string $type Export Type (php, json, sv, xml)
224 * @param string $delimiter Delimiter for export type 'sv'
225 * @param array $data Array of data
226 *
227 * @return PodsMigrate
228 *
229 * @since 2.2.0
230 */
231 function pods_migrate( $type = null, $delimiter = null, $data = null ) {
232 return new PodsMigrate( $type, $delimiter, $data );
233 }
234
235 /**
236 * Include and Init the PodsUpgrade class
237 *
238 * @param string $version Version number of upgrade to get
239 *
240 * @see PodsUpgrade
241 *
242 * @return PodsUpgrade
243 *
244 * @since 2.1.0
245 */
246 function pods_upgrade( $version = '' ) {
247 include_once PODS_DIR . 'sql/upgrade/PodsUpgrade.php';
248
249 $class_name = str_replace( '.', '_', $version );
250 $class_name = "PodsUpgrade_{$class_name}";
251
252 $class_name = trim( $class_name, '_' );
253
254 if ( ! class_exists( $class_name ) ) {
255 $file = PODS_DIR . 'sql/upgrade/' . basename( $class_name ) . '.php';
256
257 if ( file_exists( $file ) ) {
258 include_once $file;
259 }
260 }
261
262 $class = false;
263
264 if ( class_exists( $class_name ) ) {
265 $class = new $class_name();
266 }
267
268 return $class;
269 }
270