# shortcode-variables/3.0.2/includes/class.presets.php

Snippet Shortcodes, version 3.0.2. 67 lines.

- Page: https://pluginprobe.com/plugins/shortcode-variables/3.0.2/code/includes/class.presets.php
- Raw: https://pluginprobe.com/plugins/shortcode-variables/3.0.2/raw/includes/class.presets.php
- Modified: 2019-06-08T10:46:30+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/shortcode-variables/3.0.2/code/includes/class.presets.php#L10-L20`.

```php
<?php

	defined('ABSPATH') or die("Jog on!");

	abstract class SV_Preset {

		private $args = [];
		protected $escape_method = 'esc_html';

		public function init() {

			$this->auto_set_escape();
		}

		public function set_arguments( $args ) {
			$this->args = ( false === empty( $args ) && true === is_array( $args ) ) ? $args : [];
		}

		public function get_arguments() {
			return $this->args;
		}

		/**
		 * Be clever and try and auto detect the escape method that should be used.
		 */
		private function auto_set_escape() {

			$args = $this->get_arguments();

			// if _sh_cd_func argument has been specified, then dynamically set escape type
			if ( false === empty( $args['_sh_cd_func'] ) ) {

				switch ( $args['_sh_cd_func'] ) {

					case 'wpurl':
					case 'url':
					case 'stylesheet_url':
					case 'template_url':
					case 'pingback_url':
					case 'atom_url':
					case 'atom_url':
					case 'rdf_url':
					case 'rss_url':
					case 'rss2_url':
					case 'comments_atom_url':
					case 'comments_rss2_url':

						$this->escape_method = 'esc_url_raw';

						break;
					default:
						$this->escape_method = 'esc_html';
				}
			} else {

			}
		}

		abstract protected function unsanitised();

		public function sanitised() {

			$escape_function = $this->escape_method;

			return $escape_function( $this->unsanitised() );
		}
	}
```
