t_timeout_$key", 'options' ); // Update alloptions $alloptions = $wp_object_cache->get( 'alloptions', 'options' ); unset( $alloptions["_transient_$key"] ); unset( $alloptions["_transient_timeout_$key"] ); $wp_object_cache->set( 'alloptions', $alloptions, 'options' ); return $wp_object_cache->delete( "_transient_$key", 'options' ); } elseif ( 'site-transient' == $group ) { if ( ! empty( $wpdb ) && $wpdb instanceof wpdb ) { $table = $wpdb->options; if ( is_multisite() ) { $table = $wpdb->sitemeta; } $flag = $wpdb->suppress_errors; $wpdb->suppress_errors( true ); $wpdb->query( $wpdb->prepare( "DELETE FROM `{$table}` WHERE option_name IN ( %s, %s );", "_transient_{$key}", "_transient_timeout_{$key}" ) ); $wpdb->suppress_errors( $flag ); } $wp_object_cache->delete( "_transient_timeout_$key", 'site-options' ); // Update alloptions $alloptions = $wp_object_cache->get( 'alloptions', 'options' ); unset( $alloptions["_site_transient_$key"] ); unset( $alloptions["_site_transient_timeout_$key"] ); $wp_object_cache->set( 'alloptions', $alloptions, 'options' ); return $wp_object_cache->delete( "_site_transient_$key", 'site-options' ); } return $wp_object_cache->delete( $key, $group ); } function wp_cache_flush( $local_flush = false ) { global $wp_object_cache, $wpdb; if ( ! $local_flush ) { if ( ! empty( $wpdb ) && $wpdb instanceof wpdb ) { $flag = $wpdb->suppress_errors; $wpdb->suppress_errors( true ); $wpdb->query( "INSERT INTO `{$wpdb->options}` (`option_name`, `option_value`, `autoload`) VALUES ( 'gd_system_last_cache_flush', UNIX_TIMESTAMP( NOW() ), 'no' ) ON DUPLICATE KEY UPDATE `option_name` = VALUES ( `option_name` ), `option_value` = VALUES ( `option_value` ), `autoload` = VALUES ( `autoload` );" ); $wpdb->suppress_errors( $flag ); } } return $wp_object_cache->flush(); } function wp_cache_get( $key, $group = '', $force = false ) { global $wp_object_cache, $wpdb; if ( 'transient' == $group ) { $alloptions = $wp_object_cache->get( 'alloptions', 'options' ); if ( isset( $alloptions["_transient_$key"] ) && isset( $alloptions["_transient_timeout_$key"] ) && $alloptions["_transient_timeout_$key"] > time() ) { return maybe_unserialize( $alloptions["_transient_$key"] ); } $transient = $wp_object_cache->get( "_transient_$key", 'options', $force ); $timeout = $wp_object_cache->get( "_transient_timeout_$key", 'options', $force ); if ( false !== $transient && ! empty( $timeout ) && $timeout > time() ) { return maybe_unserialize( $transient ); } if ( ! empty( $wpdb ) && $wpdb instanceof wpdb ) { $flag = $wpdb->suppress_errors; $wpdb->suppress_errors( true ); $result = $wpdb->get_results( $wpdb->prepare( "SELECT option_name, option_value FROM `{$wpdb->options}` WHERE option_name IN ( %s, %s ) UNION SELECT 'current_time', UNIX_TIMESTAMP( NOW() ) AS option_value;", "_transient_{$key}", "_transient_timeout_{$key}" ), ARRAY_A ); $wpdb->suppress_errors( $flag ); if ( ! empty( $result ) ) { $transient = false; $timeout = false; $current_time = time(); foreach ( $result as $row ) { switch ( $row['option_name'] ) { case "_transient_$key" : $transient = $row['option_value']; break; case "_transient_timeout_$key" : $timeout = $row['option_value']; break; case 'current_time' : $current_time = $row['option_value']; break; } } if ( false !== $transient && ! empty( $timeout ) && $timeout > $current_time ) { return maybe_unserialize( $transient ); } } } return false; } elseif ( 'site-transient' == $group ) { $transient = $wp_object_cache->get( "_site_transient_$key", 'options', $force ); $timeout = $wp_object_cache->get( "_site_transient_timeout_$key", 'options', $force ); if ( false !== $transient && ! empty( $timeout ) && $timeout > time() ) { return maybe_unserialize( $transient ); } if ( ! empty( $wpdb ) && $wpdb instanceof wpdb ) { $table = $wpdb->options; if ( is_multisite() ) { $table = $wpdb->sitemeta; } $flag = $wpdb->suppress_errors; $wpdb->suppress_errors( true ); $result = $wpdb->get_results( $wpdb->prepare( "SELECT option_name, option_value FROM `{$table}` WHERE option_name IN ( %s, %s ) UNION SELECT 'current_time', UNIX_TIMESTAMP( NOW() ) AS option_value;", "_site_transient_{$key}", "_site_transient_timeout_{$key}" ), ARRAY_A ); $wpdb->suppress_errors( $flag ); if ( ! empty( $result ) ) { $transient = false; $timeout = false; $current_time = time(); foreach ( $result as $row ) { switch ( $row['option_name'] ) { case "_site_transient_$key" : $transient = $row['option_value']; break; case "_site_transient_timeout_$key" : $timeout = $row['option_value']; break; case 'current_time' : $current_time = $row['option_value']; break; } } if ( false !== $transient && ! empty( $timeout ) && $timeout > $current_time ) { return maybe_unserialize( $transient ); } } } return false; } else { return $wp_object_cache->get( $key, $group, $force ); } } function wp_cache_init() { global $wp_object_cache; if ( mt_rand( 1, 100 ) == 42 ) { wpaas_prune_transients(); } add_action( 'muplugins_loaded', 'wpaas_init_sync_cache' ); $wp_object_cache = new APCu_Object_Cache(); } function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) { global $wp_object_cache; return $wp_object_cache->replace( $key, $data, $group, $expire ); } function wp_cache_set( $key, $data, $group = '', $expire = 0 ) { global $wp_object_cache; if ( defined( 'WP_INSTALLING' ) == false ) { if ( 'transient' == $group ) { return wpaas_save_transient( $key, $data, $expire ); } elseif ( 'site-transient' == $group ) { return wpaas_save_transient( $key, $data, $expire, true ); } else { return $wp_object_cache->set( $key, $data, $group, $expire ); } } else { return $wp_object_cache->delete( $key, $group ); } } function wp_cache_switch_to_blog( $blog_id ) { global $wp_object_cache; return $wp_object_cache->switch_to_blog( $blog_id ); } function wp_cache_add_global_groups( $groups ) { global $wp_object_cache; $wp_object_cache->add_global_groups( $groups ); } function wp_cache_add_non_persistent_groups( $groups ) { global $wp_object_cache; $wp_object_cache->add_non_persistent_groups( $groups ); } class GD_APCu_Object_Cache { private $prefix = ''; private $local_cache = array(); private $global_groups = array(); private $non_persistent_groups = array(); private $multisite = false; private $blog_prefix = ''; public function __construct() { global $table_prefix; $this->multisite = is_multisite(); $this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : ''; $this->prefix = DB_HOST . '.' . DB_NAME . '.' . $table_prefix; } private function get_group( $group ) { return empty( $group ) ? 'default' : $group; } private function get_key( $group, $key ) { if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { return $this->prefix . '.' . $group . '.' . $this->blog_prefix . ':' . $key; } else { return $this->prefix . '.' . $group . '.' . $key; } } public function add( $key, $data, $group = 'default', $expire = 0 ) { $group = $this->get_group( $group ); $key = $this->get_key( $group, $key ); if ( function_exists( 'wp_suspend_cache_addition' ) && wp_suspend_cache_addition() ) { return false; } if ( isset( $this->local_cache[ $group ][ $key ] ) ) { return false; } // FIXME: Somehow apcu_add does not return false if key already exists if ( ! isset( $this->non_persistent_groups[ $group ] ) && apcu_exists( $key ) ) { return false; } if ( is_object( $data ) ) { $this->local_cache[ $group ][ $key ] = clone $data; } else { $this->local_cache[ $group ][ $key ] = $data; } if ( ! isset( $this->non_persistent_groups[ $group ] ) ) { return apcu_add( $key, $data, (int) $expire ); } return true; } public function add_global_groups( $groups ) { if ( is_array( $groups ) ) { foreach ( $groups as $group ) { $this->global_groups[ $group ] = true; } } else { $this->global_groups[ $groups ] = true; } } public function add_non_persistent_groups( $groups ) { if ( is_array( $groups ) ) { foreach ( $groups as $group ) { $this->non_persistent_groups[ $group ] = true; } } else { $this->non_persistent_groups[ $groups ] = true; } } public function decr( $key, $offset = 1, $group = 'default' ) { if ( $offset < 0 ) { return $this->incr( $key, abs( $offset ), $group ); } $group = $this->get_group( $group ); $key = $this->get_key( $group, $key ); if ( isset( $this->local_cache[ $group ][ $key ] ) && $this->local_cache[ $group ][ $key ] - $offset >= 0 ) { $this->local_cache[ $group ][ $key ] -= $offset; } else { $this->local_cache[ $group ][ $key ] = 0; } if ( isset( $this->non_persistent_groups[ $group ] ) ) { return $this->local_cache[ $group ][ $key ]; } else { $value = apcu_dec( $key, $offset ); if ( $value < 0 ) { apcu_store( $key, 0 ); return 0; } return $value; } } public function delete( $key, $group = 'default', $force = false ) { $group = $this->get_group( $group ); $key = $this->get_key( $group, $key ); unset( $this->local_cache[ $group ][ $key ] ); if ( ! isset( $this->non_persistent_groups[ $group ] ) ) { return apcu_delete( $key ); } return true; } public function flush() { $this->local_cache = array(); // TODO: only clear our own entries apcu_clear_cache(); return true; } public function get( $key, $group = 'default', $force = false, &$found = null ) { $group = $this->get_group( $group ); $key = $this->get_key( $group, $key ); if ( ! $force && isset( $this->local_cache[ $group ][ $key ] ) ) { $found = true; if ( is_object( $this->local_cache[ $group ][ $key ] ) ) { return clone $this->local_cache[ $group ][ $key ]; } else { return $this->local_cache[ $group ][ $key ]; } } elseif ( isset( $this->non_persistent_groups[ $group ] ) ) { $found = false; return false; } else { $value = @apcu_fetch( $key, $found ); if ( $found ) { if ( $force ) { $this->local_cache[ $group ][ $key ] = $value; } return $value; } else { return false; } } } public function incr2( $key, $offset = 1, $group = 'default' ) { if ( $offset < 0 ) { return $this->decr( $key, abs( $offset ), $group ); } $group = $this->get_group( $group ); $key = $this->get_key( $group, $key ); if ( isset( $this->local_cache[ $group ][ $key ] ) && $this->local_cache[ $group ][ $key ] + $offset >= 0 ) { $this->local_cache[ $group ][ $key ] += $offset; } else { $this->local_cache[ $group ][ $key ] = 0; } if ( isset( $this->non_persistent_groups[ $group ] ) ) { return $this->local_cache[ $group ][ $key ]; } else if ( function_exists( 'apcu_inc' ) ) { $value = apcu_inc( $key, $offset ); if ( $value < 0 ) { apcu_store( $key, 0 ); return 0; } return $value; } return false; } public function replace( $key, $data, $group = 'default', $expire = 0 ) { $group = $this->get_group( $group ); $key = $this->get_key( $group, $key ); if ( isset( $this->non_persistent_groups[ $group ] ) ) { if ( ! isset( $this->local_cache[ $group ][ $key ] ) ) { return false; } } else { if ( ! isset( $this->local_cache[ $group ][ $key ] ) && ! apcu_exists( $key ) ) { return false; } apcu_store( $key, $data, (int) $expire ); } if ( is_object( $data ) ) { $this->local_cache[ $group ][ $key ] = clone $data; } else { $this->local_cache[ $group ][ $key ] = $data; } return true; } public function reset() { // This function is deprecated as of WordPress 3.5 // Be safe and flush the cache if this function is still used $this->flush(); } public function set( $key, $data, $group = 'default', $expire = 0 ) { $group = $this->get_group( $group ); $key = $this->get_key( $group, $key ); if ( is_object( $data ) ) { $this->local_cache[ $group ][ $key ] = clone $data; } else { $this->local_cache[ $group ][ $key ] = $data; } if ( ! isset( $this->non_persistent_groups[ $group ] ) ) { return apcu_store( $key, $data, (int) $expire ); } return true; } public function stats() { // Only implemented because the default cache class provides this. // This method is never called. echo ''; } public function switch_to_blog( $blog_id ) { $this->blog_prefix = $this->multisite ? $blog_id . ':' : ''; } } if ( function_exists( 'apcu_inc' ) ) { class APCu_Object_Cache extends GD_APCu_Object_Cache { function incr( $key, $offset = 1, $group = 'default' ) { return parent::incr2( $key, $offset, $group ); } } } else { class APCu_Object_Cache extends GD_APCu_Object_Cache { // Blank } } endif; a lock or some other sending issue * * @param string $type Sync type. Can be `sync` or `full_sync`. */ static function do_cron_sync_by_type( $type ) { if ( ! self::sync_allowed() || ( 'sync' !== $type && 'full_sync' !== $type ) ) { return; } self::initialize_sender(); $time_limit = Jetpack_Sync_Settings::get_setting( 'cron_sync_time_limit' ); $start_time = time(); do { $next_sync_time = self::$sender->get_next_sync_time( $type ); if ( $next_sync_time ) { $delay = $next_sync_time - time() + 1; if ( $delay > 15 ) { break; } elseif ( $delay > 0 ) { sleep( $delay ); } } $result = 'full_sync' === $type ? self::$sender->do_full_sync() : self::$sender->do_sync(); } while ( $result && ! is_wp_error( $result ) && ( $start_time + $time_limit ) > time() ); } static function initialize_listener() { require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php'; self::$listener = Jetpack_Sync_Listener::get_instance(); } static function initialize_sender() { require_once dirname( __FILE__ ) . '/class.jetpack-sync-sender.php'; self::$sender = Jetpack_Sync_Sender::get_instance(); // bind the sending process add_filter( 'jetpack_sync_send_data', array( __CLASS__, 'send_data' ), 10, 6 ); } static function initialize_woocommerce() { if ( false === class_exists( 'WooCommerce' ) ) { return; } add_filter( 'jetpack_sync_modules', array( 'Jetpack_Sync_Actions', 'add_woocommerce_sync_module' ) ); } static function add_woocommerce_sync_module( $sync_modules ) { require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-woocommerce.php'; $sync_modules[] = 'Jetpack_Sync_Module_WooCommerce'; return $sync_modules; } static function initialize_wp_super_cache() { if ( false === function_exists( 'wp_cache_is_enabled' ) ) { return; } add_filter( 'jetpack_sync_modules', array( 'Jetpack_Sync_Actions', 'add_wp_super_cache_sync_module' ) ); } static function add_wp_super_cache_sync_module( $sync_modules ) { require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-wp-super-cache.php'; $sync_modules[] = 'Jetpack_Sync_Module_WP_Super_Cache'; return $sync_modules; } static function sanitize_filtered_sync_cron_schedule( $schedule ) { $schedule = sanitize_key( $schedule ); $schedules = wp_get_schedules(); // Make sure that the schedule has actually been registered using the `cron_intervals` filter. if ( isset( $schedules[ $schedule ] ) ) { return $schedule; } return self::DEFAULT_SYNC_CRON_INTERVAL_NAME; } static function get_start_time_offset( $schedule = '', $hook = '' ) { $start_time_offset = is_multisite() ? mt_rand( 0, ( 2 * self::DEFAULT_SYNC_CRON_INTERVAL_VALUE ) ) : 0; /** * Allows overriding the offset that the sync cron jobs will first run. This can be useful when scheduling * cron jobs across multiple sites in a network. * * @since 4.5 * * @param int $start_time_offset * @param string $hook * @param string $schedule */ return intval( apply_filters( 'jetpack_sync_cron_start_time_offset', $start_time_offset, $hook, $schedule ) ); } static function maybe_schedule_sync_cron( $schedule, $hook ) { if ( ! $hook ) { return; } $schedule = self::sanitize_filtered_sync_cron_schedule( $schedule ); $start_time = time() + self::get_start_time_offset( $schedule, $hook ); if ( ! wp_next_scheduled( $hook ) ) { // Schedule a job to send pending queue items once a minute wp_schedule_event( $start_time, $schedule, $hook ); } else if ( $schedule != wp_get_schedule( $hook ) ) { // If the schedule has changed, update the schedule wp_clear_scheduled_hook( $hook ); wp_schedule_event( $start_time, $schedule, $hook ); } } static function clear_sync_cron_jobs() { wp_clear_scheduled_hook( 'jetpack_sync_cron' ); wp_clear_scheduled_hook( 'jetpack_sync_full_cron' ); } static function init_sync_cron_jobs() { add_filter( 'cron_schedules', array( __CLASS__, 'jetpack_cron_schedule' ) ); add_action( 'jetpack_sync_cron', array( __CLASS__, 'do_cron_sync' ) ); add_action( 'jetpack_sync_full_cron', array( __CLASS__, 'do_cron_full_sync' ) ); /** * Allows overriding of the default incremental sync cron schedule which defaults to once every 5 minutes. * * @since 4.3.2 * * @param string self::DEFAULT_SYNC_CRON_INTERVAL_NAME */ $incremental_sync_cron_schedule = apply_filters( 'jetpack_sync_incremental_sync_interval', self::DEFAULT_SYNC_CRON_INTERVAL_NAME ); self::maybe_schedule_sync_cron( $incremental_sync_cron_schedule, 'jetpack_sync_cron' ); /** * Allows overriding of the full sync cron schedule which defaults to once every 5 minutes. * * @since 4.3.2 * * @param string self::DEFAULT_SYNC_CRON_INTERVAL_NAME */ $full_sync_cron_schedule = apply_filters( 'jetpack_sync_full_sync_interval', self::DEFAULT_SYNC_CRON_INTERVAL_NAME ); self::maybe_schedule_sync_cron( $full_sync_cron_schedule, 'jetpack_sync_full_cron' ); } static function cleanup_on_upgrade( $new_version = null, $old_version = null ) { if ( wp_next_scheduled( 'jetpack_sync_send_db_checksum' ) ) { wp_clear_scheduled_hook( 'jetpack_sync_send_db_checksum' ); } $is_new_sync_upgrade = version_compare( $old_version, '4.2', '>=' ); if ( ! empty( $old_version ) && $is_new_sync_upgrade && version_compare( $old_version, '4.5', '<' ) ) { require_once dirname( __FILE__ ) . '/class.jetpack-sync-settings.php'; self::clear_sync_cron_jobs(); Jetpack_Sync_Settings::update_settings( array( 'render_filtered_content' => Jetpack_Sync_Defaults::$default_render_filtered_content ) ); } } static function get_sync_status() { self::initialize_sender(); $sync_module = Jetpack_Sync_Modules::get_module( 'full-sync' ); $queue = self::$sender->get_sync_queue(); $full_queue = self::$sender->get_full_sync_queue(); $cron_timestamps = array_keys( _get_cron_array() ); $next_cron = $cron_timestamps[0] - time(); $full_sync_status = ( $sync_module ) ? $sync_module->get_status() : array(); return array_merge( $full_sync_status, array( 'cron_size' => count( $cron_timestamps ), 'next_cron' => $next_cron, 'queue_size' => $queue->size(), 'queue_lag' => $queue->lag(), 'queue_next_sync' => ( self::$sender->get_next_sync_time( 'sync' ) - microtime( true ) ), 'full_queue_size' => $full_queue->size(), 'full_queue_lag' => $full_queue->lag(), 'full_queue_next_sync' => ( self::$sender->get_next_sync_time( 'full_sync' ) - microtime( true ) ), ) ); } } // Check for WooCommerce support add_action( 'plugins_loaded', array( 'Jetpack_Sync_Actions', 'initialize_woocommerce' ), 5 ); // Check for WP Super Cache add_action( 'plugins_loaded', array( 'Jetpack_Sync_Actions', 'initialize_wp_super_cache' ), 5 ); /* * Init after plugins loaded and before the `init` action. This helps with issues where plugins init * with a high priority or sites that use alternate cron. */ add_action( 'plugins_loaded', array( 'Jetpack_Sync_Actions', 'init' ), 90 ); // We need to define this here so that it's hooked before `updating_jetpack_version` is called add_action( 'updating_jetpack_version', array( 'Jetpack_Sync_Actions', 'do_initial_sync' ), 10, 0 ); add_action( 'updating_jetpack_version', array( 'Jetpack_Sync_Actions', 'cleanup_on_upgrade' ), 10, 2 ); add_action( 'jetpack_user_authorized', array( 'Jetpack_Sync_Actions', 'do_initial_sync' ), 10, 0 ); nerated_url( $url, $path ) { if ( $this->disable_filters ) { return $url; } list( $clean_path ) = explode( '?', $path ); if ( 'wp-login.php' === $clean_path && 'wp-login.php' !== $this->settings['slug'] ) { $request_path = ITSEC_Lib::get_request_path(); if ( false !== strpos( $path, 'action=postpass' ) ) { // No special handling is needed for a password-protected post. return $url; } else if ( false !== strpos( $path, 'action=register' ) ) { $url = $this->add_token_to_url( $url, 'register' ); } elseif ( 'wp-login.php' !== $request_path || empty( $_GET['action'] ) || 'register' !== $_GET['action'] ) { $url = $this->add_token_to_url( $url, 'login' ); } } else if ( 'wp-signup.php' === $clean_path && 'wp-signup.php' !== $this->settings['register'] ) { $url = $this->add_token_to_url( $url, 'register' ); } return $url; } /** * Filter the admin URL to include hide backend tokens when necessary. * * @param string $url Complete admin URL. * @param string $path Path passed to the admin_url function. * * @return string */ public function filter_admin_url( $url, $path ) { if ( 0 === strpos( $path, 'profile.php?newuseremail=' ) ) { $url = $this->add_token_to_url( $url, 'login' ); } return $url; } /** * Filter redirection URLs to login and signup pages to include the access token query arg. * * @param string $location The relative path to redirect to. * * @return string The location with conditionally added access token query arg. */ public function filter_redirect( $location ) { return $this->filter_generated_url( $location, $location ); } /** * Filter URLs to admin pages in emails to include the access token query arg. * * This ensures that users are redirected to the correct login page if they are logged-out. * * @param string $location * * @return string */ public function filter_notify_admin_page_urls( $location ) { return $this->add_token_to_url( $location, 'login' ); } /** * Add the access token query arg to the URL. * * @param string $url The URL to modify. * @param string $type The type of request to add an access token for. * * @return string The URL with the added access token query arg. */ private function add_token_to_url( $url, $type ) { $token = $this->get_access_token( $type ); $url .= ( false === strpos( $url, '?' ) ) ? '?' : '&'; $url .= $this->token_var . '=' . urlencode( $token ); return $url; } /** * Add a hidden input containing the appropriate access token name and value. * * This function is only used on multisite user signup pages. It is needed since the code that generates the form on * that page does not use site_url() or network_site_url() to generate a full URL for form's action URL. * * @param string $context The type of signup form being rendered. * * @return null */ public function add_token_to_registration_form( $context ) { if ( 'validate-user' === $context ) { echo '' . "\n"; } } /** * Hide the navigation links on the registration page. * * These links have their security tokens removed in PHP. We only hide them for UX purposes as they would * lead to a 404 page. */ public function login_enqueue() { if ( ! empty( $_GET['action'] ) && 'register' === $_GET['action'] ) { wp_enqueue_style( 'itsec-hide-backend-login-page', plugins_url( 'css/login-page.css', __FILE__ ) ); } } /** * Register the New Login URL notification. * * @param array $notifications * * @return array */ public function register_notification( $notifications ) { if ( ITSEC_Modules::get_setting( 'hide-backend', 'enabled' ) ) { $notifications['hide-backend'] = array( 'subject_editable' => true, 'message_editable' => true, 'schedule' => ITSEC_Notification_Center::S_NONE, 'recipient' => ITSEC_Notification_Center::R_USER_LIST, 'tags' => array( 'login_url', 'site_title', 'site_url' ), 'module' => 'hide-backend', ); } return $notifications; } /** * Register the strings for the Hide Backend change notification. * * @return array */ public function notification_strings() { return array( 'label' => esc_html__( 'Hide Backend – New Login URL', 'it-l10n-ithemes-security-pro' ), 'description' => sprintf( esc_html__( '%1$sHide Backend%2$s will notify the chosen recipients whenever the login URL is changed.', 'it-l10n-ithemes-security-pro' ), '', '' ), 'subject' => esc_html__( 'WordPress Login Address Changed', 'it-l10n-ithemes-security-pro' ), 'message' => esc_html__( 'The login address for {{ $site_title }} has changed. The new login address is {{ $login_url }}. You will be unable to use the old login address.', 'it-l10n-ithemes-security-pro' ), 'tags' => array( 'login_url' => esc_html__( 'The new login link.', 'it-l10n-ithemes-security-pro' ), 'site_title' => esc_html__( 'The WordPress Site Title. Can be changed under Settings -> General -> Site Title', 'it-l10n-ithemes-security-pro' ), 'site_url' => esc_html__( 'The URL to your website.', 'it-l10n-ithemes-security-pro' ), ), ); } /** * Creates a cookie to validate future requests. * * @param string $type The type of request to add an access token for. * @param int $duration Number of seconds that the key will be valid. * * @return null */ private function set_cookie( $type, $duration = 3600 /* 1 hour */ ) { $expires = time() + $duration; setcookie( "itsec-hb-$type-" . COOKIEHASH, $this->get_access_token( $type ), $expires, ITSEC_Lib::get_home_root(), COOKIE_DOMAIN, is_ssl(), true ); } /** * Checks to see if a cookie or query arg value validates the current request for the type being checked. * * @param string $type The type of request to add an access token to validate. * * @return bool true if the request is validated, false otherwise. */ private function is_validated( $type ) { $token = $this->get_access_token( $type ); if ( isset( $_REQUEST[$this->token_var] ) && $_REQUEST[$this->token_var] === $token ) { $this->set_cookie( $type ); return true; } else if ( isset( $_COOKIE["itsec-hb-$type-" . COOKIEHASH] ) && $_COOKIE["itsec-hb-$type-" . COOKIEHASH] === $token ) { return true; } return false; } /** * The access token to use for the specific request. * * @param string $type The type of request to create an access token for. * * @return string The access token. */ private function get_access_token( $type ) { if ( isset( $this->settings[$type] ) ) { return $this->settings[$type]; } return $this->settings['slug']; } private function allow_access_to_wp_signup() { if ( is_multisite() ) { // Multisite will show its own error message and without links if signups are disabled. return true; } if ( get_option( 'users_can_register' ) ) { return true; } return false; } }