classes/Tools/Imgix/ImgixTool.php
public function newPreset() {
		$name = esc_html($_POST['name']);
		if(empty($name)) {
			json_response([
				              'status' => 'error',
				              'error' => 'Seems that you may have forgotten something.'
			              ]);
		}

		$key = sanitize_title($name);
		$newKey = $key;

		$presets = get_option('ilab-imgix-presets');
		if($presets) {
			$keyIndex = 1;
			while(isset($presets[$newKey])) {
				$keyIndex ++;
				$newKey = $key.$keyIndex;
			}
		}

		$settings = $_POST['settings'];
		$size = (isset($_POST['size'])) ? esc_html($_POST['size']) : null;
		$makeDefault = (isset($_POST['make_default'])) ? ($_POST['make_default'] == 1) : false;

		$this->doUpdatePresets($newKey, $name, $settings, $size, $makeDefault);

	}
public function newPreset() {
		$name = esc_html($_POST['name']);
		if(empty($name)) {
			json_response([
				              'status' => 'error',
				              'error' => 'Seems that you may have forgotten something.'
			              ]);
		}

		$key = sanitize_title($name);
		$newKey = $key;

		$presets = get_option('ilab-imgix-presets');
		if($presets) {
			$keyIndex = 1;
			while(isset($presets[$newKey])) {
				$keyIndex ++;
				$newKey = $key.$keyIndex;
			}
		}

		$settings = $_POST['settings'];
		$size = (isset($_POST['size'])) ? esc_html($_POST['size']) : null;
		$makeDefault = (isset($_POST['make_default'])) ? ($_POST['make_default'] == 1) : false;

		$this->doUpdatePresets($newKey, $name, $settings, $size, $makeDefault);

	}
public function newPreset ( ) { $ name = esc_html ( $ _POST [ 'name' ] ) ; if ( empty ( $ name ) ) { json_response ( [ 'status' => 'error' , 'error' => 'Seems that you may have forgotten something.' ] ) ; } $ key = sanitize_title ( $ name ) ; $ newKey = $ key ; $ presets = get_option ( 'ilab-imgix-presets' ) ; if ( $ presets ) { $ keyIndex = 1 ; while ( isset ( $ presets [ $ newKey ] ) ) { $ keyIndex ++ ; $ newKey = $ key . $ keyIndex ; } } $ settings = $ _POST [ 'settings' ] ; $ size = ( isset ( $ _POST [ 'size' ] ) ) ? esc_html ( $ _POST [ 'size' ] ) : null ; $ makeDefault = ( isset ( $ _POST [ 'make_default' ] ) ) ? ( $ _POST [ 'make_default' ] == 1 ) : false ; $ this -> doUpdatePresets ( $ newKey , $ name , $ settings , $ size , $ makeDefault ) ; }
Create a new preset
Create a new preset