<commit_before><?php

/**
 * Plugin Name: Resizefly
 * Description: Dynamically resize your images on the fly
 * Plugin URI:  http://resizefly.com/
 * Version:     1.2.2
 * Author:      alpipego
 * Author URI:  http://alpipego.com/
 * Text Domain: resizefly
 */

require_once dirname( __FILE__ ) . '/version-check.php';
$check = new RzfVersionCheck( __FILE__ );

use Alpipego\Resizefly\Image\Editor as ImageEditor;
use Alpipego\Resizefly\Image\Handler as ImageHandler;
use Alpipego\Resizefly\Image\Image;
use Alpipego\Resizefly\Image\Stream;
use Alpipego\Resizefly\Upload\Fake;
use Alpipego\Resizefly\Plugin;
use Alpipego\Resizefly\Autoload;

use Alpipego\Resizefly\Admin\OptionsPage;
use Alpipego\Resizefly\Admin\BasicOptionsSection;
use Alpipego\Resizefly\Admin\PathField;

if ( ! $check->errors() ) :
	require_once __DIR__ . '/src/Autoload.php';
	new Autoload();

	\add_action( 'plugins_loaded', function () use ( $check ) {
		$plugin = new Plugin();

		$plugin->loadTextdomain( __DIR__ . '/languages' );

		$plugin['path']    = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR;
		$plugin['url']     = plugin_dir_url( __FILE__ );
		$plugin['version'] = '1.2.2';

		$plugin['addons'] = apply_filters( 'resizefly_addons', [ ] );

		foreach ( $plugin['addons'] as $addonName => $addon ) {
			add_filter( "resizefly_plugin_{$addonName}", function () use ( $plugin ) {
				return $plugin;
			} );
		}

		$plugin['fake'] = function () {
			return new Fake();
		};

		// set the cache path throughout the plugin
		$suffix               = apply_filters( 'resizefly_resized_path', get_option( 'resizefly_resized_path', '' ) );
		$plugin['cache_path'] = trailingslashit( wp_upload_dir( null, false )['basedir'] ) . trim( $suffix, DIRECTORY_SEPARATOR );
		$plugin['cache_url'] = trailingslashit( wp_upload_dir( null, false )['baseurl'] ) . trim( $suffix, DIRECTORY_SEPARATOR );

		if ( is_admin() ) {
			$plugin['options_page'] = function ( $plugin ) {
				return new OptionsPage( $plugin['path'] );
			};

			$plugin['options_basic_settings'] = function ( $plugin ) {
				return new BasicOptionsSection( $plugin['options_page']->page, $plugin['path'] );
			};

			$plugin['options_field_path'] = function ( $plugin ) {
				return new PathField( $plugin['options_page']->page, $plugin['options_basic_settings']->optionsGroup['id'], $plugin['path'] );
			};
		}

		$plugin->run();

		add_action( 'template_redirect', function () use ( $plugin ) {
			if ( ! is_404() ) {
				return;
			}

			if ( preg_match( '/(.*?)-([0-9]+)x([0-9]+)\.(jpe?g|png|gif)/i', $_SERVER['REQUEST_URI'], $matches ) ) {
				$plugin['requested_file'] = $matches;

				// get the correct path ("regardless" of WordPress installation path etc)
				$plugin['image'] = function ( $plugin ) {
					return new Image( $plugin['requested_file'], wp_upload_dir( null, false ), get_bloginfo( 'url' ), $plugin['cache_url'] );
				};

				// get wp image editor and handle errors
				$plugin['wp_image_editor'] = wp_get_image_editor( $plugin['image']->original );
				if ( ! file_exists( $plugin['image']->original ) || is_wp_error( $plugin['wp_image_editor'] ) ) {
					status_header( '404' );
					@include_once get_404_template();

					exit;
				}
<commit_msg>put wp_upload_dir() in plugin container<commit_after><?php

/**
 * Plugin Name: Resizefly
 * Description: Dynamically resize your images on the fly
 * Plugin URI:  http://resizefly.com/
 * Version:     1.2.2
 * Author:      alpipego
 * Author URI:  http://alpipego.com/
 * Text Domain: resizefly
 */

require_once dirname( __FILE__ ) . '/version-check.php';
$check = new RzfVersionCheck( __FILE__ );

use Alpipego\Resizefly\Image\Editor as ImageEditor;
use Alpipego\Resizefly\Image\Handler as ImageHandler;
use Alpipego\Resizefly\Image\Image;
use Alpipego\Resizefly\Image\Stream;
use Alpipego\Resizefly\Upload\Fake;
use Alpipego\Resizefly\Plugin;
use Alpipego\Resizefly\Autoload;

use Alpipego\Resizefly\Admin\OptionsPage;
use Alpipego\Resizefly\Admin\BasicOptionsSection;
use Alpipego\Resizefly\Admin\PathField;

if ( ! $check->errors() ) :
	require_once __DIR__ . '/src/Autoload.php';
	new Autoload();

	\add_action( 'plugins_loaded', function () use ( $check ) {
		$plugin = new Plugin();

		$plugin->loadTextdomain( __DIR__ . '/languages' );

		$plugin['path']    = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR;
		$plugin['url']     = plugin_dir_url( __FILE__ );
		$plugin['version'] = '1.2.2';

		$plugin['addons'] = apply_filters( 'resizefly_addons', [ ] );

		foreach ( $plugin['addons'] as $addonName => $addon ) {
			add_filter( "resizefly_plugin_{$addonName}", function () use ( $plugin ) {
				return $plugin;
			} );
		}

		$plugin['fake'] = function () {
			return new Fake();
		};

		// wordpress uploads array
		$plugin['uploads'] = wp_upload_dir( null, false );

		// set the cache path throughout the plugin
		$suffix               = apply_filters( 'resizefly_resized_path', get_option( 'resizefly_resized_path', '' ) );
		$plugin['cache_path'] = trailingslashit( $plugin['uploads']['basedir'] ) . trim( $suffix, DIRECTORY_SEPARATOR );
		$plugin['cache_url'] = trailingslashit( $plugin['uploads']['baseurl'] ) . trim( $suffix, DIRECTORY_SEPARATOR );

		if ( is_admin() ) {
			$plugin['options_page'] = function ( $plugin ) {
				return new OptionsPage( $plugin['path'] );
			};

			$plugin['options_basic_settings'] = function ( $plugin ) {
				return new BasicOptionsSection( $plugin['options_page']->page, $plugin['path'] );
			};

			$plugin['options_field_path'] = function ( $plugin ) {
				return new PathField( $plugin['options_page']->page, $plugin['options_basic_settings']->optionsGroup['id'], $plugin['path'] );
			};
		}

		$plugin->run();

		add_action( 'template_redirect', function () use ( $plugin ) {
			if ( ! is_404() ) {
				return;
			}

			if ( preg_match( '/(.*?)-([0-9]+)x([0-9]+)\.(jpe?g|png|gif)/i', $_SERVER['REQUEST_URI'], $matches ) ) {
				$plugin['requested_file'] = $matches;

				// get the correct path ("regardless" of WordPress installation path etc)
				$plugin['image'] = function ( $plugin ) {
					return new Image( $plugin['requested_file'], $plugin['uploads'], get_bloginfo( 'url' ), $plugin['cache_url'] );
				};

				// get wp image editor and handle errors
				$plugin['wp_image_editor'] = wp_get_image_editor( $plugin['image']->original );
				if ( ! file_exists( $plugin['image']->original ) || is_wp_error( $plugin['wp_image_editor'] ) ) {
					status_header( '404' );
					@include_once get_404_template();

					exit;
				}

{'fraction_non_alphanumeric': 0.169139012081358, 'fraction_numerical': 0.00581128612937758, 'mean_word_length': 4.161799526440411, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '565284', 'n_tokens_mistral': 2452, 'n_tokens_neox': 2244, 'n_words': 443}