Completed
Pull Request — master (#223)
by
unknown
01:56
created
config/default.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@  discard block
 block discarded – undo
2 2
 
3 3
 //Check everything exists before using it
4 4
 if(!isset($_SERVER['HTTP_ACCEPT_ENCODING']))
5
-	$_SERVER['HTTP_ACCEPT_ENCODING'] = '';
5
+    $_SERVER['HTTP_ACCEPT_ENCODING'] = '';
6 6
 if(!isset($_SERVER['HTTP_USER_AGENT']))
7
-	$_SERVER['HTTP_USER_AGENT'] = '';
7
+    $_SERVER['HTTP_USER_AGENT'] = '';
8 8
 
9 9
 // Determine supported compression method
10 10
 $gzip = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
@@ -15,30 +15,30 @@  discard block
 block discarded – undo
15 15
 
16 16
 // Check for buggy versions of Internet Explorer
17 17
 if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Opera') &&
18
-	preg_match('/^Mozilla\/4\.0 \(compatible; MSIE ([0-9]\.[0-9])/i', $_SERVER['HTTP_USER_AGENT'], $matches))
18
+    preg_match('/^Mozilla\/4\.0 \(compatible; MSIE ([0-9]\.[0-9])/i', $_SERVER['HTTP_USER_AGENT'], $matches))
19 19
 {
20
-	$version = floatval($matches[1]);
20
+    $version = floatval($matches[1]);
21 21
 
22
-	if ($version < 6)
23
-		$encoding = 'none';
22
+    if ($version < 6)
23
+        $encoding = 'none';
24 24
 
25
-	if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1'))
26
-		$encoding = 'none';
25
+    if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1'))
26
+        $encoding = 'none';
27 27
 }
28 28
 
29 29
 //Some servers compress the output of PHP - Don't break in those cases
30 30
 if(ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1)
31
-	$encoding = 'none';
31
+    $encoding = 'none';
32 32
 
33 33
 $iscompressed = file_exists(__FILE__.'.'.$encoding);
34 34
 if($encoding != 'none' && $iscompressed == false)
35 35
 {
36
-	$flag = ($encoding == 'gzip' ? FORCE_GZIP : FORCE_DEFLATE);
37
-	$code = file_get_contents(__FILE__.'.none');
38
-	$contents = gzencode($code,9,$flag);
36
+    $flag = ($encoding == 'gzip' ? FORCE_GZIP : FORCE_DEFLATE);
37
+    $code = file_get_contents(__FILE__.'.none');
38
+    $contents = gzencode($code,9,$flag);
39 39
 }else{
40
-	//Get data
41
-	$contents = file_get_contents(__FILE__.'.'.$encoding);
40
+    //Get data
41
+    $contents = file_get_contents(__FILE__.'.'.$encoding);
42 42
 }
43 43
 
44 44
 // first check if we have to send 304
@@ -52,36 +52,36 @@  discard block
 block discarded – undo
52 52
 $modTimeMatch = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $modTime);
53 53
 
54 54
 if (($modTimeMatch)||($eTagMatch)) {
55
-	header('HTTP/1.1 304 Not Modified');
56
-	header('Connection: close');
55
+    header('HTTP/1.1 304 Not Modified');
56
+    header('Connection: close');
57 57
 } else {
58
-	// send all sorts of headers
59
-	$expireTime=60*60*24*355; // 1y max according to RFC
60
-	if ($encoding != 'none') {
61
-		header('Content-Encoding: '.$encoding);
62
-	}
63
-	header('Vary: Accept-Encoding');
64
-	header('Content-Length: '.strlen($contents));
65
-	header('Content-type: %%CONTENT%%; charset=utf-8');
66
-	header('Cache-Control: max-age='.$expireTime.', public, must-revalidate');
67
-	header('Cache-Control: max-age='.$expireTime.', public, immutable');
68
-	header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expireTime).' GMT');
69
-	header('ETag: ' . $eTag);
70
-	header('Last-Modified: '.gmdate('D, d M Y H:i:s', $modTime).' GMT');
58
+    // send all sorts of headers
59
+    $expireTime=60*60*24*355; // 1y max according to RFC
60
+    if ($encoding != 'none') {
61
+        header('Content-Encoding: '.$encoding);
62
+    }
63
+    header('Vary: Accept-Encoding');
64
+    header('Content-Length: '.strlen($contents));
65
+    header('Content-type: %%CONTENT%%; charset=utf-8');
66
+    header('Cache-Control: max-age='.$expireTime.', public, must-revalidate');
67
+    header('Cache-Control: max-age='.$expireTime.', public, immutable');
68
+    header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expireTime).' GMT');
69
+    header('ETag: ' . $eTag);
70
+    header('Last-Modified: '.gmdate('D, d M Y H:i:s', $modTime).' GMT');
71 71
 
72
-	// send output
73
-	echo $contents;
72
+    // send output
73
+    echo $contents;
74 74
 
75
-	//And write to filesystem cache if not done yet
76
-	if($encoding != 'none' && $iscompressed == false)
77
-	{
78
-		//Write the content we sent
79
-		file_put_contents(__FILE__.'.'.$encoding,$contents);
75
+    //And write to filesystem cache if not done yet
76
+    if($encoding != 'none' && $iscompressed == false)
77
+    {
78
+        //Write the content we sent
79
+        file_put_contents(__FILE__.'.'.$encoding,$contents);
80 80
 
81
-		//And write the new content
82
-		$flag = ($encoding == 'gzip' ? FORCE_DEFLATE : FORCE_GZIP);
83
-		$ext = ($encoding == 'gzip' ? 'deflate' : 'gzip');
84
-		$contents = gzencode($code,9,$flag);
85
-		file_put_contents(__FILE__.'.'.$ext,$contents);
86
-	}
81
+        //And write the new content
82
+        $flag = ($encoding == 'gzip' ? FORCE_DEFLATE : FORCE_GZIP);
83
+        $ext = ($encoding == 'gzip' ? 'deflate' : 'gzip');
84
+        $contents = gzencode($code,9,$flag);
85
+        file_put_contents(__FILE__.'.'.$ext,$contents);
86
+    }
87 87
 }
Please login to merge, or discard this patch.
classes/autoptimizeBase.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -412,7 +412,7 @@
 block discarded – undo
412 412
          * First element is the filepath, second is the md5 hash of contents
413 413
          * the filepath had when it was being processed.
414 414
          * If we don't have those, we'll bail out early.
415
-        */
415
+         */
416 416
         $filepath = null;
417 417
         $filehash = null;
418 418
 
Please login to merge, or discard this patch.
php/persist-admin-notices-dismissal/persist-admin-notices-dismissal.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -29,131 +29,131 @@
 block discarded – undo
29 29
  * Exit if called directly.
30 30
  */
31 31
 if ( ! defined( 'ABSPATH' ) ) {
32
-	die;
32
+    die;
33 33
 }
34 34
 
35 35
 if ( ! class_exists( 'PAnD' ) ) {
36 36
 
37
-	/**
38
-	 * Class PAnD
39
-	 */
40
-	class PAnD {
41
-
42
-		/**
43
-		 * Init hooks.
44
-		 */
45
-		public static function init() {
46
-			add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_script' ) );
47
-			add_action( 'wp_ajax_dismiss_admin_notice', array( __CLASS__, 'dismiss_admin_notice' ) );
48
-		}
49
-
50
-		/**
51
-		 * Enqueue javascript and variables.
52
-		 */
53
-		public static function load_script() {
54
-
55
-			if ( is_customize_preview() ) {
56
-				return;
57
-			}
58
-
59
-			wp_enqueue_script(
60
-				'dismissible-notices',
61
-				plugins_url( 'dismiss-notice.js', __FILE__ ),
62
-				array( 'jquery', 'common' ),
63
-				false,
64
-				true
65
-			);
66
-
67
-			wp_localize_script(
68
-				'dismissible-notices',
69
-				'dismissible_notice',
70
-				array(
71
-					'nonce' => wp_create_nonce( 'dismissible-notice' ),
72
-				)
73
-			);
74
-		}
75
-
76
-		/**
77
-		 * Handles Ajax request to persist notices dismissal.
78
-		 * Uses check_ajax_referer to verify nonce.
79
-		 */
80
-		public static function dismiss_admin_notice() {
81
-			$option_name        = sanitize_text_field( $_POST['option_name'] );
82
-			$dismissible_length = sanitize_text_field( $_POST['dismissible_length'] );
83
-
84
-			if ( 'forever' != $dismissible_length ) {
85
-				// If $dismissible_length is not an integer default to 1
86
-				$dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length;
87
-				$dismissible_length = strtotime( absint( $dismissible_length ) . ' days' );
88
-			}
89
-
90
-			check_ajax_referer( 'dismissible-notice', 'nonce' );
91
-			self::set_admin_notice_cache( $option_name, $dismissible_length );
92
-			wp_die();
93
-		}
94
-
95
-		/**
96
-		 * Is admin notice active?
97
-		 *
98
-		 * @param string $arg data-dismissible content of notice.
99
-		 *
100
-		 * @return bool
101
-		 */
102
-		public static function is_admin_notice_active( $arg ) {
103
-			$array       = explode( '-', $arg );
104
-			$length      = array_pop( $array );
105
-			$option_name = implode( '-', $array );
106
-			$db_record   = self::get_admin_notice_cache( $option_name );
107
-			if ( 'forever' == $db_record ) {
108
-				return false;
109
-			} elseif ( absint( $db_record ) >= time() ) {
110
-				return false;
111
-			} else {
112
-				return true;
113
-			}
114
-		}
115
-
116
-		/**
117
-		 * Returns admin notice cached timeout.
118
-		 *
119
-		 * @access public
120
-		 *
121
-		 * @param string|bool $id admin notice name or false.
122
-		 *
123
-		 * @return array|bool The timeout. False if expired.
124
-		 */
125
-		public static function get_admin_notice_cache( $id = false ) {
126
-			if ( ! $id ) {
127
-				return false;
128
-			}
129
-			$cache_key = 'pand-' . md5( $id );
130
-			$timeout   = get_site_option( $cache_key );
131
-			$timeout   = 'forever' === $timeout ? time() + 60 : $timeout;
132
-
133
-			if ( empty( $timeout ) || time() > $timeout ) {
134
-				return false;
135
-			}
136
-
137
-			return $timeout;
138
-		}
139
-
140
-		/**
141
-		 * Sets admin notice timeout in site option.
142
-		 *
143
-		 * @access public
144
-		 *
145
-		 * @param string      $id       Data Identifier.
146
-		 * @param string|bool $timeout  Timeout for admin notice.
147
-		 *
148
-		 * @return bool
149
-		 */
150
-		public static function set_admin_notice_cache( $id, $timeout ) {
151
-			$cache_key = 'pand-' . md5( $id );
152
-			update_site_option( $cache_key, $timeout );
153
-
154
-			return true;
155
-		}
156
-
157
-	}
37
+    /**
38
+     * Class PAnD
39
+     */
40
+    class PAnD {
41
+
42
+        /**
43
+         * Init hooks.
44
+         */
45
+        public static function init() {
46
+            add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_script' ) );
47
+            add_action( 'wp_ajax_dismiss_admin_notice', array( __CLASS__, 'dismiss_admin_notice' ) );
48
+        }
49
+
50
+        /**
51
+         * Enqueue javascript and variables.
52
+         */
53
+        public static function load_script() {
54
+
55
+            if ( is_customize_preview() ) {
56
+                return;
57
+            }
58
+
59
+            wp_enqueue_script(
60
+                'dismissible-notices',
61
+                plugins_url( 'dismiss-notice.js', __FILE__ ),
62
+                array( 'jquery', 'common' ),
63
+                false,
64
+                true
65
+            );
66
+
67
+            wp_localize_script(
68
+                'dismissible-notices',
69
+                'dismissible_notice',
70
+                array(
71
+                    'nonce' => wp_create_nonce( 'dismissible-notice' ),
72
+                )
73
+            );
74
+        }
75
+
76
+        /**
77
+         * Handles Ajax request to persist notices dismissal.
78
+         * Uses check_ajax_referer to verify nonce.
79
+         */
80
+        public static function dismiss_admin_notice() {
81
+            $option_name        = sanitize_text_field( $_POST['option_name'] );
82
+            $dismissible_length = sanitize_text_field( $_POST['dismissible_length'] );
83
+
84
+            if ( 'forever' != $dismissible_length ) {
85
+                // If $dismissible_length is not an integer default to 1
86
+                $dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length;
87
+                $dismissible_length = strtotime( absint( $dismissible_length ) . ' days' );
88
+            }
89
+
90
+            check_ajax_referer( 'dismissible-notice', 'nonce' );
91
+            self::set_admin_notice_cache( $option_name, $dismissible_length );
92
+            wp_die();
93
+        }
94
+
95
+        /**
96
+         * Is admin notice active?
97
+         *
98
+         * @param string $arg data-dismissible content of notice.
99
+         *
100
+         * @return bool
101
+         */
102
+        public static function is_admin_notice_active( $arg ) {
103
+            $array       = explode( '-', $arg );
104
+            $length      = array_pop( $array );
105
+            $option_name = implode( '-', $array );
106
+            $db_record   = self::get_admin_notice_cache( $option_name );
107
+            if ( 'forever' == $db_record ) {
108
+                return false;
109
+            } elseif ( absint( $db_record ) >= time() ) {
110
+                return false;
111
+            } else {
112
+                return true;
113
+            }
114
+        }
115
+
116
+        /**
117
+         * Returns admin notice cached timeout.
118
+         *
119
+         * @access public
120
+         *
121
+         * @param string|bool $id admin notice name or false.
122
+         *
123
+         * @return array|bool The timeout. False if expired.
124
+         */
125
+        public static function get_admin_notice_cache( $id = false ) {
126
+            if ( ! $id ) {
127
+                return false;
128
+            }
129
+            $cache_key = 'pand-' . md5( $id );
130
+            $timeout   = get_site_option( $cache_key );
131
+            $timeout   = 'forever' === $timeout ? time() + 60 : $timeout;
132
+
133
+            if ( empty( $timeout ) || time() > $timeout ) {
134
+                return false;
135
+            }
136
+
137
+            return $timeout;
138
+        }
139
+
140
+        /**
141
+         * Sets admin notice timeout in site option.
142
+         *
143
+         * @access public
144
+         *
145
+         * @param string      $id       Data Identifier.
146
+         * @param string|bool $timeout  Timeout for admin notice.
147
+         *
148
+         * @return bool
149
+         */
150
+        public static function set_admin_notice_cache( $id, $timeout ) {
151
+            $cache_key = 'pand-' . md5( $id );
152
+            update_site_option( $cache_key, $timeout );
153
+
154
+            return true;
155
+        }
156
+
157
+    }
158 158
 
159 159
 }
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/vendor/ParsedownLegacy.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1528,8 +1528,8 @@
 block discarded – undo
1528 1528
         'q', 'rt', 'ins', 'font',          'strong',
1529 1529
         's', 'tt', 'sub', 'mark',
1530 1530
         'u', 'xm', 'sup', 'nobr',
1531
-                   'var', 'ruby',
1532
-                   'wbr', 'span',
1533
-                          'time',
1531
+                    'var', 'ruby',
1532
+                    'wbr', 'span',
1533
+                            'time',
1534 1534
     );
1535 1535
 }
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/vendor/Parsedown.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1531,8 +1531,8 @@
 block discarded – undo
1531 1531
         'q', 'rt', 'ins', 'font',          'strong',
1532 1532
         's', 'tt', 'sub', 'mark',
1533 1533
         'u', 'xm', 'sup', 'nobr',
1534
-                   'var', 'ruby',
1535
-                   'wbr', 'span',
1536
-                          'time',
1534
+                    'var', 'ruby',
1535
+                    'wbr', 'span',
1536
+                            'time',
1537 1537
     );
1538 1538
 }
1539 1539
\ No newline at end of file
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/vendor/readme-parser.php 1 patch
Indentation   +318 added lines, -318 removed lines patch added patch discarded remove patch
@@ -9,325 +9,325 @@
 block discarded – undo
9 9
 
10 10
 class PucReadmeParser {
11 11
 
12
-	function __construct() {
13
-		// This space intentionally blank
14
-	}
15
-
16
-	function parse_readme( $file ) {
17
-		$file_contents = @implode('', @file($file));
18
-		return $this->parse_readme_contents( $file_contents );
19
-	}
20
-
21
-	function parse_readme_contents( $file_contents ) {
22
-		$file_contents = str_replace(array("\r\n", "\r"), "\n", $file_contents);
23
-		$file_contents = trim($file_contents);
24
-		if ( 0 === strpos( $file_contents, "\xEF\xBB\xBF" ) )
25
-			$file_contents = substr( $file_contents, 3 );
26
-
27
-		// Markdown transformations
28
-		$file_contents = preg_replace( "|^###([^#]+)#*?\s*?\n|im", '=$1='."\n",     $file_contents );
29
-		$file_contents = preg_replace( "|^##([^#]+)#*?\s*?\n|im",  '==$1=='."\n",   $file_contents );
30
-		$file_contents = preg_replace( "|^#([^#]+)#*?\s*?\n|im",   '===$1==='."\n", $file_contents );
31
-
32
-		// === Plugin Name ===
33
-		// Must be the very first thing.
34
-		if ( !preg_match('|^===(.*)===|', $file_contents, $_name) )
35
-			return array(); // require a name
36
-		$name = trim($_name[1], '=');
37
-		$name = $this->sanitize_text( $name );
38
-
39
-		$file_contents = $this->chop_string( $file_contents, $_name[0] );
40
-
41
-
42
-		// Requires at least: 1.5
43
-		if ( preg_match('|Requires at least:(.*)|i', $file_contents, $_requires_at_least) )
44
-			$requires_at_least = $this->sanitize_text($_requires_at_least[1]);
45
-		else
46
-			$requires_at_least = NULL;
47
-
48
-
49
-		// Tested up to: 2.1
50
-		if ( preg_match('|Tested up to:(.*)|i', $file_contents, $_tested_up_to) )
51
-			$tested_up_to = $this->sanitize_text( $_tested_up_to[1] );
52
-		else
53
-			$tested_up_to = NULL;
54
-
55
-
56
-		// Stable tag: 10.4-ride-the-fire-eagle-danger-day
57
-		if ( preg_match('|Stable tag:(.*)|i', $file_contents, $_stable_tag) )
58
-			$stable_tag = $this->sanitize_text( $_stable_tag[1] );
59
-		else
60
-			$stable_tag = NULL; // we assume trunk, but don't set it here to tell the difference between specified trunk and default trunk
61
-
62
-
63
-		// Tags: some tag, another tag, we like tags
64
-		if ( preg_match('|Tags:(.*)|i', $file_contents, $_tags) ) {
65
-			$tags = preg_split('|,[\s]*?|', trim($_tags[1]));
66
-			foreach ( array_keys($tags) as $t )
67
-				$tags[$t] = $this->sanitize_text( $tags[$t] );
68
-		} else {
69
-			$tags = array();
70
-		}
71
-
72
-
73
-		// Contributors: markjaquith, mdawaffe, zefrank
74
-		$contributors = array();
75
-		if ( preg_match('|Contributors:(.*)|i', $file_contents, $_contributors) ) {
76
-			$temp_contributors = preg_split('|,[\s]*|', trim($_contributors[1]));
77
-			foreach ( array_keys($temp_contributors) as $c ) {
78
-				$tmp_sanitized = $this->user_sanitize( $temp_contributors[$c] );
79
-				if ( strlen(trim($tmp_sanitized)) > 0 )
80
-					$contributors[$c] = $tmp_sanitized;
81
-				unset($tmp_sanitized);
82
-			}
83
-		}
84
-
85
-
86
-		// Donate Link: URL
87
-		if ( preg_match('|Donate link:(.*)|i', $file_contents, $_donate_link) )
88
-			$donate_link = esc_url( $_donate_link[1] );
89
-		else
90
-			$donate_link = NULL;
91
-
92
-
93
-		// togs, conts, etc are optional and order shouldn't matter.  So we chop them only after we've grabbed their values.
94
-		foreach ( array('tags', 'contributors', 'requires_at_least', 'tested_up_to', 'stable_tag', 'donate_link') as $chop ) {
95
-			if ( $$chop ) {
96
-				$_chop = '_' . $chop;
97
-				$file_contents = $this->chop_string( $file_contents, ${$_chop}[0] );
98
-			}
99
-		}
100
-
101
-		$file_contents = trim($file_contents);
102
-
103
-
104
-		// short-description fu
105
-		if ( !preg_match('/(^(.*?))^[\s]*=+?[\s]*.+?[\s]*=+?/ms', $file_contents, $_short_description) )
106
-			$_short_description = array( 1 => &$file_contents, 2 => &$file_contents );
107
-		$short_desc_filtered = $this->sanitize_text( $_short_description[2] );
108
-		$short_desc_length = strlen($short_desc_filtered);
109
-		$short_description = substr($short_desc_filtered, 0, 150);
110
-		if ( $short_desc_length > strlen($short_description) )
111
-			$truncated = true;
112
-		else
113
-			$truncated = false;
114
-		if ( $_short_description[1] )
115
-			$file_contents = $this->chop_string( $file_contents, $_short_description[1] ); // yes, the [1] is intentional
116
-
117
-		// == Section ==
118
-		// Break into sections
119
-		// $_sections[0] will be the title of the first section, $_sections[1] will be the content of the first section
120
-		// the array alternates from there:  title2, content2, title3, content3... and so forth
121
-		$_sections = preg_split('/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
122
-
123
-		$sections = array();
124
-		for ( $i=1; $i <= count($_sections); $i +=2 ) {
125
-			$_sections[$i] = preg_replace('/(^[\s]*)=[\s]+(.+?)[\s]+=/m', '$1<h4>$2</h4>', $_sections[$i]);
126
-			$_sections[$i] = $this->filter_text( $_sections[$i], true );
127
-			$title = $this->sanitize_text( $_sections[$i-1] );
128
-			$sections[str_replace(' ', '_', strtolower($title))] = array('title' => $title, 'content' => $_sections[$i]);
129
-		}
130
-
131
-
132
-		// Special sections
133
-		// This is where we nab our special sections, so we can enforce their order and treat them differently, if needed
134
-		// upgrade_notice is not a section, but parse it like it is for now
135
-		$final_sections = array();
136
-		foreach ( array('description', 'installation', 'frequently_asked_questions', 'screenshots', 'changelog', 'change_log', 'upgrade_notice') as $special_section ) {
137
-			if ( isset($sections[$special_section]) ) {
138
-				$final_sections[$special_section] = $sections[$special_section]['content'];
139
-				unset($sections[$special_section]);
140
-			}
141
-		}
142
-		if ( isset($final_sections['change_log']) && empty($final_sections['changelog']) )
143
-			$final_sections['changelog'] = $final_sections['change_log'];
144
-
145
-
146
-		$final_screenshots = array();
147
-		if ( isset($final_sections['screenshots']) ) {
148
-			preg_match_all('|<li>(.*?)</li>|s', $final_sections['screenshots'], $screenshots, PREG_SET_ORDER);
149
-			if ( $screenshots ) {
150
-				foreach ( (array) $screenshots as $ss )
151
-					$final_screenshots[] = $ss[1];
152
-			}
153
-		}
154
-
155
-		// Parse the upgrade_notice section specially:
156
-		// 1.0 => blah, 1.1 => fnord
157
-		$upgrade_notice = array();
158
-		if ( isset($final_sections['upgrade_notice']) ) {
159
-			$split = preg_split( '#<h4>(.*?)</h4>#', $final_sections['upgrade_notice'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
160
-			for ( $i = 0; $i < count( $split ); $i += 2 )
161
-				$upgrade_notice[$this->sanitize_text( $split[$i] )] = substr( $this->sanitize_text( $split[$i + 1] ), 0, 300 );
162
-			unset( $final_sections['upgrade_notice'] );
163
-		}
164
-
165
-		// No description?
166
-		// No problem... we'll just fall back to the old style of description
167
-		// We'll even let you use markup this time!
168
-		$excerpt = false;
169
-		if ( !isset($final_sections['description']) ) {
170
-			$final_sections = array_merge(array('description' => $this->filter_text( $_short_description[2], true )), $final_sections);
171
-			$excerpt = true;
172
-		}
173
-
174
-
175
-		// dump the non-special sections into $remaining_content
176
-		// their order will be determined by their original order in the readme.txt
177
-		$remaining_content = '';
178
-		foreach ( $sections as $s_name => $s_data ) {
179
-			$remaining_content .= "\n<h3>{$s_data['title']}</h3>\n{$s_data['content']}";
180
-		}
181
-		$remaining_content = trim($remaining_content);
182
-
183
-
184
-		// All done!
185
-		// $r['tags'] and $r['contributors'] are simple arrays
186
-		// $r['sections'] is an array with named elements
187
-		$r = array(
188
-			'name' => $name,
189
-			'tags' => $tags,
190
-			'requires_at_least' => $requires_at_least,
191
-			'tested_up_to' => $tested_up_to,
192
-			'stable_tag' => $stable_tag,
193
-			'contributors' => $contributors,
194
-			'donate_link' => $donate_link,
195
-			'short_description' => $short_description,
196
-			'screenshots' => $final_screenshots,
197
-			'is_excerpt' => $excerpt,
198
-			'is_truncated' => $truncated,
199
-			'sections' => $final_sections,
200
-			'remaining_content' => $remaining_content,
201
-			'upgrade_notice' => $upgrade_notice
202
-		);
203
-
204
-		return $r;
205
-	}
206
-
207
-	function chop_string( $string, $chop ) { // chop a "prefix" from a string: Agressive! uses strstr not 0 === strpos
208
-		if ( $_string = strstr($string, $chop) ) {
209
-			$_string = substr($_string, strlen($chop));
210
-			return trim($_string);
211
-		} else {
212
-			return trim($string);
213
-		}
214
-	}
215
-
216
-	function user_sanitize( $text, $strict = false ) { // whitelisted chars
217
-		if ( function_exists('user_sanitize') ) // bbPress native
218
-			return user_sanitize( $text, $strict );
219
-
220
-		if ( $strict ) {
221
-			$text = preg_replace('/[^a-z0-9-]/i', '', $text);
222
-			$text = preg_replace('|-+|', '-', $text);
223
-		} else {
224
-			$text = preg_replace('/[^a-z0-9_-]/i', '', $text);
225
-		}
226
-		return $text;
227
-	}
228
-
229
-	function sanitize_text( $text ) { // not fancy
230
-		$text = strip_tags($text);
231
-		$text = esc_html($text);
232
-		$text = trim($text);
233
-		return $text;
234
-	}
235
-
236
-	function filter_text( $text, $markdown = false ) { // fancy, Markdown
237
-		$text = trim($text);
238
-
239
-		$text = call_user_func( array( __CLASS__, 'code_trick' ), $text, $markdown ); // A better parser than Markdown's for: backticks -> CODE
240
-
241
-		if ( $markdown ) { // Parse markdown.
242
-			if ( !class_exists('Parsedown', false) ) {
243
-				/** @noinspection PhpIncludeInspection */
244
-				require_once(dirname(__FILE__) . '/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php');
245
-			}
246
-			$instance = Parsedown::instance();
247
-			$text = $instance->text($text);
248
-		}
249
-
250
-		$allowed = array(
251
-			'a' => array(
252
-				'href' => array(),
253
-				'title' => array(),
254
-				'rel' => array()),
255
-			'blockquote' => array('cite' => array()),
256
-			'br' => array(),
257
-			'p' => array(),
258
-			'code' => array(),
259
-			'pre' => array(),
260
-			'em' => array(),
261
-			'strong' => array(),
262
-			'ul' => array(),
263
-			'ol' => array(),
264
-			'li' => array(),
265
-			'h3' => array(),
266
-			'h4' => array()
267
-		);
268
-
269
-		$text = balanceTags($text);
12
+    function __construct() {
13
+        // This space intentionally blank
14
+    }
15
+
16
+    function parse_readme( $file ) {
17
+        $file_contents = @implode('', @file($file));
18
+        return $this->parse_readme_contents( $file_contents );
19
+    }
20
+
21
+    function parse_readme_contents( $file_contents ) {
22
+        $file_contents = str_replace(array("\r\n", "\r"), "\n", $file_contents);
23
+        $file_contents = trim($file_contents);
24
+        if ( 0 === strpos( $file_contents, "\xEF\xBB\xBF" ) )
25
+            $file_contents = substr( $file_contents, 3 );
26
+
27
+        // Markdown transformations
28
+        $file_contents = preg_replace( "|^###([^#]+)#*?\s*?\n|im", '=$1='."\n",     $file_contents );
29
+        $file_contents = preg_replace( "|^##([^#]+)#*?\s*?\n|im",  '==$1=='."\n",   $file_contents );
30
+        $file_contents = preg_replace( "|^#([^#]+)#*?\s*?\n|im",   '===$1==='."\n", $file_contents );
31
+
32
+        // === Plugin Name ===
33
+        // Must be the very first thing.
34
+        if ( !preg_match('|^===(.*)===|', $file_contents, $_name) )
35
+            return array(); // require a name
36
+        $name = trim($_name[1], '=');
37
+        $name = $this->sanitize_text( $name );
38
+
39
+        $file_contents = $this->chop_string( $file_contents, $_name[0] );
40
+
41
+
42
+        // Requires at least: 1.5
43
+        if ( preg_match('|Requires at least:(.*)|i', $file_contents, $_requires_at_least) )
44
+            $requires_at_least = $this->sanitize_text($_requires_at_least[1]);
45
+        else
46
+            $requires_at_least = NULL;
47
+
48
+
49
+        // Tested up to: 2.1
50
+        if ( preg_match('|Tested up to:(.*)|i', $file_contents, $_tested_up_to) )
51
+            $tested_up_to = $this->sanitize_text( $_tested_up_to[1] );
52
+        else
53
+            $tested_up_to = NULL;
54
+
55
+
56
+        // Stable tag: 10.4-ride-the-fire-eagle-danger-day
57
+        if ( preg_match('|Stable tag:(.*)|i', $file_contents, $_stable_tag) )
58
+            $stable_tag = $this->sanitize_text( $_stable_tag[1] );
59
+        else
60
+            $stable_tag = NULL; // we assume trunk, but don't set it here to tell the difference between specified trunk and default trunk
61
+
62
+
63
+        // Tags: some tag, another tag, we like tags
64
+        if ( preg_match('|Tags:(.*)|i', $file_contents, $_tags) ) {
65
+            $tags = preg_split('|,[\s]*?|', trim($_tags[1]));
66
+            foreach ( array_keys($tags) as $t )
67
+                $tags[$t] = $this->sanitize_text( $tags[$t] );
68
+        } else {
69
+            $tags = array();
70
+        }
71
+
72
+
73
+        // Contributors: markjaquith, mdawaffe, zefrank
74
+        $contributors = array();
75
+        if ( preg_match('|Contributors:(.*)|i', $file_contents, $_contributors) ) {
76
+            $temp_contributors = preg_split('|,[\s]*|', trim($_contributors[1]));
77
+            foreach ( array_keys($temp_contributors) as $c ) {
78
+                $tmp_sanitized = $this->user_sanitize( $temp_contributors[$c] );
79
+                if ( strlen(trim($tmp_sanitized)) > 0 )
80
+                    $contributors[$c] = $tmp_sanitized;
81
+                unset($tmp_sanitized);
82
+            }
83
+        }
84
+
85
+
86
+        // Donate Link: URL
87
+        if ( preg_match('|Donate link:(.*)|i', $file_contents, $_donate_link) )
88
+            $donate_link = esc_url( $_donate_link[1] );
89
+        else
90
+            $donate_link = NULL;
91
+
92
+
93
+        // togs, conts, etc are optional and order shouldn't matter.  So we chop them only after we've grabbed their values.
94
+        foreach ( array('tags', 'contributors', 'requires_at_least', 'tested_up_to', 'stable_tag', 'donate_link') as $chop ) {
95
+            if ( $$chop ) {
96
+                $_chop = '_' . $chop;
97
+                $file_contents = $this->chop_string( $file_contents, ${$_chop}[0] );
98
+            }
99
+        }
100
+
101
+        $file_contents = trim($file_contents);
102
+
103
+
104
+        // short-description fu
105
+        if ( !preg_match('/(^(.*?))^[\s]*=+?[\s]*.+?[\s]*=+?/ms', $file_contents, $_short_description) )
106
+            $_short_description = array( 1 => &$file_contents, 2 => &$file_contents );
107
+        $short_desc_filtered = $this->sanitize_text( $_short_description[2] );
108
+        $short_desc_length = strlen($short_desc_filtered);
109
+        $short_description = substr($short_desc_filtered, 0, 150);
110
+        if ( $short_desc_length > strlen($short_description) )
111
+            $truncated = true;
112
+        else
113
+            $truncated = false;
114
+        if ( $_short_description[1] )
115
+            $file_contents = $this->chop_string( $file_contents, $_short_description[1] ); // yes, the [1] is intentional
116
+
117
+        // == Section ==
118
+        // Break into sections
119
+        // $_sections[0] will be the title of the first section, $_sections[1] will be the content of the first section
120
+        // the array alternates from there:  title2, content2, title3, content3... and so forth
121
+        $_sections = preg_split('/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
122
+
123
+        $sections = array();
124
+        for ( $i=1; $i <= count($_sections); $i +=2 ) {
125
+            $_sections[$i] = preg_replace('/(^[\s]*)=[\s]+(.+?)[\s]+=/m', '$1<h4>$2</h4>', $_sections[$i]);
126
+            $_sections[$i] = $this->filter_text( $_sections[$i], true );
127
+            $title = $this->sanitize_text( $_sections[$i-1] );
128
+            $sections[str_replace(' ', '_', strtolower($title))] = array('title' => $title, 'content' => $_sections[$i]);
129
+        }
130
+
131
+
132
+        // Special sections
133
+        // This is where we nab our special sections, so we can enforce their order and treat them differently, if needed
134
+        // upgrade_notice is not a section, but parse it like it is for now
135
+        $final_sections = array();
136
+        foreach ( array('description', 'installation', 'frequently_asked_questions', 'screenshots', 'changelog', 'change_log', 'upgrade_notice') as $special_section ) {
137
+            if ( isset($sections[$special_section]) ) {
138
+                $final_sections[$special_section] = $sections[$special_section]['content'];
139
+                unset($sections[$special_section]);
140
+            }
141
+        }
142
+        if ( isset($final_sections['change_log']) && empty($final_sections['changelog']) )
143
+            $final_sections['changelog'] = $final_sections['change_log'];
144
+
145
+
146
+        $final_screenshots = array();
147
+        if ( isset($final_sections['screenshots']) ) {
148
+            preg_match_all('|<li>(.*?)</li>|s', $final_sections['screenshots'], $screenshots, PREG_SET_ORDER);
149
+            if ( $screenshots ) {
150
+                foreach ( (array) $screenshots as $ss )
151
+                    $final_screenshots[] = $ss[1];
152
+            }
153
+        }
154
+
155
+        // Parse the upgrade_notice section specially:
156
+        // 1.0 => blah, 1.1 => fnord
157
+        $upgrade_notice = array();
158
+        if ( isset($final_sections['upgrade_notice']) ) {
159
+            $split = preg_split( '#<h4>(.*?)</h4>#', $final_sections['upgrade_notice'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
160
+            for ( $i = 0; $i < count( $split ); $i += 2 )
161
+                $upgrade_notice[$this->sanitize_text( $split[$i] )] = substr( $this->sanitize_text( $split[$i + 1] ), 0, 300 );
162
+            unset( $final_sections['upgrade_notice'] );
163
+        }
164
+
165
+        // No description?
166
+        // No problem... we'll just fall back to the old style of description
167
+        // We'll even let you use markup this time!
168
+        $excerpt = false;
169
+        if ( !isset($final_sections['description']) ) {
170
+            $final_sections = array_merge(array('description' => $this->filter_text( $_short_description[2], true )), $final_sections);
171
+            $excerpt = true;
172
+        }
173
+
174
+
175
+        // dump the non-special sections into $remaining_content
176
+        // their order will be determined by their original order in the readme.txt
177
+        $remaining_content = '';
178
+        foreach ( $sections as $s_name => $s_data ) {
179
+            $remaining_content .= "\n<h3>{$s_data['title']}</h3>\n{$s_data['content']}";
180
+        }
181
+        $remaining_content = trim($remaining_content);
182
+
183
+
184
+        // All done!
185
+        // $r['tags'] and $r['contributors'] are simple arrays
186
+        // $r['sections'] is an array with named elements
187
+        $r = array(
188
+            'name' => $name,
189
+            'tags' => $tags,
190
+            'requires_at_least' => $requires_at_least,
191
+            'tested_up_to' => $tested_up_to,
192
+            'stable_tag' => $stable_tag,
193
+            'contributors' => $contributors,
194
+            'donate_link' => $donate_link,
195
+            'short_description' => $short_description,
196
+            'screenshots' => $final_screenshots,
197
+            'is_excerpt' => $excerpt,
198
+            'is_truncated' => $truncated,
199
+            'sections' => $final_sections,
200
+            'remaining_content' => $remaining_content,
201
+            'upgrade_notice' => $upgrade_notice
202
+        );
203
+
204
+        return $r;
205
+    }
206
+
207
+    function chop_string( $string, $chop ) { // chop a "prefix" from a string: Agressive! uses strstr not 0 === strpos
208
+        if ( $_string = strstr($string, $chop) ) {
209
+            $_string = substr($_string, strlen($chop));
210
+            return trim($_string);
211
+        } else {
212
+            return trim($string);
213
+        }
214
+    }
215
+
216
+    function user_sanitize( $text, $strict = false ) { // whitelisted chars
217
+        if ( function_exists('user_sanitize') ) // bbPress native
218
+            return user_sanitize( $text, $strict );
219
+
220
+        if ( $strict ) {
221
+            $text = preg_replace('/[^a-z0-9-]/i', '', $text);
222
+            $text = preg_replace('|-+|', '-', $text);
223
+        } else {
224
+            $text = preg_replace('/[^a-z0-9_-]/i', '', $text);
225
+        }
226
+        return $text;
227
+    }
228
+
229
+    function sanitize_text( $text ) { // not fancy
230
+        $text = strip_tags($text);
231
+        $text = esc_html($text);
232
+        $text = trim($text);
233
+        return $text;
234
+    }
235
+
236
+    function filter_text( $text, $markdown = false ) { // fancy, Markdown
237
+        $text = trim($text);
238
+
239
+        $text = call_user_func( array( __CLASS__, 'code_trick' ), $text, $markdown ); // A better parser than Markdown's for: backticks -> CODE
240
+
241
+        if ( $markdown ) { // Parse markdown.
242
+            if ( !class_exists('Parsedown', false) ) {
243
+                /** @noinspection PhpIncludeInspection */
244
+                require_once(dirname(__FILE__) . '/Parsedown' . (version_compare(PHP_VERSION, '5.3.0', '>=') ? '' : 'Legacy') . '.php');
245
+            }
246
+            $instance = Parsedown::instance();
247
+            $text = $instance->text($text);
248
+        }
249
+
250
+        $allowed = array(
251
+            'a' => array(
252
+                'href' => array(),
253
+                'title' => array(),
254
+                'rel' => array()),
255
+            'blockquote' => array('cite' => array()),
256
+            'br' => array(),
257
+            'p' => array(),
258
+            'code' => array(),
259
+            'pre' => array(),
260
+            'em' => array(),
261
+            'strong' => array(),
262
+            'ul' => array(),
263
+            'ol' => array(),
264
+            'li' => array(),
265
+            'h3' => array(),
266
+            'h4' => array()
267
+        );
268
+
269
+        $text = balanceTags($text);
270 270
 		
271
-		$text = wp_kses( $text, $allowed );
272
-		$text = trim($text);
273
-		return $text;
274
-	}
275
-
276
-	function code_trick( $text, $markdown ) { // Don't use bbPress native function - it's incompatible with Markdown
277
-		// If doing markdown, first take any user formatted code blocks and turn them into backticks so that
278
-		// markdown will preserve things like underscores in code blocks
279
-		if ( $markdown )
280
-			$text = preg_replace_callback("!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array( __CLASS__,'decodeit'), $text);
281
-
282
-		$text = str_replace(array("\r\n", "\r"), "\n", $text);
283
-		if ( !$markdown ) {
284
-			// This gets the "inline" code blocks, but can't be used with Markdown.
285
-			$text = preg_replace_callback("|(`)(.*?)`|", array( __CLASS__, 'encodeit'), $text);
286
-			// This gets the "block level" code blocks and converts them to PRE CODE
287
-			$text = preg_replace_callback("!(^|\n)`(.*?)`!s", array( __CLASS__, 'encodeit'), $text);
288
-		} else {
289
-			// Markdown can do inline code, we convert bbPress style block level code to Markdown style
290
-			$text = preg_replace_callback("!(^|\n)([ \t]*?)`(.*?)`!s", array( __CLASS__, 'indent'), $text);
291
-		}
292
-		return $text;
293
-	}
294
-
295
-	function indent( $matches ) {
296
-		$text = $matches[3];
297
-		$text = preg_replace('|^|m', $matches[2] . '    ', $text);
298
-		return $matches[1] . $text;
299
-	}
300
-
301
-	function encodeit( $matches ) {
302
-		if ( function_exists('encodeit') ) // bbPress native
303
-			return encodeit( $matches );
304
-
305
-		$text = trim($matches[2]);
306
-		$text = htmlspecialchars($text, ENT_QUOTES);
307
-		$text = str_replace(array("\r\n", "\r"), "\n", $text);
308
-		$text = preg_replace("|\n\n\n+|", "\n\n", $text);
309
-		$text = str_replace('&amp;lt;', '&lt;', $text);
310
-		$text = str_replace('&amp;gt;', '&gt;', $text);
311
-		$text = "<code>$text</code>";
312
-		if ( "`" != $matches[1] )
313
-			$text = "<pre>$text</pre>";
314
-		return $text;
315
-	}
316
-
317
-	function decodeit( $matches ) {
318
-		if ( function_exists('decodeit') ) // bbPress native
319
-			return decodeit( $matches );
320
-
321
-		$text = $matches[2];
322
-		$trans_table = array_flip(get_html_translation_table(HTML_ENTITIES));
323
-		$text = strtr($text, $trans_table);
324
-		$text = str_replace('<br />', '', $text);
325
-		$text = str_replace('&#38;', '&', $text);
326
-		$text = str_replace('&#39;', "'", $text);
327
-		if ( '<pre><code>' == $matches[1] )
328
-			$text = "\n$text\n";
329
-		return "`$text`";
330
-	}
271
+        $text = wp_kses( $text, $allowed );
272
+        $text = trim($text);
273
+        return $text;
274
+    }
275
+
276
+    function code_trick( $text, $markdown ) { // Don't use bbPress native function - it's incompatible with Markdown
277
+        // If doing markdown, first take any user formatted code blocks and turn them into backticks so that
278
+        // markdown will preserve things like underscores in code blocks
279
+        if ( $markdown )
280
+            $text = preg_replace_callback("!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array( __CLASS__,'decodeit'), $text);
281
+
282
+        $text = str_replace(array("\r\n", "\r"), "\n", $text);
283
+        if ( !$markdown ) {
284
+            // This gets the "inline" code blocks, but can't be used with Markdown.
285
+            $text = preg_replace_callback("|(`)(.*?)`|", array( __CLASS__, 'encodeit'), $text);
286
+            // This gets the "block level" code blocks and converts them to PRE CODE
287
+            $text = preg_replace_callback("!(^|\n)`(.*?)`!s", array( __CLASS__, 'encodeit'), $text);
288
+        } else {
289
+            // Markdown can do inline code, we convert bbPress style block level code to Markdown style
290
+            $text = preg_replace_callback("!(^|\n)([ \t]*?)`(.*?)`!s", array( __CLASS__, 'indent'), $text);
291
+        }
292
+        return $text;
293
+    }
294
+
295
+    function indent( $matches ) {
296
+        $text = $matches[3];
297
+        $text = preg_replace('|^|m', $matches[2] . '    ', $text);
298
+        return $matches[1] . $text;
299
+    }
300
+
301
+    function encodeit( $matches ) {
302
+        if ( function_exists('encodeit') ) // bbPress native
303
+            return encodeit( $matches );
304
+
305
+        $text = trim($matches[2]);
306
+        $text = htmlspecialchars($text, ENT_QUOTES);
307
+        $text = str_replace(array("\r\n", "\r"), "\n", $text);
308
+        $text = preg_replace("|\n\n\n+|", "\n\n", $text);
309
+        $text = str_replace('&amp;lt;', '&lt;', $text);
310
+        $text = str_replace('&amp;gt;', '&gt;', $text);
311
+        $text = "<code>$text</code>";
312
+        if ( "`" != $matches[1] )
313
+            $text = "<pre>$text</pre>";
314
+        return $text;
315
+    }
316
+
317
+    function decodeit( $matches ) {
318
+        if ( function_exists('decodeit') ) // bbPress native
319
+            return decodeit( $matches );
320
+
321
+        $text = $matches[2];
322
+        $trans_table = array_flip(get_html_translation_table(HTML_ENTITIES));
323
+        $text = strtr($text, $trans_table);
324
+        $text = str_replace('<br />', '', $text);
325
+        $text = str_replace('&#38;', '&', $text);
326
+        $text = str_replace('&#39;', "'", $text);
327
+        if ( '<pre><code>' == $matches[1] )
328
+            $text = "\n$text\n";
329
+        return "`$text`";
330
+    }
331 331
 
332 332
 } // end class
333 333
 
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/Puc/v4p4/Utils.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -2,68 +2,68 @@
 block discarded – undo
2 2
 
3 3
 if ( !class_exists('Puc_v4p4_Utils', false) ):
4 4
 
5
-	class Puc_v4p4_Utils {
6
-		/**
7
-		 * Get a value from a nested array or object based on a path.
8
-		 *
9
-		 * @param array|object|null $collection Get an entry from this array.
10
-		 * @param array|string $path A list of array keys in hierarchy order, or a string path like "foo.bar.baz".
11
-		 * @param mixed $default The value to return if the specified path is not found.
12
-		 * @param string $separator Path element separator. Only applies to string paths.
13
-		 * @return mixed
14
-		 */
15
-		public static function get($collection, $path, $default = null, $separator = '.') {
16
-			if ( is_string($path) ) {
17
-				$path = explode($separator, $path);
18
-			}
5
+    class Puc_v4p4_Utils {
6
+        /**
7
+         * Get a value from a nested array or object based on a path.
8
+         *
9
+         * @param array|object|null $collection Get an entry from this array.
10
+         * @param array|string $path A list of array keys in hierarchy order, or a string path like "foo.bar.baz".
11
+         * @param mixed $default The value to return if the specified path is not found.
12
+         * @param string $separator Path element separator. Only applies to string paths.
13
+         * @return mixed
14
+         */
15
+        public static function get($collection, $path, $default = null, $separator = '.') {
16
+            if ( is_string($path) ) {
17
+                $path = explode($separator, $path);
18
+            }
19 19
 
20
-			//Follow the $path into $input as far as possible.
21
-			$currentValue = $collection;
22
-			foreach ($path as $node) {
23
-				if ( is_array($currentValue) && isset($currentValue[$node]) ) {
24
-					$currentValue = $currentValue[$node];
25
-				} else if ( is_object($currentValue) && isset($currentValue->$node) ) {
26
-					$currentValue = $currentValue->$node;
27
-				} else {
28
-					return $default;
29
-				}
30
-			}
20
+            //Follow the $path into $input as far as possible.
21
+            $currentValue = $collection;
22
+            foreach ($path as $node) {
23
+                if ( is_array($currentValue) && isset($currentValue[$node]) ) {
24
+                    $currentValue = $currentValue[$node];
25
+                } else if ( is_object($currentValue) && isset($currentValue->$node) ) {
26
+                    $currentValue = $currentValue->$node;
27
+                } else {
28
+                    return $default;
29
+                }
30
+            }
31 31
 
32
-			return $currentValue;
33
-		}
32
+            return $currentValue;
33
+        }
34 34
 
35
-		/**
36
-		 * Get the first array element that is not empty.
37
-		 *
38
-		 * @param array $values
39
-		 * @param mixed|null $default Returns this value if there are no non-empty elements.
40
-		 * @return mixed|null
41
-		 */
42
-		public static function findNotEmpty($values, $default = null) {
43
-			if ( empty($values) ) {
44
-				return $default;
45
-			}
35
+        /**
36
+         * Get the first array element that is not empty.
37
+         *
38
+         * @param array $values
39
+         * @param mixed|null $default Returns this value if there are no non-empty elements.
40
+         * @return mixed|null
41
+         */
42
+        public static function findNotEmpty($values, $default = null) {
43
+            if ( empty($values) ) {
44
+                return $default;
45
+            }
46 46
 
47
-			foreach ($values as $value) {
48
-				if ( !empty($value) ) {
49
-					return $value;
50
-				}
51
-			}
47
+            foreach ($values as $value) {
48
+                if ( !empty($value) ) {
49
+                    return $value;
50
+                }
51
+            }
52 52
 
53
-			return $default;
54
-		}
53
+            return $default;
54
+        }
55 55
 
56
-		/**
57
-		 * Check if the input string starts with the specified prefix.
58
-		 *
59
-		 * @param string $input
60
-		 * @param string $prefix
61
-		 * @return bool
62
-		 */
63
-		public static function startsWith($input, $prefix) {
64
-			$length = strlen($prefix);
65
-			return (substr($input, 0, $length) === $prefix);
66
-		}
67
-	}
56
+        /**
57
+         * Check if the input string starts with the specified prefix.
58
+         *
59
+         * @param string $input
60
+         * @param string $prefix
61
+         * @return bool
62
+         */
63
+        public static function startsWith($input, $prefix) {
64
+            $length = strlen($prefix);
65
+            return (substr($input, 0, $length) === $prefix);
66
+        }
67
+    }
68 68
 
69 69
 endif;
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
classes/external/php/plugin-update-checker/Puc/v4p4/Vcs/BaseChecker.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@
 block discarded – undo
1 1
 <?php
2 2
 if ( !interface_exists('Puc_v4p4_Vcs_BaseChecker', false) ):
3 3
 
4
-	interface Puc_v4p4_Vcs_BaseChecker {
5
-		/**
6
-		 * Set the repository branch to use for updates. Defaults to 'master'.
7
-		 *
8
-		 * @param string $branch
9
-		 * @return $this
10
-		 */
11
-		public function setBranch($branch);
4
+    interface Puc_v4p4_Vcs_BaseChecker {
5
+        /**
6
+         * Set the repository branch to use for updates. Defaults to 'master'.
7
+         *
8
+         * @param string $branch
9
+         * @return $this
10
+         */
11
+        public function setBranch($branch);
12 12
 
13
-		/**
14
-		 * Set authentication credentials.
15
-		 *
16
-		 * @param array|string $credentials
17
-		 * @return $this
18
-		 */
19
-		public function setAuthentication($credentials);
13
+        /**
14
+         * Set authentication credentials.
15
+         *
16
+         * @param array|string $credentials
17
+         * @return $this
18
+         */
19
+        public function setAuthentication($credentials);
20 20
 
21
-		/**
22
-		 * @return Puc_v4p4_Vcs_Api
23
-		 */
24
-		public function getVcsApi();
25
-	}
21
+        /**
22
+         * @return Puc_v4p4_Vcs_Api
23
+         */
24
+        public function getVcsApi();
25
+    }
26 26
 
27 27
 endif;
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
external/php/plugin-update-checker/Puc/v4p4/Vcs/ThemeUpdateChecker.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -2,117 +2,117 @@
 block discarded – undo
2 2
 
3 3
 if ( !class_exists('Puc_v4p4_Vcs_ThemeUpdateChecker', false) ):
4 4
 
5
-	class Puc_v4p4_Vcs_ThemeUpdateChecker extends Puc_v4p4_Theme_UpdateChecker implements Puc_v4p4_Vcs_BaseChecker {
6
-		/**
7
-		 * @var string The branch where to look for updates. Defaults to "master".
8
-		 */
9
-		protected $branch = 'master';
10
-
11
-		/**
12
-		 * @var Puc_v4p4_Vcs_Api Repository API client.
13
-		 */
14
-		protected $api = null;
15
-
16
-		/**
17
-		 * Puc_v4p4_Vcs_ThemeUpdateChecker constructor.
18
-		 *
19
-		 * @param Puc_v4p4_Vcs_Api $api
20
-		 * @param null $stylesheet
21
-		 * @param null $customSlug
22
-		 * @param int $checkPeriod
23
-		 * @param string $optionName
24
-		 */
25
-		public function __construct($api, $stylesheet = null, $customSlug = null, $checkPeriod = 12, $optionName = '') {
26
-			$this->api = $api;
27
-			$this->api->setHttpFilterName($this->getUniqueName('request_update_options'));
28
-
29
-			parent::__construct($api->getRepositoryUrl(), $stylesheet, $customSlug, $checkPeriod, $optionName);
30
-
31
-			$this->api->setSlug($this->slug);
32
-		}
33
-
34
-		public function requestUpdate() {
35
-			$api = $this->api;
36
-			$api->setLocalDirectory($this->getAbsoluteDirectoryPath());
37
-
38
-			$update = new Puc_v4p4_Theme_Update();
39
-			$update->slug = $this->slug;
40
-
41
-			//Figure out which reference (tag or branch) we'll use to get the latest version of the theme.
42
-			$updateSource = $api->chooseReference($this->branch);
43
-			if ( $updateSource ) {
44
-				$ref = $updateSource->name;
45
-				$update->download_url = $updateSource->downloadUrl;
46
-			} else {
47
-				do_action(
48
-					'puc_api_error',
49
-					new WP_Error(
50
-						'puc-no-update-source',
51
-						'Could not retrieve version information from the repository. '
52
-						. 'This usually means that the update checker either can\'t connect '
53
-						. 'to the repository or it\'s configured incorrectly.'
54
-					),
55
-					null, null, $this->slug
56
-				);
57
-				$ref = $this->branch;
58
-			}
59
-
60
-			//Get headers from the main stylesheet in this branch/tag. Its "Version" header and other metadata
61
-			//are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags.
62
-			$remoteHeader = $this->getFileHeader($api->getRemoteFile('style.css', $ref));
63
-			$update->version = Puc_v4p4_Utils::findNotEmpty(array(
64
-				$remoteHeader['Version'],
65
-				Puc_v4p4_Utils::get($updateSource, 'version'),
66
-			));
67
-
68
-			//The details URL defaults to the Theme URI header or the repository URL.
69
-			$update->details_url = Puc_v4p4_Utils::findNotEmpty(array(
70
-				$remoteHeader['ThemeURI'],
71
-				$this->theme->get('ThemeURI'),
72
-				$this->metadataUrl,
73
-			));
74
-
75
-			if ( empty($update->version) ) {
76
-				//It looks like we didn't find a valid update after all.
77
-				$update = null;
78
-			}
79
-
80
-			$update = $this->filterUpdateResult($update);
81
-			return $update;
82
-		}
83
-
84
-		//FIXME: This is duplicated code. Both theme and plugin subclasses that use VCS share these methods.
85
-
86
-		public function setBranch($branch) {
87
-			$this->branch = $branch;
88
-			return $this;
89
-		}
90
-
91
-		public function setAuthentication($credentials) {
92
-			$this->api->setAuthentication($credentials);
93
-			return $this;
94
-		}
95
-
96
-		public function getVcsApi() {
97
-			return $this->api;
98
-		}
99
-
100
-		public function getUpdate() {
101
-			$update = parent::getUpdate();
102
-
103
-			if ( isset($update) && !empty($update->download_url) ) {
104
-				$update->download_url = $this->api->signDownloadUrl($update->download_url);
105
-			}
106
-
107
-			return $update;
108
-		}
109
-
110
-		public function onDisplayConfiguration($panel) {
111
-			parent::onDisplayConfiguration($panel);
112
-			$panel->row('Branch', $this->branch);
113
-			$panel->row('Authentication enabled', $this->api->isAuthenticationEnabled() ? 'Yes' : 'No');
114
-			$panel->row('API client', get_class($this->api));
115
-		}
116
-	}
5
+    class Puc_v4p4_Vcs_ThemeUpdateChecker extends Puc_v4p4_Theme_UpdateChecker implements Puc_v4p4_Vcs_BaseChecker {
6
+        /**
7
+         * @var string The branch where to look for updates. Defaults to "master".
8
+         */
9
+        protected $branch = 'master';
10
+
11
+        /**
12
+         * @var Puc_v4p4_Vcs_Api Repository API client.
13
+         */
14
+        protected $api = null;
15
+
16
+        /**
17
+         * Puc_v4p4_Vcs_ThemeUpdateChecker constructor.
18
+         *
19
+         * @param Puc_v4p4_Vcs_Api $api
20
+         * @param null $stylesheet
21
+         * @param null $customSlug
22
+         * @param int $checkPeriod
23
+         * @param string $optionName
24
+         */
25
+        public function __construct($api, $stylesheet = null, $customSlug = null, $checkPeriod = 12, $optionName = '') {
26
+            $this->api = $api;
27
+            $this->api->setHttpFilterName($this->getUniqueName('request_update_options'));
28
+
29
+            parent::__construct($api->getRepositoryUrl(), $stylesheet, $customSlug, $checkPeriod, $optionName);
30
+
31
+            $this->api->setSlug($this->slug);
32
+        }
33
+
34
+        public function requestUpdate() {
35
+            $api = $this->api;
36
+            $api->setLocalDirectory($this->getAbsoluteDirectoryPath());
37
+
38
+            $update = new Puc_v4p4_Theme_Update();
39
+            $update->slug = $this->slug;
40
+
41
+            //Figure out which reference (tag or branch) we'll use to get the latest version of the theme.
42
+            $updateSource = $api->chooseReference($this->branch);
43
+            if ( $updateSource ) {
44
+                $ref = $updateSource->name;
45
+                $update->download_url = $updateSource->downloadUrl;
46
+            } else {
47
+                do_action(
48
+                    'puc_api_error',
49
+                    new WP_Error(
50
+                        'puc-no-update-source',
51
+                        'Could not retrieve version information from the repository. '
52
+                        . 'This usually means that the update checker either can\'t connect '
53
+                        . 'to the repository or it\'s configured incorrectly.'
54
+                    ),
55
+                    null, null, $this->slug
56
+                );
57
+                $ref = $this->branch;
58
+            }
59
+
60
+            //Get headers from the main stylesheet in this branch/tag. Its "Version" header and other metadata
61
+            //are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags.
62
+            $remoteHeader = $this->getFileHeader($api->getRemoteFile('style.css', $ref));
63
+            $update->version = Puc_v4p4_Utils::findNotEmpty(array(
64
+                $remoteHeader['Version'],
65
+                Puc_v4p4_Utils::get($updateSource, 'version'),
66
+            ));
67
+
68
+            //The details URL defaults to the Theme URI header or the repository URL.
69
+            $update->details_url = Puc_v4p4_Utils::findNotEmpty(array(
70
+                $remoteHeader['ThemeURI'],
71
+                $this->theme->get('ThemeURI'),
72
+                $this->metadataUrl,
73
+            ));
74
+
75
+            if ( empty($update->version) ) {
76
+                //It looks like we didn't find a valid update after all.
77
+                $update = null;
78
+            }
79
+
80
+            $update = $this->filterUpdateResult($update);
81
+            return $update;
82
+        }
83
+
84
+        //FIXME: This is duplicated code. Both theme and plugin subclasses that use VCS share these methods.
85
+
86
+        public function setBranch($branch) {
87
+            $this->branch = $branch;
88
+            return $this;
89
+        }
90
+
91
+        public function setAuthentication($credentials) {
92
+            $this->api->setAuthentication($credentials);
93
+            return $this;
94
+        }
95
+
96
+        public function getVcsApi() {
97
+            return $this->api;
98
+        }
99
+
100
+        public function getUpdate() {
101
+            $update = parent::getUpdate();
102
+
103
+            if ( isset($update) && !empty($update->download_url) ) {
104
+                $update->download_url = $this->api->signDownloadUrl($update->download_url);
105
+            }
106
+
107
+            return $update;
108
+        }
109
+
110
+        public function onDisplayConfiguration($panel) {
111
+            parent::onDisplayConfiguration($panel);
112
+            $panel->row('Branch', $this->branch);
113
+            $panel->row('Authentication enabled', $this->api->isAuthenticationEnabled() ? 'Yes' : 'No');
114
+            $panel->row('API client', get_class($this->api));
115
+        }
116
+    }
117 117
 
118 118
 endif;
119 119
\ No newline at end of file
Please login to merge, or discard this patch.