PluginProbe ʕ •ᴥ•ʔ
WooCommerce Square / 5.4.2
WooCommerce Square v5.4.2
5.4.2 5.4.1 5.4.0 trunk 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.7.0 2.8.0 2.9.0 2.9.1 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.2.0 3.3.0 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.7.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 4.0.0 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 4.9.8 4.9.9 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.2.0 5.3.0 5.3.1 5.3.2 5.3.3
woocommerce-square / includes / Framework / Compatibility / Data_Compatibility.php
woocommerce-square / includes / Framework / Compatibility Last commit date
Data_Compatibility.php 3 years ago Order_Compatibility.php 2 years ago
Data_Compatibility.php
133 lines
1 <?php
2 /**
3 * WooCommerce Plugin Framework
4 *
5 * This source file is subject to the GNU General Public License v3.0
6 * that is bundled with this package in the file license.txt.
7 * It is also available through the world-wide-web at this URL:
8 * http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 or later
9 * If you did not receive a copy of the license and are unable to
10 * obtain it through the world-wide-web, please send an email
11 * to license@skyverge.com so we can send you a copy immediately.
12 *
13 * @since 3.0.0
14 * @author WooCommerce / SkyVerge
15 * @copyright Copyright (c) 2013-2019, SkyVerge, Inc.
16 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 or later
17 *
18 * Modified by WooCommerce on 01 December 2021.
19 */
20
21 namespace WooCommerce\Square\Framework\Compatibility;
22 use WooCommerce\Square\Framework\Plugin_Compatibility;
23
24 defined( 'ABSPATH' ) or exit;
25
26 /**
27 * WooCommerce data compatibility class.
28 *
29 * @since 3.0.0
30 */
31 abstract class Data_Compatibility {
32
33 /**
34 * Gets an object property.
35 *
36 * @since 3.0.0
37 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
38 * @param string $prop the property name
39 * @param string $context if 'view' then the value will be filtered
40 * @param array $compat_props Compatibility properties.
41 * @return mixed
42 */
43 public static function get_prop( $object, $prop, $context = 'edit', $compat_props = array() ) {
44
45 $value = '';
46
47 if ( is_callable( array( $object, "get_{$prop}" ) ) ) {
48 $value = $object->{"get_{$prop}"}( $context );
49 }
50
51 return $value;
52 }
53
54
55 /**
56 * Sets an object's properties.
57 *
58 * Note that this does not save any data to the database.
59 *
60 * @since 3.0.0
61 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
62 * @param array $props the new properties as $key => $value
63 * @param array $compat_props Compatibility properties.
64 * @return \WC_Data
65 */
66 public static function set_props( $object, $props, $compat_props = array() ) {
67 $object->set_props( $props );
68
69 return $object;
70 }
71
72
73 /**
74 * Gets an object's stored meta value.
75 *
76 * @since 3.0.0
77 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
78 * @param string $key the meta key
79 * @param bool $single whether to get the meta as a single item. Defaults to `true`
80 * @param string $context if 'view' then the value will be filtered
81 * @return mixed
82 */
83 public static function get_meta( $object, $key = '', $single = true, $context = 'edit' ) {
84 $value = $object->get_meta( $key, $single, $context );
85
86 return $value;
87 }
88
89
90 /**
91 * Stores an object meta value.
92 *
93 * @since 3.0.0
94 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
95 * @param string $key the meta key
96 * @param string $value the meta value
97 * @param bool $unique Optional. Whether the meta should be unique.
98 */
99 public static function add_meta_data( $object, $key, $value, $unique = false ) {
100 $object->add_meta_data( $key, $value, $unique );
101 $object->save_meta_data();
102 }
103
104
105 /**
106 * Updates an object's stored meta value.
107 *
108 * @since 3.0.0
109 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
110 * @param string $key the meta key
111 * @param string $value the meta value
112 * @param int|string $meta_id Optional. The specific meta ID to update
113 */
114 public static function update_meta_data( $object, $key, $value, $meta_id = '' ) {
115 $object->update_meta_data( $key, $value, $meta_id );
116 $object->save_meta_data();
117 }
118
119
120 /**
121 * Deletes an object's stored meta value.
122 *
123 * @since 3.0.0
124 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
125 * @param string $key the meta key
126 */
127 public static function delete_meta_data( $object, $key ) {
128 $object->delete_meta_data( $key );
129 $object->save_meta_data();
130 }
131 }
132
133