context = $context; } public function register() { //phpcs:ignore WordPress.Security.NonceVerification.Recommended if (isset($_GET['page']) && $_GET['page'] == 'wdp_settings') { //phpcs:disable WordPress.Security.NonceVerification.Recommended if (isset($_GET['from_notify'])) { $this->clearOutOfTimeNotices(); } } //phpcs:ignore WordPress.Security.NonceVerification.Recommended if (isset($_GET['page']) && $_GET['page'] == 'wdp_settings') { //phpcs:disable WordPress.Security.NonceVerification.Recommended if (isset($_GET['from_enable_persistence_rules_notice'])) { $this->dismissPersistenceRulesNotice(); } } //phpcs:ignore WordPress.Security.NonceVerification.Recommended if (isset($_GET['wp-']) && $_GET['page'] == 'wdp_settings') { //phpcs:ignore WordPress.Security.NonceVerification.Recommended if (isset($_GET['from_enable_persistence_rules_notice'])) { $this->dismissPersistenceRulesNotice(); } } add_action('admin_notices', array($this, 'displayPluginActivatedMessage')); add_action('admin_notices', array($this, 'notifyRuleDisabled'), 10); // add_action('admin_notices', array($this, 'notifyCouponsDisabled'), 10); add_action('admin_notices', array($this, 'notifyAboutPersistenceRules'), 10); add_action('wp_ajax_adp_notice_dismiss', array( $this, 'noticeDismiss')); } public static function cleanUp() { delete_option(self::activationNoticeOption); delete_option(self::disabledRulesOption); } public static function isDismissedNotice($key) { return get_option(self::dismissedNoticeOption.$key, false); } public function noticeDismiss() { //phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput $key = htmlspecialchars($_POST['key'] ?? "", ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401); update_option(self::dismissedNoticeOption.$key, true); wp_send_json_success(); } public function addActivationNotice() { update_option(self::activationNoticeOption, true); } public function isActivationNotice() { return get_option(self::activationNoticeOption, false); } public function removeActivationNotice() { delete_option(self::activationNoticeOption); } public function addOutOfTimeNotice($ruleId, $exclusive) { $value = get_option(self::disabledRulesOption, array()); $value[] = array( 'id' => $ruleId, 'is_exclusive' => false, ); update_option(self::disabledRulesOption, $value); } public function getOutOfTimeNotices() { return get_option(self::disabledRulesOption, array()); } public function clearOutOfTimeNotices() { update_option(self::disabledRulesOption, array()); } public function displayPluginActivatedMessage() { if ($this->isActivationNotice()) { return; } ?>
' .esc_html__('on this page', 'advanced-dynamic-pricing-for-woocommerce') .'.', 'admin.php?page=wdp_settings'); ?>
%s %s %s
"; if ($disabledCountCommon) { $noticeMessage = ""; $noticeMessage .= ''; $noticeMessage .= __( "Please enable coupons (cart adjustments won't work)", 'advanced-dynamic-pricing-for-woocommerce' ); $noticeMessage .= '
' .esc_html__('enable the "Product only" rules', 'advanced-dynamic-pricing-for-woocommerce').'', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped self::persistenceRulesNoticeThreshold, $ruleEditUrl); ?>