Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/seo-by-rank-math/includes/traits/class-meta.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * The Metadata.
4 + *
5 + * @since 0.9.0
6 + * @package RankMath
7 + * @subpackage RankMath\Traits
8 + * @author Rank Math <support@rankmath.com>
9 + */
10 +
11 + namespace RankMath\Traits;
12 +
13 + use RankMath\Helper;
14 +
15 + defined( 'ABSPATH' ) || exit;
16 +
17 + /**
18 + * Meta class.
19 + */
20 + trait Meta {
21 +
22 + /**
23 + * Get meta by object type.
24 + *
25 + * @param string $object_type Object type for destination where to save.
26 + * @param int $object_id Object id for destination where to save.
27 + * @param string $key The meta key to retrieve. If no key is provided, fetches all metadata.
28 + * @param bool $single Whether to return a single value.
29 + *
30 + * @return mixed
31 + */
32 + public function get_meta( $object_type, $object_id, $key = '', $single = true ) {
33 + $func = "get_{$object_type}_meta";
34 +
35 + return $func( $object_id, $key, $single );
36 + }
37 +
38 + /**
39 + * Update meta by object type.
40 + *
41 + * @param string $object_type Object type for destination where to save.
42 + * @param int $object_id Object id for destination where to save.
43 + * @param string $key Metadata key.
44 + * @param mixed $value Metadata value.
45 + *
46 + * @return mixed
47 + */
48 + public function update_meta( $object_type, $object_id, $key, $value ) {
49 + $func = "update_{$object_type}_meta";
50 +
51 + if ( is_string( $key ) && is_protected_meta( $key ) && ( is_scalar( $value ) || is_array( $value ) ) ) {
52 + return $func( $object_id, $key, $value );
53 + }
54 +
55 + return false;
56 + }
57 + }
58 +