Admin
4 years ago
Builder
4 years ago
Helpers
5 years ago
CFF_Autolink.php
5 years ago
CFF_Blocks.php
4 years ago
CFF_Cache.php
4 years ago
CFF_Education.php
5 years ago
CFF_Elementor_Base.php
4 years ago
CFF_Elementor_Widget.php
4 years ago
CFF_Error_Reporter.php
4 years ago
CFF_FB_Settings.php
4 years ago
CFF_Feed_Elementor_Control.php
4 years ago
CFF_Feed_Locator.php
4 years ago
CFF_Feed_Pro.php
4 years ago
CFF_GDPR_Integrations.php
4 years ago
CFF_Group_Posts.php
5 years ago
CFF_HTTP_Request.php
4 years ago
CFF_Oembed.php
5 years ago
CFF_Parse.php
4 years ago
CFF_Resizer.php
4 years ago
CFF_Response.php
4 years ago
CFF_Shortcode.php
4 years ago
CFF_Shortcode_Display.php
4 years ago
CFF_SiteHealth.php
4 years ago
CFF_Utils.php
4 years ago
CFF_View.php
4 years ago
Custom_Facebook_Feed.php
4 years ago
CFF_Shortcode.php
2255 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Custom Facebook Feed Main Shortcode Class |
| 4 | * |
| 5 | * @since 2.19 |
| 6 | */ |
| 7 | |
| 8 | namespace CustomFacebookFeed; |
| 9 | |
| 10 | use CustomFacebookFeed\Builder\CFF_Source; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | die( '-1' ); |
| 14 | } |
| 15 | |
| 16 | class CFF_Shortcode extends CFF_Shortcode_Display{ |
| 17 | |
| 18 | /** |
| 19 | * @var Class |
| 20 | */ |
| 21 | protected $fb_feed_settings; |
| 22 | |
| 23 | /** |
| 24 | * @var array |
| 25 | */ |
| 26 | protected $atts; |
| 27 | |
| 28 | /** |
| 29 | * @var array |
| 30 | */ |
| 31 | protected $options; |
| 32 | |
| 33 | /** |
| 34 | * @var id |
| 35 | */ |
| 36 | protected $page_id; |
| 37 | |
| 38 | /** |
| 39 | * @var string |
| 40 | */ |
| 41 | protected $access_token; |
| 42 | |
| 43 | /** |
| 44 | * @var string |
| 45 | */ |
| 46 | protected $feed_id; |
| 47 | |
| 48 | |
| 49 | /** |
| 50 | * Shortcode constructor |
| 51 | * |
| 52 | * @since 2.19 |
| 53 | */ |
| 54 | public function __construct(){ |
| 55 | $this->init(); |
| 56 | } |
| 57 | |
| 58 | |
| 59 | |
| 60 | /** |
| 61 | * Init. |
| 62 | * |
| 63 | * @since 2.19 |
| 64 | */ |
| 65 | public function init(){ |
| 66 | add_shortcode('custom-facebook-feed', array($this, 'display_cff')); |
| 67 | } |
| 68 | |
| 69 | |
| 70 | /** |
| 71 | * Get JSON data |
| 72 | * |
| 73 | * Returns a list of posts JSON form the FaceBook API API |
| 74 | * |
| 75 | * @since 2.19 |
| 76 | * @return JSON OBJECT |
| 77 | */ |
| 78 | public function get_feed_json( $graph_query, $cff_post_limit, $cff_locale, $cff_show_access_token, $cache_seconds, $cff_cache_time, $show_posts_by, $data_att_html ){ |
| 79 | //Is it SSL? |
| 80 | $cff_ssl = is_ssl() ? '&return_ssl_resources=true' : ''; |
| 81 | $attachments_desc = ( $this->atts['salesposts'] == 'true' ) ? '' : ',description'; |
| 82 | $story_tags = ( $this->atts['storytags'] == 'true' ) ? '' : ',story_tags'; |
| 83 | |
| 84 | $cff_posts_json_url = 'https://graph.facebook.com/v4.0/' . $this->page_id . '/' . $graph_query . '?fields=id,updated_time,from{picture,id,name,link},message,message_tags,story'. $story_tags .',status_type,created_time,backdated_time,call_to_action,attachments{title'. $attachments_desc . ',media_type,unshimmed_url,target{id},media{source}}&access_token=' . $this->access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl; |
| 85 | //Create the transient name |
| 86 | //Split the Page ID in half and stick it together so we definitely have the beginning and end of it |
| 87 | $trans_page_id = substr($this->page_id, 0, 16) . substr($this->page_id, -15); |
| 88 | $transient_name = 'cff_' . substr($graph_query, 0, 1) . '_' . $trans_page_id . substr($cff_post_limit, 0, 3) . substr($show_posts_by, 0, 2) . substr($cff_locale, 0, 2); |
| 89 | //Limit to 45 chars max |
| 90 | $transient_name = substr($transient_name, 0, 45); |
| 91 | |
| 92 | $posts_json = CFF_Utils::cff_get_set_cache( $cff_posts_json_url, $transient_name, $cff_cache_time, $cache_seconds, $data_att_html, false, $this->access_token, true ); |
| 93 | |
| 94 | return json_decode($posts_json); |
| 95 | } |
| 96 | |
| 97 | |
| 98 | /** |
| 99 | * Get Graph Query & (Show only by others) |
| 100 | * |
| 101 | * Getting the FaceBook Graph Query depending on the settings |
| 102 | * |
| 103 | * @since 2.19 |
| 104 | * @return array |
| 105 | */ |
| 106 | public function get_graph_query($show_posts_by, $cff_is_group){ |
| 107 | //Use posts? or feed? |
| 108 | $old_others_option = get_option('cff_show_others'); //Use this to help depreciate the old option |
| 109 | $show_others = $this->atts['others']; |
| 110 | $graph_query = 'posts'; |
| 111 | $cff_show_only_others = false; |
| 112 | //If 'others' shortcode option is used then it overrides any other option |
| 113 | if ($show_others || $old_others_option == 'on') { |
| 114 | //Show posts by everyone |
| 115 | if ( $old_others_option == 'on' || $show_others == 'on' || $show_others == 'true' || $show_others == true || $cff_is_group ) $graph_query = 'feed'; |
| 116 | //Only show posts by me |
| 117 | if ( $show_others == 'false' ) $graph_query = 'posts'; |
| 118 | } else { |
| 119 | //Else use the settings page option or the 'showpostsby' shortcode option |
| 120 | //Only show posts by me |
| 121 | if ( $show_posts_by == 'me' ) $graph_query = 'posts'; |
| 122 | //Show posts by everyone |
| 123 | if ( $show_posts_by == 'others' || $cff_is_group ) $graph_query = 'feed'; |
| 124 | //Show posts ONLY by others |
| 125 | if ( $show_posts_by == 'onlyothers' && !$cff_is_group ) { |
| 126 | $graph_query = 'visitor_posts'; |
| 127 | $cff_show_only_others = true; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return [ |
| 132 | 'graph_query' => $graph_query, |
| 133 | 'cff_show_only_others' => $cff_show_only_others |
| 134 | ]; |
| 135 | |
| 136 | } |
| 137 | |
| 138 | |
| 139 | /** |
| 140 | * Get Posts Limit |
| 141 | * |
| 142 | * Getting the FaceBook Graph Query depending on the settings |
| 143 | * |
| 144 | * @since 2.19 |
| 145 | * @return int |
| 146 | */ |
| 147 | public function get_post_limit($show_posts){ |
| 148 | $cff_post_limit = $this->atts['limit']; |
| 149 | if ( isset($cff_post_limit) && $cff_post_limit !== '' ) { |
| 150 | $cff_post_limit = $cff_post_limit; |
| 151 | } else { |
| 152 | if( intval($show_posts) >= 50 ) $cff_post_limit = intval(intval($show_posts) + 7); |
| 153 | if( intval($show_posts) < 50 ) $cff_post_limit = intval(intval($show_posts) + 5); |
| 154 | if( intval($show_posts) < 25 ) $cff_post_limit = intval(intval($show_posts) + 4); |
| 155 | if( intval($show_posts) < 10 ) $cff_post_limit = intval(intval($show_posts) + 3); |
| 156 | if( intval($show_posts) < 6 ) $cff_post_limit = intval(intval($show_posts) + 2); |
| 157 | if( intval($show_posts) < 2 ) $cff_post_limit = intval(intval($show_posts) + 1); |
| 158 | } |
| 159 | if( $cff_post_limit >= 100 ) $cff_post_limit = 100; |
| 160 | return $cff_post_limit; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | function cff_get_shortcode_data_attribute_html( $feed_options ) { |
| 165 | |
| 166 | //If an access token is set in the shortcode then set "use own access token" to be enabled |
| 167 | if( isset($feed_options['accesstoken']) ){ |
| 168 | //Add an encryption string to protect token |
| 169 | if ( strpos($feed_options['accesstoken'], ',') !== false ) { |
| 170 | //If there are multiple tokens then just add the string after the colon to avoid having to de/reconstruct the array |
| 171 | $feed_options['accesstoken'] = str_replace(":", ":02Sb981f26534g75h091287a46p5l63", $feed_options['accesstoken']); |
| 172 | } else { |
| 173 | //Add an encryption string to protect token |
| 174 | $feed_options['accesstoken'] = substr_replace($feed_options['accesstoken'], '02Sb981f26534g75h091287a46p5l63', 25, 0); |
| 175 | } |
| 176 | $feed_options['ownaccesstoken'] = 'on'; |
| 177 | } |
| 178 | |
| 179 | if( !empty($feed_options) ){ |
| 180 | $json_data = '{'; |
| 181 | $i = 0; |
| 182 | $len = count($feed_options); |
| 183 | foreach( $feed_options as $key => $value ) { |
| 184 | if ($i == $len - 1) { |
| 185 | $json_data .= '"'.$key.'": "'.$value.'"'; |
| 186 | } else { |
| 187 | $json_data .= '"'.$key.'": "'.$value.'", '; |
| 188 | } |
| 189 | $i++; |
| 190 | } |
| 191 | $json_data .= '}'; |
| 192 | |
| 193 | return $json_data; |
| 194 | } |
| 195 | |
| 196 | } |
| 197 | |
| 198 | function cff_get_processed_options($feed_options){ |
| 199 | $feed_id = empty( $feed_options['feed'] ) ? 'default' : intval( $feed_options['feed'] ); |
| 200 | $feed_options = $this->get_settings_for_feed( $feed_options ); |
| 201 | |
| 202 | if ( empty( $feed_options ) ) { |
| 203 | $options = get_option('cff_style_settings'); |
| 204 | $fdo = new CFF_FB_Settings($feed_options, $options); |
| 205 | $feed_options = $fdo->get_settings(); |
| 206 | $feed_options['feederror'] = $feed_id; |
| 207 | return $feed_options; |
| 208 | } |
| 209 | |
| 210 | $page_id = $feed_options['id']; |
| 211 | $cff_facebook_string = 'facebook.com'; |
| 212 | ( stripos($page_id, $cff_facebook_string) !== false) ? $cff_page_id_url_check = true : $cff_page_id_url_check = false; |
| 213 | if ( $cff_page_id_url_check === true ) { |
| 214 | //Remove trailing slash if exists |
| 215 | $page_id = preg_replace('{/$}', '', $page_id); |
| 216 | //Get last part of url |
| 217 | $page_id = substr( $page_id, strrpos( $page_id, '/' )+1 ); |
| 218 | } |
| 219 | //If the Page ID contains a query string at the end then remove it |
| 220 | if ( stripos( $page_id, '?') !== false ) $page_id = substr($page_id, 0, strrpos($page_id, '?')); |
| 221 | |
| 222 | //Always remove slash from end of Page ID |
| 223 | $page_id = preg_replace('{/$}', '', $page_id); |
| 224 | |
| 225 | //Update the page ID in the feed options array for use everywhere |
| 226 | $feed_options['id'] = $page_id; |
| 227 | |
| 228 | |
| 229 | //If an 'account' is specified then use that instead of the Page ID/token from the settings |
| 230 | $cff_account = trim($feed_options['account']); |
| 231 | |
| 232 | if( !empty( $cff_account ) ){ |
| 233 | $cff_connected_accounts = get_option('cff_connected_accounts'); |
| 234 | if( !empty($cff_connected_accounts) ){ |
| 235 | |
| 236 | //Replace both single and double quotes before decoding |
| 237 | $cff_connected_accounts = str_replace('\"','"', $cff_connected_accounts); |
| 238 | $cff_connected_accounts = str_replace("\'","'", $cff_connected_accounts); |
| 239 | |
| 240 | $cff_connected_accounts = json_decode( $cff_connected_accounts ); |
| 241 | |
| 242 | if ( isset( $cff_account ) && is_object( $cff_connected_accounts ) ) { |
| 243 | //Grab the ID and token from the connected accounts setting |
| 244 | if( isset( $cff_connected_accounts->{ $cff_account } ) ){ |
| 245 | $feed_options['id'] = $cff_connected_accounts->{ $cff_account }->{'id'}; |
| 246 | $feed_options['accesstoken'] = $cff_connected_accounts->{ $cff_account }->{'accesstoken'}; |
| 247 | } |
| 248 | |
| 249 | } |
| 250 | |
| 251 | //Replace the encryption string in the Access Token |
| 252 | if (strpos($feed_options['accesstoken'], '02Sb981f26534g75h091287a46p5l63') !== false) { |
| 253 | $feed_options['accesstoken'] = str_replace("02Sb981f26534g75h091287a46p5l63","",$feed_options['accesstoken']); |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | //Replace the encryption string in the Access Token |
| 259 | if (strpos($feed_options['accesstoken'], '02Sb981f26534g75h091287a46p5l63') !== false) { |
| 260 | $feed_options['accesstoken'] = str_replace("02Sb981f26534g75h091287a46p5l63","",$feed_options['accesstoken']); |
| 261 | } |
| 262 | $cff_connected_accounts = get_option('cff_connected_accounts'); |
| 263 | if(!empty($cff_connected_accounts)){ |
| 264 | $connected_accounts = (array)json_decode(stripcslashes($cff_connected_accounts)); |
| 265 | if(array_key_exists($feed_options['id'], $connected_accounts)){ |
| 266 | $feed_options['pagetype'] = $connected_accounts[$feed_options['id']]->pagetype; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | if ( ! empty( $feed_options['feedlayout'] ) ) { |
| 271 | if ( $feed_options['feedlayout'] === 'list' ) { |
| 272 | $feed_options['cols'] = 1; |
| 273 | $feed_options['colsmobile'] = 1; |
| 274 | $feed_options['colstablet'] = 1; |
| 275 | $feed_options['masonrycols'] = 1; |
| 276 | $feed_options['masonrycolsmobile'] = 1; |
| 277 | } elseif ( $feed_options['feedlayout'] === 'masonry' ) { |
| 278 | $feed_options['masonrycols'] = $feed_options['cols'] ; |
| 279 | $feed_options['masonrycolsmobile'] = $feed_options['colsmobile']; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | return $feed_options; |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Display. |
| 288 | * The main Shortcode display |
| 289 | * |
| 290 | * @since 2.19 |
| 291 | */ |
| 292 | public function display_cff($atts) { |
| 293 | $this->options = get_option('cff_style_settings'); |
| 294 | $data_att_html = $this->cff_get_shortcode_data_attribute_html( $atts ); |
| 295 | $feed_id = empty( $atts['feed'] ) ? 'default' : intval( $atts['feed'] ); |
| 296 | $feed_options = $this->get_settings_for_feed( $atts ); |
| 297 | |
| 298 | if ( empty( $feed_options ) ) { |
| 299 | $this->fb_feed_settings = new CFF_FB_Settings($atts, $this->options); |
| 300 | $this->atts = $this->fb_feed_settings->get_settings(); |
| 301 | $id_and_token = $this->fb_feed_settings->get_id_and_token(); |
| 302 | $this->page_id = $id_and_token['id']; |
| 303 | $this->access_token = $id_and_token['token']; |
| 304 | $this->atts = $this->cff_get_processed_options( $this->atts ); |
| 305 | |
| 306 | } else { |
| 307 | if ( ! empty( $feed_options['feedlayout'] ) ) { |
| 308 | if ( $feed_options['feedlayout'] === 'list' ) { |
| 309 | $feed_options['cols'] = 1; |
| 310 | $feed_options['colsmobile'] = 1; |
| 311 | $feed_options['colstablet'] = 1; |
| 312 | $feed_options['masonrycols'] = 1; |
| 313 | $feed_options['masonrycolsmobile'] = 1; |
| 314 | } elseif ( $feed_options['feedlayout'] === 'masonry' ) { |
| 315 | $feed_options['masonrycols'] = $feed_options['cols'] ; |
| 316 | $feed_options['masonrycolsmobile'] = $feed_options['colsmobile']; |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | |
| 321 | $this->atts = $feed_options; |
| 322 | } |
| 323 | |
| 324 | $this->cff_add_translations(); |
| 325 | #var_dump($this->atts); |
| 326 | |
| 327 | //Vars for the templates |
| 328 | $atts = $this->atts; |
| 329 | $options = $this->options; |
| 330 | $access_token = $this->access_token; |
| 331 | $page_id = $this->page_id; |
| 332 | |
| 333 | if ( $atts['cff_enqueue_with_shortcode'] === 'on' || $atts['cff_enqueue_with_shortcode'] === 'true' ) { |
| 334 | wp_enqueue_style( 'cff' ); |
| 335 | wp_enqueue_script( 'cffscripts' ); |
| 336 | } |
| 337 | |
| 338 | $palette = ''; |
| 339 | $custom_palette_class = ''; |
| 340 | $doing_custom_styles = false; |
| 341 | |
| 342 | if ( ! empty( $this->atts['colorpalette'] ) ) { |
| 343 | switch ( $this->atts['colorpalette'] ) { |
| 344 | case 'dark' : |
| 345 | $palette = 'cff-dark '; |
| 346 | break; |
| 347 | case 'light' : |
| 348 | $palette = 'cff-light '; |
| 349 | break; |
| 350 | case 'custom' : |
| 351 | $doing_custom_styles = true; |
| 352 | $custom_palette_class = 'cff-palette-' . $feed_id . ' '; |
| 353 | break; |
| 354 | default: |
| 355 | $palette = ''; |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | $this->atts['paletteclass'] = $palette . $custom_palette_class; |
| 360 | |
| 361 | /********** GENERAL **********/ |
| 362 | $cff_page_type = $this->atts[ 'pagetype' ]; |
| 363 | ($cff_page_type == 'group') ? $cff_is_group = true : $cff_is_group = false; |
| 364 | |
| 365 | |
| 366 | $cff_show_author = $this->atts[ 'showauthornew' ]; |
| 367 | $cff_cache_time = $this->atts[ 'cachetime' ]; |
| 368 | $cff_locale = $this->atts[ 'locale' ]; |
| 369 | if( empty($cff_locale) || !isset($cff_locale) || $cff_locale == '' ) $cff_locale = 'en_US'; |
| 370 | if(!isset($cff_cache_time) || $cff_cache_time == '' ) $cff_cache_time = 0; |
| 371 | $cff_cache_time_unit = $this->atts[ 'cacheunit' ]; |
| 372 | |
| 373 | $like_box = CFF_Utils::print_template_part( 'likebox', get_defined_vars()); |
| 374 | |
| 375 | |
| 376 | if($cff_cache_time == 'nocaching') $cff_cache_time = 0; |
| 377 | |
| 378 | //Like box |
| 379 | $cff_like_box_position = $this->atts[ 'likeboxpos' ]; |
| 380 | $cff_like_box_outside = CFF_Utils::check_if_on($this->atts[ 'likeboxoutside' ]); |
| 381 | //Open links in new window? |
| 382 | $target = 'target="_blank"'; |
| 383 | /********** LAYOUT **********/ |
| 384 | $cff_show_author = $this->check_show_section( 'author' ); |
| 385 | $cff_show_text = $this->check_show_section( 'text' ); |
| 386 | $cff_show_desc = $this->check_show_section( 'desc' ); |
| 387 | $cff_show_shared_links = $this->check_show_section( 'sharedlink' ); |
| 388 | $cff_show_date = $this->check_show_section( 'date' ); |
| 389 | $cff_show_media = $this->check_show_section( 'media' ); |
| 390 | $cff_show_media_link = $this->check_show_section( 'medialink' ); |
| 391 | $cff_show_event_title = $this->check_show_section( 'eventtitle' ); |
| 392 | $cff_show_event_details = $this->check_show_section( 'eventdetail' ); |
| 393 | $cff_show_meta = $this->check_show_section( 'social' ); |
| 394 | $cff_show_link = $this->check_show_section( ',link' ); |
| 395 | $cff_show_like_box = isset( $this->atts['showlikebox'] ) ? CFF_Utils::check_if_on( $this->atts['showlikebox'] ) : false; |
| 396 | |
| 397 | //Set free version to thumb layout by default as layout option not available on settings page |
| 398 | $cff_preset_layout = 'thumb'; |
| 399 | |
| 400 | //If the old shortcode option 'showauthor' is being used then apply it |
| 401 | $cff_show_author_old = $this->atts[ 'showauthor' ]; |
| 402 | if( $cff_show_author_old == 'false' ) $cff_show_author = false; |
| 403 | if( $cff_show_author_old == 'true' ) $cff_show_author = true; |
| 404 | |
| 405 | //See Less text |
| 406 | $cff_posttext_link_color = str_replace('#', '', $this->atts['textlinkcolor']); |
| 407 | $cff_title_link = CFF_Utils::check_if_on( $this->atts['textlink'] ); |
| 408 | |
| 409 | //Description Style |
| 410 | $cff_body_styles = $this->get_style_attribute( 'body_description' ); |
| 411 | |
| 412 | //Shared link box |
| 413 | $cff_disable_link_box = CFF_Utils::check_if_on( $this->atts['disablelinkbox'] ); |
| 414 | |
| 415 | $cff_link_box_styles = $cff_disable_link_box ? '' : $this->get_style_attribute( 'link_box' ); |
| 416 | |
| 417 | //Date |
| 418 | $cff_date_position = ( !isset( $this->atts[ 'datepos' ] ) ) ? 'below' : $this->atts[ 'datepos' ]; |
| 419 | |
| 420 | |
| 421 | //Show Facebook link |
| 422 | $cff_link_to_timeline = $this->atts[ 'linktotimeline' ]; |
| 423 | |
| 424 | //Post Style settings |
| 425 | $cff_post_style = $this->atts['poststyle']; |
| 426 | $cff_post_bg_color_check = ($this->atts['postbgcolor'] !== '' && $this->atts['postbgcolor'] !== '#' && $cff_post_style != 'regular' ) ? true : false; |
| 427 | $cff_box_shadow = CFF_Utils::check_if_on( $this->atts['boxshadow'] ) && $cff_post_style == 'boxed'; |
| 428 | |
| 429 | //Text limits |
| 430 | $body_limit = $this->atts['desclength']; |
| 431 | |
| 432 | //Get show posts attribute. If not set then default to 25 |
| 433 | $show_posts = ( empty( $this->atts['num'] ) || $this->atts['num'] == 'undefined' ) ? 25 : $this->atts['num']; |
| 434 | $show_posts_number = isset( $this->atts['minnum'] ) ? $this->atts['minnum'] : $this->atts['num']; |
| 435 | |
| 436 | //If the 'Enter my own Access Token' box is unchecked then don't use the user's access token, even if there's one in the field |
| 437 | get_option('cff_show_access_token') ? $cff_show_access_token = true : $cff_show_access_token = false; |
| 438 | |
| 439 | //Check whether a Page ID has been defined |
| 440 | if ($this->page_id == '') { |
| 441 | if ( $this->using_legacy_feed( $feed_options ) ) { |
| 442 | echo "Please enter the Page ID of the Facebook feed you'd like to display. You can do this in either the Custom Facebook Feed plugin settings or in the shortcode itself. For example, [custom-facebook-feed id=YOUR_PAGE_ID_HERE].<br /><br />"; |
| 443 | } |
| 444 | return false; |
| 445 | } |
| 446 | |
| 447 | //Is it a restricted page? |
| 448 | $cff_restricted_page = CFF_Utils::check_if_on( $this->atts['restrictedpage'] ); |
| 449 | |
| 450 | $show_posts_by = $this->atts['showpostsby']; |
| 451 | $graph_info = $this->get_graph_query($show_posts_by, $cff_is_group); |
| 452 | $graph_query = $graph_info['graph_query']; |
| 453 | $cff_show_only_others = $graph_info['cff_show_only_others']; |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | // If Mobile and Desktop post nums are not the same, use minnum for API requests. |
| 459 | $mobile_num = isset( $this->atts['nummobile'] ) && (int)$this->atts['nummobile'] > 0 ? (int)$this->atts['nummobile'] : 0; |
| 460 | $desk_num = $show_posts; |
| 461 | if ( $desk_num < $mobile_num ) { |
| 462 | $this->atts['minnum'] = $mobile_num; |
| 463 | } |
| 464 | |
| 465 | $show_posts = isset( $this->atts['minnum'] ) ? $this->atts['minnum'] : $show_posts; |
| 466 | $cff_post_limit = $this->get_post_limit($show_posts); |
| 467 | |
| 468 | //If the number of posts is set to zero then don't show any and set limit to one |
| 469 | if ( ($show_posts == '0' || $show_posts == 0) && $show_posts !== ''){ |
| 470 | $show_posts = 0; |
| 471 | $cff_post_limit = 1; |
| 472 | } |
| 473 | |
| 474 | |
| 475 | //Calculate the cache time in seconds |
| 476 | if($cff_cache_time_unit == 'minutes') $cff_cache_time_unit = 60; |
| 477 | if($cff_cache_time_unit == 'hours') $cff_cache_time_unit = 60*60; |
| 478 | if($cff_cache_time_unit == 'days') $cff_cache_time_unit = 60*60*24; |
| 479 | $cache_seconds = $cff_cache_time * $cff_cache_time_unit; |
| 480 | |
| 481 | |
| 482 | |
| 483 | |
| 484 | |
| 485 | //Misc Settings |
| 486 | $cff_nofollow = CFF_Utils::check_if_on( $this->atts['nofollow'] ); |
| 487 | ( $cff_nofollow ) ? $cff_nofollow = ' rel="nofollow noopener"' : $cff_nofollow = ''; |
| 488 | $cff_nofollow_referrer = ' rel="nofollow noopener noreferrer"'; |
| 489 | |
| 490 | //If the number of posts is set to zero then don't show any and set limit to one |
| 491 | if ( ($this->atts['num'] == '0' || $this->atts['num'] == 0) && $this->atts['num'] !== ''){ |
| 492 | $show_posts = 0; |
| 493 | $cff_post_limit = 1; |
| 494 | } |
| 495 | |
| 496 | //***START FEED*** |
| 497 | #$defined_vars = get_defined_vars(); |
| 498 | $cff_content = ''; |
| 499 | |
| 500 | //Create CFF container HTML |
| 501 | $cff_content .= '<div class="cff-wrapper">'; |
| 502 | $cff_style_class = $this->feed_style_class_compiler(); |
| 503 | $cff_insider_style = $this->get_style_attribute( 'feed_wrapper_insider' ); |
| 504 | $cff_feed_height = CFF_Utils::get_css_distance( $this->atts[ 'height' ] ) ; |
| 505 | //Feed header |
| 506 | $cff_show_header = CFF_Utils::check_if_on( $this->atts['showheader'] ); |
| 507 | $cff_header_outside = CFF_Utils::check_if_on( $this->atts['headeroutside'] ); |
| 508 | $cff_header_type = strtolower( $this->atts['headertype'] ); |
| 509 | $cff_header = CFF_Utils::print_template_part( 'header', get_defined_vars(), $this); |
| 510 | |
| 511 | //Add the page header to the outside of the top of feed |
| 512 | if ($cff_show_header && $cff_header_outside) $cff_content .= $cff_header; |
| 513 | |
| 514 | //Add like box to the outside of the top of feed |
| 515 | if ($cff_like_box_position == 'top' && $cff_show_like_box && $cff_like_box_outside) $cff_content .= $like_box; |
| 516 | |
| 517 | |
| 518 | //Get Custom Class and Compiled CSS |
| 519 | |
| 520 | $custom_wrp_class = !empty($cff_feed_height) ? ' cff-wrapper-fixed-height' : ''; |
| 521 | |
| 522 | $cff_content .= '<div class="cff-wrapper-ctn '.$custom_wrp_class.'" '.$cff_insider_style.'>'; |
| 523 | $cff_content .= '<div id="cff" ' . $cff_style_class['cff_custom_class'] . ' ' . $cff_style_class['cff_feed_styles'] . ' ' . $cff_style_class['cff_feed_attributes'] . '>'; |
| 524 | |
| 525 | //Add the page header to the inside of the top of feed |
| 526 | if ($cff_show_header && !$cff_header_outside) $cff_content .= $cff_header; |
| 527 | |
| 528 | //Add like box to the inside of the top of feed |
| 529 | if ($cff_like_box_position == 'top' && $cff_show_like_box && !$cff_like_box_outside) $cff_content .= $like_box; |
| 530 | //Limit var |
| 531 | $i_post = 0; |
| 532 | |
| 533 | //Define array for post items |
| 534 | $cff_posts_array = array(); |
| 535 | //ALL POSTS |
| 536 | |
| 537 | $FBdata = $this->get_feed_json( $graph_query, $cff_post_limit, $cff_locale, $cff_show_access_token, $cache_seconds, $cff_cache_time, $show_posts_by, $data_att_html ); |
| 538 | if( $cff_is_group ){ |
| 539 | $cff_ssl = is_ssl() ? '&return_ssl_resources=true' : ''; |
| 540 | $attachments_desc = ( $this->atts['salesposts'] == 'true' ) ? '' : ',description'; |
| 541 | $cff_posts_json_url = 'https://graph.facebook.com/v4.0/' . $this->page_id . '/' . $graph_query . '?fields=id,updated_time,from{picture,id,name,link},message,message_tags,story,story_tags,status_type,created_time,backdated_time,call_to_action,attachments{title'. $attachments_desc . ',media_type,unshimmed_url,target{id},media{source}}&access_token=' . $this->access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl; |
| 542 | $this->atts['type'] = 'links_events_videos_photos_albums_statuses_'; |
| 543 | $groups_post = new CFF_Group_Posts($this->page_id, $this->atts, $cff_posts_json_url, $data_att_html, false); |
| 544 | $groups_post_result = $groups_post->init_group_posts(json_encode($FBdata), false, $show_posts_number); |
| 545 | $posts_json = $groups_post_result['posts_json']; |
| 546 | $FBdata = json_decode($posts_json); |
| 547 | } |
| 548 | |
| 549 | |
| 550 | global $current_user; |
| 551 | $user_id = $current_user->ID; |
| 552 | |
| 553 | //Print Pretty Message Error |
| 554 | $cff_content .= CFF_Utils::print_template_part( 'error-message', get_defined_vars()); |
| 555 | |
| 556 | $numeric_page_id = ''; |
| 557 | if( !empty($FBdata->data) ){ |
| 558 | if ( ($cff_show_only_others || $show_posts_by == 'others') && count($FBdata->data) > 0 ) { |
| 559 | //Get the numeric ID of the page so can compare it to the author of each post |
| 560 | $first_post_id = explode("_", $FBdata->data[0]->id); |
| 561 | $numeric_page_id = $first_post_id[0]; |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | $posts_wrap_box_shadow_class = $cff_box_shadow && $this->atts['feedlayout'] === 'list' ? ' cff-posts-wrap-box-shadow' : ''; |
| 566 | $cff_content .= '<div class="cff-posts-wrap'.$posts_wrap_box_shadow_class.'">'; |
| 567 | |
| 568 | //***STARTS POSTS LOOP*** |
| 569 | if( isset($FBdata->data) ){ |
| 570 | if ( ! \cff_main()->cff_error_reporter->are_critical_errors() |
| 571 | && isset( $this->atts['sources'] ) |
| 572 | && is_array( $this->atts['sources'] ) ) { |
| 573 | foreach ( $this->atts['sources'] as $source ) { |
| 574 | if ( ! empty( $source['error'] ) ) { |
| 575 | \CustomFacebookFeed\Builder\CFF_Source::clear_error( $source['account_id'] ); |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | foreach ($FBdata->data as $news ) |
| 580 | { |
| 581 | //Explode News and Page ID's into 2 values |
| 582 | $PostID = ''; |
| 583 | $cff_post_id = ''; |
| 584 | if( isset($news->id) ){ |
| 585 | $cff_post_id = $news->id; |
| 586 | $PostID = explode("_", $cff_post_id); |
| 587 | } |
| 588 | |
| 589 | //Reassign variable changes from API v3.3 update |
| 590 | $news->link = isset($news->attachments->data[0]->unshimmed_url) ? $news->attachments->data[0]->unshimmed_url : ''; |
| 591 | $news->description = isset($news->attachments->data[0]->description) ? $news->attachments->data[0]->description : ''; |
| 592 | $news->object_id = isset($news->attachments->data[0]->target->id) ? $news->attachments->data[0]->target->id : ''; |
| 593 | $news->source = isset($news->attachments->data[0]->media->source) ? $news->attachments->data[0]->media->source : ''; |
| 594 | $news->name = isset($news->attachments->data[0]->title) ? $news->attachments->data[0]->title : ''; |
| 595 | $news->caption = isset($news->attachments->data[0]->title) ? $news->attachments->data[0]->title : ''; |
| 596 | |
| 597 | //Check the post type |
| 598 | $cff_post_type = isset($news->attachments->data[0]->media_type) ? $news->attachments->data[0]->media_type : 'status'; |
| 599 | |
| 600 | if ($cff_post_type == 'link') { |
| 601 | isset($news->story) ? $story = $news->story : $story = ''; |
| 602 | //Check whether it's an event |
| 603 | $event_link_check = "facebook.com/events/"; |
| 604 | if( isset($news->link) ){ |
| 605 | $event_link_check = CFF_Utils::stripos($news->link, $event_link_check); |
| 606 | if ( $event_link_check ) $cff_post_type = 'event'; |
| 607 | } |
| 608 | } |
| 609 | $cff_show_links_type = true; |
| 610 | $cff_show_event_type = true; |
| 611 | $cff_show_video_type = true; |
| 612 | $cff_show_photos_type = true; |
| 613 | $cff_show_status_type = true; |
| 614 | $cff_show_albums_type = true; |
| 615 | $cff_events_only = false; |
| 616 | //Are we showing ONLY events? |
| 617 | if ($cff_show_event_type && !$cff_show_links_type && !$cff_show_video_type && !$cff_show_photos_type && !$cff_show_status_type) $cff_events_only = true; |
| 618 | //Should we show this post or not? |
| 619 | $cff_show_post = false; |
| 620 | switch ($cff_post_type) { |
| 621 | case 'link': |
| 622 | if ( $cff_show_links_type ) $cff_show_post = true; |
| 623 | break; |
| 624 | case 'event': |
| 625 | if ( $cff_show_event_type ) $cff_show_post = true; |
| 626 | break; |
| 627 | case 'video': |
| 628 | if ( $cff_show_video_type ) $cff_show_post = true; |
| 629 | break; |
| 630 | case 'swf': |
| 631 | if ( $cff_show_video_type ) $cff_show_post = true; |
| 632 | break; |
| 633 | case 'photo': |
| 634 | if ( $cff_show_photos_type ) $cff_show_post = true; |
| 635 | break; |
| 636 | case 'offer': |
| 637 | $cff_show_post = true; |
| 638 | break; |
| 639 | default: |
| 640 | //Check whether it's a status (author comment or like) |
| 641 | if ( $cff_show_status_type && !empty($news->message) ) $cff_show_post = true; |
| 642 | break; |
| 643 | } |
| 644 | //Is it a duplicate post? |
| 645 | if (!isset($prev_post_message)) $prev_post_message = ''; |
| 646 | if (!isset($prev_post_link)) $prev_post_link = ''; |
| 647 | if (!isset($prev_post_description)) $prev_post_description = ''; |
| 648 | isset($news->message) ? $pm = $news->message : $pm = ''; |
| 649 | isset($news->link) ? $pl = $news->link : $pl = ''; |
| 650 | isset($news->description) ? $pd = $news->description : $pd = ''; |
| 651 | |
| 652 | if ( ($prev_post_message == $pm) && ($prev_post_link == $pl) && ($prev_post_description == $pd) ) $cff_show_post = false; |
| 653 | |
| 654 | //Offset. If the post index ($i_post) is less than the offset then don't show the post |
| 655 | if( intval($i_post) < intval($this->atts['offset']) ){ |
| 656 | $cff_show_post = false; |
| 657 | $i_post++; |
| 658 | } |
| 659 | |
| 660 | //Check post type and display post if selected |
| 661 | if ( $cff_show_post ) { |
| 662 | //If it isn't then create the post |
| 663 | //Only create posts for the amount of posts specified |
| 664 | if( intval($this->atts['offset']) > 0 ){ |
| 665 | //If offset is being used then stop after showing the number of posts + the offset |
| 666 | if ( $i_post == (intval($show_posts) + intval($this->atts['offset'])) ) break; |
| 667 | } else { |
| 668 | //Else just stop after the number of posts to be displayed is reached |
| 669 | if ( $i_post == $show_posts ) break; |
| 670 | } |
| 671 | $i_post++; |
| 672 | //********************************// |
| 673 | //***COMPILE SECTION VARIABLES***// |
| 674 | //********************************// |
| 675 | //Set the post link |
| 676 | isset($news->link) ? $link = htmlspecialchars($news->link) : $link = ''; |
| 677 | //Is it a shared album? |
| 678 | $shared_album_string = 'shared an album:'; |
| 679 | isset($news->story) ? $story = $news->story : $story = ''; |
| 680 | $shared_album = CFF_Utils::stripos($story, $shared_album_string); |
| 681 | if ( $shared_album ) { |
| 682 | $link = str_replace('photo.php?','media/set/?',$link); |
| 683 | } |
| 684 | //Check the post type |
| 685 | isset($cff_post_type) ? $cff_post_type = $cff_post_type : $cff_post_type = ''; |
| 686 | if ($cff_post_type == 'link') { |
| 687 | isset($news->story) ? $story = $news->story : $story = ''; |
| 688 | //Check whether it's an event |
| 689 | $event_link_check = "facebook.com/events/"; |
| 690 | //Make sure URL doesn't include 'permalink' as that indicates someone else sharing a post from within an event (eg: https://www.facebook.com/events/617323338414282/permalink/617324268414189/) and the event ID is then not retrieved properly from the event URL as it's formatted like so: facebook.com/events/EVENT_ID/permalink/POST_ID |
| 691 | $event_link_check = CFF_Utils::stripos($news->link, $event_link_check); |
| 692 | $event_link_check_2 = CFF_Utils::stripos($news->link, "permalink/"); |
| 693 | if ( $event_link_check && !$event_link_check_2 ) $cff_post_type = 'event'; |
| 694 | } |
| 695 | |
| 696 | //If it's an event then check whether the URL contains facebook.com |
| 697 | if(isset($news->link)){ |
| 698 | if( CFF_Utils::stripos($news->link, "events/") && $cff_post_type == 'event' ){ |
| 699 | //Facebook changed the event link from absolute to relative, and so if the link isn't absolute then add facebook.com to front |
| 700 | ( CFF_Utils::stripos($link, 'facebook.com') ) ? $link = $link : $link = 'https://facebook.com' . $link; |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | //Is it an album? |
| 705 | $cff_album = false; |
| 706 | if( isset($news->status_type) ){ |
| 707 | if( $news->status_type == 'added_photos' ){ |
| 708 | if( isset($news->attachments) ){ |
| 709 | if( $news->attachments->data[0]->media_type == 'album' ) $cff_album = true; |
| 710 | } |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | //If there's no link provided then link to either the Facebook page or the individual status |
| 715 | if (empty($news->link)) { |
| 716 | if ($cff_link_to_timeline == true){ |
| 717 | //Link to page |
| 718 | $link = 'https://facebook.com/' . $this->page_id; |
| 719 | } else { |
| 720 | //Link to status |
| 721 | $link = "https://www.facebook.com/" . $this->page_id . "/posts/" . $PostID[1]; |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | $cff_date = CFF_Utils::print_template_part( 'item/date', get_defined_vars(), $this); |
| 726 | |
| 727 | |
| 728 | |
| 729 | |
| 730 | //Story/post text vars |
| 731 | $post_text = ''; |
| 732 | $cff_story_raw = ''; |
| 733 | $cff_message_raw = ''; |
| 734 | $cff_name_raw = ''; |
| 735 | $text_tags = ''; |
| 736 | $post_text_story = ''; |
| 737 | $post_text_message = ''; |
| 738 | |
| 739 | //STORY TAGS |
| 740 | $cff_post_tags = $this->atts[ 'posttags' ]; |
| 741 | |
| 742 | //Use the story |
| 743 | if (!empty($news->story)) { |
| 744 | $cff_story_raw = $news->story; |
| 745 | $post_text_story .= htmlspecialchars($cff_story_raw); |
| 746 | |
| 747 | |
| 748 | //Add message and story tags if there are any and the post text is the message or the story |
| 749 | if( $cff_post_tags && isset($news->story_tags) && !$cff_title_link){ |
| 750 | |
| 751 | $text_tags = $news->story_tags; |
| 752 | |
| 753 | //Does the Post Text contain any html tags? - the & symbol is the best indicator of this |
| 754 | $cff_html_check_array = array('<', '’', '“', '"', '&', '>>'); |
| 755 | |
| 756 | //always use the text replace method |
| 757 | if( CFF_Utils::cff_stripos_arr($post_text_story, $cff_html_check_array) !== false || ($cff_locale == 'el_GR' && count($news->story_tags) > 3) ) { |
| 758 | |
| 759 | //Loop through the tags |
| 760 | foreach($text_tags as $message_tag ) { |
| 761 | |
| 762 | ( isset($message_tag->id) ) ? $message_tag = $message_tag : $message_tag = $message_tag[0]; |
| 763 | |
| 764 | $tag_name = $message_tag->name; |
| 765 | $tag_link = '<a href="https://facebook.com/' . $message_tag->id . '">' . $message_tag->name . '</a>'; |
| 766 | |
| 767 | $post_text_story = str_replace($tag_name, $tag_link, $post_text_story); |
| 768 | } |
| 769 | |
| 770 | } else { |
| 771 | |
| 772 | //If it doesn't contain HTMl tags then use the offset to replace message tags |
| 773 | $message_tags_arr = array(); |
| 774 | |
| 775 | $tag = 0; |
| 776 | foreach($text_tags as $message_tag ) { |
| 777 | $tag++; |
| 778 | ( isset($message_tag->id) ) ? $message_tag = $message_tag : $message_tag = $message_tag[0]; |
| 779 | |
| 780 | isset($message_tag->type) ? $tag_type = $message_tag->type : $tag_type = ''; |
| 781 | |
| 782 | $message_tags_arr = CFF_Utils::cff_array_push_assoc( |
| 783 | $message_tags_arr, |
| 784 | $tag, |
| 785 | array( |
| 786 | 'id' => $message_tag->id, |
| 787 | 'name' => $message_tag->name, |
| 788 | 'type' => isset($message_tag->type) ? $message_tag->type : '', |
| 789 | 'offset' => $message_tag->offset, |
| 790 | 'length' => $message_tag->length |
| 791 | ) |
| 792 | ); |
| 793 | |
| 794 | } |
| 795 | |
| 796 | //Keep track of the offsets so that if two tags have the same offset then only one is used. Need this as API 2.5 update changed the story_tag JSON format. A duplicate offset usually means '__ was with __ and 3 others'. We don't want to link the '3 others' part. |
| 797 | $cff_story_tag_offsets = ''; |
| 798 | $cff_story_duplicate_offset = ''; |
| 799 | |
| 800 | //Check if there are any duplicate offsets. If so, assign to the cff_story_duplicate_offset var. |
| 801 | for($tag = count($message_tags_arr); $tag >= 1; $tag--) { |
| 802 | $c = (string)$message_tags_arr[$tag]['offset']; |
| 803 | if( strpos( $cff_story_tag_offsets, $c ) !== false && $c !== '0' ){ |
| 804 | $cff_story_duplicate_offset = $c; |
| 805 | } else { |
| 806 | $cff_story_tag_offsets .= $c . ','; |
| 807 | } |
| 808 | |
| 809 | } |
| 810 | |
| 811 | for($tag = count($message_tags_arr); $tag >= 1; $tag--) { |
| 812 | |
| 813 | //If the name is blank (aka the story tag doesn't work properly) then don't use it |
| 814 | if( $message_tags_arr[$tag]['name'] !== '' ) { |
| 815 | |
| 816 | //If it's an event tag or it has the same offset as another tag then don't display it |
| 817 | if( $message_tags_arr[$tag]['type'] == 'event' || $message_tags_arr[$tag]['offset'] == $cff_story_duplicate_offset || $message_tags_arr[$tag]['type'] == 'page' ){ |
| 818 | //Don't use the story tag in this case otherwise it changes '__ created an event' to '__ created an Name Of Event' |
| 819 | //Don't use the story tag if it's a page as it causes an issue when sharing a page: Smash Balloon Dev shared a Smash Balloon. |
| 820 | } else { |
| 821 | $b = '<a href="https://facebook.com/' . $message_tags_arr[$tag]['id'] . '" target="_blank">' . $message_tags_arr[$tag]['name'] . '</a>'; |
| 822 | $c = $message_tags_arr[$tag]['offset']; |
| 823 | $d = $message_tags_arr[$tag]['length']; |
| 824 | $post_text_story = CFF_Utils::cff_mb_substr_replace( $post_text_story, $b, $c, $d); |
| 825 | } |
| 826 | |
| 827 | } |
| 828 | |
| 829 | } |
| 830 | |
| 831 | } // end if/else |
| 832 | |
| 833 | } //END STORY TAGS |
| 834 | |
| 835 | } |
| 836 | |
| 837 | //POST AUTHOR |
| 838 | $cff_author = CFF_Utils::print_template_part( 'item/author', get_defined_vars(), $this); |
| 839 | |
| 840 | //Get the actual post text |
| 841 | //Which content should we use? |
| 842 | //Use the message |
| 843 | if (!empty($news->message)) { |
| 844 | $cff_message_raw = $news->message; |
| 845 | |
| 846 | $post_text_message = htmlspecialchars($cff_message_raw); |
| 847 | |
| 848 | //MESSAGE TAGS |
| 849 | //Add message and story tags if there are any and the post text is the message or the story |
| 850 | if( $cff_post_tags && isset($news->message_tags) && !$cff_title_link){ |
| 851 | |
| 852 | $text_tags = $news->message_tags; |
| 853 | |
| 854 | //Does the Post Text contain any html tags? - the & symbol is the best indicator of this |
| 855 | $cff_html_check_array = array('<', '’', '“', '"', '&', '>>', '>'); |
| 856 | |
| 857 | //always use the text replace method |
| 858 | if( CFF_Utils::cff_stripos_arr($post_text_message, $cff_html_check_array) !== false ) { |
| 859 | //Loop through the tags |
| 860 | foreach($text_tags as $message_tag ) { |
| 861 | |
| 862 | ( isset($message_tag->id) ) ? $message_tag = $message_tag : $message_tag = $message_tag[0]; |
| 863 | |
| 864 | $tag_name = $message_tag->name; |
| 865 | $tag_link = '<a href="https://facebook.com/' . $message_tag->id . '">' . $message_tag->name . '</a>'; |
| 866 | |
| 867 | $post_text_message = str_replace($tag_name, $tag_link, $post_text_message); |
| 868 | } |
| 869 | |
| 870 | } else { |
| 871 | //If it doesn't contain HTMl tags then use the offset to replace message tags |
| 872 | $message_tags_arr = array(); |
| 873 | |
| 874 | $tag = 0; |
| 875 | foreach($text_tags as $message_tag ) { |
| 876 | $tag++; |
| 877 | |
| 878 | ( isset($message_tag->id) ) ? $message_tag = $message_tag : $message_tag = $message_tag[0]; |
| 879 | |
| 880 | $message_tags_arr = CFF_Utils::cff_array_push_assoc( |
| 881 | $message_tags_arr, |
| 882 | $tag, |
| 883 | array( |
| 884 | 'id' => $message_tag->id, |
| 885 | 'name' => $message_tag->name, |
| 886 | 'type' => isset($message_tag->type) ? $message_tag->type : '', |
| 887 | 'offset' => $message_tag->offset, |
| 888 | 'length' => $message_tag->length |
| 889 | ) |
| 890 | ); |
| 891 | } |
| 892 | |
| 893 | //Keep track of the offsets so that if two tags have the same offset then only one is used. Need this as API 2.5 update changed the story_tag JSON format. |
| 894 | $cff_msg_tag_offsets = ''; |
| 895 | $cff_msg_duplicate_offset = ''; |
| 896 | |
| 897 | //Check if there are any duplicate offsets. If so, assign to the cff_duplicate_offset var. |
| 898 | for($tag = count($message_tags_arr); $tag >= 1; $tag--) { |
| 899 | $c = (string)$message_tags_arr[$tag]['offset']; |
| 900 | if( strpos( $cff_msg_tag_offsets, $c ) !== false && $c !== '0' ){ |
| 901 | $cff_msg_duplicate_offset = $c; |
| 902 | } else { |
| 903 | $cff_msg_tag_offsets .= $c . ','; |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | //Sort the array by the "offset" key as Facebook doesn't always return them in the correct order |
| 908 | usort($message_tags_arr, "CustomFacebookFeed\CFF_Utils::cffSortTags"); |
| 909 | |
| 910 | for($tag = count($message_tags_arr)-1; $tag >= 0; $tag--) { |
| 911 | |
| 912 | //If the name is blank (aka the story tag doesn't work properly) then don't use it |
| 913 | if( $message_tags_arr[$tag]['name'] !== '' ) { |
| 914 | |
| 915 | if( $message_tags_arr[$tag]['offset'] == $cff_msg_duplicate_offset ){ |
| 916 | //If it has the same offset as another tag then don't display it |
| 917 | } else { |
| 918 | $b = '<a href="https://facebook.com/' . $message_tags_arr[$tag]['id'] . '">' . $message_tags_arr[$tag]['name'] . '</a>'; |
| 919 | $c = $message_tags_arr[$tag]['offset']; |
| 920 | $d = $message_tags_arr[$tag]['length']; |
| 921 | $post_text_message = CFF_Utils::cff_mb_substr_replace( $post_text_message, $b, $c, $d); |
| 922 | } |
| 923 | |
| 924 | } |
| 925 | |
| 926 | } |
| 927 | |
| 928 | } // end if/else |
| 929 | |
| 930 | } //END MESSAGE TAGS |
| 931 | |
| 932 | } |
| 933 | |
| 934 | |
| 935 | //Check to see whether it's an embedded video so that we can show the name above the post text if necessary |
| 936 | $cff_soundcloud = false; |
| 937 | $cff_is_video_embed = false; |
| 938 | if ($cff_post_type == 'video' || $cff_post_type == 'music'){ |
| 939 | if( isset($news->source) && !empty($news->source) ){ |
| 940 | $url = $news->source; |
| 941 | } else if ( isset($news->link) ) { |
| 942 | $url = $news->link; |
| 943 | } else { |
| 944 | $url = ''; |
| 945 | } |
| 946 | //Embeddable video strings |
| 947 | $vimeo = 'vimeo'; |
| 948 | $youtube = CFF_Utils::stripos($url, 'youtube'); |
| 949 | $youtu = CFF_Utils::stripos($url, 'youtu'); |
| 950 | $youtubeembed = CFF_Utils::stripos($url, 'youtube.com/embed'); |
| 951 | $soundcloudembed = CFF_Utils::stripos($url, 'soundcloud.com'); |
| 952 | |
| 953 | //Check whether it's a youtube video |
| 954 | if($youtube || $youtu || $youtubeembed || (stripos($url, $vimeo) !== false)) { |
| 955 | $cff_is_video_embed = true; |
| 956 | } |
| 957 | //If it's soundcloud then add it into the shared link box at the bottom of the post |
| 958 | if( $soundcloudembed ) $cff_soundcloud = true; |
| 959 | } |
| 960 | |
| 961 | //Add the story and message together |
| 962 | $post_text = ''; |
| 963 | |
| 964 | //DESCRIPTION |
| 965 | $cff_description = ''; |
| 966 | if ( !empty($news->description) || !empty($news->caption) ) { |
| 967 | $description_text = ''; |
| 968 | |
| 969 | if ( !empty($news->description) ) { |
| 970 | $description_text = $news->description; |
| 971 | } |
| 972 | |
| 973 | //Replace ellipsis char in description text |
| 974 | $raw_desc = $description_text; |
| 975 | $description_text = str_replace( '…','...', $description_text); |
| 976 | |
| 977 | //If the description is the same as the post text then don't show it |
| 978 | if( $raw_desc == $cff_story_raw || $raw_desc == $cff_message_raw || $raw_desc == $cff_name_raw ){ |
| 979 | $cff_description = ''; |
| 980 | } else { |
| 981 | //Add links and create HTML |
| 982 | $cff_description .= '<span class="cff-post-desc" '.$cff_body_styles.'>'; |
| 983 | |
| 984 | if ($cff_title_link) { |
| 985 | $cff_description_tagged = CFF_Utils::cff_wrap_span( htmlspecialchars($description_text) ); |
| 986 | } else { |
| 987 | $cff_description_text = CFF_Autolink::cff_autolink( htmlspecialchars($description_text), $link_color=$cff_posttext_link_color ); |
| 988 | $cff_description_tagged = CFF_Utils::cff_desc_tags($cff_description_text); |
| 989 | } |
| 990 | |
| 991 | $cff_description .= $cff_description_tagged; |
| 992 | $cff_description .= ' </span>'; |
| 993 | } |
| 994 | |
| 995 | if( $cff_post_type == 'event' || $cff_is_video_embed || $cff_soundcloud ) $cff_description = ''; |
| 996 | } |
| 997 | |
| 998 | //Add the message |
| 999 | if($cff_show_text) $post_text .= $post_text_message; |
| 1000 | |
| 1001 | $post_text = apply_filters( 'cff_post_text', $post_text ); |
| 1002 | |
| 1003 | //If it's a shared video post then add the video name after the post text above the video description so it's all one chunk |
| 1004 | if ($cff_post_type == 'video'){ |
| 1005 | if( !empty($cff_description) && $cff_description != '' ){ |
| 1006 | if( (!empty($post_text) && $post_text != '') && !empty($cff_video_name) ) $post_text .= '<br /><br />'; |
| 1007 | $post_text .= $cff_video_name; |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | |
| 1012 | //Use the name if there's no other text, unless it's a shared link post as then it's already used as the shared link box title |
| 1013 | if ( !empty($news->name) && empty($news->message) && $cff_post_type != 'link' ) { |
| 1014 | $cff_name_raw = $news->name; |
| 1015 | $post_text = htmlspecialchars($cff_name_raw); |
| 1016 | } |
| 1017 | |
| 1018 | //OFFER TEXT |
| 1019 | if ($cff_post_type == 'offer'){ |
| 1020 | isset($news->story) ? $post_text = htmlspecialchars($news->story) . '<br /><br />' : $post_text = ''; |
| 1021 | $post_text .= htmlspecialchars($news->name); |
| 1022 | } |
| 1023 | |
| 1024 | //Add the description |
| 1025 | if( $cff_show_desc && $cff_post_type != 'offer' && $cff_post_type != 'link' ) $post_text .= $cff_description; |
| 1026 | |
| 1027 | //Change the linebreak element if the text issue setting is enabled |
| 1028 | $cff_format_issue = CFF_Utils::check_if_on( $this->atts['textissue'] ); |
| 1029 | $cff_linebreak_el = ( $cff_format_issue ) ? '<br />' : '<img class="cff-linebreak" />'; |
| 1030 | |
| 1031 | //EVENT |
| 1032 | $cff_event_has_cover_photo = false; |
| 1033 | $cff_event = ''; |
| 1034 | |
| 1035 | |
| 1036 | //Create note |
| 1037 | if ($cff_post_type == 'note') { |
| 1038 | //Notes don't include any post text and so just replace the post text with the note content |
| 1039 | if($cff_show_text) $post_text = CFF_Utils::print_template_part( 'item/type/note', get_defined_vars(), $this); |
| 1040 | } |
| 1041 | |
| 1042 | $cff_post_text = CFF_Utils::print_template_part( 'item/post-text', get_defined_vars(), $this); |
| 1043 | |
| 1044 | //LINK |
| 1045 | //Display shared link |
| 1046 | $cff_shared_link = CFF_Utils::print_template_part( 'item/shared-link', get_defined_vars(), $this); |
| 1047 | |
| 1048 | //Link to the Facebook post if it's a link or a video |
| 1049 | if($cff_post_type == 'link' || $cff_post_type == 'video') $link = "https://www.facebook.com/" . $this->page_id . "/posts/" . $PostID[1]; |
| 1050 | |
| 1051 | |
| 1052 | //If it's a shared post then change the link to use the Post ID so that it links to the shared post and not the original post that's being shared |
| 1053 | if( isset($news->status_type) ){ |
| 1054 | if( $news->status_type == 'shared_story' ) $link = "https://www.facebook.com/" . $cff_post_id; |
| 1055 | } |
| 1056 | |
| 1057 | //Create post action links HTML |
| 1058 | $cff_link = CFF_Utils::print_template_part( 'item/post-link', get_defined_vars(), $this); |
| 1059 | /* MEDIA LINK */ |
| 1060 | $cff_media_link = CFF_Utils::print_template_part( 'item/media-link', get_defined_vars(), $this); |
| 1061 | //**************************// |
| 1062 | //***CREATE THE POST HTML***// |
| 1063 | //**************************// |
| 1064 | //Start the container |
| 1065 | $cff_post_item = CFF_Utils::print_template_part( 'item/container', get_defined_vars(), $this); |
| 1066 | |
| 1067 | //PUSH TO ARRAY |
| 1068 | $cff_posts_array = CFF_Utils::cff_array_push_assoc($cff_posts_array, $i_post, $cff_post_item); |
| 1069 | |
| 1070 | } // End post type check |
| 1071 | |
| 1072 | if (isset($news->message)) $prev_post_message = $news->message; |
| 1073 | if (isset($news->link)) $prev_post_link = $news->link; |
| 1074 | if (isset($news->description)) $prev_post_description = $news->description; |
| 1075 | |
| 1076 | } // End the loop |
| 1077 | } //End isset($FBdata->data) |
| 1078 | |
| 1079 | //Sort the array in reverse order (newest first) |
| 1080 | if(!$cff_is_group) ksort($cff_posts_array); |
| 1081 | |
| 1082 | // End ALL POSTS |
| 1083 | |
| 1084 | |
| 1085 | //Output the posts array |
| 1086 | $p = 0; |
| 1087 | foreach ($cff_posts_array as $post ) { |
| 1088 | if ( $p == $show_posts ) break; |
| 1089 | $cff_content .= $post; |
| 1090 | $p++; |
| 1091 | } |
| 1092 | |
| 1093 | |
| 1094 | //Add the Like Box inside |
| 1095 | if ($cff_like_box_position == 'bottom' && $cff_show_like_box && !$cff_like_box_outside) $cff_content .= $like_box; |
| 1096 | /* Credit link */ |
| 1097 | |
| 1098 | $cff_content .= '</div>'; // End cff-posts-wrap |
| 1099 | |
| 1100 | $cff_content .= CFF_Utils::print_template_part( 'credit', get_defined_vars()); |
| 1101 | |
| 1102 | //End the feed |
| 1103 | $cff_content .= '<input class="cff-pag-url" type="hidden" data-locatornonce="'.esc_attr( wp_create_nonce( 'cff-locator-nonce-' . get_the_ID() ) ) .'" data-cff-shortcode="'.$data_att_html.'" data-post-id="' . get_the_ID() . '" data-feed-id="'.$atts['id'].'">'; |
| 1104 | $cff_content .= '</div></div><div class="cff-clear"></div>'; |
| 1105 | |
| 1106 | //Add the Like Box outside |
| 1107 | if ($cff_like_box_position == 'bottom' && $cff_show_like_box && $cff_like_box_outside) $cff_content .= $like_box; |
| 1108 | |
| 1109 | //If the feed is loaded via Ajax then put the scripts into the shortcode itself |
| 1110 | $cff_content .= $this->ajax_loaded(); |
| 1111 | $cff_content .= '</div>'; |
| 1112 | |
| 1113 | if ( $doing_custom_styles ) { |
| 1114 | $cff_content .= '<style type="text/css">'. "\n"; |
| 1115 | |
| 1116 | if ( ! empty( $this->atts['colorpalette'] ) |
| 1117 | && $this->atts['colorpalette'] === 'custom' ) { |
| 1118 | |
| 1119 | $wrap_selector = '#cff.' . $custom_palette_class; |
| 1120 | |
| 1121 | if ( ! empty( $this->atts['custombgcolor1'] ) ) { |
| 1122 | $cff_content .= $wrap_selector . ' ' . '.cff-item,' . "\n"; |
| 1123 | $cff_content .= $wrap_selector . ' ' . '.cff-item.cff-box,' . "\n"; |
| 1124 | $cff_content .= $wrap_selector . ' ' . '.cff-item.cff-box:first-child,' . "\n"; |
| 1125 | $cff_content .= $wrap_selector . ' ' . '.cff-album-item {' . "\n"; |
| 1126 | $cff_content .= ' ' . 'background-color: ' . esc_attr( $this->atts['custombgcolor1'] ) . ';' ."\n"; |
| 1127 | $cff_content .= '}' . "\n"; |
| 1128 | } |
| 1129 | |
| 1130 | if ( ! $cff_disable_link_box && ! empty( $this->atts['custombgcolor2'] ) ) { |
| 1131 | $cff_content .= $wrap_selector . ' ' . '.cff-view-comments,' . "\n"; |
| 1132 | $cff_content .= $wrap_selector . ' ' . '.cff-load-more,' . "\n"; |
| 1133 | $cff_content .= $wrap_selector . ' ' . '.cff-shared-link {' . "\n"; |
| 1134 | $cff_content .= ' ' . 'background-color: ' . esc_attr( $this->atts['custombgcolor2'] ) . ';' ."\n"; |
| 1135 | $cff_content .= '}' . "\n"; |
| 1136 | } |
| 1137 | |
| 1138 | if ( ! empty( $this->atts['textcolor1'] ) ) { |
| 1139 | $cff_content .= $wrap_selector . ' ' . '.cff-comment .cff-comment-text p,' . "\n"; |
| 1140 | $cff_content .= $wrap_selector . ' ' . '.cff-album-info p,' . "\n"; |
| 1141 | $cff_content .= $wrap_selector . ' ' . '.cff-story,' . "\n"; |
| 1142 | $cff_content .= $wrap_selector . ' ' . '.cff-text {' . "\n"; |
| 1143 | $cff_content .= ' ' . 'color: ' . esc_attr( $this->atts['textcolor1'] ) . ';' ."\n"; |
| 1144 | $cff_content .= '}' . "\n"; |
| 1145 | } |
| 1146 | |
| 1147 | if ( ! empty( $this->atts['textcolor2'] ) ) { |
| 1148 | $cff_content .= $wrap_selector . ' ' . '.cff-comment-date,' . "\n"; |
| 1149 | $cff_content .= $wrap_selector . ' ' . '.cff-text-link .cff-post-desc,' . "\n"; |
| 1150 | $cff_content .= $wrap_selector . ' ' . '.cff-link-caption,' . "\n"; |
| 1151 | $cff_content .= $wrap_selector . ' ' . '.cff-date {' . "\n"; |
| 1152 | $cff_content .= ' ' . 'color: ' . esc_attr( $this->atts['textcolor2'] ) . ';' ."\n"; |
| 1153 | $cff_content .= '}' . "\n"; |
| 1154 | } |
| 1155 | |
| 1156 | if ( ! empty( $this->atts['customlinkcolor'] ) ) { |
| 1157 | $cff_content .= $wrap_selector . ' ' . 'a,' . "\n"; |
| 1158 | $cff_content .= $wrap_selector . ' ' . '.cff-post-links a,' . "\n"; |
| 1159 | $cff_content .= $wrap_selector . ' ' . 'a {' . "\n"; |
| 1160 | $cff_content .= ' ' . 'color: ' . esc_attr( $this->atts['customlinkcolor'] ) . ';' ."\n"; |
| 1161 | $cff_content .= '}' . "\n"; |
| 1162 | } |
| 1163 | |
| 1164 | } |
| 1165 | $lightbox_selector = '#cff-lightbox-wrapper'; |
| 1166 | |
| 1167 | if ( ! empty( $this->atts['lightboxbgcolor'] ) ) { |
| 1168 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-dataContainer,' . "\n"; |
| 1169 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-sidebar {' . "\n"; |
| 1170 | $cff_content .= ' ' . 'background-color: ' . esc_attr( $this->atts['lightboxbgcolor'] ) . ';' ."\n"; |
| 1171 | $cff_content .= '}' . "\n"; |
| 1172 | } |
| 1173 | |
| 1174 | if ( ! empty( $this->atts['lightboxtextcolor'] ) ) { |
| 1175 | $cff_content .= $lightbox_selector . ' ' . '.cff-author .cff-date,' . "\n"; |
| 1176 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-closeContainer svg,' . "\n"; |
| 1177 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-caption-text {' . "\n"; |
| 1178 | $cff_content .= ' ' . 'color: ' . esc_attr( $this->atts['lightboxtextcolor'] ) . ';' ."\n"; |
| 1179 | $cff_content .= '}' . "\n"; |
| 1180 | } |
| 1181 | |
| 1182 | if ( ! empty( $this->atts['lightboxlinkcolor'] ) ) { |
| 1183 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-caption-text a:link,' . "\n"; |
| 1184 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-caption-text a:hover,' . "\n"; |
| 1185 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-caption-text a:active,' . "\n"; |
| 1186 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-caption-text a:visited,' . "\n"; |
| 1187 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-facebook:link,' . "\n"; |
| 1188 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-facebook:hover,' . "\n"; |
| 1189 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-facebook:active,' . "\n"; |
| 1190 | $cff_content .= $lightbox_selector . ' ' . '.cff-lightbox-facebook:visited,' . "\n"; |
| 1191 | $cff_content .= $lightbox_selector . ' ' . 'a {' . "\n"; |
| 1192 | $cff_content .= ' ' . 'color: ' . esc_attr( $this->atts['lightboxlinkcolor'] ) . ';' ."\n"; |
| 1193 | $cff_content .= '}' . "\n"; |
| 1194 | } |
| 1195 | |
| 1196 | $cff_content .= '</style>'; |
| 1197 | |
| 1198 | } |
| 1199 | |
| 1200 | |
| 1201 | if( isset( $cff_posttext_link_color ) && !empty( $cff_posttext_link_color ) ) $cff_content .= '<style>#cff .cff-post-text a{ color: #'.$cff_posttext_link_color.'; }</style>'; |
| 1202 | |
| 1203 | if ( isset( $_GET['sb_debug'] ) ) { |
| 1204 | $cff_content .= $this->sb_get_debug_report( $feed_options ); |
| 1205 | } |
| 1206 | |
| 1207 | //Return our feed HTML to display |
| 1208 | return $cff_content; |
| 1209 | } |
| 1210 | |
| 1211 | /** |
| 1212 | * Get Debug Report for Feed |
| 1213 | * |
| 1214 | * @since 4.0 |
| 1215 | * |
| 1216 | * @param array $feed_opitons |
| 1217 | * |
| 1218 | * @return string $output |
| 1219 | */ |
| 1220 | public function sb_get_debug_report( $feed_options ) { |
| 1221 | if ( !isset( $_GET['sb_debug'] ) ) { |
| 1222 | return; |
| 1223 | } |
| 1224 | $cff_options = get_option( 'cff_style_settings' ); |
| 1225 | |
| 1226 | $output = ''; |
| 1227 | $output .= '<p>Settings</p>'; |
| 1228 | $output .= '<ul style="word-break: break-all;">'; |
| 1229 | |
| 1230 | $output .= '<li>Optimize Images: '; |
| 1231 | $output .= isset( $cff_options[ 'cff_disable_resize' ] ) && $cff_options[ 'cff_disable_resize' ] == 'on' ? 'Enabled' : 'Disabled'; |
| 1232 | $output .= "</li>"; |
| 1233 | $output .= "</li>"; |
| 1234 | $output .= '<li>AJAX theme loading fix: '; |
| 1235 | $output .= isset( $cff_options[ 'cff_disable_ajax_cache' ] ) && $cff_options[ 'cff_disable_ajax_cache' ] == true ? 'Enabled' : 'Disabled'; |
| 1236 | $output .= "</li>"; |
| 1237 | $output .= '<li>Show Credit Link: '; |
| 1238 | $output .= isset( $cff_options['cff_format_issue'] ) && $cff_options['cff_format_issue'] == true ? 'Enabled' : 'Disabled'; |
| 1239 | $output .= "</li>"; |
| 1240 | $output .= '<li>Fix Text Shortening Issue: '; |
| 1241 | $output .= isset( $cff_options['cff_show_credit'] ) && $cff_options['cff_show_credit'] == true ? 'Enabled' : 'Disabled'; |
| 1242 | $output .= "</li>"; |
| 1243 | $output .= '<li>Admin Error Notice: '; |
| 1244 | $output .= isset( $cff_options['disable_admin_notice'] ) && $cff_options['disable_admin_notice'] == true ? 'Enabled' : 'Disabled'; |
| 1245 | $output .= "</li>"; |
| 1246 | $output .= '</ul>'; |
| 1247 | |
| 1248 | $output .= '<p>Feed Options</p>'; |
| 1249 | $public_settings_keys = CFF_Shortcode::get_public_db_settings_keys(); |
| 1250 | |
| 1251 | $output .= '<ul style="word-break: break-all;">'; |
| 1252 | foreach( $feed_options as $key => $option ) { |
| 1253 | if ( is_array( $option ) ) continue; |
| 1254 | if ( in_array( $key, $public_settings_keys, true ) ) { |
| 1255 | $output .= sprintf('<li>%s: %s</li>', esc_html( $key ), esc_html( $option ) ); |
| 1256 | } |
| 1257 | } |
| 1258 | $output .= '</ul>'; |
| 1259 | |
| 1260 | return $output; |
| 1261 | } |
| 1262 | |
| 1263 | /** |
| 1264 | * The plugin will output settings on the frontend for debugging purposes. |
| 1265 | * Safe settings to display are added here. |
| 1266 | ** |
| 1267 | * @return array |
| 1268 | * |
| 1269 | * @since 4.0 |
| 1270 | */ |
| 1271 | public static function get_public_db_settings_keys() { |
| 1272 | $public = array( |
| 1273 | 'ownaccesstoken', |
| 1274 | 'id', |
| 1275 | 'pagetype', |
| 1276 | 'num', |
| 1277 | 'limit', |
| 1278 | 'others', |
| 1279 | 'showpostsby', |
| 1280 | 'cachetype', |
| 1281 | 'cachetime', |
| 1282 | 'cacheunit', |
| 1283 | 'locale', |
| 1284 | 'storytags', |
| 1285 | 'ajax', |
| 1286 | 'offset', |
| 1287 | 'account', |
| 1288 | 'width', |
| 1289 | 'widthresp', |
| 1290 | 'height', |
| 1291 | 'padding', |
| 1292 | 'bgcolor', |
| 1293 | 'showauthor', |
| 1294 | 'showauthornew', |
| 1295 | 'class', |
| 1296 | 'type', |
| 1297 | 'gdpr', |
| 1298 | 'loadiframes', |
| 1299 | 'eventsource', |
| 1300 | 'eventoffset', |
| 1301 | 'eventimage', |
| 1302 | 'pastevents', |
| 1303 | 'albumsource', |
| 1304 | 'showalbumtitle', |
| 1305 | 'showalbumnum', |
| 1306 | 'albumcols', |
| 1307 | 'photosource', |
| 1308 | 'photocols', |
| 1309 | 'videosource', |
| 1310 | 'showvideoname', |
| 1311 | 'showvideodesc', |
| 1312 | 'videocols', |
| 1313 | 'playlist', |
| 1314 | 'disablelightbox', |
| 1315 | 'filter', |
| 1316 | 'exfilter', |
| 1317 | 'layout', |
| 1318 | 'enablenarrow', |
| 1319 | 'oneimage', |
| 1320 | 'mediaposition' => 'above', |
| 1321 | 'include', |
| 1322 | 'exclude', |
| 1323 | 'masonry', |
| 1324 | 'masonrycols', |
| 1325 | 'masonrycolsmobile', |
| 1326 | 'masonryjs', |
| 1327 | 'cols', |
| 1328 | 'colsmobile', |
| 1329 | 'colsjs', |
| 1330 | 'nummobile', |
| 1331 | 'poststyle', |
| 1332 | 'postbgcolor', |
| 1333 | 'postcorners', |
| 1334 | 'boxshadow', |
| 1335 | 'textformat', |
| 1336 | 'textsize', |
| 1337 | 'textweight', |
| 1338 | 'textcolor', |
| 1339 | 'textlinkcolor', |
| 1340 | 'textlink', |
| 1341 | 'posttags', |
| 1342 | 'linkhashtags', |
| 1343 | 'lightboxcomments', |
| 1344 | 'authorsize', |
| 1345 | 'authorcolor', |
| 1346 | 'descsize', |
| 1347 | 'descweight', |
| 1348 | 'desccolor', |
| 1349 | 'linktitleformat', |
| 1350 | 'linktitlesize', |
| 1351 | 'linkdescsize', |
| 1352 | 'linkurlsize', |
| 1353 | 'linkdesccolor', |
| 1354 | 'linktitlecolor', |
| 1355 | 'linkurlcolor', |
| 1356 | 'linkbgcolor', |
| 1357 | 'linkbordercolor', |
| 1358 | 'disablelinkbox', |
| 1359 | 'eventtitleformat', |
| 1360 | 'eventtitlesize', |
| 1361 | 'eventtitleweight', |
| 1362 | 'eventtitlecolor', |
| 1363 | 'eventtitlelink', |
| 1364 | 'eventdatesize', |
| 1365 | 'eventdateweight', |
| 1366 | 'eventdatecolor', |
| 1367 | 'eventdatepos', |
| 1368 | 'eventdateformat', |
| 1369 | 'eventdatecustom', |
| 1370 | 'timezoneoffset', |
| 1371 | 'cff_enqueue_with_shortcode', |
| 1372 | 'eventdetailssize', |
| 1373 | 'eventdetailsweight', |
| 1374 | 'eventdetailscolor', |
| 1375 | 'eventlinkcolor', |
| 1376 | 'datepos', |
| 1377 | 'datesize', |
| 1378 | 'dateweight', |
| 1379 | 'datecolor', |
| 1380 | 'dateformat', |
| 1381 | 'datecustom', |
| 1382 | 'timezone', |
| 1383 | 'beforedate', |
| 1384 | 'afterdate', |
| 1385 | 'linksize', |
| 1386 | 'linkweight', |
| 1387 | 'linkcolor', |
| 1388 | 'viewlinktext', |
| 1389 | 'linktotimeline', |
| 1390 | 'buttoncolor', |
| 1391 | 'buttonhovercolor', |
| 1392 | 'buttontextcolor', |
| 1393 | 'buttontext', |
| 1394 | 'nomoretext', |
| 1395 | 'iconstyle', |
| 1396 | 'socialtextcolor', |
| 1397 | 'socialbgcolor', |
| 1398 | 'sociallinkcolor', |
| 1399 | 'expandcomments', |
| 1400 | 'commentsnum', |
| 1401 | 'hidecommentimages', |
| 1402 | 'loadcommentsjs', |
| 1403 | 'salesposts', |
| 1404 | 'textlength', |
| 1405 | 'desclength', |
| 1406 | 'showlikebox', |
| 1407 | 'likeboxpos', |
| 1408 | 'likeboxoutside', |
| 1409 | 'likeboxcolor', |
| 1410 | 'likeboxtextcolor', |
| 1411 | 'likeboxwidth', |
| 1412 | 'likeboxfaces', |
| 1413 | 'likeboxborder', |
| 1414 | 'likeboxcover', |
| 1415 | 'likeboxsmallheader', |
| 1416 | 'likeboxhidebtn', |
| 1417 | 'credit', |
| 1418 | 'textissue', |
| 1419 | 'disablesvgs', |
| 1420 | 'restrictedpage', |
| 1421 | 'hidesupporterposts', |
| 1422 | 'privategroup', |
| 1423 | 'nofollow', |
| 1424 | 'timelinepag', |
| 1425 | 'gridpag', |
| 1426 | 'disableresize', |
| 1427 | 'showheader', |
| 1428 | 'headertype', |
| 1429 | 'headercover', |
| 1430 | 'headeravatar', |
| 1431 | 'headername', |
| 1432 | 'headerbio', |
| 1433 | 'headercoverheight', |
| 1434 | 'headerlikes', |
| 1435 | 'headeroutside', |
| 1436 | 'headertext', |
| 1437 | 'headerbg', |
| 1438 | 'headerpadding', |
| 1439 | 'headertextsize', |
| 1440 | 'headertextweight', |
| 1441 | 'headertextcolor', |
| 1442 | 'headericon', |
| 1443 | 'headericoncolor', |
| 1444 | 'headericonsize', |
| 1445 | 'headerinc', |
| 1446 | 'headerexclude', |
| 1447 | 'loadmore', |
| 1448 | 'fulllinkimages', |
| 1449 | 'linkimagesize', |
| 1450 | 'postimagesize', |
| 1451 | 'videoheight', |
| 1452 | 'videoaction', |
| 1453 | 'videoplayer', |
| 1454 | 'sepcolor', |
| 1455 | 'sepsize', |
| 1456 | 'seemoretext', |
| 1457 | 'seelesstext', |
| 1458 | 'photostext', |
| 1459 | 'facebooklinktext', |
| 1460 | 'sharelinktext', |
| 1461 | 'showfacebooklink', |
| 1462 | 'showsharelink', |
| 1463 | 'buyticketstext', |
| 1464 | 'maptext', |
| 1465 | 'interestedtext', |
| 1466 | 'goingtext', |
| 1467 | 'previouscommentstext', |
| 1468 | 'commentonfacebooktext', |
| 1469 | 'likesthistext', |
| 1470 | 'likethistext', |
| 1471 | 'reactedtothistext', |
| 1472 | 'andtext', |
| 1473 | 'othertext', |
| 1474 | 'otherstext', |
| 1475 | 'noeventstext', |
| 1476 | 'replytext', |
| 1477 | 'repliestext', |
| 1478 | 'learnmoretext', |
| 1479 | 'shopnowtext', |
| 1480 | 'messagepage', |
| 1481 | 'getdirections', |
| 1482 | 'secondtext', |
| 1483 | 'secondstext', |
| 1484 | 'minutetext', |
| 1485 | 'minutestext', |
| 1486 | 'hourtext', |
| 1487 | 'hourstext', |
| 1488 | 'daytext', |
| 1489 | 'daystext', |
| 1490 | 'weektext', |
| 1491 | 'weekstext', |
| 1492 | 'monthtext', |
| 1493 | 'monthstext', |
| 1494 | 'yeartext', |
| 1495 | 'yearstext', |
| 1496 | 'agotext', |
| 1497 | 'multifeedactive', |
| 1498 | 'daterangeactive', |
| 1499 | 'featuredpostactive', |
| 1500 | 'albumactive', |
| 1501 | 'masonryactive', |
| 1502 | 'carouselactive', |
| 1503 | 'reviewsactive', |
| 1504 | 'from', |
| 1505 | 'until', |
| 1506 | 'featuredpost', |
| 1507 | 'album', |
| 1508 | 'daterange', |
| 1509 | 'lightbox', |
| 1510 | 'reviewsrated', |
| 1511 | 'starsize', |
| 1512 | 'hidenegative', |
| 1513 | 'reviewslinktext', |
| 1514 | 'reviewshidenotext', |
| 1515 | 'reviewsmethod', |
| 1516 | 'feedtype', |
| 1517 | 'likeboxcustomwidth', |
| 1518 | 'colstablet', |
| 1519 | 'feedlayout', |
| 1520 | 'colorpalette', |
| 1521 | 'custombgcolor1', |
| 1522 | 'custombgcolor2', |
| 1523 | 'textcolor1', |
| 1524 | 'textcolor2', |
| 1525 | 'posttextcolor', |
| 1526 | 'misctextcolor', |
| 1527 | 'misclinkcolor', |
| 1528 | 'headericonenabled', |
| 1529 | 'lightboxbgcolor', |
| 1530 | 'lightboxtextcolor', |
| 1531 | 'lightboxlinkcolor', |
| 1532 | 'beforedateenabled', |
| 1533 | 'afterdateenabled', |
| 1534 | 'showpoststypes', |
| 1535 | 'headerbiosize', |
| 1536 | 'headerbiocolor', |
| 1537 | 'apipostlimit', |
| 1538 | 'carouselheight', |
| 1539 | 'carouseldesktop_cols', |
| 1540 | 'carouselmobile_cols', |
| 1541 | 'carouselnavigation', |
| 1542 | 'carouselpagination', |
| 1543 | 'carouselautoplay', |
| 1544 | 'carouselinterval', |
| 1545 | ); |
| 1546 | |
| 1547 | return $public; |
| 1548 | } |
| 1549 | |
| 1550 | /* NEW 3.0 Methods */ |
| 1551 | /** |
| 1552 | * Whether or not this feed is meant to use the new settings |
| 1553 | * or legacy settings |
| 1554 | * |
| 1555 | * @param array $feed_options |
| 1556 | * |
| 1557 | * @return bool |
| 1558 | * |
| 1559 | * @since 4.0 |
| 1560 | */ |
| 1561 | public function using_legacy_feed( $feed_options ) { |
| 1562 | $cff_statuses = get_option( 'cff_statuses', array() ); |
| 1563 | |
| 1564 | if ( isset( $cff_statuses['support_legacy_shortcode'] ) |
| 1565 | && is_array( $cff_statuses['support_legacy_shortcode'] )) { |
| 1566 | return empty( $feed_options['feed'] ); |
| 1567 | } |
| 1568 | |
| 1569 | if ( empty( $cff_statuses['support_legacy_shortcode'] ) ) { |
| 1570 | return false; |
| 1571 | } |
| 1572 | |
| 1573 | return empty( $feed_options['feed'] ); |
| 1574 | } |
| 1575 | |
| 1576 | /** |
| 1577 | * If a single unique feed was detected when updating from version 3.x |
| 1578 | * to version 4.0, a shortcode without a feed specified will be defaulted |
| 1579 | * to feed=1 |
| 1580 | * |
| 1581 | * @param $feed_options |
| 1582 | * |
| 1583 | * @return bool |
| 1584 | */ |
| 1585 | public function is_legacy_feed_one( $feed_options ) { |
| 1586 | $cff_statuses = get_option( 'cff_statuses', array() ); |
| 1587 | |
| 1588 | if ( isset( $cff_statuses['support_legacy_shortcode'] ) |
| 1589 | && is_array( $cff_statuses['support_legacy_shortcode'] )) { |
| 1590 | return empty( $feed_options['feed'] ); |
| 1591 | } |
| 1592 | |
| 1593 | return false; |
| 1594 | } |
| 1595 | |
| 1596 | /** |
| 1597 | * For non-legacy feeds. Queries the new db tables to see if the feed |
| 1598 | * exists and then converts the settings to what is usable by the plugin. |
| 1599 | * |
| 1600 | * @param array $feed_options |
| 1601 | * |
| 1602 | * @return array|bool |
| 1603 | * |
| 1604 | * @since 4.0 |
| 1605 | */ |
| 1606 | function get_settings_for_feed( $feed_options ) { |
| 1607 | if ( ! is_array( $feed_options ) ) { |
| 1608 | $feed_options = array(); |
| 1609 | } |
| 1610 | |
| 1611 | if ( $this->is_legacy_feed_one( $feed_options ) ) { |
| 1612 | $feed_options['feed'] = 1; |
| 1613 | } |
| 1614 | |
| 1615 | if ( ! $this->using_legacy_feed( $feed_options ) ) { |
| 1616 | |
| 1617 | $feed_id = isset( $feed_options['feed'] ) ? $feed_options['feed'] : false; |
| 1618 | |
| 1619 | if ( empty( $feed_id ) ) { |
| 1620 | $feed_list = \CustomFacebookFeed\Builder\CFF_Feed_Builder::get_feed_list(); |
| 1621 | |
| 1622 | if ( count( $feed_list ) === 1 ) { |
| 1623 | $feed_saver = new \CustomFacebookFeed\Builder\CFF_Feed_Saver( $feed_list[0]['id'] ); |
| 1624 | $settings = $feed_saver->get_feed_settings(); |
| 1625 | } else { |
| 1626 | if (( current_user_can('editor') || current_user_can('administrator') ) ) { |
| 1627 | echo "<span id='cff-no-id'>" . sprintf( __( "It looks like you have more than one feed. Go to %sthis page%s and enter the intended feed ID in your shortcode like this: [custom-facebook-feed feed=YOUR_FEED_ID_HERE].", 'custom-facebook-feed' ), '<a href="' . esc_url( admin_url( 'admin.php?page=cff-feed-builder' ) ) . '">', '</a>' ) . "</span><br /><br />"; |
| 1628 | } |
| 1629 | return false; |
| 1630 | } |
| 1631 | |
| 1632 | } else { |
| 1633 | $feed_saver = new \CustomFacebookFeed\Builder\CFF_Feed_Saver( $feed_id ); |
| 1634 | $settings = $feed_saver->get_feed_settings(); |
| 1635 | } |
| 1636 | |
| 1637 | if ( empty( $settings ) ) { |
| 1638 | if (( current_user_can('editor') || current_user_can('administrator') ) ) { |
| 1639 | $feed_list = \CustomFacebookFeed\Builder\CFF_Feed_Builder::get_feed_list(); |
| 1640 | if ( empty( $feed_list ) ) { |
| 1641 | echo "<span id='cff-no-id'>" . sprintf( __( "It looks like you haven't set up a feed yet. Try going to %sthis page%s to create one and then enter the feed id in the shortcode like this [custom-facebook-feed feed=YOUR_FEED_ID_HERE].", 'custom-facebook-feed' ), '<a href="' . esc_url( admin_url( 'admin.php?page=cff-feed-builder' ) ) . '">', '</a>' ) . "</span><br /><br />"; |
| 1642 | } |
| 1643 | } |
| 1644 | return false; |
| 1645 | } elseif ( empty( $settings['sources'] ) ) { |
| 1646 | if (( current_user_can('editor') || current_user_can('administrator') ) ) { |
| 1647 | echo "<span id='cff-no-id'>" . sprintf( __( "No source found for this feed. It looks like you may have removed the account this feed was using to display posts. Go to %sthis page%s, switch to the settings tab and click the sources menu item to manage sources for this feed.", 'custom-facebook-feed' ), '<a href="' . esc_url( admin_url( 'admin.php?page=cff-feed-builder&feed_id=' . (int) $feed_id ) ) . '">', '</a>' ) . "</span><br /><br />"; |
| 1648 | } |
| 1649 | return $settings; |
| 1650 | } |
| 1651 | |
| 1652 | |
| 1653 | if ( empty( $settings['showpoststypes'] ) |
| 1654 | || $settings['showpoststypes'] === 'all' ) { |
| 1655 | $settings['type'] = 'links,events,videos,photos,albums,statuses'; |
| 1656 | } |
| 1657 | |
| 1658 | if ( ! empty( $settings['feedtype'] ) && $settings['feedtype'] !== 'timeline' ) { |
| 1659 | $settings['type'] = $settings['feedtype']; |
| 1660 | } |
| 1661 | |
| 1662 | |
| 1663 | } else { |
| 1664 | $settings = CFF_FB_Settings::get_legacy_settings( $feed_options ); |
| 1665 | |
| 1666 | if ( ! empty( $feed_options['type'] ) ) { |
| 1667 | $settings['feedtype'] = $feed_options['type']; |
| 1668 | $settings['type'] = $feed_options['type']; |
| 1669 | |
| 1670 | } else { |
| 1671 | if ( empty( $settings['showpoststypes'] ) |
| 1672 | || $settings['showpoststypes'] === 'all' ) { |
| 1673 | $settings['type'] = 'links,events,videos,photos,albums,statuses'; |
| 1674 | } |
| 1675 | |
| 1676 | if ( ! empty( $settings['feedtype'] ) && $settings['feedtype'] !== 'timeline' ) { |
| 1677 | $settings['type'] = $settings['feedtype']; |
| 1678 | } |
| 1679 | } |
| 1680 | |
| 1681 | $default_grid = [ |
| 1682 | 'albums', |
| 1683 | 'videos', |
| 1684 | 'photos', |
| 1685 | 'singlealbum' |
| 1686 | ]; |
| 1687 | |
| 1688 | $type_setting_array = is_array( $settings['type'] ) ? array_filter( $settings['type'] ) : array_filter( explode( ',', $settings['type'] ) ); |
| 1689 | |
| 1690 | $single_type = count( $type_setting_array ) === 1 ? $type_setting_array[0] : false; |
| 1691 | |
| 1692 | if ( ! empty( $feed_options['album'] ) ) { |
| 1693 | $single_type = 'singlealbum'; |
| 1694 | } |
| 1695 | |
| 1696 | if ( $single_type ) { |
| 1697 | if ( in_array( $single_type, $default_grid ) ) { |
| 1698 | if ( empty( $feed_options['feedlayout'] ) ) { |
| 1699 | $settings['feedlayout'] = 'grid'; |
| 1700 | } |
| 1701 | if ( empty( $feed_options['cols'] ) ) { |
| 1702 | $colskey = substr( $single_type, 0, -1 ) . 'cols'; |
| 1703 | $options_val = isset( $settings[ $colskey ] ) ? $settings[ $colskey ] : 4; |
| 1704 | $settings['cols'] = isset( $settings[ $colskey ] ) ? $settings[ $colskey ] : $options_val; |
| 1705 | } |
| 1706 | } |
| 1707 | $settings['feedtype'] = $single_type; |
| 1708 | } |
| 1709 | |
| 1710 | } |
| 1711 | |
| 1712 | $cff_includes = $settings['include']; |
| 1713 | $cff_excludes = $settings['exclude']; |
| 1714 | |
| 1715 | $cff_show_like_box = false; |
| 1716 | if ( is_string( $cff_includes ) ) { |
| 1717 | if ( CFF_Utils::stripos($cff_includes, 'likebox') !== false ) $cff_show_like_box = true; |
| 1718 | } elseif ( in_array( 'likebox', $cff_includes ) ) { |
| 1719 | $cff_show_like_box = true; |
| 1720 | } |
| 1721 | if ( is_string( $cff_excludes ) ) { |
| 1722 | if ( CFF_Utils::stripos($cff_excludes, 'likebox') !== false ) $cff_show_like_box = false; |
| 1723 | } elseif ( in_array( 'likebox', $cff_excludes ) ) { |
| 1724 | $cff_show_like_box = false; |
| 1725 | } |
| 1726 | |
| 1727 | if ( ! isset( $feed_options['include'] ) && ! isset( $feed_options['exclude'] ) ) { |
| 1728 | if ( ! empty( $settings['showlikebox'] ) ) { |
| 1729 | $settings['showlikebox'] = $settings['showlikebox'] === false || $settings['showlikebox'] === 'off' ? false : true; |
| 1730 | } else { |
| 1731 | $settings['showlikebox'] = $cff_show_like_box; |
| 1732 | } |
| 1733 | } else { |
| 1734 | $settings['showlikebox'] = $cff_show_like_box; |
| 1735 | } |
| 1736 | |
| 1737 | if ( ! $settings['showlikebox'] ) { |
| 1738 | $settings['include'] = str_replace( 'likebox,', ',', $settings['include'] ); |
| 1739 | } |
| 1740 | |
| 1741 | if ( ! empty( $settings['headericonenabled'] ) && $settings['headericonenabled'] === 'off' ) { |
| 1742 | $settings['headericon'] = ''; |
| 1743 | } |
| 1744 | |
| 1745 | if ( ! empty( $settings['apipostlimit'] ) |
| 1746 | && $settings['apipostlimit'] === 'auto') { |
| 1747 | $settings['limit'] = ''; |
| 1748 | } |
| 1749 | |
| 1750 | if ( $settings['poststyle'] === 'regular' ) { |
| 1751 | $settings['boxshadow'] = false; |
| 1752 | } |
| 1753 | |
| 1754 | if ( isset( $feed_options['ajax'] ) ) { |
| 1755 | $settings['ajax'] = $feed_options['ajax']; |
| 1756 | } else { |
| 1757 | $settings['ajax'] = get_option( 'cff_ajax', '' ); |
| 1758 | } |
| 1759 | $settings['locale'] = ( isset( $feed_options['locale'] ) ) ? $feed_options['locale'] : get_option( 'cff_locale', 'en_US' ); |
| 1760 | |
| 1761 | // Default Timezone |
| 1762 | $defaults = array( |
| 1763 | 'cff_timezone' => 'America/Chicago', |
| 1764 | 'gdpr' => 'auto', |
| 1765 | 'cff_show_credit' => false, |
| 1766 | 'cff_format_issue' => '', |
| 1767 | 'disable_admin_notice' => false |
| 1768 | ); |
| 1769 | $style_options = get_option( 'cff_style_settings', $defaults ); |
| 1770 | $settings['timezone'] = (isset($style_options[ 'cff_timezone' ])) ? $style_options[ 'cff_timezone' ] : $defaults[ 'cff_timezone' ]; |
| 1771 | $settings['gdpr'] = (isset($style_options[ 'gdpr' ])) ? $style_options[ 'gdpr' ] : $defaults[ 'gdpr' ]; |
| 1772 | $settings['credit'] = (isset($style_options[ 'cff_show_credit' ])) ? $style_options[ 'cff_show_credit' ] : $defaults[ 'cff_show_credit' ]; |
| 1773 | $settings['textissue'] = (isset($style_options[ 'cff_format_issue' ])) ? $style_options[ 'cff_format_issue' ] : $defaults[ 'cff_format_issue' ]; |
| 1774 | $settings['likeboxheight'] = ''; |
| 1775 | $settings['disablestyles'] = isset($style_options[ 'cff_disable_styles' ]) ? $style_options[ 'cff_disable_styles' ] : ''; |
| 1776 | |
| 1777 | $settings['cachetime'] = isset($feed_options[ 'cachetime' ]) ? $feed_options[ 'cachetime' ] : get_option( 'cff_cache_time', '1' ); |
| 1778 | $settings['cacheunit'] = isset($feed_options[ 'cacheunit' ]) ? $feed_options[ 'cacheunit' ] : get_option( 'cff_cache_time_unit', 'hours' ); |
| 1779 | |
| 1780 | $maybe_legacy_shortcode = $feed_options; |
| 1781 | if ( isset( $maybe_legacy_shortcode['feed'] ) ) { |
| 1782 | unset( $maybe_legacy_shortcode['feed'] ); |
| 1783 | } |
| 1784 | |
| 1785 | // Merge in legacy settings (shortcode only settings) |
| 1786 | if ( ! empty( $maybe_legacy_shortcode ) ) { |
| 1787 | $legacy_shortcode_settings = [ |
| 1788 | 'width', |
| 1789 | 'widthresp', |
| 1790 | 'mediaposition', |
| 1791 | 'masonryjs', |
| 1792 | 'colsjs', |
| 1793 | 'textformat', |
| 1794 | //all text weight settings |
| 1795 | 'textweight', |
| 1796 | 'descweight', |
| 1797 | 'eventtitleweight', |
| 1798 | 'eventdateweight', |
| 1799 | 'eventdetailsweight', |
| 1800 | 'dateweight', |
| 1801 | 'linkweight', |
| 1802 | 'headertextweight', |
| 1803 | 'posttags', |
| 1804 | 'linkhashtags', |
| 1805 | 'offset', |
| 1806 | 'cff_enqueue_with_shortcode', |
| 1807 | 'commentsnum', |
| 1808 | 'restrictedpage', |
| 1809 | 'hidesupporterposts', |
| 1810 | 'privategroup', |
| 1811 | 'fulllinkimages', |
| 1812 | 'linkimagesize', |
| 1813 | 'postimagesize', |
| 1814 | 'videoheight', |
| 1815 | 'videoaction', |
| 1816 | 'videoplayer', |
| 1817 | 'class', |
| 1818 | 'padding' |
| 1819 | ]; |
| 1820 | |
| 1821 | foreach ( $maybe_legacy_shortcode as $maybe_legacy => $value ) { |
| 1822 | if ( in_array( $maybe_legacy, $legacy_shortcode_settings, true ) ) { |
| 1823 | $settings[ $maybe_legacy ] = $value; |
| 1824 | } |
| 1825 | } |
| 1826 | |
| 1827 | if ( $settings['posttags'] === 'false' ) { |
| 1828 | $settings['posttags'] = false; |
| 1829 | } |
| 1830 | |
| 1831 | if ( $settings['linkhashtags'] === 'false' ) { |
| 1832 | $settings['linkhashtags'] = false; |
| 1833 | } |
| 1834 | } |
| 1835 | |
| 1836 | if ( ! CFF_Utils::cff_is_pro_version() ) { |
| 1837 | $this->page_id = $settings['id']; |
| 1838 | $this->access_token = $settings['accesstoken']; |
| 1839 | $this->feed_id = ! empty( $feed_id ) ? $feed_id : 'default'; |
| 1840 | } |
| 1841 | |
| 1842 | return \CustomFacebookFeed\Builder\CFF_Post_Set::builder_to_general_settings_convert( $settings ); |
| 1843 | } |
| 1844 | |
| 1845 | /********** |
| 1846 | * Ported from Pro version, could use cleanup |
| 1847 | * |
| 1848 | * TODO: Remove all or part of functions not needed for free |
| 1849 | *************/ |
| 1850 | |
| 1851 | /** |
| 1852 | * this where you could take the feed options to get the feed data for the first set |
| 1853 | * of posts or, if the $before and $after parameters are set, get the next set of posts |
| 1854 | * |
| 1855 | * @since 3.18 |
| 1856 | */ |
| 1857 | static function cff_get_json_data( $feed_options, $next_urls_arr_safe, $data_att_html, $is_customizer = false ) { |
| 1858 | //Define vars |
| 1859 | $access_token = $feed_options['accesstoken']; |
| 1860 | //If the 'Enter my own Access Token' box is unchecked then don't use the user's access token, even if there's one in the field |
| 1861 | $feed_options['ownaccesstoken'] ? $cff_show_access_token = true : $cff_show_access_token = true; |
| 1862 | //Reviews Access Token |
| 1863 | $page_access_token = $feed_options['pagetoken']; |
| 1864 | $cff_show_access_token = true; |
| 1865 | $page_id = trim( $feed_options['id'] ); |
| 1866 | $show_posts = isset( $feed_options['minnum'] ) ? $feed_options['minnum'] : $feed_options['num']; |
| 1867 | $show_posts_number = isset( $feed_options['minnum'] ) ? $feed_options['minnum'] : $feed_options['num']; |
| 1868 | |
| 1869 | $cff_post_limit = $feed_options['limit']; |
| 1870 | $cff_page_type = $feed_options[ 'pagetype' ]; |
| 1871 | $show_others = $feed_options['others']; |
| 1872 | $show_posts_by = $feed_options['showpostsby']; |
| 1873 | $cff_caching_type = $feed_options['cachetype']; |
| 1874 | $cff_cache_time = $feed_options['cachetime']; |
| 1875 | $cff_cache_time_unit = $feed_options['cacheunit']; |
| 1876 | $cff_locale = $feed_options['locale']; |
| 1877 | //Post types |
| 1878 | $cff_types = $feed_options['type']; |
| 1879 | $cff_events_source = $feed_options[ 'eventsource' ]; |
| 1880 | $cff_event_offset = $feed_options[ 'eventoffset' ]; |
| 1881 | $cff_albums_source = $feed_options[ 'albumsource' ]; |
| 1882 | $cff_photos_source = $feed_options[ 'photosource' ]; |
| 1883 | $cff_videos_source = $feed_options[ 'videosource' ]; |
| 1884 | //Past events |
| 1885 | $cff_past_events = $feed_options['pastevents']; |
| 1886 | //Active extensions |
| 1887 | $cff_ext_multifeed_active = $feed_options[ 'multifeedactive' ]; |
| 1888 | #$cff_ext_date_active = $feed_options[ 'daterangeactive' ]; |
| 1889 | $cff_ext_date_active = CFF_FB_Settings::check_active_extension( 'date_range' ) && CFF_Utils::check_if_on($feed_options['daterange']); |
| 1890 | |
| 1891 | $cff_featured_post_active = $feed_options[ 'featuredpostactive' ]; |
| 1892 | $cff_album_active = $feed_options[ 'albumactive' ]; |
| 1893 | $cff_masonry_columns_active = false; //Deprecated |
| 1894 | $cff_carousel_active = $feed_options[ 'carouselactive' ]; |
| 1895 | $cff_reviews_active = $feed_options[ 'reviewsactive' ]; |
| 1896 | //Extension settings |
| 1897 | $cff_album_id = $feed_options['album']; |
| 1898 | $cff_featured_post_id = $feed_options['featuredpost']; |
| 1899 | $include_extras = isset( $feed_options['include_extras'] ); |
| 1900 | |
| 1901 | //Get show posts attribute. If not set then default to 25 |
| 1902 | if (empty($show_posts)) $show_posts = 25; |
| 1903 | if ( $show_posts == 0 || $show_posts == 'undefined' ) $show_posts = 25; |
| 1904 | |
| 1905 | //Set the page type |
| 1906 | $cff_is_group = false; |
| 1907 | if ($cff_page_type == 'group') $cff_is_group = true; |
| 1908 | |
| 1909 | //Look for non-plural version of string in the types string in case user specifies singular in shortcode |
| 1910 | $cff_show_links_type = true; |
| 1911 | $cff_show_event_type = true; |
| 1912 | $cff_show_video_type = true; |
| 1913 | $cff_show_photos_type = true; |
| 1914 | $cff_show_status_type = true; |
| 1915 | $cff_show_albums_type = true; |
| 1916 | |
| 1917 | $cff_events_only = false; |
| 1918 | $cff_albums_only = false; |
| 1919 | $cff_photos_only = false; |
| 1920 | $cff_videos_only = false; |
| 1921 | |
| 1922 | //Is it SSL? |
| 1923 | $cff_ssl = ''; |
| 1924 | if (is_ssl()) $cff_ssl = '&return_ssl_resources=true'; |
| 1925 | |
| 1926 | //Use posts? or feed? |
| 1927 | $graph_query = 'posts'; |
| 1928 | $cff_show_only_others = false; |
| 1929 | |
| 1930 | //If 'others' shortcode option is used then it overrides any other option |
| 1931 | if ($show_others) { |
| 1932 | //Show posts by everyone |
| 1933 | if ( $show_others == 'on' || $show_others == 'true' || $show_others == true || $cff_is_group ) $graph_query = 'feed'; |
| 1934 | //Only show posts by me |
| 1935 | if ( $show_others == 'false' ) $graph_query = 'posts'; |
| 1936 | } else { |
| 1937 | //Else use the settings page option or the 'showpostsby' shortcode option |
| 1938 | //Only show posts by me |
| 1939 | if ( $show_posts_by == 'me' ) $graph_query = 'posts'; |
| 1940 | //Show posts by everyone |
| 1941 | if ( $show_posts_by == 'others' || $cff_is_group ) $graph_query = 'feed'; |
| 1942 | //Show posts ONLY by others |
| 1943 | if ( $show_posts_by == 'onlyothers' && !$cff_is_group ) { |
| 1944 | $graph_query = 'visitor_posts'; |
| 1945 | $cff_show_only_others = true; |
| 1946 | } |
| 1947 | } |
| 1948 | |
| 1949 | |
| 1950 | //Calculate the cache time in seconds |
| 1951 | if($cff_cache_time_unit == 'minutes') $cff_cache_time_unit = 60; |
| 1952 | if($cff_cache_time_unit == 'hour' || $cff_cache_time_unit == 'hours') $cff_cache_time_unit = 60*60; |
| 1953 | if($cff_cache_time_unit == 'days') $cff_cache_time_unit = 60*60*24; |
| 1954 | $cache_seconds = $cff_cache_time * $cff_cache_time_unit; |
| 1955 | |
| 1956 | |
| 1957 | //********************************************// |
| 1958 | //*****************GET POSTS******************// |
| 1959 | //********************************************// |
| 1960 | $FBdata_arr = array(); //Use an array to store the data for each page ID (for multifeed) |
| 1961 | $page_ids = array($page_id); |
| 1962 | |
| 1963 | |
| 1964 | //If the limit isn't set then set it to be 7 more than the number of posts defined |
| 1965 | if ( isset($cff_post_limit) && $cff_post_limit !== '' ) { |
| 1966 | $cff_post_limit = $cff_post_limit; |
| 1967 | } else { |
| 1968 | if( intval($show_posts) >= 50 ) $cff_post_limit = intval(intval($show_posts) + 7); |
| 1969 | if( intval($show_posts) < 50 ) $cff_post_limit = intval(intval($show_posts) + 5); |
| 1970 | if( intval($show_posts) < 25 ) $cff_post_limit = intval(intval($show_posts) + 4); |
| 1971 | if( intval($show_posts) < 10 ) $cff_post_limit = intval(intval($show_posts) + 3); |
| 1972 | if( intval($show_posts) < 6 ) $cff_post_limit = intval(intval($show_posts) + 2); |
| 1973 | if( intval($show_posts) < 2 ) $cff_post_limit = intval(intval($show_posts) + 1); |
| 1974 | |
| 1975 | //If using multifeed then set the limit dynamically based on the number of pages if it isn't set |
| 1976 | if( $cff_ext_multifeed_active && count($page_ids) > 1 ){ |
| 1977 | $cff_post_limit = ( ceil(intval($show_posts) / count($page_ids)) ) + 1; |
| 1978 | } |
| 1979 | } |
| 1980 | if( $cff_post_limit >= 100 ) $cff_post_limit = 100; |
| 1981 | |
| 1982 | //If the number of posts is set to zero then don't show any and set limit to one |
| 1983 | if ( ($show_posts == '0' || $show_posts == 0) && $show_posts !== ''){ |
| 1984 | $show_posts = 0; |
| 1985 | $cff_post_limit = 1; |
| 1986 | } |
| 1987 | |
| 1988 | //If the timeline pagination method is set to use the API paging method then set the limit to be the number of posts displayed so that posts aren't skipped when loading more |
| 1989 | if( $feed_options['timelinepag'] == 'paging' ) $cff_post_limit = $show_posts; |
| 1990 | |
| 1991 | |
| 1992 | //Loop through page IDs |
| 1993 | foreach ( $page_ids as $page_id ) { |
| 1994 | |
| 1995 | //********************************************// |
| 1996 | //********CREATE THE API REQUEST URL**********// |
| 1997 | //********************************************// |
| 1998 | |
| 1999 | //ALL POSTS |
| 2000 | |
| 2001 | //Add option to remove attachments description field to workaround Facebook "Unsupported Get Request" bug caused by sales posts in the API request |
| 2002 | $attachments_desc = ( $feed_options['salesposts'] == 'true' ) ? '' : ',description'; |
| 2003 | |
| 2004 | //Add option to remove story_tags to workaround Facebook "Unknown Error" message returned by API for certain posts |
| 2005 | $story_tags = ( $feed_options['storytags'] == 'true' ) ? '' : ',story_tags'; |
| 2006 | $cff_posts_json_url = 'https://graph.facebook.com/v4.0/' . $page_id . '/' . $graph_query . '?fields=id,updated_time,from{picture,id,name,link},message,message_tags,story'. $story_tags .',picture,full_picture,status_type,created_time,backdated_time,attachments{title'. $attachments_desc .',media_type,unshimmed_url,target{id},multi_share_end_card,media{source,image},subattachments},shares,call_to_action,privacy&access_token=' . $access_token . '&limit=' . $cff_post_limit . '&locale=' . $cff_locale . $cff_ssl; |
| 2007 | |
| 2008 | |
| 2009 | //********************************************// |
| 2010 | //*********CREATE THE TRANSIENT NAME**********// |
| 2011 | //********************************************// |
| 2012 | |
| 2013 | |
| 2014 | |
| 2015 | //ALL POSTS |
| 2016 | if (!$cff_events_only || ($cff_events_only && $cff_events_source == 'timeline') ){ |
| 2017 | |
| 2018 | //If it's a playlist then use the playlist ID instead of the Page ID |
| 2019 | $page_id_caching = $page_id; |
| 2020 | if( $feed_options['playlist'] ){ |
| 2021 | $page_id_caching = $feed_options['playlist']; |
| 2022 | } |
| 2023 | |
| 2024 | $trans_items_arr = array( |
| 2025 | 'page_id' => $page_id_caching, |
| 2026 | 'post_limit' => substr($cff_post_limit, 0, 3), |
| 2027 | 'show_posts_by' => substr($show_posts_by, 0, 2), |
| 2028 | 'locale' => $cff_locale |
| 2029 | ); |
| 2030 | |
| 2031 | $trans_arr_item_count = 1; |
| 2032 | if( $cff_featured_post_active && !empty($cff_featured_post_id) ){ |
| 2033 | $trans_items_arr['featured_post'] = $cff_featured_post_id; |
| 2034 | $trans_arr_item_count++; |
| 2035 | } |
| 2036 | if($cff_albums_only) $trans_items_arr['albums_source'] = $cff_albums_source; |
| 2037 | $trans_items_arr['albums_only'] = intval($cff_albums_only); |
| 2038 | $trans_items_arr['photos_only'] = intval($cff_photos_only); |
| 2039 | $trans_items_arr['videos_only'] = intval($cff_videos_only); |
| 2040 | |
| 2041 | $arr_item_max_length = floor( 28/$trans_arr_item_count ); //40 minus the 12 needed for the other 7 values shown below equals 28 |
| 2042 | $arr_item_max_length_half = floor($arr_item_max_length/2); |
| 2043 | |
| 2044 | $transient_name = 'cff_'; |
| 2045 | foreach ($trans_items_arr as $key => $value) { |
| 2046 | if($value !== false){ |
| 2047 | if( $key == 'page_id' || $key == 'featured_post' || $key == 'from' || $key == 'until' ) $transient_name .= substr($value, 0, $arr_item_max_length_half) . substr($value, $arr_item_max_length_half*-1); //-10 |
| 2048 | if( $key == 'locale' ) $transient_name .= substr($value, 0, 2); |
| 2049 | if( $key == 'post_limit' || $key == 'show_posts_by' ) $transient_name .= substr($value, 0, 3); |
| 2050 | if( $key == 'albums_only' || $key == 'photos_only' || $key == 'videos_only' || $key == 'albums_source' || $key == 'reviews' ) $transient_name .= substr($value, 0, 1); |
| 2051 | } |
| 2052 | } |
| 2053 | //Make sure it's not more than 45 chars |
| 2054 | $transient_name = substr($transient_name, 0, 45); |
| 2055 | |
| 2056 | //ALBUM EMBED |
| 2057 | if( $cff_album_active && !empty($cff_album_id) ) { |
| 2058 | $transient_name = 'cff_album_' . $cff_album_id . '_' . $cff_post_limit; |
| 2059 | $transient_name = substr($transient_name, 0, 45); |
| 2060 | } |
| 2061 | |
| 2062 | } //END ALL POSTS |
| 2063 | |
| 2064 | |
| 2065 | |
| 2066 | //Are there more posts to get for this ID? |
| 2067 | $cff_more_posts = true; |
| 2068 | |
| 2069 | //If the cron caching is enabled then set the caching time to be long so that it doesn't expire before rechecked in the cron function |
| 2070 | if( false == 'background' ) $cache_seconds = 7 * DAY_IN_SECONDS; |
| 2071 | |
| 2072 | |
| 2073 | //ALL POSTS |
| 2074 | $posts_json = CFF_Utils::cff_get_set_cache($cff_posts_json_url, $transient_name, $cff_cache_time, $cache_seconds, $data_att_html, $cff_show_access_token, $access_token, true); |
| 2075 | if( $cff_is_group ){ |
| 2076 | $groups_post = new CFF_Group_Posts($page_id, $feed_options, $cff_posts_json_url, $data_att_html, false); |
| 2077 | $groups_post_result = $groups_post->init_group_posts($posts_json, false, $show_posts_number); |
| 2078 | $posts_json = $groups_post_result['posts_json']; |
| 2079 | } |
| 2080 | //ALBUM EMBED |
| 2081 | if( $cff_album_active && !empty($cff_album_id) ) $album_json = $posts_json; |
| 2082 | |
| 2083 | //Interpret data with JSON |
| 2084 | $FBdata = json_decode($posts_json); |
| 2085 | |
| 2086 | if ( false /*$is_customizer*/ ) { |
| 2087 | //Get more data about single events since timelines don't have it |
| 2088 | $can_check_for_events = false; |
| 2089 | $event_supporting_access_tokens = array(); |
| 2090 | if ( isset( $feed_options['sources'][0] ) ) { |
| 2091 | foreach ( $feed_options['sources'] as $source ) { |
| 2092 | #if ( $source['privilege'] === 'events' ) { |
| 2093 | $can_check_for_events = true; |
| 2094 | $event_supporting_access_tokens[ $source['account_id'] ] = $source['access_token']; |
| 2095 | # } |
| 2096 | } |
| 2097 | } |
| 2098 | |
| 2099 | |
| 2100 | if ( $can_check_for_events ) { |
| 2101 | if ( isset( $FBdata->data ) ) { |
| 2102 | $post_index = 0; |
| 2103 | foreach ( $FBdata->data as $post ) { |
| 2104 | $type = CFF_Parse::get_status_type( $post ); |
| 2105 | |
| 2106 | if ( $type === 'created_event' ) { |
| 2107 | $account_id = CFF_Parse::get_from_id( $post ); |
| 2108 | $post_id = CFF_Parse::get_post_id( $post ); |
| 2109 | $event_id = explode( '_', $post_id ); |
| 2110 | $event_id = $event_id[1]; |
| 2111 | |
| 2112 | if ( ! empty( $event_supporting_access_tokens[ $account_id ] ) ) { |
| 2113 | $single_data = CFF_Shortcode::get_single_event_data( $event_id, $event_supporting_access_tokens[ $account_id ] ); |
| 2114 | foreach( $single_data as $property => $value ) { |
| 2115 | $FBdata->data[ $post_index ]->$property = $value; |
| 2116 | } |
| 2117 | |
| 2118 | } |
| 2119 | } |
| 2120 | $post_index++; |
| 2121 | } |
| 2122 | } |
| 2123 | } |
| 2124 | } |
| 2125 | |
| 2126 | |
| 2127 | if( $cff_more_posts ){ |
| 2128 | //Add the data to the array to be returned and parsed into HTML |
| 2129 | $FBdata_arr[$page_id] = $FBdata; |
| 2130 | } else { |
| 2131 | //Add something to the array for the ID if there's no posts to prevent any PHP notices |
| 2132 | $FBdata_arr[$page_id] = 'no_more_posts'; |
| 2133 | } |
| 2134 | |
| 2135 | //Add the API URL to the json array so that we can grab it and add to the button if needed |
| 2136 | if( isset($FBdata_arr[$page_id]) ){ |
| 2137 | if( !isset($FBdata_arr[$page_id]->api_url) && $FBdata_arr[$page_id] != 'no_more_posts' ){ |
| 2138 | //Replace the actual token with the Access Token placeholder |
| 2139 | $cff_api_url = str_replace($access_token,"x_cff_hide_token_x",$cff_posts_json_url); |
| 2140 | //Add it to the json array |
| 2141 | $FBdata_arr[$page_id]->api_url = $cff_api_url; |
| 2142 | } |
| 2143 | } |
| 2144 | |
| 2145 | } //End page_id loop |
| 2146 | |
| 2147 | if($cff_is_group && isset($FBdata_arr[$page_id]) && $FBdata_arr[$page_id] != 'no_more_posts'){ |
| 2148 | $FBdata_arr[$page_id]->is_load_cache = (isset($groups_post_result['latest_record_date'])) && $groups_post_result['latest_record_date'] !== 0 && $groups_post_result['load_from_cache'] !== false ? $groups_post_result['load_from_cache'] : false; |
| 2149 | $FBdata_arr[$page_id]->latest_record_date = $groups_post_result['latest_record_date']; |
| 2150 | } |
| 2151 | return $FBdata_arr; |
| 2152 | } |
| 2153 | |
| 2154 | /** |
| 2155 | * this function breaks up the "next" url from the json data into an array of parts to load into |
| 2156 | * the html to be retrieved on click and pieced back together |
| 2157 | * |
| 2158 | * @since 3.18 |
| 2159 | */ |
| 2160 | static function cff_get_next_url_parts( $json_data_arr ) { |
| 2161 | $next_urls_arr_safe = '{'; |
| 2162 | $next_urls_arr_safe .= '}'; |
| 2163 | //If the array ends in a comma then remove the comma |
| 2164 | return $next_urls_arr_safe; |
| 2165 | } |
| 2166 | |
| 2167 | public static function get_single_event_data( $eventID, $access_token ) { |
| 2168 | //Is it SSL? |
| 2169 | $cff_ssl = ''; |
| 2170 | if (is_ssl()) $cff_ssl = '&return_ssl_resources=true'; |
| 2171 | |
| 2172 | //Get the contents of the event |
| 2173 | $event_json_url = 'https://graph.facebook.com/v3.3/'.$eventID.'?fields=cover,place,name,owner,start_time,timezone,id,comments.summary(true){message,created_time},description&access_token=' . $access_token . $cff_ssl; |
| 2174 | |
| 2175 | // Get any existing copy of our transient data |
| 2176 | $transient_name = 'cff_tle_' . $eventID; |
| 2177 | $transient_name = substr($transient_name, 0, 45); |
| 2178 | |
| 2179 | if ( false === ( $event_json = get_transient( $transient_name ) ) || $event_json === null ) { |
| 2180 | //Get the contents of the Facebook page |
| 2181 | $event_json = CFF_Utils::cff_fetchUrl($event_json_url); |
| 2182 | //Cache the JSON for 180 days as the timeline event info probably isn't going to change |
| 2183 | set_transient( $transient_name, $event_json, 60 * 60 * 24 * 180 ); |
| 2184 | } else { |
| 2185 | $event_json = get_transient( $transient_name ); |
| 2186 | //If we can't find the transient then fall back to just getting the json from the api |
| 2187 | if ($event_json == false) $event_json = CFF_Utils::cff_fetchUrl($event_json_url); |
| 2188 | } |
| 2189 | |
| 2190 | //Interpret data with JSON |
| 2191 | $event_object = json_decode($event_json); |
| 2192 | |
| 2193 | $description_text = ''; |
| 2194 | if( isset($event_object->name) ) $description_text .= $event_object->name . ' '; |
| 2195 | if( isset($event_object->place->location->city) ) $description_text .= $event_object->place->location->city . ' '; |
| 2196 | if( isset($event_object->place->location->country) ) $description_text .= $event_object->place->location->country . ' '; |
| 2197 | if( isset($event_object->place->location->street) ) $description_text .= $event_object->place->location->street . ' '; |
| 2198 | if( isset($event_object->place->name) ) $description_text .= $event_object->place->name . ' '; |
| 2199 | if( isset($event_object->description) ) $description_text .= $event_object->description; |
| 2200 | $event_object->description_text = $description_text; |
| 2201 | |
| 2202 | return $event_object; |
| 2203 | |
| 2204 | } |
| 2205 | |
| 2206 | public static function add_translations( $atts ) { |
| 2207 | $translations = get_option( 'cff_style_settings', false ); |
| 2208 | |
| 2209 | $final_translations = [ |
| 2210 | 'seemoretext' => isset( $translations[ 'cff_see_more_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_see_more_text' ] ) ) : __( 'See More', 'custom-facebook-feed' ), |
| 2211 | 'seelesstext' => isset( $translations[ 'cff_see_less_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_see_less_text' ] ) ) : __( 'See Less', 'custom-facebook-feed' ), |
| 2212 | 'facebooklinktext' => isset( $translations[ 'cff_facebook_link_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_facebook_link_text' ] ) ) : __( 'View on Facebook', 'custom-facebook-feed' ), |
| 2213 | 'sharelinktext' => isset( $translations[ 'cff_facebook_share_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_facebook_share_text' ] ) ) : __( 'Share', 'custom-facebook-feed' ), |
| 2214 | |
| 2215 | 'learnmoretext' => isset( $translations[ 'cff_translate_learn_more_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_learn_more_text' ] ) ) : __( 'Learn More', 'custom-facebook-feed' ), |
| 2216 | 'shopnowtext' => isset( $translations[ 'cff_translate_shop_now_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_shop_now_text' ] ) ) : __( 'Shop Now', 'custom-facebook-feed' ), |
| 2217 | 'messagepage' => isset( $translations[ 'cff_translate_message_page_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_message_page_text' ] ) ) : __( 'Message Page', 'custom-facebook-feed' ), |
| 2218 | 'getdirections' => isset( $translations[ 'cff_translate_get_directions_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_get_directions_text' ] ) ) : __( 'Get Directions', 'custom-facebook-feed' ), |
| 2219 | |
| 2220 | 'secondtext' => isset( $translations[ 'cff_translate_second' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_second' ] ) ) : 'second', |
| 2221 | 'secondstext' => isset( $translations[ 'cff_translate_seconds' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_seconds' ] ) ) : 'seconds', |
| 2222 | 'minutetext' => isset( $translations[ 'cff_translate_minute' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_minute' ] ) ) : 'minute', |
| 2223 | 'minutestext' => isset( $translations[ 'cff_translate_minutes' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_minutes' ] ) ) : 'minutes', |
| 2224 | 'hourtext' => isset( $translations[ 'cff_translate_hour' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_hour' ] ) ) : 'hour', |
| 2225 | 'hourstext' => isset( $translations[ 'cff_translate_hours' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_hours' ] ) ) : 'hours', |
| 2226 | 'daytext' => isset( $translations[ 'cff_translate_day' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_day' ] ) ) : 'day', |
| 2227 | 'daystext' => isset( $translations[ 'cff_translate_days' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_days' ] ) ) : 'days', |
| 2228 | 'weektext' => isset( $translations[ 'cff_translate_week' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_week' ] ) ) : 'week', |
| 2229 | 'weekstext' => isset( $translations[ 'cff_translate_weeks' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_weeks' ] ) ) : 'weeks', |
| 2230 | 'monthtext' => isset( $translations[ 'cff_translate_month' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_month' ] ) ) : 'month', |
| 2231 | 'monthstext' => isset( $translations[ 'cff_translate_months' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_months' ] ) ) : 'months', |
| 2232 | 'yeartext' => isset( $translations[ 'cff_translate_year' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_year' ] ) ) : 'year', |
| 2233 | 'yearstext' => isset( $translations[ 'cff_translate_years' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_years' ] ) ) : 'years', |
| 2234 | 'agotext' => isset( $translations[ 'cff_translate_ago' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_ago' ] ) ) : 'ago', |
| 2235 | |
| 2236 | 'phototext' => isset( $translations[ 'cff_translate_photo_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_photo_text' ] ) ) : '', |
| 2237 | 'videotext' => isset( $translations[ 'cff_translate_video_text' ] ) ? stripslashes( esc_attr( $translations[ 'cff_translate_video_text' ] ) ) : '', |
| 2238 | ]; |
| 2239 | |
| 2240 | |
| 2241 | $final_translations['facebooklinktext'] = ! empty( $atts['facebooklinktext'] ) ? $atts['facebooklinktext'] : $final_translations['facebooklinktext']; |
| 2242 | $final_translations['sharelinktext'] = ! empty( $atts['sharelinktext'] ) ? $atts['sharelinktext'] : $final_translations['sharelinktext']; |
| 2243 | |
| 2244 | $atts = array_merge( $atts, $final_translations ); |
| 2245 | |
| 2246 | return $atts; |
| 2247 | |
| 2248 | } |
| 2249 | |
| 2250 | function cff_add_translations() { |
| 2251 | $this->atts = CFF_Shortcode::add_translations( $this->atts ); |
| 2252 | } |
| 2253 | |
| 2254 | |
| 2255 | } |