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 / Builder / CTF_Post_Set.php
custom-twitter-feeds / inc / Builder Last commit date
Controls 1 month ago Tabs 1 month ago CTF_Db.php 1 month ago CTF_Feed_Builder.php 1 month ago CTF_Feed_Saver.php 1 month ago CTF_Feed_Saver_Manager.php 1 month ago CTF_Post_Set.php 1 month ago CTF_Theme_CSS.php 1 month ago CTF_Tooltip_Wizard.php 1 month ago SB_Builder_Customizer.php 1 month ago
CTF_Post_Set.php
243 lines
1 <?php
2 /**
3 * Instagram Feed Feed Post Set
4 *
5 * @since 2.0
6 */
7
8 namespace TwitterFeed\Builder;
9
10
11 class CTF_Post_Set {
12
13 /**
14 * @var int
15 */
16 private $feed_id;
17
18 /**
19 * @var array
20 */
21 private $feed_settings;
22
23 /**
24 * @var array
25 */
26 private $converted_settings;
27
28 /**
29 * @var string
30 */
31 private $transient_name;
32
33 /**
34 * @var array|object
35 */
36 private $data;
37
38 /**
39 * @var array|object
40 */
41 private $comments_data;
42
43 public function __construct( $feed_id ) {
44 $this->feed_id = $feed_id;
45 $this->transient_name = '*' . $feed_id;
46
47 $this->data = array();
48 }
49
50 /**
51 * @return array|object
52 *
53 * @since 2.0
54 */
55 public function get_data() {
56 return $this->data;
57 }
58
59 /**
60 * @return array|object
61 *
62 * @since 2.0
63 */
64 public function get_comments_data() {
65 return $this->comments_data;
66 }
67
68 /**
69 * @return array
70 *
71 * @since 2.0
72 */
73 public function get_feed_settings() {
74 return $this->feed_settings;
75 }
76
77 /**
78 * @return array
79 *
80 * @since 2.0
81 */
82 public function get_converted_settings() {
83 return $this->converted_settings;
84 }
85
86 /**
87 * Sets the settings in builder form as well as converted
88 * settings for general use in the plugin
89 *
90 * @since 2.0
91 */
92 public function init( $customizerBuilder = false, $previewSettings = false ) {
93 $saver = new CTF_Feed_Saver( $this->feed_id );
94 if( $customizerBuilder && $previewSettings != false){
95 $this->feed_settings = $saver->get_feed_settings_preview( $previewSettings );
96 } else{
97 $this->feed_settings = $saver->get_feed_settings();
98 }
99
100 $this->converted_settings = CTF_Post_Set::builder_to_general_settings_convert( $this->feed_settings );
101 }
102
103 /**
104 * Gathers posts from the API until the minimum number of posts
105 * for the feed are retrieved then stores the results
106 *
107 * @since 2.0
108 */
109 public function fetch() {
110 $post_data = [];
111 $this->data = $post_data;
112 }
113
114 /**
115 * Gathers comments for posts.
116 *
117 * @return array
118 *
119 * @since 2.0
120 */
121 public function fetch_comments() {
122 if ( empty( $this->data ) ) {
123 return array();
124 }
125
126 $comments = [];
127 $this->comments_data = $comments;
128
129 return $comments;
130 }
131
132 /**
133 * Converts raw settings from the cff_feed_settings table into the
134 * more general way that the "CFF_Shortcode" class,
135 * "cff_get_processed_options" method does
136 *
137 * @param array $builder_settings
138 *
139 * @return array
140 *
141 * @since 2.0
142 */
143 public static function builder_to_general_settings_convert( $builder_settings ) {
144 $settings_with_multiples = array();
145
146 foreach ( $settings_with_multiples as $array_setting ) {
147 if ( is_array( $builder_settings[ $array_setting ] ) ) {
148 $builder_settings[ $array_setting ] = implode( ',', $builder_settings[ $array_setting ] );
149 }
150 }
151
152 if ( isset( $builder_settings['sources'] ) && is_array($builder_settings['sources'])) {
153
154 $access_tokens = array();
155 $ids = array();
156 $id_access_tokens = array();
157 $sources_setting = array();
158 foreach ( $builder_settings['sources'] as $source ) {
159 $source_array = array();
160 if ( ! is_array( $source ) ) {
161 $args = array( 'id' => $source );
162 if ( isset( $builder_settings['feedtype'] ) && $builder_settings['feedtype'] == 'events' ){
163 $args['privilege'] = 'events';
164 }
165 $source_query = CTF_Db::source_query( $args );
166
167 if ( isset( $source_query[0] ) ) {
168 $source_array = $source_query[0];
169 $sources_setting[] = $source_query[0];
170 }
171 } else {
172 $source_array = $source;
173 }
174
175
176 if ( ! empty( $source_array ) ) {
177 $access_tokens[] = $source_array['access_token'];
178 }
179
180 }
181
182 if ( ! empty( $sources_setting ) ) {
183 $builder_settings['sources'] = $sources_setting;
184 }
185 }
186
187 return $builder_settings;
188 }
189
190 /**
191 * Convert settings from 3.x for use in the builder in 6.0+
192 *
193 * @param array $atts
194 *
195 * @return array
196 *
197 * @since 2.0
198 */
199 public static function legacy_to_builder_convert( $atts = array() ) {
200 $processed_settings = [];
201
202 return $processed_settings;
203 }
204
205 /**
206 * Settings that can include an array of values
207 *
208 * @return array
209 *
210 * @since 2.0
211 */
212 public static function get_settings_with_multiple() {
213 $settings_with_multiples = [];
214
215 return $settings_with_multiples;
216 }
217
218 /**
219 * Used for changing the settings used for general front end feeds
220 *
221 * @param array $builder_settings
222 *
223 * @return array
224 *
225 * @since 2.0
226 */
227 public static function filter_general_settings( $builder_settings ) {
228 return $builder_settings;
229 }
230
231 /**
232 * Used for changing the settings for feeds being edited in the customizer
233 *
234 * @param array $processed_settings
235 *
236 * @return array
237 *
238 * @since 2.0
239 */
240 public static function filter_builder_settings( $processed_settings ) {
241 return $processed_settings;
242 }
243 }