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 / Integrations / Analytics / SB_Analytics.php
custom-twitter-feeds / inc / Integrations / Analytics Last commit date
SB_Analytics.php 1 month ago
SB_Analytics.php
141 lines
1 <?php
2 /**
3 * SB_Analytics plugin integration
4 * Class to impelement filters to return
5 * data needed in the SB_Analytics plugin
6 */
7
8 namespace TwitterFeed\Integrations\Analytics;
9
10 use TwitterFeed\Builder\CTF_Db;
11
12 class SB_Analytics
13 {
14 /**
15 * Summary of current_plugin
16 * @var string
17 */
18 private static $current_plugin = 'twitter';
19
20
21 /**
22 * Summary of __construct
23 */
24 public function __construct()
25 {
26 $this->init();
27 }
28
29 /**
30 * Summary of init
31 * @return void
32 */
33 public function init()
34 {
35 //Filter Top Posts
36 add_filter(
37 'sb_analytics_filter_top_posts',
38 [$this, 'filter_top_posts'],
39 10,
40 3
41 );
42
43 //Filter Profile Details
44 add_filter(
45 'sb_analytics_filter_profile_details',
46 [$this, 'filter_profile_details'],
47 10,
48 3
49 );
50
51 //Filter Feed Lists
52 add_filter(
53 'sb_analytics_filter_feed_list',
54 [$this, 'filter_feed_list'],
55 10,
56 3
57 );
58 }
59
60 /**
61 * Summary of filter_top_posts
62 *
63 * @param mixed $posts
64 * @param mixed $post_ids
65 * @param mixed $plugin_slug
66 *
67 * @return mixed
68 */
69 public function filter_top_posts($posts, $post_ids, $plugin_slug)
70 {
71 if ($plugin_slug !== self::$current_plugin) {
72 return $posts;
73 }
74
75 return CTF_Db::get_posts_by_ids($post_ids);
76 }
77
78 /**
79 * Summary of filter_profile_details
80 *
81 * @param mixed $profile_details
82 * @param mixed $feed_id
83 * @param mixed $plugin_slug
84 *
85 * @return mixed
86 */
87 public function filter_profile_details($profile_details, $feed_id, $plugin_slug)
88 {
89 if ($plugin_slug !== self::$current_plugin) {
90 return $profile_details;
91 }
92
93 $source = CTF_Db::get_feed_source_info($feed_id);
94 if (empty($source) || empty($source['name'])) {
95 return [];
96 }
97
98 return [
99 'pluginSlug' => self::$current_plugin,
100 'id' => $source['name'],
101 'profile' => [
102 'label' => $source['name'],
103 'imageSrc' => $source['picture']
104 ]
105 ];
106 }
107
108 /**
109 * Summary of filter_feed_list
110 *
111 * @param mixed $feeds
112 * @param mixed $plugin_slug
113 *
114 * @return mixed
115 */
116 public function filter_feed_list($feeds, $plugin_slug)
117 {
118 if ($plugin_slug !== self::$current_plugin) {
119 return $feeds;
120 }
121
122 $results = [];
123 $db_fees = CTF_Db::all_feeds_query(); //Get All stored Feeds
124
125 //Transform result feed schema
126 foreach ($db_fees as $feed) {
127 array_push(
128 $results,
129 [
130 'value' => [
131 'feed_id' => $feed['id'],
132 ],
133 'label' => $feed['feed_name'],
134 ]
135 );
136 }
137 return $results;
138 }
139
140 }
141