mespacedef_='', name_='SessionSteps', pretty_print=True):
imported_ns_def_ = GenerateDSNamespaceDefs_.get('SessionSteps')
if imported_ns_def_ is not None:
namespacedef_ = imported_ns_def_
if pretty_print:
eol_ = '\n'
else:
eol_ = ''
if self.original_tagname_ is not None and name_ == 'SessionSteps':
name_ = self.original_tagname_
if UseCapturedNS_ and self.ns_prefix_:
namespaceprefix_ = self.ns_prefix_ + ':'
showIndent(outfile, level, pretty_print)
outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
already_processed = set()
self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SessionSteps')
if self._hasContent():
outfile.write('>%s' % (eol_, ))
self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='SessionSteps', pretty_print=pretty_print)
showIndent(outfile, level, pretty_print)
outfile.write('%s%s>%s' % (namespaceprefix_, name_, eol_))
else:
outfile.write('/>%s' % (eol_, ))
def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='SessionSteps'):
pass
def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SessionSteps', fromsubclass_=False, pretty_print=True):
if pretty_print:
eol_ = '\n'
else:
eol_ = ''
for step_ in self.step:
namespaceprefix_ = self.step_nsprefix_ + ':' if (UseCapturedNS_ and self.step_nsprefix_) else ''
step_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='step', pretty_print=pretty_print)
def build(self, node, gds_collector_=None):
self.gds_collector_ = gds_collector_
if SaveElementTreeNode:
self.gds_elementtree_node_ = node
already_processed = set()
self.ns_prefix_ = node.prefix
self._buildAttributes(node, node.attrib, already_processed)
for child in node:
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
return self
def _buildAttributes(self, node, attrs, already_processed):
pass
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
if nodeName_ == 'step':
obj_ = SessionStep.factory(parent_object_=self)
obj_.build(child_, gds_collector_=gds_collector_)
self.step.append(obj_)
obj_.original_tagname_ = 'step'
def __getstate__(self):
return {m.get_name(): getattr(self, m.get_name()) for m in SessionSteps.member_data_items_}
def __setstate__(self, state):
self.__init__(**state)
# end class SessionSteps
class Session(GeneratedsSuper):
__hash__ = GeneratedsSuper.__hash__
member_data_items_ = [
MemberSpec_('session_id', 'xs:string', 0, 1, {'use': 'optional', 'name': 'session-id'}),
MemberSpec_('creation_date', 'xs:string', 0, 1, {'use': 'optional', 'name': 'creation-date'}),
MemberSpec_('steps_passed', 'SessionSteps', 0, 1, {'minOccurs': '0', 'name': 'steps-passed', 'type': 'SessionSteps'}, None),
MemberSpec_('additional_info', 'MigrationTaskInfo', 0, 0, {'name': 'additional-info', 'type': 'MigrationTaskInfo'}, None),
]
subclass = None
superclass = None
def __init__(self, session_id=None, creation_date=None, steps_passed=None, additional_info=None, gds_collector_=None, **kwargs_):
self.gds_collector_ = gds_collector_
self.gds_elementtree_node_ = None
self.original_tagname_ = None
self.parent_object_ = kwargs_.get('parent_object_')
self.ns_prefix_ = None
self.session_id = _cast(None, session_id)
self.session_id_nsprefix_ = None
self.creation_date = _cast(None, creation_date)
self.creation* return Array An array of domain names to DNS prefetch
*/
function rocket_get_dns_prefetch_domains() {
$domains = (array) get_rocket_option( 'dns_prefetch', [] );
/**
* Filter list of domains to prefetch DNS
*
* @since 1.1.0
*
* @param array $domains List of domains to prefetch DNS
*/
return apply_filters( 'rocket_dns_prefetch', $domains );
}
/**
* Gets the parameters ignored during caching
*
* These parameters are ignored when checking the query string during caching to allow serving the default cache when they are present
*
* @since 3.4
*
* @return array
*/
function rocket_get_ignored_parameters() {
/**
* Filters the ignored parameters
*
* @since 3.4
*
* @param array $params An array of ignored parameters as array keys.
*/
return apply_filters( 'rocket_cache_ignored_parameters', [] );
}
/**
* Get all uri we don't cache.
*
* @since 3.3.2 Exclude embedded URLs
* @since 2.6 Using json_get_url_prefix() to auto-exclude the WordPress REST API.
* @since 2.4.1 Auto-exclude WordPress REST API.
* @since 2.0
*
* @param bool $force Force the static uris to be reverted to null.
* @param bool $show_safe_content show sensitive uris.
* @return string A pipe separated list of rejected uri.
*/
function get_rocket_cache_reject_uri( $force = false, $show_safe_content = true ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
static $uris;
global $wp_rewrite;
if ( $force ) {
$uris = null;
}
if ( $uris ) {
return $uris;
}
$uris = (array) get_rocket_option( 'cache_reject_uri', [] );
$home_root = rocket_get_home_dirname();
$home_root_escaped = preg_quote( $home_root, '/' ); // The site is not at the domain root, it's in a folder.
$home_root_len = strlen( $home_root );
if ( '' !== $home_root && $uris ) {
foreach ( $uris as $i => $uri ) {
/**
* Since these URIs can be regex patterns like `/homeroot(/.+)/`, we can't simply search for the string `/homeroot/` (nor `/homeroot`).
* So this pattern searches for `/homeroot/` and `/homeroot(/`.
*/
if ( ! preg_match( '/' . $home_root_escaped . '\(?\//', $uri ) ) {
// Reject URIs located outside site's folder.
unset( $uris[ $i ] );
continue;
}
// Remove the home directory.
$uris[ $i ] = substr( $uri, $home_root_len );
}
}
// Exclude feeds.
$uris[] = '/(?:.+/)?' . $wp_rewrite->feed_base . '(?:/(?:.+/?)?)?$';
// Exclude embedded URLs.
$uris[] = '/(?:.+/)?embed/';
/**
* Filter the rejected uri
*
* @since 2.1
*
* @param array $uris List of rejected uri
* @param bool $show_safe_content show sensitive uris.
*/
$uris = apply_filters( 'rocket_cache_reject_uri', $uris, $show_safe_content );
$uris = array_filter( $uris );
if ( ! $uris ) {
return '';
}
$uris = array_map(
function ( $uri ) {
// Sanitize URIs and remove single quote from them to avoid syntax errors in .htaccess and php config file.
return str_replace( "'", '', esc_url_raw( $uri ) );
},
$uris
);
if ( '' !== $home_root ) {
foreach ( $uris as $i => $uri ) {
if ( preg_match( '/' . $home_root_escaped . '\(?\//', $uri ) ) {
// Remove the home directory from the new URIs.
$uris[ $i ] = substr( $uri, $home_root_len );
}
}
}
$uris = implode( '|', $uris );
if ( '' !== $home_root ) {
// Add the home directory back.
$uris = $home_root . '(' . $uris . ')';
}
return $uris;
}
/**
* Get all cookie names we don't cache.
*
* @since 2.0
*
* @return string A pipe separated list of rejected cookies.
*/
function get_rocket_cache_reject_cookies() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
$logged_in_cookie = explode( COOKIEHASH, LOGGED_IN_COOKIE );
$logged_in_cookie = array_map( 'preg_quote', $logged_in_cookie );
$logged_in_cookie = implode( '.+', $logged_in_cookie );
$cookies = get_rocket_option( 'cache_reject_cookies', [] );
$cookies[] = $logged_in_cookie;
$cookies[] = 'wp-postpass_';
$cookies[] = 'wptouch_switch_toggle';
$cookies[] = 'comment_author_';
$cookies[] = 'comment_author_email_';
/**
* Filter the rejected cookies.
*
* @since 2.1
*
* @param array $cookies List of rejected cookies.
*/
$cookies = (array) apply_filters( 'rocket_cache_reject_cookies', $cookies );
$cookies = array_filter( $cookies );
$cookies = array_flip( array_flip( $cookies ) );
return implode( '|', $cookies );
}
/**
* Get list of mandatory cookies to be able to cache pages.
*
* @since 2.7
*
* @return string A pipe separated list of mandatory cookies.
*/
function get_rocket_cache_mandatory_cookies() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
$cookies = [];
/**
* Filter list of mandatory cookies.
*
* @since 2.7
*
* @param array $cookies List of mandatory cookies.
*/
$cookies = (array) apply_filters( 'rocket_cache_mandatory_cookies', $cookies );
$cookies = array_filter( $cookies );
$cookies = array_flip( array_flip( $cookies ) );
return implode( '|', $cookies );
}
/**
* Get list of dynamic cookies.
*
* @since 2.7
*
* @return array List of dynamic cookies.
*/
function get_rocket_cache_dynamic_cookies() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
$cookies = [];
/**
* Filter list of dynamic cookies.
*
* @since 2.7
*
* @param array $cookies List of dynamic cookies.
*/
$cookies = (array) apply_filters( 'rocket_cache_dynamic_cookies', $cookies );
$cookies = array_filter( $cookies );
$cookies = array_unique( $cookies );
return $cookies;
}
/**
* Get all User-Agent we don't allow to get cache files.
*
* @since 2.3.5
*
* @return string A pipe separated list of rejected User-Agent.
*/
function get_rocket_cache_reject_ua() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
$ua = get_rocket_option( 'cache_reject_ua', [] );
$ua[] = 'facebookexternalhit';
$ua[] = 'WhatsApp';
/**
* Filter the rejected User-Agent
*
* @since 2.3.5
*
* @param array $ua List of rejected User-Agent.
*/
$ua = (array) apply_filters( 'rocket_cache_reject_ua', $ua );
$ua = array_filter( $ua );
$ua = array_flip( array_flip( $ua ) );
$ua = implode( '|', $ua );
return str_replace( [ ' ', '\\\\ ' ], '\\ ', $ua );
}
/**
* Get all query strings which can be cached.
*
* @since 2.3
*
* @return array List of query strings which can be cached.
*/
function get_rocket_cache_query_string() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
$query_strings = get_rocket_option( 'cache_query_strings', [] );
/**
* Filter query strings which can be cached.
*
* @since 2.3
*
* @param array $query_strings List of query strings which can be cached.
*/
$query_strings = (array) apply_filters( 'rocket_cache_query_strings', $query_strings );
$query_strings = array_filter( $query_strings );
$query_strings = array_flip( array_flip( $query_strings ) );
return $query_strings;
}
/**
* Determine if the key is valid
*
* @since 2.9 use hash_equals() to compare the hash values
* @since 1.0
*
* @return bool true if everything is ok, false otherwise
*/
function rocket_valid_key() {
$rocket_secret_key = (string) get_rocket_option( 'secret_key', '' );
if ( ! $rocket_secret_key ) {
return false;
}
$valid_details = 8 === strlen( (string) get_rocket_option( 'consumer_key', '' ) ) && hash_equals( $rocket_secret_key, hash( 'crc32', get_rocket_option( 'consumer_email', '' ) ) );
if ( ! $valid_details ) {
set_transient(
'rocket_check_key_errors',
[
__( 'The provided license data are not valid.', 'rocket' ) .
'
' .
// Translators: %1$s = opening link tag, %2$s = closing link tag.
sprintf( __( 'To resolve, please %1$scontact support%2$s.', 'rocket' ), '', '' ),
]
);
return $valid_details;
}
return $valid_details;
}
/**
* Determine if the key is valid.
*
* @since 2.9.7 Remove arguments ($type & $data).
* @since 2.9.7 Stop to auto-check the validation each 1 & 30 days.
* @since 2.2 The function do the live check and update the option.
*
* @return bool|array
*/
function rocket_check_key() {
// Recheck the license.
$return = rocket_valid_key();
if ( $return ) {
rocket_delete_licence_data_file();
return $return;
}
Logger::info( 'LICENSE VALIDATION PROCESS STARTED.', [ 'license validation process' ] );
$response = wp_remote_get(
'https://api.wp-rocket.me/valid_key.php',
[
'timeout' => 30,
]
);
if ( is_wp_error( $response ) ) {
Logger::error(
'License validation failed.',
[
'license validation process',
'request_error' => $response->get_error_messages(),
]
);
set_transient( 'rocket_check_key_errors', $response->get_error_messages() );
return $return;
}
$body = wp_remote_retrieve_body( $response );
$json = json_decode( $body );
if ( null === $json ) {
if ( '' === $body ) {
Logger::error( 'License validation failed. No body available in response.', [ 'license validation process' ] );
// 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$sValidate License%2$s below. If the error persists, follow %3$sthis guide%4$s.', 'rocket' ), '', '', '', '' );
set_transient( 'rocket_check_key_errors', [ $message ] );
return $return;
}
Logger::error(
'License validation failed.',
[
'license validation process',
'response_body' => $body,
]
);
if ( 'NULLED' === $body ) {
// Translators: %1$s = opening link tag, %2$s = closing link tag.
$message = __( 'License validation failed. You may be using a nulled version of the plugin. Please do the following:', 'rocket' ) . '