PluginProbe ʕ •ᴥ•ʔ
WooCommerce Square / 3.8.1
WooCommerce Square v3.8.1
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 3 years ago
Data_Compatibility.php
134 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) 2021-2022, WooCommerce.
16 * @copyright Copyright (c) 2013-2019, SkyVerge, Inc.
17 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 or later
18 *
19 * Modified by WooCommerce on 01 December 2021.
20 */
21
22 namespace WooCommerce\Square\Framework\Compatibility;
23 use WooCommerce\Square\Framework\Plugin_Compatibility;
24
25 defined( 'ABSPATH' ) or exit;
26
27 /**
28 * WooCommerce data compatibility class.
29 *
30 * @since 3.0.0
31 */
32 abstract class Data_Compatibility {
33
34 /**
35 * Gets an object property.
36 *
37 * @since 3.0.0
38 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
39 * @param string $prop the property name
40 * @param string $context if 'view' then the value will be filtered
41 * @param array $compat_props Compatibility properties.
42 * @return mixed
43 */
44 public static function get_prop( $object, $prop, $context = 'edit', $compat_props = array() ) {
45
46 $value = '';
47
48 if ( is_callable( array( $object, "get_{$prop}" ) ) ) {
49 $value = $object->{"get_{$prop}"}( $context );
50 }
51
52 return $value;
53 }
54
55
56 /**
57 * Sets an object's properties.
58 *
59 * Note that this does not save any data to the database.
60 *
61 * @since 3.0.0
62 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
63 * @param array $props the new properties as $key => $value
64 * @param array $compat_props Compatibility properties.
65 * @return \WC_Data
66 */
67 public static function set_props( $object, $props, $compat_props = array() ) {
68 $object->set_props( $props );
69
70 return $object;
71 }
72
73
74 /**
75 * Gets an object's stored meta value.
76 *
77 * @since 3.0.0
78 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
79 * @param string $key the meta key
80 * @param bool $single whether to get the meta as a single item. Defaults to `true`
81 * @param string $context if 'view' then the value will be filtered
82 * @return mixed
83 */
84 public static function get_meta( $object, $key = '', $single = true, $context = 'edit' ) {
85 $value = $object->get_meta( $key, $single, $context );
86
87 return $value;
88 }
89
90
91 /**
92 * Stores an object meta value.
93 *
94 * @since 3.0.0
95 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
96 * @param string $key the meta key
97 * @param string $value the meta value
98 * @param bool $unique Optional. Whether the meta should be unique.
99 */
100 public static function add_meta_data( $object, $key, $value, $unique = false ) {
101 $object->add_meta_data( $key, $value, $unique );
102 $object->save_meta_data();
103 }
104
105
106 /**
107 * Updates an object's stored meta value.
108 *
109 * @since 3.0.0
110 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
111 * @param string $key the meta key
112 * @param string $value the meta value
113 * @param int|string $meta_id Optional. The specific meta ID to update
114 */
115 public static function update_meta_data( $object, $key, $value, $meta_id = '' ) {
116 $object->update_meta_data( $key, $value, $meta_id );
117 $object->save_meta_data();
118 }
119
120
121 /**
122 * Deletes an object's stored meta value.
123 *
124 * @since 3.0.0
125 * @param \WC_Data $object the data object, likely \WC_Order or \WC_Product
126 * @param string $key the meta key
127 */
128 public static function delete_meta_data( $object, $key ) {
129 $object->delete_meta_data( $key );
130 $object->save_meta_data();
131 }
132 }
133
134