PluginProbe
Snippet Shortcodes / 4.0
Snippet Shortcodes v4.0
5.2.1 5.2 5.1.8 5.1.6 5.1.7 5.1.5 trunk 1.0 1.1 1.2 1.3 1.3.1 1.4 1.5 1.5.1 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 2.0 2.0.1 All 74 releases
← All changes | includes/class.presets.php +71 -67 2.04.0 View file →
@@ -1,67 +1,71 @@
1 -<?php
2 -
3 - defined('ABSPATH') or die("Jog on!");
4 -
5 - abstract class SV_Preset {
6 -
7 - private $args = [];
8 - protected $escape_method = 'esc_html';
9 -
10 - public function init() {
11 -
12 - $this->auto_set_escape();
13 - }
14 -
15 - public function set_arguments( $args ) {
16 - $this->args = ( false === empty( $args ) && true === is_array( $args ) ) ? $args : [];
17 - }
18 -
19 - public function get_arguments() {
20 - return $this->args;
21 - }
22 -
23 - /**
24 - * Be clever and try and auto detect the escape method that should be used.
25 - */
26 - private function auto_set_escape() {
27 -
28 - $args = $this->get_arguments();
29 -
30 - // if _sh_cd_func argument has been specified, then dynamically set escape type
31 - if ( false === empty( $args['_sh_cd_func'] ) ) {
32 -
33 - switch ( $args['_sh_cd_func'] ) {
34 -
35 - case 'wpurl':
36 - case 'url':
37 - case 'stylesheet_url':
38 - case 'template_url':
39 - case 'pingback_url':
40 - case 'atom_url':
41 - case 'atom_url':
42 - case 'rdf_url':
43 - case 'rss_url':
44 - case 'rss2_url':
45 - case 'comments_atom_url':
46 - case 'comments_rss2_url':
47 -
48 - $this->escape_method = 'esc_url_raw';
49 -
50 - break;
51 - default:
52 - $this->escape_method = 'esc_html';
53 - }
54 - } else {
55 -
56 - }
57 - }
58 -
59 - abstract protected function unsanitised();
60 -
61 - public function sanitised() {
62 -
63 - $escape_function = $this->escape_method;
64 -
65 - return $escape_function( $this->unsanitised() );
66 - }
67 - }
1 +<?php
2 +
3 + defined('ABSPATH') or die("Jog on!");
4 +
5 + abstract class SV_Preset {
6 +
7 + private $args = [];
8 + protected $escape_method = 'esc_html';
9 +
10 + public function init() {
11 +
12 + $this->auto_set_escape();
13 + }
14 +
15 + public function set_arguments( $args ) {
16 + $this->args = ( false === empty( $args ) && true === is_array( $args ) ) ? $args : [];
17 + }
18 +
19 + public function get_arguments() {
20 + return $this->args;
21 + }
22 +
23 + /**
24 + * Be clever and try and auto detect the escape method that should be used.
25 + */
26 + private function auto_set_escape() {
27 +
28 + $args = $this->get_arguments();
29 +
30 + // if _sh_cd_func argument has been specified, then dynamically set escape type
31 + if ( false === empty( $args['_sh_cd_func'] ) ) {
32 +
33 + switch ( $args['_sh_cd_func'] ) {
34 +
35 + case 'wpurl':
36 + case 'url':
37 + case 'stylesheet_url':
38 + case 'template_url':
39 + case 'pingback_url':
40 + case 'atom_url':
41 + case 'atom_url':
42 + case 'rdf_url':
43 + case 'rss_url':
44 + case 'rss2_url':
45 + case 'comments_atom_url':
46 + case 'comments_rss2_url':
47 + case 'registration_url':
48 + case 'current_url':
49 +
50 + $this->escape_method = 'esc_url_raw';
51 +
52 + break;
53 + default:
54 + $this->escape_method = 'esc_html';
55 + }
56 + } else {
57 +
58 + }
59 + }
60 +
61 + abstract protected function unsanitised();
62 +
63 + public function sanitised() {
64 +
65 + $escape_function = $this->escape_method;
66 +
67 + return ( false !== $escape_function ) ?
68 + $escape_function( $this->unsanitised() ) :
69 + $this->unsanitised();
70 + }
71 + }