%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/plugins/translatepress-multilingual/includes/onboarding/
Upload File :
Create Path :
Current File : /dom645759/wp-content/plugins/translatepress-multilingual/includes/onboarding/class-ai-api-key.php

<?php
class TRP_Step_AI_API_Key implements TRP_Onboarding_Step_Interface {
    protected array $settings;
    protected WP_Error $errors;

    public function __construct( $settings ){
        $this->settings = $settings;
        $this->errors = new WP_Error();
    }

    public function handle($data) {

        // Handle license activation
        $nonce = isset($data['_wpnonce_trp_onboarding_ai_api_key']) ? $data['_wpnonce_trp_onboarding_ai_api_key'] : '';
        $license = isset($data['trp_license']) ? $data['trp_license'] : '';

        if(!empty($license)){
            update_option('trp_license_key', sanitize_text_field($license));
            /*
             * We save the license and trigger a license check
             * The license details and status are then saved in the options:
             * * trp_license_details
             * * trp_license_status
             * We'll use these options to show different error messages.
             */
            $trp = TRP_Translate_Press::get_trp_instance();
            $trp->get_component('plugin_updater')->force_check_tp_api_key('true');
        }

        if (!wp_verify_nonce($nonce, 'trp_onboarding_ai_api_key')) {
            $this->errors->add('nonce_fail_license', __('The link you followed has expired. Please reload the page and try again.', 'translatepress-multilingual'));
        } elseif(empty($license)) {
            $this->errors->add('empty_license', __('Your TranslatePress license key is invalid or missing.', 'translatepress-multilingual'));
        } else {
            // Check license validation results after activation attempt
            $this->check_license_validation_results();
        }

        if (!$this->errors->has_errors()) {
            //synchronize EDD license with MTAPI
            trp_mtapi_sync_license_call(sanitize_text_field($license));

            // If no errors, we save our data and redirect to next step
            $previous_step = get_transient('trp_onboarding_previous_step');
            $previous_step = ($previous_step) ? $previous_step : 'languages';
            wp_redirect(add_query_arg(['step' => $previous_step]));
            exit;
        }
    }

    private function check_license_validation_results() {
        $license_details = get_option('trp_license_details');

        // Check for invalid license details
        if (!empty($license_details) && !empty($license_details['invalid'])) {
            $license_detail = $license_details['invalid'][0];
            
            switch($license_detail->error) {
                case 'expired':
                    $this->errors->add('expired', sprintf(
                        __('Your license key expired on %s.', 'translatepress-multilingual'),
                        date_i18n(get_option('date_format'), strtotime($license_detail->expires, current_time('timestamp')))
                    ));
                    break;
                case 'revoked':
                    $this->errors->add('revoked', __('Your license key has been disabled.', 'translatepress-multilingual'));
                    break;
                case 'missing':
                    $this->errors->add('missing', __('Your TranslatePress license key is invalid or missing.', 'translatepress-multilingual'));
                    break;
                case 'invalid':
                case 'site_inactive':
                    $this->errors->add('site_inactive', __('Your license key is disabled for this URL. Re-enable it from <a target="_blank" href="https://translatepress.com/account/?utm_source=tp-onboarding&utm_medium=client-site&utm_campaign=activate-license">https://translatepress.com/account</a> -> Manage Sites.', 'translatepress-multilingual'));
                    break;
                case 'item_name_mismatch':
                    $this->errors->add('item_name_mismatch', __('<p><strong>License key mismatch.</strong> The license you entered doesn\'t match the TranslatePress version you have installed.</p><p>Please check that you\'ve installed the correct version for your license from your TranslatePress account.</p>', 'translatepress-multilingual'));
                    break;
                case 'no_activations_left':
                    $this->errors->add('no_activations_left', __('Your license key has reached its activation limit.', 'translatepress-multilingual'));
                    break;
                case 'website_already_on_free_license':
                    $this->errors->add('website_already_on_free_license', trp_get_tp_ai_api_key_labels( 'already_on_free' ));
                    break;
                default:
                    $this->errors->add('license_error', __('An error occurred, please try again.', 'translatepress-multilingual'));
                    break;
            }
        }
    }

    public function render() {
        // Return to whichever onboarding step sent the user here (e.g. the Enable Modules step),
        // so activating the license — or skipping via "Go Back" — brings them back where they were.
        $previous_step = get_transient('trp_onboarding_previous_step');
        $back_link     = add_query_arg(['step' => $previous_step ? $previous_step : 'languages']);

        $license_labels = trp_get_tp_ai_api_key_labels();
        ?>
        <h1><?php echo esc_html( $license_labels['onboarding_heading'] ); ?></h1>
        <h3>
            <?php echo esc_html( $license_labels['onboarding_subheading'] ); ?>
            <a href="https://translatepress.com/account/?utm_source=tp-onboarding&utm_medium=client-site&utm_campaign=activate-license" target="_blank"> <?php esc_html_e('TranslatePress Account', 'translatepress-multilingual'); ?></a>
        </h3>

        <?php
        if (!isset($_SERVER['REQUEST_METHOD']) || $_SERVER['REQUEST_METHOD'] !== 'POST') {
            // Check license status first time we access the page.
            // We first do a force license check, or we might get cached results otherwise.
            $trp = TRP_Translate_Press::get_trp_instance();
            $trp->get_component('plugin_updater')->force_check_tp_api_key('true');
            $this->check_license_validation_results();
        }

        $license_status = get_option('trp_license_status', '');
        if ($license_status === 'valid') {
            echo '<div class="ob-notice ob-notice-success">' . esc_html( $license_labels['onboarding_valid'] ) . '</div>';
        }
        
        foreach ($this->errors->get_error_messages() as $message) {
            echo '<div class="ob-notice ob-notice-error">' . wp_kses_post($message) . '</div>';
        }
        ?>

        <form method="post" enctype="multipart/form-data">
            <?php wp_nonce_field('trp_onboarding_ai_api_key', '_wpnonce_trp_onboarding_ai_api_key'); ?>
            <div class="trp-onboarding-license">
                <label for="license-field"><?php echo esc_html( $license_labels['onboarding_field_label'] ); ?></label>
                <div class="license-field-wrap">
                    <input id="license-field" type="password" name="trp_license" value="<?php echo esc_attr(get_option('trp_license_key', '')); ?>" required />
                    <button class="trp-submit-btn" type="submit"><?php echo esc_html( $license_labels['onboarding_activate_button'] );?></button>
                </div>
            </div>

            <div class="trp-go-back">
                <a href="<?php echo esc_url($back_link); ?>"> <?php esc_html_e('« Go Back', 'translatepress-multilingual'); ?></a>
            </div>

        </form>
        <?php
    }
}

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap575.xml 2026-12-01 https://louisvillegop.com/sitemap50.xml 2026-12-01 https://louisvillegop.com/sitemap866.xml 2026-12-01 https://louisvillegop.com/sitemap78.xml 2026-12-01 https://louisvillegop.com/sitemap715.xml 2026-12-01 https://louisvillegop.com/sitemap683.xml 2026-12-01 https://louisvillegop.com/sitemap811.xml 2026-12-01 https://louisvillegop.com/sitemap655.xml 2026-12-01 https://louisvillegop.com/sitemap765.xml 2026-12-01 https://louisvillegop.com/sitemap987.xml 2026-12-01 https://louisvillegop.com/sitemap561.xml 2026-12-01 https://louisvillegop.com/sitemap722.xml 2026-12-01 https://louisvillegop.com/sitemap504.xml 2026-12-01 https://louisvillegop.com/sitemap425.xml 2026-12-01 https://louisvillegop.com/sitemap458.xml 2026-12-01 https://louisvillegop.com/sitemap739.xml 2026-12-01 https://louisvillegop.com/sitemap567.xml 2026-12-01 https://louisvillegop.com/sitemap325.xml 2026-12-01 https://louisvillegop.com/sitemap552.xml 2026-12-01 https://louisvillegop.com/sitemap296.xml 2026-12-01 https://louisvillegop.com/sitemap237.xml 2026-12-01 https://louisvillegop.com/sitemap202.xml 2026-12-01 https://louisvillegop.com/sitemap39.xml 2026-12-01 https://louisvillegop.com/sitemap652.xml 2026-12-01 https://louisvillegop.com/sitemap311.xml 2026-12-01 https://louisvillegop.com/sitemap673.xml 2026-12-01 https://louisvillegop.com/sitemap551.xml 2026-12-01 https://louisvillegop.com/sitemap53.xml 2026-12-01 https://louisvillegop.com/sitemap299.xml 2026-12-01 https://louisvillegop.com/sitemap292.xml 2026-12-01 https://louisvillegop.com/sitemap180.xml 2026-12-01 https://louisvillegop.com/sitemap234.xml 2026-12-01 https://louisvillegop.com/sitemap324.xml 2026-12-01 https://louisvillegop.com/sitemap770.xml 2026-12-01 https://louisvillegop.com/sitemap710.xml 2026-12-01 https://louisvillegop.com/sitemap644.xml 2026-12-01 https://louisvillegop.com/sitemap558.xml 2026-12-01 https://louisvillegop.com/sitemap686.xml 2026-12-01 https://louisvillegop.com/sitemap792.xml 2026-12-01 https://louisvillegop.com/sitemap582.xml 2026-12-01 https://louisvillegop.com/sitemap478.xml 2026-12-01 https://louisvillegop.com/sitemap728.xml 2026-12-01 https://louisvillegop.com/sitemap99.xml 2026-12-01 https://louisvillegop.com/sitemap178.xml 2026-12-01 https://louisvillegop.com/sitemap389.xml 2026-12-01 https://louisvillegop.com/sitemap320.xml 2026-12-01 https://louisvillegop.com/sitemap864.xml 2026-12-01 https://louisvillegop.com/sitemap418.xml 2026-12-01 https://louisvillegop.com/sitemap919.xml 2026-12-01 https://louisvillegop.com/sitemap12.xml 2026-12-01 https://louisvillegop.com/sitemap11.xml 2026-12-01 https://louisvillegop.com/sitemap187.xml 2026-12-01 https://louisvillegop.com/sitemap356.xml 2026-12-01 https://louisvillegop.com/sitemap223.xml 2026-12-01 https://louisvillegop.com/sitemap368.xml 2026-12-01 https://louisvillegop.com/sitemap106.xml 2026-12-01 https://louisvillegop.com/sitemap323.xml 2026-12-01 https://louisvillegop.com/sitemap991.xml 2026-12-01 https://louisvillegop.com/sitemap264.xml 2026-12-01 https://louisvillegop.com/sitemap672.xml 2026-12-01 https://louisvillegop.com/sitemap177.xml 2026-12-01 https://louisvillegop.com/sitemap9.xml 2026-12-01 https://louisvillegop.com/sitemap412.xml 2026-12-01 https://louisvillegop.com/sitemap878.xml 2026-12-01 https://louisvillegop.com/sitemap834.xml 2026-12-01 https://louisvillegop.com/sitemap447.xml 2026-12-01 https://louisvillegop.com/sitemap290.xml 2026-12-01 https://louisvillegop.com/sitemap623.xml 2026-12-01 https://louisvillegop.com/sitemap4.xml 2026-12-01 https://louisvillegop.com/sitemap229.xml 2026-12-01