<?php

if ( !function_exists( 'efbl_resolve_skin_id' ) ) {
    /**
     * Resolve a Facebook skin ID to one that is guaranteed to exist in
     * $GLOBALS['efbl_skins']. Provides graceful fallback so that feeds
     * referencing a deleted/missing skin still render.
     *
     * Resolution order:
     *   1. Requested ID, if present in the global.
     *   2. Another existing skin sharing the same layout (looked up via
     *      the layout post meta of the requested ID).
     *   3. The plugin's canonical default_skin_id from fta_settings.
     *   4. Any available skin in the global (first one).
     *   5. 0 if no skin is available at all.
     *
     * @param int|string $requested_id The skin ID coming from a shortcode,
     *                                 widget, block, or AJAX call.
     * @return int A valid skin ID that exists in $GLOBALS['efbl_skins'],
     *             or 0 if the install has no skins at all.
     */
    function efbl_resolve_skin_id(  $requested_id  ) {
        global $efbl_skins;
        $requested_id = (int) $requested_id;
        // Happy path: the requested skin exists.
        if ( $requested_id && is_array( $efbl_skins ) && isset( $efbl_skins[$requested_id] ) ) {
            return $requested_id;
        }
        if ( !is_array( $efbl_skins ) || empty( $efbl_skins ) ) {
            return 0;
        }
        // Fallback 1: try to find another skin that uses the same layout
        // as the missing one (if we can still figure out the layout from
        // post meta of the deleted/orphaned post).
        if ( $requested_id ) {
            $layout = get_post_meta( $requested_id, 'layout', true );
            if ( $layout ) {
                foreach ( $efbl_skins as $skin_id => $skin_data ) {
                    if ( isset( $skin_data['layout'] ) && $skin_data['layout'] === $layout ) {
                        return (int) $skin_id;
                    }
                }
            }
        }
        // Fallback 2: the canonical default skin from settings.
        $fta_settings = get_option( 'fta_settings', array() );
        if ( !empty( $fta_settings['plugins']['facebook']['default_skin_id'] ) ) {
            $default_id = (int) $fta_settings['plugins']['facebook']['default_skin_id'];
            if ( isset( $efbl_skins[$default_id] ) ) {
                return $default_id;
            }
        }
        // Fallback 3: just return the first available skin.
        reset( $efbl_skins );
        $first_key = key( $efbl_skins );
        return ( $first_key ? (int) $first_key : 0 );
    }

}
if ( !function_exists( 'efbl_time_ago' ) ) {
    function efbl_time_ago(  $date, $granularity = 2  ) {
        $date_timestamp = strtotime( $date );
        /**
         * Filter the readable time format for Facebook posts
         *
         * Allows developers to customize the time display format.
         * By default, it shows relative time like "2 weeks ago".
         * Use this filter to display custom formats like "Nov. 10, 2025".
         *
         * When this filter returns a non-null value, the default relative time
         * calculation is skipped entirely for better performance.
         *
         * @since 6.3.8
         *
         * @param null|string $custom_time   Return custom formatted time or null to use default
         * @param int         $date_timestamp The original date timestamp
         * @param int         $granularity    The granularity level for time calculation
         *
         * @example
         * add_filter( 'efbl_time_ago', function( $custom_time, $date_timestamp, $granularity ) {
         *     return date_i18n( 'M. j, Y', $date_timestamp );
         * }, 10, 3 );
         */
        $custom_time = apply_filters(
            'efbl_time_ago',
            null,
            $date_timestamp,
            $granularity
        );
        // If custom format is provided, return it immediately without processing
        if ( null !== $custom_time ) {
            return $custom_time;
        }
        // Default relative time calculation
        $retval = '';
        //Preparing strings to translate
        $date_time_strings = array(
            'second'  => __( esf_get_translated_string( 'second' ), 'easy-facebook-likebox' ),
            'seconds' => __( esf_get_translated_string( 'seconds' ), 'easy-facebook-likebox' ),
            'minute'  => __( esf_get_translated_string( 'minute' ), 'easy-facebook-likebox' ),
            'minutes' => __( esf_get_translated_string( 'minutes' ), 'easy-facebook-likebox' ),
            'hour'    => __( esf_get_translated_string( 'hour' ), 'easy-facebook-likebox' ),
            'hours'   => __( esf_get_translated_string( 'hours' ), 'easy-facebook-likebox' ),
            'day'     => __( esf_get_translated_string( 'day' ), 'easy-facebook-likebox' ),
            'days'    => __( esf_get_translated_string( 'days' ), 'easy-facebook-likebox' ),
            'week'    => __( esf_get_translated_string( 'week' ), 'easy-facebook-likebox' ),
            'weeks'   => __( esf_get_translated_string( 'weeks' ), 'easy-facebook-likebox' ),
            'month'   => __( esf_get_translated_string( 'month' ), 'easy-facebook-likebox' ),
            'months'  => __( esf_get_translated_string( 'months' ), 'easy-facebook-likebox' ),
            'year'    => __( esf_get_translated_string( 'year' ), 'easy-facebook-likebox' ),
            'years'   => __( esf_get_translated_string( 'years' ), 'easy-facebook-likebox' ),
            'decade'  => __( esf_get_translated_string( 'decade' ), 'easy-facebook-likebox' ),
        );
        $ago_text = __( esf_get_translated_string( 'ago' ), 'easy-facebook-likebox' );
        $difference = time() - $date_timestamp;
        $periods = array(
            'decade' => 315360000,
            'year'   => 31536000,
            'month'  => 2628000,
            'week'   => 604800,
            'day'    => 86400,
            'hour'   => 3600,
            'minute' => 60,
            'second' => 1,
        );
        foreach ( $periods as $key => $value ) {
            if ( $difference >= $value ) {
                $time = floor( $difference / $value );
                $difference %= $value;
                $retval .= (( $retval ? ' ' : '' )) . $time . ' ';
                $retval .= ( $time > 1 ? $date_time_strings[$key . 's'] : $date_time_strings[$key] );
                --$granularity;
            }
            if ( $granularity == '0' ) {
                break;
            }
        }
        return '' . $retval . ' ' . $ago_text;
    }

}
if ( !function_exists( 'ecff_stripos_arr' ) ) {
    function ecff_stripos_arr(  $haystack, $needle  ) {
        if ( !is_array( $needle ) ) {
            $needle = array($needle);
        }
        foreach ( $needle as $what ) {
            if ( ($pos = stripos( $haystack, ltrim( $what ) )) !== false ) {
                return $pos;
            }
        }
        return false;
    }

}
if ( !function_exists( 'ecff_hastags_to_link' ) ) {
    function ecff_hastags_to_link(  $text  ) {
        return preg_replace( '/(^|\\s)#(\\w*[a-zA-Z_]+\\w*)/', '\\1#<a href="https://www.facebook.com/hashtag/\\2" class="eflb-hash" target="_blank">\\2</a>', $text );
    }

}
if ( !function_exists( 'efbl_parse_url' ) ) {
    function efbl_parse_url(  $url  ) {
        // check if url is valid
        if ( !filter_var( $url, FILTER_VALIDATE_URL ) && !empty( $url ) ) {
            return $url;
        }
        $fb_url = parse_url( $url );
        $fanpage_url = str_replace( '/', '', $fb_url['path'] );
        return $fanpage_url;
    }

}
if ( !function_exists( 'efbl_check_reaction' ) ) {
    function efbl_check_reaction(  $needle, $array, $filter = null  ) {
        $efbl_reaction_count = null;
        $efbl_reaction_array = array();
        if ( $array ) {
            foreach ( $array as $efbl_reaction ) {
                $efbl_reaction = (array) $efbl_reaction;
                if ( $needle == $efbl_reaction['type'] ) {
                    ++$efbl_reaction_count;
                    $efbl_reaction_array['data'][] = $efbl_reaction;
                }
            }
        }
        if ( !empty( $efbl_reaction_array ) ) {
            $efbl_reaction_array['total_count'] = $efbl_reaction_count;
        }
        return $efbl_reaction_array;
    }

}
if ( !function_exists( 'efbl_get_page_bio' ) ) {
    function efbl_get_page_bio(  $id, $cache_seconds  ) {
        $efbl_bio_data = array();
        $accesstoken = '';
        $efbl_bio_slug = "efbl_page_bio-{$id}";
        $efbl_bio_data = get_transient( $efbl_bio_slug );
        if ( !$efbl_bio_data || '' == $efbl_bio_data ) {
            $FTA = new Feed_Them_All();
            $fta_settings = $FTA->fta_get_settings();
            if ( isset( $fta_settings['plugins']['facebook']['approved_pages'] ) ) {
                $pages = $fta_settings['plugins']['facebook']['approved_pages'];
                if ( isset( $pages[$id] ) ) {
                    $page_exists = $pages[$id];
                } else {
                    $page_exists = '';
                }
                if ( $page_exists ) {
                    $accesstoken = $pages[$id]['access_token'];
                } else {
                    $accesstoken = $fta_settings['plugins']['facebook']['access_token'];
                }
            }
            $efbl_bio_url = "https://graph.facebook.com/{$id}?fields=access_token,username,id,name,fan_count,category,about,verification_status&access_token=" . $accesstoken;
            $efbl_bio_data_api = wp_remote_get( $efbl_bio_url );
            if ( isset( $efbl_bio_data_api ) && !empty( $efbl_bio_data_api ) ) {
                if ( isset( $efbl_bio_data_api['body'] ) ) {
                    $efbl_bio_data = json_decode( $efbl_bio_data_api['body'] );
                }
            }
            if ( 200 == $efbl_bio_data_api['response']['code'] && !empty( $efbl_bio_data ) ) {
                set_transient( $efbl_bio_slug, $efbl_bio_data, $cache_seconds );
            }
        }
        return $efbl_bio_data;
    }

}
if ( !function_exists( 'efbl_readable_count' ) ) {
    function efbl_readable_count(  $input  ) {
        if ( !$input ) {
            $input = 0;
        }
        $input = number_format( $input );
        $input_count = substr_count( $input, ',' );
        if ( $input_count != '0' ) {
            if ( $input_count == '1' ) {
                return substr( $input, 0, -4 ) . 'K';
            } elseif ( $input_count == '2' ) {
                return substr( $input, 0, -8 ) . 'M';
            } elseif ( $input_count == '3' ) {
                return substr( $input, 0, -12 ) . 'B';
            } else {
                return;
            }
        } else {
            if ( !$input ) {
                $input = '';
            }
            return $input;
        }
    }

}
if ( !function_exists( 'ecff_makeClickableLinks' ) ) {
    function ecff_makeClickableLinks(  $value, $protocols = array('http', 'mail', 'https'), array $attributes = array()  ) {
        // Ensure $value is a string
        if ( is_null( $value ) ) {
            $value = '';
        }
        // Link attributes
        $attr = '';
        foreach ( $attributes as $key => $val ) {
            $attr .= ' ' . $key . '="' . htmlentities( $val ) . '"';
        }
        $links = array();
        // Extract existing links and tags
        $value = preg_replace_callback( '~(<a .*?>.*?</a>|<.*?>)~i', function ( $match ) use(&$links) {
            return '<' . array_push( $links, $match[1] ) . '>';
        }, $value );
        // Extract text links for each protocol
        foreach ( (array) $protocols as $protocol ) {
            switch ( $protocol ) {
                case 'http':
                case 'https':
                    $value = preg_replace_callback( '~(?:(https?)://([^\\s<]+)|(www\\.[^\\s<]+?\\.[^\\s<]+))(?<![\\.,:])~i', function ( $match ) use($protocol, &$links, $attr) {
                        if ( $match[1] ) {
                            $protocol = $match[1];
                        }
                        $link = ( $match[2] ?: $match[3] );
                        return '<' . array_push( $links, "<a {$attr} href=\"{$protocol}://{$link}\">{$link}</a>" ) . '>';
                    }, $value );
                    break;
                case 'mail':
                    $value = preg_replace_callback( '~([^\\s<]+?@[^\\s<]+?\\.[^\\s<]+)(?<![\\.,:])~', function ( $match ) use(&$links, $attr) {
                        return '<' . array_push( $links, "<a {$attr} href=\"mailto:{$match[1]}\">{$match[1]}</a>" ) . '>';
                    }, $value );
                    break;
                case 'twitter':
                    $value = preg_replace_callback( '~(?<!\\w)[@#](\\w++)~', function ( $match ) use(&$links, $attr) {
                        return '<' . array_push( $links, "<a {$attr} href=\"https://twitter.com/" . (( $match[0][0] == '@' ? '' : 'search/%23' )) . $match[1] . "\">{$match[0]}</a>" ) . '>';
                    }, $value );
                    break;
                default:
                    $value = preg_replace_callback( '~' . preg_quote( $protocol, '~' ) . '://([^\\s<]+?)(?<![\\.,:])~i', function ( $match ) use($protocol, &$links, $attr) {
                        return '<' . array_push( $links, "<a {$attr} href=\"{$protocol}://{$match[1]}\">{$match[1]}</a>" ) . '>';
                    }, $value );
                    break;
            }
        }
        // Insert all link
        return preg_replace_callback( '/<(\\d+)>/', function ( $match ) use(&$links) {
            return $links[$match[1] - 1];
        }, $value );
    }

}
if ( !function_exists( 'efbl_get_page_logo' ) ) {
    function efbl_get_page_logo(  $page_id = null  ) {
        if ( $page_id ) {
            $page_logo_trasneint_name = 'esf_logo_' . $page_id;
            $auth_img_src = get_transient( $page_logo_trasneint_name );
            $check_status = wp_remote_retrieve_body( wp_remote_get( $auth_img_src ) );
            if ( $check_status == 'URL signature expired' ) {
                $auth_img_src = '';
            }
            if ( $auth_img_src && !empty( $auth_img_src ) && !isset( $auth_img_src->error ) ) {
                return $auth_img_src;
            } else {
                $FTA = new Feed_Them_All();
                $fta_settings = $FTA->fta_get_settings();
                if ( isset( $fta_settings['plugins']['facebook']['approved_pages'] ) || isset( $fta_settings['plugins']['facebook']['approved_groups'] ) ) {
                    $pages = $fta_settings['plugins']['facebook']['approved_pages'];
                    if ( isset( $pages[$page_id] ) ) {
                        $page_exists = $pages[$page_id];
                    } else {
                        $page_exists = '';
                    }
                    if ( $page_exists ) {
                        $accesstoken = $pages[$page_id]['access_token'];
                    } else {
                        $accesstoken = $fta_settings['plugins']['facebook']['access_token'];
                    }
                    $auth_img_src = 'https://graph.facebook.com/' . $page_id . '/picture?type=large&redirect=0&access_token=' . $accesstoken;
                    $auth_img_src = json_decode( jws_fetchUrl( $auth_img_src ) );
                    if ( isset( $auth_img_src->data->url ) && !isset( $auth_img_src->error ) ) {
                        $auth_img_src = $auth_img_src->data->url;
                        //Store in a transient for 1 month
                        set_transient( $page_logo_trasneint_name, $auth_img_src, 30 * 60 * 60 * 24 );
                        return $auth_img_src;
                    }
                }
            }
        } else {
            return __( esf_get_translated_string( 'invalid_page_id' ), 'easy-facebook-likebox' );
        }
    }

}
/*
* Return Default page ID
*/
if ( !function_exists( 'efbl_default_page_id' ) ) {
    function efbl_default_page_id() {
        $efbl_default_page_id = '';
        $FTA = new Feed_Them_All();
        $fta_settings = $FTA->fta_get_settings();
        if ( isset( $fta_settings['plugins']['facebook']['approved_pages'] ) && !empty( $fta_settings['plugins']['facebook']['approved_pages'] ) ) {
            $approved_pages = $fta_settings['plugins']['facebook']['approved_pages'];
            if ( $approved_pages ) {
                foreach ( $approved_pages as $approved_page ) {
                    if ( isset( $approved_page['username'] ) ) {
                        $efbl_default_page_id = $approved_page['username'];
                    } else {
                        $efbl_default_page_id = $approved_page['id'];
                    }
                }
            }
        }
        return $efbl_default_page_id;
    }

}
/*
* Return Default skin ID
*/
if ( !function_exists( 'efbl_default_skin_id' ) ) {
    function efbl_default_skin_id() {
        $efbl_default_skin_id = '';
        $FTA = new Feed_Them_All();
        $fta_settings = $FTA->fta_get_settings();
        if ( isset( $fta_settings['plugins']['facebook']['default_skin_id'] ) && !empty( $fta_settings['plugins']['facebook']['default_skin_id'] ) ) {
            $efbl_default_skin_id = $fta_settings['plugins']['facebook']['default_skin_id'];
        }
        return $efbl_default_skin_id;
    }

}
if ( !function_exists( 'efbl_demo_page_id' ) ) {
    /**
     * Get Customizer demo page ID
     *
     * @return mixed|string
     * @since 6.2.0
     */
    function efbl_demo_page_id() {
        $efbl_demo_page_id = '';
        $FTA = new Feed_Them_All();
        $fta_settings = $FTA->fta_get_settings();
        if ( isset( $fta_settings['plugins']['facebook']['default_page_id'] ) && !empty( $fta_settings['plugins']['facebook']['default_page_id'] ) ) {
            $efbl_demo_page_id = $fta_settings['plugins']['facebook']['default_page_id'];
        }
        return $efbl_demo_page_id;
    }

}
if ( !function_exists( 'efbl_get_cache_seconds' ) ) {
    /**
     * Convert cache time span into seconds
     * @param $instance
     *
     * @since 6.2.0
     *
     * @return false|float|int
     */
    function efbl_get_cache_seconds(  $instance  ) {
        if ( !isset( $instance ) && !is_array( $instance ) ) {
            return false;
        }
        if ( !isset( $instance['cache_unit'] ) || $instance['cache_unit'] < 1 ) {
            $cache_unit = 1;
        } else {
            $cache_unit = $instance['cache_unit'];
        }
        $cache_duration = 60 * 60 * 24;
        //Calculate the cache time in seconds
        if ( $instance['cache_duration'] == 'minutes' || $instance['cache_duration'] == 'minute' ) {
            $cache_duration = 60;
        }
        if ( $instance['cache_duration'] == 'hours' || $instance['cache_duration'] == 'hour' ) {
            $cache_duration = 60 * 60;
        }
        if ( $instance['cache_duration'] == 'days' || $instance['cache_duration'] == 'day' ) {
            $cache_duration = 60 * 60 * 24;
        }
        $cache_seconds = $cache_duration * $cache_unit;
        return $cache_seconds;
    }

}
if ( !function_exists( 'efbl_get_page_username' ) ) {
    /**
     * Get username of the page if it's numeric
     * @param $page_id
     *
     *  @since 6.2.0
     *
     * @return false|float|int
     */
    function efbl_get_page_username(  $page_id  ) {
        if ( !isset( $page_id ) && empty( $page_id ) ) {
            return false;
        }
        $FTA = new Feed_Them_All();
        $fta_settings = $FTA->fta_get_settings();
        if ( !isset( $fta_settings['plugins']['facebook']['approved_pages'] ) && empty( $fta_settings['plugins']['facebook']['approved_pages'] ) ) {
            return false;
        }
        $approved_pages = $fta_settings['plugins']['facebook']['approved_pages'];
        if ( isset( $approved_pages[$page_id]['username'] ) && !empty( $approved_pages[$page_id]['username'] ) ) {
            $page_username = $approved_pages[$page_id]['username'];
        } else {
            $page_username = $page_id;
        }
        return $page_username;
    }

}
if ( !function_exists( 'efbl_get_page_id' ) ) {
    /**
     * Get page ID of the page
     * @param $page_id
     *
     *  @since 6.2.0
     *
     * @return false|float|int
     */
    function efbl_get_page_id(  $page_id  ) {
        if ( !isset( $page_id ) && empty( $page_id ) ) {
            return false;
        }
        $FTA = new Feed_Them_All();
        $fta_settings = $FTA->fta_get_settings();
        if ( !isset( $fta_settings['plugins']['facebook']['approved_pages'] ) && empty( $fta_settings['plugins']['facebook']['approved_pages'] ) ) {
            return false;
        }
        $approved_pages = $fta_settings['plugins']['facebook']['approved_pages'];
        foreach ( $approved_pages as $key => $value ) {
            if ( $value['username'] == $page_id ) {
                $page_id = $key;
                break;
            }
        }
        return $page_id;
    }

}
if ( !function_exists( 'efbl_array_push_assoc' ) ) {
    /**
     * Push items in associative array
     * @param $array
     * @param $key
     * @param $value
     *
     * @since 6.2.0
     * @return mixed
     */
    function efbl_array_push_assoc(  $array, $key, $value  ) {
        $array[$key] = $value;
        return $array;
    }

}
if ( !function_exists( 'efbl_eventdate' ) ) {
    /**
     * Convert into real event date
     *
     * @param $original
     * @param $date_format
     * @param $custom_date
     *
     * @since 6.2.0
     *
     * @return string
     */
    function efbl_eventdate(  $original, $date_format = '', $custom_date = ''  ) {
        switch ( $date_format ) {
            case '2':
                $print = date_i18n( '<k>F jS, </k>g:ia', $original );
                break;
            case '3':
                $print = date_i18n( 'g:ia<k> - F jS</k>', $original );
                break;
            case '4':
                $print = date_i18n( 'g:ia<k>, F jS</k>', $original );
                break;
            case '5':
                $print = date_i18n( '<k>l F jS - </k> g:ia', $original );
                break;
            case '6':
                $print = date_i18n( '<k>D M jS, Y, </k>g:iA', $original );
                break;
            case '7':
                $print = date_i18n( '<k>l F jS, Y, </k>g:iA', $original );
                break;
            case '8':
                $print = date_i18n( '<k>l F jS, Y - </k>g:ia', $original );
                break;
            case '9':
                $print = date_i18n( "<k>l M jS, 'y</k>", $original );
                break;
            case '10':
                $print = date_i18n( '<k>m.d.y - </k>g:iA', $original );
                break;
            case '11':
                $print = date_i18n( '<k>m/d/y, </k>g:ia', $original );
                break;
            case '12':
                $print = date_i18n( '<k>d.m.y - </k>g:iA', $original );
                break;
            case '13':
                $print = date_i18n( '<k>d/m/y, </k>g:ia', $original );
                break;
            case '14':
                $print = date_i18n( '<k>M j, </k>g:ia', $original );
                break;
            case '15':
                $print = date_i18n( '<k>M j, </k>G:i', $original );
                break;
            case '16':
                $print = date_i18n( '<k>d-m-Y, </k>G:i', $original );
                break;
            case '17':
                $print = date_i18n( '<k>jS F Y, </k>G:i', $original );
                break;
            case '18':
                $print = date_i18n( '<k>d M Y, </k>G:i', $original );
                break;
            case '19':
                $print = date_i18n( '<k>l jS F Y, </k>G:i', $original );
                break;
            case '20':
                $print = date_i18n( '<k>m.d.y - </k>G:i', $original );
                break;
            case '21':
                $print = date_i18n( '<k>d.m.y - </k>G:i', $original );
                break;
            default:
                $print = date_i18n( '<k>F j, Y, </k>g:ia', $original );
                break;
        }
        if ( !empty( $custom_date ) ) {
            $print = date_i18n( $custom_date, $original );
        }
        return $print;
    }

}
if ( !function_exists( 'efbl_get_albums_list' ) ) {
    function efbl_get_albums_list(  $page_id = ''  ) {
        if ( !$page_id ) {
            return false;
        }
    }

}
if ( !function_exists( 'efbl_get_group_bio' ) ) {
    /**
     * Get group bio
     * @param $id
     * @param $cache_seconds
     *
     * @return mixed
     */
    function efbl_get_group_bio(  $id, $cache_seconds  ) {
        $efbl_bio_data = array();
        $accesstoken = '';
        $efbl_bio_slug = "efbl_group_bio-{$id}";
        $efbl_bio_data = get_transient( $efbl_bio_slug );
        if ( !$efbl_bio_data || '' == $efbl_bio_data ) {
            $FTA = new Feed_Them_All();
            $fta_settings = $FTA->fta_get_settings();
            if ( isset( $fta_settings['plugins']['facebook']['approved_pages'] ) ) {
                $pages = $fta_settings['plugins']['facebook']['approved_pages'];
                $accesstoken = $fta_settings['plugins']['facebook']['access_token'];
            }
            $efbl_bio_url = "https://graph.facebook.com/{$id}?fields=member_count,description,name,link,picture&access_token=" . $accesstoken;
            $efbl_bio_data_api = wp_remote_get( $efbl_bio_url );
            if ( isset( $efbl_bio_data_api ) && !empty( $efbl_bio_data_api ) ) {
                if ( isset( $efbl_bio_data_api['body'] ) ) {
                    $efbl_bio_data = json_decode( $efbl_bio_data_api['body'] );
                }
            }
            if ( 200 == $efbl_bio_data_api['response']['code'] && !empty( $efbl_bio_data ) ) {
                set_transient( $efbl_bio_slug, $efbl_bio_data, $cache_seconds );
            }
        }
        return $efbl_bio_data;
    }

}
if ( !function_exists( 'efbl_has_connected_account' ) ) {
    /**
     * Check if the page has connected account
     * @return bool
     */
    function efbl_has_connected_account() {
        $FTA = new Feed_Them_All();
        $fta_settings = $FTA->fta_get_settings();
        if ( isset( $fta_settings['plugins']['facebook']['approved_pages'] ) && !empty( $fta_settings['plugins']['facebook']['approved_pages'] ) ) {
            return true;
        }
        return false;
    }

}