Skip to content

Commit 2546a1d

Browse files
author
Chris Gårdenberg
committed
fix: Perform fixes required for getting the plugin to pass through the review
1 parent 95f1ef9 commit 2546a1d

6 files changed

Lines changed: 62 additions & 44 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Contributors: mnchga
33
Tags: booking, participants, courses, events, eduadmin, lega online, google, analytics, tag manager
44
Requires at least: 5.8
5-
Tested up to: 6.0
5+
Tested up to: 6.4
66
Stable tag: 1.0.0
77
Requires PHP: 7.0
88
License: GPL3
@@ -14,3 +14,10 @@ This plugin adds support for Google Analytics / Tag Manager to your EduAdmin plu
1414
# EduAdmin - Google Analytics / Tag Manager WordPress
1515

1616
This plugin adds support for Google Analytics / Tag Manager to your [EduAdmin-Wordpress plugin](https://github.com/MultinetInteractive/EduAdmin-WordPress).
17+
18+
The plugin will add javascript to your website that will send events to Google Analytics / Tag Manager when a user interacts with the booking form.
19+
20+
The domain of the javascript will be from https://www.googletagmanager.com, and you can find their terms of service here:
21+
https://www.google.com/analytics/terms/tag-manager/
22+
23+
This plugin requires that you're using the [EduAdmin-Wordpress plugin](https://wordpress.org/plugins/eduadmin-booking/)

class/class-edu-google.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
defined( 'ABSPATH' ) or die( 'This plugin must be run within the scope of WordPress.' );
33

4-
if ( ! class_exists( 'EDU_Google' ) ) {
5-
class EDU_Google extends EDU_Integration {
4+
if ( ! class_exists( 'EDUGTAG_Google' ) ) {
5+
class EDUGTAG_Google extends EDU_Integration {
66
/**
77
* Constructor
88
*/
@@ -136,7 +136,7 @@ public function track_list_course_view( $courses ) {
136136
<script type="text/javascript">gtag('event', 'view_item_list', {
137137
'item_list_id': 'course_list',
138138
'item_list_name': 'Course list',
139-
'items': <?php echo json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
139+
'items': <?php echo wp_json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
140140
<?php
141141
}
142142
}
@@ -161,7 +161,7 @@ public function track_list_event_view( $events ) {
161161
<script type="text/javascript">gtag('event', 'view_item_list', {
162162
'item_list_id': 'event_list',
163163
'item_list_name': 'Event list',
164-
'items': <?php echo json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
164+
'items': <?php echo wp_json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
165165
<?php
166166
}
167167
}
@@ -183,7 +183,7 @@ public function track_detail_view( $course_template ) {
183183
if ( count( $gtag_items ) > 0 ) {
184184
?>
185185
<script type="text/javascript">gtag('event', 'view_item', {
186-
'items': <?php echo json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
186+
'items': <?php echo wp_json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
187187
<?php
188188
}
189189
}
@@ -203,7 +203,7 @@ public function track_programme_detail_view( $programme ) {
203203
if ( count( $gtag_items ) > 0 ) {
204204
?>
205205
<script type="text/javascript">gtag('event', 'view_item', {
206-
'items': <?php echo json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
206+
'items': <?php echo wp_json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
207207
<?php
208208
}
209209
}
@@ -225,7 +225,7 @@ public function track_booking_view( $course_template ) {
225225
if ( count( $gtag_items ) > 0 ) {
226226
?>
227227
<script type="text/javascript">gtag('event', 'begin_checkout', {
228-
'items': <?php echo json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
228+
'items': <?php echo wp_json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
229229
<?php
230230
}
231231
}
@@ -245,7 +245,7 @@ public function track_programme_booking_view( $programme ) {
245245
if ( count( $gtag_items ) > 0 ) {
246246
?>
247247
<script type="text/javascript">gtag('event', 'begin_checkout', {
248-
'items': <?php echo json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
248+
'items': <?php echo wp_json_encode( $gtag_items, JSON_PRETTY_PRINT ); ?> });</script>
249249
<?php
250250
}
251251
}
@@ -313,7 +313,7 @@ public function track_booking_completed( $booking_info ) {
313313
'currency': '<?php echo esc_js( $currency ); ?>',
314314
'value': <?php echo esc_js( $booking_info["TotalPriceExVat"] ); ?>,
315315
'tax': <?php echo esc_js( $booking_info["VatSum"] ); ?>,
316-
'items': <?php echo json_encode( $order_rows, JSON_PRETTY_PRINT ); ?>
316+
'items': <?php echo wp_json_encode( $order_rows, JSON_PRETTY_PRINT ); ?>
317317
});</script>
318318
<?php
319319
}

eduadmin-google.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* GitHub Plugin URI: multinetinteractive/eduadmin-google
1111
* GitHub Plugin URI: https://github.com/multinetinteractive/eduadmin-google
1212
* Requires at least: 5.8
13-
* Tested up to: 6.0
13+
* Tested up to: 6.4
1414
* Author: Chris Gårdenberg, MultiNet Interactive AB
1515
* Author URI: https://www.multinet.com
1616
* License: GPL3
@@ -35,26 +35,28 @@
3535
along with this program. If not, see <http://www.gnu.org/licenses/>.
3636
*/
3737

38-
add_action( 'admin_init', 'checkForEduAdminPlugin' );
39-
function checkForEduAdminPlugin() {
40-
if ( is_admin() && current_user_can( 'activate_plugins' ) && ( ! is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) {
41-
add_action( 'admin_notices', function () {
42-
?>
43-
<div class="error">
44-
<p><?php _e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-google' ); ?></p>
45-
</div><?php
46-
} );
47-
deactivate_plugins( plugin_basename( __FILE__ ) );
38+
if ( ! function_exists( 'EDUGTAG_checkForEduAdminPlugin' ) ) {
39+
add_action( 'admin_init', 'EDUGTAG_checkForEduAdminPlugin' );
40+
function EDUGTAG_checkForEduAdminPlugin() {
41+
if ( is_admin() && current_user_can( 'activate_plugins' ) && ( ! is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) {
42+
add_action( 'admin_notices', function () {
43+
?>
44+
<div class="error">
45+
<p><?php esc_html_e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-google' ); ?></p>
46+
</div><?php
47+
} );
48+
deactivate_plugins( plugin_basename( __FILE__ ) );
4849

49-
if ( isset( $_GET['activate'] ) ) {
50-
unset( $_GET['activate'] );
50+
if ( isset( $_GET['activate'] ) ) {
51+
unset( $_GET['activate'] );
52+
}
5153
}
5254
}
5355
}
5456

55-
if ( ! class_exists( 'EDU_Google_Loader' ) ):
57+
if ( ! class_exists( 'EDUGTAG_Google_Loader' ) ):
5658

57-
final class EDU_Google_Loader {
59+
final class EDUGTAG_Google_Loader {
5860
public function __construct() {
5961
add_action( 'plugins_loaded', array( $this, 'init' ) );
6062
}
@@ -68,11 +70,11 @@ public function init() {
6870
}
6971

7072
public function add_integration( $integrations ) {
71-
$integrations[] = 'EDU_Google';
73+
$integrations[] = 'EDUGTAG_Google';
7274

7375
return $integrations;
7476
}
7577
}
7678

77-
$edu_sveawebpay_loader = new EDU_Google_Loader( __FILE__ );
79+
$edu_google_loader = new EDUGTAG_Google_Loader( __FILE__ );
7880
endif;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"config": {
1414
"eduadmin": {
15-
"testedUpTo": "6.0",
15+
"testedUpTo": "6.4",
1616
"requiresAtLeast": "5.8",
1717
"minimumPhpVersion": "7.0"
1818
}

src/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ This plugin adds support for Google Analytics / Tag Manager to your EduAdmin plu
1414
# EduAdmin - Google Analytics / Tag Manager WordPress
1515

1616
This plugin adds support for Google Analytics / Tag Manager to your [EduAdmin-Wordpress plugin](https://github.com/MultinetInteractive/EduAdmin-WordPress).
17+
18+
The plugin will add javascript to your website that will send events to Google Analytics / Tag Manager when a user interacts with the booking form.
19+
20+
The domain of the javascript will be from https://www.googletagmanager.com, and you can find their terms of service here:
21+
https://www.google.com/analytics/terms/tag-manager/
22+
23+
This plugin requires that you're using the [EduAdmin-Wordpress plugin](https://wordpress.org/plugins/eduadmin-booking/)

src/eduadmin-google.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,28 @@
3535
along with this program. If not, see <http://www.gnu.org/licenses/>.
3636
*/
3737

38-
add_action( 'admin_init', 'checkForEduAdminPlugin' );
39-
function checkForEduAdminPlugin() {
40-
if ( is_admin() && current_user_can( 'activate_plugins' ) && ( ! is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) {
41-
add_action( 'admin_notices', function () {
42-
?>
43-
<div class="error">
44-
<p><?php _e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-google' ); ?></p>
45-
</div><?php
46-
} );
47-
deactivate_plugins( plugin_basename( __FILE__ ) );
38+
if ( ! function_exists( 'EDUGTAG_checkForEduAdminPlugin' ) ) {
39+
add_action( 'admin_init', 'EDUGTAG_checkForEduAdminPlugin' );
40+
function EDUGTAG_checkForEduAdminPlugin() {
41+
if ( is_admin() && current_user_can( 'activate_plugins' ) && ( ! is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) {
42+
add_action( 'admin_notices', function () {
43+
?>
44+
<div class="error">
45+
<p><?php esc_html_e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-google' ); ?></p>
46+
</div><?php
47+
} );
48+
deactivate_plugins( plugin_basename( __FILE__ ) );
4849

49-
if ( isset( $_GET['activate'] ) ) {
50-
unset( $_GET['activate'] );
50+
if ( isset( $_GET['activate'] ) ) {
51+
unset( $_GET['activate'] );
52+
}
5153
}
5254
}
5355
}
5456

55-
if ( ! class_exists( 'EDU_Google_Loader' ) ):
57+
if ( ! class_exists( 'EDUGTAG_Google_Loader' ) ):
5658

57-
final class EDU_Google_Loader {
59+
final class EDUGTAG_Google_Loader {
5860
public function __construct() {
5961
add_action( 'plugins_loaded', array( $this, 'init' ) );
6062
}
@@ -68,11 +70,11 @@ public function init() {
6870
}
6971

7072
public function add_integration( $integrations ) {
71-
$integrations[] = 'EDU_Google';
73+
$integrations[] = 'EDUGTAG_Google';
7274

7375
return $integrations;
7476
}
7577
}
7678

77-
$edu_sveawebpay_loader = new EDU_Google_Loader( __FILE__ );
79+
$edu_google_loader = new EDUGTAG_Google_Loader( __FILE__ );
7880
endif;

0 commit comments

Comments
 (0)