# imagify/2.2.8/inc/3rd-party/hosting/flywheel.php

Imagify Image Optimization: Optimize Images | Compress &amp; Convert to WebP/AVIF, version 2.2.8. 35 lines.

- Page: https://pluginprobe.com/plugins/imagify/2.2.8/code/inc/3rd-party/hosting/flywheel.php
- Raw: https://pluginprobe.com/plugins/imagify/2.2.8/raw/inc/3rd-party/hosting/flywheel.php
- Modified: 2026-01-14T18:08:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/imagify/2.2.8/code/inc/3rd-party/hosting/flywheel.php#L10-L20`.

```php
<?php
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );

if ( defined( 'FLYWHEEL_CONFIG_DIR' ) ) :

	add_filter( 'imagify_site_root', 'imagify_flywheel_site_root', IMAGIFY_INT_MAX );
	/**
	 * Filter the path to the site’s root.
	 *
	 * @since  1.9
	 * @author Grégory Viguier
	 *
	 * @param  string|null $root_path Path to the site's root. Default is null.
	 * @return string|null
	 */
	function imagify_flywheel_site_root( $root_path ) {
		if ( ! empty( $_SERVER['DOCUMENT_ROOT'] ) ) {
			return trailingslashit( wp_unslash( $_SERVER['DOCUMENT_ROOT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
		}

		$upload_basedir = imagify_get_filesystem()->get_upload_basedir( true );

		if ( strpos( $upload_basedir, '/wp-content/' ) === false ) {
			// Uh oooooh...
			return $root_path;
		}

		$upload_basedir = explode( '/wp-content/', $upload_basedir );
		$upload_basedir = reset( $upload_basedir );

		return $upload_basedir . '/';
	}

endif;

```
