@@ -13,31 +13,31 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | (function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n; |
131 | 131 | w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t), |
132 | 132 | m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m) |
133 | - })(window,document,'script','<?php echo esc_url( $base_url ); ?>/mtc.js','mt'); |
|
133 | + })(window,document,'script','<?php echo esc_url($base_url); ?>/mtc.js','mt'); |
|
134 | 134 | |
135 | 135 | mt('send', 'pageview'); |
136 | 136 | </script> |
@@ -144,18 +144,18 @@ discard block |
||
144 | 144 | * @return void |
145 | 145 | */ |
146 | 146 | function wpmautic_inject_noscript() { |
147 | - $base_url = wpmautic_option( 'base_url', '' ); |
|
148 | - if ( empty( $base_url ) ) { |
|
147 | + $base_url = wpmautic_option('base_url', ''); |
|
148 | + if (empty($base_url)) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | 152 | global $wp; |
153 | 153 | |
154 | 154 | $url_query = wpmautic_get_url_query(); |
155 | - $payload = rawurlencode( base64_encode( serialize( $url_query ) ) ); |
|
155 | + $payload = rawurlencode(base64_encode(serialize($url_query))); |
|
156 | 156 | ?> |
157 | 157 | <noscript> |
158 | - <img src="<?php echo esc_url( $base_url ); ?>/mtracking.gif?d=<?php echo esc_attr( $payload ); ?>" style="display:none;" alt="" /> |
|
158 | + <img src="<?php echo esc_url($base_url); ?>/mtracking.gif?d=<?php echo esc_attr($payload); ?>" style="display:none;" alt="" /> |
|
159 | 159 | </noscript> |
160 | 160 | <?php |
161 | 161 | } |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | */ |
168 | 168 | function wpmautic_get_url_query() { |
169 | 169 | global $wp; |
170 | - $current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) ); |
|
170 | + $current_url = add_query_arg($wp->query_string, '', home_url($wp->request)); |
|
171 | 171 | |
172 | 172 | $attrs = array(); |
173 | 173 | $attrs['page_url'] = $current_url; |
174 | - $attrs['page_title'] = function_exists( 'wp_get_document_title' ) |
|
174 | + $attrs['page_title'] = function_exists('wp_get_document_title') |
|
175 | 175 | ? wp_get_document_title() |
176 | - : wp_title( '»', false ); |
|
176 | + : wp_title('»', false); |
|
177 | 177 | $attrs['language'] = get_locale(); |
178 | - $attrs['referrer'] = function_exists( 'wp_get_raw_referer' ) |
|
178 | + $attrs['referrer'] = function_exists('wp_get_raw_referer') |
|
179 | 179 | ? wp_get_raw_referer() |
180 | 180 | : null; |
181 | - if ( false === $attrs['referrer'] ) { |
|
181 | + if (false === $attrs['referrer']) { |
|
182 | 182 | $attrs['referrer'] = $current_url; |
183 | 183 | } |
184 | 184 |
@@ -6,18 +6,18 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Prevent direct access to this file. |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | - header( 'HTTP/1.0 403 Forbidden' ); |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | + header('HTTP/1.0 403 Forbidden'); |
|
11 | 11 | echo 'This file should not be accessed directly!'; |
12 | 12 | exit; // Exit if accessed directly. |
13 | 13 | } |
14 | 14 | |
15 | -add_shortcode( 'mautic', 'wpmautic_shortcode' ); |
|
16 | -add_shortcode( 'mauticcontent', 'wpmautic_dwc_shortcode' ); |
|
17 | -add_shortcode( 'mauticvideo', 'wpmautic_video_shortcode' ); |
|
18 | -add_shortcode( 'mauticform', 'wpmautic_form_shortcode' ); |
|
19 | -add_shortcode( 'mautictags', 'wpmautic_tags_shortcode' ); |
|
20 | -add_shortcode( 'mauticfocus', 'wpmautic_focus_shortcode' ); |
|
15 | +add_shortcode('mautic', 'wpmautic_shortcode'); |
|
16 | +add_shortcode('mauticcontent', 'wpmautic_dwc_shortcode'); |
|
17 | +add_shortcode('mauticvideo', 'wpmautic_video_shortcode'); |
|
18 | +add_shortcode('mauticform', 'wpmautic_form_shortcode'); |
|
19 | +add_shortcode('mautictags', 'wpmautic_tags_shortcode'); |
|
20 | +add_shortcode('mauticfocus', 'wpmautic_focus_shortcode'); |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Handle mautic shortcode. Must include a type attribute. |
@@ -27,22 +27,22 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return string |
29 | 29 | */ |
30 | -function wpmautic_shortcode( $atts, $content = null ) { |
|
30 | +function wpmautic_shortcode($atts, $content = null) { |
|
31 | 31 | $default = shortcode_atts(array( |
32 | 32 | 'type' => null, |
33 | 33 | ), $atts); |
34 | 34 | |
35 | - switch ( $default['type'] ) { |
|
35 | + switch ($default['type']) { |
|
36 | 36 | case 'form': |
37 | - return wpmautic_form_shortcode( $atts ); |
|
37 | + return wpmautic_form_shortcode($atts); |
|
38 | 38 | case 'content': |
39 | - return wpmautic_dwc_shortcode( $atts, $content ); |
|
39 | + return wpmautic_dwc_shortcode($atts, $content); |
|
40 | 40 | case 'video': |
41 | - return wpmautic_video_shortcode( $atts ); |
|
41 | + return wpmautic_video_shortcode($atts); |
|
42 | 42 | case 'tags': |
43 | - return wpmautic_tags_shortcode( $atts ); |
|
43 | + return wpmautic_tags_shortcode($atts); |
|
44 | 44 | case 'focus': |
45 | - return wpmautic_focus_shortcode( $atts ); |
|
45 | + return wpmautic_focus_shortcode($atts); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return false; |
@@ -57,24 +57,24 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return string |
59 | 59 | */ |
60 | -function wpmautic_form_shortcode( $atts ) { |
|
61 | - $base_url = wpmautic_option( 'base_url', '' ); |
|
62 | - if ( '' === $base_url ) { |
|
60 | +function wpmautic_form_shortcode($atts) { |
|
61 | + $base_url = wpmautic_option('base_url', ''); |
|
62 | + if ('' === $base_url) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
66 | - $atts = shortcode_atts( array( |
|
66 | + $atts = shortcode_atts(array( |
|
67 | 67 | 'id' => '', |
68 | - ), $atts ); |
|
68 | + ), $atts); |
|
69 | 69 | |
70 | - if ( empty( $atts['id'] ) ) { |
|
70 | + if (empty($atts['id'])) { |
|
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | |
74 | 74 | return '<script type="text/javascript" ' . sprintf( |
75 | 75 | 'src="%s/form/generate.js?id=%s"', |
76 | - esc_url( $base_url ), |
|
77 | - esc_attr( $atts['id'] ) |
|
76 | + esc_url($base_url), |
|
77 | + esc_attr($atts['id']) |
|
78 | 78 | ) . '></script>'; |
79 | 79 | } |
80 | 80 | |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string |
90 | 90 | */ |
91 | -function wpmautic_dwc_shortcode( $atts, $content = null ) { |
|
92 | - $atts = shortcode_atts( array( |
|
91 | +function wpmautic_dwc_shortcode($atts, $content = null) { |
|
92 | + $atts = shortcode_atts(array( |
|
93 | 93 | 'slot' => '', |
94 | - ), $atts, 'mautic' ); |
|
94 | + ), $atts, 'mautic'); |
|
95 | 95 | |
96 | 96 | return sprintf( |
97 | 97 | '<div class="mautic-slot" data-slot-name="%s">%s</div>', |
98 | - esc_attr( $atts['slot'] ), |
|
99 | - esc_textarea( $content ) |
|
98 | + esc_attr($atts['slot']), |
|
99 | + esc_textarea($content) |
|
100 | 100 | ); |
101 | 101 | } |
102 | 102 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string |
111 | 111 | */ |
112 | -function wpmautic_video_shortcode( $atts ) { |
|
112 | +function wpmautic_video_shortcode($atts) { |
|
113 | 113 | $video_type = ''; |
114 | 114 | $atts = shortcode_atts(array( |
115 | 115 | 'gate-time' => 15, |
@@ -120,38 +120,38 @@ discard block |
||
120 | 120 | 'height' => 360, |
121 | 121 | ), $atts); |
122 | 122 | |
123 | - if ( empty( $atts['src'] ) ) { |
|
124 | - return __( 'You must provide a video source. Add a src="URL" attribute to your shortcode. Replace URL with the source url for your video.', 'wp-mautic' ); |
|
123 | + if (empty($atts['src'])) { |
|
124 | + return __('You must provide a video source. Add a src="URL" attribute to your shortcode. Replace URL with the source url for your video.', 'wp-mautic'); |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( empty( $atts['form-id'] ) ) { |
|
128 | - return __( 'You must provide a mautic form id. Add a form-id="#" attribute to your shortcode. Replace # with the id of the form you want to use.', 'wp-mautic' ); |
|
127 | + if (empty($atts['form-id'])) { |
|
128 | + return __('You must provide a mautic form id. Add a form-id="#" attribute to your shortcode. Replace # with the id of the form you want to use.', 'wp-mautic'); |
|
129 | 129 | } |
130 | 130 | |
131 | - if ( preg_match( '/^.*((youtu.be)|(youtube.com))\/((v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))?\??v?=?([^#\&\?]*).*/', $atts['src'] ) ) { |
|
131 | + if (preg_match('/^.*((youtu.be)|(youtube.com))\/((v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))?\??v?=?([^#\&\?]*).*/', $atts['src'])) { |
|
132 | 132 | $atts['video-type'] = 'youtube'; |
133 | 133 | } |
134 | - if ( preg_match( '/^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/', $atts['src'] ) ) { |
|
134 | + if (preg_match('/^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/', $atts['src'])) { |
|
135 | 135 | $atts['video-type'] = 'vimeo'; |
136 | 136 | } |
137 | - if ( strtolower( substr( $atts['src'], -3 ) ) === 'mp4' ) { |
|
137 | + if (strtolower(substr($atts['src'], -3)) === 'mp4') { |
|
138 | 138 | $atts['video-type'] = 'mp4'; |
139 | 139 | } |
140 | 140 | |
141 | - if ( empty( $atts['video-type'] ) ) { |
|
142 | - return __( 'Please define a valid video type with video-type="#".', 'wp-mautic' ); |
|
141 | + if (empty($atts['video-type'])) { |
|
142 | + return __('Please define a valid video type with video-type="#".', 'wp-mautic'); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return sprintf( |
146 | 146 | '<video height="%s" width="%s" data-form-id="%s" data-gate-time="%s">' . |
147 | 147 | '<source type="video/%s" src="%s" />' . |
148 | 148 | '</video>', |
149 | - esc_attr( $atts['height'] ), |
|
150 | - esc_attr( $atts['width'] ), |
|
151 | - esc_attr( $atts['form-id'] ), |
|
152 | - esc_attr( $atts['gate-time'] ), |
|
153 | - esc_attr( $atts['video-type'] ), |
|
154 | - esc_attr( $atts['src'] ) |
|
149 | + esc_attr($atts['height']), |
|
150 | + esc_attr($atts['width']), |
|
151 | + esc_attr($atts['form-id']), |
|
152 | + esc_attr($atts['gate-time']), |
|
153 | + esc_attr($atts['video-type']), |
|
154 | + esc_attr($atts['src']) |
|
155 | 155 | ); |
156 | 156 | } |
157 | 157 | |
@@ -164,25 +164,25 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return string |
166 | 166 | */ |
167 | -function wpmautic_tags_shortcode( $atts ) { |
|
168 | - $base_url = wpmautic_option( 'base_url', '' ); |
|
169 | - if ( '' === $base_url ) { |
|
167 | +function wpmautic_tags_shortcode($atts) { |
|
168 | + $base_url = wpmautic_option('base_url', ''); |
|
169 | + if ('' === $base_url) { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | - $atts = shortcode_atts( array( |
|
173 | + $atts = shortcode_atts(array( |
|
174 | 174 | 'values' => '', |
175 | - ), $atts ); |
|
175 | + ), $atts); |
|
176 | 176 | |
177 | - if ( empty( $atts['values'] ) ) { |
|
177 | + if (empty($atts['values'])) { |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | |
181 | 181 | return sprintf( |
182 | 182 | '<img src="%s/mtracking.gif?tags=%s" alt="%s" />', |
183 | - esc_url( $base_url ), |
|
184 | - esc_attr( $atts['values'] ), |
|
185 | - esc_attr__( 'Mautic Tags', 'wp-mautic' ) |
|
183 | + esc_url($base_url), |
|
184 | + esc_attr($atts['values']), |
|
185 | + esc_attr__('Mautic Tags', 'wp-mautic') |
|
186 | 186 | ); |
187 | 187 | } |
188 | 188 | |
@@ -194,23 +194,23 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return string |
196 | 196 | */ |
197 | -function wpmautic_focus_shortcode( $atts ) { |
|
198 | - $base_url = wpmautic_option( 'base_url', '' ); |
|
199 | - if ( '' === $base_url ) { |
|
197 | +function wpmautic_focus_shortcode($atts) { |
|
198 | + $base_url = wpmautic_option('base_url', ''); |
|
199 | + if ('' === $base_url) { |
|
200 | 200 | return false; |
201 | 201 | } |
202 | 202 | |
203 | - $atts = shortcode_atts( array( |
|
203 | + $atts = shortcode_atts(array( |
|
204 | 204 | 'id' => '', |
205 | - ), $atts ); |
|
205 | + ), $atts); |
|
206 | 206 | |
207 | - if ( empty( $atts['id'] ) ) { |
|
207 | + if (empty($atts['id'])) { |
|
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | |
211 | 211 | return '<script type="text/javascript" ' . sprintf( |
212 | 212 | 'src="%s/focus/%s.js"', |
213 | - esc_url( $base_url ), |
|
214 | - esc_attr( $atts['id'] ) |
|
213 | + esc_url($base_url), |
|
214 | + esc_attr($atts['id']) |
|
215 | 215 | ) . ' async="async"></script>'; |
216 | 216 | } |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Prevent direct access to this file. |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | - header( 'HTTP/1.0 403 Forbidden' ); |
|
9 | +if ( ! defined('ABSPATH')) { |
|
10 | + header('HTTP/1.0 403 Forbidden'); |
|
11 | 11 | echo 'This file should not be accessed directly!'; |
12 | 12 | exit; // Exit if accessed directly. |
13 | 13 | } |
@@ -18,34 +18,34 @@ discard block |
||
18 | 18 | function wpmautic_options_page() { |
19 | 19 | ?> |
20 | 20 | <div> |
21 | - <h2><?php esc_html_e( 'WP Mautic', 'wp-mautic' ); ?></h2> |
|
22 | - <p><?php esc_html_e( 'Enable Base URL for Mautic Integration.', 'wp-mautic' ); ?></p> |
|
21 | + <h2><?php esc_html_e('WP Mautic', 'wp-mautic'); ?></h2> |
|
22 | + <p><?php esc_html_e('Enable Base URL for Mautic Integration.', 'wp-mautic'); ?></p> |
|
23 | 23 | <form action="options.php" method="post"> |
24 | - <?php settings_fields( 'wpmautic' ); ?> |
|
25 | - <?php do_settings_sections( 'wpmautic' ); ?> |
|
24 | + <?php settings_fields('wpmautic'); ?> |
|
25 | + <?php do_settings_sections('wpmautic'); ?> |
|
26 | 26 | <?php submit_button(); ?> |
27 | 27 | </form> |
28 | - <h3><?php esc_html_e( 'Shortcode Examples:', 'wp-mautic' ); ?></h3> |
|
28 | + <h3><?php esc_html_e('Shortcode Examples:', 'wp-mautic'); ?></h3> |
|
29 | 29 | <ul> |
30 | - <li><?php esc_html_e( 'Mautic Form Embed:', 'wp-mautic' ); ?> <code>[mautic type="form" id="1"]</code></li> |
|
31 | - <li><?php esc_html_e( 'Mautic Dynamic Content:', 'wp-mautic' ); ?> <code>[mautic type="content" slot="slot_name"]<?php esc_html_e( 'Default Text', 'wp-mautic' ); ?>[/mautic]</code></li> |
|
30 | + <li><?php esc_html_e('Mautic Form Embed:', 'wp-mautic'); ?> <code>[mautic type="form" id="1"]</code></li> |
|
31 | + <li><?php esc_html_e('Mautic Dynamic Content:', 'wp-mautic'); ?> <code>[mautic type="content" slot="slot_name"]<?php esc_html_e('Default Text', 'wp-mautic'); ?>[/mautic]</code></li> |
|
32 | 32 | </ul> |
33 | - <h3><?php esc_html_e( 'Quick Links', 'wp-mautic' ); ?></h3> |
|
33 | + <h3><?php esc_html_e('Quick Links', 'wp-mautic'); ?></h3> |
|
34 | 34 | <ul> |
35 | 35 | <li> |
36 | - <a href="https://github.com/mautic/mautic-wordpress#mautic-wordpress-plugin" target="_blank"><?php esc_html_e( 'Plugin docs', 'wp-mautic' ); ?></a> |
|
36 | + <a href="https://github.com/mautic/mautic-wordpress#mautic-wordpress-plugin" target="_blank"><?php esc_html_e('Plugin docs', 'wp-mautic'); ?></a> |
|
37 | 37 | </li> |
38 | 38 | <li> |
39 | - <a href="https://github.com/mautic/mautic-wordpress/issues" target="_blank"><?php esc_html_e( 'Plugin support', 'wp-mautic' ); ?></a> |
|
39 | + <a href="https://github.com/mautic/mautic-wordpress/issues" target="_blank"><?php esc_html_e('Plugin support', 'wp-mautic'); ?></a> |
|
40 | 40 | </li> |
41 | 41 | <li> |
42 | - <a href="https://mautic.org" target="_blank"><?php esc_html_e( 'Mautic project', 'wp-mautic' ); ?></a> |
|
42 | + <a href="https://mautic.org" target="_blank"><?php esc_html_e('Mautic project', 'wp-mautic'); ?></a> |
|
43 | 43 | </li> |
44 | 44 | <li> |
45 | - <a href="http://docs.mautic.org/" target="_blank"><?php esc_html_e( 'Mautic docs', 'wp-mautic' ); ?></a> |
|
45 | + <a href="http://docs.mautic.org/" target="_blank"><?php esc_html_e('Mautic docs', 'wp-mautic'); ?></a> |
|
46 | 46 | </li> |
47 | 47 | <li> |
48 | - <a href="https://www.mautic.org/community/" target="_blank"><?php esc_html_e( 'Mautic forum', 'wp-mautic' ); ?></a> |
|
48 | + <a href="https://www.mautic.org/community/" target="_blank"><?php esc_html_e('Mautic forum', 'wp-mautic'); ?></a> |
|
49 | 49 | </li> |
50 | 50 | </ul> |
51 | 51 | </div> |
@@ -56,38 +56,38 @@ discard block |
||
56 | 56 | * Define admin_init hook logic |
57 | 57 | */ |
58 | 58 | function wpmautic_admin_init() { |
59 | - register_setting( 'wpmautic', 'wpmautic_options', 'wpmautic_options_validate' ); |
|
59 | + register_setting('wpmautic', 'wpmautic_options', 'wpmautic_options_validate'); |
|
60 | 60 | |
61 | 61 | add_settings_section( |
62 | 62 | 'wpmautic_main', |
63 | - __( 'Main Settings', 'wp-mautic' ), |
|
63 | + __('Main Settings', 'wp-mautic'), |
|
64 | 64 | 'wpmautic_section_text', |
65 | 65 | 'wpmautic' |
66 | 66 | ); |
67 | 67 | |
68 | 68 | add_settings_field( |
69 | 69 | 'wpmautic_base_url', |
70 | - __( 'Mautic Base URL', 'wp-mautic' ), |
|
70 | + __('Mautic Base URL', 'wp-mautic'), |
|
71 | 71 | 'wpmautic_base_url', |
72 | 72 | 'wpmautic', |
73 | 73 | 'wpmautic_main' |
74 | 74 | ); |
75 | 75 | add_settings_field( |
76 | 76 | 'wpmautic_script_location', |
77 | - __( 'Tracking script location', 'wp-mautic' ), |
|
77 | + __('Tracking script location', 'wp-mautic'), |
|
78 | 78 | 'wpmautic_script_location', |
79 | 79 | 'wpmautic', |
80 | 80 | 'wpmautic_main' |
81 | 81 | ); |
82 | 82 | add_settings_field( |
83 | 83 | 'wpmautic_fallback_activated', |
84 | - __( 'Fallback image', 'wp-mautic' ), |
|
84 | + __('Fallback image', 'wp-mautic'), |
|
85 | 85 | 'wpmautic_fallback_activated', |
86 | 86 | 'wpmautic', |
87 | 87 | 'wpmautic_main' |
88 | 88 | ); |
89 | 89 | } |
90 | -add_action( 'admin_init', 'wpmautic_admin_init' ); |
|
90 | +add_action('admin_init', 'wpmautic_admin_init'); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Section text |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * Define the input field for Mautic base URL |
100 | 100 | */ |
101 | 101 | function wpmautic_base_url() { |
102 | - $url = wpmautic_option( 'base_url', '' ); |
|
102 | + $url = wpmautic_option('base_url', ''); |
|
103 | 103 | |
104 | 104 | ?> |
105 | 105 | <input |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | size="40" |
109 | 109 | type="text" |
110 | 110 | placeholder="http://..." |
111 | - value="<?php echo esc_url_raw( $url, array( 'http', 'https' ) ); ?>" |
|
111 | + value="<?php echo esc_url_raw($url, array('http', 'https')); ?>" |
|
112 | 112 | /> |
113 | 113 | <?php |
114 | 114 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * Define the input field for Mautic script location |
118 | 118 | */ |
119 | 119 | function wpmautic_script_location() { |
120 | - $position = wpmautic_option( 'script_location', '' ); |
|
120 | + $position = wpmautic_option('script_location', ''); |
|
121 | 121 | |
122 | 122 | ?> |
123 | 123 | <fieldset id="wpmautic_script_location"> |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | type="radio" |
127 | 127 | name="wpmautic_options[script_location]" |
128 | 128 | value="header" |
129 | - <?php if ( 'footer' !== $position ) : ?>checked<?php endif; ?> |
|
129 | + <?php if ('footer' !== $position) : ?>checked<?php endif; ?> |
|
130 | 130 | /> |
131 | - <?php esc_html_e( 'Embedded within the `wp_head` hook', 'wp-mautic' ); ?> |
|
131 | + <?php esc_html_e('Embedded within the `wp_head` hook', 'wp-mautic'); ?> |
|
132 | 132 | </label> |
133 | 133 | <br/> |
134 | 134 | <label> |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | type="radio" |
137 | 137 | name="wpmautic_options[script_location]" |
138 | 138 | value="footer" |
139 | - <?php if ( 'footer' === $position ) : ?>checked<?php endif; ?> |
|
139 | + <?php if ('footer' === $position) : ?>checked<?php endif; ?> |
|
140 | 140 | /> |
141 | - <?php esc_html_e( 'Embedded within the `wp_footer` hook', 'wp-mautic' ); ?> |
|
141 | + <?php esc_html_e('Embedded within the `wp_footer` hook', 'wp-mautic'); ?> |
|
142 | 142 | </label> |
143 | 143 | </fieldset> |
144 | 144 | <?php |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * Define the input field for Mautic fallback flag |
149 | 149 | */ |
150 | 150 | function wpmautic_fallback_activated() { |
151 | - $flag = wpmautic_option( 'fallback_activated', false ); |
|
151 | + $flag = wpmautic_option('fallback_activated', false); |
|
152 | 152 | |
153 | 153 | ?> |
154 | 154 | <input |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | name="wpmautic_options[fallback_activated]" |
157 | 157 | type="checkbox" |
158 | 158 | value="1" |
159 | - <?php if ( true === $flag ) : ?>checked<?php endif; ?> |
|
159 | + <?php if (true === $flag) : ?>checked<?php endif; ?> |
|
160 | 160 | /> |
161 | 161 | <label for="wpmautic_fallback_activated"> |
162 | - <?php esc_html_e( 'Activate it when JavaScript is disabled ?', 'wp-mautic' ); ?> |
|
162 | + <?php esc_html_e('Activate it when JavaScript is disabled ?', 'wp-mautic'); ?> |
|
163 | 163 | </label> |
164 | 164 | <?php |
165 | 165 | } |
@@ -170,22 +170,22 @@ discard block |
||
170 | 170 | * @param array $input Input data. |
171 | 171 | * @return array |
172 | 172 | */ |
173 | -function wpmautic_options_validate( $input ) { |
|
174 | - $options = get_option( 'wpmautic_options' ); |
|
173 | +function wpmautic_options_validate($input) { |
|
174 | + $options = get_option('wpmautic_options'); |
|
175 | 175 | |
176 | - $input['base_url'] = isset( $input['base_url'] ) |
|
177 | - ? trim( $input['base_url'], " \t\n\r\0\x0B/" ) |
|
176 | + $input['base_url'] = isset($input['base_url']) |
|
177 | + ? trim($input['base_url'], " \t\n\r\0\x0B/") |
|
178 | 178 | : ''; |
179 | 179 | |
180 | - $options['base_url'] = esc_url_raw( trim( $input['base_url'], " \t\n\r\0\x0B/" ) ); |
|
181 | - $options['script_location'] = isset( $input['script_location'] ) |
|
182 | - ? trim( $input['script_location'] ) |
|
180 | + $options['base_url'] = esc_url_raw(trim($input['base_url'], " \t\n\r\0\x0B/")); |
|
181 | + $options['script_location'] = isset($input['script_location']) |
|
182 | + ? trim($input['script_location']) |
|
183 | 183 | : 'header'; |
184 | - if ( ! in_array( $options['script_location'], array( 'header', 'footer' ), true ) ) { |
|
184 | + if ( ! in_array($options['script_location'], array('header', 'footer'), true)) { |
|
185 | 185 | $options['script_location'] = 'header'; |
186 | 186 | } |
187 | 187 | |
188 | - $options['fallback_activated'] = isset( $input['fallback_activated'] ) && '1' === $input['fallback_activated'] |
|
188 | + $options['fallback_activated'] = isset($input['fallback_activated']) && '1' === $input['fallback_activated'] |
|
189 | 189 | ? true |
190 | 190 | : false; |
191 | 191 |
@@ -8,107 +8,107 @@ |
||
8 | 8 | */ |
9 | 9 | class SettingsTest extends WP_UnitTestCase |
10 | 10 | { |
11 | - public function setUp() |
|
12 | - { |
|
13 | - parent::setUp(); |
|
14 | - require_once(VPMAUTIC_PLUGIN_DIR.'/options.php'); |
|
11 | + public function setUp() |
|
12 | + { |
|
13 | + parent::setUp(); |
|
14 | + require_once(VPMAUTIC_PLUGIN_DIR.'/options.php'); |
|
15 | 15 | |
16 | - $this->setOutputCallback(create_function('', '')); |
|
17 | - } |
|
16 | + $this->setOutputCallback(create_function('', '')); |
|
17 | + } |
|
18 | 18 | |
19 | - public function test_nonce_fields_are_present() |
|
20 | - { |
|
21 | - wpmautic_options_page(); |
|
22 | - $output = $this->getActualOutput(); |
|
23 | - $this->assertContains("name='option_page' value='wpmautic'", $output); |
|
24 | - } |
|
19 | + public function test_nonce_fields_are_present() |
|
20 | + { |
|
21 | + wpmautic_options_page(); |
|
22 | + $output = $this->getActualOutput(); |
|
23 | + $this->assertContains("name='option_page' value='wpmautic'", $output); |
|
24 | + } |
|
25 | 25 | |
26 | - public function test_with_admin_init() |
|
27 | - { |
|
28 | - wpmautic_admin_init(); |
|
29 | - wpmautic_options_page(); |
|
30 | - $output = $this->getActualOutput(); |
|
31 | - $this->assertContains("name='option_page' value='wpmautic'", $output); |
|
32 | - $this->test_base_url_setting(); |
|
33 | - $this->test_script_location_setting(); |
|
34 | - } |
|
26 | + public function test_with_admin_init() |
|
27 | + { |
|
28 | + wpmautic_admin_init(); |
|
29 | + wpmautic_options_page(); |
|
30 | + $output = $this->getActualOutput(); |
|
31 | + $this->assertContains("name='option_page' value='wpmautic'", $output); |
|
32 | + $this->test_base_url_setting(); |
|
33 | + $this->test_script_location_setting(); |
|
34 | + } |
|
35 | 35 | |
36 | - public function test_base_url_setting() |
|
37 | - { |
|
38 | - wpmautic_base_url(); |
|
39 | - $output = $this->getActualOutput(); |
|
40 | - $this->assertContains("wpmautic_base_url", $output); |
|
41 | - $this->assertContains("wpmautic_options[base_url]", $output); |
|
42 | - $this->assertContains("value=\"\"", $output); |
|
43 | - } |
|
36 | + public function test_base_url_setting() |
|
37 | + { |
|
38 | + wpmautic_base_url(); |
|
39 | + $output = $this->getActualOutput(); |
|
40 | + $this->assertContains("wpmautic_base_url", $output); |
|
41 | + $this->assertContains("wpmautic_options[base_url]", $output); |
|
42 | + $this->assertContains("value=\"\"", $output); |
|
43 | + } |
|
44 | 44 | |
45 | - public function test_base_url_setting_with_value() |
|
46 | - { |
|
47 | - update_option('wpmautic_options', array( |
|
48 | - 'base_url' => 'http://example.com' |
|
49 | - )); |
|
45 | + public function test_base_url_setting_with_value() |
|
46 | + { |
|
47 | + update_option('wpmautic_options', array( |
|
48 | + 'base_url' => 'http://example.com' |
|
49 | + )); |
|
50 | 50 | |
51 | - wpmautic_base_url(); |
|
52 | - $output = $this->getActualOutput(); |
|
53 | - $this->assertContains("wpmautic_base_url", $output); |
|
54 | - $this->assertContains("wpmautic_options[base_url]", $output); |
|
55 | - $this->assertContains("value=\"http://example.com\"", $output); |
|
56 | - } |
|
51 | + wpmautic_base_url(); |
|
52 | + $output = $this->getActualOutput(); |
|
53 | + $this->assertContains("wpmautic_base_url", $output); |
|
54 | + $this->assertContains("wpmautic_options[base_url]", $output); |
|
55 | + $this->assertContains("value=\"http://example.com\"", $output); |
|
56 | + } |
|
57 | 57 | |
58 | - public function test_script_location_setting() |
|
59 | - { |
|
60 | - wpmautic_script_location(); |
|
61 | - $output = $this->getActualOutput(); |
|
62 | - $this->assertContains("wpmautic_script_location", $output); |
|
63 | - $this->assertContains("wpmautic_options[script_location]", $output); |
|
64 | - $this->assertRegExp('/value="header"\s+checked/', $output); |
|
65 | - } |
|
58 | + public function test_script_location_setting() |
|
59 | + { |
|
60 | + wpmautic_script_location(); |
|
61 | + $output = $this->getActualOutput(); |
|
62 | + $this->assertContains("wpmautic_script_location", $output); |
|
63 | + $this->assertContains("wpmautic_options[script_location]", $output); |
|
64 | + $this->assertRegExp('/value="header"\s+checked/', $output); |
|
65 | + } |
|
66 | 66 | |
67 | - public function test_script_location_setting_with_footer_checked() |
|
68 | - { |
|
69 | - update_option('wpmautic_options', array( |
|
70 | - 'script_location' => 'footer' |
|
71 | - )); |
|
67 | + public function test_script_location_setting_with_footer_checked() |
|
68 | + { |
|
69 | + update_option('wpmautic_options', array( |
|
70 | + 'script_location' => 'footer' |
|
71 | + )); |
|
72 | 72 | |
73 | - wpmautic_script_location(); |
|
74 | - $output = $this->getActualOutput(); |
|
75 | - $this->assertContains("wpmautic_script_location", $output); |
|
76 | - $this->assertContains("wpmautic_options[script_location]", $output); |
|
77 | - $this->assertRegExp('/value="footer"\s+checked/', $output); |
|
78 | - } |
|
73 | + wpmautic_script_location(); |
|
74 | + $output = $this->getActualOutput(); |
|
75 | + $this->assertContains("wpmautic_script_location", $output); |
|
76 | + $this->assertContains("wpmautic_options[script_location]", $output); |
|
77 | + $this->assertRegExp('/value="footer"\s+checked/', $output); |
|
78 | + } |
|
79 | 79 | |
80 | - public function test_fallback_activated_setting_with_default() |
|
81 | - { |
|
82 | - wpmautic_fallback_activated(); |
|
83 | - $output = $this->getActualOutput(); |
|
84 | - $this->assertContains("wpmautic_fallback_activated", $output); |
|
85 | - $this->assertContains("wpmautic_options[fallback_activated]", $output); |
|
86 | - $this->assertContains("checked", $output); |
|
87 | - } |
|
80 | + public function test_fallback_activated_setting_with_default() |
|
81 | + { |
|
82 | + wpmautic_fallback_activated(); |
|
83 | + $output = $this->getActualOutput(); |
|
84 | + $this->assertContains("wpmautic_fallback_activated", $output); |
|
85 | + $this->assertContains("wpmautic_options[fallback_activated]", $output); |
|
86 | + $this->assertContains("checked", $output); |
|
87 | + } |
|
88 | 88 | |
89 | - public function test_fallback_activated_setting_with_unchecked() |
|
90 | - { |
|
91 | - update_option('wpmautic_options', array( |
|
92 | - 'fallback_activated' => false |
|
93 | - )); |
|
89 | + public function test_fallback_activated_setting_with_unchecked() |
|
90 | + { |
|
91 | + update_option('wpmautic_options', array( |
|
92 | + 'fallback_activated' => false |
|
93 | + )); |
|
94 | 94 | |
95 | - wpmautic_fallback_activated(); |
|
96 | - $output = $this->getActualOutput(); |
|
97 | - $this->assertContains("wpmautic_fallback_activated", $output); |
|
98 | - $this->assertContains("wpmautic_options[fallback_activated]", $output); |
|
99 | - $this->assertNotContains("checked", $output); |
|
100 | - } |
|
95 | + wpmautic_fallback_activated(); |
|
96 | + $output = $this->getActualOutput(); |
|
97 | + $this->assertContains("wpmautic_fallback_activated", $output); |
|
98 | + $this->assertContains("wpmautic_options[fallback_activated]", $output); |
|
99 | + $this->assertNotContains("checked", $output); |
|
100 | + } |
|
101 | 101 | |
102 | - public function test_fallback_activated_setting_with_checked() |
|
103 | - { |
|
104 | - update_option('wpmautic_options', array( |
|
105 | - 'fallback_activated' => true |
|
106 | - )); |
|
102 | + public function test_fallback_activated_setting_with_checked() |
|
103 | + { |
|
104 | + update_option('wpmautic_options', array( |
|
105 | + 'fallback_activated' => true |
|
106 | + )); |
|
107 | 107 | |
108 | - wpmautic_fallback_activated(); |
|
109 | - $output = $this->getActualOutput(); |
|
110 | - $this->assertContains("wpmautic_fallback_activated", $output); |
|
111 | - $this->assertContains("wpmautic_options[fallback_activated]", $output); |
|
112 | - $this->assertContains("checked", $output); |
|
113 | - } |
|
108 | + wpmautic_fallback_activated(); |
|
109 | + $output = $this->getActualOutput(); |
|
110 | + $this->assertContains("wpmautic_fallback_activated", $output); |
|
111 | + $this->assertContains("wpmautic_options[fallback_activated]", $output); |
|
112 | + $this->assertContains("checked", $output); |
|
113 | + } |
|
114 | 114 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | public function setUp() |
12 | 12 | { |
13 | 13 | parent::setUp(); |
14 | - require_once(VPMAUTIC_PLUGIN_DIR.'/options.php'); |
|
14 | + require_once(VPMAUTIC_PLUGIN_DIR . '/options.php'); |
|
15 | 15 | |
16 | 16 | $this->setOutputCallback(create_function('', '')); |
17 | 17 | } |
@@ -8,55 +8,55 @@ |
||
8 | 8 | */ |
9 | 9 | class OptionsTest extends WP_UnitTestCase |
10 | 10 | { |
11 | - /** |
|
12 | - * @expectedException InvalidArgumentException |
|
13 | - */ |
|
14 | - public function test_invalid_option_name() |
|
15 | - { |
|
16 | - wpmautic_option('azerty123456'); |
|
17 | - } |
|
11 | + /** |
|
12 | + * @expectedException InvalidArgumentException |
|
13 | + */ |
|
14 | + public function test_invalid_option_name() |
|
15 | + { |
|
16 | + wpmautic_option('azerty123456'); |
|
17 | + } |
|
18 | 18 | |
19 | - public function test_base_url_when_empty() |
|
20 | - { |
|
21 | - update_option('wpmautic_options', array( |
|
22 | - 'base_url' => '' |
|
23 | - )); |
|
24 | - $this->assertEmpty(wpmautic_option('base_url')); |
|
25 | - } |
|
19 | + public function test_base_url_when_empty() |
|
20 | + { |
|
21 | + update_option('wpmautic_options', array( |
|
22 | + 'base_url' => '' |
|
23 | + )); |
|
24 | + $this->assertEmpty(wpmautic_option('base_url')); |
|
25 | + } |
|
26 | 26 | |
27 | - public function test_base_url_with_value() |
|
28 | - { |
|
29 | - update_option('wpmautic_options', array( |
|
30 | - 'base_url' => 'http://example.com' |
|
31 | - )); |
|
32 | - $this->assertEquals('http://example.com', wpmautic_option('base_url')); |
|
33 | - } |
|
27 | + public function test_base_url_with_value() |
|
28 | + { |
|
29 | + update_option('wpmautic_options', array( |
|
30 | + 'base_url' => 'http://example.com' |
|
31 | + )); |
|
32 | + $this->assertEquals('http://example.com', wpmautic_option('base_url')); |
|
33 | + } |
|
34 | 34 | |
35 | - public function test_script_location_when_empty() |
|
36 | - { |
|
37 | - update_option('wpmautic_options', array()); |
|
38 | - $this->assertEquals('header', wpmautic_option('script_location')); |
|
39 | - } |
|
35 | + public function test_script_location_when_empty() |
|
36 | + { |
|
37 | + update_option('wpmautic_options', array()); |
|
38 | + $this->assertEquals('header', wpmautic_option('script_location')); |
|
39 | + } |
|
40 | 40 | |
41 | - public function test_script_location_with_value() |
|
42 | - { |
|
43 | - update_option('wpmautic_options', array( |
|
44 | - 'script_location' => 'footer' |
|
45 | - )); |
|
46 | - $this->assertEquals('footer', wpmautic_option('script_location')); |
|
47 | - } |
|
41 | + public function test_script_location_with_value() |
|
42 | + { |
|
43 | + update_option('wpmautic_options', array( |
|
44 | + 'script_location' => 'footer' |
|
45 | + )); |
|
46 | + $this->assertEquals('footer', wpmautic_option('script_location')); |
|
47 | + } |
|
48 | 48 | |
49 | - public function test_fallback_activated_when_empty() |
|
50 | - { |
|
51 | - update_option('wpmautic_options', array()); |
|
52 | - $this->assertTrue(wpmautic_option('fallback_activated')); |
|
53 | - } |
|
49 | + public function test_fallback_activated_when_empty() |
|
50 | + { |
|
51 | + update_option('wpmautic_options', array()); |
|
52 | + $this->assertTrue(wpmautic_option('fallback_activated')); |
|
53 | + } |
|
54 | 54 | |
55 | - public function test_fallback_activated_with_value() |
|
56 | - { |
|
57 | - update_option('wpmautic_options', array( |
|
58 | - 'fallback_activated' => false |
|
59 | - )); |
|
60 | - $this->assertFalse(wpmautic_option('fallback_activated')); |
|
61 | - } |
|
55 | + public function test_fallback_activated_with_value() |
|
56 | + { |
|
57 | + update_option('wpmautic_options', array( |
|
58 | + 'fallback_activated' => false |
|
59 | + )); |
|
60 | + $this->assertFalse(wpmautic_option('fallback_activated')); |
|
61 | + } |
|
62 | 62 | } |
@@ -8,238 +8,238 @@ |
||
8 | 8 | */ |
9 | 9 | class ShortCodeTest extends WP_UnitTestCase |
10 | 10 | { |
11 | - public function setUp() |
|
12 | - { |
|
13 | - parent::setUp(); |
|
11 | + public function setUp() |
|
12 | + { |
|
13 | + parent::setUp(); |
|
14 | 14 | |
15 | - update_option('wpmautic_options', array( |
|
16 | - 'base_url' => 'http://example.com' |
|
17 | - )); |
|
18 | - } |
|
15 | + update_option('wpmautic_options', array( |
|
16 | + 'base_url' => 'http://example.com' |
|
17 | + )); |
|
18 | + } |
|
19 | 19 | |
20 | - public function test_shortcode_exists() |
|
21 | - { |
|
22 | - $this->assertTrue(shortcode_exists('mautic')); |
|
23 | - $this->assertTrue(shortcode_exists('mauticcontent')); |
|
24 | - $this->assertTrue(shortcode_exists('mauticvideo')); |
|
25 | - $this->assertTrue(shortcode_exists('mauticform')); |
|
26 | - $this->assertTrue(shortcode_exists('mautictags')); |
|
27 | - $this->assertTrue(shortcode_exists('mauticfocus')); |
|
28 | - } |
|
20 | + public function test_shortcode_exists() |
|
21 | + { |
|
22 | + $this->assertTrue(shortcode_exists('mautic')); |
|
23 | + $this->assertTrue(shortcode_exists('mauticcontent')); |
|
24 | + $this->assertTrue(shortcode_exists('mauticvideo')); |
|
25 | + $this->assertTrue(shortcode_exists('mauticform')); |
|
26 | + $this->assertTrue(shortcode_exists('mautictags')); |
|
27 | + $this->assertTrue(shortcode_exists('mauticfocus')); |
|
28 | + } |
|
29 | 29 | |
30 | - public function test_form_shortcode_from_empty_atts() |
|
31 | - { |
|
32 | - $result = wpmautic_form_shortcode(array()); |
|
33 | - $this->assertFalse($result); |
|
34 | - } |
|
30 | + public function test_form_shortcode_from_empty_atts() |
|
31 | + { |
|
32 | + $result = wpmautic_form_shortcode(array()); |
|
33 | + $this->assertFalse($result); |
|
34 | + } |
|
35 | 35 | |
36 | - public function provideShortCode() |
|
37 | - { |
|
38 | - return array( |
|
39 | - array( |
|
40 | - '[mauticform id="1"]', |
|
41 | - '<script type="text/javascript" src="http://example.com/form/generate.js?id=1"></script>' |
|
42 | - ), |
|
43 | - array( |
|
44 | - '[mautic type="form" id="1"]', |
|
45 | - '<script type="text/javascript" src="http://example.com/form/generate.js?id=1"></script>' |
|
46 | - ), |
|
47 | - array( |
|
48 | - '[mautictags values="tag,-tag2,tag3"]', |
|
49 | - '<img src="http://example.com/mtracking.gif?tags=tag,-tag2,tag3" alt="Mautic Tags" />' |
|
50 | - ), |
|
51 | - array( |
|
52 | - '[mautic type="tags" values="tag,tag2,-tag3"]', |
|
53 | - '<img src="http://example.com/mtracking.gif?tags=tag,tag2,-tag3" alt="Mautic Tags" />' |
|
54 | - ), |
|
55 | - array( |
|
56 | - '[mautictags values="tag,-tag2,tag3"]', |
|
57 | - '<img src="http://example.com/mtracking.gif?tags=tag,-tag2,tag3" alt="Mautic Tags" />' |
|
58 | - ), |
|
59 | - array( |
|
60 | - '[mautic type="tags" values="tag,tag2,-tag3"]', |
|
61 | - '<img src="http://example.com/mtracking.gif?tags=tag,tag2,-tag3" alt="Mautic Tags" />' |
|
62 | - ), |
|
63 | - array( |
|
64 | - '[mauticfocus id="1"]', |
|
65 | - '<script type="text/javascript" src="http://example.com/focus/1.js" async="async"></script>' |
|
66 | - ), |
|
67 | - array( |
|
68 | - '[mautic type="focus" id="1"]', |
|
69 | - '<script type="text/javascript" src="http://example.com/focus/1.js" async="async"></script>' |
|
70 | - ), |
|
71 | - array( |
|
72 | - '[mauticcontent slot="name"]content[/mauticcontent]', |
|
73 | - '<div class="mautic-slot" data-slot-name="name">content</div>' |
|
74 | - ), |
|
75 | - array( |
|
76 | - '[mautic type="content" slot="name"]content[/mautic]', |
|
77 | - '<div class="mautic-slot" data-slot-name="name">content</div>' |
|
78 | - ), |
|
79 | - array( |
|
80 | - '[mautic type="video" src="https://www.youtube.com/watch?v=1234" form-id="1" width="148"]', |
|
81 | - '<video height="360" width="148" data-form-id="1" data-gate-time="15">' . |
|
82 | - '<source type="video/youtube" src="https://www.youtube.com/watch?v=1234" />' . |
|
83 | - '</video>' |
|
84 | - ), |
|
85 | - array( |
|
86 | - '[mauticvideo src="https://www.youtube.com/watch?v=1234" form-id="1" width="148"]', |
|
87 | - '<video height="360" width="148" data-form-id="1" data-gate-time="15">' . |
|
88 | - '<source type="video/youtube" src="https://www.youtube.com/watch?v=1234" />' . |
|
89 | - '</video>' |
|
90 | - ), |
|
91 | - array( |
|
92 | - '[mautic type="video" src="https://vimeo.com/218680983" form-id="1" height="272"]', |
|
93 | - '<video height="272" width="640" data-form-id="1" data-gate-time="15">' . |
|
94 | - '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
95 | - '</video>' |
|
96 | - ), |
|
97 | - array( |
|
98 | - '[mauticvideo src="https://vimeo.com/218680983" form-id="1" height="272"]', |
|
99 | - '<video height="272" width="640" data-form-id="1" data-gate-time="15">' . |
|
100 | - '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
101 | - '</video>' |
|
102 | - ), |
|
103 | - array( |
|
104 | - '[mautic type="video" src="https://vimeo.com/218680983" form-id="1" gate-time="25"]', |
|
105 | - '<video height="360" width="640" data-form-id="1" data-gate-time="25">' . |
|
106 | - '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
107 | - '</video>' |
|
108 | - ), |
|
109 | - array( |
|
110 | - '[mauticvideo src="https://vimeo.com/218680983" form-id="1" gate-time="25"]', |
|
111 | - '<video height="360" width="640" data-form-id="1" data-gate-time="25">' . |
|
112 | - '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
113 | - '</video>' |
|
114 | - ), |
|
115 | - array( |
|
116 | - '[mautic type="video" src="https://vimeo.com/218680983" form-id="1" video-type="mp4"]', |
|
117 | - '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
118 | - '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
119 | - '</video>' |
|
120 | - ), |
|
121 | - array( |
|
122 | - '[mauticvideo src="https://vimeo.com/218680983" form-id="1" video-type="mp4"]', |
|
123 | - '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
124 | - '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
125 | - '</video>' |
|
126 | - ), |
|
127 | - array( |
|
128 | - '[mautic type="video" src="https://example.com/mavideo.mov" form-id="1" video-type="mov"]', |
|
129 | - '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
130 | - '<source type="video/mov" src="https://example.com/mavideo.mov" />' . |
|
131 | - '</video>' |
|
132 | - ), |
|
133 | - array( |
|
134 | - '[mauticvideo src="https://example.com/mavideo.mov" form-id="1" video-type="mov"]', |
|
135 | - '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
136 | - '<source type="video/mov" src="https://example.com/mavideo.mov" />' . |
|
137 | - '</video>' |
|
138 | - ), |
|
139 | - array( |
|
140 | - '[mautic type="video" src="https://example.com/mavideo.mp4" form-id="1"]', |
|
141 | - '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
142 | - '<source type="video/mp4" src="https://example.com/mavideo.mp4" />' . |
|
143 | - '</video>' |
|
144 | - ), |
|
145 | - array( |
|
146 | - '[mauticvideo src="https://example.com/mavideo.mp4" form-id="1"]', |
|
147 | - '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
148 | - '<source type="video/mp4" src="https://example.com/mavideo.mp4" />' . |
|
149 | - '</video>' |
|
150 | - ), |
|
151 | - ); |
|
152 | - } |
|
36 | + public function provideShortCode() |
|
37 | + { |
|
38 | + return array( |
|
39 | + array( |
|
40 | + '[mauticform id="1"]', |
|
41 | + '<script type="text/javascript" src="http://example.com/form/generate.js?id=1"></script>' |
|
42 | + ), |
|
43 | + array( |
|
44 | + '[mautic type="form" id="1"]', |
|
45 | + '<script type="text/javascript" src="http://example.com/form/generate.js?id=1"></script>' |
|
46 | + ), |
|
47 | + array( |
|
48 | + '[mautictags values="tag,-tag2,tag3"]', |
|
49 | + '<img src="http://example.com/mtracking.gif?tags=tag,-tag2,tag3" alt="Mautic Tags" />' |
|
50 | + ), |
|
51 | + array( |
|
52 | + '[mautic type="tags" values="tag,tag2,-tag3"]', |
|
53 | + '<img src="http://example.com/mtracking.gif?tags=tag,tag2,-tag3" alt="Mautic Tags" />' |
|
54 | + ), |
|
55 | + array( |
|
56 | + '[mautictags values="tag,-tag2,tag3"]', |
|
57 | + '<img src="http://example.com/mtracking.gif?tags=tag,-tag2,tag3" alt="Mautic Tags" />' |
|
58 | + ), |
|
59 | + array( |
|
60 | + '[mautic type="tags" values="tag,tag2,-tag3"]', |
|
61 | + '<img src="http://example.com/mtracking.gif?tags=tag,tag2,-tag3" alt="Mautic Tags" />' |
|
62 | + ), |
|
63 | + array( |
|
64 | + '[mauticfocus id="1"]', |
|
65 | + '<script type="text/javascript" src="http://example.com/focus/1.js" async="async"></script>' |
|
66 | + ), |
|
67 | + array( |
|
68 | + '[mautic type="focus" id="1"]', |
|
69 | + '<script type="text/javascript" src="http://example.com/focus/1.js" async="async"></script>' |
|
70 | + ), |
|
71 | + array( |
|
72 | + '[mauticcontent slot="name"]content[/mauticcontent]', |
|
73 | + '<div class="mautic-slot" data-slot-name="name">content</div>' |
|
74 | + ), |
|
75 | + array( |
|
76 | + '[mautic type="content" slot="name"]content[/mautic]', |
|
77 | + '<div class="mautic-slot" data-slot-name="name">content</div>' |
|
78 | + ), |
|
79 | + array( |
|
80 | + '[mautic type="video" src="https://www.youtube.com/watch?v=1234" form-id="1" width="148"]', |
|
81 | + '<video height="360" width="148" data-form-id="1" data-gate-time="15">' . |
|
82 | + '<source type="video/youtube" src="https://www.youtube.com/watch?v=1234" />' . |
|
83 | + '</video>' |
|
84 | + ), |
|
85 | + array( |
|
86 | + '[mauticvideo src="https://www.youtube.com/watch?v=1234" form-id="1" width="148"]', |
|
87 | + '<video height="360" width="148" data-form-id="1" data-gate-time="15">' . |
|
88 | + '<source type="video/youtube" src="https://www.youtube.com/watch?v=1234" />' . |
|
89 | + '</video>' |
|
90 | + ), |
|
91 | + array( |
|
92 | + '[mautic type="video" src="https://vimeo.com/218680983" form-id="1" height="272"]', |
|
93 | + '<video height="272" width="640" data-form-id="1" data-gate-time="15">' . |
|
94 | + '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
95 | + '</video>' |
|
96 | + ), |
|
97 | + array( |
|
98 | + '[mauticvideo src="https://vimeo.com/218680983" form-id="1" height="272"]', |
|
99 | + '<video height="272" width="640" data-form-id="1" data-gate-time="15">' . |
|
100 | + '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
101 | + '</video>' |
|
102 | + ), |
|
103 | + array( |
|
104 | + '[mautic type="video" src="https://vimeo.com/218680983" form-id="1" gate-time="25"]', |
|
105 | + '<video height="360" width="640" data-form-id="1" data-gate-time="25">' . |
|
106 | + '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
107 | + '</video>' |
|
108 | + ), |
|
109 | + array( |
|
110 | + '[mauticvideo src="https://vimeo.com/218680983" form-id="1" gate-time="25"]', |
|
111 | + '<video height="360" width="640" data-form-id="1" data-gate-time="25">' . |
|
112 | + '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
113 | + '</video>' |
|
114 | + ), |
|
115 | + array( |
|
116 | + '[mautic type="video" src="https://vimeo.com/218680983" form-id="1" video-type="mp4"]', |
|
117 | + '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
118 | + '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
119 | + '</video>' |
|
120 | + ), |
|
121 | + array( |
|
122 | + '[mauticvideo src="https://vimeo.com/218680983" form-id="1" video-type="mp4"]', |
|
123 | + '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
124 | + '<source type="video/vimeo" src="https://vimeo.com/218680983" />' . |
|
125 | + '</video>' |
|
126 | + ), |
|
127 | + array( |
|
128 | + '[mautic type="video" src="https://example.com/mavideo.mov" form-id="1" video-type="mov"]', |
|
129 | + '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
130 | + '<source type="video/mov" src="https://example.com/mavideo.mov" />' . |
|
131 | + '</video>' |
|
132 | + ), |
|
133 | + array( |
|
134 | + '[mauticvideo src="https://example.com/mavideo.mov" form-id="1" video-type="mov"]', |
|
135 | + '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
136 | + '<source type="video/mov" src="https://example.com/mavideo.mov" />' . |
|
137 | + '</video>' |
|
138 | + ), |
|
139 | + array( |
|
140 | + '[mautic type="video" src="https://example.com/mavideo.mp4" form-id="1"]', |
|
141 | + '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
142 | + '<source type="video/mp4" src="https://example.com/mavideo.mp4" />' . |
|
143 | + '</video>' |
|
144 | + ), |
|
145 | + array( |
|
146 | + '[mauticvideo src="https://example.com/mavideo.mp4" form-id="1"]', |
|
147 | + '<video height="360" width="640" data-form-id="1" data-gate-time="15">' . |
|
148 | + '<source type="video/mp4" src="https://example.com/mavideo.mp4" />' . |
|
149 | + '</video>' |
|
150 | + ), |
|
151 | + ); |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * @dataProvider provideShortCode |
|
156 | - * @param string $content |
|
157 | - * @param string $expected |
|
158 | - */ |
|
159 | - public function test_shortcode($content, $expected) |
|
160 | - { |
|
161 | - $result = do_shortcode($content); |
|
162 | - $this->assertEquals($expected, $result); |
|
163 | - } |
|
154 | + /** |
|
155 | + * @dataProvider provideShortCode |
|
156 | + * @param string $content |
|
157 | + * @param string $expected |
|
158 | + */ |
|
159 | + public function test_shortcode($content, $expected) |
|
160 | + { |
|
161 | + $result = do_shortcode($content); |
|
162 | + $this->assertEquals($expected, $result); |
|
163 | + } |
|
164 | 164 | |
165 | - public function provideShortCodeToBeEmptyWithoutUrl() |
|
166 | - { |
|
167 | - return array( |
|
168 | - array('[mauticform id="1"]'), |
|
169 | - array('[mautic type="form" id="1"]'), |
|
170 | - array('[mautictags values="tag,-tag2,tag3"]'), |
|
171 | - array('[mautic type="tags" values="tag,tag2,-tag3"]'), |
|
172 | - array('[mauticfocus id="1"]'), |
|
173 | - array('[mautic type="focus" id="1"]'), |
|
174 | - ); |
|
175 | - } |
|
165 | + public function provideShortCodeToBeEmptyWithoutUrl() |
|
166 | + { |
|
167 | + return array( |
|
168 | + array('[mauticform id="1"]'), |
|
169 | + array('[mautic type="form" id="1"]'), |
|
170 | + array('[mautictags values="tag,-tag2,tag3"]'), |
|
171 | + array('[mautic type="tags" values="tag,tag2,-tag3"]'), |
|
172 | + array('[mauticfocus id="1"]'), |
|
173 | + array('[mautic type="focus" id="1"]'), |
|
174 | + ); |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * @dataProvider provideShortCodeToBeEmpty |
|
179 | - * @param string $content |
|
180 | - */ |
|
181 | - public function test_shortcode_with_empty_url($content) |
|
182 | - { |
|
183 | - update_option('wpmautic_options', array()); |
|
177 | + /** |
|
178 | + * @dataProvider provideShortCodeToBeEmpty |
|
179 | + * @param string $content |
|
180 | + */ |
|
181 | + public function test_shortcode_with_empty_url($content) |
|
182 | + { |
|
183 | + update_option('wpmautic_options', array()); |
|
184 | 184 | |
185 | - $result = do_shortcode($content); |
|
186 | - $this->assertEmpty($result); |
|
187 | - } |
|
185 | + $result = do_shortcode($content); |
|
186 | + $this->assertEmpty($result); |
|
187 | + } |
|
188 | 188 | |
189 | - public function provideShortCodeToBeEmpty() |
|
190 | - { |
|
191 | - return array( |
|
192 | - array('[mauticform]'), |
|
193 | - array('[mautic type="form"]'), |
|
194 | - array('[mautictags]'), |
|
195 | - array('[mautic type="tags"]'), |
|
196 | - array('[mauticfocus]'), |
|
197 | - array('[mautic type="focus"]'), |
|
198 | - ); |
|
199 | - } |
|
189 | + public function provideShortCodeToBeEmpty() |
|
190 | + { |
|
191 | + return array( |
|
192 | + array('[mauticform]'), |
|
193 | + array('[mautic type="form"]'), |
|
194 | + array('[mautictags]'), |
|
195 | + array('[mautic type="tags"]'), |
|
196 | + array('[mauticfocus]'), |
|
197 | + array('[mautic type="focus"]'), |
|
198 | + ); |
|
199 | + } |
|
200 | 200 | |
201 | - /** |
|
202 | - * @dataProvider provideShortCodeToBeEmpty |
|
203 | - * @param string $content |
|
204 | - */ |
|
205 | - public function test_shortcode_to_be_empty($content) |
|
206 | - { |
|
207 | - $result = do_shortcode($content); |
|
208 | - $this->assertEmpty($result); |
|
209 | - } |
|
201 | + /** |
|
202 | + * @dataProvider provideShortCodeToBeEmpty |
|
203 | + * @param string $content |
|
204 | + */ |
|
205 | + public function test_shortcode_to_be_empty($content) |
|
206 | + { |
|
207 | + $result = do_shortcode($content); |
|
208 | + $this->assertEmpty($result); |
|
209 | + } |
|
210 | 210 | |
211 | - public function test_invalid_shortcode_type() |
|
212 | - { |
|
213 | - $result = do_shortcode("[mautic type='azerty']"); |
|
214 | - $this->assertEmpty($result); |
|
215 | - } |
|
211 | + public function test_invalid_shortcode_type() |
|
212 | + { |
|
213 | + $result = do_shortcode("[mautic type='azerty']"); |
|
214 | + $this->assertEmpty($result); |
|
215 | + } |
|
216 | 216 | |
217 | - public function test_no_src_on_video_shortcode() |
|
218 | - { |
|
219 | - $result = do_shortcode("[mautic type='video']"); |
|
220 | - $this->assertEquals( |
|
221 | - 'You must provide a video source. Add a src="URL" attribute to your shortcode. '. |
|
222 | - 'Replace URL with the source url for your video.', |
|
223 | - $result |
|
224 | - ); |
|
225 | - } |
|
217 | + public function test_no_src_on_video_shortcode() |
|
218 | + { |
|
219 | + $result = do_shortcode("[mautic type='video']"); |
|
220 | + $this->assertEquals( |
|
221 | + 'You must provide a video source. Add a src="URL" attribute to your shortcode. '. |
|
222 | + 'Replace URL with the source url for your video.', |
|
223 | + $result |
|
224 | + ); |
|
225 | + } |
|
226 | 226 | |
227 | - public function test_no_form_id_on_video_shortcode() |
|
228 | - { |
|
229 | - $result = do_shortcode("[mautic type='video' src='mavideo.mov']"); |
|
230 | - $this->assertEquals( |
|
231 | - 'You must provide a mautic form id. Add a form-id="#" attribute to your shortcode. '. |
|
232 | - 'Replace # with the id of the form you want to use.', |
|
233 | - $result |
|
234 | - ); |
|
235 | - } |
|
227 | + public function test_no_form_id_on_video_shortcode() |
|
228 | + { |
|
229 | + $result = do_shortcode("[mautic type='video' src='mavideo.mov']"); |
|
230 | + $this->assertEquals( |
|
231 | + 'You must provide a mautic form id. Add a form-id="#" attribute to your shortcode. '. |
|
232 | + 'Replace # with the id of the form you want to use.', |
|
233 | + $result |
|
234 | + ); |
|
235 | + } |
|
236 | 236 | |
237 | - public function test_no_video_type_on_video_shortcode() |
|
238 | - { |
|
239 | - $result = do_shortcode("[mautic type='video' src='mavideo.mov' form-id='1']"); |
|
240 | - $this->assertEquals( |
|
241 | - 'Please define a valid video type with video-type="#".', |
|
242 | - $result |
|
243 | - ); |
|
244 | - } |
|
237 | + public function test_no_video_type_on_video_shortcode() |
|
238 | + { |
|
239 | + $result = do_shortcode("[mautic type='video' src='mavideo.mov' form-id='1']"); |
|
240 | + $this->assertEquals( |
|
241 | + 'Please define a valid video type with video-type="#".', |
|
242 | + $result |
|
243 | + ); |
|
244 | + } |
|
245 | 245 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | { |
219 | 219 | $result = do_shortcode("[mautic type='video']"); |
220 | 220 | $this->assertEquals( |
221 | - 'You must provide a video source. Add a src="URL" attribute to your shortcode. '. |
|
221 | + 'You must provide a video source. Add a src="URL" attribute to your shortcode. ' . |
|
222 | 222 | 'Replace URL with the source url for your video.', |
223 | 223 | $result |
224 | 224 | ); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | { |
229 | 229 | $result = do_shortcode("[mautic type='video' src='mavideo.mov']"); |
230 | 230 | $this->assertEquals( |
231 | - 'You must provide a mautic form id. Add a form-id="#" attribute to your shortcode. '. |
|
231 | + 'You must provide a mautic form id. Add a form-id="#" attribute to your shortcode. ' . |
|
232 | 232 | 'Replace # with the id of the form you want to use.', |
233 | 233 | $result |
234 | 234 | ); |
@@ -9,12 +9,12 @@ |
||
9 | 9 | |
10 | 10 | // Load plugin within wordpress. |
11 | 11 | $GLOBALS['wp_tests_options'] = array( |
12 | - 'active_plugins' => array( 'mautic-wordpress/wpmautic.php' ), |
|
12 | + 'active_plugins' => array('mautic-wordpress/wpmautic.php'), |
|
13 | 13 | ); |
14 | 14 | |
15 | 15 | // Allow to define where WordPress source is installed. |
16 | -if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) { |
|
17 | - require rtrim( getenv( 'WP_DEVELOP_DIR' ), DIRECTORY_SEPARATOR ) . '/tests/phpunit/includes/bootstrap.php'; |
|
16 | +if (false !== getenv('WP_DEVELOP_DIR')) { |
|
17 | + require rtrim(getenv('WP_DEVELOP_DIR'), DIRECTORY_SEPARATOR) . '/tests/phpunit/includes/bootstrap.php'; |
|
18 | 18 | // Or assert that we are inside WordPress plugins directory. |
19 | 19 | } else { |
20 | 20 | require __DIR__ . '/../../../../tests/phpunit/includes/bootstrap.php'; |
@@ -8,62 +8,62 @@ |
||
8 | 8 | */ |
9 | 9 | class OptionsValidationTest extends WP_UnitTestCase |
10 | 10 | { |
11 | - public function setUp() |
|
12 | - { |
|
13 | - parent::setUp(); |
|
14 | - require_once(VPMAUTIC_PLUGIN_DIR.'/options.php'); |
|
15 | - } |
|
11 | + public function setUp() |
|
12 | + { |
|
13 | + parent::setUp(); |
|
14 | + require_once(VPMAUTIC_PLUGIN_DIR.'/options.php'); |
|
15 | + } |
|
16 | 16 | |
17 | - public function test_validation_when_empty() |
|
18 | - { |
|
19 | - $options = wpmautic_options_validate(array()); |
|
20 | - $this->assertArrayHasKey('base_url', $options); |
|
21 | - $this->assertArrayHasKey('script_location', $options); |
|
22 | - $this->assertArrayHasKey('fallback_activated', $options); |
|
23 | - $this->assertEmpty($options['base_url']); |
|
24 | - $this->assertEquals('header', $options['script_location']); |
|
25 | - $this->assertFalse($options['fallback_activated']); |
|
26 | - } |
|
17 | + public function test_validation_when_empty() |
|
18 | + { |
|
19 | + $options = wpmautic_options_validate(array()); |
|
20 | + $this->assertArrayHasKey('base_url', $options); |
|
21 | + $this->assertArrayHasKey('script_location', $options); |
|
22 | + $this->assertArrayHasKey('fallback_activated', $options); |
|
23 | + $this->assertEmpty($options['base_url']); |
|
24 | + $this->assertEquals('header', $options['script_location']); |
|
25 | + $this->assertFalse($options['fallback_activated']); |
|
26 | + } |
|
27 | 27 | |
28 | - public function test_validation_with_invalid_script_location() |
|
29 | - { |
|
30 | - $options = wpmautic_options_validate(array( |
|
31 | - 'script_location' => 'toto' |
|
32 | - )); |
|
33 | - $this->assertEquals('header', $options['script_location']); |
|
34 | - } |
|
28 | + public function test_validation_with_invalid_script_location() |
|
29 | + { |
|
30 | + $options = wpmautic_options_validate(array( |
|
31 | + 'script_location' => 'toto' |
|
32 | + )); |
|
33 | + $this->assertEquals('header', $options['script_location']); |
|
34 | + } |
|
35 | 35 | |
36 | - public function test_validation_with_whitespaces_in_values() |
|
37 | - { |
|
38 | - $options = wpmautic_options_validate(array( |
|
39 | - 'base_url' => ' http://example.com ', |
|
40 | - 'script_location' => ' footer ' |
|
41 | - )); |
|
42 | - $this->assertEquals('http://example.com', $options['base_url']); |
|
43 | - $this->assertEquals('footer', $options['script_location']); |
|
44 | - } |
|
36 | + public function test_validation_with_whitespaces_in_values() |
|
37 | + { |
|
38 | + $options = wpmautic_options_validate(array( |
|
39 | + 'base_url' => ' http://example.com ', |
|
40 | + 'script_location' => ' footer ' |
|
41 | + )); |
|
42 | + $this->assertEquals('http://example.com', $options['base_url']); |
|
43 | + $this->assertEquals('footer', $options['script_location']); |
|
44 | + } |
|
45 | 45 | |
46 | - public function test_validation_with_invalid_url() |
|
47 | - { |
|
48 | - $options = wpmautic_options_validate(array( |
|
49 | - 'base_url' => 'url' |
|
50 | - )); |
|
51 | - $this->assertEquals('http://url', $options['base_url']); |
|
52 | - } |
|
46 | + public function test_validation_with_invalid_url() |
|
47 | + { |
|
48 | + $options = wpmautic_options_validate(array( |
|
49 | + 'base_url' => 'url' |
|
50 | + )); |
|
51 | + $this->assertEquals('http://url', $options['base_url']); |
|
52 | + } |
|
53 | 53 | |
54 | - public function test_validation_with_invalid_fallback_activated() |
|
55 | - { |
|
56 | - $options = wpmautic_options_validate(array( |
|
57 | - 'fallback_activated' => 'toto' |
|
58 | - )); |
|
59 | - $this->assertFalse($options['fallback_activated']); |
|
60 | - } |
|
54 | + public function test_validation_with_invalid_fallback_activated() |
|
55 | + { |
|
56 | + $options = wpmautic_options_validate(array( |
|
57 | + 'fallback_activated' => 'toto' |
|
58 | + )); |
|
59 | + $this->assertFalse($options['fallback_activated']); |
|
60 | + } |
|
61 | 61 | |
62 | - public function test_validation_with_valid_fallback_activated() |
|
63 | - { |
|
64 | - $options = wpmautic_options_validate(array( |
|
65 | - 'fallback_activated' => '1' |
|
66 | - )); |
|
67 | - $this->assertTrue($options['fallback_activated']); |
|
68 | - } |
|
62 | + public function test_validation_with_valid_fallback_activated() |
|
63 | + { |
|
64 | + $options = wpmautic_options_validate(array( |
|
65 | + 'fallback_activated' => '1' |
|
66 | + )); |
|
67 | + $this->assertTrue($options['fallback_activated']); |
|
68 | + } |
|
69 | 69 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | public function setUp() |
12 | 12 | { |
13 | 13 | parent::setUp(); |
14 | - require_once(VPMAUTIC_PLUGIN_DIR.'/options.php'); |
|
14 | + require_once(VPMAUTIC_PLUGIN_DIR . '/options.php'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | public function test_validation_when_empty() |
@@ -8,46 +8,46 @@ |
||
8 | 8 | */ |
9 | 9 | class PluginTest extends WP_UnitTestCase |
10 | 10 | { |
11 | - public function test_plugin_is_loaded() |
|
12 | - { |
|
13 | - $active = get_option( 'active_plugins', array() ); |
|
14 | - $this->assertContains('mautic-wordpress/wpmautic.php', $active); |
|
15 | - |
|
16 | - $this->assertTrue(function_exists('wpmautic_option')); |
|
17 | - $this->assertTrue(function_exists('wpmautic_inject_script')); |
|
18 | - } |
|
19 | - |
|
20 | - public function test_action_loaded() |
|
21 | - { |
|
22 | - $this->assertTrue(false !== has_action('admin_menu', 'wpmautic_settings')); |
|
23 | - $this->assertTrue(false !== has_action('plugins_loaded', 'wpmautic_injector')); |
|
24 | - } |
|
25 | - |
|
26 | - public function test_filter_loaded() |
|
27 | - { |
|
28 | - $this->assertTrue(false !== has_filter('plugin_action_links', 'wpmautic_plugin_actions')); |
|
29 | - } |
|
30 | - |
|
31 | - public function test_settings_link_is_present() |
|
32 | - { |
|
33 | - $links = apply_filters('plugin_action_links', array(), 'mautic-wordpress/wpmautic.php'); |
|
34 | - |
|
35 | - $this->assertCount(1, $links); |
|
36 | - $this->assertContains('options-general.php?page=wpmautic', $links[0]); |
|
37 | - } |
|
38 | - |
|
39 | - public function test_option_page_is_loaded() |
|
40 | - { |
|
41 | - $current_user = get_current_user_id(); |
|
42 | - wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
|
43 | - |
|
44 | - $this->assertEmpty(menu_page_url('wpmautic', false)); |
|
45 | - wpmautic_settings(); |
|
46 | - $this->assertEquals( |
|
47 | - admin_url( 'options-general.php?page=wpmautic' ), |
|
48 | - menu_page_url('wpmautic', false) |
|
49 | - ); |
|
50 | - |
|
51 | - wp_set_current_user( $current_user ); |
|
52 | - } |
|
11 | + public function test_plugin_is_loaded() |
|
12 | + { |
|
13 | + $active = get_option( 'active_plugins', array() ); |
|
14 | + $this->assertContains('mautic-wordpress/wpmautic.php', $active); |
|
15 | + |
|
16 | + $this->assertTrue(function_exists('wpmautic_option')); |
|
17 | + $this->assertTrue(function_exists('wpmautic_inject_script')); |
|
18 | + } |
|
19 | + |
|
20 | + public function test_action_loaded() |
|
21 | + { |
|
22 | + $this->assertTrue(false !== has_action('admin_menu', 'wpmautic_settings')); |
|
23 | + $this->assertTrue(false !== has_action('plugins_loaded', 'wpmautic_injector')); |
|
24 | + } |
|
25 | + |
|
26 | + public function test_filter_loaded() |
|
27 | + { |
|
28 | + $this->assertTrue(false !== has_filter('plugin_action_links', 'wpmautic_plugin_actions')); |
|
29 | + } |
|
30 | + |
|
31 | + public function test_settings_link_is_present() |
|
32 | + { |
|
33 | + $links = apply_filters('plugin_action_links', array(), 'mautic-wordpress/wpmautic.php'); |
|
34 | + |
|
35 | + $this->assertCount(1, $links); |
|
36 | + $this->assertContains('options-general.php?page=wpmautic', $links[0]); |
|
37 | + } |
|
38 | + |
|
39 | + public function test_option_page_is_loaded() |
|
40 | + { |
|
41 | + $current_user = get_current_user_id(); |
|
42 | + wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
|
43 | + |
|
44 | + $this->assertEmpty(menu_page_url('wpmautic', false)); |
|
45 | + wpmautic_settings(); |
|
46 | + $this->assertEquals( |
|
47 | + admin_url( 'options-general.php?page=wpmautic' ), |
|
48 | + menu_page_url('wpmautic', false) |
|
49 | + ); |
|
50 | + |
|
51 | + wp_set_current_user( $current_user ); |
|
52 | + } |
|
53 | 53 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | { |
11 | 11 | public function test_plugin_is_loaded() |
12 | 12 | { |
13 | - $active = get_option( 'active_plugins', array() ); |
|
13 | + $active = get_option('active_plugins', array()); |
|
14 | 14 | $this->assertContains('mautic-wordpress/wpmautic.php', $active); |
15 | 15 | |
16 | 16 | $this->assertTrue(function_exists('wpmautic_option')); |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | public function test_option_page_is_loaded() |
40 | 40 | { |
41 | 41 | $current_user = get_current_user_id(); |
42 | - wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
|
42 | + wp_set_current_user(self::factory()->user->create(array('role' => 'administrator'))); |
|
43 | 43 | |
44 | 44 | $this->assertEmpty(menu_page_url('wpmautic', false)); |
45 | 45 | wpmautic_settings(); |
46 | 46 | $this->assertEquals( |
47 | - admin_url( 'options-general.php?page=wpmautic' ), |
|
47 | + admin_url('options-general.php?page=wpmautic'), |
|
48 | 48 | menu_page_url('wpmautic', false) |
49 | 49 | ); |
50 | 50 | |
51 | - wp_set_current_user( $current_user ); |
|
51 | + wp_set_current_user($current_user); |
|
52 | 52 | } |
53 | 53 | } |