Test Failed
Pull Request — master (#67)
by Stéphane
02:01
created
wpmautic.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -13,31 +13,31 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Prevent direct access to this file.
16
-if ( ! defined( 'ABSPATH' ) ) {
17
-	header( 'HTTP/1.0 403 Forbidden' );
16
+if ( ! defined('ABSPATH')) {
17
+	header('HTTP/1.0 403 Forbidden');
18 18
 	echo 'This file should not be accessed directly!';
19 19
 	exit; // Exit if accessed directly.
20 20
 }
21 21
 
22 22
 // Store plugin directory.
23
-define( 'VPMAUTIC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
23
+define('VPMAUTIC_PLUGIN_DIR', plugin_dir_path(__FILE__));
24 24
 // Store plugin main file path.
25
-define( 'VPMAUTIC_PLUGIN_FILE', __FILE__ );
25
+define('VPMAUTIC_PLUGIN_FILE', __FILE__);
26 26
 
27
-add_action( 'admin_menu', 'wpmautic_settings' );
28
-add_action( 'plugins_loaded', 'wpmautic_injector' );
27
+add_action('admin_menu', 'wpmautic_settings');
28
+add_action('plugins_loaded', 'wpmautic_injector');
29 29
 
30
-include_once( VPMAUTIC_PLUGIN_DIR . '/shortcodes.php' );
30
+include_once(VPMAUTIC_PLUGIN_DIR . '/shortcodes.php');
31 31
 
32 32
 /**
33 33
  * Declare option page
34 34
  */
35 35
 function wpmautic_settings() {
36
-	include_once( VPMAUTIC_PLUGIN_DIR . '/options.php' );
36
+	include_once(VPMAUTIC_PLUGIN_DIR . '/options.php');
37 37
 
38 38
 	add_options_page(
39
-		__( 'WP Mautic Settings', 'wp-mautic' ),
40
-		__( 'WPMautic', 'wp-mautic' ),
39
+		__('WP Mautic Settings', 'wp-mautic'),
40
+		__('WPMautic', 'wp-mautic'),
41 41
 		'manage_options',
42 42
 		'wpmautic',
43 43
 		'wpmautic_options_page'
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
  *
53 53
  * @return array
54 54
  */
55
-function wpmautic_plugin_actions( $links, $file ) {
56
-	if ( plugin_basename( VPMAUTIC_PLUGIN_FILE ) === $file && function_exists( 'admin_url' ) ) {
55
+function wpmautic_plugin_actions($links, $file) {
56
+	if (plugin_basename(VPMAUTIC_PLUGIN_FILE) === $file && function_exists('admin_url')) {
57 57
 		$settings_link = sprintf(
58 58
 			'<a href="%s">%s</a>',
59
-			admin_url( 'options-general.php?page=wpmautic' ),
60
-			__( 'Settings' )
59
+			admin_url('options-general.php?page=wpmautic'),
60
+			__('Settings')
61 61
 		);
62 62
 		// Add the settings link before other links.
63
-		array_unshift( $links, $settings_link );
63
+		array_unshift($links, $settings_link);
64 64
 	}
65 65
 	return $links;
66 66
 }
67
-add_filter( 'plugin_action_links', 'wpmautic_plugin_actions', 10, 2 );
67
+add_filter('plugin_action_links', 'wpmautic_plugin_actions', 10, 2);
68 68
 
69 69
 /**
70 70
  * Retrieve one of the wpmautic options but sanitized
@@ -76,24 +76,24 @@  discard block
 block discarded – undo
76 76
  *
77 77
  * @throws InvalidArgumentException Thrown when the option name is not given.
78 78
  */
79
-function wpmautic_option( $option, $default = null ) {
80
-	$options = get_option( 'wpmautic_options' );
79
+function wpmautic_option($option, $default = null) {
80
+	$options = get_option('wpmautic_options');
81 81
 
82
-	switch ( $option ) {
82
+	switch ($option) {
83 83
 		case 'script_location':
84
-			return ! isset( $options[ $option ] ) ? 'header' : $options[ $option ];
84
+			return ! isset($options[$option]) ? 'header' : $options[$option];
85 85
 		case 'fallback_activated':
86
-			return isset( $options[ $option ] ) ? (bool) $options[ $option ] : true;
86
+			return isset($options[$option]) ? (bool) $options[$option] : true;
87 87
 		default:
88
-			if ( ! isset( $options[ $option ] ) ) {
89
-				if ( isset( $default ) ) {
88
+			if ( ! isset($options[$option])) {
89
+				if (isset($default)) {
90 90
 					return $default;
91 91
 				}
92 92
 
93
-				throw new InvalidArgumentException( 'You must give a valid option name !' );
93
+				throw new InvalidArgumentException('You must give a valid option name !');
94 94
 			}
95 95
 
96
-			return $options[ $option ];
96
+			return $options[$option];
97 97
 	}
98 98
 }
99 99
 
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
  * @return void
104 104
  */
105 105
 function wpmautic_injector() {
106
-	$script_location = wpmautic_option( 'script_location' );
107
-	if ( 'header' === $script_location ) {
108
-		add_action( 'wp_head', 'wpmautic_inject_script' );
106
+	$script_location = wpmautic_option('script_location');
107
+	if ('header' === $script_location) {
108
+		add_action('wp_head', 'wpmautic_inject_script');
109 109
 	} else {
110
-		add_action( 'wp_footer', 'wpmautic_inject_script' );
110
+		add_action('wp_footer', 'wpmautic_inject_script');
111 111
 	}
112 112
 
113
-	if ( true === wpmautic_option( 'fallback_activated', false ) ) {
114
-		add_action( 'wp_footer', 'wpmautic_inject_noscript' );
113
+	if (true === wpmautic_option('fallback_activated', false)) {
114
+		add_action('wp_footer', 'wpmautic_inject_noscript');
115 115
 	}
116 116
 }
117 117
 
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
  * @return void
122 122
  */
123 123
 function wpmautic_inject_script() {
124
-	$base_url = wpmautic_option( 'base_url', '' );
125
-	if ( empty( $base_url ) ) {
124
+	$base_url = wpmautic_option('base_url', '');
125
+	if (empty($base_url)) {
126 126
 		return;
127 127
 	}
128 128
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 	(function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n;
133 133
 		w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t),
134 134
 		m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m)
135
-	})(window,document,'script','<?php echo esc_url( $base_url ); ?>/mtc.js','mt');
135
+	})(window,document,'script','<?php echo esc_url($base_url); ?>/mtc.js','mt');
136 136
 
137
-	mt('send', 'pageview'<?php echo count( $attrs ) > 0?', ' . wp_json_encode( $attrs ):'' ?>);
137
+	mt('send', 'pageview'<?php echo count($attrs) > 0 ? ', ' . wp_json_encode($attrs) : '' ?>);
138 138
 </script>
139 139
 	<?php
140 140
 }
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
  * @return void
147 147
  */
148 148
 function wpmautic_inject_noscript() {
149
-	$base_url = wpmautic_option( 'base_url', '' );
150
-	if ( empty( $base_url ) ) {
149
+	$base_url = wpmautic_option('base_url', '');
150
+	if (empty($base_url)) {
151 151
 		return;
152 152
 	}
153 153
 
154 154
 	global $wp;
155 155
 
156 156
 	$url_query = wpmautic_get_url_query();
157
-	$payload = rawurlencode( base64_encode( serialize( $url_query ) ) );
157
+	$payload = rawurlencode(base64_encode(serialize($url_query)));
158 158
 	?>
159 159
 	<noscript>
160
-		<img src="<?php echo esc_url( $base_url ); ?>/mtracking.gif?d=<?php echo esc_attr( $payload ); ?>"  style="display:none;" alt="" />
160
+		<img src="<?php echo esc_url($base_url); ?>/mtracking.gif?d=<?php echo esc_attr($payload); ?>"  style="display:none;" alt="" />
161 161
 	</noscript>
162 162
 	<?php
163 163
 }
@@ -169,19 +169,19 @@  discard block
 block discarded – undo
169 169
  */
170 170
 function wpmautic_get_url_query() {
171 171
 	global $wp;
172
-	$current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
172
+	$current_url = add_query_arg($wp->query_string, '', home_url($wp->request));
173 173
 
174 174
 	$attrs = wpmautic_get_tracking_attributes();
175 175
 
176 176
 	$attrs['language']   = get_locale();
177 177
 	$attrs['page_url']   = $current_url;
178
-	$attrs['page_title'] = function_exists( 'wp_get_document_title' )
178
+	$attrs['page_title'] = function_exists('wp_get_document_title')
179 179
 		? wp_get_document_title()
180
-		: wp_title( '&raquo;', false );
181
-	$attrs['referrer']   = function_exists( 'wp_get_raw_referer' )
180
+		: wp_title('&raquo;', false);
181
+	$attrs['referrer']   = function_exists('wp_get_raw_referer')
182 182
 		? wp_get_raw_referer()
183 183
 		: null;
184
-	if ( false === $attrs['referrer'] ) {
184
+	if (false === $attrs['referrer']) {
185 185
 		$attrs['referrer'] = $current_url;
186 186
 	}
187 187
 
@@ -206,5 +206,5 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @param array $attrs Attributes to be filters, default ['language' => get_locale()]
208 208
 	 */
209
-	return apply_filters( 'wpmautic_tracking_attributes', $attrs );
209
+	return apply_filters('wpmautic_tracking_attributes', $attrs);
210 210
 }
Please login to merge, or discard this patch.