PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.0.6
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.0.6
2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 2.7.1 All 27 releases
insert-php / includes / class.helpers.php

class.helpers.php in Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts 2.0.6, at includes/class.helpers.php

66 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 * Helpers tools
5 * @author Webcraftic <wordpress.webraftic@gmail.com>
6 * @copyright (c) 09.11.2017, Webcraftic
7 * @version 1.0
8 */
9 class WINP_Helper {
10
11 private static $meta_options = array();
12
13 /**
14 * Get meta option
15 *
16 * @param int $post_id
17 * @param string $option_name
18 * @param mixed $default
19 * @return bool|int
20 */
21 public static function getMetaOption($post_id, $option_name, $default = null)
22 {
23 $post_id = (int)$post_id;
24
25 if( !isset(self::$meta_options[$post_id]) || empty(self::$meta_options[$post_id]) ) {
26 $meta_vals = get_post_meta($post_id, '', true);
27
28 foreach($meta_vals as $name => $val) {
29 self::$meta_options[$post_id][$name] = $val[0];
30 }
31 }
32
33 return isset(self::$meta_options[$post_id][WINP_Plugin::app()->getPrefix() . $option_name])
34 ? self::$meta_options[$post_id][WINP_Plugin::app()->getPrefix() . $option_name]
35 : $default;
36 }
37
38 /**
39 * Udpdate meta option
40 *
41 * @param int $post_id
42 * @param string $option_name
43 * @param mixed $option_value
44 * @return bool|int
45 */
46 public static function updateMetaOption($post_id, $option_name, $option_value)
47 {
48 $post_id = (int)$post_id;
49
50 return update_post_meta($post_id, WINP_Plugin::app()->getPrefix() . $option_name, $option_value);
51 }
52
53 /**
54 * Remove meta option
55 *
56 * @param int $post_id
57 * @param string $option_name
58 * @return bool|int
59 */
60 public static function removeMetaOption($post_id, $option_name)
61 {
62 $post_id = (int)$post_id;
63
64 return delete_post_meta($post_id, WINP_Plugin::app()->getPrefix() . $option_name);
65 }
66 }