Admin
1 month ago
Builder
1 month ago
Integrations
1 month ago
SmashTwitter
1 month ago
UsageTracking
1 month ago
V2
1 month ago
blocks
1 month ago
CTF_Display_Elements.php
1 month ago
CTF_Feed.php
1 month ago
CTF_Feed_Locator.php
1 month ago
CTF_GDPR_Integrations.php
1 month ago
CTF_Parse.php
1 month ago
CTF_Settings.php
1 month ago
CtfAdmin.php
1 month ago
CtfCache.php
1 month ago
CtfFeed.php
1 month ago
CtfOauthConnect.php
1 month ago
SB_Twitter_Cron_Updater.php
1 month ago
admin-hooks.php
1 month ago
ctf-functions.php
1 month ago
notices.php
1 month ago
widget.php
1 month ago
CTF_Settings.php
620 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class CTF_Settings |
| 4 | * |
| 5 | * Creates organized settings from shortcode settings and settings |
| 6 | * from the options table. |
| 7 | * |
| 8 | * Also responsible for creating transient names/feed ids based on |
| 9 | * feed settings |
| 10 | * |
| 11 | * @since 2.0/5.0 |
| 12 | */ |
| 13 | namespace TwitterFeed; |
| 14 | use TwitterFeed\CtfFeed; |
| 15 | use TwitterFeed\Builder\CTF_Feed_Saver; |
| 16 | |
| 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | die( '-1' ); |
| 19 | } |
| 20 | |
| 21 | class CTF_Settings { |
| 22 | /** |
| 23 | * @var array |
| 24 | */ |
| 25 | protected $atts; |
| 26 | |
| 27 | /** |
| 28 | * @var array |
| 29 | */ |
| 30 | protected $db; |
| 31 | |
| 32 | /** |
| 33 | * @var array |
| 34 | */ |
| 35 | protected $settings; |
| 36 | |
| 37 | /** |
| 38 | * @var array |
| 39 | */ |
| 40 | protected $feed_type_and_terms; |
| 41 | |
| 42 | /** |
| 43 | * CTF_Settings constructor. |
| 44 | * |
| 45 | * Overwritten in the Pro version. |
| 46 | * |
| 47 | * @param array $atts shortcode settings |
| 48 | * @param array $db settings from the wp_options table |
| 49 | */ |
| 50 | public function __construct( $atts, $db = null, $preview_settings = false ) { |
| 51 | |
| 52 | $feed = new CtfFeed( $atts, null, null ); |
| 53 | $feed->setFeedOptions(); |
| 54 | |
| 55 | $bool_false = array( |
| 56 | 'includereplies', |
| 57 | 'masonry', |
| 58 | 'autoscroll', |
| 59 | 'disablelightbox', |
| 60 | 'carousel', |
| 61 | 'carouselautoplay', |
| 62 | 'carouselpag', |
| 63 | 'sslonly', |
| 64 | 'shorturls' |
| 65 | ); |
| 66 | $feed->setStandardBoolOptions( $bool_false, false ); |
| 67 | $feed->setStandardBoolOptions( array( 'persistentcache', 'autores' ), true ); |
| 68 | $feed->setStandardTextOptions( 'carouselarrows', 'onhover' ); |
| 69 | $feed->setStandardTextOptions( 'carouselheight', 'tallest' ); |
| 70 | $feed->setStandardTextOptions( 'carouselcols', 1 ); |
| 71 | $feed->setStandardTextOptions( 'carouselmobilecols', 1 ); |
| 72 | $feed->setStandardTextOptions( 'carouseltime', 5000 ); |
| 73 | $feed->setStandardTextOptions( 'carouselloop', 'none' ); |
| 74 | $feed->setStandardTextOptions( 'masonrycols', 3 ); |
| 75 | $feed->setStandardTextOptions( 'masonrymobilecols', 1 ); |
| 76 | $feed->setStandardTextOptions( 'autoscrolldistance', '200' ); |
| 77 | $feed->setStandardTextOptions( 'textlength', 280 ); |
| 78 | $feed->setStandardTextOptions( 'maxmedia', 4 ); |
| 79 | $feed->setStandardTextOptions( 'imagecols', 'auto' ); |
| 80 | $feed->setStandardTextOptions( 'inreplytotext', 'In reply to' ); |
| 81 | $feed->setStandardTextOptions( array( 'includewords', 'excludewords' ) ); |
| 82 | $feed->setStandardTextOptions( array( 'includeanyall', 'excludeanyall' ), 'any' ); |
| 83 | $feed->setStandardTextOptions( 'filterandor', 'and' ); |
| 84 | |
| 85 | $feed->setDatabaseOnlyOptions( 'remove_by_id' ); |
| 86 | |
| 87 | $this->settings = $feed->feed_options; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * @return array |
| 92 | * |
| 93 | * @since 2.0/5.0 |
| 94 | */ |
| 95 | public function get_settings() { |
| 96 | return $this->settings; |
| 97 | } |
| 98 | |
| 99 | public function get_feed_type_and_terms() { |
| 100 | return $this->feed_type_and_terms; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Based on the settings related to retrieving post data from the API, |
| 105 | * this setting is used to make sure all endpoints needed for the feed are |
| 106 | * connected and stored for easily looping through when adding posts |
| 107 | * |
| 108 | * Overwritten in the Pro version. |
| 109 | * |
| 110 | * @since 2.0/5.0 |
| 111 | */ |
| 112 | public function set_feed_type_and_terms() { |
| 113 | $this->feed_type_and_terms = array(); |
| 114 | if ( ! empty( $this->settings['feed_types_and_terms'] ) ) { |
| 115 | |
| 116 | foreach ( $this->settings['feed_types_and_terms'] as $type_then_term ) { |
| 117 | switch ( $type_then_term[0] ) { |
| 118 | case 'hometimeline': |
| 119 | $this->feed_type_and_terms['hometimeline'][] = array( |
| 120 | 'term' => 'hometimeline', |
| 121 | 'params' => array() |
| 122 | ); |
| 123 | break; |
| 124 | case 'hashtag': |
| 125 | $hashtag_str = isset( $type_then_term[1] ) ? $type_then_term[1] : ''; |
| 126 | $hashtag_str = str_replace( ',', ' OR ', $hashtag_str ); |
| 127 | |
| 128 | $this->feed_type_and_terms['search'][] = array( |
| 129 | 'term' => $hashtag_str, |
| 130 | 'params' => array() |
| 131 | ); |
| 132 | break; |
| 133 | default: |
| 134 | $screenname = isset( $type_then_term[1] ) ? $type_then_term[1] : ''; |
| 135 | |
| 136 | $this->feed_type_and_terms['usertimeline'][] = array( |
| 137 | 'term' => $screenname, |
| 138 | 'params' => array() |
| 139 | ); |
| 140 | break; |
| 141 | } |
| 142 | } |
| 143 | } else { |
| 144 | if ( ! empty( $this->settings['type'] ) ) { |
| 145 | switch ( $this->settings['type'] ) { |
| 146 | case 'hometimeline': |
| 147 | $this->feed_type_and_terms['hometimeline'][] = array( |
| 148 | 'term' => 'hometimeline', |
| 149 | 'params' => array() |
| 150 | ); |
| 151 | break; |
| 152 | case 'hashtag': |
| 153 | $hashtag_str = isset( $this->settings['hashtag_text'] ) ? $this->settings['hashtag_text'] : ''; |
| 154 | if ( empty( $hashtag_str ) ) { |
| 155 | $hashtag_str = ( $this->settings['feed_term'] ) ? $this->settings['feed_term'] : ''; |
| 156 | } |
| 157 | $hashtag_str = str_replace( ',', ' OR ', $hashtag_str ); |
| 158 | |
| 159 | $this->feed_type_and_terms['search'][] = array( |
| 160 | 'term' => $hashtag_str, |
| 161 | 'params' => array() |
| 162 | ); |
| 163 | break; |
| 164 | default: |
| 165 | $screennames_str = isset( $this->settings['screenname'] ) ? $this->settings['screenname'] : $this->settings['usertimeline_text']; |
| 166 | $screennames = explode( ',', $screennames_str ); |
| 167 | |
| 168 | foreach ( $screennames as $screenname ) { |
| 169 | $this->feed_type_and_terms['usertimeline'][] = array( |
| 170 | 'term' => $screenname, |
| 171 | 'params' => array() |
| 172 | ); |
| 173 | } |
| 174 | break; |
| 175 | } |
| 176 | |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | public static function get_settings_by_feed_id( $feed_id, $preview_settings = false ) { |
| 182 | if ( is_array( $preview_settings ) ) { |
| 183 | return $preview_settings; |
| 184 | } |
| 185 | |
| 186 | if ( intval( $feed_id ) < 1 ) { |
| 187 | return false; |
| 188 | } |
| 189 | |
| 190 | $feed_saver = new CTF_Feed_Saver( $feed_id ); |
| 191 | |
| 192 | return $feed_saver->get_feed_settings(); |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Filters out or converts allowed/disallowed shortcode settings |
| 197 | * |
| 198 | * @param $atts |
| 199 | * |
| 200 | * @return mixed |
| 201 | * @since 2.0 |
| 202 | */ |
| 203 | public static function filter_atts_for_legacy( $atts ) { |
| 204 | if ( empty( $atts ) ) { |
| 205 | $atts = array(); |
| 206 | } |
| 207 | if ( ! empty( $atts['from_update'] ) ) { |
| 208 | unset( $atts['from_update'] ); |
| 209 | return $atts; |
| 210 | } |
| 211 | $ctf_statuses = get_option( 'ctf_statuses', array() ); |
| 212 | $allowed_legacy_shortcode = array( |
| 213 | 'feed', |
| 214 | 'customizer', |
| 215 | 'doingcronupdate' |
| 216 | ); |
| 217 | |
| 218 | if ( ! empty( $ctf_statuses['support_legacy_shortcode'] ) |
| 219 | && empty( $atts['feed'] ) ) { |
| 220 | |
| 221 | if ( is_array( $ctf_statuses['support_legacy_shortcode'] ) ) { |
| 222 | $atts_diff = array_diff( $ctf_statuses['support_legacy_shortcode'], $atts ); |
| 223 | |
| 224 | foreach ( $atts_diff as $key => $value ) { |
| 225 | if ( in_array( $key, $allowed_legacy_shortcode ) ) { |
| 226 | unset( $atts_diff[ $key ] ); |
| 227 | } |
| 228 | } |
| 229 | if ( empty( $atts_diff ) ) { |
| 230 | $atts['feed'] = 1; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | if ( empty( $atts['feed'] ) ) { |
| 235 | return $atts; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | |
| 240 | foreach ( $atts as $key => $value ) { |
| 241 | if ( ! in_array( $key, $allowed_legacy_shortcode ) ) { |
| 242 | unset( $atts[ $key ] ); |
| 243 | } |
| 244 | |
| 245 | } |
| 246 | |
| 247 | return $atts; |
| 248 | |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * For one time update to capture existing legacy shortcode atts |
| 253 | * |
| 254 | * @param array $atts |
| 255 | * @param array $db |
| 256 | * |
| 257 | * @return array |
| 258 | */ |
| 259 | public static function legacy_shortcode_atts( $atts, $db ) { |
| 260 | $s_options = [ |
| 261 | 'author', |
| 262 | 'avatar', |
| 263 | 'author_text', |
| 264 | 'text', |
| 265 | 'date', |
| 266 | 'actions', |
| 267 | 'linkbox', |
| 268 | 'media', |
| 269 | 'twittercards', |
| 270 | 'logo', |
| 271 | 'twitterlink' |
| 272 | ]; |
| 273 | |
| 274 | if( isset( $atts['exclude'] ) ){ |
| 275 | $exclude_attr = explode( ',', $atts['exclude'] ); |
| 276 | foreach ($s_options as $opt_name) { |
| 277 | $opt_name_exc = 'include_' . $opt_name; |
| 278 | $db[$opt_name_exc] = in_array( $opt_name, $exclude_attr ) ? false : true; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | if( isset( $atts['include'] ) ){ |
| 283 | $include_attr = explode( ',', $atts['include'] ); |
| 284 | foreach ($s_options as $opt_name) { |
| 285 | $opt_name_inc = 'include_' . $opt_name; |
| 286 | $db[$opt_name_inc] = in_array( $opt_name, $include_attr ) ? true : false; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | $customHeaderTextDefault = ctf_should_rebrand_to_x() ? __('We are on X', 'custom-twitter-feeds') : __('We are on Twitter', 'custom-twitter-feeds'); |
| 291 | $repostedText = ctf_should_rebrand_to_x() ? __('Reposted', 'custom-twitter-feeds') : __('Retweeted', 'custom-twitter-feeds'); |
| 292 | |
| 293 | $settings = shortcode_atts( |
| 294 | array( |
| 295 | 'ajax_theme' => isset( $db['ajax_theme'] ) ? $db['ajax_theme'] : false, |
| 296 | 'have_own_tokens' => isset( $db['have_own_tokens'] ) ? $db['have_own_tokens'] : '', |
| 297 | 'use_own_consumer' => isset( $db['use_own_consumer'] ) ? $db['use_own_consumer'] : '', |
| 298 | 'usertimeline_includereplies' => isset( $db['usertimeline_includereplies'] ) ? $db['usertimeline_includereplies'] : '', |
| 299 | 'hometimeline_includereplies' => isset( $db['hometimeline_includereplies'] ) ? $db['hometimeline_includereplies'] : '', |
| 300 | 'mentionstimeline_includereplies' => isset( $db['mentionstimeline_includereplies'] ) ? $db['mentionstimeline_includereplies'] : '', |
| 301 | 'usertimeline_includeretweets' => isset( $db['usertimeline_includeretweets'] ) ? $db['usertimeline_includeretweets'] : '', |
| 302 | 'hometimeline_includeretweets' => isset( $db['hometimeline_includeretweets'] ) ? $db['hometimeline_includeretweets'] : true, |
| 303 | 'mentionstimeline_includeretweets' => isset( $db['mentionstimeline_includeretweets'] ) ? $db['mentionstimeline_includeretweets'] : '', |
| 304 | 'tab' => isset( $db['tab'] ) ? $db['tab'] : 'configure', |
| 305 | 'consumer_key' => isset( $db['consumer_key'] ) ? $db['consumer_key'] : '', |
| 306 | 'consumer_secret' => isset( $db['consumer_secret'] ) ? $db['consumer_secret'] : '', |
| 307 | 'access_token' => isset( $db['access_token'] ) ? $db['access_token'] : '', |
| 308 | 'access_token_secret' => isset( $db['access_token_secret'] ) ? $db['access_token_secret'] : '', |
| 309 | 'type' => isset( $db['type'] ) ? $db['type'] : 'usertimeline', |
| 310 | 'usertimeline_text' => isset( $db['usertimeline_text'] ) ? $db['usertimeline_text'] : '', |
| 311 | 'hashtag_text' => isset( $db['search_text'] ) ? $db['search_text'] : '', |
| 312 | 'search_text' => isset( $db['search_text'] ) ? $db['search_text'] : '', |
| 313 | 'hashtag' => isset( $db['search_text'] ) ? $db['search_text'] : '', |
| 314 | 'search' => isset( $db['search_text'] ) ? $db['search_text'] : '', |
| 315 | //'lists_id' => isset( $db['lists_id'] ) ? $db['lists_id'] : '', |
| 316 | //'lists_owner' => isset( $db['lists_owner'] ) ? $db['lists_owner'] : '', |
| 317 | 'num' => isset( $db['num'] ) ? $db['num'] : '5', |
| 318 | 'lists_info' => isset( $db['lists_info'] ) ? $db['lists_info'] : '{}', |
| 319 | 'includereplies' => isset( $db['includereplies'] ) ? $db['includereplies'] : true, |
| 320 | 'includeretweets' => isset( $db['includeretweets'] ) ? $db['includeretweets'] : true, |
| 321 | 'width_mobile_no_fixed' => isset( $db['width_mobile_no_fixed'] ) ? $db['width_mobile_no_fixed'] : false, |
| 322 | 'include_replied_to' => isset( $db['include_replied_to'] ) ? $db['include_replied_to'] : true, |
| 323 | 'include_retweeter' => isset( $db['include_retweeter'] ) ? $db['include_retweeter'] : true, |
| 324 | 'include_author' => isset( $db['include_author'] ) ? $db['include_author'] : true, |
| 325 | 'include_avatar' => isset( $db['include_avatar'] ) ? $db['include_avatar'] : true, |
| 326 | 'include_author_text' => isset( $db['include_author_text'] ) ? $db['include_author_text'] : true, |
| 327 | 'include_text' => isset( $db['include_text'] ) ? $db['include_text'] : true, |
| 328 | 'include_date' => isset( $db['include_date'] ) ? $db['include_date'] : true, |
| 329 | 'include_actions' => isset( $db['include_actions'] ) ? $db['include_actions'] : true, |
| 330 | 'include_linkbox' => isset( $db['include_linkbox'] ) ? $db['include_linkbox'] : true, |
| 331 | 'include_media' => isset( $db['include_media'] ) ? $db['include_media'] : true, |
| 332 | 'include_twittercards' => isset( $db['include_twittercards'] ) ? $db['include_twittercards'] : true, |
| 333 | 'include_logo' => isset( $db['include_logo'] ) ? $db['include_logo'] : true, |
| 334 | 'include_twitterlink' => isset( $db['include_twitterlink'] ) ? $db['include_twitterlink'] : true, |
| 335 | 'creditctf' => isset( $db['creditctf'] ) ? $db['creditctf'] : false, |
| 336 | 'showbutton' => isset( $db['showbutton'] ) ? $db['showbutton'] : true, |
| 337 | 'showheader' => isset( $db['showheader'] ) ? $db['showheader'] : true, |
| 338 | 'persistentcache' => isset( $db['persistentcache'] ) ? $db['persistentcache'] : true, |
| 339 | 'selfreplies' => isset( $db['selfreplies'] ) ? $db['selfreplies'] : true, |
| 340 | 'autores' => isset( $db['autores'] ) ? $db['autores'] : true, |
| 341 | 'disableintents' => isset( $db['disableintents'] ) ? $db['disableintents'] : false, |
| 342 | 'customtemplates' => isset( $db['customtemplates'] ) ? $db['customtemplates'] : false, |
| 343 | 'shorturls' => isset( $db['shorturls'] ) ? $db['shorturls'] : false, |
| 344 | 'curlcards' => isset( $db['curlcards'] ) ? $db['curlcards'] : true, |
| 345 | 'sslonly' => isset( $db['sslonly'] ) ? $db['sslonly'] : false, |
| 346 | 'disablelightbox' => isset( $db['disablelightbox'] ) ? $db['disablelightbox'] : false, |
| 347 | 'masonry' => isset( $db['masonry'] ) ? $db['masonry'] : false, |
| 348 | 'carousel' => isset( $db['carousel'] ) ? $db['carousel'] : false, |
| 349 | 'carouselnavarrows' => isset( $db['carouselnavarrows'] ) ? $db['carouselnavarrows'] : true, |
| 350 | 'carouselpag' => isset( $db['carouselpag'] ) ? $db['carouselpag'] : false, |
| 351 | 'carouselautoplay' => isset( $db['carouselautoplay'] ) ? $db['carouselautoplay'] : false, |
| 352 | 'autoscroll' => isset( $db['autoscroll'] ) ? $db['autoscroll'] : true, |
| 353 | 'width' => isset( $db['width'] ) ? $db['width'] : '100', |
| 354 | 'width_unit' => isset( $db['width_unit'] ) ? $db['width_unit'] : '%', |
| 355 | 'height' => isset( $db['height'] ) ? $db['height'] : '', |
| 356 | 'height_unit' => isset( $db['height_unit'] ) ? $db['height_unit'] : '%', |
| 357 | 'class' => isset( $db['class'] ) ? $db['class'] : '', |
| 358 | 'layout' => isset( $db['layout'] ) ? $db['layout'] : 'list', |
| 359 | 'masonrycols' => isset( $db['masonrycols'] ) ? $db['masonrycols'] : '3', |
| 360 | 'masonrytabletcols' => isset( $db['masonrytabletcols'] ) ? $db['masonrytabletcols'] : '2', |
| 361 | 'masonrymobilecols' => isset( $db['masonrymobilecols'] ) ? $db['masonrymobilecols'] : '1', |
| 362 | 'carouselrows' => isset( $db['carouselrows'] ) ? $db['carouselrows'] : '1', |
| 363 | 'carouselcols' => isset( $db['carouselcols'] ) ? $db['carouselcols'] : '3', |
| 364 | 'carouseltabletcols' => isset( $db['carouseltabletcols'] ) ? $db['carouseltabletcols'] : '2', |
| 365 | 'carouselmobilecols' => isset( $db['carouselmobilecols'] ) ? $db['carouselmobilecols'] : '1', |
| 366 | 'carouselloop' => isset( $db['carouselloop'] ) ? $db['carouselloop'] : 'rewind', |
| 367 | 'carouselarrows' => isset( $db['carouselarrows'] ) ? $db['carouselarrows'] : 'onhover', |
| 368 | 'carouselheight' => isset( $db['carouselheight'] ) ? $db['carouselheight'] : 'tallest', |
| 369 | 'carouseltime' => isset( $db['carouseltime'] ) ? $db['carouseltime'] : '5000', |
| 370 | 'maxmedia' => isset( $db['maxmedia'] ) ? $db['maxmedia'] : '4', |
| 371 | 'imagecols' => isset( $db['imagecols'] ) ? $db['imagecols'] : 'auto', |
| 372 | 'autoscrolldistance' => isset( $db['autoscrolldistance'] ) ? $db['autoscrolldistance'] : '200', |
| 373 | 'includewords' => isset( $db['includewords'] ) ? $db['includewords'] : '', |
| 374 | 'excludewords' => isset( $db['excludewords'] ) ? $db['excludewords'] : '', |
| 375 | 'includeanyall' => isset( $db['includeanyall'] ) ? $db['includeanyall'] : 'any', |
| 376 | 'filterandor' => isset( $db['filterandor'] ) ? $db['filterandor'] : 'and', |
| 377 | 'excludeanyall' => isset( $db['excludeanyall'] ) ? $db['excludeanyall'] : 'any', |
| 378 | 'remove_by_id' => isset( $db['remove_by_id'] ) ? $db['remove_by_id'] : '', |
| 379 | 'custom_css' => isset( $db['custom_css'] ) ? $db['custom_css'] : '', |
| 380 | 'custom_js' => isset( $db['custom_js'] ) ? $db['custom_js'] : '', |
| 381 | 'request_method' => isset( $db['request_method'] ) ? $db['request_method'] : 'auto', |
| 382 | 'cron_cache_clear' => isset( $db['cron_cache_clear'] ) ? $db['cron_cache_clear'] : 'unset', |
| 383 | 'multiplier' => isset( $db['multiplier'] ) ? $db['multiplier'] : '1.25', |
| 384 | 'font_method' => isset( $db['font_method'] ) ? $db['font_method'] : 'svg', |
| 385 | 'include_media_placeholder' => isset( $db['include_media_placeholder'] ) ? $db['include_media_placeholder'] : true, |
| 386 | 'showbio' => isset( $db['showbio'] ) ? $db['showbio'] : true, |
| 387 | 'disablelinks' => isset( $db['disablelinks'] ) ? $db['disablelinks'] : false, |
| 388 | 'linktexttotwitter' => isset( $db['linktexttotwitter'] ) ? $db['linktexttotwitter'] : false, |
| 389 | 'bgcolor' => isset( $db['bgcolor'] ) ? $db['bgcolor'] : '#', |
| 390 | 'tweetbgcolor' => isset( $db['tweetbgcolor'] ) ? $db['tweetbgcolor'] : '#', |
| 391 | 'headertextcolor' => isset( $db['headertextcolor'] ) ? $db['headertextcolor'] : '#', |
| 392 | 'headertext' => isset( $db['headertext'] ) ? $db['headertext'] : '', |
| 393 | 'headersize' => isset( $db['headersize'] ) ? $db['headersize'] : 'small', |
| 394 | 'headerstyle' => isset( $db['headerstyle'] ) ? $db['headerstyle'] : 'standard', |
| 395 | 'headerbgcolor' => isset( $db['headerbgcolor'] ) ? $db['headerbgcolor'] : '#', |
| 396 | 'customheadertextcolor' => isset( $db['customheadertextcolor'] ) ? $db['customheadertextcolor'] : '#', |
| 397 | 'customheadertext' => isset($db['customheadertext']) ? $db['customheadertext'] : $customHeaderTextDefault, |
| 398 | 'customheadersize' => isset( $db['customheadersize'] ) ? $db['customheadersize'] : 'small', |
| 399 | 'timezone' => isset( $db['timezone'] ) ? $db['timezone'] : 'default', |
| 400 | 'dateformat' => isset( $db['dateformat'] ) ? $db['dateformat'] : '1', |
| 401 | 'datecustom' => isset( $db['datecustom'] ) ? $db['datecustom'] : '', |
| 402 | 'mtime' => isset( $db['mtime'] ) ? $db['mtime'] : 'm', |
| 403 | 'htime' => isset( $db['htime'] ) ? $db['htime'] : 'h', |
| 404 | 'nowtime' => isset( $db['nowtime'] ) ? $db['nowtime'] : 'now', |
| 405 | 'datetextsize' => isset( $db['datetextsize'] ) ? $db['datetextsize'] : 'inherit', |
| 406 | 'datetextweight' => isset( $db['datetextweight'] ) ? $db['datetextweight'] : 'inherit', |
| 407 | 'datetextcolor' => isset( $db['datetextcolor'] ) ? $db['datetextcolor'] : '#', |
| 408 | 'authortextcolor' => isset( $db['authortextcolor'] ) ? $db['authortextcolor'] : '#', |
| 409 | 'authortextsize' => isset( $db['authortextsize'] ) ? $db['authortextsize'] : 'inherit', |
| 410 | 'authortextweight' => isset( $db['authortextweight'] ) ? $db['authortextweight'] : 'inherit', |
| 411 | 'logosize' => isset( $db['logosize'] ) ? $db['logosize'] : 'inherit', |
| 412 | 'logocolor' => isset( $db['logocolor'] ) ? $db['logocolor'] : '#', |
| 413 | 'tweettextsize' => isset( $db['tweettextsize'] ) ? $db['tweettextsize'] : 'inherit', |
| 414 | 'tweettextweight' => isset( $db['tweettextweight'] ) ? $db['tweettextweight'] : 'inherit', |
| 415 | 'textcolor' => isset( $db['textcolor'] ) ? $db['textcolor'] : '#', |
| 416 | 'textlength' => isset( $db['textlength'] ) ? $db['textlength'] : '280', |
| 417 | 'retweetedtext' => isset( $db['retweetedtext'] ) ? $db['retweetedtext'] : $repostedText, |
| 418 | 'linktextcolor' => isset( $db['linktextcolor'] ) ? $db['linktextcolor'] : '#', |
| 419 | 'quotedauthorsize' => isset( $db['quotedauthorsize'] ) ? $db['quotedauthorsize'] : 'inherit', |
| 420 | 'quotedauthorweight' => isset( $db['quotedauthorweight'] ) ? $db['quotedauthorweight'] : 'inherit', |
| 421 | 'iconsize' => isset( $db['iconsize'] ) ? $db['iconsize'] : 'inherit', |
| 422 | 'iconcolor' => isset( $db['iconcolor'] ) ? $db['iconcolor'] : '#', |
| 423 | 'viewtwitterlink' => isset( $db['viewtwitterlink'] ) ? $db['viewtwitterlink'] : true, |
| 424 | 'twitterlinktext' => isset( $db['twitterlinktext'] ) ? $db['twitterlinktext'] : 'Twitter', |
| 425 | 'buttoncolor' => isset( $db['buttoncolor'] ) ? $db['buttoncolor'] : '#', |
| 426 | 'buttonhovercolor' => isset( $db['buttonhovercolor'] ) ? $db['buttonhovercolor'] : '#', |
| 427 | 'buttontextcolor' => isset( $db['buttontextcolor'] ) ? $db['buttontextcolor'] : '#', |
| 428 | 'buttontext' => isset( $db['buttontext'] ) ? $db['buttontext'] : __( 'Load More', 'custom-twitter-feeds' ), |
| 429 | 'inreplytotext' => isset( $db['inreplytotext'] ) ? $db['inreplytotext'] : __( 'In Reply To', 'custom-twitter-feeds' ), |
| 430 | 'feedtemplate' => isset( $db['feedtemplate'] ) ? $db['feedtemplate'] : 'default', |
| 431 | 'cardstextsize' => isset( $db['cardstextsize'] ) ? $db['cardstextsize'] : 'inherit', |
| 432 | 'cardstextcolor' => isset( $db['cardstextcolor'] ) ? $db['cardstextcolor'] : '#', |
| 433 | 'colorpalette' => isset( $db['colorpalette'] ) ? $db['colorpalette'] : 'inherit', |
| 434 | 'custombgcolor' => isset( $db['custombgcolor'] ) ? $db['custombgcolor'] : '', |
| 435 | 'customaccentcolor' => isset( $db['customaccentcolor'] ) ? $db['customaccentcolor'] : '', |
| 436 | 'customtextcolor1' => isset( $db['customtextcolor1'] ) ? $db['customtextcolor1'] : '', |
| 437 | 'customtextcolor2' => isset( $db['customtextcolor2'] ) ? $db['customtextcolor2'] : '', |
| 438 | 'customlinkcolor' => isset( $db['customlinkcolor'] ) ? $db['customlinkcolor'] : '', |
| 439 | 'tweetpoststyle' => isset( $db['tweetpoststyle'] ) ? $db['tweetpoststyle'] : 'regular', |
| 440 | 'tweetbgcolor' => isset( $db['tweetbgcolor'] ) ? $db['tweetbgcolor'] : '#', |
| 441 | 'tweetcorners' => isset( $db['tweetcorners'] ) ? $db['tweetcorners'] : '0', |
| 442 | 'tweetboxshadow' => isset( $db['tweetboxshadow'] ) ? $db['tweetboxshadow'] : false, |
| 443 | 'tweetsepcolor' => isset( $db['tweetsepcolor'] ) ? $db['tweetsepcolor'] : '#ddd', |
| 444 | 'tweetsepsize' => isset( $db['tweetsepsize'] ) ? $db['tweetsepsize'] : '1', |
| 445 | 'tweetsepline' => isset( $db['tweetsepline'] ) ? $db['tweetsepline'] : true |
| 446 | ), |
| 447 | $atts |
| 448 | ); |
| 449 | |
| 450 | if ( $settings['type'] === 'search' ) { |
| 451 | $settings['type'] = 'hashtag'; |
| 452 | if ( ! empty( $atts['hashtag'] ) ) { |
| 453 | $settings['hashtag'] = $atts['hashtag']; |
| 454 | $settings['search'] = $atts['hashtag']; |
| 455 | $settings['hashtag_text'] = $atts['hashtag']; |
| 456 | $settings['search_text'] = $atts['hashtag']; |
| 457 | } else { |
| 458 | $settings['hashtag'] = $settings['search']; |
| 459 | } |
| 460 | } |
| 461 | $settings['num'] = (int) $settings['num']; |
| 462 | |
| 463 | return $settings; |
| 464 | |
| 465 | } |
| 466 | |
| 467 | public static function get_public_db_settings_keys() { |
| 468 | $customHeaderTextDefault = ctf_should_rebrand_to_x() ? __('We are on X', 'custom-twitter-feeds') : __('We are on Twitter', 'custom-twitter-feeds'); |
| 469 | |
| 470 | $public = array( |
| 471 | 'ajax_theme' => isset( $db['ajax_theme'] ) ? $db['ajax_theme'] : false, |
| 472 | 'have_own_tokens' => isset( $db['have_own_tokens'] ) ? $db['have_own_tokens'] : '', |
| 473 | 'use_own_consumer' => isset( $db['use_own_consumer'] ) ? $db['use_own_consumer'] : '', |
| 474 | 'usertimeline_includereplies' => isset( $db['usertimeline_includereplies'] ) ? $db['usertimeline_includereplies'] : '', |
| 475 | 'hometimeline_includereplies' => isset( $db['hometimeline_includereplies'] ) ? $db['hometimeline_includereplies'] : '', |
| 476 | 'mentionstimeline_includereplies' => isset( $db['mentionstimeline_includereplies'] ) ? $db['mentionstimeline_includereplies'] : '', |
| 477 | 'usertimeline_includeretweets' => isset( $db['usertimeline_includeretweets'] ) ? $db['usertimeline_includeretweets'] : '', |
| 478 | 'hometimeline_includeretweets' => isset( $db['hometimeline_includeretweets'] ) ? $db['hometimeline_includeretweets'] : true, |
| 479 | 'mentionstimeline_includeretweets' => isset( $db['mentionstimeline_includeretweets'] ) ? $db['mentionstimeline_includeretweets'] : '', |
| 480 | 'tab' => isset( $db['tab'] ) ? $db['tab'] : 'configure', |
| 481 | 'type' => isset( $db['type'] ) ? $db['type'] : 'usertimeline', |
| 482 | 'usertimeline_text' => isset( $db['usertimeline_text'] ) ? $db['usertimeline_text'] : '', |
| 483 | 'hashtag_text' => isset( $db['hashtag_text'] ) ? $db['hashtag_text'] : '', |
| 484 | 'search_text' => isset( $db['search_text'] ) ? $db['search_text'] : '', |
| 485 | 'lists_id' => isset( $db['lists_id'] ) ? $db['lists_id'] : '', |
| 486 | 'num' => isset( $db['num'] ) ? $db['num'] : '5', |
| 487 | 'lists_info' => isset( $db['lists_info'] ) ? $db['lists_info'] : '{}', |
| 488 | 'includereplies' => isset( $db['includereplies'] ) ? $db['includereplies'] : true, |
| 489 | 'includeretweets' => isset( $db['includeretweets'] ) ? $db['includeretweets'] : true, |
| 490 | 'width_mobile_no_fixed' => isset( $db['width_mobile_no_fixed'] ) ? $db['width_mobile_no_fixed'] : false, |
| 491 | 'include_replied_to' => isset( $db['include_replied_to'] ) ? $db['include_replied_to'] : true, |
| 492 | 'include_retweeter' => isset( $db['include_retweeter'] ) ? $db['include_retweeter'] : true, |
| 493 | 'include_author' => isset( $db['include_author'] ) ? $db['include_author'] : true, |
| 494 | 'include_avatar' => isset( $db['include_avatar'] ) ? $db['include_avatar'] : true, |
| 495 | 'include_author_text' => isset( $db['include_author_text'] ) ? $db['include_author_text'] : true, |
| 496 | 'include_text' => isset( $db['include_text'] ) ? $db['include_text'] : true, |
| 497 | 'include_date' => isset( $db['include_date'] ) ? $db['include_date'] : true, |
| 498 | 'include_actions' => isset( $db['include_actions'] ) ? $db['include_actions'] : true, |
| 499 | 'include_linkbox' => isset( $db['include_linkbox'] ) ? $db['include_linkbox'] : true, |
| 500 | 'include_media' => isset( $db['include_media'] ) ? $db['include_media'] : true, |
| 501 | 'include_twittercards' => isset( $db['include_twittercards'] ) ? $db['include_twittercards'] : true, |
| 502 | 'include_logo' => isset( $db['include_logo'] ) ? $db['include_logo'] : true, |
| 503 | 'include_twitterlink' => isset( $db['include_twitterlink'] ) ? $db['include_twitterlink'] : true, |
| 504 | 'creditctf' => isset( $db['creditctf'] ) ? $db['creditctf'] : false, |
| 505 | 'showbutton' => isset( $db['showbutton'] ) ? $db['showbutton'] : true, |
| 506 | 'showheader' => isset( $db['showheader'] ) ? $db['showheader'] : true, |
| 507 | 'persistentcache' => isset( $db['persistentcache'] ) ? $db['persistentcache'] : true, |
| 508 | 'selfreplies' => isset( $db['selfreplies'] ) ? $db['selfreplies'] : true, |
| 509 | 'autores' => isset( $db['autores'] ) ? $db['autores'] : true, |
| 510 | 'disableintents' => isset( $db['disableintents'] ) ? $db['disableintents'] : false, |
| 511 | 'customtemplates' => isset( $db['customtemplates'] ) ? $db['customtemplates'] : false, |
| 512 | 'shorturls' => isset( $db['shorturls'] ) ? $db['shorturls'] : false, |
| 513 | 'curlcards' => isset( $db['curlcards'] ) ? $db['curlcards'] : true, |
| 514 | 'sslonly' => isset( $db['sslonly'] ) ? $db['sslonly'] : false, |
| 515 | 'disablelightbox' => isset( $db['disablelightbox'] ) ? $db['disablelightbox'] : false, |
| 516 | 'masonry' => isset( $db['masonry'] ) ? $db['masonry'] : false, |
| 517 | 'carousel' => isset( $db['carousel'] ) ? $db['carousel'] : false, |
| 518 | 'carouselnavarrows' => isset( $db['carouselnavarrows'] ) ? $db['carouselnavarrows'] : true, |
| 519 | 'carouselpag' => isset( $db['carouselpag'] ) ? $db['carouselpag'] : false, |
| 520 | 'carouselautoplay' => isset( $db['carouselautoplay'] ) ? $db['carouselautoplay'] : false, |
| 521 | 'autoscroll' => isset( $db['autoscroll'] ) ? $db['autoscroll'] : true, |
| 522 | 'width' => isset( $db['width'] ) ? $db['width'] : '100', |
| 523 | 'width_unit' => isset( $db['width_unit'] ) ? $db['width_unit'] : '%', |
| 524 | 'height' => isset( $db['height'] ) ? $db['height'] : '', |
| 525 | 'height_unit' => isset( $db['height_unit'] ) ? $db['height_unit'] : '%', |
| 526 | 'class' => isset( $db['class'] ) ? $db['class'] : '', |
| 527 | 'layout' => isset( $db['layout'] ) ? $db['layout'] : 'list', |
| 528 | 'masonrycols' => isset( $db['masonrycols'] ) ? $db['masonrycols'] : '3', |
| 529 | 'masonrytabletcols' => isset( $db['masonrytabletcols'] ) ? $db['masonrytabletcols'] : '2', |
| 530 | 'masonrymobilecols' => isset( $db['masonrymobilecols'] ) ? $db['masonrymobilecols'] : '1', |
| 531 | 'carouselrows' => isset( $db['carouselrows'] ) ? $db['carouselrows'] : '1', |
| 532 | 'carouselcols' => isset( $db['carouselcols'] ) ? $db['carouselcols'] : '3', |
| 533 | 'carouseltabletcols' => isset( $db['carouseltabletcols'] ) ? $db['carouseltabletcols'] : '2', |
| 534 | 'carouselmobilecols' => isset( $db['carouselmobilecols'] ) ? $db['carouselmobilecols'] : '1', |
| 535 | 'carouselloop' => isset( $db['carouselloop'] ) ? $db['carouselloop'] : 'rewind', |
| 536 | 'carouselarrows' => isset( $db['carouselarrows'] ) ? $db['carouselarrows'] : 'onhover', |
| 537 | 'carouselheight' => isset( $db['carouselheight'] ) ? $db['carouselheight'] : 'tallest', |
| 538 | 'carouseltime' => isset( $db['carouseltime'] ) ? $db['carouseltime'] : '5000', |
| 539 | 'maxmedia' => isset( $db['maxmedia'] ) ? $db['maxmedia'] : '4', |
| 540 | 'imagecols' => isset( $db['imagecols'] ) ? $db['imagecols'] : 'auto', |
| 541 | 'autoscrolldistance' => isset( $db['autoscrolldistance'] ) ? $db['autoscrolldistance'] : '200', |
| 542 | 'includewords' => isset( $db['includewords'] ) ? $db['includewords'] : '', |
| 543 | 'excludewords' => isset( $db['excludewords'] ) ? $db['excludewords'] : '', |
| 544 | 'includeanyall' => isset( $db['includeanyall'] ) ? $db['includeanyall'] : 'any', |
| 545 | 'filterandor' => isset( $db['filterandor'] ) ? $db['filterandor'] : 'and', |
| 546 | 'excludeanyall' => isset( $db['excludeanyall'] ) ? $db['excludeanyall'] : 'any', |
| 547 | 'remove_by_id' => isset( $db['remove_by_id'] ) ? $db['remove_by_id'] : '', |
| 548 | 'custom_css' => isset( $db['custom_css'] ) ? $db['custom_css'] : '', |
| 549 | 'custom_js' => isset( $db['custom_js'] ) ? $db['custom_js'] : '', |
| 550 | 'request_method' => isset( $db['request_method'] ) ? $db['request_method'] : 'auto', |
| 551 | 'cron_cache_clear' => isset( $db['cron_cache_clear'] ) ? $db['cron_cache_clear'] : 'unset', |
| 552 | 'multiplier' => isset( $db['multiplier'] ) ? $db['multiplier'] : '1.25', |
| 553 | 'font_method' => isset( $db['font_method'] ) ? $db['font_method'] : 'svg', |
| 554 | 'include_media_placeholder' => isset( $db['include_media_placeholder'] ) ? $db['include_media_placeholder'] : true, |
| 555 | 'showbio' => isset( $db['showbio'] ) ? $db['showbio'] : true, |
| 556 | 'disablelinks' => isset( $db['disablelinks'] ) ? $db['disablelinks'] : false, |
| 557 | 'linktexttotwitter' => isset( $db['linktexttotwitter'] ) ? $db['linktexttotwitter'] : false, |
| 558 | 'bgcolor' => isset( $db['bgcolor'] ) ? $db['bgcolor'] : '#', |
| 559 | 'tweetbgcolor' => isset( $db['tweetbgcolor'] ) ? $db['tweetbgcolor'] : '#', |
| 560 | 'headertextcolor' => isset( $db['headertextcolor'] ) ? $db['headertextcolor'] : '#', |
| 561 | 'headertext' => isset( $db['headertext'] ) ? $db['headertext'] : '', |
| 562 | 'headersize' => isset( $db['headersize'] ) ? $db['headersize'] : 'small', |
| 563 | 'headerstyle' => isset( $db['headerstyle'] ) ? $db['headerstyle'] : 'standard', |
| 564 | 'headerbgcolor' => isset( $db['headerbgcolor'] ) ? $db['headerbgcolor'] : '#', |
| 565 | 'customheadertextcolor' => isset( $db['customheadertextcolor'] ) ? $db['customheadertextcolor'] : '#', |
| 566 | 'customheadertext' => isset( $db['customheadertext'] ) ? $db['customheadertext'] : $customHeaderTextDefault, |
| 567 | 'customheadersize' => isset( $db['customheadersize'] ) ? $db['customheadersize'] : 'small', |
| 568 | 'timezone' => isset( $db['timezone'] ) ? $db['timezone'] : 'default', |
| 569 | 'dateformat' => isset( $db['dateformat'] ) ? $db['dateformat'] : '1', |
| 570 | 'datecustom' => isset( $db['datecustom'] ) ? $db['datecustom'] : '', |
| 571 | 'mtime' => isset( $db['mtime'] ) ? $db['mtime'] : 'm', |
| 572 | 'htime' => isset( $db['htime'] ) ? $db['htime'] : 'h', |
| 573 | 'nowtime' => isset( $db['nowtime'] ) ? $db['nowtime'] : 'now', |
| 574 | 'datetextsize' => isset( $db['datetextsize'] ) ? $db['datetextsize'] : 'inherit', |
| 575 | 'datetextweight' => isset( $db['datetextweight'] ) ? $db['datetextweight'] : 'inherit', |
| 576 | 'datetextcolor' => isset( $db['datetextcolor'] ) ? $db['datetextcolor'] : '#', |
| 577 | 'authortextcolor' => isset( $db['authortextcolor'] ) ? $db['authortextcolor'] : '#', |
| 578 | 'authortextsize' => isset( $db['authortextsize'] ) ? $db['authortextsize'] : 'inherit', |
| 579 | 'authortextweight' => isset( $db['authortextweight'] ) ? $db['authortextweight'] : 'inherit', |
| 580 | 'logosize' => isset( $db['logosize'] ) ? $db['logosize'] : 'inherit', |
| 581 | 'logocolor' => isset( $db['logocolor'] ) ? $db['logocolor'] : '#', |
| 582 | 'tweettextsize' => isset( $db['tweettextsize'] ) ? $db['tweettextsize'] : 'inherit', |
| 583 | 'tweettextweight' => isset( $db['tweettextweight'] ) ? $db['tweettextweight'] : 'inherit', |
| 584 | 'textcolor' => isset( $db['textcolor'] ) ? $db['textcolor'] : '#', |
| 585 | 'textlength' => isset( $db['textlength'] ) ? $db['textlength'] : '280', |
| 586 | 'retweetedtext' => isset( $db['retweetedtext'] ) ? $db['retweetedtext'] : __( 'Retweeted', 'custom-twitter-feeds' ), |
| 587 | 'linktextcolor' => isset( $db['linktextcolor'] ) ? $db['linktextcolor'] : '#', |
| 588 | 'quotedauthorsize' => isset( $db['quotedauthorsize'] ) ? $db['quotedauthorsize'] : 'inherit', |
| 589 | 'quotedauthorweight' => isset( $db['quotedauthorweight'] ) ? $db['quotedauthorweight'] : 'inherit', |
| 590 | 'iconsize' => isset( $db['iconsize'] ) ? $db['iconsize'] : 'inherit', |
| 591 | 'iconcolor' => isset( $db['iconcolor'] ) ? $db['iconcolor'] : '#', |
| 592 | 'viewtwitterlink' => isset( $db['viewtwitterlink'] ) ? $db['viewtwitterlink'] : true, |
| 593 | 'twitterlinktext' => isset( $db['twitterlinktext'] ) ? $db['twitterlinktext'] : 'Twitter', |
| 594 | 'buttoncolor' => isset( $db['buttoncolor'] ) ? $db['buttoncolor'] : '#', |
| 595 | 'buttonhovercolor' => isset( $db['buttonhovercolor'] ) ? $db['buttonhovercolor'] : '#', |
| 596 | 'buttontextcolor' => isset( $db['buttontextcolor'] ) ? $db['buttontextcolor'] : '#', |
| 597 | 'buttontext' => isset( $db['buttontext'] ) ? $db['buttontext'] : __( 'Load More', 'custom-twitter-feeds' ), |
| 598 | 'inreplytotext' => isset( $db['inreplytotext'] ) ? $db['inreplytotext'] : __( 'In Reply To', 'custom-twitter-feeds' ), |
| 599 | 'feedtemplate' => isset( $db['feedtemplate'] ) ? $db['feedtemplate'] : 'default', |
| 600 | 'cardstextsize' => isset( $db['cardstextsize'] ) ? $db['cardstextsize'] : 'inherit', |
| 601 | 'cardstextcolor' => isset( $db['cardstextcolor'] ) ? $db['cardstextcolor'] : '#', |
| 602 | 'colorpalette' => isset( $db['colorpalette'] ) ? $db['colorpalette'] : 'inherit', |
| 603 | 'custombgcolor' => isset( $db['custombgcolor'] ) ? $db['custombgcolor'] : '', |
| 604 | 'customaccentcolor' => isset( $db['customaccentcolor'] ) ? $db['customaccentcolor'] : '', |
| 605 | 'customtextcolor1' => isset( $db['customtextcolor1'] ) ? $db['customtextcolor1'] : '', |
| 606 | 'customtextcolor2' => isset( $db['customtextcolor2'] ) ? $db['customtextcolor2'] : '', |
| 607 | 'customlinkcolor' => isset( $db['customlinkcolor'] ) ? $db['customlinkcolor'] : '', |
| 608 | 'tweetpoststyle' => isset( $db['tweetpoststyle'] ) ? $db['tweetpoststyle'] : 'regular', |
| 609 | 'tweetbgcolor' => isset( $db['tweetbgcolor'] ) ? $db['tweetbgcolor'] : '#', |
| 610 | 'tweetcorners' => isset( $db['tweetcorners'] ) ? $db['tweetcorners'] : '0', |
| 611 | 'tweetboxshadow' => isset( $db['tweetboxshadow'] ) ? $db['tweetboxshadow'] : false, |
| 612 | 'tweetsepcolor' => isset( $db['tweetsepcolor'] ) ? $db['tweetsepcolor'] : '#ddd', |
| 613 | 'tweetsepsize' => isset( $db['tweetsepsize'] ) ? $db['tweetsepsize'] : '1', |
| 614 | 'tweetsepline' => isset( $db['tweetsepline'] ) ? $db['tweetsepline'] : true |
| 615 | ); |
| 616 | |
| 617 | return array_keys( $public ); |
| 618 | } |
| 619 | } |
| 620 |