| 1 |
<?php |
| 2 |
/** |
| 3 |
* CartFlows Onboarding Core. |
| 4 |
* |
| 5 |
* @package CartFlows |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace CartflowsAdmin\AdminCore\Inc; |
| 9 |
|
| 10 |
// Exit if accessed directly. |
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Class OnboardingCore. |
| 17 |
*/ |
| 18 |
class OnboardingCore { |
| 19 |
|
| 20 |
/** |
| 21 |
* Instance |
| 22 |
* |
| 23 |
* @access private |
| 24 |
* @var object Class object. |
| 25 |
* @since 1.0.0 |
| 26 |
*/ |
| 27 |
private static $instance; |
| 28 |
|
| 29 |
/** |
| 30 |
* Initiator |
| 31 |
* |
| 32 |
* @since 1.0.0 |
| 33 |
* @return object initialized object of class. |
| 34 |
*/ |
| 35 |
public static function get_instance() { |
| 36 |
if ( ! isset( self::$instance ) ) { |
| 37 |
self::$instance = new self(); |
| 38 |
} |
| 39 |
return self::$instance; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Constructor. |
| 44 |
*/ |
| 45 |
public function __construct() { |
| 46 |
|
| 47 |
if ( apply_filters( 'cartflows_enable_setup_wizard', true ) && current_user_can( 'manage_options' ) ) { |
| 48 |
|
| 49 |
add_action( 'admin_menu', array( $this, 'admin_menus' ) ); |
| 50 |
add_action( 'admin_init', array( $this, 'setup_wizard' ) ); |
| 51 |
add_action( 'admin_init', array( $this, 'hide_notices' ) ); |
| 52 |
add_action( 'admin_notices', array( $this, 'show_setup_wizard' ) ); |
| 53 |
add_action( 'woocommerce_installed', array( $this, 'disable_woo_setup_redirect' ) ); |
| 54 |
// We are hiding admin bar intentionally, only on the setup wizard page. |
| 55 |
if ( isset( $_GET['page'] ) && 'cartflows-onboarding' === $_GET['page'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 56 |
add_filter( 'show_admin_bar', '__return_false', 1 ); //phpcs:ignore WordPressVIPMinimum.UserExperience.AdminBarRemoval.RemovalDetected, WordPressVIPMinimum.UserExperience.AdminBarRemoval.HidingDetected |
| 57 |
} |
| 58 |
|
| 59 |
add_action( 'init', array( $this, 'load_scripts' ) ); |
| 60 |
add_action( 'admin_print_styles', array( $this, 'load_admin_media_styles' ) ); |
| 61 |
|
| 62 |
add_action( 'admin_init', array( $this, 'redirect_to_onboarding' ) ); |
| 63 |
add_filter( 'before_cp_load_popup', array( $this, 'hide_convert_pro_popups' ), 10, 1 ); // Disable the render of Convert Pro popups in onboarding wizard. |
| 64 |
add_filter( 'astra_get_option_scroll-to-top-enable', '__return_false' ); // Remove Astra's Scroll to top arrow. |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Redirect to onboarding if required. |
| 70 |
* |
| 71 |
* @return void |
| 72 |
* @since 2.0.0 |
| 73 |
*/ |
| 74 |
public function redirect_to_onboarding() { |
| 75 |
|
| 76 |
if ( ! get_option( 'wcf_start_onboarding', false ) ) { |
| 77 |
return; |
| 78 |
} |
| 79 |
|
| 80 |
if ( '1' === get_option( 'wcf_setup_complete', false ) || '1' === get_option( 'wcf_setup_skipped', false ) ) { |
| 81 |
return; |
| 82 |
} |
| 83 |
|
| 84 |
delete_option( 'wcf_start_onboarding' ); |
| 85 |
wp_safe_redirect( esc_url_raw( admin_url( 'index.php?page=cartflows-onboarding' ) ) ); |
| 86 |
exit(); |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
/** |
| 91 |
* Load styles. |
| 92 |
*/ |
| 93 |
public function load_admin_media_styles() { |
| 94 |
|
| 95 |
$ary_libs = array( |
| 96 |
'common', |
| 97 |
'forms', |
| 98 |
); |
| 99 |
$admin_media_styles_url = add_query_arg( |
| 100 |
array( |
| 101 |
'c' => 0, |
| 102 |
'dir' => ! is_rtl() ? 'ltr' : 'rtl', |
| 103 |
'load[]' => implode( ',', $ary_libs ), |
| 104 |
'ver' => 'you_wp_version', |
| 105 |
), |
| 106 |
admin_url() . 'load-styles.php' |
| 107 |
); |
| 108 |
echo "<link rel='stylesheet' id='admin_styles_for_media-css' href='" . esc_url( $admin_media_styles_url ) . "' type='text/css' media='all' />"; |
| 109 |
} |
| 110 |
|
| 111 |
/** |
| 112 |
* Load media. |
| 113 |
*/ |
| 114 |
public function load_scripts() { |
| 115 |
|
| 116 |
add_action( 'wp_enqueue_scripts', array( $this, 'load_media_script' ) ); |
| 117 |
} |
| 118 |
|
| 119 |
/** |
| 120 |
* Load WP media script on init. |
| 121 |
*/ |
| 122 |
public function load_media_script() { |
| 123 |
wp_enqueue_media(); |
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* Hide a notice if the GET variable is set. |
| 128 |
*/ |
| 129 |
public function hide_notices() { |
| 130 |
|
| 131 |
if ( ! isset( $_GET['wcf-hide-notice'] ) ) { |
| 132 |
return; |
| 133 |
} |
| 134 |
|
| 135 |
$wcf_hide_notice = isset( $_GET['wcf-hide-notice'] ) ? sanitize_text_field( wp_unslash( $_GET['wcf-hide-notice'] ) ) : ''; |
| 136 |
$_wcf_notice_nonce = isset( $_GET['_wcf_notice_nonce'] ) ? sanitize_text_field( wp_unslash( $_GET['_wcf_notice_nonce'] ) ) : ''; |
| 137 |
|
| 138 |
if ( $wcf_hide_notice && $_wcf_notice_nonce && wp_verify_nonce( sanitize_text_field( wp_unslash( $_wcf_notice_nonce ) ), 'wcf_hide_notices_nonce' ) ) { |
| 139 |
update_option( 'wcf_setup_skipped', true ); |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Disable the woo redirect for new setup. |
| 145 |
*/ |
| 146 |
public function disable_woo_setup_redirect() { |
| 147 |
|
| 148 |
delete_transient( '_wc_activation_redirect' ); |
| 149 |
} |
| 150 |
|
| 151 |
/** |
| 152 |
* Show action links on the plugin screen. |
| 153 |
* |
| 154 |
* @since 1.0.0 |
| 155 |
* @return void |
| 156 |
*/ |
| 157 |
public function show_setup_wizard() { |
| 158 |
|
| 159 |
$screen = get_current_screen(); |
| 160 |
$screen_id = $screen ? $screen->id : ''; |
| 161 |
$allowed_screens = array( |
| 162 |
'cartflows_page_cartflows_settings', |
| 163 |
'edit-cartflows_flow', |
| 164 |
'dashboard', |
| 165 |
'plugins', |
| 166 |
); |
| 167 |
|
| 168 |
if ( ! in_array( $screen_id, $allowed_screens, true ) ) { |
| 169 |
return; |
| 170 |
} |
| 171 |
|
| 172 |
$status = get_option( 'wcf_setup_complete', false ); |
| 173 |
$skip_setup = get_option( 'wcf_setup_skipped', false ); |
| 174 |
|
| 175 |
if ( false === $status && ! $skip_setup ) { ?> |
| 176 |
<div class="notice notice-info wcf-notice"> |
| 177 |
<p><b><?php esc_html_e( 'Thanks for installing and using CartFlows!', 'cartflows' ); ?></b></p> |
| 178 |
<p><?php esc_html_e( 'It is easy to use the CartFlows. Please use the setup wizard to quick start setup.', 'cartflows' ); ?></p> |
| 179 |
<p> |
| 180 |
<a href="<?php echo esc_url( admin_url( 'index.php?page=cartflows-onboarding' ) ); ?>" class="button button-primary"> <?php esc_html_e( 'Start Setup', 'cartflows' ); ?></a> |
| 181 |
<a class="button-secondary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcf-hide-notice', 'install' ), 'wcf_hide_notices_nonce', '_wcf_notice_nonce' ) ); ?>"><?php esc_html_e( 'Skip Setup', 'cartflows' ); ?></a> |
| 182 |
</p> |
| 183 |
</div> |
| 184 |
<?php |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
/** |
| 189 |
* Add admin menus/screens. |
| 190 |
*/ |
| 191 |
public function admin_menus() { |
| 192 |
|
| 193 |
// Ignoring phpcs nonce rule as we are calling this function on admin action. |
| 194 |
if ( empty( $_GET['page'] ) || 'cartflows-onboarding' !== $_GET['page'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 195 |
return; |
| 196 |
} |
| 197 |
|
| 198 |
add_dashboard_page( '', '', 'manage_options', 'cartflows-onboarding', '' ); |
| 199 |
} |
| 200 |
|
| 201 |
/** |
| 202 |
* Show the setup wizard. |
| 203 |
*/ |
| 204 |
public function setup_wizard() { |
| 205 |
|
| 206 |
// Ignoring phpcs nonce rule as we are calling this function on admin action. |
| 207 |
if ( empty( $_GET['page'] ) || 'cartflows-onboarding' !== $_GET['page'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 208 |
return; |
| 209 |
} |
| 210 |
$this->load_required_scripts(); |
| 211 |
$this->localize_vars(); |
| 212 |
$this->unhook_deprecated_wp_callbacks(); |
| 213 |
|
| 214 |
// Disable loading of Query Monitor in footer. |
| 215 |
add_filter( 'qm/dispatch/html', '__return_false' ); |
| 216 |
|
| 217 |
ob_start(); |
| 218 |
include_once CARTFLOWS_DIR . 'admin-core/views/onboarding-base.php'; |
| 219 |
} |
| 220 |
|
| 221 |
/** |
| 222 |
* Detach WP core callbacks deprecated in 6.4 from the actions the |
| 223 |
* standalone onboarding view fires manually (admin_print_styles, admin_head). |
| 224 |
* |
| 225 |
* Without this, every onboarding load on WP 6.4+ emits PHP deprecation |
| 226 |
* notices for print_emoji_styles, wp_admin_bar_header, and |
| 227 |
* the_block_template_skip_link via _deprecated_function(). |
| 228 |
* |
| 229 |
* Centralised here (rather than inline in the view) so the deprecated- |
| 230 |
* callback list lives in one place and the view stays presentation-only. |
| 231 |
* |
| 232 |
* Scoped strictly to the CartFlows onboarding screen — the guard ensures |
| 233 |
* it cannot affect any other admin page even if called from elsewhere. |
| 234 |
* |
| 235 |
* @since x.x.x |
| 236 |
* @return void |
| 237 |
*/ |
| 238 |
private function unhook_deprecated_wp_callbacks() { |
| 239 |
|
| 240 |
// Hard guard — only run on the CartFlows onboarding screen. |
| 241 |
if ( empty( $_GET['page'] ) || 'cartflows-onboarding' !== $_GET['page'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 242 |
return; |
| 243 |
} |
| 244 |
|
| 245 |
$deprecated_callbacks = array( |
| 246 |
'admin_print_styles' => array( 'print_emoji_styles' ), |
| 247 |
'admin_head' => array( 'wp_admin_bar_header', 'the_block_template_skip_link' ), |
| 248 |
); |
| 249 |
|
| 250 |
foreach ( $deprecated_callbacks as $action => $callbacks ) { |
| 251 |
foreach ( $callbacks as $callback ) { |
| 252 |
remove_action( $action, $callback ); |
| 253 |
} |
| 254 |
} |
| 255 |
} |
| 256 |
|
| 257 |
/** |
| 258 |
* Load scripts. |
| 259 |
*/ |
| 260 |
public function load_required_scripts() { |
| 261 |
$handle = 'wcf-onboarding-app'; |
| 262 |
$build_path = CARTFLOWS_DIR . 'admin-core/assets/build/'; |
| 263 |
$build_url = CARTFLOWS_URL . 'admin-core/assets/build/'; |
| 264 |
$script_asset_path = $build_path . 'onboarding-app.asset.php'; |
| 265 |
$script_info = file_exists( $script_asset_path ) |
| 266 |
? include $script_asset_path |
| 267 |
: array( |
| 268 |
'dependencies' => array(), |
| 269 |
'version' => CARTFLOWS_VER, |
| 270 |
); |
| 271 |
|
| 272 |
$script_dep = array_merge( $script_info['dependencies'], array( 'updates' ) ); |
| 273 |
|
| 274 |
wp_register_script( |
| 275 |
$handle, |
| 276 |
$build_url . 'onboarding-app.js', |
| 277 |
$script_dep, |
| 278 |
$script_info['version'], |
| 279 |
true |
| 280 |
); |
| 281 |
|
| 282 |
wp_register_style( |
| 283 |
$handle, |
| 284 |
$build_url . 'onboarding-app.css', |
| 285 |
array(), |
| 286 |
CARTFLOWS_VER |
| 287 |
); |
| 288 |
|
| 289 |
wp_enqueue_script( $handle ); |
| 290 |
wp_enqueue_style( $handle ); |
| 291 |
wp_style_add_data( $handle, 'rtl', 'replace' ); |
| 292 |
|
| 293 |
wp_register_script( |
| 294 |
'wcf-onboarding-helper', |
| 295 |
CARTFLOWS_URL . 'admin-core/assets/js/onboarding-helper.js', |
| 296 |
array( 'jquery', 'wp-util', 'updates', 'media-upload' ), |
| 297 |
CARTFLOWS_VER, |
| 298 |
true |
| 299 |
); |
| 300 |
wp_enqueue_script( 'wcf-onboarding-helper' ); |
| 301 |
wp_enqueue_media(); |
| 302 |
wp_enqueue_script( 'jquery-ui' ); |
| 303 |
} |
| 304 |
|
| 305 |
/** |
| 306 |
* Localize variables in admin. |
| 307 |
*/ |
| 308 |
public function localize_vars() { |
| 309 |
|
| 310 |
$vars = array(); |
| 311 |
|
| 312 |
$plugins = array( |
| 313 |
array( |
| 314 |
'name' => 'WooCommerce', |
| 315 |
'slug' => 'woocommerce', |
| 316 |
'status' => $this->get_plugin_status( 'woocommerce/woocommerce.php' ), |
| 317 |
'required' => true, |
| 318 |
'description' => __( 'Powers your store — products, cart, and checkout. CartFlows requires it.', 'cartflows' ), |
| 319 |
'logo' => 'https://ps.w.org/woocommerce/assets/icon-128x128.png', |
| 320 |
), |
| 321 |
array( |
| 322 |
'name' => 'Cart Abandonment Recovery', |
| 323 |
'slug' => 'woo-cart-abandonment-recovery', |
| 324 |
'status' => $this->get_plugin_status( 'woo-cart-abandonment-recovery/woo-cart-abandonment-recovery.php' ), |
| 325 |
'required' => false, |
| 326 |
'description' => __( 'Recovers lost sales with automated follow-up emails.', 'cartflows' ), |
| 327 |
'logo' => 'https://ps.w.org/woo-cart-abandonment-recovery/assets/icon-128x128.gif', |
| 328 |
), |
| 329 |
array( |
| 330 |
'name' => 'Modern Cart', |
| 331 |
'slug' => 'modern-cart', |
| 332 |
'status' => $this->get_plugin_status( 'modern-cart/modern-cart.php' ), |
| 333 |
'required' => false, |
| 334 |
'description' => __( 'Adds a fast slide-in cart to your store.', 'cartflows' ), |
| 335 |
'logo' => 'https://ps.w.org/modern-cart/assets/icon.svg', |
| 336 |
), |
| 337 |
array( |
| 338 |
'name' => 'Power Coupons', |
| 339 |
'slug' => 'power-coupons', |
| 340 |
'status' => $this->get_plugin_status( 'power-coupons/power-coupons.php' ), |
| 341 |
'required' => false, |
| 342 |
'description' => __( 'Creates advanced discount coupons and smart offers.', 'cartflows' ), |
| 343 |
'logo' => 'https://ps.w.org/power-coupons/assets/icon.svg', |
| 344 |
), |
| 345 |
array( |
| 346 |
'name' => 'WooCommerce Payments', |
| 347 |
'slug' => 'woocommerce-payments', |
| 348 |
'status' => $this->get_plugin_status( 'woocommerce-payments/woocommerce-payments.php' ), |
| 349 |
'required' => false, |
| 350 |
'description' => __( 'Accepts credit cards and other payment methods on your checkout.', 'cartflows' ), |
| 351 |
'logo' => 'https://ps.w.org/woocommerce-payments/assets/icon-128x128.png', |
| 352 |
), |
| 353 |
array( |
| 354 |
'name' => 'Spectra', |
| 355 |
'slug' => 'ultimate-addons-for-gutenberg', |
| 356 |
'status' => $this->get_plugin_status( 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php' ), |
| 357 |
'required' => false, |
| 358 |
'description' => __( 'Page builder blocks used by the CartFlows checkout templates.', 'cartflows' ), |
| 359 |
'logo' => 'https://ps.w.org/ultimate-addons-for-gutenberg/assets/icon-128x128.gif', |
| 360 |
), |
| 361 |
); |
| 362 |
|
| 363 |
$installed_plugins = get_plugins(); |
| 364 |
|
| 365 |
$page_builders = array( |
| 366 |
'elementor' => array( |
| 367 |
'slug' => 'elementor', |
| 368 |
'init' => 'elementor/elementor.php', |
| 369 |
'active' => is_plugin_active( 'elementor/elementor.php' ) ? 'yes' : 'no', |
| 370 |
'install' => isset( $installed_plugins['elementor/elementor.php'] ) ? 'yes' : 'no', |
| 371 |
), |
| 372 |
'beaver-builder' => array( |
| 373 |
'slug' => 'beaver-builder-lite-version', |
| 374 |
'init' => 'beaver-builder-lite-version/fl-builder.php', |
| 375 |
'active' => is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ? 'yes' : 'no', |
| 376 |
'install' => isset( $installed_plugins['beaver-builder-lite-version/fl-builder.php'] ) ? 'yes' : 'no', |
| 377 |
), |
| 378 |
'divi' => array( |
| 379 |
'slug' => 'divi', |
| 380 |
'init' => 'divi', |
| 381 |
'active' => 'yes', |
| 382 |
'install' => 'NA', // Removed the Support of DIVI theme that is why it is set as NA. |
| 383 |
), |
| 384 |
'gutenberg' => array( |
| 385 |
'slug' => 'ultimate-addons-for-gutenberg', |
| 386 |
'init' => 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php', |
| 387 |
'active' => is_plugin_active( 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php' ) ? 'yes' : 'no', |
| 388 |
'install' => isset( $installed_plugins['ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php'] ) ? 'yes' : 'no', |
| 389 |
), |
| 390 |
'bricks-builder' => array( |
| 391 |
'slug' => 'bricks', |
| 392 |
'init' => 'bricks', |
| 393 |
'active' => 'yes', |
| 394 |
'install' => 'NA', // Bricks is an paid theme that is why, the install option is set to NA. As this will be enabled on the user's website before the CartFlows Install. |
| 395 |
), |
| 396 |
// Intentionally installing the GB plugin when the other option is selected. |
| 397 |
'other' => array( |
| 398 |
'slug' => 'ultimate-addons-for-gutenberg', |
| 399 |
'init' => 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php', |
| 400 |
'active' => is_plugin_active( 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php' ) ? 'yes' : 'no', |
| 401 |
'install' => isset( $installed_plugins['ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php'] ) ? 'yes' : 'no', |
| 402 |
), |
| 403 |
); |
| 404 |
|
| 405 |
$current_user = wp_get_current_user(); |
| 406 |
|
| 407 |
$vars = array( |
| 408 |
'current_user_name' => ! empty( $current_user->user_firstname ) ? $current_user->user_firstname : '', |
| 409 |
'current_user_email' => ! empty( $current_user->user_email ) ? $current_user->user_email : '', |
| 410 |
'plugins' => $plugins, |
| 411 |
'page_builders' => $page_builders, |
| 412 |
'active_page_builder' => OnboardingHelper::get_active_supported_builder( $page_builders ), |
| 413 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 414 |
'admin_url' => admin_url( 'admin.php' ), |
| 415 |
'admin_base_url' => admin_url(), |
| 416 |
'admin_index_url' => admin_url( 'index.php' ), |
| 417 |
'default_page_builder' => \Cartflows_Helper::get_common_settings()['default_page_builder'], |
| 418 |
'site_logo' => $this->get_site_logo_url(), |
| 419 |
'templates_url' => CARTFLOWS_TEMPLATES_URL, |
| 420 |
'template_import_errors' => array( |
| 421 |
'api_errors' => array( |
| 422 |
'title' => __( 'Oops!! Unexpected error occoured', 'cartflows' ), |
| 423 |
'msg' => __( 'Import template API call failed. Please reload the page and try again!', 'cartflows' ), |
| 424 |
), |
| 425 |
), |
| 426 |
'is_store_checkout_imported' => 'yes' === get_option( '_cartflows_wizard_store_checkout_set', 'no' ), |
| 427 |
'is_pro' => _is_cartflows_pro(), |
| 428 |
'cf_pro_type' => defined( 'CARTFLOWS_PRO_PLUGIN_TYPE' ) ? CARTFLOWS_PRO_PLUGIN_TYPE : 'free', |
| 429 |
'woocommerce_status' => $this->get_plugin_status( 'woocommerce/woocommerce.php' ), |
| 430 |
); |
| 431 |
|
| 432 |
$vars = apply_filters( 'cartflows_onboarding_localized_vars', $vars ); |
| 433 |
|
| 434 |
wp_localize_script( 'wcf-onboarding-app', 'cartflows_onboarding', $vars ); |
| 435 |
|
| 436 |
// Satisfies the @Styles/common contract — UTM helpers read from cartflows_admin. |
| 437 |
wp_localize_script( |
| 438 |
'wcf-onboarding-app', |
| 439 |
'cartflows_admin', |
| 440 |
array( |
| 441 |
'utm_defaults' => \Cartflows_Helper::get_utm_defaults(), |
| 442 |
'cf_domain_url' => CARTFLOWS_DOMAIN_URL, |
| 443 |
'cf_upgrade_to_pro_url' => \Cartflows_Helper::get_upgrade_to_pro_link(), |
| 444 |
) |
| 445 |
); |
| 446 |
} |
| 447 |
|
| 448 |
/** |
| 449 |
* Get customizer/site logo URL. |
| 450 |
* |
| 451 |
* @since 1.10.0 |
| 452 |
* |
| 453 |
* @return $image_url Site logo URL |
| 454 |
*/ |
| 455 |
public function get_site_logo_url() { |
| 456 |
|
| 457 |
$logo = get_theme_mod( 'custom_logo' ); |
| 458 |
$site_logo = ''; |
| 459 |
|
| 460 |
if ( ! empty( $logo ) ) { |
| 461 |
|
| 462 |
$image = wp_get_attachment_image_src( $logo, 'full' ); |
| 463 |
|
| 464 |
$site_logo = array( |
| 465 |
'id' => $logo, |
| 466 |
'url' => $image[0] ? $image[0] : '', |
| 467 |
'width' => $image[1] ? $image[1] : '', |
| 468 |
'height' => $image[2] ? $image[2] : '', |
| 469 |
); |
| 470 |
} |
| 471 |
|
| 472 |
return $site_logo; |
| 473 |
} |
| 474 |
|
| 475 |
/** |
| 476 |
* Get plugin status |
| 477 |
* |
| 478 |
* @since 1.1.4 |
| 479 |
* |
| 480 |
* @param string $plugin_init_file Plguin init file. |
| 481 |
* @return mixed |
| 482 |
*/ |
| 483 |
public function get_plugin_status( $plugin_init_file ) { |
| 484 |
|
| 485 |
$installed_plugins = get_plugins(); |
| 486 |
|
| 487 |
if ( ! isset( $installed_plugins[ $plugin_init_file ] ) ) { |
| 488 |
return 'not-installed'; |
| 489 |
} elseif ( is_plugin_active( $plugin_init_file ) ) { |
| 490 |
return 'active'; |
| 491 |
} else { |
| 492 |
return 'inactive'; |
| 493 |
} |
| 494 |
} |
| 495 |
|
| 496 |
/** |
| 497 |
* Function to hide Convert Pro popups during the onboarding wizard process. |
| 498 |
* |
| 499 |
* This function checks if the current page is the CartFlows onboarding page and if so, it sets the load parameter to false, effectively hiding the Convert Pro popups. |
| 500 |
* |
| 501 |
* @param bool $load The initial load state of the Convert Pro popups. |
| 502 |
* @return bool The modified load state of the Convert Pro popups. |
| 503 |
*/ |
| 504 |
public function hide_convert_pro_popups( $load ) { |
| 505 |
|
| 506 |
if ( ! empty( $_GET['page'] ) && 'cartflows-onboarding' === $_GET['page'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 507 |
$load = false; |
| 508 |
} |
| 509 |
|
| 510 |
return $load; |
| 511 |
} |
| 512 |
} |
| 513 |
|
| 514 |
|