ith-license-validation#errors" rel="noopener noreferrer" target=_"blank">', '' ); set_transient( 'rocket_check_key_errors', [ $message ] ); return $return; } // Translators: %1$s = opening em tag, %2$s = closing em tag, %3$s = opening link tag, %4$s closing link tag. $message = __( 'License validation failed. Our server could not resolve the request from your website.', 'rocket' ) . '
' . sprintf( __( 'Try clicking %1$sSave Changes%2$s below. If the error persists, follow %3$sthis guide%4$s.', 'rocket' ), '', '', '', '' ); set_transient( 'rocket_check_key_errors', [ $message ] ); return $return; } $rocket_options = []; $rocket_options['consumer_key'] = $json->data->consumer_key; $rocket_options['consumer_email'] = $json->data->consumer_email; if ( ! $json->success ) { $messages = [ // Translators: %1$s = opening link tag, %2$s = closing link tag. 'BAD_LICENSE' => __( 'Your license is not valid.', 'rocket' ) . '
' . sprintf( __( 'Make sure you have an active %1$sWP Rocket license%2$s.', 'rocket' ), '', '' ), // Translators: %1$s = opening link tag, %2$s = closing link tag, %3$s = opening link tag. 'BAD_NUMBER' => __( 'You have added as many sites as your current license allows.', 'rocket' ) . '
' . sprintf( __( 'Upgrade your %1$saccount%2$s or %3$stransfer your license%2$s to this domain.', 'rocket' ), '', '', '' ), // Translators: %1$s = opening link tag, %2$s = closing link tag. 'BAD_SITE' => __( 'This website is not allowed.', 'rocket' ) . '
' . sprintf( __( 'Please %1$scontact support%2$s.', 'rocket' ), '
', '' ), // Translators: %1$s = opening link tag, %2$s = closing link tag. 'BAD_KEY' => __( 'This license key is not recognized.', 'rocket' ) . '' . sprintf( __( 'If the issue persists, please %1$scontact support%2$s.', 'rocket' ), '', '' ), ]; $rocket_options['secret_key'] = ''; // Translators: %s = error message returned. set_transient( 'rocket_check_key_errors', [ sprintf( __( 'License validation failed: %s', 'rocket' ), $messages[ $json->data->reason ] ) ] ); Logger::error( 'License validation failed.', [ 'license validation process', 'response_error' => $json->data->reason, ] ); set_transient( rocket_get_constant( 'WP_ROCKET_SLUG' ), $rocket_options ); return $rocket_options; } $rocket_options['secret_key'] = $json->data->secret_key; if ( ! get_rocket_option( 'license' ) ) { $rocket_options['license'] = '1'; } Logger::info( 'License validation successful.', [ 'license validation process' ] ); set_transient( rocket_get_constant( 'WP_ROCKET_SLUG' ), $rocket_options ); delete_transient( 'rocket_check_key_errors' ); rocket_delete_licence_data_file(); return $rocket_options; } /** * Deletes the licence-data.php file if it exists * * @since 3.5 * @author Remy Perona * * @return void */ function rocket_delete_licence_data_file() { if ( is_multisite() ) { return; } $rocket_path = rocket_get_constant( 'WP_ROCKET_PATH' ); if ( ! rocket_direct_filesystem()->exists( $rocket_path . 'licence-data.php' ) ) { return; } rocket_direct_filesystem()->delete( $rocket_path . 'licence-data.php' ); } /** * Is WP a MultiSite and a subfolder install? * * @since 3.1.1 * @author Grégory Viguier * * @return bool */ function rocket_is_subfolder_install() { global $wpdb; static $subfolder_install; if ( isset( $subfolder_install ) ) { return $subfolder_install; } if ( is_multisite() ) { $subfolder_install = ! is_subdomain_install(); } elseif ( ! is_null( $wpdb->sitemeta ) ) { $subfolder_install = ! $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery } else { $subfolder_install = false; } return $subfolder_install; } /** * Get the name of the "home directory", in case the home URL is not at the domain's root. * It can be seen like the `RewriteBase` from the .htaccess file, but without the trailing slash. * * @since 3.1.1 * @author Grégory Viguier * * @return string */ function rocket_get_home_dirname() { static $home_root; if ( isset( $home_root ) ) { return $home_root; } $home_root = wp_parse_url( rocket_get_main_home_url() ); if ( ! empty( $home_root['path'] ) ) { $home_root = '/' . trim( $home_root['path'], '/' ); $home_root = rtrim( $home_root, '/' ); } else { $home_root = ''; } return $home_root; } /** * Get the URL of the site's root. It corresponds to the main site's home page URL. * * @since 3.1.1 * @author Grégory Viguier * * @return string */ function rocket_get_main_home_url() { static $root_url; if ( isset( $root_url ) ) { return $root_url; } if ( ! is_multisite() || is_main_site() ) { $root_url = rocket_get_home_url( '/' ); return $root_url; } $current_network = get_network(); if ( $current_network ) { $root_url = set_url_scheme( 'https://' . $current_network->domain . $current_network->path ); $root_url = trailingslashit( $root_url ); } else { $root_url = rocket_get_home_url( '/' ); } return $root_url; }