PluginProbe ʕ •ᴥ•ʔ
Custom Twitter Feeds – A Tweets Widget or X Feed Widget / 2.7.0
Custom Twitter Feeds – A Tweets Widget or X Feed Widget v2.7.0
2.8.0 2.7.0 2.6.1 2.6.0 1.0 1.0.1 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3 1.4 1.4.1 1.5 1.5.1 1.6 1.6.1 1.7 1.8 1.8.1 1.8.2 1.8.3 1.8.4 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1 2.1.1 2.1.2 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.5.4 2.5.5 trunk
custom-twitter-feeds / inc / V2 / Adapter.php
custom-twitter-feeds / inc / V2 Last commit date
Adapter.php 1 month ago CtfOauthConnect.php 1 month ago MediaAdapter.php 1 month ago TweetAdapter.php 1 month ago TwitterHelperApi.php 1 month ago UserAdapter.php 1 month ago
Adapter.php
68 lines
1 <?php
2
3 /**
4 * Convertor adapter, which is extended by other classes.
5 *
6 * @package twitter-api-v2
7 */
8
9 namespace TwitterFeed\V2;
10
11 // Don't load directly.
12 if (! defined('ABSPATH')) {
13 die('-1');
14 }
15
16 /**
17 * Adapter class.
18 */
19 class Adapter {
20 /**
21 * Get mapped fields. Override on subclasses.
22 *
23 * @return array
24 */
25 public function getMappedFields()
26 {
27 return [];
28 }
29
30 /**
31 * Get nested field from nested field names.
32 *
33 * @param string $field Field.
34 * @param array $nested_field_names Nested field names.
35 *
36 * @return array
37 */
38 public function getNestedFieldValue($field, $nested_field_names)
39 {
40 if (is_string($nested_field_names)) {
41 return isset($field[ $nested_field_names ]) ? $field[ $nested_field_names ] : null;
42 }
43
44 foreach ($nested_field_names as $nested_field_name) {
45 $field = $field[ $nested_field_name ];
46 }
47
48 return $field;
49 }
50
51 /**
52 * Convert entity.
53 *
54 * @param array $entity Entity.
55 *
56 * @return array
57 */
58 public function convert($entity)
59 {
60 $converted_entity = $entity;
61 foreach ($this->getMappedFields() as $field_v1 => $field_v2) {
62 $converted_entity[ $field_v1 ] = $this->getNestedFieldValue($entity, $field_v2);
63 }
64
65 return $converted_entity;
66 }
67 }
68