??PK     ‘s]F&ÏŒQ  Q    general/powered-by.phpnu ÏÃ6Ç$        <?php
/**
 * Powered by
 *
 * @package wpengine/common-mu-plugin
 */

?>
Powered by <a href="<?php echo esc_url( $affiliate_link ? $affiliate_link : 'https://wpengine.com' ); ?>" title="<?php esc_attr_e( 'Managed WordPress Hosting', 'wpengine' ); ?>" target="_blank"><img style="width: 100px;" src="<?php echo esc_url( $logo ); ?>"></a>
PK     ‘s]5pÖ  Ö    staging-modal.phpnu ÏÃ6Ç$        <?php
/**
 * Staging Modal
 *
 * @package wpengine/common-mu-plugin
 */

?>
<!-- Modal -->
<div id="stagingModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-header">
		<h3><span class="icon wpe-icon  icon-warning-sign"></span>Warning:</h3>
	</div>
	<div class="modal-body">
		<p style="font-size:1.2em;">Copying to staging will overwrite any changes made recently to your staging site. Are you sure you want to do this?
You can backup or restore your staging area in the <a href="<?php echo esc_url( sprintf( 'https://my.wpengine.com/installs/%s/backup_points?environment=staging', PWP_NAME ) ); ?>" target="_blank">User Portal</a>
		</p>
	</div>
	<div class="modal-footer">
		<button id="dismiss" class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
		<button id="staging-submit" class="btn btn-primary" data-confirm="true" aria-hidden="false" >Deploy to Staging</button>
	</div>
</div>
PK     ‘s]e®ôÒ†  †  	  modal.phpnu ÏÃ6Ç$        <?php
/**
 * Modal
 *
 * @package wpengine/common-mu-plugin
 */

?>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-header">
		<img src="<?php echo esc_url( WPE_PLUGIN_URL ); ?>/images/ajax-loader.gif" class="modal-loading" />
		<h3 id="myModalLabel">Modal header</h3>
	</div>
	<div class="modal-body">
		<div id="progress" class="progress"></div>
		<div class="progress-label"></div>
		<div id="status"></div>
	</div>
	<div class="modal-footer">
		<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
	</div>
</div>
PK     ‘s]3C1¾  ¾    admin/notice-sticky.phpnu ÏÃ6Ç$        <?php
/**
 * Admin notice sticky
 *
 * @package wpengine/common-mu-plugin
 */

?>
<div class="wpe-notices updated wpe-notices-<?php echo esc_attr( $class ); ?>" title="<?php echo esc_attr( $id ); ?>">
	<p class="wpe-notices-<?php echo esc_attr( $class ); ?>">
		<strong><?php echo esc_attr( ucwords( $class ) ); ?>: </strong><?php esc_html_e( $message, 'wpengine' ); // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText ?>
	</p>
</div>
PK     ‘s]¡�—’  ’    admin/main/admin-ui.phpnu ÏÃ6Ç$        <?php
/**
 * Admin UI
 * Adds the WP Engine Admin settings.
 *
 * @package wpengine/common-mu-plugin
 */

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

// Check user capabilities.
if ( ! current_user_can( 'manage_options' ) ) {
	return;
}

$wpe_common = WpeCommon::instance();
$site_info  = $wpe_common->get_site_info();

// Nonce verification is being ignored here because no user action is being taken here, and no data is being saved. This simply loads the page in question.
// Ignoring the nonce allows this page to be loaded from a bookmark, for example.
// No saving logic should be added to this page. Rather, it should be handled in a separate function, or ideally through the REST api, which has nonce protection.
$page_var        = isset( $_REQUEST['page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) : '';// phpcs:ignore WordPress.Security.NonceVerification
$active_tab      = isset( $_REQUEST['tab'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) ) : '';// phpcs:ignore WordPress.Security.NonceVerification
$active_page_tab = ( 'wpengine-staging' === $page_var ) ? 'staging' : 'info';

$page_title = __( 'WP Engine has your back', 'wpe-common-plugin' );
$page_logo  = WPE_PLUGIN_URL . '/images/wpe-logo-white.svg';

// Override with whitelabel vaues if they exist.
if ( $wpe_common->is_whitelabel() ) {
	$page_title = get_option( 'wpe-install-menu_title', $page_title );
	$page_logo  = get_option( 'wpe-install-menu_icon', $page_logo );
}
?>

<div class="wrap">
	<div id="wpe-common-plugin-admin">
		<!-- Admin Header -->
		<div class="wpe-common-plugin-admin-header wpe-common-plugin-grid-2">
			<div class="wpe-common-plugin-header-title-area">
				<h1><img class="wpe-plugin-common-logo" src="<?php echo esc_url( $page_logo ); ?>" alt="" /><?php echo esc_html( $page_title ); ?></h1>
			</div>
			<div class="wpe-common-plugin-header-controls-area">
				<a href="https://my.wpengine.com/support/" class="wpe-header-button" target="_blank" rel="noopener noreferrer"><img class="wpe-header-button-icon" src="<?php echo esc_url( WPE_PLUGIN_URL . '/images/wpe-help.svg' ); ?>" alt="" /><?php esc_html_e( 'Visit Support Page', 'wpe-common-plugin' ); ?></a>
				<a href="https://my.wpengine.com/" class="wpe-header-button" target="_blank" rel="noopener noreferrer"><img class="wpe-header-button-icon" src="<?php echo esc_url( WPE_PLUGIN_URL . '/images/wpe-portal.svg' ); ?>" alt="" /><?php esc_html_e( 'Go to Portal', 'wpe-common-plugin' ); ?></a>
			</div>
		</div>
		<!-- Admin Nav -->
		<nav class="wpe-nav-tab-wrapper">
			<a href="?page=wpengine-common" class="wpe-nav-tab wpe-admin-button 
			<?php
			if ( '' === $active_tab && 'info' === $active_page_tab ) {
				echo 'wpe-nav-tab-active';
			}
			?>
			"><?php esc_html_e( 'Information', 'wpe-common-plugin' ); ?></a>
			<?php if ( wpe\plugin\Wpe_Cache_Adaptor::get_instance()->is_cache_plugin_present() ) { ?>
				<a href="?page=wpengine-common&tab=caching" class="wpe-nav-tab wpe-admin-button 
				<?php
				if ( 'caching' === $active_tab ) {
					echo 'wpe-nav-tab-active';
				}
				?>
				"><?php esc_html_e( 'Caching', 'wpe-common-plugin' ); ?></a>
			<?php } ?>
			<a href="?page=wpengine-common&tab=display" class="wpe-nav-tab wpe-admin-button 
			<?php
			if ( 'display' === $active_tab ) {
				echo 'wpe-nav-tab-active';
			}
			?>
			"><?php esc_html_e( 'Display', 'wpe-common-plugin' ); ?></a>
			<a href="?page=wpengine-common&tab=site-settings" class="wpe-nav-tab wpe-admin-button 
			<?php
			if ( 'site-settings' === $active_tab ) {
				echo 'wpe-nav-tab-active';
			}
			?>
			"><?php esc_html_e( 'Site Settings', 'wpe-common-plugin' ); ?></a>
			<?php if ( ! $wpe_common->is_legacy_staging_disabled() ) { ?>
				<a href="?page=wpengine-common&tab=staging" class="wpe-nav-tab wpe-admin-button 
				<?php
				if ( 'staging' === $active_tab ) {
					echo 'wpe-nav-tab-active';
				}
				?>
				"><?php esc_html_e( 'Legacy Staging', 'wpe-common-plugin' ); ?></a>
				<?php
			}
			?>
		</nav>
		<!-- Admin Body -->
		<div class="wpe-common-plugin-admin-body">
		<?php
		if ( '' === $active_tab && 'info' === $active_page_tab ) {
			require_once WPE_PLUGIN_DIR . '/views/admin/main/tabs/information/logic.php';
			do_action( 'wpe_common_admin_notices' );
			include WPE_PLUGIN_DIR . '/views/admin/main/tabs/information/view.php';
		} elseif ( 'caching' === $active_tab ) {
			do_action( 'wpe_common_admin_notices' );
			wpengine\cache_plugin\WpeCachePage::display_cache_page();
		} elseif ( 'display' === $active_tab ) {
			require_once WPE_PLUGIN_DIR . '/views/admin/main/tabs/display/logic.php';
			do_action( 'wpe_common_admin_notices' );
			include WPE_PLUGIN_DIR . '/views/admin/main/tabs/display/view.php';
		} elseif ( 'site-settings' === $active_tab ) {
			require_once WPE_PLUGIN_DIR . '/views/admin/main/tabs/site-settings/logic.php';
			do_action( 'wpe_common_admin_notices' );
			include WPE_PLUGIN_DIR . '/views/admin/main/tabs/site-settings/view.php';
		} elseif ( 'staging' === $active_tab ) {
			require_once WPE_PLUGIN_DIR . '/views/admin/main/tabs/staging/logic.php';
			do_action( 'wpe_common_admin_notices' );
			include WPE_PLUGIN_DIR . '/views/admin/main/tabs/staging/view.php';
		}
		?>
		</div>
	</div>
</div>
PK     ‘s]ŸÇÀ–*  –*  !  admin/main/tabs/staging/logic.phpnu ÏÃ6Ç$        <?php
/**
 * Admin UI - Logic for actions which take place on the Staging Tab.
 *
 * @package wpengine/common-mu-plugin
 */

declare(strict_types=1);

namespace wpengine\admin_options;

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

/**
 * If this is a staging site, don't show any staging controls.
 */
function hide_controls_for_non_live() {
	if ( \is_wpe_snapshot() ) {
		?>
		<div class="notice wpe-error is-dismissible inline">
			<p><?php echo esc_html( __( 'Cannot use the standard WPEngine controls from a staging server!. This is valid only from your live site.', 'wpe-common' ) ); ?></p>
		</div>
		<?php
		die();
	}
}
add_action( 'wpe_common_admin_notices', __NAMESPACE__ . '\hide_controls_for_non_live', 1 );

/**
 * Deploy From Staging
 * Sends the api request to deploy from staging.
 * This function was formerly located in ajax.php, but has been changed to be non-ajax with the new redesign of 2021.
 * That function is moved here with almost no changes, aside from security improvements and WPCS applied.
 */
function deploy_staging_to_live() {
	// Don't do anything here unless the user has submitted a deploy_staging_to_live request.
	if ( ! wpe_param( 'wpe-common-deploy-staging-to-live' ) ) {
		return;
	}

	if ( ! is_user_logged_in() ) {
		wp_die( esc_attr( __( 'Must be an autheticated user', 'wpe-common' ) ) );
	}

	if ( ! current_user_can( 'administrator' ) ) {
		wp_die( esc_attr( __( 'Must be an administrator', 'wpe-common' ) ) );
	}

	if ( ! defined( 'PWP_NAME' ) || ! defined( 'WPE_APIKEY' ) ) {
		wp_die( esc_attr( __( 'This process could not be started.', 'wpe-common' ) ) );
	}

	check_admin_referer( PWP_NAME . '-config' );

	require_once WPE_PLUGIN_DIR . '/class-wpeapi.php';

	$db_mode = isset( $_REQUEST['db_mode'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['db_mode'] ) ) : 'default';
	$email   = isset( $_REQUEST['email'] ) ? sanitize_email( wp_unslash( $_REQUEST['email'] ) ) : get_option( 'admin_email' );

	if ( isset( $_REQUEST['tables'] ) ) {
		$tables = array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['tables'] ) );
	} else {
		$tables = false;
	}

	$api = new \WPE_API();
	$api->set_arg( 'method', 'deploy-from-staging' );
	$api->set_arg( 'db_mode', esc_attr( $db_mode ) );
	$api->set_arg( 'email', esc_attr( $email ) );

	if ( $tables ) {
		$api->set_arg( 'tables', implode( '&', $tables ) );
	}
	$api_domain = wpe_el( $GLOBALS, 'api-domain', 'https://api.wpengine.com' );
	$api_domain = str_replace( 'https://', '', $api_domain );
	$api->set_arg( 'headers', "Host:{$api_domain}" );
	$api->post();

	if ( ! $api->is_error() ) {
		// Translators: The email address where the deploy notification will be sent.
		render_admin_notice( 'info', sprintf( __( 'Your staging site is being deployed. You will receive an email at %s once it has been completed.', 'wpe-common' ), $email ) );
	} else {
		render_admin_notice( 'error', $api->is_error() );
	}
}
add_action( 'wpe_common_admin_notices', __NAMESPACE__ . '\deploy_staging_to_live' );

/**
 * Check if a deployment from staging to live has happened, and show a notice to the user if so.
 */
function maybe_notify_user_about_staging_to_live_deployment() {
	// If a deployment is underway.
	$status_file = ABSPATH . '/wpe-deploy-status-' . PWP_NAME;

	// Stop here if there's no status file.
	if ( ! file_exists( $status_file ) ) {
		return;
	}

	// Check status and either delete the status file if it is more than five minutes old, else post a nag message.
	// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
	$status = file_get_contents( $status_file );
	$time   = filemtime( $status_file );

	if ( ! strstr( $status, 'Deploy Completed' ) ) {
		return;
	}

	if ( function_exists( 'wp_timezone' ) ) {
		$dt = new \DateTime();
		$dt->setTimezone( wp_timezone() );
		$dt->setTimestamp( $time );
		$rendered_date = $dt->format( 'Y-m-d g:ia (T)' );
	} else {
		$rendered_date = gmdate( 'Y-m-d g:ia (T)', $time );
	}

	$message = sprintf(
		// Translators: 1. The date when a deployment last took place. 2. The HTML for an opening anchor tag. 3. The closing HTML for the anchor tag.
		__( 'A deployment from STAGING to LIVE was completed for this site on %1$s. If you need to revert to previous state you can do so via the WP Engine %2$sUser Portal%3$s.', 'wpe-common' ),
		$rendered_date,
		'<a href="https://my.wpengine.com" target="_blank" rel="noopener noreferrer">',
		'</a>'
	);

	?>
	<div class="notice wpe-default inline">
		<p><b>
			<?php
				echo esc_html( __( 'Successful Deployment', 'wpe-common' ) );
			?>
		</b></p>
		<p><?php echo wp_kses_post( $message ); ?></p>
	</div>
	<?php
}
add_action( 'wpe_common_admin_notices', __NAMESPACE__ . '\maybe_notify_user_about_staging_to_live_deployment' );

/**
 * This function handles legacy staging requests and displaying the corresponding notices to the user.
 *
 * This function does way too much. It should be broken down, but requires better responses from WpeCommon.
 * Specifically, the get_staging_status needs to provide a proper response about the status of a staging site,
 * especially in regards to whether a staging site is being built right now.
 *
 * The logic in this function was mostly taken unmodified from the old admin-ui.php file during the redesign process.
 * Changes made are only to accomodate the new admin notice functionality in the new design.
 */
function handle_staging_requests_and_notices() {
	$wpe_common     = \WpeCommon::instance();
	$snapshot_state = $wpe_common->get_staging_status();

	// Process snapshot -> staging.
	$just_started_snapshot = false;

	if ( wpe_param( 'snapshot' ) ) {
		check_admin_referer( PWP_NAME . '-config' );

		// Can't run one if one is already running.
		$snapshot_state = $wpe_common->get_staging_status();
		if ( $snapshot_state['have_snapshot'] && ! $snapshot_state['is_ready'] ) {
			add_action( 'wpe_common_admin_notices', __NAMESPACE__ . '\staging_snapshot_error_notice' );
		} else {
			$snapshot_result = $wpe_common->snapshot_to_staging();

			// This is definitely not an ideal check, but it's working with the way the "snapshot_to_staging" function works.
			if ( 'Recreating the staging area failed!  Please contact support for assistance.' !== $snapshot_result ) {
				$wpe_common->snapshot_to_staging();
				$just_started_snapshot = true;
				add_action( 'wpe_common_admin_notices', __NAMESPACE__ . '\notice_snapshot_in_progress' );

				// Because WpeCommon::get_staging_status doesn't return accurate results for in-progress staging calls, we have to hide the deploy section this way.
				// This makes sure it stays hidden directly after a new deploy is initiated, since $just_started_snapshot only exists here, and not in the WpeCommon::get_staging_status method.
				?>
				<style type="text/css">
					#wpe-common-deploy-staging-to-live-section {
						display:none;
					}
				</style>
				<?php

			} else {
				?>
				<div class="notice wpe-error is-dismissible inline">
					<p>
					<?php
						echo esc_attr( __( 'Recreating the staging area failed!  Please contact support for assistance.', 'wpe-common' ) );
					?>
					</p>
				</div>
				<?php
			}
		}
	}

	// If a snapshot was just initiated, override the status and the is_ready values. This is where better logic needs to come from WpeCommon::get_staging_status.
	if ( $just_started_snapshot && $snapshot_state['have_snapshot'] ) {
		$snapshot_state['status']   = 'Starting the staging snapshot process...';
		$snapshot_state['is_ready'] = false;
	}

	if ( isset( $snapshot_state['is_ready'] ) && $snapshot_state['is_ready'] ) {
		$message_type = 'success';
	} else {
		$message_type = 'info';
	}

	// If a staging snapshot exists.
	if ( $snapshot_state['have_snapshot'] ) {
		?>
		<div class="notice wpe-<?php echo esc_attr( $message_type ); ?> inline">
			<p><b>
			<?php
				echo esc_html( __( 'Staging Status:', 'wpe-common' ) . ' ' . $snapshot_state['status'] );
			?>
			</b></p>
			<?php
			if ( $snapshot_state['is_ready'] ) {
				?>
				<p>
				<?php
				if ( function_exists( 'wp_timezone' ) ) {
					$dt = new \DateTime();
					$dt->setTimezone( wp_timezone() );
					$dt->setTimestamp( $snapshot_state['last_update'] );
					$rendered_date = $dt->format( 'Y-m-d g:ia (T)' );
				} else {
					$rendered_date = gmdate( 'Y-m-d g:ia (T)', $snapshot_state['last_update'] );
				}

				echo wp_kses_post(
					sprintf(
						// Translators: the opening and closing for a bold tag.
						__( 'Last staging snapshot was taken on %1$s. Access it here:', 'wpe-common' ),
						'<span class="wpe_last_updated_date">' . $rendered_date . '</span>'
					)
				);

				?>
				<a target="_blank" rel="noopener noreferrer" href="<?php echo esc_url( $snapshot_state['staging_url'] ); ?>"><b><?php echo esc_url( $snapshot_state['staging_url'] ); ?></b></a>
			<?php } else { ?>
				<p>
				<?php
					echo esc_html( __( 'Please wait while the staging area continues to be deployed.  It can take a while!  You can refresh this page to check on its progress.', 'wpe-common' ) );
			}
			?>
			</p>
		</div>
		<?php
	}
}

/**
 * Add an admin notice to the WP Engine settings page in wp-admin.
 *
 * @param string $type The type of error. One of the following: 'default', 'error', 'info', 'success', 'warning'.
 * @param string $message The message to be shown to the user.
 */
function render_admin_notice( string $type, string $message ) {

	// Make sure the supplied message type exists.
	if ( ! in_array( $type, array( 'default', 'error', 'info', 'success', 'warning' ), true ) ) {
		return;
	}

	$type = 'wpe-' . $type;

	// Translators: 1. The CSS class name representing the type of notification this is. 2. The message shown to the user.
	echo \sprintf(
		'<div class="notice %1$s is-dismissible inline"><p>%2$s</p></div>',
		esc_attr( $type ),
		wp_kses_post( $message )
	);
}

/**
 * Render an admin notice that tells the user a staging snapshot is already in progress.
 */
function staging_snapshot_error_notice() {
	?>
	<div class="notice wpe-error is-dismissible inline">
		<p><?php echo esc_html( __( 'A staging snapshot is already in progress. Please wait for the current staging process to complete, then you can either use the staging area or you can then request another snapshot.', 'wpe-common' ) ); ?></p>
	</div>
	<?php
}

/**
 * Render an admin notice that tells the user their staging site is being built.
 */
function notice_snapshot_in_progress() {
	?>
	<div class="notice wpe-info is-dismissible inline">
		<p>
		<?php
		echo wp_kses_post(
			sprintf(
				// Translators: the opening and closing for a bold tag.
				__( 'Your staging site is being built in the background.  %1$sIt can take a long time%2$s, especially for large sites.', 'wpe-common' ),
				'<b>',
				'</b>'
			)
		);
		?>
		</p>
	</div>
	<?php
}
add_action( 'wpe_common_admin_notices', __NAMESPACE__ . '\handle_staging_requests_and_notices' );
PK     ‘s]HL«ðí  í     admin/main/tabs/staging/view.phpnu ÏÃ6Ç$        <?php
/**
 * Admin UI - Staging Tab
 * Adds the WP Engine Admin "Staging" tab.
 *
 * @package wpengine/common-mu-plugin
 */

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

// Check user capabilities.
if ( ! current_user_can( 'manage_options' ) ) {
	return;
}

$wpe_common     = \WpeCommon::instance();
$snapshot_state = $wpe_common->get_staging_status();

?>

<!-- WordPress settings tab -->
<div class="notice wpe-warning inline">
		<p>Legacy staging will reach End-of-Life and no longer be available on WP Engine by March 2022. You will now be able to test any new site changes with the <a href="https://wpengine.com/support/copy-site/" target="_blank" rel="noopener noreferrer">Copy Environment</a> feature in the WP Engine User Portal.</p>
</div>
<div class="wpe-common-plugin-container">
	<h2>What is a Staging Area?</h2>
	<p>This takes a snapshot of your site and copies it to a "<strong>staging area</strong>" where you can test changes without it affecting your <strong>live site</strong>. There's only one staging area, so every time you click this button the old staging area is lost forever, replaced with a snapshot of your live site. Both your live and staging areas are backed up daily. You can use backup points to create and restore your <a href="https://my.wpengine.com/installs/<?php echo esc_attr( esc_attr( $site_info->name ) ); ?>/backup_points" target="_blank" rel="noopener noreferrer">live site</a> and <a href="https://my.wpengine.com/installs/<?php echo esc_attr( $site_info->name ); ?>/backup_points#staging" target="_blank" rel="noopener noreferrer">staging area</a> anytime via the <a href="https://my.wpengine.com/" target="_blank" rel="noopener noreferrer">WP Engine User Portal</a>.</p>

	<p>Please note: if you want to access your staging site via SFTP, there is a different username required.  You can manage your SFTP users in your <a href="https://my.wpengine.com/" target="_blank" rel="noopener noreferrer">User Portal</a>.</p>
	<div class="wpe-admin-button-controls">
		<form id="staging" method="post" name="options" action="">
			<?php wp_nonce_field( PWP_NAME . '-config' ); ?>
			<button
				type="submit"
				name="snapshot"
				value="Create staging area"
				class="wpe-admin-button-primary"
				onclick="return confirm('This will overwrite your STAGING site with your LIVE site. Are you sure you want to do this?');"
			>Copy site from <span class="wpe-caps">Live</span> to <span class="wpe-caps">Staging</span></button>
		</form>
	</div>
</div>
<?php
// If there's a staging site that exists, and the current user has permission to deploy to live from staging, show the form for deploying.
if ( ( $snapshot_state['is_ready'] ?? false ) && current_user_can( 'administrator' ) ) {
	?>
	<div id="wpe-common-deploy-staging-to-live-section" class="wpe-common-plugin-container">
		<h2>Deploy STAGING to LIVE</h2>
			<form class="form" action="" name="deploy_staging_to_live" method="post">
				<p>By default only your files will be copied back to <b>LIVE</b>. You can choose to move content by checking the tables you would like to move below. Keep in mind these tables will replace the <b>LIVE</b> version with the <b>STAGING</b> version. So for instance if you choose to move <b>wp_posts</b> all posts added to the <b>LIVE</b> site since the staging site was created will be removed. However, a checkpoint of your site will be created so you can 'undo' the changes if necessary.</p>
				<?php
					// Tables.
					global $wpdb;

					// Allow a direct database call here to make sure it's fresh and non cached.
					$tables = $wpdb->get_col( 'SHOW TABLES;' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
					$wpdb->flush();
				?>
				<div class="wpe-common-select-panel">
					<label for="wpe-common-staging-db-mode-select">Database Mode</label>
					<select id="wpe-common-staging-db-mode-select" name="db_mode">
						<option value="none">Move No Tables</option>
						<option value="default">Move All Tables</option>
						<option value="tables">Select Tables to Move</option>
					</select>
				</div>

				<div id="wpe-common-staging-table-select" class="wpe-common-select-panel wpe-panel-align-top" style="display:none;">
					<label for="select_tables">Select Tables</label>
					<div class="wpe-common-select-tables">
						<div class="wpe-select-table-links">
							<a id="wpe-add-all-tables">Add all tables</a> | <a id="wpe-remove-all-tables">Remove all tables</a>
						</div>
						<select name="tables[]" multiple size="12">
							<?php foreach ( $tables as $table ) { ?>
								<option value="<?php echo esc_attr( $table ); ?>" <?php echo 'wp_options' === $table ? 'selected' : ''; ?>><?php echo esc_attr( $table ); ?></option>
							<?php } ?>
						</select>
					</div>
				</div>

				<div class="wpe-common-select-panel">
					<label for="staging-email">Email to Notify</label>
					<input id="staging-email" type="email" name="email" placeholder="<?php echo esc_attr( get_option( 'admin_email' ) ); ?>" value="<?php echo esc_attr( get_option( 'admin_email' ) ); ?>"/>
				</div>

				<?php
				$production_version = get_bloginfo( 'version' );
				$staging_version    = $snapshot_state['version'];
				$can_push_staging   = is_staging_gte( $production_version, $snapshot_state['version'] );
				?>

				<?php if ( $can_push_staging ) { ?>
					<div class="form-actions">
						<?php wp_nonce_field( PWP_NAME . '-config' ); ?>
						<div class="wpe-admin-button-controls">
							<button
								id="submit-deploy"
								name="wpe-common-deploy-staging-to-live"
								value="Submit"
								class="wpe-admin-button-primary"
								onclick="return confirm('This will overwrite your LIVE site with your STAGING site. Are you sure you want to do this?');"
							>Deploy STAGING to LIVE</button>
				</div>
					</div>
				<?php } else { ?>
					<div class="wpe-error">
						<h3>Your Staging Site is Running an Old Version of WordPress (<?php echo esc_attr( $snapshot_state['version'] ); ?>)</h3>
						<p>Your staging site is running an old version of WordPress, WordPress <?php echo esc_attr( $snapshot_state['version'] ); ?>.
						Before you can deploy your staging site to your live site, you need to
						<a target="_blank" rel="noopener noreferrer" href="<?php echo esc_url( $snapshot_state['staging_url'] ); ?>/wp-admin/update-core.php">update WordPress</a>
						to match your live version, <?php echo esc_attr( $production_version ); ?>. Please follow the steps to update WordPress.
						We recommend you also create a <a target="_blank" rel="noopener noreferrer" href="https://my.wpengine.com/installs/<?php echo esc_attr( PWP_NAME ); ?>/backup_points">backup point</a> before updating.</p>
					</div>
				<?php } ?>
			</form>
	</div>

	<script type="text/javascript">
		jQuery(function($) {
			// Show/hide the select field that allows the user to choose the tables they want to deploy.
			$('#wpe-common-staging-db-mode-select').change(function() {
				if( $(this).attr('name') == 'db_mode' && $(this).find('option:selected').val() == 'tables') {
					$('#wpe-common-staging-table-select').slideDown();
				} else {
					$('#wpe-common-staging-table-select').slideUp();
				}
			});

			// Select all tables when the user clicks "Add all tables".
			$('#wpe-add-all-tables').on('click', function() {
				$("[name='tables[]'] option").prop('selected', true);
			});
			// Clear all tables selected when the user clicks "Remove all tables".
			$('#wpe-remove-all-tables').on('click', function() {
				$("[name='tables[]'] option").prop('selected', false);
			});
		});
	</script>
	<?php
}
PK     ‘s]¯z¾1ï  ï  %  admin/main/tabs/information/logic.phpnu ÏÃ6Ç$        <?php
/**
 * Admin UI - Logic for actions which take place on the Information Tab.
 *
 * @package wpengine/common-mu-plugin
 */

declare(strict_types=1);

namespace wpengine\admin_options;

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

/**
 * Get the blog posts from WP Engine to show in the WP admin dashboard.
 *
 * @return array
 */
function get_blog_posts() {

	// First check if there's a cached result we can use.
	$latest_posts_transient = get_transient( 'wpecommon_latest_posts' );

	// If there is a cached result we can use, use it.
	if ( ! empty( $latest_posts_transient ) ) {
		return $latest_posts_transient;
	}

	// Otherwise, fetch the REST api for the site where the posts come from.
	$api_response = wp_remote_retrieve_body( wp_remote_get( 'https://wpengine.com/wp-json/wp/v2/posts/?_embed&per_page=1' ) );

	if ( ! is_wp_error( $api_response ) ) {
		$latest_posts = json_decode( $api_response, true );
	} else {
		// Return an empty array if the API response failed. This is not mission critical if it fails, so we fail silently here for now.
		return array();
	}

	// Set the API result in a transient for 24 hours.
	set_transient( 'wpecommon_latest_posts', $latest_posts, DAY_IN_SECONDS );

	return $latest_posts;
}
PK     ‘s]—éÛs[!  [!  $  admin/main/tabs/information/view.phpnu ÏÃ6Ç$        <?php
/**
 * Admin UI - Information Tab
 * Adds the WP Engine Admin "Information" tab.
 *
 * @package wpengine/common-mu-plugin
 */

// Don't load directly.

if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

use wpe\plugin\update_providers\Update_Providers;

// Check user capabilities.
if ( ! current_user_can( 'manage_options' ) ) {
	return;
}
?>

<!-- Admin Information Tab -->
<div class="wpe-common-plugin-tab-info wpe-common-plugin-grid-2 uneven">
	<!-- Column 1 -->
	<div class="wpe-common-plugin-column">
		<!-- Update Provider Status -->
		<?php if ( wpe_show_update_provider_health_panel() ) : ?>
			<div class="wpe-common-plugin-container">
				<h2>WordPress Core, Theme, and Plugin Availability</h2>

				<?php if ( ! wpe_allow_source_override() ) : ?>
					<!-- Source Selection Locked Message -->
					<?php $notice_data = apply_filters( 'wpe_uss_host_override_notice', array() ); ?>
					<div class="wpe-common-settings-panel" style="border-left-color: #D18431;">
						<p>
							<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $notice_data['imgsrc'] contains a trusted Base64-encoded SVG data URL from filter_wpe_uss_host_override_notice() ?>
							<img src="<?php echo $notice_data['imgsrc']; ?>" alt="WP Engine Logo" style="margin-right: 4px; vertical-align: text-bottom;" />
							<strong><?php echo esc_html( $notice_data['title'] ); ?></strong>
						</p>
						<p><?php echo wp_kses_post( $notice_data['msg'] ); ?></p>
					</div>
				<?php endif; ?>

				<?php if ( wpe_show_update_provider_current_source() ) : ?>
					<h3>Current Source</h3>
					<p class="wpe-current-provider">
						<span class="icon-info"></span>
						<span class="wpe-current-provider-text">
							<?php echo esc_html( Update_Providers::instance()->get_current_provider()->display_name ); ?>
							(<?php echo esc_html( Update_Providers::instance()->get_current_provider()->display_domain ); ?>)
							is the current source of WordPress core, themes, and plugins for this&nbsp;site.
						</span>
					</p>
				<?php endif; ?>

				<h3>Source Statuses</h3>
				<div id="wpe-provider-status-widget">
					<ul>
						<?php foreach ( Update_Providers::instance()->providers as $provider ) : ?>
							<li class="wpe-provider-status wpe-provider-status--unknown">
								Checking connection to <?php echo esc_html( $provider->display_domain ); ?>
							</li>
						<?php endforeach; ?>
					</ul>
				</div>
				<p data-remove-on-error="1">WP Engineâ€™s Mirror of WordPress.org (wpe-api.wpengine.com) provides an availability cache of the WordPress.org API.</p>
				<p><a target="_blank" rel="noopener noreferrer" href="<?php echo esc_url( 'https://wpengine.com/support/wordpress-update-source/' ); ?>">Learn more about setting a source</a></p>

				<?php if ( \wpe\plugin\WPE_Update_Source_Selector::get_settings_page_url() && wpe_allow_source_override() ) : ?>
					<div class="wpe-admin-button-controls">
						<a href="<?php echo esc_attr( \wpe\plugin\WPE_Update_Source_Selector::get_settings_page_url() ); ?>" class="wpe-admin-button-secondary">Manage Source</a>
					</div>
				<?php endif; ?>
			</div>
		<?php endif; ?>

		<!-- SFTP -->
		<div class="wpe-common-plugin-container">
			<h2>SFTP</h2>
			<p>Please read over our <a href="https://wpengine.com/support/wordpress-best-practice-configuring-dns-for-wp-engine/" target="_blank" rel="noopener noreferrer">DNS Best Practices</a> before you set your <strong>DNS</strong> to CNAME: <code><?php echo esc_html( $site_info->name . '.wpengine.com' ); ?></code> or an A record to <code class="wpe_public_ip"><?php echo esc_html( $site_info->public_ip ); ?></code></p>
			<p>Your SFTP access (<i>not FTP!</i>) is at hostname <code><?php echo esc_html( $site_info->sftp_host ); ?></code> or IP at <code class="wpe_sftp_ip"><?php echo esc_html( $site_info->sftp_ip ); ?></code> on port <code><?php echo esc_html( $site_info->sftp_port ); ?></code>.</p>
			<p>You will need to create a Username and Password in order to gain access. This can be <a href="<?php echo esc_url( get_option( 'wpe-install-userportal', 'https://my.wpengine.com' ) ); ?>" target="_blank" rel="noopener noreferrer">created in the user portal</a>.</p>
			<div class="wpe-admin-button-controls">
				<a class="wpe-admin-button-primary wpe-link-external" href="https://my.wpengine.com/support" target="_blank" rel="noopener noreferrer">Visit Support Page</a>
			</div>
		</div>
		<!-- Access and Error Logs -->
		<div class="wpe-common-plugin-container">
			<h2>Access and Error Logs</h2>
			<p><strong>Access logs</strong> are records of all the requests processed by your server. The <strong>Error logs</strong> record all errors returned by WordPress, the server, or some plugins you may have installed.</p>
			<?php if ( WpeCommon::should_render_log_links() ) : ?>
			<div class="wpe-admin-button-controls">
				<a class="wpe-admin-button-secondary wpe-link-download" href="<?php echo esc_url( $wpe_common->get_access_log_url( 'previous' ) ); ?>">Previous access logs</a>
				<?php if ( ! $wpe_common->is_legacy_staging_disabled() ) { ?>
				<a class="wpe-admin-button-secondary wpe-link-download" href="<?php echo esc_url( $this->get_error_log_url( false ) ); ?>">Legacy staging error logs</a>
				<?php } ?>
				<a class="wpe-admin-button-secondary wpe-link-download" href="<?php echo esc_url( $wpe_common->get_access_log_url( 'current' ) ); ?>">Current access logs</a>
				<a class="wpe-admin-button-secondary wpe-link-download" href="<?php echo esc_url( $this->get_error_log_url( true ) ); ?>">Current error logs</a>
			</div>
			<?php else : ?>
			<p>Please contact your WordPress site administrator to download logs.</p>
			<?php endif; ?>
			<div class="wpe-admin-button-controls">
				<a href="https://my.wpengine.com/installs/<?php echo esc_attr( $site_info->name ); ?>/access_logs" target="_blank" rel="noopener noreferrer">Access logs in the user Portal</a>
				<a href="https://my.wpengine.com/installs/<?php echo esc_attr( $site_info->name ); ?>/error_logs" target="_blank" rel="noopener noreferrer">Error logs in the user Portal</a>
			</div>
		</div>

		<?php do_action( 'wpe_common_admin_information_tab_col1' ); ?>
	</div>
	<!-- Column 2 -->
	<div class="wpe-common-plugin-column">
		<?php if ( $wpe_common->is_wpengine_news_feed_enabled() ) { ?>
		<!-- Announcements -->
		<div class="wpe-common-plugin-container wpe-announcements">
			<h2>WP Engine Announcements</h2>
			<?php
			$latest_posts = \wpengine\admin_options\get_blog_posts();

			// Loop through each post.
			foreach ( $latest_posts as $latest_post ) {
				$post_title          = isset( $latest_post['title']['rendered'] ) ? $latest_post['title']['rendered'] : '';
				$post_content        = isset( $latest_post['content']['rendered'] ) ? $latest_post['content']['rendered'] : '';
				$post_excerpt        = isset( $latest_post['excerpt']['rendered'] ) ? $latest_post['excerpt']['rendered'] : '';
				$post_permalink      = isset( $latest_post['link'] ) ? $latest_post['link'] : '';
				$post_featured_image = isset( $latest_post['_embedded']['wp:featuredmedia']['0']['media_details']['sizes']['medium']['source_url'] ) ? $latest_post['_embedded']['wp:featuredmedia']['0']['media_details']['sizes']['medium']['source_url'] : '';
				?>
				<div class="wpe-announcement-item">
					<?php if ( $post_featured_image ) { ?>
					<img class="wpe-announcement-image" src="<?php echo esc_url( $post_featured_image ); ?>" alt="" aria-hidden="true" />
					<?php } ?>
					<h3 class="wpe-announcement-title"><?php echo wp_kses_post( $post_title ); ?></h3>
					<p><?php echo wp_kses_post( wp_trim_words( $post_excerpt, 23, ' [ &#8230; ]' ) ); ?></p>
					<a class="wpe-admin-button-primary" href="<?php echo esc_url( $post_permalink ); ?>" target="_blank" rel="noopener noreferrer">Learn More<span class="screen-reader-text">About <?php echo wp_kses_post( $post_title ); ?></span></a>
				</div>
			<?php } ?>
		</div>
		<?php } ?>
		<!-- Service Status -->
		<div class="wpe-common-plugin-container">
			<h2>WP Engine Service Status</h2>
			<p>You should <a href="https://wpenginestatus.com/" target="_blank" rel="noopener noreferrer">subscribe to our WP Engine Status Page</a> to keep on top of any disruptions in service to our WP platform, support services, or product features.</p>
			<p>Of course, you can unsubscribe at any time. We use the status page only for infrequent, but important, service announcements.</p>
		</div>
		<?php do_action( 'wpe_common_admin_information_tab_col2' ); ?>
	</div>
</div>
PK     ‘s]á‹UÊ  Ê    admin/main/tabs/caching.phpnu ÏÃ6Ç$        <?php
/**
 * Admin UI - Caching Tab
 * Adds the WP Engine Admin "Caching" tab.
 *
 * @package wpengine/common-mu-plugin
 */

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

// Check user capabilities.
if ( ! current_user_can( 'manage_options' ) ) {
	return;
}

?>

<!-- Caching Tab -->
<div class="wpe-common-plugin-container">
	<h2>Quick Actions</h2>
	<p>Caching reduces the load on your site by storing the results of a request, so that it can be served to the next visitor. This significantly increases the speed of the site. However, this can lead to a visitor receiving an old version of the page. This can be fixed by clearing the cache below.</p>
	<p><strong>Note:</strong> Cache is cleared by environment, not by domain. This does not clear <strong>Global Edge Security</strong> cache.</p>
	<div class="wpe-admin-button-controls">
		<a href="#" target="_blank" rel="noopener noreferrer">Clear GES caches by domain in Portal</a>
		<a href="#" target="_blank" rel="noopener noreferrer">Learn more about caching</a>
	</div>
	<div class="wpe-common-cta-panel">
		<div class="wpe-common-cta-wrap">
		<span class="wpe-admin-icon-check-solid"></span>
			<div class="wpe-common-cta-text">
				<p class="wpe-common-cta-heading"><strong>Clear all caches at once</strong></p>
				<p>This will slow down your site until caches are rebuilt.</p>
			</div>
		</div>
		<div class="wpe-common-cta-button">
			<button class="wpe-admin-button-primary">Clear all caches</button>
		</div>
	</div>
	<div class="wpe-common-cta-panel wpe-completed">
		<div class="wpe-common-cta-wrap">
		<span class="wpe-admin-icon-check-solid"></span>
			<div class="wpe-common-cta-text">
				<p class="wpe-common-cta-heading"><strong>Clear all caches at once</strong></p>
				<p>This will slow down your site until caches are rebuilt.</p>
			</div>
		</div>
		<div class="wpe-common-cta-button">
			<button disabled class="wpe-admin-button-primary">Clear all caches</button>
		</div>
	</div>
</div>
PK     ‘s]µ&ë©©  ©  !  admin/main/tabs/display/logic.phpnu ÏÃ6Ç$        <?php
/**
 * Admin UI - Logic for actions from the Display tab.
 *
 * @package wpengine/common-mu-plugin
 */

declare(strict_types=1);

namespace wpengine\admin_options;

use WpeCommon;

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

/**
 * Regarding the WP Engine Quick Links and who is able to see/use it, this function ensures that the list of user
 * roles does not include the "administrator" role, because it is enabled for that role by default.
 */
function get_access_roles() {
	$roles = ( WP_Roles() )->get_names();
	unset( $roles['administrator'] );
	return $roles;
}

/**
 * Handles a form submission for the display options.
 */
function handle_display_options_submission() {
	if ( ! current_user_can( 'manage_options' ) ) {
		return;
	}

	if ( ! isset( $_POST['displayoptions'] ) ) {
		return;
	}

	check_admin_referer( PWP_NAME . '-config' );

	$wpe_plugin            = WpeCommon::instance();
	$enable_admin_bar_name = 'wpe-adminbar-enable';
	$admin_bar_roles_name  = 'wpe-adminbar-roles';

	$wpe_plugin->set_wpengine_admin_bar_enabled( ! empty( $_POST[ $enable_admin_bar_name ] ) );

	if ( ! empty( $_POST[ $admin_bar_roles_name ] ) && is_array( $_POST[ $admin_bar_roles_name ] ) ) {
		$wpe_plugin->set_option(
			$admin_bar_roles_name,
			array_map( 'sanitize_text_field', wp_unslash( $_POST[ $admin_bar_roles_name ] ) )
		);
	} else {
		delete_option( $admin_bar_roles_name );
	}

	add_action(
		'wpe_common_admin_notices',
		function () {
			?>
			<div class="notice wpe-success is-dismissable inline">
				<p><?php esc_html_e( 'Settings have been successfully updated', 'wpe-common' ); ?></p>
			</div>
			<?php
		}
	);
}

handle_display_options_submission();
PK     ‘s]a›8¿Ô
  Ô
     admin/main/tabs/display/view.phpnu ÏÃ6Ç$        <?php
/**
 * Admin UI - Display Tab
 * Adds the WP Engine Admin "Display" tab.
 *
 * @package wpengine/common-mu-plugin
 */

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

// Check user capabilities.
if ( ! current_user_can( 'manage_options' ) ) {
	return;
}

$enable_admin_bar_name = 'wpe-adminbar-enable';
$admin_bar_roles_name  = 'wpe-adminbar-roles';
$nonce_action          = PWP_NAME . '-config';
$form_name             = 'displayoptions';
$form_action           = add_query_arg(
	array(
		'page' => 'wpengine-common',
		'tab'  => 'display',
	),
	admin_url()
);

?>
<form
	class="wpe-common-plugin-container"
	method="post"
	action="<?php echo esc_url( $form_action ); ?>"
	name="<?php echo esc_attr( $form_name ); ?>"
>
	<?php wp_nonce_field( $nonce_action ); ?>
	<h2><?php esc_html_e( 'Display Options', 'wpe-common' ); ?></h2>

	<input
		id="<?php echo esc_attr( $enable_admin_bar_name ); ?>"
		name="<?php echo esc_attr( $enable_admin_bar_name ); ?>"
		type="checkbox"
		<?php checked( $this->is_wpengine_admin_bar_enabled() ); ?>
	>
	<label for="<?php echo esc_attr( $enable_admin_bar_name ); ?>" class="wpe-checkbox-label">
		<?php
		printf(
			/* translators: %1$s: an opening HTML tag, %2$s: a closing HTML tag */
			esc_html__( 'Display the %1$s"WP Engine Quick Actions"%2$s menu in the WordPress Admin Bar.', 'wpe-common' ),
			'<strong>',
			'</strong>'
		);
		?>
	</label>
	<h3><?php esc_html_e( 'Access Roles', 'wpe-common' ); ?></h3>
	<p>
		<?php
		printf(
			/* translators: %1$s: an opening HTML tag, %2$s: a closing HTML tag */
			esc_html__( 'Administrators will always see the %1$s"WP Engine Quick Actions"%2$s menu. For other users, please select which role should have access to it below', 'wpe-common' ),
			'<strong>',
			'</strong>'
		);
		?>
	</p>
	<div class="wpe-access-roles">
		<?php
		$roles_with_access = get_option( $admin_bar_roles_name, array() );
		foreach ( wpengine\admin_options\get_access_roles() as $user_role => $role_name ) :
			$input_id = "role-{$user_role}";

			?>
			<input
				id="<?php echo esc_attr( $input_id ); ?>"
				name="<?php echo esc_attr( "{$admin_bar_roles_name}[]" ); ?>"
				value="<?php echo esc_attr( $user_role ); ?>"
				type="checkbox"
				<?php
				checked(
					is_array( $roles_with_access ) &&
					in_array( $user_role, $roles_with_access, true )
				)
				?>
			/>
			<label for="<?php echo esc_attr( $input_id ); ?>" class="wpe-checkbox-label">
				<?php echo esc_html( $role_name ); ?>
			</label>
			<br/>
		<?php endforeach; ?>
	</div>
	<div class="wpe-admin-button-controls">
		<input
			type="submit"
			name="<?php echo esc_attr( $form_name ); ?>"
			value="<?php esc_attr_e( 'Save', 'wpe-common' ); ?>"
			class="wpe-admin-button-primary"
		/>
	</div>
</form>
PK     ‘s]�®üû    '  admin/main/tabs/site-settings/logic.phpnu ÏÃ6Ç$        <?php
/**
 * Admin UI - Site Settings Logic
 *
 * @package wpengine/common-mu-plugin
 */

declare(strict_types=1);

namespace wpengine\admin_options;

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

// Check user capabilities.
if ( ! current_user_can( 'manage_options' ) ) {
	return;
}

/**
 * Handles displaying an error notice.
 *
 * @param string $type The type of notice to be shown.
 * @param string $message The message that should be included.
 */
function show_admin_notice( string $type, string $message ) {
	if ( ! in_array( $type, array( 'default', 'error', 'info', 'success', 'warning' ), true ) ) {
		return;
	}
	$type = esc_attr( "wpe-{$type}" );
	echo wp_kses_post( "<div class=\"notice {$type} is-dismissible inline\"><p>{$message}</p></div>" );
}

/**
 * Handles the File Reset request.
 */
function handle_file_reset_request() {
	if ( ! wpe_param( 'file-perms' ) ) {
		return;
	}
	check_admin_referer( PWP_NAME . '-site-settings-file-perm-reset' );

	$api_domain = wpe_el( $GLOBALS, 'api-domain', 'https://api.wpengine.com' );
	$url        = "{$api_domain}/1.2/?method=file-permissions&account_name=" . PWP_NAME . '&wpe_apikey=' . WPE_APIKEY;
	$http       = new \WP_Http();
	$resp       = $http->get( $url );

	if (
		is_a( $resp, 'WP_Error' ) ||
		empty( $resp['response'] ) ||
		200 !== $resp['response']['code']
	) {
		add_action(
			'wpe_common_admin_notices',
			function () {
				show_admin_notice( 'error', __( 'Failed to reset file permissions, please try again.', 'wpe-common' ) );
			}
		);
	}

	$data = json_decode( $resp['body'], true );

	if ( $data['success'] ) {
		add_action(
			'wpe_common_admin_notices',
			function () use ( $data ) {
				show_admin_notice( 'success', $data['message'] );
			}
		);
	}
}

/**
 * Enables ORDER BY RAND() setting.
 *
 * @uses \WpeCommon::is_rand_enabled
 * @uses \WpeCommon::set_rand_enabled
 *
 * @param \WpeCommon  $wpe_common Instance of the WpeCommon class.
 * @param string|bool $enable_rand New value to be set.
 */
function enable_rand( \WpeCommon $wpe_common, $enable_rand ): void {
	$current_state = filter_var( $wpe_common->is_rand_enabled(), FILTER_VALIDATE_BOOLEAN );
	$new_state     = filter_var( $enable_rand, FILTER_VALIDATE_BOOLEAN );

	if ( $current_state !== $new_state ) {
		$wpe_common->set_rand_enabled( $new_state );

		$message = sprintf(
			'%1$s <b>%2$s</b>',
			__( 'ORDER BY RAND() support is now', 'wpe-common' ),
			$new_state ? 'enabled' : 'disabled'
		);

		add_action(
			'wpe_common_admin_notices',
			function () use ( $message ) {
				show_admin_notice( 'success', $message );
			}
		);
	}
}

/**
 * Sets the HTML Post Process Regex.
 *
 * @uses \WpeCommon::get_regex_html_post_process_text
 * @uses \WpeCommon::set_regex_html_post_process_text
 *
 * @param \WpeCommon $wpe_common Instance of the WpeCommon class.
 * @param string     $regex_value Post Processing Regex value to save.
 */
function set_post_process_regex( \WpeCommon $wpe_common, string $regex_value ): void {
	$regex_value = trim( $regex_value );
	$old_regex   = trim( $wpe_common->get_regex_html_post_process_text() );

	if ( $old_regex === $regex_value ) {
		return;
	}

	$result = $wpe_common->set_regex_html_post_process_text( $regex_value );

	if ( true !== $result ) {
		$message = sprintf(
			'<b>%1$s</b><br>%2$s<br>%3$s',
			__( 'Error in HTML replacement regex', 'wpe-common' ),
			$result,
			__( '(Maybe you forgot the beginning and ending characters?)', 'wpe-common' )
		);
		add_action(
			'wpe_common_admin_notices',
			function () use ( $message ) {
				show_admin_notice( 'error', $message );
			}
		);
	} else {
		add_action(
			'wpe_common_admin_notices',
			function () {
				show_admin_notice(
					'success',
					__( 'HTML Post-Processing saved.', 'wpe-common' )
				);
			}
		);
	}
}

/**
 * Handles the Advanced Options actions.
 *
 * @note The phpcs Detected usage of a non-sanitized input variable error
 *       is intentionally supressed. Too much sanitization of the regex input
 *       will remove essential regex characters.
 *
 * @note Sanitization and Validation of the inbound regex
 *       is handled by WpeCommon::set_regex_html_post_process_text
 *
 * @see https://github.com/wpengine/wpengine-common-mu-plugin/blob/master/src/wpengine-common/plugin.php#L1443
 */
function handle_advanced_options_request(): void {
	if ( ! wpe_param( 'advanced' ) ) {
		return;
	}
	check_admin_referer( PWP_NAME . '-site-settings-advanced-options' );

	$wpe_common         = \WpeCommon::instance();
	$rand_enabled       = isset( $_POST['rand_enabled'] ) ? true : false;
	$post_process_regex = isset( $_POST['post_process_regex'] ) ? wp_unslash( $_POST['post_process_regex'] ) : ''; //phpcs:ignore

	enable_rand( $wpe_common, $rand_enabled );
	set_post_process_regex( $wpe_common, $post_process_regex );
}

handle_file_reset_request();
handle_advanced_options_request();
PK     ‘s]'PŠ  Š  &  admin/main/tabs/site-settings/view.phpnu ÏÃ6Ç$        <?php
/**
 * Admin UI - Site Settings Tab
 * Adds the WP Engine Admin "Site Settings" tab.
 *
 * @package wpengine/common-mu-plugin
 */

// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

// Check user capabilities.
if ( ! current_user_can( 'manage_options' ) ) {
	return;
}

?>

<!-- WordPress settings tab -->
<div class="wpe-common-plugin-container">
	<form method="post" name="file-perms">
		<?php wp_nonce_field( PWP_NAME . '-site-settings-file-perm-reset' ); ?>
		<h2>File Permissions</h2>
		<p>
			This will properly set your <strong>WP file permissions</strong> to defaults that are needed for normal operation. Use this button after uploading files via SFTP.
			<br>
			<a href="https://wpengine.com/support/file-permissions/#Reset_File_Permissions" target="_blank" rel="noopener noreferrer">Learn about File Permissions here.</a>
		</p>

		<div class="wpe-admin-button-controls">
			<input
				type="submit"
				name="file-perms"
				value="Reset file permissions"
				class="wpe-admin-button-primary"
				onclick="return confirm('Please be patient, this sometimes takes a while.');"
			>
		</div>
	</form>
</div>
<div class="wpe-common-plugin-container">
	<h2>Advanced Configuration</h2>
	<p>
		These tools have the potential to cause significant issues for your site.
		<a href="https://my.wpengine.com/support" target="_blank" rel="noopener noreferrer">Contact support if you have any questions.</a>
	</p>
	<form method="post" name="advanced">
		<?php wp_nonce_field( PWP_NAME . '-site-settings-advanced-options' ); ?>
		<details class="wpe-common-settings-panel">
			<summary>
				<h3 class="wpe-common-cta-heading">Random order (<code>ORDER BY RAND()</code>)</h3>
			</summary>
			<div class="wpe-details-content">
				<hr>
				<input
					id="wpe-order-by-rand"
					name="rand_enabled"
					type="checkbox"
					value="1"
					<?php checked( $wpe_common->is_rand_enabled() ); ?>
				>
				<label for="wpe-order-by-rand" class="wpe-checkbox-label">
					<strong>Allow <code>ORDER BY RAND()</code></strong>
				</label>
				<p>
					We disable <code>ORDER BY RAND()</code> orderings in MySQL queries because this is not advised for sites with large databases as this may significantly decrease performance.
					If you enable this, it is recommended that you cache the results for 5 to 15 minutes to reduce the number of large server requests.
				</p>
			</div>
		</details>
		<details class="wpe-common-settings-panel">
			<summary>
				<h3 class="wpe-common-cta-heading"><abbr title="HyperText Markup Language">HTML</abbr> Post-Processing</h3>
			</summary>
			<div class="wpe-details-content">
				<hr>
				<p>
					A mapping of <strong>PHP regular expressions to replacement values</strong> which are executed on all blog HTML after WordPress finishes emitting the entire page.
					The pattern and replacement behavior is in the manner of
					<a href="http://php.net/manual/en/function.preg-replace.php" target="_blank" rel="noopener noreferrer">preg_replace()</a>.
				</p>
				<textarea
					id="regex-html-post-process"
					class="wpe-common-textarea"
					name="post_process_regex"
					rows="5"
					cols="120"
				><?php echo esc_textarea( $wpe_common->get_regex_html_post_process_text() ); // phpcs:ignore ?></textarea>
				<p>
					The following example removes all HTML comments in the first pattern, and causes a favicon (with any filename extension) to be loaded from another domain in the second pattern:
					<ul>
						<li><code>#&lt;!--.*?--&gt;#s =></code></li>
						<li><code>#\bsrc="/(favicon\..*)"# => src="http://mycdn.somewhere.com/$1"</code></li>
					</ul>
					To test regular expressions, check out
					<a href="https://www.regexpal.com/" target="_blank" rel="noopener noreferrer">Regexpal</a>,
					a free online tool.
				</p>
			</div>
		</details>
		<div class="wpe-admin-button-controls">
			<input type="submit" name="advanced" value="Save" class="wpe-admin-button-primary">
		</div>
	</form>
</div>
PK     ‘s]_íCÀT  T    admin/notice.phpnu ÏÃ6Ç$        <?php
/**
 * Admin notice
 *
 * @package wpengine/common-mu-plugin
 */

?>
<div class="wpe-notices updated wpe-notices-<?php echo esc_attr( $class ); ?>" title="<?php echo esc_attr( $id ); ?>">
	<div class="dismissable"><img src="<?php echo esc_url( $icon ); ?>" id="dismiss-it" alt="<?php esc_attr_e( 'Dismiss this message', 'wpengine' ); ?>"></div>
	<p class="wpe-notices-<?php echo esc_attr( $class ); ?>">
		<strong><?php echo esc_attr( ucwords( $class ) ); ?>: </strong><?php esc_html_e( $message, 'wpengine' ); // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText ?>
	</p>
</div>
PK       ‘s]F&ÏŒQ  Q                  general/powered-by.phpnu ÏÃ6Ç$        PK       ‘s]5pÖ  Ö              —  staging-modal.phpnu ÏÃ6Ç$        PK       ‘s]e®ôÒ†  †  	            ®  modal.phpnu ÏÃ6Ç$        PK       ‘s]3C1¾  ¾              m  admin/notice-sticky.phpnu ÏÃ6Ç$        PK       ‘s]¡�—’  ’              r
  admin/main/admin-ui.phpnu ÏÃ6Ç$        PK       ‘s]ŸÇÀ–*  –*  !            K  admin/main/tabs/staging/logic.phpnu ÏÃ6Ç$        PK       ‘s]HL«ðí  í               2J  admin/main/tabs/staging/view.phpnu ÏÃ6Ç$        PK       ‘s]¯z¾1ï  ï  %            oh  admin/main/tabs/information/logic.phpnu ÏÃ6Ç$        PK       ‘s]—éÛs[!  [!  $            ³m  admin/main/tabs/information/view.phpnu ÏÃ6Ç$        PK       ‘s]á‹UÊ  Ê              b�  admin/main/tabs/caching.phpnu ÏÃ6Ç$        PK       ‘s]µ&ë©©  ©  !            w—  admin/main/tabs/display/logic.phpnu ÏÃ6Ç$        PK       ‘s]a›8¿Ô
  Ô
               qž  admin/main/tabs/display/view.phpnu ÏÃ6Ç$        PK       ‘s]�®üû    '            •©  admin/main/tabs/site-settings/logic.phpnu ÏÃ6Ç$        PK       ‘s]'PŠ  Š  &            ½  admin/main/tabs/site-settings/view.phpnu ÏÃ6Ç$        PK       ‘s]_íCÀT  T              äÌ  admin/notice.phpnu ÏÃ6Ç$        PK      a  xÏ  