@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function __construct() { |
| 38 | 38 | |
| 39 | - // Populate $notices |
|
| 40 | - $this->notices = get_option( 'monsterinsights_notices' ); |
|
| 41 | - if ( ! is_array( $this->notices ) ) { |
|
| 42 | - $this->notices = array(); |
|
| 43 | - } |
|
| 39 | + // Populate $notices |
|
| 40 | + $this->notices = get_option( 'monsterinsights_notices' ); |
|
| 41 | + if ( ! is_array( $this->notices ) ) { |
|
| 42 | + $this->notices = array(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | |
| 57 | 57 | public function is_dismissed( $notice ) { |
| 58 | - if ( ! isset( $this->notices[ $notice ] ) ) { |
|
| 59 | - return false; |
|
| 60 | - } |
|
| 61 | - return true; |
|
| 58 | + if ( ! isset( $this->notices[ $notice ] ) ) { |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 61 | + return true; |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | * @return null |
| 73 | 73 | */ |
| 74 | 74 | public function dismiss( $notice ) { |
| 75 | - $this->notices[ $notice ] = true; |
|
| 76 | - update_option( 'monsterinsights_notices', $this->notices ); |
|
| 75 | + $this->notices[ $notice ] = true; |
|
| 76 | + update_option( 'monsterinsights_notices', $this->notices ); |
|
| 77 | 77 | |
| 78 | 78 | } |
| 79 | 79 | |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | * @return null |
| 89 | 89 | */ |
| 90 | 90 | public function undismiss( $notice ) { |
| 91 | - unset( $this->notices[ $notice ] ); |
|
| 92 | - update_option( 'monsterinsights_notices', $this->notices ); |
|
| 91 | + unset( $this->notices[ $notice ] ); |
|
| 92 | + update_option( 'monsterinsights_notices', $this->notices ); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param bool $is_dismissible User can Dismiss Message (default: false) |
| 109 | 109 | */ |
| 110 | 110 | public function display_inline_notice( $name, $title, $message, $type = 'success', $is_dismissible = false, $args = array() ) { |
| 111 | - /* Available/Planned $args options |
|
| 111 | + /* Available/Planned $args options |
|
| 112 | 112 | * $args = array( |
| 113 | 113 | * 'primary' => array( |
| 114 | 114 | * 'text' => '', |
@@ -127,110 +127,110 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | |
| 129 | 129 | |
| 130 | - // Check if the notice is dismissible, and if so has been dismissed. |
|
| 131 | - if ( $is_dismissible && $this->is_dismissed( $name ) ) { |
|
| 132 | - // Nothing to show here, return! |
|
| 133 | - return ''; |
|
| 134 | - } |
|
| 130 | + // Check if the notice is dismissible, and if so has been dismissed. |
|
| 131 | + if ( $is_dismissible && $this->is_dismissed( $name ) ) { |
|
| 132 | + // Nothing to show here, return! |
|
| 133 | + return ''; |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - $dismissible = ( $is_dismissible ) ? ' is-dismissible': ''; |
|
| 136 | + $dismissible = ( $is_dismissible ) ? ' is-dismissible': ''; |
|
| 137 | 137 | |
| 138 | - // Display inline notice |
|
| 139 | - ob_start(); |
|
| 140 | - ?> |
|
| 138 | + // Display inline notice |
|
| 139 | + ob_start(); |
|
| 140 | + ?> |
|
| 141 | 141 | <div class="monsterinsights-notice <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice' . $dismissible; ?>" data-notice="<?php echo esc_attr( $name ); ?>"> |
| 142 | 142 | <div class="monsterinsights-notice-icon <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-icon'?>"> |
| 143 | 143 | </div> |
| 144 | 144 | <div class="monsterinsights-notice-text <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-text'?>"> |
| 145 | 145 | <?php |
| 146 | - // Title |
|
| 147 | - if ( ! empty ( $title ) ) { |
|
| 148 | - ?> |
|
| 146 | + // Title |
|
| 147 | + if ( ! empty ( $title ) ) { |
|
| 148 | + ?> |
|
| 149 | 149 | <p class="monsterinsights-notice-title"><?php echo esc_html( $title ); ?></p> |
| 150 | 150 | <?php |
| 151 | - } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - // Message |
|
| 154 | - if ( ! empty( $message ) ) { |
|
| 155 | - if ( empty( $args['skip_message_escape'] ) ) { |
|
| 156 | - ?> |
|
| 153 | + // Message |
|
| 154 | + if ( ! empty( $message ) ) { |
|
| 155 | + if ( empty( $args['skip_message_escape'] ) ) { |
|
| 156 | + ?> |
|
| 157 | 157 | <p class="monsterinsights-notice-message"><?php echo esc_html( $message ); ?></p> |
| 158 | 158 | <?php |
| 159 | - } else { |
|
| 160 | - ?> |
|
| 159 | + } else { |
|
| 160 | + ?> |
|
| 161 | 161 | <p class="monsterinsights-notice-message"><?php echo $message; ?></p> |
| 162 | 162 | <?php |
| 163 | - } |
|
| 164 | - } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - // Primary Button |
|
| 167 | - if ( ! empty( $args['primary']['text'] ) ) { |
|
| 166 | + // Primary Button |
|
| 167 | + if ( ! empty( $args['primary']['text'] ) ) { |
|
| 168 | 168 | |
| 169 | - $text = ''; |
|
| 170 | - if ( ! empty( $args['primary']['text'] ) ) { |
|
| 171 | - $text = $args['primary']['text']; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - $url = '#'; |
|
| 175 | - if ( ! empty( $args['primary']['url'] ) ) { |
|
| 176 | - $url = $args['primary']['url']; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - $target = ''; |
|
| 180 | - if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') { |
|
| 181 | - $target = ' target="_blank" rel="noopener noreferrer"'; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $class = 'button button-primary'; |
|
| 185 | - if ( ! empty( $args['primary']['class'] ) ) { |
|
| 186 | - $class = ' class="'. $args['primary']['class'] . '"'; |
|
| 187 | - } |
|
| 188 | - ?> |
|
| 169 | + $text = ''; |
|
| 170 | + if ( ! empty( $args['primary']['text'] ) ) { |
|
| 171 | + $text = $args['primary']['text']; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + $url = '#'; |
|
| 175 | + if ( ! empty( $args['primary']['url'] ) ) { |
|
| 176 | + $url = $args['primary']['url']; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + $target = ''; |
|
| 180 | + if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') { |
|
| 181 | + $target = ' target="_blank" rel="noopener noreferrer"'; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $class = 'button button-primary'; |
|
| 185 | + if ( ! empty( $args['primary']['class'] ) ) { |
|
| 186 | + $class = ' class="'. $args['primary']['class'] . '"'; |
|
| 187 | + } |
|
| 188 | + ?> |
|
| 189 | 189 | <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a> |
| 190 | 190 | <?php |
| 191 | - } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - // Secondary Button |
|
| 194 | - if ( ! empty( $args['secondary']['text'] ) ) { |
|
| 193 | + // Secondary Button |
|
| 194 | + if ( ! empty( $args['secondary']['text'] ) ) { |
|
| 195 | 195 | |
| 196 | - $text = ''; |
|
| 197 | - if ( ! empty( $args['secondary']['text'] ) ) { |
|
| 198 | - $text = $args['secondary']['text']; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - $url = '#'; |
|
| 202 | - if ( ! empty( $args['secondary']['url'] ) ) { |
|
| 203 | - $url = $args['secondary']['url']; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - $target = ''; |
|
| 207 | - if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') { |
|
| 208 | - $target = ' target="_blank" rel="noopener noreferrer"'; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - $class = 'button button-secondary'; |
|
| 212 | - if ( ! empty( $args['secondary']['class'] ) ) { |
|
| 213 | - $class = ' class="'. $args['secondary']['class'] . '"'; |
|
| 214 | - } |
|
| 215 | - ?> |
|
| 196 | + $text = ''; |
|
| 197 | + if ( ! empty( $args['secondary']['text'] ) ) { |
|
| 198 | + $text = $args['secondary']['text']; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + $url = '#'; |
|
| 202 | + if ( ! empty( $args['secondary']['url'] ) ) { |
|
| 203 | + $url = $args['secondary']['url']; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + $target = ''; |
|
| 207 | + if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') { |
|
| 208 | + $target = ' target="_blank" rel="noopener noreferrer"'; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + $class = 'button button-secondary'; |
|
| 212 | + if ( ! empty( $args['secondary']['class'] ) ) { |
|
| 213 | + $class = ' class="'. $args['secondary']['class'] . '"'; |
|
| 214 | + } |
|
| 215 | + ?> |
|
| 216 | 216 | <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a> |
| 217 | 217 | <?php |
| 218 | - } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - // Dismiss Button |
|
| 221 | - if ( $is_dismissible ) { |
|
| 222 | - ?> |
|
| 220 | + // Dismiss Button |
|
| 221 | + if ( $is_dismissible ) { |
|
| 222 | + ?> |
|
| 223 | 223 | <button type="button" class="notice-dismiss<?php echo $dismissible; ?>"> |
| 224 | 224 | <span class="screen-reader-text"> |
| 225 | 225 | <?php esc_html_e( 'Dismiss this notice', 'google-analytics-for-wordpress' ); ?> |
| 226 | 226 | </span> |
| 227 | 227 | </button> |
| 228 | 228 | <?php |
| 229 | - } |
|
| 230 | - ?> |
|
| 229 | + } |
|
| 230 | + ?> |
|
| 231 | 231 | </div> |
| 232 | 232 | </div> |
| 233 | 233 | <?php |
| 234 | - return ob_get_clean(); |
|
| 234 | + return ob_get_clean(); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function __construct( $args = array() ) { |
| 27 | 27 | |
| 28 | - parent::__construct(); |
|
| 28 | + parent::__construct(); |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function set_upgrader( &$upgrader ) { |
| 40 | 40 | |
| 41 | - if ( is_object( $upgrader ) ) { |
|
| 42 | - $this->upgrader =& $upgrader; |
|
| 43 | - } |
|
| 41 | + if ( is_object( $upgrader ) ) { |
|
| 42 | + $this->upgrader =& $upgrader; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function set_result( $result ) { |
| 55 | 55 | |
| 56 | - $this->result = $result; |
|
| 56 | + $this->result = $result; |
|
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | function error( $errors ) { |
| 84 | 84 | |
| 85 | - if ( ! empty( $errors ) ) { |
|
| 86 | - echo json_encode( array( 'error' => esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' ) ) ); |
|
| 87 | - die; |
|
| 88 | - } |
|
| 85 | + if ( ! empty( $errors ) ) { |
|
| 86 | + echo json_encode( array( 'error' => esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' ) ) ); |
|
| 87 | + die; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | } |
| 91 | 91 | |
@@ -13,20 +13,20 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | // If this is multisite and is not on the main site, return early. |
| 15 | 15 | if ( is_multisite() && ! is_main_site() ) { |
| 16 | - return $update; |
|
| 16 | + return $update; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | // If we don't have everything we need, return early. |
| 20 | 20 | $item = (array) $item; |
| 21 | 21 | if ( ! isset( $item['new_version'] ) || ! isset( $item['slug'] ) ) { |
| 22 | - return $update; |
|
| 22 | + return $update; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | // If the plugin isn't ours, return early. |
| 26 | 26 | $is_free = 'google-analytics-for-wordpress' === $item['slug']; |
| 27 | 27 | $is_paid = isset( $item['monsterinsights_plugin'] ); // see updater class |
| 28 | 28 | if ( ! $is_free && ! $is_paid ) { |
| 29 | - return $update; |
|
| 29 | + return $update; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | $version = $is_free ? MONSTERINSIGHTS_LITE_VERSION : $item['old_version']; |
@@ -36,20 +36,20 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | // If the opt in update allows major updates but there is no major version update, return early. |
| 38 | 38 | if ( $current_major < $new_major ) { |
| 39 | - if ( $automatic_updates === 'all' ) { |
|
| 40 | - return true; |
|
| 41 | - } else { |
|
| 42 | - return $update; |
|
| 43 | - } |
|
| 39 | + if ( $automatic_updates === 'all' ) { |
|
| 40 | + return true; |
|
| 41 | + } else { |
|
| 42 | + return $update; |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // If the opt in update allows minor updates but there is no minor version update, return early. |
| 47 | 47 | if ( $current_major == $new_major ) { |
| 48 | - if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) { |
|
| 49 | - return true; |
|
| 50 | - } else { |
|
| 51 | - return $update; |
|
| 52 | - } |
|
| 48 | + if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) { |
|
| 49 | + return true; |
|
| 50 | + } else { |
|
| 51 | + return $update; |
|
| 52 | + } |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // All our checks have passed - this plugin can be updated! |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | function monsterinsights_get_major_version( $version ) { |
| 88 | 88 | $exploded_version = explode( '.', $version ); |
| 89 | 89 | if ( isset( $exploded_version[2] ) ) { |
| 90 | - return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2]; |
|
| 90 | + return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2]; |
|
| 91 | 91 | } else { |
| 92 | - return $exploded_version[0] . '.' . $exploded_version[1] . '.0'; |
|
| 92 | + return $exploded_version[0] . '.' . $exploded_version[1] . '.0'; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | \ No newline at end of file |
@@ -195,14 +195,14 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | - * Helper method for deleting a setting's value. |
|
| 199 | - * |
|
| 200 | - * @since 6.0.0 |
|
| 201 | - * @access public |
|
| 202 | - * |
|
| 203 | - * @param string $key The setting key. |
|
| 204 | - * @return boolean True if removed, false if not. |
|
| 205 | - */ |
|
| 198 | + * Helper method for deleting a setting's value. |
|
| 199 | + * |
|
| 200 | + * @since 6.0.0 |
|
| 201 | + * @access public |
|
| 202 | + * |
|
| 203 | + * @param string $key The setting key. |
|
| 204 | + * @return boolean True if removed, false if not. |
|
| 205 | + */ |
|
| 206 | 206 | function monsterinsights_delete_option( $key = '' ) { |
| 207 | 207 | // If no key, exit |
| 208 | 208 | if ( empty( $key ) ){ |
@@ -245,14 +245,14 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | - * Helper method for deleting multiple settings value. |
|
| 249 | - * |
|
| 250 | - * @since 6.0.0 |
|
| 251 | - * @access public |
|
| 252 | - * |
|
| 253 | - * @param string $key The setting key. |
|
| 254 | - * @return boolean True if removed, false if not. |
|
| 255 | - */ |
|
| 248 | + * Helper method for deleting multiple settings value. |
|
| 249 | + * |
|
| 250 | + * @since 6.0.0 |
|
| 251 | + * @access public |
|
| 252 | + * |
|
| 253 | + * @param string $key The setting key. |
|
| 254 | + * @return boolean True if removed, false if not. |
|
| 255 | + */ |
|
| 256 | 256 | function monsterinsights_delete_options( $keys = array() ) { |
| 257 | 257 | // If no keys, exit |
| 258 | 258 | if ( empty( $keys ) || ! is_array( $keys ) ){ |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @return array Array of the options to use. |
| 59 | 59 | */ |
| 60 | 60 | public function frontend_tracking_options( ) { |
| 61 | - return array(); |
|
| 61 | + return array(); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -74,6 +74,6 @@ discard block |
||
| 74 | 74 | * @return string Javascript to output. |
| 75 | 75 | */ |
| 76 | 76 | public function frontend_output( ) { |
| 77 | - return "<!-- MonsterInsights Abstract Tracking class -->"; |
|
| 77 | + return "<!-- MonsterInsights Abstract Tracking class -->"; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | \ No newline at end of file |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @return array Array of the options to use. |
| 58 | 58 | */ |
| 59 | 59 | public function frontend_tracking_options( ) { |
| 60 | - return array(); |
|
| 60 | + return array(); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | * @return string Javascript to output. |
| 74 | 74 | */ |
| 75 | 75 | public function frontend_output( ) { |
| 76 | - $output = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->'; |
|
| 77 | - $output .= '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->'; |
|
| 78 | - $output .= '<!-- / Google Analytics by MonsterInsights -->'; |
|
| 79 | - return $output; |
|
| 76 | + $output = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->'; |
|
| 77 | + $output .= '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->'; |
|
| 78 | + $output .= '<!-- / Google Analytics by MonsterInsights -->'; |
|
| 79 | + return $output; |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | \ No newline at end of file |
@@ -35,54 +35,54 @@ |
||
| 35 | 35 | function monsterinsights_add_capabilities( $caps, $cap, $user_id, $args ) { |
| 36 | 36 | |
| 37 | 37 | switch( $cap ) { |
| 38 | - case 'monsterinsights_view_dashboard' : |
|
| 39 | - $roles = monsterinsights_get_option( 'view_reports', array() ); |
|
| 38 | + case 'monsterinsights_view_dashboard' : |
|
| 39 | + $roles = monsterinsights_get_option( 'view_reports', array() ); |
|
| 40 | 40 | |
| 41 | - $user_can_via_settings = false; |
|
| 42 | - if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
| 43 | - foreach ( $roles as $role ) { |
|
| 44 | - if ( is_string( $role ) ) { |
|
| 45 | - if ( user_can( $user_id, $role ) ) { |
|
| 46 | - $user_can_via_settings = true; |
|
| 47 | - break; |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
|
| 52 | - if ( user_can( $user_id, $roles ) ) { |
|
| 53 | - $user_can_via_settings = true; |
|
| 54 | - } |
|
| 55 | - } |
|
| 41 | + $user_can_via_settings = false; |
|
| 42 | + if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
| 43 | + foreach ( $roles as $role ) { |
|
| 44 | + if ( is_string( $role ) ) { |
|
| 45 | + if ( user_can( $user_id, $role ) ) { |
|
| 46 | + $user_can_via_settings = true; |
|
| 47 | + break; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
|
| 52 | + if ( user_can( $user_id, $roles ) ) { |
|
| 53 | + $user_can_via_settings = true; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) { |
|
| 58 | - $caps = array(); |
|
| 59 | - } |
|
| 57 | + if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) { |
|
| 58 | + $caps = array(); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - break; |
|
| 62 | - case 'monsterinsights_save_settings' : |
|
| 63 | - $roles = monsterinsights_get_option( 'save_settings', array() ); |
|
| 61 | + break; |
|
| 62 | + case 'monsterinsights_save_settings' : |
|
| 63 | + $roles = monsterinsights_get_option( 'save_settings', array() ); |
|
| 64 | 64 | |
| 65 | - $user_can_via_settings = false; |
|
| 66 | - if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
| 67 | - foreach ( $roles as $role ) { |
|
| 68 | - if ( is_string( $role ) ) { |
|
| 69 | - if ( user_can( $user_id, $role ) ) { |
|
| 70 | - $user_can_via_settings = true; |
|
| 71 | - break; |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
|
| 76 | - if ( user_can( $user_id, $roles ) ) { |
|
| 77 | - $user_can_via_settings = true; |
|
| 78 | - } |
|
| 79 | - } |
|
| 65 | + $user_can_via_settings = false; |
|
| 66 | + if ( ! empty( $roles ) && is_array( $roles ) ) { |
|
| 67 | + foreach ( $roles as $role ) { |
|
| 68 | + if ( is_string( $role ) ) { |
|
| 69 | + if ( user_can( $user_id, $role ) ) { |
|
| 70 | + $user_can_via_settings = true; |
|
| 71 | + break; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } else if ( ! empty( $roles ) && is_string( $roles ) ) { |
|
| 76 | + if ( user_can( $user_id, $roles ) ) { |
|
| 77 | + $user_can_via_settings = true; |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) { |
|
| 82 | - $caps = array(); |
|
| 83 | - } |
|
| 81 | + if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) { |
|
| 82 | + $caps = array(); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - break; |
|
| 85 | + break; |
|
| 86 | 86 | } |
| 87 | 87 | return $caps; |
| 88 | 88 | } |
@@ -37,13 +37,13 @@ discard block |
||
| 37 | 37 | do_action( 'monsterinsights_tracking_before_' . $mode ); |
| 38 | 38 | do_action( 'monsterinsights_tracking_before', $mode ); |
| 39 | 39 | if ( $mode === 'preview' ) { |
| 40 | - require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-preview.php'; |
|
| 41 | - $tracking = new MonsterInsights_Tracking_Preview(); |
|
| 42 | - echo $tracking->frontend_output(); |
|
| 40 | + require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-preview.php'; |
|
| 41 | + $tracking = new MonsterInsights_Tracking_Preview(); |
|
| 42 | + echo $tracking->frontend_output(); |
|
| 43 | 43 | } else { |
| 44 | - require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-analytics.php'; |
|
| 45 | - $tracking = new MonsterInsights_Tracking_Analytics(); |
|
| 46 | - echo $tracking->frontend_output(); |
|
| 44 | + require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-analytics.php'; |
|
| 45 | + $tracking = new MonsterInsights_Tracking_Analytics(); |
|
| 46 | + echo $tracking->frontend_output(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | do_action( 'monsterinsights_tracking_after_' . $mode ); |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | $track_user = monsterinsights_track_user(); |
| 70 | 70 | |
| 71 | 71 | if ( $track_user && ( $events_mode === 'js' || $events_mode === 'php' ) ) { |
| 72 | - require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-analytics-events.php'; |
|
| 73 | - new MonsterInsights_Analytics_Events(); |
|
| 72 | + require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-analytics-events.php'; |
|
| 73 | + new MonsterInsights_Analytics_Events(); |
|
| 74 | 74 | } else { |
| 75 | - // User is in the disabled group or events mode is off |
|
| 75 | + // User is in the disabled group or events mode is off |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | add_action( 'template_redirect', 'monsterinsights_events_tracking', 9 ); |
@@ -91,17 +91,17 @@ discard block |
||
| 91 | 91 | global $post; |
| 92 | 92 | |
| 93 | 93 | if ( monsterinsights_get_option( 'tag_links_in_rss', false ) ){ |
| 94 | - if ( is_feed() ) { |
|
| 95 | - if ( monsterinsights_get_option( 'allow_anchor', false ) ) { |
|
| 96 | - $delimiter = '#'; |
|
| 97 | - } else { |
|
| 98 | - $delimiter = '?'; |
|
| 99 | - if ( strpos( $guid, $delimiter ) > 0 ) { |
|
| 100 | - $delimiter = '&'; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - return $guid . $delimiter . 'utm_source=rss&utm_medium=rss&utm_campaign=' . urlencode( $post->post_name ); |
|
| 104 | - } |
|
| 94 | + if ( is_feed() ) { |
|
| 95 | + if ( monsterinsights_get_option( 'allow_anchor', false ) ) { |
|
| 96 | + $delimiter = '#'; |
|
| 97 | + } else { |
|
| 98 | + $delimiter = '?'; |
|
| 99 | + if ( strpos( $guid, $delimiter ) > 0 ) { |
|
| 100 | + $delimiter = '&'; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + return $guid . $delimiter . 'utm_source=rss&utm_medium=rss&utm_campaign=' . urlencode( $post->post_name ); |
|
| 104 | + } |
|
| 105 | 105 | } |
| 106 | 106 | return $guid; |
| 107 | 107 | } |
@@ -51,60 +51,60 @@ discard block |
||
| 51 | 51 | check_ajax_referer( 'monsterinsights-install', 'nonce' ); |
| 52 | 52 | |
| 53 | 53 | if ( ! current_user_can( 'install_plugins' ) ) { |
| 54 | - echo json_encode( true ); |
|
| 54 | + echo json_encode( true ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // Install the addon. |
| 58 | 58 | if ( isset( $_POST['plugin'] ) ) { |
| 59 | - $download_url = $_POST['plugin']; |
|
| 60 | - global $hook_suffix; |
|
| 61 | - |
|
| 62 | - // Set the current screen to avoid undefined notices. |
|
| 63 | - set_current_screen(); |
|
| 64 | - |
|
| 65 | - // Prepare variables. |
|
| 66 | - $method = ''; |
|
| 67 | - $url = add_query_arg( |
|
| 68 | - array( |
|
| 69 | - 'page' => 'monsterinsights-settings' |
|
| 70 | - ), |
|
| 71 | - admin_url( 'admin.php' ) |
|
| 72 | - ); |
|
| 73 | - $url = esc_url( $url ); |
|
| 74 | - |
|
| 75 | - // Start output bufferring to catch the filesystem form if credentials are needed. |
|
| 76 | - ob_start(); |
|
| 77 | - if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) { |
|
| 78 | - $form = ob_get_clean(); |
|
| 79 | - echo json_encode( array( 'form' => $form ) ); |
|
| 80 | - wp_die(); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - // If we are not authenticated, make it happen now. |
|
| 84 | - if ( ! WP_Filesystem( $creds ) ) { |
|
| 85 | - ob_start(); |
|
| 86 | - request_filesystem_credentials( $url, $method, true, false, null ); |
|
| 87 | - $form = ob_get_clean(); |
|
| 88 | - echo json_encode( array( 'form' => $form ) ); |
|
| 89 | - wp_die(); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // We do not need any extra credentials if we have gotten this far, so let's install the plugin. |
|
| 93 | - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
| 94 | - $base = MonsterInsights(); |
|
| 95 | - require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php'; |
|
| 59 | + $download_url = $_POST['plugin']; |
|
| 60 | + global $hook_suffix; |
|
| 61 | + |
|
| 62 | + // Set the current screen to avoid undefined notices. |
|
| 63 | + set_current_screen(); |
|
| 64 | + |
|
| 65 | + // Prepare variables. |
|
| 66 | + $method = ''; |
|
| 67 | + $url = add_query_arg( |
|
| 68 | + array( |
|
| 69 | + 'page' => 'monsterinsights-settings' |
|
| 70 | + ), |
|
| 71 | + admin_url( 'admin.php' ) |
|
| 72 | + ); |
|
| 73 | + $url = esc_url( $url ); |
|
| 74 | + |
|
| 75 | + // Start output bufferring to catch the filesystem form if credentials are needed. |
|
| 76 | + ob_start(); |
|
| 77 | + if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) { |
|
| 78 | + $form = ob_get_clean(); |
|
| 79 | + echo json_encode( array( 'form' => $form ) ); |
|
| 80 | + wp_die(); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + // If we are not authenticated, make it happen now. |
|
| 84 | + if ( ! WP_Filesystem( $creds ) ) { |
|
| 85 | + ob_start(); |
|
| 86 | + request_filesystem_credentials( $url, $method, true, false, null ); |
|
| 87 | + $form = ob_get_clean(); |
|
| 88 | + echo json_encode( array( 'form' => $form ) ); |
|
| 89 | + wp_die(); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // We do not need any extra credentials if we have gotten this far, so let's install the plugin. |
|
| 93 | + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
| 94 | + $base = MonsterInsights(); |
|
| 95 | + require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php'; |
|
| 96 | 96 | |
| 97 | - // Create the plugin upgrader with our custom skin. |
|
| 98 | - $installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() ); |
|
| 99 | - $installer->install( $download_url ); |
|
| 100 | - |
|
| 101 | - // Flush the cache and return the newly installed plugin basename. |
|
| 102 | - wp_cache_flush(); |
|
| 103 | - if ( $installer->plugin_info() ) { |
|
| 104 | - $plugin_basename = $installer->plugin_info(); |
|
| 105 | - echo json_encode( array( 'plugin' => $plugin_basename ) ); |
|
| 106 | - wp_die(); |
|
| 107 | - } |
|
| 97 | + // Create the plugin upgrader with our custom skin. |
|
| 98 | + $installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() ); |
|
| 99 | + $installer->install( $download_url ); |
|
| 100 | + |
|
| 101 | + // Flush the cache and return the newly installed plugin basename. |
|
| 102 | + wp_cache_flush(); |
|
| 103 | + if ( $installer->plugin_info() ) { |
|
| 104 | + $plugin_basename = $installer->plugin_info(); |
|
| 105 | + echo json_encode( array( 'plugin' => $plugin_basename ) ); |
|
| 106 | + wp_die(); |
|
| 107 | + } |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | // Send back a response. |
@@ -126,21 +126,21 @@ discard block |
||
| 126 | 126 | check_ajax_referer( 'monsterinsights-activate', 'nonce' ); |
| 127 | 127 | |
| 128 | 128 | if ( ! current_user_can( 'activate_plugins' ) ) { |
| 129 | - echo json_encode( true ); |
|
| 129 | + echo json_encode( true ); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // Activate the addon. |
| 133 | 133 | if ( isset( $_POST['plugin'] ) ) { |
| 134 | - if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) { |
|
| 135 | - $activate = activate_plugin( $_POST['plugin'], NULL, true ); |
|
| 136 | - } else { |
|
| 137 | - $activate = activate_plugin( $_POST['plugin'] ); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - if ( is_wp_error( $activate ) ) { |
|
| 141 | - echo json_encode( array( 'error' => $activate->get_error_message() ) ); |
|
| 142 | - wp_die(); |
|
| 143 | - } |
|
| 134 | + if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) { |
|
| 135 | + $activate = activate_plugin( $_POST['plugin'], NULL, true ); |
|
| 136 | + } else { |
|
| 137 | + $activate = activate_plugin( $_POST['plugin'] ); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + if ( is_wp_error( $activate ) ) { |
|
| 141 | + echo json_encode( array( 'error' => $activate->get_error_message() ) ); |
|
| 142 | + wp_die(); |
|
| 143 | + } |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | echo json_encode( true ); |
@@ -161,16 +161,16 @@ discard block |
||
| 161 | 161 | check_ajax_referer( 'monsterinsights-deactivate', 'nonce' ); |
| 162 | 162 | |
| 163 | 163 | if ( ! current_user_can( 'activate_plugins' ) ) { |
| 164 | - echo json_encode( true ); |
|
| 164 | + echo json_encode( true ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // Deactivate the addon. |
| 168 | 168 | if ( isset( $_POST['plugin'] ) ) { |
| 169 | - if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) { |
|
| 170 | - $deactivate = deactivate_plugins( $_POST['plugin'], false, true ); |
|
| 171 | - } else { |
|
| 172 | - $deactivate = deactivate_plugins( $_POST['plugin'] ); |
|
| 173 | - } |
|
| 169 | + if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) { |
|
| 170 | + $deactivate = deactivate_plugins( $_POST['plugin'], false, true ); |
|
| 171 | + } else { |
|
| 172 | + $deactivate = deactivate_plugins( $_POST['plugin'] ); |
|
| 173 | + } |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | echo json_encode( true ); |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | // Deactivate the notice |
| 195 | 195 | if ( isset( $_POST['notice'] ) ) { |
| 196 | - // Init the notice class and mark notice as deactivated |
|
| 197 | - MonsterInsights()->notices->dismiss( $_POST['notice'] ); |
|
| 196 | + // Init the notice class and mark notice as deactivated |
|
| 197 | + MonsterInsights()->notices->dismiss( $_POST['notice'] ); |
|
| 198 | 198 | |
| 199 | - // Return true |
|
| 200 | - echo json_encode( true ); |
|
| 201 | - wp_die(); |
|
| 199 | + // Return true |
|
| 200 | + echo json_encode( true ); |
|
| 201 | + wp_die(); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // If here, an error occurred |