Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/hostinge.../includes/Admin
File: Hooks.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Hostinger\EasyOnboarding\Admin;
[2] Fix | Delete
[3] Fix | Delete
use Hostinger\EasyOnboarding\Admin\Actions as Admin_Actions;
[4] Fix | Delete
use Hostinger\EasyOnboarding\Admin\Onboarding\Onboarding;
[5] Fix | Delete
use Hostinger\EasyOnboarding\AmplitudeEvents\Actions as AmplitudeActions;
[6] Fix | Delete
use Hostinger\EasyOnboarding\AmplitudeEvents\Amplitude;
[7] Fix | Delete
use Hostinger\EasyOnboarding\Helper;
[8] Fix | Delete
use Hostinger\EasyOnboarding\WooCommerce\GatewayManager;
[9] Fix | Delete
use Hostinger\EasyOnboarding\WooCommerce\Options as WooCommerceOptions;
[10] Fix | Delete
use Hostinger\WpHelper\Utils;
[11] Fix | Delete
[12] Fix | Delete
defined( 'ABSPATH' ) || exit;
[13] Fix | Delete
[14] Fix | Delete
[15] Fix | Delete
class Hooks {
[16] Fix | Delete
[17] Fix | Delete
public const WOOCOMMERCE_PAGES = array(
[18] Fix | Delete
'admin.php?page=wc-admin',
[19] Fix | Delete
'edit.php?post_type=shop_order',
[20] Fix | Delete
'admin.php?page=wc-admin&path=/customers',
[21] Fix | Delete
'edit.php?post_type=shop_coupon&legacy_coupon_menu=1',
[22] Fix | Delete
'admin.php?page=wc-admin&path=/marketing',
[23] Fix | Delete
'admin.php?page=wc-reports',
[24] Fix | Delete
'admin.php?page=wc-settings',
[25] Fix | Delete
'admin.php?page=wc-status',
[26] Fix | Delete
'admin.php?page=wc-admin&path=/extensions',
[27] Fix | Delete
'edit.php?post_type=product',
[28] Fix | Delete
'post-new.php?post_type=product',
[29] Fix | Delete
'edit.php?post_type=product&page=product-reviews',
[30] Fix | Delete
'edit.php?post_type=product&page=product_attributes',
[31] Fix | Delete
'edit-tags.php?taxonomy=product_cat&post_type=product',
[32] Fix | Delete
'edit-tags.php?taxonomy=product_tag&post_type=product',
[33] Fix | Delete
'admin.php?page=wc-admin&path=/analytics/overview',
[34] Fix | Delete
'admin.php?page=wc-admin',
[35] Fix | Delete
'admin.php?page=wc-orders',
[36] Fix | Delete
);
[37] Fix | Delete
[38] Fix | Delete
public const COMPLETED_REMINDER_VISIBLE_PAGES = array(
[39] Fix | Delete
'admin.php?page=googlesitekit-splash',
[40] Fix | Delete
'admin.php?page=googlesitekit-dashboard',
[41] Fix | Delete
);
[42] Fix | Delete
[43] Fix | Delete
public const COMPLETED_REMINDER_OPTION_NAME = 'hostinger_setup_completed';
[44] Fix | Delete
[45] Fix | Delete
public const WOOPAYMENTS_REMINDER_OPTION_NAME = 'hostinger_woopayments_completed';
[46] Fix | Delete
[47] Fix | Delete
public const WOO_ONBOARDING_NOTICE_TRANS = 'hostinger_return_to_onboarding';
[48] Fix | Delete
/**
[49] Fix | Delete
* @var Onboarding
[50] Fix | Delete
*/
[51] Fix | Delete
private Onboarding $onboarding;
[52] Fix | Delete
[53] Fix | Delete
private Helper $helper;
[54] Fix | Delete
[55] Fix | Delete
public const DAY_IN_SECONDS = 86400;
[56] Fix | Delete
[57] Fix | Delete
public function __construct() {
[58] Fix | Delete
$this->helper = new Helper();
[59] Fix | Delete
$this->onboarding = new Onboarding();
[60] Fix | Delete
[61] Fix | Delete
add_action( 'admin_init', array( $this, 'init_onboarding' ), 0 );
[62] Fix | Delete
add_action( 'admin_init', array( $this, 'handle_onboarding_started_redirect' ) );
[63] Fix | Delete
[64] Fix | Delete
// Admin init actions.
[65] Fix | Delete
add_action( 'admin_init', array( $this, 'admin_init_actions' ) );
[66] Fix | Delete
add_action( 'admin_init', array( $this, 'set_woocommerce_options' ), 0 );
[67] Fix | Delete
[68] Fix | Delete
// Admin notices.
[69] Fix | Delete
add_action( 'admin_notices', array( $this, 'omnisend_discount_notice' ) );
[70] Fix | Delete
[71] Fix | Delete
// Return back to onboarding.
[72] Fix | Delete
add_action( 'admin_footer', array( $this, 'back_to_onboarding_notice' ) );
[73] Fix | Delete
add_filter( 'admin_body_class', array( $this, 'add_onboarding_notice_class' ) );
[74] Fix | Delete
[75] Fix | Delete
// Admin Styles.
[76] Fix | Delete
add_action( 'admin_head', array( $this, 'hide_notices' ) );
[77] Fix | Delete
[78] Fix | Delete
// WooCommerce filters.
[79] Fix | Delete
add_filter(
[80] Fix | Delete
'woocommerce_prevent_automatic_wizard_redirect',
[81] Fix | Delete
function () {
[82] Fix | Delete
return true;
[83] Fix | Delete
},
[84] Fix | Delete
999
[85] Fix | Delete
);
[86] Fix | Delete
add_filter(
[87] Fix | Delete
'woocommerce_enable_setup_wizard',
[88] Fix | Delete
function () {
[89] Fix | Delete
return false;
[90] Fix | Delete
},
[91] Fix | Delete
999
[92] Fix | Delete
);
[93] Fix | Delete
[94] Fix | Delete
// Spectra.
[95] Fix | Delete
add_filter(
[96] Fix | Delete
'uagb_enable_redirect_activation',
[97] Fix | Delete
function () {
[98] Fix | Delete
return false;
[99] Fix | Delete
},
[100] Fix | Delete
999
[101] Fix | Delete
);
[102] Fix | Delete
[103] Fix | Delete
// Hooking up one action before and removing astra redirect to onboarding.
[104] Fix | Delete
if ( function_exists( 'astra_sites_redirect_to_onboarding' ) ) {
[105] Fix | Delete
add_action(
[106] Fix | Delete
'admin_menu',
[107] Fix | Delete
function () {
[108] Fix | Delete
remove_action( 'admin_init', 'astra_sites_redirect_to_onboarding' );
[109] Fix | Delete
}
[110] Fix | Delete
);
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
add_filter( 'get_edit_post_link', array( $this, 'change_shop_page_edit_url' ), 99, 3 );
[114] Fix | Delete
[115] Fix | Delete
add_action( 'admin_menu', array( $this, 'disable_beaver_builder_redirect' ) );
[116] Fix | Delete
[117] Fix | Delete
add_action( 'admin_menu', array( $this, 'disable_monsterinsights_redirect' ) );
[118] Fix | Delete
[119] Fix | Delete
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
[120] Fix | Delete
add_action( 'admin_init', array( $this, 'check_if_payment_gateway_enabled' ), 20 );
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
add_action( 'admin_init', array( $this, 'skip_cartflow_onboarding' ), 0 );
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
public function init_onboarding() {
[127] Fix | Delete
$this->onboarding->init();
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
public function hide_notices() {
[131] Fix | Delete
$helper = new Helper();
[132] Fix | Delete
?>
[133] Fix | Delete
<style>
[134] Fix | Delete
[135] Fix | Delete
<?php
[136] Fix | Delete
[137] Fix | Delete
if ( is_plugin_active( 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php' ) || is_plugin_active( 'astra-sites/astra-sites.php' ) ) {
[138] Fix | Delete
?>
[139] Fix | Delete
.interface-interface-skeleton .editor-header__settings button[aria-controls="zip-ai-page-level-settings:zip-ai-page-settings-panel"] {
[140] Fix | Delete
display: none !important;
[141] Fix | Delete
}
[142] Fix | Delete
<?php
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
?>
[146] Fix | Delete
body.hostinger-onboarding-white-overlay::before {
[147] Fix | Delete
content: "";
[148] Fix | Delete
position: fixed;
[149] Fix | Delete
top: 0;
[150] Fix | Delete
left: 0;
[151] Fix | Delete
width: 100%;
[152] Fix | Delete
height: 100%;
[153] Fix | Delete
background-color: #ffffff;
[154] Fix | Delete
z-index: 100000;
[155] Fix | Delete
pointer-events: none;
[156] Fix | Delete
}
[157] Fix | Delete
<?php if ( ! $helper->is_woocommerce_onboarding_completed() ) : ?>
[158] Fix | Delete
.post-php.post-type-product #wpadminbar .wpforms-menu-notification-counter,
[159] Fix | Delete
.post-php.post-type-product #wpadminbar .aioseo-menu-notification-counter,
[160] Fix | Delete
.post-php.post-type-product .woocommerce-layout__header-tasks-reminder-bar,
[161] Fix | Delete
.post-php.post-type-product .litespeed_icon.notice.is-dismissible,
[162] Fix | Delete
.post-php.post-type-product .monsterinsights-menu-notification-indicator,
[163] Fix | Delete
.post-php.post-type-product .aioseo-review-plugin-cta,
[164] Fix | Delete
.post-php.post-type-product .omnisend-connection-notice-hidden,
[165] Fix | Delete
.post-php.post-type-product #astra-upgrade-pro-wc {
[166] Fix | Delete
display: none !important;
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
.notice.hts-notice {
[170] Fix | Delete
display: block !important;
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
<?php endif; ?>
[174] Fix | Delete
[175] Fix | Delete
<?php if ( $this->is_woocommerce_admin_page() && ! $helper->is_woocommerce_onboarding_completed() ) : ?>
[176] Fix | Delete
#wpadminbar .wpforms-menu-notification-counter,
[177] Fix | Delete
#wpadminbar .aioseo-menu-notification-counter,
[178] Fix | Delete
.woocommerce-layout__header-tasks-reminder-bar,
[179] Fix | Delete
.litespeed_icon.notice.is-dismissible,
[180] Fix | Delete
.monsterinsights-menu-notification-indicator,
[181] Fix | Delete
.aioseo-review-plugin-cta,
[182] Fix | Delete
.omnisend-connection-notice-hidden,
[183] Fix | Delete
#astra-upgrade-pro-wc,
[184] Fix | Delete
.notice {
[185] Fix | Delete
display: none !important;
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
.notice.hts-notice {
[189] Fix | Delete
display: block !important;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
<?php endif; ?>
[193] Fix | Delete
</style>
[194] Fix | Delete
<?php
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
public function admin_init_actions(): void {
[198] Fix | Delete
$this->hide_astra_builder_selection_screen();
[199] Fix | Delete
$this->hide_metaboxes();
[200] Fix | Delete
$this->hide_monsterinsight_notice();
[201] Fix | Delete
$this->check_plugins_and_remove_duplicates();
[202] Fix | Delete
}
[203] Fix | Delete
public function check_plugins_and_remove_duplicates() {
[204] Fix | Delete
// Check if the script has already run.
[205] Fix | Delete
if ( get_option( 'hostinger_woocommerce_pages_cleanup_done' ) ) {
[206] Fix | Delete
return;
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
// Check if Astra Sites and WooCommerce are activated.
[210] Fix | Delete
if ( is_plugin_active( 'astra-sites/astra-sites.php' ) && is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
[211] Fix | Delete
// List of pages to check.
[212] Fix | Delete
$page_slugs = array( 'shop', 'cart', 'checkout', 'my-account' );
[213] Fix | Delete
$astra_page_slugs = array( 'shop-2', 'cart-2', 'checkout-2', 'my-account-2' );
[214] Fix | Delete
$pages_to_remove = array();
[215] Fix | Delete
$pages_to_rename = array();
[216] Fix | Delete
[217] Fix | Delete
$query = new \WP_Query(
[218] Fix | Delete
array(
[219] Fix | Delete
'post_type' => 'page',
[220] Fix | Delete
'post_status' => 'publish',
[221] Fix | Delete
'post_name__in' => array_merge( $page_slugs, $astra_page_slugs ),
[222] Fix | Delete
'posts_per_page' => -1,
[223] Fix | Delete
)
[224] Fix | Delete
);
[225] Fix | Delete
[226] Fix | Delete
if ( $query->have_posts() ) {
[227] Fix | Delete
$pages = $query->posts;
[228] Fix | Delete
$page_ids = array();
[229] Fix | Delete
[230] Fix | Delete
foreach ( $pages as $page ) {
[231] Fix | Delete
$page_ids[ $page->post_name ] = $page->ID;
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
foreach ( $page_slugs as $index => $slug ) {
[235] Fix | Delete
$astra_slug = $astra_page_slugs[ $index ];
[236] Fix | Delete
if ( isset( $page_ids[ $slug ] ) && isset( $page_ids[ $astra_slug ] ) ) {
[237] Fix | Delete
$pages_to_remove[] = $page_ids[ $slug ];
[238] Fix | Delete
$pages_to_rename[ $astra_slug ] = $page_ids[ $astra_slug ];
[239] Fix | Delete
}
[240] Fix | Delete
}
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
// Reset post data after query.
[244] Fix | Delete
wp_reset_postdata();
[245] Fix | Delete
[246] Fix | Delete
// Assign the 'shop-2', 'cart-2', 'checkout-2' pages as WooCommerce pages.
[247] Fix | Delete
foreach ( $pages_to_rename as $astra_slug => $page_id ) {
[248] Fix | Delete
switch ( $astra_slug ) {
[249] Fix | Delete
case 'shop-2':
[250] Fix | Delete
update_option( 'woocommerce_shop_page_id', $page_id );
[251] Fix | Delete
break;
[252] Fix | Delete
case 'cart-2':
[253] Fix | Delete
update_option( 'woocommerce_cart_page_id', $page_id );
[254] Fix | Delete
break;
[255] Fix | Delete
case 'checkout-2':
[256] Fix | Delete
update_option( 'woocommerce_checkout_page_id', $page_id );
[257] Fix | Delete
break;
[258] Fix | Delete
case 'my-account-2':
[259] Fix | Delete
update_option( 'woocommerce_my_account_page_id', $page_id );
[260] Fix | Delete
break;
[261] Fix | Delete
}
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
// Remove the original 'shop', 'cart', 'checkout' pages.
[265] Fix | Delete
foreach ( $pages_to_remove as $page_id ) {
[266] Fix | Delete
wp_delete_post( $page_id, true );
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
// Rename 'shop-2', 'cart-2', 'checkout-2' to 'shop', 'cart', 'checkout'.
[270] Fix | Delete
foreach ( $pages_to_rename as $astra_slug => $page_id ) {
[271] Fix | Delete
$new_slug = str_replace( '-2', '', $astra_slug );
[272] Fix | Delete
$new_title = $new_slug === 'my-account' ? 'My Account' : ucfirst( $new_slug );
[273] Fix | Delete
wp_update_post(
[274] Fix | Delete
array(
[275] Fix | Delete
'ID' => $page_id,
[276] Fix | Delete
'post_name' => $new_slug,
[277] Fix | Delete
'post_title' => $new_title,
[278] Fix | Delete
)
[279] Fix | Delete
);
[280] Fix | Delete
}
[281] Fix | Delete
[282] Fix | Delete
// Set the option to indicate the script has run.
[283] Fix | Delete
update_option( 'hostinger_woocommerce_pages_cleanup_done', 1 );
[284] Fix | Delete
}
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
public function hide_metaboxes(): void {
[288] Fix | Delete
$this->hide_plugin_metabox( 'google-analytics-for-wordpress/googleanalytics.php', 'monsterinsights-metabox', 'metaboxhidden_product' );
[289] Fix | Delete
$this->hide_plugin_metabox( 'all-in-one-seo-pack/all_in_one_seo_pack.php', 'aioseo-settings', 'aioseo-settings' );
[290] Fix | Delete
$this->hide_plugin_metabox( 'litespeed-cache/litespeed-cache.php', 'litespeed_meta_boxes', 'litespeed_meta_boxes' );
[291] Fix | Delete
$this->hide_astra_theme_metabox();
[292] Fix | Delete
$this->hide_custom_fields_metabox();
[293] Fix | Delete
[294] Fix | Delete
// Hide panels in Gutenberg editor.
[295] Fix | Delete
$this->hide_plugin_panel( 'all-in-one-seo-pack/all_in_one_seo_pack.php', 'meta-box-aioseo-settings' );
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
public function hide_astra_theme_metabox(): void {
[299] Fix | Delete
if ( ! $this->is_astra_theme_active() ) {
[300] Fix | Delete
return;
[301] Fix | Delete
}
[302] Fix | Delete
$this->hide_metabox( 'astra_settings_meta_box', 'astra_metabox' );
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
public function hide_custom_fields_metabox(): void {
[306] Fix | Delete
$this->hide_metabox( 'postcustom', 'custom_fields_metabox' );
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
public function hide_metabox( string $metabox_id, string $transient_suffix ): void {
[310] Fix | Delete
$helper = new Utils();
[311] Fix | Delete
$user_id = get_current_user_id();
[312] Fix | Delete
$transient_key = $transient_suffix . '_' . $user_id;
[313] Fix | Delete
$hide_metabox = get_transient( $transient_key );
[314] Fix | Delete
[315] Fix | Delete
if ( $hide_metabox ) {
[316] Fix | Delete
return;
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
$hide_metabox = get_user_meta( $user_id, 'metaboxhidden_product', true );
[320] Fix | Delete
[321] Fix | Delete
if ( ! is_array( $hide_metabox ) ) {
[322] Fix | Delete
$hide_metabox = array();
[323] Fix | Delete
}
[324] Fix | Delete
[325] Fix | Delete
if ( $helper->isThisPage( 'post-new.php?post_type=product' ) ) {
[326] Fix | Delete
if ( ! in_array( $metabox_id, $hide_metabox, true ) ) {
[327] Fix | Delete
array_push( $hide_metabox, $metabox_id );
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
update_user_meta( $user_id, 'metaboxhidden_product', $hide_metabox );
[331] Fix | Delete
set_transient( $transient_key, 'hidden', self::DAY_IN_SECONDS );
[332] Fix | Delete
}
[333] Fix | Delete
}
[334] Fix | Delete
[335] Fix | Delete
public function is_astra_theme_active(): bool {
[336] Fix | Delete
$theme = wp_get_theme();
[337] Fix | Delete
[338] Fix | Delete
return $theme->get( 'Name' ) === 'Astra';
[339] Fix | Delete
}
[340] Fix | Delete
[341] Fix | Delete
public function hide_monsterinsight_notice(): void {
[342] Fix | Delete
if ( is_plugin_active( 'google-analytics-for-wordpress/googleanalytics.php' ) ) {
[343] Fix | Delete
define( 'MONSTERINSIGHTS_DISABLE_TRACKING', true );
[344] Fix | Delete
}
[345] Fix | Delete
}
[346] Fix | Delete
[347] Fix | Delete
public function omnisend_discount_notice(): void {
[348] Fix | Delete
$omnisend_notice_hidden = get_transient( 'hts_omnisend_notice_hidden' );
[349] Fix | Delete
[350] Fix | Delete
$admin_path = parse_url( admin_url(), PHP_URL_PATH );
[351] Fix | Delete
$omnisend_page = $admin_path . 'admin.php?page=omnisend';
[352] Fix | Delete
[353] Fix | Delete
if ( $omnisend_notice_hidden === false && $this->helper->is_this_page( $omnisend_page ) && ( Helper::is_plugin_active( 'class-omnisend-core-bootstrap' ) || Helper::is_plugin_active( 'omnisend-woocommerce' ) ) ) :
[354] Fix | Delete
?>
[355] Fix | Delete
<div class="notice notice-info hts-admin-notice hts-omnisend">
[356] Fix | Delete
<p><?php echo wp_kses( __( 'Use the special discount code <b>ONLYHOSTINGER30</b> to get 30% off on Omnisend for 6 months when you upgrade.', 'hostinger-easy-onboarding' ), array( 'b' => array() ) ); ?></p>
[357] Fix | Delete
<div>
[358] Fix | Delete
<a class="button button-primary"
[359] Fix | Delete
href="https://your.omnisend.com/LXqyZ0"
[360] Fix | Delete
target="_blank"><?php echo esc_html__( 'Get Discount', 'hostinger-easy-onboarding' ); ?></a>
[361] Fix | Delete
<button type="button" class="notice-dismiss"></button>
[362] Fix | Delete
</div>
[363] Fix | Delete
</div>
[364] Fix | Delete
<?php
[365] Fix | Delete
endif;
[366] Fix | Delete
wp_nonce_field( 'hts_close_omnisend', 'hts_close_omnisend_nonce', true );
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
public function hide_astra_builder_selection_screen(): void {
[370] Fix | Delete
add_filter( 'st_enable_block_page_builder', '__return_true' );
[371] Fix | Delete
}
[372] Fix | Delete
[373] Fix | Delete
public function hide_plugin_metabox( string $plugin_slug, string $metabox_id, string $transient_suffix ): void {
[374] Fix | Delete
$helper = new Utils();
[375] Fix | Delete
$user_id = get_current_user_id();
[376] Fix | Delete
$transient_key = $transient_suffix . '_' . $user_id;
[377] Fix | Delete
$hide_metabox = get_transient( $transient_key );
[378] Fix | Delete
[379] Fix | Delete
if ( $hide_metabox ) {
[380] Fix | Delete
return;
[381] Fix | Delete
}
[382] Fix | Delete
[383] Fix | Delete
$hide_metabox = get_user_meta( $user_id, 'metaboxhidden_product', true );
[384] Fix | Delete
[385] Fix | Delete
if ( ! is_plugin_active( $plugin_slug ) ) {
[386] Fix | Delete
return;
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
if ( ! is_array( $hide_metabox ) ) {
[390] Fix | Delete
$hide_metabox = array();
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
if ( $helper->isThisPage( 'post-new.php?post_type=product' ) ) {
[394] Fix | Delete
if ( ! in_array( $metabox_id, $hide_metabox, true ) ) {
[395] Fix | Delete
array_push( $hide_metabox, $metabox_id );
[396] Fix | Delete
}
[397] Fix | Delete
[398] Fix | Delete
update_user_meta( $user_id, 'metaboxhidden_product', $hide_metabox );
[399] Fix | Delete
set_transient( $transient_key, 'hidden', self::DAY_IN_SECONDS );
[400] Fix | Delete
}
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
public function hide_plugin_panel( string $plugin_slug, $panel_id ) {
[404] Fix | Delete
if ( ! is_plugin_active( $plugin_slug ) ) {
[405] Fix | Delete
return;
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
$user_id = get_current_user_id();
[409] Fix | Delete
$flag_name = 'hostinger_' . $panel_id . '_changed';
[410] Fix | Delete
[411] Fix | Delete
$hidden_once = get_user_meta( $user_id, $flag_name, true );
[412] Fix | Delete
[413] Fix | Delete
if ( $hidden_once ) {
[414] Fix | Delete
return;
[415] Fix | Delete
}
[416] Fix | Delete
[417] Fix | Delete
$persisted_preferences = get_user_meta( $user_id, 'wp_persisted_preferences', true );
[418] Fix | Delete
[419] Fix | Delete
if ( empty( $persisted_preferences ) ) {
[420] Fix | Delete
$persisted_preferences = array(
[421] Fix | Delete
'core/edit-post' => array(
[422] Fix | Delete
'welcomeGuide' => '',
[423] Fix | Delete
'isComplementaryAreaVisible' => 1,
[424] Fix | Delete
'inactivePanels' => array(
[425] Fix | Delete
$panel_id,
[426] Fix | Delete
),
[427] Fix | Delete
),
[428] Fix | Delete
'core/edit-site' => array(
[429] Fix | Delete
'welcomeGuide' => '',
[430] Fix | Delete
'isComplementaryAreaVisible' => 1,
[431] Fix | Delete
),
[432] Fix | Delete
'_modified' => wp_date( 'c' ),
[433] Fix | Delete
);
[434] Fix | Delete
} else {
[435] Fix | Delete
if ( ! empty( $persisted_preferences['core/edit-post']['inactivePanels'] ) && ! in_array( $panel_id, $persisted_preferences['core/edit-post']['inactivePanels'], true ) ) {
[436] Fix | Delete
$persisted_preferences['core/edit-post']['inactivePanels'][] = $panel_id;
[437] Fix | Delete
}
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
update_user_meta( $user_id, 'wp_persisted_preferences', $persisted_preferences );
[441] Fix | Delete
update_user_meta( $user_id, $flag_name, 1 );
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
private function is_completed_reminder_page(): bool {
[445] Fix | Delete
if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
[446] Fix | Delete
return false;
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
$current_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] );
[450] Fix | Delete
[451] Fix | Delete
if ( defined( 'DOING_AJAX' ) && \DOING_AJAX ) {
[452] Fix | Delete
return false;
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
if ( isset( $current_uri ) && strpos( $current_uri, '/wp-json/' ) !== false ) {
[456] Fix | Delete
return false;
[457] Fix | Delete
}
[458] Fix | Delete
[459] Fix | Delete
foreach ( self::COMPLETED_REMINDER_VISIBLE_PAGES as $page ) {
[460] Fix | Delete
if ( strpos( $current_uri, $page ) !== false ) {
[461] Fix | Delete
return true;
[462] Fix | Delete
}
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
return false;
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
private function is_woocommerce_admin_page(): bool {
[469] Fix | Delete
// Product edit etc.
[470] Fix | Delete
if ( get_post_type() === 'product' ) {
[471] Fix | Delete
return true;
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
[475] Fix | Delete
return false;
[476] Fix | Delete
}
[477] Fix | Delete
[478] Fix | Delete
$current_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] );
[479] Fix | Delete
[480] Fix | Delete
if ( defined( 'DOING_AJAX' ) && \DOING_AJAX ) {
[481] Fix | Delete
return false;
[482] Fix | Delete
}
[483] Fix | Delete
[484] Fix | Delete
if ( isset( $current_uri ) && strpos( $current_uri, '/wp-json/' ) !== false ) {
[485] Fix | Delete
return false;
[486] Fix | Delete
}
[487] Fix | Delete
[488] Fix | Delete
if ( isset( $current_uri ) && ( strpos( $current_uri, 'paymentsonboarding' ) !== false || strpos( $current_uri, '/payments/onboarding' ) !== false ) ) {
[489] Fix | Delete
return false;
[490] Fix | Delete
}
[491] Fix | Delete
[492] Fix | Delete
foreach ( self::WOOCOMMERCE_PAGES as $page ) {
[493] Fix | Delete
if ( strpos( $current_uri, $page ) !== false ) {
[494] Fix | Delete
return true;
[495] Fix | Delete
}
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
return false;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function