pricing_monthly = [ 'compliance_monthly_notrial' => '14.95', 'compliance_monthly_5' => '29.95', 'compliance_monthly_10' => '49.95', 'compliance_monthly_20' => '69.95' ]; $this->pricing_yearly = [ 'compliance_yearly_notrial' => '149.50', 'compliance_yearly_5' => '299.50', 'compliance_yearly_10' => '499.50', 'compliance_yearly_20' => '699.50' ]; } /** * Load scripts and styles - admin. * * @return void */ public function admin_enqueue_scripts( $page ) { // get main instance $cn = Cookie_Notice(); if ( $cn->check_status( $cn->get_status() ) ) return; // Legacy welcome scripts only load when ui_mode is explicitly set to legacy. if ( $cn->options['general']['ui_mode'] !== 'legacy' ) return; // styles wp_enqueue_style( 'dashicons' ); wp_enqueue_style( 'cookie-notice-modaal', COOKIE_NOTICE_URL . '/assets/modaal/css/modaal.min.css', [], $cn->defaults['version'] ); wp_enqueue_style( 'cookie-notice-spectrum', COOKIE_NOTICE_URL . '/assets/spectrum/spectrum.min.css', [], $cn->defaults['version'] ); wp_enqueue_style( 'cookie-notice-microtip', COOKIE_NOTICE_URL . '/assets/microtip/microtip.min.css', [], $cn->defaults['version'] ); // scripts wp_enqueue_script( 'cookie-notice-modaal', COOKIE_NOTICE_URL . '/assets/modaal/js/modaal.min.js', [], $cn->defaults['version'] ); wp_enqueue_script( 'cookie-notice-spectrum', COOKIE_NOTICE_URL . '/assets/spectrum/spectrum.min.js', [], $cn->defaults['version'] ); wp_enqueue_script( 'cookie-notice-welcome', COOKIE_NOTICE_URL . '/js/admin-welcome.js', [ 'jquery', 'jquery-ui-core', 'jquery-ui-progressbar' ], $cn->defaults['version'] ); wp_enqueue_script( 'cookie-notice-braintree-client', 'https://js.braintreegateway.com/web/3.71.0/js/client.min.js', [], null, false ); wp_enqueue_script( 'cookie-notice-braintree-hostedfields', 'https://js.braintreegateway.com/web/3.71.0/js/hosted-fields.min.js', [], null, false ); wp_enqueue_script( 'cookie-notice-braintree-paypal', 'https://js.braintreegateway.com/web/3.71.0/js/paypal-checkout.min.js', [], null, false ); // check network $network = $cn->is_network_admin(); // prepare script data $script_data = [ 'ajaxURL' => admin_url( 'admin-ajax.php' ), 'network' => $network, 'nonce' => wp_create_nonce( 'cookie-notice-welcome' ), 'cnNonce' => wp_create_nonce( 'cookie-notice-welcome' ), 'initModal' => $network ? get_site_transient( 'cn_show_welcome' ) : get_transient( 'cn_show_welcome' ), // welcome modal 'error' => esc_html__( 'Unexpected error occurred. Please try again later.', 'cookie-notice' ), 'statusPassed' => esc_html__( 'Passed', 'cookie-notice' ), 'statusFailed' => esc_html__( 'Failed', 'cookie-notice' ), 'paidMonth' => esc_html__( 'monthly', 'cookie-notice' ), 'paidYear' => esc_html__( 'yearly', 'cookie-notice' ), 'pricingMonthly' => $this->pricing_monthly, 'pricingYearly' => $this->pricing_yearly, 'complianceStatus' => $cn->get_status(), 'complianceFailed' => sprintf( esc_html__( '%sCompliance Failed!%sYour website does not achieve minimum viable compliance. %sSign up to Compliance by Hu-manity.co%s to bring your site into compliance with the latest data privacy rules and regulations.', 'cookie-notice' ), '', '', '', '' ), 'compliancePassed' => sprintf( esc_html__( '%sCompliance Passed!%sCongratulations. Your website meets minimum viable compliance.', 'cookie-notice' ), '', '' ), 'licensesAvailable' => esc_html__( 'available', 'cookie-notice' ), 'invalidFields' => esc_html__( 'Please fill all the required fields.', 'cookie-notice' ), 'dismissed' => (bool) get_option( 'cookie_notice_welcome_dismissed', false ) ]; // delete the show modal transient if ( $network ) delete_site_transient( 'cn_show_welcome' ); else delete_transient( 'cn_show_welcome' ); wp_add_inline_script( 'cookie-notice-welcome', 'var cnWelcomeArgs = ' . wp_json_encode( $script_data ) . ";\n", 'before' ); wp_enqueue_style( 'cookie-notice-welcome', COOKIE_NOTICE_URL . '/css/admin-welcome.css', [], $cn->defaults['version'] ); } /** * Send user to the welcome page on first activation. * * @global string $pagenow * * @return void */ public function welcome() { global $pagenow; if ( $pagenow !== 'admin.php' ) return; // get page $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : ''; if ( $page !== 'cookie-notice' ) return; // bail if bulk activating or within an iframe if ( isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) ) return; // get action $action = isset( $_GET['action'] ) ? sanitize_key( $_GET['action'] ) : ''; // get plugin $plugin = isset( $_GET['plugin'] ) ? sanitize_file_name( $_GET['plugin'] ) : ''; if ( $action === 'upgrade-plugin' && strpos( $plugin, 'cookie-notice.php' ) !== false ) return; add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] ); add_action( 'admin_footer', [ $this, 'admin_footer' ] ); } /** * Welcome modal container. * * @return void */ public function admin_footer() { echo ''; } /** * Dismiss the welcome modal — AJAX handler. * Sets cookie_notice_welcome_dismissed option so the modal won't auto-fire again * when user navigates to ?welcome=1 after closing without completing. * * @return void */ public function dismiss_welcome() { if ( ! check_ajax_referer( 'cookie-notice-welcome', 'nonce', false ) ) wp_die( -1 ); if ( ! current_user_can( 'manage_options' ) ) wp_die( -1 ); update_option( 'cookie_notice_welcome_dismissed', true, false ); wp_die( 1 ); } /** * Render welcome screen sidebar step. * * @param int|string $screen * @param bool $echo * @return string|void */ public function welcome_screen( $screen, $echo = true ) { if ( ! current_user_can( 'install_plugins' ) ) wp_die( __( 'You do not have permission to access this page.', 'cookie-notice' ) ); $sidebars = [ 'about', 'login', 'register', 'configure', 'success' ]; $steps = [ 1, 2, 3, 4 ]; $screens = array_merge( $sidebars, $steps ); if ( ! empty( $screen ) ) { if ( is_numeric( $screen ) ) $screen = (int) $screen; else $screen = sanitize_key( $screen ); } else $screen = ''; if ( empty( $screen ) || ! in_array( $screen, $screens, true ) ) { if ( isset( $_REQUEST['screen'] ) ) { if ( is_numeric( $_REQUEST['screen'] ) ) $screen = (int) $_REQUEST['screen']; else $screen = sanitize_key( $_REQUEST['screen'] ); } else $screen = ''; if ( ! in_array( $screen, $screens, true ) ) $screen = ''; } if ( empty( $screen ) ) wp_die( __( 'You do not have permission to access this page.', 'cookie-notice' ) ); if ( wp_doing_ajax() && ! check_ajax_referer( 'cookie-notice-welcome', 'nonce' ) ) wp_die( __( 'You do not have permission to access this page.', 'cookie-notice' ) ); // step screens if ( in_array( $screen, $steps ) ) { $html = '
'; if ( $screen == 1 ) { $html .= $this->welcome_screen( 'about', false ); $html .= '

Compliance by Hu-manity.co

' . esc_html__( 'Simple cookie & privacy compliance solution for your business.', 'cookie-notice' ) . '

Compliance by Hu-manity.co dashboard

' . sprintf( esc_html__( 'Protect your business and take a proactive approach to data privacy laws with Compliance by Hu-manity.co. Build trust by giving your website visitors a beautiful, multi-level consent experience that complies with the latest cookie regulations in 100+ countries.', 'cookie-notice' ), '', '' ) . '

'; $html .= '

'; $html .= '
'; } elseif ( $screen == 2 ) { $html .= $this->welcome_screen( 'configure', false ); $html .= '
'; } elseif ( $screen == 3 ) { $html .= $this->welcome_screen( 'register', false ); $html .= '

Compliance by Hu-manity.co

' . esc_html__( 'Consent Management Platform with simple, transparent pricing.', 'cookie-notice' ) . '

' . esc_html__( 'Choose monthly or yearly payment and number of domains for the fully featured, Professional plan. Or start with limited, Basic plan for free.', 'cookie-notice' ) . '

'; $html .= '

' . esc_html__( 'Select plan', 'cookie-notice' ) . ':

'; $html .= '
'; } elseif ( $screen == 4 ) { $html .= $this->welcome_screen( 'success', false ); // get main instance $cn = Cookie_Notice(); $subscription = $cn->get_subscription(); $html .= '

' . esc_html__( 'Congratulations', 'cookie-notice' ) . '

' . esc_html__( 'You have successfully signed up to Compliance by Hu-manity.co.', 'cookie-notice' ) . '

' . esc_html__( 'Log in to your account and continue configuring your website.', 'cookie-notice' ) . '

'; } $html .= '
'; // sidebar screens } elseif ( in_array( $screen, $sidebars ) ) { $html = ''; if ( $screen === 'about' ) { $theme = wp_get_theme(); $html .= '

' . esc_html__( 'Compliance check', 'cookie-notice' ) . '

' . esc_html__( 'This is a Compliance Check to determine your site’s compliance with updated data processing and consent rules under GDPR, CCPA and other international data privacy laws.', 'cookie-notice' ) . '

' . esc_html__( 'Site URL', 'cookie-notice' ) . ': ' . esc_url( home_url() ) . '

' . esc_html__( 'Site Name', 'cookie-notice' ) . ': ' . esc_html( get_bloginfo( 'name' ) ) . '

' . esc_html__( 'Checking...', 'cookie-notice' ) . '

' . esc_html__( 'Consent Banner', 'cookie-notice' ) . '

' . esc_html__( 'Notify visitors to the site that it uses cookies or similar technologies.', 'cookie-notice' ) . '

' /*
. '
*/ . '
'; } elseif ( $screen === 'configure' ) { $html .= '

' . esc_html__( 'Live Setup', 'cookie-notice' ) . '

' . esc_html__( 'Configure your Compliance by Hu-manity.co design and compliance features through the options below. Click Apply Setup to save the configuration and go to selecting your preferred cookie solution.', 'cookie-notice' ) . '

' . /*
*/ '
' . //
* ' . esc_html__( 'available for Cookie Compliance™ Pro plans only', 'cookie-notice' ) . '
'
' . //
* ' . esc_html__( 'available for Cookie Compliance™ Pro plans only', 'cookie-notice' ) . '
'
'; $html .= wp_nonce_field( 'cn_api_configure', 'cn_nonce', true, false ); $html .= '
'; } elseif ( $screen === 'register' ) { $html .= '

' . esc_html__( 'Compliance account', 'cookie-notice' ) . '

' . esc_html__( 'Create a Compliance by Hu-manity.co account and select your preferred plan.', 'cookie-notice' ) . '

' . esc_html( 'Minimum eight characters, at least one capital letter and one number are required.', 'cookie-notice' ) . '
'; // get site language $locale = get_locale(); $locale_code = explode( '_', $locale ); $html .= ' '; $html .= wp_nonce_field( 'cn_api_register', 'cn_nonce', true, false ); $html .= '

' . esc_html__( 'Already have an account?', 'cookie-notice' ) . ' ' . esc_html__( 'Sign in', 'cookie-notice' ). '

'; $html .= '
'; $html .= wp_nonce_field( 'cn_api_payment', 'cn_payment_nonce', true, false ); $html .= '
'; } elseif ( $screen === 'login' ) { $html .= '

' . esc_html__( 'Compliance Sign in', 'cookie-notice' ) . '

' . esc_html__( 'Sign in to your existing Compliance by Hu-manity.co account and select your preferred plan.', 'cookie-notice' ) . '

'; // get site language $locale = get_locale(); $locale_code = explode( '_', $locale ); $html .= ' '; $html .= wp_nonce_field( 'cn_api_login', 'cn_nonce', true, false ); $html .= '

' . esc_html__( 'Don\'t have an account yet?', 'cookie-notice' ) . ' ' . esc_html__( 'Sign up', 'cookie-notice' ) . '


'; $html .= wp_nonce_field( 'cn_api_payment', 'cn_payment_nonce', true, false ); $html .= '
'; } elseif ( $screen === 'success' ) { $html .= '

' . esc_html__( 'Success!', 'cookie-notice' ) . '

' . esc_html__( 'You have successfully integrated your website with Compliance by Hu-manity.co.', 'cookie-notice' ) . '

' . sprintf( esc_html__( 'Go to Compliance by Hu-manity.co now. Or access it anytime from your %sCompliance settings page%s.', 'cookie-notice' ), '', '' ) . '

'; } $html .= '
'; } if ( $echo ) { // get allowed html $allowed_html = wp_kses_allowed_html( 'post' ); $allowed_html['div']['tabindex'] = true; $allowed_html['button']['tabindex'] = true; $allowed_html['iframe'] = [ 'id' => true, 'src' => true ]; $allowed_html['form'] = [ 'id' => true, 'class' => true, 'action' => true, 'data-action' => true ]; $allowed_html['select'] = [ 'name' => true, 'class' => true, 'id' => true, 'aria-label' => true ]; $allowed_html['option'] = [ 'value' => true, 'data-price' => true ]; $allowed_html['input'] = [ 'id' => true, 'type' => true, 'name' => true, 'class' => true, 'value' => true, 'tabindex' => true, 'autocomplete' => true, 'checked' => true, 'placeholder' => true, 'title' => true ]; add_filter( 'safe_style_css', [ $this, 'allow_style_attributes' ] ); // echo wp_kses( $html, $allowed_html ); echo $html; remove_filter( 'safe_style_css', [ $this, 'allow_style_attributes' ] ); } else return $html; if ( wp_doing_ajax() ) exit(); } }