eatures', 'custom-facebook-feed'), 'smallHeading' => __('STEP 2', 'custom-facebook-feed'), 'featuresList' => [ [ 'heading' => __('Facebook User Feed', 'custom-facebook-feed'), 'description' => __('Create and display Facebook feeds from connected accounts', 'custom-facebook-feed'), 'color' => 'green', 'active' => true, 'uncheck' => true, 'icon' => '' ], [ 'data' => [ 'id' => 'enable_email_report', 'type' => 'settings' ], 'heading' => __('Downtime Prevention', 'custom-facebook-feed'), 'description' => __('Prevent downtime in the event your feed is unable to update', 'custom-facebook-feed'), 'color' => 'green', 'active' => true, 'uncheck' => true, 'icon' => '' ], [ 'data' => [ 'id' => 'cff_locale', 'type' => 'settings', 'value' => get_option('cff_locale', 'en_US') ], 'options' => CFF_Onboarding_Wizard::locales(), 'type' => 'select', 'heading' => __('Localization', 'custom-facebook-feed'), 'description' => __('This controls the language of any predefined text strings provided by Facebook.', 'custom-facebook-feed'), 'color' => 'green', 'active' => true, 'icon' => '' ] ], 'proFeaturesList' => [ [ 'heading' => __('Images and Videos', 'custom-facebook-feed'), 'description' => __('Display images and play videos from your Facebook posts.', 'custom-facebook-feed'), 'uncheck' => true, 'active' => false, 'icon' => '' ], [ 'heading' => __('Albums, Events, and More', 'custom-facebook-feed'), 'description' => __('Create feeds from your albums page. Show upcoming and past events.', 'custom-facebook-feed'), 'uncheck' => true, 'active' => false, 'icon' => '' ], [ 'heading' => __('Load More Posts', 'custom-facebook-feed'), 'description' => __('Visitors can load more posts to see more of your content.', 'custom-facebook-feed'), 'uncheck' => true, 'active' => false, 'icon' => '' ], ] ], [ 'id' => 'install-plugins', 'template' => CFF_BUILDER_DIR . 'templates/onboarding/install-plugins.php', 'heading' => __('You might also be interested in...', 'custom-facebook-feed'), 'description' => __('Facebook Feed users also install these plugins', 'custom-facebook-feed'), 'pluginsList' => self::get_awesomemotive_plugins(), 'star_icons' => CFF_PLUGIN_URL . 'admin/assets/img/stars.svg' ], [ 'id' => 'success-page', 'template' => CFF_BUILDER_DIR . 'templates/onboarding/success-page.php', 'heading' => __('Awesome. You are all set up!', 'custom-facebook-feed'), 'description' => __('Here\'s an overview of everything that is setup', 'custom-facebook-feed'), 'upgradeContent' => [ 'heading' => __('Upgrade to unlock hashtag feeds, tagged feeds, a popup lightbox and more', 'custom-facebook-feed'), 'description' => __('To unlock these features and much more, upgrade to Pro and enter your license key below.', 'custom-facebook-feed'), 'button' => [ 'text' => __('Upgrade to Facebook Feed Pro', 'custom-facebook-feed'), 'link' => 'https://smashballoon.com/pricing/facebook-feed/?license_key&upgrade=true&utm_campaign=facebook-free&utm_source=setup&utm_medium=upgrade-license' ], 'upgradeCouppon' => sprintf( __('Upgrade today and %ssave 50%% on a Pro License!%s%s (auto-applied at checkout)', 'custom-facebook-feed'), '', '', '
' ), 'banner' => CFF_BUILDER_URL . 'assets/img/success-banner.jpg', 'upgradeFeaturesList' => [ [ 'heading' => __('Hashtag Feeds', 'custom-facebook-feed'), 'icon' => '' ], [ 'heading' => __('Tagged Feeds', 'custom-facebook-feed'), 'icon' => '' ], [ 'heading' => __('Lightbox', 'custom-facebook-feed'), 'icon' => '' ], [ 'heading' => __('And many more', 'custom-facebook-feed'), 'icon' => '' ] ] ] ], ] ]; $dynamic_features_list = self::get_dynamic_features_list(); if (isset($data['steps']) && sizeof($dynamic_features_list) > 0) { $key_cf_ft = array_search('configure-features', array_column($data['steps'], 'id')); if ($key_cf_ft !== false) { $new_features_lit = array_merge($data['steps'][$key_cf_ft]['featuresList'], $dynamic_features_list) ; $data['steps'][$key_cf_ft]['featuresList'] = $new_features_lit; } } return $data; } /** * Return Dynamic Features List depending on multiple criteria * * @return array * * @since 6.X */ public static function get_dynamic_features_list() { $features_list = []; $smash_plugin_list = self::get_smash_plugins_list(); if (isset($smash_plugin_list['plugins']) && sizeof($smash_plugin_list['plugins']) > 0) { $description_plugins = implode(', ', $smash_plugin_list['text']); $search = ','; $description_plugins_text = strrev(preg_replace(strrev("/$search/"), strrev(' and '), strrev($description_plugins), 1)); $plugins_info = []; foreach ($smash_plugin_list['plugins'] as $p_item) { if ($p_item['is_istalled'] === false) { array_push( $plugins_info, $p_item ); } } array_push( $features_list, [ 'data' => [ 'id' => $description_plugins, 'type' => 'install_plugins', 'plugins' => 'smash' ], 'heading' => __('Social Feed Collection', 'custom-facebook-feed'), 'description' => __('Install', 'custom-facebook-feed') . ' ' . $description_plugins_text . ' ' . __('feed plugins for more fresh content', 'custom-facebook-feed'), 'color' => 'blue', 'active' => true, 'icon' => '', 'plugins' => $plugins_info, 'tooltip' => __('Smash Balloon offers the best social media feed solutions for WordPress. Enabling this feature will install additional plugins to power all of the supported platforms', 'custom-facebook-feed'), ] ); } // Reviews Plugin $reviews_plugin = self::get_smash_reviews_plugin(); if ($reviews_plugin !== false) { array_push($features_list, $reviews_plugin); } return $features_list; } /** * Return Uninstalled SmashBalloon Plugins * * @return array * * @since 6.X */ public static function get_smash_plugins_list() { $installed_plugins = get_plugins(); // check whether the pro or free plugins are installed $is_facebook_installed = false; $facebook_plugin = 'custom-facebook-feed/custom-facebook-feed.php'; if (isset($installed_plugins['custom-facebook-feed-pro/custom-facebook-feed.php'])) { $is_facebook_installed = true; $facebook_plugin = 'custom-facebook-feed-pro/custom-facebook-feed.php'; } elseif (isset($installed_plugins['custom-facebook-feed/custom-facebook-feed.php'])) { $is_facebook_installed = true; } $is_instagram_installed = false; $instagram_plugin = 'instagram-feed/instagram-feed.php'; if (isset($installed_plugins['instagram-feed-pro/instagram-feed.php'])) { $is_instagram_installed = true; $instagram_plugin = 'instagram-feed-pro/instagram-feed.php'; } elseif (isset($installed_plugins['instagram-feed/instagram-feed.php'])) { $is_instagram_installed = true; } $is_twitter_installed = false; $twitter_plugin = 'custom-twitter-feeds/custom-twitter-feed.php'; if (isset($installed_plugins['custom-twitter-feeds-pro/custom-twitter-feed.php'])) { $is_twitter_installed = true; $twitter_plugin = 'custom-twitter-feeds-pro/custom-twitter-feed.php'; } elseif (isset($installed_plugins['custom-twitter-feeds/custom-twitter-feed.php'])) { $is_twitter_installed = true; } $is_youtube_installed = false; $youtube_plugin = 'feeds-for-youtube/youtube-feed.php'; if (isset($installed_plugins['youtube-feed-pro/youtube-feed.php'])) { $is_youtube_installed = true; $youtube_plugin = 'youtube-feed-pro/youtube-feed.php'; } elseif (isset($installed_plugins['feeds-for-youtube/youtube-feed.php'])) { $is_youtube_installed = true; } $is_tiktok_installed = false; $tiktok_plugin = 'feeds-for-tiktok/feeds-for-tiktok.php'; if (isset($installed_plugins['tiktok-feeds-pro/tiktok-feeds-pro.php'])) { $is_tiktok_installed = true; $tiktok_plugin = 'tiktok-feeds-pro/tiktok-feeds-pro.php'; } elseif (isset($installed_plugins['feeds-for-tiktok/feeds-for-tiktok.php'])) { $is_tiktok_installed = true; } $smash_list = [ 'text' => [], 'plugins' => [ [ 'type' => 'instagram', 'is_istalled' => $is_instagram_installed, 'download_link' => $instagram_plugin, 'min_php' => '5.6.0', 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/insta-icon.svg' ], [ 'type' => 'facebook', 'is_istalled' => $is_facebook_installed, 'download_link' => $facebook_plugin, 'min_php' => '5.6.0', 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/fb-icon.svg' ], [ 'type' => 'twitter', 'is_istalled' => $is_twitter_installed, 'download_link' => $twitter_plugin, 'min_php' => '5.6.0', 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/twitter-icon.svg' ], [ 'type' => 'youtube', 'is_istalled' => $is_youtube_installed, 'download_link' => $youtube_plugin, 'min_php' => '5.6.0', 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/youtube-icon.svg' ], [ 'type' => 'tiktok', 'is_istalled' => $is_tiktok_installed, 'download_link' => $tiktok_plugin, 'min_php' => '7.0', 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/tiktok-icon.svg' ] ] ]; foreach ($smash_list['plugins'] as $mash_plugin) { if (version_compare(PHP_VERSION, $mash_plugin['min_php'], '<')) { $mash_plugin['is_istalled'] = true; } if ($mash_plugin['type'] === self::$plugin_name || $mash_plugin['is_istalled'] === true) { unset($mash_plugin); } else { array_push($smash_list['text'], ucfirst($mash_plugin['type'])); } } return $smash_list; } /** * Return Reviews Plugin if not Installed * * @return array * * @since 6.X */ public static function get_smash_reviews_plugin() { $installed_plugins = get_plugins(); $min_php = '7.1'; $is_reviews_installed = false; $reviews_plugin = 'reviews-feed/sb-reviews.php'; if (isset($installed_plugins['reviews-feed-pro/sb-reviews-pro.php'])) { $is_reviews_installed = true; $reviews_plugin = 'reviews-feed-pro/sb-reviews-pro.php'; } elseif (isset($installed_plugins['reviews-feed/sb-reviews.php'])) { $is_reviews_installed = true; } if (version_compare(PHP_VERSION, $min_php, '<')) { $is_reviews_installed = true; } if ($is_reviews_installed === false) { return [ 'data' => [ 'id' => 'reviews', 'type' => 'install_plugins' ], 'heading' => __('Customer Reviews Plugin', 'custom-facebook-feed'), 'description' => __('Install Reviews Feed to display customer reviews from Google or Yelp and build trust', 'custom-facebook-feed'), 'color' => 'blue', 'active' => true, 'icon' => '', 'plugins' => [ [ 'type' => 'reviews', 'is_istalled' => $is_reviews_installed, 'download_link' => $reviews_plugin, 'min_php' => $min_php, 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/reviews-icon.svg' ] ], 'tooltip' => __('Enabling this feature will install Reviews Feed plugin. Reviews Feed by Smash Balloon helps users to display reviews from Google, TripAdvisor, TrustPilot and more.', 'custom-facebook-feed'), ]; } return false; } /** * Return Awesome Motive Plugins * * @return array * * @since 6.X */ public static function get_awesomemotive_plugins() { $installed_plugins = get_plugins(); $awesomemotive_plugins_list = [ [ 'plugin' => 'allinoneseo', 'data' => [ 'type' => 'install_plugins', 'id' => 'allinoneseo', 'pluginName' => __('All in One SEO', 'custom-facebook-feed'), ], 'heading' => __('All in One SEO Toolkit', 'custom-facebook-feed'), 'description' => __('Out-of-the-box SEO for WordPress. Features like XML Sitemaps, SEO for custom post types, SEO for blogs, business sites, or ecommerce sites, and much more.', 'custom-facebook-feed'), 'color' => 'blue', 'active' => true, 'icon' => CFF_BUILDER_URL . 'assets/img/allinoneseo.png', 'installs_number' => '3 Million+ Installs' ], [ 'plugin' => 'monsterinsight', 'data' => [ 'type' => 'install_plugins', 'id' => 'monsterinsight', 'pluginName' => __('Monster Insights', 'custom-facebook-feed'), ], 'heading' => __('Analytics by MonsterInsights', 'custom-facebook-feed'), 'description' => __('Make it “effortless” to connect your WordPress site with Google Analytics, so you can start making data-driven decisions to grow your business.', 'custom-facebook-feed'), 'color' => 'blue', 'active' => true, 'icon' => CFF_BUILDER_URL . 'assets/img/monsterinsight.png', 'installs_number' => '3 Million+ Installs' ], [ 'plugin' => 'wpforms', 'data' => [ 'type' => 'install_plugins', 'id' => 'wpforms', 'pluginName' => __('WPForms', 'custom-facebook-feed'), ], 'heading' => __('Forms by WPForms', 'custom-facebook-feed'), 'description' => __('Create contact, subscription or payment forms with the most beginner friendly drag & drop WordPress forms plugin', 'custom-facebook-feed'), 'color' => 'blue', 'active' => true, 'icon' => CFF_BUILDER_URL . 'assets/img/wpforms.png', 'installs_number' => '5 Million+ Installs' ], [ 'plugin' => 'seedprod', 'data' => [ 'type' => 'install_plugins', 'id' => 'seedprod', 'pluginName' => __('SeedProd', 'custom-facebook-feed'), ], 'heading' => __('SeedProd Website Builder', 'custom-facebook-feed'), 'description' => __('A simple and powerful theme builder, landing page builder, "coming soon" page builder, and maintenance mode notice builder', 'custom-facebook-feed'), 'color' => 'blue', 'active' => true, 'icon' => CFF_BUILDER_URL . 'assets/img/seedprod.png', 'installs_number' => '900 Thousand+ Installs' ], [ 'plugin' => 'optinmonster', 'data' => [ 'type' => 'install_plugins', 'id' => 'optinmonster', 'pluginName' => __('OptinMonster', 'custom-facebook-feed'), ], 'heading' => __('OptinMonster Popup Builder', 'custom-facebook-feed'), 'description' => __('Make popups & opt-in forms to build your email newsletter subscribers, generate leads, and close sales', 'custom-facebook-feed'), 'color' => 'blue', 'active' => true, 'icon' => CFF_BUILDER_URL . 'assets/img/optinmonster.png', 'installs_number' => '1 Million+ Installs' ], [ 'plugin' => 'pushengage', 'data' => [ 'type' => 'install_plugins', 'id' => 'pushengage', 'pluginName' => __('PushEngage', 'custom-facebook-feed'), ], 'heading' => __('PushEngage Notifications', 'custom-facebook-feed'), 'description' => __('Create and send high-converting web push notifications to your website visitors.', 'custom-facebook-feed'), 'color' => 'blue', 'active' => true, 'icon' => CFF_BUILDER_URL . 'assets/img/pushengage.svg', 'installs_number' => '10 Thousand+ Installs' ] ]; $available_plugins = []; foreach ($awesomemotive_plugins_list as $plugin) { if (!self::check_awesome_motive_plugin($plugin['plugin'], $installed_plugins)) { array_push($available_plugins, $plugin); } } return array_slice($available_plugins, 0, 3); } /** * Check if AWESOME MOTIVE Plugin * * @return boolean * * @since 6.X */ public static function check_awesome_motive_plugin($plugin, $installed_plugins) { switch ($plugin) { case 'allinoneseo': if ( isset($installed_plugins['all-in-one-seo-pack/all_in_one_seo_pack.php']) || isset($installed_plugins['all-in-one-seo-pack-pro/all_in_one_seo_pack.php']) ) { return true; } return false; case 'monsterinsight': if ( isset($installed_plugins['google-analytics-for-wordpress/googleanalytics.php']) || isset($installed_plugins['google-analytics-premium/googleanalytics-premium.php']) ) { return true; } return false; case 'wpforms': if ( isset($installed_plugins['wpforms-lite/wpforms.php']) || isset($installed_plugins['wpforms/wpforms.php']) ) { return true; } return false; case 'seedprod': if ( isset($installed_plugins['coming-soon/coming-soon.php']) ) { return true; } return false; case 'optinmonster': if ( isset($installed_plugins['optinmonster/optin-monster-wp-api.php']) ) { return true; } return false; case 'pushengage': if ( isset($installed_plugins['pushengage/main.php']) ) { return true; } return false; } } /** * Get Plugin Download * * @since 6.X */ public static function get_plugin_download_link($plugin_name) { $plugin_download = false; switch (strtolower($plugin_name)) { case 'facebook': $plugin_download = 'https://downloads.wordpress.org/plugin/custom-facebook-feed.zip'; break; case 'instagram': $plugin_download = 'https://downloads.wordpress.org/plugin/instagram-feed.zip'; break; case 'twitter': $plugin_download = 'https://downloads.wordpress.org/plugin/custom-twitter-feeds.zip'; break; case 'youtube': $plugin_download = 'https://downloads.wordpress.org/plugin/feeds-for-youtube.zip'; break; case 'tiktok': $plugin_download = 'https://downloads.wordpress.org/plugin/feeds-for-tiktok.zip'; break; case 'reviews': $plugin_download = 'https://downloads.wordpress.org/plugin/reviews-feed.zip'; break; case 'allinoneseo': $plugin_download = 'https://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip'; break; case 'monsterinsight': $plugin_download = 'https://downloads.wordpress.org/plugin/google-analytics-for-wordpress.zip'; break; case 'wpforms': $plugin_download = 'https://downloads.wordpress.org/plugin/wpforms-lite.zip'; break; case 'seedprod': $plugin_download = 'https://downloads.wordpress.org/plugin/coming-soon.zip'; break; case 'optinmonster': $plugin_download = 'https://downloads.wordpress.org/plugin/optinmonster.zip'; break; case 'pushengage': $plugin_download = 'https://downloads.wordpress.org/plugin/pushengage.zip'; break; } return $plugin_download; } /** * Install Plugin * * @since 6.X */ public static function install_single_plugin($plugin_name) { $plugin_download = self::get_plugin_download_link(strtolower(str_replace(' ', '', $plugin_name))); if ($plugin_download === false || !current_user_can('install_plugins')) { return false; } if (strpos($plugin_download, 'https://downloads.wordpress.org/plugin/') !== 0) { return false; } set_current_screen('cff-feed-builder'); // Prepare variables. $url = esc_url_raw( add_query_arg( array( 'page' => 'cff-feed-builder', ), admin_url('admin.php') ) ); $creds = request_filesystem_credentials($url, '', false, false, null); // Check for file system permissions. if (false === $creds || ! WP_Filesystem($creds)) { return false; } // Do not allow WordPress to search/download translations, as this will break JS output. remove_action('upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20); // Create the plugin upgrader with our custom skin. $installer = new \CustomFacebookFeed\Helpers\PluginSilentUpgrader(new \CustomFacebookFeed\Admin\CFF_Install_Skin()); // Error check. if (! method_exists($installer, 'install') || empty($plugin_download)) { wp_send_json_error($error); } $installer->install(esc_url_raw(wp_unslash($plugin_download))); // Flush the cache and return the newly installed plugin basename. wp_cache_flush(); $plugin_basename = $installer->plugin_info(); if ($plugin_basename) { activate_plugin($plugin_basename); } } /** * Process Wizard Data * Save Settings, Install Plugins and more * * @since 6.0.8 */ public function process_wizard_data() { if (! isset($_POST['data'])) { wp_send_json_error(); } check_ajax_referer('cff-admin', 'nonce'); $cap = current_user_can('manage_custom_facebook_feed_options') ? 'manage_custom_facebook_feed_options' : 'manage_options'; $cap = apply_filters('cff_settings_pages_capability', $cap); if (! current_user_can($cap)) { wp_send_json_error(); // This auto-dies. } $cff_settings = get_option('cff_style_settings', array()); $onboarding_data = sanitize_text_field(stripslashes($_POST['data'])); $onboarding_data = json_decode($onboarding_data, true); foreach ($onboarding_data as $single_data) { if ($single_data['type'] === 'settings') { if (isset($single_data['value'])) { if ($single_data['id'] === 'cff_locale') { update_option('cff_locale', $single_data['value']); } else { $cff_settings[$single_data['id']] = $single_data['value']; } } else { $cff_settings[$single_data['id']] = $single_data['id'] === 'cff_disable_resize' ? false : true; } } if ($single_data['type'] === 'install_plugins' && current_user_can('install_plugins')) { $plugins = explode(',', $single_data['id']); foreach ($plugins as $plugin_name) { @CFF_Onboarding_wizard::install_single_plugin($plugin_name); } } } update_option('cff_style_settings', $cff_settings); // Deleting Redirect Data for 3rd plugins $this->disable_installed_plugins_redirect(); wp_die(); } /** * Dismiss Onboarding Wizard * * @since 6.0.8 */ public function dismiss_wizard() { check_ajax_referer('cff-admin', 'nonce'); $cap = current_user_can('manage_custom_facebook_feed_options') ? 'manage_custom_facebook_feed_options' : 'manage_options'; $cap = apply_filters('cff_settings_pages_capability', $cap); if (! current_user_can($cap)) { wp_send_json_error(); // This auto-dies. } $cff_statuses_option = get_option('cff_statuses', array()); $cff_statuses_option['wizard_dismissed'] = true; update_option('cff_statuses', $cff_statuses_option); wp_send_json_error(); } /** * Disable Installed Plugins Redirect * * @since 6.0.8 */ public function disable_installed_plugins_redirect() { // Monster Insight delete_transient('_monsterinsights_activation_redirect'); // All in one SEO update_option('aioseo_activation_redirect', true); // WPForms update_option('wpforms_activation_redirect', true); // Optin Monster delete_transient('optin_monster_api_activation_redirect'); update_option('optin_monster_api_activation_redirect_disabled', true); // Seed PROD update_option('seedprod_dismiss_setup_wizard', true); // PushEngage delete_transient('pushengage_activation_redirect'); // Smash Plugin redirect remove $this->disable_smash_installed_plugins_redirect(); } /** * Disable Smash Balloon Plugins Redirect * * @since 6.0.8 */ public function disable_smash_installed_plugins_redirect() { $smash_list = [ 'facebook' => 'cff_plugin_do_activation_redirect', 'instagram' => 'sbi_plugin_do_activation_redirect', 'youtube' => 'sby_plugin_do_activation_redirect', 'twitter' => 'ctf_plugin_do_activation_redirect', 'reviews' => 'sbr_plugin_do_activation_redirect', ]; if (isset($smash_list[self::$plugin_name])) { unset($smash_list[self::$plugin_name]); } foreach ($smash_list as $key => $opt) { delete_option($opt); } } }