# optimole-wp/3.0.0/inc/filters.php

Optimole – Optimize Images | Convert WebP &amp; AVIF | CDN &amp; Lazy Load | Image Optimization, version 3.0.0. 73 lines.

- Page: https://pluginprobe.com/plugins/optimole-wp/3.0.0/code/inc/filters.php
- Raw: https://pluginprobe.com/plugins/optimole-wp/3.0.0/raw/inc/filters.php
- Modified: 2020-06-08T08:33:32+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/optimole-wp/3.0.0/code/inc/filters.php#L10-L20`.

```php
<?php

/**
 * Class Optml_Filters.
 *
 * @package    \Optml\Inc
 * @author     Optimole <friends@optimole.com>
 */
final class Optml_Filters {

	/**
	 * Generic method to check if the page is allowed to do the action.
	 *
	 * @param array $flags Flags array.
	 *
	 * @return bool Should do action on page?
	 */
	public static function should_do_page( $flags ) {
		if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
			return true;
		}
		foreach ( $flags as $rule_flag => $status ) {
			if ( strpos( $_SERVER['REQUEST_URI'], $rule_flag ) !== false ) {
				return false;
			}
			if ( $rule_flag === 'home' && ( empty( $_SERVER['REQUEST_URI'] ) || $_SERVER['REQUEST_URI'] === '/' ) ) {
				return false;
			}
		}

		return true;
	}

	/**
	 * Check if image qualifies for processing.
	 *
	 * @param string $image_url Image url.
	 * @param array  $flags Flags array.
	 *
	 * @return bool Should we process the image?
	 */
	public static function should_do_image( $image_url, $flags ) {

		foreach ( $flags as $rule_flag => $status ) {
			if ( strpos( $image_url, $rule_flag ) !== false ) {
				return false;
			}
		}

		return true;

	}

	/**
	 *
	 * Check if the image should be processed based on the extension.
	 *
	 * @param array  $flags Flags array.
	 * @param string $ext Extension string.
	 *
	 * @return bool Should we do the processing?
	 */
	public static function should_do_extension( $flags, $ext ) {
		foreach ( $flags as $rule_flag => $status ) {
			if ( $rule_flag === $ext ) {
				return false;
			}
		}

		return $ext;
	}
}

```
