<?php

/*
* Stop execution if someone tried to get file directly.
*/
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
if ( $is_album_feed ) {
} else {
    $efbl_ver = 'free';
    $efbl_status_col_content = '12';
    if ( efl_fs()->is_plan( 'facebook_premium', true ) or efl_fs()->is_plan( 'combo_premium', true ) ) {
        $efbl_ver = 'pro';
    }
    $efbl_free_popup_type = 'data-imagelink=' . $feed_img . '';
    $efbl_free_popup_class = null;
    if ( 'added_video' == $feed_type && !empty( $video_source ) ) {
        $efbl_free_popup_type = 'data-video=' . $video_source . '';
        $efbl_free_popup_class = 'efbl_popup_video';
    }
    if ( isset( $story->attachments->data[0]->type ) && $story->attachments->data[0]->type == 'video_inline' && isset( $story->attachments->data[0]->url ) && 'added_video' !== $feed_type ) {
        $video_source = 'https://www.facebook.com/v2.3/plugins/video.php?href=' . $story->attachments->data[0]->url;
        $efbl_free_popup_type = 'data-videolink=' . $video_source . '';
        $efbl_free_popup_class = 'efbl_popup_video';
    }
    ?>

<div class="efbl-thumbnail-skin <?php 
    esc_attr_e( $feed_type );
    ?> efbl-story-wrapper">

	<div class="efbl-thumbnail-wrapper">
		<div class="efbl-row">

			<?php 
    if ( $feed_type == 'mobile_status_update' ) {
        $efbl_status_col_img = 12;
        ?>

				<?php 
        if ( isset( $story->attachments->data[0]->media->image->src ) ) {
            $efbl_status_col_img = 4;
            $efbl_status_col_content = 8;
            ?>
					<div class="efbl-col-<?php 
            esc_attr_e( $efbl_status_col_img );
            ?> efbl-thumbnail-col">

						<?php 
            if ( efl_fs()->is_free_plan() || efl_fs()->is_plan( 'instagram_premium', true ) ) {
                ?>

							<a href="<?php 
                echo admin_url( 'admin-ajax.php' );
                ?>?action=efbl_generate_popup_html" <?php 
                echo esc_attr_e( $efbl_free_popup_type );
                ?>
							   data-storylink="<?php 
                echo esc_url( $story_link );
                ?>"
							   rel="nofollow"
							   data-linktext="<?php 
                echo esc_attr( __( esf_get_translated_string( 'read_full_story' ), 'easy-facebook-likebox' ) );
                ?>"
							   data-caption="<?php 
                // Sanitize post_text to prevent XSS while preserving safe HTML
                $sanitized_caption = $this->esf_sanitize_content( $post_text );
                echo esc_attr( $sanitized_caption );
                ?>"
							   data-itemnumber="<?php 
                esc_attr_e( $pi );
                ?>"
							   class="efbl_feed_popup <?php 
                esc_attr_e( $efbl_free_popup_class );
                ?> efbl-cff-item_number-<?php 
                esc_attr_e( $pi );
                ?>">
								<div class="efbl-overlay">

									<?php 
                if ( $efbl_skin_values['design']['show_feed_open_popup_icon'] ) {
                    ?>

										<i class="icon icon-esf-plus efbl-plus"
										   aria-hidden="true"></i>

									<?php 
                }
                ?>
									<?php 
                if ( $feed_type == 'added_video' || $feed_attachment_type == 'video_inline' ) {
                    ?>
										<i class="icon icon-esf-clone icon-esf-video-camera"
										   aria-hidden="true"></i>
										<?php 
                }
                if ( isset( $story->attachments->data['0']->subattachments->data ) && !empty( $story->attachments->data['0']->subattachments->data ) ) {
                    ?>
										<i class="icon icon-esf-clone efbl_multimedia"
										   aria-hidden="true"></i>
									<?php 
                }
                ?>
								</div>
								<?php 
                $thumb_img_src = $story->attachments->data[0]->media->image->src;
                $thumb_img_class = '';
                $thumb_img_attr = '';
                if ( !empty( $gdpr_active ) && !empty( $thumb_img_src ) && !esf_is_local_media_url( $thumb_img_src, 'facebook' ) ) {
                    $thumb_img_attr = ' data-image-url="' . esc_url( $thumb_img_src ) . '"';
                    $thumb_img_src = ESF_GDPR_Integrations::get_placeholder_image();
                    $thumb_img_class = 'esf-no-consent';
                }
                ?>
								<img alt="<?php 
                esc_attr_e( $story_name );
                ?>"
									 src="<?php 
                echo esc_url( $thumb_img_src );
                ?>"
									 class="<?php 
                echo esc_attr( $thumb_img_class );
                ?>"
									 <?php 
                echo $thumb_img_attr;
                ?>/>
								<div class="efbl-overlay">


									<?php 
                if ( $efbl_skin_values['design']['show_feed_open_popup_icon'] ) {
                    ?>

										<i class="icon icon-esf-plus efbl-plus"
										   aria-hidden="true"></i>

										<?php 
                }
                ?>
									<?php 
                if ( $feed_type == 'added_video' ) {
                    ?>
										<i class="icon icon-esf-clone icon-esf-video-camera"
										   aria-hidden="true"></i>
										<?php 
                }
                if ( isset( $story->attachments->data['0']->subattachments->data ) && !empty( $story->attachments->data['0']->subattachments->data ) ) {
                    ?>
										<i class="icon icon-esf-clone efbl_multimedia"
										   aria-hidden="true"></i>
										<?php 
                }
                ?>
								</div>
							</a>

						<?php 
            }
            ?>

					</div>
				<?php 
        }
        ?>


				<div class="efbl-feed-content efbl-col-<?php 
        esc_attr_e( $efbl_status_col_content );
        ?>  ">

					<?php 
        if ( $efbl_skin_values['design']['feed_header'] ) {
            ?>

						<div class="efbl-d-flex">

							<?php 
            if ( $auth_img_src && $efbl_skin_values['design']['feed_header_logo'] ) {
                ?>

								<div class="efbl-profile-image">
									<a href="https://facebook.com/<?php 
                esc_attr_e( $page_id );
                ?>"
									   title="<?php 
                esc_attr_e( $story_name );
                ?>"
									   rel="nofollow"
									   target="<?php 
                esc_attr_e( $link_target );
                ?>">
										<img alt="<?php 
                esc_attr_e( $story_name );
                ?>"
											 src="<?php 
                echo esc_url( $auth_img_src );
                ?>"/></a>
								</div>

							<?php 
            }
            ?>

							<div class="efbl-profile-title">
								<div class="efbl-profile-title-wrap <?php 
            esc_attr_e( $efbl_no_story_name );
            ?>">
									<h2><?php 
            esc_html_e( $story_from_name );
            ?>
										<?php 
            if ( isset( $efbl_bio_data->verification_status ) && $efbl_bio_data->verification_status == 'blue_verified' ) {
                ?>
											<div class="efbl-verified-status">
												<i class="icon icon-esf-check"
												   aria-hidden="true"></i>
											</div>
										<?php 
            }
            ?>
										<span class="efbl-profile-story-text"><?php 
            esc_html_e( $story_text );
            ?> </span>
									</h2>
								</div>
								<span><?php 
            esc_html_e( $time );
            ?></span>
							</div>
						</div>

					<?php 
        }
        ?>


					<?php 
        if ( isset( $story->attachments->data[0] ) ) {
            ?>

						<div class="efbl_link_text">

							<p class="efbl_title_link">
								<a href="<?php 
            echo esc_url( $story_link );
            ?>"
								   rel="nofollow"
								   target="<?php 
            esc_attr_e( $link_target );
            ?>">
									<?php 
            esc_html_e( $story->attachments->data['0']->title );
            ?>
								</a>
							</p>
						</div>

						<?php 
            if ( $post_text ) {
                ?>
							<?php 
                if ( $efbl_skin_values['design']['show_feed_caption'] ) {
                    ?>
								<p class="description">
									<span class="efbl-description-wrap"><?php 
                    echo wp_kses_post( nl2br( $post_text ) );
                    ?></span>


									<?php 
                    ?>


								</p>

							<?php 
                }
                ?>
						<?php 
            }
            ?>

					<?php 
        } else {
            ?>
						<?php 
            if ( $efbl_skin_values['design']['show_feed_caption'] ) {
                ?>
							<p class="description">
								<span class="efbl-description-wrap"><?php 
                echo wp_kses_post( nl2br( $post_text ) );
                ?></span>


								<?php 
                ?>


							</p>

						<?php 
            }
            ?>

					<?php 
        }
        ?>

				</div>

				<?php 
    }
    if ( $feed_type == 'shared_story' ) {
        $efbl_shared_img_col = 12;
        if ( !isset( $shared_src ) || empty( $shared_src ) ) {
            if ( isset( $story->full_picture ) ) {
                $shared_src = $story->full_picture;
            } else {
                $shared_src = '';
            }
        }
        $shared_src = $story->attachments->data['0']->media->image->src;
        ?>


				<?php 
        if ( $story->full_picture ) {
            $efbl_shared_img_col = 8;
            ?>

				<div class="efbl-col-4 efbl-thumbnail-col">

					<?php 
            if ( efl_fs()->is_free_plan() || efl_fs()->is_plan( 'instagram_premium', true ) ) {
                ?>

					<?php 
                $thumb_img_src = $story->full_picture;
                $thumb_img_class = '';
                $thumb_img_attr = '';
                if ( !empty( $gdpr_active ) && !empty( $thumb_img_src ) && !esf_is_local_media_url( $thumb_img_src, 'facebook' ) ) {
                    $thumb_img_attr = ' data-image-url="' . esc_url( $thumb_img_src ) . '"';
                    $thumb_img_src = ESF_GDPR_Integrations::get_placeholder_image();
                    $thumb_img_class = 'esf-no-consent';
                }
                ?>
					<a href="<?php 
                echo esc_url( $story->attachments->data['0']->url );
                ?>"
					   class="efbl_link_image" rel="nofollow"
					   target="<?php 
                esc_attr_e( $link_target );
                ?>"><img
								alt="<?php 
                esc_attr_e( $story_name );
                ?>"
								src="<?php 
                echo esc_url( $thumb_img_src );
                ?>"
								class="<?php 
                echo esc_attr( $thumb_img_class );
                ?>"
								<?php 
                echo $thumb_img_attr;
                ?>/>

						<?php 
            }
            ?>

				</div>
			<?php 
        }
        ?>

				<div class="efbl-feed-content efbl-col-<?php 
        esc_attr_e( $efbl_shared_img_col );
        ?>">

					<?php 
        if ( $efbl_skin_values['design']['feed_header'] ) {
            ?>

						<div class="efbl-d-flex">

							<?php 
            if ( $auth_img_src && $efbl_skin_values['design']['feed_header_logo'] ) {
                ?>

								<div class="efbl-profile-image">
									<a href="https://facebook.com/<?php 
                esc_attr_e( $page_id );
                ?>"
									   title="<?php 
                esc_attr_e( $story_name );
                ?>"
									   rel="nofollow"
									   target="<?php 
                esc_attr_e( $link_target );
                ?>">
										<img alt="<?php 
                esc_attr_e( $story_name );
                ?>"
											 src="<?php 
                echo esc_url( $auth_img_src );
                ?>"/></a>
								</div>

							<?php 
            }
            ?>

							<div class="efbl-profile-title">
								<div class="efbl-profile-title-wrap <?php 
            esc_attr_e( $efbl_no_story_name );
            ?>">
									<h2><?php 
            esc_html_e( $story_from_name );
            ?>
										<?php 
            if ( isset( $efbl_bio_data->verification_status ) && $efbl_bio_data->verification_status == 'blue_verified' ) {
                ?>
											<div class="efbl-verified-status">
												<i class="icon icon-esf-check"
												   aria-hidden="true"></i>
											</div>
										<?php 
            }
            ?>
										<span class="efbl-profile-story-text"><?php 
            esc_html_e( $story_text );
            ?> </span>
									</h2>
								</div>
								<span><?php 
            esc_html_e( $time );
            ?></span>
							</div>
						</div>

					<?php 
        }
        ?>


					<?php 
        if ( $post_text ) {
            ?>
						<?php 
            if ( $efbl_skin_values['design']['show_feed_caption'] ) {
                ?>
							<p class="description">
								<span class="efbl-description-wrap"><?php 
                echo wp_kses_post( nl2br( $post_text ) );
                ?></span>


								<?php 
                ?>


							</p>

						<?php 
            }
            ?>

					<?php 
        }
        ?>

					<div class="efbl_link_text">

						<p class="efbl_title_link">
							<a href="<?php 
        echo esc_url( $story->attachments->data['0']->url );
        ?>"
							   target="<?php 
        esc_attr_e( $link_target );
        ?>" rel="nofollow">
								<?php 
        esc_html_e( $story->attachments->data['0']->title );
        ?>
							</a>
						</p>
						<?php 
        if ( $efbl_skin_values['design']['show_feed_caption'] ) {
            ?>
							<p class="efbl_link_description"><?php 
            esc_html_e( $story->attachments->data['0']->description );
            ?></p>
						<?php 
        }
        ?>
					</div>


				</div>

				<?php 
    }
    if ( $feed_type == 'added_photos' || $feed_type == 'added_video' || $filter == 'images' || $filter == 'albums' ) {
        ?>


				<div class="efbl-thumbnail-col efbl-col-4">

					<?php 
        if ( efl_fs()->is_free_plan() || efl_fs()->is_plan( 'instagram_premium', true ) ) {
            ?>

						<a href="<?php 
            echo admin_url( 'admin-ajax.php' );
            ?>?action=efbl_generate_popup_html" <?php 
            echo esc_attr_e( $efbl_free_popup_type );
            ?>
						   data-storylink="<?php 
            echo esc_url( $story_link );
            ?>"
						   rel="nofollow"
						   data-linktext="<?php 
            echo esc_attr( __( esf_get_translated_string( 'read_full_story' ), 'easy-facebook-likebox' ) );
            ?>"
						   data-caption="<?php 
            // Sanitize post_text to prevent XSS while preserving safe HTML
            $sanitized_caption = $this->esf_sanitize_content( $post_text );
            echo esc_attr( $sanitized_caption );
            ?>"
						   data-itemnumber="<?php 
            esc_attr_e( $pi );
            ?>"
						   class="efbl_feed_popup <?php 
            esc_attr_e( $efbl_free_popup_class );
            ?> efbl-cff-item_number-<?php 
            esc_attr_e( $pi );
            ?>">
							<div class="efbl-overlay">

								<?php 
            if ( $efbl_skin_values['design']['show_feed_open_popup_icon'] ) {
                ?>

									<i class="icon icon-esf-plus efbl-plus"
									   aria-hidden="true"></i>

								<?php 
            }
            ?>
								<?php 
            if ( $feed_type == 'added_video' || $feed_attachment_type == 'video_inline' ) {
                ?>
									<i class="icon icon-esf-clone icon-esf-video-camera"
									   aria-hidden="true"></i>
									<?php 
            }
            if ( isset( $story->attachments->data['0']->subattachments->data ) && !empty( $story->attachments->data['0']->subattachments->data ) ) {
                ?>
									<i class="icon icon-esf-clone efbl_multimedia"
									   aria-hidden="true"></i>
								<?php 
            }
            ?>
							</div>
							<?php 
            $thumb_img_src = $feed_img;
            $thumb_img_class = 'img-responsive';
            $thumb_img_attr = '';
            if ( !empty( $gdpr_active ) && !empty( $thumb_img_src ) && !esf_is_local_media_url( $thumb_img_src, 'facebook' ) ) {
                $thumb_img_attr = ' data-image-url="' . esc_url( $thumb_img_src ) . '"';
                $thumb_img_src = ESF_GDPR_Integrations::get_placeholder_image();
                $thumb_img_class .= ' esf-no-consent';
            }
            ?>
							<img src="<?php 
            echo esc_url( $thumb_img_src );
            ?>"
								 class="<?php 
            echo esc_attr( $thumb_img_class );
            ?>"
								 alt="<?php 
            esc_attr_e( $story_from_name );
            ?>"
								 <?php 
            echo $thumb_img_attr;
            ?>/>
						</a>

					<?php 
        }
        ?>


				</div>

				<div class="efbl-feed-content efbl-col-8  ">

					<?php 
        if ( $efbl_skin_values['design']['feed_header'] ) {
            ?>

						<div class="efbl-d-flex">

							<?php 
            if ( $auth_img_src && $efbl_skin_values['design']['feed_header_logo'] ) {
                ?>

								<div class="efbl-profile-image">
									<a href="https://facebook.com/<?php 
                esc_attr_e( $page_id );
                ?>"
									   title="<?php 
                esc_attr_e( $story_name );
                ?>"
									   rel="nofollow"
									   target="<?php 
                esc_attr_e( $link_target );
                ?>">
										<img alt="<?php 
                esc_attr_e( $story_name );
                ?>"
											 src="<?php 
                echo esc_url( $auth_img_src );
                ?>"/></a>
								</div>

							<?php 
            }
            ?>

							<div class="efbl-profile-title">
								<div class="efbl-profile-title-wrap <?php 
            esc_attr_e( $efbl_no_story_name );
            ?>">
									<h2><?php 
            esc_html_e( $story_from_name );
            ?>
										<?php 
            if ( isset( $efbl_bio_data->verification_status ) && $efbl_bio_data->verification_status == 'blue_verified' ) {
                ?>
											<div class="efbl-verified-status">
												<i class="icon icon-esf-check"
												   aria-hidden="true"></i>
											</div>
										<?php 
            }
            ?>
										<span class="efbl-profile-story-text"><?php 
            esc_html_e( $story_text );
            ?> </span>
									</h2>
								</div>
								<span><?php 
            esc_html_e( $time );
            ?></span>
							</div>
						</div>

					<?php 
        }
        ?>


					<?php 
        if ( $filter == 'videos' ) {
            ?>

						<div class="efbl_videos_data_holder">
							<h6 class="efbl_videos_title">
								<a href="https://www.facebook.com<?php 
            echo esc_url( $story->permalink_url );
            ?>"
								   rel="nofollow"
								   target="<?php 
            esc_attr_e( $link_target );
            ?>">
									<?php 
            esc_html_e( $story_title );
            ?>
								</a>
							</h6>
						</div>

					<?php 
        }
        ?>

					<?php 
        if ( $post_text ) {
            ?>
						<?php 
            if ( $efbl_skin_values['design']['show_feed_caption'] ) {
                ?>
							<p class="description">
								<span class="efbl-description-wrap"><?php 
                echo wp_kses_post( nl2br( $post_text ) );
                ?></span>


								<?php 
                ?>


							</p>

						<?php 
            }
            ?>
					<?php 
        }
        ?>

					<?php 
        if ( $filter == 'albums' ) {
            ?>

						<div class="efbl_albums_data_holder">

							<h6 class="efbl_albums_title">
								<a href="<?php 
            echo esc_url( $story->link );
            ?>"
								   rel="nofollow"
								   target="<?php 
            esc_attr_e( $link_target );
            ?>">
									<?php 
            esc_html_e( $story_name );
            ?>
								</a>
							</h6>

							<div class="efbl-total-album-images">
								<span class="efbl_albums_icon"><i
											class="icon icon-esf-picture-o"
											aria-hidden="true"></i></span>
								<span class="efbl_albums_count"><?php 
            esc_html_e( $story->count );
            ?> </span>
							</div>

						</div>

					<?php 
        }
        ?>

				</div>
				<?php 
    }
    if ( $feed_type == 'created_event' || $filter == 'events' ) {
        // premium condition
        ?>

				<?php 
        if ( efl_fs()->is_free_plan() || efl_fs()->is_plan( 'instagram_premium', true ) ) {
            ?>

					<?php 
            if ( $story->attachments->data[0]->media->image->src ) {
                ?>
					<?php 
                $thumb_img_src = $story->attachments->data[0]->media->image->src;
                $thumb_img_class = '';
                $thumb_img_attr = '';
                if ( !empty( $gdpr_active ) && !empty( $thumb_img_src ) && !esf_is_local_media_url( $thumb_img_src, 'facebook' ) ) {
                    $thumb_img_attr = ' data-image-url="' . esc_url( $thumb_img_src ) . '"';
                    $thumb_img_src = ESF_GDPR_Integrations::get_placeholder_image();
                    $thumb_img_class = 'esf-no-consent';
                }
                ?>
					<div class="efbl-col-4">

						<img src="<?php 
                echo esc_url( $thumb_img_src );
                ?>"
							 class="<?php 
                echo esc_attr( $thumb_img_class );
                ?>"
							 <?php 
                echo $thumb_img_attr;
                ?>/>

					</div>
				<?php 
            }
            ?>

				<div class="efbl-feed-content efbl-col-8  ">

					<?php 
            if ( $efbl_skin_values['design']['feed_header'] ) {
                ?>

						<div class="efbl-d-flex">

							<?php 
                if ( $auth_img_src && $efbl_skin_values['design']['feed_header_logo'] ) {
                    ?>

								<div class="efbl-profile-image">
									<a href="https://facebook.com/<?php 
                    esc_attr_e( $page_id );
                    ?>"
									   rel="nofollow"
									   title="<?php 
                    esc_attr_e( $story_name );
                    ?>"
									   target="<?php 
                    esc_attr_e( $link_target );
                    ?>">
										<img alt="<?php 
                    esc_attr_e( $story_name );
                    ?>"
											 src="<?php 
                    echo esc_url( $auth_img_src );
                    ?>"/></a>
								</div>

							<?php 
                }
                ?>

							<div class="efbl-profile-title">
								<div class="efbl-profile-title-wrap <?php 
                esc_attr_e( $efbl_no_story_name );
                ?>">
									<h2><?php 
                esc_html_e( $story_from_name );
                ?>
										<?php 
                if ( isset( $efbl_bio_data->verification_status ) && $efbl_bio_data->verification_status == 'blue_verified' ) {
                    ?>
											<div class="efbl-verified-status">
												<i class="icon icon-esf-check"
												   aria-hidden="true"></i>
											</div>
										<?php 
                }
                ?>
										<span class="efbl-profile-story-text"><?php 
                esc_html_e( $story_text );
                ?> </span>
									</h2>
								</div>
								<span><?php 
                esc_html_e( $time );
                ?></span>
							</div>
						</div>

					<?php 
            }
            ?>
					<?php 
            if ( $efbl_skin_values['design']['show_feed_caption'] ) {
                ?>
						<p class="efbl_link_description"><?php 
                esc_html_e( $post_text );
                ?></p>
					<?php 
            }
            ?>

				</div>

			<?php 
        }
        ?>


			<?php 
    }
    // events conditon
    ?>


		</div>
		<?php 
    if ( $esf_feed_meta_url = locate_template( array('easy-facebook-likebox/html-feed-meta.php') ) ) {
        $esf_feed_meta_url = $esf_feed_meta_url;
    } else {
        $esf_feed_meta_url = EFBL_PLUGIN_DIR . 'frontend/views/html-feed-meta.php';
    }
    include $esf_feed_meta_url;
    ?>
	</div>

</div>

<?php 
}