Completed
Push — master ( 512e93...e75b2f )
by
unknown
02:22
created
public/includes/wrap-shortcodes.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
  * Wraps shortcodes of other Plugins in prep for later replacement on save to preserve the shortcodes
4 4
  */
5 5
 
6
-if ( lasso_user_can( 'edit_posts' ) && ! is_admin() ) {
7
-	add_filter( 'the_content', 'lasso_wrap_shortcodes', 9 );
6
+if (lasso_user_can('edit_posts') && !is_admin()) {
7
+	add_filter('the_content', 'lasso_wrap_shortcodes', 9);
8 8
 }
9 9
 
10 10
 /**
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
  *
18 18
  * @return string
19 19
  */
20
-function lasso_wrap_shortcodes( $content ) {
20
+function lasso_wrap_shortcodes($content) {
21 21
 	global $shortcode_tags;
22 22
 
23
-	if ( false === strpos( $content, '[' ) ) {
23
+	if (false === strpos($content, '[')) {
24 24
 		return $content;
25 25
 	}
26 26
 
27
-	if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) {
27
+	if (empty($shortcode_tags) || !is_array($shortcode_tags)) {
28 28
 		return $content;
29 29
 	}
30 30
 
31
-	$tagnames  = array_keys( $shortcode_tags );
32
-	$tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) );
31
+	$tagnames  = array_keys($shortcode_tags);
32
+	$tagregexp = join('|', array_map('preg_quote', $tagnames));
33 33
 	$pattern   = "/\\[($tagregexp)/s";
34 34
 
35
-	if ( 0 === preg_match( $pattern, $content ) ) {
35
+	if (0 === preg_match($pattern, $content)) {
36 36
 		// Avoids parsing HTML when there are no shortcodes or embeds anyway.
37 37
 		return $content;
38 38
 	}
39 39
 
40
-	$content = do_shortcodes_in_html_tags( $content, true ,$tagnames);
40
+	$content = do_shortcodes_in_html_tags($content, true, $tagnames);
41 41
 
42 42
 	$pattern = get_shortcode_regex();
43
-	$content = preg_replace_callback( "/$pattern/s", 'lasso_wrap_shortcode_tag', $content );
43
+	$content = preg_replace_callback("/$pattern/s", 'lasso_wrap_shortcode_tag', $content);
44 44
 
45 45
 	// Always restore square braces so we don't break things like <!--[if IE ]>
46
-	$content = unescape_invalid_shortcodes( $content );
46
+	$content = unescape_invalid_shortcodes($content);
47 47
 
48 48
 	return $content;
49 49
 }
@@ -57,28 +57,28 @@  discard block
 block discarded – undo
57 57
  *
58 58
  * @return string
59 59
  */
60
-function lasso_wrap_shortcode_tag( $m ) {
60
+function lasso_wrap_shortcode_tag($m) {
61 61
 	// allow [[foo]] syntax for escaping a tag
62
-	if ( $m[1] == '[' && $m[6] == ']' ) {
63
-		return substr( $m[0], 1, - 1 );
62
+	if ($m[1] == '[' && $m[6] == ']') {
63
+		return substr($m[0], 1, - 1);
64 64
 	}
65 65
 	//array('aesop_quote','aesop_gallery','aesop_chapter','aesop_timeline_stop','aesop_video','aesop_collection','aesop_character','aesop_document','aesop_audio','aesop_content','aesop_map')
66 66
 
67
-	if ( strpos( $m[2],'aesop_'  ) === 0 ) {
67
+	if (strpos($m[2], 'aesop_') === 0) {
68 68
 		// check against the exceptions
69
-		if (strpos_arr($m[2],array('aesop_gallery_pop','aesop_character_carousel'))===false) {
69
+		if (strpos_arr($m[2], array('aesop_gallery_pop', 'aesop_character_carousel')) === false) {
70 70
 		    return $m[0];
71 71
 		}
72 72
 	}
73 73
 
74
-	return '<!--EDITUS_OTHER_SHORTCODE_START|[' . $m[0] . ']-->' . $m[0] . '<!--EDITUS_OTHER_SHORTCODE_END-->';
74
+	return '<!--EDITUS_OTHER_SHORTCODE_START|['.$m[0].']-->'.$m[0].'<!--EDITUS_OTHER_SHORTCODE_END-->';
75 75
 }
76 76
 
77 77
 /* a helper function */
78 78
 function strpos_arr($haystack, $needle) {
79
-    if(!is_array($needle)) $needle = array($needle);
80
-    foreach($needle as $what) {
81
-        if(($pos = strpos($haystack, $what))!==false) return $pos;
79
+    if (!is_array($needle)) $needle = array($needle);
80
+    foreach ($needle as $what) {
81
+        if (($pos = strpos($haystack, $what)) !== false) return $pos;
82 82
     }
83 83
     return false;
84 84
 }
85 85
\ No newline at end of file
Please login to merge, or discard this patch.