Blocks
1 month ago
Traits
1 month ago
CFF_About_Us.php
1 month ago
CFF_Admin.php
1 month ago
CFF_Admin_Notices.php
1 month ago
CFF_Callout.php
1 month ago
CFF_Global_Settings.php
1 month ago
CFF_Install_Skin.php
1 month ago
CFF_New_User.php
1 month ago
CFF_Notifications.php
1 month ago
CFF_Onboarding_Wizard.php
1 month ago
CFF_Support.php
1 month ago
CFF_Support_Tool.php
1 month ago
CFF_Upgrader.php
1 month ago
CFF_oEmbeds.php
1 month ago
index.php
1 month ago
CFF_Onboarding_Wizard.php
957 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Onbaording Wizard |
| 5 | * |
| 6 | * @since 6.3 |
| 7 | */ |
| 8 | |
| 9 | namespace CustomFacebookFeed\Admin; |
| 10 | |
| 11 | use CustomFacebookFeed\Admin\Traits\CFF_Settings; |
| 12 | use CustomFacebookFeed\Builder\CFF_Feed_Builder; |
| 13 | use CustomFacebookFeed\Builder\CFF_Feed_Saver_Manager; |
| 14 | use CustomFacebookFeed\Builder\CFF_Source; |
| 15 | |
| 16 | if (!defined('ABSPATH')) { |
| 17 | exit; |
| 18 | } |
| 19 | |
| 20 | class CFF_Onboarding_Wizard extends CFF_Feed_Builder |
| 21 | { |
| 22 | use CFF_Settings; |
| 23 | |
| 24 | static $plugin_name = 'facebook'; |
| 25 | static $current_version = CFF_DBVERSION; |
| 26 | static $target_version = '2.4'; |
| 27 | static $statues_name = 'cff_statuses'; |
| 28 | |
| 29 | public function __construct() |
| 30 | { |
| 31 | $this->init(); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Init Setup Dashboard. |
| 36 | * |
| 37 | * @since 6.0 |
| 38 | */ |
| 39 | public function init() |
| 40 | { |
| 41 | if (is_admin()) { |
| 42 | add_action('admin_menu', array( $this, 'register_menu' )); |
| 43 | // add ajax listeners |
| 44 | CFF_Feed_Saver_Manager::hooks(); |
| 45 | CFF_Source::hooks(); |
| 46 | self::hooks(); |
| 47 | $this->ajax_hooks(); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | public function ajax_hooks() |
| 52 | { |
| 53 | add_action('wp_ajax_cff_feed_saver_manager_process_wizard', array( $this , 'process_wizard_data' )); |
| 54 | add_action('wp_ajax_cff_feed_saver_manager_dismiss_wizard', array( $this , 'dismiss_wizard' )); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Check if we need to Init the Onboarding wizard |
| 59 | * |
| 60 | * @since 6.0 |
| 61 | */ |
| 62 | public static function should_init_wizard() |
| 63 | { |
| 64 | $statues = get_option(self::$statues_name, array()); |
| 65 | if (!isset($statues['wizard_dismissed']) || $statues['wizard_dismissed'] === false) { |
| 66 | return true; |
| 67 | } |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | |
| 73 | /** |
| 74 | * Wizard Wrapper. |
| 75 | * |
| 76 | * @since 6.0 |
| 77 | */ |
| 78 | public function feed_builder() |
| 79 | { |
| 80 | include_once CFF_BUILDER_DIR . 'templates/wizard.php'; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Register Menu. |
| 85 | * |
| 86 | * @since 6.0 |
| 87 | */ |
| 88 | public function register_menu() |
| 89 | { |
| 90 | $cap = current_user_can('manage_custom_facebook_feed_options') ? 'manage_custom_facebook_feed_options' : 'manage_options'; |
| 91 | $cap = apply_filters('cff_settings_pages_capability', $cap); |
| 92 | |
| 93 | $submenu = self::should_init_wizard() ? 'cff-top' : 'sb'; |
| 94 | |
| 95 | $feed_builder = add_submenu_page( |
| 96 | $submenu, |
| 97 | __('Setup', 'custom-facebook-feed'), |
| 98 | __('Setup', 'custom-facebook-feed'), |
| 99 | $cap, |
| 100 | 'cff-setup', |
| 101 | array( $this, 'feed_builder' ), |
| 102 | 0 |
| 103 | ); |
| 104 | add_action('load-' . $feed_builder, array( $this, 'builder_enqueue_admin_scripts' )); |
| 105 | } |
| 106 | |
| 107 | |
| 108 | /** |
| 109 | * Onboarding Wizard Content & Steps |
| 110 | * |
| 111 | * @return array |
| 112 | * |
| 113 | * @since 6.X |
| 114 | */ |
| 115 | public static function get_onboarding_wizard_content() |
| 116 | { |
| 117 | |
| 118 | $data = [ |
| 119 | 'heading' => __('Smash Balloon', 'custom-facebook-feed'), |
| 120 | 'subheading' => __('Facebook Feed by', 'custom-facebook-feed'), |
| 121 | 'logo' => CFF_BUILDER_URL . 'assets/img/facebook.png', |
| 122 | 'balloon' => CFF_BUILDER_URL . 'assets/img/balloon.png', |
| 123 | 'balloon1' => CFF_BUILDER_URL . 'assets/img/balloon-1.png', |
| 124 | 'userIcon' => CFF_BUILDER_URL . 'assets/img/user.png', |
| 125 | 'saveSettings' => [ 'featuresList', 'pluginsList' ], |
| 126 | 'successMessages' => [ |
| 127 | 'connectAccount' => __('Connect a Facebook Account!', 'custom-facebook-feed'), |
| 128 | 'setupFeatures' => __('Setup Features!', 'custom-facebook-feed'), |
| 129 | 'feedPlugins' => __('Feed plugins for # installed', 'custom-facebook-feed') |
| 130 | ], |
| 131 | 'steps' => [ |
| 132 | [ |
| 133 | 'id' => 'welcome', |
| 134 | 'template' => CFF_BUILDER_DIR . 'templates/onboarding/welcome.php', |
| 135 | 'heading' => __('Let\'s set up your plugin!', 'custom-facebook-feed'), |
| 136 | 'description' => __('Ready to add a dash of Facebook to your website? Setting up your first feed is quick and easy. We\'ll get you up and running in no time.', 'custom-facebook-feed'), |
| 137 | 'button' => __('Launch the Setup Wizard', 'custom-facebook-feed'), |
| 138 | 'img' => CFF_BUILDER_URL . 'assets/img/waving-hand.png', |
| 139 | 'banner' => CFF_BUILDER_URL . 'assets/img/onboarding-banner.jpg', |
| 140 | |
| 141 | ], |
| 142 | [ |
| 143 | 'id' => 'add-source', |
| 144 | 'template' => CFF_BUILDER_DIR . 'templates/onboarding/add-source.php', |
| 145 | 'heading' => __('Connect your Facebook Account', 'custom-facebook-feed'), |
| 146 | 'smallHeading' => __('STEP 1', 'custom-facebook-feed'), |
| 147 | ], |
| 148 | [ |
| 149 | 'id' => 'configure-features', |
| 150 | 'template' => CFF_BUILDER_DIR . 'templates/onboarding/configure-features.php', |
| 151 | 'heading' => __('Configure features', 'custom-facebook-feed'), |
| 152 | 'smallHeading' => __('STEP 2', 'custom-facebook-feed'), |
| 153 | 'featuresList' => [ |
| 154 | [ |
| 155 | 'heading' => __('Facebook User Feed', 'custom-facebook-feed'), |
| 156 | 'description' => __('Create and display Facebook feeds from connected accounts', 'custom-facebook-feed'), |
| 157 | 'color' => 'green', |
| 158 | 'active' => true, |
| 159 | 'uncheck' => true, |
| 160 | 'icon' => '<svg fill="#696D80" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve"><path d="M256,0C114.9,0,0,114.9,0,256s114.9,256,256,256s256-114.9,256-256S397.1,0,256,0z M256,42.7 c118.1,0,213.3,95.3,213.3,213.3c0,107.3-78.7,195.4-181.6,210.8V318.2h60.8l9.5-61.7h-70.3v-33.7c0-25.6,8.4-48.4,32.4-48.4h38.5 v-53.8c-6.8-0.9-21.1-2.9-48.1-2.9c-56.5,0-89.6,29.8-89.6,97.8v41h-58.1v61.7h58.1v148C119.7,449.5,42.7,362.1,42.7,256 C42.7,137.9,137.9,42.7,256,42.7z"/></svg>' |
| 161 | ], |
| 162 | [ |
| 163 | 'data' => [ |
| 164 | 'id' => 'enable_email_report', |
| 165 | 'type' => 'settings' |
| 166 | ], |
| 167 | 'heading' => __('Downtime Prevention', 'custom-facebook-feed'), |
| 168 | 'description' => __('Prevent downtime in the event your feed is unable to update', 'custom-facebook-feed'), |
| 169 | 'color' => 'green', |
| 170 | 'active' => true, |
| 171 | 'uncheck' => true, |
| 172 | 'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_4085_38049)"><path d="M18.9999 16.9003C20.2151 16.6536 21.2952 15.9641 22.0306 14.9658C22.766 13.9674 23.1043 12.7315 22.9796 11.4978C22.855 10.2641 22.2765 9.12077 21.3563 8.28967C20.4361 7.45858 19.2399 6.99905 17.9999 7.0003H16.7399C16.4086 5.71762 15.764 4.53729 14.8638 3.56529C13.9637 2.59328 12.8363 1.86003 11.5828 1.43136C10.3292 1.0027 8.98891 0.892032 7.68207 1.10931C6.37523 1.32658 5.1428 1.865 4.09544 2.67621C3.04808 3.48742 2.21856 4.54604 1.68137 5.75701C1.14418 6.96799 0.916124 8.29341 1.01769 9.61429C1.11925 10.9352 1.54725 12.2102 2.26326 13.3248C2.97926 14.4394 3.96087 15.3587 5.11993 16.0003" stroke="#696D80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M13 11L9 17H15L11 23" stroke="#696D80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></g><defs><clipPath id="clip0_4085_38049"><rect width="24" height="24" fill="white"/></clipPath></defs></svg>' |
| 173 | ], |
| 174 | [ |
| 175 | 'data' => [ |
| 176 | 'id' => 'cff_locale', |
| 177 | 'type' => 'settings', |
| 178 | 'value' => get_option('cff_locale', 'en_US') |
| 179 | ], |
| 180 | 'options' => CFF_Onboarding_Wizard::locales(), |
| 181 | 'type' => 'select', |
| 182 | 'heading' => __('Localization', 'custom-facebook-feed'), |
| 183 | 'description' => __('This controls the language of any predefined text strings provided by Facebook.', 'custom-facebook-feed'), |
| 184 | 'color' => 'green', |
| 185 | 'active' => true, |
| 186 | 'icon' => '<svg fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="m3 5h12m-6-2v2m1.0482 9.5c-1.52737-1.5822-2.76747-3.4435-3.63633-5.5m6.08813 9h7m-8.5 3 5-10 5 10m-8.2489-16c-.968 5.7702-4.68141 10.6095-9.7511 13.129" stroke="#696D80" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/></svg>' |
| 187 | ] |
| 188 | |
| 189 | ], |
| 190 | 'proFeaturesList' => [ |
| 191 | [ |
| 192 | 'heading' => __('Images and Videos', 'custom-facebook-feed'), |
| 193 | 'description' => __('Display images and play videos from your Facebook posts.', 'custom-facebook-feed'), |
| 194 | 'uncheck' => true, |
| 195 | 'active' => false, |
| 196 | 'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 9H20" stroke="#8C8F9A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M4 15H20" stroke="#8C8F9A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M10 3L8 21" stroke="#8C8F9A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M16 3L14 21" stroke="#8C8F9A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>' |
| 197 | ], |
| 198 | [ |
| 199 | 'heading' => __('Albums, Events, and More', 'custom-facebook-feed'), |
| 200 | 'description' => __('Create feeds from your albums page. Show upcoming and past events.', 'custom-facebook-feed'), |
| 201 | 'uncheck' => true, |
| 202 | 'active' => false, |
| 203 | 'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 16C14.2091 16 16 14.2091 16 12C16 9.79086 14.2091 8 12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16Z" stroke="#696D80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M16 8.00036V13.0004C16 13.796 16.3161 14.5591 16.8787 15.1217C17.4413 15.6843 18.2044 16.0004 19 16.0004C19.7957 16.0004 20.5587 15.6843 21.1213 15.1217C21.6839 14.5591 22 13.796 22 13.0004V12.0004C21.9999 9.74339 21.2362 7.55283 19.8333 5.78489C18.4303 4.01694 16.4706 2.77558 14.2726 2.26265C12.0747 1.74973 9.76794 1.9954 7.72736 2.95972C5.68677 3.92405 4.03241 5.55031 3.03327 7.57408C2.03413 9.59785 1.74898 11.9001 2.22418 14.1065C2.69938 16.3128 3.90699 18.2936 5.65064 19.7266C7.39429 21.1597 9.57144 21.9607 11.8281 21.9995C14.0847 22.0383 16.2881 21.3126 18.08 19.9404" stroke="#696D80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>' |
| 204 | ], |
| 205 | [ |
| 206 | 'heading' => __('Load More Posts', 'custom-facebook-feed'), |
| 207 | 'description' => __('Visitors can load more posts to see more of your content.', 'custom-facebook-feed'), |
| 208 | 'uncheck' => true, |
| 209 | 'active' => false, |
| 210 | 'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 3H5C4.46957 3 3.96086 3.21071 3.58579 3.58579C3.21071 3.96086 3 4.46957 3 5V8M21 8V5C21 4.46957 20.7893 3.96086 20.4142 3.58579C20.0391 3.21071 19.5304 3 19 3H16M16 21H19C19.5304 21 20.0391 20.7893 20.4142 20.4142C20.7893 20.0391 21 19.5304 21 19V16M3 16V19C3 19.5304 3.21071 20.0391 3.58579 20.4142C3.96086 20.7893 4.46957 21 5 21H8" stroke="#696D80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>' |
| 211 | ], |
| 212 | ] |
| 213 | ], |
| 214 | [ |
| 215 | 'id' => 'install-plugins', |
| 216 | 'template' => CFF_BUILDER_DIR . 'templates/onboarding/install-plugins.php', |
| 217 | 'heading' => __('You might also be interested in...', 'custom-facebook-feed'), |
| 218 | 'description' => __('Facebook Feed users also install these plugins', 'custom-facebook-feed'), |
| 219 | 'pluginsList' => self::get_awesomemotive_plugins(), |
| 220 | 'star_icons' => CFF_PLUGIN_URL . 'admin/assets/img/stars.svg' |
| 221 | ], |
| 222 | [ |
| 223 | 'id' => 'success-page', |
| 224 | 'template' => CFF_BUILDER_DIR . 'templates/onboarding/success-page.php', |
| 225 | 'heading' => __('Awesome. You are all set up!', 'custom-facebook-feed'), |
| 226 | 'description' => __('Here\'s an overview of everything that is setup', 'custom-facebook-feed'), |
| 227 | 'upgradeContent' => [ |
| 228 | 'heading' => __('Upgrade to unlock hashtag feeds, tagged feeds, a popup lightbox and more', 'custom-facebook-feed'), |
| 229 | 'description' => __('To unlock these features and much more, upgrade to Pro and enter your license key below.', 'custom-facebook-feed'), |
| 230 | 'button' => [ |
| 231 | 'text' => __('Upgrade to Facebook Feed Pro', 'custom-facebook-feed'), |
| 232 | 'link' => 'https://smashballoon.com/custom-facebook-feed/facebook-lite-upgrade/?license_key&upgrade=true&utm_campaign=facebook-free&utm_source=setup&utm_medium=upgrade-license' |
| 233 | ], |
| 234 | 'upgradeCouppon' => sprintf( |
| 235 | __('Upgrade today and %ssave 50%% on a Pro License!%s%s (auto-applied at checkout)', 'custom-facebook-feed'), |
| 236 | '<strong>', |
| 237 | '</strong>', |
| 238 | '<br>' |
| 239 | ), |
| 240 | 'banner' => CFF_BUILDER_URL . 'assets/img/success-banner.jpg', |
| 241 | |
| 242 | 'upgradeFeaturesList' => [ |
| 243 | [ |
| 244 | 'heading' => __('Hashtag Feeds', 'custom-facebook-feed'), |
| 245 | 'icon' => '<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.66797 6.5H13.3346" stroke="#0068A0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M2.66797 10.5H13.3346" stroke="#0068A0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M6.66536 2.5L5.33203 14.5" stroke="#0068A0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M10.6654 2.5L9.33203 14.5" stroke="#0068A0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>' |
| 246 | ], |
| 247 | [ |
| 248 | 'heading' => __('Tagged Feeds', 'custom-facebook-feed'), |
| 249 | 'icon' => '<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.9987 11.1663C9.47146 11.1663 10.6654 9.97243 10.6654 8.49967C10.6654 7.02692 9.47146 5.83301 7.9987 5.83301C6.52594 5.83301 5.33203 7.02692 5.33203 8.49967C5.33203 9.97243 6.52594 11.1663 7.9987 11.1663Z" stroke="#E34F0E" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M10.6654 5.83357V9.1669C10.6654 9.69734 10.8761 10.206 11.2512 10.5811C11.6262 10.9562 12.1349 11.1669 12.6654 11.1669C13.1958 11.1669 13.7045 10.9562 14.0796 10.5811C14.4547 10.206 14.6654 9.69734 14.6654 9.1669V8.50024C14.6653 6.99559 14.1562 5.53522 13.2209 4.35659C12.2856 3.17796 10.9791 2.35039 9.5138 2.00844C8.04852 1.66648 6.51066 1.83027 5.15027 2.47315C3.78988 3.11603 2.68697 4.20021 2.02088 5.54939C1.35478 6.89856 1.16468 8.4334 1.48148 9.90431C1.79828 11.3752 2.60335 12.6957 3.76579 13.6511C4.92823 14.6064 6.37966 15.1405 7.88408 15.1663C9.38851 15.1922 10.8574 14.7084 12.052 13.7936" stroke="#E34F0E" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>' |
| 250 | ], |
| 251 | [ |
| 252 | 'heading' => __('Lightbox', 'custom-facebook-feed'), |
| 253 | 'icon' => '<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.33333 2.5H3.33333C2.97971 2.5 2.64057 2.64048 2.39052 2.89052C2.14048 3.14057 2 3.47971 2 3.83333V5.83333M14 5.83333V3.83333C14 3.47971 13.8595 3.14057 13.6095 2.89052C13.3594 2.64048 13.0203 2.5 12.6667 2.5H10.6667M10.6667 14.5H12.6667C13.0203 14.5 13.3594 14.3595 13.6095 14.1095C13.8595 13.8594 14 13.5203 14 13.1667V11.1667M2 11.1667V13.1667C2 13.5203 2.14048 13.8594 2.39052 14.1095C2.64057 14.3595 2.97971 14.5 3.33333 14.5H5.33333" stroke="#CC7A00" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>' |
| 254 | ], |
| 255 | [ |
| 256 | 'heading' => __('And many more', 'custom-facebook-feed'), |
| 257 | 'icon' => '<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.9987 9.16634C8.36689 9.16634 8.66536 8.86786 8.66536 8.49967C8.66536 8.13148 8.36689 7.83301 7.9987 7.83301C7.63051 7.83301 7.33203 8.13148 7.33203 8.49967C7.33203 8.86786 7.63051 9.16634 7.9987 9.16634Z" fill="#434960" stroke="#434960" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M12.6667 9.16634C13.0349 9.16634 13.3333 8.86786 13.3333 8.49967C13.3333 8.13148 13.0349 7.83301 12.6667 7.83301C12.2985 7.83301 12 8.13148 12 8.49967C12 8.86786 12.2985 9.16634 12.6667 9.16634Z" fill="#434960" stroke="#434960" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M3.33464 9.16634C3.70283 9.16634 4.0013 8.86786 4.0013 8.49967C4.0013 8.13148 3.70283 7.83301 3.33464 7.83301C2.96645 7.83301 2.66797 8.13148 2.66797 8.49967C2.66797 8.86786 2.96645 9.16634 3.33464 9.16634Z" fill="#434960" stroke="#434960" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>' |
| 258 | ] |
| 259 | ] |
| 260 | ] |
| 261 | ], |
| 262 | |
| 263 | ] |
| 264 | ]; |
| 265 | |
| 266 | $dynamic_features_list = self::get_dynamic_features_list(); |
| 267 | |
| 268 | if (isset($data['steps']) && sizeof($dynamic_features_list) > 0) { |
| 269 | $key_cf_ft = array_search('configure-features', array_column($data['steps'], 'id')); |
| 270 | if ($key_cf_ft !== false) { |
| 271 | $new_features_lit = array_merge($data['steps'][$key_cf_ft]['featuresList'], $dynamic_features_list) ; |
| 272 | $data['steps'][$key_cf_ft]['featuresList'] = $new_features_lit; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | return $data; |
| 277 | } |
| 278 | |
| 279 | |
| 280 | /** |
| 281 | * Return Dynamic Features List depending on multiple criteria |
| 282 | * |
| 283 | * @return array |
| 284 | * |
| 285 | * @since 6.X |
| 286 | */ |
| 287 | public static function get_dynamic_features_list() |
| 288 | { |
| 289 | $features_list = []; |
| 290 | $smash_plugin_list = self::get_smash_plugins_list(); |
| 291 | if (isset($smash_plugin_list['plugins']) && sizeof($smash_plugin_list['plugins']) > 0) { |
| 292 | $description_plugins = implode(', ', $smash_plugin_list['text']); |
| 293 | $search = ','; |
| 294 | $description_plugins_text = strrev(preg_replace(strrev("/$search/"), strrev(' and '), strrev($description_plugins), 1)); |
| 295 | |
| 296 | $plugins_info = []; |
| 297 | foreach ($smash_plugin_list['plugins'] as $p_item) { |
| 298 | if ($p_item['is_installed'] === false) { |
| 299 | array_push( |
| 300 | $plugins_info, |
| 301 | $p_item |
| 302 | ); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | array_push( |
| 307 | $features_list, |
| 308 | [ |
| 309 | 'data' => [ |
| 310 | 'id' => $description_plugins, |
| 311 | 'type' => 'install_plugins', |
| 312 | 'plugins' => 'smash' |
| 313 | ], |
| 314 | 'heading' => __('Social Feed Collection', 'custom-facebook-feed'), |
| 315 | 'description' => __('Install', 'custom-facebook-feed') . ' ' . $description_plugins_text . ' ' . __('feed plugins for more fresh content', 'custom-facebook-feed'), |
| 316 | 'color' => 'blue', |
| 317 | 'active' => true, |
| 318 | 'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M21 15.9999V7.9999C20.9996 7.64918 20.9071 7.30471 20.7315 7.00106C20.556 6.69742 20.3037 6.44526 20 6.2699L13 2.2699C12.696 2.09437 12.3511 2.00195 12 2.00195C11.6489 2.00195 11.304 2.09437 11 2.2699L4 6.2699C3.69626 6.44526 3.44398 6.69742 3.26846 7.00106C3.09294 7.30471 3.00036 7.64918 3 7.9999V15.9999C3.00036 16.3506 3.09294 16.6951 3.26846 16.9987C3.44398 17.3024 3.69626 17.5545 4 17.7299L11 21.7299C11.304 21.9054 11.6489 21.9979 12 21.9979C12.3511 21.9979 12.696 21.9054 13 21.7299L20 17.7299C20.3037 17.5545 20.556 17.3024 20.7315 16.9987C20.9071 16.6951 20.9996 16.3506 21 15.9999Z" stroke="#696D80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M3.26953 6.95996L11.9995 12.01L20.7295 6.95996" stroke="#696D80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 22.08V12" stroke="#696D80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>', |
| 319 | 'plugins' => $plugins_info, |
| 320 | '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'), |
| 321 | ] |
| 322 | ); |
| 323 | } |
| 324 | |
| 325 | |
| 326 | // Reviews Plugin |
| 327 | $reviews_plugin = self::get_smash_reviews_plugin(); |
| 328 | if ($reviews_plugin !== false) { |
| 329 | array_push($features_list, $reviews_plugin); |
| 330 | } |
| 331 | |
| 332 | // WPChat Plugin |
| 333 | $wpchat_plugin = self::get_smash_wpchat_plugin(); |
| 334 | if ($wpchat_plugin !== false) { |
| 335 | array_push($features_list, $wpchat_plugin); |
| 336 | } |
| 337 | |
| 338 | return $features_list; |
| 339 | } |
| 340 | |
| 341 | |
| 342 | /** |
| 343 | * Return Uninstalled SmashBalloon Plugins |
| 344 | * |
| 345 | * @return array |
| 346 | * |
| 347 | * @since 6.X |
| 348 | */ |
| 349 | public static function get_smash_plugins_list() |
| 350 | { |
| 351 | $installed_plugins = get_plugins(); |
| 352 | |
| 353 | // check whether the pro or free plugins are installed |
| 354 | $is_facebook_installed = false; |
| 355 | $facebook_plugin = 'custom-facebook-feed/custom-facebook-feed.php'; |
| 356 | if (isset($installed_plugins['custom-facebook-feed-pro/custom-facebook-feed.php'])) { |
| 357 | $is_facebook_installed = true; |
| 358 | $facebook_plugin = 'custom-facebook-feed-pro/custom-facebook-feed.php'; |
| 359 | } elseif (isset($installed_plugins['custom-facebook-feed/custom-facebook-feed.php'])) { |
| 360 | $is_facebook_installed = true; |
| 361 | } |
| 362 | |
| 363 | $is_instagram_installed = false; |
| 364 | $instagram_plugin = 'instagram-feed/instagram-feed.php'; |
| 365 | if (isset($installed_plugins['instagram-feed-pro/instagram-feed.php'])) { |
| 366 | $is_instagram_installed = true; |
| 367 | $instagram_plugin = 'instagram-feed-pro/instagram-feed.php'; |
| 368 | } elseif (isset($installed_plugins['instagram-feed/instagram-feed.php'])) { |
| 369 | $is_instagram_installed = true; |
| 370 | } |
| 371 | |
| 372 | $is_twitter_installed = false; |
| 373 | $twitter_plugin = 'custom-twitter-feeds/custom-twitter-feed.php'; |
| 374 | if (isset($installed_plugins['custom-twitter-feeds-pro/custom-twitter-feed.php'])) { |
| 375 | $is_twitter_installed = true; |
| 376 | $twitter_plugin = 'custom-twitter-feeds-pro/custom-twitter-feed.php'; |
| 377 | } elseif (isset($installed_plugins['custom-twitter-feeds/custom-twitter-feed.php'])) { |
| 378 | $is_twitter_installed = true; |
| 379 | } |
| 380 | |
| 381 | $is_youtube_installed = false; |
| 382 | $youtube_plugin = 'feeds-for-youtube/youtube-feed.php'; |
| 383 | if (isset($installed_plugins['youtube-feed-pro/youtube-feed.php'])) { |
| 384 | $is_youtube_installed = true; |
| 385 | $youtube_plugin = 'youtube-feed-pro/youtube-feed.php'; |
| 386 | } elseif (isset($installed_plugins['feeds-for-youtube/youtube-feed.php'])) { |
| 387 | $is_youtube_installed = true; |
| 388 | } |
| 389 | |
| 390 | $is_tiktok_installed = false; |
| 391 | $tiktok_plugin = 'feeds-for-tiktok/feeds-for-tiktok.php'; |
| 392 | if (isset($installed_plugins['tiktok-feeds-pro/tiktok-feeds-pro.php'])) { |
| 393 | $is_tiktok_installed = true; |
| 394 | $tiktok_plugin = 'tiktok-feeds-pro/tiktok-feeds-pro.php'; |
| 395 | } elseif (isset($installed_plugins['feeds-for-tiktok/feeds-for-tiktok.php'])) { |
| 396 | $is_tiktok_installed = true; |
| 397 | } |
| 398 | |
| 399 | $smash_list = [ |
| 400 | 'text' => [], |
| 401 | 'plugins' => [ |
| 402 | [ |
| 403 | 'type' => 'instagram', |
| 404 | 'is_installed' => $is_instagram_installed, |
| 405 | 'download_link' => $instagram_plugin, |
| 406 | 'min_php' => '5.6.0', |
| 407 | 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/insta-icon.svg' |
| 408 | ], |
| 409 | [ |
| 410 | 'type' => 'facebook', |
| 411 | 'is_installed' => $is_facebook_installed, |
| 412 | 'download_link' => $facebook_plugin, |
| 413 | 'min_php' => '5.6.0', |
| 414 | 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/fb-icon.svg' |
| 415 | ], |
| 416 | [ |
| 417 | 'type' => 'twitter', |
| 418 | 'is_installed' => $is_twitter_installed, |
| 419 | 'download_link' => $twitter_plugin, |
| 420 | 'min_php' => '5.6.0', |
| 421 | 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/twitter-icon.svg' |
| 422 | |
| 423 | ], |
| 424 | [ |
| 425 | 'type' => 'youtube', |
| 426 | 'is_installed' => $is_youtube_installed, |
| 427 | 'download_link' => $youtube_plugin, |
| 428 | 'min_php' => '5.6.0', |
| 429 | 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/youtube-icon.svg' |
| 430 | ], |
| 431 | [ |
| 432 | 'type' => 'tiktok', |
| 433 | 'is_installed' => $is_tiktok_installed, |
| 434 | 'download_link' => $tiktok_plugin, |
| 435 | 'min_php' => '7.0', |
| 436 | 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/tiktok-icon.svg' |
| 437 | ] |
| 438 | ] |
| 439 | ]; |
| 440 | foreach ($smash_list['plugins'] as $mash_plugin) { |
| 441 | if (version_compare(PHP_VERSION, $mash_plugin['min_php'], '<')) { |
| 442 | $mash_plugin['is_installed'] = true; |
| 443 | } |
| 444 | if ($mash_plugin['type'] === self::$plugin_name || $mash_plugin['is_installed'] === true) { |
| 445 | unset($mash_plugin); |
| 446 | } else { |
| 447 | array_push($smash_list['text'], ucfirst($mash_plugin['type'])); |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | return $smash_list; |
| 452 | } |
| 453 | |
| 454 | |
| 455 | /** |
| 456 | * Return Reviews Plugin if not Installed |
| 457 | * |
| 458 | * @return array |
| 459 | * |
| 460 | * @since 6.X |
| 461 | */ |
| 462 | public static function get_smash_reviews_plugin() |
| 463 | { |
| 464 | $installed_plugins = get_plugins(); |
| 465 | $min_php = '7.1'; |
| 466 | |
| 467 | $is_reviews_installed = false; |
| 468 | $reviews_plugin = 'reviews-feed/sb-reviews.php'; |
| 469 | if (isset($installed_plugins['reviews-feed-pro/sb-reviews-pro.php'])) { |
| 470 | $is_reviews_installed = true; |
| 471 | $reviews_plugin = 'reviews-feed-pro/sb-reviews-pro.php'; |
| 472 | } elseif (isset($installed_plugins['reviews-feed/sb-reviews.php'])) { |
| 473 | $is_reviews_installed = true; |
| 474 | } |
| 475 | |
| 476 | if (version_compare(PHP_VERSION, $min_php, '<')) { |
| 477 | $is_reviews_installed = true; |
| 478 | } |
| 479 | |
| 480 | if ($is_reviews_installed === false) { |
| 481 | return [ |
| 482 | 'data' => [ |
| 483 | 'id' => 'reviews', |
| 484 | 'type' => 'install_plugins' |
| 485 | ], |
| 486 | 'heading' => __('Customer Reviews Plugin', 'custom-facebook-feed'), |
| 487 | 'description' => __('Install Reviews Feed to display customer reviews from Google or Yelp and build trust', 'custom-facebook-feed'), |
| 488 | 'color' => 'blue', |
| 489 | 'active' => true, |
| 490 | 'icon' => '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 9.50003C19.0034 10.8199 18.6951 12.1219 18.1 13.3C17.3944 14.7118 16.3098 15.8992 14.9674 16.7293C13.6251 17.5594 12.0782 17.9994 10.5 18C9.18013 18.0035 7.87812 17.6951 6.7 17.1L1 19L2.9 13.3C2.30493 12.1219 1.99656 10.8199 2 9.50003C2.00061 7.92179 2.44061 6.37488 3.27072 5.03258C4.10083 3.69028 5.28825 2.6056 6.7 1.90003C7.87812 1.30496 9.18013 0.996587 10.5 1.00003H11C13.0843 1.11502 15.053 1.99479 16.5291 3.47089C18.0052 4.94699 18.885 6.91568 19 9.00003V9.50003Z" stroke="#696D80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>', |
| 491 | 'plugins' => [ |
| 492 | [ |
| 493 | 'type' => 'reviews', |
| 494 | 'is_installed' => $is_reviews_installed, |
| 495 | 'download_link' => $reviews_plugin, |
| 496 | 'min_php' => $min_php, |
| 497 | 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/reviews-icon.svg' |
| 498 | ] |
| 499 | ], |
| 500 | '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'), |
| 501 | ]; |
| 502 | } |
| 503 | return false; |
| 504 | } |
| 505 | |
| 506 | /** |
| 507 | * Return WPChat Plugin if not Installed |
| 508 | * |
| 509 | * @return array |
| 510 | * |
| 511 | * @since 6.X |
| 512 | */ |
| 513 | public static function get_smash_wpchat_plugin() |
| 514 | { |
| 515 | $installed_plugins = get_plugins(); |
| 516 | $min_php = '8.0'; |
| 517 | |
| 518 | $is_wpchat_installed = false; |
| 519 | $wpchat_plugin = 'smashballoon-wpchat-livechat-customer-support/wp-chat.php'; |
| 520 | if (isset($installed_plugins['wp-chat-pro/wp-chat-pro.php'])) { |
| 521 | $is_wpchat_installed = true; |
| 522 | $wpchat_plugin = 'wp-chat-pro/wp-chat-pro.php'; |
| 523 | } elseif (isset($installed_plugins['smashballoon-wpchat-livechat-customer-support/wp-chat.php'])) { |
| 524 | $is_wpchat_installed = true; |
| 525 | } |
| 526 | |
| 527 | if (version_compare(PHP_VERSION, $min_php, '<')) { |
| 528 | $is_wpchat_installed = true; |
| 529 | } |
| 530 | |
| 531 | if ($is_wpchat_installed === false) { |
| 532 | return [ |
| 533 | 'data' => [ |
| 534 | 'id' => 'wpchat', |
| 535 | 'type' => 'install_plugins' |
| 536 | ], |
| 537 | 'heading' => __('Live Chat Customer Support', 'custom-facebook-feed'), |
| 538 | 'description' => __('Install WPChat and connect with customers on WhatsApp, Messenger, Telegram & Instagram and more', 'custom-facebook-feed'), |
| 539 | 'color' => 'blue', |
| 540 | 'active' => true, |
| 541 | 'icon' => '<svg width="20" height="20" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="40" height="40"/><path d="M24.9043 5.62825C32.4709 5.62825 38.6048 11.7622 38.6048 19.3287C38.6048 27.0749 32.2378 33.1326 24.7466 33.0311L1.3954 34.2794L4.02646 26.2735C2.36821 24.0988 1.39563 21.3894 1.39563 18.4817C1.39563 11.3829 7.15032 5.62825 14.2491 5.62825H24.9043Z" fill="#F53C5E"/><path fill-rule="evenodd" clip-rule="evenodd" d="M15.4226 18.6218V18.7695C15.4226 20.8897 17.1414 22.6085 19.2616 22.6085C21.3819 22.6085 23.1007 20.8897 23.1007 18.7695V18.6218H26.9397V18.7695C26.9397 23.0099 23.5021 26.4475 19.2616 26.4475C15.0211 26.4475 11.5836 23.0099 11.5836 18.7695V18.6218H15.4226Z" fill="white"/></svg>', |
| 542 | 'plugins' => [ |
| 543 | [ |
| 544 | 'type' => 'wpchat', |
| 545 | 'is_installed' => $is_wpchat_installed, |
| 546 | 'download_link' => $wpchat_plugin, |
| 547 | 'min_php' => $min_php, |
| 548 | 'icon' => CFF_PLUGIN_URL . 'admin/assets/img/wpchat-icon.svg' |
| 549 | ] |
| 550 | ], |
| 551 | 'tooltip' => __('Enabling this feature will install WPChat plugin. WPChat by Smash Balloon helps you add live chat and customer support to your website.', 'custom-facebook-feed'), |
| 552 | ]; |
| 553 | } |
| 554 | return false; |
| 555 | } |
| 556 | |
| 557 | |
| 558 | /** |
| 559 | * Return Awesome Motive Plugins |
| 560 | * |
| 561 | * @return array |
| 562 | * |
| 563 | * @since 6.X |
| 564 | */ |
| 565 | public static function get_awesomemotive_plugins() |
| 566 | { |
| 567 | $installed_plugins = get_plugins(); |
| 568 | |
| 569 | $awesomemotive_plugins_list = [ |
| 570 | [ |
| 571 | 'plugin' => 'allinoneseo', |
| 572 | 'data' => [ |
| 573 | 'type' => 'install_plugins', |
| 574 | 'id' => 'allinoneseo', |
| 575 | 'pluginName' => __('All in One SEO', 'custom-facebook-feed'), |
| 576 | ], |
| 577 | 'heading' => __('All in One SEO Toolkit', 'custom-facebook-feed'), |
| 578 | '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'), |
| 579 | 'color' => 'blue', |
| 580 | 'active' => true, |
| 581 | 'icon' => CFF_BUILDER_URL . 'assets/img/allinoneseo.png', |
| 582 | 'installs_number' => '3 Million+ Installs' |
| 583 | ], |
| 584 | [ |
| 585 | 'plugin' => 'monsterinsight', |
| 586 | 'data' => [ |
| 587 | 'type' => 'install_plugins', |
| 588 | 'id' => 'monsterinsight', |
| 589 | 'pluginName' => __('Monster Insights', 'custom-facebook-feed'), |
| 590 | ], |
| 591 | 'heading' => __('Analytics by MonsterInsights', 'custom-facebook-feed'), |
| 592 | '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'), |
| 593 | 'color' => 'blue', |
| 594 | 'active' => true, |
| 595 | 'icon' => CFF_BUILDER_URL . 'assets/img/monsterinsight.png', |
| 596 | 'installs_number' => '3 Million+ Installs' |
| 597 | ], |
| 598 | [ |
| 599 | 'plugin' => 'wpforms', |
| 600 | 'data' => [ |
| 601 | 'type' => 'install_plugins', |
| 602 | 'id' => 'wpforms', |
| 603 | 'pluginName' => __('WPForms', 'custom-facebook-feed'), |
| 604 | ], |
| 605 | 'heading' => __('Forms by WPForms', 'custom-facebook-feed'), |
| 606 | 'description' => __('Create contact, subscription or payment forms with the most beginner friendly drag & drop WordPress forms plugin', 'custom-facebook-feed'), |
| 607 | 'color' => 'blue', |
| 608 | 'active' => true, |
| 609 | 'icon' => CFF_BUILDER_URL . 'assets/img/wpforms.png', |
| 610 | 'installs_number' => '5 Million+ Installs' |
| 611 | ], |
| 612 | [ |
| 613 | 'plugin' => 'seedprod', |
| 614 | 'data' => [ |
| 615 | 'type' => 'install_plugins', |
| 616 | 'id' => 'seedprod', |
| 617 | 'pluginName' => __('SeedProd', 'custom-facebook-feed'), |
| 618 | ], |
| 619 | 'heading' => __('SeedProd Website Builder', 'custom-facebook-feed'), |
| 620 | 'description' => __('A simple and powerful theme builder, landing page builder, "coming soon" page builder, and maintenance mode notice builder', 'custom-facebook-feed'), |
| 621 | 'color' => 'blue', |
| 622 | 'active' => true, |
| 623 | 'icon' => CFF_BUILDER_URL . 'assets/img/seedprod.png', |
| 624 | 'installs_number' => '900 Thousand+ Installs' |
| 625 | ], |
| 626 | [ |
| 627 | 'plugin' => 'optinmonster', |
| 628 | 'data' => [ |
| 629 | 'type' => 'install_plugins', |
| 630 | 'id' => 'optinmonster', |
| 631 | 'pluginName' => __('OptinMonster', 'custom-facebook-feed'), |
| 632 | ], |
| 633 | 'heading' => __('OptinMonster Popup Builder', 'custom-facebook-feed'), |
| 634 | 'description' => __('Make popups & opt-in forms to build your email newsletter subscribers, generate leads, and close sales', 'custom-facebook-feed'), |
| 635 | 'color' => 'blue', |
| 636 | 'active' => true, |
| 637 | 'icon' => CFF_BUILDER_URL . 'assets/img/optinmonster.png', |
| 638 | 'installs_number' => '1 Million+ Installs' |
| 639 | ], |
| 640 | [ |
| 641 | 'plugin' => 'pushengage', |
| 642 | 'data' => [ |
| 643 | 'type' => 'install_plugins', |
| 644 | 'id' => 'pushengage', |
| 645 | 'pluginName' => __('PushEngage', 'custom-facebook-feed'), |
| 646 | ], |
| 647 | 'heading' => __('PushEngage Notifications', 'custom-facebook-feed'), |
| 648 | 'description' => __('Create and send high-converting web push notifications to your website visitors.', 'custom-facebook-feed'), |
| 649 | 'color' => 'blue', |
| 650 | 'active' => true, |
| 651 | 'icon' => CFF_BUILDER_URL . 'assets/img/pushengage.svg', |
| 652 | 'installs_number' => '10 Thousand+ Installs' |
| 653 | ] |
| 654 | ]; |
| 655 | |
| 656 | $available_plugins = []; |
| 657 | foreach ($awesomemotive_plugins_list as $plugin) { |
| 658 | if (!self::check_awesome_motive_plugin($plugin['plugin'], $installed_plugins)) { |
| 659 | array_push($available_plugins, $plugin); |
| 660 | } |
| 661 | } |
| 662 | return array_slice($available_plugins, 0, 3); |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * Check if AWESOME MOTIVE Plugin |
| 667 | * |
| 668 | * @return boolean |
| 669 | * |
| 670 | * @since 6.X |
| 671 | */ |
| 672 | public static function check_awesome_motive_plugin($plugin, $installed_plugins) |
| 673 | { |
| 674 | |
| 675 | switch ($plugin) { |
| 676 | case 'allinoneseo': |
| 677 | if ( |
| 678 | isset($installed_plugins['all-in-one-seo-pack/all_in_one_seo_pack.php']) |
| 679 | || isset($installed_plugins['all-in-one-seo-pack-pro/all_in_one_seo_pack.php']) |
| 680 | ) { |
| 681 | return true; |
| 682 | } |
| 683 | return false; |
| 684 | case 'monsterinsight': |
| 685 | if ( |
| 686 | isset($installed_plugins['google-analytics-for-wordpress/googleanalytics.php']) |
| 687 | || isset($installed_plugins['google-analytics-premium/googleanalytics-premium.php']) |
| 688 | ) { |
| 689 | return true; |
| 690 | } |
| 691 | return false; |
| 692 | case 'wpforms': |
| 693 | if ( |
| 694 | isset($installed_plugins['wpforms-lite/wpforms.php']) |
| 695 | || isset($installed_plugins['wpforms/wpforms.php']) |
| 696 | ) { |
| 697 | return true; |
| 698 | } |
| 699 | return false; |
| 700 | case 'seedprod': |
| 701 | if ( |
| 702 | isset($installed_plugins['coming-soon/coming-soon.php']) |
| 703 | ) { |
| 704 | return true; |
| 705 | } |
| 706 | return false; |
| 707 | case 'optinmonster': |
| 708 | if ( |
| 709 | isset($installed_plugins['optinmonster/optin-monster-wp-api.php']) |
| 710 | ) { |
| 711 | return true; |
| 712 | } |
| 713 | return false; |
| 714 | case 'pushengage': |
| 715 | if ( |
| 716 | isset($installed_plugins['pushengage/main.php']) |
| 717 | ) { |
| 718 | return true; |
| 719 | } |
| 720 | return false; |
| 721 | } |
| 722 | } |
| 723 | /** |
| 724 | * Get Plugin Download |
| 725 | * |
| 726 | * @since 6.X |
| 727 | */ |
| 728 | public static function get_plugin_download_link($plugin_name) |
| 729 | { |
| 730 | $plugin_download = false; |
| 731 | switch (strtolower($plugin_name)) { |
| 732 | case 'facebook': |
| 733 | $plugin_download = 'https://downloads.wordpress.org/plugin/custom-facebook-feed.zip'; |
| 734 | break; |
| 735 | case 'instagram': |
| 736 | $plugin_download = 'https://downloads.wordpress.org/plugin/instagram-feed.zip'; |
| 737 | break; |
| 738 | case 'twitter': |
| 739 | $plugin_download = 'https://downloads.wordpress.org/plugin/custom-twitter-feeds.zip'; |
| 740 | break; |
| 741 | case 'youtube': |
| 742 | $plugin_download = 'https://downloads.wordpress.org/plugin/feeds-for-youtube.zip'; |
| 743 | break; |
| 744 | case 'tiktok': |
| 745 | $plugin_download = 'https://downloads.wordpress.org/plugin/feeds-for-tiktok.zip'; |
| 746 | break; |
| 747 | case 'reviews': |
| 748 | $plugin_download = 'https://downloads.wordpress.org/plugin/reviews-feed.zip'; |
| 749 | break; |
| 750 | case 'wpchat': |
| 751 | $plugin_download = 'https://downloads.wordpress.org/plugin/smashballoon-wpchat-livechat-customer-support.zip'; |
| 752 | break; |
| 753 | case 'allinoneseo': |
| 754 | $plugin_download = 'https://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip'; |
| 755 | break; |
| 756 | case 'monsterinsight': |
| 757 | $plugin_download = 'https://downloads.wordpress.org/plugin/google-analytics-for-wordpress.zip'; |
| 758 | break; |
| 759 | case 'wpforms': |
| 760 | $plugin_download = 'https://downloads.wordpress.org/plugin/wpforms-lite.zip'; |
| 761 | break; |
| 762 | case 'seedprod': |
| 763 | $plugin_download = 'https://downloads.wordpress.org/plugin/coming-soon.zip'; |
| 764 | break; |
| 765 | case 'optinmonster': |
| 766 | $plugin_download = 'https://downloads.wordpress.org/plugin/optinmonster.zip'; |
| 767 | break; |
| 768 | case 'pushengage': |
| 769 | $plugin_download = 'https://downloads.wordpress.org/plugin/pushengage.zip'; |
| 770 | break; |
| 771 | } |
| 772 | return $plugin_download; |
| 773 | } |
| 774 | /** |
| 775 | * Install Plugin |
| 776 | * |
| 777 | * @since 6.X |
| 778 | */ |
| 779 | public static function install_single_plugin($plugin_name) |
| 780 | { |
| 781 | $plugin_download = self::get_plugin_download_link(strtolower(str_replace(' ', '', $plugin_name))); |
| 782 | if ($plugin_download === false || !current_user_can('install_plugins')) { |
| 783 | return false; |
| 784 | } |
| 785 | |
| 786 | |
| 787 | if (strpos($plugin_download, 'https://downloads.wordpress.org/plugin/') !== 0) { |
| 788 | return false; |
| 789 | } |
| 790 | |
| 791 | set_current_screen('cff-feed-builder'); |
| 792 | // Prepare variables. |
| 793 | $url = esc_url_raw( |
| 794 | add_query_arg( |
| 795 | array( |
| 796 | 'page' => 'cff-feed-builder', |
| 797 | ), |
| 798 | admin_url('admin.php') |
| 799 | ) |
| 800 | ); |
| 801 | |
| 802 | $creds = request_filesystem_credentials($url, '', false, false, null); |
| 803 | // Check for file system permissions. |
| 804 | if (false === $creds || ! WP_Filesystem($creds)) { |
| 805 | return false; |
| 806 | } |
| 807 | // Do not allow WordPress to search/download translations, as this will break JS output. |
| 808 | remove_action('upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20); |
| 809 | |
| 810 | // Create the plugin upgrader with our custom skin. |
| 811 | $installer = new \CustomFacebookFeed\Helpers\PluginSilentUpgrader(new \CustomFacebookFeed\Admin\CFF_Install_Skin()); |
| 812 | |
| 813 | // Error check. |
| 814 | if (! method_exists($installer, 'install') || empty($plugin_download)) { |
| 815 | wp_send_json_error($error); |
| 816 | } |
| 817 | |
| 818 | $installer->install(esc_url_raw(wp_unslash($plugin_download))); |
| 819 | |
| 820 | // Flush the cache and return the newly installed plugin basename. |
| 821 | wp_cache_flush(); |
| 822 | |
| 823 | $plugin_basename = $installer->plugin_info(); |
| 824 | |
| 825 | if ($plugin_basename) { |
| 826 | activate_plugin($plugin_basename); |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | /** |
| 831 | * Process Wizard Data |
| 832 | * Save Settings, Install Plugins and more |
| 833 | * |
| 834 | * @since 6.0.8 |
| 835 | */ |
| 836 | public function process_wizard_data() |
| 837 | { |
| 838 | if (! isset($_POST['data'])) { |
| 839 | wp_send_json_error(); |
| 840 | } |
| 841 | |
| 842 | check_ajax_referer('cff-admin', 'nonce'); |
| 843 | $cap = current_user_can('manage_custom_facebook_feed_options') ? 'manage_custom_facebook_feed_options' : 'manage_options'; |
| 844 | $cap = apply_filters('cff_settings_pages_capability', $cap); |
| 845 | if (! current_user_can($cap)) { |
| 846 | wp_send_json_error(); // This auto-dies. |
| 847 | } |
| 848 | |
| 849 | $cff_settings = get_option('cff_style_settings', array()); |
| 850 | |
| 851 | $onboarding_data = sanitize_text_field(stripslashes($_POST['data'])); |
| 852 | $onboarding_data = json_decode($onboarding_data, true); |
| 853 | foreach ($onboarding_data as $single_data) { |
| 854 | if ($single_data['type'] === 'settings') { |
| 855 | if (isset($single_data['value'])) { |
| 856 | if ($single_data['id'] === 'cff_locale') { |
| 857 | update_option('cff_locale', $single_data['value']); |
| 858 | } else { |
| 859 | $cff_settings[$single_data['id']] = $single_data['value']; |
| 860 | } |
| 861 | } else { |
| 862 | $cff_settings[$single_data['id']] = $single_data['id'] === 'cff_disable_resize' ? false : true; |
| 863 | } |
| 864 | } |
| 865 | if ($single_data['type'] === 'install_plugins' && current_user_can('install_plugins')) { |
| 866 | $plugins = explode(',', $single_data['id']); |
| 867 | foreach ($plugins as $plugin_name) { |
| 868 | @CFF_Onboarding_wizard::install_single_plugin($plugin_name); |
| 869 | } |
| 870 | } |
| 871 | } |
| 872 | update_option('cff_style_settings', $cff_settings); |
| 873 | |
| 874 | // Deleting Redirect Data for 3rd plugins |
| 875 | $this->disable_installed_plugins_redirect(); |
| 876 | |
| 877 | wp_die(); |
| 878 | } |
| 879 | |
| 880 | |
| 881 | /** |
| 882 | * Dismiss Onboarding Wizard |
| 883 | * |
| 884 | * @since 6.0.8 |
| 885 | */ |
| 886 | public function dismiss_wizard() |
| 887 | { |
| 888 | check_ajax_referer('cff-admin', 'nonce'); |
| 889 | |
| 890 | $cap = current_user_can('manage_custom_facebook_feed_options') ? 'manage_custom_facebook_feed_options' : 'manage_options'; |
| 891 | $cap = apply_filters('cff_settings_pages_capability', $cap); |
| 892 | if (! current_user_can($cap)) { |
| 893 | wp_send_json_error(); // This auto-dies. |
| 894 | } |
| 895 | |
| 896 | $cff_statuses_option = get_option('cff_statuses', array()); |
| 897 | $cff_statuses_option['wizard_dismissed'] = true; |
| 898 | update_option('cff_statuses', $cff_statuses_option); |
| 899 | wp_send_json_error(); |
| 900 | } |
| 901 | |
| 902 | /** |
| 903 | * Disable Installed Plugins Redirect |
| 904 | * |
| 905 | * @since 6.0.8 |
| 906 | */ |
| 907 | public function disable_installed_plugins_redirect() |
| 908 | { |
| 909 | // Monster Insight |
| 910 | delete_transient('_monsterinsights_activation_redirect'); |
| 911 | |
| 912 | // All in one SEO |
| 913 | update_option('aioseo_activation_redirect', true); |
| 914 | |
| 915 | // WPForms |
| 916 | update_option('wpforms_activation_redirect', true); |
| 917 | |
| 918 | // Optin Monster |
| 919 | delete_transient('optin_monster_api_activation_redirect'); |
| 920 | update_option('optin_monster_api_activation_redirect_disabled', true); |
| 921 | |
| 922 | // Seed PROD |
| 923 | update_option('seedprod_dismiss_setup_wizard', true); |
| 924 | |
| 925 | // PushEngage |
| 926 | delete_transient('pushengage_activation_redirect'); |
| 927 | |
| 928 | // Smash Plugin redirect remove |
| 929 | $this->disable_smash_installed_plugins_redirect(); |
| 930 | } |
| 931 | |
| 932 | /** |
| 933 | * Disable Smash Balloon Plugins Redirect |
| 934 | * |
| 935 | * @since 6.0.8 |
| 936 | */ |
| 937 | public function disable_smash_installed_plugins_redirect() |
| 938 | { |
| 939 | $smash_list = [ |
| 940 | 'facebook' => 'cff_plugin_do_activation_redirect', |
| 941 | 'instagram' => 'sbi_plugin_do_activation_redirect', |
| 942 | 'youtube' => 'sby_plugin_do_activation_redirect', |
| 943 | 'twitter' => 'ctf_plugin_do_activation_redirect', |
| 944 | 'reviews' => 'sbr_plugin_do_activation_redirect', |
| 945 | 'wpchat' => 'wpchat_plugin_do_activation_redirect', |
| 946 | ]; |
| 947 | |
| 948 | if (isset($smash_list[self::$plugin_name])) { |
| 949 | unset($smash_list[self::$plugin_name]); |
| 950 | } |
| 951 | |
| 952 | foreach ($smash_list as $key => $opt) { |
| 953 | delete_option($opt); |
| 954 | } |
| 955 | } |
| 956 | } |
| 957 |