Version Description
12.04.2022
- Tweak: Improve output formatting for enhanced_conversion_data if shipping address is not set
Download this release
Release Info
Developer | alekv |
Plugin | Pixel Manager for WooCommerce – Track Google Analytics, Google Ads, Facebook and more |
Version | 1.16.7 |
Comparing to | |
See all releases |
Code changes from version 1.13.0 to 1.16.7
- classes/admin/class-admin.php +972 -1291
- classes/admin/class-ask-for-rating.php +152 -156
- classes/admin/class-consent-mode-regions.php +261 -0
- classes/admin/class-debug-info.php +293 -277
- classes/admin/class-documentation.php +131 -135
- classes/admin/class-environment-check.php +1178 -1056
- classes/admin/class-launch-deal.php +0 -146
- classes/admin/class-notifications.php +181 -176
- classes/admin/class-validations.php +167 -0
- classes/admin/index.php +1 -1
- classes/class-db-upgrade.php +101 -109
- classes/class-default-options.php +137 -104
- classes/index.php +1 -1
- classes/pixels/class-cookie-consent-management.php +118 -120
- classes/pixels/class-facebook-browser-pixel.php +0 -94
- classes/pixels/class-facebook-pixel-manager.php +0 -38
- classes/pixels/class-google-ads.php +0 -234
- classes/pixels/class-google-optimize.php +0 -31
- classes/pixels/class-google-pixel-manager.php +0 -377
- classes/pixels/class-google-pixel.php +0 -148
- classes/pixels/class-google-standard-ecommerce.php +0 -24
- classes/pixels/class-google.php +0 -479
- classes/pixels/class-hotjar.php +0 -29
- classes/pixels/class-pinterest.php +0 -100
- classes/pixels/class-pixel-manager.php +290 -304
- classes/pixels/class-pixel.php +36 -99
- classes/pixels/{class-pixel-manager-base.php → class-script-manager.php} +37 -69
- classes/pixels/class-shortcodes.php +277 -201
- classes/pixels/class-twitter.php +0 -87
- classes/pixels/facebook/class-facebook-browser-pixel.php +0 -87
- classes/pixels/facebook/class-facebook-pixel-manager-microdata.php +25 -31
- classes/pixels/facebook/class-facebook-pixel-manager.php +2 -76
- classes/pixels/facebook/index.php +1 -0
- classes/pixels/google/class-google-ads-pixel.php +0 -191
- classes/pixels/google/class-google-ads.php +0 -196
- classes/pixels/google/class-google-analytics-4-eec.php +0 -33
- classes/pixels/google/class-google-analytics-4-standard-pixel.php +0 -40
- classes/pixels/google/class-google-analytics-4-standard.php +0 -16
- classes/pixels/google/class-google-analytics-4.php +0 -90
- classes/pixels/google/class-google-analytics-refund-4.php +0 -38
- classes/pixels/google/class-google-analytics-refund-ua.php +0 -38
- classes/pixels/google/class-google-analytics-refund.php +37 -2
- classes/pixels/google/class-google-analytics-ua-eec.php +0 -32
- classes/pixels/google/class-google-analytics-ua-standard-pixel.php +0 -28
- classes/pixels/google/class-google-analytics-ua-standard.php +0 -16
- classes/pixels/google/class-google-analytics-ua.php +0 -84
- classes/pixels/google/class-google-analytics.php +8 -59
- classes/pixels/google/class-google-optimize.php +0 -31
- classes/pixels/google/class-google-pixel-manager.php +19 -145
- classes/pixels/google/class-google-pixel.php +0 -337
- classes/pixels/google/class-google.php +297 -340
- classes/pixels/google/index.php +1 -0
- classes/pixels/google/trait-google.php +0 -190
- classes/pixels/hotjar/class-hotjar-pixel.php +0 -48
- classes/pixels/index.php +1 -1
- classes/pixels/trait-google.php +0 -44
- classes/pixels/trait-product.php +363 -297
- classes/pixels/trait-shop.php +282 -194
- composer.json +0 -20
- composer.lock +0 -264
- css/admin.css +2 -2
- css/index.php +1 -1
- freemius/LICENSE.txt +0 -674
- freemius/README.md +0 -282
- freemius/assets/css/admin/account.css +0 -1
- freemius/assets/css/admin/add-ons.css +0 -2
- freemius/assets/css/admin/affiliation.css +0 -1
- freemius/assets/css/admin/checkout.css +0 -1
- freemius/assets/css/admin/common.css +0 -2
- freemius/assets/css/admin/connect.css +0 -1
- freemius/assets/css/admin/debug.css +0 -1
- freemius/assets/css/admin/dialog-boxes.css +0 -2
- freemius/assets/css/admin/gdpr-optin-notice.css +0 -1
- freemius/assets/css/admin/index.php +0 -3
- freemius/assets/css/admin/plugins.css +0 -1
- freemius/assets/css/customizer.css +0 -1
- freemius/assets/css/index.php +0 -3
- freemius/assets/img/index.php +0 -3
- freemius/assets/img/plugin-icon.png +0 -0
- freemius/assets/img/theme-icon.png +0 -0
- freemius/assets/img/woocommerce-google-adwords-conversion-tracking-tag.png +0 -0
- freemius/assets/index.php +0 -3
- freemius/assets/js/index.php +0 -3
- freemius/assets/js/nojquery.ba-postmessage.js +0 -140
- freemius/assets/js/nojquery.ba-postmessage.min.js +0 -12
- freemius/assets/js/postmessage.js +0 -135
- freemius/config.php +0 -391
- freemius/includes/class-freemius-abstract.php +0 -493
- freemius/includes/class-freemius.php +0 -6056
classes/admin/class-admin.php
CHANGED
@@ -1,11 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
// TODO move script for copying debug info into a proper .js enqueued file, or switch tabs to JavaScript switching and always save all settings at the same time
|
4 |
-
// TODO debug info list of active payment gateways
|
5 |
namespace WCPM\Classes\Admin;
|
6 |
|
7 |
-
use
|
8 |
-
use WCPM\Classes\Pixels\Google\Trait_Google ;
|
9 |
use WCPM\Classes\Pixels\Trait_Shop ;
|
10 |
|
11 |
if ( !defined( 'ABSPATH' ) ) {
|
@@ -15,38 +13,56 @@ if ( !defined( 'ABSPATH' ) ) {
|
|
15 |
|
16 |
class Admin
|
17 |
{
|
18 |
-
use Trait_Google ;
|
19 |
use Trait_Shop ;
|
20 |
public $ip ;
|
21 |
protected $text_domain ;
|
22 |
protected $options ;
|
23 |
protected $plugin_hook ;
|
24 |
protected $documentation ;
|
|
|
|
|
|
|
25 |
public function __construct( $options )
|
26 |
{
|
27 |
$this->options = $options;
|
28 |
$this->plugin_hook = 'woocommerce_page_wpm';
|
29 |
$this->documentation = new Documentation();
|
|
|
30 |
add_action( 'admin_enqueue_scripts', [ $this, 'wpm_admin_scripts' ] );
|
31 |
// add the admin options page
|
32 |
add_action( 'admin_menu', [ $this, 'wpm_plugin_admin_add_page' ], 99 );
|
33 |
// install a settings page in the admin console
|
34 |
add_action( 'admin_init', [ $this, 'wpm_plugin_admin_init' ] );
|
35 |
// add admin scripts to plugins.php page
|
36 |
-
add_action( 'load-
|
37 |
// Load textdomain
|
38 |
add_action( 'init', [ $this, 'load_plugin_textdomain' ] );
|
39 |
wpm_fs()->add_filter( 'checkout/purchaseCompleted', [ $this, 'my_after_purchase_js' ] );
|
40 |
wpm_fs()->add_filter( 'templates/checkout.php', [ $this, 'my_checkout_enrich' ] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
|
43 |
// This function is only called when our plugin's page loads!
|
44 |
-
function freemius_load_deactivation_button_js()
|
45 |
{
|
46 |
add_action( 'admin_enqueue_scripts', [ $this, 'freemius_enqueue_deactivation_button_js' ] );
|
47 |
}
|
48 |
|
49 |
-
function freemius_enqueue_deactivation_button_js()
|
50 |
{
|
51 |
wp_enqueue_script(
|
52 |
'freemius-enqueue-deactivation-button',
|
@@ -55,20 +71,14 @@ class Admin
|
|
55 |
WPM_CURRENT_VERSION,
|
56 |
true
|
57 |
);
|
58 |
-
// wp_enqueue_script(
|
59 |
-
// 'freemius-enqueue-deactivation-button',
|
60 |
-
// WPM_PLUGIN_DIR_PATH . 'js/admin/freemius-keep-deactivate-button-enabled' . $this->get_script_suffix(),
|
61 |
-
// ['jquery'], WPM_CURRENT_VERSION,
|
62 |
-
// true
|
63 |
-
// );
|
64 |
}
|
65 |
|
66 |
-
public function my_after_purchase_js( $js_function )
|
67 |
{
|
68 |
-
return "function ( response ) {\n\n let\n isTrial = (null != response.purchase.trial_ends),\n isSubscription = (null != response.purchase.initial_amount),\n total = isTrial ? 0 : (isSubscription ? response.purchase.initial_amount : response.purchase.gross).toString(),\n productName = 'WooCommerce Pixel Manager',\n // storeUrl = 'https://sweetcode.
|
69 |
}
|
70 |
|
71 |
-
public function my_checkout_enrich( $html )
|
72 |
{
|
73 |
return '<script async src="https://www.googletagmanager.com/gtag/js?id=UA-39746956-10"></script>' . $html;
|
74 |
}
|
@@ -137,6 +147,10 @@ class Admin
|
|
137 |
public function wpm_plugin_admin_init()
|
138 |
{
|
139 |
register_setting( 'wpm_plugin_options_group', 'wgact_plugin_options', [ $this, 'wpm_options_validate' ] );
|
|
|
|
|
|
|
|
|
140 |
$this->add_section_main();
|
141 |
$this->add_section_advanced();
|
142 |
$this->add_section_beta();
|
@@ -189,7 +203,7 @@ class Admin
|
|
189 |
// add the field for the conversion label
|
190 |
add_settings_field(
|
191 |
'wpm_plugin_conversion_label',
|
192 |
-
esc_html__( 'Google Ads Conversion Label', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
193 |
[ $this, 'wpm_option_html_google_ads_conversion_label' ],
|
194 |
'wpm_plugin_options_page',
|
195 |
$section_ids['settings_name']
|
@@ -220,7 +234,7 @@ class Admin
|
|
220 |
public function add_section_main_subsection_facebook( $section_ids )
|
221 |
{
|
222 |
$sub_section_ids = [
|
223 |
-
'title' => esc_html__( 'Facebook', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
224 |
'slug' => 'facebook',
|
225 |
];
|
226 |
add_settings_field(
|
@@ -235,7 +249,7 @@ class Admin
|
|
235 |
// add the field for the conversion label
|
236 |
add_settings_field(
|
237 |
'wpm_plugin_facebook_pixel_id',
|
238 |
-
esc_html__( 'Facebook pixel ID', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
239 |
[ $this, 'wpm_option_html_facebook_pixel_id' ],
|
240 |
'wpm_plugin_options_page',
|
241 |
$section_ids['settings_name']
|
@@ -374,6 +388,16 @@ class Admin
|
|
374 |
'wpm_plugin_options_page',
|
375 |
$section_ids['settings_name']
|
376 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
}
|
378 |
|
379 |
public function add_section_advanced_subsection_google( $section_ids )
|
@@ -391,16 +415,6 @@ class Admin
|
|
391 |
'wpm_plugin_options_page',
|
392 |
$section_ids['settings_name']
|
393 |
);
|
394 |
-
if ( $this->options['google']['gtag']['deactivation'] ) {
|
395 |
-
// add fields for the gtag insertion
|
396 |
-
add_settings_field(
|
397 |
-
'wpm_plugin_option_gtag_deactivation',
|
398 |
-
esc_html__( 'gtag Deactivation', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
399 |
-
[ $this, 'wpm_setting_html_google_gtag_deactivation' ],
|
400 |
-
'wpm_plugin_options_page',
|
401 |
-
$section_ids['settings_name']
|
402 |
-
);
|
403 |
-
}
|
404 |
// add the field for the aw_merchant_id
|
405 |
add_settings_field(
|
406 |
'wpm_plugin_aw_merchant_id',
|
@@ -518,7 +532,7 @@ class Admin
|
|
518 |
'wpm_plugin_options_page',
|
519 |
$section_ids['settings_name']
|
520 |
);
|
521 |
-
if ( ( new Environment_Check() )->is_borlabs_cookie_active() ) {
|
522 |
// add fields for the Borlabs Cookie support
|
523 |
add_settings_field(
|
524 |
'wpm_setting_borlabs_support',
|
@@ -528,7 +542,7 @@ class Admin
|
|
528 |
$section_ids['settings_name']
|
529 |
);
|
530 |
}
|
531 |
-
if ( ( new Environment_Check() )->is_cookiebot_active() ) {
|
532 |
// add fields for the Cookiebot support
|
533 |
add_settings_field(
|
534 |
'wpm_setting_cookiebot_support',
|
@@ -538,17 +552,7 @@ class Admin
|
|
538 |
$section_ids['settings_name']
|
539 |
);
|
540 |
}
|
541 |
-
if (
|
542 |
-
// add fields for the Cookiebot support
|
543 |
-
add_settings_field(
|
544 |
-
'wpm_setting_cookiebot_active',
|
545 |
-
esc_html__( 'Cookiebot support', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
546 |
-
[ $this, 'wpm_setting_html_cookiebot_manual_setting' ],
|
547 |
-
'wpm_plugin_options_page',
|
548 |
-
$section_ids['settings_name']
|
549 |
-
);
|
550 |
-
}
|
551 |
-
if ( ( new Environment_Check() )->is_complianz_active() ) {
|
552 |
// add fields for the Complianz GDPR support
|
553 |
add_settings_field(
|
554 |
'wpm_setting_complianz_support',
|
@@ -558,7 +562,7 @@ class Admin
|
|
558 |
$section_ids['settings_name']
|
559 |
);
|
560 |
}
|
561 |
-
if ( ( new Environment_Check() )->is_cookie_notice_active() ) {
|
562 |
// add fields for the Cookie Notice by hu-manity.co support
|
563 |
add_settings_field(
|
564 |
'wpm_setting_cookie_notice_support',
|
@@ -568,7 +572,7 @@ class Admin
|
|
568 |
$section_ids['settings_name']
|
569 |
);
|
570 |
}
|
571 |
-
if ( ( new Environment_Check() )->is_cookie_script_active() ) {
|
572 |
// add fields for the Cookie Script support
|
573 |
add_settings_field(
|
574 |
'wpm_setting_cookie_script_support',
|
@@ -578,7 +582,7 @@ class Admin
|
|
578 |
$section_ids['settings_name']
|
579 |
);
|
580 |
}
|
581 |
-
if ( ( new Environment_Check() )->is_moove_gdpr_active() ) {
|
582 |
// add fields for the GDPR Cookie Compliance support
|
583 |
add_settings_field(
|
584 |
'wpm_setting_moove_gdpr_support',
|
@@ -588,7 +592,7 @@ class Admin
|
|
588 |
$section_ids['settings_name']
|
589 |
);
|
590 |
}
|
591 |
-
if ( ( new Environment_Check() )->is_cookie_law_info_active() ) {
|
592 |
// add fields for the GDPR Cookie Consent support
|
593 |
add_settings_field(
|
594 |
'wpm_setting_cookie_law_info_support',
|
@@ -603,7 +607,7 @@ class Admin
|
|
603 |
public function add_section_advanced_subsection_facebook( $section_ids )
|
604 |
{
|
605 |
$sub_section_ids = [
|
606 |
-
'title' => 'Facebook',
|
607 |
'slug' => 'facebook',
|
608 |
];
|
609 |
add_settings_field(
|
@@ -618,7 +622,7 @@ class Admin
|
|
618 |
// add field for the Facebook CAPI token
|
619 |
add_settings_field(
|
620 |
'wpm_setting_facebook_capi_token',
|
621 |
-
esc_html__( 'Facebook CAPI: token', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
622 |
[ $this, 'wpm_setting_html_facebook_capi_token' ],
|
623 |
'wpm_plugin_options_page',
|
624 |
$section_ids['settings_name']
|
@@ -626,7 +630,7 @@ class Admin
|
|
626 |
// add field for the Facebook CAPI user transparency process anonymous hits
|
627 |
add_settings_field(
|
628 |
'wpm_setting_facebook_capi_user_transparency_process_anonymous_hits',
|
629 |
-
esc_html__( 'Facebook CAPI: process anonymous hits', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
630 |
[ $this, 'wpm_setting_facebook_capi_user_transparency_process_anonymous_hits' ],
|
631 |
'wpm_plugin_options_page',
|
632 |
$section_ids['settings_name']
|
@@ -634,7 +638,7 @@ class Admin
|
|
634 |
// add field for the Facebook CAPI user transparency send additional client identifiers
|
635 |
add_settings_field(
|
636 |
'wpm_setting_facebook_capi_user_transparency_send_additional_client_identifiers',
|
637 |
-
esc_html__( 'Facebook CAPI: send additional visitor identifiers', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
638 |
[ $this, 'wpm_setting_facebook_capi_user_transparency_send_additional_client_identifiers' ],
|
639 |
'wpm_plugin_options_page',
|
640 |
$section_ids['settings_name']
|
@@ -642,7 +646,7 @@ class Admin
|
|
642 |
// add fields for Facebook microdata
|
643 |
add_settings_field(
|
644 |
'wpm_setting_facebook_microdata_active',
|
645 |
-
esc_html__( 'Facebook Microdata Tags for Catalogues', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
646 |
[ $this, 'wpm_setting_html_facebook_microdata' ],
|
647 |
'wpm_plugin_options_page',
|
648 |
$section_ids['settings_name']
|
@@ -664,39 +668,6 @@ class Admin
|
|
664 |
[ $this, 'wpm_plugin_section_add_cart_data_description' ],
|
665 |
'wpm_plugin_options_page'
|
666 |
);
|
667 |
-
// add fields for cart data
|
668 |
-
// add_settings_field(
|
669 |
-
// 'wgact_plugin_add_cart_data',
|
670 |
-
// esc_html__(
|
671 |
-
// 'Activation',
|
672 |
-
// 'woocommerce-google-adwords-conversion-tracking-tag'
|
673 |
-
// ),
|
674 |
-
// [$this, 'wgact_option_html_google_ads_add_cart_data'],
|
675 |
-
// 'wpm_plugin_options_page',
|
676 |
-
// 'wpm_plugin_beta_section'
|
677 |
-
// );
|
678 |
-
// add the field for the aw_feed_country
|
679 |
-
// add_settings_field(
|
680 |
-
// 'wgact_plugin_aw_feed_country',
|
681 |
-
// esc_html__(
|
682 |
-
// 'aw_feed_country',
|
683 |
-
// 'woocommerce-google-adwords-conversion-tracking-tag'
|
684 |
-
// ),
|
685 |
-
// [$this, 'wgact_plugin_setting_aw_feed_country'],
|
686 |
-
// 'wpm_plugin_options_page',
|
687 |
-
// 'wpm_plugin_beta_section'
|
688 |
-
// );
|
689 |
-
// add the field for the aw_feed_language
|
690 |
-
// add_settings_field(
|
691 |
-
// 'wgact_plugin_aw_feed_language',
|
692 |
-
// esc_html__(
|
693 |
-
// 'aw_feed_language',
|
694 |
-
// 'woocommerce-google-adwords-conversion-tracking-tag'
|
695 |
-
// ),
|
696 |
-
// [$this, 'wgact_plugin_setting_aw_feed_language'],
|
697 |
-
// 'wpm_plugin_options_page',
|
698 |
-
// 'wpm_plugin_beta_section'
|
699 |
-
// );
|
700 |
// add checkbox for dynamic remarketing
|
701 |
add_settings_field(
|
702 |
'wpm_plugin_option_gads_dynamic_remarketing',
|
@@ -763,6 +734,7 @@ class Admin
|
|
763 |
[ $this, 'wpm_plugin_section_author_description' ],
|
764 |
'wpm_plugin_options_page'
|
765 |
);
|
|
|
766 |
}
|
767 |
|
768 |
protected function output_section_data_field( array $section_ids )
|
@@ -780,119 +752,119 @@ class Admin
|
|
780 |
|
781 |
public function wpm_section_generic_opening_div_html( $section_ids )
|
782 |
{
|
783 |
-
echo '<div class="section" data-section-title="' . $section_ids['title'] . '" data-section-slug="' . $section_ids['slug'] . '"></div>' ;
|
784 |
}
|
785 |
|
786 |
public function wpm_subsection_generic_opening_div_html( $section_ids, $sub_section_ids )
|
787 |
{
|
788 |
-
echo '<div class="subsection" data-section-slug="' . $section_ids['slug'] . '" data-subsection-title="' . $sub_section_ids['title'] . '" data-subsection-slug="' . $sub_section_ids['slug'] . '"></div>' ;
|
789 |
}
|
790 |
|
791 |
// display the admin options page
|
792 |
public function wpm_plugin_options_page()
|
793 |
{
|
794 |
?>
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
esc_html_e( 'It looks like you are using some sort of ad or script blocker which is blocking the script and CSS files of this plugin.
|
800 |
In order for the plugin to work properly you need to disable the script blocker.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
801 |
?>
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
?>"
|
807 |
-
|
808 |
-
|
809 |
esc_html_e( 'Learn more', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
810 |
?>
|
811 |
-
|
812 |
-
|
813 |
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
|
820 |
-
|
821 |
|
822 |
-
|
823 |
|
824 |
-
|
825 |
settings_errors();
|
826 |
?>
|
827 |
|
828 |
-
|
829 |
-
|
830 |
|
831 |
-
|
832 |
|
833 |
-
|
834 |
settings_fields( 'wpm_plugin_options_group' );
|
835 |
do_settings_sections( 'wpm_plugin_options_page' );
|
836 |
submit_button();
|
837 |
$this->inject_developer_banner();
|
838 |
?>
|
839 |
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
}
|
844 |
|
845 |
private function inject_developer_banner()
|
846 |
{
|
847 |
?>
|
848 |
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
esc_html_e( 'Profit Driven Marketing by SweetCode', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
854 |
?>
|
855 |
-
|
856 |
|
857 |
-
|
858 |
?>
|
859 |
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
checked( $this->options['general']['pro_version_demo'] );
|
872 |
?>
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
|
878 |
-
|
879 |
?>
|
880 |
|
881 |
-
|
882 |
-
|
883 |
esc_html_e( 'Visit us here:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
884 |
?>
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
}
|
894 |
|
895 |
-
private function get_link_locale()
|
896 |
{
|
897 |
|
898 |
if ( substr( get_user_locale(), 0, 2 ) === 'de' ) {
|
@@ -927,143 +899,152 @@ class Admin
|
|
927 |
public function wpm_plugin_section_support_description()
|
928 |
{
|
929 |
?>
|
930 |
-
|
931 |
-
|
932 |
esc_html_e( 'Contacting Support', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
933 |
?></h2>
|
934 |
|
935 |
-
|
936 |
-
|
937 |
$this->support_info_for_freemius();
|
938 |
?>
|
939 |
-
|
940 |
-
|
941 |
$this->info_for_translators();
|
942 |
?>
|
943 |
-
|
944 |
-
|
945 |
esc_html_e( 'Debug Information', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
946 |
?></h2>
|
947 |
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
?>
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
esc_html_e( 'copy to clipboard', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
959 |
?></button>
|
960 |
-
|
961 |
|
962 |
-
|
963 |
-
|
964 |
|
965 |
-
|
966 |
}
|
967 |
|
968 |
private function info_for_translators()
|
969 |
{
|
970 |
?>
|
971 |
|
972 |
-
|
973 |
-
|
974 |
esc_html_e( 'Translations', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
975 |
?></h2>
|
976 |
-
|
977 |
esc_html_e( 'If you want to participate improving the translations of this plugin into your language, please follow this link:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
978 |
?>
|
979 |
-
|
980 |
-
|
981 |
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
}
|
986 |
|
987 |
private function support_info_for_freemius()
|
988 |
{
|
989 |
?>
|
990 |
-
|
991 |
-
|
992 |
|
993 |
-
|
994 |
-
|
995 |
esc_html_e( 'Post a support request in the WordPress support forum here: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
996 |
?>
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
esc_html_e( 'Support forum', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1001 |
?>
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
esc_html_e( '(Never post the debug or other sensitive information to the support forum. Instead send us the information by email.)', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1007 |
?>
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
esc_html_e( 'Or send us an email to the following address: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1012 |
?>
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
|
1018 |
-
|
1019 |
}
|
1020 |
|
1021 |
private function support_info_for_wc_market()
|
1022 |
{
|
1023 |
?>
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
esc_html_e( 'Send us your support request through the WooCommerce.com dashboard: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1029 |
?>
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
|
1036 |
-
|
1037 |
}
|
1038 |
|
1039 |
public function wpm_plugin_section_author_description()
|
1040 |
{
|
1041 |
?>
|
1042 |
-
|
1043 |
-
|
1044 |
esc_html_e( 'More details about the developer of this plugin: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1045 |
?>
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
esc_html_e( 'Developer: SweetCode', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1050 |
?></div>
|
1051 |
-
|
1052 |
-
|
1053 |
esc_html_e( 'Website: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1054 |
?>
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
}
|
1061 |
|
1062 |
public function wpm_option_html_google_analytics_universal_property()
|
1063 |
{
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1067 |
echo '<br><br>' ;
|
1068 |
esc_html_e( 'The Google Analytics Universal property ID looks like this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1069 |
echo ' <i>UA-12345678-1</i>' ;
|
@@ -1071,9 +1052,18 @@ class Admin
|
|
1071 |
|
1072 |
public function wpm_option_html_google_analytics_4_id()
|
1073 |
{
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1077 |
echo '<br><br>' ;
|
1078 |
esc_html_e( 'The Google Analytics 4 measurement ID looks like this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1079 |
echo ' <i>G-R912ZZ1MHH0</i>' ;
|
@@ -1081,9 +1071,18 @@ class Admin
|
|
1081 |
|
1082 |
public function wpm_option_html_google_ads_conversion_id()
|
1083 |
{
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1087 |
echo '<br><br>' ;
|
1088 |
esc_html_e( 'The conversion ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1089 |
echo ' <i>123456789</i>' ;
|
@@ -1091,11 +1090,20 @@ class Admin
|
|
1091 |
|
1092 |
public function wpm_option_html_google_ads_conversion_label()
|
1093 |
{
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1097 |
echo '<br><br>' ;
|
1098 |
-
esc_html_e( 'The conversion
|
1099 |
echo ' <i>Xt19CO3axGAX0vg6X3gM</i>' ;
|
1100 |
|
1101 |
if ( $this->options['google']['ads']['conversion_label'] && !$this->options['google']['ads']['conversion_id'] ) {
|
@@ -1108,10 +1116,19 @@ class Admin
|
|
1108 |
|
1109 |
public function wpm_option_html_google_optimize_container_id()
|
1110 |
{
|
1111 |
-
|
1112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1113 |
// echo $this->get_documentation_html('/wgact/#/plugin-configuration?id=configure-the-plugin');
|
1114 |
-
|
1115 |
echo '<br><br>' ;
|
1116 |
esc_html_e( 'The Google Optimize container ID looks like this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1117 |
echo ' <i>GTM-WMAB1BM</i>' ;
|
@@ -1119,20 +1136,41 @@ class Admin
|
|
1119 |
|
1120 |
public function wpm_option_html_facebook_pixel_id()
|
1121 |
{
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1125 |
echo '<br><br>' ;
|
1126 |
-
esc_html_e( 'The Facebook pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1127 |
echo ' <i>765432112345678</i>' ;
|
1128 |
}
|
1129 |
|
1130 |
public function wpm_option_html_bing_uet_tag_id()
|
1131 |
{
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1136 |
echo '<br><br>' ;
|
1137 |
esc_html_e( 'The Microsoft Advertising UET tag ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1138 |
echo ' <i>12345678</i>' ;
|
@@ -1140,10 +1178,23 @@ class Admin
|
|
1140 |
|
1141 |
public function wpm_option_html_twitter_pixel_id()
|
1142 |
{
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1147 |
echo '<br><br>' ;
|
1148 |
esc_html_e( 'The Twitter pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1149 |
echo ' <i>a1cde</i>' ;
|
@@ -1151,10 +1202,23 @@ class Admin
|
|
1151 |
|
1152 |
public function wpm_option_html_pinterest_pixel_id()
|
1153 |
{
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1158 |
echo '<br><br>' ;
|
1159 |
esc_html_e( 'The Pinterest pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1160 |
echo ' <i>1234567890123</i>' ;
|
@@ -1162,10 +1226,23 @@ class Admin
|
|
1162 |
|
1163 |
public function wpm_option_html_snapchat_pixel_id()
|
1164 |
{
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1169 |
echo '<br><br>' ;
|
1170 |
esc_html_e( 'The Snapchat pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1171 |
echo ' <i>1a2345b6-cd78-9012-e345-fg6h7890ij12</i>' ;
|
@@ -1173,10 +1250,23 @@ class Admin
|
|
1173 |
|
1174 |
public function wpm_option_html_tiktok_pixel_id()
|
1175 |
{
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1180 |
echo '<br><br>' ;
|
1181 |
esc_html_e( 'The TikTok pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1182 |
echo ' <i>ABCD1E2FGH3IJK45LMN6</i>' ;
|
@@ -1184,9 +1274,14 @@ class Admin
|
|
1184 |
|
1185 |
public function wpm_option_html_hotjar_site_id()
|
1186 |
{
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
|
|
|
|
|
|
|
|
|
|
1190 |
echo '<br><br>' ;
|
1191 |
esc_html_e( 'The Hotjar site ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1192 |
echo ' <i>1234567</i>' ;
|
@@ -1195,80 +1290,59 @@ class Admin
|
|
1195 |
public function wpm_option_html_shop_order_total_logic()
|
1196 |
{
|
1197 |
?>
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
echo checked( 0, $this->options['shop']['order_total_logic'], false ) ;
|
1203 |
-
?>
|
|
|
1204 |
esc_html_e( 'Use order_subtotal: Doesn\'t include tax and shipping (default)', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1205 |
?>
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
echo checked( 1, $this->options['shop']['order_total_logic'], false ) ;
|
1213 |
-
?>
|
|
|
1214 |
esc_html_e( 'Use order_total: Includes tax and shipping', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1215 |
?>
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
esc_html_e( 'This is the order total amount reported back to Google Ads', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1220 |
?>
|
1221 |
-
|
1222 |
}
|
1223 |
|
1224 |
-
private function get_documentation_html_by_key( $key = 'default' )
|
1225 |
{
|
1226 |
return $this->get_documentation_html( $this->documentation->get_link( $key ) );
|
1227 |
}
|
1228 |
|
1229 |
-
protected function get_documentation_html( $path )
|
1230 |
-
{
|
1231 |
-
$html = '<a class="documentation-icon" href="' . $path . '" target="_blank">';
|
1232 |
-
$html .= '<span style="vertical-align: top; margin-top: 0px" class="dashicons dashicons-info-outline tooltip"><span class="tooltiptext">';
|
1233 |
-
$html .= esc_html__( 'open the documentation', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1234 |
-
$html .= '</span></span></a>';
|
1235 |
-
return $html;
|
1236 |
-
}
|
1237 |
-
|
1238 |
-
public function wpm_setting_html_google_gtag_deactivation()
|
1239 |
{
|
1240 |
-
//
|
1241 |
-
//
|
1242 |
-
//
|
|
|
|
|
|
|
1243 |
?>
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
<?php
|
1252 |
-
esc_html_e( 'Disable gtag.js insertion, if another plugin is inserting it already', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1253 |
-
?>
|
1254 |
-
</label>
|
1255 |
-
<?php
|
1256 |
-
echo $this->get_documentation_html_by_key( 'google_gtag_deactivation' ) ;
|
1257 |
-
?>
|
1258 |
-
<br>
|
1259 |
-
<p>
|
1260 |
-
<span class="dashicons dashicons-info"></span>
|
1261 |
-
<?php
|
1262 |
-
esc_html_e( 'Only do this, if the other plugin does insert the gtag above this pixel. If not, keep the gtag active.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1263 |
-
?>
|
1264 |
-
</p>
|
1265 |
-
<p>
|
1266 |
-
<span class="dashicons dashicons-info"></span>
|
1267 |
-
<?php
|
1268 |
-
esc_html_e( 'This setting is deprecated. It will be removed in future versions of the plugin. Read more about it in the documentation.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1269 |
?>
|
1270 |
-
|
1271 |
-
|
|
|
1272 |
}
|
1273 |
|
1274 |
public function wpm_setting_html_google_consent_mode_active()
|
@@ -1277,28 +1351,28 @@ class Admin
|
|
1277 |
// instead of not saving it and remove that array key entirely
|
1278 |
// https://stackoverflow.com/a/1992745/4688612
|
1279 |
?>
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
checked( $this->options['google']['consent_mode']['active'] );
|
1287 |
?>
|
1288 |
-
|
1289 |
-
|
1290 |
?>
|
1291 |
-
|
1292 |
-
|
1293 |
esc_html_e( 'Enable Google consent mode with standard settings', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1294 |
?>
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
?>
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
}
|
1303 |
|
1304 |
public function wpm_setting_html_google_consent_regions()
|
@@ -1307,45 +1381,45 @@ class Admin
|
|
1307 |
// https://developer.woocommerce.com/2017/08/08/selectwoo-an-accessible-replacement-for-select2/
|
1308 |
// https://github.com/woocommerce/selectWoo
|
1309 |
?>
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
?>
|
1317 |
-
|
1318 |
-
|
1319 |
-
foreach ( $this->get_consent_mode_regions() as $region_code => $region_name ) {
|
1320 |
?>
|
1321 |
-
|
1322 |
-
|
1323 |
?>" <?php
|
1324 |
-
|
1325 |
?>><?php
|
1326 |
-
|
1327 |
?></option>
|
1328 |
-
|
1329 |
}
|
1330 |
?>
|
1331 |
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
?>
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
esc_html_e( 'If no region is set, then the restrictions are enabled for all regions. If you specify one or more regions, then the restrictions only apply for the specified regions.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1346 |
?>
|
1347 |
-
|
1348 |
-
|
1349 |
}
|
1350 |
|
1351 |
public function wpm_setting_html_google_analytics_eec()
|
@@ -1354,28 +1428,28 @@ class Admin
|
|
1354 |
// instead of not saving it and remove that array key entirely
|
1355 |
// https://stackoverflow.com/a/1992745/4688612
|
1356 |
?>
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
checked( $this->options['google']['analytics']['eec'] );
|
1364 |
?>
|
1365 |
-
|
1366 |
-
|
1367 |
?>
|
1368 |
-
|
1369 |
-
|
1370 |
esc_html_e( 'Enable Google Analytics enhanced e-commerce', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1371 |
?>
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
//
|
1377 |
?>
|
1378 |
-
|
1379 |
|
1380 |
if ( $this->options['google']['analytics']['eec'] && (!$this->options['google']['analytics']['universal']['property_id'] && !$this->options['google']['analytics']['ga4']['measurement_id']) ) {
|
1381 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
@@ -1387,10 +1461,23 @@ class Admin
|
|
1387 |
|
1388 |
public function wpm_setting_html_google_analytics_4_api_secret()
|
1389 |
{
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1394 |
echo '<br><br>' ;
|
1395 |
|
1396 |
if ( !$this->options['google']['analytics']['ga4']['measurement_id'] ) {
|
@@ -1415,24 +1502,25 @@ class Admin
|
|
1415 |
// instead of not saving it and remove that array key entirely
|
1416 |
// https://stackoverflow.com/a/1992745/4688612
|
1417 |
?>
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
checked( $this->options['google']['analytics']['link_attribution'] );
|
1424 |
-
?>
|
1425 |
-
|
|
|
1426 |
esc_html_e( 'Enable Google Analytics enhanced link attribution', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1427 |
?>
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
?>
|
1432 |
-
|
1433 |
// echo $this->get_documentation_html('/wgact/?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-consent-mode#/consent-mgmt/google-consent-mode');
|
1434 |
?>
|
1435 |
-
|
1436 |
|
1437 |
if ( $this->options['google']['analytics']['link_attribution'] && (!$this->options['google']['analytics']['universal']['property_id'] && !$this->options['google']['analytics']['ga4']['measurement_id']) ) {
|
1438 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
@@ -1448,28 +1536,28 @@ class Admin
|
|
1448 |
// instead of not saving it and remove that array key entirely
|
1449 |
// https://stackoverflow.com/a/1992745/4688612
|
1450 |
?>
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
checked( $this->options['google']['user_id'] );
|
1458 |
?>
|
1459 |
-
|
1460 |
-
|
1461 |
?>
|
1462 |
-
|
1463 |
-
|
1464 |
esc_html_e( 'Enable Google user ID', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1465 |
?>
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
// echo $this->get_documentation_html('/wgact/?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-consent-mode#/consent-mgmt/google-consent-mode');
|
1471 |
?>
|
1472 |
-
|
1473 |
|
1474 |
if ( $this->options['google']['analytics']['eec'] && (!$this->options['google']['analytics']['universal']['property_id'] && !$this->options['google']['analytics']['ga4']['measurement_id']) ) {
|
1475 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
@@ -1485,30 +1573,30 @@ class Admin
|
|
1485 |
// instead of not saving it and remove that array key entirely
|
1486 |
// https://stackoverflow.com/a/1992745/4688612
|
1487 |
?>
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
checked( $this->options['google']['ads']['enhanced_conversions'] );
|
1495 |
?>
|
1496 |
-
|
1497 |
-
|
1498 |
?>
|
1499 |
-
|
1500 |
-
|
1501 |
esc_html_e( 'Enable Google Ads Enhanced Conversions', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1502 |
?>
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
?>
|
1509 |
-
|
1510 |
|
1511 |
-
if ( !$this->is_google_ads_active() ) {
|
1512 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1513 |
esc_html_e( 'You need to activate Google Ads', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1514 |
echo '</p><br>' ;
|
@@ -1518,20 +1606,46 @@ class Admin
|
|
1518 |
|
1519 |
public function wpm_setting_html_google_ads_phone_conversion_number()
|
1520 |
{
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1525 |
echo '<br><br>' ;
|
1526 |
esc_html_e( 'The Google Ads phone conversion number must be in the same format as on the website.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1527 |
}
|
1528 |
|
1529 |
public function wpm_setting_html_google_ads_phone_conversion_label()
|
1530 |
{
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1535 |
echo '<br><br>' ;
|
1536 |
// esc_html_e('The Google Ads phone conversion label must be in the same format as on the website.', 'woocommerce-google-adwords-conversion-tracking-tag');
|
1537 |
}
|
@@ -1539,83 +1653,50 @@ class Admin
|
|
1539 |
public function wpm_setting_html_borlabs_support()
|
1540 |
{
|
1541 |
esc_html_e( 'Borlabs Cookie detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1542 |
-
|
1543 |
-
|
1544 |
}
|
1545 |
|
1546 |
public function wpm_setting_html_cookiebot_support()
|
1547 |
{
|
1548 |
esc_html_e( 'Cookiebot detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1549 |
-
|
1550 |
-
|
1551 |
-
}
|
1552 |
-
|
1553 |
-
public function wpm_setting_html_cookiebot_manual_setting()
|
1554 |
-
{
|
1555 |
-
// adding the hidden input is a hack to make WordPress save the option with the value zero,
|
1556 |
-
// instead of not saving it and remove that array key entirely
|
1557 |
-
// https://stackoverflow.com/a/1992745/4688612
|
1558 |
-
?>
|
1559 |
-
<label>
|
1560 |
-
<input type='hidden' value='0' name='wgact_plugin_options[shop][cookie_consent_mgmt][cookiebot][active]'>
|
1561 |
-
<input type='checkbox' id='wpm_setting_cookiebot_active'
|
1562 |
-
name='wgact_plugin_options[shop][cookie_consent_mgmt][cookiebot][active]'
|
1563 |
-
value='1'
|
1564 |
-
<?php
|
1565 |
-
checked( $this->options['shop']['cookie_consent_mgmt']['cookiebot']['active'] );
|
1566 |
-
?>
|
1567 |
-
<?php
|
1568 |
-
echo $this->disable_if_demo() ;
|
1569 |
-
?>
|
1570 |
-
/>
|
1571 |
-
<?php
|
1572 |
-
esc_html_e( 'Enable Cookiebot settings', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1573 |
-
?></label>
|
1574 |
-
<?php
|
1575 |
-
echo $this->get_status_icon( $this->options['shop']['cookie_consent_mgmt']['cookiebot']['active'], $this->options['google']['consent_mode']['active'], true ) ;
|
1576 |
-
echo $this->html_pro_feature() ;
|
1577 |
-
|
1578 |
-
if ( $this->options['shop']['cookie_consent_mgmt']['cookiebot']['active'] && !$this->options['google']['consent_mode']['active'] ) {
|
1579 |
-
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1580 |
-
esc_html_e( 'You need to activate the Google consent mode', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1581 |
-
echo '</p><br>' ;
|
1582 |
-
}
|
1583 |
-
|
1584 |
}
|
1585 |
|
1586 |
public function wpm_setting_html_complianz_support()
|
1587 |
{
|
1588 |
esc_html_e( 'Complianz GDPR detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1589 |
-
|
1590 |
-
|
1591 |
}
|
1592 |
|
1593 |
public function wpm_setting_html_cookie_notice_support()
|
1594 |
{
|
1595 |
esc_html_e( 'Cookie Notice (by hu-manity.co) detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1596 |
-
|
1597 |
-
|
1598 |
}
|
1599 |
|
1600 |
public function wpm_setting_html_cookie_script_support()
|
1601 |
{
|
1602 |
esc_html_e( 'Cookie Script (by cookie-script.com) detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1603 |
-
|
1604 |
-
|
1605 |
}
|
1606 |
|
1607 |
public function wpm_setting_html_moove_gdpr_support()
|
1608 |
{
|
1609 |
esc_html_e( 'GDPR Cookie Compliance (by Moove Agency) detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1610 |
-
|
1611 |
-
|
1612 |
}
|
1613 |
|
1614 |
public function wpm_setting_html_cookie_law_info_support()
|
1615 |
{
|
1616 |
esc_html_e( 'GDPR Cookie Consent (by WebToffee) detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1617 |
-
|
1618 |
-
|
1619 |
}
|
1620 |
|
1621 |
public function wpm_setting_html_explicit_consent_mode()
|
@@ -1624,25 +1705,26 @@ class Admin
|
|
1624 |
// instead of not saving it and remove that array key entirely
|
1625 |
// https://stackoverflow.com/a/1992745/4688612
|
1626 |
?>
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
checked( $this->options['shop']['cookie_consent_mgmt']['explicit_consent'] );
|
1634 |
?>
|
1635 |
-
|
1636 |
-
|
1637 |
?>
|
1638 |
-
|
1639 |
-
|
1640 |
esc_html_e( 'Enable Explicit Consent Mode', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
|
|
1646 |
echo '<p style="margin-top:10px">' ;
|
1647 |
esc_html_e( 'Only activate the Explicit Consent Mode if you are also using a Cookie Management Platform (a cookie banner) that is compatible with this plugin. Find a list of compatible plugins in the documentation.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1648 |
echo '</p>' ;
|
@@ -1650,24 +1732,25 @@ class Admin
|
|
1650 |
|
1651 |
public function wpm_setting_html_facebook_capi_token()
|
1652 |
{
|
1653 |
-
?><textarea id='wpm_setting_facebook_capi_token'
|
1654 |
-
name='wgact_plugin_options[facebook][capi][token]'
|
1655 |
-
cols='60'
|
1656 |
-
rows='5'
|
1657 |
-
<?php
|
1658 |
-
echo $this->disable_if_demo() ;
|
1659 |
?>
|
1660 |
-
|
1661 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1662 |
?></textarea>
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
|
1668 |
if ( !$this->options['facebook']['pixel_id'] ) {
|
1669 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1670 |
-
esc_html_e( 'You need to activate the Facebook pixel', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1671 |
echo '</p><br>' ;
|
1672 |
}
|
1673 |
|
@@ -1683,31 +1766,31 @@ class Admin
|
|
1683 |
// instead of not saving it and remove that array key entirely
|
1684 |
// https://stackoverflow.com/a/1992745/4688612
|
1685 |
?>
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
checked( $this->options['facebook']['capi']['user_transparency']['process_anonymous_hits'] );
|
1694 |
?>
|
1695 |
-
|
1696 |
-
|
1697 |
?>
|
1698 |
-
|
1699 |
-
|
1700 |
-
esc_html_e( 'Send CAPI hits for anonymous visitors who likely have blocked the Facebook pixel.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1701 |
?>
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
|
1708 |
if ( $this->options['facebook']['capi']['user_transparency']['process_anonymous_hits'] && !$this->options['facebook']['pixel_id'] ) {
|
1709 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1710 |
-
esc_html_e( 'You need to activate the Facebook pixel', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1711 |
echo '</p><br>' ;
|
1712 |
}
|
1713 |
|
@@ -1719,31 +1802,31 @@ class Admin
|
|
1719 |
// instead of not saving it and remove that array key entirely
|
1720 |
// https://stackoverflow.com/a/1992745/4688612
|
1721 |
?>
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
checked( $this->options['facebook']['capi']['user_transparency']['send_additional_client_identifiers'] );
|
1730 |
?>
|
1731 |
-
|
1732 |
-
|
1733 |
?>
|
1734 |
-
|
1735 |
-
|
1736 |
esc_html_e( 'Include additional visitor\'s identifiers, such as IP address, email and shop ID in the CAPI hit.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1737 |
?>
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
|
1744 |
if ( $this->options['facebook']['capi']['user_transparency']['send_additional_client_identifiers'] && !$this->options['facebook']['pixel_id'] ) {
|
1745 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1746 |
-
esc_html_e( 'You need to activate the Facebook pixel', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1747 |
echo '</p><br>' ;
|
1748 |
}
|
1749 |
|
@@ -1755,94 +1838,64 @@ class Admin
|
|
1755 |
// instead of not saving it and remove that array key entirely
|
1756 |
// https://stackoverflow.com/a/1992745/4688612
|
1757 |
?>
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
checked( $this->options['facebook']['microdata'] );
|
1765 |
?>
|
1766 |
-
|
1767 |
-
|
1768 |
?>
|
1769 |
-
|
1770 |
-
|
1771 |
-
esc_html_e( 'Enable Facebook product microdata output', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1772 |
?>
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
|
1779 |
if ( $this->options['facebook']['microdata'] && !$this->options['facebook']['pixel_id'] ) {
|
1780 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1781 |
-
esc_html_e( 'You need to activate the Facebook pixel', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1782 |
echo '</p><br>' ;
|
1783 |
}
|
1784 |
|
1785 |
}
|
1786 |
|
1787 |
-
public function wgact_option_html_google_ads_add_cart_data()
|
1788 |
-
{
|
1789 |
-
// adding the hidden input is a hack to make WordPress save the option with the value zero,
|
1790 |
-
// instead of not saving it and remove that array key entirely
|
1791 |
-
// https://stackoverflow.com/a/1992745/4688612
|
1792 |
-
?>
|
1793 |
-
<label>
|
1794 |
-
<input type='hidden' value='0' name='wgact_plugin_options[google][ads][add_cart_data]'>
|
1795 |
-
<input type='checkbox' id='wgact_plugin_option_gads_add_cart_data'
|
1796 |
-
name='wgact_plugin_options[google][ads][add_cart_data]'
|
1797 |
-
value='1' <?php
|
1798 |
-
checked( $this->options['google']['ads']['add_cart_data'] );
|
1799 |
-
?> />
|
1800 |
-
<?php
|
1801 |
-
esc_html_e( 'Add the cart data to the conversion event', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1802 |
-
?>
|
1803 |
-
</label>
|
1804 |
-
<?php
|
1805 |
-
echo $this->get_status_icon( $this->options['google']['ads']['add_cart_data'], $this->add_to_cart_requirements_fulfilled() ) ;
|
1806 |
-
|
1807 |
-
if ( !$this->add_to_cart_requirements_fulfilled() ) {
|
1808 |
-
?>
|
1809 |
-
<p><span class="dashicons dashicons-info"></span>
|
1810 |
-
<?php
|
1811 |
-
esc_html_e( 'Requires an active Google Ads Conversion ID, an active Conversion Label and an active Google Merchant Center ID (aw_merchant_id)', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1812 |
-
?>
|
1813 |
-
</p>
|
1814 |
-
<?php
|
1815 |
-
}
|
1816 |
-
|
1817 |
-
}
|
1818 |
-
|
1819 |
public function wpm_setting_html_order_duplication_prevention()
|
1820 |
{
|
1821 |
// adding the hidden input is a hack to make WordPress save the option with the value zero,
|
1822 |
// instead of not saving it and remove that array key entirely
|
1823 |
// https://stackoverflow.com/a/1992745/4688612
|
1824 |
?>
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
checked( $this->options['shop']['order_deduplication'] );
|
1831 |
-
?>
|
1832 |
-
|
|
|
1833 |
$this->get_order_duplication_prevention_text();
|
1834 |
-
?></label>
|
1835 |
-
<?php
|
1836 |
-
echo $this->get_status_icon( $this->options['shop']['order_deduplication'] ) ;
|
1837 |
?>
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
|
|
|
|
|
|
|
|
1842 |
esc_html_e( 'Only disable order duplication prevention for testing. Remember to re-enable the setting once done.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1843 |
?>
|
1844 |
-
|
1845 |
-
|
1846 |
}
|
1847 |
|
1848 |
public function wpm_setting_html_maximum_compatibility_mode()
|
@@ -1851,20 +1904,59 @@ class Admin
|
|
1851 |
// instead of not saving it and remove that array key entirely
|
1852 |
// https://stackoverflow.com/a/1992745/4688612
|
1853 |
?>
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
checked( $this->options['general']['maximum_compatibility_mode'] );
|
1860 |
?> />
|
1861 |
-
|
1862 |
esc_html_e( 'Enable the maximum compatibility mode', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1863 |
?>
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1868 |
}
|
1869 |
|
1870 |
private function get_order_duplication_prevention_text()
|
@@ -1872,7 +1964,7 @@ class Admin
|
|
1872 |
esc_html_e( 'Basic order duplication prevention is ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1873 |
}
|
1874 |
|
1875 |
-
private function add_to_cart_requirements_fulfilled()
|
1876 |
{
|
1877 |
|
1878 |
if ( $this->options['google']['ads']['conversion_id'] && $this->options['google']['ads']['conversion_label'] && $this->options['google']['ads']['aw_merchant_id'] ) {
|
@@ -1889,40 +1981,42 @@ class Admin
|
|
1889 |
// instead of not saving it and remove that array key entirely
|
1890 |
// https://stackoverflow.com/a/1992745/4688612
|
1891 |
?>
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
checked( $this->options['google']['ads']['dynamic_remarketing'] );
|
1898 |
?> />
|
1899 |
|
1900 |
-
|
1901 |
esc_html_e( 'Enable dynamic remarketing audience collection', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1902 |
?>
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
?>
|
1907 |
-
|
1908 |
-
|
1909 |
?>
|
1910 |
-
|
|
|
1911 |
|
1912 |
if ( !$this->options['google']['ads']['conversion_id'] ) {
|
1913 |
?>
|
1914 |
-
|
1915 |
-
|
1916 |
esc_html_e( 'Requires an active Google Ads Conversion ID', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1917 |
echo '<br>' ;
|
1918 |
}
|
1919 |
|
1920 |
-
|
1921 |
-
|
|
|
1922 |
esc_html_e( 'You need to choose the correct product identifier setting in order to match the product identifiers in the product feeds.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1923 |
?>
|
1924 |
-
|
1925 |
-
|
1926 |
}
|
1927 |
|
1928 |
public function wpm_option_html_variations_output()
|
@@ -1931,335 +2025,332 @@ class Admin
|
|
1931 |
// instead of not saving it and remove that array key entirely
|
1932 |
// https://stackoverflow.com/a/1992745/4688612
|
1933 |
?>
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
checked( $this->options['general']['variations_output'] );
|
1940 |
-
?>
|
1941 |
-
|
1942 |
-
|
1943 |
esc_html_e( 'Enable variations output', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1944 |
?>
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
?>
|
1949 |
-
|
1950 |
-
|
1951 |
?>
|
1952 |
-
|
1953 |
-
|
1954 |
esc_html_e( 'In order for this to work you need to upload your product feed including product variations and the item_group_id. Disable it, if you choose only to upload the parent product for variable products.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1955 |
?>
|
1956 |
-
|
1957 |
-
|
1958 |
}
|
1959 |
|
1960 |
public function wpm_plugin_option_google_business_vertical()
|
1961 |
{
|
1962 |
?>
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
echo checked( 0, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
1969 |
?>
|
1970 |
-
|
1971 |
-
|
1972 |
?>
|
1973 |
-
|
1974 |
-
|
1975 |
esc_html_e( 'Retail', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1976 |
?>
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
echo checked( 1, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
1985 |
?>
|
1986 |
-
|
1987 |
-
|
1988 |
?>
|
1989 |
-
|
1990 |
-
|
1991 |
esc_html_e( 'Education', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1992 |
?>
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
echo checked( 3, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2001 |
?>
|
2002 |
-
|
2003 |
-
|
2004 |
?>
|
2005 |
-
|
2006 |
-
|
2007 |
esc_html_e( 'Hotels and rentals', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2008 |
?>
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
echo checked( 4, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2017 |
?>
|
2018 |
-
|
2019 |
-
|
2020 |
?>
|
2021 |
-
|
2022 |
-
|
2023 |
esc_html_e( 'Jobs', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2024 |
?>
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
echo checked( 5, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2033 |
?>
|
2034 |
-
|
2035 |
-
|
2036 |
?>
|
2037 |
-
|
2038 |
-
|
2039 |
esc_html_e( 'Local deals', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2040 |
?>
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
echo checked( 6, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2049 |
?>
|
2050 |
-
|
2051 |
-
|
2052 |
?>
|
2053 |
-
|
2054 |
-
|
2055 |
esc_html_e( 'Real estate', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2056 |
?>
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
echo checked( 8, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2065 |
?>
|
2066 |
-
|
2067 |
-
|
2068 |
?>
|
2069 |
-
|
2070 |
-
|
2071 |
esc_html_e( 'Custom', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2072 |
?>
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
}
|
2077 |
|
2078 |
public function wpm_plugin_setting_aw_merchant_id()
|
2079 |
{
|
2080 |
-
echo "<input type='text' id='wpm_plugin_aw_merchant_id' name='wgact_plugin_options[google][ads][aw_merchant_id]' size='40' value='{$this->options['google']['ads']['aw_merchant_id']}' />" ;
|
2081 |
-
echo $this->get_status_icon( $this->options['google']['ads']['aw_merchant_id'] ) ;
|
2082 |
-
echo $this->get_documentation_html_by_key( 'aw_merchant_id' ) ;
|
2083 |
-
echo '<br>' ;
|
2084 |
-
esc_html_e( 'ID of your Google Merchant Center account. It looks like this: 12345678', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2085 |
-
}
|
2086 |
-
|
2087 |
-
public function wgact_plugin_setting_aw_feed_country()
|
2088 |
-
{
|
2089 |
-
?><b><?php
|
2090 |
-
echo $this->get_visitor_country() ;
|
2091 |
-
?></b><?php
|
2092 |
-
// echo '<br>' . 'get_external_ip_address: ' . WC_Geolocation::get_external_ip_address();
|
2093 |
-
// echo '<br>' . 'get_ip_address: ' . WC_Geolocation::get_ip_address();
|
2094 |
-
// echo '<p>' . 'geolocate_ip: ' . '<br>';
|
2095 |
-
// echo print_r(WC_Geolocation::geolocate_ip());
|
2096 |
-
// echo '<p>' . 'WC_Geolocation::geolocate_ip(WC_Geolocation::get_external_ip_address()): ' . '<br>';
|
2097 |
-
// echo print_r(WC_Geolocation::geolocate_ip(WC_Geolocation::get_external_ip_address()));
|
2098 |
?>
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2102 |
?>
|
2103 |
-
|
2104 |
-
|
2105 |
-
<?php
|
2106 |
-
}
|
2107 |
-
|
2108 |
-
// dupe in pixel
|
2109 |
-
public function get_visitor_country()
|
2110 |
-
{
|
2111 |
-
|
2112 |
-
if ( $this->isLocalhost() ) {
|
2113 |
-
// error_log('check external ip');
|
2114 |
-
$this->ip = WC_Geolocation::get_external_ip_address();
|
2115 |
-
} else {
|
2116 |
-
// error_log('check regular ip');
|
2117 |
-
$this->ip = WC_Geolocation::get_ip_address();
|
2118 |
-
}
|
2119 |
-
|
2120 |
-
$location = WC_Geolocation::geolocate_ip( $this->ip );
|
2121 |
-
// error_log ('ip: ' . $this->>$ip);
|
2122 |
-
// error_log ('country: ' . $location['country']);
|
2123 |
-
return $location['country'];
|
2124 |
-
}
|
2125 |
-
|
2126 |
-
// dupe in pixel
|
2127 |
-
public function isLocalhost() : bool
|
2128 |
-
{
|
2129 |
-
return in_array( $_SERVER['REMOTE_ADDR'], [ '127.0.0.1', '::1' ] );
|
2130 |
-
}
|
2131 |
-
|
2132 |
-
public function wgact_plugin_setting_aw_feed_language()
|
2133 |
-
{
|
2134 |
-
?><b><?php
|
2135 |
-
echo $this->get_gmc_language() ;
|
2136 |
-
?></b>
|
2137 |
-
<div style="margin-top:10px">
|
2138 |
-
<?php
|
2139 |
-
esc_html_e( 'The plugin will use the WordPress default language for this setting. If the shop uses translations, in theory we could also use the visitors locale. But, if that language is not set up in the Google Merchant Center we might run into issues. If you need more options here let us know:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2140 |
?>
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
}
|
2145 |
-
|
2146 |
-
// dupe in pixel
|
2147 |
-
public function get_gmc_language() : string
|
2148 |
-
{
|
2149 |
-
return strtoupper( substr( get_locale(), 0, 2 ) );
|
2150 |
}
|
2151 |
|
2152 |
public function wpm_plugin_option_product_identifier()
|
2153 |
{
|
2154 |
?>
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
echo checked( 0, $this->options['google']['ads']['product_identifier'], false ) ;
|
2160 |
-
|
|
|
2161 |
esc_html_e( 'post ID (default)', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2162 |
?></label>
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
echo checked( 2, $this->options['google']['ads']['product_identifier'], false ) ;
|
2169 |
-
|
|
|
2170 |
esc_html_e( 'SKU', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2171 |
?>
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
echo checked( 1, $this->options['google']['ads']['product_identifier'], false ) ;
|
2179 |
-
|
|
|
2180 |
esc_html_e( 'ID for the WooCommerce Google Product Feed. Outputs the post ID with woocommerce_gpf_ prefix *', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2181 |
?>
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
echo checked( 3, $this->options['google']['ads']['product_identifier'], false ) ;
|
2189 |
-
|
|
|
2190 |
esc_html_e( 'ID for the WooCommerce Google Listings & Ads Plugin. Outputs the post ID with gla_ prefix **', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2191 |
?>
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
esc_html_e( 'Choose a product identifier.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2197 |
?>
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
esc_html_e( '* This is for users of the WooCommerce Google Product Feed Plugin', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2202 |
?>
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
esc_html_e( '** This is for users of the WooCommerce Google Listings & Ads Plugin', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2208 |
?>
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
|
2213 |
-
|
2214 |
}
|
2215 |
|
2216 |
-
private function html_beta()
|
2217 |
{
|
2218 |
return '<div class="status-icon beta">' . esc_html__( 'beta', 'woocommerce-google-adwords-conversion-tracking-tag' ) . '</div>';
|
2219 |
}
|
2220 |
|
2221 |
-
private function html_active()
|
2222 |
{
|
2223 |
return '<div class="status-icon active">' . esc_html__( 'active', 'woocommerce-google-adwords-conversion-tracking-tag' ) . '</div>';
|
2224 |
}
|
2225 |
|
2226 |
-
private function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2227 |
{
|
2228 |
return '<div class="status-icon inactive">' . esc_html__( 'inactive', 'woocommerce-google-adwords-conversion-tracking-tag' ) . '</div>';
|
2229 |
}
|
2230 |
|
2231 |
-
private function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2232 |
{
|
2233 |
return '<div class="status-icon partially-active">' . esc_html__( 'partially active', 'woocommerce-google-adwords-conversion-tracking-tag' ) . '</div>';
|
2234 |
}
|
2235 |
|
2236 |
-
private function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2237 |
{
|
2238 |
|
2239 |
if ( !wpm_fs()->is__premium_only() && $this->options['general']['pro_version_demo'] ) {
|
2240 |
// if (1===1) {
|
2241 |
-
return '<div class="pro-feature">' . esc_html__(
|
2242 |
-
|
2243 |
-
|
|
|
|
|
|
|
|
|
2244 |
}
|
2245 |
|
2246 |
}
|
2247 |
|
2248 |
-
private function get_status_icon( $status, $requirements = true, $inactive_silent = false )
|
2249 |
{
|
2250 |
|
2251 |
if ( $status && $requirements ) {
|
2252 |
return $this->html_active();
|
2253 |
} elseif ( $status && !$requirements ) {
|
2254 |
return $this->html_partially_active();
|
2255 |
-
} elseif (
|
2256 |
return $this->html_inactive();
|
2257 |
}
|
2258 |
|
2259 |
return '';
|
2260 |
}
|
2261 |
|
2262 |
-
private function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2263 |
{
|
2264 |
|
2265 |
if ( !wpm_fs()->is__premium_only() && $this->options['general']['pro_version_demo'] ) {
|
@@ -2271,13 +2362,13 @@ class Admin
|
|
2271 |
}
|
2272 |
|
2273 |
// validate the options
|
2274 |
-
public function wpm_options_validate( $input )
|
2275 |
{
|
2276 |
// error_log(print_r($input, true));
|
2277 |
// validate Google Analytics Universal property ID
|
2278 |
if ( isset( $input['google']['analytics']['universal']['property_id'] ) ) {
|
2279 |
|
2280 |
-
if ( !$this->is_google_analytics_universal_property_id( $input['google']['analytics']['universal']['property_id'] ) ) {
|
2281 |
$input['google']['analytics']['universal']['property_id'] = ( isset( $this->options['google']['analytics']['universal']['property_id'] ) ? $this->options['google']['analytics']['universal']['property_id'] : '' );
|
2282 |
add_settings_error( 'wgact_plugin_options', 'invalid-google-analytics-universal-property-id', esc_html__( 'You have entered an invalid Google Analytics Universal property ID.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2283 |
}
|
@@ -2286,7 +2377,7 @@ class Admin
|
|
2286 |
// validate Google Analytics 4 measurement ID
|
2287 |
if ( isset( $input['google']['analytics']['ga4']['measurement_id'] ) ) {
|
2288 |
|
2289 |
-
if ( !$this->is_google_analytics_4_measurement_id( $input['google']['analytics']['ga4']['measurement_id'] ) ) {
|
2290 |
$input['google']['analytics']['ga4']['measurement_id'] = ( isset( $this->options['google']['analytics']['ga4']['measurement_id'] ) ? $this->options['google']['analytics']['ga4']['measurement_id'] : '' );
|
2291 |
add_settings_error( 'wgact_plugin_options', 'invalid-google-analytics-4-measurement-id', esc_html__( 'You have entered an invalid Google Analytics 4 measurement ID.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2292 |
}
|
@@ -2295,7 +2386,7 @@ class Admin
|
|
2295 |
// validate Google Analytics 4 API key
|
2296 |
if ( isset( $input['google']['analytics']['ga4']['api_secret'] ) ) {
|
2297 |
|
2298 |
-
if ( !$this->is_google_analytics_4_api_secret( $input['google']['analytics']['ga4']['api_secret'] ) ) {
|
2299 |
$input['google']['analytics']['ga4']['api_secret'] = ( isset( $this->options['google']['analytics']['ga4']['api_secret'] ) ? $this->options['google']['analytics']['ga4']['api_secret'] : '' );
|
2300 |
add_settings_error( 'wgact_plugin_options', 'invalid-google-analytics-4-measurement-id', esc_html__( 'You have entered an invalid Google Analytics 4 API key.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2301 |
}
|
@@ -2304,7 +2395,7 @@ class Admin
|
|
2304 |
// validate ['google]['ads']['conversion_id']
|
2305 |
if ( isset( $input['google']['ads']['conversion_id'] ) ) {
|
2306 |
|
2307 |
-
if ( !$this->is_gads_conversion_id( $input['google']['ads']['conversion_id'] ) ) {
|
2308 |
$input['google']['ads']['conversion_id'] = ( isset( $this->options['google']['ads']['conversion_id'] ) ? $this->options['google']['ads']['conversion_id'] : '' );
|
2309 |
add_settings_error( 'wgact_plugin_options', 'invalid-conversion-id', esc_html__( 'You have entered an invalid conversion ID. It only contains 8 to 10 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2310 |
}
|
@@ -2313,7 +2404,7 @@ class Admin
|
|
2313 |
// validate ['google]['ads']['conversion_label']
|
2314 |
if ( isset( $input['google']['ads']['conversion_label'] ) ) {
|
2315 |
|
2316 |
-
if ( !$this->is_gads_conversion_label( $input['google']['ads']['conversion_label'] ) ) {
|
2317 |
$input['google']['ads']['conversion_label'] = ( isset( $this->options['google']['ads']['conversion_label'] ) ? $this->options['google']['ads']['conversion_label'] : '' );
|
2318 |
add_settings_error( 'wgact_plugin_options', 'invalid-conversion-label', esc_html__( 'You have entered an invalid conversion label.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2319 |
}
|
@@ -2322,7 +2413,7 @@ class Admin
|
|
2322 |
// validate ['google]['ads']['phone_conversion_label']
|
2323 |
if ( isset( $input['google']['ads']['phone_conversion_label'] ) ) {
|
2324 |
|
2325 |
-
if ( !$this->is_gads_conversion_label( $input['google']['ads']['phone_conversion_label'] ) ) {
|
2326 |
$input['google']['ads']['phone_conversion_label'] = ( isset( $this->options['google']['ads']['phone_conversion_label'] ) ? $this->options['google']['ads']['phone_conversion_label'] : '' );
|
2327 |
add_settings_error( 'wgact_plugin_options', 'invalid-conversion-label', esc_html__( 'You have entered an invalid conversion label.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2328 |
}
|
@@ -2331,7 +2422,7 @@ class Admin
|
|
2331 |
// validate ['google]['ads']['aw_merchant_id']
|
2332 |
if ( isset( $input['google']['ads']['aw_merchant_id'] ) ) {
|
2333 |
|
2334 |
-
if ( !$this->is_gads_aw_merchant_id( $input['google']['ads']['aw_merchant_id'] ) ) {
|
2335 |
$input['google']['ads']['aw_merchant_id'] = ( isset( $this->options['google']['ads']['aw_merchant_id'] ) ? $this->options['google']['ads']['aw_merchant_id'] : '' );
|
2336 |
add_settings_error( 'wgact_plugin_options', 'invalid-aw-merchant-id', esc_html__( 'You have entered an invalid merchant ID. It only contains 7 to 10 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2337 |
}
|
@@ -2340,7 +2431,7 @@ class Admin
|
|
2340 |
// validate Google Optimize container ID
|
2341 |
if ( isset( $input['google']['optimize']['container_id'] ) ) {
|
2342 |
|
2343 |
-
if ( !$this->is_google_optimize_measurement_id( $input['google']['optimize']['container_id'] ) ) {
|
2344 |
$input['google']['optimize']['container_id'] = ( isset( $this->options['google']['optimize']['container_id'] ) ? $this->options['google']['optimize']['container_id'] : '' );
|
2345 |
add_settings_error( 'wgact_plugin_options', 'invalid-google-optimize-container-id', esc_html__( 'You have entered an invalid Google Optimize container ID.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2346 |
}
|
@@ -2349,25 +2440,25 @@ class Admin
|
|
2349 |
// validate ['facebook']['pixel_id']
|
2350 |
if ( isset( $input['facebook']['pixel_id'] ) ) {
|
2351 |
|
2352 |
-
if ( !$this->is_facebook_pixel_id( $input['facebook']['pixel_id'] ) ) {
|
2353 |
$input['facebook']['pixel_id'] = ( isset( $this->options['facebook']['pixel_id'] ) ? $this->options['facebook']['pixel_id'] : '' );
|
2354 |
-
add_settings_error( 'wgact_plugin_options', 'invalid-facebook-pixel-id', esc_html__( 'You have entered an invalid Facebook pixel ID. It only contains 14 to 16 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2355 |
}
|
2356 |
|
2357 |
}
|
2358 |
// validate ['facebook']['capi']['token']
|
2359 |
if ( isset( $input['facebook']['capi']['token'] ) ) {
|
2360 |
|
2361 |
-
if ( !$this->is_facebook_capi_token( $input['facebook']['capi']['token'] ) ) {
|
2362 |
$input['facebook']['capi']['token'] = ( isset( $this->options['facebook']['capi']['token'] ) ? $this->options['facebook']['capi']['token'] : '' );
|
2363 |
-
add_settings_error( 'wgact_plugin_options', 'invalid-facebook-pixel-id', esc_html__( 'You have entered an invalid Facebook CAPI token.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2364 |
}
|
2365 |
|
2366 |
}
|
2367 |
// validate Bing Ads UET tag ID
|
2368 |
if ( isset( $input['bing']['uet_tag_id'] ) ) {
|
2369 |
|
2370 |
-
if ( !$this->is_bing_uet_tag_id( $input['bing']['uet_tag_id'] ) ) {
|
2371 |
$input['bing']['uet_tag_id'] = ( isset( $this->options['bing']['uet_tag_id'] ) ? $this->options['bing']['uet_tag_id'] : '' );
|
2372 |
add_settings_error( 'wgact_plugin_options', 'invalid-bing-ads-uet-tag-id', esc_html__( 'You have entered an invalid Bing Ads UET tag ID. It only contains 7 to 9 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2373 |
}
|
@@ -2376,7 +2467,7 @@ class Admin
|
|
2376 |
// validate Twitter pixel ID
|
2377 |
if ( isset( $input['twitter']['pixel_id'] ) ) {
|
2378 |
|
2379 |
-
if ( !$this->is_twitter_pixel_id( $input['twitter']['pixel_id'] ) ) {
|
2380 |
$input['twitter']['pixel_id'] = ( isset( $this->options['twitter']['pixel_id'] ) ? $this->options['twitter']['pixel_id'] : '' );
|
2381 |
add_settings_error( 'wgact_plugin_options', 'invalid-twitter-pixel-id', esc_html__( 'You have entered an invalid Twitter pixel ID. It only contains 5 to 7 lowercase letters and numbers.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2382 |
}
|
@@ -2385,7 +2476,7 @@ class Admin
|
|
2385 |
// validate Pinterest pixel ID
|
2386 |
if ( isset( $input['pinterest']['pixel_id'] ) ) {
|
2387 |
|
2388 |
-
if ( !$this->is_pinterest_pixel_id( $input['pinterest']['pixel_id'] ) ) {
|
2389 |
$input['pinterest']['pixel_id'] = ( isset( $this->options['pinterest']['pixel_id'] ) ? $this->options['pinterest']['pixel_id'] : '' );
|
2390 |
add_settings_error( 'wgact_plugin_options', 'invalid-pinterest-pixel-id', esc_html__( 'You have entered an invalid Pinterest pixel ID. It only contains 13 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2391 |
}
|
@@ -2394,7 +2485,7 @@ class Admin
|
|
2394 |
// validate Snapchat pixel ID
|
2395 |
if ( isset( $input['snapchat']['pixel_id'] ) ) {
|
2396 |
|
2397 |
-
if ( !$this->is_snapchat_pixel_id( $input['snapchat']['pixel_id'] ) ) {
|
2398 |
$input['snapchat']['pixel_id'] = ( isset( $this->options['snapchat']['pixel_id'] ) ? $this->options['snapchat']['pixel_id'] : '' );
|
2399 |
add_settings_error( 'wgact_plugin_options', 'invalid-snapchat-pixel-id', esc_html__( 'You have entered an invalid Snapchat pixel ID.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2400 |
}
|
@@ -2403,7 +2494,7 @@ class Admin
|
|
2403 |
// validate TikTok pixel ID
|
2404 |
if ( isset( $input['tiktok']['pixel_id'] ) ) {
|
2405 |
|
2406 |
-
if ( !$this->is_tiktok_pixel_id( $input['tiktok']['pixel_id'] ) ) {
|
2407 |
$input['tiktok']['pixel_id'] = ( isset( $this->options['tiktok']['pixel_id'] ) ? $this->options['tiktok']['pixel_id'] : '' );
|
2408 |
add_settings_error( 'wgact_plugin_options', 'invalid-tiktok-pixel-id', esc_html__( 'You have entered an invalid TikTok pixel ID.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2409 |
}
|
@@ -2412,28 +2503,24 @@ class Admin
|
|
2412 |
// validate Hotjar site ID
|
2413 |
if ( isset( $input['hotjar']['site_id'] ) ) {
|
2414 |
|
2415 |
-
if ( !$this->is_hotjar_site_id( $input['hotjar']['site_id'] ) ) {
|
2416 |
$input['hotjar']['site_id'] = ( isset( $this->options['hotjar']['site_id'] ) ? $this->options['hotjar']['site_id'] : '' );
|
2417 |
add_settings_error( 'wgact_plugin_options', 'invalid-hotjar-site-id', esc_html__( 'You have entered an invalid Hotjar site ID. It only contains 6 to 9 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2418 |
}
|
2419 |
|
2420 |
}
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
// $input = $this->merge_options($this->options, $input);
|
2428 |
-
// error_log('input merged');
|
2429 |
-
// error_log(print_r($input, true));
|
2430 |
-
return $input;
|
2431 |
}
|
2432 |
|
2433 |
// Recursively go through the array and merge (overwrite old values with new ones
|
2434 |
// if a value is missing in the input array, set it to value zero in the options array
|
2435 |
// Omit key like 'db_version' since they would be overwritten with zero.
|
2436 |
-
protected function merge_options( $array_existing, $array_input )
|
2437 |
{
|
2438 |
$array_output = [];
|
2439 |
foreach ( $array_existing as $key => $value ) {
|
@@ -2460,13 +2547,16 @@ class Admin
|
|
2460 |
return $array_output;
|
2461 |
}
|
2462 |
|
2463 |
-
protected function non_form_keys( $input )
|
2464 |
{
|
2465 |
// place here what could be overwritten when a form field is missing
|
2466 |
// and what should not be re-set to the default value
|
2467 |
// but should be preserved
|
2468 |
$non_form_keys = [
|
2469 |
'db_version' => $this->options['db_version'],
|
|
|
|
|
|
|
2470 |
];
|
2471 |
// in case the form field input is missing
|
2472 |
// if (!array_key_exists('google_business_vertical', $input['google']['ads'])) {
|
@@ -2475,7 +2565,7 @@ class Admin
|
|
2475 |
return $non_form_keys;
|
2476 |
}
|
2477 |
|
2478 |
-
function set_array_value_to_zero( $array )
|
2479 |
{
|
2480 |
array_walk_recursive( $array, function ( &$leafnode ) {
|
2481 |
$leafnode = 0;
|
@@ -2483,416 +2573,7 @@ class Admin
|
|
2483 |
return $array;
|
2484 |
}
|
2485 |
|
2486 |
-
|
2487 |
-
{
|
2488 |
-
if ( empty($string) ) {
|
2489 |
-
return true;
|
2490 |
-
}
|
2491 |
-
$re = '/^\\d{8,11}$/m';
|
2492 |
-
return $this->validate_with_regex( $re, $string );
|
2493 |
-
}
|
2494 |
-
|
2495 |
-
protected function is_gads_conversion_label( $string ) : bool
|
2496 |
-
{
|
2497 |
-
if ( empty($string) ) {
|
2498 |
-
return true;
|
2499 |
-
}
|
2500 |
-
$re = '/^[-a-zA-Z_0-9]{17,20}$/m';
|
2501 |
-
return $this->validate_with_regex( $re, $string );
|
2502 |
-
}
|
2503 |
-
|
2504 |
-
protected function is_gads_aw_merchant_id( $string ) : bool
|
2505 |
-
{
|
2506 |
-
if ( empty($string) ) {
|
2507 |
-
return true;
|
2508 |
-
}
|
2509 |
-
$re = '/^\\d{7,10}$/m';
|
2510 |
-
return $this->validate_with_regex( $re, $string );
|
2511 |
-
}
|
2512 |
-
|
2513 |
-
public function is_google_optimize_measurement_id( $string ) : bool
|
2514 |
-
{
|
2515 |
-
if ( empty($string) ) {
|
2516 |
-
return true;
|
2517 |
-
}
|
2518 |
-
$re = '/^(GTM|OPT)-[A-Z0-9]{6,8}$/m';
|
2519 |
-
return $this->validate_with_regex( $re, $string );
|
2520 |
-
}
|
2521 |
-
|
2522 |
-
public function is_google_analytics_universal_property_id( $string ) : bool
|
2523 |
-
{
|
2524 |
-
if ( empty($string) ) {
|
2525 |
-
return true;
|
2526 |
-
}
|
2527 |
-
$re = '/^UA-\\d{6,10}-\\d{1,2}$/m';
|
2528 |
-
return $this->validate_with_regex( $re, $string );
|
2529 |
-
}
|
2530 |
-
|
2531 |
-
public function is_google_analytics_4_measurement_id( $string ) : bool
|
2532 |
-
{
|
2533 |
-
if ( empty($string) ) {
|
2534 |
-
return true;
|
2535 |
-
}
|
2536 |
-
$re = '/^G-[A-Z0-9]{10,12}$/m';
|
2537 |
-
return $this->validate_with_regex( $re, $string );
|
2538 |
-
}
|
2539 |
-
|
2540 |
-
public function is_google_analytics_4_api_secret( $string ) : bool
|
2541 |
-
{
|
2542 |
-
if ( empty($string) ) {
|
2543 |
-
return true;
|
2544 |
-
}
|
2545 |
-
$re = '/^[a-zA-Z\\d_-]{18,26}$/m';
|
2546 |
-
return $this->validate_with_regex( $re, $string );
|
2547 |
-
}
|
2548 |
-
|
2549 |
-
protected function is_facebook_pixel_id( $string ) : bool
|
2550 |
-
{
|
2551 |
-
if ( empty($string) ) {
|
2552 |
-
return true;
|
2553 |
-
}
|
2554 |
-
$re = '/^\\d{14,16}$/m';
|
2555 |
-
return $this->validate_with_regex( $re, $string );
|
2556 |
-
}
|
2557 |
-
|
2558 |
-
protected function is_facebook_capi_token( $string ) : bool
|
2559 |
-
{
|
2560 |
-
if ( empty($string) ) {
|
2561 |
-
return true;
|
2562 |
-
}
|
2563 |
-
$re = '/^[a-zA-Z\\d_-]{150,250}$/m';
|
2564 |
-
return $this->validate_with_regex( $re, $string );
|
2565 |
-
}
|
2566 |
-
|
2567 |
-
protected function is_bing_uet_tag_id( $string ) : bool
|
2568 |
-
{
|
2569 |
-
if ( empty($string) ) {
|
2570 |
-
return true;
|
2571 |
-
}
|
2572 |
-
$re = '/^\\d{7,9}$/m';
|
2573 |
-
return $this->validate_with_regex( $re, $string );
|
2574 |
-
}
|
2575 |
-
|
2576 |
-
protected function is_twitter_pixel_id( $string ) : bool
|
2577 |
-
{
|
2578 |
-
if ( empty($string) ) {
|
2579 |
-
return true;
|
2580 |
-
}
|
2581 |
-
$re = '/^[a-z0-9]{5,7}$/m';
|
2582 |
-
return $this->validate_with_regex( $re, $string );
|
2583 |
-
}
|
2584 |
-
|
2585 |
-
protected function is_pinterest_pixel_id( $string ) : bool
|
2586 |
-
{
|
2587 |
-
if ( empty($string) ) {
|
2588 |
-
return true;
|
2589 |
-
}
|
2590 |
-
$re = '/^\\d{13}$/m';
|
2591 |
-
return $this->validate_with_regex( $re, $string );
|
2592 |
-
}
|
2593 |
-
|
2594 |
-
protected function is_snapchat_pixel_id( $string ) : bool
|
2595 |
-
{
|
2596 |
-
if ( empty($string) ) {
|
2597 |
-
return true;
|
2598 |
-
}
|
2599 |
-
$re = '/^[a-z0-9\\-]*$/m';
|
2600 |
-
return $this->validate_with_regex( $re, $string );
|
2601 |
-
}
|
2602 |
-
|
2603 |
-
protected function is_tiktok_pixel_id( $string ) : bool
|
2604 |
-
{
|
2605 |
-
if ( empty($string) ) {
|
2606 |
-
return true;
|
2607 |
-
}
|
2608 |
-
$re = '/^[A-Z0-9]{20,20}$/m';
|
2609 |
-
return $this->validate_with_regex( $re, $string );
|
2610 |
-
}
|
2611 |
-
|
2612 |
-
protected function is_hotjar_site_id( $string ) : bool
|
2613 |
-
{
|
2614 |
-
if ( empty($string) ) {
|
2615 |
-
return true;
|
2616 |
-
}
|
2617 |
-
$re = '/^\\d{6,9}$/m';
|
2618 |
-
return $this->validate_with_regex( $re, $string );
|
2619 |
-
}
|
2620 |
-
|
2621 |
-
protected function validate_with_regex( string $re, $string ) : bool
|
2622 |
-
{
|
2623 |
-
preg_match_all(
|
2624 |
-
$re,
|
2625 |
-
$string,
|
2626 |
-
$matches,
|
2627 |
-
PREG_SET_ORDER,
|
2628 |
-
0
|
2629 |
-
);
|
2630 |
-
|
2631 |
-
if ( isset( $matches[0] ) ) {
|
2632 |
-
return true;
|
2633 |
-
} else {
|
2634 |
-
return false;
|
2635 |
-
}
|
2636 |
-
|
2637 |
-
}
|
2638 |
-
|
2639 |
-
private function get_consent_mode_regions() : array
|
2640 |
-
{
|
2641 |
-
return [
|
2642 |
-
'AF' => 'Afghanistan',
|
2643 |
-
'AX' => 'Åland Islands',
|
2644 |
-
'AL' => 'Albania',
|
2645 |
-
'DZ' => 'Algeria',
|
2646 |
-
'AS' => 'American Samoa',
|
2647 |
-
'AD' => 'Andorra',
|
2648 |
-
'AO' => 'Angola',
|
2649 |
-
'AI' => 'Anguilla',
|
2650 |
-
'AQ' => 'Antarctica',
|
2651 |
-
'AG' => 'Antigua and Barbuda',
|
2652 |
-
'AR' => 'Argentina',
|
2653 |
-
'AM' => 'Armenia',
|
2654 |
-
'AW' => 'Aruba',
|
2655 |
-
'AU' => 'Australia',
|
2656 |
-
'AT' => 'Austria',
|
2657 |
-
'AZ' => 'Azerbaijan',
|
2658 |
-
'BS' => 'Bahamas',
|
2659 |
-
'BH' => 'Bahrain',
|
2660 |
-
'BD' => 'Bangladesh',
|
2661 |
-
'BB' => 'Barbados',
|
2662 |
-
'BY' => 'Belarus',
|
2663 |
-
'BE' => 'Belgium',
|
2664 |
-
'BZ' => 'Belize',
|
2665 |
-
'BJ' => 'Benin',
|
2666 |
-
'BM' => 'Bermuda',
|
2667 |
-
'BT' => 'Bhutan',
|
2668 |
-
'BO' => 'Bolivia, Plurinational State of',
|
2669 |
-
'BQ' => 'Bonaire, Sint Eustatius and Saba',
|
2670 |
-
'BA' => 'Bosnia and Herzegovina',
|
2671 |
-
'BW' => 'Botswana',
|
2672 |
-
'BV' => 'Bouvet Island',
|
2673 |
-
'BR' => 'Brazil',
|
2674 |
-
'IO' => 'British Indian Ocean Territory',
|
2675 |
-
'BN' => 'Brunei Darussalam',
|
2676 |
-
'BG' => 'Bulgaria',
|
2677 |
-
'BF' => 'Burkina Faso',
|
2678 |
-
'BI' => 'Burundi',
|
2679 |
-
'KH' => 'Cambodia',
|
2680 |
-
'CM' => 'Cameroon',
|
2681 |
-
'CA' => 'Canada',
|
2682 |
-
'CV' => 'Cape Verde',
|
2683 |
-
'KY' => 'Cayman Islands',
|
2684 |
-
'CF' => 'Central African Republic',
|
2685 |
-
'TD' => 'Chad',
|
2686 |
-
'CL' => 'Chile',
|
2687 |
-
'CN' => 'China',
|
2688 |
-
'CX' => 'Christmas Island',
|
2689 |
-
'CC' => 'Cocos (Keeling) Islands',
|
2690 |
-
'CO' => 'Colombia',
|
2691 |
-
'KM' => 'Comoros',
|
2692 |
-
'CG' => 'Congo',
|
2693 |
-
'CD' => 'Congo, the Democratic Republic of the',
|
2694 |
-
'CK' => 'Cook Islands',
|
2695 |
-
'CR' => 'Costa Rica',
|
2696 |
-
'CI' => 'Côte d\'Ivoire',
|
2697 |
-
'HR' => 'Croatia',
|
2698 |
-
'CU' => 'Cuba',
|
2699 |
-
'CW' => 'Curaçao',
|
2700 |
-
'CY' => 'Cyprus',
|
2701 |
-
'CZ' => 'Czech Republic',
|
2702 |
-
'DK' => 'Denmark',
|
2703 |
-
'DJ' => 'Djibouti',
|
2704 |
-
'DM' => 'Dominica',
|
2705 |
-
'DO' => 'Dominican Republic',
|
2706 |
-
'EC' => 'Ecuador',
|
2707 |
-
'EG' => 'Egypt',
|
2708 |
-
'SV' => 'El Salvador',
|
2709 |
-
'GQ' => 'Equatorial Guinea',
|
2710 |
-
'ER' => 'Eritrea',
|
2711 |
-
'EE' => 'Estonia',
|
2712 |
-
'ET' => 'Ethiopia',
|
2713 |
-
'FK' => 'Falkland Islands (Malvinas)',
|
2714 |
-
'FO' => 'Faroe Islands',
|
2715 |
-
'FJ' => 'Fiji',
|
2716 |
-
'FI' => 'Finland',
|
2717 |
-
'FR' => 'France',
|
2718 |
-
'GF' => 'French Guiana',
|
2719 |
-
'PF' => 'French Polynesia',
|
2720 |
-
'TF' => 'French Southern Territories',
|
2721 |
-
'GA' => 'Gabon',
|
2722 |
-
'GM' => 'Gambia',
|
2723 |
-
'GE' => 'Georgia',
|
2724 |
-
'DE' => 'Germany',
|
2725 |
-
'GH' => 'Ghana',
|
2726 |
-
'GI' => 'Gibraltar',
|
2727 |
-
'GR' => 'Greece',
|
2728 |
-
'GL' => 'Greenland',
|
2729 |
-
'GD' => 'Grenada',
|
2730 |
-
'GP' => 'Guadeloupe',
|
2731 |
-
'GU' => 'Guam',
|
2732 |
-
'GT' => 'Guatemala',
|
2733 |
-
'GG' => 'Guernsey',
|
2734 |
-
'GN' => 'Guinea',
|
2735 |
-
'GW' => 'Guinea-Bissau',
|
2736 |
-
'GY' => 'Guyana',
|
2737 |
-
'HT' => 'Haiti',
|
2738 |
-
'HM' => 'Heard Island and McDonald Islands',
|
2739 |
-
'VA' => 'Holy See (Vatican City State)',
|
2740 |
-
'HN' => 'Honduras',
|
2741 |
-
'HK' => 'Hong Kong',
|
2742 |
-
'HU' => 'Hungary',
|
2743 |
-
'IS' => 'Iceland',
|
2744 |
-
'IN' => 'India',
|
2745 |
-
'ID' => 'Indonesia',
|
2746 |
-
'IR' => 'Iran, Islamic Republic of',
|
2747 |
-
'IQ' => 'Iraq',
|
2748 |
-
'IE' => 'Ireland',
|
2749 |
-
'IM' => 'Isle of Man',
|
2750 |
-
'IL' => 'Israel',
|
2751 |
-
'IT' => 'Italy',
|
2752 |
-
'JM' => 'Jamaica',
|
2753 |
-
'JP' => 'Japan',
|
2754 |
-
'JE' => 'Jersey',
|
2755 |
-
'JO' => 'Jordan',
|
2756 |
-
'KZ' => 'Kazakhstan',
|
2757 |
-
'KE' => 'Kenya',
|
2758 |
-
'KI' => 'Kiribati',
|
2759 |
-
'KP' => 'Korea, Democratic People\'s Republic of',
|
2760 |
-
'KR' => 'Korea, Republic of',
|
2761 |
-
'KW' => 'Kuwait',
|
2762 |
-
'KG' => 'Kyrgyzstan',
|
2763 |
-
'LA' => 'Lao People\'s Democratic Republic',
|
2764 |
-
'LV' => 'Latvia',
|
2765 |
-
'LB' => 'Lebanon',
|
2766 |
-
'LS' => 'Lesotho',
|
2767 |
-
'LR' => 'Liberia',
|
2768 |
-
'LY' => 'Libya',
|
2769 |
-
'LI' => 'Liechtenstein',
|
2770 |
-
'LT' => 'Lithuania',
|
2771 |
-
'LU' => 'Luxembourg',
|
2772 |
-
'MO' => 'Macao',
|
2773 |
-
'MK' => 'North Macedonia',
|
2774 |
-
'MG' => 'Madagascar',
|
2775 |
-
'MW' => 'Malawi',
|
2776 |
-
'MY' => 'Malaysia',
|
2777 |
-
'MV' => 'Maldives',
|
2778 |
-
'ML' => 'Mali',
|
2779 |
-
'MT' => 'Malta',
|
2780 |
-
'MH' => 'Marshall Islands',
|
2781 |
-
'MQ' => 'Martinique',
|
2782 |
-
'MR' => 'Mauritania',
|
2783 |
-
'MU' => 'Mauritius',
|
2784 |
-
'YT' => 'Mayotte',
|
2785 |
-
'MX' => 'Mexico',
|
2786 |
-
'FM' => 'Micronesia, Federated States of',
|
2787 |
-
'MD' => 'Moldova, Republic of',
|
2788 |
-
'MC' => 'Monaco',
|
2789 |
-
'MN' => 'Mongolia',
|
2790 |
-
'ME' => 'Montenegro',
|
2791 |
-
'MS' => 'Montserrat',
|
2792 |
-
'MA' => 'Morocco',
|
2793 |
-
'MZ' => 'Mozambique',
|
2794 |
-
'MM' => 'Myanmar',
|
2795 |
-
'NA' => 'Namibia',
|
2796 |
-
'NR' => 'Nauru',
|
2797 |
-
'NP' => 'Nepal',
|
2798 |
-
'NL' => 'Netherlands',
|
2799 |
-
'NC' => 'New Caledonia',
|
2800 |
-
'NZ' => 'New Zealand',
|
2801 |
-
'NI' => 'Nicaragua',
|
2802 |
-
'NE' => 'Niger',
|
2803 |
-
'NG' => 'Nigeria',
|
2804 |
-
'NU' => 'Niue',
|
2805 |
-
'NF' => 'Norfolk Island',
|
2806 |
-
'MP' => 'Northern Mariana Islands',
|
2807 |
-
'NO' => 'Norway',
|
2808 |
-
'OM' => 'Oman',
|
2809 |
-
'PK' => 'Pakistan',
|
2810 |
-
'PW' => 'Palau',
|
2811 |
-
'PS' => 'Palestine, State of',
|
2812 |
-
'PA' => 'Panama',
|
2813 |
-
'PG' => 'Papua New Guinea',
|
2814 |
-
'PY' => 'Paraguay',
|
2815 |
-
'PE' => 'Peru',
|
2816 |
-
'PH' => 'Philippines',
|
2817 |
-
'PN' => 'Pitcairn',
|
2818 |
-
'PL' => 'Poland',
|
2819 |
-
'PT' => 'Portugal',
|
2820 |
-
'PR' => 'Puerto Rico',
|
2821 |
-
'QA' => 'Qatar',
|
2822 |
-
'RE' => 'Réunion',
|
2823 |
-
'RO' => 'Romania',
|
2824 |
-
'RU' => 'Russian Federation',
|
2825 |
-
'RW' => 'Rwanda',
|
2826 |
-
'BL' => 'Saint Barthélemy',
|
2827 |
-
'SH' => 'Saint Helena, Ascension and Tristan da Cunha',
|
2828 |
-
'KN' => 'Saint Kitts and Nevis',
|
2829 |
-
'LC' => 'Saint Lucia',
|
2830 |
-
'MF' => 'Saint Martin (French part)',
|
2831 |
-
'PM' => 'Saint Pierre and Miquelon',
|
2832 |
-
'VC' => 'Saint Vincent and the Grenadines',
|
2833 |
-
'WS' => 'Samoa',
|
2834 |
-
'SM' => 'San Marino',
|
2835 |
-
'ST' => 'Sao Tome and Principe',
|
2836 |
-
'SA' => 'Saudi Arabia',
|
2837 |
-
'SN' => 'Senegal',
|
2838 |
-
'RS' => 'Serbia',
|
2839 |
-
'SC' => 'Seychelles',
|
2840 |
-
'SL' => 'Sierra Leone',
|
2841 |
-
'SG' => 'Singapore',
|
2842 |
-
'SX' => 'Sint Maarten (Dutch part)',
|
2843 |
-
'SK' => 'Slovakia',
|
2844 |
-
'SI' => 'Slovenia',
|
2845 |
-
'SB' => 'Solomon Islands',
|
2846 |
-
'SO' => 'Somalia',
|
2847 |
-
'ZA' => 'South Africa',
|
2848 |
-
'GS' => 'South Georgia and the South Sandwich Islands',
|
2849 |
-
'SS' => 'South Sudan',
|
2850 |
-
'ES' => 'Spain',
|
2851 |
-
'LK' => 'Sri Lanka',
|
2852 |
-
'SD' => 'Sudan',
|
2853 |
-
'SR' => 'Suriname',
|
2854 |
-
'SJ' => 'Svalbard and Jan Mayen',
|
2855 |
-
'SZ' => 'Swaziland',
|
2856 |
-
'SE' => 'Sweden',
|
2857 |
-
'CH' => 'Switzerland',
|
2858 |
-
'SY' => 'Syrian Arab Republic',
|
2859 |
-
'TW' => 'Taiwan, Province of China',
|
2860 |
-
'TJ' => 'Tajikistan',
|
2861 |
-
'TZ' => 'Tanzania, United Republic of',
|
2862 |
-
'TH' => 'Thailand',
|
2863 |
-
'TL' => 'Timor-Leste',
|
2864 |
-
'TG' => 'Togo',
|
2865 |
-
'TK' => 'Tokelau',
|
2866 |
-
'TO' => 'Tonga',
|
2867 |
-
'TT' => 'Trinidad and Tobago',
|
2868 |
-
'TN' => 'Tunisia',
|
2869 |
-
'TR' => 'Turkey',
|
2870 |
-
'TM' => 'Turkmenistan',
|
2871 |
-
'TC' => 'Turks and Caicos Islands',
|
2872 |
-
'TV' => 'Tuvalu',
|
2873 |
-
'UG' => 'Uganda',
|
2874 |
-
'UA' => 'Ukraine',
|
2875 |
-
'AE' => 'United Arab Emirates',
|
2876 |
-
'GB' => 'United Kingdom',
|
2877 |
-
'US' => 'United States',
|
2878 |
-
'US-CA' => 'United States - California',
|
2879 |
-
'UM' => 'United States Minor Outlying Islands',
|
2880 |
-
'UY' => 'Uruguay',
|
2881 |
-
'UZ' => 'Uzbekistan',
|
2882 |
-
'VU' => 'Vanuatu',
|
2883 |
-
'VE' => 'Venezuela, Bolivarian Republic of',
|
2884 |
-
'VN' => 'Viet Nam',
|
2885 |
-
'VG' => 'Virgin Islands, British',
|
2886 |
-
'VI' => 'Virgin Islands, U.S.',
|
2887 |
-
'WF' => 'Wallis and Futuna',
|
2888 |
-
'EH' => 'Western Sahara',
|
2889 |
-
'YE' => 'Yemen',
|
2890 |
-
'ZM' => 'Zambia',
|
2891 |
-
'ZW' => 'Zimbabwe',
|
2892 |
-
];
|
2893 |
-
}
|
2894 |
-
|
2895 |
-
private function pro_version_demo_active() : bool
|
2896 |
{
|
2897 |
|
2898 |
if ( $this->options['general']['pro_version_demo'] ) {
|
1 |
<?php
|
2 |
|
3 |
// TODO move script for copying debug info into a proper .js enqueued file, or switch tabs to JavaScript switching and always save all settings at the same time
|
|
|
4 |
namespace WCPM\Classes\Admin;
|
5 |
|
6 |
+
use WCPM\Classes\Pixels\Google\Google ;
|
|
|
7 |
use WCPM\Classes\Pixels\Trait_Shop ;
|
8 |
|
9 |
if ( !defined( 'ABSPATH' ) ) {
|
13 |
|
14 |
class Admin
|
15 |
{
|
|
|
16 |
use Trait_Shop ;
|
17 |
public $ip ;
|
18 |
protected $text_domain ;
|
19 |
protected $options ;
|
20 |
protected $plugin_hook ;
|
21 |
protected $documentation ;
|
22 |
+
private $consent_mode_regions ;
|
23 |
+
private $validations ;
|
24 |
+
private $google ;
|
25 |
public function __construct( $options )
|
26 |
{
|
27 |
$this->options = $options;
|
28 |
$this->plugin_hook = 'woocommerce_page_wpm';
|
29 |
$this->documentation = new Documentation();
|
30 |
+
$this->google = new Google( $this->options );
|
31 |
add_action( 'admin_enqueue_scripts', [ $this, 'wpm_admin_scripts' ] );
|
32 |
// add the admin options page
|
33 |
add_action( 'admin_menu', [ $this, 'wpm_plugin_admin_add_page' ], 99 );
|
34 |
// install a settings page in the admin console
|
35 |
add_action( 'admin_init', [ $this, 'wpm_plugin_admin_init' ] );
|
36 |
// add admin scripts to plugins.php page
|
37 |
+
add_action( 'load-plugins.php', [ $this, 'freemius_load_deactivation_button_js' ] );
|
38 |
// Load textdomain
|
39 |
add_action( 'init', [ $this, 'load_plugin_textdomain' ] );
|
40 |
wpm_fs()->add_filter( 'checkout/purchaseCompleted', [ $this, 'my_after_purchase_js' ] );
|
41 |
wpm_fs()->add_filter( 'templates/checkout.php', [ $this, 'my_checkout_enrich' ] );
|
42 |
+
// end __construct
|
43 |
+
$this->consent_mode_regions = new Consent_Mode_Regions();
|
44 |
+
$this->validations = new Validations();
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function if_is_wpm_admin_page()
|
48 |
+
{
|
49 |
+
$_get = filter_input_array( INPUT_GET, FILTER_SANITIZE_FULL_SPECIAL_CHARS );
|
50 |
+
|
51 |
+
if ( !empty($_get['page']) && 'wpm' === $_get['page'] ) {
|
52 |
+
return true;
|
53 |
+
} else {
|
54 |
+
return false;
|
55 |
+
}
|
56 |
+
|
57 |
}
|
58 |
|
59 |
// This function is only called when our plugin's page loads!
|
60 |
+
public function freemius_load_deactivation_button_js()
|
61 |
{
|
62 |
add_action( 'admin_enqueue_scripts', [ $this, 'freemius_enqueue_deactivation_button_js' ] );
|
63 |
}
|
64 |
|
65 |
+
public function freemius_enqueue_deactivation_button_js()
|
66 |
{
|
67 |
wp_enqueue_script(
|
68 |
'freemius-enqueue-deactivation-button',
|
71 |
WPM_CURRENT_VERSION,
|
72 |
true
|
73 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
|
76 |
+
public function my_after_purchase_js( $js_function )
|
77 |
{
|
78 |
+
return "function ( response ) {\n\n let\n isTrial = (null != response.purchase.trial_ends),\n isSubscription = (null != response.purchase.initial_amount),\n total = isTrial ? 0 : (isSubscription ? response.purchase.initial_amount : response.purchase.gross).toString(),\n productName = 'WooCommerce Pixel Manager',\n // storeUrl = 'https://sweetcode.com',\n storeName = 'SweetCode';\n \n window.dataLayer = window.dataLayer || [];\n\n function gtag() {\n dataLayer.push(arguments);\n }\n \n gtag('js', new Date()); \n \n gtag('config', 'UA-39746956-10', {'anonymize_ip': true});\n gtag('config', 'G-2QE000DX8D');\n gtag('config', 'AW-406204436');\n \n gtag('event', 'purchase', {\n 'send_to':['UA-39746956-10', 'G-2QE000DX8D'],\n 'transaction_id':response.purchase.id.toString(),\n 'currency': response.purchase.currency.toUpperCase(),\n 'discount':0,\n 'items':[{\n 'id':response.purchase.plan_id.toString(),\n 'quantity':1,\n 'price':total,\n 'name':productName,\n 'category': 'Plugin',\n }],\n 'affiliation': storeName,\n 'value':response.purchase.initial_amount.toString()\n });\n \n gtag('event', 'conversion', {\n 'send_to': 'AW-406204436/XrUYCK3J8YoCEJTg2MEB',\n 'value': response.purchase.initial_amount.toString(),\n 'currency': response.purchase.currency.toUpperCase(),\n 'transaction_id': response.purchase.id.toString()\n });\n \n !function(f,b,e,v,n,t,s)\n {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n n.queue=[];t=b.createElement(e);t.async=!0;\n t.src=v;s=b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t,s)}(window, document,'script',\n 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '257839909406661');\n fbq('track', 'PageView');\n \n fbq('track', 'Purchase', {\n currency: 'USD',\n value: total\n });\n \n var _dcq = _dcq || [];\n\t\t\tvar _dcs = _dcs || {};\n\t\t\t_dcs.account = '5594556';\n\t\n\t\t\t(function() {\n\t\t\t\tvar dc = document.createElement('script');\n\t\t\t\tdc.type = 'text/javascript'; dc.async = true;\n\t\t\t\tdc.src = '//tag.getdrip.com/5594556.js';\n\t\t\t\tvar s = document.getElementsByTagName('script')[0];\n\t\t\t\ts.parentNode.insertBefore(dc, s);\n\t\t\t})();\n\t\t\t\n\t\t\twindow._dcq.push([\n\t\t\t\t'track',\n\t\t\t\t'Placed an order',\n\t\t\t]);\n\t\t\t\n\t\t\twindow._dcq.push([\n\t\t\t\t'track',\n\t\t\t\t'purchase,\n\t\t\t\t{\n\t\t\t\t\tvalue: total * 100,\n\t\t\t\t\tcurrency_code: response.purchase.currency.toUpperCase(),\n\t\t\t\t}\n\t\t\t]);\n \n }";
|
79 |
}
|
80 |
|
81 |
+
public function my_checkout_enrich( $html )
|
82 |
{
|
83 |
return '<script async src="https://www.googletagmanager.com/gtag/js?id=UA-39746956-10"></script>' . $html;
|
84 |
}
|
147 |
public function wpm_plugin_admin_init()
|
148 |
{
|
149 |
register_setting( 'wpm_plugin_options_group', 'wgact_plugin_options', [ $this, 'wpm_options_validate' ] );
|
150 |
+
// don't load the UX if we are not on the plugin UX page
|
151 |
+
if ( !$this->if_is_wpm_admin_page() ) {
|
152 |
+
return;
|
153 |
+
}
|
154 |
$this->add_section_main();
|
155 |
$this->add_section_advanced();
|
156 |
$this->add_section_beta();
|
203 |
// add the field for the conversion label
|
204 |
add_settings_field(
|
205 |
'wpm_plugin_conversion_label',
|
206 |
+
esc_html__( 'Google Ads Purchase Conversion Label', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
207 |
[ $this, 'wpm_option_html_google_ads_conversion_label' ],
|
208 |
'wpm_plugin_options_page',
|
209 |
$section_ids['settings_name']
|
234 |
public function add_section_main_subsection_facebook( $section_ids )
|
235 |
{
|
236 |
$sub_section_ids = [
|
237 |
+
'title' => esc_html__( 'Meta (Facebook)', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
238 |
'slug' => 'facebook',
|
239 |
];
|
240 |
add_settings_field(
|
249 |
// add the field for the conversion label
|
250 |
add_settings_field(
|
251 |
'wpm_plugin_facebook_pixel_id',
|
252 |
+
esc_html__( 'Meta (Facebook) pixel ID', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
253 |
[ $this, 'wpm_option_html_facebook_pixel_id' ],
|
254 |
'wpm_plugin_options_page',
|
255 |
$section_ids['settings_name']
|
388 |
'wpm_plugin_options_page',
|
389 |
$section_ids['settings_name']
|
390 |
);
|
391 |
+
if ( wpm_fs()->is__premium_only() || $this->options['general']['pro_version_demo'] ) {
|
392 |
+
// add checkbox for disabling tracking for user roles
|
393 |
+
add_settings_field(
|
394 |
+
'wpm_setting_disable_tracking_for_user_roles',
|
395 |
+
esc_html__( 'Disable Tracking for User Roles', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
396 |
+
[ $this, 'wpm_setting_html_disable_tracking_for_user_roles' ],
|
397 |
+
'wpm_plugin_options_page',
|
398 |
+
$section_ids['settings_name']
|
399 |
+
);
|
400 |
+
}
|
401 |
}
|
402 |
|
403 |
public function add_section_advanced_subsection_google( $section_ids )
|
415 |
'wpm_plugin_options_page',
|
416 |
$section_ids['settings_name']
|
417 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
// add the field for the aw_merchant_id
|
419 |
add_settings_field(
|
420 |
'wpm_plugin_aw_merchant_id',
|
532 |
'wpm_plugin_options_page',
|
533 |
$section_ids['settings_name']
|
534 |
);
|
535 |
+
if ( ( new Environment_Check( $this->options ) )->is_borlabs_cookie_active() ) {
|
536 |
// add fields for the Borlabs Cookie support
|
537 |
add_settings_field(
|
538 |
'wpm_setting_borlabs_support',
|
542 |
$section_ids['settings_name']
|
543 |
);
|
544 |
}
|
545 |
+
if ( ( new Environment_Check( $this->options ) )->is_cookiebot_active() ) {
|
546 |
// add fields for the Cookiebot support
|
547 |
add_settings_field(
|
548 |
'wpm_setting_cookiebot_support',
|
552 |
$section_ids['settings_name']
|
553 |
);
|
554 |
}
|
555 |
+
if ( ( new Environment_Check( $this->options ) )->is_complianz_active() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
556 |
// add fields for the Complianz GDPR support
|
557 |
add_settings_field(
|
558 |
'wpm_setting_complianz_support',
|
562 |
$section_ids['settings_name']
|
563 |
);
|
564 |
}
|
565 |
+
if ( ( new Environment_Check( $this->options ) )->is_cookie_notice_active() ) {
|
566 |
// add fields for the Cookie Notice by hu-manity.co support
|
567 |
add_settings_field(
|
568 |
'wpm_setting_cookie_notice_support',
|
572 |
$section_ids['settings_name']
|
573 |
);
|
574 |
}
|
575 |
+
if ( ( new Environment_Check( $this->options ) )->is_cookie_script_active() ) {
|
576 |
// add fields for the Cookie Script support
|
577 |
add_settings_field(
|
578 |
'wpm_setting_cookie_script_support',
|
582 |
$section_ids['settings_name']
|
583 |
);
|
584 |
}
|
585 |
+
if ( ( new Environment_Check( $this->options ) )->is_moove_gdpr_active() ) {
|
586 |
// add fields for the GDPR Cookie Compliance support
|
587 |
add_settings_field(
|
588 |
'wpm_setting_moove_gdpr_support',
|
592 |
$section_ids['settings_name']
|
593 |
);
|
594 |
}
|
595 |
+
if ( ( new Environment_Check( $this->options ) )->is_cookie_law_info_active() ) {
|
596 |
// add fields for the GDPR Cookie Consent support
|
597 |
add_settings_field(
|
598 |
'wpm_setting_cookie_law_info_support',
|
607 |
public function add_section_advanced_subsection_facebook( $section_ids )
|
608 |
{
|
609 |
$sub_section_ids = [
|
610 |
+
'title' => 'Meta (Facebook)',
|
611 |
'slug' => 'facebook',
|
612 |
];
|
613 |
add_settings_field(
|
622 |
// add field for the Facebook CAPI token
|
623 |
add_settings_field(
|
624 |
'wpm_setting_facebook_capi_token',
|
625 |
+
esc_html__( 'Meta (Facebook) CAPI: token', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
626 |
[ $this, 'wpm_setting_html_facebook_capi_token' ],
|
627 |
'wpm_plugin_options_page',
|
628 |
$section_ids['settings_name']
|
630 |
// add field for the Facebook CAPI user transparency process anonymous hits
|
631 |
add_settings_field(
|
632 |
'wpm_setting_facebook_capi_user_transparency_process_anonymous_hits',
|
633 |
+
esc_html__( 'Meta (Facebook) CAPI: process anonymous hits', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
634 |
[ $this, 'wpm_setting_facebook_capi_user_transparency_process_anonymous_hits' ],
|
635 |
'wpm_plugin_options_page',
|
636 |
$section_ids['settings_name']
|
638 |
// add field for the Facebook CAPI user transparency send additional client identifiers
|
639 |
add_settings_field(
|
640 |
'wpm_setting_facebook_capi_user_transparency_send_additional_client_identifiers',
|
641 |
+
esc_html__( 'Meta (Facebook) CAPI: send additional visitor identifiers', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
642 |
[ $this, 'wpm_setting_facebook_capi_user_transparency_send_additional_client_identifiers' ],
|
643 |
'wpm_plugin_options_page',
|
644 |
$section_ids['settings_name']
|
646 |
// add fields for Facebook microdata
|
647 |
add_settings_field(
|
648 |
'wpm_setting_facebook_microdata_active',
|
649 |
+
esc_html__( 'Meta (Facebook) Microdata Tags for Catalogues', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
650 |
[ $this, 'wpm_setting_html_facebook_microdata' ],
|
651 |
'wpm_plugin_options_page',
|
652 |
$section_ids['settings_name']
|
668 |
[ $this, 'wpm_plugin_section_add_cart_data_description' ],
|
669 |
'wpm_plugin_options_page'
|
670 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
671 |
// add checkbox for dynamic remarketing
|
672 |
add_settings_field(
|
673 |
'wpm_plugin_option_gads_dynamic_remarketing',
|
734 |
[ $this, 'wpm_plugin_section_author_description' ],
|
735 |
'wpm_plugin_options_page'
|
736 |
);
|
737 |
+
// end add_section_author
|
738 |
}
|
739 |
|
740 |
protected function output_section_data_field( array $section_ids )
|
752 |
|
753 |
public function wpm_section_generic_opening_div_html( $section_ids )
|
754 |
{
|
755 |
+
echo '<div class="section" data-section-title="' . esc_js( $section_ids['title'] ) . '" data-section-slug="' . esc_js( $section_ids['slug'] ) . '"></div>' ;
|
756 |
}
|
757 |
|
758 |
public function wpm_subsection_generic_opening_div_html( $section_ids, $sub_section_ids )
|
759 |
{
|
760 |
+
echo '<div class="subsection" data-section-slug="' . esc_js( $section_ids['slug'] ) . '" data-subsection-title="' . esc_js( $sub_section_ids['title'] ) . '" data-subsection-slug="' . esc_js( $sub_section_ids['slug'] ) . '"></div>' ;
|
761 |
}
|
762 |
|
763 |
// display the admin options page
|
764 |
public function wpm_plugin_options_page()
|
765 |
{
|
766 |
?>
|
767 |
+
<div id="script-blocker-notice" class="notice notice-error"
|
768 |
+
style="width:90%; float: left; margin: 5px; font-weight: bold">
|
769 |
+
<p>
|
770 |
+
<?php
|
771 |
esc_html_e( 'It looks like you are using some sort of ad or script blocker which is blocking the script and CSS files of this plugin.
|
772 |
In order for the plugin to work properly you need to disable the script blocker.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
773 |
?>
|
774 |
+
</p>
|
775 |
+
<p>
|
776 |
+
<a href="<?php
|
777 |
+
$this->get_documentation_html_by_key( 'script_blockers' );
|
778 |
?>"
|
779 |
+
target="_blank">
|
780 |
+
<?php
|
781 |
esc_html_e( 'Learn more', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
782 |
?>
|
783 |
+
</a>
|
784 |
+
</p>
|
785 |
|
786 |
+
<script>
|
787 |
+
if (typeof wpm_hide_script_blocker_warning === "function") {
|
788 |
+
wpm_hide_script_blocker_warning()
|
789 |
+
}
|
790 |
+
</script>
|
791 |
|
792 |
+
</div>
|
793 |
|
794 |
+
<div style="width:90%; margin: 5px">
|
795 |
|
796 |
+
<?php
|
797 |
settings_errors();
|
798 |
?>
|
799 |
|
800 |
+
<h2 class="nav-tab-wrapper">
|
801 |
+
</h2>
|
802 |
|
803 |
+
<form id="wpm_settings_form" action="options.php" method="post">
|
804 |
|
805 |
+
<?php
|
806 |
settings_fields( 'wpm_plugin_options_group' );
|
807 |
do_settings_sections( 'wpm_plugin_options_page' );
|
808 |
submit_button();
|
809 |
$this->inject_developer_banner();
|
810 |
?>
|
811 |
|
812 |
+
</form>
|
813 |
+
</div>
|
814 |
+
<?php
|
815 |
}
|
816 |
|
817 |
private function inject_developer_banner()
|
818 |
{
|
819 |
?>
|
820 |
|
821 |
+
<div class="developer-banner">
|
822 |
+
<div style="display: flex; justify-content: space-between">
|
823 |
+
<span>
|
824 |
+
<?php
|
825 |
esc_html_e( 'Profit Driven Marketing by SweetCode', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
826 |
?>
|
827 |
+
</span>
|
828 |
|
829 |
+
<?php
|
830 |
?>
|
831 |
|
832 |
+
<div style="float: right; padding-left: 20px">
|
833 |
+
<span style="padding-right: 6px">
|
834 |
+
Enable Pro version demo features
|
835 |
+
</span>
|
836 |
+
<label class="switch" id="wpm_pro_version_demo">
|
837 |
|
838 |
+
<input type='hidden' value='0'
|
839 |
+
name='wgact_plugin_options[general][pro_version_demo]'>
|
840 |
+
<input type="checkbox" value='1'
|
841 |
+
name='wgact_plugin_options[general][pro_version_demo]'
|
842 |
+
<?php
|
843 |
checked( $this->options['general']['pro_version_demo'] );
|
844 |
?>
|
845 |
+
/>
|
846 |
+
<span class="slider round"></span>
|
847 |
+
</label>
|
848 |
+
</div>
|
849 |
|
850 |
+
<?php
|
851 |
?>
|
852 |
|
853 |
+
<span style=" padding-left: 20px;">
|
854 |
+
<?php
|
855 |
esc_html_e( 'Visit us here:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
856 |
?>
|
857 |
+
<a href="https://sweetcode.com/?utm_source=plugin&utm_medium=banner&utm_campaign=wpm"
|
858 |
+
target="_blank">https://sweetcode.com
|
859 |
+
</a>
|
860 |
+
</span>
|
861 |
|
862 |
+
</div>
|
863 |
+
</div>
|
864 |
+
<?php
|
865 |
}
|
866 |
|
867 |
+
private function get_link_locale()
|
868 |
{
|
869 |
|
870 |
if ( substr( get_user_locale(), 0, 2 ) === 'de' ) {
|
899 |
public function wpm_plugin_section_support_description()
|
900 |
{
|
901 |
?>
|
902 |
+
<div style="margin-top:20px">
|
903 |
+
<h2><?php
|
904 |
esc_html_e( 'Contacting Support', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
905 |
?></h2>
|
906 |
|
907 |
+
</div>
|
908 |
+
<?php
|
909 |
$this->support_info_for_freemius();
|
910 |
?>
|
911 |
+
<hr style="border: none;height: 1px; color: #333; background-color: #333;">
|
912 |
+
<?php
|
913 |
$this->info_for_translators();
|
914 |
?>
|
915 |
+
<div>
|
916 |
+
<h2><?php
|
917 |
esc_html_e( 'Debug Information', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
918 |
?></h2>
|
919 |
|
920 |
+
<div>
|
921 |
+
<textarea id="debug-info-textarea" class=""
|
922 |
+
style="display:block; margin-bottom: 10px; width: 100%;resize: none;color:dimgrey;"
|
923 |
+
cols="100%" rows="30"
|
924 |
+
readonly><?php
|
925 |
+
esc_html_e( ( new Debug_Info( $this->options ) )->get_debug_info() );
|
926 |
+
?>
|
927 |
+
</textarea>
|
928 |
+
<button id="debug-info-button"
|
929 |
+
type="button"><?php
|
930 |
esc_html_e( 'copy to clipboard', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
931 |
?></button>
|
932 |
+
</div>
|
933 |
|
934 |
+
</div>
|
935 |
+
<hr style="border: none;height: 1px; color: #333; background-color: #333;">
|
936 |
|
937 |
+
<?php
|
938 |
}
|
939 |
|
940 |
private function info_for_translators()
|
941 |
{
|
942 |
?>
|
943 |
|
944 |
+
<div style="margin-bottom: 20px">
|
945 |
+
<h2><?php
|
946 |
esc_html_e( 'Translations', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
947 |
?></h2>
|
948 |
+
<?php
|
949 |
esc_html_e( 'If you want to participate improving the translations of this plugin into your language, please follow this link:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
950 |
?>
|
951 |
+
<a href="https://translate.wordpress.org/projects/wp-plugins/woocommerce-google-adwords-conversion-tracking-tag/"
|
952 |
+
target="_blank">translate.wordpress.org</a>
|
953 |
|
954 |
+
</div>
|
955 |
+
<hr style="border: none;height: 1px; color: #333; background-color: #333;">
|
956 |
+
<?php
|
957 |
}
|
958 |
|
959 |
private function support_info_for_freemius()
|
960 |
{
|
961 |
?>
|
962 |
+
<div style="margin-bottom: 30px;">
|
963 |
+
<ul>
|
964 |
|
965 |
+
<li>
|
966 |
+
<?php
|
967 |
esc_html_e( 'Post a support request in the WordPress support forum here: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
968 |
?>
|
969 |
+
<a href="https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/"
|
970 |
+
target="_blank">
|
971 |
+
<?php
|
972 |
esc_html_e( 'Support forum', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
973 |
?>
|
974 |
+
</a>
|
975 |
+
|
976 |
+
<span class="dashicons dashicons-info"></span>
|
977 |
+
<?php
|
978 |
esc_html_e( '(Never post the debug or other sensitive information to the support forum. Instead send us the information by email.)', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
979 |
?>
|
980 |
+
</li>
|
981 |
+
<li>
|
982 |
+
<?php
|
983 |
esc_html_e( 'Or send us an email to the following address: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
984 |
?>
|
985 |
+
<a href="mailto:support@sweetcode.com" target="_blank">support@sweetcode.com</a>
|
986 |
+
</li>
|
987 |
+
</ul>
|
988 |
+
</div>
|
989 |
|
990 |
+
<?php
|
991 |
}
|
992 |
|
993 |
private function support_info_for_wc_market()
|
994 |
{
|
995 |
?>
|
996 |
+
<div style="margin-bottom: 30px;">
|
997 |
+
<ul>
|
998 |
+
<li>
|
999 |
+
<?php
|
1000 |
esc_html_e( 'Send us your support request through the WooCommerce.com dashboard: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1001 |
?>
|
1002 |
+
<a href="https://woocommerce.com/my-account/create-a-ticket/" target="_blank">WooCommerce support
|
1003 |
+
dashboard</a>
|
1004 |
+
</li>
|
1005 |
+
</ul>
|
1006 |
+
</div>
|
1007 |
|
1008 |
+
<?php
|
1009 |
}
|
1010 |
|
1011 |
public function wpm_plugin_section_author_description()
|
1012 |
{
|
1013 |
?>
|
1014 |
+
<div style="margin-top:20px;margin-bottom: 30px">
|
1015 |
+
<?php
|
1016 |
esc_html_e( 'More details about the developer of this plugin: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1017 |
?>
|
1018 |
+
</div>
|
1019 |
+
<div style="margin-bottom: 30px;">
|
1020 |
+
<div><?php
|
1021 |
esc_html_e( 'Developer: SweetCode', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1022 |
?></div>
|
1023 |
+
<div>
|
1024 |
+
<?php
|
1025 |
esc_html_e( 'Website: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1026 |
?>
|
1027 |
+
<a href="https://sweetcode.com/?utm_source=plugin&utm_medium=banner&utm_campaign=wpm"
|
1028 |
+
target="_blank">https://sweetcode.com</a>
|
1029 |
+
</div>
|
1030 |
+
</div>
|
1031 |
+
<?php
|
1032 |
}
|
1033 |
|
1034 |
public function wpm_option_html_google_analytics_universal_property()
|
1035 |
{
|
1036 |
+
?>
|
1037 |
+
<input id='wpm_plugin_analytics_ua_property_id'
|
1038 |
+
name='wgact_plugin_options[google][analytics][universal][property_id]'
|
1039 |
+
size='40'
|
1040 |
+
type='text'
|
1041 |
+
value='<?php
|
1042 |
+
esc_html_e( $this->options['google']['analytics']['universal']['property_id'] );
|
1043 |
+
?>'
|
1044 |
+
/>
|
1045 |
+
<?php
|
1046 |
+
$this->get_status_icon_new( $this->options['google']['analytics']['universal']['property_id'] );
|
1047 |
+
$this->get_documentation_html_by_key( 'google_analytics_universal_property' );
|
1048 |
echo '<br><br>' ;
|
1049 |
esc_html_e( 'The Google Analytics Universal property ID looks like this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1050 |
echo ' <i>UA-12345678-1</i>' ;
|
1052 |
|
1053 |
public function wpm_option_html_google_analytics_4_id()
|
1054 |
{
|
1055 |
+
?>
|
1056 |
+
<input id='wpm_plugin_analytics_4_measurement_id'
|
1057 |
+
name='wgact_plugin_options[google][analytics][ga4][measurement_id]'
|
1058 |
+
size='40'
|
1059 |
+
type='text'
|
1060 |
+
value='<?php
|
1061 |
+
esc_html_e( $this->options['google']['analytics']['ga4']['measurement_id'] );
|
1062 |
+
?>'
|
1063 |
+
/>
|
1064 |
+
<?php
|
1065 |
+
$this->get_status_icon_new( $this->options['google']['analytics']['ga4']['measurement_id'] );
|
1066 |
+
$this->get_documentation_html_by_key( 'google_analytics_4_id' );
|
1067 |
echo '<br><br>' ;
|
1068 |
esc_html_e( 'The Google Analytics 4 measurement ID looks like this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1069 |
echo ' <i>G-R912ZZ1MHH0</i>' ;
|
1071 |
|
1072 |
public function wpm_option_html_google_ads_conversion_id()
|
1073 |
{
|
1074 |
+
?>
|
1075 |
+
<input id='wpm_plugin_conversion_id'
|
1076 |
+
name='wgact_plugin_options[google][ads][conversion_id]'
|
1077 |
+
size='40'
|
1078 |
+
type='text'
|
1079 |
+
value='<?php
|
1080 |
+
esc_html_e( $this->options['google']['ads']['conversion_id'] );
|
1081 |
+
?>'
|
1082 |
+
/>
|
1083 |
+
<?php
|
1084 |
+
$this->get_status_icon_new( $this->options['google']['ads']['conversion_id'] );
|
1085 |
+
$this->get_documentation_html_by_key( 'google_ads_conversion_id' );
|
1086 |
echo '<br><br>' ;
|
1087 |
esc_html_e( 'The conversion ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1088 |
echo ' <i>123456789</i>' ;
|
1090 |
|
1091 |
public function wpm_option_html_google_ads_conversion_label()
|
1092 |
{
|
1093 |
+
?>
|
1094 |
+
<input id='wpm_plugin_conversion_label'
|
1095 |
+
name='wgact_plugin_options[google][ads][conversion_label]'
|
1096 |
+
size='40'
|
1097 |
+
type='text'
|
1098 |
+
value='<?php
|
1099 |
+
esc_html_e( $this->options['google']['ads']['conversion_label'] );
|
1100 |
+
?>'
|
1101 |
+
/>
|
1102 |
+
<?php
|
1103 |
+
$this->get_status_icon_new( $this->options['google']['ads']['conversion_label'], $this->options['google']['ads']['conversion_id'] );
|
1104 |
+
$this->get_documentation_html_by_key( 'google_ads_conversion_label' );
|
1105 |
echo '<br><br>' ;
|
1106 |
+
esc_html_e( 'The purchase conversion label looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1107 |
echo ' <i>Xt19CO3axGAX0vg6X3gM</i>' ;
|
1108 |
|
1109 |
if ( $this->options['google']['ads']['conversion_label'] && !$this->options['google']['ads']['conversion_id'] ) {
|
1116 |
|
1117 |
public function wpm_option_html_google_optimize_container_id()
|
1118 |
{
|
1119 |
+
?>
|
1120 |
+
<input id='wpm_plugin_google_optimize_container_id'
|
1121 |
+
name='wgact_plugin_options[google][optimize][container_id]'
|
1122 |
+
size='40'
|
1123 |
+
type='text'
|
1124 |
+
value='<?php
|
1125 |
+
esc_html_e( $this->options['google']['optimize']['container_id'] );
|
1126 |
+
?>'
|
1127 |
+
/>
|
1128 |
+
<?php
|
1129 |
+
$this->get_status_icon_new( $this->options['google']['optimize']['container_id'] );
|
1130 |
// echo $this->get_documentation_html('/wgact/#/plugin-configuration?id=configure-the-plugin');
|
1131 |
+
$this->get_documentation_html_by_key( 'google_optimize_container_id' );
|
1132 |
echo '<br><br>' ;
|
1133 |
esc_html_e( 'The Google Optimize container ID looks like this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1134 |
echo ' <i>GTM-WMAB1BM</i>' ;
|
1136 |
|
1137 |
public function wpm_option_html_facebook_pixel_id()
|
1138 |
{
|
1139 |
+
?>
|
1140 |
+
<input id='wpm_plugin_facebook_pixel_id'
|
1141 |
+
name='wgact_plugin_options[facebook][pixel_id]'
|
1142 |
+
size='40'
|
1143 |
+
type='text'
|
1144 |
+
value='<?php
|
1145 |
+
esc_html_e( $this->options['facebook']['pixel_id'] );
|
1146 |
+
?>'
|
1147 |
+
/>
|
1148 |
+
<?php
|
1149 |
+
$this->get_status_icon_new( $this->options['facebook']['pixel_id'] );
|
1150 |
+
$this->get_documentation_html_by_key( 'facebook_pixel_id' );
|
1151 |
echo '<br><br>' ;
|
1152 |
+
esc_html_e( 'The Meta (Facebook) pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1153 |
echo ' <i>765432112345678</i>' ;
|
1154 |
}
|
1155 |
|
1156 |
public function wpm_option_html_bing_uet_tag_id()
|
1157 |
{
|
1158 |
+
?>
|
1159 |
+
<input id='wpm_plugin_bing_uet_tag_id'
|
1160 |
+
name='wgact_plugin_options[bing][uet_tag_id]'
|
1161 |
+
size='40'
|
1162 |
+
type='text'
|
1163 |
+
value='<?php
|
1164 |
+
esc_html_e( $this->options['bing']['uet_tag_id'] );
|
1165 |
+
?>'
|
1166 |
+
<?php
|
1167 |
+
esc_html_e( $this->disable_if_demo() );
|
1168 |
+
?>
|
1169 |
+
/>
|
1170 |
+
<?php
|
1171 |
+
$this->get_status_icon_new( $this->options['bing']['uet_tag_id'] );
|
1172 |
+
$this->get_documentation_html_by_key( 'bing_uet_tag_id' );
|
1173 |
+
$this->html_pro_feature();
|
1174 |
echo '<br><br>' ;
|
1175 |
esc_html_e( 'The Microsoft Advertising UET tag ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1176 |
echo ' <i>12345678</i>' ;
|
1178 |
|
1179 |
public function wpm_option_html_twitter_pixel_id()
|
1180 |
{
|
1181 |
+
?>
|
1182 |
+
<input
|
1183 |
+
id='wpm_plugin_twitter_pixel_id'
|
1184 |
+
name='wgact_plugin_options[twitter][pixel_id]'
|
1185 |
+
size='40'
|
1186 |
+
type='text'
|
1187 |
+
value='<?php
|
1188 |
+
esc_html_e( $this->options['twitter']['pixel_id'] );
|
1189 |
+
?>'
|
1190 |
+
<?php
|
1191 |
+
esc_html_e( $this->disable_if_demo() );
|
1192 |
+
?>
|
1193 |
+
/>
|
1194 |
+
<?php
|
1195 |
+
$this->get_status_icon_new( $this->options['twitter']['pixel_id'] );
|
1196 |
+
// ($this->get_documentation_html_by_key('twitter_pixel_id'));
|
1197 |
+
$this->html_pro_feature();
|
1198 |
echo '<br><br>' ;
|
1199 |
esc_html_e( 'The Twitter pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1200 |
echo ' <i>a1cde</i>' ;
|
1202 |
|
1203 |
public function wpm_option_html_pinterest_pixel_id()
|
1204 |
{
|
1205 |
+
?>
|
1206 |
+
<input
|
1207 |
+
id='wpm_plugin_pinterest_pixel_id'
|
1208 |
+
name='wgact_plugin_options[pinterest][pixel_id]'
|
1209 |
+
size='40'
|
1210 |
+
type='text'
|
1211 |
+
value='<?php
|
1212 |
+
esc_html_e( $this->options['pinterest']['pixel_id'] );
|
1213 |
+
?>'
|
1214 |
+
<?php
|
1215 |
+
esc_html_e( $this->disable_if_demo() );
|
1216 |
+
?>
|
1217 |
+
/>
|
1218 |
+
<?php
|
1219 |
+
$this->get_status_icon_new( $this->options['pinterest']['pixel_id'] );
|
1220 |
+
// ($this->get_documentation_html_by_key('pinterest_pixel_id'));
|
1221 |
+
$this->html_pro_feature();
|
1222 |
echo '<br><br>' ;
|
1223 |
esc_html_e( 'The Pinterest pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1224 |
echo ' <i>1234567890123</i>' ;
|
1226 |
|
1227 |
public function wpm_option_html_snapchat_pixel_id()
|
1228 |
{
|
1229 |
+
?>
|
1230 |
+
<input
|
1231 |
+
id='wpm_plugin_snapchat_pixel_id'
|
1232 |
+
name='wgact_plugin_options[snapchat][pixel_id]'
|
1233 |
+
size='40'
|
1234 |
+
type='text'
|
1235 |
+
value='<?php
|
1236 |
+
esc_html_e( $this->options['snapchat']['pixel_id'] );
|
1237 |
+
?>'
|
1238 |
+
<?php
|
1239 |
+
esc_html_e( $this->disable_if_demo() );
|
1240 |
+
?>
|
1241 |
+
/>
|
1242 |
+
<?php
|
1243 |
+
$this->get_status_icon_new( $this->options['snapchat']['pixel_id'] );
|
1244 |
+
// ($this->get_documentation_html_by_key('snapchat_pixel_id'));
|
1245 |
+
$this->html_pro_feature();
|
1246 |
echo '<br><br>' ;
|
1247 |
esc_html_e( 'The Snapchat pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1248 |
echo ' <i>1a2345b6-cd78-9012-e345-fg6h7890ij12</i>' ;
|
1250 |
|
1251 |
public function wpm_option_html_tiktok_pixel_id()
|
1252 |
{
|
1253 |
+
?>
|
1254 |
+
<input
|
1255 |
+
id='wpm_plugin_tiktok_pixel_id'
|
1256 |
+
name='wgact_plugin_options[tiktok][pixel_id]'
|
1257 |
+
size='40'
|
1258 |
+
type='text'
|
1259 |
+
value='<?php
|
1260 |
+
esc_html_e( $this->options['tiktok']['pixel_id'] );
|
1261 |
+
?>'
|
1262 |
+
<?php
|
1263 |
+
esc_html_e( $this->disable_if_demo() );
|
1264 |
+
?>
|
1265 |
+
/>
|
1266 |
+
<?php
|
1267 |
+
$this->get_status_icon_new( $this->options['tiktok']['pixel_id'] );
|
1268 |
+
// ($this->get_documentation_html_by_key('tiktok_pixel_id'));
|
1269 |
+
$this->html_pro_feature();
|
1270 |
echo '<br><br>' ;
|
1271 |
esc_html_e( 'The TikTok pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1272 |
echo ' <i>ABCD1E2FGH3IJK45LMN6</i>' ;
|
1274 |
|
1275 |
public function wpm_option_html_hotjar_site_id()
|
1276 |
{
|
1277 |
+
?>
|
1278 |
+
<input id='wpm_plugin_hotjar_site_id' name='wgact_plugin_options[hotjar][site_id]' size='40' type='text'
|
1279 |
+
value='<?php
|
1280 |
+
esc_html_e( $this->options['hotjar']['site_id'] );
|
1281 |
+
?>'/>
|
1282 |
+
<?php
|
1283 |
+
$this->get_status_icon_new( $this->options['hotjar']['site_id'] );
|
1284 |
+
$this->get_documentation_html_by_key( 'hotjar_site_id' );
|
1285 |
echo '<br><br>' ;
|
1286 |
esc_html_e( 'The Hotjar site ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1287 |
echo ' <i>1234567</i>' ;
|
1290 |
public function wpm_option_html_shop_order_total_logic()
|
1291 |
{
|
1292 |
?>
|
1293 |
+
<label>
|
1294 |
+
<input type='radio' id='wpm_plugin_order_total_logic_0'
|
1295 |
+
name='wgact_plugin_options[shop][order_total_logic]'
|
1296 |
+
value='0' <?php
|
1297 |
echo checked( 0, $this->options['shop']['order_total_logic'], false ) ;
|
1298 |
+
?> >
|
1299 |
+
<?php
|
1300 |
esc_html_e( 'Use order_subtotal: Doesn\'t include tax and shipping (default)', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1301 |
?>
|
1302 |
+
</label>
|
1303 |
+
<br>
|
1304 |
+
<label>
|
1305 |
+
<input type='radio' id='wpm_plugin_order_total_logic_1'
|
1306 |
+
name='wgact_plugin_options[shop][order_total_logic]'
|
1307 |
+
value='1' <?php
|
1308 |
echo checked( 1, $this->options['shop']['order_total_logic'], false ) ;
|
1309 |
+
?> >
|
1310 |
+
<?php
|
1311 |
esc_html_e( 'Use order_total: Includes tax and shipping', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1312 |
?>
|
1313 |
+
</label>
|
1314 |
+
<br><br>
|
1315 |
+
<?php
|
1316 |
esc_html_e( 'This is the order total amount reported back to Google Ads', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1317 |
?>
|
1318 |
+
<?php
|
1319 |
}
|
1320 |
|
1321 |
+
private function get_documentation_html_by_key( $key = 'default' )
|
1322 |
{
|
1323 |
return $this->get_documentation_html( $this->documentation->get_link( $key ) );
|
1324 |
}
|
1325 |
|
1326 |
+
protected function get_documentation_html( $path )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1327 |
{
|
1328 |
+
// $html = '<a class="documentation-icon" href="' . $path . '" target="_blank">';
|
1329 |
+
// $html .= '<span style="vertical-align: top; margin-top: 0px" class="dashicons dashicons-info-outline tooltip"><span class="tooltiptext">';
|
1330 |
+
// $html .= esc_html__('open the documentation', 'woocommerce-google-adwords-conversion-tracking-tag');
|
1331 |
+
// $html .= '</span></span></a>';
|
1332 |
+
//
|
1333 |
+
// return $html;
|
1334 |
?>
|
1335 |
+
<a class="documentation-icon" href="<?php
|
1336 |
+
echo esc_url( $path ) ;
|
1337 |
+
?>" target="_blank">
|
1338 |
+
<span style="vertical-align: top; margin-top: 0" class="dashicons dashicons-info-outline tooltip"><span
|
1339 |
+
class="tooltiptext">
|
1340 |
+
<?php
|
1341 |
+
esc_html_e( 'open the documentation', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1342 |
?>
|
1343 |
+
</span></span></a>
|
1344 |
+
|
1345 |
+
<?php
|
1346 |
}
|
1347 |
|
1348 |
public function wpm_setting_html_google_consent_mode_active()
|
1351 |
// instead of not saving it and remove that array key entirely
|
1352 |
// https://stackoverflow.com/a/1992745/4688612
|
1353 |
?>
|
1354 |
+
<label>
|
1355 |
+
<input type='hidden' value='0' name='wgact_plugin_options[google][consent_mode][active]'>
|
1356 |
+
<input type='checkbox' id='wpm_setting_google_consent_mode_active'
|
1357 |
+
name='wgact_plugin_options[google][consent_mode][active]'
|
1358 |
+
value='1'
|
1359 |
+
<?php
|
1360 |
checked( $this->options['google']['consent_mode']['active'] );
|
1361 |
?>
|
1362 |
+
<?php
|
1363 |
+
esc_html_e( $this->disable_if_demo() );
|
1364 |
?>
|
1365 |
+
/>
|
1366 |
+
<?php
|
1367 |
esc_html_e( 'Enable Google consent mode with standard settings', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1368 |
?>
|
1369 |
+
</label>
|
1370 |
+
<?php
|
1371 |
+
$this->get_status_icon_new( $this->options['google']['consent_mode']['active'], true, true );
|
1372 |
?>
|
1373 |
+
<?php
|
1374 |
+
$this->get_documentation_html_by_key( 'google_consent_mode' );
|
1375 |
+
$this->html_pro_feature();
|
1376 |
}
|
1377 |
|
1378 |
public function wpm_setting_html_google_consent_regions()
|
1381 |
// https://developer.woocommerce.com/2017/08/08/selectwoo-an-accessible-replacement-for-select2/
|
1382 |
// https://github.com/woocommerce/selectWoo
|
1383 |
?>
|
1384 |
+
<select id="wpm_setting_google_consent_regions" multiple="multiple"
|
1385 |
+
name="wgact_plugin_options[google][consent_mode][regions][]"
|
1386 |
+
style="width:350px; padding-left: 10px" data-placeholder="Choose countries…" aria-label="Country"
|
1387 |
+
class="wc-enhanced-select"
|
1388 |
+
<?php
|
1389 |
+
esc_html_e( $this->disable_if_demo() );
|
1390 |
?>
|
1391 |
+
>
|
1392 |
+
<?php
|
1393 |
+
foreach ( $this->consent_mode_regions->get_consent_mode_regions() as $region_code => $region_name ) {
|
1394 |
?>
|
1395 |
+
<option value="<?php
|
1396 |
+
esc_html_e( $region_code );
|
1397 |
?>" <?php
|
1398 |
+
esc_html_e( ( in_array( $region_code, $this->options['google']['consent_mode']['regions'], true ) ? 'selected' : '' ) );
|
1399 |
?>><?php
|
1400 |
+
esc_html_e( $region_name );
|
1401 |
?></option>
|
1402 |
+
<?php
|
1403 |
}
|
1404 |
?>
|
1405 |
|
1406 |
+
</select>
|
1407 |
+
<script>
|
1408 |
+
jQuery("#wpm_setting_google_consent_regions").select2({
|
1409 |
+
// theme: "classic"
|
1410 |
+
})
|
1411 |
+
</script>
|
1412 |
+
<?php
|
1413 |
+
$this->get_documentation_html_by_key( 'google_consent_regions' );
|
1414 |
+
$this->html_pro_feature();
|
1415 |
+
?>
|
1416 |
+
<p>
|
1417 |
+
<span class="dashicons dashicons-info"></span>
|
1418 |
+
<?php
|
1419 |
esc_html_e( 'If no region is set, then the restrictions are enabled for all regions. If you specify one or more regions, then the restrictions only apply for the specified regions.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1420 |
?>
|
1421 |
+
</p>
|
1422 |
+
<?php
|
1423 |
}
|
1424 |
|
1425 |
public function wpm_setting_html_google_analytics_eec()
|
1428 |
// instead of not saving it and remove that array key entirely
|
1429 |
// https://stackoverflow.com/a/1992745/4688612
|
1430 |
?>
|
1431 |
+
<label>
|
1432 |
+
<input type='hidden' value='0' name='wgact_plugin_options[google][analytics][eec]'>
|
1433 |
+
<input type='checkbox' id='wpm_setting_google_analytics_eec'
|
1434 |
+
name='wgact_plugin_options[google][analytics][eec]'
|
1435 |
+
value='1'
|
1436 |
+
<?php
|
1437 |
checked( $this->options['google']['analytics']['eec'] );
|
1438 |
?>
|
1439 |
+
<?php
|
1440 |
+
esc_html_e( $this->disable_if_demo() );
|
1441 |
?>
|
1442 |
+
/>
|
1443 |
+
<?php
|
1444 |
esc_html_e( 'Enable Google Analytics enhanced e-commerce', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1445 |
?>
|
1446 |
+
</label>
|
1447 |
+
<?php
|
1448 |
+
$this->get_status_icon_new( $this->options['google']['analytics']['eec'], $this->options['google']['analytics']['universal']['property_id'] || $this->options['google']['analytics']['ga4']['measurement_id'], true );
|
1449 |
+
$this->html_pro_feature();
|
1450 |
+
// ($this->get_documentation_html_by_key('google_analytics_eec'));
|
1451 |
?>
|
1452 |
+
<?php
|
1453 |
|
1454 |
if ( $this->options['google']['analytics']['eec'] && (!$this->options['google']['analytics']['universal']['property_id'] && !$this->options['google']['analytics']['ga4']['measurement_id']) ) {
|
1455 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1461 |
|
1462 |
public function wpm_setting_html_google_analytics_4_api_secret()
|
1463 |
{
|
1464 |
+
?>
|
1465 |
+
<input
|
1466 |
+
id='wpm_setting_google_analytics_4_api_secret'
|
1467 |
+
name='wgact_plugin_options[google][analytics][ga4][api_secret]'
|
1468 |
+
size='40'
|
1469 |
+
type='text'
|
1470 |
+
value='<?php
|
1471 |
+
esc_html_e( $this->options['google']['analytics']['ga4']['api_secret'] );
|
1472 |
+
?>'
|
1473 |
+
<?php
|
1474 |
+
esc_html_e( $this->disable_if_demo() );
|
1475 |
+
?>
|
1476 |
+
/>
|
1477 |
+
<?php
|
1478 |
+
$this->get_status_icon_new( $this->options['google']['analytics']['ga4']['api_secret'], $this->options['google']['analytics']['eec'] );
|
1479 |
+
$this->get_documentation_html_by_key( 'google_analytics_4_api_secret' );
|
1480 |
+
$this->html_pro_feature();
|
1481 |
echo '<br><br>' ;
|
1482 |
|
1483 |
if ( !$this->options['google']['analytics']['ga4']['measurement_id'] ) {
|
1502 |
// instead of not saving it and remove that array key entirely
|
1503 |
// https://stackoverflow.com/a/1992745/4688612
|
1504 |
?>
|
1505 |
+
<label>
|
1506 |
+
<input type='hidden' value='0' name='wgact_plugin_options[google][analytics][link_attribution]'>
|
1507 |
+
<input type='checkbox' id='wpm_setting_google_analytics_link_attribution'
|
1508 |
+
name='wgact_plugin_options[google][analytics][link_attribution]'
|
1509 |
+
value='1' <?php
|
1510 |
checked( $this->options['google']['analytics']['link_attribution'] );
|
1511 |
+
?>
|
1512 |
+
/>
|
1513 |
+
<?php
|
1514 |
esc_html_e( 'Enable Google Analytics enhanced link attribution', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1515 |
?>
|
1516 |
+
</label>
|
1517 |
+
<?php
|
1518 |
+
$this->get_status_icon_new( $this->options['google']['analytics']['link_attribution'], $this->options['google']['analytics']['universal']['property_id'] || $this->options['google']['analytics']['ga4']['measurement_id'], true );
|
1519 |
?>
|
1520 |
+
<?php
|
1521 |
// echo $this->get_documentation_html('/wgact/?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-consent-mode#/consent-mgmt/google-consent-mode');
|
1522 |
?>
|
1523 |
+
<?php
|
1524 |
|
1525 |
if ( $this->options['google']['analytics']['link_attribution'] && (!$this->options['google']['analytics']['universal']['property_id'] && !$this->options['google']['analytics']['ga4']['measurement_id']) ) {
|
1526 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1536 |
// instead of not saving it and remove that array key entirely
|
1537 |
// https://stackoverflow.com/a/1992745/4688612
|
1538 |
?>
|
1539 |
+
<label>
|
1540 |
+
<input type='hidden' value='0' name='wgact_plugin_options[google][user_id]'>
|
1541 |
+
<input type='checkbox' id='wpm_setting_google_user_id'
|
1542 |
+
name='wgact_plugin_options[google][user_id]'
|
1543 |
+
value='1'
|
1544 |
+
<?php
|
1545 |
checked( $this->options['google']['user_id'] );
|
1546 |
?>
|
1547 |
+
<?php
|
1548 |
+
esc_html_e( $this->disable_if_demo() );
|
1549 |
?>
|
1550 |
+
/>
|
1551 |
+
<?php
|
1552 |
esc_html_e( 'Enable Google user ID', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1553 |
?>
|
1554 |
+
</label>
|
1555 |
+
<?php
|
1556 |
+
$this->get_status_icon_new( $this->options['google']['user_id'], $this->options['google']['analytics']['universal']['property_id'] || $this->options['google']['analytics']['ga4']['measurement_id'] || $this->google->is_google_ads_active(), true );
|
1557 |
+
$this->html_pro_feature();
|
1558 |
// echo $this->get_documentation_html('/wgact/?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-consent-mode#/consent-mgmt/google-consent-mode');
|
1559 |
?>
|
1560 |
+
<?php
|
1561 |
|
1562 |
if ( $this->options['google']['analytics']['eec'] && (!$this->options['google']['analytics']['universal']['property_id'] && !$this->options['google']['analytics']['ga4']['measurement_id']) ) {
|
1563 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1573 |
// instead of not saving it and remove that array key entirely
|
1574 |
// https://stackoverflow.com/a/1992745/4688612
|
1575 |
?>
|
1576 |
+
<label>
|
1577 |
+
<input type='hidden' value='0' name='wgact_plugin_options[google][ads][enhanced_conversions]'>
|
1578 |
+
<input type='checkbox' id='wpm_setting_google_user_id'
|
1579 |
+
name='wgact_plugin_options[google][ads][enhanced_conversions]'
|
1580 |
+
value='1'
|
1581 |
+
<?php
|
1582 |
checked( $this->options['google']['ads']['enhanced_conversions'] );
|
1583 |
?>
|
1584 |
+
<?php
|
1585 |
+
esc_html_e( $this->disable_if_demo() );
|
1586 |
?>
|
1587 |
+
/>
|
1588 |
+
<?php
|
1589 |
esc_html_e( 'Enable Google Ads Enhanced Conversions', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1590 |
?>
|
1591 |
+
</label>
|
1592 |
+
<?php
|
1593 |
+
$this->get_status_icon_new( $this->options['google']['ads']['enhanced_conversions'], $this->google->is_google_ads_active(), false );
|
1594 |
+
$this->html_pro_feature();
|
1595 |
+
$this->get_documentation_html_by_key( 'google_ads_enhanced_conversions' );
|
1596 |
?>
|
1597 |
+
<?php
|
1598 |
|
1599 |
+
if ( !$this->google->is_google_ads_active() ) {
|
1600 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1601 |
esc_html_e( 'You need to activate Google Ads', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1602 |
echo '</p><br>' ;
|
1606 |
|
1607 |
public function wpm_setting_html_google_ads_phone_conversion_number()
|
1608 |
{
|
1609 |
+
?>
|
1610 |
+
<input
|
1611 |
+
id='wpm_plugin_google_ads_phone_conversion_number'
|
1612 |
+
name='wgact_plugin_options[google][ads][phone_conversion_number]'
|
1613 |
+
size='40'
|
1614 |
+
type='text'
|
1615 |
+
value='<?php
|
1616 |
+
esc_html_e( $this->options['google']['ads']['phone_conversion_number'] );
|
1617 |
+
?>'
|
1618 |
+
<?php
|
1619 |
+
esc_html_e( $this->disable_if_demo() );
|
1620 |
+
?>
|
1621 |
+
/>
|
1622 |
+
<?php
|
1623 |
+
$this->get_status_icon_new( $this->options['google']['ads']['phone_conversion_number'], $this->options['google']['ads']['phone_conversion_label'] && $this->options['google']['ads']['phone_conversion_number'] );
|
1624 |
+
$this->get_documentation_html_by_key( 'google_ads_phone_conversion_number' );
|
1625 |
+
$this->html_pro_feature();
|
1626 |
echo '<br><br>' ;
|
1627 |
esc_html_e( 'The Google Ads phone conversion number must be in the same format as on the website.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1628 |
}
|
1629 |
|
1630 |
public function wpm_setting_html_google_ads_phone_conversion_label()
|
1631 |
{
|
1632 |
+
?>
|
1633 |
+
<input
|
1634 |
+
id='wpm_plugin_google_ads_phone_conversion_label'
|
1635 |
+
name='wgact_plugin_options[google][ads][phone_conversion_label]'
|
1636 |
+
size='40'
|
1637 |
+
type='text'
|
1638 |
+
value='<?php
|
1639 |
+
esc_html_e( $this->options['google']['ads']['phone_conversion_label'] );
|
1640 |
+
?>'
|
1641 |
+
<?php
|
1642 |
+
esc_html_e( $this->disable_if_demo() );
|
1643 |
+
?>
|
1644 |
+
/>
|
1645 |
+
<?php
|
1646 |
+
$this->get_status_icon_new( $this->options['google']['ads']['phone_conversion_label'], $this->options['google']['ads']['phone_conversion_label'] && $this->options['google']['ads']['phone_conversion_number'] );
|
1647 |
+
$this->get_documentation_html_by_key( 'google_ads_phone_conversion_label' );
|
1648 |
+
$this->html_pro_feature();
|
1649 |
echo '<br><br>' ;
|
1650 |
// esc_html_e('The Google Ads phone conversion label must be in the same format as on the website.', 'woocommerce-google-adwords-conversion-tracking-tag');
|
1651 |
}
|
1653 |
public function wpm_setting_html_borlabs_support()
|
1654 |
{
|
1655 |
esc_html_e( 'Borlabs Cookie detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1656 |
+
$this->get_status_icon_new( true, true, true );
|
1657 |
+
$this->html_pro_feature();
|
1658 |
}
|
1659 |
|
1660 |
public function wpm_setting_html_cookiebot_support()
|
1661 |
{
|
1662 |
esc_html_e( 'Cookiebot detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1663 |
+
$this->get_status_icon_new( true, true, true );
|
1664 |
+
$this->html_pro_feature();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1665 |
}
|
1666 |
|
1667 |
public function wpm_setting_html_complianz_support()
|
1668 |
{
|
1669 |
esc_html_e( 'Complianz GDPR detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1670 |
+
$this->get_status_icon_new( true, true, true );
|
1671 |
+
$this->html_pro_feature();
|
1672 |
}
|
1673 |
|
1674 |
public function wpm_setting_html_cookie_notice_support()
|
1675 |
{
|
1676 |
esc_html_e( 'Cookie Notice (by hu-manity.co) detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1677 |
+
$this->get_status_icon_new( true, true, true );
|
1678 |
+
$this->html_pro_feature();
|
1679 |
}
|
1680 |
|
1681 |
public function wpm_setting_html_cookie_script_support()
|
1682 |
{
|
1683 |
esc_html_e( 'Cookie Script (by cookie-script.com) detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1684 |
+
$this->get_status_icon_new( true, true, true );
|
1685 |
+
$this->html_pro_feature();
|
1686 |
}
|
1687 |
|
1688 |
public function wpm_setting_html_moove_gdpr_support()
|
1689 |
{
|
1690 |
esc_html_e( 'GDPR Cookie Compliance (by Moove Agency) detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1691 |
+
$this->get_status_icon_new( true, true, true );
|
1692 |
+
$this->html_pro_feature();
|
1693 |
}
|
1694 |
|
1695 |
public function wpm_setting_html_cookie_law_info_support()
|
1696 |
{
|
1697 |
esc_html_e( 'GDPR Cookie Consent (by WebToffee) detected. Automatic support is:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1698 |
+
$this->get_status_icon_new( true, true, true );
|
1699 |
+
$this->html_pro_feature();
|
1700 |
}
|
1701 |
|
1702 |
public function wpm_setting_html_explicit_consent_mode()
|
1705 |
// instead of not saving it and remove that array key entirely
|
1706 |
// https://stackoverflow.com/a/1992745/4688612
|
1707 |
?>
|
1708 |
+
<label>
|
1709 |
+
<input type='hidden' value='0' name='wgact_plugin_options[shop][cookie_consent_mgmt][explicit_consent]'>
|
1710 |
+
<input type='checkbox' id='wpm_setting_explicit_consent_mode'
|
1711 |
+
name='wgact_plugin_options[shop][cookie_consent_mgmt][explicit_consent]'
|
1712 |
+
value='1'
|
1713 |
+
<?php
|
1714 |
checked( $this->options['shop']['cookie_consent_mgmt']['explicit_consent'] );
|
1715 |
?>
|
1716 |
+
<?php
|
1717 |
+
esc_html_e( $this->disable_if_demo() );
|
1718 |
?>
|
1719 |
+
/>
|
1720 |
+
<?php
|
1721 |
esc_html_e( 'Enable Explicit Consent Mode', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1722 |
+
?>
|
1723 |
+
</label>
|
1724 |
+
<?php
|
1725 |
+
$this->get_status_icon_new( $this->options['shop']['cookie_consent_mgmt']['explicit_consent'], true, true );
|
1726 |
+
$this->get_documentation_html_by_key( 'explicit_consent_mode' );
|
1727 |
+
$this->html_pro_feature();
|
1728 |
echo '<p style="margin-top:10px">' ;
|
1729 |
esc_html_e( 'Only activate the Explicit Consent Mode if you are also using a Cookie Management Platform (a cookie banner) that is compatible with this plugin. Find a list of compatible plugins in the documentation.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1730 |
echo '</p>' ;
|
1732 |
|
1733 |
public function wpm_setting_html_facebook_capi_token()
|
1734 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
1735 |
?>
|
1736 |
+
<textarea id='wpm_setting_facebook_capi_token'
|
1737 |
+
name='wgact_plugin_options[facebook][capi][token]'
|
1738 |
+
cols='60'
|
1739 |
+
rows='5'
|
1740 |
+
<?php
|
1741 |
+
esc_html_e( $this->disable_if_demo() );
|
1742 |
+
?>
|
1743 |
+
><?php
|
1744 |
+
esc_html_e( $this->options['facebook']['capi']['token'] );
|
1745 |
?></textarea>
|
1746 |
+
<?php
|
1747 |
+
$this->get_status_icon_new( $this->options['facebook']['capi']['token'], $this->options['facebook']['pixel_id'] );
|
1748 |
+
$this->get_documentation_html_by_key( 'facebook_capi_token' );
|
1749 |
+
$this->html_pro_feature();
|
1750 |
|
1751 |
if ( !$this->options['facebook']['pixel_id'] ) {
|
1752 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1753 |
+
esc_html_e( 'You need to activate the Meta (Facebook) pixel', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1754 |
echo '</p><br>' ;
|
1755 |
}
|
1756 |
|
1766 |
// instead of not saving it and remove that array key entirely
|
1767 |
// https://stackoverflow.com/a/1992745/4688612
|
1768 |
?>
|
1769 |
+
<label>
|
1770 |
+
<input type='hidden' value='0'
|
1771 |
+
name='wgact_plugin_options[facebook][capi][user_transparency][process_anonymous_hits]'>
|
1772 |
+
<input type='checkbox' id='wpm_setting_facebook_capi_user_transparency_process_anonymous_hits'
|
1773 |
+
name='wgact_plugin_options[facebook][capi][user_transparency][process_anonymous_hits]'
|
1774 |
+
value='1'
|
1775 |
+
<?php
|
1776 |
checked( $this->options['facebook']['capi']['user_transparency']['process_anonymous_hits'] );
|
1777 |
?>
|
1778 |
+
<?php
|
1779 |
+
esc_html_e( $this->disable_if_demo() );
|
1780 |
?>
|
1781 |
+
/>
|
1782 |
+
<?php
|
1783 |
+
esc_html_e( 'Send CAPI hits for anonymous visitors who likely have blocked the Meta (Facebook) pixel.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1784 |
?>
|
1785 |
+
</label>
|
1786 |
+
<?php
|
1787 |
+
$this->get_status_icon_new( $this->options['facebook']['capi']['user_transparency']['process_anonymous_hits'], $this->options['facebook']['pixel_id'], true );
|
1788 |
+
$this->get_documentation_html_by_key( 'facebook_capi_user_transparency_process_anonymous_hits' );
|
1789 |
+
$this->html_pro_feature();
|
1790 |
|
1791 |
if ( $this->options['facebook']['capi']['user_transparency']['process_anonymous_hits'] && !$this->options['facebook']['pixel_id'] ) {
|
1792 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1793 |
+
esc_html_e( 'You need to activate the Meta (Facebook) pixel', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1794 |
echo '</p><br>' ;
|
1795 |
}
|
1796 |
|
1802 |
// instead of not saving it and remove that array key entirely
|
1803 |
// https://stackoverflow.com/a/1992745/4688612
|
1804 |
?>
|
1805 |
+
<label>
|
1806 |
+
<input type='hidden' value='0'
|
1807 |
+
name='wgact_plugin_options[facebook][capi][user_transparency][send_additional_client_identifiers]'>
|
1808 |
+
<input type='checkbox' id='wpm_setting_facebook_capi_user_transparency_send_additional_client_identifiers'
|
1809 |
+
name='wgact_plugin_options[facebook][capi][user_transparency][send_additional_client_identifiers]'
|
1810 |
+
value='1'
|
1811 |
+
<?php
|
1812 |
checked( $this->options['facebook']['capi']['user_transparency']['send_additional_client_identifiers'] );
|
1813 |
?>
|
1814 |
+
<?php
|
1815 |
+
esc_html_e( $this->disable_if_demo() );
|
1816 |
?>
|
1817 |
+
/>
|
1818 |
+
<?php
|
1819 |
esc_html_e( 'Include additional visitor\'s identifiers, such as IP address, email and shop ID in the CAPI hit.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1820 |
?>
|
1821 |
+
</label>
|
1822 |
+
<?php
|
1823 |
+
$this->get_status_icon_new( $this->options['facebook']['capi']['user_transparency']['send_additional_client_identifiers'], $this->options['facebook']['pixel_id'], true );
|
1824 |
+
$this->get_documentation_html_by_key( 'facebook_capi_user_transparency_send_additional_client_identifiers' );
|
1825 |
+
$this->html_pro_feature();
|
1826 |
|
1827 |
if ( $this->options['facebook']['capi']['user_transparency']['send_additional_client_identifiers'] && !$this->options['facebook']['pixel_id'] ) {
|
1828 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1829 |
+
esc_html_e( 'You need to activate the Meta (Facebook) pixel', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1830 |
echo '</p><br>' ;
|
1831 |
}
|
1832 |
|
1838 |
// instead of not saving it and remove that array key entirely
|
1839 |
// https://stackoverflow.com/a/1992745/4688612
|
1840 |
?>
|
1841 |
+
<label>
|
1842 |
+
<input type='hidden' value='0' name='wgact_plugin_options[facebook][microdata]'>
|
1843 |
+
<input type='checkbox' id='wpm_setting_facebook_microdata_active'
|
1844 |
+
name='wgact_plugin_options[facebook][microdata]'
|
1845 |
+
value='1'
|
1846 |
+
<?php
|
1847 |
checked( $this->options['facebook']['microdata'] );
|
1848 |
?>
|
1849 |
+
<?php
|
1850 |
+
esc_html_e( $this->disable_if_demo() );
|
1851 |
?>
|
1852 |
+
/>
|
1853 |
+
<?php
|
1854 |
+
esc_html_e( 'Enable Meta (Facebook) product microdata output', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1855 |
?>
|
1856 |
+
</label>
|
1857 |
+
<?php
|
1858 |
+
$this->get_status_icon_new( $this->options['facebook']['microdata'], $this->options['facebook']['pixel_id'], true );
|
1859 |
+
$this->get_documentation_html_by_key( 'facebook_microdata' );
|
1860 |
+
$this->html_pro_feature();
|
1861 |
|
1862 |
if ( $this->options['facebook']['microdata'] && !$this->options['facebook']['pixel_id'] ) {
|
1863 |
echo '<p></p><span class="dashicons dashicons-info"></span>' ;
|
1864 |
+
esc_html_e( 'You need to activate the Meta (Facebook) pixel', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1865 |
echo '</p><br>' ;
|
1866 |
}
|
1867 |
|
1868 |
}
|
1869 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1870 |
public function wpm_setting_html_order_duplication_prevention()
|
1871 |
{
|
1872 |
// adding the hidden input is a hack to make WordPress save the option with the value zero,
|
1873 |
// instead of not saving it and remove that array key entirely
|
1874 |
// https://stackoverflow.com/a/1992745/4688612
|
1875 |
?>
|
1876 |
+
<label>
|
1877 |
+
<input type='hidden' value='0' name='wgact_plugin_options[shop][order_deduplication]'>
|
1878 |
+
<input type='checkbox' id='wpm_setting_order_duplication_prevention'
|
1879 |
+
name='wgact_plugin_options[shop][order_deduplication]'
|
1880 |
+
value='1' <?php
|
1881 |
checked( $this->options['shop']['order_deduplication'] );
|
1882 |
+
?>
|
1883 |
+
/>
|
1884 |
+
<?php
|
1885 |
$this->get_order_duplication_prevention_text();
|
|
|
|
|
|
|
1886 |
?>
|
1887 |
+
</label>
|
1888 |
+
<?php
|
1889 |
+
$this->get_status_icon_new( $this->options['shop']['order_deduplication'] );
|
1890 |
+
?>
|
1891 |
+
<br>
|
1892 |
+
<p>
|
1893 |
+
<span class="dashicons dashicons-info"></span>
|
1894 |
+
<?php
|
1895 |
esc_html_e( 'Only disable order duplication prevention for testing. Remember to re-enable the setting once done.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1896 |
?>
|
1897 |
+
</p>
|
1898 |
+
<?php
|
1899 |
}
|
1900 |
|
1901 |
public function wpm_setting_html_maximum_compatibility_mode()
|
1904 |
// instead of not saving it and remove that array key entirely
|
1905 |
// https://stackoverflow.com/a/1992745/4688612
|
1906 |
?>
|
1907 |
+
<label>
|
1908 |
+
<input type='hidden' value='0' name='wgact_plugin_options[general][maximum_compatibility_mode]'>
|
1909 |
+
<input type='checkbox' id='wpm_setting_maximum_compatibility_mode'
|
1910 |
+
name='wgact_plugin_options[general][maximum_compatibility_mode]'
|
1911 |
+
value='1' <?php
|
1912 |
checked( $this->options['general']['maximum_compatibility_mode'] );
|
1913 |
?> />
|
1914 |
+
<?php
|
1915 |
esc_html_e( 'Enable the maximum compatibility mode', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1916 |
?>
|
1917 |
+
</label>
|
1918 |
+
<?php
|
1919 |
+
$this->get_status_icon_new( $this->options['general']['maximum_compatibility_mode'], true, true );
|
1920 |
+
$this->get_documentation_html_by_key( 'maximum_compatibility_mode' );
|
1921 |
+
}
|
1922 |
+
|
1923 |
+
public function wpm_setting_html_disable_tracking_for_user_roles()
|
1924 |
+
{
|
1925 |
+
// https://semantic-ui.com/modules/dropdown.html#multiple-selection
|
1926 |
+
// https://developer.woocommerce.com/2017/08/08/selectwoo-an-accessible-replacement-for-select2/
|
1927 |
+
// https://github.com/woocommerce/selectWoo
|
1928 |
+
?>
|
1929 |
+
<select id="wpm_setting_disable_tracking_for_user_roles" multiple="multiple"
|
1930 |
+
name="wgact_plugin_options[shop][disable_tracking_for][]"
|
1931 |
+
style="width:350px; padding-left: 10px" data-placeholder="Choose roles…" aria-label="Roles"
|
1932 |
+
class="wc-enhanced-select"
|
1933 |
+
<?php
|
1934 |
+
esc_html_e( $this->disable_if_demo() );
|
1935 |
+
?>
|
1936 |
+
>
|
1937 |
+
<?php
|
1938 |
+
foreach ( get_editable_roles() as $role => $details ) {
|
1939 |
+
?>
|
1940 |
+
<option value="<?php
|
1941 |
+
esc_html_e( $role );
|
1942 |
+
?>" <?php
|
1943 |
+
esc_html_e( ( in_array( $role, $this->options['shop']['disable_tracking_for'], true ) ? 'selected' : '' ) );
|
1944 |
+
?>><?php
|
1945 |
+
esc_html_e( $details['name'] );
|
1946 |
+
?></option>
|
1947 |
+
<?php
|
1948 |
+
}
|
1949 |
+
?>
|
1950 |
+
|
1951 |
+
</select>
|
1952 |
+
<script>
|
1953 |
+
jQuery("#wpm_setting_disable_tracking_for_user_roles").select2({
|
1954 |
+
// theme: "classic"
|
1955 |
+
})
|
1956 |
+
</script>
|
1957 |
+
<?php
|
1958 |
+
// $this->get_documentation_html_by_key('google_consent_regions');
|
1959 |
+
$this->html_pro_feature();
|
1960 |
}
|
1961 |
|
1962 |
private function get_order_duplication_prevention_text()
|
1964 |
esc_html_e( 'Basic order duplication prevention is ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1965 |
}
|
1966 |
|
1967 |
+
private function add_to_cart_requirements_fulfilled()
|
1968 |
{
|
1969 |
|
1970 |
if ( $this->options['google']['ads']['conversion_id'] && $this->options['google']['ads']['conversion_label'] && $this->options['google']['ads']['aw_merchant_id'] ) {
|
1981 |
// instead of not saving it and remove that array key entirely
|
1982 |
// https://stackoverflow.com/a/1992745/4688612
|
1983 |
?>
|
1984 |
+
<label>
|
1985 |
+
<input type='hidden' value='0' name='wgact_plugin_options[google][ads][dynamic_remarketing]'>
|
1986 |
+
<input type='checkbox' id='wpm_plugin_option_gads_dynamic_remarketing'
|
1987 |
+
name='wgact_plugin_options[google][ads][dynamic_remarketing]'
|
1988 |
+
value='1' <?php
|
1989 |
checked( $this->options['google']['ads']['dynamic_remarketing'] );
|
1990 |
?> />
|
1991 |
|
1992 |
+
<?php
|
1993 |
esc_html_e( 'Enable dynamic remarketing audience collection', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
1994 |
?>
|
1995 |
+
</label>
|
1996 |
+
<?php
|
1997 |
+
$this->get_status_icon_new( $this->options['google']['ads']['dynamic_remarketing'], $this->options['google']['ads']['conversion_id'] );
|
1998 |
?>
|
1999 |
+
<?php
|
2000 |
+
$this->get_documentation_html_by_key( 'google_ads_dynamic_remarketing' );
|
2001 |
?>
|
2002 |
+
<p>
|
2003 |
+
<?php
|
2004 |
|
2005 |
if ( !$this->options['google']['ads']['conversion_id'] ) {
|
2006 |
?>
|
2007 |
+
<span class="dashicons dashicons-info"></span>
|
2008 |
+
<?php
|
2009 |
esc_html_e( 'Requires an active Google Ads Conversion ID', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2010 |
echo '<br>' ;
|
2011 |
}
|
2012 |
|
2013 |
+
?>
|
2014 |
+
<span class="dashicons dashicons-info"></span>
|
2015 |
+
<?php
|
2016 |
esc_html_e( 'You need to choose the correct product identifier setting in order to match the product identifiers in the product feeds.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2017 |
?>
|
2018 |
+
</p>
|
2019 |
+
<?php
|
2020 |
}
|
2021 |
|
2022 |
public function wpm_option_html_variations_output()
|
2025 |
// instead of not saving it and remove that array key entirely
|
2026 |
// https://stackoverflow.com/a/1992745/4688612
|
2027 |
?>
|
2028 |
+
<label>
|
2029 |
+
<input type='hidden' value='0' name='wgact_plugin_options[general][variations_output]'>
|
2030 |
+
<input type='checkbox' id='wpm_plugin_option_variations_output'
|
2031 |
+
name='wgact_plugin_options[general][variations_output]'
|
2032 |
+
value='1' <?php
|
2033 |
checked( $this->options['general']['variations_output'] );
|
2034 |
+
?>
|
2035 |
+
/>
|
2036 |
+
<?php
|
2037 |
esc_html_e( 'Enable variations output', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2038 |
?>
|
2039 |
+
</label>
|
2040 |
+
<?php
|
2041 |
+
$this->get_status_icon_new( $this->options['general']['variations_output'], $this->options['google']['ads']['dynamic_remarketing'], true );
|
2042 |
?>
|
2043 |
+
<?php
|
2044 |
+
$this->get_documentation_html_by_key( 'variations_output' );
|
2045 |
?>
|
2046 |
+
<p><span class="dashicons dashicons-info"></span>
|
2047 |
+
<?php
|
2048 |
esc_html_e( 'In order for this to work you need to upload your product feed including product variations and the item_group_id. Disable it, if you choose only to upload the parent product for variable products.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2049 |
?>
|
2050 |
+
</p>
|
2051 |
+
<?php
|
2052 |
}
|
2053 |
|
2054 |
public function wpm_plugin_option_google_business_vertical()
|
2055 |
{
|
2056 |
?>
|
2057 |
+
<label>
|
2058 |
+
<input type='radio' id='wpm_plugin_google_business_vertical_0'
|
2059 |
+
name='wgact_plugin_options[google][ads][google_business_vertical]'
|
2060 |
+
value='0'
|
2061 |
+
<?php
|
2062 |
echo checked( 0, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2063 |
?>
|
2064 |
+
<?php
|
2065 |
+
esc_html_e( $this->disable_if_demo() );
|
2066 |
?>
|
2067 |
+
/>
|
2068 |
+
<?php
|
2069 |
esc_html_e( 'Retail', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2070 |
?>
|
2071 |
+
</label>
|
2072 |
+
<br>
|
2073 |
+
<label>
|
2074 |
+
<input type='radio' id='wpm_plugin_google_business_vertical_1'
|
2075 |
+
name='wgact_plugin_options[google][ads][google_business_vertical]'
|
2076 |
+
value='1'
|
2077 |
+
<?php
|
2078 |
echo checked( 1, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2079 |
?>
|
2080 |
+
<?php
|
2081 |
+
esc_html_e( $this->disable_if_demo() );
|
2082 |
?>
|
2083 |
+
/>
|
2084 |
+
<?php
|
2085 |
esc_html_e( 'Education', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2086 |
?>
|
2087 |
+
</label>
|
2088 |
+
<br>
|
2089 |
+
<label>
|
2090 |
+
<input type='radio' id='wpm_plugin_google_business_vertical_3'
|
2091 |
+
name='wgact_plugin_options[google][ads][google_business_vertical]'
|
2092 |
+
value='3'
|
2093 |
+
<?php
|
2094 |
echo checked( 3, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2095 |
?>
|
2096 |
+
<?php
|
2097 |
+
esc_html_e( $this->disable_if_demo() );
|
2098 |
?>
|
2099 |
+
/>
|
2100 |
+
<?php
|
2101 |
esc_html_e( 'Hotels and rentals', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2102 |
?>
|
2103 |
+
</label>
|
2104 |
+
<br>
|
2105 |
+
<label>
|
2106 |
+
<input type='radio' id='wpm_plugin_google_business_vertical_4'
|
2107 |
+
name='wgact_plugin_options[google][ads][google_business_vertical]'
|
2108 |
+
value='4'
|
2109 |
+
<?php
|
2110 |
echo checked( 4, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2111 |
?>
|
2112 |
+
<?php
|
2113 |
+
esc_html_e( $this->disable_if_demo() );
|
2114 |
?>
|
2115 |
+
/>
|
2116 |
+
<?php
|
2117 |
esc_html_e( 'Jobs', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2118 |
?>
|
2119 |
+
</label>
|
2120 |
+
<br>
|
2121 |
+
<label>
|
2122 |
+
<input type='radio' id='wpm_plugin_google_business_vertical_5'
|
2123 |
+
name='wgact_plugin_options[google][ads][google_business_vertical]'
|
2124 |
+
value='5'
|
2125 |
+
<?php
|
2126 |
echo checked( 5, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2127 |
?>
|
2128 |
+
<?php
|
2129 |
+
esc_html_e( $this->disable_if_demo() );
|
2130 |
?>
|
2131 |
+
/>
|
2132 |
+
<?php
|
2133 |
esc_html_e( 'Local deals', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2134 |
?>
|
2135 |
+
</label>
|
2136 |
+
<br>
|
2137 |
+
<label>
|
2138 |
+
<input type='radio' id='wpm_plugin_google_business_vertical_6'
|
2139 |
+
name='wgact_plugin_options[google][ads][google_business_vertical]'
|
2140 |
+
value='6'
|
2141 |
+
<?php
|
2142 |
echo checked( 6, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2143 |
?>
|
2144 |
+
<?php
|
2145 |
+
esc_html_e( $this->disable_if_demo() );
|
2146 |
?>
|
2147 |
+
/>
|
2148 |
+
<?php
|
2149 |
esc_html_e( 'Real estate', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2150 |
?>
|
2151 |
+
</label>
|
2152 |
+
<br>
|
2153 |
+
<label>
|
2154 |
+
<input type='radio' id='wpm_plugin_google_business_vertical_8'
|
2155 |
+
name='wgact_plugin_options[google][ads][google_business_vertical]'
|
2156 |
+
value='8'
|
2157 |
+
<?php
|
2158 |
echo checked( 8, $this->options['google']['ads']['google_business_vertical'], false ) ;
|
2159 |
?>
|
2160 |
+
<?php
|
2161 |
+
esc_html_e( $this->disable_if_demo() );
|
2162 |
?>
|
2163 |
+
/>
|
2164 |
+
<?php
|
2165 |
esc_html_e( 'Custom', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2166 |
?>
|
2167 |
+
</label>
|
2168 |
+
<br>
|
2169 |
+
<?php
|
2170 |
}
|
2171 |
|
2172 |
public function wpm_plugin_setting_aw_merchant_id()
|
2173 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2174 |
?>
|
2175 |
+
<input type="text"
|
2176 |
+
id="wpm_plugin_aw_merchant_id"
|
2177 |
+
name="wgact_plugin_options[google][ads][aw_merchant_id]"
|
2178 |
+
size="40"
|
2179 |
+
value="<?php
|
2180 |
+
esc_html_e( $this->options['google']['ads']['aw_merchant_id'] );
|
2181 |
+
?>"
|
2182 |
+
/>
|
2183 |
+
<?php
|
2184 |
+
$this->get_status_icon_new( $this->options['google']['ads']['aw_merchant_id'] );
|
2185 |
?>
|
2186 |
+
<?php
|
2187 |
+
$this->get_documentation_html_by_key( 'aw_merchant_id' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2188 |
?>
|
2189 |
+
<br><br>
|
2190 |
+
<?php
|
2191 |
+
esc_html_e( 'ID of your Google Merchant Center account. It looks like this: 12345678', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
|
|
|
|
|
|
|
|
|
|
|
|
2192 |
}
|
2193 |
|
2194 |
public function wpm_plugin_option_product_identifier()
|
2195 |
{
|
2196 |
?>
|
2197 |
+
<label>
|
2198 |
+
<input type='radio' id='wpm_plugin_option_product_identifier_0'
|
2199 |
+
name='wgact_plugin_options[google][ads][product_identifier]'
|
2200 |
+
value='0' <?php
|
2201 |
echo checked( 0, $this->options['google']['ads']['product_identifier'], false ) ;
|
2202 |
+
?>/>
|
2203 |
+
<?php
|
2204 |
esc_html_e( 'post ID (default)', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2205 |
?></label>
|
2206 |
+
<br>
|
2207 |
+
<label>
|
2208 |
+
<input type='radio' id='wpm_plugin_option_product_identifier_2'
|
2209 |
+
name='wgact_plugin_options[google][ads][product_identifier]'
|
2210 |
+
value='2' <?php
|
2211 |
echo checked( 2, $this->options['google']['ads']['product_identifier'], false ) ;
|
2212 |
+
?>/>
|
2213 |
+
<?php
|
2214 |
esc_html_e( 'SKU', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2215 |
?>
|
2216 |
+
</label>
|
2217 |
+
<br>
|
2218 |
+
<label>
|
2219 |
+
<input type='radio' id='wpm_plugin_option_product_identifier_1'
|
2220 |
+
name='wgact_plugin_options[google][ads][product_identifier]'
|
2221 |
+
value='1' <?php
|
2222 |
echo checked( 1, $this->options['google']['ads']['product_identifier'], false ) ;
|
2223 |
+
?>/>
|
2224 |
+
<?php
|
2225 |
esc_html_e( 'ID for the WooCommerce Google Product Feed. Outputs the post ID with woocommerce_gpf_ prefix *', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2226 |
?>
|
2227 |
+
</label>
|
2228 |
+
<br>
|
2229 |
+
<label>
|
2230 |
+
<input type='radio' id='wpm_plugin_option_product_identifier_3'
|
2231 |
+
name='wgact_plugin_options[google][ads][product_identifier]'
|
2232 |
+
value='3' <?php
|
2233 |
echo checked( 3, $this->options['google']['ads']['product_identifier'], false ) ;
|
2234 |
+
?>/>
|
2235 |
+
<?php
|
2236 |
esc_html_e( 'ID for the WooCommerce Google Listings & Ads Plugin. Outputs the post ID with gla_ prefix **', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2237 |
?>
|
2238 |
+
</label>
|
2239 |
+
<br>
|
2240 |
+
<p style="margin-top:10px">
|
2241 |
+
<?php
|
2242 |
esc_html_e( 'Choose a product identifier.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2243 |
?>
|
2244 |
+
</p>
|
2245 |
+
<br>
|
2246 |
+
<?php
|
2247 |
esc_html_e( '* This is for users of the WooCommerce Google Product Feed Plugin', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2248 |
?>
|
2249 |
+
<a href="https://woocommerce.com/products/google-product-feed/" target="_blank">WooCommerce Google Product Feed
|
2250 |
+
Plugin</a>
|
2251 |
+
<br>
|
2252 |
+
<?php
|
2253 |
esc_html_e( '** This is for users of the WooCommerce Google Listings & Ads Plugin', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2254 |
?>
|
2255 |
+
<a href="https://woocommerce.com/products/google-listings-and-ads/" target="_blank">WooCommerce Google Listings
|
2256 |
+
& Ads Plugin
|
2257 |
+
Plugin</a>
|
2258 |
|
2259 |
+
<?php
|
2260 |
}
|
2261 |
|
2262 |
+
private function html_beta()
|
2263 |
{
|
2264 |
return '<div class="status-icon beta">' . esc_html__( 'beta', 'woocommerce-google-adwords-conversion-tracking-tag' ) . '</div>';
|
2265 |
}
|
2266 |
|
2267 |
+
private function html_active()
|
2268 |
{
|
2269 |
return '<div class="status-icon active">' . esc_html__( 'active', 'woocommerce-google-adwords-conversion-tracking-tag' ) . '</div>';
|
2270 |
}
|
2271 |
|
2272 |
+
private function html_active_new()
|
2273 |
+
{
|
2274 |
+
?>
|
2275 |
+
<div class="status-icon active"><?php
|
2276 |
+
esc_html_e( 'active', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2277 |
+
?></div>
|
2278 |
+
<?php
|
2279 |
+
}
|
2280 |
+
|
2281 |
+
private function html_inactive()
|
2282 |
{
|
2283 |
return '<div class="status-icon inactive">' . esc_html__( 'inactive', 'woocommerce-google-adwords-conversion-tracking-tag' ) . '</div>';
|
2284 |
}
|
2285 |
|
2286 |
+
private function html_inactive_new()
|
2287 |
+
{
|
2288 |
+
?>
|
2289 |
+
<div class="status-icon inactive"><?php
|
2290 |
+
esc_html_e( 'inactive', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2291 |
+
?></div>
|
2292 |
+
<?php
|
2293 |
+
}
|
2294 |
+
|
2295 |
+
private function html_partially_active()
|
2296 |
{
|
2297 |
return '<div class="status-icon partially-active">' . esc_html__( 'partially active', 'woocommerce-google-adwords-conversion-tracking-tag' ) . '</div>';
|
2298 |
}
|
2299 |
|
2300 |
+
private function html_partially_active_new()
|
2301 |
+
{
|
2302 |
+
?>
|
2303 |
+
<div class="status-icon partially-active"><?php
|
2304 |
+
esc_html_e( 'partially active', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2305 |
+
?></div>
|
2306 |
+
<?php
|
2307 |
+
}
|
2308 |
+
|
2309 |
+
private function html_pro_feature()
|
2310 |
{
|
2311 |
|
2312 |
if ( !wpm_fs()->is__premium_only() && $this->options['general']['pro_version_demo'] ) {
|
2313 |
// if (1===1) {
|
2314 |
+
// return '<div class="pro-feature">' . esc_html__('Pro Feature', 'woocommerce-google-adwords-conversion-tracking-tag') . '</div>';
|
2315 |
+
?>
|
2316 |
+
<div class="pro-feature"><?php
|
2317 |
+
esc_html_e( 'Pro Feature', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
2318 |
+
?></div>
|
2319 |
+
|
2320 |
+
<?php
|
2321 |
}
|
2322 |
|
2323 |
}
|
2324 |
|
2325 |
+
private function get_status_icon( $status, $requirements = true, $inactive_silent = false )
|
2326 |
{
|
2327 |
|
2328 |
if ( $status && $requirements ) {
|
2329 |
return $this->html_active();
|
2330 |
} elseif ( $status && !$requirements ) {
|
2331 |
return $this->html_partially_active();
|
2332 |
+
} elseif ( false == $inactive_silent ) {
|
2333 |
return $this->html_inactive();
|
2334 |
}
|
2335 |
|
2336 |
return '';
|
2337 |
}
|
2338 |
|
2339 |
+
private function get_status_icon_new( $status, $requirements = true, $inactive_silent = false )
|
2340 |
+
{
|
2341 |
+
|
2342 |
+
if ( $status && $requirements ) {
|
2343 |
+
$this->html_active_new();
|
2344 |
+
} elseif ( $status && !$requirements ) {
|
2345 |
+
$this->html_partially_active_new();
|
2346 |
+
} elseif ( false == $inactive_silent ) {
|
2347 |
+
$this->html_inactive_new();
|
2348 |
+
}
|
2349 |
+
|
2350 |
+
return '';
|
2351 |
+
}
|
2352 |
+
|
2353 |
+
private function disable_if_demo()
|
2354 |
{
|
2355 |
|
2356 |
if ( !wpm_fs()->is__premium_only() && $this->options['general']['pro_version_demo'] ) {
|
2362 |
}
|
2363 |
|
2364 |
// validate the options
|
2365 |
+
public function wpm_options_validate( $input )
|
2366 |
{
|
2367 |
// error_log(print_r($input, true));
|
2368 |
// validate Google Analytics Universal property ID
|
2369 |
if ( isset( $input['google']['analytics']['universal']['property_id'] ) ) {
|
2370 |
|
2371 |
+
if ( !$this->validations->is_google_analytics_universal_property_id( $input['google']['analytics']['universal']['property_id'] ) ) {
|
2372 |
$input['google']['analytics']['universal']['property_id'] = ( isset( $this->options['google']['analytics']['universal']['property_id'] ) ? $this->options['google']['analytics']['universal']['property_id'] : '' );
|
2373 |
add_settings_error( 'wgact_plugin_options', 'invalid-google-analytics-universal-property-id', esc_html__( 'You have entered an invalid Google Analytics Universal property ID.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2374 |
}
|
2377 |
// validate Google Analytics 4 measurement ID
|
2378 |
if ( isset( $input['google']['analytics']['ga4']['measurement_id'] ) ) {
|
2379 |
|
2380 |
+
if ( !$this->validations->is_google_analytics_4_measurement_id( $input['google']['analytics']['ga4']['measurement_id'] ) ) {
|
2381 |
$input['google']['analytics']['ga4']['measurement_id'] = ( isset( $this->options['google']['analytics']['ga4']['measurement_id'] ) ? $this->options['google']['analytics']['ga4']['measurement_id'] : '' );
|
2382 |
add_settings_error( 'wgact_plugin_options', 'invalid-google-analytics-4-measurement-id', esc_html__( 'You have entered an invalid Google Analytics 4 measurement ID.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2383 |
}
|
2386 |
// validate Google Analytics 4 API key
|
2387 |
if ( isset( $input['google']['analytics']['ga4']['api_secret'] ) ) {
|
2388 |
|
2389 |
+
if ( !$this->validations->is_google_analytics_4_api_secret( $input['google']['analytics']['ga4']['api_secret'] ) ) {
|
2390 |
$input['google']['analytics']['ga4']['api_secret'] = ( isset( $this->options['google']['analytics']['ga4']['api_secret'] ) ? $this->options['google']['analytics']['ga4']['api_secret'] : '' );
|
2391 |
add_settings_error( 'wgact_plugin_options', 'invalid-google-analytics-4-measurement-id', esc_html__( 'You have entered an invalid Google Analytics 4 API key.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2392 |
}
|
2395 |
// validate ['google]['ads']['conversion_id']
|
2396 |
if ( isset( $input['google']['ads']['conversion_id'] ) ) {
|
2397 |
|
2398 |
+
if ( !$this->validations->is_gads_conversion_id( $input['google']['ads']['conversion_id'] ) ) {
|
2399 |
$input['google']['ads']['conversion_id'] = ( isset( $this->options['google']['ads']['conversion_id'] ) ? $this->options['google']['ads']['conversion_id'] : '' );
|
2400 |
add_settings_error( 'wgact_plugin_options', 'invalid-conversion-id', esc_html__( 'You have entered an invalid conversion ID. It only contains 8 to 10 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2401 |
}
|
2404 |
// validate ['google]['ads']['conversion_label']
|
2405 |
if ( isset( $input['google']['ads']['conversion_label'] ) ) {
|
2406 |
|
2407 |
+
if ( !$this->validations->is_gads_conversion_label( $input['google']['ads']['conversion_label'] ) ) {
|
2408 |
$input['google']['ads']['conversion_label'] = ( isset( $this->options['google']['ads']['conversion_label'] ) ? $this->options['google']['ads']['conversion_label'] : '' );
|
2409 |
add_settings_error( 'wgact_plugin_options', 'invalid-conversion-label', esc_html__( 'You have entered an invalid conversion label.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2410 |
}
|
2413 |
// validate ['google]['ads']['phone_conversion_label']
|
2414 |
if ( isset( $input['google']['ads']['phone_conversion_label'] ) ) {
|
2415 |
|
2416 |
+
if ( !$this->validations->is_gads_conversion_label( $input['google']['ads']['phone_conversion_label'] ) ) {
|
2417 |
$input['google']['ads']['phone_conversion_label'] = ( isset( $this->options['google']['ads']['phone_conversion_label'] ) ? $this->options['google']['ads']['phone_conversion_label'] : '' );
|
2418 |
add_settings_error( 'wgact_plugin_options', 'invalid-conversion-label', esc_html__( 'You have entered an invalid conversion label.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2419 |
}
|
2422 |
// validate ['google]['ads']['aw_merchant_id']
|
2423 |
if ( isset( $input['google']['ads']['aw_merchant_id'] ) ) {
|
2424 |
|
2425 |
+
if ( !$this->validations->is_gads_aw_merchant_id( $input['google']['ads']['aw_merchant_id'] ) ) {
|
2426 |
$input['google']['ads']['aw_merchant_id'] = ( isset( $this->options['google']['ads']['aw_merchant_id'] ) ? $this->options['google']['ads']['aw_merchant_id'] : '' );
|
2427 |
add_settings_error( 'wgact_plugin_options', 'invalid-aw-merchant-id', esc_html__( 'You have entered an invalid merchant ID. It only contains 7 to 10 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2428 |
}
|
2431 |
// validate Google Optimize container ID
|
2432 |
if ( isset( $input['google']['optimize']['container_id'] ) ) {
|
2433 |
|
2434 |
+
if ( !$this->validations->is_google_optimize_measurement_id( $input['google']['optimize']['container_id'] ) ) {
|
2435 |
$input['google']['optimize']['container_id'] = ( isset( $this->options['google']['optimize']['container_id'] ) ? $this->options['google']['optimize']['container_id'] : '' );
|
2436 |
add_settings_error( 'wgact_plugin_options', 'invalid-google-optimize-container-id', esc_html__( 'You have entered an invalid Google Optimize container ID.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2437 |
}
|
2440 |
// validate ['facebook']['pixel_id']
|
2441 |
if ( isset( $input['facebook']['pixel_id'] ) ) {
|
2442 |
|
2443 |
+
if ( !$this->validations->is_facebook_pixel_id( $input['facebook']['pixel_id'] ) ) {
|
2444 |
$input['facebook']['pixel_id'] = ( isset( $this->options['facebook']['pixel_id'] ) ? $this->options['facebook']['pixel_id'] : '' );
|
2445 |
+
add_settings_error( 'wgact_plugin_options', 'invalid-facebook-pixel-id', esc_html__( 'You have entered an invalid Meta (Facebook) pixel ID. It only contains 14 to 16 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2446 |
}
|
2447 |
|
2448 |
}
|
2449 |
// validate ['facebook']['capi']['token']
|
2450 |
if ( isset( $input['facebook']['capi']['token'] ) ) {
|
2451 |
|
2452 |
+
if ( !$this->validations->is_facebook_capi_token( $input['facebook']['capi']['token'] ) ) {
|
2453 |
$input['facebook']['capi']['token'] = ( isset( $this->options['facebook']['capi']['token'] ) ? $this->options['facebook']['capi']['token'] : '' );
|
2454 |
+
add_settings_error( 'wgact_plugin_options', 'invalid-facebook-pixel-id', esc_html__( 'You have entered an invalid Meta (Facebook) CAPI token.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2455 |
}
|
2456 |
|
2457 |
}
|
2458 |
// validate Bing Ads UET tag ID
|
2459 |
if ( isset( $input['bing']['uet_tag_id'] ) ) {
|
2460 |
|
2461 |
+
if ( !$this->validations->is_bing_uet_tag_id( $input['bing']['uet_tag_id'] ) ) {
|
2462 |
$input['bing']['uet_tag_id'] = ( isset( $this->options['bing']['uet_tag_id'] ) ? $this->options['bing']['uet_tag_id'] : '' );
|
2463 |
add_settings_error( 'wgact_plugin_options', 'invalid-bing-ads-uet-tag-id', esc_html__( 'You have entered an invalid Bing Ads UET tag ID. It only contains 7 to 9 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2464 |
}
|
2467 |
// validate Twitter pixel ID
|
2468 |
if ( isset( $input['twitter']['pixel_id'] ) ) {
|
2469 |
|
2470 |
+
if ( !$this->validations->is_twitter_pixel_id( $input['twitter']['pixel_id'] ) ) {
|
2471 |
$input['twitter']['pixel_id'] = ( isset( $this->options['twitter']['pixel_id'] ) ? $this->options['twitter']['pixel_id'] : '' );
|
2472 |
add_settings_error( 'wgact_plugin_options', 'invalid-twitter-pixel-id', esc_html__( 'You have entered an invalid Twitter pixel ID. It only contains 5 to 7 lowercase letters and numbers.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2473 |
}
|
2476 |
// validate Pinterest pixel ID
|
2477 |
if ( isset( $input['pinterest']['pixel_id'] ) ) {
|
2478 |
|
2479 |
+
if ( !$this->validations->is_pinterest_pixel_id( $input['pinterest']['pixel_id'] ) ) {
|
2480 |
$input['pinterest']['pixel_id'] = ( isset( $this->options['pinterest']['pixel_id'] ) ? $this->options['pinterest']['pixel_id'] : '' );
|
2481 |
add_settings_error( 'wgact_plugin_options', 'invalid-pinterest-pixel-id', esc_html__( 'You have entered an invalid Pinterest pixel ID. It only contains 13 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2482 |
}
|
2485 |
// validate Snapchat pixel ID
|
2486 |
if ( isset( $input['snapchat']['pixel_id'] ) ) {
|
2487 |
|
2488 |
+
if ( !$this->validations->is_snapchat_pixel_id( $input['snapchat']['pixel_id'] ) ) {
|
2489 |
$input['snapchat']['pixel_id'] = ( isset( $this->options['snapchat']['pixel_id'] ) ? $this->options['snapchat']['pixel_id'] : '' );
|
2490 |
add_settings_error( 'wgact_plugin_options', 'invalid-snapchat-pixel-id', esc_html__( 'You have entered an invalid Snapchat pixel ID.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2491 |
}
|
2494 |
// validate TikTok pixel ID
|
2495 |
if ( isset( $input['tiktok']['pixel_id'] ) ) {
|
2496 |
|
2497 |
+
if ( !$this->validations->is_tiktok_pixel_id( $input['tiktok']['pixel_id'] ) ) {
|
2498 |
$input['tiktok']['pixel_id'] = ( isset( $this->options['tiktok']['pixel_id'] ) ? $this->options['tiktok']['pixel_id'] : '' );
|
2499 |
add_settings_error( 'wgact_plugin_options', 'invalid-tiktok-pixel-id', esc_html__( 'You have entered an invalid TikTok pixel ID.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2500 |
}
|
2503 |
// validate Hotjar site ID
|
2504 |
if ( isset( $input['hotjar']['site_id'] ) ) {
|
2505 |
|
2506 |
+
if ( !$this->validations->is_hotjar_site_id( $input['hotjar']['site_id'] ) ) {
|
2507 |
$input['hotjar']['site_id'] = ( isset( $this->options['hotjar']['site_id'] ) ? $this->options['hotjar']['site_id'] : '' );
|
2508 |
add_settings_error( 'wgact_plugin_options', 'invalid-hotjar-site-id', esc_html__( 'You have entered an invalid Hotjar site ID. It only contains 6 to 9 digits.', 'woocommerce-google-adwords-conversion-tracking-tag' ) );
|
2509 |
}
|
2510 |
|
2511 |
}
|
2512 |
+
/**
|
2513 |
+
* Merging with the existing options and overwriting old values
|
2514 |
+
* since disabling a checkbox doesn't send a value,
|
2515 |
+
* we need to set one to overwrite the old value
|
2516 |
+
*/
|
2517 |
+
return array_replace_recursive( $this->non_form_keys( $input ), $input );
|
|
|
|
|
|
|
|
|
2518 |
}
|
2519 |
|
2520 |
// Recursively go through the array and merge (overwrite old values with new ones
|
2521 |
// if a value is missing in the input array, set it to value zero in the options array
|
2522 |
// Omit key like 'db_version' since they would be overwritten with zero.
|
2523 |
+
protected function merge_options( $array_existing, $array_input )
|
2524 |
{
|
2525 |
$array_output = [];
|
2526 |
foreach ( $array_existing as $key => $value ) {
|
2547 |
return $array_output;
|
2548 |
}
|
2549 |
|
2550 |
+
protected function non_form_keys( $input )
|
2551 |
{
|
2552 |
// place here what could be overwritten when a form field is missing
|
2553 |
// and what should not be re-set to the default value
|
2554 |
// but should be preserved
|
2555 |
$non_form_keys = [
|
2556 |
'db_version' => $this->options['db_version'],
|
2557 |
+
'shop' => [
|
2558 |
+
'disable_tracking_for' => [],
|
2559 |
+
],
|
2560 |
];
|
2561 |
// in case the form field input is missing
|
2562 |
// if (!array_key_exists('google_business_vertical', $input['google']['ads'])) {
|
2565 |
return $non_form_keys;
|
2566 |
}
|
2567 |
|
2568 |
+
private function set_array_value_to_zero( $array )
|
2569 |
{
|
2570 |
array_walk_recursive( $array, function ( &$leafnode ) {
|
2571 |
$leafnode = 0;
|
2573 |
return $array;
|
2574 |
}
|
2575 |
|
2576 |
+
private function pro_version_demo_active()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2577 |
{
|
2578 |
|
2579 |
if ( $this->options['general']['pro_version_demo'] ) {
|
classes/admin/class-ask-for-rating.php
CHANGED
@@ -3,15 +3,13 @@
|
|
3 |
namespace WCPM\Classes\Admin;
|
4 |
|
5 |
if (!defined('ABSPATH')) {
|
6 |
-
|
7 |
}
|
8 |
|
9 |
-
class Ask_For_Rating
|
10 |
-
|
11 |
-
private $option_name = WPM_DB_RATINGS;
|
12 |
|
13 |
-
|
14 |
-
{
|
15 |
// $options = get_option($this->option_name);
|
16 |
// $options['conversions_count'] = 8;
|
17 |
// $options['rating_threshold'] = 10;
|
@@ -19,154 +17,152 @@ class Ask_For_Rating
|
|
19 |
// $options['rating_done'] = false;
|
20 |
// update_option($this->option_name,$options);
|
21 |
|
22 |
-
|
23 |
// add_action('admin_enqueue_scripts', [$this, 'wpm_rating_script']);
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
}
|
172 |
-
}
|
3 |
namespace WCPM\Classes\Admin;
|
4 |
|
5 |
if (!defined('ABSPATH')) {
|
6 |
+
exit; // Exit if accessed directly
|
7 |
}
|
8 |
|
9 |
+
class Ask_For_Rating {
|
10 |
+
private $option_name = WPM_DB_RATINGS;
|
|
|
11 |
|
12 |
+
public function __construct() {
|
|
|
13 |
// $options = get_option($this->option_name);
|
14 |
// $options['conversions_count'] = 8;
|
15 |
// $options['rating_threshold'] = 10;
|
17 |
// $options['rating_done'] = false;
|
18 |
// update_option($this->option_name,$options);
|
19 |
|
20 |
+
// ask for a rating in a plugin notice
|
21 |
// add_action('admin_enqueue_scripts', [$this, 'wpm_rating_script']);
|
22 |
+
add_action('wp_ajax_wpm_dismissed_notice_handler', [$this, 'ajax_rating_notice_handler']);
|
23 |
+
add_action('admin_notices', [$this, 'ask_for_rating_notices_if_not_asked_before']);
|
24 |
+
}
|
25 |
+
|
26 |
+
public function wpm_rating_script() {
|
27 |
+
wp_enqueue_script(
|
28 |
+
'wpm-ask-for-rating',
|
29 |
+
WPM_PLUGIN_DIR_PATH . 'js/admin/ask-for-rating.js',
|
30 |
+
['jquery'],
|
31 |
+
WPM_CURRENT_VERSION,
|
32 |
+
true
|
33 |
+
);
|
34 |
+
}
|
35 |
+
|
36 |
+
// server side php ajax handler for the admin rating notice
|
37 |
+
public function ajax_rating_notice_handler() {
|
38 |
+
|
39 |
+
$_post = filter_input_array(INPUT_POST, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
40 |
+
|
41 |
+
$set = $_post['set'];
|
42 |
+
|
43 |
+
$options = get_option($this->option_name);
|
44 |
+
|
45 |
+
if ('rating_done' === $set) {
|
46 |
+
|
47 |
+
$options['rating_done'] = true;
|
48 |
+
update_option($this->option_name, $options);
|
49 |
+
|
50 |
+
} elseif ('later' === $set) {
|
51 |
+
|
52 |
+
$options['rating_threshold'] = $this->get_next_threshold($options['conversions_count']);
|
53 |
+
update_option($this->option_name, $options);
|
54 |
+
}
|
55 |
+
|
56 |
+
wp_die(); // this is required to terminate immediately and return a proper response
|
57 |
+
}
|
58 |
+
|
59 |
+
private function show_admin_notifications() {
|
60 |
+
$show_admin_notifications = apply_filters_deprecated('wooptpm_show_admin_notifications', [true], '1.13.0', 'wpm_show_admin_notifications');
|
61 |
+
|
62 |
+
// Allow users to disable admin notifications for the plugin
|
63 |
+
return apply_filters('wpm_show_admin_notifications', $show_admin_notifications);
|
64 |
+
}
|
65 |
+
|
66 |
+
public function ask_for_rating_notices_if_not_asked_before() {
|
67 |
+
if (current_user_can('administrator') && $this->show_admin_notifications()) {
|
68 |
+
|
69 |
+
$wpm_ratings = get_option($this->option_name);
|
70 |
+
|
71 |
+
if (isset($wpm_ratings['conversions_count'])) {
|
72 |
+
|
73 |
+
$conversions_count = $wpm_ratings['conversions_count'];
|
74 |
+
|
75 |
+
// in rare cases this option has not been set
|
76 |
+
// in those cases we set it to avoid further errors
|
77 |
+
if (!isset($wpm_ratings['rating_done'])) {
|
78 |
+
$wpm_ratings['rating_done'] = false;
|
79 |
+
update_option($this->option_name, $wpm_ratings);
|
80 |
+
}
|
81 |
+
|
82 |
+
// in rare cases this option has not been set
|
83 |
+
// in those cases we set it to avoid further errors
|
84 |
+
if (!isset($wpm_ratings['rating_threshold'])) {
|
85 |
+
$wpm_ratings['rating_threshold'] = 10;
|
86 |
+
update_option($this->option_name, $wpm_ratings);
|
87 |
+
}
|
88 |
+
|
89 |
+
if (( false === $wpm_ratings['rating_done'] && $conversions_count > $wpm_ratings['rating_threshold'] ) || ( defined('WPM_ALWAYS_AKS_FOR_RATING') && true === WPM_ALWAYS_AKS_FOR_RATING )) {
|
90 |
+
|
91 |
+
$this->ask_for_rating_notices($conversions_count);
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
|
95 |
+
// set default settings for wpm_ratings
|
96 |
+
update_option($this->option_name, $this->get_default_settings());
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
private function get_next_threshold( $conversions_count ) {
|
102 |
+
return $conversions_count * 10;
|
103 |
+
}
|
104 |
+
|
105 |
+
private function get_default_settings() {
|
106 |
+
return [
|
107 |
+
'conversions_count' => 1,
|
108 |
+
'rating_threshold' => 10,
|
109 |
+
'rating_done' => false,
|
110 |
+
];
|
111 |
+
}
|
112 |
+
|
113 |
+
// show an admin notice to ask for a plugin rating
|
114 |
+
public function ask_for_rating_notices( $conversions_count ) {
|
115 |
+
?>
|
116 |
+
<div class="notice notice-success wpm-rating-success-notice" style="display: none">
|
117 |
+
<div style="color:#02830b;font-weight: bold">
|
118 |
+
|
119 |
+
<span>
|
120 |
+
<?php
|
121 |
+
printf(
|
122 |
+
/* translators: %d: the amount of purchase conversions that have been measured */
|
123 |
+
esc_html__('Hey, I noticed that you tracked more than %d purchase conversions with the Google Ads Conversion Tracking plugin - that\'s awesome! Could you please do me a BIG favour and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation.', 'woocommerce-google-adwords-conversion-tracking-tag'),
|
124 |
+
esc_html__($conversions_count)
|
125 |
+
);
|
126 |
+
?>
|
127 |
+
|
128 |
+
</span>
|
129 |
+
<br>
|
130 |
+
<span>- Aleksandar</span>
|
131 |
+
</div>
|
132 |
+
<div style="font-weight: bold;">
|
133 |
+
|
134 |
+
<ul style="list-style-type: disc ;padding-left:20px">
|
135 |
+
<li>
|
136 |
+
<a id="wpm-rate-it" href="#">
|
137 |
+
<?php esc_html_e('Ok, you deserve it', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
138 |
+
</a>
|
139 |
+
</li>
|
140 |
+
<li>
|
141 |
+
<a id="wpm-maybe-later" href="#">
|
142 |
+
<?php esc_html_e('Nope, maybe later', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
143 |
+
</a>
|
144 |
+
</li>
|
145 |
+
<li>
|
146 |
+
|
147 |
+
<div style=" margin-bottom: 10px; display: flex; justify-content: space-between">
|
148 |
+
|
149 |
+
<div id="wpm-paypal-standard-error-dismissal-button" style="white-space:normal;">
|
150 |
+
<a id="wpm-already-did" href="#">
|
151 |
+
<?php esc_html_e('I already did', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
152 |
+
</a>
|
153 |
+
</div>
|
154 |
+
<div style="white-space:normal; bottom:0; right: 0; margin-bottom: 0; margin-right: 5px;align-self: flex-end;">
|
155 |
+
<a href="<?php echo esc_url(( new Documentation() )->get_link('the_dismiss_button_doesnt_work_why')); ?>"
|
156 |
+
target="_blank">
|
157 |
+
<?php esc_html_e('If the dismiss button is not working, here\'s why >>', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
158 |
+
</a>
|
159 |
+
</div>
|
160 |
+
</div>
|
161 |
+
</li>
|
162 |
+
</ul>
|
163 |
+
</div>
|
164 |
+
|
165 |
+
</div>
|
166 |
+
<?php
|
167 |
+
}
|
168 |
+
}
|
|
|
|
classes/admin/class-consent-mode-regions.php
ADDED
@@ -0,0 +1,261 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WCPM\Classes\Admin;
|
4 |
+
|
5 |
+
class Consent_Mode_Regions {
|
6 |
+
|
7 |
+
public function get_consent_mode_regions() {
|
8 |
+
return [
|
9 |
+
'AF' => 'Afghanistan',
|
10 |
+
'AX' => 'Åland Islands',
|
11 |
+
'AL' => 'Albania',
|
12 |
+
'DZ' => 'Algeria',
|
13 |
+
'AS' => 'American Samoa',
|
14 |
+
'AD' => 'Andorra',
|
15 |
+
'AO' => 'Angola',
|
16 |
+
'AI' => 'Anguilla',
|
17 |
+
'AQ' => 'Antarctica',
|
18 |
+
'AG' => 'Antigua and Barbuda',
|
19 |
+
'AR' => 'Argentina',
|
20 |
+
'AM' => 'Armenia',
|
21 |
+
'AW' => 'Aruba',
|
22 |
+
'AU' => 'Australia',
|
23 |
+
'AT' => 'Austria',
|
24 |
+
'AZ' => 'Azerbaijan',
|
25 |
+
'BS' => 'Bahamas',
|
26 |
+
'BH' => 'Bahrain',
|
27 |
+
'BD' => 'Bangladesh',
|
28 |
+
'BB' => 'Barbados',
|
29 |
+
'BY' => 'Belarus',
|
30 |
+
'BE' => 'Belgium',
|
31 |
+
'BZ' => 'Belize',
|
32 |
+
'BJ' => 'Benin',
|
33 |
+
'BM' => 'Bermuda',
|
34 |
+
'BT' => 'Bhutan',
|
35 |
+
'BO' => 'Bolivia, Plurinational State of',
|
36 |
+
'BQ' => 'Bonaire, Sint Eustatius and Saba',
|
37 |
+
'BA' => 'Bosnia and Herzegovina',
|
38 |
+
'BW' => 'Botswana',
|
39 |
+
'BV' => 'Bouvet Island',
|
40 |
+
'BR' => 'Brazil',
|
41 |
+
'IO' => 'British Indian Ocean Territory',
|
42 |
+
'BN' => 'Brunei Darussalam',
|
43 |
+
'BG' => 'Bulgaria',
|
44 |
+
'BF' => 'Burkina Faso',
|
45 |
+
'BI' => 'Burundi',
|
46 |
+
'KH' => 'Cambodia',
|
47 |
+
'CM' => 'Cameroon',
|
48 |
+
'CA' => 'Canada',
|
49 |
+
'CV' => 'Cape Verde',
|
50 |
+
'KY' => 'Cayman Islands',
|
51 |
+
'CF' => 'Central African Republic',
|
52 |
+
'TD' => 'Chad',
|
53 |
+
'CL' => 'Chile',
|
54 |
+
'CN' => 'China',
|
55 |
+
'CX' => 'Christmas Island',
|
56 |
+
'CC' => 'Cocos (Keeling) Islands',
|
57 |
+
'CO' => 'Colombia',
|
58 |
+
'KM' => 'Comoros',
|
59 |
+
'CG' => 'Congo',
|
60 |
+
'CD' => 'Congo, the Democratic Republic of the',
|
61 |
+
'CK' => 'Cook Islands',
|
62 |
+
'CR' => 'Costa Rica',
|
63 |
+
'CI' => 'Côte d\'Ivoire',
|
64 |
+
'HR' => 'Croatia',
|
65 |
+
'CU' => 'Cuba',
|
66 |
+
'CW' => 'Curaçao',
|
67 |
+
'CY' => 'Cyprus',
|
68 |
+
'CZ' => 'Czech Republic',
|
69 |
+
'DK' => 'Denmark',
|
70 |
+
'DJ' => 'Djibouti',
|
71 |
+
'DM' => 'Dominica',
|
72 |
+
'DO' => 'Dominican Republic',
|
73 |
+
'EC' => 'Ecuador',
|
74 |
+
'EG' => 'Egypt',
|
75 |
+
'SV' => 'El Salvador',
|
76 |
+
'GQ' => 'Equatorial Guinea',
|
77 |
+
'ER' => 'Eritrea',
|
78 |
+
'EE' => 'Estonia',
|
79 |
+
'ET' => 'Ethiopia',
|
80 |
+
'FK' => 'Falkland Islands (Malvinas)',
|
81 |
+
'FO' => 'Faroe Islands',
|
82 |
+
'FJ' => 'Fiji',
|
83 |
+
'FI' => 'Finland',
|
84 |
+
'FR' => 'France',
|
85 |
+
'GF' => 'French Guiana',
|
86 |
+
'PF' => 'French Polynesia',
|
87 |
+
'TF' => 'French Southern Territories',
|
88 |
+
'GA' => 'Gabon',
|
89 |
+
'GM' => 'Gambia',
|
90 |
+
'GE' => 'Georgia',
|
91 |
+
'DE' => 'Germany',
|
92 |
+
'GH' => 'Ghana',
|
93 |
+
'GI' => 'Gibraltar',
|
94 |
+
'GR' => 'Greece',
|
95 |
+
'GL' => 'Greenland',
|
96 |
+
'GD' => 'Grenada',
|
97 |
+
'GP' => 'Guadeloupe',
|
98 |
+
'GU' => 'Guam',
|
99 |
+
'GT' => 'Guatemala',
|
100 |
+
'GG' => 'Guernsey',
|
101 |
+
'GN' => 'Guinea',
|
102 |
+
'GW' => 'Guinea-Bissau',
|
103 |
+
'GY' => 'Guyana',
|
104 |
+
'HT' => 'Haiti',
|
105 |
+
'HM' => 'Heard Island and McDonald Islands',
|
106 |
+
'VA' => 'Holy See (Vatican City State)',
|
107 |
+
'HN' => 'Honduras',
|
108 |
+
'HK' => 'Hong Kong',
|
109 |
+
'HU' => 'Hungary',
|
110 |
+
'IS' => 'Iceland',
|
111 |
+
'IN' => 'India',
|
112 |
+
'ID' => 'Indonesia',
|
113 |
+
'IR' => 'Iran, Islamic Republic of',
|
114 |
+
'IQ' => 'Iraq',
|
115 |
+
'IE' => 'Ireland',
|
116 |
+
'IM' => 'Isle of Man',
|
117 |
+
'IL' => 'Israel',
|
118 |
+
'IT' => 'Italy',
|
119 |
+
'JM' => 'Jamaica',
|
120 |
+
'JP' => 'Japan',
|
121 |
+
'JE' => 'Jersey',
|
122 |
+
'JO' => 'Jordan',
|
123 |
+
'KZ' => 'Kazakhstan',
|
124 |
+
'KE' => 'Kenya',
|
125 |
+
'KI' => 'Kiribati',
|
126 |
+
'KP' => 'Korea, Democratic People\'s Republic of',
|
127 |
+
'KR' => 'Korea, Republic of',
|
128 |
+
'KW' => 'Kuwait',
|
129 |
+
'KG' => 'Kyrgyzstan',
|
130 |
+
'LA' => 'Lao People\'s Democratic Republic',
|
131 |
+
'LV' => 'Latvia',
|
132 |
+
'LB' => 'Lebanon',
|
133 |
+
'LS' => 'Lesotho',
|
134 |
+
'LR' => 'Liberia',
|
135 |
+
'LY' => 'Libya',
|
136 |
+
'LI' => 'Liechtenstein',
|
137 |
+
'LT' => 'Lithuania',
|
138 |
+
'LU' => 'Luxembourg',
|
139 |
+
'MO' => 'Macao',
|
140 |
+
'MK' => 'North Macedonia',
|
141 |
+
'MG' => 'Madagascar',
|
142 |
+
'MW' => 'Malawi',
|
143 |
+
'MY' => 'Malaysia',
|
144 |
+
'MV' => 'Maldives',
|
145 |
+
'ML' => 'Mali',
|
146 |
+
'MT' => 'Malta',
|
147 |
+
'MH' => 'Marshall Islands',
|
148 |
+
'MQ' => 'Martinique',
|
149 |
+
'MR' => 'Mauritania',
|
150 |
+
'MU' => 'Mauritius',
|
151 |
+
'YT' => 'Mayotte',
|
152 |
+
'MX' => 'Mexico',
|
153 |
+
'FM' => 'Micronesia, Federated States of',
|
154 |
+
'MD' => 'Moldova, Republic of',
|
155 |
+
'MC' => 'Monaco',
|
156 |
+
'MN' => 'Mongolia',
|
157 |
+
'ME' => 'Montenegro',
|
158 |
+
'MS' => 'Montserrat',
|
159 |
+
'MA' => 'Morocco',
|
160 |
+
'MZ' => 'Mozambique',
|
161 |
+
'MM' => 'Myanmar',
|
162 |
+
'NA' => 'Namibia',
|
163 |
+
'NR' => 'Nauru',
|
164 |
+
'NP' => 'Nepal',
|
165 |
+
'NL' => 'Netherlands',
|
166 |
+
'NC' => 'New Caledonia',
|
167 |
+
'NZ' => 'New Zealand',
|
168 |
+
'NI' => 'Nicaragua',
|
169 |
+
'NE' => 'Niger',
|
170 |
+
'NG' => 'Nigeria',
|
171 |
+
'NU' => 'Niue',
|
172 |
+
'NF' => 'Norfolk Island',
|
173 |
+
'MP' => 'Northern Mariana Islands',
|
174 |
+
'NO' => 'Norway',
|
175 |
+
'OM' => 'Oman',
|
176 |
+
'PK' => 'Pakistan',
|
177 |
+
'PW' => 'Palau',
|
178 |
+
'PS' => 'Palestine, State of',
|
179 |
+
'PA' => 'Panama',
|
180 |
+
'PG' => 'Papua New Guinea',
|
181 |
+
'PY' => 'Paraguay',
|
182 |
+
'PE' => 'Peru',
|
183 |
+
'PH' => 'Philippines',
|
184 |
+
'PN' => 'Pitcairn',
|
185 |
+
'PL' => 'Poland',
|
186 |
+
'PT' => 'Portugal',
|
187 |
+
'PR' => 'Puerto Rico',
|
188 |
+
'QA' => 'Qatar',
|
189 |
+
'RE' => 'Réunion',
|
190 |
+
'RO' => 'Romania',
|
191 |
+
'RU' => 'Russian Federation',
|
192 |
+
'RW' => 'Rwanda',
|
193 |
+
'BL' => 'Saint Barthélemy',
|
194 |
+
'SH' => 'Saint Helena, Ascension and Tristan da Cunha',
|
195 |
+
'KN' => 'Saint Kitts and Nevis',
|
196 |
+
'LC' => 'Saint Lucia',
|
197 |
+
'MF' => 'Saint Martin (French part)',
|
198 |
+
'PM' => 'Saint Pierre and Miquelon',
|
199 |
+
'VC' => 'Saint Vincent and the Grenadines',
|
200 |
+
'WS' => 'Samoa',
|
201 |
+
'SM' => 'San Marino',
|
202 |
+
'ST' => 'Sao Tome and Principe',
|
203 |
+
'SA' => 'Saudi Arabia',
|
204 |
+
'SN' => 'Senegal',
|
205 |
+
'RS' => 'Serbia',
|
206 |
+
'SC' => 'Seychelles',
|
207 |
+
'SL' => 'Sierra Leone',
|
208 |
+
'SG' => 'Singapore',
|
209 |
+
'SX' => 'Sint Maarten (Dutch part)',
|
210 |
+
'SK' => 'Slovakia',
|
211 |
+
'SI' => 'Slovenia',
|
212 |
+
'SB' => 'Solomon Islands',
|
213 |
+
'SO' => 'Somalia',
|
214 |
+
'ZA' => 'South Africa',
|
215 |
+
'GS' => 'South Georgia and the South Sandwich Islands',
|
216 |
+
'SS' => 'South Sudan',
|
217 |
+
'ES' => 'Spain',
|
218 |
+
'LK' => 'Sri Lanka',
|
219 |
+
'SD' => 'Sudan',
|
220 |
+
'SR' => 'Suriname',
|
221 |
+
'SJ' => 'Svalbard and Jan Mayen',
|
222 |
+
'SZ' => 'Swaziland',
|
223 |
+
'SE' => 'Sweden',
|
224 |
+
'CH' => 'Switzerland',
|
225 |
+
'SY' => 'Syrian Arab Republic',
|
226 |
+
'TW' => 'Taiwan, Province of China',
|
227 |
+
'TJ' => 'Tajikistan',
|
228 |
+
'TZ' => 'Tanzania, United Republic of',
|
229 |
+
'TH' => 'Thailand',
|
230 |
+
'TL' => 'Timor-Leste',
|
231 |
+
'TG' => 'Togo',
|
232 |
+
'TK' => 'Tokelau',
|
233 |
+
'TO' => 'Tonga',
|
234 |
+
'TT' => 'Trinidad and Tobago',
|
235 |
+
'TN' => 'Tunisia',
|
236 |
+
'TR' => 'Turkey',
|
237 |
+
'TM' => 'Turkmenistan',
|
238 |
+
'TC' => 'Turks and Caicos Islands',
|
239 |
+
'TV' => 'Tuvalu',
|
240 |
+
'UG' => 'Uganda',
|
241 |
+
'UA' => 'Ukraine',
|
242 |
+
'AE' => 'United Arab Emirates',
|
243 |
+
'GB' => 'United Kingdom',
|
244 |
+
'US' => 'United States',
|
245 |
+
'US-CA' => 'United States - California',
|
246 |
+
'UM' => 'United States Minor Outlying Islands',
|
247 |
+
'UY' => 'Uruguay',
|
248 |
+
'UZ' => 'Uzbekistan',
|
249 |
+
'VU' => 'Vanuatu',
|
250 |
+
'VE' => 'Venezuela, Bolivarian Republic of',
|
251 |
+
'VN' => 'Viet Nam',
|
252 |
+
'VG' => 'Virgin Islands, British',
|
253 |
+
'VI' => 'Virgin Islands, U.S.',
|
254 |
+
'WF' => 'Wallis and Futuna',
|
255 |
+
'EH' => 'Western Sahara',
|
256 |
+
'YE' => 'Yemen',
|
257 |
+
'ZM' => 'Zambia',
|
258 |
+
'ZW' => 'Zimbabwe',
|
259 |
+
];
|
260 |
+
}
|
261 |
+
}
|
classes/admin/class-debug-info.php
CHANGED
@@ -5,380 +5,396 @@ namespace WCPM\Classes\Admin;
|
|
5 |
use WC_Order_Query;
|
6 |
|
7 |
if (!defined('ABSPATH')) {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
-
class
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
global $woocommerce, $wp_version, $current_user, $hook_suffix;
|
23 |
|
24 |
-
|
25 |
|
26 |
-
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
// $html .= 'wp_remote_post to Facebook Graph API: ' . $this->wp_remote_get_response('https://graph.facebook.com/') . PHP_EOL;
|
42 |
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
|
53 |
-
|
54 |
|
55 |
// wp_get_current_user();
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
|
61 |
-
|
62 |
|
63 |
-
|
64 |
|
65 |
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
// $html .= 'wc_get_page_permalink(\'checkout\'): ' . wc_get_page_permalink('checkout') . PHP_EOL;
|
93 |
|
94 |
-
|
95 |
-
|
96 |
|
97 |
// $this->get_enabled_payment_gateways();
|
98 |
|
99 |
-
|
100 |
// error_log(get_class($value));
|
101 |
// error_log($value->method_title);
|
102 |
|
103 |
-
|
104 |
-
|
105 |
|
106 |
-
|
107 |
-
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
|
113 |
// $html .= PHP_EOL;
|
114 |
|
115 |
-
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
|
122 |
-
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
|
139 |
-
|
140 |
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
|
155 |
-
|
156 |
|
157 |
-
|
158 |
|
159 |
-
|
160 |
|
161 |
-
|
162 |
-
|
163 |
|
164 |
// $html .= PHP_EOL . '## misc ##' . PHP_EOL . PHP_EOL;
|
165 |
|
166 |
// $html .= 'WP Rocket JavaScript concatenation: ' . $this->is_wp_rocket_js_concatenation();
|
167 |
|
168 |
-
|
169 |
|
170 |
-
|
171 |
-
|
172 |
|
173 |
-
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
]);
|
188 |
|
189 |
// error_log(print_r($response, true));
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
|
253 |
// error_log(print_r($enabled_gateways, true)); // Should return an array of enabled gateways
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
return [];
|
283 |
-
}
|
284 |
|
285 |
// error_log(print_r(array_flip($last_orders), true));
|
286 |
// error_log(min($last_orders));
|
287 |
|
288 |
-
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
|
299 |
// error_log(print_r(array_flip($last_orders), true));
|
300 |
|
301 |
-
|
302 |
|
303 |
-
|
304 |
-
|
305 |
|
306 |
// error_log(print_r(get_post_meta($order_id, '_wpm_conversion_pixel_fired', true), true));
|
307 |
// error_log('payment method: ' . $order->get_payment_method() . ', ' . $order->get_payment_method_title());
|
308 |
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
|
316 |
-
|
317 |
|
318 |
// error_log('order_id: ' . $order_id . ', payment method: ' . $order->get_payment_method() . ', ' . $order->get_payment_method_title() . ', ' . $fired);
|
319 |
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
// error_log('payment method title: ' . $order->get_payment_method_title());
|
326 |
-
|
327 |
|
328 |
// error_log(print_r($data, true));
|
329 |
|
330 |
-
|
331 |
-
|
332 |
|
333 |
-
|
334 |
-
|
335 |
-
$data = [];
|
336 |
|
337 |
-
|
338 |
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
|
350 |
-
|
351 |
-
|
352 |
|
353 |
-
|
354 |
-
|
355 |
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
]);
|
367 |
|
368 |
// error_log(print_r($query->get_orders(), true));
|
369 |
// error_log('min: ' . min($query->get_orders()));
|
370 |
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
}
|
|
5 |
use WC_Order_Query;
|
6 |
|
7 |
if (!defined('ABSPATH')) {
|
8 |
+
exit; // Exit if accessed directly
|
9 |
}
|
10 |
|
11 |
+
class Debug_Info {
|
12 |
+
protected $environment_check;
|
13 |
+
protected $options;
|
14 |
|
15 |
+
public function __construct( $options ) {
|
16 |
+
$this->options = $options;
|
17 |
+
$this->environment_check = new Environment_Check($this->options);
|
18 |
+
}
|
19 |
|
20 |
+
public function get_debug_info() {
|
21 |
+
global $woocommerce, $wp_version, $current_user, $hook_suffix;
|
|
|
22 |
|
23 |
+
$html = '### Debug Information ###' . PHP_EOL . PHP_EOL;
|
24 |
|
25 |
+
$html .= '## System Environment ##' . PHP_EOL . PHP_EOL;
|
26 |
|
27 |
+
$html .= 'This plugin\'s version: ' . WPM_CURRENT_VERSION . PHP_EOL;
|
28 |
|
29 |
+
$html .= PHP_EOL;
|
30 |
|
31 |
+
$html .= 'WordPress version: ' . $wp_version . PHP_EOL;
|
32 |
+
$html .= 'WooCommerce version: ' . $woocommerce->version . PHP_EOL;
|
33 |
+
$html .= 'PHP version: ' . phpversion() . PHP_EOL;
|
34 |
|
35 |
+
$curl_available = $this->environment_check->is_curl_active() ? 'yes' : 'no';
|
36 |
+
$html .= 'curl available: ' . $curl_available . PHP_EOL;
|
37 |
+
$html .= 'wp_remote_get to Cloudflare: ' . $this->wp_remote_get_response('https://www.cloudflare.com/cdn-cgi/trace') . PHP_EOL;
|
38 |
+
$html .= 'wp_remote_get to Google Analytics API: ' . $this->wp_remote_get_response('https://www.google-analytics.com/debug/collect') . PHP_EOL;
|
39 |
+
$html .= 'wp_remote_get to Facebook Graph API: ' . $this->wp_remote_get_response('https://graph.facebook.com/facebook/picture?redirect=false') . PHP_EOL;
|
40 |
// $html .= 'wp_remote_post to Facebook Graph API: ' . $this->wp_remote_get_response('https://graph.facebook.com/') . PHP_EOL;
|
41 |
|
42 |
+
$html .= PHP_EOL;
|
43 |
|
44 |
+
$multisite_enabled = is_multisite() ? 'yes' : 'no';
|
45 |
+
$html .= 'Multisite enabled: ' . $multisite_enabled . PHP_EOL;
|
46 |
|
47 |
+
$wp_debug = 'no';
|
48 |
+
if (defined('WP_DEBUG') && true === WP_DEBUG) {
|
49 |
+
$wp_debug = 'yes';
|
50 |
+
}
|
51 |
|
52 |
+
$html .= 'WordPress debug mode enabled: ' . $wp_debug . PHP_EOL;
|
53 |
|
54 |
// wp_get_current_user();
|
55 |
+
$html .= 'Logged in user login name: ' . $current_user->user_login . PHP_EOL;
|
56 |
+
$html .= 'Logged in user display name: ' . $current_user->display_name . PHP_EOL;
|
57 |
|
58 |
+
$html .= 'hook_suffix: ' . $hook_suffix . PHP_EOL;
|
59 |
|
60 |
+
$html .= PHP_EOL;
|
61 |
|
62 |
+
$html .= 'Hosting provider: ' . $this->environment_check->get_hosting_provider() . PHP_EOL;
|
63 |
|
64 |
|
65 |
+
$html .= PHP_EOL . '## WooCommerce ##' . PHP_EOL . PHP_EOL;
|
66 |
|
67 |
+
$html .= 'Default currency: ' . get_woocommerce_currency() . PHP_EOL;
|
68 |
+
$html .= 'Shop URL: ' . get_home_url() . PHP_EOL;
|
69 |
+
$html .= 'Cart URL: ' . wc_get_cart_url() . PHP_EOL;
|
70 |
+
$html .= 'Checkout URL: ' . wc_get_checkout_url() . PHP_EOL;
|
71 |
+
$html .= 'Purchase confirmation endpoint: ' . wc_get_endpoint_url('order-received') . PHP_EOL;
|
72 |
|
73 |
+
$order_received_page_url = wc_get_checkout_url() . ltrim(wc_get_endpoint_url('order-received'), '/');
|
74 |
+
$html .= 'is_order_received_page(): ' . $order_received_page_url . PHP_EOL . PHP_EOL;
|
75 |
|
76 |
+
if ($this->environment_check->does_one_order_exist()) {
|
77 |
+
$last_order_url = $this->environment_check->get_last_order_url();
|
78 |
+
$html .= 'Last order URL: ' . $last_order_url . '&nodedupe' . PHP_EOL;
|
79 |
|
80 |
+
$last_order_url_contains_order_received_page_url = strpos($this->environment_check->get_last_order_url(), $order_received_page_url) !== false ? 'yes' : 'no';
|
81 |
+
$html .= 'Order received page uses proper is_order_received() url: ' . $last_order_url_contains_order_received_page_url . PHP_EOL;
|
82 |
|
83 |
+
$purchase_confirmation_page_redirect = $this->environment_check->does_url_redirect($last_order_url) ? 'yes' : 'no';
|
84 |
+
$html .= $this->show_warning($this->environment_check->does_url_redirect($last_order_url)) . 'Purchase confirmation page redirect: ' . $purchase_confirmation_page_redirect . PHP_EOL;
|
85 |
|
86 |
+
if ($this->environment_check->does_url_redirect($last_order_url)) {
|
87 |
+
$html .= 'Redirect URL: ' . $this->environment_check->get_redirect_url($this->environment_check->get_last_order_url()) . PHP_EOL;
|
88 |
+
}
|
89 |
+
}
|
90 |
|
91 |
// $html .= 'wc_get_page_permalink(\'checkout\'): ' . wc_get_page_permalink('checkout') . PHP_EOL;
|
92 |
|
93 |
+
$html .= PHP_EOL . '## WooCommerce Payment Gateways ##' . PHP_EOL . PHP_EOL;
|
94 |
+
$html .= 'Active payment gateways: ' . PHP_EOL;
|
95 |
|
96 |
// $this->get_enabled_payment_gateways();
|
97 |
|
98 |
+
foreach ($this->get_enabled_payment_gateways() as $key => $value) {
|
99 |
// error_log(get_class($value));
|
100 |
// error_log($value->method_title);
|
101 |
|
102 |
+
$html .= "\t" . get_class($value) . '(' . $value->method_title . ')' . PHP_EOL;
|
103 |
+
}
|
104 |
|
105 |
+
$max_order_amount = 100;
|
106 |
+
$html .= PHP_EOL . "Purchase confirmation page reached per gateway (of last $max_order_amount orders):" . PHP_EOL;
|
107 |
|
108 |
+
foreach ($this->get_gateway_analysis_array($max_order_amount) as $text) {
|
109 |
+
$html .= "\t" . $text . PHP_EOL;
|
110 |
+
}
|
111 |
|
112 |
// $html .= PHP_EOL;
|
113 |
|
114 |
+
$html .= PHP_EOL . '## Theme ##' . PHP_EOL . PHP_EOL;
|
115 |
|
116 |
+
$is_child_theme = is_child_theme() ? 'yes' : 'no';
|
117 |
+
$html .= 'Is child theme: ' . $is_child_theme . PHP_EOL;
|
118 |
+
$theme_support = current_theme_supports('woocommerce') ? 'yes' : 'no';
|
119 |
+
$html .= 'WooCommerce support: ' . $theme_support . PHP_EOL;
|
120 |
|
121 |
+
$html .= PHP_EOL;
|
122 |
|
123 |
+
// using the double check prevents problems with some themes that have not implemented
|
124 |
+
// the child state correctly
|
125 |
+
// https://wordpress.org/support/topic/debug-error-33/
|
126 |
+
$theme_description_prefix = ( is_child_theme() && wp_get_theme()->parent() ) ? 'Child theme ' : 'Theme ';
|
127 |
|
128 |
+
$html .= $theme_description_prefix . 'Name: ' . wp_get_theme()->get('Name') . PHP_EOL;
|
129 |
+
$html .= $theme_description_prefix . 'ThemeURI: ' . wp_get_theme()->get('ThemeURI') . PHP_EOL;
|
130 |
+
$html .= $theme_description_prefix . 'Author: ' . wp_get_theme()->get('Author') . PHP_EOL;
|
131 |
+
$html .= $theme_description_prefix . 'AuthorURI: ' . wp_get_theme()->get('AuthorURI') . PHP_EOL;
|
132 |
+
$html .= $theme_description_prefix . 'Version: ' . wp_get_theme()->get('Version') . PHP_EOL;
|
133 |
+
$html .= $theme_description_prefix . 'Template: ' . wp_get_theme()->get('Template') . PHP_EOL;
|
134 |
+
$html .= $theme_description_prefix . 'Status: ' . wp_get_theme()->get('Status') . PHP_EOL;
|
135 |
+
$html .= $theme_description_prefix . 'TextDomain: ' . wp_get_theme()->get('TextDomain') . PHP_EOL;
|
136 |
+
$html .= $theme_description_prefix . 'DomainPath: ' . wp_get_theme()->get('DomainPath') . PHP_EOL;
|
137 |
|
138 |
+
$html .= PHP_EOL;
|
139 |
|
140 |
+
// using the double check prevents problems with some themes that have not implemented
|
141 |
+
// the child state correctly
|
142 |
+
if (is_child_theme() && wp_get_theme()->parent()) {
|
143 |
+
$html .= 'Parent theme Name: ' . wp_get_theme()->parent()->get('Name') . PHP_EOL;
|
144 |
+
$html .= 'Parent theme ThemeURI: ' . wp_get_theme()->parent()->get('ThemeURI') . PHP_EOL;
|
145 |
+
$html .= 'Parent theme Author: ' . wp_get_theme()->parent()->get('Author') . PHP_EOL;
|
146 |
+
$html .= 'Parent theme AuthorURI: ' . wp_get_theme()->parent()->get('AuthorURI') . PHP_EOL;
|
147 |
+
$html .= 'Parent theme Version: ' . wp_get_theme()->parent()->get('Version') . PHP_EOL;
|
148 |
+
$html .= 'Parent theme Template: ' . wp_get_theme()->parent()->get('Template') . PHP_EOL;
|
149 |
+
$html .= 'Parent theme Status: ' . wp_get_theme()->parent()->get('Status') . PHP_EOL;
|
150 |
+
$html .= 'Parent theme TextDomain: ' . wp_get_theme()->parent()->get('TextDomain') . PHP_EOL;
|
151 |
+
$html .= 'Parent theme DomainPath: ' . wp_get_theme()->parent()->get('DomainPath') . PHP_EOL;
|
152 |
+
}
|
153 |
|
154 |
+
// TODO maybe add all active plugins
|
155 |
|
156 |
+
$html .= PHP_EOL;
|
157 |
|
158 |
+
$html .= PHP_EOL . '## freemius ##' . PHP_EOL . PHP_EOL;
|
159 |
|
160 |
+
$html .= 'api.freemius.com : ' . $this->try_connect_to_server('api.freemius.com') . PHP_EOL;
|
161 |
+
$html .= 'wp.freemius.com : ' . $this->try_connect_to_server('wp.freemius.com') . PHP_EOL;
|
162 |
|
163 |
// $html .= PHP_EOL . '## misc ##' . PHP_EOL . PHP_EOL;
|
164 |
|
165 |
// $html .= 'WP Rocket JavaScript concatenation: ' . $this->is_wp_rocket_js_concatenation();
|
166 |
|
167 |
+
$html .= PHP_EOL . PHP_EOL . '### End of Information ###';
|
168 |
|
169 |
+
return $html;
|
170 |
+
}
|
171 |
|
172 |
+
// possible way to use a proxy if necessary
|
173 |
|
174 |
+
// https://deliciousbrains.com/php-curl-how-wordpress-makes-http-requests/
|
175 |
+
// possible proxy list
|
176 |
+
// https://www.us-proxy.org/
|
177 |
+
// https://freemius.com/help/documentation/wordpress-sdk/license-activation-issues/#isp_blockage
|
178 |
|
179 |
+
// Google and Facebook might block free proxy requests
|
180 |
+
private function wp_remote_get_response( $url ) {
|
181 |
+
$response = wp_remote_get($url, [
|
182 |
+
'timeout' => 1,
|
183 |
+
'sslverify' => false,
|
184 |
+
'limit_response_size' => 5000,
|
185 |
+
]);
|
|
|
186 |
|
187 |
// error_log(print_r($response, true));
|
188 |
|
189 |
+
if (is_wp_error($response)) {
|
190 |
+
return $this->show_warning(true) . $response->get_error_message();
|
191 |
+
} else {
|
192 |
+
$response_code = wp_remote_retrieve_response_code($response);
|
193 |
+
|
194 |
+
if (200 === $response_code) {
|
195 |
+
return $response_code;
|
196 |
+
} else {
|
197 |
+
return $this->show_warning(true) . $response_code;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
private function show_warning( $test = false ) {
|
203 |
+
if ($test) {
|
204 |
+
return '❗ ';
|
205 |
+
} else {
|
206 |
+
return '';
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
private function is_wp_rocket_js_concatenation() {
|
211 |
+
if (is_plugin_active('wp-rocket/wp-rocket.php')) {
|
212 |
+
|
213 |
+
$wp_rocket_settings = get_option('wp_rocket_settings');
|
214 |
+
|
215 |
+
if ($wp_rocket_settings) {
|
216 |
+
if (true == $wp_rocket_settings['minify_concatenate_js']) {
|
217 |
+
return 'on';
|
218 |
+
} else {
|
219 |
+
return 'off';
|
220 |
+
}
|
221 |
+
}
|
222 |
+
} else {
|
223 |
+
return 'off';
|
224 |
+
}
|
225 |
+
|
226 |
+
return 'off';
|
227 |
+
}
|
228 |
+
|
229 |
+
// private function try_connect_to_server( $server ) {
|
230 |
+
// if ($socket = @ fsockopen($server, 80)) {
|
231 |
+
// @fclose($socket);
|
232 |
+
// return 'online';
|
233 |
+
// } else {
|
234 |
+
// return 'offline';
|
235 |
+
// }
|
236 |
+
// }
|
237 |
+
|
238 |
+
private function try_connect_to_server( $server ) {
|
239 |
+
try {
|
240 |
+
$socket = @ fsockopen($server, 80);
|
241 |
+
if ($socket) {
|
242 |
+
@ fclose($socket);
|
243 |
+
return 'online';
|
244 |
+
} else {
|
245 |
+
return 'offline';
|
246 |
+
}
|
247 |
+
} catch (\Exception $e) {
|
248 |
+
wc_get_logger()->debug(
|
249 |
+
'Error while trying to connect to ' . $server,
|
250 |
+
['source' => 'wpm']
|
251 |
+
);
|
252 |
+
wc_get_logger()->debug(
|
253 |
+
$e,
|
254 |
+
['source' => 'wpm']
|
255 |
+
);
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
private function get_enabled_payment_gateways() {
|
260 |
+
$gateways = WC()->payment_gateways->get_available_payment_gateways();
|
261 |
+
$enabled_gateways = [];
|
262 |
+
|
263 |
+
if ($gateways) {
|
264 |
+
foreach ($gateways as $gateway) {
|
265 |
+
|
266 |
+
if ('yes' == $gateway->enabled) {
|
267 |
+
$enabled_gateways[] = $gateway;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}
|
271 |
|
272 |
// error_log(print_r($enabled_gateways, true)); // Should return an array of enabled gateways
|
273 |
|
274 |
+
return $enabled_gateways;
|
275 |
+
}
|
276 |
+
|
277 |
+
private function get_last_orders( $limit = 100 ) {
|
278 |
+
// Get most recent order ids in date descending order.
|
279 |
+
$query = new WC_Order_Query([
|
280 |
+
'limit' => $limit,
|
281 |
+
'type' => 'shop_order',
|
282 |
+
'orderby' => 'date',
|
283 |
+
'order' => 'DESC',
|
284 |
+
'return' => 'ids',
|
285 |
+
]);
|
286 |
+
|
287 |
+
try {
|
288 |
+
return $query->get_orders();
|
289 |
+
} catch (\Exception $e) {
|
290 |
+
error_log($e);
|
291 |
+
return [];
|
292 |
+
}
|
293 |
+
}
|
294 |
+
|
295 |
+
private function list_gateways_of_orders( $limit = 100 ) {
|
296 |
+
$last_orders = $this->get_last_orders($limit);
|
297 |
+
|
298 |
+
if (empty($last_orders)) {
|
299 |
+
return [];
|
300 |
+
}
|
|
|
|
|
301 |
|
302 |
// error_log(print_r(array_flip($last_orders), true));
|
303 |
// error_log(min($last_orders));
|
304 |
|
305 |
+
$earliest_relevant_order_id = $this->get_earliest_order_with_pixel_fired_tag($last_orders, $limit);
|
306 |
|
307 |
+
if (false === $earliest_relevant_order_id) {
|
308 |
+
return [];
|
309 |
+
}
|
310 |
|
311 |
+
// only keep orders up until the oldest one with _wpm_conversion_pixel_fired
|
312 |
+
$last_orders = array_filter($last_orders, function ( $x ) use ( $earliest_relevant_order_id ) {
|
313 |
+
return $x >= $earliest_relevant_order_id;
|
314 |
+
});
|
315 |
|
316 |
// error_log(print_r(array_flip($last_orders), true));
|
317 |
|
318 |
+
$data = [];
|
319 |
|
320 |
+
foreach ($last_orders as $order_id) {
|
321 |
+
$order = wc_get_order($order_id);
|
322 |
|
323 |
// error_log(print_r(get_post_meta($order_id, '_wpm_conversion_pixel_fired', true), true));
|
324 |
// error_log('payment method: ' . $order->get_payment_method() . ', ' . $order->get_payment_method_title());
|
325 |
|
326 |
+
if (!array_key_exists($order->get_payment_method(), $data)) {
|
327 |
+
$data[$order->get_payment_method()] = [];
|
328 |
+
$data[$order->get_payment_method()]['fired'] = 0;
|
329 |
+
$data[$order->get_payment_method()]['not_fired'] = 0;
|
330 |
+
$data[$order->get_payment_method()]['method_title'] = $order->get_payment_method_title();
|
331 |
+
}
|
332 |
|
333 |
+
$fired = get_post_meta($order_id, '_wpm_conversion_pixel_fired', true);
|
334 |
|
335 |
// error_log('order_id: ' . $order_id . ', payment method: ' . $order->get_payment_method() . ', ' . $order->get_payment_method_title() . ', ' . $fired);
|
336 |
|
337 |
+
if ($fired) {
|
338 |
+
$data[$order->get_payment_method()]['fired'] += 1;
|
339 |
+
} else {
|
340 |
+
$data[$order->get_payment_method()]['not_fired'] += 1;
|
341 |
+
}
|
342 |
// error_log('payment method title: ' . $order->get_payment_method_title());
|
343 |
+
}
|
344 |
|
345 |
// error_log(print_r($data, true));
|
346 |
|
347 |
+
return $data;
|
348 |
+
}
|
349 |
|
350 |
+
private function get_gateway_analysis_array( $limit = 100 ) {
|
351 |
+
$data = [];
|
|
|
352 |
|
353 |
+
foreach ($this->list_gateways_of_orders($limit) as $gateway => $value) {
|
354 |
|
355 |
+
$fired = $value['fired'];
|
356 |
+
$not_fired = $value['not_fired'];
|
357 |
+
$total = $fired + $not_fired;
|
358 |
|
359 |
+
if ($total > 0) {
|
360 |
+
$percentage = number_format((float) ( $fired / $total ), 2, '.', '');
|
361 |
+
$text = $gateway . ' (' . $value['method_title'] . '): ' . $fired . ' / ' . $total . ' => ' . $percentage * 100 . '% accuracy';
|
362 |
+
} else {
|
363 |
+
$text = $gateway . ' (' . $value['method_title'] . '): ' . $fired . ' / ' . $total;
|
364 |
+
}
|
365 |
|
366 |
+
$data[] = $text;
|
367 |
+
}
|
368 |
|
369 |
+
return $data;
|
370 |
+
}
|
371 |
|
372 |
+
public function get_earliest_order_with_pixel_fired_tag( $order_ids, $limit ) {
|
373 |
+
$query = new WC_Order_Query([
|
374 |
+
'limit' => $limit,
|
375 |
+
// 'orderby' => 'date',
|
376 |
+
// 'order' => 'DESC',
|
377 |
+
'type' => 'shop_order',
|
378 |
+
'return' => 'ids',
|
379 |
+
'post__in' => $order_ids,
|
380 |
+
'meta_key' => '_wpm_conversion_pixel_fired'
|
381 |
+
]);
|
|
|
382 |
|
383 |
// error_log(print_r($query->get_orders(), true));
|
384 |
// error_log('min: ' . min($query->get_orders()));
|
385 |
|
386 |
+
try {
|
387 |
+
$result = $query->get_orders();
|
388 |
+
} catch (\Exception $e) {
|
389 |
+
error_log($e);
|
390 |
+
return false;
|
391 |
+
}
|
392 |
+
|
393 |
+
if (!empty($result)) {
|
394 |
+
return min($result);
|
395 |
+
} else {
|
396 |
+
return false;
|
397 |
+
}
|
398 |
+
}
|
399 |
+
}
|
400 |
+
|
classes/admin/class-documentation.php
CHANGED
@@ -3,144 +3,140 @@
|
|
3 |
namespace WCPM\Classes\Admin;
|
4 |
|
5 |
if (!defined('ABSPATH')) {
|
6 |
-
|
7 |
}
|
8 |
|
9 |
-
class Documentation
|
10 |
-
|
11 |
-
protected $documentation_host;
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
}
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
];
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
}
|
3 |
namespace WCPM\Classes\Admin;
|
4 |
|
5 |
if (!defined('ABSPATH')) {
|
6 |
+
exit; // Exit if accessed directly
|
7 |
}
|
8 |
|
9 |
+
class Documentation {
|
10 |
+
protected $documentation_host;
|
|
|
11 |
|
12 |
+
public function __construct() {
|
13 |
+
$this->documentation_host = 'sweetcode.com';
|
14 |
+
}
|
|
|
15 |
|
16 |
+
public function get_link( $key = 'default' ) {
|
17 |
+
$documentation_links = [
|
18 |
+
'default' => [
|
19 |
+
'default' => '/docs/wpm/',
|
20 |
+
'wcm' => '/'],
|
21 |
+
'script_blockers' => [
|
22 |
+
'default' => '/docs/wpm/setup/script-blockers/?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=script-blocker-error',
|
23 |
+
'wcm' => '/'],
|
24 |
+
'google_analytics_universal_property' => [
|
25 |
+
'default' => '/docs/wpm/plugin-configuration/google-analytics?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-analytics-property-id',
|
26 |
+
'wcm' => '/'],
|
27 |
+
'google_analytics_4_id' => [
|
28 |
+
'default' => '/docs/wpm/plugin-configuration/google-analytics#connect-an-existing-google-analytics-4-property?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-analytics-4-id',
|
29 |
+
'wcm' => '/'],
|
30 |
+
'google_ads_conversion_id' => [
|
31 |
+
'default' => '/docs/wpm/plugin-configuration/google-ads#configure-the-plugin?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-ads-configure-the-plugin',
|
32 |
+
'wcm' => '/'],
|
33 |
+
'google_ads_conversion_label' => [
|
34 |
+
'default' => '/docs/wpm/plugin-configuration/google-ads#configure-the-plugin?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-ads-configure-the-plugin',
|
35 |
+
'wcm' => '/'],
|
36 |
+
'google_optimize_container_id' => [
|
37 |
+
'default' => '/docs/wpm/plugin-configuration/google-optimize?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-optimize',
|
38 |
+
'wcm' => '/'],
|
39 |
+
'facebook_pixel_id' => [
|
40 |
+
'default' => '/docs/wpm/plugin-configuration/facebook#find-the-pixel-id?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=facebook-pixel-id',
|
41 |
+
'wcm' => '/'],
|
42 |
+
'bing_uet_tag_id' => [
|
43 |
+
'default' => '/docs/wpm/plugin-configuration/microsoft-advertising#setting-up-the-uet-tag?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=microsoft-advertising-uet-tag-id',
|
44 |
+
'wcm' => '/'],
|
45 |
+
'twitter_pixel_id' => [
|
46 |
+
'default' => '/docs/wpm/plugin-configuration/twitter',
|
47 |
+
'wcm' => '/'],
|
48 |
+
'pinterest_pixel_id' => [
|
49 |
+
'default' => '/docs/wpm/plugin-configuration/pinterest',
|
50 |
+
'wcm' => '/'],
|
51 |
+
'snapchat_pixel_id' => [
|
52 |
+
'default' => '/docs/wpm/plugin-configuration/snapchat',
|
53 |
+
'wcm' => '/'],
|
54 |
+
'tiktok_pixel_id' => [
|
55 |
+
'default' => '/docs/wpm/plugin-configuration/tiktok',
|
56 |
+
'wcm' => '/'],
|
57 |
+
'hotjar_site_id' => [
|
58 |
+
'default' => '/docs/wpm/plugin-configuration/hotjar#hotjar-site-id?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=hotjar-site-id',
|
59 |
+
'wcm' => '/'],
|
60 |
+
'google_gtag_deactivation' => [
|
61 |
+
'default' => '/docs/wpm/faq/#google-tag-assistant-reports-multiple-installations-of-global-site-tag-gtagjs-detected-what-shall-i-do&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=gtag-js',
|
62 |
+
'wcm' => '/'],
|
63 |
+
'google_consent_mode' => [
|
64 |
+
'default' => '/docs/wpm/consent-management/google-consent-mode?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-consent-mode',
|
65 |
+
'wcm' => '/'],
|
66 |
+
'google_consent_regions' => [
|
67 |
+
'default' => '/docs/wpm/consent-management/google-consent-mode#regions?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-consent-mode-regions',
|
68 |
+
'wcm' => '/'],
|
69 |
+
'google_analytics_eec' => [
|
70 |
+
'default' => '/docs/wpm/plugin-configuration/google-analytics#enhanced-e-commerce-funnel-setup',
|
71 |
+
'wcm' => '/'],
|
72 |
+
'google_analytics_4_api_secret' => [
|
73 |
+
'default' => '/docs/wpm/plugin-configuration/google-analytics#ga4-api-secret?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-analytics-4-api-secret',
|
74 |
+
'wcm' => '/'],
|
75 |
+
'google_ads_enhanced_conversions' => [
|
76 |
+
'default' => '/docs/wpm/plugin-configuration/google-ads#enhanced-conversions?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-ads-enhanced-conversions',
|
77 |
+
'wcm' => '/'],
|
78 |
+
'google_ads_phone_conversion_number' => [
|
79 |
+
'default' => '/docs/wpm/plugin-configuration/google-ads#phone-conversion-number?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-ads-phone-conversion-number',
|
80 |
+
'wcm' => '/'],
|
81 |
+
'google_ads_phone_conversion_label' => [
|
82 |
+
'default' => '/docs/wpm/plugin-configuration/google-ads#phone-conversion-number?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=google-ads-phone-conversion-number',
|
83 |
+
'wcm' => '/'],
|
84 |
+
'explicit_consent_mode' => [
|
85 |
+
'default' => '/docs/wpm/consent-management/overview/#explicit-consent-mode',
|
86 |
+
'wcm' => '/'],
|
87 |
+
'facebook_capi_token' => [
|
88 |
+
'default' => '/docs/wpm/plugin-configuration/facebook#facebook-conversion-api-capi?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=facebook-capi-token',
|
89 |
+
'wcm' => '/'],
|
90 |
+
'facebook_capi_user_transparency_process_anonymous_hits' => [
|
91 |
+
'default' => '/docs/wpm/plugin-configuration/facebook#user-transparency-settings?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=facebook-capi-transparency-settings',
|
92 |
+
'wcm' => '/'],
|
93 |
+
'facebook_capi_user_transparency_send_additional_client_identifiers' => [
|
94 |
+
'default' => '/docs/wpm/plugin-configuration/facebook#user-transparency-settings?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=facebook-capi-transparency-settings',
|
95 |
+
'wcm' => '/'],
|
96 |
+
'facebook_microdata' => [
|
97 |
+
'default' => '/docs/wpm/plugin-configuration/facebook#microdata-tags-for-catalogues?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=facebook-microdata',
|
98 |
+
'wcm' => '/'],
|
99 |
+
'maximum_compatibility_mode' => [
|
100 |
+
'default' => '/docs/wpm/plugin-configuration/general-settings/#maximum-compatibility-mode?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=maximum-compatibility-mode',
|
101 |
+
'wcm' => '/'],
|
102 |
+
'google_ads_dynamic_remarketing' => [
|
103 |
+
'default' => '/docs/wpm/plugin-configuration/dynamic-remarketing?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=dynamic-remarketing',
|
104 |
+
'wcm' => '/'],
|
105 |
+
'variations_output' => [
|
106 |
+
'default' => '/docs/wpm/plugin-configuration/dynamic-remarketing?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=dynamic-remarketing',
|
107 |
+
'wcm' => '/'],
|
108 |
+
'aw_merchant_id' => [
|
109 |
+
'default' => '/docs/wpm/plugin-configuration/google-ads/#conversion-cart-data?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=conversion-cart-data',
|
110 |
+
'wcm' => '/'],
|
111 |
+
'custom_thank_you' => [
|
112 |
+
'default' => '/docs/wpm/troubleshooting/#wc-custom-thank-you',
|
113 |
+
'wcm' => '/'],
|
114 |
+
'the_dismiss_button_doesnt_work_why' => [
|
115 |
+
'default' => '/docs/wpm/faq/#the-dismiss-button-doesnt-work-why?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=wpp-pixel-manager-docs&utm_content=dismiss-button-info',
|
116 |
+
'wcm' => '/'],
|
117 |
+
'wp-rocket-javascript-concatenation' => [
|
118 |
+
'default' => '/docs/wpm/troubleshooting?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=wp-rocket-javascript-concatenation-error',
|
119 |
+
'wcm' => '/'],
|
120 |
+
'litespeed-cache-inline-javascript-after-dom-ready' => [
|
121 |
+
'default' => '/docs/wpm/troubleshooting?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=litespeed-inline-js-dom-ready-error',
|
122 |
+
'wcm' => '/'],
|
123 |
+
'payment-gateways' => [
|
124 |
+
'default' => '/docs/wpm/setup/requirements#payment-gateways?utm_source=woocommerce-plugin&utm_medium=documentation-link&utm_campaign=woocommerce-pixel-manager-docs&utm_content=paypal-standard-warning',
|
125 |
+
'wcm' => '/'],
|
126 |
+
'test_order' => [
|
127 |
+
'default' => '/docs/wpm/testing#test-order',
|
128 |
+
'wcm' => '/'],
|
129 |
+
];
|
|
|
130 |
|
131 |
+
if (array_key_exists($key, $documentation_links)) {
|
132 |
+
return $this->get_host() . $documentation_links[$key]['default'];
|
133 |
+
} else {
|
134 |
+
error_log('wpm documentation key "' . $key . '" not available');
|
135 |
+
return $this->get_host() . $documentation_links['default'];
|
136 |
+
}
|
137 |
+
}
|
138 |
|
139 |
+
private function get_host() {
|
140 |
+
return 'https://' . $this->documentation_host;
|
141 |
+
}
|
142 |
+
}
|
|
classes/admin/class-environment-check.php
CHANGED
@@ -3,1130 +3,1252 @@
|
|
3 |
namespace WCPM\Classes\Admin;
|
4 |
|
5 |
if (!defined('ABSPATH')) {
|
6 |
-
|
7 |
}
|
8 |
|
9 |
-
class Environment_Check
|
10 |
-
{
|
11 |
-
public $notifications;
|
12 |
-
private $documentation;
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
// add_action('admin_enqueue_scripts', [$this, 'environment_check_script']);
|
22 |
-
|
23 |
|
24 |
-
|
25 |
// add_action('plugins_loaded', [$this, 'get_active_payment_gateways_after_plugins_loaded']);
|
26 |
|
27 |
-
|
28 |
// $this->check_active_off_site_payment_gateways();
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
// flush cache after install
|
71 |
-
// we don't need that because after first install the user needs to set new options anyway where the cache flush happens too
|
72 |
// add_filter('upgrader_post_install', [$this, 'flush_cache_of_all_cache_plugins'], 10, 3);
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
|
78 |
-
|
79 |
-
{
|
80 |
// error_log('flush cache of all cache plugins');
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
// if ($this->is_hosting_pagely()) $this->flush_pagely_cache(); // TODO test
|
97 |
-
|
|
|
|
|
98 |
//
|
99 |
// if ($this->is_nginx_helper_active()) $this->flush_nginx_cache(); // TODO test
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
}
|
236 |
-
|
237 |
-
} catch (\Exception $e) {
|
238 |
-
error_log($e);
|
239 |
-
}
|
240 |
|
241 |
// do_action('nitropack_integration_purge_all');
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
return $active_gateways;
|
312 |
-
}
|
313 |
-
|
314 |
-
public function run_checks()
|
315 |
-
{
|
316 |
// $this->check_wp_rocket_js_concatenation();
|
317 |
// $this->check_litespeed_js_inline_after_dom();
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
{
|
371 |
-
$wpm_notifications = get_option(WPM_DB_NOTIFICATIONS_NAME);
|
372 |
-
|
373 |
-
if ($this->is_wp_rocket_active() && (!is_array($wpm_notifications) || false == $wpm_notifications['dismiss_wp_rocket_javascript_concatenation_error'])) {
|
374 |
-
|
375 |
-
$wp_rocket_settings = get_option('wp_rocket_settings');
|
376 |
-
|
377 |
-
if ($wp_rocket_settings) {
|
378 |
-
if (true == $wp_rocket_settings['minify_concatenate_js']) {
|
379 |
-
// display warning
|
380 |
-
(new Notifications())->wp_rocket_js_concatenation_error();
|
381 |
-
}
|
382 |
-
}
|
383 |
-
}
|
384 |
-
}
|
385 |
-
|
386 |
-
private function check_litespeed_js_inline_after_dom()
|
387 |
-
{
|
388 |
-
$wpm_notifications = get_option(WPM_DB_NOTIFICATIONS_NAME);
|
389 |
-
|
390 |
-
if ($this->is_litespeed_active() && (!is_array($wpm_notifications) || false == $wpm_notifications['dismiss_litespeed_inline_js_dom_ready_error'])) {
|
391 |
-
|
392 |
-
$litespeed_js_inline_defer_settings = get_option('litespeed.conf.optm-js_inline_defer');
|
393 |
-
|
394 |
-
if ($litespeed_js_inline_defer_settings) {
|
395 |
-
if (1 == $litespeed_js_inline_defer_settings) {
|
396 |
-
// display warning
|
397 |
-
(new Notifications())->litespeed_js_defer_error();
|
398 |
-
}
|
399 |
-
}
|
400 |
-
}
|
401 |
-
}
|
402 |
-
|
403 |
-
public function is_paypal_standard_active(): bool
|
404 |
-
{
|
405 |
-
$woocommerce_paypal_settings = get_option('woocommerce_paypal_settings');
|
406 |
-
|
407 |
-
if (!is_bool($woocommerce_paypal_settings) && array_key_exists('enabled', $woocommerce_paypal_settings) && $woocommerce_paypal_settings['enabled'] === 'yes') {
|
408 |
-
return true;
|
409 |
-
} else {
|
410 |
-
return false;
|
411 |
-
}
|
412 |
-
}
|
413 |
-
|
414 |
-
public function is_wc_custom_thank_you_active(): bool
|
415 |
-
{
|
416 |
-
return is_plugin_active('wc-custom-thank-you/woocommerce-custom-thankyou.php');
|
417 |
-
}
|
418 |
-
|
419 |
-
public function is_wp_rocket_active(): bool
|
420 |
-
{
|
421 |
-
return is_plugin_active('wp-rocket/wp-rocket.php');
|
422 |
-
}
|
423 |
-
|
424 |
-
public function is_sg_optimizer_active(): bool
|
425 |
-
{
|
426 |
-
return is_plugin_active('sg-cachepress/sg-cachepress.php');
|
427 |
-
}
|
428 |
-
|
429 |
-
public function is_w3_total_cache_active(): bool
|
430 |
-
{
|
431 |
-
return is_plugin_active('w3-total-cache/w3-total-cache.php');
|
432 |
-
}
|
433 |
-
|
434 |
-
public function is_litespeed_active(): bool
|
435 |
-
{
|
436 |
-
// TODO find out if there is a pro version with different folder and file name
|
437 |
-
|
438 |
-
return is_plugin_active('litespeed-cache/litespeed-cache.php');
|
439 |
-
}
|
440 |
-
|
441 |
-
public function is_autoptimize_active(): bool
|
442 |
-
{
|
443 |
-
// TODO find out if there is a pro version with different folder and file name
|
444 |
-
|
445 |
-
return is_plugin_active('autoptimize/autoptimize.php');
|
446 |
-
}
|
447 |
-
|
448 |
-
public function is_hummingbird_active(): bool
|
449 |
-
{
|
450 |
-
// TODO find out if there is a pro version with different folder and file name
|
451 |
-
|
452 |
-
return is_plugin_active('hummingbird-performance/wp-hummingbird.php');
|
453 |
-
}
|
454 |
-
|
455 |
-
public function is_nitropack_active(): bool
|
456 |
-
{
|
457 |
-
// TODO find out if there is a pro version with different folder and file name
|
458 |
-
|
459 |
-
return is_plugin_active('nitropack/main.php');
|
460 |
-
}
|
461 |
-
|
462 |
-
public function is_yoast_seo_active(): bool
|
463 |
-
{
|
464 |
-
// TODO find out if there is a pro version with different folder and file name
|
465 |
-
|
466 |
-
return is_plugin_active('wordpress-seo/wp-seo.php');
|
467 |
-
}
|
468 |
-
|
469 |
-
public function is_borlabs_cookie_active(): bool
|
470 |
-
{
|
471 |
-
// TODO find out if there is a pro version with different folder and file name
|
472 |
-
|
473 |
-
return is_plugin_active('borlabs-cookie/borlabs-cookie.php');
|
474 |
-
}
|
475 |
-
|
476 |
-
public function is_cookiebot_active(): bool
|
477 |
-
{
|
478 |
-
return is_plugin_active('cookiebot/cookiebot.php');
|
479 |
-
}
|
480 |
-
|
481 |
-
public function is_complianz_active(): bool
|
482 |
-
{
|
483 |
-
return is_plugin_active('complianz-gdpr/complianz-gpdr.php');
|
484 |
-
}
|
485 |
-
|
486 |
-
// Cookie Notice by hu-manity.co
|
487 |
-
public function is_cookie_notice_active(): bool
|
488 |
-
{
|
489 |
-
return is_plugin_active('cookie-notice/cookie-notice.php');
|
490 |
-
}
|
491 |
-
|
492 |
-
public function is_cookie_script_active(): bool
|
493 |
-
{
|
494 |
-
return is_plugin_active('cookie-script-com/cookie-script.php');
|
495 |
-
}
|
496 |
-
|
497 |
-
public function is_moove_gdpr_active(): bool
|
498 |
-
{
|
499 |
-
return is_plugin_active('gdpr-cookie-compliance/moove-gdpr.php');
|
500 |
-
}
|
501 |
-
|
502 |
-
public function is_cookie_law_info_active(): bool
|
503 |
-
{
|
504 |
-
return is_plugin_active('cookie-law-info/cookie-law-info.php');
|
505 |
-
}
|
506 |
-
|
507 |
-
public function is_some_cmp_active(): bool
|
508 |
-
{
|
509 |
-
if (
|
510 |
-
$this->is_borlabs_cookie_active() ||
|
511 |
-
$this->is_cookiebot_active() ||
|
512 |
-
$this->is_complianz_active() ||
|
513 |
-
$this->is_cookie_notice_active() ||
|
514 |
-
$this->is_cookie_script_active() ||
|
515 |
-
$this->is_moove_gdpr_active() ||
|
516 |
-
$this->is_cookie_law_info_active()
|
517 |
-
) {
|
518 |
-
return true;
|
519 |
-
} else {
|
520 |
-
return false;
|
521 |
-
}
|
522 |
-
}
|
523 |
-
|
524 |
-
public function is_wp_super_cache_active(): bool
|
525 |
-
{
|
526 |
-
// TODO find out if there is a pro version with different folder and file name
|
527 |
-
|
528 |
-
return is_plugin_active('wp-super-cache/wp-cache.php');
|
529 |
-
}
|
530 |
-
|
531 |
-
public function is_wp_fastest_cache_active(): bool
|
532 |
-
{
|
533 |
-
// The pro version requires the free version to be active
|
534 |
-
|
535 |
-
return is_plugin_active('wp-fastest-cache/wpFastestCache.php');
|
536 |
-
}
|
537 |
-
|
538 |
-
public function is_cloudflare_active(): bool
|
539 |
-
{
|
540 |
-
return is_plugin_active('cloudflare/cloudflare.php');
|
541 |
-
}
|
542 |
-
|
543 |
-
public function is_wpml_woocommerce_multi_currency_active(): bool
|
544 |
-
{
|
545 |
-
global $woocommerce_wpml;
|
546 |
-
|
547 |
-
if (is_plugin_active('woocommerce-multilingual/wpml-woocommerce.php') && is_object($woocommerce_wpml->multi_currency)) {
|
548 |
-
return true;
|
549 |
-
} else {
|
550 |
-
return false;
|
551 |
-
}
|
552 |
-
}
|
553 |
-
|
554 |
-
public function is_woo_discount_rules_active(): bool
|
555 |
-
{
|
556 |
-
if (is_plugin_active('woo-discount-rules/woo-discount-rules.php') || is_plugin_active('woo-discount-rules-pro/woo-discount-rules-pro.php')) {
|
557 |
-
return true;
|
558 |
-
} else {
|
559 |
-
return false;
|
560 |
-
}
|
561 |
-
}
|
562 |
-
|
563 |
-
public function is_wp_optimize_active(): bool
|
564 |
-
{
|
565 |
-
return is_plugin_active('wp-optimize/wp-optimize.php');
|
566 |
-
}
|
567 |
-
|
568 |
-
public function is_woocommerce_brands_active(): bool
|
569 |
-
{
|
570 |
-
return is_plugin_active('woocommerce-brands/woocommerce-brands.php');
|
571 |
-
}
|
572 |
-
|
573 |
-
public function is_yith_wc_brands_active(): bool
|
574 |
-
{
|
575 |
-
return is_plugin_active('yith-woocommerce-brands-add-on-premium/init.php');
|
576 |
-
}
|
577 |
-
|
578 |
-
public function is_optimocha_active(): bool
|
579 |
-
{
|
580 |
-
// TODO find out if there is a pro version with different folder and file name
|
581 |
-
return is_plugin_active('speed-booster-pack/speed-booster-pack.php');
|
582 |
-
}
|
583 |
-
|
584 |
-
public function is_async_javascript_active(): bool
|
585 |
-
{
|
586 |
-
// TODO find out if there is a pro version with different folder and file name
|
587 |
-
return is_plugin_active('async-javascript/async-javascript.php');
|
588 |
-
}
|
589 |
-
|
590 |
-
public function is_flying_press_active(): bool
|
591 |
-
{
|
592 |
-
// TODO find out if there is a pro version with different folder and file name
|
593 |
-
return is_plugin_active('flying-press/flying-press.php');
|
594 |
-
}
|
595 |
-
|
596 |
-
/*
|
597 |
-
* Check to find out what hosting provider is being used
|
598 |
-
* */
|
599 |
-
|
600 |
-
public function is_hosting_flywheel(): bool
|
601 |
-
{
|
602 |
-
return defined("FLYWHEEL_PLUGIN_DIR");
|
603 |
-
}
|
604 |
-
|
605 |
-
public function is_hosting_cloudways(): bool
|
606 |
-
{
|
607 |
-
return array_key_exists("cw_allowed_ip", $_SERVER) || preg_match("~/home/.*?cloudways.*~", __FILE__);
|
608 |
-
}
|
609 |
-
|
610 |
-
public function is_hosting_wp_engine(): bool
|
611 |
-
{
|
612 |
-
return !!getenv('IS_WPE');
|
613 |
-
}
|
614 |
-
|
615 |
-
public function is_hosting_godaddy_wpaas(): bool
|
616 |
-
{
|
617 |
-
return class_exists('\WPaaS\Plugin');
|
618 |
-
}
|
619 |
-
|
620 |
-
public function is_hosting_siteground(): bool
|
621 |
-
{
|
622 |
-
$configFilePath = $this->get_wpconfig_path();
|
623 |
-
if (!$configFilePath) return false;
|
624 |
-
return strpos(file_get_contents($configFilePath), 'Added by SiteGround WordPress management system') !== false;
|
625 |
-
}
|
626 |
-
|
627 |
-
public function is_hosting_gridpane(): bool
|
628 |
-
{
|
629 |
-
$configFilePath = $this->get_wpconfig_path();
|
630 |
-
if (!$configFilePath) return false;
|
631 |
-
return strpos(file_get_contents($configFilePath), 'GridPane Cache Settings') !== false;
|
632 |
-
}
|
633 |
-
|
634 |
-
public function is_hosting_kinsta(): bool
|
635 |
-
{
|
636 |
-
return defined("KINSTAMU_VERSION");
|
637 |
-
}
|
638 |
-
|
639 |
-
public function is_hosting_closte(): bool
|
640 |
-
{
|
641 |
-
return defined("CLOSTE_APP_ID");
|
642 |
-
}
|
643 |
-
|
644 |
-
public function is_hosting_pagely(): bool
|
645 |
-
{
|
646 |
-
return class_exists('\PagelyCachePurge');
|
647 |
-
}
|
648 |
-
|
649 |
-
public function get_hosting_provider(): string
|
650 |
-
{
|
651 |
-
if ($this->is_hosting_flywheel()) {
|
652 |
-
return "Flywheel";
|
653 |
-
} else if ($this->is_hosting_cloudways()) {
|
654 |
-
return "Cloudways";
|
655 |
-
} else if ($this->is_hosting_wp_engine()) {
|
656 |
-
return "WP Engine";
|
657 |
-
} else if ($this->is_hosting_siteground()) {
|
658 |
-
return "SiteGround";
|
659 |
-
} else if ($this->is_hosting_godaddy_wpaas()) {
|
660 |
-
return "GoDaddy WPaas";
|
661 |
-
} else if ($this->is_hosting_gridpane()) {
|
662 |
-
return "GridPane";
|
663 |
-
} else if ($this->is_hosting_kinsta()) {
|
664 |
-
return "Kinsta";
|
665 |
-
} else if ($this->is_hosting_closte()) {
|
666 |
-
return "Closte";
|
667 |
-
} else if ($this->is_hosting_pagely()) {
|
668 |
-
return "Pagely";
|
669 |
-
} else {
|
670 |
-
return "unknown";
|
671 |
-
}
|
672 |
-
}
|
673 |
-
|
674 |
-
// https://github.com/wp-cli/wp-cli/blob/c3bd5bd76abf024f9d492579539646e0d263a05a/php/utils.php#L257
|
675 |
-
public function get_wpconfig_path()
|
676 |
-
{
|
677 |
-
static $path;
|
678 |
-
|
679 |
-
if (null === $path) {
|
680 |
-
$path = false;
|
681 |
-
|
682 |
-
if (getenv('WP_CONFIG_PATH') && file_exists(getenv('WP_CONFIG_PATH'))) {
|
683 |
-
$path = getenv('WP_CONFIG_PATH');
|
684 |
-
} elseif (file_exists(ABSPATH . 'wp-config.php')) {
|
685 |
-
$path = ABSPATH . 'wp-config.php';
|
686 |
-
} elseif (file_exists(dirname(ABSPATH) . '/wp-config.php') && !file_exists(dirname(ABSPATH) . '/wp-settings.php')) {
|
687 |
-
$path = dirname(ABSPATH) . '/wp-config.php';
|
688 |
-
}
|
689 |
-
|
690 |
-
if ($path) {
|
691 |
-
$path = realpath($path);
|
692 |
-
}
|
693 |
-
}
|
694 |
-
|
695 |
-
return $path;
|
696 |
-
}
|
697 |
-
|
698 |
-
public function disable_yoast_seo_facebook_social($option)
|
699 |
-
{
|
700 |
-
$option['opengraph'] = false;
|
701 |
-
return $option;
|
702 |
-
}
|
703 |
-
|
704 |
-
public function disable_litespeed_js_inline_after_dom($option): int
|
705 |
-
{
|
706 |
-
return 0;
|
707 |
-
}
|
708 |
-
|
709 |
-
public function disable_wp_rocket_js_optimizations($option)
|
710 |
-
{
|
711 |
-
$option['minify_concatenate_js'] = 0;
|
712 |
-
// $option['defer_all_js'] = 0;
|
713 |
-
// $option['delay_js'] = 0;
|
714 |
-
return $option;
|
715 |
-
}
|
716 |
-
|
717 |
-
public function permanent_compatibility_mode()
|
718 |
-
{
|
719 |
-
if ($this->is_wp_rocket_active()) $this->exclude_inline_scripts_from_wp_rocket_using_options();
|
720 |
-
|
721 |
-
// for testing you need to clear the WP Rocket cache, only then the filters run
|
722 |
-
if ($this->is_wp_rocket_active()) {
|
723 |
-
add_filter('rocket_delay_js_exclusions', [$this, 'add_wp_rocket_exclusions']);
|
724 |
-
add_filter('rocket_defer_inline_exclusions', [$this, 'add_wp_rocket_exclusions']);
|
725 |
-
add_filter('rocket_exclude_defer_js', [$this, 'add_wp_rocket_exclusions']);
|
726 |
-
add_filter('rocket_exclude_js', [$this, 'add_wp_rocket_exclusions']);
|
727 |
-
add_filter('rocket_minify_excluded_external_js', [$this, 'add_wp_rocket_exclusions']);
|
728 |
-
add_filter('rocket_excluded_inline_js_content', [$this, 'add_wp_rocket_exclusions']);
|
729 |
-
}
|
730 |
-
|
731 |
-
if ($this->is_sg_optimizer_active()) {
|
732 |
-
add_filter('sgo_javascript_combine_excluded_inline_content', [$this, 'sg_optimizer_js_exclude_combine_inline_content']);
|
733 |
-
add_filter('sgo_js_minify_exclude', [$this, 'sg_optimizer_js_minify_exclude']);
|
734 |
-
add_filter('sgo_javascript_combine_exclude_move_after', [$this, 'sgo_javascript_combine_exclude_move_after']);
|
735 |
-
}
|
736 |
-
|
737 |
-
if ($this->is_litespeed_active()) {
|
738 |
-
add_filter('litespeed_optm_js_defer_exc', [$this, 'litespeed_cache_js_defer_exc']);
|
739 |
-
add_filter('litespeed_optimize_js_excludes', [$this, 'litespeed_optimize_js_excludes']);
|
740 |
-
add_filter('litespeed_optm_cssjs', [$this, 'litespeed_optm_cssjs']);
|
741 |
-
// add_filter('option_litespeed.conf.optm-js_inline_defer', [$this, 'disable_litespeed_js_inline_after_dom']);
|
742 |
-
|
743 |
-
// litespeed_optm_cssjs
|
744 |
-
// litespeed_optm_html_head
|
745 |
-
}
|
746 |
-
|
747 |
-
if ($this->is_autoptimize_active()) {
|
748 |
-
add_filter('autoptimize_filter_js_consider_minified', [$this, 'autoptimize_filter_js_consider_minified']);
|
749 |
-
add_filter('autoptimize_filter_js_dontmove', [$this, 'autoptimize_filter_js_dontmove']);
|
750 |
-
}
|
751 |
-
|
752 |
-
if ($this->is_wp_optimize_active()) {
|
753 |
-
// add_filter('wpo_minify_inline_js', '__return_false');
|
754 |
-
add_filter('wp-optimize-minify-default-exclusions', [$this, 'wp_optimize_minify_default_exclusions']);
|
755 |
-
}
|
756 |
-
|
757 |
-
if ($this->is_optimocha_active()) {
|
758 |
-
add_filter('option_sbp_options', function ($options) {
|
759 |
-
|
760 |
-
$options['js_exclude'] = $options['js_exclude'] . PHP_EOL . implode(PHP_EOL, $this->get_wpm_script_identifiers());
|
761 |
-
|
762 |
-
$js_include = explode(PHP_EOL, $options['js_include']);
|
763 |
-
|
764 |
-
$js_include = array_filter($js_include, function ($string) {
|
765 |
-
foreach ($this->get_wpm_script_identifiers() as $value) {
|
766 |
-
if (strpos($string, $value) !== false) return false;
|
767 |
-
}
|
768 |
-
|
769 |
-
return true;
|
770 |
-
});
|
771 |
-
|
772 |
-
$options['js_include'] = implode(PHP_EOL, $js_include);
|
773 |
-
|
774 |
-
return $options;
|
775 |
-
});
|
776 |
-
}
|
777 |
-
|
778 |
-
if ($this->is_async_javascript_active()) {
|
779 |
-
|
780 |
-
// add_filter('option_aj_exclusions', function ($options) {
|
781 |
-
// $options = explode(',', $options);
|
782 |
-
// $options = array_unique(array_merge($options, $this->get_wpm_script_identifiers()));
|
783 |
-
// return implode(',', $options);
|
784 |
-
// });
|
785 |
-
|
786 |
-
add_filter('option_aj_plugin_exclusions', function ($options) {
|
787 |
-
|
788 |
-
if (!is_array($options)) {
|
789 |
-
$options = [];
|
790 |
-
}
|
791 |
-
|
792 |
-
return array_unique(array_merge($options, [
|
793 |
-
'woocommerce-google-adwords-conversion-tracking-tag',
|
794 |
-
'woopt-pixel-manager-pro',
|
795 |
-
'woocommerce-pixel-manager',
|
796 |
-
'woocommerce-pixel-manager-pro',
|
797 |
-
]));
|
798 |
-
});
|
799 |
-
}
|
800 |
-
|
801 |
-
if ($this->is_flying_press_active()) {
|
802 |
-
|
803 |
-
add_filter('pre_update_option_FLYING_PRESS_CONFIG', function ($options) {
|
804 |
-
|
805 |
-
$options['js_defer_excludes'] = array_unique(array_merge($options['js_defer_excludes'], $this->get_wpm_script_identifiers()));
|
806 |
-
return $options;
|
807 |
-
});
|
808 |
-
|
809 |
-
add_filter('option_FLYING_PRESS_CONFIG', function ($options) {
|
810 |
-
|
811 |
-
$options['js_defer_excludes'] = array_unique(array_merge($options['js_defer_excludes'], $this->get_wpm_script_identifiers()));
|
812 |
-
return $options;
|
813 |
-
});
|
814 |
-
}
|
815 |
-
}
|
816 |
-
|
817 |
-
public function wp_optimize_minify_default_exclusions($default_exclusions): array
|
818 |
-
{
|
819 |
-
// $default_exclusions[] = 'something/else.js';
|
820 |
-
// $default_exclusions[] = 'something/else.css';
|
821 |
-
return array_unique(array_merge($default_exclusions, $this->get_wpm_script_identifiers()));
|
822 |
-
}
|
823 |
-
|
824 |
-
// https://github.com/futtta/autoptimize/blob/37b13d4e19269bb2f50df123257de51afa37244f/classes/autoptimizeScripts.php#L387
|
825 |
-
public function autoptimize_filter_js_consider_minified(): array
|
826 |
-
{
|
827 |
-
$exclude_js[] = 'wpm.min.js';
|
828 |
-
$exclude_js[] = 'wpm.min.js';
|
829 |
|
830 |
-
|
831 |
-
|
832 |
|
833 |
-
|
834 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
835 |
|
836 |
// $exclude_js[] = 'jquery.js';
|
837 |
// $exclude_js[] = 'jquery.min.js';
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
public function sg_optimizer_js_exclude_combine_inline_content($exclude_list): array
|
881 |
-
{
|
882 |
-
if (is_array($exclude_list)) {
|
883 |
-
$exclude_list = array_unique(array_merge($exclude_list, $this->get_wpm_script_identifiers()));
|
884 |
-
}
|
885 |
|
886 |
// foreach ($this->get_wpm_script_identifiers() as $exclusion) {
|
887 |
// $exclude_list[] = $exclusion;
|
888 |
// }
|
889 |
|
890 |
-
|
891 |
-
|
|
|
|
|
892 |
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
$exclude_list[] = 'wpm-ga4-eec';
|
908 |
-
$exclude_list[] = 'polyfill-io';
|
909 |
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
|
914 |
-
|
915 |
-
|
916 |
|
917 |
-
|
918 |
-
{
|
919 |
-
if (is_array($exclude_list)) {
|
920 |
-
$exclude_list = array_unique(array_merge($exclude_list, $this->get_wpm_script_identifiers()));
|
921 |
-
}
|
922 |
|
923 |
-
|
924 |
-
|
|
|
925 |
|
926 |
-
|
927 |
-
|
928 |
-
if (is_array($exclusions)) $exclusions = array_unique(array_merge($exclusions, $this->get_wpm_script_identifiers()));
|
929 |
|
930 |
-
|
931 |
-
|
|
|
|
|
932 |
|
|
|
|
|
933 |
|
934 |
-
// works for WP Rocket >= 3.9
|
935 |
-
public function exclude_inline_scripts_from_wp_rocket_using_options()
|
936 |
-
{
|
937 |
-
$options = get_option('wp_rocket_settings');
|
938 |
|
939 |
-
|
940 |
-
|
|
|
941 |
|
942 |
-
|
|
|
|
|
|
|
943 |
|
944 |
-
|
945 |
|
946 |
-
|
947 |
|
948 |
-
|
|
|
|
|
949 |
// if (array_key_exists('exclude_inline_js', $options) && is_array($options['exclude_inline_js']) && !in_array($string, $options['exclude_inline_js'])) {
|
950 |
//
|
951 |
// array_push($options['exclude_inline_js'], $string);
|
952 |
// $update_options = true;
|
953 |
// }
|
954 |
|
955 |
-
|
956 |
// if (array_key_exists('exclude_js', $options) && is_array($options['exclude_js']) && !in_array($string, $options['exclude_js'])) {
|
957 |
//
|
958 |
// array_push($options['exclude_js'], $string);
|
959 |
// $update_options = true;
|
960 |
// }
|
961 |
|
962 |
-
|
963 |
-
|
964 |
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
|
969 |
-
|
970 |
// if (array_key_exists('exclude_defer_js', $options) && is_array($options['exclude_defer_js']) && !in_array($string, $options['exclude_defer_js'])) {
|
971 |
//
|
972 |
// array_push($options['exclude_defer_js'], $string);
|
973 |
// $update_options = true;
|
974 |
// }
|
975 |
|
976 |
-
|
977 |
// if (array_key_exists('delay_js_exclusions', $options) && is_array($options['delay_js_exclusions']) && !in_array($string, $options['delay_js_exclusions'])) {
|
978 |
//
|
979 |
// array_push($options['delay_js_exclusions'], $string);
|
980 |
// $update_options = true;
|
981 |
// }
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
namespace WCPM\Classes\Admin;
|
4 |
|
5 |
if (!defined('ABSPATH')) {
|
6 |
+
exit; // Exit if accessed directly
|
7 |
}
|
8 |
|
9 |
+
class Environment_Check {
|
|
|
|
|
|
|
10 |
|
11 |
+
public $notifications;
|
12 |
+
private $documentation;
|
13 |
+
private $order_redirect = null;
|
14 |
+
private $options;
|
15 |
|
16 |
+
public function __construct( $options ) {
|
17 |
+
if (is_admin()) {
|
18 |
+
|
19 |
+
$this->options = $options;
|
20 |
+
|
21 |
+
$this->notifications = new Notifications();
|
22 |
+
$this->documentation = new Documentation();
|
23 |
|
24 |
// add_action('admin_enqueue_scripts', [$this, 'environment_check_script']);
|
25 |
+
add_action('wp_ajax_environment_check_handler', [$this, 'ajax_environment_check_handler']);
|
26 |
|
27 |
+
// get all active payment gateways
|
28 |
// add_action('plugins_loaded', [$this, 'get_active_payment_gateways_after_plugins_loaded']);
|
29 |
|
30 |
+
//check for active off-site payment gateways
|
31 |
// $this->check_active_off_site_payment_gateways();
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
public function run_incompatible_plugins_checks() {
|
36 |
+
$saved_notifications = get_option(WPM_DB_NOTIFICATIONS_NAME);
|
37 |
+
|
38 |
+
foreach ($this->get_incompatible_plugins_list() as $plugin) {
|
39 |
+
|
40 |
+
if (is_array($saved_notifications) && !array_key_exists($plugin['slug'], $saved_notifications) && is_plugin_active($plugin['file_location'])) {
|
41 |
+
|
42 |
+
( new Notifications() )->plugin_is_incompatible(
|
43 |
+
$plugin['name'],
|
44 |
+
$plugin['version'],
|
45 |
+
$plugin['slug'],
|
46 |
+
$plugin['link'],
|
47 |
+
$plugin['wpm_doc_link']
|
48 |
+
);
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
public function get_incompatible_plugins_list() {
|
54 |
+
return [
|
55 |
+
'wc-custom-thank-you' => [
|
56 |
+
'name' => 'WC Custom Thank You',
|
57 |
+
'slug' => 'wc-custom-thank-you',
|
58 |
+
'file_location' => 'wc-custom-thank-you/woocommerce-custom-thankyou.php',
|
59 |
+
'link' => 'https://wordpress.org/plugins/wc-custom-thank-you/',
|
60 |
+
'wpm_doc_link' => $this->documentation->get_link('custom_thank_you'),
|
61 |
+
'version' => '1.2.1',
|
62 |
+
]
|
63 |
+
];
|
64 |
+
}
|
65 |
+
|
66 |
+
public function flush_cache_on_plugin_changes() {
|
67 |
+
// flush cache after saving the plugin options
|
68 |
+
add_action('update_option_wgact_plugin_options', [$this, 'flush_cache_of_all_cache_plugins'], 10, 3);
|
69 |
+
|
70 |
+
// flush cache after install
|
71 |
+
// we don't need that because after first install the user needs to set new options anyway where the cache flush happens too
|
|
|
|
|
|
|
72 |
// add_filter('upgrader_post_install', [$this, 'flush_cache_of_all_cache_plugins'], 10, 3);
|
73 |
|
74 |
+
// flush cache after plugin update
|
75 |
+
add_action('upgrader_process_complete', [$this, 'flush_cache_of_all_cache_plugins'], 10, 2);
|
76 |
+
}
|
77 |
|
78 |
+
public function flush_cache_of_all_cache_plugins() {
|
|
|
79 |
// error_log('flush cache of all cache plugins');
|
80 |
+
if ($this->is_wp_rocket_active()) {
|
81 |
+
$this->flush_wp_rocket_cache();
|
82 |
+
} // works
|
83 |
+
if ($this->is_litespeed_active()) {
|
84 |
+
$this->flush_litespeed_cache();
|
85 |
+
} // works
|
86 |
+
if ($this->is_autoptimize_active()) {
|
87 |
+
$this->flush_autoptimize_cache();
|
88 |
+
} // works
|
89 |
+
if ($this->is_hummingbird_active()) {
|
90 |
+
$this->flush_hummingbird_cache();
|
91 |
+
} // works
|
92 |
+
if ($this->is_nitropack_active()) {
|
93 |
+
$this->flush_nitropack_cache();
|
94 |
+
} // works
|
95 |
+
if ($this->is_sg_optimizer_active()) {
|
96 |
+
$this->flush_sg_optimizer_cache();
|
97 |
+
} // works
|
98 |
+
if ($this->is_w3_total_cache_active()) {
|
99 |
+
$this->flush_w3_total_cache();
|
100 |
+
} // works
|
101 |
+
if ($this->is_wp_optimize_active()) {
|
102 |
+
$this->flush_wp_optimize_cache();
|
103 |
+
} // works
|
104 |
+
if ($this->is_wp_super_cache_active()) {
|
105 |
+
$this->flush_wp_super_cache();
|
106 |
+
} // works
|
107 |
+
if ($this->is_wp_fastest_cache_active()) {
|
108 |
+
$this->flush_wp_fastest_cache();
|
109 |
+
} // works
|
110 |
+
if ($this->is_cloudflare_active()) {
|
111 |
+
$this->flush_cloudflare_cache();
|
112 |
+
} // works
|
113 |
+
if ($this->is_flying_press_active()) {
|
114 |
+
$this->flush_flying_press_cache();
|
115 |
+
} // works
|
116 |
+
|
117 |
+
|
118 |
+
if ($this->is_hosting_wp_engine()) {
|
119 |
+
$this->flush_wp_engine_cache();
|
120 |
+
} // works
|
121 |
// if ($this->is_hosting_pagely()) $this->flush_pagely_cache(); // TODO test
|
122 |
+
if ($this->is_hosting_kinsta()) {
|
123 |
+
$this->flush_kinsta_cache();
|
124 |
+
} // TODO test
|
125 |
//
|
126 |
// if ($this->is_nginx_helper_active()) $this->flush_nginx_cache(); // TODO test
|
127 |
|
128 |
+
// TODO add generic varnish purge
|
129 |
+
}
|
130 |
+
|
131 |
+
private function flush_kinsta_cache() {
|
132 |
+
try {
|
133 |
+
wp_remote_get('https://localhost/kinsta-clear-cache-all', [
|
134 |
+
'sslverify' => false,
|
135 |
+
'timeout' => 5
|
136 |
+
]);
|
137 |
+
|
138 |
+
} catch (\Exception $e) {
|
139 |
+
error_log($e);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
public function is_nginx_helper_active() {
|
144 |
+
return defined('NGINX_HELPER_BASEPATH');
|
145 |
+
}
|
146 |
+
|
147 |
+
private function flush_nginx_cache() {
|
148 |
+
global $nginx_purger;
|
149 |
+
if ($nginx_purger) {
|
150 |
+
$nginx_purger->purge_all();
|
151 |
+
}
|
152 |
+
return true;
|
153 |
+
}
|
154 |
+
|
155 |
+
public function flush_cloudflare_cache() {
|
156 |
+
try {
|
157 |
+
if (class_exists('\CF\WordPress\Hooks')) {
|
158 |
+
( new \CF\WordPress\Hooks() )->purgeCacheEverything();
|
159 |
+
}
|
160 |
+
} catch (\Exception $e) {
|
161 |
+
error_log($e);
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
public function flush_flying_press_cache() {
|
166 |
+
try {
|
167 |
+
if (class_exists('\FlyingPress\Purge') && method_exists('\FlyingPress\Purge', 'purge_cached_pages')) {
|
168 |
+
\FlyingPress\Purge::purge_cached_pages();
|
169 |
+
}
|
170 |
+
|
171 |
+
// /**
|
172 |
+
// * Update config and flush cache
|
173 |
+
// */
|
174 |
+
// if (class_exists('\FlyingPress\Config') && class_exists('\FlyingPress\Purge')) {
|
175 |
+
//
|
176 |
+
// // This is the way to update the Flying Press settings.
|
177 |
+
// // No other 'normal' way is possible.
|
178 |
+
//
|
179 |
+
// if (!is_array(\FlyingPress\Config::$config['js_defer_excludes'])) {
|
180 |
+
// \FlyingPress\Config::$config['js_defer_excludes'] = [];
|
181 |
+
// }
|
182 |
+
//
|
183 |
+
// \FlyingPress\Config::$config['js_defer_excludes'] = array_unique(array_merge(\FlyingPress\Config::$config['js_defer_excludes'], $this->get_wpm_script_identifiers()));
|
184 |
+
//
|
185 |
+
// if (
|
186 |
+
// method_exists('\FlyingPress\Config', 'update_config') &&
|
187 |
+
// method_exists('\FlyingPress\Purge', 'purge_cached_pages')
|
188 |
+
// ) {
|
189 |
+
// \FlyingPress\Config::update_config(\FlyingPress\Config::$config);
|
190 |
+
// \FlyingPress\Purge::purge_cached_pages();
|
191 |
+
// }
|
192 |
+
// }
|
193 |
+
|
194 |
+
} catch (\Exception $e) {
|
195 |
+
error_log($e);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
public function flush_wp_engine_cache() {
|
200 |
+
try {
|
201 |
+
if (class_exists('WpeCommon')) {
|
202 |
+
\WpeCommon::purge_varnish_cache_all();
|
203 |
+
}
|
204 |
+
} catch (\Exception $e) {
|
205 |
+
error_log($e);
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
private function flush_pagely_cache() {
|
210 |
+
try {
|
211 |
+
if (class_exists('PagelyCachePurge')) { // We need to have this check for clients that switch hosts
|
212 |
+
$pagely = new \PagelyCachePurge();
|
213 |
+
$pagely->purgeAll();
|
214 |
+
}
|
215 |
+
} catch (\Exception $e) {
|
216 |
+
error_log($e);
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
public function flush_wp_fastest_cache() {
|
221 |
+
if (function_exists('wpfc_clear_all_cache')) {
|
222 |
+
wpfc_clear_all_cache(true);
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
public function flush_wp_super_cache() {
|
227 |
+
if (function_exists('wp_cache_clean_cache')) {
|
228 |
+
global $file_prefix;
|
229 |
+
wp_cache_clean_cache($file_prefix, true);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
public function flush_wp_optimize_cache() {
|
234 |
+
if (function_exists('wpo_cache_flush')) {
|
235 |
+
wpo_cache_flush();
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
public function flush_w3_total_cache() {
|
240 |
+
if (function_exists('w3tc_flush_all')) {
|
241 |
+
w3tc_flush_all();
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
public function flush_sg_optimizer_cache() {
|
246 |
+
if (function_exists('sg_cachepress_purge_everything')) {
|
247 |
+
sg_cachepress_purge_everything();
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
public function flush_nitropack_cache() {
|
252 |
+
try {
|
253 |
+
if (class_exists('\NitroPack\SDK\Api\Cache')) {
|
254 |
+
$siteId = get_option('nitropack-siteId');
|
255 |
+
$siteSecret = get_option('nitropack-siteSecret');
|
256 |
+
( new \NitroPack\SDK\Api\Cache($siteId, $siteSecret) )->purge();
|
257 |
+
}
|
258 |
+
|
259 |
+
} catch (\Exception $e) {
|
260 |
+
error_log($e);
|
261 |
+
}
|
|
|
|
|
|
|
|
|
|
|
262 |
|
263 |
// do_action('nitropack_integration_purge_all');
|
264 |
+
}
|
265 |
+
|
266 |
+
public function flush_hummingbird_cache() {
|
267 |
+
do_action('wphb_clear_page_cache');
|
268 |
+
}
|
269 |
+
|
270 |
+
public function flush_autoptimize_cache() {
|
271 |
+
if (class_exists('autoptimizeCache')) {
|
272 |
+
// we need the backslash because autoptimizeCache is in the global namespace
|
273 |
+
// and otherwise our plugin would search in its own namespace and throw an error
|
274 |
+
\autoptimizeCache::clearall();
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
public function flush_litespeed_cache() {
|
279 |
+
do_action('litespeed_purge_all');
|
280 |
+
}
|
281 |
+
|
282 |
+
protected function flush_wp_rocket_cache() {
|
283 |
+
// flush WP Rocket cache
|
284 |
+
if (function_exists('rocket_clean_domain')) {
|
285 |
+
rocket_clean_domain();
|
286 |
+
}
|
287 |
+
|
288 |
+
// Preload cache.
|
289 |
+
if (function_exists('run_rocket_bot')) {
|
290 |
+
run_rocket_bot();
|
291 |
+
}
|
292 |
+
|
293 |
+
if (function_exists('run_rocket_sitemap_preload')) {
|
294 |
+
run_rocket_sitemap_preload();
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
public function check_active_off_site_payment_gateways() {
|
299 |
+
$wpm_notifications = get_option(WPM_DB_NOTIFICATIONS_NAME);
|
300 |
+
|
301 |
+
if (
|
302 |
+
!is_array($wpm_notifications) ||
|
303 |
+
!array_key_exists('dismiss_paypal_standard_warning', $wpm_notifications) ||
|
304 |
+
true !== $wpm_notifications['dismiss_paypal_standard_warning']
|
305 |
+
) {
|
306 |
+
if ($this->is_paypal_standard_active()) {
|
307 |
+
// run off-site payment gateway warning
|
308 |
+
( new Notifications() )->paypal_standard_active_warning();
|
309 |
+
}
|
310 |
+
}
|
311 |
+
}
|
312 |
+
|
313 |
+
public function get_active_payment_gateways_after_plugins_loaded() {
|
314 |
+
error_log(print_r($this->get_active_payment_gateways(), true));
|
315 |
+
}
|
316 |
+
|
317 |
+
private static function get_active_payment_gateways() {
|
318 |
+
$active_gateways = [];
|
319 |
+
$gateways = WC()->payment_gateways->payment_gateways();
|
320 |
+
foreach ($gateways as $id => $gateway) {
|
321 |
+
if (isset($gateway->enabled) && 'yes' === $gateway->enabled) {
|
322 |
+
$active_gateways[$id] = [
|
323 |
+
'title' => $gateway->title,
|
324 |
+
'supports' => $gateway->supports,
|
325 |
+
];
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
return $active_gateways;
|
330 |
+
}
|
331 |
+
|
332 |
+
public function run_checks() {
|
|
|
|
|
|
|
|
|
|
|
333 |
// $this->check_wp_rocket_js_concatenation();
|
334 |
// $this->check_litespeed_js_inline_after_dom();
|
335 |
+
}
|
336 |
+
|
337 |
+
public function environment_check_script() {
|
338 |
+
wp_enqueue_script('wpm-environment-check', WPM_PLUGIN_DIR_PATH . 'js/admin/environment-check.js', ['jquery'], WPM_CURRENT_VERSION, true);
|
339 |
+
}
|
340 |
+
|
341 |
+
public function ajax_environment_check_handler() {
|
342 |
+
|
343 |
+
$_post = filter_input_array(INPUT_POST, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
344 |
+
|
345 |
+
if (isset($_post['set'])) {
|
346 |
+
|
347 |
+
$set = $_post['set'];
|
348 |
+
|
349 |
+
if ('disable_wp_rocket_javascript_concatenation' == $set) {
|
350 |
+
$wp_rocket_options = get_option('wp_rocket_settings');
|
351 |
+
$wp_rocket_options['minify_concatenate_js'] = 0;
|
352 |
+
update_option('wp_rocket_settings', $wp_rocket_options);
|
353 |
+
}
|
354 |
+
|
355 |
+
if ('dismiss_wp_rocket_javascript_concatenation_error' == $set) {
|
356 |
+
$wpm_notifications = get_option(WPM_DB_NOTIFICATIONS_NAME);
|
357 |
+
$wpm_notifications['dismiss_wp_rocket_javascript_concatenation_error'] = true;
|
358 |
+
update_option(WPM_DB_NOTIFICATIONS_NAME, $wpm_notifications);
|
359 |
+
}
|
360 |
+
|
361 |
+
if ('disable_litespeed_inline_js_dom_ready' == $set) {
|
362 |
+
$litespeed_inline_js_dom_ready_option = 0;
|
363 |
+
update_option('litespeed.conf.optm-js_inline_defer', $litespeed_inline_js_dom_ready_option);
|
364 |
+
}
|
365 |
+
|
366 |
+
if ('dismiss_litespeed_inline_js_dom_ready' == $set) {
|
367 |
+
$wpm_notifications = get_option(WPM_DB_NOTIFICATIONS_NAME);
|
368 |
+
$wpm_notifications['dismiss_litespeed_inline_js_dom_ready_error'] = true;
|
369 |
+
update_option(WPM_DB_NOTIFICATIONS_NAME, $wpm_notifications);
|
370 |
+
}
|
371 |
+
|
372 |
+
if ('dismiss_paypal_standard_warning' == $set) {
|
373 |
+
$wpm_notifications = get_option(WPM_DB_NOTIFICATIONS_NAME);
|
374 |
+
$wpm_notifications['dismiss_paypal_standard_warning'] = true;
|
375 |
+
update_option(WPM_DB_NOTIFICATIONS_NAME, $wpm_notifications);
|
376 |
+
}
|
377 |
+
} else {
|
378 |
+
if (isset($_post['disable_warning'])) {
|
379 |
+
$wpm_notifications = get_option(WPM_DB_NOTIFICATIONS_NAME);
|
380 |
+
$wpm_notifications[$_post['disable_warning']] = true;
|
381 |
+
update_option(WPM_DB_NOTIFICATIONS_NAME, $wpm_notifications);
|
382 |
+
}
|
383 |
+
}
|
384 |
+
|
385 |
+
wp_die(); // this is required to terminate immediately and return a proper response
|
386 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
|
388 |
+
private function check_wp_rocket_js_concatenation() {
|
389 |
+
$wpm_notifications = get_option(WPM_DB_NOTIFICATIONS_NAME);
|
390 |
|
391 |
+
if ($this->is_wp_rocket_active() && ( !is_array($wpm_notifications) || false == $wpm_notifications['dismiss_wp_rocket_javascript_concatenation_error'] )) {
|
392 |
+
|
393 |
+
$wp_rocket_settings = get_option('wp_rocket_settings');
|
394 |
+
|
395 |
+
if ($wp_rocket_settings) {
|
396 |
+
if (true == $wp_rocket_settings['minify_concatenate_js']) {
|
397 |
+
// display warning
|
398 |
+
( new Notifications() )->wp_rocket_js_concatenation_error();
|
399 |
+
}
|
400 |
+
}
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
private function check_litespeed_js_inline_after_dom() {
|
405 |
+
$wpm_notifications = get_option(WPM_DB_NOTIFICATIONS_NAME);
|
406 |
+
|
407 |
+
if ($this->is_litespeed_active() && ( !is_array($wpm_notifications) || false == $wpm_notifications['dismiss_litespeed_inline_js_dom_ready_error'] )) {
|
408 |
+
|
409 |
+
$litespeed_js_inline_defer_settings = get_option('litespeed.conf.optm-js_inline_defer');
|
410 |
+
|
411 |
+
if ($litespeed_js_inline_defer_settings) {
|
412 |
+
if (1 == $litespeed_js_inline_defer_settings) {
|
413 |
+
// display warning
|
414 |
+
( new Notifications() )->litespeed_js_defer_error();
|
415 |
+
}
|
416 |
+
}
|
417 |
+
}
|
418 |
+
}
|
419 |
+
|
420 |
+
public function is_paypal_standard_active() {
|
421 |
+
$woocommerce_paypal_settings = get_option('woocommerce_paypal_settings');
|
422 |
+
|
423 |
+
if (
|
424 |
+
!is_bool($woocommerce_paypal_settings) &&
|
425 |
+
array_key_exists('enabled', $woocommerce_paypal_settings) &&
|
426 |
+
'yes' === $woocommerce_paypal_settings['enabled']) {
|
427 |
+
return true;
|
428 |
+
} else {
|
429 |
+
return false;
|
430 |
+
}
|
431 |
+
}
|
432 |
+
|
433 |
+
public function is_wc_custom_thank_you_active() {
|
434 |
+
return is_plugin_active('wc-custom-thank-you/woocommerce-custom-thankyou.php');
|
435 |
+
}
|
436 |
+
|
437 |
+
public function is_wp_rocket_active() {
|
438 |
+
return is_plugin_active('wp-rocket/wp-rocket.php');
|
439 |
+
}
|
440 |
+
|
441 |
+
public function is_sg_optimizer_active() {
|
442 |
+
return is_plugin_active('sg-cachepress/sg-cachepress.php');
|
443 |
+
}
|
444 |
+
|
445 |
+
public function is_w3_total_cache_active() {
|
446 |
+
return is_plugin_active('w3-total-cache/w3-total-cache.php');
|
447 |
+
}
|
448 |
+
|
449 |
+
public function is_litespeed_active() {
|
450 |
+
// TODO find out if there is a pro version with different folder and file name
|
451 |
+
|
452 |
+
return is_plugin_active('litespeed-cache/litespeed-cache.php');
|
453 |
+
}
|
454 |
+
|
455 |
+
public function is_autoptimize_active() {
|
456 |
+
// TODO find out if there is a pro version with different folder and file name
|
457 |
+
|
458 |
+
return is_plugin_active('autoptimize/autoptimize.php');
|
459 |
+
}
|
460 |
+
|
461 |
+
public function is_hummingbird_active() {
|
462 |
+
// TODO find out if there is a pro version with different folder and file name
|
463 |
+
|
464 |
+
return is_plugin_active('hummingbird-performance/wp-hummingbird.php');
|
465 |
+
}
|
466 |
+
|
467 |
+
public function is_nitropack_active() {
|
468 |
+
// TODO find out if there is a pro version with different folder and file name
|
469 |
+
|
470 |
+
return is_plugin_active('nitropack/main.php');
|
471 |
+
}
|
472 |
+
|
473 |
+
public function is_yoast_seo_active() {
|
474 |
+
// TODO find out if there is a pro version with different folder and file name
|
475 |
+
|
476 |
+
return is_plugin_active('wordpress-seo/wp-seo.php');
|
477 |
+
}
|
478 |
+
|
479 |
+
public function is_borlabs_cookie_active() {
|
480 |
+
// TODO find out if there is a pro version with different folder and file name
|
481 |
+
|
482 |
+
return is_plugin_active('borlabs-cookie/borlabs-cookie.php');
|
483 |
+
}
|
484 |
+
|
485 |
+
public function is_cookiebot_active() {
|
486 |
+
return is_plugin_active('cookiebot/cookiebot.php');
|
487 |
+
}
|
488 |
+
|
489 |
+
public function is_complianz_active() {
|
490 |
+
return is_plugin_active('complianz-gdpr/complianz-gpdr.php');
|
491 |
+
}
|
492 |
+
|
493 |
+
// Cookie Notice by hu-manity.co
|
494 |
+
public function is_cookie_notice_active() {
|
495 |
+
return is_plugin_active('cookie-notice/cookie-notice.php');
|
496 |
+
}
|
497 |
+
|
498 |
+
public function is_cookie_script_active() {
|
499 |
+
return is_plugin_active('cookie-script-com/cookie-script.php');
|
500 |
+
}
|
501 |
+
|
502 |
+
public function is_moove_gdpr_active() {
|
503 |
+
return is_plugin_active('gdpr-cookie-compliance/moove-gdpr.php');
|
504 |
+
}
|
505 |
+
|
506 |
+
public function is_cookie_law_info_active() {
|
507 |
+
return is_plugin_active('cookie-law-info/cookie-law-info.php');
|
508 |
+
}
|
509 |
+
|
510 |
+
public function is_some_cmp_active() {
|
511 |
+
if (
|
512 |
+
$this->is_borlabs_cookie_active() ||
|
513 |
+
$this->is_cookiebot_active() ||
|
514 |
+
$this->is_complianz_active() ||
|
515 |
+
$this->is_cookie_notice_active() ||
|
516 |
+
$this->is_cookie_script_active() ||
|
517 |
+
$this->is_moove_gdpr_active() ||
|
518 |
+
$this->is_cookie_law_info_active()
|
519 |
+
) {
|
520 |
+
return true;
|
521 |
+
} else {
|
522 |
+
return false;
|
523 |
+
}
|
524 |
+
}
|
525 |
+
|
526 |
+
public function is_wp_super_cache_active() {
|
527 |
+
// TODO find out if there is a pro version with different folder and file name
|
528 |
+
|
529 |
+
return is_plugin_active('wp-super-cache/wp-cache.php');
|
530 |
+
}
|
531 |
+
|
532 |
+
public function is_wp_fastest_cache_active() {
|
533 |
+
// The pro version requires the free version to be active
|
534 |
+
|
535 |
+
return is_plugin_active('wp-fastest-cache/wpFastestCache.php');
|
536 |
+
}
|
537 |
+
|
538 |
+
public function is_cloudflare_active() {
|
539 |
+
return is_plugin_active('cloudflare/cloudflare.php');
|
540 |
+
}
|
541 |
+
|
542 |
+
public function is_wpml_woocommerce_multi_currency_active() {
|
543 |
+
global $woocommerce_wpml;
|
544 |
+
|
545 |
+
if (is_plugin_active('woocommerce-multilingual/wpml-woocommerce.php') && is_object($woocommerce_wpml->multi_currency)) {
|
546 |
+
return true;
|
547 |
+
} else {
|
548 |
+
return false;
|
549 |
+
}
|
550 |
+
}
|
551 |
+
|
552 |
+
public function is_woo_discount_rules_active() {
|
553 |
+
if (is_plugin_active('woo-discount-rules/woo-discount-rules.php') || is_plugin_active('woo-discount-rules-pro/woo-discount-rules-pro.php')) {
|
554 |
+
return true;
|
555 |
+
} else {
|
556 |
+
return false;
|
557 |
+
}
|
558 |
+
}
|
559 |
+
|
560 |
+
public function is_wp_optimize_active() {
|
561 |
+
return is_plugin_active('wp-optimize/wp-optimize.php');
|
562 |
+
}
|
563 |
+
|
564 |
+
public function is_woocommerce_brands_active() {
|
565 |
+
return is_plugin_active('woocommerce-brands/woocommerce-brands.php');
|
566 |
+
}
|
567 |
+
|
568 |
+
public function is_yith_wc_brands_active() {
|
569 |
+
return is_plugin_active('yith-woocommerce-brands-add-on-premium/init.php');
|
570 |
+
}
|
571 |
+
|
572 |
+
public function is_optimocha_active() {
|
573 |
+
// TODO find out if there is a pro version with different folder and file name
|
574 |
+
return is_plugin_active('speed-booster-pack/speed-booster-pack.php');
|
575 |
+
}
|
576 |
+
|
577 |
+
public function is_async_javascript_active() {
|
578 |
+
// TODO find out if there is a pro version with different folder and file name
|
579 |
+
return is_plugin_active('async-javascript/async-javascript.php');
|
580 |
+
}
|
581 |
+
|
582 |
+
public function is_flying_press_active() {
|
583 |
+
// TODO find out if there is a pro version with different folder and file name
|
584 |
+
return is_plugin_active('flying-press/flying-press.php');
|
585 |
+
}
|
586 |
+
|
587 |
+
/*
|
588 |
+
* Check to find out what hosting provider is being used
|
589 |
+
* */
|
590 |
+
|
591 |
+
public function is_hosting_flywheel() {
|
592 |
+
return defined('FLYWHEEL_PLUGIN_DIR');
|
593 |
+
}
|
594 |
+
|
595 |
+
public function is_hosting_cloudways() {
|
596 |
+
|
597 |
+
$_server = filter_input_array(INPUT_SERVER, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
598 |
+
|
599 |
+
return array_key_exists('cw_allowed_ip', $_server) || preg_match('~/home/.*?cloudways.*~', __FILE__);
|
600 |
+
}
|
601 |
+
|
602 |
+
public function is_hosting_wp_engine() {
|
603 |
+
return !!getenv('IS_WPE');
|
604 |
+
}
|
605 |
+
|
606 |
+
public function is_hosting_godaddy_wpaas() {
|
607 |
+
return class_exists('\WPaaS\Plugin');
|
608 |
+
}
|
609 |
+
|
610 |
+
public function is_hosting_siteground() {
|
611 |
+
$configFilePath = $this->get_wpconfig_path();
|
612 |
+
if (!$configFilePath) {
|
613 |
+
return false;
|
614 |
+
}
|
615 |
+
return strpos(file_get_contents($configFilePath), 'Added by SiteGround WordPress management system') !== false;
|
616 |
+
}
|
617 |
+
|
618 |
+
public function is_hosting_gridpane() {
|
619 |
+
$configFilePath = $this->get_wpconfig_path();
|
620 |
+
if (!$configFilePath) {
|
621 |
+
return false;
|
622 |
+
}
|
623 |
+
return strpos(file_get_contents($configFilePath), 'GridPane Cache Settings') !== false;
|
624 |
+
}
|
625 |
+
|
626 |
+
public function is_hosting_kinsta() {
|
627 |
+
return defined('KINSTAMU_VERSION');
|
628 |
+
}
|
629 |
+
|
630 |
+
public function is_hosting_closte() {
|
631 |
+
return defined('CLOSTE_APP_ID');
|
632 |
+
}
|
633 |
+
|
634 |
+
public function is_hosting_pagely() {
|
635 |
+
return class_exists('\PagelyCachePurge');
|
636 |
+
}
|
637 |
+
|
638 |
+
public function get_hosting_provider() {
|
639 |
+
if ($this->is_hosting_flywheel()) {
|
640 |
+
return 'Flywheel';
|
641 |
+
} elseif ($this->is_hosting_cloudways()) {
|
642 |
+
return 'Cloudways';
|
643 |
+
} elseif ($this->is_hosting_wp_engine()) {
|
644 |
+
return 'WP Engine';
|
645 |
+
} elseif ($this->is_hosting_siteground()) {
|
646 |
+
return 'SiteGround';
|
647 |
+
} elseif ($this->is_hosting_godaddy_wpaas()) {
|
648 |
+
return 'GoDaddy WPaas';
|
649 |
+
} elseif ($this->is_hosting_gridpane()) {
|
650 |
+
return 'GridPane';
|
651 |
+
} elseif ($this->is_hosting_kinsta()) {
|
652 |
+
return 'Kinsta';
|
653 |
+
} elseif ($this->is_hosting_closte()) {
|
654 |
+
return 'Closte';
|
655 |
+
} elseif ($this->is_hosting_pagely()) {
|
656 |
+
return 'Pagely';
|
657 |
+
} else {
|
658 |
+
return 'unknown';
|
659 |
+
}
|
660 |
+
}
|
661 |
+
|
662 |
+
// https://github.com/wp-cli/wp-cli/blob/c3bd5bd76abf024f9d492579539646e0d263a05a/php/utils.php#L257
|
663 |
+
public function get_wpconfig_path() {
|
664 |
+
static $path;
|
665 |
+
|
666 |
+
if (null === $path) {
|
667 |
+
$path = false;
|
668 |
+
|
669 |
+
if (getenv('WP_CONFIG_PATH') && file_exists(getenv('WP_CONFIG_PATH'))) {
|
670 |
+
$path = getenv('WP_CONFIG_PATH');
|
671 |
+
} elseif (file_exists(ABSPATH . 'wp-config.php')) {
|
672 |
+
$path = ABSPATH . 'wp-config.php';
|
673 |
+
} elseif (file_exists(dirname(ABSPATH) . '/wp-config.php') && !file_exists(dirname(ABSPATH) . '/wp-settings.php')) {
|
674 |
+
$path = dirname(ABSPATH) . '/wp-config.php';
|
675 |
+
}
|
676 |
+
|
677 |
+
if ($path) {
|
678 |
+
$path = realpath($path);
|
679 |
+
}
|
680 |
+
}
|
681 |
+
|
682 |
+
return $path;
|
683 |
+
}
|
684 |
+
|
685 |
+
public function disable_yoast_seo_facebook_social( $option ) {
|
686 |
+
$option['opengraph'] = false;
|
687 |
+
return $option;
|
688 |
+
}
|
689 |
+
|
690 |
+
public function disable_litespeed_js_inline_after_dom( $option ) {
|
691 |
+
return 0;
|
692 |
+
}
|
693 |
+
|
694 |
+
// public function disable_wp_rocket_js_optimizations( $option ) {
|
695 |
+
// $option['minify_concatenate_js'] = 0;
|
696 |
+
//// $option['defer_all_js'] = 0;
|
697 |
+
//// $option['delay_js'] = 0;
|
698 |
+
// return $option;
|
699 |
+
// }
|
700 |
+
|
701 |
+
|
702 |
+
public function wp_optimize_minify_default_exclusions( $default_exclusions ) {
|
703 |
+
// $default_exclusions[] = 'something/else.js';
|
704 |
+
// $default_exclusions[] = 'something/else.css';
|
705 |
+
return array_unique(array_merge($default_exclusions, $this->get_wpm_script_identifiers()));
|
706 |
+
}
|
707 |
+
|
708 |
+
// https://github.com/futtta/autoptimize/blob/37b13d4e19269bb2f50df123257de51afa37244f/classes/autoptimizeScripts.php#L387
|
709 |
+
public function autoptimize_filter_js_consider_minified() {
|
710 |
+
$exclude_js[] = 'wpm.min.js';
|
711 |
+
$exclude_js[] = 'wpm.min.js';
|
712 |
+
|
713 |
+
$exclude_js[] = 'wpm-public.p1.min.js';
|
714 |
+
$exclude_js[] = 'wpm-public__premium_only.p1.min.js';
|
715 |
+
|
716 |
+
$exclude_js[] = 'wpm-public.p2.min.js';
|
717 |
+
$exclude_js[] = 'wpm-public__premium_only.p2.min.js';
|
718 |
|
719 |
// $exclude_js[] = 'jquery.js';
|
720 |
// $exclude_js[] = 'jquery.min.js';
|
721 |
+
return $exclude_js;
|
722 |
+
}
|
723 |
+
|
724 |
+
// https://github.com/futtta/autoptimize/blob/37b13d4e19269bb2f50df123257de51afa37244f/classes/autoptimizeScripts.php#L285
|
725 |
+
public function autoptimize_filter_js_dontmove( $dontmove ) {
|
726 |
+
$dontmove[] = 'wpm.js';
|
727 |
+
$dontmove[] = 'wpm.min.js';
|
728 |
+
|
729 |
+
$dontmove[] = 'wpm-public.p1.min.js';
|
730 |
+
$dontmove[] = 'wpm-public__premium_only.p1.min.js';
|
731 |
+
|
732 |
+
$dontmove[] = 'wpm-public.p2.min.js';
|
733 |
+
$dontmove[] = 'wpm-public__premium_only.p2.min.js';
|
734 |
+
|
735 |
+
$dontmove[] = 'jquery.js';
|
736 |
+
$dontmove[] = 'jquery.min.js';
|
737 |
+
return $dontmove;
|
738 |
+
}
|
739 |
+
|
740 |
+
public function litespeed_optm_cssjs( $excludes ) {
|
741 |
+
return $excludes;
|
742 |
+
}
|
743 |
+
|
744 |
+
public function litespeed_optimize_js_excludes( $excludes ) {
|
745 |
+
if (is_array($excludes)) {
|
746 |
+
$excludes = array_unique(array_merge($excludes, $this->get_wpm_script_identifiers()));
|
747 |
+
}
|
748 |
+
|
749 |
+
return $excludes;
|
750 |
+
}
|
751 |
+
|
752 |
+
public function litespeed_cache_js_defer_exc( $excludes ) {
|
753 |
+
if (is_array($excludes)) {
|
754 |
+
$excludes = array_unique(array_merge($excludes, $this->get_wpm_script_identifiers()));
|
755 |
+
}
|
756 |
+
return $excludes;
|
757 |
+
}
|
758 |
+
|
759 |
+
public function sg_optimizer_js_exclude_combine_inline_content( $exclude_list ) {
|
760 |
+
if (is_array($exclude_list)) {
|
761 |
+
$exclude_list = array_unique(array_merge($exclude_list, $this->get_wpm_script_identifiers()));
|
762 |
+
}
|
|
|
|
|
|
|
|
|
|
|
763 |
|
764 |
// foreach ($this->get_wpm_script_identifiers() as $exclusion) {
|
765 |
// $exclude_list[] = $exclusion;
|
766 |
// }
|
767 |
|
768 |
+
return $exclude_list;
|
769 |
+
}
|
770 |
+
|
771 |
+
public function sg_optimizer_js_minify_exclude( $exclude_list ) {
|
772 |
|
773 |
+
$exclude_list[] = 'wpm-front-end-scripts';
|
774 |
+
$exclude_list[] = 'wpm-front-end-scripts-premium-only';
|
775 |
+
$exclude_list[] = 'wpm';
|
776 |
+
$exclude_list[] = 'wpm-admin';
|
777 |
+
$exclude_list[] = 'wpm-premium-only';
|
778 |
+
$exclude_list[] = 'wpm-facebook';
|
779 |
+
$exclude_list[] = 'wpm-script-blocker-warning';
|
780 |
+
$exclude_list[] = 'wpm-admin-helpers';
|
781 |
+
$exclude_list[] = 'wpm-admin-tabs';
|
782 |
+
$exclude_list[] = 'wpm-selectWoo';
|
783 |
+
$exclude_list[] = 'wpm-google-ads';
|
784 |
+
$exclude_list[] = 'wpm-ga-ua-eec';
|
785 |
+
$exclude_list[] = 'wpm-ga4-eec';
|
786 |
+
$exclude_list[] = 'polyfill-io';
|
|
|
|
|
787 |
|
788 |
+
$exclude_list[] = 'jquery';
|
789 |
+
$exclude_list[] = 'jquery-core';
|
790 |
+
$exclude_list[] = 'jquery-migrate';
|
791 |
|
792 |
+
return $exclude_list;
|
793 |
+
}
|
794 |
|
795 |
+
public function sgo_javascript_combine_exclude_move_after( $exclude_list ) {
|
|
|
|
|
|
|
|
|
796 |
|
797 |
+
if (is_array($exclude_list)) {
|
798 |
+
$exclude_list = array_unique(array_merge($exclude_list, $this->get_wpm_script_identifiers()));
|
799 |
+
}
|
800 |
|
801 |
+
return $exclude_list;
|
802 |
+
}
|
|
|
803 |
|
804 |
+
public function add_wp_rocket_exclusions( $exclusions ) {
|
805 |
+
if (is_array($exclusions)) {
|
806 |
+
$exclusions = array_unique(array_merge($exclusions, $this->get_wpm_script_identifiers()));
|
807 |
+
}
|
808 |
|
809 |
+
return $exclusions;
|
810 |
+
}
|
811 |
|
|
|
|
|
|
|
|
|
812 |
|
813 |
+
// works for WP Rocket >= 3.9
|
814 |
+
public function exclude_inline_scripts_from_wp_rocket_using_options() {
|
815 |
+
$options = get_option('wp_rocket_settings');
|
816 |
|
817 |
+
// if no options array could be retrieved.
|
818 |
+
if (!is_array($options)) {
|
819 |
+
return;
|
820 |
+
}
|
821 |
|
822 |
+
$update_options = false;
|
823 |
|
824 |
+
$js_to_exclude = $this->get_wpm_script_identifiers();
|
825 |
|
826 |
+
foreach ($js_to_exclude as $string) {
|
827 |
+
|
828 |
+
// add exclusions for inline js
|
829 |
// if (array_key_exists('exclude_inline_js', $options) && is_array($options['exclude_inline_js']) && !in_array($string, $options['exclude_inline_js'])) {
|
830 |
//
|
831 |
// array_push($options['exclude_inline_js'], $string);
|
832 |
// $update_options = true;
|
833 |
// }
|
834 |
|
835 |
+
// add exclusions for js
|
836 |
// if (array_key_exists('exclude_js', $options) && is_array($options['exclude_js']) && !in_array($string, $options['exclude_js'])) {
|
837 |
//
|
838 |
// array_push($options['exclude_js'], $string);
|
839 |
// $update_options = true;
|
840 |
// }
|
841 |
|
842 |
+
// remove scripts from delay_js_scripts
|
843 |
+
if (array_key_exists('delay_js_scripts', $options) && is_array($options['delay_js_scripts']) && in_array($string, $options['delay_js_scripts'])) {
|
844 |
|
845 |
+
unset($options['delay_js_scripts'][array_search($string, $options['delay_js_scripts'])]);
|
846 |
+
$update_options = true;
|
847 |
+
}
|
848 |
|
849 |
+
// exclude_defer_js
|
850 |
// if (array_key_exists('exclude_defer_js', $options) && is_array($options['exclude_defer_js']) && !in_array($string, $options['exclude_defer_js'])) {
|
851 |
//
|
852 |
// array_push($options['exclude_defer_js'], $string);
|
853 |
// $update_options = true;
|
854 |
// }
|
855 |
|
856 |
+
// exclude_delay_js
|
857 |
// if (array_key_exists('delay_js_exclusions', $options) && is_array($options['delay_js_exclusions']) && !in_array($string, $options['delay_js_exclusions'])) {
|
858 |
//
|
859 |
// array_push($options['delay_js_exclusions'], $string);
|
860 |
// $update_options = true;
|
861 |
// }
|
862 |
+
}
|
863 |
+
|
864 |
+
if (true === $update_options) {
|
865 |
+
update_option('wp_rocket_settings', $options);
|
866 |
+
}
|
867 |
+
}
|
868 |
+
|
869 |
+
public function disable_third_party_js_optimization() {
|
870 |
+
|
871 |
+
/**
|
872 |
+
* SiteGround Optimizer
|
873 |
+
*/
|
874 |
+
|
875 |
+
if ($this->is_sg_optimizer_active()) {
|
876 |
+
|
877 |
+
/**
|
878 |
+
* The function wpmFunctionExists needs to be excluded from combination from SGO.
|
879 |
+
* Otherwise, it won't work on pages which include WPM shortcodes.
|
880 |
+
* */
|
881 |
+
|
882 |
+
add_filter('sgo_javascript_combine_excluded_inline_content', function ( $excluded_scripts ) {
|
883 |
+
$excluded_scripts[] = 'wpmFunctionExists';
|
884 |
+
return $excluded_scripts;
|
885 |
+
});
|
886 |
+
|
887 |
+
/**
|
888 |
+
* SGO's defer feature doesn't queue jQuery correctly on some pages,
|
889 |
+
* leading to errors "jQuery not defined" errors on several pages
|
890 |
+
* and thus breaking tracking in those cases.
|
891 |
+
*
|
892 |
+
* Therefore, we need to exclude jquery-core from deferring.
|
893 |
+
* */
|
894 |
+
|
895 |
+
add_filter('sgo_js_async_exclude', function ( $excludes ) {
|
896 |
+
$excludes[] = 'jquery-core';
|
897 |
+
return $excludes;
|
898 |
+
});
|
899 |
+
}
|
900 |
+
|
901 |
+
/**
|
902 |
+
* Litespeed
|
903 |
+
*/
|
904 |
+
|
905 |
+
if ($this->is_litespeed_active()) {
|
906 |
+
add_filter('litespeed_optimize_js_excludes', function ( $excludes ) {
|
907 |
+
if (is_array($excludes)) {
|
908 |
+
$excludes[] = 'wpmFunctionExists';
|
909 |
+
}
|
910 |
+
|
911 |
+
return $excludes;
|
912 |
+
});
|
913 |
+
}
|
914 |
+
}
|
915 |
+
|
916 |
+
public function enable_compatibility_mode() {
|
917 |
+
|
918 |
+
$this->compatibility_mode_yoast_seo();
|
919 |
+
|
920 |
+
$this->compatibility_mode_prevent_third_party_js_optimization();
|
921 |
+
}
|
922 |
+
|
923 |
+
protected function compatibility_mode_prevent_third_party_js_optimization() {
|
924 |
+
|
925 |
+
if ($this->is_wp_rocket_active()) {
|
926 |
+
$this->disable_wp_rocket_js_optimization();
|
927 |
+
}
|
928 |
+
|
929 |
+
if ($this->is_flying_press_active()) {
|
930 |
+
$this->disable_flying_press_js_optimization();
|
931 |
+
}
|
932 |
+
|
933 |
+
if ($this->is_optimocha_active()) {
|
934 |
+
$this->disable_optimocha_js_optimization();
|
935 |
+
}
|
936 |
+
|
937 |
+
if ($this->is_wp_optimize_active()) {
|
938 |
+
$this->disable_wp_optimize_js_optimization();
|
939 |
+
}
|
940 |
+
|
941 |
+
if ($this->is_async_javascript_active()) {
|
942 |
+
$this->disable_async_javascript_js_optimization();
|
943 |
+
}
|
944 |
+
|
945 |
+
if ($this->is_sg_optimizer_active()) {
|
946 |
+
$this->disable_sg_optimizer_js_optimization();
|
947 |
+
}
|
948 |
+
|
949 |
+
if ($this->is_litespeed_active()) {
|
950 |
+
$this->disable_litespeed_js_optimization();
|
951 |
+
}
|
952 |
+
|
953 |
+
if ($this->is_autoptimize_active()) {
|
954 |
+
$this->disable_autoptimze_js_optimization();
|
955 |
+
}
|
956 |
+
}
|
957 |
+
|
958 |
+
protected function disable_sg_optimizer_js_optimization() {
|
959 |
+
|
960 |
+
add_filter('sgo_javascript_combine_excluded_inline_content', [$this, 'sg_optimizer_js_exclude_combine_inline_content']);
|
961 |
+
add_filter('sgo_javascript_combine_exclude', [$this, 'sgo_javascript_combine_exclude_move_after']);
|
962 |
+
add_filter('sgo_javascript_combine_exclude_move_after', [$this, 'sgo_javascript_combine_exclude_move_after']);
|
963 |
+
add_filter('sgo_js_minify_exclude', [$this, 'sg_optimizer_js_minify_exclude']);
|
964 |
+
add_filter('sgo_js_async_exclude', [$this, 'sgo_javascript_combine_exclude_move_after']);
|
965 |
+
}
|
966 |
+
|
967 |
+
protected function disable_litespeed_js_optimization() {
|
968 |
+
add_filter('litespeed_optimize_js_excludes', [$this, 'litespeed_optimize_js_excludes']);
|
969 |
+
add_filter('litespeed_optm_js_defer_exc', [$this, 'litespeed_cache_js_defer_exc']);
|
970 |
+
add_filter('litespeed_optm_cssjs', [$this, 'litespeed_optm_cssjs']);
|
971 |
+
add_filter('option_litespeed.conf.optm-js_inline_defer', [$this, 'disable_litespeed_js_inline_after_dom']);
|
972 |
+
}
|
973 |
+
|
974 |
+
protected function disable_autoptimze_js_optimization() {
|
975 |
+
add_filter('autoptimize_filter_js_consider_minified', [$this, 'autoptimize_filter_js_consider_minified']);
|
976 |
+
add_filter('autoptimize_filter_js_dontmove', [$this, 'autoptimize_filter_js_dontmove']);
|
977 |
+
}
|
978 |
+
|
979 |
+
protected function disable_wp_optimize_js_optimization() {
|
980 |
+
// add_filter('wpo_minify_inline_js', '__return_false');
|
981 |
+
add_filter('wp-optimize-minify-default-exclusions', [$this, 'wp_optimize_minify_default_exclusions']);
|
982 |
+
}
|
983 |
+
|
984 |
+
protected function disable_async_javascript_js_optimization() {
|
985 |
+
add_filter('option_aj_plugin_exclusions', function ( $options ) {
|
986 |
+
|
987 |
+
if (!is_array($options)) {
|
988 |
+
$options = [];
|
989 |
+
}
|
990 |
+
|
991 |
+
return array_unique(array_merge($options, [
|
992 |
+
'woocommerce-google-adwords-conversion-tracking-tag',
|
993 |
+
'woopt-pixel-manager-pro',
|
994 |
+
'woocommerce-pixel-manager',
|
995 |
+
'woocommerce-pixel-manager-pro',
|
996 |
+
]));
|
997 |
+
});
|
998 |
+
}
|
999 |
+
|
1000 |
+
protected function disable_optimocha_js_optimization() {
|
1001 |
+
add_filter('option_sbp_options', function ( $options ) {
|
1002 |
+
|
1003 |
+
if (isset($options['js_exclude'])) {
|
1004 |
+
$options['js_exclude'] = $options['js_exclude'] . PHP_EOL . implode(PHP_EOL, $this->get_wpm_script_identifiers());
|
1005 |
+
$js_include = explode(PHP_EOL, $options['js_include']);
|
1006 |
+
$js_include = array_filter($js_include, function ( $string ) {
|
1007 |
+
foreach ($this->get_wpm_script_identifiers() as $value) {
|
1008 |
+
if (strpos($string, $value) !== false) {
|
1009 |
+
return false;
|
1010 |
+
}
|
1011 |
+
}
|
1012 |
+
|
1013 |
+
return true;
|
1014 |
+
});
|
1015 |
+
$options['js_include'] = implode(PHP_EOL, $js_include);
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
return $options;
|
1019 |
+
});
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
protected function disable_flying_press_js_optimization() {
|
1023 |
+
add_filter('pre_update_option_FLYING_PRESS_CONFIG', function ( $options ) {
|
1024 |
+
|
1025 |
+
if (isset($options['js_defer_excludes'])) {
|
1026 |
+
$options['js_defer_excludes'] = array_unique(array_merge($options['js_defer_excludes'], $this->get_wpm_script_identifiers()));
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
return $options;
|
1030 |
+
});
|
1031 |
+
|
1032 |
+
add_filter('option_FLYING_PRESS_CONFIG', function ( $options ) {
|
1033 |
+
|
1034 |
+
if (isset($options['js_defer_excludes'])) {
|
1035 |
+
$options['js_defer_excludes'] = array_unique(array_merge($options['js_defer_excludes'], $this->get_wpm_script_identifiers()));
|
1036 |
+
}
|
1037 |
+
return $options;
|
1038 |
+
});
|
1039 |
+
|
1040 |
+
// Make sure to never delay JS until interaction
|
1041 |
+
// if ($this->is_flying_press_active()) {
|
1042 |
+
// add_filter('option_FLYING_PRESS_CONFIG', function ( $options ) {
|
1043 |
+
// if (isset($options['js_interaction'])) {
|
1044 |
+
// $options['js_interaction'] = false;
|
1045 |
+
// }
|
1046 |
+
// return $options;
|
1047 |
+
// });
|
1048 |
+
// }
|
1049 |
+
}
|
1050 |
+
|
1051 |
+
protected function disable_wp_rocket_js_optimization() {
|
1052 |
+
// for testing you need to clear the WP Rocket cache, only then the filters run
|
1053 |
+
$this->exclude_inline_scripts_from_wp_rocket_using_options();
|
1054 |
+
add_filter('rocket_delay_js_exclusions', [$this, 'add_wp_rocket_exclusions']);
|
1055 |
+
add_filter('rocket_defer_inline_exclusions', [$this, 'add_wp_rocket_exclusions']);
|
1056 |
+
add_filter('rocket_exclude_defer_js', [$this, 'add_wp_rocket_exclusions']);
|
1057 |
+
add_filter('rocket_exclude_js', [$this, 'add_wp_rocket_exclusions']);
|
1058 |
+
add_filter('rocket_minify_excluded_external_js', [$this, 'add_wp_rocket_exclusions']);
|
1059 |
+
add_filter('rocket_excluded_inline_js_content', [$this, 'add_wp_rocket_exclusions']);
|
1060 |
+
}
|
1061 |
+
|
1062 |
+
public function compatibility_mode_yoast_seo() {
|
1063 |
+
|
1064 |
+
if ($this->is_yoast_seo_active() && isset($this->options['facebook']['microdata']) && $this->options['facebook']['microdata']) {
|
1065 |
+
add_filter('option_wpseo_social', [$this, 'disable_yoast_seo_facebook_social']);
|
1066 |
+
}
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
private function get_wpm_script_identifiers() {
|
1070 |
+
return [
|
1071 |
+
'optimize.js',
|
1072 |
+
'googleoptimize.com/optimize.js',
|
1073 |
+
'jquery',
|
1074 |
+
'jQuery',
|
1075 |
+
'jQuery.min.js',
|
1076 |
+
'jquery.js',
|
1077 |
+
'jquery.min.js',
|
1078 |
+
'wpm',
|
1079 |
+
'wpm-js',
|
1080 |
+
'wpmDataLayer',
|
1081 |
+
'window.wpmDataLayer',
|
1082 |
+
'wpm.js',
|
1083 |
+
'wpm.min.js',
|
1084 |
+
'wpm__premium_only.js',
|
1085 |
+
'wpm__premium_only.min.js',
|
1086 |
+
'wpm-public.p1.min.js',
|
1087 |
+
'wpm-public__premium_only.p1.min.js',
|
1088 |
+
'polyfill-io',
|
1089 |
+
'polyfill.min.js',
|
1090 |
+
// 'facebook.js',
|
1091 |
+
// 'facebook.min.js',
|
1092 |
+
// 'facebook__premium_only.js',
|
1093 |
+
// 'facebook__premium_only.min.js',
|
1094 |
+
// 'google-ads.js',
|
1095 |
+
// 'google-ads.min.js',
|
1096 |
+
// 'google-ga-4-eec__premium_only.js',
|
1097 |
+
// 'google-ga-4-eec__premium_only.min.js',
|
1098 |
+
// 'google-ga-us-eec__premium_only.js',
|
1099 |
+
// 'google-ga-us-eec__premium_only.min.js',
|
1100 |
+
// 'google__premium_only.js',
|
1101 |
+
// 'google__premium_only.min.js',
|
1102 |
+
'window.dataLayer',
|
1103 |
+
// '/gtag/js',
|
1104 |
+
'gtag',
|
1105 |
+
// '/gtag/js',
|
1106 |
+
// 'gtag(',
|
1107 |
+
'gtm.js',
|
1108 |
+
// '/gtm-',
|
1109 |
+
// 'GTM-',
|
1110 |
+
// 'fbq(',
|
1111 |
+
'fbq',
|
1112 |
+
'fbevents.js',
|
1113 |
+
// 'twq(',
|
1114 |
+
'twq',
|
1115 |
+
// 'e.twq',
|
1116 |
+
'static.ads-twitter.com/uwt.js',
|
1117 |
+
'platform.twitter.com/widgets.js',
|
1118 |
+
'uetq',
|
1119 |
+
'ttq',
|
1120 |
+
'events.js',
|
1121 |
+
'snaptr',
|
1122 |
+
'scevent.min.js',
|
1123 |
+
];
|
1124 |
+
}
|
1125 |
+
|
1126 |
+
public function is_curl_active() {
|
1127 |
+
return function_exists('curl_version');
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
public function does_url_redirect( $url ) {
|
1131 |
+
|
1132 |
+
if (null !== $this->order_redirect) {
|
1133 |
+
return $this->order_redirect;
|
1134 |
+
} else {
|
1135 |
+
|
1136 |
+
$context = stream_context_create([
|
1137 |
+
'ssl' => [
|
1138 |
+
'verify_peer' => false,
|
1139 |
+
'verify_peer_name' => false,
|
1140 |
+
],
|
1141 |
+
]);
|
1142 |
+
|
1143 |
+
// $headers = get_headers($url, 1, $context);
|
1144 |
+
|
1145 |
+
$headers = $this->get_headers_with_stream_context($url, $context, 1);
|
1146 |
+
|
1147 |
+
if (!empty($headers['Location'])) {
|
1148 |
+
$this->order_redirect = true;
|
1149 |
+
return true;
|
1150 |
+
} else {
|
1151 |
+
$this->order_redirect = false;
|
1152 |
+
return false;
|
1153 |
+
}
|
1154 |
+
}
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
// https://stackoverflow.com/questions/8429342/php-get-headers-set-temporary-stream-context
|
1158 |
+
protected function get_headers_with_stream_context( $url, $context, $assoc = 0 ) {
|
1159 |
+
|
1160 |
+
$fp = @fopen($url, 'r', null, $context);
|
1161 |
+
|
1162 |
+
if (!is_bool($fp)) {
|
1163 |
+
|
1164 |
+
$metaData = stream_get_meta_data($fp);
|
1165 |
+
fclose($fp);
|
1166 |
+
|
1167 |
+
$headerLines = $metaData['wrapper_data'];
|
1168 |
+
|
1169 |
+
if (!$assoc) {
|
1170 |
+
return $headerLines;
|
1171 |
+
}
|
1172 |
+
|
1173 |
+
$headers = [];
|
1174 |
+
foreach ($headerLines as $line) {
|
1175 |
+
if (strpos($line, 'HTTP') === 0) {
|
1176 |
+
$headers[0] = $line;
|
1177 |
+
continue;
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
list($key, $value) = explode(': ', $line);
|
1181 |
+
$headers[$key] = $value;
|
1182 |
+
}
|
1183 |
+
|
1184 |
+
return $headers;
|
1185 |
+
} else {
|
1186 |
+
return [];
|
1187 |
+
}
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
public function get_redirect_url( $url ) {
|
1191 |
+
$headers = get_headers($url, 1);
|
1192 |
+
|
1193 |
+
if (!empty($headers['Location'])) {
|
1194 |
+
if (is_array($headers['Location'])) {
|
1195 |
+
return end($headers['Location']);
|
1196 |
+
} else {
|
1197 |
+
return $headers['Location'];
|
1198 |
+
}
|
1199 |
+
} else {
|
1200 |
+
return '';
|
1201 |
+
}
|
1202 |
+
}
|
1203 |
+
|
1204 |
+
// https://stackoverflow.com/a/46690009/4688612
|
1205 |
+
// public function get_last_order_id() {
|
1206 |
+
// global $wpdb;
|
1207 |
+
// $statuses = array_keys(wc_get_order_statuses());
|
1208 |
+
// $statuses = implode("','", $statuses);
|
1209 |
+
//
|
1210 |
+
// // Getting last Order ID (max value)
|
1211 |
+
// $results = $wpdb->get_col("
|
1212 |
+
// SELECT MAX(ID) FROM {$wpdb->prefix}posts
|
1213 |
+
// WHERE post_type LIKE 'shop_order'
|
1214 |
+
// AND post_status IN ('$statuses')
|
1215 |
+
// ");
|
1216 |
+
// error_log(reset($results));
|
1217 |
+
// return reset($results);
|
1218 |
+
// }
|
1219 |
+
|
1220 |
+
// https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query#usage
|
1221 |
+
public function get_last_order_id() {
|
1222 |
+
|
1223 |
+
$orders = wc_get_orders([
|
1224 |
+
'limit' => 1,
|
1225 |
+
'orderby' => 'date',
|
1226 |
+
'order' => 'DESC',
|
1227 |
+
'return' => 'ids',
|
1228 |
+
'post_type' => 'shop_order'
|
1229 |
+
]);
|
1230 |
+
|
1231 |
+
// error_log(reset($orders));
|
1232 |
+
|
1233 |
+
return reset($orders);
|
1234 |
+
}
|
1235 |
+
|
1236 |
+
public function get_last_order_url() {
|
1237 |
+
$last_order_id = $this->get_last_order_id();
|
1238 |
+
$last_order = wc_get_order($last_order_id);
|
1239 |
+
|
1240 |
+
if ($last_order) {
|
1241 |
+
return $last_order->get_checkout_order_received_url();
|
1242 |
+
} else {
|
1243 |
+
return '';
|
1244 |
+
}
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
public function does_one_order_exist() {
|
1248 |
+
if ($this->get_last_order_id()) {
|
1249 |
+
return true;
|
1250 |
+
} else {
|
1251 |
+
return false;
|
1252 |
+
}
|
1253 |
+
}
|
1254 |
+
}
|
classes/admin/class-launch-deal.php
DELETED
@@ -1,146 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Admin;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Launch_Deal
|
10 |
-
{
|
11 |
-
|
12 |
-
public function __construct()
|
13 |
-
{
|
14 |
-
// $options = get_option('wooptpm_launch_deal');
|
15 |
-
// $options['dismissed'] = false;
|
16 |
-
// $options['later'] = false;
|
17 |
-
// $options['later_date'] = '';
|
18 |
-
// update_option('wooptpm_launch_deal',$options);
|
19 |
-
|
20 |
-
// ask for a rating in a plugin notice
|
21 |
-
|
22 |
-
// front-end script
|
23 |
-
add_action('admin_enqueue_scripts', [$this, 'wooptpm_launch_deal_front_end_script']);
|
24 |
-
// back-end processor
|
25 |
-
add_action('wp_ajax_wooptpm_launch_deal_notice_handler', [$this, 'ajax_launch_deal_notice_handler']);
|
26 |
-
|
27 |
-
// display the notification
|
28 |
-
add_action('admin_notices', [$this, 'launch_deal_notification']);
|
29 |
-
}
|
30 |
-
|
31 |
-
public function launch_deal_notification()
|
32 |
-
{
|
33 |
-
$wooptpm_launch_deal = get_option('wooptpm_launch_deal');
|
34 |
-
|
35 |
-
if ($wooptpm_launch_deal['eligible'] === true && $wooptpm_launch_deal['dismissed'] === false) {
|
36 |
-
if ($wooptpm_launch_deal['later'] === true) {
|
37 |
-
|
38 |
-
if (strtotime("now") >= $wooptpm_launch_deal['later_date']) {
|
39 |
-
// error_log('lat');
|
40 |
-
$this->wooptpm_pro_launch_deal();
|
41 |
-
}
|
42 |
-
|
43 |
-
} else {
|
44 |
-
$this->wooptpm_pro_launch_deal();
|
45 |
-
}
|
46 |
-
}
|
47 |
-
}
|
48 |
-
|
49 |
-
public function wooptpm_launch_deal_front_end_script()
|
50 |
-
{
|
51 |
-
wp_enqueue_script('wooptpm-launch-deal', plugin_dir_url(__DIR__) . '../js/admin/launch-deal.js', ['jquery'], WGACT_CURRENT_VERSION, true);
|
52 |
-
}
|
53 |
-
|
54 |
-
// server side php ajax handler for the admin rating notice
|
55 |
-
public function ajax_launch_deal_notice_handler()
|
56 |
-
{
|
57 |
-
|
58 |
-
$set = $_POST['set'];
|
59 |
-
|
60 |
-
$options = get_option('wooptpm_launch_deal');
|
61 |
-
|
62 |
-
if ('launch-deal-maybe-later' === $set) {
|
63 |
-
|
64 |
-
// error_log('later');
|
65 |
-
// error_log('later_date: ' . strtotime("+12 day"));
|
66 |
-
$options['later'] = true;
|
67 |
-
$options['later_date'] = strtotime("+12 day");
|
68 |
-
update_option('wooptpm_launch_deal', $options);
|
69 |
-
|
70 |
-
} elseif ('launch-deal-dismiss' === $set) {
|
71 |
-
|
72 |
-
$options['dismissed'] = true;
|
73 |
-
// error_log('saving dismissed');
|
74 |
-
update_option('wooptpm_launch_deal', $options);
|
75 |
-
}
|
76 |
-
|
77 |
-
wp_die(); // this is required to terminate immediately and return a proper response
|
78 |
-
}
|
79 |
-
|
80 |
-
public function wooptpm_pro_launch_deal()
|
81 |
-
{
|
82 |
-
?>
|
83 |
-
<div class="notice notice-success is-dismissible launch-deal-notification">
|
84 |
-
<div style="color:#02830b">
|
85 |
-
|
86 |
-
<div id="party" style="letter-spacing: 20px;margin-top: 8px; margin-bottom: 0px"></div>
|
87 |
-
<script>
|
88 |
-
jQuery(window).load(function () {
|
89 |
-
|
90 |
-
let dots = document.getElementById('party');
|
91 |
-
|
92 |
-
let savedContent;
|
93 |
-
|
94 |
-
let repetitions = dots.parentNode.getBoundingClientRect().width / 33
|
95 |
-
for (let i = 0; i < repetitions; i++) {
|
96 |
-
savedContent = dots.innerHTML;
|
97 |
-
dots.innerHTML += '🎉';
|
98 |
-
}
|
99 |
-
dots.innerHTML = savedContent;
|
100 |
-
dots.style.visibility = 'visible';
|
101 |
-
})
|
102 |
-
</script>
|
103 |
-
<br>
|
104 |
-
<div>
|
105 |
-
<?php
|
106 |
-
_e('I am super happy and excited to announce our <a href="https://woopt.com/launch-deal-8a63336b/" target="_blank">special deal</a> for the launch of the <a href="https://woopt.com/" target="_blank">pro version</a> of the <b>woopt WooCommerce Pixel Manager Plugin</b> (formerly known as the <b>WooCommmerce Google Ads Conversion Tracking Plugin</b>).', 'woocommerce-google-adwords-conversion-tracking-tag');
|
107 |
-
|
108 |
-
|
109 |
-
?>
|
110 |
-
|
111 |
-
</div>
|
112 |
-
<br>
|
113 |
-
<?php _e('Because you are an existing user of this plugin you are eligible to receive a generous discount if you chose to participate in the launch deal. After all, you helped to shape the plugin into what it is today. Go ahead and have a look.', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
114 |
-
<div>
|
115 |
-
|
116 |
-
</div>
|
117 |
-
<br>
|
118 |
-
<div>- Aleksandar, CTO of woopt</div>
|
119 |
-
</div>
|
120 |
-
<div style="font-weight: bold;">
|
121 |
-
|
122 |
-
<ul style="list-style-type: disc ;padding-left:20px">
|
123 |
-
<li>
|
124 |
-
<a id="launch-deal-take-me-to-the-deal" href="https://woopt.com/launch-deal-8a63336b/"
|
125 |
-
target="_blank">
|
126 |
-
<?php esc_html_e('Take me to the deal!', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
127 |
-
</a>
|
128 |
-
</li>
|
129 |
-
<li>
|
130 |
-
<a id="launch-deal-maybe-later" href="#">
|
131 |
-
<?php esc_html_e('Maybe later', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
132 |
-
</a>
|
133 |
-
</li>
|
134 |
-
<li>
|
135 |
-
<a id="launch-deal-dismiss" href="#">
|
136 |
-
<?php esc_html_e('Not interested. Close this message.', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
137 |
-
</a>
|
138 |
-
</li>
|
139 |
-
</ul>
|
140 |
-
</div>
|
141 |
-
|
142 |
-
|
143 |
-
</div>
|
144 |
-
<?php
|
145 |
-
}
|
146 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/admin/class-notifications.php
CHANGED
@@ -3,181 +3,186 @@
|
|
3 |
namespace WCPM\Classes\Admin;
|
4 |
|
5 |
if (!defined('ABSPATH')) {
|
6 |
-
|
7 |
}
|
8 |
|
9 |
-
class Notifications
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
3 |
namespace WCPM\Classes\Admin;
|
4 |
|
5 |
if (!defined('ABSPATH')) {
|
6 |
+
exit; // Exit if accessed directly
|
7 |
}
|
8 |
|
9 |
+
class Notifications {
|
10 |
+
private $documentation;
|
11 |
+
|
12 |
+
public function __construct() {
|
13 |
+
$this->documentation = new Documentation();
|
14 |
+
}
|
15 |
+
|
16 |
+
public function wp_rocket_js_concatenation_error() {
|
17 |
+
?>
|
18 |
+
<div class="notice notice-error wpm-wp-rocket-js-concatenation-error">
|
19 |
+
<p style="color:red;font-weight: bold">
|
20 |
+
<span>
|
21 |
+
<?php
|
22 |
+
esc_html_e('We detected that the WP Rocket JavaScript concatenation function has been enabled. This function has been proven to be incompatible with the WooCommerce Google Ads Conversion Tracking plugin.
|
23 |
+
Please turn off the WP Rocket JavaScript concatenation.', 'woocommerce-google-adwords-conversion-tracking-tag')
|
24 |
+
?>
|
25 |
+
</span><br>
|
26 |
+
</p>
|
27 |
+
<p>
|
28 |
+
<a href="<?php echo esc_url($this->documentation->get_link('wp-rocket-javascript-concatenation')); ?>"
|
29 |
+
target="_blank"
|
30 |
+
style="font-weight: bold;color:blue">
|
31 |
+
<?php esc_html_e('Learn more', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
32 |
+
</a>
|
33 |
+
</p>
|
34 |
+
<p>
|
35 |
+
<a href="<?php echo esc_url(get_admin_url() . 'options-general.php?page=wprocket#file_optimization'); ?>"
|
36 |
+
style="font-weight: bold;color:blue">
|
37 |
+
<?php esc_html_e('Open the WP Rocket JavaScript concatenation settings', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
38 |
+
</a>
|
39 |
+
</p>
|
40 |
+
<p>
|
41 |
+
<div id="wpm-wp-rocket-js-concatenation-disable" class="button button-primary">
|
42 |
+
<?php esc_html_e('Click here to simply turn off the WP Rocket JavaScript concatenation', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
43 |
+
</div>
|
44 |
+
</p>
|
45 |
+
<p>
|
46 |
+
<div id="wpm-dismiss-wp-rocket-js-concatenation-error" class="button" style="white-space:normal;">
|
47 |
+
<?php esc_html_e('Click here to dismiss this warning forever.', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
48 |
+
<br>
|
49 |
+
<?php esc_html_e('And I swear that I triple checked that the visitor and conversion tracking is working just fine and that I won\'t ask for support as long as the WP Rocket JavaScript concatenation is turned on!', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
50 |
+
|
51 |
+
</div>
|
52 |
+
</p>
|
53 |
+
|
54 |
+
</div>
|
55 |
+
<?php
|
56 |
+
}
|
57 |
+
|
58 |
+
public function litespeed_js_defer_error() {
|
59 |
+
?>
|
60 |
+
<div class="notice notice-error wpm-litespeed-inline-js-dom-ready-error">
|
61 |
+
<p style="color:red;font-weight: bold">
|
62 |
+
<span>
|
63 |
+
<?php
|
64 |
+
esc_html_e('We detected that the LiteSpeed Inline JavaScript After DOM Ready function has been enabled. This function has been proven to be incompatible with the WooCommerce Google Ads Conversion Tracking plugin.
|
65 |
+
Please turn off the LiteSpeed Inline JavaScript After DOM Ready function.', 'woocommerce-google-adwords-conversion-tracking-tag')
|
66 |
+
?>
|
67 |
+
</span><br>
|
68 |
+
</p>
|
69 |
+
<p>
|
70 |
+
<a href="<?php echo esc_url($this->documentation->get_link('litespeed-cache-inline-javascript-after-dom-ready')); ?>"
|
71 |
+
target="_blank"
|
72 |
+
style="font-weight: bold;color:blue">
|
73 |
+
<?php esc_html_e('Learn more', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
74 |
+
</a>
|
75 |
+
</p>
|
76 |
+
<p>
|
77 |
+
<a href="<?php echo esc_url(get_admin_url() . 'admin.php?page=litespeed-page_optm'); ?>"
|
78 |
+
style="font-weight: bold;color:blue">
|
79 |
+
<?php esc_html_e('Open the LiteSpeed Inline JavaScript After DOM Ready settings', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
80 |
+
</a>
|
81 |
+
</p>
|
82 |
+
<p>
|
83 |
+
<div id="wpm-litespeed-inline-js-dom-ready-disable" class="button button-primary">
|
84 |
+
<?php esc_html_e('Click here to simply turn off LiteSpeed Inline JavaScript After DOM Ready', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
85 |
+
</div>
|
86 |
+
</p>
|
87 |
+
<p>
|
88 |
+
<div id="wpm-dismiss-litespeed-inline-js-dom-ready-error" class="button" style="white-space:normal;">
|
89 |
+
<?php esc_html_e('Click here to dismiss this warning forever.', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
90 |
+
<br>
|
91 |
+
<?php esc_html_e('And I swear that I triple checked that the visitor and conversion tracking is working just fine and that I won\'t ask for support as long as the LiteSpeed Inline JavaScript After DOM Ready is turned on!', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
92 |
+
|
93 |
+
</div>
|
94 |
+
</p>
|
95 |
+
|
96 |
+
</div>
|
97 |
+
<?php
|
98 |
+
}
|
99 |
+
|
100 |
+
public function paypal_standard_active_warning() {
|
101 |
+
?>
|
102 |
+
<div class="notice notice-error wpm-paypal-standard-error">
|
103 |
+
<p style="color:red;">
|
104 |
+
<span>
|
105 |
+
|
106 |
+
<?php
|
107 |
+
esc_html_e('The WooCommerce Pixel Manager plugin detected that the PayPal standard payment gateway is active. The PayPal standard payment gateway is an off-site payment gateway which impairs conversion tracking significantly. Please switch to an on-site payment gateway as soon as possible in order to increase your conversion tracking accuracy.', 'woocommerce-google-adwords-conversion-tracking-tag');
|
108 |
+
?>
|
109 |
+
</span><br>
|
110 |
+
</p>
|
111 |
+
<p>
|
112 |
+
<a href="<?php echo esc_url($this->documentation->get_link('payment-gateways')); ?>"
|
113 |
+
target="_blank">
|
114 |
+
<?php esc_html_e('Learn more', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
115 |
+
</a>
|
116 |
+
</p>
|
117 |
+
<p>
|
118 |
+
<a href="<?php echo esc_url(get_admin_url() . 'admin.php?page=wc-settings&tab=checkout'); ?>">
|
119 |
+
<?php esc_html_e('Open the WooCommerce payment methods settings', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
120 |
+
</a>
|
121 |
+
</p>
|
122 |
+
|
123 |
+
<div style=" margin-bottom: 10px; display: flex; justify-content: space-between">
|
124 |
+
|
125 |
+
<div id="wpm-paypal-standard-error-dismissal-button" class="button" style="white-space:normal;">
|
126 |
+
<?php esc_html_e('Click here to dismiss this warning forever', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
127 |
+
</div>
|
128 |
+
<div style="white-space:normal; bottom:0; right: 0; margin-bottom: 0; margin-right: 5px;align-self: flex-end;">
|
129 |
+
<a href="<?php echo esc_url(( new Documentation() )->get_link('the_dismiss_button_doesnt_work_why')); ?>"
|
130 |
+
target="_blank">
|
131 |
+
<?php esc_html_e('If the dismiss button is not working, here\'s why >>', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
132 |
+
</a>
|
133 |
+
</div>
|
134 |
+
</div>
|
135 |
+
|
136 |
+
</div>
|
137 |
+
<?php
|
138 |
+
}
|
139 |
+
|
140 |
+
public function plugin_is_incompatible( $name, $version, $slug, $link = '', $wpm_doc_link = '' ) {
|
141 |
+
?>
|
142 |
+
<div class="notice notice-error <?php echo esc_js($slug); ?>-incompatible-plugin-error">
|
143 |
+
<p>
|
144 |
+
<span>
|
145 |
+
<?php esc_html_e('The following plugin is not compatible with the WooCommerce Pixel Manager: ', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
146 |
+
</span>
|
147 |
+
<span>
|
148 |
+
<a href="<?php echo esc_url($link); ?>" target="_blank">
|
149 |
+
<?php echo esc_js($name); ?>
|
150 |
+
</a>
|
151 |
+
(<?php esc_html_e('Version', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>: <?php echo esc_js($version); ?>)
|
152 |
+
</span>
|
153 |
+
<br>
|
154 |
+
<span>
|
155 |
+
|
156 |
+
<?php esc_html_e('Please disable the plugin as soon as possible.', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
157 |
+
</span><br>
|
158 |
+
<span>
|
159 |
+
|
160 |
+
<?php esc_html_e('Find more information about the the reason in our documentation: ', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
161 |
+
</span><a
|
162 |
+
href="<?php echo esc_url($wpm_doc_link); ?>"
|
163 |
+
target="_blank">
|
164 |
+
<?php esc_html_e('Learn more', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
165 |
+
</a><br>
|
166 |
+
</p>
|
167 |
+
<p>
|
168 |
+
|
169 |
+
</p>
|
170 |
+
<div style="margin-bottom: 10px; display: flex; justify-content: space-between">
|
171 |
+
|
172 |
+
<div id="<?php echo esc_js($slug); ?>-incompatible-plugin-error-dismissal-button"
|
173 |
+
class="button incompatible-plugin-error-dismissal-button" style="white-space:normal;"
|
174 |
+
data-plugin-slug="<?php echo esc_js($slug); ?>">
|
175 |
+
<?php esc_html_e('Click here to dismiss this warning forever', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
176 |
+
</div>
|
177 |
+
<div style="white-space:normal; bottom:0; right: 0; margin-bottom: 0; margin-right: 5px;align-self: flex-end;">
|
178 |
+
<a href="<?php echo esc_url(( new Documentation() )->get_link('the_dismiss_button_doesnt_work_why')); ?>"
|
179 |
+
target="_blank">
|
180 |
+
<?php esc_html_e('If the dismiss button is not working, here\'s why >>', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
181 |
+
</a>
|
182 |
+
</div>
|
183 |
+
</div>
|
184 |
+
|
185 |
+
</div>
|
186 |
+
<?php
|
187 |
+
}
|
188 |
+
}
|
classes/admin/class-validations.php
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WCPM\Classes\Admin;
|
4 |
+
|
5 |
+
class Validations {
|
6 |
+
|
7 |
+
public function is_gads_conversion_id( $string ) {
|
8 |
+
if (empty($string)) {
|
9 |
+
return true;
|
10 |
+
}
|
11 |
+
|
12 |
+
$re = '/^\d{8,11}$/m';
|
13 |
+
|
14 |
+
return $this->validate_with_regex($re, $string);
|
15 |
+
}
|
16 |
+
|
17 |
+
public function is_hotjar_site_id( $string ) {
|
18 |
+
if (empty($string)) {
|
19 |
+
return true;
|
20 |
+
}
|
21 |
+
|
22 |
+
$re = '/^\d{6,9}$/m';
|
23 |
+
|
24 |
+
return $this->validate_with_regex($re, $string);
|
25 |
+
}
|
26 |
+
|
27 |
+
public function is_facebook_capi_token( $string ) {
|
28 |
+
if (empty($string)) {
|
29 |
+
return true;
|
30 |
+
}
|
31 |
+
|
32 |
+
$re = '/^[a-zA-Z\d_-]{150,250}$/m';
|
33 |
+
|
34 |
+
return $this->validate_with_regex($re, $string);
|
35 |
+
}
|
36 |
+
|
37 |
+
public function is_gads_conversion_label( $string ) {
|
38 |
+
if (empty($string)) {
|
39 |
+
return true;
|
40 |
+
}
|
41 |
+
|
42 |
+
$re = '/^[-a-zA-Z_0-9]{17,20}$/m';
|
43 |
+
|
44 |
+
return $this->validate_with_regex($re, $string);
|
45 |
+
}
|
46 |
+
|
47 |
+
public function is_gads_aw_merchant_id( $string ) {
|
48 |
+
if (empty($string)) {
|
49 |
+
return true;
|
50 |
+
}
|
51 |
+
|
52 |
+
$re = '/^\d{7,10}$/m';
|
53 |
+
|
54 |
+
return $this->validate_with_regex($re, $string);
|
55 |
+
}
|
56 |
+
|
57 |
+
public function is_google_optimize_measurement_id( $string ) {
|
58 |
+
if (empty($string)) {
|
59 |
+
return true;
|
60 |
+
}
|
61 |
+
|
62 |
+
$re = '/^(GTM|OPT)-[A-Z0-9]{6,8}$/m';
|
63 |
+
|
64 |
+
return $this->validate_with_regex($re, $string);
|
65 |
+
}
|
66 |
+
|
67 |
+
public function is_google_analytics_universal_property_id( $string ) {
|
68 |
+
if (empty($string)) {
|
69 |
+
return true;
|
70 |
+
}
|
71 |
+
|
72 |
+
$re = '/^UA-\d{6,10}-\d{1,2}$/m';
|
73 |
+
|
74 |
+
return $this->validate_with_regex($re, $string);
|
75 |
+
}
|
76 |
+
|
77 |
+
public function is_google_analytics_4_measurement_id( $string ) {
|
78 |
+
if (empty($string)) {
|
79 |
+
return true;
|
80 |
+
}
|
81 |
+
|
82 |
+
$re = '/^G-[A-Z0-9]{10,12}$/m';
|
83 |
+
|
84 |
+
return $this->validate_with_regex($re, $string);
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
public function is_google_analytics_4_api_secret( $string ) {
|
89 |
+
if (empty($string)) {
|
90 |
+
return true;
|
91 |
+
}
|
92 |
+
|
93 |
+
$re = '/^[a-zA-Z\d_-]{18,26}$/m';
|
94 |
+
|
95 |
+
return $this->validate_with_regex($re, $string);
|
96 |
+
}
|
97 |
+
|
98 |
+
public function is_facebook_pixel_id( $string ) {
|
99 |
+
if (empty($string)) {
|
100 |
+
return true;
|
101 |
+
}
|
102 |
+
|
103 |
+
$re = '/^\d{14,16}$/m';
|
104 |
+
|
105 |
+
return $this->validate_with_regex($re, $string);
|
106 |
+
}
|
107 |
+
|
108 |
+
public function is_bing_uet_tag_id( $string ) {
|
109 |
+
if (empty($string)) {
|
110 |
+
return true;
|
111 |
+
}
|
112 |
+
|
113 |
+
$re = '/^\d{7,9}$/m';
|
114 |
+
|
115 |
+
return $this->validate_with_regex($re, $string);
|
116 |
+
}
|
117 |
+
|
118 |
+
public function is_twitter_pixel_id( $string ) {
|
119 |
+
if (empty($string)) {
|
120 |
+
return true;
|
121 |
+
}
|
122 |
+
|
123 |
+
$re = '/^[a-z0-9]{5,7}$/m';
|
124 |
+
|
125 |
+
return $this->validate_with_regex($re, $string);
|
126 |
+
}
|
127 |
+
|
128 |
+
public function is_pinterest_pixel_id( $string ) {
|
129 |
+
if (empty($string)) {
|
130 |
+
return true;
|
131 |
+
}
|
132 |
+
|
133 |
+
$re = '/^\d{13}$/m';
|
134 |
+
|
135 |
+
return $this->validate_with_regex($re, $string);
|
136 |
+
}
|
137 |
+
|
138 |
+
public function is_snapchat_pixel_id( $string ) {
|
139 |
+
if (empty($string)) {
|
140 |
+
return true;
|
141 |
+
}
|
142 |
+
|
143 |
+
$re = '/^[a-z0-9\-]*$/m';
|
144 |
+
|
145 |
+
return $this->validate_with_regex($re, $string);
|
146 |
+
}
|
147 |
+
|
148 |
+
public function is_tiktok_pixel_id( $string ) {
|
149 |
+
if (empty($string)) {
|
150 |
+
return true;
|
151 |
+
}
|
152 |
+
|
153 |
+
$re = '/^[A-Z0-9]{20,20}$/m';
|
154 |
+
|
155 |
+
return $this->validate_with_regex($re, $string);
|
156 |
+
}
|
157 |
+
|
158 |
+
public function validate_with_regex( $re, $string ) {
|
159 |
+
preg_match_all($re, $string, $matches, PREG_SET_ORDER, 0);
|
160 |
+
|
161 |
+
if (isset($matches[0])) {
|
162 |
+
return true;
|
163 |
+
} else {
|
164 |
+
return false;
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
classes/admin/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
classes/class-db-upgrade.php
CHANGED
@@ -6,136 +6,128 @@
|
|
6 |
namespace WCPM\Classes;
|
7 |
|
8 |
if (!defined('ABSPATH')) {
|
9 |
-
|
10 |
}
|
11 |
|
12 |
-
class Db_Upgrade
|
13 |
-
|
14 |
-
protected $options_backup_name = 'wgact_options_backup';
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
$mysql_db_version = $this->get_mysql_db_version();
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
$options_old = get_option(WPM_DB_OPTIONS_NAME);
|
38 |
|
39 |
-
|
40 |
|
41 |
-
|
42 |
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
57 |
|
58 |
-
|
59 |
-
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
$options_old = get_option(WPM_DB_OPTIONS_NAME);
|
64 |
|
65 |
-
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
83 |
-
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
$options = get_option(WPM_DB_OPTIONS_NAME);
|
88 |
|
89 |
// error_log(print_r($options,true));
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
update_option($this->options_backup_name, $options_backup);
|
140 |
-
}
|
141 |
-
}
|
6 |
namespace WCPM\Classes;
|
7 |
|
8 |
if (!defined('ABSPATH')) {
|
9 |
+
exit; // Exit if accessed directly
|
10 |
}
|
11 |
|
12 |
+
class Db_Upgrade {
|
13 |
+
protected $options_backup_name = 'wgact_options_backup';
|
|
|
14 |
|
15 |
+
public function run_options_db_upgrade() {
|
16 |
+
$mysql_db_version = $this->get_mysql_db_version();
|
|
|
17 |
|
18 |
+
// determine version and run version specific upgrade function
|
19 |
+
// check if options db version zero by looking if the old entries are still there.
|
20 |
+
if ('0' === $mysql_db_version) {
|
21 |
+
$this->up_from_zero_to_1();
|
22 |
+
}
|
23 |
|
24 |
+
if (version_compare(2, $mysql_db_version, '>')) {
|
25 |
+
$this->up_from_1_to_2();
|
26 |
+
}
|
27 |
|
28 |
+
if (version_compare(3, $mysql_db_version, '>')) {
|
29 |
+
$this->up_from_2_to_3();
|
30 |
+
}
|
31 |
+
}
|
32 |
|
33 |
+
protected function up_from_2_to_3() {
|
34 |
+
$options_old = get_option(WPM_DB_OPTIONS_NAME);
|
|
|
35 |
|
36 |
+
$this->backup_options($options_old, '2');
|
37 |
|
38 |
+
$options_new = $options_old;
|
39 |
|
40 |
+
$options_new['shop']['order_total_logic'] = $options_old['gads']['order_total_logic'];
|
41 |
|
42 |
+
$options_new['google']['ads'] = $options_old['gads'];
|
43 |
+
$options_new['google']['gtag'] = $options_old['gtag'];
|
44 |
|
45 |
|
46 |
+
unset($options_new['google']['ads']['order_total_logic']);
|
47 |
+
unset($options_new['gads']);
|
48 |
+
unset($options_new['gtag']);
|
49 |
+
unset($options_new['google']['ads']['google_business_vertical']);
|
50 |
|
51 |
+
$options_new['google']['ads']['google_business_vertical'] = 0;
|
52 |
|
53 |
+
$options_new['db_version'] = '3';
|
54 |
|
55 |
+
update_option(WPM_DB_OPTIONS_NAME, $options_new);
|
56 |
+
}
|
57 |
|
58 |
+
protected function up_from_1_to_2() {
|
59 |
+
$options_old = get_option(WPM_DB_OPTIONS_NAME);
|
|
|
60 |
|
61 |
+
$this->backup_options($options_old, '1');
|
62 |
|
63 |
+
$options_new = [
|
64 |
+
'gads' => [
|
65 |
+
'conversion_id' => $options_old['conversion_id'],
|
66 |
+
'conversion_label' => $options_old['conversion_label'],
|
67 |
+
'order_total_logic' => $options_old['order_total_logic'],
|
68 |
+
'add_cart_data' => $options_old['add_cart_data'],
|
69 |
+
'aw_merchant_id' => $options_old['aw_merchant_id'],
|
70 |
+
'product_identifier' => $options_old['product_identifier'],
|
71 |
+
],
|
72 |
+
'gtag' => [
|
73 |
+
'deactivation' => $options_old['gtag_deactivation'],
|
74 |
+
],
|
75 |
+
'db_version' => '2',
|
76 |
+
];
|
77 |
|
78 |
+
update_option(WPM_DB_OPTIONS_NAME, $options_new);
|
79 |
+
}
|
80 |
|
81 |
+
protected function get_mysql_db_version() {
|
82 |
+
$options = get_option(WPM_DB_OPTIONS_NAME);
|
|
|
83 |
|
84 |
// error_log(print_r($options,true));
|
85 |
|
86 |
+
if (( get_option('wgact_plugin_options_1') ) || ( get_option('wgact_plugin_options_2') )) {
|
87 |
+
return '0';
|
88 |
+
} elseif (array_key_exists('conversion_id', $options)) {
|
89 |
+
return '1';
|
90 |
+
} else {
|
91 |
+
return $options['db_version'];
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
public function up_from_zero_to_1() {
|
96 |
+
$option_name_old_1 = 'wgact_plugin_options_1';
|
97 |
+
$option_name_old_2 = 'wgact_plugin_options_2';
|
98 |
+
|
99 |
+
// db version place options into new array
|
100 |
+
$options = [
|
101 |
+
'conversion_id' => $this->get_option_value_v1($option_name_old_1),
|
102 |
+
'conversion_label' => $this->get_option_value_v1($option_name_old_2),
|
103 |
+
];
|
104 |
+
|
105 |
+
// store new option array into the options table
|
106 |
+
update_option(WPM_DB_OPTIONS_NAME, $options);
|
107 |
+
|
108 |
+
// delete old options
|
109 |
+
// only on single site
|
110 |
+
// we will run the multisite deletion only during uninstall
|
111 |
+
delete_option($option_name_old_1);
|
112 |
+
delete_option($option_name_old_2);
|
113 |
+
}
|
114 |
+
|
115 |
+
protected function get_option_value_v1( $option_name ) {
|
116 |
+
if (!get_option($option_name)) {
|
117 |
+
$option_value = '';
|
118 |
+
} else {
|
119 |
+
$option = get_option($option_name);
|
120 |
+
$option_value = $option['text_string'];
|
121 |
+
}
|
122 |
+
|
123 |
+
return $option_value;
|
124 |
+
}
|
125 |
+
|
126 |
+
protected function backup_options( $options, $version ) {
|
127 |
+
$options_backup = get_option($this->options_backup_name);
|
128 |
+
|
129 |
+
$options_backup[$version] = $options;
|
130 |
+
|
131 |
+
update_option($this->options_backup_name, $options_backup);
|
132 |
+
}
|
133 |
+
}
|
|
|
|
|
|
classes/class-default-options.php
CHANGED
@@ -3,112 +3,145 @@
|
|
3 |
namespace WCPM\Classes;
|
4 |
|
5 |
if (!defined('ABSPATH')) {
|
6 |
-
|
7 |
}
|
8 |
|
9 |
-
class Default_Options
|
10 |
-
{
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
99 |
|
100 |
-
|
101 |
-
{
|
102 |
-
foreach ($array_default as $key => $value) {
|
103 |
-
if (array_key_exists($key, $array_input)) {
|
104 |
-
if (is_array($value)) {
|
105 |
-
$array_input[$key] = $this->update_with_defaults($array_input[$key], $value);
|
106 |
-
}
|
107 |
-
} else {
|
108 |
-
$array_input[$key] = $value;
|
109 |
-
}
|
110 |
-
}
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
namespace WCPM\Classes;
|
4 |
|
5 |
if (!defined('ABSPATH')) {
|
6 |
+
exit; // Exit if accessed directly
|
7 |
}
|
8 |
|
9 |
+
class Default_Options {
|
|
|
10 |
|
11 |
+
// get the default options
|
12 |
+
public function get_default_options() {
|
13 |
+
// default options settings
|
14 |
+
return [
|
15 |
+
'google' => [
|
16 |
+
'ads' => [
|
17 |
+
'conversion_id' => '',
|
18 |
+
'conversion_label' => '',
|
19 |
+
'aw_merchant_id' => '',
|
20 |
+
'product_identifier' => 0,
|
21 |
+
'google_business_vertical' => 0,
|
22 |
+
'dynamic_remarketing' => 0,
|
23 |
+
'phone_conversion_number' => '',
|
24 |
+
'phone_conversion_label' => '',
|
25 |
+
'enhanced_conversions' => 0,
|
26 |
+
],
|
27 |
+
'analytics' => [
|
28 |
+
'universal' => [
|
29 |
+
'property_id' => '',
|
30 |
+
],
|
31 |
+
'ga4' => [
|
32 |
+
'measurement_id' => '',
|
33 |
+
'api_secret' => '',
|
34 |
+
],
|
35 |
+
'eec' => 0,
|
36 |
+
'link_attribution' => 0,
|
37 |
+
],
|
38 |
+
'optimize' => [
|
39 |
+
'container_id' => '',
|
40 |
+
],
|
41 |
+
'gtag' => [
|
42 |
+
'deactivation' => 0,
|
43 |
+
],
|
44 |
+
'consent_mode' => [
|
45 |
+
'active' => 0,
|
46 |
+
'regions' => [],
|
47 |
+
],
|
48 |
+
'user_id' => 0,
|
49 |
+
],
|
50 |
+
'facebook' => [
|
51 |
+
'pixel_id' => '',
|
52 |
+
'microdata' => 0,
|
53 |
+
'capi' => [
|
54 |
+
'token' => '',
|
55 |
+
'user_transparency' => [
|
56 |
+
'process_anonymous_hits' => false,
|
57 |
+
'send_additional_client_identifiers' => false,
|
58 |
+
]
|
59 |
+
]
|
60 |
+
],
|
61 |
+
'bing' => [
|
62 |
+
'uet_tag_id' => ''
|
63 |
+
],
|
64 |
+
'twitter' => [
|
65 |
+
'pixel_id' => ''
|
66 |
+
],
|
67 |
+
'pinterest' => [
|
68 |
+
'pixel_id' => ''
|
69 |
+
],
|
70 |
+
'snapchat' => [
|
71 |
+
'pixel_id' => ''
|
72 |
+
],
|
73 |
+
'tiktok' => [
|
74 |
+
'pixel_id' => ''
|
75 |
+
],
|
76 |
+
'hotjar' => [
|
77 |
+
'site_id' => ''
|
78 |
+
],
|
79 |
+
'shop' => [
|
80 |
+
'order_total_logic' => 0,
|
81 |
+
'cookie_consent_mgmt' => [
|
82 |
+
'cookiebot' => [ // This Cookiebot setting is deprecated. Not in use anymore.
|
83 |
+
'active' => 0
|
84 |
+
],
|
85 |
+
'explicit_consent' => 0,
|
86 |
+
],
|
87 |
+
'order_deduplication' => 1,
|
88 |
+
'disable_tracking_for' => [
|
89 |
+
'administrator',
|
90 |
+
'shop_manager',
|
91 |
+
],
|
92 |
+
],
|
93 |
+
'general' => [
|
94 |
+
'variations_output' => 1,
|
95 |
+
'maximum_compatibility_mode' => 0,
|
96 |
+
'pro_version_demo' => 0,
|
97 |
+
],
|
98 |
+
'db_version' => WPM_DB_VERSION,
|
99 |
+
];
|
100 |
+
}
|
101 |
|
102 |
+
public function update_with_defaults( $target_array, $default_array ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
+
// error_log(print_r($target_array, true));
|
105 |
+
|
106 |
+
// Walk through every key in the default array
|
107 |
+
foreach ($default_array as $default_key => $default_value) {
|
108 |
+
|
109 |
+
// If the target key doesn't exist yet
|
110 |
+
// copy all default values,
|
111 |
+
// including the subtree if one exists,
|
112 |
+
// into the target array.
|
113 |
+
if (!isset($target_array[$default_key])) {
|
114 |
+
$target_array[$default_key] = $default_value;
|
115 |
+
|
116 |
+
// We only want to keep going down the tree
|
117 |
+
// if the array contains more settings in an associative array,
|
118 |
+
// otherwise we keep the settings of what's in the target array.
|
119 |
+
} elseif ($this->is_associative_array($default_value)) {
|
120 |
+
|
121 |
+
$target_array[$default_key] = $this->update_with_defaults($target_array[$default_key], $default_value);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
// error_log(print_r($target_array, true));
|
126 |
+
return $target_array;
|
127 |
+
}
|
128 |
+
|
129 |
+
protected function does_contain_nested_arrays( $array ) {
|
130 |
+
|
131 |
+
foreach ($array as $key) {
|
132 |
+
if (is_array($key)) {
|
133 |
+
return true;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
protected function is_associative_array( $array ) {
|
141 |
+
if (is_array($array)) {
|
142 |
+
return ( array_values($array) !== $array );
|
143 |
+
} else {
|
144 |
+
return false;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
classes/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
classes/pixels/class-cookie-consent-management.php
CHANGED
@@ -20,125 +20,123 @@
|
|
20 |
namespace WCPM\Classes\Pixels;
|
21 |
|
22 |
if (!defined('ABSPATH')) {
|
23 |
-
|
24 |
}
|
25 |
|
26 |
-
class Cookie_Consent_Management
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
}
|
144 |
-
}
|
20 |
namespace WCPM\Classes\Pixels;
|
21 |
|
22 |
if (!defined('ABSPATH')) {
|
23 |
+
exit; // Exit if accessed directly
|
24 |
}
|
25 |
|
26 |
+
class Cookie_Consent_Management {
|
27 |
+
public $plugin_prefix;
|
28 |
+
|
29 |
+
// check if third party cookie prevention is active
|
30 |
+
public function is_cookie_prevention_active() {
|
31 |
+
$cookie_prevention = false;
|
32 |
+
|
33 |
+
// use filter to set default to activate prevention
|
34 |
+
// add_filter( 'wgact_cookie_prevention', '__return_true' );
|
35 |
+
// later, turn it off in order to allow cookies in case they have been actively approved
|
36 |
+
$cookie_prevention = apply_filters_deprecated('wgact_cookie_prevention', [$cookie_prevention], '1.10.4', 'wooptpm_cookie_prevention');
|
37 |
+
$cookie_prevention = apply_filters_deprecated('wooptpm_cookie_prevention', [$cookie_prevention], '1.13.0', 'wpm_cookie_prevention');
|
38 |
+
$cookie_prevention = apply_filters('wpm_cookie_prevention', $cookie_prevention);
|
39 |
+
|
40 |
+
// check if the Moove third party cookie prevention is on
|
41 |
+
if ($this->is_moove_cookie_prevention_active()) {
|
42 |
+
$cookie_prevention = true;
|
43 |
+
}
|
44 |
+
|
45 |
+
// check if the Cookie Notice Plugin third party cookie prevention is on
|
46 |
+
if ($this->is_cookie_notice_plugin_cookie_prevention_active()) {
|
47 |
+
$cookie_prevention = true;
|
48 |
+
}
|
49 |
+
|
50 |
+
// check if the Cookie Law Info third party cookie prevention is on
|
51 |
+
if ($this->is_cookie_law_info_cookie_prevention_active()) {
|
52 |
+
$cookie_prevention = true;
|
53 |
+
}
|
54 |
+
|
55 |
+
// check if marketing cookies have been approved by Borlabs
|
56 |
+
if ($this->check_borlabs_gave_marketing_consent()) {
|
57 |
+
$cookie_prevention = false;
|
58 |
+
}
|
59 |
+
|
60 |
+
return $cookie_prevention;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function check_borlabs_gave_marketing_consent() {
|
64 |
+
// check if Borlabs is running
|
65 |
+
if (function_exists('BorlabsCookieHelper')) {
|
66 |
+
|
67 |
+
// check if Borlabs minimum version is installed
|
68 |
+
$borlabs_info = get_file_data(ABSPATH . 'wp-content/plugins/borlabs-cookie/borlabs-cookie.php', [
|
69 |
+
'Version' => 'Version'
|
70 |
+
]);
|
71 |
+
|
72 |
+
// the minimum version I know of that supports gaveConsent('marketing') is 2.2.4
|
73 |
+
if (version_compare('2.1.0', $borlabs_info['Version'], '<=')) {
|
74 |
+
|
75 |
+
if (BorlabsCookieHelper()->gaveConsent('google-ads') || BorlabsCookieHelper()->gaveConsent('woopt-pixel-manager')) {
|
76 |
+
return true;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function set_plugin_prefix( $name ) {
|
85 |
+
$this->plugin_prefix = $name;
|
86 |
+
}
|
87 |
+
|
88 |
+
// return the cookie contents, if the cookie is set
|
89 |
+
public function get_cookie( $cookie_name ) {
|
90 |
+
|
91 |
+
$_cookie = filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
92 |
+
|
93 |
+
return $_cookie[$cookie_name] ? $_cookie[$cookie_name] : null;
|
94 |
+
}
|
95 |
+
|
96 |
+
// check if the Cookie Law Info plugin prevents third party cookies
|
97 |
+
// https://wordpress.org/plugins/cookie-law-info/
|
98 |
+
public function is_cookie_law_info_cookie_prevention_active() {
|
99 |
+
$cookie_consent_management_cookie = $this->get_cookie('cookielawinfo-checkbox-non-necessary');
|
100 |
+
|
101 |
+
if ('no' == $cookie_consent_management_cookie) {
|
102 |
+
return true;
|
103 |
+
} else {
|
104 |
+
return false;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
// check if the Cookie Notice Plugin prevents third party cookies
|
109 |
+
// https://wordpress.org/plugins/cookie-notice/
|
110 |
+
public function is_cookie_notice_plugin_cookie_prevention_active() {
|
111 |
+
$cookie_consent_management_cookie = $this->get_cookie('cookie_notice_accepted');
|
112 |
+
|
113 |
+
if ('false' == $cookie_consent_management_cookie) {
|
114 |
+
return true;
|
115 |
+
} else {
|
116 |
+
return false;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
// check if the Moove GDPR Cookie Compliance prevents third party cookies
|
121 |
+
// https://wordpress.org/plugins/gdpr-cookie-compliance/
|
122 |
+
public function is_moove_cookie_prevention_active() {
|
123 |
+
|
124 |
+
$_cookie = filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
125 |
+
|
126 |
+
if (isset($_cookie['moove_gdpr_popup'])) {
|
127 |
+
|
128 |
+
$cookie_consent_management_cookie = $_cookie['moove_gdpr_popup'];
|
129 |
+
$cookie_consent_management_cookie = json_decode(stripslashes($cookie_consent_management_cookie), true);
|
130 |
+
|
131 |
+
if (array_key_exists('thirdparty', $cookie_consent_management_cookie) && 0 == $cookie_consent_management_cookie['thirdparty']) {
|
132 |
+
// print_r( $cookie_consent_management_cookie );
|
133 |
+
return true;
|
134 |
+
} else {
|
135 |
+
return false;
|
136 |
+
}
|
137 |
+
|
138 |
+
} else {
|
139 |
+
return false;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
}
|
|
|
|
classes/pixels/class-facebook-browser-pixel.php
DELETED
@@ -1,94 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Facebook_Browser_Pixel extends Pixel
|
10 |
-
{
|
11 |
-
public function inject_everywhere()
|
12 |
-
{
|
13 |
-
// @formatter:off
|
14 |
-
?>
|
15 |
-
|
16 |
-
<script>
|
17 |
-
!function(f,b,e,v,n,t,s)
|
18 |
-
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
19 |
-
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
|
20 |
-
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
|
21 |
-
n.queue=[];t=b.createElement(e);t.async=!0;
|
22 |
-
t.src=v;s=b.getElementsByTagName(e)[0];
|
23 |
-
s.parentNode.insertBefore(t,s)}(window, document,'script',
|
24 |
-
'https://connect.facebook.net/en_US/fbevents.js');
|
25 |
-
fbq('init', '<?php echo $this->options_obj->facebook->pixel_id ?>');
|
26 |
-
fbq('track', 'PageView');
|
27 |
-
</script>
|
28 |
-
<noscript><img height="1" width="1" style="display:none"
|
29 |
-
src="https://www.facebook.com/tr?id=<?php echo $this->options_obj->facebook->pixel_id ?>&ev=PageView&noscript=1"
|
30 |
-
/></noscript>
|
31 |
-
<?php
|
32 |
-
// @formatter:on
|
33 |
-
}
|
34 |
-
|
35 |
-
public function inject_search()
|
36 |
-
{
|
37 |
-
?>
|
38 |
-
|
39 |
-
<script>
|
40 |
-
fbq('track', 'Search');
|
41 |
-
</script>
|
42 |
-
<?php
|
43 |
-
}
|
44 |
-
|
45 |
-
public function inject_product($product_id, $product, $product_attributes)
|
46 |
-
{
|
47 |
-
?>
|
48 |
-
|
49 |
-
<script>
|
50 |
-
fbq('track', 'ViewContent', {
|
51 |
-
'content_type' : 'product',
|
52 |
-
'content_name' : '<?php echo $product->get_name() ?>',
|
53 |
-
'content_category': <?php echo json_encode($this->get_product_category($product_id)) ?>,
|
54 |
-
'content_ids' : '<?php echo $product_id ?>',
|
55 |
-
'currency' : '<?php echo $this->options_obj->shop->currency ?>',
|
56 |
-
'value' : <?php echo (float)$product->get_price() . PHP_EOL ?>
|
57 |
-
});
|
58 |
-
</script>
|
59 |
-
<?php
|
60 |
-
}
|
61 |
-
|
62 |
-
public function inject_cart($cart, $cart_total)
|
63 |
-
{
|
64 |
-
?>
|
65 |
-
<script>
|
66 |
-
fbq('track', 'AddToCart', {
|
67 |
-
'content_name': 'Shopping Cart',
|
68 |
-
'content_type': 'product',
|
69 |
-
'content_ids' : <?php echo json_encode($this->get_cart_ids($cart)) ?>,
|
70 |
-
'currency' : '<?php echo $this->options_obj->shop->currency ?>',
|
71 |
-
'value' : <?php echo $cart_total . PHP_EOL ?>
|
72 |
-
});
|
73 |
-
</script>
|
74 |
-
<?php
|
75 |
-
}
|
76 |
-
|
77 |
-
public function inject_order_received_page($order, $order_total, $order_item_ids)
|
78 |
-
{
|
79 |
-
?>
|
80 |
-
|
81 |
-
<script>
|
82 |
-
if ((typeof wgact !== "undefined") && !wgact.isOrderIdStored(<?php echo $order->get_id() ?>)) {
|
83 |
-
fbq('track', 'Purchase', {
|
84 |
-
'content_type': 'product',
|
85 |
-
'content_ids' : <?php echo json_encode($order_item_ids) ?>,
|
86 |
-
'currency' : '<?php echo $this->options_obj->shop->currency ?>',
|
87 |
-
'value' : <?php echo $order_total . PHP_EOL ?>
|
88 |
-
});
|
89 |
-
}
|
90 |
-
</script>
|
91 |
-
|
92 |
-
<?php
|
93 |
-
}
|
94 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/class-facebook-pixel-manager.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels;
|
4 |
-
|
5 |
-
|
6 |
-
if ( !defined( 'ABSPATH' ) ) {
|
7 |
-
exit;
|
8 |
-
// Exit if accessed directly
|
9 |
-
}
|
10 |
-
|
11 |
-
class Facebook_Pixel_Manager extends Pixel
|
12 |
-
{
|
13 |
-
public function inject_everywhere()
|
14 |
-
{
|
15 |
-
( new Facebook_Browser_Pixel( $this->options, $this->options_obj ) )->inject_everywhere();
|
16 |
-
}
|
17 |
-
|
18 |
-
public function inject_search()
|
19 |
-
{
|
20 |
-
( new Facebook_Browser_Pixel( $this->options, $this->options_obj ) )->inject_search();
|
21 |
-
}
|
22 |
-
|
23 |
-
public function inject_product( $product_id, $product, $product_attributes )
|
24 |
-
{
|
25 |
-
( new Facebook_Browser_Pixel( $this->options, $this->options_obj ) )->inject_product( $product_id, $product, $product_attributes );
|
26 |
-
}
|
27 |
-
|
28 |
-
public function inject_cart( $cart, $cart_total )
|
29 |
-
{
|
30 |
-
( new Facebook_Browser_Pixel( $this->options, $this->options_obj ) )->inject_cart( $cart, $cart_total );
|
31 |
-
}
|
32 |
-
|
33 |
-
public function inject_order_received_page( $order, $order_total, $order_item_ids )
|
34 |
-
{
|
35 |
-
( new Facebook_Browser_Pixel( $this->options, $this->options_obj ) )->inject_order_received_page( $order, $order_total, $order_item_ids );
|
36 |
-
}
|
37 |
-
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/class-google-ads.php
DELETED
@@ -1,234 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Google_Ads extends Google_Pixel
|
10 |
-
{
|
11 |
-
protected $google_business_vertical;
|
12 |
-
|
13 |
-
public function __construct($options, $options_obj)
|
14 |
-
{
|
15 |
-
parent::__construct($options, $options_obj);
|
16 |
-
}
|
17 |
-
|
18 |
-
public function inject_product_category()
|
19 |
-
{
|
20 |
-
global $wp_query;
|
21 |
-
|
22 |
-
if ($this->is_dynamic_remarketing_active()) {
|
23 |
-
|
24 |
-
?>
|
25 |
-
|
26 |
-
<script type="text/javascript">
|
27 |
-
gtag('event', 'view_item_list', {
|
28 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
29 |
-
'items' : <?php echo json_encode($this->get_products_from_wp_query($wp_query)) . PHP_EOL ?>
|
30 |
-
});
|
31 |
-
</script>
|
32 |
-
<?php
|
33 |
-
}
|
34 |
-
}
|
35 |
-
|
36 |
-
public function inject_search()
|
37 |
-
{
|
38 |
-
global $wp_query;
|
39 |
-
|
40 |
-
if ($this->is_dynamic_remarketing_active()) {
|
41 |
-
|
42 |
-
?>
|
43 |
-
|
44 |
-
<script type="text/javascript">
|
45 |
-
gtag('event', 'view_search_results',
|
46 |
-
{
|
47 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
48 |
-
'items' : <?php echo json_encode($this->get_products_from_wp_query($wp_query)) . PHP_EOL ?>
|
49 |
-
});
|
50 |
-
</script>
|
51 |
-
<?php
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
public function inject_product($product_id_compiled, $product, $product_attributes)
|
56 |
-
{
|
57 |
-
//global $wp_query;
|
58 |
-
// error_log(print_r($related_products, true));
|
59 |
-
// error_log(print_r(wc_get_related_products($product->get_id()), true));
|
60 |
-
// error_log(print_r($wp_query, true));
|
61 |
-
|
62 |
-
|
63 |
-
if ($this->is_dynamic_remarketing_active()) {
|
64 |
-
|
65 |
-
$product_details = $this->get_gads_formatted_product_details_from_product_id($product->get_id());
|
66 |
-
?>
|
67 |
-
|
68 |
-
<script type="text/javascript">
|
69 |
-
gtag('event', 'view_item', {
|
70 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
71 |
-
'value' : <?php echo $product_details['price'] ?>,
|
72 |
-
'items' : [<?php echo(json_encode($product_details)) ?>]
|
73 |
-
});
|
74 |
-
</script>
|
75 |
-
<?php
|
76 |
-
}
|
77 |
-
}
|
78 |
-
|
79 |
-
public function inject_cart($cart, $cart_total)
|
80 |
-
{
|
81 |
-
if ($this->is_dynamic_remarketing_active()) {
|
82 |
-
|
83 |
-
?>
|
84 |
-
|
85 |
-
<script type="text/javascript">
|
86 |
-
gtag('event', 'add_to_cart', {
|
87 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
88 |
-
'value' : <?php echo $cart_total ?>,
|
89 |
-
'items' : <?php echo (json_encode($this->get_gads_formatted_cart_items($cart))) . PHP_EOL ?>
|
90 |
-
});
|
91 |
-
</script>
|
92 |
-
<?php
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
private function is_dynamic_remarketing_active(): bool
|
97 |
-
{
|
98 |
-
if ($this->dynamic_remarketing && $this->options_obj->google->ads->conversion_id) {
|
99 |
-
return true;
|
100 |
-
} else {
|
101 |
-
return false;
|
102 |
-
}
|
103 |
-
}
|
104 |
-
|
105 |
-
public function inject_order_received_page($order, $order_total, $order_item_ids, $is_new_customer)
|
106 |
-
{
|
107 |
-
$order_currency = $this->get_order_currency($order);
|
108 |
-
|
109 |
-
?>
|
110 |
-
|
111 |
-
<?php
|
112 |
-
|
113 |
-
// if cart data beta is off and conversion id has been set
|
114 |
-
if ($this->add_cart_data == false && $this->options_obj->google->ads->conversion_id) {
|
115 |
-
|
116 |
-
// no deduper needed here
|
117 |
-
// Google does this server side
|
118 |
-
if ($this->options_obj->google->ads->conversion_label): ?>
|
119 |
-
|
120 |
-
<script>
|
121 |
-
gtag('event', 'conversion', {
|
122 |
-
'send_to' : <?php echo json_encode($this->get_google_ads_conversion_ids(true))?>,
|
123 |
-
'value' : <?php echo $order_total; ?>,
|
124 |
-
'currency' : '<?php echo $order_currency; ?>',
|
125 |
-
'transaction_id': '<?php echo $order->get_order_number(); ?>',
|
126 |
-
});
|
127 |
-
</script>
|
128 |
-
<?php
|
129 |
-
endif; ?>
|
130 |
-
|
131 |
-
<?php
|
132 |
-
if ($this->is_dynamic_remarketing_active()) echo $this->get_dyn_remarketing_purchase_script($order, $order_total) ?>
|
133 |
-
|
134 |
-
<?php
|
135 |
-
}
|
136 |
-
|
137 |
-
if ($this->add_cart_data == true && $this->conversion_id && $this->conversion_label ) {
|
138 |
-
?>
|
139 |
-
|
140 |
-
<script>
|
141 |
-
gtag('event', 'purchase', <?php echo $this->get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer, 'ads') ?>);
|
142 |
-
</script>
|
143 |
-
<?php
|
144 |
-
}
|
145 |
-
|
146 |
-
?>
|
147 |
-
|
148 |
-
<?php
|
149 |
-
}
|
150 |
-
|
151 |
-
|
152 |
-
// get products from wp_query
|
153 |
-
protected function get_products_from_wp_query($wp_query): array
|
154 |
-
{
|
155 |
-
$items = [];
|
156 |
-
|
157 |
-
$posts = $wp_query->posts;
|
158 |
-
|
159 |
-
foreach ($posts as $key => $post) {
|
160 |
-
|
161 |
-
if ($post->post_type == 'product') {
|
162 |
-
|
163 |
-
$item_details = [];
|
164 |
-
|
165 |
-
$product = wc_get_product($post->ID);
|
166 |
-
$item_details['id'] = $this->get_compiled_product_id($post->ID, $product->get_sku());
|
167 |
-
$item_details['google_business_vertical'] = $this->google_business_vertical;
|
168 |
-
|
169 |
-
array_push($items, $item_details);
|
170 |
-
}
|
171 |
-
}
|
172 |
-
|
173 |
-
return $items;
|
174 |
-
}
|
175 |
-
|
176 |
-
protected function get_gads_formatted_product_details_from_product_id($product_id): array
|
177 |
-
{
|
178 |
-
$product = wc_get_product($product_id);
|
179 |
-
|
180 |
-
$product_details['id'] = $this->get_compiled_product_id($product_id, $product->get_sku());
|
181 |
-
$product_details['category'] = $this->get_product_category($product_id);
|
182 |
-
// $product_details['list_position'] = 1;
|
183 |
-
$product_details['quantity'] = 1;
|
184 |
-
$product_details['price'] = (float)$product->get_price();
|
185 |
-
$product_details['google_business_vertical'] = $this->google_business_vertical;
|
186 |
-
|
187 |
-
return $product_details;
|
188 |
-
}
|
189 |
-
|
190 |
-
// get an array with all cart product ids
|
191 |
-
protected function get_gads_formatted_cart_items($cart)
|
192 |
-
{
|
193 |
-
// error_log(print_r($cart, true));
|
194 |
-
// initiate product identifier array
|
195 |
-
$cart_items = [];
|
196 |
-
$item_details = [];
|
197 |
-
|
198 |
-
// go through the array and get all product identifiers
|
199 |
-
foreach ((array)$cart as $cart_item) {
|
200 |
-
// error_log(print_r($cart_item,true));
|
201 |
-
$product_id = $this->get_variation_or_product_id($cart_item, $this->options_obj->general->variations_output);
|
202 |
-
// error_log('id: ' . $product_id);
|
203 |
-
$product = wc_get_product($product_id);
|
204 |
-
|
205 |
-
$item_details['id'] = $this->get_compiled_product_id($product_id, $product->get_sku());
|
206 |
-
$item_details['quantity'] = (int)$cart_item['quantity'];
|
207 |
-
$item_details['price'] = (int)$product->get_price();
|
208 |
-
$item_details['google_business_vertical'] = $this->google_business_vertical;
|
209 |
-
|
210 |
-
array_push($cart_items, $item_details);
|
211 |
-
}
|
212 |
-
|
213 |
-
// apply filter to the $cartprods_items array
|
214 |
-
$cart_items = apply_filters('wgact_filter', $cart_items, 'cart_items');
|
215 |
-
|
216 |
-
return $cart_items;
|
217 |
-
}
|
218 |
-
|
219 |
-
protected function get_dyn_remarketing_purchase_script($order, $order_total)
|
220 |
-
{
|
221 |
-
?>
|
222 |
-
|
223 |
-
<script>
|
224 |
-
if ((typeof wgact !== "undefined") && !wgact.isOrderIdStored(<?php echo $order->get_id() ?>)) {
|
225 |
-
gtag('event', 'purchase', {
|
226 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
227 |
-
'value' : <?php echo $order_total; ?>,
|
228 |
-
'items' : <?php echo (json_encode($this->get_formatted_order_items($order))) . PHP_EOL ?>
|
229 |
-
});
|
230 |
-
}
|
231 |
-
</script>
|
232 |
-
<?php
|
233 |
-
}
|
234 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/class-google-optimize.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Google_Optimize extends Google_Pixel
|
10 |
-
{
|
11 |
-
public function inject_google_optimize_anti_flicker_snippet()
|
12 |
-
{
|
13 |
-
?>
|
14 |
-
|
15 |
-
<script>(function (a, s, y, n, c, h, i, d, e) {
|
16 |
-
s.className += ' ' + y;
|
17 |
-
h.start = 1 * new Date;
|
18 |
-
h.end = i = function () {
|
19 |
-
s.className = s.className.replace(RegExp(' ?' + y), '')
|
20 |
-
};
|
21 |
-
(a[n] = a[n] || []).hide = h;
|
22 |
-
setTimeout(function () {
|
23 |
-
i();
|
24 |
-
h.end = null
|
25 |
-
}, c);
|
26 |
-
h.timeout = c;
|
27 |
-
})(window, document.documentElement, 'async-hide', 'dataLayer', 4000,
|
28 |
-
{'<?php echo $this->options_obj->google->optimize->container_id ?>': true});</script>
|
29 |
-
<?php
|
30 |
-
}
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/class-google-pixel-manager.php
DELETED
@@ -1,377 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels;
|
4 |
-
|
5 |
-
use WGACT\Classes\Admin\Environment_Check ;
|
6 |
-
|
7 |
-
if ( !defined( 'ABSPATH' ) ) {
|
8 |
-
exit;
|
9 |
-
// Exit if accessed directly
|
10 |
-
}
|
11 |
-
|
12 |
-
class Google_Pixel_Manager extends Google_Pixel
|
13 |
-
{
|
14 |
-
use Trait_Google ;
|
15 |
-
public function __construct( $options, $options_obj )
|
16 |
-
{
|
17 |
-
parent::__construct( $options, $options_obj );
|
18 |
-
}
|
19 |
-
|
20 |
-
public function inject_everywhere()
|
21 |
-
{
|
22 |
-
|
23 |
-
if ( $this->options_obj->google->optimize->container_id ) {
|
24 |
-
?>
|
25 |
-
|
26 |
-
<script async src="https://www.googleoptimize.com/optimize.js?id=<?php
|
27 |
-
echo $this->options_obj->google->optimize->container_id ;
|
28 |
-
?>"></script>
|
29 |
-
<?php
|
30 |
-
}
|
31 |
-
|
32 |
-
|
33 |
-
if ( !$this->options_obj->google->gtag->deactivation ) {
|
34 |
-
?>
|
35 |
-
|
36 |
-
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php
|
37 |
-
echo $this->get_gtag_id() ;
|
38 |
-
?>"></script>
|
39 |
-
<script<?php
|
40 |
-
echo ( $this->options_obj->shop->cookie_consent_mgmt->cookiebot->active ? ' data-cookieconsent="ignore"' : '' ) ;
|
41 |
-
?>>
|
42 |
-
window.dataLayer = window.dataLayer || [];
|
43 |
-
|
44 |
-
function gtag() {
|
45 |
-
dataLayer.push(arguments);
|
46 |
-
}
|
47 |
-
|
48 |
-
<?php
|
49 |
-
echo ( $this->options_obj->google->consent_mode->active ? $this->consent_mode_gtag_html() : '' ) ;
|
50 |
-
?>
|
51 |
-
|
52 |
-
gtag('js', new Date());
|
53 |
-
|
54 |
-
</script>
|
55 |
-
|
56 |
-
<?php
|
57 |
-
}
|
58 |
-
|
59 |
-
?>
|
60 |
-
|
61 |
-
<script>
|
62 |
-
<?php
|
63 |
-
foreach ( $this->conversion_identifiers as $conversion_id => $conversion_label ) {
|
64 |
-
?>
|
65 |
-
<?php
|
66 |
-
echo ( $this->options_obj->google->ads->conversion_id ? $this->gtag_config( $conversion_id, 'ads' ) : PHP_EOL ) ;
|
67 |
-
?>
|
68 |
-
<?php
|
69 |
-
}
|
70 |
-
?>
|
71 |
-
|
72 |
-
<?php
|
73 |
-
echo ( $this->options_obj->google->analytics->universal->property_id ? $this->gtag_config( $this->options_obj->google->analytics->universal->property_id, 'analytics' ) . PHP_EOL : PHP_EOL ) ;
|
74 |
-
?>
|
75 |
-
<?php
|
76 |
-
echo ( $this->options_obj->google->analytics->ga4->measurement_id ? $this->gtag_config( $this->options_obj->google->analytics->ga4->measurement_id, 'analytics' ) : PHP_EOL ) ;
|
77 |
-
?>
|
78 |
-
|
79 |
-
</script>
|
80 |
-
<?php
|
81 |
-
if ( $this->options_obj->google->consent_mode->active && ( new Environment_Check() )->is_borlabs_cookie_active() ) {
|
82 |
-
$this->inject_borlabs_consent_mode_update();
|
83 |
-
}
|
84 |
-
if ( $this->is_google_ads_active() && $this->options_obj->google->ads->phone_conversion_number ) {
|
85 |
-
$this->inject_phone_conversion_number_html__premium_only();
|
86 |
-
}
|
87 |
-
$this->inject_data_layer_init();
|
88 |
-
$this->inject_data_layer_shop();
|
89 |
-
$this->inject_data_layer_product();
|
90 |
-
$this->inject_data_layer_pixels();
|
91 |
-
}
|
92 |
-
|
93 |
-
private function inject_data_layer_pixels()
|
94 |
-
{
|
95 |
-
?>
|
96 |
-
|
97 |
-
<script>
|
98 |
-
wooptpmDataLayer['pixels'] = {
|
99 |
-
'dynamic_remarketing': true,
|
100 |
-
};
|
101 |
-
</script>
|
102 |
-
<?php
|
103 |
-
}
|
104 |
-
|
105 |
-
private function inject_data_layer_init()
|
106 |
-
{
|
107 |
-
?>
|
108 |
-
<script>
|
109 |
-
window.wooptpmDataLayer = window.wooptpmDataLayer || [];
|
110 |
-
// window.wooptpmDataLayer['cart'] = window.wooptpmDataLayer['cart'] || {};
|
111 |
-
</script>
|
112 |
-
|
113 |
-
<?php
|
114 |
-
}
|
115 |
-
|
116 |
-
private function inject_data_layer_shop()
|
117 |
-
{
|
118 |
-
$data = [];
|
119 |
-
|
120 |
-
if ( is_product_category() ) {
|
121 |
-
$data['list_name'] = 'Product Category';
|
122 |
-
$data['page_type'] = 'product_category';
|
123 |
-
} elseif ( is_product_tag() ) {
|
124 |
-
$data['list_name'] = 'Product Tag';
|
125 |
-
$data['page_type'] = 'product_tag';
|
126 |
-
} elseif ( is_search() ) {
|
127 |
-
$data['list_name'] = 'Product Search';
|
128 |
-
$data['page_type'] = 'search';
|
129 |
-
} elseif ( is_shop() ) {
|
130 |
-
$data['list_name'] = 'Shop';
|
131 |
-
$data['page_type'] = 'product_shop';
|
132 |
-
} elseif ( is_product() ) {
|
133 |
-
$data['page_type'] = 'product';
|
134 |
-
$product = wc_get_product();
|
135 |
-
$data['product_type'] = $product->get_type();
|
136 |
-
} elseif ( is_cart() ) {
|
137 |
-
$data['list_name'] = '';
|
138 |
-
$data['page_type'] = 'cart';
|
139 |
-
} else {
|
140 |
-
$data['list_name'] = '';
|
141 |
-
}
|
142 |
-
|
143 |
-
?>
|
144 |
-
|
145 |
-
<script>
|
146 |
-
wooptpmDataLayer['shop'] = <?php
|
147 |
-
echo json_encode( $data ) ;
|
148 |
-
?>;
|
149 |
-
</script>
|
150 |
-
<?php
|
151 |
-
}
|
152 |
-
|
153 |
-
private function inject_data_layer_product()
|
154 |
-
{
|
155 |
-
global $wp_query, $woocommerce ;
|
156 |
-
|
157 |
-
if ( is_shop() || is_product_category() || is_product_tag() || is_search() ) {
|
158 |
-
$product_ids = [];
|
159 |
-
$posts = $wp_query->posts;
|
160 |
-
foreach ( $posts as $key => $post ) {
|
161 |
-
if ( $post->post_type == 'product' ) {
|
162 |
-
array_push( $product_ids, $post->ID );
|
163 |
-
}
|
164 |
-
}
|
165 |
-
?>
|
166 |
-
|
167 |
-
<script>
|
168 |
-
wooptpmDataLayer['visible_products'] = <?php
|
169 |
-
echo json_encode( $this->eec_get_visible_products( $product_ids ) ) ;
|
170 |
-
?>;
|
171 |
-
</script>
|
172 |
-
<?php
|
173 |
-
} elseif ( is_cart() ) {
|
174 |
-
$visible_product_ids = [];
|
175 |
-
$upsell_product_ids = [];
|
176 |
-
$items = $woocommerce->cart->get_cart();
|
177 |
-
foreach ( $items as $item => $values ) {
|
178 |
-
array_push( $visible_product_ids, $values['data']->get_id() );
|
179 |
-
$product = wc_get_product( $values['data']->get_id() );
|
180 |
-
$single_product_upsell_ids = $product->get_upsell_ids();
|
181 |
-
// error_log(print_r($single_product_upsell_ids,true));
|
182 |
-
foreach ( $single_product_upsell_ids as $item => $value ) {
|
183 |
-
// error_log('item ' . $item);
|
184 |
-
// error_log('value' . $value);
|
185 |
-
if ( !in_array( $value, $upsell_product_ids, true ) ) {
|
186 |
-
array_push( $upsell_product_ids, $value );
|
187 |
-
}
|
188 |
-
}
|
189 |
-
}
|
190 |
-
// error_log(print_r($upsell_product_ids,true));
|
191 |
-
?>
|
192 |
-
|
193 |
-
<script>
|
194 |
-
wooptpmDataLayer['visible_products'] = <?php
|
195 |
-
echo json_encode( $this->eec_get_visible_products( $visible_product_ids ) ) ;
|
196 |
-
?>;
|
197 |
-
wooptpmDataLayer['upsell_products'] = <?php
|
198 |
-
echo json_encode( $this->eec_get_visible_products( $upsell_product_ids ) ) ;
|
199 |
-
?>;
|
200 |
-
</script>
|
201 |
-
<?php
|
202 |
-
} elseif ( is_product() ) {
|
203 |
-
$product = wc_get_product();
|
204 |
-
$visible_product_ids = [];
|
205 |
-
array_push( $visible_product_ids, $product->get_id() );
|
206 |
-
$related_products = wc_get_related_products( $product->get_id() );
|
207 |
-
foreach ( $related_products as $item => $value ) {
|
208 |
-
array_push( $visible_product_ids, $value );
|
209 |
-
}
|
210 |
-
$upsell_product_ids = $product->get_upsell_ids();
|
211 |
-
foreach ( $upsell_product_ids as $item => $value ) {
|
212 |
-
array_push( $visible_product_ids, $value );
|
213 |
-
}
|
214 |
-
// error_log(print_r($visible_product_ids, true));
|
215 |
-
if ( $product->get_type() === 'grouped' ) {
|
216 |
-
$visible_product_ids = array_merge( $visible_product_ids, $product->get_children() );
|
217 |
-
}
|
218 |
-
?>
|
219 |
-
|
220 |
-
<script>
|
221 |
-
wooptpmDataLayer['visible_products'] = <?php
|
222 |
-
echo json_encode( $this->eec_get_visible_products( $visible_product_ids ) ) ;
|
223 |
-
?>;
|
224 |
-
</script>
|
225 |
-
<?php
|
226 |
-
}
|
227 |
-
|
228 |
-
}
|
229 |
-
|
230 |
-
private function eec_get_visible_products( $product_ids ) : array
|
231 |
-
{
|
232 |
-
$data = [];
|
233 |
-
$position = 1;
|
234 |
-
foreach ( $product_ids as $key => $product_id ) {
|
235 |
-
$product = wc_get_product( $product_id );
|
236 |
-
$data[$product->get_id()] = [
|
237 |
-
'id' => (string) $product->get_id(),
|
238 |
-
'sku' => (string) $product->get_sku(),
|
239 |
-
'name' => (string) $product->get_name(),
|
240 |
-
'price' => (string) $product->get_price(),
|
241 |
-
'brand' => $this->get_brand_name( $product->get_id() ),
|
242 |
-
'category' => (array) $this->get_product_category( $product->get_id() ),
|
243 |
-
'quantity' => (int) 1,
|
244 |
-
'position' => (int) $position,
|
245 |
-
];
|
246 |
-
$position++;
|
247 |
-
}
|
248 |
-
return $data;
|
249 |
-
}
|
250 |
-
|
251 |
-
private function inject_borlabs_consent_mode_update()
|
252 |
-
{
|
253 |
-
?>
|
254 |
-
|
255 |
-
<script>
|
256 |
-
(function updateGoogleConsentMode() {
|
257 |
-
if (typeof BorlabsCookie == "undefined" || typeof gtag == "undefined") {
|
258 |
-
window.setTimeout(updateGoogleConsentMode, 50);
|
259 |
-
} else {
|
260 |
-
if (window.BorlabsCookie.checkCookieGroupConsent('statistics')) {
|
261 |
-
gtag('consent', 'update', {
|
262 |
-
'analytics_storage': 'granted'
|
263 |
-
});
|
264 |
-
}
|
265 |
-
|
266 |
-
if (window.BorlabsCookie.checkCookieGroupConsent('marketing')) {
|
267 |
-
gtag('consent', 'update', {
|
268 |
-
'ad_storage': 'granted'
|
269 |
-
});
|
270 |
-
}
|
271 |
-
}
|
272 |
-
})();
|
273 |
-
</script>
|
274 |
-
<?php
|
275 |
-
}
|
276 |
-
|
277 |
-
public function inject_product_category()
|
278 |
-
{
|
279 |
-
( new Google_Ads( $this->options, $this->options_obj ) )->inject_product_category();
|
280 |
-
}
|
281 |
-
|
282 |
-
public function inject_product_tag()
|
283 |
-
{
|
284 |
-
}
|
285 |
-
|
286 |
-
public function inject_shop_top_page()
|
287 |
-
{
|
288 |
-
}
|
289 |
-
|
290 |
-
public function inject_search()
|
291 |
-
{
|
292 |
-
( new Google_Ads( $this->options, $this->options_obj ) )->inject_search();
|
293 |
-
}
|
294 |
-
|
295 |
-
public function inject_product( $product_id, $product, $product_attributes )
|
296 |
-
{
|
297 |
-
( new Google_Ads( $this->options, $this->options_obj ) )->inject_product( $product_id, $product, $product_attributes );
|
298 |
-
}
|
299 |
-
|
300 |
-
public function inject_cart( $cart, $cart_total )
|
301 |
-
{
|
302 |
-
( new Google_Ads( $this->options, $this->options_obj ) )->inject_cart( $cart, $cart_total );
|
303 |
-
}
|
304 |
-
|
305 |
-
public function inject_order_received_page(
|
306 |
-
$order,
|
307 |
-
$order_total,
|
308 |
-
$order_item_ids,
|
309 |
-
$is_new_customer
|
310 |
-
)
|
311 |
-
{
|
312 |
-
if ( $this->options_obj->google->ads->conversion_id ) {
|
313 |
-
( new Google_Ads( $this->options, $this->options_obj ) )->inject_order_received_page(
|
314 |
-
$order,
|
315 |
-
$order_total,
|
316 |
-
$order_item_ids,
|
317 |
-
$is_new_customer
|
318 |
-
);
|
319 |
-
}
|
320 |
-
if ( $this->is_google_analytics_active() ) {
|
321 |
-
// this is the same code for standard and eec, therefore using the same for both
|
322 |
-
( new Google_Standard_Ecommerce( $this->options, $this->options_obj ) )->inject_order_received_page(
|
323 |
-
$order,
|
324 |
-
$order_total,
|
325 |
-
$order_item_ids,
|
326 |
-
$is_new_customer
|
327 |
-
);
|
328 |
-
}
|
329 |
-
}
|
330 |
-
|
331 |
-
private function get_gtag_id() : string
|
332 |
-
{
|
333 |
-
|
334 |
-
if ( $this->options_obj->google->analytics->universal->property_id ) {
|
335 |
-
return $this->options_obj->google->analytics->universal->property_id;
|
336 |
-
} elseif ( $this->options_obj->google->analytics->ga4->measurement_id ) {
|
337 |
-
return $this->options_obj->google->analytics->ga4->measurement_id;
|
338 |
-
} elseif ( $this->options_obj->google->ads->conversion_id ) {
|
339 |
-
return 'AW-' . $this->options_obj->google->ads->conversion_id;
|
340 |
-
}
|
341 |
-
|
342 |
-
}
|
343 |
-
|
344 |
-
protected function gtag_config( $id, $channel = '' ) : string
|
345 |
-
{
|
346 |
-
$analytics_parameters = [
|
347 |
-
'anonymize_ip' => 'true',
|
348 |
-
'link_attribution' => ( $this->options_obj->google->analytics->link_attribution ? 'true' : 'false' ),
|
349 |
-
];
|
350 |
-
$analytics_parameters = apply_filters( 'woopt_pm_analytics_parameters', $analytics_parameters, $id );
|
351 |
-
|
352 |
-
if ( 'ads' === $channel ) {
|
353 |
-
return "gtag('config', 'AW-" . $id . "');" . PHP_EOL;
|
354 |
-
} elseif ( 'analytics' ) {
|
355 |
-
return "gtag('config', '" . $id . "', " . json_encode( $analytics_parameters ) . ");";
|
356 |
-
}
|
357 |
-
|
358 |
-
}
|
359 |
-
|
360 |
-
private function consent_mode_gtag_html() : string
|
361 |
-
{
|
362 |
-
$data = [
|
363 |
-
'ad_storage' => 'denied',
|
364 |
-
'analytics_storage' => 'denied',
|
365 |
-
'wait_for_update' => 500,
|
366 |
-
];
|
367 |
-
if ( $this->options_obj->google->consent_mode->regions ) {
|
368 |
-
$data['regions'] = $this->options_obj->google->consent_mode->regions;
|
369 |
-
}
|
370 |
-
$ads_data_redaction = 'true';
|
371 |
-
// needs to be output as text
|
372 |
-
$url_passthrough = 'true';
|
373 |
-
// needs to be output as text
|
374 |
-
return "gtag('consent', 'default', " . json_encode( $data ) . ");\n \n gtag('set', 'ads_data_redaction', " . $ads_data_redaction . ");\n \n gtag('set', 'url_passthrough', " . $url_passthrough . ");" . PHP_EOL;
|
375 |
-
}
|
376 |
-
|
377 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/class-google-pixel.php
DELETED
@@ -1,148 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Google_Pixel extends Pixel
|
10 |
-
{
|
11 |
-
use Trait_Google;
|
12 |
-
|
13 |
-
protected $conversion_identifiers;
|
14 |
-
|
15 |
-
public function __construct($options, $options_obj)
|
16 |
-
{
|
17 |
-
parent::__construct($options, $options_obj);
|
18 |
-
|
19 |
-
$this->google_business_vertical = $this->get_google_business_vertical($this->options['google']['ads']['google_business_vertical']);
|
20 |
-
|
21 |
-
$this->conversion_identifiers[$this->conversion_id] = $this->conversion_label;
|
22 |
-
|
23 |
-
$this->conversion_identifiers = apply_filters('wgact_google_ads_conversion_identifiers', $this->conversion_identifiers);
|
24 |
-
}
|
25 |
-
|
26 |
-
protected function get_google_business_vertical($id): string
|
27 |
-
{
|
28 |
-
$verticals = [
|
29 |
-
0 => 'retail',
|
30 |
-
1 => 'education',
|
31 |
-
2 => 'flights',
|
32 |
-
3 => 'hotel_rental',
|
33 |
-
4 => 'jobs',
|
34 |
-
5 => 'local',
|
35 |
-
6 => 'real_estate',
|
36 |
-
7 => 'travel',
|
37 |
-
8 => 'custom'
|
38 |
-
];
|
39 |
-
|
40 |
-
return $verticals[$id];
|
41 |
-
}
|
42 |
-
|
43 |
-
protected function get_formatted_order_items($order, $channel = '')
|
44 |
-
{
|
45 |
-
$order_items = $order->get_items();
|
46 |
-
$order_items_array = [];
|
47 |
-
|
48 |
-
$list_position = 1;
|
49 |
-
|
50 |
-
foreach ((array)$order_items as $order_item) {
|
51 |
-
|
52 |
-
$product_id = $this->get_variation_or_product_id($order_item->get_data(), $this->options_obj->general->variations_output);
|
53 |
-
$product = wc_get_product($product_id);
|
54 |
-
|
55 |
-
$item_details_array = [];
|
56 |
-
|
57 |
-
$item_details_array['id'] = $this->get_compiled_product_id($product_id, $product->get_sku(), $channel);
|
58 |
-
$item_details_array['quantity'] = (int)$order_item['quantity'];
|
59 |
-
$item_details_array['price'] = (int)$product->get_price();
|
60 |
-
if ($this->is_google_ads_active()) {
|
61 |
-
$item_details_array['google_business_vertical'] = $this->google_business_vertical;
|
62 |
-
}
|
63 |
-
|
64 |
-
if ($this->is_google_analytics_active()) {
|
65 |
-
$item_details_array['name'] = (string)$product->get_name();
|
66 |
-
// $item_details_array['list_name'] = '';
|
67 |
-
$item_details_array['brand'] = $this->get_brand_name($product_id);
|
68 |
-
$item_details_array['category'] = $this->get_product_category($product_id);
|
69 |
-
// $item_details_array['variant'] = '';
|
70 |
-
$item_details_array['list_position'] = $list_position++;
|
71 |
-
}
|
72 |
-
|
73 |
-
array_push($order_items_array, $item_details_array);
|
74 |
-
}
|
75 |
-
|
76 |
-
// apply filter to the $order_items_array array
|
77 |
-
$order_items_array = apply_filters('wgact_filter', $order_items_array, 'order_items_array');
|
78 |
-
|
79 |
-
return $order_items_array;
|
80 |
-
}
|
81 |
-
|
82 |
-
protected function get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer, $channel)
|
83 |
-
{
|
84 |
-
$gtag_data = [
|
85 |
-
'send_to' => [],
|
86 |
-
'transaction_id' => $order->get_order_number(),
|
87 |
-
'currency' => $order_currency,
|
88 |
-
'discount' => $order->get_total_discount(),
|
89 |
-
'items' => $this->get_formatted_order_items($order, $channel),
|
90 |
-
];
|
91 |
-
|
92 |
-
if ('ads' === $channel) {
|
93 |
-
array_push($gtag_data['send_to'], $this->get_google_ads_conversion_ids(true));
|
94 |
-
$gtag_data['value'] = $order_total;
|
95 |
-
$gtag_data['aw_merchant_id'] = $this->aw_merchant_id;
|
96 |
-
$gtag_data['aw_feed_country'] = $this->get_visitor_country();
|
97 |
-
$gtag_data['aw_feed_language'] = $this->get_gmc_language();
|
98 |
-
$gtag_data['new_customer'] = $is_new_customer;
|
99 |
-
}
|
100 |
-
|
101 |
-
if ('analytics' === $channel) {
|
102 |
-
if ($this->options_obj->google->analytics->universal->property_id) array_push($gtag_data['send_to'], $this->options_obj->google->analytics->universal->property_id);
|
103 |
-
if ($this->options_obj->google->analytics->ga4->measurement_id) array_push($gtag_data['send_to'], $this->options_obj->google->analytics->ga4->measurement_id);
|
104 |
-
$gtag_data['affiliation'] = (string)get_bloginfo('name');
|
105 |
-
$gtag_data['tax'] = (string)$order->get_total_tax();
|
106 |
-
$gtag_data['shipping'] = (string)$order->get_total_shipping();
|
107 |
-
$gtag_data['value'] = (float)$order->get_total();
|
108 |
-
}
|
109 |
-
|
110 |
-
return json_encode($gtag_data);
|
111 |
-
}
|
112 |
-
|
113 |
-
protected function get_gmc_language(): string
|
114 |
-
{
|
115 |
-
return strtoupper(substr(get_locale(), 0, 2));
|
116 |
-
}
|
117 |
-
|
118 |
-
protected function get_order_currency($order)
|
119 |
-
{
|
120 |
-
// use the right function to get the currency depending on the WooCommerce version
|
121 |
-
return $this->woocommerce_3_and_above() ? $order->get_currency() : $order->get_order_currency();
|
122 |
-
}
|
123 |
-
|
124 |
-
protected function woocommerce_3_and_above(): bool
|
125 |
-
{
|
126 |
-
global $woocommerce;
|
127 |
-
if (version_compare($woocommerce->version, 3.0, ">=")) {
|
128 |
-
return true;
|
129 |
-
} else {
|
130 |
-
return false;
|
131 |
-
}
|
132 |
-
}
|
133 |
-
|
134 |
-
protected function get_google_ads_conversion_ids($purchase = false): array
|
135 |
-
{
|
136 |
-
$formatted_conversion_ids = [];
|
137 |
-
if ($purchase) {
|
138 |
-
foreach ($this->conversion_identifiers as $conversion_id => $conversion_label) {
|
139 |
-
array_push($formatted_conversion_ids, 'AW-' . $conversion_id . '/' . $conversion_label);
|
140 |
-
}
|
141 |
-
} else {
|
142 |
-
foreach ($this->conversion_identifiers as $conversion_id => $conversion_label) {
|
143 |
-
array_push($formatted_conversion_ids, 'AW-' . $conversion_id);
|
144 |
-
}
|
145 |
-
}
|
146 |
-
return $formatted_conversion_ids;
|
147 |
-
}
|
148 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/class-google-standard-ecommerce.php
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
namespace WGACT\Classes\Pixels;
|
5 |
-
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class Google_Standard_Ecommerce extends Google_Pixel
|
11 |
-
{
|
12 |
-
public function inject_order_received_page($order, $order_total, $order_item_ids, $is_new_customer)
|
13 |
-
{
|
14 |
-
$order_currency = $this->get_order_currency($order);
|
15 |
-
|
16 |
-
?>
|
17 |
-
<script>
|
18 |
-
if ((typeof wgact !== "undefined") && !wgact.isOrderIdStored(<?php echo $order->get_id() ?>)) {
|
19 |
-
gtag('event', 'purchase', <?php echo $this->get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer, 'analytics') ?>);
|
20 |
-
}
|
21 |
-
</script>
|
22 |
-
<?php
|
23 |
-
}
|
24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/class-google.php
DELETED
@@ -1,479 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Google extends Pixel
|
10 |
-
{
|
11 |
-
protected $google_business_vertical;
|
12 |
-
protected $conversion_identifiers;
|
13 |
-
|
14 |
-
public function __construct($options, $options_obj)
|
15 |
-
{
|
16 |
-
parent::__construct($options, $options_obj);
|
17 |
-
|
18 |
-
$this->google_business_vertical = $this->get_google_business_vertical($this->options['google']['ads']['google_business_vertical']);
|
19 |
-
|
20 |
-
$this->conversion_identifiers[$this->conversion_id] = $this->conversion_label;
|
21 |
-
|
22 |
-
$this->conversion_identifiers = apply_filters('wgact_google_ads_conversion_identifiers', $this->conversion_identifiers);
|
23 |
-
}
|
24 |
-
|
25 |
-
public function inject_everywhere()
|
26 |
-
{
|
27 |
-
if ($this->options_obj->google->optimize->container_id) {
|
28 |
-
?>
|
29 |
-
|
30 |
-
<script async src="https://www.googleoptimize.com/optimize.js?id=<?php
|
31 |
-
echo $this->options_obj->google->optimize->container_id ?>"></script>
|
32 |
-
<?php
|
33 |
-
}
|
34 |
-
|
35 |
-
if (!$this->options_obj->google->gtag->deactivation) {
|
36 |
-
?>
|
37 |
-
|
38 |
-
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php
|
39 |
-
echo $this->get_gtag_id() ?>"></script>
|
40 |
-
<script<?php echo
|
41 |
-
$this->options_obj->shop->cookie_consent_mgmt->cookiebot->active ? ' data-cookieconsent="ignore"' : ''; ?>>
|
42 |
-
window.dataLayer = window.dataLayer || [];
|
43 |
-
|
44 |
-
function gtag() {
|
45 |
-
dataLayer.push(arguments);
|
46 |
-
}
|
47 |
-
|
48 |
-
<?php echo $this->options_obj->google->consent_mode->active ? $this->consent_mode_gtag_html() : ''; ?>
|
49 |
-
|
50 |
-
gtag('js', new Date());
|
51 |
-
|
52 |
-
</script>
|
53 |
-
|
54 |
-
<?php
|
55 |
-
}
|
56 |
-
|
57 |
-
?>
|
58 |
-
|
59 |
-
<script>
|
60 |
-
<?php foreach ($this->conversion_identifiers as $conversion_id => $conversion_label): ?>
|
61 |
-
<?php echo $this->options_obj->google->ads->conversion_id ? $this->gtag_config($conversion_id, 'ads') : PHP_EOL; ?>
|
62 |
-
<?php endforeach; ?>
|
63 |
-
|
64 |
-
<?php echo $this->options_obj->google->analytics->universal->property_id ? $this->gtag_config($this->options_obj->google->analytics->universal->property_id, 'analytics') . PHP_EOL : PHP_EOL; ?>
|
65 |
-
<?php echo $this->options_obj->google->analytics->ga4->measurement_id ? $this->gtag_config($this->options_obj->google->analytics->ga4->measurement_id, 'analytics') : PHP_EOL; ?>
|
66 |
-
|
67 |
-
</script>
|
68 |
-
<?php
|
69 |
-
}
|
70 |
-
|
71 |
-
private function consent_mode_gtag_html(): string
|
72 |
-
{
|
73 |
-
return "gtag('consent', 'default', {
|
74 |
-
'ad_storage': 'denied',
|
75 |
-
'analytics_storage': 'denied',
|
76 |
-
'wait_for_update': 500
|
77 |
-
});
|
78 |
-
|
79 |
-
gtag('set', 'ads_data_redaction', true);
|
80 |
-
|
81 |
-
gtag('set', 'url_passthrough', true);" . PHP_EOL;
|
82 |
-
}
|
83 |
-
|
84 |
-
private function get_gtag_id(): string
|
85 |
-
{
|
86 |
-
if ($this->options_obj->google->analytics->universal->property_id) {
|
87 |
-
return $this->options_obj->google->analytics->universal->property_id;
|
88 |
-
} elseif ($this->options_obj->google->analytics->ga4->measurement_id) {
|
89 |
-
return $this->options_obj->google->analytics->ga4->measurement_id;
|
90 |
-
} elseif ($this->options_obj->google->ads->conversion_id) {
|
91 |
-
return 'AW-' . $this->options_obj->google->ads->conversion_id;
|
92 |
-
}
|
93 |
-
}
|
94 |
-
|
95 |
-
public function inject_google_optimize_anti_flicker_snippet()
|
96 |
-
{
|
97 |
-
?>
|
98 |
-
|
99 |
-
<script>(function (a, s, y, n, c, h, i, d, e) {
|
100 |
-
s.className += ' ' + y;
|
101 |
-
h.start = 1 * new Date;
|
102 |
-
h.end = i = function () {
|
103 |
-
s.className = s.className.replace(RegExp(' ?' + y), '')
|
104 |
-
};
|
105 |
-
(a[n] = a[n] || []).hide = h;
|
106 |
-
setTimeout(function () {
|
107 |
-
i();
|
108 |
-
h.end = null
|
109 |
-
}, c);
|
110 |
-
h.timeout = c;
|
111 |
-
})(window, document.documentElement, 'async-hide', 'dataLayer', 4000,
|
112 |
-
{'<?php echo $this->options_obj->google->optimize->container_id ?>': true});</script>
|
113 |
-
<?php
|
114 |
-
}
|
115 |
-
|
116 |
-
|
117 |
-
public function inject_product_category()
|
118 |
-
{
|
119 |
-
global $wp_query;
|
120 |
-
|
121 |
-
if ($this->is_dynamic_remarketing_active()) {
|
122 |
-
|
123 |
-
?>
|
124 |
-
|
125 |
-
<script type="text/javascript">
|
126 |
-
gtag('event', 'view_item_list', {
|
127 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
128 |
-
'items' : <?php echo json_encode($this->get_products_from_wp_query($wp_query)) . PHP_EOL ?>
|
129 |
-
});
|
130 |
-
</script>
|
131 |
-
<?php
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
public function inject_search()
|
136 |
-
{
|
137 |
-
global $wp_query;
|
138 |
-
|
139 |
-
if ($this->is_dynamic_remarketing_active()) {
|
140 |
-
|
141 |
-
?>
|
142 |
-
|
143 |
-
<script type="text/javascript">
|
144 |
-
gtag('event', 'view_search_results',
|
145 |
-
{
|
146 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
147 |
-
'items' : <?php echo json_encode($this->get_products_from_wp_query($wp_query)) . PHP_EOL ?>
|
148 |
-
});
|
149 |
-
</script>
|
150 |
-
<?php
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
public function inject_product($product_id_compiled, $product, $product_attributes)
|
155 |
-
{
|
156 |
-
if ($this->is_dynamic_remarketing_active()) {
|
157 |
-
|
158 |
-
$product_details = $this->get_gads_formatted_product_details_from_product_id($product->get_id());
|
159 |
-
?>
|
160 |
-
|
161 |
-
<script type="text/javascript">
|
162 |
-
gtag('event', 'view_item', {
|
163 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
164 |
-
'value' : <?php echo $product_details['price'] ?>,
|
165 |
-
'items' : [<?php echo(json_encode($product_details)) ?>]
|
166 |
-
});
|
167 |
-
</script>
|
168 |
-
<?php
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
public function inject_cart($cart, $cart_total)
|
173 |
-
{
|
174 |
-
if ($this->is_dynamic_remarketing_active()) {
|
175 |
-
|
176 |
-
?>
|
177 |
-
|
178 |
-
<script type="text/javascript">
|
179 |
-
gtag('event', 'add_to_cart', {
|
180 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
181 |
-
'value' : <?php echo $cart_total ?>,
|
182 |
-
'items' : <?php echo (json_encode($this->get_gads_formatted_cart_items($cart))) . PHP_EOL ?>
|
183 |
-
});
|
184 |
-
</script>
|
185 |
-
<?php
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
private function is_dynamic_remarketing_active(): bool
|
190 |
-
{
|
191 |
-
if ($this->dynamic_remarketing && $this->options_obj->google->ads->conversion_id) {
|
192 |
-
return true;
|
193 |
-
} else {
|
194 |
-
return false;
|
195 |
-
}
|
196 |
-
}
|
197 |
-
|
198 |
-
public function inject_order_received_page($order, $order_total, $order_item_ids, $is_new_customer)
|
199 |
-
{
|
200 |
-
// use the right function to get the currency depending on the WooCommerce version
|
201 |
-
$order_currency = $this->woocommerce_3_and_above() ? $order->get_currency() : $order->get_order_currency();
|
202 |
-
|
203 |
-
$ratings = get_option(WGACT_DB_RATINGS);
|
204 |
-
$ratings['conversions_count'] = $ratings['conversions_count'] + 1;
|
205 |
-
update_option(WGACT_DB_RATINGS, $ratings);
|
206 |
-
|
207 |
-
?>
|
208 |
-
|
209 |
-
<?php
|
210 |
-
|
211 |
-
// Only run conversion script if the payment has not failed. (has_status('completed') is too restrictive)
|
212 |
-
// Also don't run the pixel if an admin or shop manager is logged in.
|
213 |
-
if ($this->add_cart_data == 0 && $this->options_obj->google->ads->conversion_id) {
|
214 |
-
// if ( ! $order->has_status( 'failed' ) ) {
|
215 |
-
?>
|
216 |
-
|
217 |
-
<?php
|
218 |
-
if ($this->options_obj->google->ads->conversion_label): ?>
|
219 |
-
|
220 |
-
<script>
|
221 |
-
// no deduper needed here
|
222 |
-
// Google does this server side
|
223 |
-
gtag('event', 'conversion', {
|
224 |
-
'send_to' : <?php echo json_encode($this->get_google_ads_conversion_ids(true))?>,
|
225 |
-
'value' : <?php echo $order_total; ?>,
|
226 |
-
'currency' : '<?php echo $order_currency; ?>',
|
227 |
-
'transaction_id': '<?php echo $order->get_order_number(); ?>',
|
228 |
-
});
|
229 |
-
</script>
|
230 |
-
<?php
|
231 |
-
endif; ?>
|
232 |
-
|
233 |
-
<?php
|
234 |
-
echo $this->get_dyn_remarketing_purchase_script($order, $order_total) ?>
|
235 |
-
|
236 |
-
<?php
|
237 |
-
}
|
238 |
-
|
239 |
-
if ($this->add_cart_data == 1 || $this->is_google_analytics_active()) {
|
240 |
-
?>
|
241 |
-
|
242 |
-
<script>
|
243 |
-
|
244 |
-
<?php if ($this->add_cart_data && $this->conversion_id && $this->conversion_label ): ?>
|
245 |
-
gtag('event', 'purchase', <?php echo $this->get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer, 'ads') ?>);
|
246 |
-
<?php endif; ?>
|
247 |
-
|
248 |
-
if ((typeof wgact !== "undefined") && !wgact.isOrderIdStored(<?php echo $order->get_id() ?>)) {
|
249 |
-
<?php if ($this->is_google_analytics_active() ): ?>
|
250 |
-
gtag('event', 'purchase', <?php echo $this->get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer, 'analytics') ?>);
|
251 |
-
<?php endif; ?>
|
252 |
-
}
|
253 |
-
</script>
|
254 |
-
<?php
|
255 |
-
}
|
256 |
-
|
257 |
-
?>
|
258 |
-
|
259 |
-
<?php
|
260 |
-
}
|
261 |
-
|
262 |
-
private function get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer, $channel)
|
263 |
-
{
|
264 |
-
$gtag_data = [
|
265 |
-
'send_to' => [],
|
266 |
-
'transaction_id' => $order->get_order_number(),
|
267 |
-
'currency' => $order_currency,
|
268 |
-
'discount' => $order->get_total_discount(),
|
269 |
-
'items' => $this->get_gads_formatted_order_items($order),
|
270 |
-
];
|
271 |
-
|
272 |
-
if ('ads' === $channel) {
|
273 |
-
array_push($gtag_data['send_to'], $this->get_google_ads_conversion_ids(true));
|
274 |
-
$gtag_data['value'] = $order_total;
|
275 |
-
$gtag_data['aw_merchant_id'] = $this->aw_merchant_id;
|
276 |
-
$gtag_data['aw_feed_country'] = $this->get_visitor_country();
|
277 |
-
$gtag_data['aw_feed_language'] = $this->get_gmc_language();
|
278 |
-
$gtag_data['new_customer'] = $is_new_customer;
|
279 |
-
}
|
280 |
-
|
281 |
-
if ('analytics' === $channel) {
|
282 |
-
if ($this->options_obj->google->analytics->universal->property_id) array_push($gtag_data['send_to'], $this->options_obj->google->analytics->universal->property_id);
|
283 |
-
if ($this->options_obj->google->analytics->ga4->measurement_id) array_push($gtag_data['send_to'], $this->options_obj->google->analytics->ga4->measurement_id);
|
284 |
-
$gtag_data['affiliation'] = (string)get_bloginfo('name');
|
285 |
-
$gtag_data['tax'] = (string)$order->get_total_tax();
|
286 |
-
$gtag_data['shipping'] = (string)$order->get_total_shipping();
|
287 |
-
$gtag_data['value'] = (float)$order->get_total();
|
288 |
-
}
|
289 |
-
|
290 |
-
return json_encode($gtag_data);
|
291 |
-
}
|
292 |
-
|
293 |
-
private function is_google_analytics_active(): bool
|
294 |
-
{
|
295 |
-
if ($this->options_obj->google->analytics->universal->property_id) {
|
296 |
-
return true;
|
297 |
-
} elseif ($this->options_obj->google->analytics->ga4->measurement_id) {
|
298 |
-
return true;
|
299 |
-
} else {
|
300 |
-
return false;
|
301 |
-
}
|
302 |
-
}
|
303 |
-
|
304 |
-
|
305 |
-
protected function woocommerce_3_and_above(): bool
|
306 |
-
{
|
307 |
-
global $woocommerce;
|
308 |
-
if (version_compare($woocommerce->version, 3.0, ">=")) {
|
309 |
-
return true;
|
310 |
-
} else {
|
311 |
-
return false;
|
312 |
-
}
|
313 |
-
}
|
314 |
-
|
315 |
-
protected function get_gmc_language(): string
|
316 |
-
{
|
317 |
-
return strtoupper(substr(get_locale(), 0, 2));
|
318 |
-
}
|
319 |
-
|
320 |
-
protected function get_gads_formatted_order_items($order)
|
321 |
-
{
|
322 |
-
$order_items = $order->get_items();
|
323 |
-
$order_items_array = [];
|
324 |
-
|
325 |
-
foreach ((array)$order_items as $item) {
|
326 |
-
|
327 |
-
$product = wc_get_product($item['product_id']);
|
328 |
-
|
329 |
-
$item_details_array = [];
|
330 |
-
|
331 |
-
$item_details_array['id'] = $this->get_compiled_product_id($item['product_id'], $product->get_sku());
|
332 |
-
$item_details_array['quantity'] = (int)$item['quantity'];
|
333 |
-
$item_details_array['price'] = (int)$product->get_price();
|
334 |
-
$item_details_array['google_business_vertical'] = $this->google_business_vertical;
|
335 |
-
|
336 |
-
if ($this->is_google_analytics_active()) {
|
337 |
-
$item_details_array['name'] = (string)$product->get_name();
|
338 |
-
// $item_details_array['list_name'] = '';
|
339 |
-
// $item_details_array['brand'] = '';
|
340 |
-
$item_details_array['category'] = $this->get_product_category($item['product_id']);
|
341 |
-
// $item_details_array['variant'] = '';
|
342 |
-
// $item_details_array['list_position'] = 1;
|
343 |
-
}
|
344 |
-
|
345 |
-
array_push($order_items_array, $item_details_array);
|
346 |
-
}
|
347 |
-
|
348 |
-
// apply filter to the $order_items_array array
|
349 |
-
$order_items_array = apply_filters('wgact_filter', $order_items_array, 'order_items_array');
|
350 |
-
|
351 |
-
return $order_items_array;
|
352 |
-
}
|
353 |
-
|
354 |
-
|
355 |
-
// get products from wp_query
|
356 |
-
protected function get_products_from_wp_query($wp_query): array
|
357 |
-
{
|
358 |
-
$items = [];
|
359 |
-
|
360 |
-
$posts = $wp_query->posts;
|
361 |
-
|
362 |
-
foreach ($posts as $key => $post) {
|
363 |
-
|
364 |
-
if ($post->post_type == 'product') {
|
365 |
-
|
366 |
-
$item_details = [];
|
367 |
-
|
368 |
-
$product = wc_get_product($post->ID);
|
369 |
-
$item_details['id'] = $this->get_compiled_product_id($post->ID, $product->get_sku());
|
370 |
-
$item_details['google_business_vertical'] = $this->google_business_vertical;
|
371 |
-
|
372 |
-
array_push($items, $item_details);
|
373 |
-
}
|
374 |
-
}
|
375 |
-
|
376 |
-
return $items;
|
377 |
-
}
|
378 |
-
|
379 |
-
protected function gtag_config($id, $channel = ''): string
|
380 |
-
{
|
381 |
-
if ('ads' === $channel) {
|
382 |
-
return "gtag('config', 'AW-" . $id . "');" . PHP_EOL;
|
383 |
-
} elseif ('analytics') {
|
384 |
-
return "gtag('config', '" . $id . "', { 'anonymize_ip': true });";
|
385 |
-
}
|
386 |
-
}
|
387 |
-
|
388 |
-
protected function get_gads_formatted_product_details_from_product_id($product_id): array
|
389 |
-
{
|
390 |
-
$product = wc_get_product($product_id);
|
391 |
-
|
392 |
-
$product_details['id'] = $this->get_compiled_product_id(get_the_ID(), $product->get_sku());
|
393 |
-
$product_details['category'] = $this->get_product_category($product_id);
|
394 |
-
// $product_details['list_position'] = 1;
|
395 |
-
$product_details['quantity'] = 1;
|
396 |
-
$product_details['price'] = (float)$product->get_price();
|
397 |
-
$product_details['google_business_vertical'] = $this->google_business_vertical;
|
398 |
-
|
399 |
-
return $product_details;
|
400 |
-
}
|
401 |
-
|
402 |
-
// get an array with all cart product ids
|
403 |
-
protected function get_gads_formatted_cart_items($cart)
|
404 |
-
{
|
405 |
-
// error_log(print_r($cart, true));
|
406 |
-
// initiate product identifier array
|
407 |
-
$cart_items = [];
|
408 |
-
$item_details = [];
|
409 |
-
|
410 |
-
// go through the array and get all product identifiers
|
411 |
-
foreach ((array)$cart as $item) {
|
412 |
-
|
413 |
-
$product = wc_get_product($item['product_id']);
|
414 |
-
|
415 |
-
$item_details['id'] = $this->get_compiled_product_id($item['product_id'], $product->get_sku());
|
416 |
-
$item_details['quantity'] = (int)$item['quantity'];
|
417 |
-
$item_details['price'] = (int)$product->get_price();
|
418 |
-
$item_details['google_business_vertical'] = $this->google_business_vertical;
|
419 |
-
|
420 |
-
array_push($cart_items, $item_details);
|
421 |
-
}
|
422 |
-
|
423 |
-
// apply filter to the $cartprods_items array
|
424 |
-
$cart_items = apply_filters('wgact_filter', $cart_items, 'cart_items');
|
425 |
-
|
426 |
-
return $cart_items;
|
427 |
-
}
|
428 |
-
|
429 |
-
protected function get_dyn_remarketing_purchase_script($order, $order_total)
|
430 |
-
{
|
431 |
-
if ($this->is_dynamic_remarketing_active()) {
|
432 |
-
|
433 |
-
?>
|
434 |
-
|
435 |
-
<script>
|
436 |
-
if ((typeof wgact !== "undefined") && !wgact.isOrderIdStored(<?php echo $order->get_id() ?>)) {
|
437 |
-
gtag('event', 'purchase', {
|
438 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
439 |
-
'value' : <?php echo $order_total; ?>,
|
440 |
-
'items' : <?php echo (json_encode($this->get_gads_formatted_order_items($order))) . PHP_EOL ?>
|
441 |
-
});
|
442 |
-
}
|
443 |
-
</script>
|
444 |
-
<?php
|
445 |
-
}
|
446 |
-
}
|
447 |
-
|
448 |
-
protected function get_google_business_vertical($id): string
|
449 |
-
{
|
450 |
-
$verticals = [
|
451 |
-
0 => 'retail',
|
452 |
-
1 => 'education',
|
453 |
-
2 => 'flights',
|
454 |
-
3 => 'hotel_rental',
|
455 |
-
4 => 'jobs',
|
456 |
-
5 => 'local',
|
457 |
-
6 => 'real_estate',
|
458 |
-
7 => 'travel',
|
459 |
-
8 => 'custom'
|
460 |
-
];
|
461 |
-
|
462 |
-
return $verticals[$id];
|
463 |
-
}
|
464 |
-
|
465 |
-
private function get_google_ads_conversion_ids($purchase = false): array
|
466 |
-
{
|
467 |
-
$formatted_conversion_ids = [];
|
468 |
-
if ($purchase) {
|
469 |
-
foreach ($this->conversion_identifiers as $conversion_id => $conversion_label) {
|
470 |
-
array_push($formatted_conversion_ids, 'AW-' . $conversion_id . '/' . $conversion_label);
|
471 |
-
}
|
472 |
-
} else {
|
473 |
-
foreach ($this->conversion_identifiers as $conversion_id => $conversion_label) {
|
474 |
-
array_push($formatted_conversion_ids, 'AW-' . $conversion_id);
|
475 |
-
}
|
476 |
-
}
|
477 |
-
return $formatted_conversion_ids;
|
478 |
-
}
|
479 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/class-hotjar.php
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Hotjar extends Pixel
|
10 |
-
{
|
11 |
-
public function inject_everywhere()
|
12 |
-
{
|
13 |
-
// @formatter:off
|
14 |
-
?>
|
15 |
-
|
16 |
-
<script>
|
17 |
-
(function(h,o,t,j,a,r){
|
18 |
-
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
|
19 |
-
h._hjSettings={hjid:<?php echo $this->options_obj->hotjar->site_id ?>,hjsv:6};
|
20 |
-
a=o.getElementsByTagName('head')[0];
|
21 |
-
r=o.createElement('script');r.async=1;
|
22 |
-
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
|
23 |
-
a.appendChild(r);
|
24 |
-
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
|
25 |
-
</script>
|
26 |
-
<?php
|
27 |
-
// @formatter:on
|
28 |
-
}
|
29 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/class-pinterest.php
DELETED
@@ -1,100 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// TODO add enhanced match email hash to uncached pages like cart and purchase confirmation page
|
4 |
-
// TODO check if more values can be passed to product and category pages
|
5 |
-
|
6 |
-
namespace WGACT\Classes\Pixels;
|
7 |
-
|
8 |
-
if (!defined('ABSPATH')) {
|
9 |
-
exit; // Exit if accessed directly
|
10 |
-
}
|
11 |
-
|
12 |
-
class Pinterest extends Pixel
|
13 |
-
{
|
14 |
-
public function inject_everywhere()
|
15 |
-
{
|
16 |
-
// @formatter:off
|
17 |
-
?>
|
18 |
-
|
19 |
-
<script>
|
20 |
-
!function(e){if(!window.pintrk){window.pintrk = function () {
|
21 |
-
window.pintrk.queue.push(Array.prototype.slice.call(arguments))};var
|
22 |
-
n=window.pintrk;n.queue=[],n.version="3.0";var
|
23 |
-
t=document.createElement("script");t.async=!0,t.src=e;var
|
24 |
-
r=document.getElementsByTagName("script")[0];
|
25 |
-
r.parentNode.insertBefore(t,r)}}("https://s.pinimg.com/ct/core.js");
|
26 |
-
// pintrk('load', '1111111111111', {em: '<user_email_address>'});
|
27 |
-
pintrk('load', '<?php echo $this->options_obj->pinterest->pixel_id ?>');
|
28 |
-
pintrk('page');
|
29 |
-
</script>
|
30 |
-
<?php
|
31 |
-
// @formatter:on
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
public function inject_product_category()
|
36 |
-
{
|
37 |
-
?>
|
38 |
-
<script>
|
39 |
-
pintrk('track', 'viewcategory');
|
40 |
-
</script>
|
41 |
-
<?php
|
42 |
-
|
43 |
-
}
|
44 |
-
|
45 |
-
public function inject_search()
|
46 |
-
{
|
47 |
-
|
48 |
-
?>
|
49 |
-
<script>
|
50 |
-
pintrk('track', 'search', {
|
51 |
-
search_query: '<?php echo get_search_query() ?>'
|
52 |
-
});
|
53 |
-
</script>
|
54 |
-
<?php
|
55 |
-
|
56 |
-
}
|
57 |
-
|
58 |
-
public function inject_product($product_id, $product)
|
59 |
-
{
|
60 |
-
?>
|
61 |
-
|
62 |
-
<script>
|
63 |
-
pintrk('track', 'pagevisit');
|
64 |
-
</script>
|
65 |
-
<?php
|
66 |
-
}
|
67 |
-
|
68 |
-
public function inject_cart($cart, $cart_total)
|
69 |
-
{
|
70 |
-
?>
|
71 |
-
|
72 |
-
<script>
|
73 |
-
pintrk('track', 'addtocart', {
|
74 |
-
value : <?php echo $cart_total ?>,
|
75 |
-
order_quantity: <?php echo count($cart) ?>,
|
76 |
-
currency : '<?php echo get_woocommerce_currency() ?>'
|
77 |
-
});
|
78 |
-
</script>
|
79 |
-
|
80 |
-
<?php
|
81 |
-
}
|
82 |
-
|
83 |
-
public function inject_order_received_page($order, $order_total, $order_item_ids)
|
84 |
-
{
|
85 |
-
?>
|
86 |
-
|
87 |
-
<script>
|
88 |
-
if ((typeof wgact !== "undefined") && !wgact.isOrderIdStored(<?php echo $order->get_id() ?>)) {
|
89 |
-
pintrk('track', 'checkout', {
|
90 |
-
value : <?php echo $order_total ?>,
|
91 |
-
order_quantity: <?php echo count($order->get_items()) ?>,
|
92 |
-
currency : '<?php echo $order->get_currency() ?>',
|
93 |
-
order_id : '<?php echo $order->get_order_number(); ?>',
|
94 |
-
product_ids : <?php echo json_encode($order_item_ids) ?>
|
95 |
-
});
|
96 |
-
}
|
97 |
-
</script>
|
98 |
-
<?php
|
99 |
-
}
|
100 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/class-pixel-manager.php
CHANGED
@@ -2,56 +2,46 @@
|
|
2 |
|
3 |
namespace WCPM\Classes\Pixels;
|
4 |
|
5 |
-
use stdClass ;
|
6 |
-
use WC_Order ;
|
7 |
-
use WCPM\Classes\Admin\Environment_Check ;
|
8 |
-
use WCPM\Classes\Pixels\Bing\Bing_Pixel_Manager ;
|
9 |
use WCPM\Classes\Pixels\Facebook\Facebook_Pixel_Manager ;
|
10 |
use WCPM\Classes\Pixels\Facebook\Facebook_Pixel_Manager_Microdata ;
|
|
|
11 |
use WCPM\Classes\Pixels\Google\Google_Analytics_Refund ;
|
12 |
use WCPM\Classes\Pixels\Google\Google_Pixel_Manager ;
|
13 |
-
use WCPM\Classes\Pixels\Google\Trait_Google ;
|
14 |
-
use WCPM\Classes\Pixels\Hotjar\Hotjar_Pixel ;
|
15 |
-
use WCPM\Classes\Pixels\Pinterest\Pinterest_Pixel_Manager ;
|
16 |
-
use WCPM\Classes\Pixels\Snapchat\Snapchat_Pixel_Manager ;
|
17 |
-
use WCPM\Classes\Pixels\TikTok\TikTok_Pixel_Manager ;
|
18 |
-
use WCPM\Classes\Pixels\Twitter\Twitter_Pixel_Manager ;
|
19 |
|
20 |
if ( !defined( 'ABSPATH' ) ) {
|
21 |
exit;
|
22 |
// Exit if accessed directly
|
23 |
}
|
24 |
|
25 |
-
class Pixel_Manager extends
|
26 |
{
|
27 |
use Trait_Product ;
|
28 |
-
use Trait_Google ;
|
29 |
use Trait_Shop ;
|
30 |
protected $options ;
|
31 |
protected $options_obj ;
|
32 |
protected $cart ;
|
33 |
protected $facebook_active ;
|
34 |
protected $google_active ;
|
35 |
-
protected $transaction_deduper_timeout = 1000 ;
|
36 |
-
protected $hotjar_pixel ;
|
37 |
protected $dyn_r_ids ;
|
|
|
38 |
protected $position = 1 ;
|
|
|
39 |
public function __construct( $options )
|
40 |
{
|
41 |
-
|
42 |
* Initialize options
|
43 |
*/
|
44 |
-
// $this->options = get_option(WPM_DB_OPTIONS_NAME);
|
45 |
$this->options = $options;
|
46 |
-
$this->options_obj = json_decode(
|
47 |
-
$this->options_obj->shop->currency = new stdClass();
|
48 |
$this->options_obj->shop->currency = get_woocommerce_currency();
|
49 |
-
|
50 |
* Set a few states
|
51 |
*/
|
52 |
$this->facebook_active = !empty($this->options_obj->facebook->pixel_id);
|
53 |
-
$this->google_active
|
54 |
-
|
|
|
|
|
55 |
* Inject pixel snippets in head
|
56 |
*/
|
57 |
// add_action('wp_head', function () {
|
@@ -59,12 +49,9 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
59 |
// });
|
60 |
add_action( 'wp_head', function () {
|
61 |
$this->inject_wpm_opening();
|
62 |
-
$this->
|
63 |
-
$this->inject_data_layer_shop();
|
64 |
-
$this->inject_data_layer_general();
|
65 |
-
// $this->inject_data_layer_product();
|
66 |
} );
|
67 |
-
|
68 |
* Initialize all pixels
|
69 |
*/
|
70 |
if ( $this->google_active ) {
|
@@ -73,9 +60,6 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
73 |
if ( $this->facebook_active ) {
|
74 |
new Facebook_Pixel_Manager( $this->options );
|
75 |
}
|
76 |
-
if ( $this->options_obj->hotjar->site_id ) {
|
77 |
-
$this->hotjar_pixel = new Hotjar_Pixel( $this->options );
|
78 |
-
}
|
79 |
add_action( 'wp_head', function () {
|
80 |
$this->inject_wpm_closing();
|
81 |
// if( isset(WC()->session)) {
|
@@ -83,17 +67,28 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
83 |
// error_log(print_r(WC()->session,true));
|
84 |
// }
|
85 |
} );
|
86 |
-
|
87 |
* Front-end script section
|
88 |
*/
|
89 |
-
|
|
|
|
|
90 |
add_action( 'wp_ajax_wpm_get_cart_items', [ $this, 'ajax_wpm_get_cart_items' ] );
|
91 |
add_action( 'wp_ajax_nopriv_wpm_get_cart_items', [ $this, 'ajax_wpm_get_cart_items' ] );
|
92 |
add_action( 'wp_ajax_wpm_get_product_ids', [ $this, 'ajax_wpm_get_product_ids' ] );
|
93 |
add_action( 'wp_ajax_nopriv_wpm_get_product_ids', [ $this, 'ajax_wpm_get_product_ids' ] );
|
94 |
add_action( 'wp_ajax_wpm_purchase_pixels_fired', [ $this, 'ajax_purchase_pixels_fired_handler' ] );
|
95 |
add_action( 'wp_ajax_nopriv_wpm_purchase_pixels_fired', [ $this, 'ajax_purchase_pixels_fired_handler' ] );
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
* Inject pixel snippets after <body> tag
|
98 |
*/
|
99 |
if ( did_action( 'wp_body_open' ) ) {
|
@@ -101,11 +96,11 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
101 |
$this->inject_body_pixels();
|
102 |
} );
|
103 |
}
|
104 |
-
|
105 |
* Inject pixel snippets into wp_footer
|
106 |
*/
|
107 |
add_action( 'wp_footer', [ $this, 'wpm_wp_footer' ] );
|
108 |
-
|
109 |
* Process short codes
|
110 |
*/
|
111 |
new Shortcodes( $this->options );
|
@@ -138,6 +133,16 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
138 |
add_action( 'woocommerce_mini_cart_contents', [ $this, 'woocommerce_mini_cart_contents' ] );
|
139 |
}
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
public function woocommerce_mini_cart_contents()
|
142 |
{
|
143 |
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
@@ -152,35 +157,16 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
152 |
'variation_id' => $cart_item['variation_id'],
|
153 |
];
|
154 |
?>
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
echo $cart_item_key ;
|
159 |
?>'] = <?php
|
160 |
-
echo
|
161 |
-
|
162 |
-
|
163 |
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
private function get_cart_parent_product_for_pinterest( $product_id )
|
168 |
-
{
|
169 |
-
$product = wc_get_product( $product_id );
|
170 |
-
|
171 |
-
if ( !is_object( $product ) ) {
|
172 |
-
// $this->log_problematic_product_id();
|
173 |
-
wc_get_logger()->debug( 'get_product_data_layer_script received an invalid product', [
|
174 |
-
'source' => 'wpm',
|
175 |
-
] );
|
176 |
-
return '';
|
177 |
-
}
|
178 |
-
|
179 |
-
$this->dyn_r_ids = $this->get_dyn_r_ids( $product );
|
180 |
-
return [
|
181 |
-
'id' => (string) $product->get_id(),
|
182 |
-
'dyn_r_ids' => $this->dyn_r_ids,
|
183 |
-
];
|
184 |
}
|
185 |
|
186 |
// on product page
|
@@ -191,7 +177,7 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
191 |
$product = wc_get_product( get_the_id() );
|
192 |
|
193 |
if ( is_object( $product ) ) {
|
194 |
-
|
195 |
} else {
|
196 |
wc_get_logger()->debug( 'woocommerce_inject_product_data_on_product_page provided no product on a product page: .' . get_the_id(), [
|
197 |
'source' => 'wpm',
|
@@ -203,7 +189,7 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
203 |
$product = wc_get_product( $product_id );
|
204 |
|
205 |
if ( is_object( $product ) ) {
|
206 |
-
|
207 |
} else {
|
208 |
$this->log_problematic_product_id( $product_id );
|
209 |
}
|
@@ -211,12 +197,16 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
211 |
}
|
212 |
}
|
213 |
if ( $product->is_type( 'variable' ) ) {
|
214 |
-
/**
|
|
|
|
|
|
|
|
|
215 |
foreach ( $product->get_available_variations() as $key => $variation ) {
|
216 |
$variable_product = wc_get_product( $variation['variation_id'] );
|
217 |
|
218 |
if ( is_object( $variable_product ) ) {
|
219 |
-
|
220 |
} else {
|
221 |
$this->log_problematic_product_id( $variation['variation_id'] );
|
222 |
}
|
@@ -231,13 +221,13 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
231 |
public function action_woocommerce_after_shop_loop_item()
|
232 |
{
|
233 |
global $product ;
|
234 |
-
|
235 |
}
|
236 |
|
237 |
// product views generated by a gutenberg block instead of a shortcode
|
238 |
-
function wc_add_date_to_gutenberg_block( $html, $data, $product )
|
239 |
{
|
240 |
-
return $html . $this->
|
241 |
}
|
242 |
|
243 |
public function wpm_wp_footer()
|
@@ -248,13 +238,28 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
248 |
}
|
249 |
|
250 |
// https://support.cloudflare.com/hc/en-us/articles/200169436-How-can-I-have-Rocket-Loader-ignore-specific-JavaScripts-
|
251 |
-
private function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
{
|
253 |
$data = [
|
254 |
-
'cart' => [],
|
255 |
-
'cart_item_keys' => [],
|
256 |
-
'
|
257 |
-
'orderDeduplication' => ( $this->options['shop']['order_deduplication'] && !$this->is_nodedupe_parameter_set() ? true : false ),
|
258 |
'position' => 1,
|
259 |
'viewItemListTrigger' => $this->view_item_list_trigger_settings(),
|
260 |
'version' => [
|
@@ -262,30 +267,187 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
262 |
'pro' => wpm_fs()->is__premium_only(),
|
263 |
],
|
264 |
];
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
}
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
echo json_encode( $data, JSON_FORCE_OBJECT ) ;
|
281 |
-
?>;
|
282 |
-
|
283 |
-
</script>
|
284 |
-
|
285 |
-
<?php
|
286 |
}
|
287 |
|
288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
{
|
290 |
$settings = [
|
291 |
'testMode' => false,
|
@@ -306,29 +468,20 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
306 |
|
307 |
public function inject_wpm_opening()
|
308 |
{
|
309 |
-
if ( ( new Environment_Check() )->is_autoptimize_active() ) {
|
310 |
-
$this->inject_noptimize_opening_tag();
|
311 |
-
}
|
312 |
echo PHP_EOL . '<!-- START WooCommerce Pixel Manager -->' . PHP_EOL ;
|
313 |
}
|
314 |
|
315 |
public function inject_wpm_closing()
|
316 |
{
|
317 |
-
if ( $this->options_obj->hotjar->site_id ) {
|
318 |
-
$this->hotjar_pixel->inject_everywhere();
|
319 |
-
}
|
320 |
if ( is_order_received_page() ) {
|
321 |
|
322 |
-
if ( $
|
323 |
-
$
|
324 |
$this->increase_conversion_count_for_ratings( $order );
|
325 |
}
|
326 |
|
327 |
}
|
328 |
echo PHP_EOL . '<!-- END WooCommerce Pixel Manager -->' . PHP_EOL ;
|
329 |
-
if ( ( new Environment_Check() )->is_autoptimize_active() ) {
|
330 |
-
$this->inject_noptimize_closing_tag();
|
331 |
-
}
|
332 |
}
|
333 |
|
334 |
private function increase_conversion_count_for_ratings( $order )
|
@@ -350,8 +503,6 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
350 |
$cart_items = $woocommerce->cart->get_cart();
|
351 |
$data = [];
|
352 |
foreach ( $cart_items as $cart_item => $value ) {
|
353 |
-
// error_log('qty: ' . $value['quantity']);
|
354 |
-
// error_log(print_r($value['data'], true));
|
355 |
$product = wc_get_product( $value['data']->get_id() );
|
356 |
|
357 |
if ( !is_object( $product ) ) {
|
@@ -373,7 +524,7 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
373 |
'isVariation' => false,
|
374 |
];
|
375 |
|
376 |
-
if ( $product->get_type()
|
377 |
$parent_product = wc_get_product( $product->get_parent_id() );
|
378 |
|
379 |
if ( $parent_product ) {
|
@@ -404,13 +555,13 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
404 |
}
|
405 |
|
406 |
}
|
407 |
-
// error_log(print_r($data, true));
|
408 |
wp_send_json( $data );
|
409 |
}
|
410 |
|
411 |
public function ajax_wpm_get_product_ids()
|
412 |
{
|
413 |
-
$
|
|
|
414 |
|
415 |
if ( !$product_ids ) {
|
416 |
wp_send_json_error();
|
@@ -439,15 +590,13 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
439 |
|
440 |
public function ajax_purchase_pixels_fired_handler()
|
441 |
{
|
442 |
-
// error_log('test save');
|
443 |
// if (!check_ajax_referer('wpm-premium-only-nonce', 'nonce', false)) {
|
444 |
-
// error_log('post nonce: ' . $_POST['nonce']);
|
445 |
-
// if (!wp_verify_nonce($_POST['nonce'], $_POST['action'])) {
|
446 |
// wp_send_json_error('Invalid security token sent.');
|
447 |
// error_log('Invalid security token sent.');
|
448 |
// wp_die();
|
449 |
// }
|
450 |
-
$
|
|
|
451 |
update_post_meta( $order_id, '_wpm_conversion_pixel_fired', true );
|
452 |
wp_send_json_success();
|
453 |
wp_die();
|
@@ -457,13 +606,14 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
457 |
public function wpm_front_end_scripts()
|
458 |
{
|
459 |
$wpm_dependencies = [ 'jquery' ];
|
|
|
460 |
|
461 |
if ( wpm_fs()->is__premium_only() && apply_filters( 'wpm_experimental_inject_polyfill_io', false ) ) {
|
462 |
wp_enqueue_script(
|
463 |
'polyfill-io',
|
464 |
'https://cdn.polyfill.io/v2/polyfill.min.js',
|
465 |
false,
|
466 |
-
|
467 |
false
|
468 |
);
|
469 |
$wpm_dependencies[] = 'polyfill-io';
|
@@ -474,7 +624,7 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
474 |
WPM_PLUGIN_DIR_PATH . 'js/public/wpm-public.p1.min.js',
|
475 |
$wpm_dependencies,
|
476 |
WPM_CURRENT_VERSION,
|
477 |
-
|
478 |
);
|
479 |
wp_localize_script(
|
480 |
'wpm',
|
@@ -484,19 +634,15 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
484 |
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
485 |
]
|
486 |
);
|
487 |
-
// if (wpm_fs()->is__premium_only()) {
|
488 |
-
//
|
489 |
-
// wp_enqueue_script(
|
490 |
-
// 'wpm-premium-only',
|
491 |
-
// WPM_PLUGIN_DIR_PATH . 'js/public/head/wpm__premium_only' . $this->get_script_suffix(),
|
492 |
-
// ['jquery', 'wpm'],
|
493 |
-
// WPM_CURRENT_VERSION,
|
494 |
-
// false
|
495 |
-
// );
|
496 |
-
// }
|
497 |
}
|
498 |
|
499 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
{
|
501 |
return '.p' . apply_filters( 'wpm_script_optimization_preset_version', 1 );
|
502 |
}
|
@@ -511,7 +657,7 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
511 |
// $this->google_pixel_manager->inject_google_optimize_anti_flicker_snippet();
|
512 |
}
|
513 |
|
514 |
-
private function
|
515 |
{
|
516 |
$data = [];
|
517 |
|
@@ -572,196 +718,36 @@ class Pixel_Manager extends Pixel_Manager_Base
|
|
572 |
}
|
573 |
|
574 |
$data['currency'] = get_woocommerce_currency();
|
575 |
-
$data['mini_cart']['track'] = apply_filters_deprecated(
|
|
|
|
|
|
|
576 |
'wooptpm_track_mini_cart',
|
577 |
[ true ],
|
578 |
'1.13.0',
|
579 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
);
|
581 |
-
$data['mini_cart']['track'] = apply_filters( 'wpm_track_mini_cart', $data['mini_cart']['track'] );
|
582 |
$data['cookie_consent_mgmt'] = [
|
583 |
'explicit_consent' => (bool) $this->options_obj->shop->cookie_consent_mgmt->explicit_consent,
|
584 |
];
|
585 |
-
|
586 |
-
|
587 |
-
<script>
|
588 |
-
wpmDataLayer.shop = <?php
|
589 |
-
echo json_encode( $data ) ;
|
590 |
-
?>;
|
591 |
-
</script>
|
592 |
-
<?php
|
593 |
-
if ( $this->options_obj->shop->cookie_consent_mgmt->explicit_consent ) {
|
594 |
-
?>
|
595 |
-
|
596 |
-
<script>
|
597 |
-
if (typeof wpm != "undefined") {
|
598 |
-
wpm.updateConsentCookieValues(true)
|
599 |
-
} else {
|
600 |
-
console.error('wpm is not defined. That means you are deferring the script which you shouldn\'t. wpm must be loaded before the inline scripts run. Visitor tracking will continue to work, but explicit consent mode will be ignored.')
|
601 |
-
}
|
602 |
-
</script>
|
603 |
-
<?php
|
604 |
-
}
|
605 |
}
|
606 |
|
607 |
-
private function
|
608 |
{
|
609 |
$data = [
|
610 |
'variationsOutput' => (bool) $this->options_obj->general->variations_output,
|
|
|
611 |
];
|
612 |
-
?>
|
613 |
-
|
614 |
-
<script>
|
615 |
-
wpmDataLayer.general = <?php
|
616 |
-
echo json_encode( $data ) ;
|
617 |
-
?>;
|
618 |
-
</script>
|
619 |
-
<?php
|
620 |
-
}
|
621 |
-
|
622 |
-
private function inject_data_layer_product()
|
623 |
-
{
|
624 |
-
global $wp_query, $woocommerce ;
|
625 |
-
|
626 |
-
if ( is_shop() || is_product_category() || is_product_tag() || is_search() ) {
|
627 |
-
// if (!is_cart() || !is_order_received_page()) {
|
628 |
-
$product_ids = [];
|
629 |
-
$posts = $wp_query->posts;
|
630 |
-
foreach ( $posts as $key => $post ) {
|
631 |
-
if ( $post->post_type == 'product' || $post->post_type == 'product_variation' ) {
|
632 |
-
array_push( $product_ids, $post->ID );
|
633 |
-
}
|
634 |
-
}
|
635 |
-
?>
|
636 |
-
|
637 |
-
<script>
|
638 |
-
wpmDataLayer.visible_products = <?php
|
639 |
-
echo json_encode( $this->eec_get_visible_products( $product_ids ) ) ;
|
640 |
-
?>;
|
641 |
-
</script>
|
642 |
-
<?php
|
643 |
-
} elseif ( is_cart() ) {
|
644 |
-
$visible_product_ids = [];
|
645 |
-
$upsell_product_ids = [];
|
646 |
-
$items = $woocommerce->cart->get_cart();
|
647 |
-
foreach ( $items as $item => $values ) {
|
648 |
-
array_push( $visible_product_ids, $values['data']->get_id() );
|
649 |
-
$product = wc_get_product( $values['data']->get_id() );
|
650 |
-
// only continue if WC retrieves a valid product
|
651 |
-
|
652 |
-
if ( is_object( $product ) ) {
|
653 |
-
$single_product_upsell_ids = $product->get_upsell_ids();
|
654 |
-
// error_log(print_r($single_product_upsell_ids,true));
|
655 |
-
foreach ( $single_product_upsell_ids as $item => $value ) {
|
656 |
-
// error_log('item ' . $item);
|
657 |
-
// error_log('value' . $value);
|
658 |
-
if ( !in_array( $value, $upsell_product_ids, true ) ) {
|
659 |
-
array_push( $upsell_product_ids, $value );
|
660 |
-
}
|
661 |
-
}
|
662 |
-
}
|
663 |
-
|
664 |
-
}
|
665 |
-
// error_log(print_r($upsell_product_ids,true));
|
666 |
-
?>
|
667 |
-
|
668 |
-
<script>
|
669 |
-
wpmDataLayer.visible_products = <?php
|
670 |
-
echo json_encode( $this->eec_get_visible_products( $visible_product_ids ) ) ;
|
671 |
-
?>;
|
672 |
-
wpmDataLayer.upsell_products = <?php
|
673 |
-
echo json_encode( $this->eec_get_visible_products( $upsell_product_ids ) ) ;
|
674 |
-
?>;
|
675 |
-
</script>
|
676 |
-
<?php
|
677 |
-
} elseif ( is_product() ) {
|
678 |
-
$visible_product_ids = [];
|
679 |
-
$product = wc_get_product();
|
680 |
-
array_push( $visible_product_ids, $product->get_id() );
|
681 |
-
$related_products = wc_get_related_products( $product->get_id() );
|
682 |
-
foreach ( $related_products as $item => $value ) {
|
683 |
-
array_push( $visible_product_ids, $value );
|
684 |
-
}
|
685 |
-
$upsell_product_ids = $product->get_upsell_ids();
|
686 |
-
foreach ( $upsell_product_ids as $item => $value ) {
|
687 |
-
array_push( $visible_product_ids, $value );
|
688 |
-
}
|
689 |
-
// error_log(print_r($visible_product_ids, true));
|
690 |
-
if ( $product->get_type() === 'grouped' ) {
|
691 |
-
$visible_product_ids = array_merge( $visible_product_ids, $product->get_children() );
|
692 |
-
}
|
693 |
-
?>
|
694 |
-
|
695 |
-
<script>
|
696 |
-
wpmDataLayer.visible_products = <?php
|
697 |
-
echo json_encode( $this->eec_get_visible_products( $visible_product_ids ) ) ;
|
698 |
-
?>;
|
699 |
-
</script>
|
700 |
-
<?php
|
701 |
-
}
|
702 |
-
|
703 |
-
}
|
704 |
-
|
705 |
-
private function eec_get_visible_products( $product_ids ) : array
|
706 |
-
{
|
707 |
-
// error_log(print_r($product_ids, true));
|
708 |
-
$data = [];
|
709 |
-
$position = 1;
|
710 |
-
foreach ( $product_ids as $key => $product_id ) {
|
711 |
-
$product = wc_get_product( $product_id );
|
712 |
-
// only continue if WC retrieves a valid product
|
713 |
-
|
714 |
-
if ( is_object( $product ) ) {
|
715 |
-
$this->dyn_r_ids = $this->get_dyn_r_ids( $product );
|
716 |
-
$data[$product->get_id()] = [
|
717 |
-
'id' => (string) $product->get_id(),
|
718 |
-
'sku' => (string) $product->get_sku(),
|
719 |
-
'name' => (string) $product->get_name(),
|
720 |
-
'price' => (int) $product->get_price(),
|
721 |
-
'brand' => $this->get_brand_name( $product->get_id() ),
|
722 |
-
'category' => (array) $this->get_product_category( $product->get_id() ),
|
723 |
-
'quantity' => (int) 1,
|
724 |
-
'position' => (int) $position,
|
725 |
-
'dyn_r_ids' => $this->dyn_r_ids,
|
726 |
-
];
|
727 |
-
$position++;
|
728 |
-
} else {
|
729 |
-
$this->log_problematic_product_id( $product_id );
|
730 |
-
}
|
731 |
-
|
732 |
-
}
|
733 |
return $data;
|
734 |
}
|
735 |
-
|
736 |
-
protected function inject_transaction_deduper_script( $order_id )
|
737 |
-
{
|
738 |
-
// error_log('order id: ' . $order_id);
|
739 |
-
?>
|
740 |
-
|
741 |
-
<script>
|
742 |
-
jQuery(function () {
|
743 |
-
setTimeout(function () {
|
744 |
-
wpmExists().then(function () {
|
745 |
-
wpm.writeOrderIdToStorage('<?php
|
746 |
-
echo $order_id ;
|
747 |
-
?>');
|
748 |
-
});
|
749 |
-
}, <?php
|
750 |
-
echo $this->transaction_deduper_timeout ;
|
751 |
-
?>);
|
752 |
-
});
|
753 |
-
</script>
|
754 |
-
<?php
|
755 |
-
}
|
756 |
-
|
757 |
-
private function inject_noptimize_opening_tag()
|
758 |
-
{
|
759 |
-
echo PHP_EOL . '<!--noptimize-->' ;
|
760 |
-
}
|
761 |
-
|
762 |
-
private function inject_noptimize_closing_tag()
|
763 |
-
{
|
764 |
-
echo '<!--/noptimize-->' . PHP_EOL . PHP_EOL ;
|
765 |
-
}
|
766 |
|
767 |
}
|
2 |
|
3 |
namespace WCPM\Classes\Pixels;
|
4 |
|
|
|
|
|
|
|
|
|
5 |
use WCPM\Classes\Pixels\Facebook\Facebook_Pixel_Manager ;
|
6 |
use WCPM\Classes\Pixels\Facebook\Facebook_Pixel_Manager_Microdata ;
|
7 |
+
use WCPM\Classes\Pixels\Google\Google ;
|
8 |
use WCPM\Classes\Pixels\Google\Google_Analytics_Refund ;
|
9 |
use WCPM\Classes\Pixels\Google\Google_Pixel_Manager ;
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
if ( !defined( 'ABSPATH' ) ) {
|
12 |
exit;
|
13 |
// Exit if accessed directly
|
14 |
}
|
15 |
|
16 |
+
class Pixel_Manager extends Script_Manager
|
17 |
{
|
18 |
use Trait_Product ;
|
|
|
19 |
use Trait_Shop ;
|
20 |
protected $options ;
|
21 |
protected $options_obj ;
|
22 |
protected $cart ;
|
23 |
protected $facebook_active ;
|
24 |
protected $google_active ;
|
|
|
|
|
25 |
protected $dyn_r_ids ;
|
26 |
+
protected $transaction_deduper_timeout = 1000 ;
|
27 |
protected $position = 1 ;
|
28 |
+
protected $google ;
|
29 |
public function __construct( $options )
|
30 |
{
|
31 |
+
/**
|
32 |
* Initialize options
|
33 |
*/
|
|
|
34 |
$this->options = $options;
|
35 |
+
$this->options_obj = json_decode( wp_json_encode( $this->options ) );
|
|
|
36 |
$this->options_obj->shop->currency = get_woocommerce_currency();
|
37 |
+
/**
|
38 |
* Set a few states
|
39 |
*/
|
40 |
$this->facebook_active = !empty($this->options_obj->facebook->pixel_id);
|
41 |
+
// $this->google_active = $this->google_active();
|
42 |
+
$this->google = new Google( $this->options );
|
43 |
+
$this->google_active = $this->google->google_active();
|
44 |
+
/**
|
45 |
* Inject pixel snippets in head
|
46 |
*/
|
47 |
// add_action('wp_head', function () {
|
49 |
// });
|
50 |
add_action( 'wp_head', function () {
|
51 |
$this->inject_wpm_opening();
|
52 |
+
$this->inject_data_layer();
|
|
|
|
|
|
|
53 |
} );
|
54 |
+
/**
|
55 |
* Initialize all pixels
|
56 |
*/
|
57 |
if ( $this->google_active ) {
|
60 |
if ( $this->facebook_active ) {
|
61 |
new Facebook_Pixel_Manager( $this->options );
|
62 |
}
|
|
|
|
|
|
|
63 |
add_action( 'wp_head', function () {
|
64 |
$this->inject_wpm_closing();
|
65 |
// if( isset(WC()->session)) {
|
67 |
// error_log(print_r(WC()->session,true));
|
68 |
// }
|
69 |
} );
|
70 |
+
/**
|
71 |
* Front-end script section
|
72 |
*/
|
73 |
+
if ( $this->track_user() ) {
|
74 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'wpm_front_end_scripts' ] );
|
75 |
+
}
|
76 |
add_action( 'wp_ajax_wpm_get_cart_items', [ $this, 'ajax_wpm_get_cart_items' ] );
|
77 |
add_action( 'wp_ajax_nopriv_wpm_get_cart_items', [ $this, 'ajax_wpm_get_cart_items' ] );
|
78 |
add_action( 'wp_ajax_wpm_get_product_ids', [ $this, 'ajax_wpm_get_product_ids' ] );
|
79 |
add_action( 'wp_ajax_nopriv_wpm_get_product_ids', [ $this, 'ajax_wpm_get_product_ids' ] );
|
80 |
add_action( 'wp_ajax_wpm_purchase_pixels_fired', [ $this, 'ajax_purchase_pixels_fired_handler' ] );
|
81 |
add_action( 'wp_ajax_nopriv_wpm_purchase_pixels_fired', [ $this, 'ajax_purchase_pixels_fired_handler' ] );
|
82 |
+
// Experimental filter ! Can be removed without further notification
|
83 |
+
if ( apply_filters( 'wpm_experimental_defer_scripts', false ) ) {
|
84 |
+
add_filter(
|
85 |
+
'script_loader_tag',
|
86 |
+
[ $this, 'experimental_defer_scripts' ],
|
87 |
+
10,
|
88 |
+
2
|
89 |
+
);
|
90 |
+
}
|
91 |
+
/**
|
92 |
* Inject pixel snippets after <body> tag
|
93 |
*/
|
94 |
if ( did_action( 'wp_body_open' ) ) {
|
96 |
$this->inject_body_pixels();
|
97 |
} );
|
98 |
}
|
99 |
+
/**
|
100 |
* Inject pixel snippets into wp_footer
|
101 |
*/
|
102 |
add_action( 'wp_footer', [ $this, 'wpm_wp_footer' ] );
|
103 |
+
/**
|
104 |
* Process short codes
|
105 |
*/
|
106 |
new Shortcodes( $this->options );
|
133 |
add_action( 'woocommerce_mini_cart_contents', [ $this, 'woocommerce_mini_cart_contents' ] );
|
134 |
}
|
135 |
|
136 |
+
// Thanks to: https://gist.github.com/mishterk/6b7a4d6e5a91086a5a9b05ace304b5ce#file-mark-wordpress-scripts-as-async-or-defer-php
|
137 |
+
public function experimental_defer_scripts( $tag, $handle )
|
138 |
+
{
|
139 |
+
if ( 'wpm' !== $handle ) {
|
140 |
+
return $tag;
|
141 |
+
}
|
142 |
+
return str_replace( ' src', ' defer src', $tag );
|
143 |
+
// defer the script
|
144 |
+
}
|
145 |
+
|
146 |
public function woocommerce_mini_cart_contents()
|
147 |
{
|
148 |
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
157 |
'variation_id' => $cart_item['variation_id'],
|
158 |
];
|
159 |
?>
|
160 |
+
<script>
|
161 |
+
window.wpmDataLayer.cartItemKeys = window.wpmDataLayer.cartItemKeys || {}
|
162 |
+
window.wpmDataLayer.cartItemKeys['<?php
|
163 |
+
echo esc_js( $cart_item_key ) ;
|
164 |
?>'] = <?php
|
165 |
+
echo wp_json_encode( $data ) ;
|
166 |
+
?>;
|
167 |
+
</script>
|
168 |
|
169 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
}
|
171 |
|
172 |
// on product page
|
177 |
$product = wc_get_product( get_the_id() );
|
178 |
|
179 |
if ( is_object( $product ) ) {
|
180 |
+
$this->get_product_data_layer_script( $product, false, true );
|
181 |
} else {
|
182 |
wc_get_logger()->debug( 'woocommerce_inject_product_data_on_product_page provided no product on a product page: .' . get_the_id(), [
|
183 |
'source' => 'wpm',
|
189 |
$product = wc_get_product( $product_id );
|
190 |
|
191 |
if ( is_object( $product ) ) {
|
192 |
+
$this->get_product_data_layer_script( $product, false, true );
|
193 |
} else {
|
194 |
$this->log_problematic_product_id( $product_id );
|
195 |
}
|
197 |
}
|
198 |
}
|
199 |
if ( $product->is_type( 'variable' ) ) {
|
200 |
+
/**
|
201 |
+
* Stop inspection
|
202 |
+
*
|
203 |
+
* @noinspection PhpPossiblePolymorphicInvocationInspection
|
204 |
+
*/
|
205 |
foreach ( $product->get_available_variations() as $key => $variation ) {
|
206 |
$variable_product = wc_get_product( $variation['variation_id'] );
|
207 |
|
208 |
if ( is_object( $variable_product ) ) {
|
209 |
+
$this->get_product_data_layer_script( $variable_product, false, true );
|
210 |
} else {
|
211 |
$this->log_problematic_product_id( $variation['variation_id'] );
|
212 |
}
|
221 |
public function action_woocommerce_after_shop_loop_item()
|
222 |
{
|
223 |
global $product ;
|
224 |
+
$this->get_product_data_layer_script( $product );
|
225 |
}
|
226 |
|
227 |
// product views generated by a gutenberg block instead of a shortcode
|
228 |
+
public function wc_add_date_to_gutenberg_block( $html, $data, $product )
|
229 |
{
|
230 |
+
return $html . $this->buffer_get_product_data_layer_script( $product );
|
231 |
}
|
232 |
|
233 |
public function wpm_wp_footer()
|
238 |
}
|
239 |
|
240 |
// https://support.cloudflare.com/hc/en-us/articles/200169436-How-can-I-have-Rocket-Loader-ignore-specific-JavaScripts-
|
241 |
+
private function inject_data_layer()
|
242 |
+
{
|
243 |
+
?>
|
244 |
+
|
245 |
+
<script>
|
246 |
+
|
247 |
+
window.wpmDataLayer = window.wpmDataLayer || {}
|
248 |
+
window.wpmDataLayer = <?php
|
249 |
+
echo wp_json_encode( $this->get_data_for_data_layer() ) ;
|
250 |
+
?>;
|
251 |
+
|
252 |
+
</script>
|
253 |
+
|
254 |
+
<?php
|
255 |
+
}
|
256 |
+
|
257 |
+
protected function get_data_for_data_layer()
|
258 |
{
|
259 |
$data = [
|
260 |
+
'cart' => (object) [],
|
261 |
+
'cart_item_keys' => (object) [],
|
262 |
+
'orderDeduplication' => $this->options['shop']['order_deduplication'] && !$this->is_nodedupe_parameter_set(),
|
|
|
263 |
'position' => 1,
|
264 |
'viewItemListTrigger' => $this->view_item_list_trigger_settings(),
|
265 |
'version' => [
|
267 |
'pro' => wpm_fs()->is__premium_only(),
|
268 |
],
|
269 |
];
|
270 |
+
$data['pixels'] = [
|
271 |
+
'bing' => [
|
272 |
+
'uet_tag_id' => $this->options_obj->bing->uet_tag_id,
|
273 |
+
'dynamic_remarketing' => [
|
274 |
+
'id_type' => $this->get_dyn_r_id_type( 'bing' ),
|
275 |
+
],
|
276 |
+
],
|
277 |
+
'facebook' => [
|
278 |
+
'pixel_id' => $this->options_obj->facebook->pixel_id,
|
279 |
+
'dynamic_remarketing' => [
|
280 |
+
'id_type' => $this->get_dyn_r_id_type( 'facebook' ),
|
281 |
+
],
|
282 |
+
'capi' => (bool) $this->options_obj->facebook->capi->token,
|
283 |
+
],
|
284 |
+
'google' => [
|
285 |
+
'ads' => [
|
286 |
+
'conversionIds' => (object) $this->google->get_google_ads_conversion_ids( is_order_received_page() ),
|
287 |
+
'dynamic_remarketing' => [
|
288 |
+
'status' => (bool) $this->options_obj->google->ads->dynamic_remarketing,
|
289 |
+
'id_type' => $this->get_dyn_r_id_type( 'google' ),
|
290 |
+
'send_events_with_parent_ids' => apply_filters( 'wpm_send_events_with_parent_ids', apply_filters_deprecated(
|
291 |
+
'wooptpm_send_events_with_parent_ids',
|
292 |
+
[ true ],
|
293 |
+
'1.13.0',
|
294 |
+
'wpm_send_events_with_parent_ids'
|
295 |
+
) ),
|
296 |
+
],
|
297 |
+
'google_business_vertical' => $this->google->get_google_business_vertical( $this->options['google']['ads']['google_business_vertical'] ),
|
298 |
+
'phone_conversion_label' => $this->options_obj->google->ads->phone_conversion_label,
|
299 |
+
'phone_conversion_number' => $this->options_obj->google->ads->phone_conversion_number,
|
300 |
+
],
|
301 |
+
'analytics' => [
|
302 |
+
'universal' => [
|
303 |
+
'property_id' => $this->options_obj->google->analytics->universal->property_id,
|
304 |
+
'parameters' => (object) $this->google->get_ga_ua_parameters( $this->options_obj->google->analytics->universal->property_id ),
|
305 |
+
'mp_active' => wpm_fs()->is__premium_only(),
|
306 |
+
],
|
307 |
+
'ga4' => [
|
308 |
+
'measurement_id' => $this->options_obj->google->analytics->ga4->measurement_id,
|
309 |
+
'parameters' => (object) $this->google->get_ga4_parameters( $this->options_obj->google->analytics->ga4->measurement_id ),
|
310 |
+
'mp_active' => $this->options_obj->google->analytics->ga4->api_secret && wpm_fs()->is__premium_only(),
|
311 |
+
],
|
312 |
+
'id_type' => $this->google->get_ga_id_type(),
|
313 |
+
'eec' => (bool) $this->options_obj->google->analytics->eec,
|
314 |
+
],
|
315 |
+
'optimize' => [
|
316 |
+
'container_id' => $this->options_obj->google->optimize->container_id,
|
317 |
+
],
|
318 |
+
'linker' => [
|
319 |
+
'settings' => $this->google->get_google_linker_settings(),
|
320 |
+
],
|
321 |
+
'user_id' => (bool) $this->options_obj->google->user_id,
|
322 |
+
],
|
323 |
+
'hotjar' => [
|
324 |
+
'site_id' => $this->options_obj->hotjar->site_id,
|
325 |
+
],
|
326 |
+
'pinterest' => [
|
327 |
+
'pixel_id' => $this->options_obj->pinterest->pixel_id,
|
328 |
+
'dynamic_remarketing' => [
|
329 |
+
'id_type' => $this->get_dyn_r_id_type( 'pinterest' ),
|
330 |
+
],
|
331 |
+
'enhanced_match' => apply_filters( 'wpm_pinterest_enhanced_match', apply_filters_deprecated(
|
332 |
+
'wooptpm_pinterest_enhanced_match',
|
333 |
+
[ false ],
|
334 |
+
'1.13.0',
|
335 |
+
'wpm_pinterest_enhanced_match'
|
336 |
+
) ),
|
337 |
+
'enhanced_match_email' => $this->get_user_email(),
|
338 |
+
],
|
339 |
+
'snapchat' => [
|
340 |
+
'pixel_id' => $this->options_obj->snapchat->pixel_id,
|
341 |
+
'dynamic_remarketing' => [
|
342 |
+
'id_type' => $this->get_dyn_r_id_type( 'snapchat' ),
|
343 |
+
],
|
344 |
+
],
|
345 |
+
'tiktok' => [
|
346 |
+
'pixel_id' => $this->options_obj->tiktok->pixel_id,
|
347 |
+
'dynamic_remarketing' => [
|
348 |
+
'id_type' => $this->get_dyn_r_id_type( 'tiktok' ),
|
349 |
+
],
|
350 |
+
'purchase_event_name' => apply_filters( 'wpm_tiktok_purchase_event_name', 'PlaceAnOrder' ),
|
351 |
+
],
|
352 |
+
'twitter' => [
|
353 |
+
'pixel_id' => $this->options_obj->twitter->pixel_id,
|
354 |
+
'dynamic_remarketing' => [
|
355 |
+
'id_type' => $this->get_dyn_r_id_type( 'twitter' ),
|
356 |
+
],
|
357 |
+
],
|
358 |
+
];
|
359 |
+
$data = array_merge( $data, $this->get_order_data() );
|
360 |
+
$data['shop'] = $this->get_shop_data();
|
361 |
+
$data['general'] = $this->get_general_data();
|
362 |
+
$data['user'] = $this->get_user_data();
|
363 |
+
// Return and optionally modify the wpm data layer
|
364 |
+
return apply_filters( 'wpm_experimental_data_layer', $data );
|
365 |
+
}
|
366 |
+
|
367 |
+
protected function get_order_data()
|
368 |
+
{
|
369 |
+
if ( !is_order_received_page() ) {
|
370 |
+
return [];
|
371 |
+
}
|
372 |
+
$order = $this->get_order_from_order_received_page();
|
373 |
+
if ( $order && !$this->can_order_confirmation_be_processed( $order ) ) {
|
374 |
+
return [];
|
375 |
+
}
|
376 |
+
$data = [];
|
377 |
+
|
378 |
+
if ( $order ) {
|
379 |
+
$data['order'] = [
|
380 |
+
'id' => (int) $order->get_id(),
|
381 |
+
'number' => (string) $order->get_order_number(),
|
382 |
+
'affiliation' => (string) get_bloginfo( 'name' ),
|
383 |
+
'currency' => (string) $this->get_order_currency( $order ),
|
384 |
+
'value_filtered' => (double) $this->wpm_get_order_total( $order ),
|
385 |
+
'value_regular' => (double) $order->get_total(),
|
386 |
+
'discount' => (double) $order->get_total_discount(),
|
387 |
+
'tax' => (double) $order->get_total_tax(),
|
388 |
+
'shipping' => (double) $order->get_shipping_total(),
|
389 |
+
'coupon' => implode( ',', $order->get_coupon_codes() ),
|
390 |
+
'aw_merchant_id' => ( (int) $this->options['google']['ads']['aw_merchant_id'] ? (int) $this->options['google']['ads']['aw_merchant_id'] : '' ),
|
391 |
+
'aw_feed_country' => (string) $this->get_visitor_country(),
|
392 |
+
'aw_feed_language' => (string) $this->google->get_gmc_language(),
|
393 |
+
'new_customer' => !$this->is_existing_customer( $order ),
|
394 |
+
'quantity' => (int) count( $this->wpm_get_order_items( $order ) ),
|
395 |
+
'items' => $this->get_front_end_order_items( $order ),
|
396 |
+
];
|
397 |
+
$data['products'] = $this->get_order_products( $order );
|
398 |
+
}
|
399 |
+
|
400 |
+
return $data;
|
401 |
+
}
|
402 |
+
|
403 |
+
protected function get_user_data()
|
404 |
+
{
|
405 |
+
$data = [];
|
406 |
+
|
407 |
+
if ( is_user_logged_in() || is_order_received_page() ) {
|
408 |
+
$data['id'] = get_current_user_id();
|
409 |
+
$data['email'] = $this->get_user_email();
|
410 |
+
$data['email_sha256'] = $this->get_user_email( 'sha256' );
|
411 |
+
}
|
412 |
+
|
413 |
+
return $data;
|
414 |
+
}
|
415 |
+
|
416 |
+
protected function get_order_products( $order )
|
417 |
+
{
|
418 |
+
$order_products = [];
|
419 |
+
foreach ( (array) $this->wpm_get_order_items( $order ) as $order_item ) {
|
420 |
+
$order_item_data = $order_item->get_data();
|
421 |
+
if ( 0 !== $order_item_data['variation_id'] ) {
|
422 |
+
// add variation
|
423 |
+
$order_products[$order_item_data['variation_id']] = $this->get_product_data( $order_item_data['variation_id'] );
|
424 |
}
|
425 |
+
$order_products[$order_item_data['product_id']] = $this->get_product_data( $order_item_data['product_id'] );
|
426 |
+
}
|
427 |
+
return $order_products;
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
}
|
429 |
|
430 |
+
protected function get_product_data( $product_id )
|
431 |
+
{
|
432 |
+
$product = wc_get_product( $product_id );
|
433 |
+
|
434 |
+
if ( !is_object( $product ) ) {
|
435 |
+
$this->log_problematic_product_id( $product_id );
|
436 |
+
return [];
|
437 |
+
}
|
438 |
+
|
439 |
+
return [
|
440 |
+
'product_id' => $product->get_id(),
|
441 |
+
'name' => $product->get_name(),
|
442 |
+
'type' => $product->get_type(),
|
443 |
+
'dyn_r_ids' => $this->get_dyn_r_ids( $product ),
|
444 |
+
'brand' => (string) $this->get_brand_name( $product_id ),
|
445 |
+
'category' => (array) $this->get_product_category( $product_id ),
|
446 |
+
'variant_name' => ( (string) ($product->get_type() === 'variation') ? $this->get_formatted_variant_text( $product ) : '' ),
|
447 |
+
];
|
448 |
+
}
|
449 |
+
|
450 |
+
public function view_item_list_trigger_settings()
|
451 |
{
|
452 |
$settings = [
|
453 |
'testMode' => false,
|
468 |
|
469 |
public function inject_wpm_opening()
|
470 |
{
|
|
|
|
|
|
|
471 |
echo PHP_EOL . '<!-- START WooCommerce Pixel Manager -->' . PHP_EOL ;
|
472 |
}
|
473 |
|
474 |
public function inject_wpm_closing()
|
475 |
{
|
|
|
|
|
|
|
476 |
if ( is_order_received_page() ) {
|
477 |
|
478 |
+
if ( $this->get_order_from_order_received_page() ) {
|
479 |
+
$order = $this->get_order_from_order_received_page();
|
480 |
$this->increase_conversion_count_for_ratings( $order );
|
481 |
}
|
482 |
|
483 |
}
|
484 |
echo PHP_EOL . '<!-- END WooCommerce Pixel Manager -->' . PHP_EOL ;
|
|
|
|
|
|
|
485 |
}
|
486 |
|
487 |
private function increase_conversion_count_for_ratings( $order )
|
503 |
$cart_items = $woocommerce->cart->get_cart();
|
504 |
$data = [];
|
505 |
foreach ( $cart_items as $cart_item => $value ) {
|
|
|
|
|
506 |
$product = wc_get_product( $value['data']->get_id() );
|
507 |
|
508 |
if ( !is_object( $product ) ) {
|
524 |
'isVariation' => false,
|
525 |
];
|
526 |
|
527 |
+
if ( 'variation' === $product->get_type() ) {
|
528 |
$parent_product = wc_get_product( $product->get_parent_id() );
|
529 |
|
530 |
if ( $parent_product ) {
|
555 |
}
|
556 |
|
557 |
}
|
|
|
558 |
wp_send_json( $data );
|
559 |
}
|
560 |
|
561 |
public function ajax_wpm_get_product_ids()
|
562 |
{
|
563 |
+
$_get = filter_input_array( INPUT_GET, FILTER_SANITIZE_FULL_SPECIAL_CHARS );
|
564 |
+
$product_ids = $_get['productIds'];
|
565 |
|
566 |
if ( !$product_ids ) {
|
567 |
wp_send_json_error();
|
590 |
|
591 |
public function ajax_purchase_pixels_fired_handler()
|
592 |
{
|
|
|
593 |
// if (!check_ajax_referer('wpm-premium-only-nonce', 'nonce', false)) {
|
|
|
|
|
594 |
// wp_send_json_error('Invalid security token sent.');
|
595 |
// error_log('Invalid security token sent.');
|
596 |
// wp_die();
|
597 |
// }
|
598 |
+
$_post = filter_input_array( INPUT_POST, FILTER_SANITIZE_FULL_SPECIAL_CHARS );
|
599 |
+
$order_id = $_post['order_id'];
|
600 |
update_post_meta( $order_id, '_wpm_conversion_pixel_fired', true );
|
601 |
wp_send_json_success();
|
602 |
wp_die();
|
606 |
public function wpm_front_end_scripts()
|
607 |
{
|
608 |
$wpm_dependencies = [ 'jquery' ];
|
609 |
+
// enable polyfill.io with filter
|
610 |
|
611 |
if ( wpm_fs()->is__premium_only() && apply_filters( 'wpm_experimental_inject_polyfill_io', false ) ) {
|
612 |
wp_enqueue_script(
|
613 |
'polyfill-io',
|
614 |
'https://cdn.polyfill.io/v2/polyfill.min.js',
|
615 |
false,
|
616 |
+
WPM_CURRENT_VERSION,
|
617 |
false
|
618 |
);
|
619 |
$wpm_dependencies[] = 'polyfill-io';
|
624 |
WPM_PLUGIN_DIR_PATH . 'js/public/wpm-public.p1.min.js',
|
625 |
$wpm_dependencies,
|
626 |
WPM_CURRENT_VERSION,
|
627 |
+
$this->move_wpm_script_to_footer()
|
628 |
);
|
629 |
wp_localize_script(
|
630 |
'wpm',
|
634 |
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
635 |
]
|
636 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
637 |
}
|
638 |
|
639 |
+
protected function move_wpm_script_to_footer()
|
640 |
+
{
|
641 |
+
// this filter moves the wpm script to the footer
|
642 |
+
return apply_filters( 'wpm_experimental_move_wpm_script_to_footer', false );
|
643 |
+
}
|
644 |
+
|
645 |
+
private function get_preset_version()
|
646 |
{
|
647 |
return '.p' . apply_filters( 'wpm_script_optimization_preset_version', 1 );
|
648 |
}
|
657 |
// $this->google_pixel_manager->inject_google_optimize_anti_flicker_snippet();
|
658 |
}
|
659 |
|
660 |
+
private function get_shop_data()
|
661 |
{
|
662 |
$data = [];
|
663 |
|
718 |
}
|
719 |
|
720 |
$data['currency'] = get_woocommerce_currency();
|
721 |
+
// $data['mini_cart']['track'] = apply_filters_deprecated('wooptpm_track_mini_cart', [true], '1.13.0', 'wpm_track_mini_cart');
|
722 |
+
// $data['mini_cart']['track'] = apply_filters('wpm_track_mini_cart', $data['mini_cart']['track']);
|
723 |
+
$mini_cart_filter_deprecation_message = 'The filter has become obsolete since WPM now tracks cart item data using the browser cache and doesn\'t rely entirely on the server anymore.';
|
724 |
+
apply_filters_deprecated(
|
725 |
'wooptpm_track_mini_cart',
|
726 |
[ true ],
|
727 |
'1.13.0',
|
728 |
+
'',
|
729 |
+
$mini_cart_filter_deprecation_message
|
730 |
+
);
|
731 |
+
apply_filters_deprecated(
|
732 |
+
'wpm_track_mini_cart',
|
733 |
+
[ true ],
|
734 |
+
'1.15.5',
|
735 |
+
'',
|
736 |
+
$mini_cart_filter_deprecation_message
|
737 |
);
|
|
|
738 |
$data['cookie_consent_mgmt'] = [
|
739 |
'explicit_consent' => (bool) $this->options_obj->shop->cookie_consent_mgmt->explicit_consent,
|
740 |
];
|
741 |
+
return $data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
}
|
743 |
|
744 |
+
private function get_general_data()
|
745 |
{
|
746 |
$data = [
|
747 |
'variationsOutput' => (bool) $this->options_obj->general->variations_output,
|
748 |
+
'userLoggedIn' => is_user_logged_in(),
|
749 |
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
750 |
return $data;
|
751 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
|
753 |
}
|
classes/pixels/class-pixel.php
CHANGED
@@ -3,106 +3,43 @@
|
|
3 |
namespace WCPM\Classes\Pixels;
|
4 |
|
5 |
use stdClass;
|
6 |
-
use WC_Geolocation;
|
7 |
|
8 |
if (!defined('ABSPATH')) {
|
9 |
-
|
10 |
}
|
11 |
|
12 |
-
class Pixel
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
$this->order_total_logic = $this->options['shop']['order_total_logic'];
|
49 |
-
// $this->add_cart_data = $this->options['google']['ads']['add_cart_data'];
|
50 |
-
$this->add_cart_data = $this->options['google']['ads']['aw_merchant_id'] ? true : false;
|
51 |
-
$this->aw_merchant_id = $this->options['google']['ads']['aw_merchant_id'];
|
52 |
-
$this->conversion_id = $this->options['google']['ads']['conversion_id'];
|
53 |
-
$this->conversion_label = $this->options['google']['ads']['conversion_label'];
|
54 |
-
$this->dynamic_remarketing = $this->options['google']['ads']['dynamic_remarketing'];
|
55 |
-
$this->product_identifier = $this->options['google']['ads']['product_identifier'];
|
56 |
-
|
57 |
-
if(array_key_exists('gtag', $this->options['google'])){
|
58 |
-
$this->gtag_deactivation = $this->options['google']['gtag']['deactivation'];
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
// get an array with all cart product ids
|
63 |
-
public function get_cart_ids($cart): array
|
64 |
-
{
|
65 |
-
// error_log(print_r($cart, true));
|
66 |
-
// initiate product identifier array
|
67 |
-
$cart_items = [];
|
68 |
-
|
69 |
-
// go through the array and get all product identifiers
|
70 |
-
foreach ((array)$cart as $cart_item) {
|
71 |
-
|
72 |
-
$product_id = $this->get_variation_or_product_id($cart_item, $this->options_obj->general->variations_output);
|
73 |
-
$product = wc_get_product($product_id);
|
74 |
-
|
75 |
-
$product_id_compiled = $this->get_compiled_product_id($product_id, $product->get_sku(), $this->options,'');
|
76 |
-
|
77 |
-
array_push($cart_items, $product_id_compiled);
|
78 |
-
}
|
79 |
-
|
80 |
-
return $cart_items;
|
81 |
-
}
|
82 |
-
|
83 |
-
protected function get_visitor_country()
|
84 |
-
{
|
85 |
-
if ($this->isLocalhost()) {
|
86 |
-
$this->ip = WC_Geolocation::get_external_ip_address();
|
87 |
-
} else {
|
88 |
-
$this->ip = WC_Geolocation::get_ip_address();
|
89 |
-
}
|
90 |
-
|
91 |
-
$location = WC_Geolocation::geolocate_ip($this->ip);
|
92 |
-
|
93 |
-
return $location['country'];
|
94 |
-
}
|
95 |
-
|
96 |
-
protected function isLocalhost(): bool
|
97 |
-
{
|
98 |
-
return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']);
|
99 |
-
}
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
}
|
3 |
namespace WCPM\Classes\Pixels;
|
4 |
|
5 |
use stdClass;
|
|
|
6 |
|
7 |
if (!defined('ABSPATH')) {
|
8 |
+
exit; // Exit if accessed directly
|
9 |
}
|
10 |
|
11 |
+
class Pixel {
|
12 |
+
use Trait_Product;
|
13 |
+
|
14 |
+
protected $add_cart_data;
|
15 |
+
protected $aw_merchant_id;
|
16 |
+
protected $conversion_id;
|
17 |
+
protected $conversion_label;
|
18 |
+
protected $dynamic_remarketing;
|
19 |
+
protected $google_business_vertical;
|
20 |
+
protected $ip;
|
21 |
+
protected $order_total_logic;
|
22 |
+
protected $product_identifier;
|
23 |
+
protected $options;
|
24 |
+
protected $options_obj;
|
25 |
+
protected $dyn_r_id_type;
|
26 |
+
protected $pixel_name = '';
|
27 |
+
|
28 |
+
public function __construct( $options ) {
|
29 |
+
/*
|
30 |
+
* Initialize options
|
31 |
+
*/
|
32 |
+
$this->options = $options;
|
33 |
+
$this->options_obj = json_decode(wp_json_encode($this->options));
|
34 |
+
|
35 |
+
$this->options_obj->shop->currency = get_woocommerce_currency();
|
36 |
+
|
37 |
+
$this->order_total_logic = $this->options['shop']['order_total_logic'];
|
38 |
+
$this->add_cart_data = (bool) $this->options['google']['ads']['aw_merchant_id'];
|
39 |
+
$this->aw_merchant_id = $this->options['google']['ads']['aw_merchant_id'];
|
40 |
+
$this->conversion_id = $this->options['google']['ads']['conversion_id'];
|
41 |
+
$this->conversion_label = $this->options['google']['ads']['conversion_label'];
|
42 |
+
$this->dynamic_remarketing = $this->options['google']['ads']['dynamic_remarketing'];
|
43 |
+
$this->product_identifier = $this->options['google']['ads']['product_identifier'];
|
44 |
+
}
|
45 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/{class-pixel-manager-base.php → class-script-manager.php}
RENAMED
@@ -12,7 +12,7 @@ if ( !defined( 'ABSPATH' ) ) {
|
|
12 |
// Exit if accessed directly
|
13 |
}
|
14 |
|
15 |
-
class
|
16 |
{
|
17 |
use Trait_Product ;
|
18 |
use Trait_Shop ;
|
@@ -26,7 +26,7 @@ class Pixel_Manager_Base
|
|
26 |
*/
|
27 |
// $this->options = get_option(WPM_DB_OPTIONS_NAME);
|
28 |
$this->options = $options;
|
29 |
-
$this->options_obj = json_decode(
|
30 |
$this->options_obj->shop->currency = new stdClass();
|
31 |
$this->options_obj->shop->currency = get_woocommerce_currency();
|
32 |
/*
|
@@ -40,6 +40,7 @@ class Pixel_Manager_Base
|
|
40 |
public function inject_head_pixels()
|
41 |
{
|
42 |
global $woocommerce ;
|
|
|
43 |
$this->inject_opening_script_tag();
|
44 |
$this->inject_everywhere();
|
45 |
|
@@ -49,7 +50,7 @@ class Pixel_Manager_Base
|
|
49 |
$this->inject_product_tag();
|
50 |
} elseif ( is_search() ) {
|
51 |
$this->inject_search();
|
52 |
-
} elseif ( is_product() && !isset( $
|
53 |
$product = wc_get_product();
|
54 |
$product_id = $product->get_id();
|
55 |
$product_attributes = [
|
@@ -105,28 +106,8 @@ class Pixel_Manager_Base
|
|
105 |
$user = $order->get_billing_email();
|
106 |
}
|
107 |
|
108 |
-
$is_new_customer = !$this->
|
109 |
-
$order_total =
|
110 |
-
// filter to adjust the order value
|
111 |
-
$order_total = apply_filters_deprecated(
|
112 |
-
'wgact_conversion_value_filter',
|
113 |
-
[ $order_total, $order ],
|
114 |
-
'1.10.2',
|
115 |
-
'wooptpm_conversion_value_filter'
|
116 |
-
);
|
117 |
-
$order_total = apply_filters_deprecated(
|
118 |
-
'wooptpm_conversion_value_filter',
|
119 |
-
[ $order_total, $order ],
|
120 |
-
'1.13.0',
|
121 |
-
'wpm_conversion_value_filter'
|
122 |
-
);
|
123 |
-
$order_total = apply_filters( 'wpm_conversion_value_filter', $order_total, $order );
|
124 |
-
$order_total = number_format(
|
125 |
-
(double) $order_total,
|
126 |
-
2,
|
127 |
-
'.',
|
128 |
-
''
|
129 |
-
);
|
130 |
// dedupe code
|
131 |
if ( $this->can_order_confirmation_be_processed( $order ) ) {
|
132 |
$this->inject_order_received_page_dedupe( $order, $order_total, $is_new_customer );
|
@@ -139,7 +120,7 @@ class Pixel_Manager_Base
|
|
139 |
$this->inject_closing_script_tag();
|
140 |
}
|
141 |
|
142 |
-
protected function can_order_confirmation_be_processed( $order )
|
143 |
{
|
144 |
$conversion_prevention = false;
|
145 |
$conversion_prevention = apply_filters_deprecated(
|
@@ -164,11 +145,9 @@ class Pixel_Manager_Base
|
|
164 |
// error_log('order number: ' . $order->get_order_number());
|
165 |
// error_log('get_post_meta($order->get_order_number(), \'_wpm_conversion_pixel_fired\', true): ' . get_post_meta($order->get_order_number(), '_wpm_conversion_pixel_fired', true));
|
166 |
|
167 |
-
if ( $this->is_nodedupe_parameter_set() || !$order->has_status( 'failed' ) &&
|
168 |
-
// error_log('fire pixels: true' . PHP_EOL);
|
169 |
return true;
|
170 |
} else {
|
171 |
-
// error_log('fire pixels: false' . PHP_EOL);
|
172 |
return false;
|
173 |
}
|
174 |
|
@@ -211,10 +190,11 @@ class Pixel_Manager_Base
|
|
211 |
{
|
212 |
}
|
213 |
|
214 |
-
protected function is_nodedupe_parameter_set()
|
215 |
{
|
|
|
216 |
|
217 |
-
if ( isset( $
|
218 |
return true;
|
219 |
} else {
|
220 |
return false;
|
@@ -222,31 +202,12 @@ class Pixel_Manager_Base
|
|
222 |
|
223 |
}
|
224 |
|
225 |
-
|
226 |
-
protected function has_bought( $order, $value = 0 ) : bool
|
227 |
-
{
|
228 |
-
global $wpdb ;
|
229 |
-
// Based on user ID (registered users)
|
230 |
-
|
231 |
-
if ( is_numeric( $value ) ) {
|
232 |
-
$meta_key = '_customer_user';
|
233 |
-
$meta_value = ( $value == 0 ? (int) get_current_user_id() : (int) $value );
|
234 |
-
} else {
|
235 |
-
$meta_key = '_billing_email';
|
236 |
-
$meta_value = sanitize_email( $value );
|
237 |
-
}
|
238 |
-
|
239 |
-
$paid_order_statuses = array_map( 'esc_sql', wc_get_is_paid_statuses() );
|
240 |
-
$count = $wpdb->get_var( $wpdb->prepare( "\n SELECT COUNT(p.ID) FROM {$wpdb->prefix}posts AS p\n INNER JOIN {$wpdb->prefix}postmeta AS pm ON p.ID = pm.post_id\n WHERE p.post_status IN ( 'wc-" . implode( "','wc-", $paid_order_statuses ) . "' )\n AND p.post_type LIKE 'shop_order'\n AND p.ID <> {$order->get_id()}\n AND pm.meta_key = '%s'\n AND pm.meta_value = %s\n LIMIT 1\n ", $meta_key, $meta_value ) );
|
241 |
-
// Return a boolean value based on orders count
|
242 |
-
return ( $count > 0 ? true : false );
|
243 |
-
}
|
244 |
-
|
245 |
-
protected function query_string_contains_all_variation_attributes( $product ) : bool
|
246 |
{
|
|
|
247 |
|
248 |
-
if ( !empty($
|
249 |
-
parse_str( $
|
250 |
foreach ( array_keys( $product->get_attributes() ) as $variation_attribute => $value ) {
|
251 |
if ( !array_key_exists( 'attribute_' . $value, $query_string_attributes ) ) {
|
252 |
return false;
|
@@ -259,9 +220,10 @@ class Pixel_Manager_Base
|
|
259 |
|
260 |
}
|
261 |
|
262 |
-
protected function get_variation_from_query_string( $product_id, $product )
|
263 |
{
|
264 |
-
|
|
|
265 |
$search_variation_attributes = [];
|
266 |
foreach ( array_keys( $product->get_attributes() ) as $variation_attribute => $value ) {
|
267 |
$search_variation_attributes['attribute_' . $value] = $query_string_attributes['attribute_' . $value];
|
@@ -269,7 +231,7 @@ class Pixel_Manager_Base
|
|
269 |
return $this->find_matching_product_variation_id( $product_id, $search_variation_attributes );
|
270 |
}
|
271 |
|
272 |
-
protected function find_matching_product_variation_id( $product_id, $attributes )
|
273 |
{
|
274 |
return ( new WC_Product_Data_Store_CPT() )->find_matching_product_variation( new WC_Product( $product_id ), $attributes );
|
275 |
}
|
@@ -278,21 +240,27 @@ class Pixel_Manager_Base
|
|
278 |
{
|
279 |
?>
|
280 |
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
|
|
|
|
|
|
|
|
290 |
?>
|
291 |
-
|
292 |
-
|
|
|
|
|
293 |
}
|
294 |
|
295 |
-
private function is_shop_top_page()
|
296 |
{
|
297 |
|
298 |
if ( !is_product() && !is_product_category() && !is_order_received_page() && !is_cart() && !is_search() && is_shop() ) {
|
12 |
// Exit if accessed directly
|
13 |
}
|
14 |
|
15 |
+
class Script_Manager
|
16 |
{
|
17 |
use Trait_Product ;
|
18 |
use Trait_Shop ;
|
26 |
*/
|
27 |
// $this->options = get_option(WPM_DB_OPTIONS_NAME);
|
28 |
$this->options = $options;
|
29 |
+
$this->options_obj = json_decode( wp_json_encode( $this->options ) );
|
30 |
$this->options_obj->shop->currency = new stdClass();
|
31 |
$this->options_obj->shop->currency = get_woocommerce_currency();
|
32 |
/*
|
40 |
public function inject_head_pixels()
|
41 |
{
|
42 |
global $woocommerce ;
|
43 |
+
$_post = filter_input_array( INPUT_POST, FILTER_SANITIZE_FULL_SPECIAL_CHARS );
|
44 |
$this->inject_opening_script_tag();
|
45 |
$this->inject_everywhere();
|
46 |
|
50 |
$this->inject_product_tag();
|
51 |
} elseif ( is_search() ) {
|
52 |
$this->inject_search();
|
53 |
+
} elseif ( is_product() && !isset( $_post['add-to-cart'] ) ) {
|
54 |
$product = wc_get_product();
|
55 |
$product_id = $product->get_id();
|
56 |
$product_attributes = [
|
106 |
$user = $order->get_billing_email();
|
107 |
}
|
108 |
|
109 |
+
$is_new_customer = !$this->is_existing_customer( $order, $user );
|
110 |
+
$order_total = $this->wpm_get_order_total( $order );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
// dedupe code
|
112 |
if ( $this->can_order_confirmation_be_processed( $order ) ) {
|
113 |
$this->inject_order_received_page_dedupe( $order, $order_total, $is_new_customer );
|
120 |
$this->inject_closing_script_tag();
|
121 |
}
|
122 |
|
123 |
+
protected function can_order_confirmation_be_processed( $order )
|
124 |
{
|
125 |
$conversion_prevention = false;
|
126 |
$conversion_prevention = apply_filters_deprecated(
|
145 |
// error_log('order number: ' . $order->get_order_number());
|
146 |
// error_log('get_post_meta($order->get_order_number(), \'_wpm_conversion_pixel_fired\', true): ' . get_post_meta($order->get_order_number(), '_wpm_conversion_pixel_fired', true));
|
147 |
|
148 |
+
if ( $this->is_nodedupe_parameter_set() || !$order->has_status( 'failed' ) && $this->track_user() && false == $conversion_prevention && (!$this->options['shop']['order_deduplication'] || $this->has_conversion_pixel_already_fired( $order ) != true) ) {
|
|
|
149 |
return true;
|
150 |
} else {
|
|
|
151 |
return false;
|
152 |
}
|
153 |
|
190 |
{
|
191 |
}
|
192 |
|
193 |
+
protected function is_nodedupe_parameter_set()
|
194 |
{
|
195 |
+
$_get = filter_input_array( INPUT_GET, FILTER_SANITIZE_FULL_SPECIAL_CHARS );
|
196 |
|
197 |
+
if ( isset( $_get['nodedupe'] ) ) {
|
198 |
return true;
|
199 |
} else {
|
200 |
return false;
|
202 |
|
203 |
}
|
204 |
|
205 |
+
protected function query_string_contains_all_variation_attributes( $product )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
{
|
207 |
+
$_server = filter_input_array( INPUT_SERVER, FILTER_SANITIZE_FULL_SPECIAL_CHARS );
|
208 |
|
209 |
+
if ( !empty($_server['QUERY_STRING']) ) {
|
210 |
+
parse_str( $_server['QUERY_STRING'], $query_string_attributes );
|
211 |
foreach ( array_keys( $product->get_attributes() ) as $variation_attribute => $value ) {
|
212 |
if ( !array_key_exists( 'attribute_' . $value, $query_string_attributes ) ) {
|
213 |
return false;
|
220 |
|
221 |
}
|
222 |
|
223 |
+
protected function get_variation_from_query_string( $product_id, $product )
|
224 |
{
|
225 |
+
$_server = filter_input_array( INPUT_SERVER, FILTER_SANITIZE_FULL_SPECIAL_CHARS );
|
226 |
+
parse_str( $_server['QUERY_STRING'], $query_string_attributes );
|
227 |
$search_variation_attributes = [];
|
228 |
foreach ( array_keys( $product->get_attributes() ) as $variation_attribute => $value ) {
|
229 |
$search_variation_attributes['attribute_' . $value] = $query_string_attributes['attribute_' . $value];
|
231 |
return $this->find_matching_product_variation_id( $product_id, $search_variation_attributes );
|
232 |
}
|
233 |
|
234 |
+
protected function find_matching_product_variation_id( $product_id, $attributes )
|
235 |
{
|
236 |
return ( new WC_Product_Data_Store_CPT() )->find_matching_product_variation( new WC_Product( $product_id ), $attributes );
|
237 |
}
|
240 |
{
|
241 |
?>
|
242 |
|
243 |
+
<!-- ----------------------------------------------------------------------------------------------------
|
244 |
+
The conversion pixels have not been fired. Possible reasons:
|
245 |
+
- The user role has been disabled for tracking.
|
246 |
+
- The order payment has failed.
|
247 |
+
- The pixels have already been fired. To prevent double counting the pixels are only fired once.
|
248 |
+
|
249 |
+
If you want to test the order you have two options:
|
250 |
+
- Turn off order duplication prevention in the advanced settings
|
251 |
+
- Add the '&nodedupe' parameter to the order confirmation URL like this:
|
252 |
+
https://example.test/checkout/order-received/123/?key=wc_order_123abc&nodedupe
|
253 |
+
|
254 |
+
More info on testing: <?php
|
255 |
+
esc_html_e( ( new Documentation() )->get_link( 'test_order' ) );
|
256 |
?>
|
257 |
+
|
258 |
+
----------------------------------------------------------------------------------------------------
|
259 |
+
-->
|
260 |
+
<?php
|
261 |
}
|
262 |
|
263 |
+
private function is_shop_top_page()
|
264 |
{
|
265 |
|
266 |
if ( !is_product() && !is_product_category() && !is_order_received_page() && !is_cart() && !is_search() && is_shop() ) {
|
classes/pixels/class-shortcodes.php
CHANGED
@@ -2,208 +2,284 @@
|
|
2 |
|
3 |
namespace WCPM\Classes\Pixels;
|
4 |
|
5 |
-
use WCPM\Classes\Pixels\Google\
|
6 |
|
7 |
if (!defined('ABSPATH')) {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
-
class Shortcodes extends Pixel
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
namespace WCPM\Classes\Pixels;
|
4 |
|
5 |
+
use WCPM\Classes\Pixels\Google\Google;
|
6 |
|
7 |
if (!defined('ABSPATH')) {
|
8 |
+
exit; // Exit if accessed directly
|
9 |
}
|
10 |
|
11 |
+
class Shortcodes extends Pixel {
|
12 |
+
use Trait_Product;
|
13 |
+
|
14 |
+
private $google;
|
15 |
+
|
16 |
+
public function __construct( $options ) {
|
17 |
+
parent::__construct($options);
|
18 |
+
|
19 |
+
$this->google = new Google($options);
|
20 |
+
|
21 |
+
add_shortcode('view-item', [$this, 'wpm_view_item']);
|
22 |
+
add_shortcode('conversion-pixel', [$this, 'wpm_conversion_pixel']);
|
23 |
+
}
|
24 |
+
|
25 |
+
public function wpm_view_item( $attributes ) {
|
26 |
+
$shortcode_attributes = shortcode_atts(
|
27 |
+
[
|
28 |
+
'product-id' => null,
|
29 |
+
], $attributes);
|
30 |
+
|
31 |
+
if ($shortcode_attributes['product-id']) {
|
32 |
+
|
33 |
+
$product = wc_get_product($shortcode_attributes['product-id']);
|
34 |
+
|
35 |
+
if (!is_object($product)) {
|
36 |
+
wc_get_logger()->debug('get_product_data_layer_script received an invalid product', ['source' => 'wpm']);
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
+
$this->get_product_data_layer_script($product, false, false);
|
41 |
+
|
42 |
+
?>
|
43 |
+
|
44 |
+
<script>
|
45 |
+
jQuery(window).on("wpmLoad", function () {
|
46 |
+
jQuery(document).trigger("wpmViewItem", wpm.getProductDetailsFormattedForEvent(<?php echo esc_js($shortcode_attributes['product-id']); ?>))
|
47 |
+
})
|
48 |
+
</script>
|
49 |
+
<?php
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
public function wpm_conversion_pixel( $attributes ) {
|
54 |
+
$this->function_exists_script();
|
55 |
+
|
56 |
+
$pairs = [
|
57 |
+
'pixel' => 'all',
|
58 |
+
'gads-conversion-id' => $this->options_obj->google->ads->conversion_id,
|
59 |
+
'gads-conversion-label' => '',
|
60 |
+
'fbc-event' => 'Lead',
|
61 |
+
'twc-event' => 'CompleteRegistration',
|
62 |
+
'pinc-event' => 'lead',
|
63 |
+
'pinc-lead-type' => '',
|
64 |
+
'ms-ads-event' => 'submit',
|
65 |
+
'ms-ads-event-category' => '',
|
66 |
+
'ms-ads-event-label' => 'lead',
|
67 |
+
'ms-ads-event-value' => 0,
|
68 |
+
'snap-event' => 'SIGN_UP',
|
69 |
+
'tiktok-event' => 'SubmitForm',
|
70 |
+
];
|
71 |
+
|
72 |
+
$shortcode_attributes = shortcode_atts($pairs, $attributes);
|
73 |
+
|
74 |
+
if ('google-ads' === $shortcode_attributes['pixel']) {
|
75 |
+
if ($this->google->is_google_ads_active()) {
|
76 |
+
$this->conversion_html_google_ads($shortcode_attributes);
|
77 |
+
}
|
78 |
+
} elseif ('facebook' === $shortcode_attributes['pixel'] || 'meta' === $shortcode_attributes['pixel']) {
|
79 |
+
if ($this->options_obj->facebook->pixel_id) {
|
80 |
+
$this->conversion_html_facebook($shortcode_attributes);
|
81 |
+
}
|
82 |
+
} elseif ('twitter' === $shortcode_attributes['pixel']) {
|
83 |
+
if ($this->options_obj->twitter->pixel_id) {
|
84 |
+
$this->conversion_html_twitter($shortcode_attributes);
|
85 |
+
}
|
86 |
+
} elseif ('pinterest' === $shortcode_attributes['pixel']) {
|
87 |
+
if ($this->options_obj->pinterest->pixel_id) {
|
88 |
+
$this->conversion_html_pinterest($shortcode_attributes);
|
89 |
+
}
|
90 |
+
} elseif ('ms-ads' === $shortcode_attributes['pixel']) {
|
91 |
+
if ($this->options_obj->bing->uet_tag_id) {
|
92 |
+
$this->conversion_html_microsoft_ads($shortcode_attributes);
|
93 |
+
}
|
94 |
+
} elseif ('snapchat' === $shortcode_attributes['pixel']) {
|
95 |
+
if ($this->options_obj->snapchat->pixel_id) {
|
96 |
+
$this->conversion_html_snapchat($shortcode_attributes);
|
97 |
+
}
|
98 |
+
} elseif ('tiktok' === $shortcode_attributes['pixel']) {
|
99 |
+
if ($this->options_obj->tiktok->pixel_id) {
|
100 |
+
$this->conversion_html_tiktok($shortcode_attributes);
|
101 |
+
}
|
102 |
+
} elseif ('all' === $shortcode_attributes['pixel']) {
|
103 |
+
if ($this->google->is_google_ads_active()) {
|
104 |
+
$this->conversion_html_google_ads($shortcode_attributes);
|
105 |
+
}
|
106 |
+
if ($this->options_obj->facebook->pixel_id) {
|
107 |
+
$this->conversion_html_facebook($shortcode_attributes);
|
108 |
+
}
|
109 |
+
if ($this->options_obj->twitter->pixel_id) {
|
110 |
+
$this->conversion_html_twitter($shortcode_attributes);
|
111 |
+
}
|
112 |
+
if ($this->options_obj->pinterest->pixel_id) {
|
113 |
+
$this->conversion_html_pinterest($shortcode_attributes);
|
114 |
+
}
|
115 |
+
if ($this->options_obj->bing->uet_tag_id) {
|
116 |
+
$this->conversion_html_microsoft_ads($shortcode_attributes);
|
117 |
+
}
|
118 |
+
if ($this->options_obj->snapchat->pixel_id) {
|
119 |
+
$this->conversion_html_snapchat($shortcode_attributes);
|
120 |
+
}
|
121 |
+
if ($this->options_obj->tiktok->pixel_id) {
|
122 |
+
$this->conversion_html_tiktok($shortcode_attributes);
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
private function conversion_html_snapchat( $shortcode_attributes ) {
|
128 |
+
|
129 |
+
?>
|
130 |
+
|
131 |
+
<script>
|
132 |
+
wpmFunctionExists("snaptr").then(function () {
|
133 |
+
snaptr("track", '<?php echo esc_js($shortcode_attributes['snap-event']); ?>')
|
134 |
+
},
|
135 |
+
)
|
136 |
+
</script>
|
137 |
+
<?php
|
138 |
+
}
|
139 |
+
|
140 |
+
private function conversion_html_tiktok( $shortcode_attributes ) {
|
141 |
+
|
142 |
+
?>
|
143 |
+
|
144 |
+
<script>
|
145 |
+
wpmFunctionExists("ttq").then(function () {
|
146 |
+
ttq.track('<?php echo esc_js($shortcode_attributes['tiktok-event']); ?>')
|
147 |
+
},
|
148 |
+
)
|
149 |
+
</script>
|
150 |
+
<?php
|
151 |
+
}
|
152 |
+
|
153 |
+
private function conversion_html_google_ads( $shortcode_attributes ) {
|
154 |
+
|
155 |
+
?>
|
156 |
+
|
157 |
+
<script>
|
158 |
+
wpmFunctionExists("gtag").then(function () {
|
159 |
+
if (wpm.googleConfigConditionsMet("ads")) gtag("event", "conversion", {"send_to": 'AW-<?php echo esc_js($shortcode_attributes['gads-conversion-id']); ?>/<?php echo esc_js($shortcode_attributes['gads-conversion-label']); ?>'})
|
160 |
+
},
|
161 |
+
)
|
162 |
+
</script>
|
163 |
+
<?php
|
164 |
+
}
|
165 |
+
|
166 |
+
// https://developers.facebook.com/docs/analytics/send_data/events/
|
167 |
+
private function conversion_html_facebook( $shortcode_attributes ) {
|
168 |
+
|
169 |
+
if ($this->options_obj->facebook->capi->token) {
|
170 |
+
?>
|
171 |
+
|
172 |
+
<script>
|
173 |
+
jQuery(window).on("wpmLoad", function () {
|
174 |
+
|
175 |
+
let eventId = wpm.getRandomEventId()
|
176 |
+
|
177 |
+
wpmFunctionExists("fbq").then(function () {
|
178 |
+
fbq("track", '<?php echo esc_js($shortcode_attributes['fbc-event']); ?>', {}, {
|
179 |
+
eventID: eventId,
|
180 |
+
})
|
181 |
+
},
|
182 |
+
)
|
183 |
+
|
184 |
+
jQuery(document).trigger("wpmFbCapiEvent", {
|
185 |
+
event_name : "<?php echo esc_js($shortcode_attributes['fbc-event']); ?>",
|
186 |
+
event_id : eventId,
|
187 |
+
user_data : wpm.getFbUserData(),
|
188 |
+
event_source_url: window.location.href,
|
189 |
+
})
|
190 |
+
})
|
191 |
+
|
192 |
+
</script>
|
193 |
+
<?php
|
194 |
+
} else {
|
195 |
+
?>
|
196 |
+
|
197 |
+
<script>
|
198 |
+
wpmFunctionExists("fbq").then(function () {
|
199 |
+
fbq("track", '<?php echo esc_js($shortcode_attributes['fbc-event']); ?>')
|
200 |
+
},
|
201 |
+
)
|
202 |
+
</script>
|
203 |
+
<?php
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
// https://business.twitter.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites.html
|
208 |
+
private function conversion_html_twitter( $shortcode_attributes ) {
|
209 |
+
|
210 |
+
?>
|
211 |
+
|
212 |
+
<script>
|
213 |
+
wpmFunctionExists("twq").then(function () {
|
214 |
+
twq("track", '<?php echo esc_js($shortcode_attributes['twc-event']); ?>')
|
215 |
+
},
|
216 |
+
)
|
217 |
+
</script>
|
218 |
+
<?php
|
219 |
+
}
|
220 |
+
|
221 |
+
// https://help.pinterest.com/en/business/article/track-conversions-with-pinterest-tag
|
222 |
+
// https://help.pinterest.com/en/business/article/add-event-codes
|
223 |
+
private function conversion_html_pinterest( $shortcode_attributes ) {
|
224 |
+
|
225 |
+
if ('' === $shortcode_attributes['pinc-lead-type']) {
|
226 |
+
?>
|
227 |
+
|
228 |
+
<script>
|
229 |
+
wpmFunctionExists("pintrk").then(function () {
|
230 |
+
pintrk("track", '<?php echo esc_js($shortcode_attributes['pinc-event']); ?>')
|
231 |
+
},
|
232 |
+
)
|
233 |
+
</script>
|
234 |
+
<?php
|
235 |
+
} else {
|
236 |
+
?>
|
237 |
+
|
238 |
+
<script>
|
239 |
+
wpmFunctionExists("pintrk").then(function () {
|
240 |
+
pintrk("track", '<?php echo esc_js($shortcode_attributes['pinc-event']); ?>', {
|
241 |
+
lead_type: '<?php echo esc_js($shortcode_attributes['pinc-lead-type']); ?>',
|
242 |
+
})
|
243 |
+
},
|
244 |
+
)
|
245 |
+
</script>
|
246 |
+
<?php
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
// https://bingadsuet.azurewebsites.net/UETDirectOnSite_ReportCustomEvents.html
|
251 |
+
private function conversion_html_microsoft_ads( $shortcode_attributes ) {
|
252 |
+
?>
|
253 |
+
|
254 |
+
<script>
|
255 |
+
wpmFunctionExists("uetq").then(function () {
|
256 |
+
window.uetq = window.uetq || []
|
257 |
+
window.uetq.push("event", '<?php echo esc_js($shortcode_attributes['ms-ads-event']); ?>', {
|
258 |
+
"event_category": '<?php echo esc_js($shortcode_attributes['ms-ads-event-category']); ?>',
|
259 |
+
"event_label" : '<?php echo esc_js($shortcode_attributes['ms-ads-event-label']); ?>',
|
260 |
+
"event_value" : '<?php echo esc_js($shortcode_attributes['ms-ads-event-value']); ?>',
|
261 |
+
})
|
262 |
+
},
|
263 |
+
)
|
264 |
+
</script>
|
265 |
+
<?php
|
266 |
+
}
|
267 |
+
|
268 |
+
protected function function_exists_script() {
|
269 |
+
?>
|
270 |
+
|
271 |
+
<script>
|
272 |
+
if (typeof wpmFunctionExists !== "function") {
|
273 |
+
window.wpmFunctionExists = function (functionName) {
|
274 |
+
return new Promise(function (resolve) {
|
275 |
+
(function waitForVar() {
|
276 |
+
if (typeof window[functionName] !== "undefined") return resolve()
|
277 |
+
setTimeout(waitForVar, 1000)
|
278 |
+
})()
|
279 |
+
})
|
280 |
+
}
|
281 |
+
}
|
282 |
+
</script>
|
283 |
+
<?php
|
284 |
+
}
|
285 |
+
}
|
classes/pixels/class-twitter.php
DELETED
@@ -1,87 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// TODO check if more values can be passed to product and cart pages
|
4 |
-
|
5 |
-
namespace WGACT\Classes\Pixels;
|
6 |
-
|
7 |
-
if (!defined('ABSPATH')) {
|
8 |
-
exit; // Exit if accessed directly
|
9 |
-
}
|
10 |
-
|
11 |
-
class Twitter extends Pixel
|
12 |
-
{
|
13 |
-
public function inject_everywhere()
|
14 |
-
{
|
15 |
-
// @formatter:off
|
16 |
-
?>
|
17 |
-
|
18 |
-
<script>
|
19 |
-
!function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);
|
20 |
-
},s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='//static.ads-twitter.com/uwt.js',
|
21 |
-
a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');
|
22 |
-
twq('init','<?php echo $this->options_obj->twitter->pixel_id ?>');
|
23 |
-
</script>
|
24 |
-
|
25 |
-
<?php if(!is_order_received_page()): ?>
|
26 |
-
|
27 |
-
<script>
|
28 |
-
twq('track','PageView');
|
29 |
-
</script>
|
30 |
-
<?php endif; ?>
|
31 |
-
<?php
|
32 |
-
// @formatter:on
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
public function inject_search()
|
37 |
-
{
|
38 |
-
?>
|
39 |
-
|
40 |
-
<script>
|
41 |
-
twq('track', 'Search');
|
42 |
-
</script>
|
43 |
-
<?php
|
44 |
-
}
|
45 |
-
|
46 |
-
public function inject_product($product_id, $product)
|
47 |
-
{
|
48 |
-
?>
|
49 |
-
|
50 |
-
<script>
|
51 |
-
twq('track', 'ViewContent');
|
52 |
-
</script>
|
53 |
-
<?php
|
54 |
-
}
|
55 |
-
|
56 |
-
public function inject_cart($cart, $cart_total)
|
57 |
-
{
|
58 |
-
?>
|
59 |
-
|
60 |
-
<script>
|
61 |
-
twq('track', 'AddToCart');
|
62 |
-
</script>
|
63 |
-
<?php
|
64 |
-
}
|
65 |
-
|
66 |
-
public function inject_order_received_page($order, $order_total, $order_item_ids)
|
67 |
-
{
|
68 |
-
// TODO find out under which circumstances to use different values in content_type
|
69 |
-
|
70 |
-
?>
|
71 |
-
|
72 |
-
<script>
|
73 |
-
if ((typeof wgact !== "undefined") && !wgact.isOrderIdStored(<?php echo $order->get_id() ?>)) {
|
74 |
-
twq('track', 'Purchase', {
|
75 |
-
value : '<?php echo $order_total ?>',
|
76 |
-
currency : '<?php echo $order->get_currency() ?>',
|
77 |
-
num_items : '<?php echo count($order->get_items()) ?>',
|
78 |
-
content_ids : <?php echo json_encode($order_item_ids) ?>,
|
79 |
-
content_type: 'product',
|
80 |
-
order_id : '<?php echo $order->get_order_number(); ?>'
|
81 |
-
});
|
82 |
-
}
|
83 |
-
|
84 |
-
</script>
|
85 |
-
<?php
|
86 |
-
}
|
87 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/facebook/class-facebook-browser-pixel.php
DELETED
@@ -1,87 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WCPM\Classes\Pixels\Facebook;
|
4 |
-
|
5 |
-
use WCPM\Classes\Pixels\Pixel;
|
6 |
-
|
7 |
-
if (!defined('ABSPATH')) {
|
8 |
-
exit; // Exit if accessed directly
|
9 |
-
}
|
10 |
-
|
11 |
-
class Facebook_Browser_Pixel extends Pixel
|
12 |
-
{
|
13 |
-
protected $pixel_name;
|
14 |
-
|
15 |
-
public function __construct($options)
|
16 |
-
{
|
17 |
-
parent::__construct($options);
|
18 |
-
|
19 |
-
$this->pixel_name = 'facebook';
|
20 |
-
}
|
21 |
-
|
22 |
-
public function inject_everywhere()
|
23 |
-
{
|
24 |
-
$facebook_data_layer = [
|
25 |
-
'dynamic_remarketing' => [
|
26 |
-
'id_type' => $this->get_dyn_r_id_type(),
|
27 |
-
],
|
28 |
-
'pixel_id' => $this->options_obj->facebook->pixel_id,
|
29 |
-
'capi' => $this->options_obj->facebook->capi->token ? true : false,
|
30 |
-
];
|
31 |
-
|
32 |
-
|
33 |
-
// @formatter:off
|
34 |
-
?>
|
35 |
-
wpmDataLayer.pixels.<?php echo $this->pixel_name ?> = <?php echo json_encode($facebook_data_layer) ?>;
|
36 |
-
|
37 |
-
!function(f,b,e,v,n,t,s)
|
38 |
-
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
39 |
-
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
|
40 |
-
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
|
41 |
-
n.queue=[];t=b.createElement(e);t.async=!0;
|
42 |
-
t.src=v;s=b.getElementsByTagName(e)[0];
|
43 |
-
s.parentNode.insertBefore(t,s)}(window, document,'script',
|
44 |
-
'https://connect.facebook.net/en_US/fbevents.js');
|
45 |
-
|
46 |
-
fbq('init', '<?php echo $this->options_obj->facebook->pixel_id ?>');
|
47 |
-
fbq('track', 'PageView');
|
48 |
-
<?php
|
49 |
-
// @formatter:on
|
50 |
-
}
|
51 |
-
|
52 |
-
public function inject_search()
|
53 |
-
{
|
54 |
-
// handled on front-end
|
55 |
-
}
|
56 |
-
|
57 |
-
public function inject_cart($cart, $cart_total)
|
58 |
-
{
|
59 |
-
// AddToCart event is triggered in front-end event layer
|
60 |
-
}
|
61 |
-
|
62 |
-
public function inject_product($product, $product_attributes)
|
63 |
-
{
|
64 |
-
// handled on front-end
|
65 |
-
}
|
66 |
-
|
67 |
-
public function inject_order_received_page($order, $order_total, $is_new_customer)
|
68 |
-
{
|
69 |
-
$data = [
|
70 |
-
'value' => $order_total,
|
71 |
-
'currency' => get_woocommerce_currency(),
|
72 |
-
'content_ids' => $this->get_order_item_ids($order),
|
73 |
-
'content_type' => 'product',
|
74 |
-
];
|
75 |
-
|
76 |
-
echo "
|
77 |
-
wpmExists().then(function(){
|
78 |
-
if (!wpm.isOrderIdStored('". $order->get_id() . "')) {
|
79 |
-
fbq('track', 'Purchase', " . json_encode($data) . ", {
|
80 |
-
'eventID': '" . $order->get_order_number() . "',
|
81 |
-
});
|
82 |
-
}
|
83 |
-
});
|
84 |
-
|
85 |
-
";
|
86 |
-
}
|
87 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/facebook/class-facebook-pixel-manager-microdata.php
CHANGED
@@ -2,38 +2,32 @@
|
|
2 |
|
3 |
namespace WCPM\Classes\Pixels\Facebook;
|
4 |
|
5 |
-
use WCPM\Classes\Pixels\
|
6 |
|
7 |
if (!defined('ABSPATH')) {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
-
class Facebook_Pixel_Manager_Microdata extends
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
protected function inject_closing_script_tag()
|
36 |
-
{
|
37 |
-
// remove default script output
|
38 |
-
}
|
39 |
-
}
|
2 |
|
3 |
namespace WCPM\Classes\Pixels\Facebook;
|
4 |
|
5 |
+
use WCPM\Classes\Pixels\Script_Manager;
|
6 |
|
7 |
if (!defined('ABSPATH')) {
|
8 |
+
exit; // Exit if accessed directly
|
9 |
}
|
10 |
|
11 |
+
class Facebook_Pixel_Manager_Microdata extends Script_Manager {
|
12 |
+
protected $facebook_microdata_pixel;
|
13 |
+
|
14 |
+
public function __construct( $options ) {
|
15 |
+
parent::__construct($options);
|
16 |
+
$this->facebook_microdata_pixel = new Facebook_Microdata($options);
|
17 |
+
}
|
18 |
+
|
19 |
+
public function inject_product( $product, $product_attributes ) {
|
20 |
+
$this->facebook_microdata_pixel->inject_product($product, $product_attributes);
|
21 |
+
}
|
22 |
+
|
23 |
+
public function inject_order_received_page_no_dedupe( $order, $order_total, $is_new_customer ) {
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function inject_opening_script_tag() {
|
27 |
+
// remove default script output
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function inject_closing_script_tag() {
|
31 |
+
// remove default script output
|
32 |
+
}
|
33 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/facebook/class-facebook-pixel-manager.php
CHANGED
@@ -3,24 +3,19 @@
|
|
3 |
namespace WCPM\Classes\Pixels\Facebook;
|
4 |
|
5 |
use WCPM\Classes\Http\Facebook_CAPI ;
|
6 |
-
use WCPM\Classes\Pixels\Pixel_Manager_Base ;
|
7 |
|
8 |
if ( !defined( 'ABSPATH' ) ) {
|
9 |
exit;
|
10 |
// Exit if accessed directly
|
11 |
}
|
12 |
|
13 |
-
class Facebook_Pixel_Manager
|
14 |
{
|
15 |
-
protected $facebook_browser_pixel ;
|
16 |
protected $facebook_capi ;
|
17 |
public function __construct( $options )
|
18 |
{
|
19 |
-
parent::__construct( $options );
|
20 |
-
// add_action('wp_enqueue_scripts', [$this, 'wpm_facebook_front_end_scripts']);
|
21 |
-
$this->facebook_browser_pixel = new Facebook_Browser_Pixel( $options );
|
22 |
|
23 |
-
if ( wpm_fs()->is__premium_only() && $
|
24 |
$this->facebook_capi = new Facebook_CAPI( $options );
|
25 |
// Save the Facebook session identifiers on the order so that we can use them later when the order gets paid or completed
|
26 |
// https://woocommerce.github.io/code-reference/files/woocommerce-includes-class-wc-checkout.html#source-view.403
|
@@ -37,74 +32,5 @@ class Facebook_Pixel_Manager extends Pixel_Manager_Base
|
|
37 |
}
|
38 |
|
39 |
}
|
40 |
-
|
41 |
-
public function wpm_facebook_front_end_scripts()
|
42 |
-
{
|
43 |
-
wp_enqueue_script(
|
44 |
-
'wpm-facebook',
|
45 |
-
WPM_PLUGIN_DIR_PATH . 'js/public/footer/facebook' . $this->get_script_suffix(),
|
46 |
-
[ 'jquery', 'wpm' ],
|
47 |
-
// ['jquery'],
|
48 |
-
WPM_CURRENT_VERSION,
|
49 |
-
true
|
50 |
-
);
|
51 |
-
}
|
52 |
-
|
53 |
-
public function inject_everywhere()
|
54 |
-
{
|
55 |
-
$this->facebook_browser_pixel->inject_everywhere();
|
56 |
-
}
|
57 |
-
|
58 |
-
public function inject_search()
|
59 |
-
{
|
60 |
-
$this->facebook_browser_pixel->inject_search();
|
61 |
-
}
|
62 |
-
|
63 |
-
public function inject_product( $product, $product_attributes )
|
64 |
-
{
|
65 |
-
$this->facebook_browser_pixel->inject_product( $product, $product_attributes );
|
66 |
-
}
|
67 |
-
|
68 |
-
public function inject_cart( $cart, $cart_total )
|
69 |
-
{
|
70 |
-
$this->facebook_browser_pixel->inject_cart( $cart, $cart_total );
|
71 |
-
}
|
72 |
-
|
73 |
-
public function inject_order_received_page_dedupe( $order, $order_total, $is_new_customer )
|
74 |
-
{
|
75 |
-
$this->facebook_browser_pixel->inject_order_received_page( $order, $order_total, $is_new_customer );
|
76 |
-
}
|
77 |
-
|
78 |
-
public function inject_order_received_page_no_dedupe( $order, $order_total, $is_new_customer )
|
79 |
-
{
|
80 |
-
}
|
81 |
-
|
82 |
-
protected function inject_opening_script_tag()
|
83 |
-
{
|
84 |
-
echo PHP_EOL ;
|
85 |
-
echo ' <!-- START Facebook scripts -->' . PHP_EOL ;
|
86 |
-
// echo ' <script>';
|
87 |
-
echo "\t\t\t" . $this->get_formatted_script_tag( [
|
88 |
-
'async' => true,
|
89 |
-
'defer' => false,
|
90 |
-
'src' => '',
|
91 |
-
'cookie_category' => 'ads',
|
92 |
-
'pixel_name' => 'facebook-ads',
|
93 |
-
'inject_cfasync' => false,
|
94 |
-
] ) . PHP_EOL ;
|
95 |
-
echo PHP_EOL ;
|
96 |
-
}
|
97 |
-
|
98 |
-
protected function inject_closing_script_tag()
|
99 |
-
{
|
100 |
-
echo PHP_EOL ;
|
101 |
-
echo ' </script>' ;
|
102 |
-
echo PHP_EOL ;
|
103 |
-
echo ' <!-- END Facebook scripts -->' . PHP_EOL ;
|
104 |
-
}
|
105 |
-
|
106 |
-
protected function inject_closing_script_after_tag()
|
107 |
-
{
|
108 |
-
}
|
109 |
|
110 |
}
|
3 |
namespace WCPM\Classes\Pixels\Facebook;
|
4 |
|
5 |
use WCPM\Classes\Http\Facebook_CAPI ;
|
|
|
6 |
|
7 |
if ( !defined( 'ABSPATH' ) ) {
|
8 |
exit;
|
9 |
// Exit if accessed directly
|
10 |
}
|
11 |
|
12 |
+
class Facebook_Pixel_Manager
|
13 |
{
|
|
|
14 |
protected $facebook_capi ;
|
15 |
public function __construct( $options )
|
16 |
{
|
|
|
|
|
|
|
17 |
|
18 |
+
if ( wpm_fs()->is__premium_only() && $options['facebook']['capi']['token'] ) {
|
19 |
$this->facebook_capi = new Facebook_CAPI( $options );
|
20 |
// Save the Facebook session identifiers on the order so that we can use them later when the order gets paid or completed
|
21 |
// https://woocommerce.github.io/code-reference/files/woocommerce-includes-class-wc-checkout.html#source-view.403
|
32 |
}
|
33 |
|
34 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
}
|
classes/pixels/facebook/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
classes/pixels/google/class-google-ads-pixel.php
DELETED
@@ -1,191 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels\Google;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Google_Ads_Pixel extends Google_Pixel
|
10 |
-
{
|
11 |
-
use Trait_Google;
|
12 |
-
|
13 |
-
protected $google_business_vertical;
|
14 |
-
|
15 |
-
public function __construct()
|
16 |
-
{
|
17 |
-
parent::__construct();
|
18 |
-
|
19 |
-
add_action('wp_enqueue_scripts', [$this, 'wooptpm_google_ads_front_end_scripts']);
|
20 |
-
|
21 |
-
// $this->pixel_name = 'google_ads';
|
22 |
-
}
|
23 |
-
|
24 |
-
public function wooptpm_google_ads_front_end_scripts()
|
25 |
-
{
|
26 |
-
wp_enqueue_script('google-ads', plugin_dir_url(__DIR__) . '../../js/public/google_ads.js', [], WGACT_CURRENT_VERSION, false);
|
27 |
-
}
|
28 |
-
|
29 |
-
public function inject_product_list($list_name)
|
30 |
-
{
|
31 |
-
global $wp_query;
|
32 |
-
|
33 |
-
?>
|
34 |
-
|
35 |
-
gtag('event', '<?php echo $list_name ?>', {
|
36 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
37 |
-
'items' : <?php echo json_encode($this->get_products_from_wp_query($wp_query)) . PHP_EOL ?>
|
38 |
-
});
|
39 |
-
<?php
|
40 |
-
}
|
41 |
-
|
42 |
-
public function inject_product($product, $product_attributes)
|
43 |
-
{
|
44 |
-
$product_details = $this->get_gads_formatted_product_details_from_product_id($product->get_id());
|
45 |
-
|
46 |
-
?>
|
47 |
-
|
48 |
-
gtag('event', 'view_item', {
|
49 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
50 |
-
'value' : <?php echo $product_details['price'] ?>,
|
51 |
-
'items' : [<?php echo(json_encode($product_details)) ?>]
|
52 |
-
});
|
53 |
-
<?php
|
54 |
-
}
|
55 |
-
|
56 |
-
public function inject_cart($cart, $cart_total)
|
57 |
-
{
|
58 |
-
// triggered by front-end scripts
|
59 |
-
}
|
60 |
-
|
61 |
-
public function inject_order_received_page($order, $order_total, $is_new_customer)
|
62 |
-
{
|
63 |
-
$order_currency = $this->get_order_currency($order);
|
64 |
-
|
65 |
-
?>
|
66 |
-
|
67 |
-
<?php
|
68 |
-
|
69 |
-
// if cart data beta is off and conversion id has been set
|
70 |
-
if ($this->add_cart_data == false && $this->options_obj->google->ads->conversion_id) {
|
71 |
-
|
72 |
-
// no deduper needed here
|
73 |
-
// Google does this server side
|
74 |
-
if ($this->options_obj->google->ads->conversion_label): ?>
|
75 |
-
|
76 |
-
gtag('event', 'conversion', {
|
77 |
-
'send_to' : <?php echo json_encode($this->get_google_ads_conversion_ids(true)) ?>,
|
78 |
-
'value' : <?php echo $order_total; ?>,
|
79 |
-
'currency' : '<?php echo $order_currency; ?>',
|
80 |
-
'transaction_id': '<?php echo $order->get_order_number(); ?>',
|
81 |
-
});
|
82 |
-
<?php
|
83 |
-
endif; ?>
|
84 |
-
|
85 |
-
<?php
|
86 |
-
if ($this->is_dynamic_remarketing_active()) echo $this->get_dyn_remarketing_purchase_script($order, $order_total) ?>
|
87 |
-
|
88 |
-
<?php
|
89 |
-
}
|
90 |
-
|
91 |
-
if ($this->add_cart_data == true && $this->conversion_id && $this->conversion_label) {
|
92 |
-
?>
|
93 |
-
|
94 |
-
gtag('event', 'purchase', <?php echo $this->get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer, 'ads') ?>);
|
95 |
-
<?php
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
// get products from wp_query
|
101 |
-
protected function get_products_from_wp_query($wp_query): array
|
102 |
-
{
|
103 |
-
$items = [];
|
104 |
-
|
105 |
-
$posts = $wp_query->posts;
|
106 |
-
|
107 |
-
foreach ($posts as $key => $post) {
|
108 |
-
|
109 |
-
if ($post->post_type == 'product' || $post->post_type == 'product_variation') {
|
110 |
-
|
111 |
-
$item_details = [];
|
112 |
-
|
113 |
-
$product = wc_get_product($post->ID);
|
114 |
-
|
115 |
-
// only continue if WC retrieves a valid product
|
116 |
-
if (!is_bool($product)) {
|
117 |
-
|
118 |
-
$dyn_r_ids = $this->get_dyn_r_ids($product);
|
119 |
-
|
120 |
-
$item_details['id'] = $dyn_r_ids[$this->get_dyn_r_id_type()];
|
121 |
-
$item_details['google_business_vertical'] = $this->google_business_vertical;
|
122 |
-
|
123 |
-
array_push($items, $item_details);
|
124 |
-
}
|
125 |
-
}
|
126 |
-
}
|
127 |
-
|
128 |
-
return $items;
|
129 |
-
}
|
130 |
-
|
131 |
-
protected function get_gads_formatted_product_details_from_product_id($product_id): array
|
132 |
-
{
|
133 |
-
$product = wc_get_product($product_id);
|
134 |
-
|
135 |
-
$dyn_r_ids = $this->get_dyn_r_ids($product);
|
136 |
-
|
137 |
-
$product_details['id'] = $dyn_r_ids[$this->get_dyn_r_id_type()];
|
138 |
-
$product_details['category'] = $this->get_product_category($product_id);
|
139 |
-
// $product_details['list_position'] = 1;
|
140 |
-
$product_details['quantity'] = 1;
|
141 |
-
$product_details['price'] = (float)$product->get_price();
|
142 |
-
$product_details['google_business_vertical'] = $this->google_business_vertical;
|
143 |
-
|
144 |
-
return $product_details;
|
145 |
-
}
|
146 |
-
|
147 |
-
// get an array with all cart product ids
|
148 |
-
protected function get_gads_formatted_cart_items($cart)
|
149 |
-
{
|
150 |
-
// error_log(print_r($cart, true));
|
151 |
-
// initiate product identifier array
|
152 |
-
$cart_items = [];
|
153 |
-
$item_details = [];
|
154 |
-
|
155 |
-
// go through the array and get all product identifiers
|
156 |
-
foreach ((array)$cart as $cart_item) {
|
157 |
-
// error_log(print_r($cart_item,true));
|
158 |
-
$product_id = $this->get_variation_or_product_id($cart_item, $this->options_obj->general->variations_output);
|
159 |
-
// error_log('id: ' . $product_id);
|
160 |
-
$product = wc_get_product($product_id);
|
161 |
-
|
162 |
-
$dyn_r_ids = $this->get_dyn_r_ids($product);
|
163 |
-
|
164 |
-
$item_details['id'] = $dyn_r_ids[$this->get_dyn_r_id_type()];
|
165 |
-
$item_details['quantity'] = (int)$cart_item['quantity'];
|
166 |
-
$item_details['price'] = (int)$product->get_price();
|
167 |
-
$item_details['google_business_vertical'] = $this->google_business_vertical;
|
168 |
-
|
169 |
-
array_push($cart_items, $item_details);
|
170 |
-
}
|
171 |
-
|
172 |
-
// apply filter to the $cartprods_items array
|
173 |
-
$cart_items = apply_filters('wgact_filter', $cart_items, 'cart_items');
|
174 |
-
|
175 |
-
return $cart_items;
|
176 |
-
}
|
177 |
-
|
178 |
-
protected function get_dyn_remarketing_purchase_script($order, $order_total)
|
179 |
-
{
|
180 |
-
?>
|
181 |
-
|
182 |
-
if ((typeof wooptpm !== "undefined") && !wooptpm.isOrderIdStored(<?php echo $order->get_id() ?>)) {
|
183 |
-
gtag('event', 'purchase', {
|
184 |
-
'send_to': <?php echo json_encode($this->get_google_ads_conversion_ids()) ?>,
|
185 |
-
'value' : <?php echo $order_total; ?>,
|
186 |
-
'items' : <?php echo (json_encode($this->get_formatted_order_items($order, 'ads'))) . PHP_EOL ?>
|
187 |
-
});
|
188 |
-
}
|
189 |
-
<?php
|
190 |
-
}
|
191 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-ads.php
DELETED
@@ -1,196 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WCPM\Classes\Pixels\Google;
|
4 |
-
|
5 |
-
use libphonenumber\PhoneNumberFormat ;
|
6 |
-
use libphonenumber\PhoneNumberUtil ;
|
7 |
-
use WCPM\Classes\Pixels\Trait_Shop ;
|
8 |
-
|
9 |
-
if ( !defined( 'ABSPATH' ) ) {
|
10 |
-
exit;
|
11 |
-
// Exit if accessed directly
|
12 |
-
}
|
13 |
-
|
14 |
-
class Google_Ads extends Google
|
15 |
-
{
|
16 |
-
use Trait_Google ;
|
17 |
-
use Trait_Shop ;
|
18 |
-
protected $google_business_vertical ;
|
19 |
-
public function __construct( $options )
|
20 |
-
{
|
21 |
-
parent::__construct( $options );
|
22 |
-
// add_action('wp_enqueue_scripts', [$this, 'wpm_google_ads_front_end_scripts']);
|
23 |
-
$this->pixel_name = 'google_ads';
|
24 |
-
}
|
25 |
-
|
26 |
-
public function wpm_google_ads_front_end_scripts()
|
27 |
-
{
|
28 |
-
wp_enqueue_script(
|
29 |
-
'wpm-google-ads',
|
30 |
-
WPM_PLUGIN_DIR_PATH . 'js/public/footer/google-ads' . $this->get_script_suffix(),
|
31 |
-
[ 'jquery', 'wpm' ],
|
32 |
-
WPM_CURRENT_VERSION,
|
33 |
-
true
|
34 |
-
);
|
35 |
-
}
|
36 |
-
|
37 |
-
public function inject_product_list( $list_name )
|
38 |
-
{
|
39 |
-
// handled on front-end
|
40 |
-
}
|
41 |
-
|
42 |
-
public function inject_product( $product, $product_attributes )
|
43 |
-
{
|
44 |
-
// handled on front-end
|
45 |
-
}
|
46 |
-
|
47 |
-
public function inject_cart( $cart, $cart_total )
|
48 |
-
{
|
49 |
-
// handled on front-end
|
50 |
-
}
|
51 |
-
|
52 |
-
public function inject_order_received_page_dedupe( $order, $order_total, $is_new_customer )
|
53 |
-
{
|
54 |
-
$order_currency = $this->get_order_currency( $order );
|
55 |
-
// if cart data beta is off and conversion id has been set
|
56 |
-
|
57 |
-
if ( $this->add_cart_data == false && $this->options_obj->google->ads->conversion_id ) {
|
58 |
-
// no deduper needed here
|
59 |
-
// Google does this server side
|
60 |
-
|
61 |
-
if ( $this->options_obj->google->ads->conversion_label ) {
|
62 |
-
?>
|
63 |
-
|
64 |
-
if (googleConfigConditionsMet('ads')) gtag('event', 'conversion', {
|
65 |
-
'send_to' : <?php
|
66 |
-
echo json_encode( $this->get_google_ads_conversion_ids( true ) ) ;
|
67 |
-
?>,
|
68 |
-
'value' : <?php
|
69 |
-
echo $order_total ;
|
70 |
-
?>,
|
71 |
-
'currency' : '<?php
|
72 |
-
echo $order_currency ;
|
73 |
-
?>',
|
74 |
-
'transaction_id': '<?php
|
75 |
-
echo $order->get_order_number() ;
|
76 |
-
?>',
|
77 |
-
});
|
78 |
-
<?php
|
79 |
-
}
|
80 |
-
|
81 |
-
?>
|
82 |
-
|
83 |
-
<?php
|
84 |
-
if ( $this->is_dynamic_remarketing_active() ) {
|
85 |
-
$this->get_dyn_remarketing_purchase_script( $order, $order_total );
|
86 |
-
}
|
87 |
-
?>
|
88 |
-
|
89 |
-
<?php
|
90 |
-
}
|
91 |
-
|
92 |
-
if ( $this->add_cart_data == true && $this->conversion_id && $this->conversion_label ) {
|
93 |
-
if ( $this->is_dynamic_remarketing_active() ) {
|
94 |
-
$this->get_dyn_remarketing_purchase_script( $order, $order_total );
|
95 |
-
}
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
public function inject_order_received_page_no_dedupe( $order, $order_total, $is_new_customer )
|
100 |
-
{
|
101 |
-
$order_currency = $this->get_order_currency( $order );
|
102 |
-
|
103 |
-
if ( $this->add_cart_data == true && $this->conversion_id && $this->conversion_label ) {
|
104 |
-
?>
|
105 |
-
|
106 |
-
if (googleConfigConditionsMet('ads')) gtag('event', 'purchase', <?php
|
107 |
-
echo json_encode( $this->get_google_ads_formatted_purchase_json(
|
108 |
-
$order,
|
109 |
-
$order_total,
|
110 |
-
$order_currency,
|
111 |
-
$is_new_customer
|
112 |
-
) ) ;
|
113 |
-
?>);
|
114 |
-
|
115 |
-
<?php
|
116 |
-
}
|
117 |
-
|
118 |
-
}
|
119 |
-
|
120 |
-
private function are_billing_and_shipping_addresses_equal( $order ) : bool
|
121 |
-
{
|
122 |
-
|
123 |
-
if ( $order->get_billing_address_1() === $order->get_shipping_address_1() && $order->get_billing_city() === $order->get_shipping_city() && $order->get_billing_state() === $order->get_shipping_state() && $order->get_billing_postcode() === $order->get_shipping_postcode() && $order->get_billing_country() === $order->get_shipping_country() ) {
|
124 |
-
return true;
|
125 |
-
} else {
|
126 |
-
return false;
|
127 |
-
}
|
128 |
-
|
129 |
-
}
|
130 |
-
|
131 |
-
private function get_e164_formatted_phone_number( $number, $country ) : string
|
132 |
-
{
|
133 |
-
try {
|
134 |
-
$phone_util = PhoneNumberUtil::getInstance();
|
135 |
-
$number_parsed = $phone_util->parse( $number, $country );
|
136 |
-
return $phone_util->format( $number_parsed, PhoneNumberFormat::E164 );
|
137 |
-
} catch ( \libphonenumber\NumberParseException $e ) {
|
138 |
-
error_log( $e );
|
139 |
-
return $number;
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
// https://support.google.com/google-ads/answer/9028614
|
144 |
-
private function get_google_ads_formatted_purchase_json(
|
145 |
-
$order,
|
146 |
-
$order_total,
|
147 |
-
$order_currency,
|
148 |
-
$is_new_customer
|
149 |
-
) : array
|
150 |
-
{
|
151 |
-
return [
|
152 |
-
'send_to' => $this->get_google_ads_conversion_ids( true ),
|
153 |
-
'transaction_id' => (string) $order->get_order_number(),
|
154 |
-
'value' => (double) $order_total,
|
155 |
-
'currency' => (string) $order_currency,
|
156 |
-
'discount' => (double) $order->get_total_discount(),
|
157 |
-
'aw_merchant_id' => (int) $this->aw_merchant_id,
|
158 |
-
'aw_feed_country' => (string) $this->get_visitor_country(),
|
159 |
-
'aw_feed_language' => $this->get_gmc_language(),
|
160 |
-
'new_customer' => (string) $is_new_customer,
|
161 |
-
'items' => $this->get_order_items_for_google_ads_purchase_script( $order, false ),
|
162 |
-
];
|
163 |
-
}
|
164 |
-
|
165 |
-
protected function get_dyn_remarketing_purchase_script( $order, $order_total )
|
166 |
-
{
|
167 |
-
echo "\n wpmExists().then(function(){\n if (!wpm.isOrderIdStored('" . $order->get_id() . "')) {\n if (googleConfigConditionsMet('ads')) gtag('event', 'purchase', {\n 'send_to': " . json_encode( $this->get_google_ads_conversion_ids() ) . ",\n 'value' : " . $order_total . ",\n 'items' : " . json_encode( $this->get_order_items_for_google_ads_purchase_script( $order, true ) ) . "\n });\n }\n });\n " ;
|
168 |
-
}
|
169 |
-
|
170 |
-
private function get_order_items_for_google_ads_purchase_script( $order, $dyn_r = false ) : array
|
171 |
-
{
|
172 |
-
$order_items = (array) $this->wpm_get_order_items( $order );
|
173 |
-
$order_items_array = [];
|
174 |
-
foreach ( $order_items as $order_item ) {
|
175 |
-
$product_id = $this->get_variation_or_product_id( $order_item->get_data(), $this->options_obj->general->variations_output );
|
176 |
-
$product = wc_get_product( $product_id );
|
177 |
-
$order_items_array = [];
|
178 |
-
|
179 |
-
if ( !is_object( $product ) ) {
|
180 |
-
$this->log_problematic_product_id( $product_id );
|
181 |
-
continue;
|
182 |
-
}
|
183 |
-
|
184 |
-
$dyn_r_ids = $this->get_dyn_r_ids( $product );
|
185 |
-
$item_details_array['id'] = (string) $dyn_r_ids[$this->get_dyn_r_id_type()];
|
186 |
-
$item_details_array['quantity'] = (int) $order_item['quantity'];
|
187 |
-
$item_details_array['price'] = (double) $product->get_price();
|
188 |
-
if ( $dyn_r === true ) {
|
189 |
-
$item_details_array['google_business_vertical'] = (string) $this->google_business_vertical;
|
190 |
-
}
|
191 |
-
array_push( $order_items_array, $item_details_array );
|
192 |
-
}
|
193 |
-
return $order_items_array;
|
194 |
-
}
|
195 |
-
|
196 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics-4-eec.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
namespace WCPM\Classes\Pixels\Google;
|
5 |
-
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class Google_Analytics_4_EEC extends Google_Analytics_4
|
11 |
-
{
|
12 |
-
use Trait_Google;
|
13 |
-
|
14 |
-
public function __construct($options)
|
15 |
-
{
|
16 |
-
parent::__construct($options);
|
17 |
-
}
|
18 |
-
|
19 |
-
protected function output_view_item_list_html($items, $list_id)
|
20 |
-
{
|
21 |
-
// handled on front-end
|
22 |
-
}
|
23 |
-
|
24 |
-
public function inject_cart($cart, $cart_total)
|
25 |
-
{
|
26 |
-
// handled on front-end
|
27 |
-
}
|
28 |
-
|
29 |
-
public function inject_product($product, $product_attributes)
|
30 |
-
{
|
31 |
-
// handled on front-end
|
32 |
-
}
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics-4-standard-pixel.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
namespace WGACT\Classes\Pixels\Google;
|
5 |
-
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class Google_Analytics_4_Standard_Pixel extends Google_Analytics
|
11 |
-
{
|
12 |
-
public function __construct()
|
13 |
-
{
|
14 |
-
parent::__construct();
|
15 |
-
}
|
16 |
-
|
17 |
-
public function inject_order_received_page($order, $order_total, $is_new_customer)
|
18 |
-
{
|
19 |
-
$gtag_data = [
|
20 |
-
'send_to' => [],
|
21 |
-
'transaction_id' => $order->get_order_number(),
|
22 |
-
'currency' => $this->get_order_currency($order),
|
23 |
-
'discount' => $order->get_total_discount(),
|
24 |
-
'affiliation' => (string)get_bloginfo('name'),
|
25 |
-
'tax' => (float)$order->get_total_tax(),
|
26 |
-
'shipping' => (float)$order->get_total_shipping(),
|
27 |
-
'value' => (float)$order->get_total(),
|
28 |
-
'items' => $this->get_formatted_order_items($order),
|
29 |
-
];
|
30 |
-
|
31 |
-
array_push($gtag_data['send_to'], $this->options_obj->google->analytics->ga4->measurement_id);
|
32 |
-
|
33 |
-
?>
|
34 |
-
|
35 |
-
if ((typeof wooptpm !== "undefined") && !wooptpm.isOrderIdStored(<?php echo $order->get_id() ?>)) {
|
36 |
-
gtag('event', 'purchase', <?php echo json_encode($gtag_data) ?>);
|
37 |
-
}
|
38 |
-
<?php
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics-4-standard.php
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
namespace WCPM\Classes\Pixels\Google;
|
5 |
-
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class Google_Analytics_4_Standard extends Google_Analytics_4
|
11 |
-
{
|
12 |
-
public function __construct($options)
|
13 |
-
{
|
14 |
-
parent::__construct($options);
|
15 |
-
}
|
16 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics-4.php
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
namespace WCPM\Classes\Pixels\Google;
|
5 |
-
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class Google_Analytics_4 extends Google_Analytics
|
11 |
-
{
|
12 |
-
use Trait_Google;
|
13 |
-
|
14 |
-
public function __construct($options)
|
15 |
-
{
|
16 |
-
parent::__construct($options);
|
17 |
-
}
|
18 |
-
|
19 |
-
public function inject_order_received_page($order, $order_total, $is_new_customer)
|
20 |
-
{
|
21 |
-
$order_currency = $this->get_order_currency($order);
|
22 |
-
|
23 |
-
echo "
|
24 |
-
wpmExists().then(function(){
|
25 |
-
if (!wpm.isOrderIdStored('" . $order->get_id() . "')) {
|
26 |
-
if (googleConfigConditionsMet('analytics')) gtag('event', 'purchase', " . $this->get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer) . ");
|
27 |
-
}
|
28 |
-
});
|
29 |
-
";
|
30 |
-
}
|
31 |
-
|
32 |
-
protected function get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer, $channel = null)
|
33 |
-
{
|
34 |
-
$gtag_data = [
|
35 |
-
'send_to' => [],
|
36 |
-
'transaction_id' => (string)$order->get_order_number(),
|
37 |
-
'affiliation' => (string)get_bloginfo('name'),
|
38 |
-
'currency' => (string)$this->get_order_currency($order),
|
39 |
-
'value' => (float)$order->get_total(),
|
40 |
-
'discount' => (float)$order->get_total_discount(),
|
41 |
-
'tax' => (float)$order->get_total_tax(),
|
42 |
-
'shipping' => (float)$order->get_total_shipping(),
|
43 |
-
'coupon' => implode(',', $order->get_coupon_codes()),
|
44 |
-
'items' => (array)$this->get_formatted_order_items($order),
|
45 |
-
];
|
46 |
-
|
47 |
-
array_push($gtag_data['send_to'], $this->options_obj->google->analytics->ga4->measurement_id);
|
48 |
-
|
49 |
-
return json_encode($gtag_data);
|
50 |
-
}
|
51 |
-
|
52 |
-
protected function get_formatted_order_items($order, $channel = null)
|
53 |
-
{
|
54 |
-
$order_items = $this->wpm_get_order_items($order);
|
55 |
-
$order_items_array = [];
|
56 |
-
|
57 |
-
$list_position = 1;
|
58 |
-
|
59 |
-
foreach ((array)$order_items as $order_item) {
|
60 |
-
|
61 |
-
// $product_id = $this->get_variation_or_product_id($order_item->get_data(), $this->options_obj->general->variations_output);
|
62 |
-
|
63 |
-
$order_item_data = $this->get_order_item_data($order_item);
|
64 |
-
|
65 |
-
$item_details_array = [
|
66 |
-
'item_id' => $order_item_data['id'],
|
67 |
-
'item_name' => $order_item_data['name'],
|
68 |
-
'quantity' => $order_item_data['quantity'],
|
69 |
-
// 'affiliation' => $order_item_data['affiliation'],
|
70 |
-
// 'coupon' => '',
|
71 |
-
// 'discount' => 0,
|
72 |
-
'item_brand' => $order_item_data['brand'],
|
73 |
-
'item_variant' => $order_item_data['variant'],
|
74 |
-
// 'tax' => 0,
|
75 |
-
'price' => $order_item_data['price'],
|
76 |
-
// 'list_name' => ,
|
77 |
-
'currency' => get_woocommerce_currency(),
|
78 |
-
];
|
79 |
-
|
80 |
-
$item_details_array = $this->add_categories_to_ga4_product_items($item_details_array, $order_item_data['category_array']);
|
81 |
-
|
82 |
-
array_push($order_items_array, $item_details_array);
|
83 |
-
}
|
84 |
-
|
85 |
-
// apply filter to the $order_items_array array
|
86 |
-
$order_items_array = apply_filters_deprecated('wgact_filter', [$order_items_array], '1.10.2', '', 'This filter has been deprecated without replacement.');
|
87 |
-
|
88 |
-
return $order_items_array;
|
89 |
-
}
|
90 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics-refund-4.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WCPM\Classes\Pixels\Google;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Google_Analytics_Refund_4 extends Google_Analytics
|
10 |
-
{
|
11 |
-
public function __construct($options)
|
12 |
-
{
|
13 |
-
parent::__construct($options);
|
14 |
-
}
|
15 |
-
|
16 |
-
public function output_refund_to_frontend($order, $refund, $dataLayer_refund_items = null)
|
17 |
-
{
|
18 |
-
$data = [
|
19 |
-
'send_to' => $this->options_obj->google->analytics->ga4->measurement_id,
|
20 |
-
'affiliation' => get_bloginfo('name'),
|
21 |
-
//'coupon'=> $order->get_coupon_codes()),
|
22 |
-
'currency' => (string)$this->get_order_currency($order),
|
23 |
-
'items' => (array)$dataLayer_refund_items,
|
24 |
-
'transaction_id' => (string)$order->get_order_number(),
|
25 |
-
'shipping' => (float)$order->get_total_shipping(),
|
26 |
-
'tax' => (float)$order->get_total_tax(),
|
27 |
-
'value' => (float)$refund->get_amount(),
|
28 |
-
//'value': (float)$order->get_total(),
|
29 |
-
];
|
30 |
-
|
31 |
-
?>
|
32 |
-
<script>
|
33 |
-
// console.log('pushed refund to dataLayer');
|
34 |
-
if (googleConfigConditionsMet('analytics')) gtag('event', 'refund', <?php echo json_encode($data)?>);
|
35 |
-
</script>
|
36 |
-
<?php
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics-refund-ua.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WCPM\Classes\Pixels\Google;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Google_Analytics_Refund_UA extends Google_Analytics
|
10 |
-
{
|
11 |
-
public function __construct($options)
|
12 |
-
{
|
13 |
-
parent::__construct($options);
|
14 |
-
}
|
15 |
-
|
16 |
-
public function output_refund_to_frontend($order, $refund, $dataLayer_refund_items = null)
|
17 |
-
{
|
18 |
-
$data = [
|
19 |
-
'send_to' => $this->options_obj->google->analytics->universal->property_id,
|
20 |
-
'transaction_id' => (string)$order->get_order_number(),
|
21 |
-
//'coupon'=> (array)$order->get_coupon_codes()),
|
22 |
-
'affiliation' => (string)get_bloginfo('name'),
|
23 |
-
'currency' => (string)$this->get_order_currency($order),
|
24 |
-
//'value'=> (float)$order->get_total(),
|
25 |
-
'value' => (float)$refund->get_amount(),
|
26 |
-
'tax' => (float)$order->get_total_tax(),
|
27 |
-
'shipping' => (float)$order->get_total_shipping(),
|
28 |
-
'items' => (array)$dataLayer_refund_items,
|
29 |
-
];
|
30 |
-
|
31 |
-
?>
|
32 |
-
<script>
|
33 |
-
// console.log('pushed refund to dataLayer');
|
34 |
-
if (googleConfigConditionsMet('analytics')) gtag('event', 'refund', <?php echo json_encode($data) ?>);
|
35 |
-
</script>
|
36 |
-
<?php
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics-refund.php
CHANGED
@@ -2,7 +2,6 @@
|
|
2 |
|
3 |
namespace WCPM\Classes\Pixels\Google;
|
4 |
|
5 |
-
use WC_Order ;
|
6 |
use WC_Order_Refund ;
|
7 |
use WC_Product ;
|
8 |
|
@@ -13,10 +12,46 @@ if ( !defined( 'ABSPATH' ) ) {
|
|
13 |
|
14 |
class Google_Analytics_Refund extends Google_Analytics
|
15 |
{
|
16 |
-
use Trait_Google ;
|
17 |
public function __construct( $options )
|
18 |
{
|
19 |
parent::__construct( $options );
|
20 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
}
|
2 |
|
3 |
namespace WCPM\Classes\Pixels\Google;
|
4 |
|
|
|
5 |
use WC_Order_Refund ;
|
6 |
use WC_Product ;
|
7 |
|
12 |
|
13 |
class Google_Analytics_Refund extends Google_Analytics
|
14 |
{
|
|
|
15 |
public function __construct( $options )
|
16 |
{
|
17 |
parent::__construct( $options );
|
18 |
}
|
19 |
+
|
20 |
+
public function output_refund_to_frontend( $order, $refund, $dataLayer_refund_items = null )
|
21 |
+
{
|
22 |
+
$data = [
|
23 |
+
'send_to' => $this->options_obj->google->analytics->ga4->measurement_id,
|
24 |
+
'affiliation' => get_bloginfo( 'name' ),
|
25 |
+
'currency' => (string) $this->get_order_currency( $order ),
|
26 |
+
'items' => (array) $dataLayer_refund_items,
|
27 |
+
'transaction_id' => (string) $order->get_order_number(),
|
28 |
+
'shipping' => (double) $order->get_shipping_total(),
|
29 |
+
'tax' => (double) $order->get_total_tax(),
|
30 |
+
'value' => (double) $refund->get_amount(),
|
31 |
+
];
|
32 |
+
?>
|
33 |
+
<script>
|
34 |
+
|
35 |
+
if (typeof wpmFunctionExists !== 'function') {
|
36 |
+
window.wpmFunctionExists = function (functionName) {
|
37 |
+
return new Promise(function (resolve) {
|
38 |
+
(function waitForVar() {
|
39 |
+
if (typeof window[functionName] !== 'undefined') return resolve();
|
40 |
+
setTimeout(waitForVar, 1000);
|
41 |
+
})();
|
42 |
+
});
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
wpmFunctionExists('wpm').then(function () {
|
47 |
+
if (wpm.googleConfigConditionsMet('analytics')) {
|
48 |
+
gtag('event', 'refund', <?php
|
49 |
+
echo wp_json_encode( $data ) ;
|
50 |
+
?>);
|
51 |
+
}
|
52 |
+
})
|
53 |
+
</script>
|
54 |
+
<?php
|
55 |
+
}
|
56 |
|
57 |
}
|
classes/pixels/google/class-google-analytics-ua-eec.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
namespace WCPM\Classes\Pixels\Google;
|
5 |
-
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class Google_Analytics_UA_EEC extends Google_Analytics_UA
|
11 |
-
{
|
12 |
-
use Trait_Google;
|
13 |
-
|
14 |
-
public function __construct($options)
|
15 |
-
{
|
16 |
-
parent::__construct($options);
|
17 |
-
}
|
18 |
-
|
19 |
-
protected function output_view_item_list_html($items, $list_id){
|
20 |
-
// handled on front-end
|
21 |
-
}
|
22 |
-
|
23 |
-
public function inject_cart($cart, $cart_total)
|
24 |
-
{
|
25 |
-
// handled on front-end
|
26 |
-
}
|
27 |
-
|
28 |
-
public function inject_product($product, $product_attributes)
|
29 |
-
{
|
30 |
-
// handled on front-end
|
31 |
-
}
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics-ua-standard-pixel.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
namespace WGACT\Classes\Pixels\Google;
|
5 |
-
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class Google_Analytics_UA_Standard_Pixel extends Google_Analytics
|
11 |
-
{
|
12 |
-
public function __construct()
|
13 |
-
{
|
14 |
-
parent::__construct();
|
15 |
-
}
|
16 |
-
|
17 |
-
public function inject_order_received_page($order, $order_total, $is_new_customer)
|
18 |
-
{
|
19 |
-
$order_currency = $this->get_order_currency($order);
|
20 |
-
|
21 |
-
?>
|
22 |
-
|
23 |
-
if ((typeof wooptpm !== "undefined") && !wooptpm.isOrderIdStored(<?php echo $order->get_id() ?>)) {
|
24 |
-
gtag('event', 'purchase', <?php echo $this->get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer, 'ga_ua') ?>);
|
25 |
-
}
|
26 |
-
<?php
|
27 |
-
}
|
28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics-ua-standard.php
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
namespace WCPM\Classes\Pixels\Google;
|
5 |
-
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class Google_Analytics_UA_Standard extends Google_Analytics_UA
|
11 |
-
{
|
12 |
-
public function __construct($options)
|
13 |
-
{
|
14 |
-
parent::__construct($options);
|
15 |
-
}
|
16 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics-ua.php
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
namespace WCPM\Classes\Pixels\Google;
|
5 |
-
|
6 |
-
if (!defined('ABSPATH')) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class Google_Analytics_UA extends Google_Analytics
|
11 |
-
{
|
12 |
-
public function __construct($options)
|
13 |
-
{
|
14 |
-
parent::__construct($options);
|
15 |
-
}
|
16 |
-
|
17 |
-
public function inject_order_received_page($order, $order_total, $is_new_customer)
|
18 |
-
{
|
19 |
-
$order_currency = $this->get_order_currency($order);
|
20 |
-
|
21 |
-
echo "
|
22 |
-
wpmExists().then(function(){
|
23 |
-
if (!wpm.isOrderIdStored('" . $order->get_id() . "')) {
|
24 |
-
if (googleConfigConditionsMet('analytics')) gtag('event', 'purchase', " . $this->get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer) . ")
|
25 |
-
}
|
26 |
-
}).catch(() => {
|
27 |
-
console.log('couldn\'t run gtag for GA UA');
|
28 |
-
});
|
29 |
-
";
|
30 |
-
}
|
31 |
-
|
32 |
-
protected function get_event_purchase_json($order, $order_total, $order_currency, $is_new_customer, $channel = null)
|
33 |
-
{
|
34 |
-
$gtag_data = [
|
35 |
-
'send_to' => [],
|
36 |
-
'transaction_id' => (string)$order->get_order_number(),
|
37 |
-
'affiliation' => (string)get_bloginfo('name'),
|
38 |
-
'currency' => (string)$this->get_order_currency($order),
|
39 |
-
'value' => (float)$order->get_total(),
|
40 |
-
'discount' => (float)$order->get_total_discount(),
|
41 |
-
'tax' => (float)$order->get_total_tax(),
|
42 |
-
'shipping' => (float)$order->get_total_shipping(),
|
43 |
-
'coupon' => implode(',', $order->get_coupon_codes()),
|
44 |
-
'items' => (array)$this->get_formatted_order_items($order),
|
45 |
-
];
|
46 |
-
|
47 |
-
array_push($gtag_data['send_to'], $this->options_obj->google->analytics->universal->property_id);
|
48 |
-
|
49 |
-
return json_encode($gtag_data);
|
50 |
-
}
|
51 |
-
|
52 |
-
protected function get_formatted_order_items($order, $channel = null)
|
53 |
-
{
|
54 |
-
$order_items = $this->wpm_get_order_items($order);
|
55 |
-
$order_items_array = [];
|
56 |
-
|
57 |
-
$list_position = 1;
|
58 |
-
|
59 |
-
foreach ((array)$order_items as $order_item) {
|
60 |
-
|
61 |
-
// $product_id = $this->get_variation_or_product_id($order_item->get_data(), $this->options_obj->general->variations_output);
|
62 |
-
|
63 |
-
$order_item_data = $this->get_order_item_data($order_item);
|
64 |
-
|
65 |
-
$item_details_array = [
|
66 |
-
'id' => $order_item_data['id'],
|
67 |
-
'name' => $order_item_data['name'],
|
68 |
-
'brand' => $order_item_data['brand'],
|
69 |
-
'category' => $order_item_data['category'],
|
70 |
-
// 'coupon' => '',
|
71 |
-
// 'list_name' => '',
|
72 |
-
'list_position' => (int)$list_position++,
|
73 |
-
'price' => $order_item_data['price'],
|
74 |
-
'quantity' => $order_item_data['quantity'],
|
75 |
-
'variant' => $order_item_data['variant'],
|
76 |
-
];
|
77 |
-
|
78 |
-
array_push($order_items_array, $item_details_array);
|
79 |
-
}
|
80 |
-
|
81 |
-
// apply filter to the $order_items_array array
|
82 |
-
return apply_filters_deprecated('wgact_filter', [$order_items_array], '1.10.2', '', 'This filter has been deprecated without replacement.');
|
83 |
-
}
|
84 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-analytics.php
CHANGED
@@ -2,69 +2,18 @@
|
|
2 |
|
3 |
namespace WCPM\Classes\Pixels\Google;
|
4 |
|
5 |
-
use WCPM\Classes\Admin\Environment_Check;
|
6 |
use WCPM\Classes\Pixels\Trait_Shop;
|
7 |
|
8 |
if (!defined('ABSPATH')) {
|
9 |
-
|
10 |
}
|
11 |
|
12 |
-
class Google_Analytics extends Google
|
13 |
-
|
14 |
-
use Trait_Shop;
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
parent::__construct($options);
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
protected function get_list_name_by_current_page_type($list_id): string
|
24 |
-
{
|
25 |
-
$list_names = [
|
26 |
-
'add_payment_method_page' => 'Add Payment Method page',
|
27 |
-
'cart' => 'Cart',
|
28 |
-
'checkout' => 'Checkout Page',
|
29 |
-
'checkout_pay_page' => 'Checkout Pay Page',
|
30 |
-
'front_page' => 'Front Page',
|
31 |
-
'order_received_page' => 'Order Received Page',
|
32 |
-
'product' => 'Product',
|
33 |
-
'product_category' => 'Product Category',
|
34 |
-
'product_detail' => 'Product Detail',
|
35 |
-
'product_tag' => 'Product Tag',
|
36 |
-
'product_taxonomy' => 'Product Taxonomy',
|
37 |
-
'search' => 'Search Page',
|
38 |
-
'shop' => 'Shop Page',
|
39 |
-
];
|
40 |
-
|
41 |
-
return $list_names[$list_id];
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
// public function inject_product_list_object($list_id)
|
49 |
-
// {
|
50 |
-
// global $wp_query;
|
51 |
-
//
|
52 |
-
// $items = [];
|
53 |
-
//
|
54 |
-
// $position = 1;
|
55 |
-
//
|
56 |
-
// $posts = $wp_query->posts;
|
57 |
-
//
|
58 |
-
// foreach ($posts as $key => $post) {
|
59 |
-
//
|
60 |
-
// if ($post->post_type == 'product' || $post->post_type == 'product_variation') {
|
61 |
-
//
|
62 |
-
// array_push($items, $this->eec_appweb_get_product_details_array($post->ID, $list_id, $position));
|
63 |
-
//
|
64 |
-
// $position++;
|
65 |
-
// }
|
66 |
-
// }
|
67 |
-
//
|
68 |
-
// $this->output_view_item_list_html($items, $list_id);
|
69 |
-
// }
|
70 |
-
}
|
2 |
|
3 |
namespace WCPM\Classes\Pixels\Google;
|
4 |
|
|
|
5 |
use WCPM\Classes\Pixels\Trait_Shop;
|
6 |
|
7 |
if (!defined('ABSPATH')) {
|
8 |
+
exit; // Exit if accessed directly
|
9 |
}
|
10 |
|
11 |
+
class Google_Analytics extends Google {
|
12 |
+
use Trait_Shop;
|
|
|
13 |
|
14 |
+
public function __construct( $options ) {
|
15 |
+
parent::__construct($options);
|
|
|
16 |
|
17 |
+
$this->pixel_name = 'google_analytics';
|
18 |
+
}
|
19 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-optimize.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WCPM\Classes\Pixels\Google;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
class Google_Optimize extends Google
|
10 |
-
{
|
11 |
-
public function inject_google_optimize_anti_flicker_snippet()
|
12 |
-
{
|
13 |
-
?>
|
14 |
-
|
15 |
-
<script>(function (a, s, y, n, c, h, i, d, e) {
|
16 |
-
s.className += ' ' + y;
|
17 |
-
h.start = 1 * new Date;
|
18 |
-
h.end = i = function () {
|
19 |
-
s.className = s.className.replace(RegExp(' ?' + y), '')
|
20 |
-
};
|
21 |
-
(a[n] = a[n] || []).hide = h;
|
22 |
-
setTimeout(function () {
|
23 |
-
i();
|
24 |
-
h.end = null
|
25 |
-
}, c);
|
26 |
-
h.timeout = c;
|
27 |
-
})(window, document.documentElement, 'async-hide', 'dataLayer', 4000,
|
28 |
-
{'<?php echo $this->options_obj->google->optimize->container_id ?>': true});</script>
|
29 |
-
<?php
|
30 |
-
}
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google-pixel-manager.php
CHANGED
@@ -4,145 +4,55 @@ namespace WCPM\Classes\Pixels\Google;
|
|
4 |
|
5 |
use WCPM\Classes\Http\Google_MP_GA4 ;
|
6 |
use WCPM\Classes\Http\Google_MP_UA ;
|
7 |
-
use WCPM\Classes\Pixels\
|
8 |
|
9 |
if ( !defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
11 |
// Exit if accessed directly
|
12 |
}
|
13 |
|
14 |
-
class Google_Pixel_Manager extends
|
15 |
{
|
16 |
-
use Trait_Google ;
|
17 |
private $google_pixel ;
|
18 |
-
private $google_ads_pixel ;
|
19 |
-
private $google_analytics_ua_standard_pixel ;
|
20 |
-
private $google_analytics_4_standard_pixel ;
|
21 |
-
private $google_analytics_ua_eec_pixel ;
|
22 |
private $google_analytics_ua_http_mp ;
|
23 |
private $google_analytics_4_http_mp ;
|
24 |
-
// private $google_analytics_ua_refund_pixel;
|
25 |
-
private $google_analytics_4_eec_pixel ;
|
26 |
private $cid_key_ga_ua ;
|
27 |
private $cid_key_ga4 ;
|
28 |
public function __construct( $options )
|
29 |
{
|
30 |
parent::__construct( $options );
|
31 |
$this->google_pixel = new Google( $options );
|
32 |
-
if ( $this->is_google_ads_active() ) {
|
33 |
-
if ( $this->is_google_ads_active() ) {
|
34 |
-
$this->google_ads_pixel = new Google_Ads( $options );
|
35 |
-
}
|
36 |
-
}
|
37 |
-
// add_action('wp_enqueue_scripts', [$this, 'google_front_end_scripts']);
|
38 |
-
|
39 |
-
if ( !wpm_fs()->is__premium_only() || !$this->options_obj->google->analytics->eec ) {
|
40 |
-
if ( $this->is_google_analytics_ua_active() ) {
|
41 |
-
$this->google_analytics_ua_standard_pixel = new Google_Analytics_UA_Standard( $options );
|
42 |
-
}
|
43 |
-
if ( $this->is_google_analytics_4_active() ) {
|
44 |
-
$this->google_analytics_4_standard_pixel = new Google_Analytics_4_Standard( $options );
|
45 |
-
}
|
46 |
-
} else {
|
47 |
-
$this->google_analytics_ua_eec_pixel = new Google_Analytics_UA_EEC( $options );
|
48 |
-
// $this->google_analytics_ua_refund_pixel = new Google_Analytics_UA_Refund_Pixel();
|
49 |
-
$this->google_analytics_4_eec_pixel = new Google_Analytics_4_EEC( $options );
|
50 |
-
|
51 |
-
if ( $this->is_google_analytics_active() ) {
|
52 |
-
// woocommerce_order_status_refunded
|
53 |
-
// woocommerce_order_refunded
|
54 |
-
// woocommerce_order_partially_refunded
|
55 |
-
// https://github.com/woocommerce/woocommerce/blob/b19500728b4b292562afb65eb3a0c0f50d5859de/includes/wc-order-functions.php#L614
|
56 |
-
// woocommerce_order_fully_refunded
|
57 |
-
// https://github.com/woocommerce/woocommerce/blob/b19500728b4b292562afb65eb3a0c0f50d5859de/includes/wc-order-functions.php#L616
|
58 |
-
// how to tell if order is fully refunded
|
59 |
-
// https://github.com/woocommerce/woocommerce/blob/b19500728b4b292562afb65eb3a0c0f50d5859de/includes/wc-order-functions.php#L774
|
60 |
-
$this->google_analytics_ua_http_mp = new Google_MP_UA( $options );
|
61 |
-
$this->google_analytics_4_http_mp = new Google_MP_GA4( $options );
|
62 |
-
$this->cid_key_ga_ua = 'google_cid_' . $this->options_obj->google->analytics->universal->property_id;
|
63 |
-
$this->cid_key_ga4 = 'google_cid_' . $this->options_obj->google->analytics->ga4->measurement_id;
|
64 |
-
// error_log('running mp scripts');
|
65 |
-
// add_action('woocommerce_order_refunded', [$this, 'google_analytics_eec_action_woocommerce_order_refunded__premium_only'], 10, 2);
|
66 |
-
// Save the Google cid on the order so that we can use it later when the order gets paid or completed
|
67 |
-
// https://woocommerce.github.io/code-reference/files/woocommerce-includes-class-wc-checkout.html#source-view.403
|
68 |
-
add_action( 'woocommerce_checkout_order_created', [ $this, 'google_analytics_save_cid_on_order__premium_only' ] );
|
69 |
-
// Process the purchase through the GA Measurement Protocol when they are paid, when they change to processing, or
|
70 |
-
// when they are manually set to completed.
|
71 |
-
// https://docs.woocommerce.com/document/managing-orders/
|
72 |
-
// Maybe also use woocommerce_pre_payment_complete
|
73 |
-
// https://woocommerce.github.io/code-reference/files/woocommerce-includes-class-wc-order.html#source-view.105
|
74 |
-
add_action( 'woocommerce_order_status_processing', [ $this, 'google_analytics_mp_report_purchase__premium_only' ] );
|
75 |
-
add_action( 'woocommerce_payment_complete', [ $this, 'google_analytics_mp_report_purchase__premium_only' ] );
|
76 |
-
add_action( 'woocommerce_order_status_completed', [ $this, 'google_analytics_mp_report_purchase__premium_only' ] );
|
77 |
-
// Process total an partial refunds
|
78 |
-
add_action(
|
79 |
-
'woocommerce_order_fully_refunded',
|
80 |
-
[ $this, 'google_analytics_mp_send_full_refund__premium_only' ],
|
81 |
-
10,
|
82 |
-
2
|
83 |
-
);
|
84 |
-
add_action(
|
85 |
-
'woocommerce_order_partially_refunded',
|
86 |
-
[ $this, 'google_analytics_mp_send_partial_refund__premium_only' ],
|
87 |
-
10,
|
88 |
-
2
|
89 |
-
);
|
90 |
-
// Process subscription renewals
|
91 |
-
// https://docs.woocommerce.com/document/subscriptions/develop/action-reference/
|
92 |
-
add_action(
|
93 |
-
'woocommerce_subscription_renewal_payment_complete',
|
94 |
-
[ $this, 'google_analytics_mp_report_subscription_purchase_renewal__premium_only' ],
|
95 |
-
10,
|
96 |
-
2
|
97 |
-
);
|
98 |
-
}
|
99 |
-
|
100 |
-
}
|
101 |
-
|
102 |
-
add_action( 'init', [ $this, 'run_on_init' ] );
|
103 |
}
|
104 |
|
105 |
-
|
106 |
{
|
107 |
-
// function to only fire gtag login once after login
|
108 |
-
// and then wait for the next session
|
109 |
-
if ( is_user_logged_in() ) {
|
110 |
-
|
111 |
-
if ( !isset( $_COOKIE['gtag_logged_in'] ) ) {
|
112 |
-
add_action( 'wp_footer', [ $this, 'output_gtag_login' ] );
|
113 |
-
// the cookie expires after the session
|
114 |
-
setcookie( 'gtag_logged_in', 'true' );
|
115 |
-
}
|
116 |
|
|
|
|
|
|
|
|
|
|
|
117 |
}
|
|
|
118 |
}
|
119 |
|
120 |
-
public function
|
121 |
{
|
122 |
-
$
|
123 |
-
|
124 |
-
|
125 |
-
?>
|
126 |
-
|
127 |
-
<script>
|
128 |
-
gtag('event', 'login', <?php
|
129 |
-
echo json_encode( $data ) ;
|
130 |
-
?>);
|
131 |
-
</script>
|
132 |
-
<?php
|
133 |
}
|
134 |
|
135 |
-
public function
|
136 |
{
|
137 |
-
$this->google_pixel->
|
|
|
|
|
138 |
}
|
139 |
|
140 |
-
|
141 |
-
// {
|
142 |
-
// $this->google_pixel->inject_product_category();
|
143 |
-
// }
|
144 |
-
public function google_front_end_scripts()
|
145 |
{
|
|
|
146 |
}
|
147 |
|
148 |
public function inject_product_category()
|
@@ -175,48 +85,12 @@ class Google_Pixel_Manager extends Pixel_Manager_Base
|
|
175 |
// all handled on front-end
|
176 |
}
|
177 |
|
178 |
-
public function inject_order_received_page_dedupe( $order, $order_total, $is_new_customer )
|
179 |
-
{
|
180 |
-
if ( $this->is_google_ads_active() ) {
|
181 |
-
$this->google_ads_pixel->inject_order_received_page_dedupe( $order, $order_total, $is_new_customer );
|
182 |
-
}
|
183 |
-
|
184 |
-
if ( !wpm_fs()->is__premium_only() || !$this->options_obj->google->analytics->eec ) {
|
185 |
-
if ( $this->is_google_analytics_ua_active() ) {
|
186 |
-
$this->google_analytics_ua_standard_pixel->inject_order_received_page( $order, $order_total, $is_new_customer );
|
187 |
-
}
|
188 |
-
if ( $this->is_google_analytics_4_active() ) {
|
189 |
-
$this->google_analytics_4_standard_pixel->inject_order_received_page( $order, $order_total, $is_new_customer );
|
190 |
-
}
|
191 |
-
} else {
|
192 |
-
if ( $this->is_google_analytics_4_active() && !$this->options_obj->google->analytics->ga4->api_secret ) {
|
193 |
-
$this->google_analytics_4_eec_pixel->inject_order_received_page( $order, $order_total, $is_new_customer );
|
194 |
-
}
|
195 |
-
}
|
196 |
-
|
197 |
-
}
|
198 |
-
|
199 |
-
public function inject_order_received_page_no_dedupe( $order, $order_total, $is_new_customer )
|
200 |
-
{
|
201 |
-
if ( $this->is_google_ads_active() ) {
|
202 |
-
$this->google_ads_pixel->inject_order_received_page_no_dedupe( $order, $order_total, $is_new_customer );
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
protected function inject_opening_script_tag()
|
207 |
{
|
208 |
-
echo PHP_EOL ;
|
209 |
-
echo ' <!-- START Google scripts -->' . PHP_EOL ;
|
210 |
-
// echo PHP_EOL;
|
211 |
}
|
212 |
|
213 |
protected function inject_closing_script_tag()
|
214 |
{
|
215 |
-
echo PHP_EOL ;
|
216 |
-
echo "\t\t" . '//# sourceURL=wpmGoogleInlineScripts.js' . PHP_EOL ;
|
217 |
-
echo "\t\t" . '</script>' ;
|
218 |
-
echo PHP_EOL . PHP_EOL ;
|
219 |
-
echo "\t" . '<!-- END Google scripts -->' . PHP_EOL ;
|
220 |
}
|
221 |
|
222 |
}
|
4 |
|
5 |
use WCPM\Classes\Http\Google_MP_GA4 ;
|
6 |
use WCPM\Classes\Http\Google_MP_UA ;
|
7 |
+
use WCPM\Classes\Pixels\Script_Manager ;
|
8 |
|
9 |
if ( !defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
11 |
// Exit if accessed directly
|
12 |
}
|
13 |
|
14 |
+
class Google_Pixel_Manager extends Script_Manager
|
15 |
{
|
|
|
16 |
private $google_pixel ;
|
|
|
|
|
|
|
|
|
17 |
private $google_analytics_ua_http_mp ;
|
18 |
private $google_analytics_4_http_mp ;
|
|
|
|
|
19 |
private $cid_key_ga_ua ;
|
20 |
private $cid_key_ga4 ;
|
21 |
public function __construct( $options )
|
22 |
{
|
23 |
parent::__construct( $options );
|
24 |
$this->google_pixel = new Google( $options );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
+
protected function log_prevented_order_report_for_user( $order )
|
28 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
if ( is_user_logged_in() ) {
|
31 |
+
$user_info = $order->get_user();
|
32 |
+
wc_get_logger()->debug( 'Prevented order ID ' . $order->get_id() . ' to be reported through the Measurement Protocol for user ' . $user_info->user_login . ' (roles: ' . implode( ', ', $user_info->roles ) . ')', [
|
33 |
+
'source' => 'wpm',
|
34 |
+
] );
|
35 |
}
|
36 |
+
|
37 |
}
|
38 |
|
39 |
+
public function inject_order_received_page_dedupe( $order, $order_total, $is_new_customer )
|
40 |
{
|
41 |
+
if ( $this->google_pixel->is_google_ads_active() && wpm_fs()->is__premium_only() ) {
|
42 |
+
$this->save_gclid_in_order__premium_only( $order );
|
43 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
|
46 |
+
public function inject_order_received_page_no_dedupe( $order, $order_total, $is_new_customer )
|
47 |
{
|
48 |
+
if ( $this->google_pixel->is_google_ads_active() && wpm_fs()->is__premium_only() ) {
|
49 |
+
$this->save_gclid_in_order__premium_only( $order );
|
50 |
+
}
|
51 |
}
|
52 |
|
53 |
+
public function inject_everywhere()
|
|
|
|
|
|
|
|
|
54 |
{
|
55 |
+
// $this->google_pixel->inject_everywhere();
|
56 |
}
|
57 |
|
58 |
public function inject_product_category()
|
85 |
// all handled on front-end
|
86 |
}
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
protected function inject_opening_script_tag()
|
89 |
{
|
|
|
|
|
|
|
90 |
}
|
91 |
|
92 |
protected function inject_closing_script_tag()
|
93 |
{
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
|
96 |
}
|
classes/pixels/google/class-google-pixel.php
DELETED
@@ -1,337 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels\Google;
|
4 |
-
|
5 |
-
use WGACT\Classes\Admin\Environment_Check ;
|
6 |
-
use WGACT\Classes\Pixels\Pixel ;
|
7 |
-
|
8 |
-
if ( !defined( 'ABSPATH' ) ) {
|
9 |
-
exit;
|
10 |
-
// Exit if accessed directly
|
11 |
-
}
|
12 |
-
|
13 |
-
class Google_Pixel extends Pixel
|
14 |
-
{
|
15 |
-
use Trait_Google ;
|
16 |
-
protected $google_ads_conversion_identifiers ;
|
17 |
-
public function __construct()
|
18 |
-
{
|
19 |
-
parent::__construct();
|
20 |
-
$this->google_business_vertical = $this->get_google_business_vertical( $this->options['google']['ads']['google_business_vertical'] );
|
21 |
-
$this->google_ads_conversion_identifiers[$this->conversion_id] = $this->conversion_label;
|
22 |
-
$this->google_ads_conversion_identifiers = apply_filters( 'wgact_google_ads_conversion_identifiers', $this->google_ads_conversion_identifiers );
|
23 |
-
$this->pixel_name = 'google';
|
24 |
-
}
|
25 |
-
|
26 |
-
public function inject_everywhere()
|
27 |
-
{
|
28 |
-
$this->inject_data_layer_pixels();
|
29 |
-
|
30 |
-
if ( $this->options_obj->google->optimize->container_id ) {
|
31 |
-
// $opt = "<script async src='https://www.googleoptimize.com/optimize.js?id=" . $this->options_obj->google->optimize->container_id . "'></script>";
|
32 |
-
//
|
33 |
-
// echo $opt;
|
34 |
-
?>
|
35 |
-
|
36 |
-
<script async src="https://www.googleoptimize.com/optimize.js?id=<?php
|
37 |
-
echo $this->options_obj->google->optimize->container_id ;
|
38 |
-
?>"></script>
|
39 |
-
<?php
|
40 |
-
}
|
41 |
-
|
42 |
-
|
43 |
-
if ( !$this->options_obj->google->gtag->deactivation ) {
|
44 |
-
?>
|
45 |
-
|
46 |
-
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php
|
47 |
-
echo $this->get_gtag_id() ;
|
48 |
-
?>"></script>
|
49 |
-
|
50 |
-
<?php
|
51 |
-
echo $this->get_modified_script_opening_tag() . PHP_EOL ;
|
52 |
-
?>
|
53 |
-
|
54 |
-
<?php
|
55 |
-
echo $this->get_google_init_js() ;
|
56 |
-
} else {
|
57 |
-
?><script><?php
|
58 |
-
}
|
59 |
-
|
60 |
-
foreach ( $this->google_ads_conversion_identifiers as $conversion_id => $conversion_label ) {
|
61 |
-
?>
|
62 |
-
<?php
|
63 |
-
echo ( $this->options_obj->google->ads->conversion_id ? $this->gtag_config( $conversion_id, 'ads' ) : PHP_EOL ) ;
|
64 |
-
?>
|
65 |
-
<?php
|
66 |
-
}
|
67 |
-
?>
|
68 |
-
|
69 |
-
<?php
|
70 |
-
echo ( $this->options_obj->google->analytics->universal->property_id ? $this->gtag_config( $this->options_obj->google->analytics->universal->property_id, 'ga_ua' ) . PHP_EOL : PHP_EOL ) ;
|
71 |
-
?>
|
72 |
-
<?php
|
73 |
-
echo ( $this->options_obj->google->analytics->ga4->measurement_id ? $this->gtag_config( $this->options_obj->google->analytics->ga4->measurement_id, 'ga_4' ) : PHP_EOL ) ;
|
74 |
-
?>
|
75 |
-
|
76 |
-
<?php
|
77 |
-
if ( $this->is_google_ads_active() && $this->options_obj->google->ads->phone_conversion_number && $this->options_obj->google->ads->phone_conversion_label ) {
|
78 |
-
$this->inject_phone_conversion_number_html__premium_only();
|
79 |
-
}
|
80 |
-
if ( $this->options_obj->google->consent_mode->active && ( new Environment_Check() )->is_borlabs_cookie_active() ) {
|
81 |
-
echo $this->inject_borlabs_consent_mode_update() ;
|
82 |
-
}
|
83 |
-
// $this->inject_closing_script_tag();
|
84 |
-
}
|
85 |
-
|
86 |
-
private function get_modified_script_opening_tag()
|
87 |
-
{
|
88 |
-
$cookiebot_snippet = ( $this->options_obj->shop->cookie_consent_mgmt->cookiebot->active ? ' data-cookieconsent="ignore"' : '' );
|
89 |
-
return "<script" . $cookiebot_snippet . ">";
|
90 |
-
}
|
91 |
-
|
92 |
-
protected function get_google_init_js() : string
|
93 |
-
{
|
94 |
-
return "window.dataLayer = window.dataLayer || [];\n\n function gtag() {\n dataLayer.push(arguments);\n }\n " . $this->consent_mode_gtag_html() . "\n gtag('js', new Date());";
|
95 |
-
}
|
96 |
-
|
97 |
-
private function consent_mode_gtag_html() : string
|
98 |
-
{
|
99 |
-
|
100 |
-
if ( $this->options_obj->google->consent_mode->active ) {
|
101 |
-
$data = [
|
102 |
-
'ad_storage' => 'denied',
|
103 |
-
'analytics_storage' => 'denied',
|
104 |
-
'wait_for_update' => 500,
|
105 |
-
];
|
106 |
-
if ( $this->options_obj->google->consent_mode->regions ) {
|
107 |
-
$data['regions'] = $this->options_obj->google->consent_mode->regions;
|
108 |
-
}
|
109 |
-
$ads_data_redaction = 'true';
|
110 |
-
// needs to be output as text
|
111 |
-
$url_passthrough = 'true';
|
112 |
-
// needs to be output as text
|
113 |
-
return "\n gtag('consent', 'default', " . json_encode( $data ) . ");\n gtag('set', 'ads_data_redaction', " . $ads_data_redaction . ");\n gtag('set', 'url_passthrough', " . $url_passthrough . ");" . PHP_EOL;
|
114 |
-
} else {
|
115 |
-
return '';
|
116 |
-
}
|
117 |
-
|
118 |
-
}
|
119 |
-
|
120 |
-
protected function get_google_business_vertical( $id ) : string
|
121 |
-
{
|
122 |
-
$verticals = [
|
123 |
-
0 => 'retail',
|
124 |
-
1 => 'education',
|
125 |
-
2 => 'flights',
|
126 |
-
3 => 'hotel_rental',
|
127 |
-
4 => 'jobs',
|
128 |
-
5 => 'local',
|
129 |
-
6 => 'real_estate',
|
130 |
-
7 => 'travel',
|
131 |
-
8 => 'custom',
|
132 |
-
];
|
133 |
-
return $verticals[$id];
|
134 |
-
}
|
135 |
-
|
136 |
-
protected function get_formatted_order_items( $order, $channel = '' )
|
137 |
-
{
|
138 |
-
$order_items = $order->get_items();
|
139 |
-
$order_items_array = [];
|
140 |
-
$list_position = 1;
|
141 |
-
foreach ( (array) $order_items as $order_item ) {
|
142 |
-
$product_id = $this->get_variation_or_product_id( $order_item->get_data(), $this->options_obj->general->variations_output );
|
143 |
-
$product = wc_get_product( $product_id );
|
144 |
-
$item_details_array = [];
|
145 |
-
$dyn_r_ids = $this->get_dyn_r_ids( $product );
|
146 |
-
|
147 |
-
if ( $channel === 'ads' ) {
|
148 |
-
$item_details_array['id'] = $dyn_r_ids[$this->get_dyn_r_id_type()];
|
149 |
-
} else {
|
150 |
-
$item_details_array['id'] = $product->get_id();
|
151 |
-
}
|
152 |
-
|
153 |
-
$item_details_array['quantity'] = (int) $order_item['quantity'];
|
154 |
-
$item_details_array['price'] = (int) $product->get_price();
|
155 |
-
if ( $this->is_google_ads_active() ) {
|
156 |
-
$item_details_array['google_business_vertical'] = $this->google_business_vertical;
|
157 |
-
}
|
158 |
-
|
159 |
-
if ( $this->is_google_analytics_active() ) {
|
160 |
-
$item_details_array['name'] = (string) $product->get_name();
|
161 |
-
// $item_details_array['list_name'] = '';
|
162 |
-
$item_details_array['brand'] = $this->get_brand_name( $product_id );
|
163 |
-
$item_details_array['category'] = $this->get_product_category( $product_id );
|
164 |
-
// $item_details_array['variant'] = '';
|
165 |
-
$item_details_array['list_position'] = $list_position++;
|
166 |
-
}
|
167 |
-
|
168 |
-
array_push( $order_items_array, $item_details_array );
|
169 |
-
}
|
170 |
-
// apply filter to the $order_items_array array
|
171 |
-
$order_items_array = apply_filters( 'wgact_filter', $order_items_array, 'order_items_array' );
|
172 |
-
return $order_items_array;
|
173 |
-
}
|
174 |
-
|
175 |
-
protected function get_event_purchase_json(
|
176 |
-
$order,
|
177 |
-
$order_total,
|
178 |
-
$order_currency,
|
179 |
-
$is_new_customer,
|
180 |
-
$channel
|
181 |
-
)
|
182 |
-
{
|
183 |
-
$gtag_data = [
|
184 |
-
'send_to' => [],
|
185 |
-
'transaction_id' => $order->get_order_number(),
|
186 |
-
'currency' => $order_currency,
|
187 |
-
'discount' => $order->get_total_discount(),
|
188 |
-
'items' => $this->get_formatted_order_items( $order, $channel ),
|
189 |
-
];
|
190 |
-
|
191 |
-
if ( 'ads' === $channel ) {
|
192 |
-
array_push( $gtag_data['send_to'], $this->get_google_ads_conversion_ids( true ) );
|
193 |
-
$gtag_data['value'] = $order_total;
|
194 |
-
$gtag_data['aw_merchant_id'] = $this->aw_merchant_id;
|
195 |
-
$gtag_data['aw_feed_country'] = $this->get_visitor_country();
|
196 |
-
$gtag_data['aw_feed_language'] = $this->get_gmc_language();
|
197 |
-
$gtag_data['new_customer'] = $is_new_customer;
|
198 |
-
} else {
|
199 |
-
|
200 |
-
if ( 'ga_ua' === $channel ) {
|
201 |
-
if ( $this->options_obj->google->analytics->universal->property_id ) {
|
202 |
-
array_push( $gtag_data['send_to'], $this->options_obj->google->analytics->universal->property_id );
|
203 |
-
}
|
204 |
-
// if ($this->options_obj->google->analytics->ga4->measurement_id) array_push($gtag_data['send_to'], $this->options_obj->google->analytics->ga4->measurement_id);
|
205 |
-
$gtag_data['affiliation'] = (string) get_bloginfo( 'name' );
|
206 |
-
$gtag_data['tax'] = (string) $order->get_total_tax();
|
207 |
-
$gtag_data['shipping'] = (string) $order->get_total_shipping();
|
208 |
-
$gtag_data['value'] = (double) $order->get_total();
|
209 |
-
} else {
|
210 |
-
|
211 |
-
if ( 'ga_4' === $channel ) {
|
212 |
-
// if ($this->options_obj->google->analytics->universal->property_id) array_push($gtag_data['send_to'], $this->options_obj->google->analytics->universal->property_id);
|
213 |
-
if ( $this->options_obj->google->analytics->ga4->measurement_id ) {
|
214 |
-
array_push( $gtag_data['send_to'], $this->options_obj->google->analytics->ga4->measurement_id );
|
215 |
-
}
|
216 |
-
$gtag_data['affiliation'] = (string) get_bloginfo( 'name' );
|
217 |
-
$gtag_data['tax'] = (string) $order->get_total_tax();
|
218 |
-
$gtag_data['shipping'] = (string) $order->get_total_shipping();
|
219 |
-
$gtag_data['value'] = (double) $order->get_total();
|
220 |
-
}
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
}
|
225 |
-
|
226 |
-
return json_encode( $gtag_data );
|
227 |
-
}
|
228 |
-
|
229 |
-
protected function get_gmc_language() : string
|
230 |
-
{
|
231 |
-
return strtoupper( substr( get_locale(), 0, 2 ) );
|
232 |
-
}
|
233 |
-
|
234 |
-
protected function get_order_currency( $order )
|
235 |
-
{
|
236 |
-
// use the right function to get the currency depending on the WooCommerce version
|
237 |
-
return ( $this->woocommerce_3_and_above() ? $order->get_currency() : $order->get_order_currency() );
|
238 |
-
}
|
239 |
-
|
240 |
-
protected function woocommerce_3_and_above() : bool
|
241 |
-
{
|
242 |
-
global $woocommerce ;
|
243 |
-
|
244 |
-
if ( version_compare( $woocommerce->version, 3.0, ">=" ) ) {
|
245 |
-
return true;
|
246 |
-
} else {
|
247 |
-
return false;
|
248 |
-
}
|
249 |
-
|
250 |
-
}
|
251 |
-
|
252 |
-
protected function get_google_ads_conversion_ids( $purchase = false ) : array
|
253 |
-
{
|
254 |
-
$formatted_conversion_ids = [];
|
255 |
-
|
256 |
-
if ( $purchase ) {
|
257 |
-
foreach ( $this->google_ads_conversion_identifiers as $conversion_id => $conversion_label ) {
|
258 |
-
array_push( $formatted_conversion_ids, 'AW-' . $conversion_id . '/' . $conversion_label );
|
259 |
-
}
|
260 |
-
} else {
|
261 |
-
foreach ( $this->google_ads_conversion_identifiers as $conversion_id => $conversion_label ) {
|
262 |
-
array_push( $formatted_conversion_ids, 'AW-' . $conversion_id );
|
263 |
-
}
|
264 |
-
}
|
265 |
-
|
266 |
-
return $formatted_conversion_ids;
|
267 |
-
}
|
268 |
-
|
269 |
-
private function get_gtag_id() : string
|
270 |
-
{
|
271 |
-
|
272 |
-
if ( $this->options_obj->google->analytics->universal->property_id ) {
|
273 |
-
return $this->options_obj->google->analytics->universal->property_id;
|
274 |
-
} elseif ( $this->options_obj->google->analytics->ga4->measurement_id ) {
|
275 |
-
return $this->options_obj->google->analytics->ga4->measurement_id;
|
276 |
-
} elseif ( $this->options_obj->google->ads->conversion_id ) {
|
277 |
-
return 'AW-' . $this->options_obj->google->ads->conversion_id;
|
278 |
-
}
|
279 |
-
|
280 |
-
}
|
281 |
-
|
282 |
-
private function inject_data_layer_pixels()
|
283 |
-
{
|
284 |
-
$data = [
|
285 |
-
'google' => [
|
286 |
-
'ads' => [
|
287 |
-
'dynamic_remarketing' => [
|
288 |
-
'status' => $this->options_obj->google->ads->dynamic_remarketing,
|
289 |
-
'id_type' => $this->get_dyn_r_id_type(),
|
290 |
-
],
|
291 |
-
'conversionIds' => $this->get_google_ads_conversion_ids(),
|
292 |
-
'google_business_vertical' => $this->google_business_vertical,
|
293 |
-
],
|
294 |
-
'analytics' => [
|
295 |
-
'universal' => [
|
296 |
-
'property_id' => $this->options_obj->google->analytics->universal->property_id,
|
297 |
-
],
|
298 |
-
'ga4' => [
|
299 |
-
'measurement_id' => $this->options_obj->google->analytics->ga4->measurement_id,
|
300 |
-
],
|
301 |
-
],
|
302 |
-
],
|
303 |
-
];
|
304 |
-
?>
|
305 |
-
|
306 |
-
<script>
|
307 |
-
wooptpmDataLayer.pixels = <?php
|
308 |
-
echo json_encode( $data ) ;
|
309 |
-
?>
|
310 |
-
</script>
|
311 |
-
<?php
|
312 |
-
}
|
313 |
-
|
314 |
-
protected function gtag_config( $id, $channel = '' ) : string
|
315 |
-
{
|
316 |
-
|
317 |
-
if ( 'ads' === $channel ) {
|
318 |
-
return PHP_EOL . "\t\t\t\t" . "gtag('config', 'AW-" . $id . "');" . PHP_EOL;
|
319 |
-
} elseif ( 'ga_ua' === $channel ) {
|
320 |
-
$ga_ua_parameters = [
|
321 |
-
'anonymize_ip' => 'true',
|
322 |
-
'link_attribution' => ( $this->options_obj->google->analytics->link_attribution ? 'true' : 'false' ),
|
323 |
-
];
|
324 |
-
$ga_ua_parameters = apply_filters( 'woopt_pm_analytics_parameters', $ga_ua_parameters, $id );
|
325 |
-
return "\t\t" . "gtag('config', '" . $id . "', " . json_encode( $ga_ua_parameters ) . ");";
|
326 |
-
} elseif ( 'ga_4' === $channel ) {
|
327 |
-
return "\t\t" . "gtag('config', '" . $id . "');";
|
328 |
-
}
|
329 |
-
|
330 |
-
}
|
331 |
-
|
332 |
-
private function inject_borlabs_consent_mode_update() : string
|
333 |
-
{
|
334 |
-
return "\n (function updateGoogleConsentMode() {\n if (typeof BorlabsCookie == 'undefined' || typeof gtag == 'undefined') {\n window.setTimeout(updateGoogleConsentMode, 50);\n } else {\n if (window.BorlabsCookie.checkCookieGroupConsent('statistics')) {\n gtag('consent', 'update', {\n 'analytics_storage': 'granted'\n });\n }\n \n if (window.BorlabsCookie.checkCookieGroupConsent('marketing')) {\n gtag('consent', 'update', {\n 'ad_storage': 'granted'\n });\n }\n }\n })();" . PHP_EOL;
|
335 |
-
}
|
336 |
-
|
337 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/google/class-google.php
CHANGED
@@ -13,177 +13,167 @@ if ( !defined( 'ABSPATH' ) ) {
|
|
13 |
|
14 |
class Google extends Pixel
|
15 |
{
|
16 |
-
use Trait_Google ;
|
17 |
use Trait_Shop ;
|
18 |
-
protected $google_ads_conversion_identifiers ;
|
19 |
public function __construct( $options )
|
20 |
{
|
21 |
parent::__construct( $options );
|
22 |
$this->google_business_vertical = $this->get_google_business_vertical( $this->options['google']['ads']['google_business_vertical'] );
|
23 |
-
$this->
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
$
|
31 |
-
'
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
'1.13.0',
|
34 |
-
'
|
35 |
);
|
36 |
-
|
37 |
-
|
38 |
}
|
39 |
|
40 |
-
public function
|
41 |
{
|
42 |
-
|
43 |
-
if ( $this->options_obj->google->
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
'src' => "https://www.googleoptimize.com/optimize.js?id=" . $this->options_obj->google->optimize->container_id,
|
54 |
-
'cookie_category' => 'analytics',
|
55 |
-
'pixel_name' => 'google-optimize',
|
56 |
-
'inject_cfasync' => false,
|
57 |
-
] ) . PHP_EOL ;
|
58 |
-
}
|
59 |
-
// echo "\t\t" . '<script async src="https://www.googletagmanager.com/gtag/js?id=' . $this->get_gtag_id() . '"' . $this->explicit_consent_mode_type_value($this->get_cookie_category()) . '></script>';
|
60 |
-
// echo "\t\t";
|
61 |
-
// echo '<script async ';
|
62 |
-
// echo 'src="https://www.googletagmanager.com/gtag/js?id=' . $this->get_gtag_id() . '"';
|
63 |
-
// echo !$this->options_obj->google->consent_mode->active ? ' data-wpm-src="https://www.googletagmanager.com/gtag/js?id=' . $this->get_gtag_id() . '"' : '';
|
64 |
-
// echo !$this->options_obj->google->consent_mode->active ? $this->script_type_value($this->get_cookie_category()) : '';
|
65 |
-
// echo '></script>';
|
66 |
-
echo "\t\t" . $this->get_formatted_script_tag( [
|
67 |
-
'async' => true,
|
68 |
-
'defer' => false,
|
69 |
-
'src' => "https://www.googletagmanager.com/gtag/js?id=" . $this->get_gtag_id(),
|
70 |
-
'cookie_category' => $this->get_cookie_category(),
|
71 |
-
'pixel_name' => 'google',
|
72 |
-
'inject_cfasync' => false,
|
73 |
-
] ) . PHP_EOL ;
|
74 |
-
echo $this->get_modified_script_opening_tag() . PHP_EOL ;
|
75 |
-
echo $this->get_google_init_js() ;
|
76 |
-
foreach ( $this->google_ads_conversion_identifiers as $conversion_id => $conversion_label ) {
|
77 |
-
?>
|
78 |
-
<?php
|
79 |
-
echo ( $this->options_obj->google->ads->conversion_id ? $this->gtag_config( $conversion_id, 'ads' ) : PHP_EOL ) ;
|
80 |
-
?>
|
81 |
-
<?php
|
82 |
-
}
|
83 |
-
?>
|
84 |
-
|
85 |
-
<?php
|
86 |
-
echo ( $this->options_obj->google->analytics->universal->property_id ? $this->gtag_config( $this->options_obj->google->analytics->universal->property_id, 'ga_ua' ) . PHP_EOL : PHP_EOL ) ;
|
87 |
-
?>
|
88 |
-
<?php
|
89 |
-
echo ( $this->options_obj->google->analytics->ga4->measurement_id ? $this->gtag_config( $this->options_obj->google->analytics->ga4->measurement_id, 'ga_4' ) : PHP_EOL ) ;
|
90 |
-
?>
|
91 |
-
|
92 |
-
<?php
|
93 |
-
if ( $this->is_google_ads_active() && $this->options_obj->google->ads->phone_conversion_number && $this->options_obj->google->ads->phone_conversion_label ) {
|
94 |
-
$this->inject_phone_conversion_number_html__premium_only();
|
95 |
-
}
|
96 |
-
// if ($this->options_obj->google->consent_mode->active && (new Environment_Check())->is_borlabs_cookie_active()) {
|
97 |
-
// echo $this->inject_borlabs_consent_mode_update();
|
98 |
-
// }
|
99 |
-
// $this->inject_closing_script_tag();
|
100 |
}
|
101 |
|
102 |
-
public function
|
103 |
{
|
104 |
-
|
105 |
-
if ( $this->
|
106 |
-
|
|
|
|
|
107 |
}
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
-
|
112 |
}
|
113 |
|
114 |
-
|
115 |
{
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
'cookiebot-cookieconsent' => $this->options_obj->shop->cookie_consent_mgmt->cookiebot->active || ( new Environment_Check() )->is_some_cmp_active(),
|
124 |
-
] ) . PHP_EOL;
|
125 |
}
|
126 |
|
127 |
-
protected function
|
128 |
{
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
}
|
131 |
|
132 |
-
|
133 |
-
private function linker_html() : string
|
134 |
{
|
135 |
-
$linker_domains = apply_filters_deprecated(
|
136 |
-
'wooptpm_google_cross_domain_linker_settings',
|
137 |
-
[ null ],
|
138 |
-
'1.13.0',
|
139 |
-
'wpm_google_cross_domain_linker_settings'
|
140 |
-
);
|
141 |
-
$linker_domains = apply_filters( 'wpm_google_cross_domain_linker_settings', $linker_domains );
|
142 |
|
143 |
-
if ( $
|
144 |
-
return
|
145 |
} else {
|
146 |
-
return
|
147 |
}
|
148 |
|
149 |
}
|
150 |
|
151 |
-
|
152 |
{
|
153 |
|
154 |
-
if ( $this->
|
155 |
-
$
|
156 |
-
|
157 |
-
|
158 |
-
'
|
159 |
-
]
|
160 |
-
|
161 |
-
|
|
|
162 |
}
|
163 |
-
|
164 |
-
$ads_data_redaction = apply_filters_deprecated(
|
165 |
-
'wooptpm_google_ads_data_redaction',
|
166 |
-
[ true ],
|
167 |
-
'1.13.0',
|
168 |
-
'wpm_google_ads_data_redaction'
|
169 |
-
);
|
170 |
-
$ads_data_redaction = ( apply_filters( 'wpm_google_ads_data_redaction', $ads_data_redaction ) ? 'true' : 'false' );
|
171 |
-
// needs to be output as text
|
172 |
-
$url_passthrough = apply_filters_deprecated(
|
173 |
-
'wooptpm_google_url_passthrough',
|
174 |
-
[ true ],
|
175 |
-
'1.13.0',
|
176 |
-
'wpm_google_url_passthrough'
|
177 |
-
);
|
178 |
-
$url_passthrough = ( apply_filters( 'wpm_google_url_passthrough', $url_passthrough ) ? 'true' : 'false' );
|
179 |
-
return "\n let google_consent_settings = " . json_encode( $data ) . ";\n \n google_consent_settings = getVisitorConsentStatusAndUpdateGoogleConsentSettings(google_consent_settings);\n \n// console.log(google_consent_settings);\n \n gtag('consent', 'default', google_consent_settings);\n gtag('set', 'ads_data_redaction', " . $ads_data_redaction . ");\n gtag('set', 'url_passthrough', " . $url_passthrough . ");" . PHP_EOL;
|
180 |
} else {
|
181 |
-
return
|
182 |
}
|
183 |
|
184 |
}
|
185 |
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
{
|
188 |
$verticals = [
|
189 |
0 => 'retail',
|
@@ -199,252 +189,219 @@ class Google extends Pixel
|
|
199 |
return $verticals[$id];
|
200 |
}
|
201 |
|
202 |
-
|
203 |
{
|
204 |
-
$
|
205 |
-
$
|
206 |
-
|
207 |
-
|
208 |
-
$product_id = $this->get_variation_or_product_id( $order_item->get_data(), $this->options_obj->general->variations_output );
|
209 |
-
$product = wc_get_product( $product_id );
|
210 |
-
|
211 |
-
if ( !is_object( $product ) ) {
|
212 |
-
$this->log_problematic_product_id( $product_id );
|
213 |
-
continue;
|
214 |
-
}
|
215 |
-
|
216 |
-
$item_details_array = [];
|
217 |
-
$dyn_r_ids = $this->get_dyn_r_ids( $product );
|
218 |
-
|
219 |
-
if ( $channel === 'ads' ) {
|
220 |
-
$item_details_array['id'] = (string) $dyn_r_ids[$this->get_dyn_r_id_type()];
|
221 |
-
} else {
|
222 |
-
$item_details_array['id'] = (string) $dyn_r_ids[$this->get_ga_id_type()];
|
223 |
-
}
|
224 |
-
|
225 |
-
$item_details_array['quantity'] = (int) $order_item['quantity'];
|
226 |
-
$item_details_array['price'] = (double) $product->get_price();
|
227 |
-
if ( $this->is_google_ads_active() ) {
|
228 |
-
$item_details_array['google_business_vertical'] = (string) $this->google_business_vertical;
|
229 |
-
}
|
230 |
-
|
231 |
-
if ( $this->is_google_analytics_active() && $channel != 'ads' ) {
|
232 |
-
$item_details_array['name'] = (string) $product->get_name();
|
233 |
-
// $item_details_array['list_name'] = '';
|
234 |
-
$item_details_array['brand'] = (string) $this->get_brand_name( $product_id );
|
235 |
-
$item_details_array['category'] = (array) $this->get_product_category( $product_id );
|
236 |
-
// $item_details_array['variant'] = '';
|
237 |
-
$item_details_array['list_position'] = (int) $list_position++;
|
238 |
-
}
|
239 |
-
|
240 |
-
array_push( $order_items_array, $item_details_array );
|
241 |
-
}
|
242 |
-
// apply filter to $order_items_array
|
243 |
-
$order_items_array = apply_filters_deprecated(
|
244 |
-
'wgact_filter',
|
245 |
-
[ $order_items_array ],
|
246 |
'1.10.2',
|
247 |
-
''
|
248 |
-
'This filter has been deprecated without replacement.'
|
249 |
);
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
$
|
257 |
-
$
|
258 |
-
$channel
|
259 |
-
)
|
260 |
-
{
|
261 |
-
$gtag_data = [
|
262 |
-
'send_to' => [],
|
263 |
-
'transaction_id' => (string) $order->get_order_number(),
|
264 |
-
'currency' => (string) $order_currency,
|
265 |
-
'discount' => (double) $order->get_total_discount(),
|
266 |
-
'items' => (array) $this->get_formatted_order_items( $order, $channel ),
|
267 |
-
];
|
268 |
|
269 |
-
if (
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
$gtag_data['aw_feed_language'] = (string) $this->get_gmc_language();
|
275 |
-
$gtag_data['new_customer'] = (string) $is_new_customer;
|
276 |
-
} else {
|
277 |
-
|
278 |
-
if ( 'ga_ua' === $channel ) {
|
279 |
-
if ( $this->options_obj->google->analytics->universal->property_id ) {
|
280 |
-
array_push( $gtag_data['send_to'], $this->options_obj->google->analytics->universal->property_id );
|
281 |
}
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
$
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
if ( 'ga_4' === $channel ) {
|
290 |
-
// if ($this->options_obj->google->analytics->universal->property_id) array_push($gtag_data['send_to'], $this->options_obj->google->analytics->universal->property_id);
|
291 |
-
if ( $this->options_obj->google->analytics->ga4->measurement_id ) {
|
292 |
-
array_push( $gtag_data['send_to'], $this->options_obj->google->analytics->ga4->measurement_id );
|
293 |
-
}
|
294 |
-
$gtag_data['affiliation'] = (string) get_bloginfo( 'name' );
|
295 |
-
$gtag_data['tax'] = (double) $order->get_total_tax();
|
296 |
-
$gtag_data['shipping'] = (double) $order->get_total_shipping();
|
297 |
-
$gtag_data['value'] = (double) $order->get_total();
|
298 |
}
|
299 |
-
|
300 |
}
|
301 |
-
|
302 |
}
|
303 |
|
304 |
-
return
|
305 |
}
|
306 |
|
307 |
-
protected function
|
308 |
{
|
309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
}
|
311 |
|
312 |
-
|
313 |
{
|
314 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
|
316 |
-
if ( $
|
317 |
-
|
318 |
-
|
319 |
-
}
|
320 |
} else {
|
321 |
-
|
322 |
-
array_push( $formatted_conversion_ids, 'AW-' . $conversion_id );
|
323 |
-
}
|
324 |
}
|
325 |
|
326 |
-
return $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
}
|
328 |
|
329 |
-
private function
|
330 |
{
|
|
|
331 |
|
332 |
-
if ( $
|
333 |
-
return
|
334 |
-
} elseif ( $this->options_obj->google->analytics->ga4->measurement_id ) {
|
335 |
-
return $this->options_obj->google->analytics->ga4->measurement_id;
|
336 |
-
} elseif ( $this->options_obj->google->ads->conversion_id ) {
|
337 |
-
return 'AW-' . $this->options_obj->google->ads->conversion_id;
|
338 |
} else {
|
339 |
-
return
|
340 |
}
|
341 |
|
342 |
}
|
343 |
|
344 |
-
|
345 |
{
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
'
|
354 |
-
[
|
355 |
'1.13.0',
|
356 |
-
'
|
357 |
-
)
|
358 |
-
|
359 |
-
'conversionIds' => $this->get_google_ads_conversion_ids(),
|
360 |
-
'google_business_vertical' => $this->google_business_vertical,
|
361 |
-
],
|
362 |
-
'analytics' => [
|
363 |
-
'universal' => [
|
364 |
-
'property_id' => $this->options_obj->google->analytics->universal->property_id,
|
365 |
-
],
|
366 |
-
'ga4' => [
|
367 |
-
'measurement_id' => $this->options_obj->google->analytics->ga4->measurement_id,
|
368 |
-
],
|
369 |
-
'id_type' => $this->get_ga_id_type(),
|
370 |
-
'eec' => (bool) $this->options_obj->google->analytics->eec,
|
371 |
-
],
|
372 |
-
'consent_mode' => [
|
373 |
-
'active' => (bool) $this->options_obj->google->consent_mode->active,
|
374 |
-
],
|
375 |
-
],
|
376 |
-
];
|
377 |
-
?>
|
378 |
-
|
379 |
-
<script>
|
380 |
-
wpmDataLayer.pixels = <?php
|
381 |
-
echo json_encode( $data ) ;
|
382 |
-
?>;
|
383 |
-
</script>
|
384 |
-
<?php
|
385 |
}
|
386 |
|
387 |
-
|
388 |
{
|
389 |
-
|
390 |
-
if (
|
391 |
-
|
392 |
-
|
393 |
-
return PHP_EOL . "\t\t\t" . "if (googleConfigConditionsMet('ads')) gtag('config', 'AW-" . $id . "', {'allow_enhanced_conversions':true});" . PHP_EOL;
|
394 |
-
} else {
|
395 |
-
return PHP_EOL . "\t\t\t" . "if (googleConfigConditionsMet('ads')) gtag('config', 'AW-" . $id . "');" . PHP_EOL;
|
396 |
-
}
|
397 |
-
|
398 |
-
} elseif ( 'ga_ua' === $channel ) {
|
399 |
-
$ga_ua_parameters = [
|
400 |
-
'anonymize_ip' => 'true',
|
401 |
-
'link_attribution' => ( $this->options_obj->google->analytics->link_attribution ? 'true' : 'false' ),
|
402 |
];
|
403 |
-
if ( $this->options_obj->google->user_id && is_user_logged_in() ) {
|
404 |
-
$ga_ua_parameters['user_id'] = get_current_user_id();
|
405 |
-
}
|
406 |
-
$ga_ua_parameters = apply_filters_deprecated(
|
407 |
-
'woopt_pm_analytics_parameters',
|
408 |
-
[ $ga_ua_parameters, $id ],
|
409 |
-
'1.10.10',
|
410 |
-
'wooptpm_ga_ua_parameters'
|
411 |
-
);
|
412 |
-
$ga_ua_parameters = apply_filters_deprecated(
|
413 |
-
'wooptpm_ga_ua_parameters',
|
414 |
-
[ $ga_ua_parameters, $id ],
|
415 |
-
'1.13.0',
|
416 |
-
'wpm_ga_ua_parameters'
|
417 |
-
);
|
418 |
-
$ga_ua_parameters = apply_filters( 'wpm_ga_ua_parameters', $ga_ua_parameters, $id );
|
419 |
-
return "\t" . "if (googleConfigConditionsMet('analytics')) gtag('config', '" . $id . "', " . json_encode( $ga_ua_parameters ) . ");";
|
420 |
-
} elseif ( 'ga_4' === $channel ) {
|
421 |
-
$ga_4_parameters = [];
|
422 |
-
if ( $this->options_obj->google->user_id && is_user_logged_in() ) {
|
423 |
-
$ga_4_parameters = [
|
424 |
-
'user_id' => get_current_user_id(),
|
425 |
-
];
|
426 |
-
}
|
427 |
-
$ga_4_parameters = apply_filters_deprecated(
|
428 |
-
'wooptpm_ga_4_parameters',
|
429 |
-
[ $ga_4_parameters, $id ],
|
430 |
-
'1.13.0',
|
431 |
-
'wpm_ga_4_parameters'
|
432 |
-
);
|
433 |
-
$ga_4_parameters = apply_filters( 'wpm_ga_4_parameters', $ga_4_parameters, $id );
|
434 |
-
|
435 |
-
if ( empty($ga_4_parameters) ) {
|
436 |
-
return "\t" . "if (googleConfigConditionsMet('analytics')) gtag('config', '" . $id . "');";
|
437 |
-
} else {
|
438 |
-
return "\t" . "if (googleConfigConditionsMet('analytics')) gtag('config', '" . $id . "', " . json_encode( $ga_4_parameters ) . ");";
|
439 |
-
}
|
440 |
-
|
441 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
}
|
444 |
|
445 |
-
|
446 |
{
|
447 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
}
|
449 |
|
450 |
}
|
13 |
|
14 |
class Google extends Pixel
|
15 |
{
|
|
|
16 |
use Trait_Shop ;
|
|
|
17 |
public function __construct( $options )
|
18 |
{
|
19 |
parent::__construct( $options );
|
20 |
$this->google_business_vertical = $this->get_google_business_vertical( $this->options['google']['ads']['google_business_vertical'] );
|
21 |
+
$this->pixel_name = 'google';
|
22 |
+
}
|
23 |
+
|
24 |
+
public function get_order_item_data( $order_item )
|
25 |
+
{
|
26 |
+
$product = $order_item->get_product();
|
27 |
+
|
28 |
+
if ( !is_object( $product ) ) {
|
29 |
+
wc_get_logger()->debug( 'get_order_item_data received an order item which is not a valid product: ' . $order_item->get_id(), [
|
30 |
+
'source' => 'wpm',
|
31 |
+
] );
|
32 |
+
return [];
|
33 |
+
}
|
34 |
+
|
35 |
+
$dyn_r_ids = $this->get_dyn_r_ids( $product );
|
36 |
+
|
37 |
+
if ( $product->get_type() === 'variation' ) {
|
38 |
+
$parent_product = wc_get_product( $product->get_parent_id() );
|
39 |
+
$name = $parent_product->get_name();
|
40 |
+
} else {
|
41 |
+
$name = $product->get_name();
|
42 |
+
}
|
43 |
+
|
44 |
+
return [
|
45 |
+
'id' => (string) $dyn_r_ids[$this->get_ga_id_type()],
|
46 |
+
'name' => (string) $name,
|
47 |
+
'quantity' => (int) $order_item['quantity'],
|
48 |
+
'affiliation' => (string) get_bloginfo( 'name' ),
|
49 |
+
'brand' => (string) $this->get_brand_name( $product->get_id() ),
|
50 |
+
'category' => implode( ',', $this->get_product_category( $product->get_id() ) ),
|
51 |
+
'category_array' => $this->get_product_category( $product->get_id() ),
|
52 |
+
'variant' => ( (string) ($product->get_type() === 'variation') ? $this->get_formatted_variant_text( $product ) : '' ),
|
53 |
+
'price' => (double) $this->wpm_get_order_item_price( $order_item, $product ),
|
54 |
+
];
|
55 |
+
}
|
56 |
+
|
57 |
+
public function get_ga_id_type()
|
58 |
+
{
|
59 |
+
$ga_id_type = 'post_id';
|
60 |
+
$ga_id_type = apply_filters_deprecated(
|
61 |
+
'wooptpm_product_id_type_for_google_analytics',
|
62 |
+
[ $ga_id_type ],
|
63 |
'1.13.0',
|
64 |
+
'wpm_product_id_type_for_google_analytics'
|
65 |
);
|
66 |
+
// Change the output of the product ID type for Google Analytics
|
67 |
+
return apply_filters( 'wpm_product_id_type_for_google_analytics', $ga_id_type );
|
68 |
}
|
69 |
|
70 |
+
public function google_active()
|
71 |
{
|
72 |
+
|
73 |
+
if ( $this->options_obj->google->analytics->universal->property_id ) {
|
74 |
+
return true;
|
75 |
+
} elseif ( $this->options_obj->google->analytics->ga4->measurement_id ) {
|
76 |
+
return true;
|
77 |
+
} elseif ( $this->options_obj->google->ads->conversion_id ) {
|
78 |
+
return true;
|
79 |
+
} else {
|
80 |
+
return false;
|
81 |
+
}
|
82 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
|
85 |
+
public function is_google_ads_active()
|
86 |
{
|
87 |
+
|
88 |
+
if ( $this->options['google']['ads']['conversion_id'] ) {
|
89 |
+
return true;
|
90 |
+
} else {
|
91 |
+
return false;
|
92 |
}
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
public function is_google_analytics_active()
|
97 |
+
{
|
98 |
+
|
99 |
+
if ( $this->is_google_analytics_ua_active() || $this->is_google_analytics_4_active() ) {
|
100 |
+
return true;
|
101 |
+
} else {
|
102 |
+
return false;
|
103 |
}
|
104 |
+
|
105 |
}
|
106 |
|
107 |
+
public function is_google_analytics_ua_active()
|
108 |
{
|
109 |
+
|
110 |
+
if ( $this->options_obj->google->analytics->universal->property_id ) {
|
111 |
+
return true;
|
112 |
+
} else {
|
113 |
+
return false;
|
114 |
+
}
|
115 |
+
|
|
|
|
|
116 |
}
|
117 |
|
118 |
+
protected function is_google_analytics_4_active()
|
119 |
{
|
120 |
+
|
121 |
+
if ( $this->options_obj->google->analytics->ga4->measurement_id ) {
|
122 |
+
return true;
|
123 |
+
} else {
|
124 |
+
return false;
|
125 |
+
}
|
126 |
+
|
127 |
}
|
128 |
|
129 |
+
public function is_google_analytics_4_mp_active()
|
|
|
130 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
+
if ( $this->options_obj->google->analytics->ga4->measurement_id && $this->options_obj->google->analytics->ga4->api_secret ) {
|
133 |
+
return true;
|
134 |
} else {
|
135 |
+
return false;
|
136 |
}
|
137 |
|
138 |
}
|
139 |
|
140 |
+
public function wpm_get_order_item_price( $order_item, $product )
|
141 |
{
|
142 |
|
143 |
+
if ( ( new Environment_Check( $this->options ) )->is_woo_discount_rules_active() ) {
|
144 |
+
$item_value = $order_item->get_meta( '_advanced_woo_discount_item_total_discount' );
|
145 |
+
|
146 |
+
if ( is_array( $item_value ) && array_key_exists( 'discounted_price', $item_value ) && 0 != $item_value['discounted_price'] ) {
|
147 |
+
return (double) $item_value['discounted_price'];
|
148 |
+
} elseif ( is_array( $item_value ) && array_key_exists( 'initial_price', $item_value ) && 0 != $item_value['initial_price'] ) {
|
149 |
+
return (double) $item_value['initial_price'];
|
150 |
+
} else {
|
151 |
+
return (double) $product->get_price();
|
152 |
}
|
153 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
} else {
|
155 |
+
return (double) $product->get_price();
|
156 |
}
|
157 |
|
158 |
}
|
159 |
|
160 |
+
public function add_categories_to_ga4_product_items( $item_details_array, $categories )
|
161 |
+
{
|
162 |
+
$categories = array_unique( $categories );
|
163 |
+
|
164 |
+
if ( count( $categories ) > 0 ) {
|
165 |
+
$max_categories = 5;
|
166 |
+
$item_details_array['item_category'] = $categories[0];
|
167 |
+
$max = ( count( $categories ) > $max_categories ? $max_categories : count( $categories ) );
|
168 |
+
for ( $i = 1 ; $i < $max ; $i++ ) {
|
169 |
+
$item_details_array['item_category' . ($i + 1)] = $categories[$i];
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
return $item_details_array;
|
174 |
+
}
|
175 |
+
|
176 |
+
public function get_google_business_vertical( $id )
|
177 |
{
|
178 |
$verticals = [
|
179 |
0 => 'retail',
|
189 |
return $verticals[$id];
|
190 |
}
|
191 |
|
192 |
+
public function get_google_ads_conversion_ids( $purchase = false )
|
193 |
{
|
194 |
+
$this->google_ads_conversion_identifiers[$this->options['google']['ads']['conversion_id']] = $this->options['google']['ads']['conversion_label'];
|
195 |
+
$this->google_ads_conversion_identifiers = apply_filters_deprecated(
|
196 |
+
'wgact_google_ads_conversion_identifiers',
|
197 |
+
[ $this->google_ads_conversion_identifiers ],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
'1.10.2',
|
199 |
+
'wooptpm_google_ads_conversion_identifiers'
|
|
|
200 |
);
|
201 |
+
$this->google_ads_conversion_identifiers = apply_filters_deprecated(
|
202 |
+
'wooptpm_google_ads_conversion_identifiers',
|
203 |
+
[ $this->google_ads_conversion_identifiers ],
|
204 |
+
'1.13.0',
|
205 |
+
'wpm_google_ads_conversion_identifiers'
|
206 |
+
);
|
207 |
+
$this->google_ads_conversion_identifiers = apply_filters( 'wpm_google_ads_conversion_identifiers', $this->google_ads_conversion_identifiers );
|
208 |
+
$formatted_conversion_ids = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
+
if ( $purchase ) {
|
211 |
+
foreach ( $this->google_ads_conversion_identifiers as $conversion_id => $conversion_label ) {
|
212 |
+
$conversion_id = $this->extract_google_ads_id( $conversion_id );
|
213 |
+
if ( $conversion_id ) {
|
214 |
+
$formatted_conversion_ids['AW-' . $conversion_id] = $conversion_label;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
}
|
216 |
+
}
|
217 |
+
} else {
|
218 |
+
foreach ( $this->google_ads_conversion_identifiers as $conversion_id => $conversion_label ) {
|
219 |
+
$conversion_id = $this->extract_google_ads_id( $conversion_id );
|
220 |
+
if ( $conversion_id ) {
|
221 |
+
$formatted_conversion_ids['AW-' . $conversion_id] = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
}
|
|
|
223 |
}
|
|
|
224 |
}
|
225 |
|
226 |
+
return $formatted_conversion_ids;
|
227 |
}
|
228 |
|
229 |
+
protected function extract_google_ads_id( $string )
|
230 |
{
|
231 |
+
$re = '/\\d{9,11}/';
|
232 |
+
|
233 |
+
if ( $string ) {
|
234 |
+
preg_match(
|
235 |
+
$re,
|
236 |
+
$string,
|
237 |
+
$matches,
|
238 |
+
PREG_OFFSET_CAPTURE,
|
239 |
+
0
|
240 |
+
);
|
241 |
+
if ( is_array( $matches[0] ) ) {
|
242 |
+
return $matches[0][0];
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
return '';
|
247 |
}
|
248 |
|
249 |
+
public function get_google_ads_enhanced_conversion_data( $order )
|
250 |
{
|
251 |
+
$customer_data = [];
|
252 |
+
if ( $order->get_billing_email() ) {
|
253 |
+
$customer_data['email'] = (string) $order->get_billing_email();
|
254 |
+
}
|
255 |
+
if ( $order->get_billing_phone() ) {
|
256 |
+
$customer_data['phone_number'] = $this->get_e164_formatted_phone_number( (string) $order->get_billing_phone(), (string) $order->get_billing_country() );
|
257 |
+
}
|
258 |
|
259 |
+
if ( $this->is_shipping_address_set( $order ) ) {
|
260 |
+
$customer_data['address'][] = $this->get_billing_address_details( $order );
|
261 |
+
$customer_data['address'][] = $this->get_shipping_address_details( $order );
|
|
|
262 |
} else {
|
263 |
+
$customer_data['address'] = $this->get_billing_address_details( $order );
|
|
|
|
|
264 |
}
|
265 |
|
266 |
+
return $customer_data;
|
267 |
+
}
|
268 |
+
|
269 |
+
protected function get_billing_address_details( $order )
|
270 |
+
{
|
271 |
+
$customer_data = [];
|
272 |
+
if ( $order->get_billing_first_name() ) {
|
273 |
+
$customer_data['first_name'] = (string) $order->get_billing_first_name();
|
274 |
+
}
|
275 |
+
if ( $order->get_billing_last_name() ) {
|
276 |
+
$customer_data['last_name'] = (string) $order->get_billing_last_name();
|
277 |
+
}
|
278 |
+
if ( $order->get_billing_address_1() ) {
|
279 |
+
$customer_data['street'] = (string) $order->get_billing_address_1();
|
280 |
+
}
|
281 |
+
if ( $order->get_billing_city() ) {
|
282 |
+
$customer_data['city'] = (string) $order->get_billing_city();
|
283 |
+
}
|
284 |
+
if ( $order->get_billing_state() ) {
|
285 |
+
$customer_data['region'] = (string) $order->get_billing_state();
|
286 |
+
}
|
287 |
+
if ( $order->get_billing_postcode() ) {
|
288 |
+
$customer_data['postal_code'] = (string) $order->get_billing_postcode();
|
289 |
+
}
|
290 |
+
if ( $order->get_billing_country() ) {
|
291 |
+
$customer_data['country'] = (string) $order->get_billing_country();
|
292 |
+
}
|
293 |
+
return $customer_data;
|
294 |
+
}
|
295 |
+
|
296 |
+
protected function get_shipping_address_details( $order )
|
297 |
+
{
|
298 |
+
$customer_data = [];
|
299 |
+
if ( $order->get_shipping_first_name() ) {
|
300 |
+
$customer_data['first_name'] = (string) $order->get_shipping_first_name();
|
301 |
+
}
|
302 |
+
if ( $order->get_shipping_last_name() ) {
|
303 |
+
$customer_data['last_name'] = (string) $order->get_shipping_last_name();
|
304 |
+
}
|
305 |
+
if ( $order->get_shipping_address_1() ) {
|
306 |
+
$customer_data['street'] = (string) $order->get_shipping_address_1();
|
307 |
+
}
|
308 |
+
if ( $order->get_shipping_city() ) {
|
309 |
+
$customer_data['city'] = (string) $order->get_shipping_city();
|
310 |
+
}
|
311 |
+
if ( $order->get_shipping_state() ) {
|
312 |
+
$customer_data['region'] = (string) $order->get_shipping_state();
|
313 |
+
}
|
314 |
+
if ( $order->get_shipping_postcode() ) {
|
315 |
+
$customer_data['postal_code'] = (string) $order->get_shipping_postcode();
|
316 |
+
}
|
317 |
+
if ( $order->get_shipping_country() ) {
|
318 |
+
$customer_data['country'] = (string) $order->get_shipping_country();
|
319 |
+
}
|
320 |
+
return $customer_data;
|
321 |
}
|
322 |
|
323 |
+
private function is_shipping_address_set( $order )
|
324 |
{
|
325 |
+
// https://woocommerce.github.io/code-reference/files/woocommerce-includes-admin-meta-boxes-class-wc-meta-box-order-data.html#source-view.446
|
326 |
|
327 |
+
if ( $order->get_formatted_shipping_address() ) {
|
328 |
+
return true;
|
|
|
|
|
|
|
|
|
329 |
} else {
|
330 |
+
return false;
|
331 |
}
|
332 |
|
333 |
}
|
334 |
|
335 |
+
public function get_gmc_language()
|
336 |
{
|
337 |
+
return strtoupper( substr( get_locale(), 0, 2 ) );
|
338 |
+
}
|
339 |
+
|
340 |
+
// https://developers.google.com/gtagjs/devguide/linker
|
341 |
+
public function get_google_linker_settings()
|
342 |
+
{
|
343 |
+
$linker_settings = apply_filters_deprecated(
|
344 |
+
'wooptpm_google_cross_domain_linker_settings',
|
345 |
+
[ null ],
|
346 |
'1.13.0',
|
347 |
+
'wpm_google_cross_domain_linker_settings'
|
348 |
+
);
|
349 |
+
return apply_filters( 'wpm_google_cross_domain_linker_settings', $linker_settings );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
}
|
351 |
|
352 |
+
public function get_ga4_parameters( $id )
|
353 |
{
|
354 |
+
$ga_4_parameters = [];
|
355 |
+
if ( $this->options_obj->google->user_id && is_user_logged_in() ) {
|
356 |
+
$ga_4_parameters = [
|
357 |
+
'user_id' => get_current_user_id(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
}
|
360 |
+
$ga_4_parameters = apply_filters_deprecated(
|
361 |
+
'wooptpm_ga_4_parameters',
|
362 |
+
[ $ga_4_parameters, $id ],
|
363 |
+
'1.13.0',
|
364 |
+
'wpm_ga_4_parameters'
|
365 |
+
);
|
366 |
+
return apply_filters( 'wpm_ga_4_parameters', $ga_4_parameters, $id );
|
367 |
+
}
|
368 |
|
369 |
+
public function get_ga_ua_parameters( $id )
|
370 |
+
{
|
371 |
+
$ga_ua_parameters = [
|
372 |
+
'anonymize_ip' => true,
|
373 |
+
'link_attribution' => (bool) $this->options_obj->google->analytics->link_attribution,
|
374 |
+
];
|
375 |
+
if ( $this->options_obj->google->user_id && is_user_logged_in() ) {
|
376 |
+
$ga_ua_parameters['user_id'] = get_current_user_id();
|
377 |
+
}
|
378 |
+
$ga_ua_parameters = apply_filters_deprecated(
|
379 |
+
'woopt_pm_analytics_parameters',
|
380 |
+
[ $ga_ua_parameters, $id ],
|
381 |
+
'1.10.10',
|
382 |
+
'wooptpm_ga_ua_parameters'
|
383 |
+
);
|
384 |
+
$ga_ua_parameters = apply_filters_deprecated(
|
385 |
+
'wooptpm_ga_ua_parameters',
|
386 |
+
[ $ga_ua_parameters, $id ],
|
387 |
+
'1.13.0',
|
388 |
+
'wpm_ga_ua_parameters'
|
389 |
+
);
|
390 |
+
return apply_filters( 'wpm_ga_ua_parameters', $ga_ua_parameters, $id );
|
391 |
}
|
392 |
|
393 |
+
public function get_all_refund_products( $refund )
|
394 |
{
|
395 |
+
$data = [];
|
396 |
+
$item_index = 1;
|
397 |
+
foreach ( $refund->get_items() as $item_id => $item ) {
|
398 |
+
// $product = new WC_Product($refund_item->get_product_id());
|
399 |
+
$order_item_data = $this->google->get_order_item_data( $item );
|
400 |
+
$data['pr' . $item_index . 'id'] = $order_item_data['id'];
|
401 |
+
$data['pr' . $item_index . 'qt'] = -1 * $order_item_data['quantity'];
|
402 |
+
$item_index++;
|
403 |
+
}
|
404 |
+
return $data;
|
405 |
}
|
406 |
|
407 |
}
|
classes/pixels/google/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
classes/pixels/google/trait-google.php
DELETED
@@ -1,190 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WCPM\Classes\Pixels\Google;
|
4 |
-
|
5 |
-
use WCPM\Classes\Admin\Environment_Check;
|
6 |
-
|
7 |
-
if (!defined('ABSPATH')) {
|
8 |
-
exit; // Exit if accessed directly
|
9 |
-
}
|
10 |
-
|
11 |
-
trait Trait_Google
|
12 |
-
{
|
13 |
-
protected function get_ga_id_type(): string
|
14 |
-
{
|
15 |
-
$ga_id_type = 'post_id';
|
16 |
-
|
17 |
-
$ga_id_type = apply_filters_deprecated('wooptpm_product_id_type_for_google_analytics', [$ga_id_type], '1.13.0', 'wpm_product_id_type_for_google_analytics');
|
18 |
-
$ga_id_type = apply_filters('wpm_product_id_type_for_google_analytics', $ga_id_type);
|
19 |
-
|
20 |
-
return $ga_id_type;
|
21 |
-
}
|
22 |
-
|
23 |
-
protected function google_active(): bool
|
24 |
-
{
|
25 |
-
if ($this->options_obj->google->analytics->universal->property_id) {
|
26 |
-
return true;
|
27 |
-
} elseif ($this->options_obj->google->analytics->ga4->measurement_id) {
|
28 |
-
return true;
|
29 |
-
} elseif ($this->options_obj->google->ads->conversion_id) {
|
30 |
-
return true;
|
31 |
-
} else {
|
32 |
-
return false;
|
33 |
-
}
|
34 |
-
}
|
35 |
-
|
36 |
-
protected function is_google_ads_active(): bool
|
37 |
-
{
|
38 |
-
if ($this->options['google']['ads']['conversion_id']) {
|
39 |
-
|
40 |
-
return true;
|
41 |
-
} else {
|
42 |
-
return false;
|
43 |
-
}
|
44 |
-
}
|
45 |
-
|
46 |
-
private function is_dynamic_remarketing_active(): bool
|
47 |
-
{
|
48 |
-
if ($this->options_obj->google->ads->dynamic_remarketing && $this->options_obj->google->ads->conversion_id) {
|
49 |
-
return true;
|
50 |
-
} else {
|
51 |
-
return false;
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
// protected function is_google_ads_active(): bool
|
56 |
-
// {
|
57 |
-
// if ($this->options_obj->google->ads->conversion_id && $this->options_obj->google->ads->conversion_label) {
|
58 |
-
// return true;
|
59 |
-
// } else {
|
60 |
-
// return false;
|
61 |
-
// }
|
62 |
-
// }
|
63 |
-
|
64 |
-
protected function is_google_analytics_active(): bool
|
65 |
-
{
|
66 |
-
if ($this->is_google_analytics_ua_active() || $this->is_google_analytics_4_active()) {
|
67 |
-
return true;
|
68 |
-
} else {
|
69 |
-
return false;
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
protected function is_google_analytics_ua_active(): bool
|
74 |
-
{
|
75 |
-
if ($this->options_obj->google->analytics->universal->property_id) {
|
76 |
-
return true;
|
77 |
-
} else {
|
78 |
-
return false;
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
protected function is_google_analytics_4_active(): bool
|
83 |
-
{
|
84 |
-
if ($this->options_obj->google->analytics->ga4->measurement_id) {
|
85 |
-
return true;
|
86 |
-
} else {
|
87 |
-
return false;
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
protected function is_google_analytics_4_mp_active(): bool
|
92 |
-
{
|
93 |
-
if ($this->options_obj->google->analytics->ga4->measurement_id && $this->options_obj->google->analytics->ga4->api_secret) {
|
94 |
-
return true;
|
95 |
-
} else {
|
96 |
-
return false;
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
protected function get_order_currency($order)
|
101 |
-
{
|
102 |
-
// use the right function to get the currency depending on the WooCommerce version
|
103 |
-
return $this->woocommerce_3_and_above() ? $order->get_currency() : $order->get_order_currency();
|
104 |
-
}
|
105 |
-
|
106 |
-
protected function woocommerce_3_and_above(): bool
|
107 |
-
{
|
108 |
-
global $woocommerce;
|
109 |
-
if (version_compare($woocommerce->version, 3.0, ">=")) {
|
110 |
-
return true;
|
111 |
-
} else {
|
112 |
-
return false;
|
113 |
-
}
|
114 |
-
}
|
115 |
-
|
116 |
-
protected function get_order_item_data($order_item): array
|
117 |
-
{
|
118 |
-
$product = $order_item->get_product();
|
119 |
-
|
120 |
-
if (!is_object($product)) {
|
121 |
-
|
122 |
-
// $this->log_problematic_product_id();
|
123 |
-
wc_get_logger()->debug('get_order_item_data received an order item which is not a valid product: ' . $order_item->get_id(), ['source' => 'wpm']);
|
124 |
-
return [];
|
125 |
-
}
|
126 |
-
|
127 |
-
$dyn_r_ids = $this->get_dyn_r_ids($product);
|
128 |
-
|
129 |
-
if ($product->get_type() === 'variation') {
|
130 |
-
$parent_product = wc_get_product($product->get_parent_id());
|
131 |
-
$name = $parent_product->get_name();
|
132 |
-
} else {
|
133 |
-
$name = $product->get_name();
|
134 |
-
}
|
135 |
-
|
136 |
-
return [
|
137 |
-
'id' => (string)$dyn_r_ids[$this->get_ga_id_type()],
|
138 |
-
'name' => (string)$name,
|
139 |
-
'quantity' => (int)$order_item['quantity'],
|
140 |
-
'affiliation' => (string)get_bloginfo('name'),
|
141 |
-
// 'coupon' => '',
|
142 |
-
// 'discount' => 0,
|
143 |
-
'brand' => (string)$this->get_brand_name($product->get_id()),
|
144 |
-
// https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#pr_ca
|
145 |
-
'category' => implode(',', $this->get_product_category($product->get_id())),
|
146 |
-
'category_array' => $this->get_product_category($product->get_id()),
|
147 |
-
'variant' => (string)($product->get_type() === 'variation') ? $this->get_formatted_variant_text($product) : '',
|
148 |
-
// 'tax' => 0,
|
149 |
-
'price' => (float)$this->wpm_get_order_item_price($order_item, $product),
|
150 |
-
// 'list_name' => ,
|
151 |
-
// 'currency' => '',
|
152 |
-
];
|
153 |
-
}
|
154 |
-
|
155 |
-
protected function wpm_get_order_item_price($order_item, $product): float
|
156 |
-
{
|
157 |
-
if ((new Environment_Check())->is_woo_discount_rules_active()) {
|
158 |
-
$item_value = $order_item->get_meta('_advanced_woo_discount_item_total_discount');
|
159 |
-
if (is_array($item_value) && array_key_exists('discounted_price', $item_value) && $item_value['discounted_price'] != 0) {
|
160 |
-
return (float)$item_value['discounted_price'];
|
161 |
-
} elseif (is_array($item_value) && array_key_exists('initial_price', $item_value) && $item_value['initial_price'] != 0) {
|
162 |
-
return (float)$item_value['initial_price'];
|
163 |
-
} else {
|
164 |
-
return (float)$product->get_price();
|
165 |
-
}
|
166 |
-
} else {
|
167 |
-
return (float)$product->get_price();
|
168 |
-
}
|
169 |
-
}
|
170 |
-
|
171 |
-
protected function add_categories_to_ga4_product_items($item_details_array, $categories)
|
172 |
-
{
|
173 |
-
$categories = array_unique($categories);
|
174 |
-
|
175 |
-
if(count($categories) > 0){
|
176 |
-
|
177 |
-
$max_categories = 5;
|
178 |
-
|
179 |
-
$item_details_array['item_category'] = $categories[0];
|
180 |
-
|
181 |
-
$max = count($categories) > $max_categories ? $max_categories : count($categories);
|
182 |
-
|
183 |
-
for ($i = 1; $i < $max; $i++) {
|
184 |
-
$item_details_array['item_category' . ($i + 1)] = $categories[$i];
|
185 |
-
}
|
186 |
-
}
|
187 |
-
|
188 |
-
return $item_details_array;
|
189 |
-
}
|
190 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/hotjar/class-hotjar-pixel.php
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WCPM\Classes\Pixels\Hotjar;
|
4 |
-
|
5 |
-
use WCPM\Classes\Pixels\Pixel;
|
6 |
-
use WCPM\Classes\Pixels\Trait_Shop;
|
7 |
-
|
8 |
-
if (!defined('ABSPATH')) {
|
9 |
-
exit; // Exit if accessed directly
|
10 |
-
}
|
11 |
-
|
12 |
-
class Hotjar_Pixel extends Pixel
|
13 |
-
{
|
14 |
-
use Trait_Shop;
|
15 |
-
|
16 |
-
public function __construct($options)
|
17 |
-
{
|
18 |
-
parent::__construct($options);
|
19 |
-
}
|
20 |
-
|
21 |
-
public function inject_everywhere()
|
22 |
-
{
|
23 |
-
// @formatter:off
|
24 |
-
|
25 |
-
echo "\n\t\t" . $this->get_formatted_script_tag([
|
26 |
-
'async' => false,
|
27 |
-
'defer' => false,
|
28 |
-
'src' => '',
|
29 |
-
'cookie_category' => 'analytics',
|
30 |
-
'pixel_name' => 'hotjar',
|
31 |
-
'inject_cfasync' => false,
|
32 |
-
|
33 |
-
]) . PHP_EOL;
|
34 |
-
?>
|
35 |
-
|
36 |
-
(function(h,o,t,j,a,r){
|
37 |
-
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
|
38 |
-
h._hjSettings={hjid:<?php echo $this->options_obj->hotjar->site_id ?>,hjsv:6};
|
39 |
-
a=o.getElementsByTagName('head')[0];
|
40 |
-
r=o.createElement('script');r.async=1;
|
41 |
-
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
|
42 |
-
a.appendChild(r);
|
43 |
-
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
|
44 |
-
</script>
|
45 |
-
<?php
|
46 |
-
// @formatter:on
|
47 |
-
}
|
48 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
classes/pixels/trait-google.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WGACT\Classes\Pixels;
|
4 |
-
|
5 |
-
if (!defined('ABSPATH')) {
|
6 |
-
exit; // Exit if accessed directly
|
7 |
-
}
|
8 |
-
|
9 |
-
trait Trait_Google
|
10 |
-
{
|
11 |
-
|
12 |
-
protected function google_active(): bool
|
13 |
-
{
|
14 |
-
if ($this->options_obj->google->analytics->universal->property_id) {
|
15 |
-
return true;
|
16 |
-
} elseif ($this->options_obj->google->analytics->ga4->measurement_id) {
|
17 |
-
return true;
|
18 |
-
} elseif ($this->options_obj->google->ads->conversion_id) {
|
19 |
-
return true;
|
20 |
-
} else {
|
21 |
-
return false;
|
22 |
-
}
|
23 |
-
}
|
24 |
-
|
25 |
-
protected function is_google_ads_active(): bool
|
26 |
-
{
|
27 |
-
if($this->options_obj->google->ads->conversion_id){
|
28 |
-
return true;
|
29 |
-
} else {
|
30 |
-
return false;
|
31 |
-
}
|
32 |
-
}
|
33 |
-
|
34 |
-
protected function is_google_analytics_active(): bool
|
35 |
-
{
|
36 |
-
if ($this->options_obj->google->analytics->universal->property_id) {
|
37 |
-
return true;
|
38 |
-
} elseif ($this->options_obj->google->analytics->ga4->measurement_id) {
|
39 |
-
return true;
|
40 |
-
} else {
|
41 |
-
return false;
|
42 |
-
}
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/pixels/trait-product.php
CHANGED
@@ -3,309 +3,375 @@
|
|
3 |
namespace WCPM\Classes\Pixels;
|
4 |
|
5 |
use WCPM\Classes\Admin\Environment_Check;
|
|
|
6 |
|
7 |
if (!defined('ABSPATH')) {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
-
trait Trait_Product
|
12 |
-
{
|
13 |
-
protected function get_formatted_variant_text($product): string
|
14 |
-
{
|
15 |
-
$variant_text_array = [];
|
16 |
-
|
17 |
-
$attributes = $product->get_attributes();
|
18 |
-
if ($attributes) {
|
19 |
-
foreach ($attributes as $key => $value) {
|
20 |
-
|
21 |
-
$key_name = str_replace('pa_', '', $key);
|
22 |
-
$variant_text_array[] = ucfirst($key_name) . ': ' . strtolower($value);
|
23 |
-
}
|
24 |
-
}
|
25 |
-
|
26 |
-
return implode(' | ', $variant_text_array);
|
27 |
-
}
|
28 |
-
|
29 |
-
protected function get_variation_or_product_id($item, $variations_output = true)
|
30 |
-
{
|
31 |
-
if ($item['variation_id'] <> 0 && $variations_output == true) {
|
32 |
-
return $item['variation_id'];
|
33 |
-
} else {
|
34 |
-
return $item['product_id'];
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
// https://stackoverflow.com/a/56278308/4688612
|
39 |
-
// https://stackoverflow.com/a/39034036/4688612
|
40 |
-
public function get_brand_name($product_id): string
|
41 |
-
{
|
42 |
-
// return $this->get_brand_by_taxonomy($product_id, 'product_brand') ?: // for Woocommerce Brands plugin
|
43 |
-
// $this->get_brand_by_taxonomy($product_id, 'yith_product_brand') ?: // for YITH WooCommerce Brands plugin
|
44 |
-
// $this->get_brand_by_taxonomy($product_id, 'pa_brand') ?: // for a custom product attribute
|
45 |
-
// '';
|
46 |
-
|
47 |
-
$brand_taxonomy = 'pa_brand';
|
48 |
-
|
49 |
-
if ((new Environment_Check())->is_yith_wc_brands_active()) {
|
50 |
-
$brand_taxonomy = 'yith_product_brand';
|
51 |
-
} else if ((new Environment_Check())->is_woocommerce_brands_active()) {
|
52 |
-
$brand_taxonomy = 'product_brand';
|
53 |
-
}
|
54 |
-
|
55 |
-
$brand_taxonomy = apply_filters_deprecated('wooptpm_custom_brand_taxonomy', [$brand_taxonomy], '1.13.0', 'wpm_custom_brand_taxonomy');
|
56 |
-
$brand_taxonomy = apply_filters('wpm_custom_brand_taxonomy', $brand_taxonomy);
|
57 |
-
|
58 |
-
return $this->get_brand_by_taxonomy($product_id, $brand_taxonomy) ?:
|
59 |
-
$this->get_brand_by_taxonomy($product_id, 'pa_' . $brand_taxonomy) ?:
|
60 |
-
'';
|
61 |
-
}
|
62 |
-
|
63 |
-
public function get_brand_by_taxonomy($product_id, $taxonomy): string
|
64 |
-
{
|
65 |
-
if (taxonomy_exists($taxonomy)) {
|
66 |
-
$brand_names = wp_get_post_terms($product_id, $taxonomy, ['fields' => 'names']);
|
67 |
-
return reset($brand_names);
|
68 |
-
} else {
|
69 |
-
return '';
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
// get an array with all product categories
|
74 |
-
public function get_product_category($product_id): array
|
75 |
-
{
|
76 |
-
$prod_cats = get_the_terms($product_id, 'product_cat');
|
77 |
-
$prod_cats_output = [];
|
78 |
-
|
79 |
-
// only continue with the loop if one or more product categories have been set for the product
|
80 |
-
if (!empty($prod_cats)) {
|
81 |
-
foreach ((array)$prod_cats as $key) {
|
82 |
-
array_push($prod_cats_output, $key->name);
|
83 |
-
}
|
84 |
-
|
85 |
-
// apply filter to the $prod_cats_output array
|
86 |
-
$prod_cats_output = apply_filters_deprecated('wgact_filter', [$prod_cats_output], '1.10.2', '', 'This filter has been deprecated without replacement.');
|
87 |
-
}
|
88 |
-
|
89 |
-
return $prod_cats_output;
|
90 |
-
}
|
91 |
-
|
92 |
-
protected function get_compiled_product_id($product_id, $product_sku, $options, $channel = ''): string
|
93 |
-
{
|
94 |
-
// depending on setting use product IDs or SKUs
|
95 |
-
if (0 == $this->options['google']['ads']['product_identifier'] || $channel === 'ga_ua' || $channel === 'ga_4') {
|
96 |
-
return (string)$product_id;
|
97 |
-
} else if (1 == $this->options['google']['ads']['product_identifier']) {
|
98 |
-
return (string)'woocommerce_gpf_' . $product_id;
|
99 |
-
} else {
|
100 |
-
if ($product_sku) {
|
101 |
-
return (string)$product_sku;
|
102 |
-
} else {
|
103 |
-
return (string)$product_id;
|
104 |
-
}
|
105 |
-
}
|
106 |
-
}
|
107 |
-
|
108 |
-
protected function get_dyn_r_ids($product): array
|
109 |
-
{
|
110 |
-
$dyn_r_ids = [
|
111 |
-
'post_id' => (string)$product->get_id(),
|
112 |
-
'sku' => (string)$product->get_sku() ? $product->get_sku() : $product->get_id(),
|
113 |
-
'gpf' => 'woocommerce_gpf_' . $product->get_id(),
|
114 |
-
'gla' => 'gla_' . $product->get_id(),
|
115 |
-
];
|
116 |
-
|
117 |
-
// if you want to add a custom dyn_r_id for each product
|
118 |
-
$dyn_r_ids = apply_filters_deprecated('wooptpm_product_ids', [$dyn_r_ids, $product], '1.13.0', 'wpm_product_ids');
|
119 |
-
return apply_filters('wpm_product_ids', $dyn_r_ids, $product);
|
120 |
-
}
|
121 |
-
|
122 |
-
protected function log_problematic_product_id($product_id = 0)
|
123 |
-
{
|
124 |
-
wc_get_logger()->debug(
|
125 |
-
'WooCommerce detects the page ID ' . $product_id . ' as product, but when invoked by wc_get_product( ' . $product_id . ' ) it returns no product object',
|
126 |
-
['source' => 'wpm']
|
127 |
-
);
|
128 |
-
}
|
129 |
-
|
130 |
-
protected function get_order_item_ids($order): array
|
131 |
-
{
|
132 |
-
$order_items = $this->wpm_get_order_items($order);
|
133 |
-
$order_items_array = [];
|
134 |
-
|
135 |
-
foreach ((array)$order_items as $order_item) {
|
136 |
-
|
137 |
-
$product_id = $this->get_variation_or_product_id($order_item->get_data(), $this->options_obj->general->variations_output);
|
138 |
-
|
139 |
-
$product = wc_get_product($product_id);
|
140 |
-
|
141 |
-
// only continue if WC retrieves a valid product
|
142 |
-
if (is_object($product)) {
|
143 |
-
|
144 |
-
$dyn_r_ids = $this->get_dyn_r_ids($product);
|
145 |
-
$product_id_compiled = $dyn_r_ids[$this->get_dyn_r_id_type()];
|
146 |
-
// $product_id_compiled = $this->get_compiled_product_id($product_id, $product->get_sku(), $this->options, '');
|
147 |
-
array_push($order_items_array, $product_id_compiled);
|
148 |
-
} else {
|
149 |
-
|
150 |
-
$this->log_problematic_product_id($product_id);
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
return $order_items_array;
|
155 |
-
}
|
156 |
-
|
157 |
-
protected function get_order_items_formatted_for_purchase_event($order): array
|
158 |
-
{
|
159 |
-
$order_items = $this->wpm_get_order_items($order);
|
160 |
-
$order_items_formatted = [];
|
161 |
-
|
162 |
-
foreach ((array)$order_items as $order_item) {
|
163 |
-
|
164 |
-
$product_id = $this->get_variation_or_product_id($order_item->get_data(), $this->options_obj->general->variations_output);
|
165 |
-
|
166 |
-
$product = wc_get_product($product_id);
|
167 |
-
$product_details = [];
|
168 |
-
|
169 |
-
// only continue if WC retrieves a valid product
|
170 |
-
if (is_object($product)) {
|
171 |
-
|
172 |
-
$dyn_r_ids = $this->get_dyn_r_ids($product);
|
173 |
-
$product_id_compiled = $dyn_r_ids[$this->get_dyn_r_id_type()];
|
174 |
-
// $product_id_compiled = $this->get_compiled_product_id($product_id, $product->get_sku(), $this->options, '');
|
175 |
-
|
176 |
-
$product_details['id'] = $product_id_compiled;
|
177 |
-
$product_details['name'] = $product->get_name();
|
178 |
-
$product_details['quantity'] = $order_item->get_quantity();
|
179 |
-
$product_details['price'] = $product->get_price();
|
180 |
-
$product_details['brand'] = $this->get_brand_name($product_id);
|
181 |
-
$product_details['category'] = implode(',', $this->get_product_category($product_id));
|
182 |
-
|
183 |
-
// error_log('type: ' . $product->get_type());
|
184 |
-
|
185 |
-
if ($product->is_type('variation')) {
|
186 |
-
$product_details['variant'] = $this->get_formatted_variant_text($product);
|
187 |
-
|
188 |
-
$parent_id = $product->get_parent_id();
|
189 |
-
$parent_product = wc_get_product($parent_id);
|
190 |
-
|
191 |
-
$dyn_r_ids_parent = $this->get_dyn_r_ids($parent_product);
|
192 |
-
$parent_product_id_compiled = $dyn_r_ids_parent[$this->get_dyn_r_id_type()];
|
193 |
-
$product_details['parent_id'] = $parent_product_id_compiled;
|
194 |
-
}
|
195 |
-
|
196 |
-
$order_items_formatted[] = $product_details;
|
197 |
-
// array_push($order_items_formatted, $product_details);
|
198 |
-
} else {
|
199 |
-
|
200 |
-
$this->log_problematic_product_id($product_id);
|
201 |
-
}
|
202 |
-
}
|
203 |
-
|
204 |
-
return $order_items_formatted;
|
205 |
-
}
|
206 |
-
|
207 |
-
|
208 |
-
protected function get_dyn_r_id_type(): string
|
209 |
-
{
|
210 |
-
// $dyn_r_id_type = '';
|
211 |
-
|
212 |
-
if ($this->options_obj->google->ads->product_identifier == 0) {
|
213 |
-
$this->dyn_r_id_type = 'post_id';
|
214 |
-
} elseif ($this->options_obj->google->ads->product_identifier == 1) {
|
215 |
-
$this->dyn_r_id_type = 'gpf';
|
216 |
-
} elseif ($this->options_obj->google->ads->product_identifier == 2) {
|
217 |
-
$this->dyn_r_id_type = 'sku';
|
218 |
-
} elseif ($this->options_obj->google->ads->product_identifier == 3) {
|
219 |
-
$this->dyn_r_id_type = 'gla';
|
220 |
-
}
|
221 |
|
222 |
-
|
223 |
-
|
224 |
-
$this->dyn_r_id_type = apply_filters('wpm_product_id_type_for_' . $this->pixel_name, $this->dyn_r_id_type);
|
225 |
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
-
|
236 |
-
{
|
237 |
-
if (!is_object($product)) {
|
238 |
|
239 |
-
//
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
namespace WCPM\Classes\Pixels;
|
4 |
|
5 |
use WCPM\Classes\Admin\Environment_Check;
|
6 |
+
use WCPM\Classes\Pixels\Google\Google;
|
7 |
|
8 |
if (!defined('ABSPATH')) {
|
9 |
+
exit; // Exit if accessed directly
|
10 |
}
|
11 |
|
12 |
+
trait Trait_Product {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
protected function get_formatted_variant_text( $product ) {
|
15 |
+
$variant_text_array = [];
|
|
|
16 |
|
17 |
+
$attributes = $product->get_attributes();
|
18 |
+
if ($attributes) {
|
19 |
+
foreach ($attributes as $key => $value) {
|
20 |
+
|
21 |
+
$key_name = str_replace('pa_', '', $key);
|
22 |
+
$variant_text_array[] = ucfirst($key_name) . ': ' . strtolower($value);
|
23 |
+
}
|
24 |
+
}
|
25 |
|
26 |
+
return implode(' | ', $variant_text_array);
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function get_variation_or_product_id( $item, $variations_output = true ) {
|
30 |
+
|
31 |
+
if (0 <> $item['variation_id'] && true === $variations_output) {
|
32 |
+
return $item['variation_id'];
|
33 |
+
} else {
|
34 |
+
return $item['product_id'];
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
// https://stackoverflow.com/a/56278308/4688612
|
39 |
+
// https://stackoverflow.com/a/39034036/4688612
|
40 |
+
public function get_brand_name( $product_id ) {
|
41 |
+
|
42 |
+
$brand_taxonomy = 'pa_brand';
|
43 |
+
|
44 |
+
if (( new Environment_Check($this->options) )->is_yith_wc_brands_active()) {
|
45 |
+
$brand_taxonomy = 'yith_product_brand';
|
46 |
+
} elseif (( new Environment_Check($this->options) )->is_woocommerce_brands_active()) {
|
47 |
+
$brand_taxonomy = 'product_brand';
|
48 |
+
}
|
49 |
|
50 |
+
$brand_taxonomy = apply_filters_deprecated('wooptpm_custom_brand_taxonomy', [$brand_taxonomy], '1.13.0', 'wpm_custom_brand_taxonomy');
|
|
|
|
|
51 |
|
52 |
+
// Use custom brand_taxonomy
|
53 |
+
$brand_taxonomy = apply_filters('wpm_custom_brand_taxonomy', $brand_taxonomy);
|
54 |
+
|
55 |
+
if ($this->get_brand_by_taxonomy($product_id, $brand_taxonomy)) {
|
56 |
+
return $this->get_brand_by_taxonomy($product_id, $brand_taxonomy);
|
57 |
+
} elseif ($this->get_brand_by_taxonomy($product_id, 'pa_' . $brand_taxonomy)) {
|
58 |
+
return $this->get_brand_by_taxonomy($product_id, 'pa_' . $brand_taxonomy);
|
59 |
+
} else {
|
60 |
+
return '';
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
public function get_brand_by_taxonomy( $product_id, $taxonomy ) {
|
65 |
+
|
66 |
+
if (taxonomy_exists($taxonomy)) {
|
67 |
+
$brand_names = wp_get_post_terms($product_id, $taxonomy, ['fields' => 'names']);
|
68 |
+
return reset($brand_names);
|
69 |
+
} else {
|
70 |
+
return '';
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
// get an array with all product categories
|
75 |
+
public function get_product_category( $product_id ) {
|
76 |
+
|
77 |
+
if ($this->is_variable_product_by_id($product_id)) {
|
78 |
+
$product = wc_get_product($product_id);
|
79 |
+
$product_id = $product->get_parent_id();
|
80 |
+
}
|
81 |
+
|
82 |
+
$prod_cats = get_the_terms($product_id, 'product_cat');
|
83 |
+
$prod_cats_output = [];
|
84 |
+
|
85 |
+
// only continue with the loop if one or more product categories have been set for the product
|
86 |
+
if (!empty($prod_cats)) {
|
87 |
+
foreach ((array) $prod_cats as $key) {
|
88 |
+
$prod_cats_output[] = $key->name;
|
89 |
+
}
|
90 |
+
|
91 |
+
// apply filter to the $prod_cats_output array
|
92 |
+
$prod_cats_output = apply_filters_deprecated('wgact_filter', [$prod_cats_output], '1.10.2', '', 'This filter has been deprecated without replacement.');
|
93 |
+
}
|
94 |
+
|
95 |
+
return $prod_cats_output;
|
96 |
+
}
|
97 |
+
|
98 |
+
protected function is_variable_product_by_id( $product_id ) {
|
99 |
+
|
100 |
+
$product = wc_get_product($product_id);
|
101 |
+
|
102 |
+
return $product->get_type() === 'variable';
|
103 |
+
}
|
104 |
+
|
105 |
+
protected function get_compiled_product_id( $product_id, $product_sku, $options, $channel = '' ) {
|
106 |
+
|
107 |
+
// depending on setting use product IDs or SKUs
|
108 |
+
if (0 == $this->options['google']['ads']['product_identifier'] || 'ga_ua' === $channel || 'ga_4' === $channel) {
|
109 |
+
return (string) $product_id;
|
110 |
+
} else {
|
111 |
+
if (1 == $this->options['google']['ads']['product_identifier']) {
|
112 |
+
return (string) 'woocommerce_gpf_' . $product_id;
|
113 |
+
} else {
|
114 |
+
if ($product_sku) {
|
115 |
+
return (string) $product_sku;
|
116 |
+
} else {
|
117 |
+
return (string) $product_id;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
protected function get_dyn_r_ids( $product ) {
|
124 |
+
|
125 |
+
$dyn_r_ids = [
|
126 |
+
'post_id' => (string) $product->get_id(),
|
127 |
+
'sku' => (string) $product->get_sku() ? $product->get_sku() : $product->get_id(),
|
128 |
+
'gpf' => 'woocommerce_gpf_' . $product->get_id(),
|
129 |
+
'gla' => 'gla_' . $product->get_id(),
|
130 |
+
];
|
131 |
+
|
132 |
+
// if you want to add a custom dyn_r_id for each product
|
133 |
+
$dyn_r_ids = apply_filters_deprecated('wooptpm_product_ids', [$dyn_r_ids, $product], '1.13.0', 'wpm_product_ids');
|
134 |
+
return apply_filters('wpm_product_ids', $dyn_r_ids, $product);
|
135 |
+
}
|
136 |
+
|
137 |
+
protected function log_problematic_product_id( $product_id = 0 ) {
|
138 |
+
|
139 |
+
wc_get_logger()->debug(
|
140 |
+
'WooCommerce detects the page ID ' . $product_id . ' as product, but when invoked by wc_get_product( ' . $product_id . ' ) it returns no product object',
|
141 |
+
['source' => 'wpm']
|
142 |
+
);
|
143 |
+
}
|
144 |
+
|
145 |
+
protected function get_order_item_ids( $order ) {
|
146 |
+
|
147 |
+
$order_items = $this->wpm_get_order_items($order);
|
148 |
+
$order_items_array = [];
|
149 |
+
|
150 |
+
foreach ((array) $order_items as $order_item) {
|
151 |
+
|
152 |
+
$product_id = $this->get_variation_or_product_id($order_item->get_data(), $this->options_obj->general->variations_output);
|
153 |
+
|
154 |
+
$product = wc_get_product($product_id);
|
155 |
+
|
156 |
+
// only continue if WC retrieves a valid product
|
157 |
+
if (is_object($product)) {
|
158 |
+
|
159 |
+
$dyn_r_ids = $this->get_dyn_r_ids($product);
|
160 |
+
$product_id_compiled = $dyn_r_ids[$this->get_dyn_r_id_type()];
|
161 |
+
array_push($order_items_array, $product_id_compiled);
|
162 |
+
} else {
|
163 |
+
|
164 |
+
$this->log_problematic_product_id($product_id);
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
return $order_items_array;
|
169 |
+
}
|
170 |
+
|
171 |
+
protected function get_order_items_formatted_for_purchase_event( $order ) {
|
172 |
+
|
173 |
+
$order_items = $this->wpm_get_order_items($order);
|
174 |
+
$order_items_formatted = [];
|
175 |
+
|
176 |
+
foreach ((array) $order_items as $order_item) {
|
177 |
+
|
178 |
+
$product_id = $this->get_variation_or_product_id($order_item->get_data(), $this->options_obj->general->variations_output);
|
179 |
+
|
180 |
+
$product = wc_get_product($product_id);
|
181 |
+
$product_details = [];
|
182 |
+
|
183 |
+
// only continue if WC retrieves a valid product
|
184 |
+
if (is_object($product)) {
|
185 |
+
|
186 |
+
$dyn_r_ids = $this->get_dyn_r_ids($product);
|
187 |
+
$product_id_compiled = $dyn_r_ids[$this->get_dyn_r_id_type()];
|
188 |
+
|
189 |
+
$product_details['id'] = $product_id_compiled;
|
190 |
+
$product_details['name'] = $product->get_name();
|
191 |
+
$product_details['quantity'] = $order_item->get_quantity();
|
192 |
+
$product_details['price'] = $product->get_price();
|
193 |
+
$product_details['brand'] = $this->get_brand_name($product_id);
|
194 |
+
$product_details['category'] = implode(',', $this->get_product_category($product_id));
|
195 |
+
|
196 |
+
if ($product->is_type('variation')) {
|
197 |
+
$product_details['variant'] = $this->get_formatted_variant_text($product);
|
198 |
+
|
199 |
+
$parent_id = $product->get_parent_id();
|
200 |
+
$parent_product = wc_get_product($parent_id);
|
201 |
+
|
202 |
+
$dyn_r_ids_parent = $this->get_dyn_r_ids($parent_product);
|
203 |
+
$parent_product_id_compiled = $dyn_r_ids_parent[$this->get_dyn_r_id_type()];
|
204 |
+
$product_details['parent_id'] = $parent_product_id_compiled;
|
205 |
+
}
|
206 |
+
|
207 |
+
$order_items_formatted[] = $product_details;
|
208 |
+
} else {
|
209 |
+
|
210 |
+
$this->log_problematic_product_id($product_id);
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
return $order_items_formatted;
|
215 |
+
}
|
216 |
+
|
217 |
+
protected function get_dyn_r_id_type( $pixel_name = null ) {
|
218 |
+
|
219 |
+
if ($pixel_name) {
|
220 |
+
$this->pixel_name = $pixel_name;
|
221 |
+
}
|
222 |
+
|
223 |
+
if (0 == $this->options_obj->google->ads->product_identifier) {
|
224 |
+
$this->dyn_r_id_type = 'post_id';
|
225 |
+
} elseif (1 == $this->options_obj->google->ads->product_identifier) {
|
226 |
+
$this->dyn_r_id_type = 'gpf';
|
227 |
+
} elseif (2 == $this->options_obj->google->ads->product_identifier) {
|
228 |
+
$this->dyn_r_id_type = 'sku';
|
229 |
+
} elseif (3 == $this->options_obj->google->ads->product_identifier) {
|
230 |
+
$this->dyn_r_id_type = 'gla';
|
231 |
+
}
|
232 |
+
|
233 |
+
// If you want to change the dyn_r_id type programmatically
|
234 |
+
$this->dyn_r_id_type = apply_filters_deprecated('wooptpm_product_id_type_for_' . $this->pixel_name, [$this->dyn_r_id_type], '1.13.0', 'wpm_product_id_type_for_');
|
235 |
+
$this->dyn_r_id_type = apply_filters('wpm_product_id_type_for_' . $this->pixel_name, $this->dyn_r_id_type);
|
236 |
+
|
237 |
+
return $this->dyn_r_id_type;
|
238 |
+
}
|
239 |
+
|
240 |
+
protected function wpm_get_order_items( $order ) {
|
241 |
+
|
242 |
+
$order_items = apply_filters_deprecated('wooptpm_order_items', [$order->get_items(), $order], '1.13.0', 'wpm_order_items');
|
243 |
+
|
244 |
+
// Give option to filter order items
|
245 |
+
// then return
|
246 |
+
return apply_filters('wpm_order_items', $order_items, $order);
|
247 |
+
}
|
248 |
+
|
249 |
+
protected function get_front_end_order_items( $order ) {
|
250 |
+
|
251 |
+
$order_items = $this->wpm_get_order_items($order);
|
252 |
+
$order_items_formatted = [];
|
253 |
+
|
254 |
+
foreach ((array) $order_items as $order_item) {
|
255 |
+
|
256 |
+
$order_item_data = $order_item->get_data();
|
257 |
+
|
258 |
+
$product = $order_item->get_product();
|
259 |
+
|
260 |
+
if (!is_object($product)) {
|
261 |
+
|
262 |
+
wc_get_logger()->debug('get_order_item_data received an order item which is not a valid product: ' . $order_item->get_id(), ['source' => 'wpm']);
|
263 |
+
return [];
|
264 |
+
}
|
265 |
+
|
266 |
+
$order_items_formatted[$order_item_data['product_id']] = [
|
267 |
+
'id' => $order_item_data['product_id'],
|
268 |
+
'variation_id' => $order_item_data['variation_id'],
|
269 |
+
'name' => $order_item_data['name'],
|
270 |
+
'quantity' => $order_item_data['quantity'],
|
271 |
+
'price' => ( new Google($this->options) )->wpm_get_order_item_price($order_item, $product),
|
272 |
+
'subtotal' => (float) number_format($order_item_data['subtotal'], 2, '.', ''),
|
273 |
+
'subtotal_tax' => (float) number_format($order_item_data['subtotal_tax'], 2, '.', ''),
|
274 |
+
'total' => (float) number_format($order_item_data['total'], 2, '.', ''),
|
275 |
+
'total_tax' => (float) number_format($order_item_data['total_tax'], 2, '.', ''),
|
276 |
+
];
|
277 |
+
}
|
278 |
+
|
279 |
+
return $order_items_formatted;
|
280 |
+
}
|
281 |
+
|
282 |
+
public function buffer_get_product_data_layer_script( $product, $set_position = true, $meta_tag = false ) {
|
283 |
+
|
284 |
+
ob_start();
|
285 |
+
|
286 |
+
$this->get_product_data_layer_script($product, $set_position = true, $meta_tag = false);
|
287 |
+
|
288 |
+
return ob_get_clean();
|
289 |
+
}
|
290 |
+
|
291 |
+
public function get_product_data_layer_script( $product, $set_position = true, $meta_tag = false ) {
|
292 |
+
|
293 |
+
if (!is_object($product)) {
|
294 |
+
wc_get_logger()->debug('get_product_data_layer_script received an invalid product', ['source' => 'wpm']);
|
295 |
+
return '';
|
296 |
+
}
|
297 |
+
|
298 |
+
$data = $this->get_product_details_for_datalayer($product);
|
299 |
+
|
300 |
+
// If placed in <head> it must be a <meta> tag else, it can be an <input> tag
|
301 |
+
// Added name and content to meta in order to pass W3 validation test at https://validator.w3.org/nu/
|
302 |
+
$tag = $meta_tag ? "meta name='wpm-dataLayer-meta' content='" . $product->get_id() . "'" : "input type='hidden'";
|
303 |
+
|
304 |
+
$this->get_product_data_layer_script_html_part_1($tag, $product, $data, $set_position, $meta_tag);
|
305 |
+
}
|
306 |
+
|
307 |
+
protected function get_product_data_layer_script_html_part_1( $tag, $product, $data, $set_position, $meta_tag ) {
|
308 |
+
|
309 |
+
if ($meta_tag) {
|
310 |
+
?>
|
311 |
+
<meta name="pm-dataLayer-meta" content="<?php esc_html_e($product->get_id()); ?>" class="wpmProductId"
|
312 |
+
data-id="<?php esc_html_e($product->get_id()); ?>">
|
313 |
+
<?php
|
314 |
+
} else {
|
315 |
+
?>
|
316 |
+
<meta input type="hidden" class="wpmProductId" data-id="<?php esc_html_e($product->get_id()); ?>">
|
317 |
+
<?php
|
318 |
+
}
|
319 |
+
|
320 |
+
?>
|
321 |
+
<script>
|
322 |
+
(window.wpmDataLayer = window.wpmDataLayer || {}).products = window.wpmDataLayer.products || {}
|
323 |
+
window.wpmDataLayer.products[<?php esc_html_e($product->get_id()); ?>] = <?php echo wp_json_encode($data); ?>;
|
324 |
+
<?php $set_position ? $this->get_product_data_layer_script_html_part_2($product) : ''; ?>
|
325 |
+
</script>
|
326 |
+
<?php
|
327 |
+
}
|
328 |
+
|
329 |
+
protected function get_product_data_layer_script_html_part_2( $product ) {
|
330 |
+
?>
|
331 |
+
window.wpmDataLayer.products[<?php esc_html_e($product->get_id()); ?>]['position'] = window.wpmDataLayer.position++
|
332 |
+
<?php
|
333 |
+
}
|
334 |
+
|
335 |
+
public function get_product_details_for_datalayer( $product ) {
|
336 |
+
|
337 |
+
global $woocommerce_wpml;
|
338 |
+
|
339 |
+
$dyn_r_ids = $this->get_dyn_r_ids($product);
|
340 |
+
|
341 |
+
if (( new Environment_Check($this->options) )->is_wpml_woocommerce_multi_currency_active()) {
|
342 |
+
$price = $woocommerce_wpml->multi_currency->prices->get_product_price_in_currency($product->get_id(), get_woocommerce_currency());
|
343 |
+
} else {
|
344 |
+
$price = $product->get_price();
|
345 |
+
}
|
346 |
+
|
347 |
+
$product_details = [
|
348 |
+
'id' => (string) $product->get_id(),
|
349 |
+
'sku' => (string) $product->get_sku(),
|
350 |
+
'name' => (string) $product->get_name(),
|
351 |
+
'price' => (float) $price,
|
352 |
+
'brand' => $this->get_brand_name($product->get_id()),
|
353 |
+
'category' => $this->get_product_category($product->get_id()),
|
354 |
+
'quantity' => 1,
|
355 |
+
'dyn_r_ids' => $dyn_r_ids,
|
356 |
+
'isVariable' => $product->get_type() === 'variable',
|
357 |
+
'isVariation' => false,
|
358 |
+
];
|
359 |
+
|
360 |
+
if ($product->get_type() === 'variation') {
|
361 |
+
|
362 |
+
$parent_product = wc_get_product($product->get_parent_id());
|
363 |
+
if ($parent_product) {
|
364 |
+
$product_details['name'] = $parent_product->get_name();
|
365 |
+
$product_details['parentId_dyn_r_ids'] = $this->get_dyn_r_ids($parent_product);
|
366 |
+
$product_details['parentId'] = $parent_product->get_id();
|
367 |
+
} else {
|
368 |
+
wc_get_logger()->debug('Variation ' . $product->get_id() . ' doesn\'t link to a valid parent product.', ['source' => 'wpm']);
|
369 |
+
}
|
370 |
+
|
371 |
+
$product_details['isVariation'] = true;
|
372 |
+
$product_details['variant'] = $this->get_formatted_variant_text($product);
|
373 |
+
}
|
374 |
+
|
375 |
+
return $product_details;
|
376 |
+
}
|
377 |
+
}
|
classes/pixels/trait-shop.php
CHANGED
@@ -2,200 +2,288 @@
|
|
2 |
|
3 |
namespace WCPM\Classes\Pixels;
|
4 |
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
if (
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
10 |
|
11 |
-
trait Trait_Shop
|
12 |
-
{
|
13 |
-
protected function get_formatted_script_tag( $components ) : string
|
14 |
-
{
|
15 |
-
// error_log(print_r($components, true));
|
16 |
-
$html = '<script ';
|
17 |
-
|
18 |
-
if ( $components['src'] ) {
|
19 |
-
// A script tag can't have both async and defer attributes,
|
20 |
-
// therefore fall back to a default if both are set.
|
21 |
-
// Otherwise, use the one that is set.
|
22 |
-
|
23 |
-
if ( $components['async'] && $components['defer'] ) {
|
24 |
-
$html .= 'async ';
|
25 |
-
} else {
|
26 |
-
|
27 |
-
if ( $components['async'] ) {
|
28 |
-
$html .= 'async ';
|
29 |
-
} else {
|
30 |
-
|
31 |
-
if ( $components['defer'] ) {
|
32 |
-
$html .= 'defer ';
|
33 |
-
} else {
|
34 |
-
$html .= '';
|
35 |
-
}
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
}
|
40 |
-
|
41 |
-
if ( !$this->options_obj->shop->cookie_consent_mgmt->explicit_consent ) {
|
42 |
-
$html .= 'src="' . $components['src'] . '" ';
|
43 |
-
}
|
44 |
-
// $html .= !$this->options_obj->google->consent_mode->active ? 'data-wpm-src="' . $components['src'] . '" ' : '';
|
45 |
-
$html .= 'data-wpm-src="' . $components['src'] . '" ';
|
46 |
-
}
|
47 |
-
|
48 |
-
// $html .= !$this->options_obj->google->consent_mode->active ? $this->script_type_value($components['cookie_category']) . ' ' : '';
|
49 |
-
$html .= $this->script_type_value( $components['cookie_category'] ) . ' ';
|
50 |
-
// $html .= 'data-wpm-pixel-name="' . $this->pixel_name . '" ';
|
51 |
-
$html .= 'data-wpm-pixel-name="' . $components['pixel_name'] . '" ';
|
52 |
-
if ( $components['inject_cfasync'] ) {
|
53 |
-
$html .= 'data-cfasync="false"';
|
54 |
-
}
|
55 |
-
if ( array_key_exists( 'cookiebot-cookieconsent', $components ) && $components['cookiebot-cookieconsent'] ) {
|
56 |
-
$html .= 'data-cookieconsent="ignore"';
|
57 |
-
}
|
58 |
-
|
59 |
-
if ( $components['src'] ) {
|
60 |
-
$html .= '></script>';
|
61 |
-
} else {
|
62 |
-
$html .= '>';
|
63 |
-
}
|
64 |
-
|
65 |
-
return $html;
|
66 |
-
}
|
67 |
-
|
68 |
-
public function script_type_value( $cookie_category ) : string
|
69 |
-
{
|
70 |
-
$type = '';
|
71 |
-
$type = 'text/javascript';
|
72 |
-
return 'type="' . $type . '" data-wpm-cookie-category="' . $cookie_category . '"';
|
73 |
-
}
|
74 |
-
|
75 |
-
protected function get_script_suffix() : string
|
76 |
-
{
|
77 |
-
return ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET['nominify'] ) ? '.js' : '.min.js' );
|
78 |
-
}
|
79 |
-
|
80 |
-
protected function get_list_name_suffix() : string
|
81 |
-
{
|
82 |
-
$list_suffix = '';
|
83 |
-
|
84 |
-
if ( is_product_category() ) {
|
85 |
-
$category = get_queried_object();
|
86 |
-
$list_suffix = ' | ' . $category->name;
|
87 |
-
$list_suffix = $this->add_parent_category_name( $category, $list_suffix );
|
88 |
-
} else {
|
89 |
-
|
90 |
-
if ( is_product_tag() ) {
|
91 |
-
$tag = get_queried_object();
|
92 |
-
$list_suffix = ' | ' . $tag->name;
|
93 |
-
}
|
94 |
-
|
95 |
-
}
|
96 |
-
|
97 |
-
return $list_suffix;
|
98 |
-
}
|
99 |
-
|
100 |
-
protected function add_parent_category_name( $category, $list_suffix )
|
101 |
-
{
|
102 |
-
|
103 |
-
if ( $category->parent > 0 ) {
|
104 |
-
$parent_category = get_term_by( 'id', $category->parent, 'product_cat' );
|
105 |
-
$list_suffix = ' | ' . $parent_category->name . $list_suffix;
|
106 |
-
$list_suffix = $this->add_parent_category_name( $parent_category, $list_suffix );
|
107 |
-
}
|
108 |
-
|
109 |
-
return $list_suffix;
|
110 |
-
}
|
111 |
-
|
112 |
-
protected function get_list_id_suffix() : string
|
113 |
-
{
|
114 |
-
$list_suffix = '';
|
115 |
-
|
116 |
-
if ( is_product_category() ) {
|
117 |
-
$category = get_queried_object();
|
118 |
-
$list_suffix = '.' . $category->slug;
|
119 |
-
$list_suffix = $this->add_parent_category_id( $category, $list_suffix );
|
120 |
-
} else {
|
121 |
-
|
122 |
-
if ( is_product_tag() ) {
|
123 |
-
$tag = get_queried_object();
|
124 |
-
$list_suffix = '.' . $tag->slug;
|
125 |
-
}
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
return $list_suffix;
|
130 |
-
}
|
131 |
-
|
132 |
-
protected function add_parent_category_id( $category, $list_suffix )
|
133 |
-
{
|
134 |
-
|
135 |
-
if ( $category->parent > 0 ) {
|
136 |
-
$parent_category = get_term_by( 'id', $category->parent, 'product_cat' );
|
137 |
-
// error_log(print_r($parent_category, true));
|
138 |
-
$list_suffix = '.' . $parent_category->slug . $list_suffix;
|
139 |
-
$list_suffix = $this->add_parent_category_id( $parent_category, $list_suffix );
|
140 |
-
}
|
141 |
-
|
142 |
-
return $list_suffix;
|
143 |
-
}
|
144 |
-
|
145 |
-
// https://stackoverflow.com/a/49616130/4688612
|
146 |
-
protected function get_order_from_order_received_page()
|
147 |
-
{
|
148 |
-
|
149 |
-
if ( $this->get_order_from_query_vars() ) {
|
150 |
-
return $this->get_order_from_query_vars();
|
151 |
-
} else {
|
152 |
-
|
153 |
-
if ( $this->get_order_with_url_order_key() ) {
|
154 |
-
return $this->get_order_with_url_order_key();
|
155 |
-
} else {
|
156 |
-
return false;
|
157 |
-
}
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
protected function get_order_from_query_vars()
|
164 |
-
{
|
165 |
-
global $wp ;
|
166 |
-
$order_id = absint( $wp->query_vars['order-received'] );
|
167 |
-
|
168 |
-
if ( $order_id && $order_id != 0 && ($order = wc_get_order( $order_id )) ) {
|
169 |
-
return $order;
|
170 |
-
} else {
|
171 |
-
wc_get_logger()->debug( 'WooCommerce couldn\'t retrieve the order ID from $wp->query_vars[\'order-received\']', [
|
172 |
-
'source' => 'wpm',
|
173 |
-
] );
|
174 |
-
wc_get_logger()->debug( print_r( $wp->query_vars, true ), [
|
175 |
-
'source' => 'wpm',
|
176 |
-
] );
|
177 |
-
return false;
|
178 |
-
}
|
179 |
-
|
180 |
-
}
|
181 |
-
|
182 |
-
protected function get_order_with_url_order_key()
|
183 |
-
{
|
184 |
-
|
185 |
-
if ( isset( $_GET['key'] ) ) {
|
186 |
-
$order_key = $_GET['key'];
|
187 |
-
return wc_get_order( wc_get_order_id_by_order_key( $order_key ) );
|
188 |
-
} else {
|
189 |
-
wc_get_logger()->debug( 'WooCommerce couldn\'t retrieve the order ID from order key in the URL', [
|
190 |
-
'source' => 'wpm',
|
191 |
-
] );
|
192 |
-
$order_key = $_GET['key'] ?? '';
|
193 |
-
wc_get_logger()->debug( 'URL order key: ' . $order_key, [
|
194 |
-
'source' => 'wpm',
|
195 |
-
] );
|
196 |
-
return false;
|
197 |
-
}
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
}
|
2 |
|
3 |
namespace WCPM\Classes\Pixels;
|
4 |
|
5 |
+
use libphonenumber\NumberParseException;
|
6 |
+
use libphonenumber\PhoneNumberFormat;
|
7 |
+
use libphonenumber\PhoneNumberUtil;
|
8 |
+
use WC_Geolocation;
|
9 |
|
10 |
+
if (!defined('ABSPATH')) {
|
11 |
+
exit; // Exit if accessed directly
|
12 |
+
}
|
13 |
+
|
14 |
+
trait Trait_Shop {
|
15 |
+
|
16 |
+
protected function get_list_name_suffix() {
|
17 |
+
$list_suffix = '';
|
18 |
+
|
19 |
+
if (is_product_category()) {
|
20 |
+
|
21 |
+
$category = get_queried_object();
|
22 |
+
$list_suffix = ' | ' . $category->name;
|
23 |
+
$list_suffix = $this->add_parent_category_name($category, $list_suffix);
|
24 |
+
} else {
|
25 |
+
if (is_product_tag()) {
|
26 |
+
$tag = get_queried_object();
|
27 |
+
$list_suffix = ' | ' . $tag->name;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
return $list_suffix;
|
32 |
+
}
|
33 |
+
|
34 |
+
protected function add_parent_category_name( $category, $list_suffix ) {
|
35 |
+
if ($category->parent > 0) {
|
36 |
+
|
37 |
+
$parent_category = get_term_by('id', $category->parent, 'product_cat');
|
38 |
+
$list_suffix = ' | ' . $parent_category->name . $list_suffix;
|
39 |
+
$list_suffix = $this->add_parent_category_name($parent_category, $list_suffix);
|
40 |
+
}
|
41 |
+
|
42 |
+
return $list_suffix;
|
43 |
+
}
|
44 |
+
|
45 |
+
protected function get_list_id_suffix() {
|
46 |
+
$list_suffix = '';
|
47 |
+
|
48 |
+
if (is_product_category()) {
|
49 |
+
$category = get_queried_object();
|
50 |
+
$list_suffix = '.' . $category->slug;
|
51 |
+
$list_suffix = $this->add_parent_category_id($category, $list_suffix);
|
52 |
+
} else {
|
53 |
+
if (is_product_tag()) {
|
54 |
+
$tag = get_queried_object();
|
55 |
+
$list_suffix = '.' . $tag->slug;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
return $list_suffix;
|
60 |
+
}
|
61 |
+
|
62 |
+
protected function add_parent_category_id( $category, $list_suffix ) {
|
63 |
+
if ($category->parent > 0) {
|
64 |
+
|
65 |
+
$parent_category = get_term_by('id', $category->parent, 'product_cat');
|
66 |
+
$list_suffix = '.' . $parent_category->slug . $list_suffix;
|
67 |
+
$list_suffix = $this->add_parent_category_id($parent_category, $list_suffix);
|
68 |
+
}
|
69 |
+
|
70 |
+
return $list_suffix;
|
71 |
+
}
|
72 |
+
|
73 |
+
// https://stackoverflow.com/a/49616130/4688612
|
74 |
+
protected function get_order_from_order_received_page() {
|
75 |
+
if ($this->get_order_from_query_vars()) {
|
76 |
+
return $this->get_order_from_query_vars();
|
77 |
+
} else {
|
78 |
+
if ($this->get_order_with_url_order_key()) {
|
79 |
+
return $this->get_order_with_url_order_key();
|
80 |
+
} else {
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
protected function wpm_get_order_total( $order ) {
|
87 |
+
|
88 |
+
$order_total = 0 == $this->options_obj->shop->order_total_logic ? $order->get_subtotal() - $order->get_total_discount() : $order->get_total();
|
89 |
+
|
90 |
+
// filter to adjust the order value
|
91 |
+
$order_total = apply_filters_deprecated('wgact_conversion_value_filter', [$order_total, $order], '1.10.2', 'wooptpm_conversion_value_filter');
|
92 |
+
$order_total = apply_filters_deprecated('wooptpm_conversion_value_filter', [$order_total, $order], '1.13.0', 'wpm_conversion_value_filter');
|
93 |
+
$order_total = apply_filters('wpm_conversion_value_filter', $order_total, $order);
|
94 |
+
|
95 |
+
return number_format((float) $order_total, 2, '.', '');
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
protected function get_order_from_query_vars() {
|
100 |
+
global $wp;
|
101 |
+
|
102 |
+
$order_id = absint($wp->query_vars['order-received']);
|
103 |
+
|
104 |
+
if ($order_id && 0 != $order_id && wc_get_order($order_id)) {
|
105 |
+
|
106 |
+
return wc_get_order($order_id);
|
107 |
+
} else {
|
108 |
+
|
109 |
+
wc_get_logger()->debug(
|
110 |
+
'WooCommerce couldn\'t retrieve the order ID from $wp->query_vars[\'order-received\']',
|
111 |
+
['source' => 'wpm']
|
112 |
+
);
|
113 |
+
|
114 |
+
wc_get_logger()->debug(
|
115 |
+
print_r($wp->query_vars, true),
|
116 |
+
['source' => 'wpm']
|
117 |
+
);
|
118 |
+
|
119 |
+
return false;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
protected function get_order_with_url_order_key() {
|
124 |
+
|
125 |
+
$_get = filter_input_array(INPUT_GET, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
126 |
+
|
127 |
+
if (isset($_get['key'])) {
|
128 |
+
$order_key = $_get['key'];
|
129 |
+
return wc_get_order(wc_get_order_id_by_order_key($order_key));
|
130 |
+
} else {
|
131 |
+
|
132 |
+
wc_get_logger()->debug(
|
133 |
+
'WooCommerce couldn\'t retrieve the order ID from order key in the URL',
|
134 |
+
['source' => 'wpm']
|
135 |
+
);
|
136 |
+
|
137 |
+
$order_key = $_get['key'] ? $_get['key'] : '';
|
138 |
+
wc_get_logger()->debug(
|
139 |
+
'URL order key: ' . $order_key,
|
140 |
+
['source' => 'wpm']
|
141 |
+
);
|
142 |
+
|
143 |
+
return false;
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
protected function get_order_currency( $order ) {
|
148 |
+
// use the right function to get the currency depending on the WooCommerce version
|
149 |
+
return $this->woocommerce_3_and_above() ? $order->get_currency() : $order->get_order_currency();
|
150 |
+
}
|
151 |
+
|
152 |
+
protected function woocommerce_3_and_above() {
|
153 |
+
global $woocommerce;
|
154 |
+
if (version_compare($woocommerce->version, 3.0, '>=')) {
|
155 |
+
return true;
|
156 |
+
} else {
|
157 |
+
return false;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
// https://stackoverflow.com/a/46216073/4688612
|
162 |
+
// https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query#description
|
163 |
+
protected function is_existing_customer( $order, $value = 0 ) {
|
164 |
+
|
165 |
+
if (is_numeric($value)) { // Based on user ID (registered users)
|
166 |
+
$meta_key = '_customer_user';
|
167 |
+
$meta_value = 0 == $value ? get_current_user_id() : (int) $value;
|
168 |
+
} else { // Based on billing email (Guest users)
|
169 |
+
$meta_key = '_billing_email';
|
170 |
+
$meta_value = sanitize_email($value);
|
171 |
+
}
|
172 |
+
|
173 |
+
$orders = wc_get_orders([
|
174 |
+
'return' => 'ids',
|
175 |
+
'meta_key' => $meta_key,
|
176 |
+
'meta_value' => $meta_value,
|
177 |
+
// 'orderby' => 'date',
|
178 |
+
// 'order' => 'DESC',
|
179 |
+
'post_status' => wc_get_is_paid_statuses(),
|
180 |
+
'limit' => 1,
|
181 |
+
]);
|
182 |
+
|
183 |
+
// Return a boolean value based on orders count
|
184 |
+
return count($orders) > 0;
|
185 |
+
}
|
186 |
+
|
187 |
+
protected function get_user_ip() {
|
188 |
+
|
189 |
+
if ($this->is_localhost()) {
|
190 |
+
$ip = WC_Geolocation::get_external_ip_address();
|
191 |
+
} else {
|
192 |
+
$ip = WC_Geolocation::get_ip_address();
|
193 |
+
}
|
194 |
+
|
195 |
+
// only set the IP if it is a public address
|
196 |
+
$ip = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
|
197 |
+
|
198 |
+
// Remove the IPv6 to IPv4 mapping in case the IP contains one
|
199 |
+
// and return the IP plain public IPv4 or IPv6 IP
|
200 |
+
// https://en.wikipedia.org/wiki/IPv6_address
|
201 |
+
return str_replace('::ffff:', '', $ip);
|
202 |
+
}
|
203 |
+
|
204 |
+
protected function get_visitor_country() {
|
205 |
+
|
206 |
+
$location = WC_Geolocation::geolocate_ip($this->get_user_ip());
|
207 |
+
|
208 |
+
return $location['country'];
|
209 |
+
}
|
210 |
+
|
211 |
+
protected function is_localhost() {
|
212 |
+
|
213 |
+
$_server = filter_input_array(INPUT_SERVER, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
214 |
+
|
215 |
+
// If the IP is local, return true, else false
|
216 |
+
// https://stackoverflow.com/a/13818647/4688612
|
217 |
+
return !filter_var(
|
218 |
+
$_server['REMOTE_ADDR'],
|
219 |
+
FILTER_VALIDATE_IP,
|
220 |
+
FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE
|
221 |
+
);
|
222 |
+
}
|
223 |
+
|
224 |
+
protected function get_user_email( $algo = null ) {
|
225 |
+
|
226 |
+
if (is_user_logged_in()) {
|
227 |
+
$current_user = wp_get_current_user();
|
228 |
+
$email = $current_user->user_email;
|
229 |
+
} elseif (is_order_received_page()) {
|
230 |
+
$order = $this->get_order_from_order_received_page();
|
231 |
+
|
232 |
+
if ($order) {
|
233 |
+
$email = $order->get_billing_email();
|
234 |
+
} else {
|
235 |
+
$email = '';
|
236 |
+
}
|
237 |
+
} else {
|
238 |
+
$email = '';
|
239 |
+
}
|
240 |
+
|
241 |
+
// encrypt email
|
242 |
+
if ($email && $algo && in_array($algo, hash_algos(), true)) {
|
243 |
+
$email = hash($algo, $email);
|
244 |
+
}
|
245 |
+
|
246 |
+
return $email;
|
247 |
+
}
|
248 |
+
|
249 |
+
private function get_e164_formatted_phone_number( $number, $country ) {
|
250 |
+
try {
|
251 |
+
$phone_util = PhoneNumberUtil::getInstance();
|
252 |
+
$number_parsed = $phone_util->parse($number, $country);
|
253 |
+
return $phone_util->format($number_parsed, PhoneNumberFormat::E164);
|
254 |
+
} catch (NumberParseException $e) {
|
255 |
+
error_log($e);
|
256 |
+
return $number;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
protected function track_user( $user_id = null ) {
|
261 |
+
|
262 |
+
$user = null;
|
263 |
+
|
264 |
+
if (0 === $user_id) { // If anonymous visitor then track
|
265 |
+
return true;
|
266 |
+
} elseif ($user_id && 0 <= $user_id) { // If user ID is known, get the user
|
267 |
+
$user = get_user_by('id', $user_id);
|
268 |
+
} elseif (null === $user_id && is_user_logged_in()) { // If user id is not given, but the user is logged in, get the user
|
269 |
+
$user = wp_get_current_user();
|
270 |
+
}
|
271 |
+
|
272 |
+
// Find out if the user has a role that is restricted from tracking
|
273 |
+
if ($user) {
|
274 |
+
|
275 |
+
foreach ($user->roles as $role) {
|
276 |
+
if (in_array($role, $this->options_obj->shop->disable_tracking_for, true)) {
|
277 |
+
return false;
|
278 |
+
}
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
+
return true;
|
283 |
+
}
|
284 |
+
|
285 |
+
protected function do_not_track_user( $user_id = null ) {
|
286 |
+
return !$this->track_user($user_id);
|
287 |
+
}
|
288 |
}
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
composer.json
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "woopt/woocommerce-pixel-manager",
|
3 |
-
"type": "wordpress-plugin",
|
4 |
-
"require": {
|
5 |
-
"giggsey/libphonenumber-for-php": "^8.12",
|
6 |
-
"freemius/wordpress-sdk": "^2.4",
|
7 |
-
"symfony/polyfill-mbstring": "v1.20"
|
8 |
-
},
|
9 |
-
"autoload": {
|
10 |
-
"psr-4": {
|
11 |
-
"Woopt\\WoocommercePixelManager\\": "src/"
|
12 |
-
}
|
13 |
-
},
|
14 |
-
"authors": [
|
15 |
-
{
|
16 |
-
"name": "Aleksandar Vucenovic",
|
17 |
-
"email": "aleksandar@woopt.com"
|
18 |
-
}
|
19 |
-
]
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
composer.lock
DELETED
@@ -1,264 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"_readme": [
|
3 |
-
"This file locks the dependencies of your project to a known state",
|
4 |
-
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
5 |
-
"This file is @generated automatically"
|
6 |
-
],
|
7 |
-
"content-hash": "a67a210636590a4a0f882d48dca3160f",
|
8 |
-
"packages": [
|
9 |
-
{
|
10 |
-
"name": "freemius/wordpress-sdk",
|
11 |
-
"version": "2.4.2",
|
12 |
-
"source": {
|
13 |
-
"type": "git",
|
14 |
-
"url": "https://github.com/Freemius/wordpress-sdk.git",
|
15 |
-
"reference": "84a9be4717effd7697a217e0d931f48ae0d2ecc6"
|
16 |
-
},
|
17 |
-
"dist": {
|
18 |
-
"type": "zip",
|
19 |
-
"url": "https://api.github.com/repos/Freemius/wordpress-sdk/zipball/84a9be4717effd7697a217e0d931f48ae0d2ecc6",
|
20 |
-
"reference": "84a9be4717effd7697a217e0d931f48ae0d2ecc6",
|
21 |
-
"shasum": ""
|
22 |
-
},
|
23 |
-
"require": {
|
24 |
-
"php": ">=5.2"
|
25 |
-
},
|
26 |
-
"type": "library",
|
27 |
-
"notification-url": "https://packagist.org/downloads/",
|
28 |
-
"license": [
|
29 |
-
"GPL-3.0-only"
|
30 |
-
],
|
31 |
-
"description": "Freemius WordPress SDK",
|
32 |
-
"homepage": "https://freemius.com",
|
33 |
-
"keywords": [
|
34 |
-
"freemius",
|
35 |
-
"plugin",
|
36 |
-
"sdk",
|
37 |
-
"theme",
|
38 |
-
"wordpress",
|
39 |
-
"wordpress-plugin",
|
40 |
-
"wordpress-theme"
|
41 |
-
],
|
42 |
-
"support": {
|
43 |
-
"issues": "https://github.com/Freemius/wordpress-sdk/issues",
|
44 |
-
"source": "https://github.com/Freemius/wordpress-sdk/tree/2.4.2"
|
45 |
-
},
|
46 |
-
"time": "2021-02-08T16:47:44+00:00"
|
47 |
-
},
|
48 |
-
{
|
49 |
-
"name": "giggsey/libphonenumber-for-php",
|
50 |
-
"version": "8.12.29",
|
51 |
-
"source": {
|
52 |
-
"type": "git",
|
53 |
-
"url": "https://github.com/giggsey/libphonenumber-for-php.git",
|
54 |
-
"reference": "407bbbb6c857aeab010ce7b40e84a938f8b43003"
|
55 |
-
},
|
56 |
-
"dist": {
|
57 |
-
"type": "zip",
|
58 |
-
"url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/407bbbb6c857aeab010ce7b40e84a938f8b43003",
|
59 |
-
"reference": "407bbbb6c857aeab010ce7b40e84a938f8b43003",
|
60 |
-
"shasum": ""
|
61 |
-
},
|
62 |
-
"require": {
|
63 |
-
"giggsey/locale": "^1.7",
|
64 |
-
"php": ">=5.3.2",
|
65 |
-
"symfony/polyfill-mbstring": "^1.17"
|
66 |
-
},
|
67 |
-
"require-dev": {
|
68 |
-
"pear/pear-core-minimal": "^1.9",
|
69 |
-
"pear/pear_exception": "^1.0",
|
70 |
-
"pear/versioncontrol_git": "^0.5",
|
71 |
-
"phing/phing": "^2.7",
|
72 |
-
"php-coveralls/php-coveralls": "^1.0|^2.0",
|
73 |
-
"symfony/console": "^2.8|^3.0|^v4.4|^v5.2",
|
74 |
-
"symfony/phpunit-bridge": "^4.2 || ^5"
|
75 |
-
},
|
76 |
-
"type": "library",
|
77 |
-
"extra": {
|
78 |
-
"branch-alias": {
|
79 |
-
"dev-master": "8.x-dev"
|
80 |
-
}
|
81 |
-
},
|
82 |
-
"autoload": {
|
83 |
-
"psr-4": {
|
84 |
-
"libphonenumber\\": "src/"
|
85 |
-
},
|
86 |
-
"exclude-from-classmap": [
|
87 |
-
"/src/data/",
|
88 |
-
"/src/carrier/data/",
|
89 |
-
"/src/geocoding/data/",
|
90 |
-
"/src/timezone/data/"
|
91 |
-
]
|
92 |
-
},
|
93 |
-
"notification-url": "https://packagist.org/downloads/",
|
94 |
-
"license": [
|
95 |
-
"Apache-2.0"
|
96 |
-
],
|
97 |
-
"authors": [
|
98 |
-
{
|
99 |
-
"name": "Joshua Gigg",
|
100 |
-
"email": "giggsey@gmail.com",
|
101 |
-
"homepage": "https://giggsey.com/"
|
102 |
-
}
|
103 |
-
],
|
104 |
-
"description": "PHP Port of Google's libphonenumber",
|
105 |
-
"homepage": "https://github.com/giggsey/libphonenumber-for-php",
|
106 |
-
"keywords": [
|
107 |
-
"geocoding",
|
108 |
-
"geolocation",
|
109 |
-
"libphonenumber",
|
110 |
-
"mobile",
|
111 |
-
"phonenumber",
|
112 |
-
"validation"
|
113 |
-
],
|
114 |
-
"support": {
|
115 |
-
"irc": "irc://irc.appliedirc.com/lobby",
|
116 |
-
"issues": "https://github.com/giggsey/libphonenumber-for-php/issues",
|
117 |
-
"source": "https://github.com/giggsey/libphonenumber-for-php"
|
118 |
-
},
|
119 |
-
"time": "2021-08-06T13:37:53+00:00"
|
120 |
-
},
|
121 |
-
{
|
122 |
-
"name": "giggsey/locale",
|
123 |
-
"version": "1.9",
|
124 |
-
"source": {
|
125 |
-
"type": "git",
|
126 |
-
"url": "https://github.com/giggsey/Locale.git",
|
127 |
-
"reference": "b07f1eace8072ccc61445ad8fbd493ff9d783043"
|
128 |
-
},
|
129 |
-
"dist": {
|
130 |
-
"type": "zip",
|
131 |
-
"url": "https://api.github.com/repos/giggsey/Locale/zipball/b07f1eace8072ccc61445ad8fbd493ff9d783043",
|
132 |
-
"reference": "b07f1eace8072ccc61445ad8fbd493ff9d783043",
|
133 |
-
"shasum": ""
|
134 |
-
},
|
135 |
-
"require": {
|
136 |
-
"php": ">=5.3.2"
|
137 |
-
},
|
138 |
-
"require-dev": {
|
139 |
-
"pear/pear-core-minimal": "^1.9",
|
140 |
-
"pear/pear_exception": "^1.0",
|
141 |
-
"pear/versioncontrol_git": "^0.5",
|
142 |
-
"phing/phing": "~2.7",
|
143 |
-
"php-coveralls/php-coveralls": "^1.0|^2.0",
|
144 |
-
"phpunit/phpunit": "^4.8|^5.0",
|
145 |
-
"symfony/console": "^2.8|^3.0|^4.0",
|
146 |
-
"symfony/filesystem": "^2.8|^3.0|^4.0",
|
147 |
-
"symfony/finder": "^2.8|^3.0|^4.0",
|
148 |
-
"symfony/process": "^2.8|^3.0|^4.0"
|
149 |
-
},
|
150 |
-
"type": "library",
|
151 |
-
"autoload": {
|
152 |
-
"psr-4": {
|
153 |
-
"Giggsey\\Locale\\": "src/"
|
154 |
-
}
|
155 |
-
},
|
156 |
-
"notification-url": "https://packagist.org/downloads/",
|
157 |
-
"license": [
|
158 |
-
"MIT"
|
159 |
-
],
|
160 |
-
"authors": [
|
161 |
-
{
|
162 |
-
"name": "Joshua Gigg",
|
163 |
-
"email": "giggsey@gmail.com",
|
164 |
-
"homepage": "http://giggsey.com/"
|
165 |
-
}
|
166 |
-
],
|
167 |
-
"description": "Locale functions required by libphonenumber-for-php",
|
168 |
-
"support": {
|
169 |
-
"issues": "https://github.com/giggsey/Locale/issues",
|
170 |
-
"source": "https://github.com/giggsey/Locale/tree/master"
|
171 |
-
},
|
172 |
-
"time": "2020-07-07T11:16:24+00:00"
|
173 |
-
},
|
174 |
-
{
|
175 |
-
"name": "symfony/polyfill-mbstring",
|
176 |
-
"version": "v1.20.0",
|
177 |
-
"source": {
|
178 |
-
"type": "git",
|
179 |
-
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
180 |
-
"reference": "39d483bdf39be819deabf04ec872eb0b2410b531"
|
181 |
-
},
|
182 |
-
"dist": {
|
183 |
-
"type": "zip",
|
184 |
-
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531",
|
185 |
-
"reference": "39d483bdf39be819deabf04ec872eb0b2410b531",
|
186 |
-
"shasum": ""
|
187 |
-
},
|
188 |
-
"require": {
|
189 |
-
"php": ">=7.1"
|
190 |
-
},
|
191 |
-
"suggest": {
|
192 |
-
"ext-mbstring": "For best performance"
|
193 |
-
},
|
194 |
-
"type": "library",
|
195 |
-
"extra": {
|
196 |
-
"branch-alias": {
|
197 |
-
"dev-main": "1.20-dev"
|
198 |
-
},
|
199 |
-
"thanks": {
|
200 |
-
"name": "symfony/polyfill",
|
201 |
-
"url": "https://github.com/symfony/polyfill"
|
202 |
-
}
|
203 |
-
},
|
204 |
-
"autoload": {
|
205 |
-
"psr-4": {
|
206 |
-
"Symfony\\Polyfill\\Mbstring\\": ""
|
207 |
-
},
|
208 |
-
"files": [
|
209 |
-
"bootstrap.php"
|
210 |
-
]
|
211 |
-
},
|
212 |
-
"notification-url": "https://packagist.org/downloads/",
|
213 |
-
"license": [
|
214 |
-
"MIT"
|
215 |
-
],
|
216 |
-
"authors": [
|
217 |
-
{
|
218 |
-
"name": "Nicolas Grekas",
|
219 |
-
"email": "p@tchwork.com"
|
220 |
-
},
|
221 |
-
{
|
222 |
-
"name": "Symfony Community",
|
223 |
-
"homepage": "https://symfony.com/contributors"
|
224 |
-
}
|
225 |
-
],
|
226 |
-
"description": "Symfony polyfill for the Mbstring extension",
|
227 |
-
"homepage": "https://symfony.com",
|
228 |
-
"keywords": [
|
229 |
-
"compatibility",
|
230 |
-
"mbstring",
|
231 |
-
"polyfill",
|
232 |
-
"portable",
|
233 |
-
"shim"
|
234 |
-
],
|
235 |
-
"support": {
|
236 |
-
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0"
|
237 |
-
},
|
238 |
-
"funding": [
|
239 |
-
{
|
240 |
-
"url": "https://symfony.com/sponsor",
|
241 |
-
"type": "custom"
|
242 |
-
},
|
243 |
-
{
|
244 |
-
"url": "https://github.com/fabpot",
|
245 |
-
"type": "github"
|
246 |
-
},
|
247 |
-
{
|
248 |
-
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
249 |
-
"type": "tidelift"
|
250 |
-
}
|
251 |
-
],
|
252 |
-
"time": "2020-10-23T14:02:19+00:00"
|
253 |
-
}
|
254 |
-
],
|
255 |
-
"packages-dev": [],
|
256 |
-
"aliases": [],
|
257 |
-
"minimum-stability": "stable",
|
258 |
-
"stability-flags": [],
|
259 |
-
"prefer-stable": false,
|
260 |
-
"prefer-lowest": false,
|
261 |
-
"platform": [],
|
262 |
-
"platform-dev": [],
|
263 |
-
"plugin-api-version": "2.1.0"
|
264 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/admin.css
CHANGED
@@ -47,7 +47,7 @@
|
|
47 |
.developer-banner {
|
48 |
background: #f3f5f6;
|
49 |
color: #0071a1;
|
50 |
-
padding:
|
51 |
margin-bottom: 20px;
|
52 |
border-radius: 3px;
|
53 |
border-style: solid;
|
@@ -174,4 +174,4 @@ input:checked + .slider:before {
|
|
174 |
text-decoration: none;
|
175 |
margin-left: 5px;
|
176 |
margin-right: 5px;
|
177 |
-
}
|
47 |
.developer-banner {
|
48 |
background: #f3f5f6;
|
49 |
color: #0071a1;
|
50 |
+
padding: 0 10px;
|
51 |
margin-bottom: 20px;
|
52 |
border-radius: 3px;
|
53 |
border-style: solid;
|
174 |
text-decoration: none;
|
175 |
margin-left: 5px;
|
176 |
margin-right: 5px;
|
177 |
+
}
|
css/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
freemius/LICENSE.txt
DELETED
@@ -1,674 +0,0 @@
|
|
1 |
-
GNU GENERAL PUBLIC LICENSE
|
2 |
-
Version 3, 29 June 2007
|
3 |
-
|
4 |
-
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5 |
-
Everyone is permitted to copy and distribute verbatim copies
|
6 |
-
of this license document, but changing it is not allowed.
|
7 |
-
|
8 |
-
Preamble
|
9 |
-
|
10 |
-
The GNU General Public License is a free, copyleft license for
|
11 |
-
software and other kinds of works.
|
12 |
-
|
13 |
-
The licenses for most software and other practical works are designed
|
14 |
-
to take away your freedom to share and change the works. By contrast,
|
15 |
-
the GNU General Public License is intended to guarantee your freedom to
|
16 |
-
share and change all versions of a program--to make sure it remains free
|
17 |
-
software for all its users. We, the Free Software Foundation, use the
|
18 |
-
GNU General Public License for most of our software; it applies also to
|
19 |
-
any other work released this way by its authors. You can apply it to
|
20 |
-
your programs, too.
|
21 |
-
|
22 |
-
When we speak of free software, we are referring to freedom, not
|
23 |
-
price. Our General Public Licenses are designed to make sure that you
|
24 |
-
have the freedom to distribute copies of free software (and charge for
|
25 |
-
them if you wish), that you receive source code or can get it if you
|
26 |
-
want it, that you can change the software or use pieces of it in new
|
27 |
-
free programs, and that you know you can do these things.
|
28 |
-
|
29 |
-
To protect your rights, we need to prevent others from denying you
|
30 |
-
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
-
certain responsibilities if you distribute copies of the software, or if
|
32 |
-
you modify it: responsibilities to respect the freedom of others.
|
33 |
-
|
34 |
-
For example, if you distribute copies of such a program, whether
|
35 |
-
gratis or for a fee, you must pass on to the recipients the same
|
36 |
-
freedoms that you received. You must make sure that they, too, receive
|
37 |
-
or can get the source code. And you must show them these terms so they
|
38 |
-
know their rights.
|
39 |
-
|
40 |
-
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
-
(1) assert copyright on the software, and (2) offer you this License
|
42 |
-
giving you legal permission to copy, distribute and/or modify it.
|
43 |
-
|
44 |
-
For the developers' and authors' protection, the GPL clearly explains
|
45 |
-
that there is no warranty for this free software. For both users' and
|
46 |
-
authors' sake, the GPL requires that modified versions be marked as
|
47 |
-
changed, so that their problems will not be attributed erroneously to
|
48 |
-
authors of previous versions.
|
49 |
-
|
50 |
-
Some devices are designed to deny users access to install or run
|
51 |
-
modified versions of the software inside them, although the manufacturer
|
52 |
-
can do so. This is fundamentally incompatible with the aim of
|
53 |
-
protecting users' freedom to change the software. The systematic
|
54 |
-
pattern of such abuse occurs in the area of products for individuals to
|
55 |
-
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
-
have designed this version of the GPL to prohibit the practice for those
|
57 |
-
products. If such problems arise substantially in other domains, we
|
58 |
-
stand ready to extend this provision to those domains in future versions
|
59 |
-
of the GPL, as needed to protect the freedom of users.
|
60 |
-
|
61 |
-
Finally, every program is threatened constantly by software patents.
|
62 |
-
States should not allow patents to restrict development and use of
|
63 |
-
software on general-purpose computers, but in those that do, we wish to
|
64 |
-
avoid the special danger that patents applied to a free program could
|
65 |
-
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
-
patents cannot be used to render the program non-free.
|
67 |
-
|
68 |
-
The precise terms and conditions for copying, distribution and
|
69 |
-
modification follow.
|
70 |
-
|
71 |
-
TERMS AND CONDITIONS
|
72 |
-
|
73 |
-
0. Definitions.
|
74 |
-
|
75 |
-
"This License" refers to version 3 of the GNU General Public License.
|
76 |
-
|
77 |
-
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
-
works, such as semiconductor masks.
|
79 |
-
|
80 |
-
"The Program" refers to any copyrightable work licensed under this
|
81 |
-
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
-
"recipients" may be individuals or organizations.
|
83 |
-
|
84 |
-
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
-
in a fashion requiring copyright permission, other than the making of an
|
86 |
-
exact copy. The resulting work is called a "modified version" of the
|
87 |
-
earlier work or a work "based on" the earlier work.
|
88 |
-
|
89 |
-
A "covered work" means either the unmodified Program or a work based
|
90 |
-
on the Program.
|
91 |
-
|
92 |
-
To "propagate" a work means to do anything with it that, without
|
93 |
-
permission, would make you directly or secondarily liable for
|
94 |
-
infringement under applicable copyright law, except executing it on a
|
95 |
-
computer or modifying a private copy. Propagation includes copying,
|
96 |
-
distribution (with or without modification), making available to the
|
97 |
-
public, and in some countries other activities as well.
|
98 |
-
|
99 |
-
To "convey" a work means any kind of propagation that enables other
|
100 |
-
parties to make or receive copies. Mere interaction with a user through
|
101 |
-
a computer network, with no transfer of a copy, is not conveying.
|
102 |
-
|
103 |
-
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
-
to the extent that it includes a convenient and prominently visible
|
105 |
-
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
-
tells the user that there is no warranty for the work (except to the
|
107 |
-
extent that warranties are provided), that licensees may convey the
|
108 |
-
work under this License, and how to view a copy of this License. If
|
109 |
-
the interface presents a list of user commands or options, such as a
|
110 |
-
menu, a prominent item in the list meets this criterion.
|
111 |
-
|
112 |
-
1. Source Code.
|
113 |
-
|
114 |
-
The "source code" for a work means the preferred form of the work
|
115 |
-
for making modifications to it. "Object code" means any non-source
|
116 |
-
form of a work.
|
117 |
-
|
118 |
-
A "Standard Interface" means an interface that either is an official
|
119 |
-
standard defined by a recognized standards body, or, in the case of
|
120 |
-
interfaces specified for a particular programming language, one that
|
121 |
-
is widely used among developers working in that language.
|
122 |
-
|
123 |
-
The "System Libraries" of an executable work include anything, other
|
124 |
-
than the work as a whole, that (a) is included in the normal form of
|
125 |
-
packaging a Major Component, but which is not part of that Major
|
126 |
-
Component, and (b) serves only to enable use of the work with that
|
127 |
-
Major Component, or to implement a Standard Interface for which an
|
128 |
-
implementation is available to the public in source code form. A
|
129 |
-
"Major Component", in this context, means a major essential component
|
130 |
-
(kernel, window system, and so on) of the specific operating system
|
131 |
-
(if any) on which the executable work runs, or a compiler used to
|
132 |
-
produce the work, or an object code interpreter used to run it.
|
133 |
-
|
134 |
-
The "Corresponding Source" for a work in object code form means all
|
135 |
-
the source code needed to generate, install, and (for an executable
|
136 |
-
work) run the object code and to modify the work, including scripts to
|
137 |
-
control those activities. However, it does not include the work's
|
138 |
-
System Libraries, or general-purpose tools or generally available free
|
139 |
-
programs which are used unmodified in performing those activities but
|
140 |
-
which are not part of the work. For example, Corresponding Source
|
141 |
-
includes interface definition files associated with source files for
|
142 |
-
the work, and the source code for shared libraries and dynamically
|
143 |
-
linked subprograms that the work is specifically designed to require,
|
144 |
-
such as by intimate data communication or control flow between those
|
145 |
-
subprograms and other parts of the work.
|
146 |
-
|
147 |
-
The Corresponding Source need not include anything that users
|
148 |
-
can regenerate automatically from other parts of the Corresponding
|
149 |
-
Source.
|
150 |
-
|
151 |
-
The Corresponding Source for a work in source code form is that
|
152 |
-
same work.
|
153 |
-
|
154 |
-
2. Basic Permissions.
|
155 |
-
|
156 |
-
All rights granted under this License are granted for the term of
|
157 |
-
copyright on the Program, and are irrevocable provided the stated
|
158 |
-
conditions are met. This License explicitly affirms your unlimited
|
159 |
-
permission to run the unmodified Program. The output from running a
|
160 |
-
covered work is covered by this License only if the output, given its
|
161 |
-
content, constitutes a covered work. This License acknowledges your
|
162 |
-
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
-
|
164 |
-
You may make, run and propagate covered works that you do not
|
165 |
-
convey, without conditions so long as your license otherwise remains
|
166 |
-
in force. You may convey covered works to others for the sole purpose
|
167 |
-
of having them make modifications exclusively for you, or provide you
|
168 |
-
with facilities for running those works, provided that you comply with
|
169 |
-
the terms of this License in conveying all material for which you do
|
170 |
-
not control copyright. Those thus making or running the covered works
|
171 |
-
for you must do so exclusively on your behalf, under your direction
|
172 |
-
and control, on terms that prohibit them from making any copies of
|
173 |
-
your copyrighted material outside their relationship with you.
|
174 |
-
|
175 |
-
Conveying under any other circumstances is permitted solely under
|
176 |
-
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
-
makes it unnecessary.
|
178 |
-
|
179 |
-
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
-
|
181 |
-
No covered work shall be deemed part of an effective technological
|
182 |
-
measure under any applicable law fulfilling obligations under article
|
183 |
-
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
-
similar laws prohibiting or restricting circumvention of such
|
185 |
-
measures.
|
186 |
-
|
187 |
-
When you convey a covered work, you waive any legal power to forbid
|
188 |
-
circumvention of technological measures to the extent such circumvention
|
189 |
-
is effected by exercising rights under this License with respect to
|
190 |
-
the covered work, and you disclaim any intention to limit operation or
|
191 |
-
modification of the work as a means of enforcing, against the work's
|
192 |
-
users, your or third parties' legal rights to forbid circumvention of
|
193 |
-
technological measures.
|
194 |
-
|
195 |
-
4. Conveying Verbatim Copies.
|
196 |
-
|
197 |
-
You may convey verbatim copies of the Program's source code as you
|
198 |
-
receive it, in any medium, provided that you conspicuously and
|
199 |
-
appropriately publish on each copy an appropriate copyright notice;
|
200 |
-
keep intact all notices stating that this License and any
|
201 |
-
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
-
keep intact all notices of the absence of any warranty; and give all
|
203 |
-
recipients a copy of this License along with the Program.
|
204 |
-
|
205 |
-
You may charge any price or no price for each copy that you convey,
|
206 |
-
and you may offer support or warranty protection for a fee.
|
207 |
-
|
208 |
-
5. Conveying Modified Source Versions.
|
209 |
-
|
210 |
-
You may convey a work based on the Program, or the modifications to
|
211 |
-
produce it from the Program, in the form of source code under the
|
212 |
-
terms of section 4, provided that you also meet all of these conditions:
|
213 |
-
|
214 |
-
a) The work must carry prominent notices stating that you modified
|
215 |
-
it, and giving a relevant date.
|
216 |
-
|
217 |
-
b) The work must carry prominent notices stating that it is
|
218 |
-
released under this License and any conditions added under section
|
219 |
-
7. This requirement modifies the requirement in section 4 to
|
220 |
-
"keep intact all notices".
|
221 |
-
|
222 |
-
c) You must license the entire work, as a whole, under this
|
223 |
-
License to anyone who comes into possession of a copy. This
|
224 |
-
License will therefore apply, along with any applicable section 7
|
225 |
-
additional terms, to the whole of the work, and all its parts,
|
226 |
-
regardless of how they are packaged. This License gives no
|
227 |
-
permission to license the work in any other way, but it does not
|
228 |
-
invalidate such permission if you have separately received it.
|
229 |
-
|
230 |
-
d) If the work has interactive user interfaces, each must display
|
231 |
-
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
-
interfaces that do not display Appropriate Legal Notices, your
|
233 |
-
work need not make them do so.
|
234 |
-
|
235 |
-
A compilation of a covered work with other separate and independent
|
236 |
-
works, which are not by their nature extensions of the covered work,
|
237 |
-
and which are not combined with it such as to form a larger program,
|
238 |
-
in or on a volume of a storage or distribution medium, is called an
|
239 |
-
"aggregate" if the compilation and its resulting copyright are not
|
240 |
-
used to limit the access or legal rights of the compilation's users
|
241 |
-
beyond what the individual works permit. Inclusion of a covered work
|
242 |
-
in an aggregate does not cause this License to apply to the other
|
243 |
-
parts of the aggregate.
|
244 |
-
|
245 |
-
6. Conveying Non-Source Forms.
|
246 |
-
|
247 |
-
You may convey a covered work in object code form under the terms
|
248 |
-
of sections 4 and 5, provided that you also convey the
|
249 |
-
machine-readable Corresponding Source under the terms of this License,
|
250 |
-
in one of these ways:
|
251 |
-
|
252 |
-
a) Convey the object code in, or embodied in, a physical product
|
253 |
-
(including a physical distribution medium), accompanied by the
|
254 |
-
Corresponding Source fixed on a durable physical medium
|
255 |
-
customarily used for software interchange.
|
256 |
-
|
257 |
-
b) Convey the object code in, or embodied in, a physical product
|
258 |
-
(including a physical distribution medium), accompanied by a
|
259 |
-
written offer, valid for at least three years and valid for as
|
260 |
-
long as you offer spare parts or customer support for that product
|
261 |
-
model, to give anyone who possesses the object code either (1) a
|
262 |
-
copy of the Corresponding Source for all the software in the
|
263 |
-
product that is covered by this License, on a durable physical
|
264 |
-
medium customarily used for software interchange, for a price no
|
265 |
-
more than your reasonable cost of physically performing this
|
266 |
-
conveying of source, or (2) access to copy the
|
267 |
-
Corresponding Source from a network server at no charge.
|
268 |
-
|
269 |
-
c) Convey individual copies of the object code with a copy of the
|
270 |
-
written offer to provide the Corresponding Source. This
|
271 |
-
alternative is allowed only occasionally and noncommercially, and
|
272 |
-
only if you received the object code with such an offer, in accord
|
273 |
-
with subsection 6b.
|
274 |
-
|
275 |
-
d) Convey the object code by offering access from a designated
|
276 |
-
place (gratis or for a charge), and offer equivalent access to the
|
277 |
-
Corresponding Source in the same way through the same place at no
|
278 |
-
further charge. You need not require recipients to copy the
|
279 |
-
Corresponding Source along with the object code. If the place to
|
280 |
-
copy the object code is a network server, the Corresponding Source
|
281 |
-
may be on a different server (operated by you or a third party)
|
282 |
-
that supports equivalent copying facilities, provided you maintain
|
283 |
-
clear directions next to the object code saying where to find the
|
284 |
-
Corresponding Source. Regardless of what server hosts the
|
285 |
-
Corresponding Source, you remain obligated to ensure that it is
|
286 |
-
available for as long as needed to satisfy these requirements.
|
287 |
-
|
288 |
-
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
-
you inform other peers where the object code and Corresponding
|
290 |
-
Source of the work are being offered to the general public at no
|
291 |
-
charge under subsection 6d.
|
292 |
-
|
293 |
-
A separable portion of the object code, whose source code is excluded
|
294 |
-
from the Corresponding Source as a System Library, need not be
|
295 |
-
included in conveying the object code work.
|
296 |
-
|
297 |
-
A "User Product" is either (1) a "consumer product", which means any
|
298 |
-
tangible personal property which is normally used for personal, family,
|
299 |
-
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
-
into a dwelling. In determining whether a product is a consumer product,
|
301 |
-
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
-
product received by a particular user, "normally used" refers to a
|
303 |
-
typical or common use of that class of product, regardless of the status
|
304 |
-
of the particular user or of the way in which the particular user
|
305 |
-
actually uses, or expects or is expected to use, the product. A product
|
306 |
-
is a consumer product regardless of whether the product has substantial
|
307 |
-
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
-
the only significant mode of use of the product.
|
309 |
-
|
310 |
-
"Installation Information" for a User Product means any methods,
|
311 |
-
procedures, authorization keys, or other information required to install
|
312 |
-
and execute modified versions of a covered work in that User Product from
|
313 |
-
a modified version of its Corresponding Source. The information must
|
314 |
-
suffice to ensure that the continued functioning of the modified object
|
315 |
-
code is in no case prevented or interfered with solely because
|
316 |
-
modification has been made.
|
317 |
-
|
318 |
-
If you convey an object code work under this section in, or with, or
|
319 |
-
specifically for use in, a User Product, and the conveying occurs as
|
320 |
-
part of a transaction in which the right of possession and use of the
|
321 |
-
User Product is transferred to the recipient in perpetuity or for a
|
322 |
-
fixed term (regardless of how the transaction is characterized), the
|
323 |
-
Corresponding Source conveyed under this section must be accompanied
|
324 |
-
by the Installation Information. But this requirement does not apply
|
325 |
-
if neither you nor any third party retains the ability to install
|
326 |
-
modified object code on the User Product (for example, the work has
|
327 |
-
been installed in ROM).
|
328 |
-
|
329 |
-
The requirement to provide Installation Information does not include a
|
330 |
-
requirement to continue to provide support service, warranty, or updates
|
331 |
-
for a work that has been modified or installed by the recipient, or for
|
332 |
-
the User Product in which it has been modified or installed. Access to a
|
333 |
-
network may be denied when the modification itself materially and
|
334 |
-
adversely affects the operation of the network or violates the rules and
|
335 |
-
protocols for communication across the network.
|
336 |
-
|
337 |
-
Corresponding Source conveyed, and Installation Information provided,
|
338 |
-
in accord with this section must be in a format that is publicly
|
339 |
-
documented (and with an implementation available to the public in
|
340 |
-
source code form), and must require no special password or key for
|
341 |
-
unpacking, reading or copying.
|
342 |
-
|
343 |
-
7. Additional Terms.
|
344 |
-
|
345 |
-
"Additional permissions" are terms that supplement the terms of this
|
346 |
-
License by making exceptions from one or more of its conditions.
|
347 |
-
Additional permissions that are applicable to the entire Program shall
|
348 |
-
be treated as though they were included in this License, to the extent
|
349 |
-
that they are valid under applicable law. If additional permissions
|
350 |
-
apply only to part of the Program, that part may be used separately
|
351 |
-
under those permissions, but the entire Program remains governed by
|
352 |
-
this License without regard to the additional permissions.
|
353 |
-
|
354 |
-
When you convey a copy of a covered work, you may at your option
|
355 |
-
remove any additional permissions from that copy, or from any part of
|
356 |
-
it. (Additional permissions may be written to require their own
|
357 |
-
removal in certain cases when you modify the work.) You may place
|
358 |
-
additional permissions on material, added by you to a covered work,
|
359 |
-
for which you have or can give appropriate copyright permission.
|
360 |
-
|
361 |
-
Notwithstanding any other provision of this License, for material you
|
362 |
-
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
-
that material) supplement the terms of this License with terms:
|
364 |
-
|
365 |
-
a) Disclaiming warranty or limiting liability differently from the
|
366 |
-
terms of sections 15 and 16 of this License; or
|
367 |
-
|
368 |
-
b) Requiring preservation of specified reasonable legal notices or
|
369 |
-
author attributions in that material or in the Appropriate Legal
|
370 |
-
Notices displayed by works containing it; or
|
371 |
-
|
372 |
-
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
-
requiring that modified versions of such material be marked in
|
374 |
-
reasonable ways as different from the original version; or
|
375 |
-
|
376 |
-
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
-
authors of the material; or
|
378 |
-
|
379 |
-
e) Declining to grant rights under trademark law for use of some
|
380 |
-
trade names, trademarks, or service marks; or
|
381 |
-
|
382 |
-
f) Requiring indemnification of licensors and authors of that
|
383 |
-
material by anyone who conveys the material (or modified versions of
|
384 |
-
it) with contractual assumptions of liability to the recipient, for
|
385 |
-
any liability that these contractual assumptions directly impose on
|
386 |
-
those licensors and authors.
|
387 |
-
|
388 |
-
All other non-permissive additional terms are considered "further
|
389 |
-
restrictions" within the meaning of section 10. If the Program as you
|
390 |
-
received it, or any part of it, contains a notice stating that it is
|
391 |
-
governed by this License along with a term that is a further
|
392 |
-
restriction, you may remove that term. If a license document contains
|
393 |
-
a further restriction but permits relicensing or conveying under this
|
394 |
-
License, you may add to a covered work material governed by the terms
|
395 |
-
of that license document, provided that the further restriction does
|
396 |
-
not survive such relicensing or conveying.
|
397 |
-
|
398 |
-
If you add terms to a covered work in accord with this section, you
|
399 |
-
must place, in the relevant source files, a statement of the
|
400 |
-
additional terms that apply to those files, or a notice indicating
|
401 |
-
where to find the applicable terms.
|
402 |
-
|
403 |
-
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
-
form of a separately written license, or stated as exceptions;
|
405 |
-
the above requirements apply either way.
|
406 |
-
|
407 |
-
8. Termination.
|
408 |
-
|
409 |
-
You may not propagate or modify a covered work except as expressly
|
410 |
-
provided under this License. Any attempt otherwise to propagate or
|
411 |
-
modify it is void, and will automatically terminate your rights under
|
412 |
-
this License (including any patent licenses granted under the third
|
413 |
-
paragraph of section 11).
|
414 |
-
|
415 |
-
However, if you cease all violation of this License, then your
|
416 |
-
license from a particular copyright holder is reinstated (a)
|
417 |
-
provisionally, unless and until the copyright holder explicitly and
|
418 |
-
finally terminates your license, and (b) permanently, if the copyright
|
419 |
-
holder fails to notify you of the violation by some reasonable means
|
420 |
-
prior to 60 days after the cessation.
|
421 |
-
|
422 |
-
Moreover, your license from a particular copyright holder is
|
423 |
-
reinstated permanently if the copyright holder notifies you of the
|
424 |
-
violation by some reasonable means, this is the first time you have
|
425 |
-
received notice of violation of this License (for any work) from that
|
426 |
-
copyright holder, and you cure the violation prior to 30 days after
|
427 |
-
your receipt of the notice.
|
428 |
-
|
429 |
-
Termination of your rights under this section does not terminate the
|
430 |
-
licenses of parties who have received copies or rights from you under
|
431 |
-
this License. If your rights have been terminated and not permanently
|
432 |
-
reinstated, you do not qualify to receive new licenses for the same
|
433 |
-
material under section 10.
|
434 |
-
|
435 |
-
9. Acceptance Not Required for Having Copies.
|
436 |
-
|
437 |
-
You are not required to accept this License in order to receive or
|
438 |
-
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
-
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
-
to receive a copy likewise does not require acceptance. However,
|
441 |
-
nothing other than this License grants you permission to propagate or
|
442 |
-
modify any covered work. These actions infringe copyright if you do
|
443 |
-
not accept this License. Therefore, by modifying or propagating a
|
444 |
-
covered work, you indicate your acceptance of this License to do so.
|
445 |
-
|
446 |
-
10. Automatic Licensing of Downstream Recipients.
|
447 |
-
|
448 |
-
Each time you convey a covered work, the recipient automatically
|
449 |
-
receives a license from the original licensors, to run, modify and
|
450 |
-
propagate that work, subject to this License. You are not responsible
|
451 |
-
for enforcing compliance by third parties with this License.
|
452 |
-
|
453 |
-
An "entity transaction" is a transaction transferring control of an
|
454 |
-
organization, or substantially all assets of one, or subdividing an
|
455 |
-
organization, or merging organizations. If propagation of a covered
|
456 |
-
work results from an entity transaction, each party to that
|
457 |
-
transaction who receives a copy of the work also receives whatever
|
458 |
-
licenses to the work the party's predecessor in interest had or could
|
459 |
-
give under the previous paragraph, plus a right to possession of the
|
460 |
-
Corresponding Source of the work from the predecessor in interest, if
|
461 |
-
the predecessor has it or can get it with reasonable efforts.
|
462 |
-
|
463 |
-
You may not impose any further restrictions on the exercise of the
|
464 |
-
rights granted or affirmed under this License. For example, you may
|
465 |
-
not impose a license fee, royalty, or other charge for exercise of
|
466 |
-
rights granted under this License, and you may not initiate litigation
|
467 |
-
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
-
any patent claim is infringed by making, using, selling, offering for
|
469 |
-
sale, or importing the Program or any portion of it.
|
470 |
-
|
471 |
-
11. Patents.
|
472 |
-
|
473 |
-
A "contributor" is a copyright holder who authorizes use under this
|
474 |
-
License of the Program or a work on which the Program is based. The
|
475 |
-
work thus licensed is called the contributor's "contributor version".
|
476 |
-
|
477 |
-
A contributor's "essential patent claims" are all patent claims
|
478 |
-
owned or controlled by the contributor, whether already acquired or
|
479 |
-
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
-
by this License, of making, using, or selling its contributor version,
|
481 |
-
but do not include claims that would be infringed only as a
|
482 |
-
consequence of further modification of the contributor version. For
|
483 |
-
purposes of this definition, "control" includes the right to grant
|
484 |
-
patent sublicenses in a manner consistent with the requirements of
|
485 |
-
this License.
|
486 |
-
|
487 |
-
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
-
patent license under the contributor's essential patent claims, to
|
489 |
-
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
-
propagate the contents of its contributor version.
|
491 |
-
|
492 |
-
In the following three paragraphs, a "patent license" is any express
|
493 |
-
agreement or commitment, however denominated, not to enforce a patent
|
494 |
-
(such as an express permission to practice a patent or covenant not to
|
495 |
-
sue for patent infringement). To "grant" such a patent license to a
|
496 |
-
party means to make such an agreement or commitment not to enforce a
|
497 |
-
patent against the party.
|
498 |
-
|
499 |
-
If you convey a covered work, knowingly relying on a patent license,
|
500 |
-
and the Corresponding Source of the work is not available for anyone
|
501 |
-
to copy, free of charge and under the terms of this License, through a
|
502 |
-
publicly available network server or other readily accessible means,
|
503 |
-
then you must either (1) cause the Corresponding Source to be so
|
504 |
-
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
-
patent license for this particular work, or (3) arrange, in a manner
|
506 |
-
consistent with the requirements of this License, to extend the patent
|
507 |
-
license to downstream recipients. "Knowingly relying" means you have
|
508 |
-
actual knowledge that, but for the patent license, your conveying the
|
509 |
-
covered work in a country, or your recipient's use of the covered work
|
510 |
-
in a country, would infringe one or more identifiable patents in that
|
511 |
-
country that you have reason to believe are valid.
|
512 |
-
|
513 |
-
If, pursuant to or in connection with a single transaction or
|
514 |
-
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
-
covered work, and grant a patent license to some of the parties
|
516 |
-
receiving the covered work authorizing them to use, propagate, modify
|
517 |
-
or convey a specific copy of the covered work, then the patent license
|
518 |
-
you grant is automatically extended to all recipients of the covered
|
519 |
-
work and works based on it.
|
520 |
-
|
521 |
-
A patent license is "discriminatory" if it does not include within
|
522 |
-
the scope of its coverage, prohibits the exercise of, or is
|
523 |
-
conditioned on the non-exercise of one or more of the rights that are
|
524 |
-
specifically granted under this License. You may not convey a covered
|
525 |
-
work if you are a party to an arrangement with a third party that is
|
526 |
-
in the business of distributing software, under which you make payment
|
527 |
-
to the third party based on the extent of your activity of conveying
|
528 |
-
the work, and under which the third party grants, to any of the
|
529 |
-
parties who would receive the covered work from you, a discriminatory
|
530 |
-
patent license (a) in connection with copies of the covered work
|
531 |
-
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
-
for and in connection with specific products or compilations that
|
533 |
-
contain the covered work, unless you entered into that arrangement,
|
534 |
-
or that patent license was granted, prior to 28 March 2007.
|
535 |
-
|
536 |
-
Nothing in this License shall be construed as excluding or limiting
|
537 |
-
any implied license or other defenses to infringement that may
|
538 |
-
otherwise be available to you under applicable patent law.
|
539 |
-
|
540 |
-
12. No Surrender of Others' Freedom.
|
541 |
-
|
542 |
-
If conditions are imposed on you (whether by court order, agreement or
|
543 |
-
otherwise) that contradict the conditions of this License, they do not
|
544 |
-
excuse you from the conditions of this License. If you cannot convey a
|
545 |
-
covered work so as to satisfy simultaneously your obligations under this
|
546 |
-
License and any other pertinent obligations, then as a consequence you may
|
547 |
-
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
-
to collect a royalty for further conveying from those to whom you convey
|
549 |
-
the Program, the only way you could satisfy both those terms and this
|
550 |
-
License would be to refrain entirely from conveying the Program.
|
551 |
-
|
552 |
-
13. Use with the GNU Affero General Public License.
|
553 |
-
|
554 |
-
Notwithstanding any other provision of this License, you have
|
555 |
-
permission to link or combine any covered work with a work licensed
|
556 |
-
under version 3 of the GNU Affero General Public License into a single
|
557 |
-
combined work, and to convey the resulting work. The terms of this
|
558 |
-
License will continue to apply to the part which is the covered work,
|
559 |
-
but the special requirements of the GNU Affero General Public License,
|
560 |
-
section 13, concerning interaction through a network will apply to the
|
561 |
-
combination as such.
|
562 |
-
|
563 |
-
14. Revised Versions of this License.
|
564 |
-
|
565 |
-
The Free Software Foundation may publish revised and/or new versions of
|
566 |
-
the GNU General Public License from time to time. Such new versions will
|
567 |
-
be similar in spirit to the present version, but may differ in detail to
|
568 |
-
address new problems or concerns.
|
569 |
-
|
570 |
-
Each version is given a distinguishing version number. If the
|
571 |
-
Program specifies that a certain numbered version of the GNU General
|
572 |
-
Public License "or any later version" applies to it, you have the
|
573 |
-
option of following the terms and conditions either of that numbered
|
574 |
-
version or of any later version published by the Free Software
|
575 |
-
Foundation. If the Program does not specify a version number of the
|
576 |
-
GNU General Public License, you may choose any version ever published
|
577 |
-
by the Free Software Foundation.
|
578 |
-
|
579 |
-
If the Program specifies that a proxy can decide which future
|
580 |
-
versions of the GNU General Public License can be used, that proxy's
|
581 |
-
public statement of acceptance of a version permanently authorizes you
|
582 |
-
to choose that version for the Program.
|
583 |
-
|
584 |
-
Later license versions may give you additional or different
|
585 |
-
permissions. However, no additional obligations are imposed on any
|
586 |
-
author or copyright holder as a result of your choosing to follow a
|
587 |
-
later version.
|
588 |
-
|
589 |
-
15. Disclaimer of Warranty.
|
590 |
-
|
591 |
-
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
-
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
-
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
-
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
-
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
-
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
-
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
-
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
-
|
600 |
-
16. Limitation of Liability.
|
601 |
-
|
602 |
-
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
-
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
-
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
-
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
-
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
-
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
-
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
-
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
-
SUCH DAMAGES.
|
611 |
-
|
612 |
-
17. Interpretation of Sections 15 and 16.
|
613 |
-
|
614 |
-
If the disclaimer of warranty and limitation of liability provided
|
615 |
-
above cannot be given local legal effect according to their terms,
|
616 |
-
reviewing courts shall apply local law that most closely approximates
|
617 |
-
an absolute waiver of all civil liability in connection with the
|
618 |
-
Program, unless a warranty or assumption of liability accompanies a
|
619 |
-
copy of the Program in return for a fee.
|
620 |
-
|
621 |
-
END OF TERMS AND CONDITIONS
|
622 |
-
|
623 |
-
How to Apply These Terms to Your New Programs
|
624 |
-
|
625 |
-
If you develop a new program, and you want it to be of the greatest
|
626 |
-
possible use to the public, the best way to achieve this is to make it
|
627 |
-
free software which everyone can redistribute and change under these terms.
|
628 |
-
|
629 |
-
To do so, attach the following notices to the program. It is safest
|
630 |
-
to attach them to the start of each source file to most effectively
|
631 |
-
state the exclusion of warranty; and each file should have at least
|
632 |
-
the "copyright" line and a pointer to where the full notice is found.
|
633 |
-
|
634 |
-
{one line to give the program's name and a brief idea of what it does.}
|
635 |
-
Copyright (C) {year} {name of author}
|
636 |
-
|
637 |
-
This program is free software: you can redistribute it and/or modify
|
638 |
-
it under the terms of the GNU General Public License as published by
|
639 |
-
the Free Software Foundation, either version 3 of the License, or
|
640 |
-
(at your option) any later version.
|
641 |
-
|
642 |
-
This program is distributed in the hope that it will be useful,
|
643 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
644 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
-
GNU General Public License for more details.
|
646 |
-
|
647 |
-
You should have received a copy of the GNU General Public License
|
648 |
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
649 |
-
|
650 |
-
Also add information on how to contact you by electronic and paper mail.
|
651 |
-
|
652 |
-
If the program does terminal interaction, make it output a short
|
653 |
-
notice like this when it starts in an interactive mode:
|
654 |
-
|
655 |
-
{project} Copyright (C) {year} {fullname}
|
656 |
-
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
-
This is free software, and you are welcome to redistribute it
|
658 |
-
under certain conditions; type `show c' for details.
|
659 |
-
|
660 |
-
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
-
parts of the General Public License. Of course, your program's commands
|
662 |
-
might be different; for a GUI interface, you would use an "about box".
|
663 |
-
|
664 |
-
You should also get your employer (if you work as a programmer) or school,
|
665 |
-
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
-
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
-
<http://www.gnu.org/licenses/>.
|
668 |
-
|
669 |
-
The GNU General Public License does not permit incorporating your program
|
670 |
-
into proprietary programs. If your program is a subroutine library, you
|
671 |
-
may consider it more useful to permit linking proprietary applications with
|
672 |
-
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
-
Public License instead of this License. But first, please read
|
674 |
-
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freemius/README.md
DELETED
@@ -1,282 +0,0 @@
|
|
1 |
-
Freemius WordPress SDK
|
2 |
-
======================
|
3 |
-
|
4 |
-
Welcome to the official repository for the Freemius SDK! Adding the SDK to your WordPress plugin, theme, or add-ons, enables all the benefits that come with using the [Freemius platform](https://freemius.com) such as:
|
5 |
-
|
6 |
-
* [Software Licensing](https://freemius.com/wordpress/software-licensing/)
|
7 |
-
* [Secure Checkout](https://freemius.com/wordpress/checkout/)
|
8 |
-
* [Subscriptions](https://freemius.com/wordpress/recurring-payments-subscriptions/)
|
9 |
-
* [Automatic Updates](https://freemius.com/wordpress/automatic-software-updates/)
|
10 |
-
* [Seamless EU VAT](https://freemius.com/wordpress/collecting-eu-vat-europe/)
|
11 |
-
* [Cart Abandonment Recovery](https://freemius.com/wordpress/cart-abandonment-recovery/)
|
12 |
-
* [Affiliate Platform](https://freemius.com/wordpress/affiliate-platform/)
|
13 |
-
* [Analytics & Usage Tracking](https://freemius.com/wordpress/insights/)
|
14 |
-
* [User Dashboard](https://freemius.com/wordpress/user-dashboard/)
|
15 |
-
|
16 |
-
* [Monetization](https://freemius.com/wordpress/)
|
17 |
-
* [Analytics](https://freemius.com/wordpress/insights/)
|
18 |
-
* [More...](https://freemius.com/wordpress/features-comparison/)
|
19 |
-
|
20 |
-
Freemius truly empowers developers to create prosperous subscription-based businesses.
|
21 |
-
|
22 |
-
If you're new to Freemius then we recommend taking a look at our [Getting Started](https://freemius.com/help/documentation/getting-started/) guide first.
|
23 |
-
|
24 |
-
If you're a WordPress plugin or theme developer and are interested in monetizing with Freemius then you can [sign-up for a FREE account](https://dashboard.freemius.com/register/):
|
25 |
-
|
26 |
-
https://dashboard.freemius.com/register/
|
27 |
-
|
28 |
-
Once you have your account setup and are familiar with how it all works you're ready to begin [integrating Freemius](https://freemius.com/help/documentation/wordpress-sdk/integrating-freemius-sdk/) into your WordPress product
|
29 |
-
|
30 |
-
You can see some of the existing WordPress.org plugins & themes that are already utilizing the power of Freemius here:
|
31 |
-
|
32 |
-
* https://profiles.wordpress.org/freemius/#content-plugins
|
33 |
-
* https://includewp.com/freemius/#focus
|
34 |
-
|
35 |
-
## Code Documentation
|
36 |
-
|
37 |
-
You can find the SDK's documentation here:
|
38 |
-
https://freemius.com/help/documentation/wordpress-sdk/
|
39 |
-
|
40 |
-
## Integrating & Initializing the SDK
|
41 |
-
|
42 |
-
As part of the integration process, you'll need to [add the latest version](https://freemius.com/help/documentation/getting-started/#add_the_latest_wordpress_sdk_into_your_product) of the Freemius SDK into your WordPress project.
|
43 |
-
|
44 |
-
Then, when you've completed the [SDK integration form](https://freemius.com/help/documentation/getting-started/#fill_out_the_sdk_integration_form) a snippet of code is generated which you'll need to copy and paste into the top of your main plugin's PHP file, right after the plugin's header comment.
|
45 |
-
|
46 |
-
Note: For themes, this will be in the root `functions.php` file instead.
|
47 |
-
|
48 |
-
A typical SDK snippet will look similar to the following (your particular snippet may differ slightly depending on your integration):
|
49 |
-
|
50 |
-
```php
|
51 |
-
if ( ! function_exists( 'my_prefix_fs' ) ) {
|
52 |
-
// Create a helper function for easy SDK access.
|
53 |
-
function my_prefix_fs() {
|
54 |
-
global $my_prefix_fs;
|
55 |
-
|
56 |
-
if ( ! isset( $my_prefix_fs ) ) {
|
57 |
-
// Include Freemius SDK.
|
58 |
-
require_once dirname(__FILE__) . '/freemius/start.php';
|
59 |
-
|
60 |
-
$my_prefix_fs = fs_dynamic_init( array(
|
61 |
-
'id' => '1234',
|
62 |
-
'slug' => 'my-new-plugin',
|
63 |
-
'premium_slug' => 'my-new-plugin-premium',
|
64 |
-
'type' => 'plugin',
|
65 |
-
'public_key' => 'pk_bAEfta69seKymZzmf2xtqq8QXHz9y',
|
66 |
-
'is_premium' => true,
|
67 |
-
// If your plugin is a serviceware, set this option to false.
|
68 |
-
'has_premium_version' => true,
|
69 |
-
'has_paid_plans' => true,
|
70 |
-
'is_org_compliant' => true,
|
71 |
-
'menu' => array(
|
72 |
-
'slug' => 'my-new-plugin',
|
73 |
-
'parent' => array(
|
74 |
-
'slug' => 'options-general.php',
|
75 |
-
),
|
76 |
-
),
|
77 |
-
// Set the SDK to work in a sandbox mode (for development & testing).
|
78 |
-
// IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
|
79 |
-
'secret_key' => 'sk_ubb4yN3mzqGR2x8#P7r5&@*xC$utE',
|
80 |
-
) );
|
81 |
-
}
|
82 |
-
|
83 |
-
return $my_prefix_fs;
|
84 |
-
}
|
85 |
-
|
86 |
-
// Init Freemius.
|
87 |
-
my_prefix_fs();
|
88 |
-
// Signal that SDK was initiated.
|
89 |
-
do_action( 'my_prefix_fs_loaded' );
|
90 |
-
}
|
91 |
-
|
92 |
-
```
|
93 |
-
|
94 |
-
## Usage example
|
95 |
-
|
96 |
-
You can call anySDK methods by prefixing them with the shortcode function for your particular plugin/theme (specified when completing the SDK integration form in the Developer Dashboard):
|
97 |
-
|
98 |
-
```php
|
99 |
-
<?php my_prefix_fs()->get_upgrade_url(); ?>
|
100 |
-
```
|
101 |
-
|
102 |
-
Or when calling Freemius multiple times in a scope, it's recommended to use it with the global variable:
|
103 |
-
|
104 |
-
```php
|
105 |
-
<?php
|
106 |
-
global $my_prefix_fs;
|
107 |
-
$my_prefix_fs->get_account_url();
|
108 |
-
?>
|
109 |
-
```
|
110 |
-
|
111 |
-
There are many other SDK methods available that you can use to enhance the functionality of your WordPress product. Some of the more common use-cases are covered in the [Freemius SDK Gists](https://freemius.com/help/documentation/wordpress-sdk/gists/) documentation.
|
112 |
-
|
113 |
-
## Adding license based logic examples
|
114 |
-
|
115 |
-
Add marketing content to encourage your users to upgrade for your paid version:
|
116 |
-
|
117 |
-
```php
|
118 |
-
<?php
|
119 |
-
if ( my_prefix_fs()->is_not_paying() ) {
|
120 |
-
echo '<section><h1>' . esc_html__('Awesome Premium Features', 'my-plugin-slug') . '</h1>';
|
121 |
-
echo '<a href="' . my_prefix_fs()->get_upgrade_url() . '">' .
|
122 |
-
esc_html__('Upgrade Now!', 'my-plugin-slug') .
|
123 |
-
'</a>';
|
124 |
-
echo '</section>';
|
125 |
-
}
|
126 |
-
?>
|
127 |
-
```
|
128 |
-
|
129 |
-
Add logic which will only be available in your premium plugin version:
|
130 |
-
|
131 |
-
```php
|
132 |
-
<?php
|
133 |
-
// This "if" block will be auto removed from the Free version.
|
134 |
-
if ( my_prefix_fs()->is__premium_only() ) {
|
135 |
-
|
136 |
-
// ... premium only logic ...
|
137 |
-
|
138 |
-
}
|
139 |
-
?>
|
140 |
-
```
|
141 |
-
|
142 |
-
To add a function which will only be available in your premium plugin version, simply add __premium_only as the suffix of the function name. Just make sure that all lines that call that method directly or by hooks, are also wrapped in premium only logic:
|
143 |
-
|
144 |
-
```php
|
145 |
-
<?php
|
146 |
-
class My_Plugin {
|
147 |
-
function init() {
|
148 |
-
...
|
149 |
-
|
150 |
-
// This "if" block will be auto removed from the free version.
|
151 |
-
if ( my_prefix_fs()->is__premium_only() ) {
|
152 |
-
// Init premium version.
|
153 |
-
$this->admin_init__premium_only();
|
154 |
-
|
155 |
-
add_action( 'admin_init', array( &$this, 'admin_init_hook__premium_only' );
|
156 |
-
}
|
157 |
-
|
158 |
-
...
|
159 |
-
}
|
160 |
-
|
161 |
-
// This method will be only included in the premium version.
|
162 |
-
function admin_init__premium_only() {
|
163 |
-
...
|
164 |
-
}
|
165 |
-
|
166 |
-
// This method will be only included in the premium version.
|
167 |
-
function admin_init_hook__premium_only() {
|
168 |
-
...
|
169 |
-
}
|
170 |
-
}
|
171 |
-
?>
|
172 |
-
```
|
173 |
-
|
174 |
-
Add logic which will only be executed for customers in your 'professional' plan:
|
175 |
-
|
176 |
-
```php
|
177 |
-
<?php
|
178 |
-
if ( my_prefix_fs()->is_plan('professional', true) ) {
|
179 |
-
// .. logic related to Professional plan only ...
|
180 |
-
}
|
181 |
-
?>
|
182 |
-
```
|
183 |
-
|
184 |
-
Add logic which will only be executed for customers in your 'professional' plan or higher plans:
|
185 |
-
|
186 |
-
```php
|
187 |
-
<?php
|
188 |
-
if ( my_prefix_fs()->is_plan('professional') ) {
|
189 |
-
// ... logic related to Professional plan and higher plans ...
|
190 |
-
}
|
191 |
-
?>
|
192 |
-
```
|
193 |
-
|
194 |
-
Add logic which will only be available in your premium plugin version AND will only be executed for customers in your 'professional' plan (and higher plans):
|
195 |
-
|
196 |
-
```php
|
197 |
-
<?php
|
198 |
-
// This "if" block will be auto removed from the Free version.
|
199 |
-
if ( my_prefix_fs()->is_plan__premium_only('professional') ) {
|
200 |
-
// ... logic related to Professional plan and higher plans ...
|
201 |
-
}
|
202 |
-
?>
|
203 |
-
```
|
204 |
-
|
205 |
-
Add logic only for users in trial:
|
206 |
-
|
207 |
-
```php
|
208 |
-
<?php
|
209 |
-
if ( my_prefix_fs()->is_trial() ) {
|
210 |
-
// ... logic for users in trial ...
|
211 |
-
}
|
212 |
-
?>
|
213 |
-
```
|
214 |
-
|
215 |
-
Add logic for specified paid plan:
|
216 |
-
|
217 |
-
```php
|
218 |
-
<?php
|
219 |
-
// This "if" block will be auto removed from the Free version.
|
220 |
-
if ( my_prefix_fs()->is__premium_only() ) {
|
221 |
-
if ( my_prefix_fs()->is_plan( 'professional', true ) ) {
|
222 |
-
|
223 |
-
// ... logic related to Professional plan only ...
|
224 |
-
|
225 |
-
} else if ( my_prefix_fs()->is_plan( 'business' ) ) {
|
226 |
-
|
227 |
-
// ... logic related to Business plan and higher plans ...
|
228 |
-
|
229 |
-
}
|
230 |
-
}
|
231 |
-
?>
|
232 |
-
```
|
233 |
-
|
234 |
-
## Excluding files and folders from the free plugin version
|
235 |
-
There are [two ways](https://freemius.com/help/documentation/wordpress-sdk/software-licensing/#excluding_files_and_folders_from_the_free_plugin_version) to exclude files from your free version.
|
236 |
-
|
237 |
-
1. Add `__premium_only` just before the file extension. For example, functions__premium_only.php will be only included in the premium plugin version. This works for all types of files, not only PHP.
|
238 |
-
2. Add `@fs_premium_only` a special meta tag to the plugin's main PHP file header. Example:
|
239 |
-
```php
|
240 |
-
<?php
|
241 |
-
/**
|
242 |
-
* Plugin Name: My Very Awesome Plugin
|
243 |
-
* Plugin URI: http://my-awesome-plugin.com
|
244 |
-
* Description: Create and manage Awesomeness right in WordPress.
|
245 |
-
* Version: 1.0.0
|
246 |
-
* Author: Awesomattic
|
247 |
-
* Author URI: http://my-awesome-plugin.com/me/
|
248 |
-
* License: GPLv2
|
249 |
-
* Text Domain: myplugin
|
250 |
-
* Domain Path: /langs
|
251 |
-
*
|
252 |
-
* @fs_premium_only /lib/functions.php, /premium-files/
|
253 |
-
*/
|
254 |
-
|
255 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
256 |
-
exit;
|
257 |
-
}
|
258 |
-
|
259 |
-
// ... my code ...
|
260 |
-
?>
|
261 |
-
```
|
262 |
-
In the example plugin header above, the file `/lib/functions.php` and the directory `/premium-files/` will be removed from the free plugin version.
|
263 |
-
|
264 |
-
# WordPress.org Compliance
|
265 |
-
Based on [WordPress.org Guidelines](https://wordpress.org/plugins/about/guidelines/) you are not allowed to submit a plugin that has premium code in it:
|
266 |
-
> All code hosted by WordPress.org servers must be free and fully-functional. If you want to sell advanced features for a plugin (such as a "pro" version), then you must sell and serve that code from your own site, we will not host it on our servers.
|
267 |
-
|
268 |
-
Therefore, if you want to deploy your free plugin's version to WordPress.org, make sure you wrap all your premium code with `if ( my_prefix_fs()->{{ method }}__premium_only() )` or use [some of the other methods](https://freemius.com/help/documentation/wordpress-sdk/software-licensing/) provided by the SDK to exclude premium features & files from the free version.
|
269 |
-
|
270 |
-
## Deployment
|
271 |
-
Zip your Freemius product’s root folder and [upload it in the Deployment section](https://freemius.com/help/documentation/selling-with-freemius/deployment/) in the *Freemius Developer's Dashboard*.
|
272 |
-
The plugin/theme will automatically be scanned and processed by a custom-developed *PHP Processor* which will auto-generate two versions of your plugin:
|
273 |
-
|
274 |
-
1. **Premium version**: Identical to your uploaded version, including all code (except your `secret_key`). Will be enabled for download ONLY for your paying or in trial customers.
|
275 |
-
2. **Free version**: The code stripped from all your paid features (based on the logic added wrapped in `{ method }__premium_only()`).
|
276 |
-
|
277 |
-
The free version is the one that you should give your users to download. Therefore, download the free generated version and upload to your site. Or, if your plugin was WordPress.org compliant and you made sure to exclude all your premium code with the different provided techniques, you can deploy the downloaded free version to the .org repo.
|
278 |
-
|
279 |
-
## License
|
280 |
-
Copyright (c) Freemius®, Inc.
|
281 |
-
|
282 |
-
Licensed under the GNU general public license (version 3).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freemius/assets/css/admin/account.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
label.fs-tag,span.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn,span.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-info,span.fs-tag.fs-info{background:#00a0d2}label.fs-tag.fs-success,span.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error,span.fs-tag.fs-error{background:#dc3232}.fs-notice[data-id="license_not_whitelabeled"].success,.fs-notice[data-id="license_whitelabeled"].success{color:inherit;border-left-color:#00a0d2}.fs-notice[data-id="license_not_whitelabeled"].success label.fs-plugin-title,.fs-notice[data-id="license_whitelabeled"].success label.fs-plugin-title{display:none}#fs_account .postbox,#fs_account .widefat{max-width:800px}#fs_account h3{font-size:1.3em;padding:12px 15px;margin:0 0 12px 0;line-height:1.4;border-bottom:1px solid #F1F1F1}#fs_account h3 .dashicons{width:26px;height:26px;font-size:1.3em}#fs_account i.dashicons{font-size:1.2em;height:1.2em;width:1.2em}#fs_account .dashicons{vertical-align:middle}#fs_account .fs-header-actions{position:absolute;top:17px;right:15px;font-size:0.9em}#fs_account .fs-header-actions ul{margin:0}#fs_account .fs-header-actions li{float:left}#fs_account .fs-header-actions li form{display:inline-block}#fs_account .fs-header-actions li a{text-decoration:none}#fs_account_details .button-group{float:right}.rtl #fs_account .fs-header-actions{left:15px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table tr td:first-child{text-align:right}.fs-key-value-table tr td:first-child nobr{font-weight:bold}.fs-key-value-table tr td:first-child form{display:block}.fs-key-value-table tr td.fs-right{text-align:right}.fs-key-value-table tr.fs-odd{background:#ebebeb}.fs-key-value-table td,.fs-key-value-table th{padding:10px}.fs-key-value-table code{line-height:28px}.fs-key-value-table var,.fs-key-value-table code,.fs-key-value-table input[type="text"]{color:#0073AA;font-size:16px;background:none}.fs-key-value-table input[type="text"]{width:100%;font-weight:bold}.fs-field-beta_program label{margin-left:7px}label.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error{background:#dc3232}#fs_sites .fs-scrollable-table .fs-table-body{max-height:200px;overflow:auto;border:1px solid #e5e5e5}#fs_sites .fs-scrollable-table .fs-table-body>table.widefat{border:none !important}#fs_sites .fs-scrollable-table .fs-main-column{width:100%}#fs_sites .fs-scrollable-table .fs-site-details td:first-of-type{text-align:right;color:grey;width:1px}#fs_sites .fs-scrollable-table .fs-site-details td:last-of-type{text-align:right}#fs_sites .fs-scrollable-table .fs-install-details table tr td{width:1px;white-space:nowrap}#fs_sites .fs-scrollable-table .fs-install-details table tr td:last-of-type{width:auto}#fs_addons h3{border:none;margin-bottom:0;padding:4px 5px}#fs_addons td{vertical-align:middle}#fs_addons thead{white-space:nowrap}#fs_addons td:first-child,#fs_addons th:first-child{text-align:left;font-weight:bold}#fs_addons td:last-child,#fs_addons th:last-child{text-align:right}#fs_addons th{font-weight:bold}#fs_billing_address{width:100%}#fs_billing_address tr td{width:50%;padding:5px}#fs_billing_address tr:first-of-type td{padding-top:0}#fs_billing_address span{font-weight:bold}#fs_billing_address input,#fs_billing_address select{display:block;width:100%;margin-top:5px}#fs_billing_address input::-moz-placeholder,#fs_billing_address select::-moz-placeholder{color:transparent;opacity:1}#fs_billing_address input:-ms-input-placeholder,#fs_billing_address select:-ms-input-placeholder{color:transparent}#fs_billing_address input::-webkit-input-placeholder,#fs_billing_address select::-webkit-input-placeholder{color:transparent}#fs_billing_address input.fs-read-mode,#fs_billing_address select.fs-read-mode{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode td span{display:none}#fs_billing_address.fs-read-mode input,#fs_billing_address.fs-read-mode select{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode input::-moz-placeholder,#fs_billing_address.fs-read-mode select::-moz-placeholder{color:#ccc;opacity:1}#fs_billing_address.fs-read-mode input:-ms-input-placeholder,#fs_billing_address.fs-read-mode select:-ms-input-placeholder{color:#ccc}#fs_billing_address.fs-read-mode input::-webkit-input-placeholder,#fs_billing_address.fs-read-mode select::-webkit-input-placeholder{color:#ccc}#fs_billing_address button{display:block;width:100%}
|
|
freemius/assets/css/admin/add-ons.css
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
.fs-badge{position:absolute;top:10px;right:0;background:#71ae00;color:white;text-transform:uppercase;padding:5px 10px;-moz-border-radius:3px 0 0 3px;-webkit-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;font-weight:bold;border-right:0;-moz-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);box-shadow:0 2px 1px -1px rgba(0,0,0,0.3)}#fs_addons .fs-cards-list{list-style:none}#fs_addons .fs-cards-list .fs-card{float:left;height:152px;width:310px;padding:0;margin:0 0 30px 30px;font-size:14px;list-style:none;border:1px solid #ddd;cursor:pointer;position:relative}#fs_addons .fs-cards-list .fs-card .fs-overlay{position:absolute;left:0;right:0;bottom:0;top:0;z-index:9}#fs_addons .fs-cards-list .fs-card .fs-inner{background-color:#fff;overflow:hidden;height:100%;position:relative}#fs_addons .fs-cards-list .fs-card .fs-inner>ul{-moz-transition:all,0.15s;-o-transition:all,0.15s;-ms-transition:all,0.15s;-webkit-transition:all,0.15s;transition:all,0.15s;left:0;right:0;top:0;position:absolute}#fs_addons .fs-cards-list .fs-card .fs-inner>ul>li{list-style:none;line-height:18px;padding:0 15px;width:100%;display:block;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-card-banner{padding:0;margin:0;line-height:0;display:block;height:100px;background-repeat:repeat-x;background-size:100% 100%;-moz-transition:all,0.15s;-o-transition:all,0.15s;-ms-transition:all,0.15s;-webkit-transition:all,0.15s;transition:all,0.15s}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-card-banner .fs-badge.fs-installed-addon-badge{font-size:1.02em;line-height:1.3em}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-title{margin:10px 0 0 0;height:18px;overflow:hidden;color:#000;white-space:nowrap;text-overflow:ellipsis;font-weight:bold}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-offer{font-size:0.9em}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-description{background-color:#f9f9f9;padding:10px 15px 100px 15px;border-top:1px solid #eee;margin:0 0 10px 0;color:#777}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-tag{position:absolute;top:10px;right:0px;background:greenyellow;display:block;padding:2px 10px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.3);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.3);box-shadow:1px 1px 1px rgba(0,0,0,0.3);text-transform:uppercase;font-size:0.9em;font-weight:bold}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-cta .button,#fs_addons .fs-cards-list .fs-card .fs-inner .fs-cta .button-group{position:absolute;top:112px;right:10px}@media screen and (min-width: 960px){#fs_addons .fs-cards-list .fs-card:hover .fs-overlay{border:2px solid #29abe1;margin-left:-1px;margin-top:-1px}#fs_addons .fs-cards-list .fs-card:hover .fs-inner ul{top:-100px}#fs_addons .fs-cards-list .fs-card:hover .fs-inner .fs-title,#fs_addons .fs-cards-list .fs-card:hover .fs-inner .fs-offer{color:#29abe1}}
|
2 |
-
#TB_window,#TB_window iframe{width:821px !important}#plugin-information .fyi{width:266px !important}#plugin-information #section-holder{margin-right:299px}#plugin-information #section-description h2,#plugin-information #section-description h3,#plugin-information #section-description p,#plugin-information #section-description b,#plugin-information #section-description i,#plugin-information #section-description blockquote,#plugin-information #section-description li,#plugin-information #section-description ul,#plugin-information #section-description ol{clear:none}#plugin-information #section-description iframe{max-width:100%}#plugin-information #section-description .fs-selling-points{padding-bottom:10px;border-bottom:1px solid #ddd}#plugin-information #section-description .fs-selling-points ul{margin:0}#plugin-information #section-description .fs-selling-points ul li{padding:0;list-style:none outside none}#plugin-information #section-description .fs-selling-points ul li i.dashicons{color:#71ae00;font-size:3em;vertical-align:middle;line-height:30px;float:left;margin:0 0 0 -15px}#plugin-information #section-description .fs-selling-points ul li h3{margin:1em 30px !important}#plugin-information #section-description .fs-screenshots:after{content:"";display:table;clear:both}#plugin-information #section-description .fs-screenshots ul{list-style:none;margin:0}#plugin-information #section-description .fs-screenshots ul li{width:225px;height:225px;float:left;margin-bottom:20px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}#plugin-information #section-description .fs-screenshots ul li a{display:block;width:100%;height:100%;border:1px solid;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);background-size:cover}#plugin-information #section-description .fs-screenshots ul li.odd{margin-right:20px}#plugin-information .plugin-information-pricing{margin:-16px;border-bottom:1px solid #ddd}#plugin-information .plugin-information-pricing .fs-plan h3{margin-top:0;padding:20px;font-size:16px}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper{border-bottom:1px solid #ddd}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab{cursor:pointer;position:relative;padding:0 10px;font-size:0.9em}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab label{text-transform:uppercase;color:green;background:greenyellow;position:absolute;left:-1px;right:-1px;bottom:100%;border:1px solid darkgreen;padding:2px;text-align:center;font-size:0.9em;line-height:1em}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab.nav-tab-active{cursor:default;background:#fffeec;border-bottom-color:#fffeec}#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle h3{background:#fffeec;margin:0;padding-bottom:0;color:#0073aa}#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle .nav-tab-wrapper,#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle .fs-billing-frequency{display:none}#plugin-information .plugin-information-pricing .fs-plan .fs-pricing-body{background:#fffeec;padding:20px}#plugin-information .plugin-information-pricing .fs-plan .button{width:100%;text-align:center;font-weight:bold;text-transform:uppercase;font-size:1.1em}#plugin-information .plugin-information-pricing .fs-plan label{white-space:nowrap}#plugin-information .plugin-information-pricing .fs-plan var{font-style:normal}#plugin-information .plugin-information-pricing .fs-plan .fs-billing-frequency,#plugin-information .plugin-information-pricing .fs-plan .fs-annual-discount{text-align:center;display:block;font-weight:bold;margin-bottom:10px;text-transform:uppercase;background:#F3F3F3;padding:2px;border:1px solid #ccc}#plugin-information .plugin-information-pricing .fs-plan .fs-annual-discount{text-transform:none;color:green;background:greenyellow}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms{font-size:0.9em}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms i{float:left;margin:0 0 0 -15px}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms li{margin:10px 0 0 0}#plugin-information #section-features .fs-features{margin:-20px -26px}#plugin-information #section-features table{width:100%;border-spacing:0;border-collapse:separate}#plugin-information #section-features table thead th{padding:10px 0}#plugin-information #section-features table thead .fs-price{color:#71ae00;font-weight:normal;display:block;text-align:center}#plugin-information #section-features table tbody td{border-top:1px solid #ccc;padding:10px 0;text-align:center;width:100px;color:#71ae00}#plugin-information #section-features table tbody td:first-child{text-align:left;width:auto;color:inherit;padding-left:26px}#plugin-information #section-features table tbody tr.fs-odd td{background:#fefefe}#plugin-information #section-features .dashicons-yes{width:30px;height:30px;font-size:30px}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .button-group .button,#plugin-information .fs-dropdown .button-group .button{position:relative;width:auto;top:0;right:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .button-group .button:focus,#plugin-information .fs-dropdown .button-group .button:focus{z-index:10}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .button-group .fs-dropdown-arrow,#plugin-information .fs-dropdown .button-group .fs-dropdown-arrow{border-top:6px solid white;border-right:4px solid transparent;border-left:4px solid transparent;top:12px;position:relative}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active:not(.up) .button:not(.fs-dropdown-arrow-button),#plugin-information .fs-dropdown.active:not(.up) .button:not(.fs-dropdown-arrow-button){border-bottom-left-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active:not(.up) .fs-dropdown-arrow-button,#plugin-information .fs-dropdown.active:not(.up) .fs-dropdown-arrow-button{border-bottom-right-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active.up .button:not(.fs-dropdown-arrow-button),#plugin-information .fs-dropdown.active.up .button:not(.fs-dropdown-arrow-button){border-top-left-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active.up .fs-dropdown-arrow-button,#plugin-information .fs-dropdown.active.up .fs-dropdown-arrow-button{border-top-right-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list,#plugin-information .fs-dropdown .fs-dropdown-list{position:absolute;right:-1px;top:100%;margin-left:auto;padding:3px 0;border:1px solid #bfbfbf;background-color:#fff;z-index:1;width:230px;text-align:left;-moz-box-shadow:0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);-webkit-box-shadow:0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);box-shadow:0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12)}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li,#plugin-information .fs-dropdown .fs-dropdown-list li{margin:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li a,#plugin-information .fs-dropdown .fs-dropdown-list li a{display:block;padding:5px 10px;text-decoration:none;text-shadow:none}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li:hover,#plugin-information .fs-dropdown .fs-dropdown-list li:hover{background-color:#0074a3;color:#fff}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li:hover a,#plugin-information .fs-dropdown .fs-dropdown-list li:hover a{color:#fff}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown:not(.up) .fs-dropdown-list,#plugin-information .fs-dropdown:not(.up) .fs-dropdown-list{-moz-border-radius:3px 0 3px 3px;-webkit-border-radius:3px 0 3px 3px;border-radius:3px 0 3px 3px}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.up .fs-dropdown-list,#plugin-information .fs-dropdown.up .fs-dropdown-list{-moz-border-radius:3px 3px 0 3px;-webkit-border-radius:3px 3px 0 3px;border-radius:3px 3px 0 3px}#plugin-information .fs-dropdown .button-group{width:100%}#plugin-information .fs-dropdown .button-group .button{float:none;font-size:14px;font-weight:normal;text-transform:none}#plugin-information .fs-dropdown .fs-dropdown-list{margin-top:1px}#plugin-information .fs-dropdown.up .fs-dropdown-list{top:auto;bottom:100%;margin-bottom:2px}#plugin-information.wp-core-ui .fs-pricing-body .fs-dropdown .button-group{text-align:center;display:table}#plugin-information.wp-core-ui .fs-pricing-body .fs-dropdown .button-group .button{display:table-cell}#plugin-information.wp-core-ui .fs-pricing-body .fs-dropdown .button-group .button:not(.fs-dropdown-arrow-button){left:1px;width:100%}#plugin-information-footer>.button,#plugin-information-footer .fs-dropdown{position:relative;top:3px}#plugin-information-footer>.button.left,#plugin-information-footer .fs-dropdown.left{float:left}#plugin-information-footer>.right,#plugin-information-footer .fs-dropdown{float:right}@media screen and (max-width: 961px){#fs_addons .fs-cards-list .fs-card{height:265px}}
|
|
|
|
freemius/assets/css/admin/affiliation.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
@charset "UTF-8";#fs_affiliation_content_wrapper #messages{margin-top:25px}#fs_affiliation_content_wrapper h3{font-size:24px;padding:0;margin-left:0}#fs_affiliation_content_wrapper ul li{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;list-style-type:none}#fs_affiliation_content_wrapper ul li:before{content:'✓';margin-right:10px;font-weight:bold}#fs_affiliation_content_wrapper p:not(.description),#fs_affiliation_content_wrapper li,#fs_affiliation_content_wrapper label{font-size:16px !important;line-height:26px !important}#fs_affiliation_content_wrapper .button{margin-top:20px;margin-bottom:7px;line-height:35px;height:40px;font-size:16px}#fs_affiliation_content_wrapper .button#cancel_button{margin-right:5px}#fs_affiliation_content_wrapper form .input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form .input-container .input-label{font-weight:bold;display:block;width:100%}#fs_affiliation_content_wrapper form .input-container.input-container-text label,#fs_affiliation_content_wrapper form .input-container.input-container-text input,#fs_affiliation_content_wrapper form .input-container.input-container-text textarea{display:block}#fs_affiliation_content_wrapper form .input-container #add_domain,#fs_affiliation_content_wrapper form .input-container .remove-domain{text-decoration:none;display:inline-block;margin-top:3px}#fs_affiliation_content_wrapper form .input-container #add_domain:focus,#fs_affiliation_content_wrapper form .input-container .remove-domain:focus{box-shadow:none}#fs_affiliation_content_wrapper form .input-container #add_domain.disabled,#fs_affiliation_content_wrapper form .input-container .remove-domain.disabled{color:#aaa;cursor:default}#fs_affiliation_content_wrapper form #extra_domains_container .description{margin-top:0;position:relative;top:-4px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain{display:inline-block;margin-right:5px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain:last-of-type{margin-bottom:0}
|
|
freemius/assets/css/admin/checkout.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
@media screen and (max-width: 782px){#wpbody-content{padding-bottom:0 !important}}
|
|
freemius/assets/css/admin/common.css
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
.fs-badge{position:absolute;top:10px;right:0;background:#71ae00;color:white;text-transform:uppercase;padding:5px 10px;-moz-border-radius:3px 0 0 3px;-webkit-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;font-weight:bold;border-right:0;-moz-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);box-shadow:0 2px 1px -1px rgba(0,0,0,0.3)}.theme-browser .theme .fs-premium-theme-badge-container{position:absolute;right:0;top:0}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge{position:relative;top:0;margin-top:10px;text-align:center}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge.fs-premium-theme-badge{font-size:1.1em}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge.fs-beta-theme-badge{background:#00a0d2}.fs-switch{position:relative;display:inline-block;color:#ccc;text-shadow:0 1px 1px rgba(255,255,255,0.8);height:18px;padding:6px 6px 5px 6px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);background:#ececec;box-shadow:0 0 4px rgba(0,0,0,0.1),inset 0 1px 3px 0 rgba(0,0,0,0.1);cursor:pointer}.fs-switch span{display:inline-block;width:35px;text-transform:uppercase}.fs-switch .fs-toggle{position:absolute;top:1px;width:37px;height:25px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.3);border-radius:4px;background:#fff;background-color:#fff;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, #ececec), color-stop(1, #fff));background-image:-webkit-linear-gradient(top, #ececec, #fff);background-image:-moz-linear-gradient(top, #ececec, #fff);background-image:-ms-linear-gradient(top, #ececec, #fff);background-image:-o-linear-gradient(top, #ececec, #fff);background-image:linear-gradient(top, bottom, #ececec, #fff);box-shadow:inset 0 1px 0 0 rgba(255,255,255,0.5);z-index:999;-moz-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-o-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-ms-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-webkit-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1)}.fs-switch.fs-off .fs-toggle{left:2%}.fs-switch.fs-on .fs-toggle{left:54%}.fs-switch.fs-round{top:8px;padding:4px 25px;-moz-border-radius:24px;-webkit-border-radius:24px;border-radius:24px}.fs-switch.fs-round .fs-toggle{top:0;width:24px;height:24px;-moz-border-radius:24px;-webkit-border-radius:24px;border-radius:24px}.fs-switch.fs-round.fs-off .fs-toggle{left:-1px}.fs-switch.fs-round.fs-on{background:#0085ba}.fs-switch.fs-round.fs-on .fs-toggle{left:25px}.fs-switch.fs-small.fs-round{padding:1px 19px}.fs-switch.fs-small.fs-round .fs-toggle{top:0;width:18px;height:18px;-moz-border-radius:18px;-webkit-border-radius:18px;border-radius:18px}.fs-switch.fs-small.fs-round.fs-on .fs-toggle{left:19px}.fs-switch-feedback{margin-left:10px}.fs-switch-feedback.success{color:#71ae00}.rtl .fs-switch-feedback{margin-left:0;margin-right:10px}#fs_frame{line-height:0;font-size:0}.fs-full-size-wrapper{margin:40px 0 -65px -20px}@media (max-width: 600px){.fs-full-size-wrapper{margin:0 0 -65px -10px}}
|
2 |
-
.fs-notice{position:relative}.fs-notice.fs-has-title{margin-bottom:30px !important}.fs-notice.success{color:green}.fs-notice.promotion{border-color:#00a0d2 !important;background-color:#f2fcff !important}.fs-notice .fs-notice-body{margin:.5em 0;padding:2px}.fs-notice .fs-close{cursor:pointer;color:#aaa;float:right}.fs-notice .fs-close:hover{color:#666}.fs-notice .fs-close>*{margin-top:7px;display:inline-block}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;top:100%;bottom:auto;right:auto;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;left:10px;font-size:12px;font-weight:bold;cursor:auto}div.fs-notice.updated,div.fs-notice.success,div.fs-notice.promotion{display:block !important}.rtl .fs-notice .fs-close{float:left}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;-moz-box-shadow:0 2px 2px rgba(6,113,6,0.3);-webkit-box-shadow:0 2px 2px rgba(6,113,6,0.3);box-shadow:0 2px 2px rgba(6,113,6,0.3);opacity:0.95;filter:alpha(opacity=95)}.fs-secure-notice:hover{opacity:1;filter:alpha(opacity=100)}.fs-secure-notice a.fs-security-proof{color:green;text-decoration:none}@media screen and (max-width: 960px){.fs-secure-notice{left:36px}}@media screen and (max-width: 600px){.fs-secure-notice{display:none}}@media screen and (max-width: 1250px){#fs_promo_tab{display:none}}@media screen and (max-width: 782px){.fs-secure-notice{left:0;top:46px;text-align:center}}span.fs-submenu-item.fs-sub:before{content:'\21B3';padding:0 5px}.rtl span.fs-submenu-item.fs-sub:before{content:'\21B2'}.fs-submenu-item.pricing.upgrade-mode{color:greenyellow}.fs-submenu-item.pricing.trial-mode{color:#83e2ff}#adminmenu .update-plugins.fs-trial{background-color:#00b9eb}.fs-ajax-spinner{border:0;width:20px;height:20px;margin-right:5px;vertical-align:sub;display:inline-block;background:url("/wp-admin/images/wpspin_light-2x.gif");background-size:contain;margin-bottom:-2px}.wrap.fs-section h2{text-align:left}.plugins p.fs-upgrade-notice{border:0;background-color:#d54e21;padding:10px;color:#f9f9f9;margin-top:10px}
|
|
|
|
freemius/assets/css/admin/connect.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
#fs_connect{width:480px;-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.3);-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.3);box-shadow:0px 1px 2px rgba(0,0,0,0.3);margin:20px 0}@media screen and (max-width: 479px){#fs_connect{-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;width:auto;margin:0 0 0 -10px}}#fs_connect .fs-content{background:#fff;padding:15px 20px}#fs_connect .fs-content .fs-error{background:snow;color:#d3135a;border:1px solid #d3135a;-moz-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);text-align:center;padding:5px;margin-bottom:10px}#fs_connect .fs-content p{margin:0;padding:0;font-size:1.2em}#fs_connect .fs-license-key-container{position:relative;width:280px;margin:10px auto 0 auto}#fs_connect .fs-license-key-container input{width:100%}#fs_connect .fs-license-key-container .dashicons{position:absolute;top:5px;right:5px}#fs_connect.require-license-key .fs-sites-list-container td{cursor:pointer}#fs_connect #delegate_to_site_admins{margin-right:15px;float:right;height:26px;vertical-align:middle;line-height:37px;font-weight:bold;border-bottom:1px dashed;text-decoration:none}#fs_connect #delegate_to_site_admins.rtl{margin-left:15px;margin-right:0}#fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}#fs_connect .fs-actions .button{padding:0 10px 1px;line-height:35px;height:37px;font-size:16px;margin-bottom:0}#fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}#fs_connect .fs-actions .button.button-primary{padding-right:15px;padding-left:15px}#fs_connect .fs-actions .button.button-primary:after{content:' \279C'}#fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}#fs_connect .fs-actions .button.button-secondary{float:right}#fs_connect.fs-anonymous-disabled .fs-actions .button.button-primary{width:100%}#fs_connect .fs-permissions{padding:10px 20px;background:#FEFEFE;-moz-transition:background 0.5s ease;-o-transition:background 0.5s ease;-ms-transition:background 0.5s ease;-webkit-transition:background 0.5s ease;transition:background 0.5s ease}#fs_connect .fs-permissions .fs-license-sync-disclaimer{text-align:center;margin-top:0}#fs_connect .fs-permissions>.fs-trigger{font-size:0.9em;text-decoration:none;text-align:center;display:block}#fs_connect .fs-permissions ul{height:0;overflow:hidden;margin:0}#fs_connect .fs-permissions ul li{margin-bottom:12px}#fs_connect .fs-permissions ul li:last-child{margin-bottom:0}#fs_connect .fs-permissions ul li>i.dashicons{float:left;font-size:40px;width:40px;height:40px}#fs_connect .fs-permissions ul li .fs-switch{float:right}#fs_connect .fs-permissions ul li .fs-permission-description{margin-left:55px}#fs_connect .fs-permissions ul li .fs-permission-description span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li .fs-permission-description p{margin:2px 0 0 0}#fs_connect .fs-permissions.fs-open{background:#fff}#fs_connect .fs-permissions.fs-open ul{overflow:initial;height:auto;margin:20px 20px 10px 20px}@media screen and (max-width: 479px){#fs_connect .fs-permissions{background:#fff}#fs_connect .fs-permissions .fs-trigger{display:none}#fs_connect .fs-permissions ul{height:auto;margin:20px}}#fs_connect .fs-freemium-licensing{padding:8px;background:#777;color:#fff}#fs_connect .fs-freemium-licensing p{text-align:center;display:block;margin:0;padding:0}#fs_connect .fs-freemium-licensing a{color:#C2EEFF;text-decoration:underline}#fs_connect .fs-visual{padding:12px;line-height:0;background:#fafafa;height:80px;position:relative}#fs_connect .fs-visual .fs-site-icon{position:absolute;left:20px;top:10px}#fs_connect .fs-visual .fs-connect-logo{position:absolute;right:20px;top:10px}#fs_connect .fs-visual .fs-plugin-icon{position:absolute;top:10px;left:50%;margin-left:-40px}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-site-icon,#fs_connect .fs-visual img,#fs_connect .fs-visual object{width:80px;height:80px}#fs_connect .fs-visual .dashicons-wordpress{font-size:64px;background:#01749a;color:#fff;width:64px;height:64px;padding:8px}#fs_connect .fs-visual .dashicons-plus{position:absolute;top:50%;font-size:30px;margin-top:-10px;color:#bbb}#fs_connect .fs-visual .dashicons-plus.fs-first{left:28%}#fs_connect .fs-visual .dashicons-plus.fs-second{left:65%}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-connect-logo,#fs_connect .fs-visual .fs-site-icon{border:1px solid #ccc;padding:1px;background:#fff}#fs_connect .fs-terms{text-align:center;font-size:0.85em;padding:5px;background:rgba(0,0,0,0.05)}#fs_connect .fs-terms,#fs_connect .fs-terms a{color:#999}#fs_connect .fs-terms a{text-decoration:none}.fs-multisite-options-container{margin-top:10px;border:1px solid #ccc;padding:5px}.fs-multisite-options-container a{text-decoration:none}.fs-multisite-options-container a:focus{box-shadow:none}.fs-multisite-options-container a.selected{font-weight:bold}.fs-multisite-options-container.fs-apply-on-all-sites{border:0 none;padding:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options{border-spacing:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options td:not(:first-child){display:none}.fs-multisite-options-container .fs-sites-list-container{display:none;overflow:auto}.fs-multisite-options-container .fs-sites-list-container table td{border-top:1px solid #ccc;padding:4px 2px}.fs-tooltip-trigger{position:relative}.fs-tooltip-trigger:not(a){cursor:help}.fs-tooltip-trigger .fs-tooltip{opacity:0;visibility:hidden;-moz-transition:opacity 0.3s ease-in-out;-o-transition:opacity 0.3s ease-in-out;-ms-transition:opacity 0.3s ease-in-out;-webkit-transition:opacity 0.3s ease-in-out;transition:opacity 0.3s ease-in-out;position:absolute;background:rgba(0,0,0,0.8);color:#fff !important;font-family:'arial', serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:-17px;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);line-height:1.3em;font-weight:bold;text-align:left;text-transform:none !important}.rtl .fs-tooltip-trigger .fs-tooltip{text-align:right;left:auto;right:-17px}.fs-tooltip-trigger .fs-tooltip::after{content:' ';display:block;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:rgba(0,0,0,0.8) transparent transparent transparent;position:absolute;top:100%;left:21px}.rtl .fs-tooltip-trigger .fs-tooltip::after{right:21px;left:auto}.fs-tooltip-trigger:hover .fs-tooltip{visibility:visible;opacity:1}#fs_marketing_optin{display:none;margin-top:10px;border:1px solid #ccc;padding:10px;line-height:1.5em}#fs_marketing_optin .fs-message{display:block;margin-bottom:5px;font-size:1.05em;font-weight:600}#fs_marketing_optin.error{border:1px solid #d3135a;background:#fee}#fs_marketing_optin.error .fs-message{color:#d3135a}#fs_marketing_optin .fs-input-container{margin-top:5px}#fs_marketing_optin .fs-input-container label{margin-top:5px;display:block}#fs_marketing_optin .fs-input-container label input{float:left;margin:1px 0 0 0}#fs_marketing_optin .fs-input-container label:first-child{display:block;margin-bottom:2px}#fs_marketing_optin .fs-input-label{display:block;margin-left:20px}#fs_marketing_optin .fs-input-label .underlined{text-decoration:underline}.rtl #fs_marketing_optin .fs-input-container label input{float:right}.rtl #fs_marketing_optin .fs-input-label{margin-left:0;margin-right:20px}.rtl #fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}.rtl #fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}.rtl #fs_connect .fs-actions .button.button-primary:after{content:' \000bb'}.rtl #fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}.rtl #fs_connect .fs-actions .button.button-secondary{float:left}.rtl #fs_connect .fs-permissions ul li .fs-permission-description{margin-right:55px;margin-left:0}.rtl #fs_connect .fs-permissions ul li .fs-switch{float:left}.rtl #fs_connect .fs-permissions ul li i.dashicons{float:right}.rtl #fs_connect .fs-visual .fs-site-icon{right:20px;left:auto}.rtl #fs_connect .fs-visual .fs-connect-logo{right:auto;left:20px}#fs_theme_connect_wrapper{position:fixed;top:0;height:100%;width:100%;z-index:99990;background:rgba(0,0,0,0.75);text-align:center;overflow-y:auto}#fs_theme_connect_wrapper:before{content:"";display:inline-block;vertical-align:middle;height:100%}#fs_theme_connect_wrapper>button.close{color:white;cursor:pointer;height:40px;width:40px;position:absolute;right:0;border:0;background-color:transparent;top:32px}#fs_theme_connect_wrapper #fs_connect{top:0;text-align:left;display:inline-block;vertical-align:middle;margin-top:52px;margin-bottom:20px}#fs_theme_connect_wrapper #fs_connect .fs-terms{background:rgba(140,140,140,0.64)}#fs_theme_connect_wrapper #fs_connect .fs-terms,#fs_theme_connect_wrapper #fs_connect .fs-terms a{color:#c5c5c5}.wp-pointer-content #fs_connect{margin:0;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none}.fs-opt-in-pointer .wp-pointer-content{padding:0}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow{border-bottom-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow-inner{border-bottom-color:#fafafa}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow{border-top-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow-inner{border-top-color:#fafafa}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow{border-right-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow-inner{border-right-color:#fafafa}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow{border-left-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow-inner{border-left-color:#fafafa}#license_issues_link{display:block;text-align:center;font-size:0.9em;margin-top:10px}
|
|
freemius/assets/css/admin/debug.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
.fs-switch-label{font-size:20px;line-height:31px;margin:0 5px}#fs_log_book table{font-family:Consolas,Monaco,monospace;font-size:12px}#fs_log_book table th{color:#ccc}#fs_log_book table tr{background:#232525}#fs_log_book table tr.alternate{background:#2b2b2b}#fs_log_book table tr td.fs-col--logger{color:#5a7435}#fs_log_book table tr td.fs-col--type{color:#ffc861}#fs_log_book table tr td.fs-col--function{color:#a7b7b1;font-weight:bold}#fs_log_book table tr td.fs-col--message,#fs_log_book table tr td.fs-col--message a{color:#9a73ac !important}#fs_log_book table tr td.fs-col--file{color:#d07922}#fs_log_book table tr td.fs-col--timestamp{color:#6596be}
|
|
freemius/assets/css/admin/dialog-boxes.css
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
.fs-modal{position:fixed;overflow:auto;height:100%;width:100%;top:0;z-index:100000;display:none;background:rgba(0,0,0,0.6)}.fs-modal .dashicons{vertical-align:middle}.fs-modal .fs-modal-dialog{background:transparent;position:absolute;left:50%;margin-left:-298px;padding-bottom:30px;top:-100%;z-index:100001;width:596px}@media (max-width: 650px){.fs-modal .fs-modal-dialog{margin-left:-50%;box-sizing:border-box;padding-left:10px;padding-right:10px;width:100%}.fs-modal .fs-modal-dialog .fs-modal-panel>h3>strong{font-size:1.3em}}.fs-modal.active{display:block}.fs-modal.active:before{display:block}.fs-modal.active .fs-modal-dialog{top:10%}.fs-modal.fs-success .fs-modal-header{border-bottom-color:#46b450}.fs-modal.fs-success .fs-modal-body{background-color:#f7fff7}.fs-modal.fs-warn .fs-modal-header{border-bottom-color:#ffb900}.fs-modal.fs-warn .fs-modal-body{background-color:#fff8e5}.fs-modal.fs-error .fs-modal-header{border-bottom-color:#dc3232}.fs-modal.fs-error .fs-modal-body{background-color:#ffeaea}.fs-modal .fs-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-header{border-bottom:#eeeeee solid 1px;background:#fbfbfb;padding:15px 20px;position:relative;margin-bottom:-10px}.fs-modal .fs-modal-header h4{margin:0;padding:0;text-transform:uppercase;font-size:1.2em;font-weight:bold;color:#cacaca;text-shadow:1px 1px 1px #fff;letter-spacing:0.6px;-webkit-font-smoothing:antialiased}.fs-modal .fs-modal-header .fs-close{position:absolute;right:10px;top:12px;cursor:pointer;color:#bbb;-moz-border-radius:20px;-webkit-border-radius:20px;border-radius:20px;padding:3px;-moz-transition:all 0.2s ease-in-out;-o-transition:all 0.2s ease-in-out;-ms-transition:all 0.2s ease-in-out;-webkit-transition:all 0.2s ease-in-out;transition:all 0.2s ease-in-out}.fs-modal .fs-modal-header .fs-close:hover{color:#fff;background:#aaa}.fs-modal .fs-modal-header .fs-close .dashicons,.fs-modal .fs-modal-header .fs-close:hover .dashicons{text-decoration:none}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body p{font-size:14px}.fs-modal .fs-modal-body h2{font-size:20px;line-height:1.5em}.fs-modal .fs-modal-body>div{margin-top:10px}.fs-modal .fs-modal-body>div h2{font-weight:bold;font-size:20px;margin-top:0}.fs-modal .fs-modal-footer{border-top:#eeeeee solid 1px;text-align:right}.fs-modal .fs-modal-footer>.button{margin:0 7px}.fs-modal .fs-modal-footer>.button:first-child{margin:0}.fs-modal .fs-modal-panel>.notice.inline{margin:0;display:none}.fs-modal .fs-modal-panel:not(.active){display:none}.rtl .fs-modal .fs-modal-header .fs-close{right:auto;left:20px}body.has-fs-modal{overflow:hidden}.fs-modal.fs-modal-deactivation-feedback .reason-input,.fs-modal.fs-modal-deactivation-feedback .internal-message{margin:3px 0 3px 22px}.fs-modal.fs-modal-deactivation-feedback .reason-input input,.fs-modal.fs-modal-deactivation-feedback .reason-input textarea,.fs-modal.fs-modal-deactivation-feedback .internal-message input,.fs-modal.fs-modal-deactivation-feedback .internal-message textarea{width:100%}.fs-modal.fs-modal-deactivation-feedback li.reason.has-internal-message .internal-message{border:1px solid #ccc;padding:7px;display:none}@media (max-width: 650px){.fs-modal.fs-modal-deactivation-feedback li.reason li.reason{margin-bottom:10px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .reason-input,.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .internal-message{margin-left:29px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label{display:table}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label>span{display:table-cell;font-size:1.3em}}.fs-modal.fs-modal-deactivation-feedback .anonymous-feedback-label{float:left}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel{margin-top:0 !important}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel h3{margin-top:0;line-height:1.5em}#the-list .deactivate>.fs-slug{display:none}.fs-modal.fs-modal-subscription-cancellation .fs-price-increase-warning{color:red;font-weight:bold;padding:0 25px;margin-bottom:0}.fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label input{float:left;top:5px;position:relative}.rtl .fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label input{float:right}.fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label span{display:block;margin-left:24px}.rtl .fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label span{margin-left:0;margin-right:24px}.fs-modal.fs-modal-license-activation .fs-modal-body input.fs-license-key{width:100%}.fs-license-options-container table,.fs-license-options-container table select,.fs-license-options-container table .fs-available-license-key{width:100%}.fs-license-options-container table td:first-child{width:1%}.fs-license-options-container table .fs-other-license-key-container label{position:relative;top:6px;float:left;margin-right:5px}.fs-license-options-container table .fs-other-license-key-container div{overflow:hidden;width:auto;height:30px;display:block;top:2px;position:relative}.fs-license-options-container table .fs-other-license-key-container div input{margin:0}.fs-sites-list-container td{cursor:pointer}.fs-modal.fs-modal-user-change .fs-modal-body input#fs_other_email_address{width:100%}.fs-user-change-options-container table{width:100%;border-collapse:collapse}.fs-user-change-options-container table tr{display:block;margin-bottom:2px}.fs-user-change-options-container table .fs-email-address-container td{display:inline-block}.fs-user-change-options-container table .fs-email-address-container input[type="radio"]{margin-bottom:0;margin-top:0}.fs-user-change-options-container table .fs-other-email-address-container{width:100%}.fs-user-change-options-container table .fs-other-email-address-container>div{display:table;width:100%}.fs-user-change-options-container table .fs-other-email-address-container>div label,.fs-user-change-options-container table .fs-other-email-address-container>div>div{display:table-cell}.fs-user-change-options-container table .fs-other-email-address-container>div label{width:1%;padding-left:3px;padding-right:3px}.fs-user-change-options-container table .fs-other-email-address-container>div>div{width:auto}.fs-user-change-options-container table .fs-other-email-address-container>div>div input{width:100%}.fs-modal.fs-modal-developer-license-debug-mode .fs-modal-body input.fs-license-or-user-key{width:100%}.fs-multisite-options-container{margin-top:10px;border:1px solid #ccc;padding:5px}.fs-multisite-options-container a{text-decoration:none}.fs-multisite-options-container a:focus{box-shadow:none}.fs-multisite-options-container a.selected{font-weight:bold}.fs-multisite-options-container.fs-apply-on-all-sites{border:0 none;padding:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options{border-spacing:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options td:not(:first-child){display:none}.fs-multisite-options-container .fs-sites-list-container{display:none;overflow:auto}.fs-multisite-options-container .fs-sites-list-container table td{border-top:1px solid #ccc;padding:4px 2px}.fs-modal.fs-modal-license-key-resend .email-address-container{overflow:hidden;padding-right:2px}.fs-modal.fs-modal-license-key-resend.fs-freemium input.email-address{width:300px}.fs-modal.fs-modal-license-key-resend.fs-freemium label{display:block;margin-bottom:10px}.fs-modal.fs-modal-license-key-resend.fs-premium input.email-address{width:100%}.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{float:right;margin-left:7px}@media (max-width: 650px){.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{margin-top:2px}}
|
2 |
-
.rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .input-container>.email-address-container{padding-left:2px;padding-right:0}.rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .button-container{float:left;margin-right:7px;margin-left:0}a.show-license-resend-modal{margin-top:4px;display:inline-block}.fs-ajax-loader{position:relative;width:170px;height:20px;margin:auto}.fs-ajax-loader .fs-ajax-loader-bar{position:absolute;top:0;background-color:#0074a3;width:20px;height:20px;-webkit-animation-name:bounce_ajaxLoader;-moz-animation-name:bounce_ajaxLoader;-ms-animation-name:bounce_ajaxLoader;-o-animation-name:bounce_ajaxLoader;animation-name:bounce_ajaxLoader;-webkit-animation-duration:1.5s;-moz-animation-duration:1.5s;-ms-animation-duration:1.5s;-o-animation-duration:1.5s;animation-duration:1.5s;animation-iteration-count:infinite;-o-animation-iteration-count:infinite;-ms-animation-iteration-count:infinite;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;-webkit-animation-direction:normal;-moz-animation-direction:normal;-ms-animation-direction:normal;-o-animation-direction:normal;animation-direction:normal;-moz-transform:0.3;-o-transform:0.3;-ms-transform:0.3;-webkit-transform:0.3;transform:0.3}.fs-ajax-loader .fs-ajax-loader-bar-1{left:0px;animation-delay:0.6s;-o-animation-delay:0.6s;-ms-animation-delay:0.6s;-webkit-animation-delay:0.6s;-moz-animation-delay:0.6s}.fs-ajax-loader .fs-ajax-loader-bar-2{left:19px;animation-delay:0.75s;-o-animation-delay:0.75s;-ms-animation-delay:0.75s;-webkit-animation-delay:0.75s;-moz-animation-delay:0.75s}.fs-ajax-loader .fs-ajax-loader-bar-3{left:38px;animation-delay:0.9s;-o-animation-delay:0.9s;-ms-animation-delay:0.9s;-webkit-animation-delay:0.9s;-moz-animation-delay:0.9s}.fs-ajax-loader .fs-ajax-loader-bar-4{left:57px;animation-delay:1.05s;-o-animation-delay:1.05s;-ms-animation-delay:1.05s;-webkit-animation-delay:1.05s;-moz-animation-delay:1.05s}.fs-ajax-loader .fs-ajax-loader-bar-5{left:76px;animation-delay:1.2s;-o-animation-delay:1.2s;-ms-animation-delay:1.2s;-webkit-animation-delay:1.2s;-moz-animation-delay:1.2s}.fs-ajax-loader .fs-ajax-loader-bar-6{left:95px;animation-delay:1.35s;-o-animation-delay:1.35s;-ms-animation-delay:1.35s;-webkit-animation-delay:1.35s;-moz-animation-delay:1.35s}.fs-ajax-loader .fs-ajax-loader-bar-7{left:114px;animation-delay:1.5s;-o-animation-delay:1.5s;-ms-animation-delay:1.5s;-webkit-animation-delay:1.5s;-moz-animation-delay:1.5s}.fs-ajax-loader .fs-ajax-loader-bar-8{left:133px;animation-delay:1.65s;-o-animation-delay:1.65s;-ms-animation-delay:1.65s;-webkit-animation-delay:1.65s;-moz-animation-delay:1.65s}@-moz-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-ms-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-o-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-webkit-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}.fs-modal-auto-install #request-filesystem-credentials-form h2,.fs-modal-auto-install #request-filesystem-credentials-form .request-filesystem-credentials-action-buttons{display:none}.fs-modal-auto-install #request-filesystem-credentials-form input[type=password],.fs-modal-auto-install #request-filesystem-credentials-form input[type=email],.fs-modal-auto-install #request-filesystem-credentials-form input[type=text]{-webkit-appearance:none;padding:10px 10px 5px 10px;width:300px;max-width:100%}.fs-modal-auto-install #request-filesystem-credentials-form>div,.fs-modal-auto-install #request-filesystem-credentials-form label,.fs-modal-auto-install #request-filesystem-credentials-form fieldset{width:300px;max-width:100%;margin:0 auto;display:block}.button-primary.warn{box-shadow:0 1px 0 #d2593c;text-shadow:0 -1px 1px #d2593c,1px 0 1px #d2593c,0 1px 1px #d2593c,-1px 0 1px #d2593c;background:#f56a48;border-color:#ec6544 #d2593c #d2593c}.button-primary.warn:hover{background:#fd6d4a;border-color:#d2593c}.button-primary.warn:focus{box-shadow:0 1px 0 #dd6041,0 0 2px 1px #e4a796}.button-primary.warn:active{background:#dd6041;border-color:#d2593c;box-shadow:inset 0 2px 0 #d2593c}.button-primary.warn.disabled{color:#f5b3a1 !important;background:#e76444 !important;border-color:#d85e40 !important;text-shadow:0 -1px 0 rgba(0,0,0,0.1) !important}
|
|
|
|
freemius/assets/css/admin/gdpr-optin-notice.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
.fs-notice[data-id^="gdpr_optin_actions"] .underlined{text-decoration:underline}.fs-notice[data-id^="gdpr_optin_actions"] ul .button,.fs-notice[data-id^="gdpr_optin_actions"] ul .action-description{vertical-align:middle}.fs-notice[data-id^="gdpr_optin_actions"] ul .action-description{display:inline-block;margin-left:3px}
|
|
freemius/assets/css/admin/index.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// Silence is golden.
|
3 |
-
// Hide file structure from users on unprotected servers.
|
|
|
|
|
|
freemius/assets/css/admin/plugins.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
label.fs-tag,span.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn,span.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-info,span.fs-tag.fs-info{background:#00a0d2}label.fs-tag.fs-success,span.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error,span.fs-tag.fs-error{background:#dc3232}.wp-list-table.plugins .plugin-title span.fs-tag{display:inline-block;margin-left:5px;line-height:10px}
|
|
freemius/assets/css/customizer.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
#fs_customizer_upsell .fs-customizer-plan{padding:10px 20px 20px 20px;border-radius:3px;background:#fff}#fs_customizer_upsell .fs-customizer-plan h2{position:relative;margin:0;line-height:2em;text-transform:uppercase}#fs_customizer_upsell .fs-customizer-plan h2 .button-link{top:-2px}#fs_customizer_upsell .fs-feature{position:relative}#fs_customizer_upsell .dashicons-yes{color:#0085ba;font-size:2em;vertical-align:bottom;margin-left:-7px;margin-right:10px}.rtl #fs_customizer_upsell .dashicons-yes{margin-left:10px;margin-right:-7px}#fs_customizer_upsell .dashicons-editor-help{color:#bbb;cursor:help}#fs_customizer_upsell .dashicons-editor-help .fs-feature-desc{opacity:0;visibility:hidden;-moz-transition:opacity 0.3s ease-in-out;-o-transition:opacity 0.3s ease-in-out;-ms-transition:opacity 0.3s ease-in-out;-webkit-transition:opacity 0.3s ease-in-out;transition:opacity 0.3s ease-in-out;position:absolute;background:#000;color:#fff;font-family:'arial', serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:0;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);line-height:1.3em;font-weight:bold;text-align:left}.rtl #fs_customizer_upsell .dashicons-editor-help .fs-feature-desc{text-align:right}#fs_customizer_upsell .dashicons-editor-help .fs-feature-desc::after{content:' ';display:block;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:#000 transparent transparent transparent;position:absolute;top:100%;left:21px}.rtl #fs_customizer_upsell .dashicons-editor-help .fs-feature-desc::after{right:21px;left:auto}#fs_customizer_upsell .dashicons-editor-help:hover .fs-feature-desc{visibility:visible;opacity:1}#fs_customizer_upsell .button-primary{display:block;text-align:center;margin-top:10px}#fs_customizer_support{display:block !important}#fs_customizer_support .button{float:right}#fs_customizer_support .button-group{width:100%;display:block;margin-top:10px}#fs_customizer_support .button-group .button{float:none;width:50%;text-align:center}#customize-theme-controls #accordion-section-freemius_upsell{border-top:1px solid #0085ba !important;border-bottom:1px solid #0085ba !important}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title{color:#fff;background-color:#0085ba;border-left:4px solid #0085ba;transition:.15s background-color ease-in-out, .15s border-color ease-in-out;outline:none;border-bottom:none !important}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title:hover{background-color:#008ec2;border-left-color:#0073aa}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title:after{color:#fff}#customize-theme-controls #accordion-section-freemius_upsell .rtl h3.accordion-section-title{border-left:none;border-right:4px solid #0085ba}#customize-theme-controls #accordion-section-freemius_upsell .rtl h3.accordion-section-title:hover{border-right-color:#0073aa}
|
|
freemius/assets/css/index.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// Silence is golden.
|
3 |
-
// Hide file structure from users on unprotected servers.
|
|
|
|
|
|
freemius/assets/img/index.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// Silence is golden.
|
3 |
-
// Hide file structure from users on unprotected servers.
|
|
|
|
|
|
freemius/assets/img/plugin-icon.png
DELETED
Binary file
|
freemius/assets/img/theme-icon.png
DELETED
Binary file
|
freemius/assets/img/woocommerce-google-adwords-conversion-tracking-tag.png
DELETED
Binary file
|
freemius/assets/index.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// Silence is golden.
|
3 |
-
// Hide file structure from users on unprotected servers.
|
|
|
|
|
|
freemius/assets/js/index.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// Silence is golden.
|
3 |
-
// Hide file structure from users on unprotected servers.
|
|
|
|
|
|
freemius/assets/js/nojquery.ba-postmessage.js
DELETED
@@ -1,140 +0,0 @@
|
|
1 |
-
/*!
|
2 |
-
* jQuery postMessage - v0.5 - 9/11/2009
|
3 |
-
* http://benalman.com/projects/jquery-postmessage-plugin/
|
4 |
-
*
|
5 |
-
* Copyright (c) 2009 "Cowboy" Ben Alman
|
6 |
-
* Dual licensed under the MIT and GPL licenses.
|
7 |
-
* http://benalman.com/about/license/
|
8 |
-
*
|
9 |
-
* Non-jQuery fork by Jeff Lee
|
10 |
-
*
|
11 |
-
* This fork consists of the following changes:
|
12 |
-
* 1. Basic code cleanup and restructuring, for legibility.
|
13 |
-
* 2. The `postMessage` and `receiveMessage` functions can be bound arbitrarily,
|
14 |
-
* in terms of both function names and object scope. Scope is specified by
|
15 |
-
* the the "this" context of NoJQueryPostMessageMixin();
|
16 |
-
* 3. I've removed the check for Opera 9.64, which used `$.browser`. There were
|
17 |
-
* at least three different GitHub users requesting the removal of this
|
18 |
-
* "Opera sniff" on the original project's Issues page, so I figured this
|
19 |
-
* would be a relatively safe change.
|
20 |
-
* 4. `postMessage` no longer uses `$.param` to serialize messages that are not
|
21 |
-
* strings. I actually prefer this structure anyway. `receiveMessage` does
|
22 |
-
* not implement a corresponding deserialization step, and as such it seems
|
23 |
-
* cleaner and more symmetric to leave both data serialization and
|
24 |
-
* deserialization to the client.
|
25 |
-
* 5. The use of `$.isFunction` is replaced by a functionally-identical check.
|
26 |
-
* 6. The `$:nomunge` YUI option is no longer necessary.
|
27 |
-
*/
|
28 |
-
|
29 |
-
function NoJQueryPostMessageMixin(postBinding, receiveBinding) {
|
30 |
-
|
31 |
-
var setMessageCallback, unsetMessageCallback, currentMsgCallback,
|
32 |
-
intervalId, lastHash, cacheBust = 1;
|
33 |
-
|
34 |
-
if (window.postMessage) {
|
35 |
-
|
36 |
-
if (window.addEventListener) {
|
37 |
-
setMessageCallback = function(callback) {
|
38 |
-
window.addEventListener('message', callback, false);
|
39 |
-
}
|
40 |
-
|
41 |
-
unsetMessageCallback = function(callback) {
|
42 |
-
window.removeEventListener('message', callback, false);
|
43 |
-
}
|
44 |
-
} else {
|
45 |
-
setMessageCallback = function(callback) {
|
46 |
-
window.attachEvent('onmessage', callback);
|
47 |
-
}
|
48 |
-
|
49 |
-
unsetMessageCallback = function(callback) {
|
50 |
-
window.detachEvent('onmessage', callback);
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
this[postBinding] = function(message, targetUrl, target) {
|
55 |
-
if (!targetUrl) {
|
56 |
-
return;
|
57 |
-
}
|
58 |
-
|
59 |
-
// The browser supports window.postMessage, so call it with a targetOrigin
|
60 |
-
// set appropriately, based on the targetUrl parameter.
|
61 |
-
target.postMessage( message, targetUrl.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
|
62 |
-
}
|
63 |
-
|
64 |
-
// Since the browser supports window.postMessage, the callback will be
|
65 |
-
// bound to the actual event associated with window.postMessage.
|
66 |
-
this[receiveBinding] = function(callback, sourceOrigin, delay) {
|
67 |
-
// Unbind an existing callback if it exists.
|
68 |
-
if (currentMsgCallback) {
|
69 |
-
unsetMessageCallback(currentMsgCallback);
|
70 |
-
currentMsgCallback = null;
|
71 |
-
}
|
72 |
-
|
73 |
-
if (!callback) {
|
74 |
-
return false;
|
75 |
-
}
|
76 |
-
|
77 |
-
// Bind the callback. A reference to the callback is stored for ease of
|
78 |
-
// unbinding.
|
79 |
-
currentMsgCallback = setMessageCallback(function(e) {
|
80 |
-
switch(Object.prototype.toString.call(sourceOrigin)) {
|
81 |
-
case '[object String]':
|
82 |
-
if (sourceOrigin !== e.origin) {
|
83 |
-
return false;
|
84 |
-
}
|
85 |
-
break;
|
86 |
-
case '[object Function]':
|
87 |
-
if (sourceOrigin(e.origin)) {
|
88 |
-
return false;
|
89 |
-
}
|
90 |
-
break;
|
91 |
-
}
|
92 |
-
|
93 |
-
callback(e);
|
94 |
-
});
|
95 |
-
};
|
96 |
-
|
97 |
-
} else {
|
98 |
-
|
99 |
-
this[postBinding] = function(message, targetUrl, target) {
|
100 |
-
if (!targetUrl) {
|
101 |
-
return;
|
102 |
-
}
|
103 |
-
|
104 |
-
// The browser does not support window.postMessage, so set the location
|
105 |
-
// of the target to targetUrl#message. A bit ugly, but it works! A cache
|
106 |
-
// bust parameter is added to ensure that repeat messages trigger the
|
107 |
-
// callback.
|
108 |
-
target.location = targetUrl.replace( /#.*$/, '' ) + '#' + (+new Date) + (cacheBust++) + '&' + message;
|
109 |
-
}
|
110 |
-
|
111 |
-
// Since the browser sucks, a polling loop will be started, and the
|
112 |
-
// callback will be called whenever the location.hash changes.
|
113 |
-
this[receiveBinding] = function(callback, sourceOrigin, delay) {
|
114 |
-
if (intervalId) {
|
115 |
-
clearInterval(intervalId);
|
116 |
-
intervalId = null;
|
117 |
-
}
|
118 |
-
|
119 |
-
if (callback) {
|
120 |
-
delay = typeof sourceOrigin === 'number'
|
121 |
-
? sourceOrigin
|
122 |
-
: typeof delay === 'number'
|
123 |
-
? delay
|
124 |
-
: 100;
|
125 |
-
|
126 |
-
intervalId = setInterval(function(){
|
127 |
-
var hash = document.location.hash,
|
128 |
-
re = /^#?\d+&/;
|
129 |
-
if ( hash !== lastHash && re.test( hash ) ) {
|
130 |
-
lastHash = hash;
|
131 |
-
callback({ data: hash.replace( re, '' ) });
|
132 |
-
}
|
133 |
-
}, delay );
|
134 |
-
}
|
135 |
-
};
|
136 |
-
|
137 |
-
}
|
138 |
-
|
139 |
-
return this;
|
140 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freemius/assets/js/nojquery.ba-postmessage.min.js
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* nojquery-postmessage by Jeff Lee
|
3 |
-
* a non-jQuery fork of:
|
4 |
-
*
|
5 |
-
* jQuery postMessage - v0.5 - 9/11/2009
|
6 |
-
* http://benalman.com/projects/jquery-postmessage-plugin/
|
7 |
-
*
|
8 |
-
* Copyright (c) 2009 "Cowboy" Ben Alman
|
9 |
-
* Dual licensed under the MIT and GPL licenses.
|
10 |
-
* http://benalman.com/about/license/
|
11 |
-
*/
|
12 |
-
function NoJQueryPostMessageMixin(g,a){var b,h,e,d,f,c=1;if(window.postMessage){if(window.addEventListener){b=function(i){window.addEventListener("message",i,false)};h=function(i){window.removeEventListener("message",i,false)}}else{b=function(i){window.attachEvent("onmessage",i)};h=function(i){window.detachEvent("onmessage",i)}}this[g]=function(i,k,j){if(!k){return}j.postMessage(i,k.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))};this[a]=function(k,j,i){if(e){h(e);e=null}if(!k){return false}e=b(function(l){switch(Object.prototype.toString.call(j)){case"[object String]":if(j!==l.origin){return false}break;case"[object Function]":if(j(l.origin)){return false}break}k(l)})}}else{this[g]=function(i,k,j){if(!k){return}j.location=k.replace(/#.*$/,"")+"#"+(+new Date)+(c++)+"&"+i};this[a]=function(k,j,i){if(d){clearInterval(d);d=null}if(k){i=typeof j==="number"?j:typeof i==="number"?i:100;d=setInterval(function(){var m=document.location.hash,l=/^#?\d+&/;if(m!==f&&l.test(m)){f=m;k({data:m.replace(l,"")})}},i)}}}return this};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freemius/assets/js/postmessage.js
DELETED
@@ -1,135 +0,0 @@
|
|
1 |
-
(function ($, undef) {
|
2 |
-
var global = this;
|
3 |
-
|
4 |
-
// Namespace.
|
5 |
-
global.FS = global.FS || {};
|
6 |
-
|
7 |
-
global.FS.PostMessage = function ()
|
8 |
-
{
|
9 |
-
var
|
10 |
-
_is_child = false,
|
11 |
-
_postman = new NoJQueryPostMessageMixin('postMessage', 'receiveMessage'),
|
12 |
-
_callbacks = {},
|
13 |
-
_base_url,
|
14 |
-
_parent_url = decodeURIComponent(document.location.hash.replace(/^#/, '')),
|
15 |
-
_parent_subdomain = _parent_url.substring(0, _parent_url.indexOf('/', ('https://' === _parent_url.substring(0, ('https://').length)) ? 8 : 7)),
|
16 |
-
_init = function () {
|
17 |
-
_postman.receiveMessage(function (e) {
|
18 |
-
var data = JSON.parse(e.data);
|
19 |
-
|
20 |
-
if (_callbacks[data.type]) {
|
21 |
-
for (var i = 0; i < _callbacks[data.type].length; i++) {
|
22 |
-
// Execute type callbacks.
|
23 |
-
_callbacks[data.type][i](data.data);
|
24 |
-
}
|
25 |
-
}
|
26 |
-
}, _base_url);
|
27 |
-
},
|
28 |
-
_hasParent = ('' !== _parent_url),
|
29 |
-
$window = $(window),
|
30 |
-
$html = $('html');
|
31 |
-
|
32 |
-
return {
|
33 |
-
init : function (url, iframes)
|
34 |
-
{
|
35 |
-
_base_url = url;
|
36 |
-
_init();
|
37 |
-
|
38 |
-
// Automatically receive forward messages.
|
39 |
-
FS.PostMessage.receiveOnce('forward', function (data){
|
40 |
-
window.location = data.url;
|
41 |
-
});
|
42 |
-
|
43 |
-
iframes = iframes || [];
|
44 |
-
|
45 |
-
if (iframes.length > 0) {
|
46 |
-
$window.on('scroll', function () {
|
47 |
-
for (var i = 0; i < iframes.length; i++) {
|
48 |
-
FS.PostMessage.postScroll(iframes[i]);
|
49 |
-
}
|
50 |
-
});
|
51 |
-
}
|
52 |
-
},
|
53 |
-
init_child : function ()
|
54 |
-
{
|
55 |
-
this.init(_parent_subdomain);
|
56 |
-
|
57 |
-
_is_child = true;
|
58 |
-
|
59 |
-
// Post height of a child right after window is loaded.
|
60 |
-
$(window).bind('load', function () {
|
61 |
-
FS.PostMessage.postHeight();
|
62 |
-
|
63 |
-
// Post message that window was loaded.
|
64 |
-
FS.PostMessage.post('loaded');
|
65 |
-
});
|
66 |
-
},
|
67 |
-
hasParent : function ()
|
68 |
-
{
|
69 |
-
return _hasParent;
|
70 |
-
},
|
71 |
-
postHeight : function (diff, wrapper) {
|
72 |
-
diff = diff || 0;
|
73 |
-
wrapper = wrapper || '#wrap_section';
|
74 |
-
this.post('height', {
|
75 |
-
height: diff + $(wrapper).outerHeight(true)
|
76 |
-
});
|
77 |
-
},
|
78 |
-
postScroll : function (iframe) {
|
79 |
-
this.post('scroll', {
|
80 |
-
top: $window.scrollTop(),
|
81 |
-
height: ($window.height() - parseFloat($html.css('paddingTop')) - parseFloat($html.css('marginTop')))
|
82 |
-
}, iframe);
|
83 |
-
},
|
84 |
-
post : function (type, data, iframe)
|
85 |
-
{
|
86 |
-
console.debug('PostMessage.post', type);
|
87 |
-
|
88 |
-
if (iframe)
|
89 |
-
{
|
90 |
-
// Post to iframe.
|
91 |
-
_postman.postMessage(JSON.stringify({
|
92 |
-
type: type,
|
93 |
-
data: data
|
94 |
-
}), iframe.src, iframe.contentWindow);
|
95 |
-
}
|
96 |
-
else {
|
97 |
-
// Post to parent.
|
98 |
-
_postman.postMessage(JSON.stringify({
|
99 |
-
type: type,
|
100 |
-
data: data
|
101 |
-
}), _parent_url, window.parent);
|
102 |
-
}
|
103 |
-
},
|
104 |
-
receive: function (type, callback)
|
105 |
-
{
|
106 |
-
console.debug('PostMessage.receive', type);
|
107 |
-
|
108 |
-
if (undef === _callbacks[type])
|
109 |
-
_callbacks[type] = [];
|
110 |
-
|
111 |
-
_callbacks[type].push(callback);
|
112 |
-
},
|
113 |
-
receiveOnce: function (type, callback)
|
114 |
-
{
|
115 |
-
if (this.is_set(type))
|
116 |
-
return;
|
117 |
-
|
118 |
-
this.receive(type, callback);
|
119 |
-
},
|
120 |
-
// Check if any callbacks assigned to a specified message type.
|
121 |
-
is_set: function (type)
|
122 |
-
{
|
123 |
-
return (undef != _callbacks[type]);
|
124 |
-
},
|
125 |
-
parent_url: function ()
|
126 |
-
{
|
127 |
-
return _parent_url;
|
128 |
-
},
|
129 |
-
parent_subdomain: function ()
|
130 |
-
{
|
131 |
-
return _parent_subdomain;
|
132 |
-
}
|
133 |
-
};
|
134 |
-
}();
|
135 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freemius/config.php
DELETED
@@ -1,391 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package Freemius
|
4 |
-
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
-
* @since 1.0.4
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
-
exit;
|
11 |
-
}
|
12 |
-
|
13 |
-
if ( ! defined( 'WP_FS__SLUG' ) ) {
|
14 |
-
define( 'WP_FS__SLUG', 'freemius' );
|
15 |
-
}
|
16 |
-
if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
|
17 |
-
define( 'WP_FS__DEV_MODE', false );
|
18 |
-
}
|
19 |
-
|
20 |
-
#--------------------------------------------------------------------------------
|
21 |
-
#region API Connectivity Issues Simulation
|
22 |
-
#--------------------------------------------------------------------------------
|
23 |
-
|
24 |
-
if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) {
|
25 |
-
define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false );
|
26 |
-
}
|
27 |
-
if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) {
|
28 |
-
define( 'WP_FS__SIMULATE_NO_CURL', false );
|
29 |
-
}
|
30 |
-
if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
|
31 |
-
define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
|
32 |
-
}
|
33 |
-
if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
|
34 |
-
define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
|
35 |
-
}
|
36 |
-
if ( WP_FS__SIMULATE_NO_CURL ) {
|
37 |
-
define( 'FS_SDK__SIMULATE_NO_CURL', true );
|
38 |
-
}
|
39 |
-
if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
|
40 |
-
define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
|
41 |
-
}
|
42 |
-
if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
|
43 |
-
define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
|
44 |
-
}
|
45 |
-
|
46 |
-
#endregion
|
47 |
-
|
48 |
-
if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) {
|
49 |
-
define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false );
|
50 |
-
}
|
51 |
-
|
52 |
-
if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) {
|
53 |
-
/**
|
54 |
-
* @since 1.1.7.3
|
55 |
-
* @author Vova Feldman (@svovaf)
|
56 |
-
*
|
57 |
-
* I'm not sure if shared servers periodically change IP, or the subdomain of the
|
58 |
-
* admin dashboard. Also, I've seen sites that have strange loop of switching
|
59 |
-
* between domains on a daily basis. Therefore, to eliminate the risk of
|
60 |
-
* multiple unwanted connectivity test pings, temporary ignore domain or
|
61 |
-
* server IP changes.
|
62 |
-
*/
|
63 |
-
define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false );
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* If your dev environment supports custom public network IP setup
|
68 |
-
* like VVV, please update WP_FS__LOCALHOST_IP with your public IP
|
69 |
-
* and uncomment it during dev.
|
70 |
-
*/
|
71 |
-
if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
|
72 |
-
// VVV default public network IP.
|
73 |
-
define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' );
|
74 |
-
|
75 |
-
// define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* If true and running with secret key, the opt-in process
|
80 |
-
* will skip the email activation process which is invoked
|
81 |
-
* when the email of the context user already exist in Freemius
|
82 |
-
* database (as a security precaution, to prevent sharing user
|
83 |
-
* secret with unauthorized entity).
|
84 |
-
*
|
85 |
-
* IMPORTANT:
|
86 |
-
* AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
|
87 |
-
* THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
|
88 |
-
* CLOCK IS SYNCED.
|
89 |
-
*/
|
90 |
-
if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) {
|
91 |
-
define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
#--------------------------------------------------------------------------------
|
96 |
-
#region Directories
|
97 |
-
#--------------------------------------------------------------------------------
|
98 |
-
|
99 |
-
if ( ! defined( 'WP_FS__DIR' ) ) {
|
100 |
-
define( 'WP_FS__DIR', dirname( __FILE__ ) );
|
101 |
-
}
|
102 |
-
if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) {
|
103 |
-
define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
|
104 |
-
}
|
105 |
-
if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) {
|
106 |
-
define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
|
107 |
-
}
|
108 |
-
if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) {
|
109 |
-
define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
|
110 |
-
}
|
111 |
-
if ( ! defined( 'WP_FS__DIR_CSS' ) ) {
|
112 |
-
define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
|
113 |
-
}
|
114 |
-
if ( ! defined( 'WP_FS__DIR_JS' ) ) {
|
115 |
-
define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
|
116 |
-
}
|
117 |
-
if ( ! defined( 'WP_FS__DIR_IMG' ) ) {
|
118 |
-
define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
|
119 |
-
}
|
120 |
-
if ( ! defined( 'WP_FS__DIR_SDK' ) ) {
|
121 |
-
define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
|
122 |
-
}
|
123 |
-
|
124 |
-
#endregion
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Domain / URL / Address
|
128 |
-
*/
|
129 |
-
define( 'WP_FS__ROOT_DOMAIN_PRODUCTION', 'freemius.com' );
|
130 |
-
define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
|
131 |
-
define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
|
132 |
-
|
133 |
-
if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) {
|
134 |
-
define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
|
135 |
-
}
|
136 |
-
if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) {
|
137 |
-
define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
|
138 |
-
}
|
139 |
-
|
140 |
-
if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) {
|
141 |
-
define( 'WP_FS__TESTING_DOMAIN', 'fswp' );
|
142 |
-
}
|
143 |
-
|
144 |
-
#--------------------------------------------------------------------------------
|
145 |
-
#region HTTP
|
146 |
-
#--------------------------------------------------------------------------------
|
147 |
-
|
148 |
-
if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) {
|
149 |
-
define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) );
|
150 |
-
}
|
151 |
-
|
152 |
-
if ( ! defined( 'WP_FS__IS_HTTPS' ) ) {
|
153 |
-
define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST &&
|
154 |
-
// Checks if CloudFlare's HTTPS (Flexible SSL support).
|
155 |
-
isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
|
156 |
-
'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
|
157 |
-
) ||
|
158 |
-
// Check if HTTPS request.
|
159 |
-
( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
|
160 |
-
( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
|
161 |
-
);
|
162 |
-
}
|
163 |
-
|
164 |
-
if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) {
|
165 |
-
define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST &&
|
166 |
-
strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
|
167 |
-
}
|
168 |
-
|
169 |
-
if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) {
|
170 |
-
define( 'WP_FS__REMOTE_ADDR', fs_get_ip() );
|
171 |
-
}
|
172 |
-
|
173 |
-
if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) {
|
174 |
-
if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
|
175 |
-
define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) );
|
176 |
-
} else {
|
177 |
-
define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST &&
|
178 |
-
is_string( WP_FS__REMOTE_ADDR ) &&
|
179 |
-
( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' ||
|
180 |
-
WP_FS__REMOTE_ADDR === '::1' )
|
181 |
-
);
|
182 |
-
}
|
183 |
-
}
|
184 |
-
|
185 |
-
if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) {
|
186 |
-
define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST ||
|
187 |
-
false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
|
188 |
-
}
|
189 |
-
|
190 |
-
#endregion
|
191 |
-
|
192 |
-
if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) {
|
193 |
-
// By default, run with Freemius production servers.
|
194 |
-
define( 'WP_FS__IS_PRODUCTION_MODE', true );
|
195 |
-
}
|
196 |
-
|
197 |
-
if ( ! defined( 'WP_FS__ADDRESS' ) ) {
|
198 |
-
define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
|
199 |
-
}
|
200 |
-
|
201 |
-
|
202 |
-
#--------------------------------------------------------------------------------
|
203 |
-
#region API
|
204 |
-
#--------------------------------------------------------------------------------
|
205 |
-
|
206 |
-
if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) {
|
207 |
-
define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius-local.com:8080' );
|
208 |
-
}
|
209 |
-
if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) {
|
210 |
-
define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' );
|
211 |
-
}
|
212 |
-
|
213 |
-
// Set API address for local testing.
|
214 |
-
if ( ! WP_FS__IS_PRODUCTION_MODE ) {
|
215 |
-
if ( ! defined( 'FS_API__ADDRESS' ) ) {
|
216 |
-
define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST );
|
217 |
-
}
|
218 |
-
if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
|
219 |
-
define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST );
|
220 |
-
}
|
221 |
-
}
|
222 |
-
|
223 |
-
#endregion
|
224 |
-
|
225 |
-
#--------------------------------------------------------------------------------
|
226 |
-
#region Checkout
|
227 |
-
#--------------------------------------------------------------------------------
|
228 |
-
|
229 |
-
if ( ! defined( 'FS_CHECKOUT__ADDRESS_PRODUCTION' ) ) {
|
230 |
-
define( 'FS_CHECKOUT__ADDRESS_PRODUCTION', 'https://checkout.freemius.com' );
|
231 |
-
}
|
232 |
-
|
233 |
-
if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) {
|
234 |
-
define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius-local.com:8080' );
|
235 |
-
}
|
236 |
-
|
237 |
-
if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) {
|
238 |
-
define( 'FS_CHECKOUT__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? FS_CHECKOUT__ADDRESS_PRODUCTION : FS_CHECKOUT__ADDRESS_LOCALHOST ) );
|
239 |
-
}
|
240 |
-
|
241 |
-
#endregion
|
242 |
-
|
243 |
-
define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
|
244 |
-
|
245 |
-
if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
|
246 |
-
define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
|
247 |
-
}
|
248 |
-
if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
|
249 |
-
define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
|
250 |
-
}
|
251 |
-
if ( ! defined( 'WP_FS__GDPR_OPTION_NAME' ) ) {
|
252 |
-
define( 'WP_FS__GDPR_OPTION_NAME', WP_FS___OPTION_PREFIX . 'gdpr' );
|
253 |
-
}
|
254 |
-
define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Module types
|
258 |
-
*
|
259 |
-
* @since 1.2.2
|
260 |
-
*/
|
261 |
-
define( 'WP_FS__MODULE_TYPE_PLUGIN', 'plugin' );
|
262 |
-
define( 'WP_FS__MODULE_TYPE_THEME', 'theme' );
|
263 |
-
|
264 |
-
/**
|
265 |
-
* Billing Frequencies
|
266 |
-
*/
|
267 |
-
define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
|
268 |
-
define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
|
269 |
-
define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
|
270 |
-
|
271 |
-
/**
|
272 |
-
* Plans
|
273 |
-
*/
|
274 |
-
define( 'WP_FS__PLAN_DEFAULT_PAID', false );
|
275 |
-
define( 'WP_FS__PLAN_FREE', 'free' );
|
276 |
-
define( 'WP_FS__PLAN_TRIAL', 'trial' );
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Times in seconds
|
280 |
-
*/
|
281 |
-
if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) {
|
282 |
-
define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
|
283 |
-
}
|
284 |
-
if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) {
|
285 |
-
define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
|
286 |
-
}
|
287 |
-
// define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
|
288 |
-
if ( ! defined( 'WP_FS__TIME_12_HOURS_IN_SEC' ) ) {
|
289 |
-
define( 'WP_FS__TIME_12_HOURS_IN_SEC', 43200 );
|
290 |
-
}
|
291 |
-
if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) {
|
292 |
-
define( 'WP_FS__TIME_24_HOURS_IN_SEC', WP_FS__TIME_12_HOURS_IN_SEC * 2 );
|
293 |
-
}
|
294 |
-
if ( ! defined( 'WP_FS__TIME_WEEK_IN_SEC' ) ) {
|
295 |
-
define( 'WP_FS__TIME_WEEK_IN_SEC', 7 * WP_FS__TIME_24_HOURS_IN_SEC );
|
296 |
-
}
|
297 |
-
|
298 |
-
#--------------------------------------------------------------------------------
|
299 |
-
#region Debugging
|
300 |
-
#--------------------------------------------------------------------------------
|
301 |
-
|
302 |
-
if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) {
|
303 |
-
$debug_mode = get_option( 'fs_debug_mode', null );
|
304 |
-
|
305 |
-
if ( $debug_mode === null ) {
|
306 |
-
$debug_mode = false;
|
307 |
-
add_option( 'fs_debug_mode', $debug_mode );
|
308 |
-
}
|
309 |
-
|
310 |
-
define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE );
|
311 |
-
}
|
312 |
-
|
313 |
-
if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) {
|
314 |
-
define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) );
|
315 |
-
}
|
316 |
-
if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) {
|
317 |
-
define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' );
|
318 |
-
}
|
319 |
-
if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
|
320 |
-
define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK );
|
321 |
-
}
|
322 |
-
|
323 |
-
if ( WP_FS__ECHO_DEBUG_SDK ) {
|
324 |
-
error_reporting( E_ALL );
|
325 |
-
}
|
326 |
-
|
327 |
-
#endregion
|
328 |
-
|
329 |
-
if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) {
|
330 |
-
define( 'WP_FS__SCRIPT_START_TIME', time() );
|
331 |
-
}
|
332 |
-
if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) {
|
333 |
-
define( 'WP_FS__DEFAULT_PRIORITY', 10 );
|
334 |
-
}
|
335 |
-
if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) {
|
336 |
-
define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
|
337 |
-
}
|
338 |
-
|
339 |
-
#--------------------------------------------------------------------------------
|
340 |
-
#region Multisite Network
|
341 |
-
#--------------------------------------------------------------------------------
|
342 |
-
|
343 |
-
/**
|
344 |
-
* Do not use this define directly, it will have the wrong value
|
345 |
-
* during plugin uninstall/deletion when the inclusion of the plugin
|
346 |
-
* is triggered due to registration with register_uninstall_hook().
|
347 |
-
*
|
348 |
-
* Instead, use fs_is_network_admin().
|
349 |
-
*
|
350 |
-
* @author Vova Feldman (@svovaf)
|
351 |
-
*/
|
352 |
-
if ( ! defined( 'WP_FS__IS_NETWORK_ADMIN' ) ) {
|
353 |
-
define( 'WP_FS__IS_NETWORK_ADMIN',
|
354 |
-
is_multisite() &&
|
355 |
-
( is_network_admin() ||
|
356 |
-
( ( defined( 'DOING_AJAX' ) && DOING_AJAX &&
|
357 |
-
( isset( $_REQUEST['_fs_network_admin'] ) /*||
|
358 |
-
( ! empty( $_REQUEST['action'] ) && 'delete-plugin' === $_REQUEST['action'] )*/ )
|
359 |
-
) ||
|
360 |
-
// Plugin uninstall.
|
361 |
-
defined( 'WP_UNINSTALL_PLUGIN' ) )
|
362 |
-
)
|
363 |
-
);
|
364 |
-
}
|
365 |
-
|
366 |
-
/**
|
367 |
-
* Do not use this define directly, it will have the wrong value
|
368 |
-
* during plugin uninstall/deletion when the inclusion of the plugin
|
369 |
-
* is triggered due to registration with register_uninstall_hook().
|
370 |
-
*
|
371 |
-
* Instead, use fs_is_blog_admin().
|
372 |
-
*
|
373 |
-
* @author Vova Feldman (@svovaf)
|
374 |
-
*/
|
375 |
-
if ( ! defined( 'WP_FS__IS_BLOG_ADMIN' ) ) {
|
376 |
-
define( 'WP_FS__IS_BLOG_ADMIN', is_blog_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['_fs_blog_admin'] ) ) );
|
377 |
-
}
|
378 |
-
|
379 |
-
if ( ! defined( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED' ) ) {
|
380 |
-
// Set to true to show network level settings even if delegated to site admins.
|
381 |
-
define( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED', false );
|
382 |
-
}
|
383 |
-
|
384 |
-
#endregion
|
385 |
-
|
386 |
-
if ( ! defined( 'WP_FS__DEMO_MODE' ) ) {
|
387 |
-
define( 'WP_FS__DEMO_MODE', false );
|
388 |
-
}
|
389 |
-
if ( ! defined( 'FS_SDK__SSLVERIFY' ) ) {
|
390 |
-
define( 'FS_SDK__SSLVERIFY', false );
|
391 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freemius/includes/class-freemius-abstract.php
DELETED
@@ -1,493 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* @package Freemius
|
5 |
-
* @copyright Copyright (c) 2015, Freemius, Inc.
|
6 |
-
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
7 |
-
* @since 1.0.7
|
8 |
-
*/
|
9 |
-
if ( !defined( 'ABSPATH' ) ) {
|
10 |
-
exit;
|
11 |
-
}
|
12 |
-
/**
|
13 |
-
* - Each instance of Freemius class represents a single plugin
|
14 |
-
* install by a single user (the installer of the plugin).
|
15 |
-
*
|
16 |
-
* - Each website can only have one install of the same plugin.
|
17 |
-
*
|
18 |
-
* - Install entity is only created after a user connects his account with Freemius.
|
19 |
-
*
|
20 |
-
* Class Freemius_Abstract
|
21 |
-
*/
|
22 |
-
abstract class Freemius_Abstract
|
23 |
-
{
|
24 |
-
#----------------------------------------------------------------------------------
|
25 |
-
#region Identity
|
26 |
-
#----------------------------------------------------------------------------------
|
27 |
-
/**
|
28 |
-
* Check if user has connected his account (opted-in).
|
29 |
-
*
|
30 |
-
* Note:
|
31 |
-
* If the user opted-in and opted-out on a later stage,
|
32 |
-
* this will still return true. If you want to check if the
|
33 |
-
* user is currently opted-in, use:
|
34 |
-
* `$fs->is_registered() && $fs->is_tracking_allowed()`
|
35 |
-
*
|
36 |
-
* @since 1.0.1
|
37 |
-
* @return bool
|
38 |
-
*/
|
39 |
-
abstract function is_registered();
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Check if the user skipped connecting the account with Freemius.
|
43 |
-
*
|
44 |
-
* @since 1.0.7
|
45 |
-
*
|
46 |
-
* @return bool
|
47 |
-
*/
|
48 |
-
abstract function is_anonymous();
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Check if the user currently in activation mode.
|
52 |
-
*
|
53 |
-
* @since 1.0.7
|
54 |
-
*
|
55 |
-
* @return bool
|
56 |
-
*/
|
57 |
-
abstract function is_activation_mode();
|
58 |
-
|
59 |
-
#endregion
|
60 |
-
#----------------------------------------------------------------------------------
|
61 |
-
#region Usage Tracking
|
62 |
-
#----------------------------------------------------------------------------------
|
63 |
-
/**
|
64 |
-
* Returns TRUE if the user opted-in and didn't disconnect (opt-out).
|
65 |
-
*
|
66 |
-
* @author Leo Fajardo (@leorw)
|
67 |
-
* @since 1.2.1.5
|
68 |
-
*
|
69 |
-
* @return bool
|
70 |
-
*/
|
71 |
-
abstract function is_tracking_allowed();
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Returns TRUE if the user never opted-in or manually opted-out.
|
75 |
-
*
|
76 |
-
* @author Vova Feldman (@svovaf)
|
77 |
-
* @since 1.2.1.5
|
78 |
-
*
|
79 |
-
* @return bool
|
80 |
-
*/
|
81 |
-
function is_tracking_prohibited()
|
82 |
-
{
|
83 |
-
return !$this->is_registered() || !$this->is_tracking_allowed();
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Opt-out from usage tracking.
|
88 |
-
*
|
89 |
-
* Note: This will not delete the account information but will stop all tracking.
|
90 |
-
*
|
91 |
-
* Returns:
|
92 |
-
* 1. FALSE - If the user never opted-in.
|
93 |
-
* 2. TRUE - If successfully opted-out.
|
94 |
-
* 3. object - API Result on failure.
|
95 |
-
*
|
96 |
-
* @author Leo Fajardo (@leorw)
|
97 |
-
* @since 1.2.1.5
|
98 |
-
*
|
99 |
-
* @return bool|object
|
100 |
-
*/
|
101 |
-
abstract function stop_tracking();
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Opt-in back into usage tracking.
|
105 |
-
*
|
106 |
-
* Note: This will only work if the user opted-in previously.
|
107 |
-
*
|
108 |
-
* Returns:
|
109 |
-
* 1. FALSE - If the user never opted-in.
|
110 |
-
* 2. TRUE - If successfully opted-in back to usage tracking.
|
111 |
-
* 3. object - API result on failure.
|
112 |
-
*
|
113 |
-
* @author Leo Fajardo (@leorw)
|
114 |
-
* @since 1.2.1.5
|
115 |
-
*
|
116 |
-
* @return bool|object
|
117 |
-
*/
|
118 |
-
abstract function allow_tracking();
|
119 |
-
|
120 |
-
#endregion
|
121 |
-
#----------------------------------------------------------------------------------
|
122 |
-
#region Module Type
|
123 |
-
#----------------------------------------------------------------------------------
|
124 |
-
/**
|
125 |
-
* Checks if the plugin's type is "plugin". The other type is "theme".
|
126 |
-
*
|
127 |
-
* @author Leo Fajardo (@leorw)
|
128 |
-
* @since 1.2.2
|
129 |
-
*
|
130 |
-
* @return bool
|
131 |
-
*/
|
132 |
-
abstract function is_plugin();
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Checks if the module type is "theme". The other type is "plugin".
|
136 |
-
*
|
137 |
-
* @author Leo Fajardo (@leorw)
|
138 |
-
* @since 1.2.2
|
139 |
-
*
|
140 |
-
* @return bool
|
141 |
-
*/
|
142 |
-
function is_theme()
|
143 |
-
{
|
144 |
-
return !$this->is_plugin();
|
145 |
-
}
|
146 |
-
|
147 |
-
#endregion
|
148 |
-
#----------------------------------------------------------------------------------
|
149 |
-
#region Permissions
|
150 |
-
#----------------------------------------------------------------------------------
|
151 |
-
/**
|
152 |
-
* Check if plugin must be WordPress.org compliant.
|
153 |
-
*
|
154 |
-
* @since 1.0.7
|
155 |
-
*
|
156 |
-
* @return bool
|
157 |
-
*/
|
158 |
-
abstract function is_org_repo_compliant();
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Check if plugin is allowed to install executable files.
|
162 |
-
*
|
163 |
-
* @author Vova Feldman (@svovaf)
|
164 |
-
* @since 1.0.5
|
165 |
-
*
|
166 |
-
* @return bool
|
167 |
-
*/
|
168 |
-
function is_allowed_to_install()
|
169 |
-
{
|
170 |
-
return $this->is_premium() || !$this->is_org_repo_compliant();
|
171 |
-
}
|
172 |
-
|
173 |
-
#endregion
|
174 |
-
/**
|
175 |
-
* Check if user in trial or in free plan (not paying).
|
176 |
-
*
|
177 |
-
* @author Vova Feldman (@svovaf)
|
178 |
-
* @since 1.0.4
|
179 |
-
*
|
180 |
-
* @return bool
|
181 |
-
*/
|
182 |
-
function is_not_paying()
|
183 |
-
{
|
184 |
-
return $this->is_trial() || $this->is_free_plan();
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Check if the user has an activated and valid paid license on current plugin's install.
|
189 |
-
*
|
190 |
-
* @since 1.0.9
|
191 |
-
*
|
192 |
-
* @return bool
|
193 |
-
*/
|
194 |
-
abstract function is_paying();
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Check if the user is paying or in trial.
|
198 |
-
*
|
199 |
-
* @since 1.0.9
|
200 |
-
*
|
201 |
-
* @return bool
|
202 |
-
*/
|
203 |
-
function is_paying_or_trial()
|
204 |
-
{
|
205 |
-
return $this->is_paying() || $this->is_trial();
|
206 |
-
}
|
207 |
-
|
208 |
-
/**
|
209 |
-
* Check if user in a trial or have feature enabled license.
|
210 |
-
*
|
211 |
-
* @author Vova Feldman (@svovaf)
|
212 |
-
* @since 1.1.7
|
213 |
-
*
|
214 |
-
* @return bool
|
215 |
-
*/
|
216 |
-
abstract function can_use_premium_code();
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Check if the user has an activated and valid paid license on current plugin's install.
|
220 |
-
*
|
221 |
-
* @since 1.0.4
|
222 |
-
*
|
223 |
-
* @return bool
|
224 |
-
*
|
225 |
-
* @deprecated Method name is confusing since it's not clear from the name the code will be removed.
|
226 |
-
* @using Alias to is_paying__premium_only()
|
227 |
-
*/
|
228 |
-
function is_paying__fs__()
|
229 |
-
{
|
230 |
-
return $this->is_paying__premium_only();
|
231 |
-
}
|
232 |
-
|
233 |
-
#endregion
|
234 |
-
#----------------------------------------------------------------------------------
|
235 |
-
#region Trial
|
236 |
-
#----------------------------------------------------------------------------------
|
237 |
-
/**
|
238 |
-
* Check if the user in a trial.
|
239 |
-
*
|
240 |
-
* @since 1.0.3
|
241 |
-
*
|
242 |
-
* @return bool
|
243 |
-
*/
|
244 |
-
abstract function is_trial();
|
245 |
-
|
246 |
-
/**
|
247 |
-
* Check if trial already utilized.
|
248 |
-
*
|
249 |
-
* @since 1.0.9
|
250 |
-
*
|
251 |
-
* @return bool
|
252 |
-
*/
|
253 |
-
abstract function is_trial_utilized();
|
254 |
-
|
255 |
-
#endregion
|
256 |
-
#----------------------------------------------------------------------------------
|
257 |
-
#region Plans
|
258 |
-
#----------------------------------------------------------------------------------
|
259 |
-
/**
|
260 |
-
* Check if the user is on the free plan of the product.
|
261 |
-
*
|
262 |
-
* @since 1.0.4
|
263 |
-
*
|
264 |
-
* @return bool
|
265 |
-
*/
|
266 |
-
abstract function is_free_plan();
|
267 |
-
|
268 |
-
/**
|
269 |
-
* @since 1.0.2
|
270 |
-
*
|
271 |
-
* @param string $plan Plan name.
|
272 |
-
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
|
273 |
-
*
|
274 |
-
* @return bool
|
275 |
-
*/
|
276 |
-
abstract function is_plan( $plan, $exact = false );
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Check if plan based on trial. If not in trial mode, should return false.
|
280 |
-
*
|
281 |
-
* @since 1.0.9
|
282 |
-
*
|
283 |
-
* @param string $plan Plan name.
|
284 |
-
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
|
285 |
-
*
|
286 |
-
* @return bool
|
287 |
-
*/
|
288 |
-
abstract function is_trial_plan( $plan, $exact = false );
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Check if plan matches active license' plan or active trial license' plan.
|
292 |
-
*
|
293 |
-
* @since 1.0.9
|
294 |
-
*
|
295 |
-
* @param string $plan Plan name.
|
296 |
-
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
|
297 |
-
*
|
298 |
-
* @return bool
|
299 |
-
*/
|
300 |
-
function is_plan_or_trial( $plan, $exact = false )
|
301 |
-
{
|
302 |
-
return $this->is_plan( $plan, $exact ) || $this->is_trial_plan( $plan, $exact );
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Check if plugin has any paid plans.
|
307 |
-
*
|
308 |
-
* @author Vova Feldman (@svovaf)
|
309 |
-
* @since 1.0.7
|
310 |
-
*
|
311 |
-
* @return bool
|
312 |
-
*/
|
313 |
-
abstract function has_paid_plan();
|
314 |
-
|
315 |
-
/**
|
316 |
-
* Check if plugin has any free plan, or is it premium only.
|
317 |
-
*
|
318 |
-
* Note: If no plans configured, assume plugin is free.
|
319 |
-
*
|
320 |
-
* @author Vova Feldman (@svovaf)
|
321 |
-
* @since 1.0.7
|
322 |
-
*
|
323 |
-
* @return bool
|
324 |
-
*/
|
325 |
-
abstract function has_free_plan();
|
326 |
-
|
327 |
-
/**
|
328 |
-
* Check if plugin is premium only (no free plans).
|
329 |
-
*
|
330 |
-
* NOTE: is__premium_only() is very different method, don't get confused.
|
331 |
-
*
|
332 |
-
* @author Vova Feldman (@svovaf)
|
333 |
-
* @since 1.1.9
|
334 |
-
*
|
335 |
-
* @return bool
|
336 |
-
*/
|
337 |
-
abstract function is_only_premium();
|
338 |
-
|
339 |
-
/**
|
340 |
-
* Check if module has a premium code version.
|
341 |
-
*
|
342 |
-
* Serviceware module might be freemium without any
|
343 |
-
* premium code version, where the paid features
|
344 |
-
* are all part of the service.
|
345 |
-
*
|
346 |
-
* @author Vova Feldman (@svovaf)
|
347 |
-
* @since 1.2.1.6
|
348 |
-
*
|
349 |
-
* @return bool
|
350 |
-
*/
|
351 |
-
abstract function has_premium_version();
|
352 |
-
|
353 |
-
/**
|
354 |
-
* Check if module has any release on Freemius,
|
355 |
-
* or all plugin's code is on WordPress.org (Serviceware).
|
356 |
-
*
|
357 |
-
* @return bool
|
358 |
-
*/
|
359 |
-
function has_release_on_freemius()
|
360 |
-
{
|
361 |
-
return !$this->is_org_repo_compliant() || $this->has_premium_version();
|
362 |
-
}
|
363 |
-
|
364 |
-
/**
|
365 |
-
* Checks if it's a freemium plugin.
|
366 |
-
*
|
367 |
-
* @author Vova Feldman (@svovaf)
|
368 |
-
* @since 1.1.9
|
369 |
-
*
|
370 |
-
* @return bool
|
371 |
-
*/
|
372 |
-
function is_freemium()
|
373 |
-
{
|
374 |
-
return $this->has_paid_plan() && $this->has_free_plan();
|
375 |
-
}
|
376 |
-
|
377 |
-
/**
|
378 |
-
* Check if module has only one plan.
|
379 |
-
*
|
380 |
-
* @author Vova Feldman (@svovaf)
|
381 |
-
* @since 1.2.1.7
|
382 |
-
*
|
383 |
-
* @return bool
|
384 |
-
*/
|
385 |
-
abstract function is_single_plan();
|
386 |
-
|
387 |
-
#endregion
|
388 |
-
/**
|
389 |
-
* Check if running payments in sandbox mode.
|
390 |
-
*
|
391 |
-
* @since 1.0.4
|
392 |
-
*
|
393 |
-
* @return bool
|
394 |
-
*/
|
395 |
-
abstract function is_payments_sandbox();
|
396 |
-
|
397 |
-
/**
|
398 |
-
* Check if running test vs. live plugin.
|
399 |
-
*
|
400 |
-
* @since 1.0.5
|
401 |
-
*
|
402 |
-
* @return bool
|
403 |
-
*/
|
404 |
-
abstract function is_live();
|
405 |
-
|
406 |
-
/**
|
407 |
-
* Check if running premium plugin code.
|
408 |
-
*
|
409 |
-
* @since 1.0.5
|
410 |
-
*
|
411 |
-
* @return bool
|
412 |
-
*/
|
413 |
-
abstract function is_premium();
|
414 |
-
|
415 |
-
/**
|
416 |
-
* Get upgrade URL.
|
417 |
-
*
|
418 |
-
* @author Vova Feldman (@svovaf)
|
419 |
-
* @since 1.0.2
|
420 |
-
*
|
421 |
-
* @param string $period Billing cycle.
|
422 |
-
*
|
423 |
-
* @return string
|
424 |
-
*/
|
425 |
-
abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY );
|
426 |
-
|
427 |
-
/**
|
428 |
-
* Check if Freemius was first added in a plugin update.
|
429 |
-
*
|
430 |
-
* @author Vova Feldman (@svovaf)
|
431 |
-
* @since 1.1.5
|
432 |
-
*
|
433 |
-
* @return bool
|
434 |
-
*/
|
435 |
-
function is_plugin_update()
|
436 |
-
{
|
437 |
-
return !$this->is_plugin_new_install();
|
438 |
-
}
|
439 |
-
|
440 |
-
/**
|
441 |
-
* Check if Freemius was part of the plugin when the user installed it first.
|
442 |
-
*
|
443 |
-
* @author Vova Feldman (@svovaf)
|
444 |
-
* @since 1.1.5
|
445 |
-
*
|
446 |
-
* @return bool
|
447 |
-
*/
|
448 |
-
abstract function is_plugin_new_install();
|
449 |
-
|
450 |
-
#----------------------------------------------------------------------------------
|
451 |
-
#region Marketing
|
452 |
-
#----------------------------------------------------------------------------------
|
453 |
-
/**
|
454 |
-
* Check if current user purchased any other plugins before.
|
455 |
-
*
|
456 |
-
* @author Vova Feldman (@svovaf)
|
457 |
-
* @since 1.0.9
|
458 |
-
*
|
459 |
-
* @return bool
|
460 |
-
*/
|
461 |
-
abstract function has_purchased_before();
|
462 |
-
|
463 |
-
/**
|
464 |
-
* Check if current user classified as an agency.
|
465 |
-
*
|
466 |
-
* @author Vova Feldman (@svovaf)
|
467 |
-
* @since 1.0.9
|
468 |
-
*
|
469 |
-
* @return bool
|
470 |
-
*/
|
471 |
-
abstract function is_agency();
|
472 |
-
|
473 |
-
/**
|
474 |
-
* Check if current user classified as a developer.
|
475 |
-
*
|
476 |
-
* @author Vova Feldman (@svovaf)
|
477 |
-
* @since 1.0.9
|
478 |
-
*
|
479 |
-
* @return bool
|
480 |
-
*/
|
481 |
-
abstract function is_developer();
|
482 |
-
|
483 |
-
/**
|
484 |
-
* Check if current user classified as a business.
|
485 |
-
*
|
486 |
-
* @author Vova Feldman (@svovaf)
|
487 |
-
* @since 1.0.9
|
488 |
-
*
|
489 |
-
* @return bool
|
490 |
-
*/
|
491 |
-
abstract function is_business();
|
492 |
-
|
493 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
freemius/includes/class-freemius.php
DELETED
@@ -1,25364 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package Freemius
|
4 |
-
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
-
* @since 1.0.3
|
7 |
-
*/
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit;
|
10 |
-
}
|
11 |
-
|
12 |
-
// "final class"
|
13 |
-
class Freemius extends Freemius_Abstract {
|
14 |
-
/**
|
15 |
-
* SDK Version
|
16 |
-
*
|
17 |
-
* @var string
|
18 |
-
*/
|
19 |
-
public $version = WP_FS__SDK_VERSION;
|
20 |
-
|
21 |
-
#region Plugin Info
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @since 1.0.1
|
25 |
-
*
|
26 |
-
* @var string
|
27 |
-
*/
|
28 |
-
private $_slug;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @since 1.0.0
|
32 |
-
*
|
33 |
-
* @var string
|
34 |
-
*/
|
35 |
-
private $_plugin_basename;
|
36 |
-
/**
|
37 |
-
* @since 2.2.1
|
38 |
-
*
|
39 |
-
* @var string
|
40 |
-
*/
|
41 |
-
private $_premium_plugin_basename;
|
42 |
-
/**
|
43 |
-
* @since 1.0.0
|
44 |
-
*
|
45 |
-
* @var string
|
46 |
-
*/
|
47 |
-
private $_free_plugin_basename;
|
48 |
-
/**
|
49 |
-
* @since 1.0.0
|
50 |
-
*
|
51 |
-
* @var string
|
52 |
-
*/
|
53 |
-
private $_plugin_dir_path;
|
54 |
-
/**
|
55 |
-
* @since 1.0.0
|
56 |
-
*
|
57 |
-
* @var string
|
58 |
-
*/
|
59 |
-
private $_plugin_dir_name;
|
60 |
-
/**
|
61 |
-
* @since 1.0.0
|
62 |
-
*
|
63 |
-
* @var string
|
64 |
-
*/
|
65 |
-
private $_plugin_main_file_path;
|
66 |
-
/**
|
67 |
-
* @var string[]
|
68 |
-
*/
|
69 |
-
private $_plugin_data;
|
70 |
-
/**
|
71 |
-
* @since 1.0.9
|
72 |
-
*
|
73 |
-
* @var string
|
74 |
-
*/
|
75 |
-
private $_plugin_name;
|
76 |
-
/**
|
77 |
-
* @since 1.2.2
|
78 |
-
*
|
79 |
-
* @var string
|
80 |
-
*/
|
81 |
-
private $_module_type;
|
82 |
-
|
83 |
-
#endregion Plugin Info
|
84 |
-
|
85 |
-
/**
|
86 |
-
* @since 1.0.9
|
87 |
-
*
|
88 |
-
* @var bool If false, don't turn Freemius on.
|
89 |
-
*/
|
90 |
-
private $_is_on;
|
91 |
-
|
92 |
-
/**
|
93 |
-
* @since 1.1.3
|
94 |
-
*
|
95 |
-
* @var bool If false, don't turn Freemius on.
|
96 |
-
*/
|
97 |
-
private $_is_anonymous;
|
98 |
-
|
99 |
-
/**
|
100 |
-
* @since 1.0.9
|
101 |
-
* @var bool If false, issues with connectivity to Freemius API.
|
102 |
-
*/
|
103 |
-
private $_has_api_connection;
|
104 |
-
|
105 |
-
/**
|
106 |
-
* @since 1.0.9
|
107 |
-
* @since 2.0.0 Default to true since we need the property during the instance construction, prior to the dynamic_init() execution.
|
108 |
-
* @var bool Hints the SDK if plugin can support anonymous mode (if skip connect is visible).
|
109 |
-
*/
|
110 |
-
private $_enable_anonymous = true;
|
111 |
-
|
112 |
-
/**
|
113 |
-
* @since 1.1.7.5
|
114 |
-
* @var bool Hints the SDK if plugin should run in anonymous mode (only adds feedback form).
|
115 |
-
*/
|
116 |
-
private $_anonymous_mode;
|
117 |
-
|
118 |
-
/**
|
119 |
-
* @since 1.1.9
|
120 |
-
* @var bool Hints the SDK if plugin have any free plans.
|
121 |
-
*/
|
122 |
-
private $_is_premium_only;
|
123 |
-
|
124 |
-
/**
|
125 |
-
* @since 1.2.1.6
|
126 |
-
* @var bool Hints the SDK if plugin have premium code version at all.
|
127 |
-
*/
|
128 |
-
private $_has_premium_version;
|
129 |
-
|
130 |
-
/**
|
131 |
-
* @since 1.2.1.6
|
132 |
-
* @var bool Hints the SDK if plugin should ignore pending mode by simulating a skip.
|
133 |
-
*/
|
134 |
-
private $_ignore_pending_mode;
|
135 |
-
|
136 |
-
/**
|
137 |
-
* @since 1.0.8
|
138 |
-
* @var bool Hints the SDK if the plugin has any paid plans.
|
139 |
-
*/
|
140 |
-
private $_has_paid_plans;
|
141 |
-
|
142 |
-
/**
|
143 |
-
* @since 1.2.1.5
|
144 |
-
* @var int Hints the SDK if the plugin offers a trial period. If negative, no trial, if zero - has a trial but
|
145 |
-
* without a specified period, if positive - the number of trial days.
|
146 |
-
*/
|
147 |
-
private $_trial_days = - 1;
|
148 |
-
|
149 |
-
/**
|
150 |
-
* @since 1.2.1.5
|
151 |
-
* @var bool Hints the SDK if the trial requires a payment method or not.
|
152 |
-
*/
|
153 |
-
private $_is_trial_require_payment = false;
|
154 |
-
|
155 |
-
/**
|
156 |
-
* @since 1.0.7
|
157 |
-
* @var bool Hints the SDK if the plugin is WordPress.org compliant.
|
158 |
-
*/
|
159 |
-
private $_is_org_compliant;
|
160 |
-
|
161 |
-
/**
|
162 |
-
* @since 1.0.7
|
163 |
-
* @var bool Hints the SDK if the plugin is has add-ons.
|
164 |
-
*/
|
165 |
-
private $_has_addons;
|
166 |
-
|
167 |
-
/**
|
168 |
-
* @since 2.4.5
|
169 |
-
* @var string Navigation type: 'menu' or 'tabs'.
|
170 |
-
*/
|
171 |
-
private $_navigation;
|
172 |
-
|
173 |
-
const NAVIGATION_MENU = 'menu';
|
174 |
-
const NAVIGATION_TABS = 'tabs';
|
175 |
-
|
176 |
-
/**
|
177 |
-
* @since 1.1.6
|
178 |
-
* @var string[]bool.
|
179 |
-
*/
|
180 |
-
private $_permissions;
|
181 |
-
|
182 |
-
/**
|
183 |
-
* @var FS_Storage
|
184 |
-
*/
|
185 |
-
private $_storage;
|
186 |
-
|
187 |
-
/**
|
188 |
-
* @since 1.2.2.7
|
189 |
-
* @var FS_Cache_Manager
|
190 |
-
*/
|
191 |
-
private $_cache;
|
192 |
-
|
193 |
-
/**
|
194 |
-
* @since 1.0.0
|
195 |
-
*
|
196 |
-
* @var FS_Logger
|
197 |
-
*/
|
198 |
-
private $_logger;
|
199 |
-
/**
|
200 |
-
* @since 1.0.4
|
201 |
-
*
|
202 |
-
* @var FS_Plugin
|
203 |
-
*/
|
204 |
-
private $_plugin = false;
|
205 |
-
/**
|
206 |
-
* @since 1.0.4
|
207 |
-
*
|
208 |
-
* @var FS_Plugin|false
|
209 |
-
*/
|
210 |
-
private $_parent_plugin = false;
|
211 |
-
/**
|
212 |
-
* @since 1.1.1
|
213 |
-
*
|
214 |
-
* @var Freemius
|
215 |
-
*/
|
216 |
-
private $_parent = false;
|
217 |
-
/**
|
218 |
-
* @since 1.0.1
|
219 |
-
*
|
220 |
-
* @var FS_User
|
221 |
-
*/
|
222 |
-
private $_user = false;
|
223 |
-
/**
|
224 |
-
* @since 1.0.1
|
225 |
-
*
|
226 |
-
* @var FS_Site
|
227 |
-
*/
|
228 |
-
private $_site = false;
|
229 |
-
/**
|
230 |
-
* @since 1.0.1
|
231 |
-
*
|
232 |
-
* @var FS_Plugin_License
|
233 |
-
*/
|
234 |
-
private $_license;
|
235 |
-
/**
|
236 |
-
* @since 1.0.2
|
237 |
-
*
|
238 |
-
* @var FS_Plugin_Plan[]
|
239 |
-
*/
|
240 |
-
private $_plans = false;
|
241 |
-
/**
|
242 |
-
* @var FS_Plugin_License[]
|
243 |
-
* @since 1.0.5
|
244 |
-
*/
|
245 |
-
private $_licenses = false;
|
246 |
-
|
247 |
-
/**
|
248 |
-
* @since 1.0.1
|
249 |
-
*
|
250 |
-
* @var FS_Admin_Menu_Manager
|
251 |
-
*/
|
252 |
-
private $_menu;
|
253 |
-
|
254 |
-
/**
|
255 |
-
* @var FS_Admin_Notices
|
256 |
-
*/
|
257 |
-
private $_admin_notices;
|
258 |
-
|
259 |
-
/**
|
260 |
-
* @since 1.1.6
|
261 |
-
*
|
262 |
-
* @var FS_Admin_Notices
|
263 |
-
*/
|
264 |
-
private static $_global_admin_notices;
|
265 |
-
|
266 |
-
/**
|
267 |
-
* @var FS_Logger
|
268 |
-
* @since 1.0.0
|
269 |
-
*/
|
270 |
-
private static $_static_logger;
|
271 |
-
|
272 |
-
/**
|
273 |
-
* @var FS_Options
|
274 |
-
* @since 1.0.2
|
275 |
-
*/
|
276 |
-
private static $_accounts;
|
277 |
-
|
278 |
-
/**
|
279 |
-
* @since 1.2.2
|
280 |
-
*
|
281 |
-
* @var number
|
282 |
-
*/
|
283 |
-
private $_module_id;
|
284 |
-
|
285 |
-
/**
|
286 |
-
* @var Freemius[]
|
287 |
-
*/
|
288 |
-
private static $_instances = array();
|
289 |
-
|
290 |
-
/**
|
291 |
-
* @since 1.2.3
|
292 |
-
*
|
293 |
-
* @var FS_Affiliate
|
294 |
-
*/
|
295 |
-
private $affiliate = null;
|
296 |
-
|
297 |
-
/**
|
298 |
-
* @since 1.2.3
|
299 |
-
*
|
300 |
-
* @var FS_AffiliateTerms
|
301 |
-
*/
|
302 |
-
private $plugin_affiliate_terms = null;
|
303 |
-
|
304 |
-
/**
|
305 |
-
* @since 1.2.3
|
306 |
-
*
|
307 |
-
* @var FS_AffiliateTerms
|
308 |
-
*/
|
309 |
-
private $custom_affiliate_terms = null;
|
310 |
-
|
311 |
-
/**
|
312 |
-
* @since 2.0.0
|
313 |
-
*
|
314 |
-
* @var bool
|
315 |
-
*/
|
316 |
-
private $_is_multisite_integrated;
|
317 |
-
|
318 |
-
/**
|
319 |
-
* @since 2.0.0
|
320 |
-
*
|
321 |
-
* @var bool True if the current request is for a network admin screen and the plugin is network active.
|
322 |
-
*/
|
323 |
-
private $_is_network_active;
|
324 |
-
|
325 |
-
/**
|
326 |
-
* @since 2.0.0
|
327 |
-
*
|
328 |
-
* @var int|null The original blog ID the plugin was loaded with.
|
329 |
-
*/
|
330 |
-
private $_blog_id = null;
|
331 |
-
|
332 |
-
/**
|
333 |
-
* @since 2.0.0
|
334 |
-
*
|
335 |
-
* @var int|null The current execution context. When true, run on network context. When int, run on the specified blog context.
|
336 |
-
*/
|
337 |
-
private $_context_is_network_or_blog_id = null;
|
338 |
-
|
339 |
-
/**
|
340 |
-
* @since 2.0.0
|
341 |
-
*
|
342 |
-
* @var string
|
343 |
-
*/
|
344 |
-
private $_dynamically_added_top_level_page_hook_name = '';
|
345 |
-
|
346 |
-
/**
|
347 |
-
* @author Leo Fajardo (@leorw)
|
348 |
-
* @since 2.3.1
|
349 |
-
*
|
350 |
-
* @var bool
|
351 |
-
*/
|
352 |
-
private $is_whitelabeled;
|
353 |
-
|
354 |
-
/**
|
355 |
-
* @author Leo Fajardo (@leorw)
|
356 |
-
* @since 2.4.0
|
357 |
-
*
|
358 |
-
* @var bool
|
359 |
-
*/
|
360 |
-
private $_is_bundle_license_auto_activation_enabled = false;
|
361 |
-
|
362 |
-
#region Uninstall Reasons IDs
|
363 |
-
|
364 |
-
const REASON_NO_LONGER_NEEDED = 1;
|
365 |
-
const REASON_FOUND_A_BETTER_PLUGIN = 2;
|
366 |
-
const REASON_NEEDED_FOR_A_SHORT_PERIOD = 3;
|
367 |
-
const REASON_BROKE_MY_SITE = 4;
|
368 |
-
const REASON_SUDDENLY_STOPPED_WORKING = 5;
|
369 |
-
const REASON_CANT_PAY_ANYMORE = 6;
|
370 |
-
const REASON_OTHER = 7;
|
371 |
-
const REASON_DIDNT_WORK = 8;
|
372 |
-
const REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION = 9;
|
373 |
-
const REASON_COULDNT_MAKE_IT_WORK = 10;
|
374 |
-
const REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE = 11;
|
375 |
-
const REASON_NOT_WORKING = 12;
|
376 |
-
const REASON_NOT_WHAT_I_WAS_LOOKING_FOR = 13;
|
377 |
-
const REASON_DIDNT_WORK_AS_EXPECTED = 14;
|
378 |
-
const REASON_TEMPORARY_DEACTIVATION = 15;
|
379 |
-
|
380 |
-
/**
|
381 |
-
* @author Leo Fajardo (@leorw)
|
382 |
-
* @since 2.3.1
|
383 |
-
*
|
384 |
-
* @var boolean|null
|
385 |
-
*/
|
386 |
-
private $_use_external_pricing = null;
|
387 |
-
/**
|
388 |
-
* @author Leo Fajardo (@leorw)
|
389 |
-
* @since 2.4.2
|
390 |
-
*
|
391 |
-
* @var string|null
|
392 |
-
*/
|
393 |
-
private $_pricing_js_path = null;
|
394 |
-
|
395 |
-
#endregion
|
396 |
-
|
397 |
-
/* Ctor
|
398 |
-
------------------------------------------------------------------------------------------------------------------*/
|
399 |
-
|
400 |
-
/**
|
401 |
-
* Main singleton instance.
|
402 |
-
*
|
403 |
-
* @author Vova Feldman (@svovaf)
|
404 |
-
* @since 1.0.0
|
405 |
-
*
|
406 |
-
* @param number $module_id
|
407 |
-
* @param string|bool $slug
|
408 |
-
* @param bool $is_init Since 1.2.1 Is initiation sequence.
|
409 |
-
*/
|
410 |
-
private function __construct( $module_id, $slug = false, $is_init = false ) {
|
411 |
-
if ( $is_init && is_numeric( $module_id ) && is_string( $slug ) ) {
|
412 |
-
$this->store_id_slug_type_path_map( $module_id, $slug );
|
413 |
-
}
|
414 |
-
|
415 |
-
$this->_module_id = $module_id;
|
416 |
-
$this->_slug = $this->get_slug();
|
417 |
-
$this->_module_type = $this->get_module_type();
|
418 |
-
|
419 |
-
$this->_blog_id = is_multisite() ? get_current_blog_id() : null;
|
420 |
-
|
421 |
-
$this->_storage = FS_Storage::instance( $this->_module_type, $this->_slug );
|
422 |
-
|
423 |
-
$this->_cache = FS_Cache_Manager::get_manager( WP_FS___OPTION_PREFIX . "cache_{$module_id}" );
|
424 |
-
|
425 |
-
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $this->get_unique_affix(), WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
|
426 |
-
|
427 |
-
$this->_plugin_main_file_path = $this->_find_caller_plugin_file( $is_init );
|
428 |
-
$this->_plugin_dir_path = plugin_dir_path( $this->_plugin_main_file_path );
|
429 |
-
$this->_plugin_basename = $this->get_plugin_basename();
|
430 |
-
$this->_free_plugin_basename = str_replace( '-premium/', '/', $this->_plugin_basename );
|
431 |
-
|
432 |
-
$this->_is_multisite_integrated = (
|
433 |
-
defined( "WP_FS__PRODUCT_{$module_id}_MULTISITE" ) &&
|
434 |
-
( true === constant( "WP_FS__PRODUCT_{$module_id}_MULTISITE" ) )
|
435 |
-
);
|
436 |
-
|
437 |
-
$this->_is_network_active = (
|
438 |
-
is_multisite() &&
|
439 |
-
$this->_is_multisite_integrated &&
|
440 |
-
// Themes are always network activated, but the ACTUAL activation is per site.
|
441 |
-
$this->is_plugin() &&
|
442 |
-
(
|
443 |
-
is_plugin_active_for_network( $this->_plugin_basename ) ||
|
444 |
-
// Plugin network level activation or uninstall.
|
445 |
-
( fs_is_network_admin() && is_plugin_inactive( $this->_plugin_basename ) )
|
446 |
-
)
|
447 |
-
);
|
448 |
-
|
449 |
-
$this->_storage->set_network_active(
|
450 |
-
$this->_is_network_active,
|
451 |
-
$this->is_delegated_connection()
|
452 |
-
);
|
453 |
-
|
454 |
-
if ( ! isset( $this->_storage->is_network_activated ) ) {
|
455 |
-
$this->_storage->is_network_activated = $this->_is_network_active;
|
456 |
-
}
|
457 |
-
|
458 |
-
if ( $this->_storage->is_network_activated != $this->_is_network_active ) {
|
459 |
-
// Update last activation level.
|
460 |
-
$this->_storage->is_network_activated = $this->_is_network_active;
|
461 |
-
|
462 |
-
$this->maybe_adjust_storage();
|
463 |
-
}
|
464 |
-
|
465 |
-
#region Migration
|
466 |
-
|
467 |
-
if ( is_multisite() ) {
|
468 |
-
/**
|
469 |
-
* If the install_timestamp exists on the site level but doesn't exist on the
|
470 |
-
* network level storage, it means that we need to process the storage with migration.
|
471 |
-
*
|
472 |
-
* The code in this `if` scope will only be executed once and only for the first site that will execute it because once we migrate the storage data, install_timestamp will be already set in the network level storage.
|
473 |
-
*
|
474 |
-
* @author Vova Feldman (@svovaf)
|
475 |
-
* @since 2.0.0
|
476 |
-
*/
|
477 |
-
if ( false === $this->_storage->get( 'install_timestamp', false, true ) &&
|
478 |
-
false !== $this->_storage->get( 'install_timestamp', false, false )
|
479 |
-
) {
|
480 |
-
// Initiate storage migration.
|
481 |
-
$this->_storage->migrate_to_network();
|
482 |
-
|
483 |
-
// Migrate module cache to network level storage.
|
484 |
-
$this->_cache->migrate_to_network();
|
485 |
-
}
|
486 |
-
}
|
487 |
-
|
488 |
-
#endregion
|
489 |
-
|
490 |
-
$base_name_split = explode( '/', $this->_plugin_basename );
|
491 |
-
$this->_plugin_dir_name = $base_name_split[0];
|
492 |
-
|
493 |
-
if ( $this->_logger->is_on() ) {
|
494 |
-
$this->_logger->info( 'plugin_main_file_path = ' . $this->_plugin_main_file_path );
|
495 |
-
$this->_logger->info( 'plugin_dir_path = ' . $this->_plugin_dir_path );
|
496 |
-
$this->_logger->info( 'plugin_basename = ' . $this->_plugin_basename );
|
497 |
-
$this->_logger->info( 'free_plugin_basename = ' . $this->_free_plugin_basename );
|
498 |
-
$this->_logger->info( 'plugin_dir_name = ' . $this->_plugin_dir_name );
|
499 |
-
}
|
500 |
-
|
501 |
-
// Remember link between file to slug.
|
502 |
-
$this->store_file_slug_map();
|
503 |
-
|
504 |
-
// Store plugin's initial install timestamp.
|
505 |
-
if ( ! isset( $this->_storage->install_timestamp ) ) {
|
506 |
-
$this->_storage->install_timestamp = WP_FS__SCRIPT_START_TIME;
|
507 |
-
}
|
508 |
-
|
509 |
-
if ( ! is_object( $this->_plugin ) ) {
|
510 |
-
$this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->get();
|
511 |
-
}
|
512 |
-
|
513 |
-
$this->_admin_notices = FS_Admin_Notices::instance(
|
514 |
-
$this->_slug . ( $this->is_theme() ? ':theme' : '' ),
|
515 |
-
/**
|
516 |
-
* Ensure that the admin notice will always have a title by using the stored plugin title if available and
|
517 |
-
* retrieving the title via the "get_plugin_name" method if there is no stored plugin title available.
|
518 |
-
*
|
519 |
-
* @author Leo Fajardo (@leorw)
|
520 |
-
* @since 1.2.2
|
521 |
-
*/
|
522 |
-
( is_object( $this->_plugin ) ? $this->_plugin->title : $this->get_plugin_name() ),
|
523 |
-
$this->get_unique_affix()
|
524 |
-
);
|
525 |
-
|
526 |
-
if ( 'true' === fs_request_get( 'fs_clear_api_cache' ) ||
|
527 |
-
fs_request_is_action( 'restart_freemius' )
|
528 |
-
) {
|
529 |
-
FS_Api::clear_cache();
|
530 |
-
$this->_cache->clear();
|
531 |
-
}
|
532 |
-
|
533 |
-
$this->register_constructor_hooks();
|
534 |
-
|
535 |
-
/**
|
536 |
-
* Starting from version 2.0.0, `FS_Site` entities no longer have the `plan` property and have `plan_id`
|
537 |
-
* instead. This should be called before calling `_load_account()`, otherwise, `$this->_site` will not be
|
538 |
-
* loaded in `_load_account` for versions of SDK starting from 2.0.0.
|
539 |
-
*
|
540 |
-
* @author Leo Fajardo (@leorw)
|
541 |
-
*/
|
542 |
-
self::migrate_install_plan_to_plan_id( $this->_storage );
|
543 |
-
|
544 |
-
$this->_load_account();
|
545 |
-
|
546 |
-
$this->_version_updates_handler();
|
547 |
-
}
|
548 |
-
|
549 |
-
/**
|
550 |
-
* @author Leo Fajardo (@leorw)
|
551 |
-
* @since 2.3.0
|
552 |
-
*/
|
553 |
-
private function maybe_adjust_storage() {
|
554 |
-
$install_timestamp = null;
|
555 |
-
$prev_is_premium = null;
|
556 |
-
|
557 |
-
$options_to_update = array();
|
558 |
-
|
559 |
-
$is_network_admin = fs_is_network_admin();
|
560 |
-
|
561 |
-
$network_install_timestamp = $this->_storage->get( 'install_timestamp', null, true );
|
562 |
-
|
563 |
-
if ( ! $is_network_admin ) {
|
564 |
-
if ( is_null( $network_install_timestamp ) ) {
|
565 |
-
// Plugin was not network-activated before.
|
566 |
-
return;
|
567 |
-
}
|
568 |
-
|
569 |
-
if ( is_null( $this->_storage->get( 'install_timestamp', null, false ) ) ) {
|
570 |
-
// Set the `install_timestamp` only if it's not yet set.
|
571 |
-
$install_timestamp = $network_install_timestamp;
|
572 |
-
}
|
573 |
-
|
574 |
-
$prev_is_premium = $this->_storage->get( 'prev_is_premium', null, true );
|
575 |
-
} else {
|
576 |
-
$current_wp_user = self::_get_current_wp_user();
|
577 |
-
$current_fs_user = self::_get_user_by_email( $current_wp_user->user_email );
|
578 |
-
$network_user_info = array();
|
579 |
-
|
580 |
-
$skips_count = 0;
|
581 |
-
|
582 |
-
$sites = self::get_sites();
|
583 |
-
$sites_count = count( $sites );
|
584 |
-
|
585 |
-
$blog_id_2_install_map = array();
|
586 |
-
|
587 |
-
$is_first_non_ignored_blog = true;
|
588 |
-
|
589 |
-
foreach ( $sites as $site ) {
|
590 |
-
$blog_id = self::get_site_blog_id( $site );
|
591 |
-
|
592 |
-
$blog_install_timestamp = $this->_storage->get( 'install_timestamp', null, $blog_id );
|
593 |
-
|
594 |
-
if ( is_null( $blog_install_timestamp ) ) {
|
595 |
-
// Plugin has not been installed on this blog.
|
596 |
-
continue;
|
597 |
-
}
|
598 |
-
|
599 |
-
$is_earlier_install = (
|
600 |
-
! is_null( $install_timestamp ) &&
|
601 |
-
$blog_install_timestamp < $install_timestamp
|
602 |
-
);
|
603 |
-
|
604 |
-
$install = $this->get_install_by_blog_id( $blog_id );
|
605 |
-
|
606 |
-
$update_network_user_info = false;
|
607 |
-
|
608 |
-
if ( ! is_object( $install ) ) {
|
609 |
-
if ( ! $this->_storage->get( 'is_anonymous', false, $blog_id ) ) {
|
610 |
-
// The opt-in decision (whether to skip or opt in) is yet to be made.
|
611 |
-
continue;
|
612 |
-
}
|
613 |
-
|
614 |
-
$skips_count ++;
|
615 |
-
} else {
|
616 |
-
$blog_id_2_install_map[ $blog_id ] = $install;
|
617 |
-
|
618 |
-
if ( empty( $network_user_info ) ) {
|
619 |
-
// Set the network user info for the 1st time. Choose any user information whether or not it is for the current WP user.
|
620 |
-
$update_network_user_info = true;
|
621 |
-
}
|
622 |
-
|
623 |
-
if ( ! $update_network_user_info &&
|
624 |
-
is_object( $current_fs_user ) &&
|
625 |
-
$network_user_info['user_id'] != $current_fs_user->id &&
|
626 |
-
$install->user_id == $current_fs_user->id
|
627 |
-
) {
|
628 |
-
// If an install that is owned by the current WP user is found, use its user information instead.
|
629 |
-
$update_network_user_info = true;
|
630 |
-
}
|
631 |
-
|
632 |
-
if ( ! $update_network_user_info &&
|
633 |
-
$is_earlier_install &&
|
634 |
-
( ! is_object( $current_fs_user ) || $current_fs_user->id == $install->user_id )
|
635 |
-
) {
|
636 |
-
// Update to the earliest install info if there's no install found so far that is owned by the current WP user; OR only if the found install is owned by the current WP user.
|
637 |
-
$update_network_user_info = true;
|
638 |
-
}
|
639 |
-
}
|
640 |
-
|
641 |
-
if ( $update_network_user_info ) {
|
642 |
-
$network_user_info = array(
|
643 |
-
'user_id' => $install->user_id,
|
644 |
-
'blog_id' => $blog_id
|
645 |
-
);
|
646 |
-
}
|
647 |
-
|
648 |
-
$site_prev_is_premium = $this->_storage->get( 'prev_is_premium', null, $blog_id );
|
649 |
-
|
650 |
-
if ( $is_first_non_ignored_blog ) {
|
651 |
-
$prev_is_premium = $site_prev_is_premium;
|
652 |
-
|
653 |
-
if ( is_null( $network_install_timestamp ) ) {
|
654 |
-
$install_timestamp = $blog_install_timestamp;
|
655 |
-
}
|
656 |
-
|
657 |
-
$is_first_non_ignored_blog = false;
|
658 |
-
|
659 |
-
continue;
|
660 |
-
}
|
661 |
-
|
662 |
-
if ( ! is_null( $prev_is_premium ) && $prev_is_premium !== $site_prev_is_premium ) {
|
663 |
-
// If a different `$site_prev_is_premium` value is found, do not include the option in the collection of options to update.
|
664 |
-
$prev_is_premium = null;
|
665 |
-
}
|
666 |
-
|
667 |
-
if ( $is_earlier_install ) {
|
668 |
-
// If an earlier install timestamp is found.
|
669 |
-
$install_timestamp = $blog_install_timestamp;
|
670 |
-
}
|
671 |
-
}
|
672 |
-
|
673 |
-
$installs_count = count( $blog_id_2_install_map );
|
674 |
-
|
675 |
-
if ( $sites_count === ( $installs_count + $skips_count ) ) {
|
676 |
-
if ( ! empty( $network_user_info ) ) {
|
677 |
-
$options_to_update['network_user_id'] = $network_user_info['user_id'];
|
678 |
-
$options_to_update['network_install_blog_id'] = $network_user_info['blog_id'];
|
679 |
-
|
680 |
-
foreach ( $blog_id_2_install_map as $blog_id => $install ) {
|
681 |
-
if ( $install->user_id == $network_user_info['user_id'] ) {
|
682 |
-
continue;
|
683 |
-
}
|
684 |
-
|
685 |
-
$this->_storage->store( 'is_delegated_connection', true, $blog_id );
|
686 |
-
}
|
687 |
-
}
|
688 |
-
|
689 |
-
if ( $sites_count === $skips_count ) {
|
690 |
-
/**
|
691 |
-
* Assume network-level skipping as the intended action if all actions identified were only
|
692 |
-
* skipping of the connection (i.e., no opt-ins and delegated connections so far).
|
693 |
-
*/
|
694 |
-
$options_to_update['is_anonymous_ms'] = true;
|
695 |
-
} else if ( $sites_count === $installs_count ) {
|
696 |
-
/**
|
697 |
-
* Assume network-level opt-in as the intended action if all actions identified were only opt-ins
|
698 |
-
* (i.e., no delegation and skipping of the connections so far).
|
699 |
-
*/
|
700 |
-
$options_to_update['is_network_connected'] = true;
|
701 |
-
}
|
702 |
-
}
|
703 |
-
}
|
704 |
-
|
705 |
-
if ( ! is_null( $install_timestamp ) ) {
|
706 |
-
$options_to_update['install_timestamp'] = $install_timestamp;
|
707 |
-
}
|
708 |
-
|
709 |
-
if ( ! is_null( $prev_is_premium ) ) {
|
710 |
-
$options_to_update['prev_is_premium'] = $prev_is_premium;
|
711 |
-
}
|
712 |
-
|
713 |
-
if ( ! empty( $options_to_update ) ) {
|
714 |
-
$this->adjust_storage( $options_to_update, $is_network_admin );
|
715 |
-
}
|
716 |
-
}
|
717 |
-
|
718 |
-
/**
|
719 |
-
* @author Leo Fajardo (@leorw)
|
720 |
-
* @since 2.3.0
|
721 |
-
*
|
722 |
-
* @param array $options
|
723 |
-
* @param bool $is_network_admin
|
724 |
-
*/
|
725 |
-
private function adjust_storage( $options, $is_network_admin ) {
|
726 |
-
foreach ( $options as $name => $value ) {
|
727 |
-
$this->_storage->store( $name, $value, $is_network_admin ? true : null );
|
728 |
-
}
|
729 |
-
}
|
730 |
-
|
731 |
-
/**
|
732 |
-
* Checks whether this module has a settings menu.
|
733 |
-
*
|
734 |
-
* @author Leo Fajardo (@leorw)
|
735 |
-
* @since 1.2.2
|
736 |
-
*
|
737 |
-
* @return bool
|
738 |
-
*/
|
739 |
-
function has_settings_menu() {
|
740 |
-
return ( $this->_is_network_active && fs_is_network_admin() ) ?
|
741 |
-
$this->_menu->has_network_menu() :
|
742 |
-
$this->_menu->has_menu();
|
743 |
-
}
|
744 |
-
|
745 |
-
/**
|
746 |
-
* If `true` the opt-in should be shown as a modal dialog box on the themes.php page. WordPress.org themes guidelines prohibit from redirecting the user from the themes.php page after activating a theme.
|
747 |
-
*
|
748 |
-
* @author Vova Feldman (@svovaf)
|
749 |
-
* @since 2.4.5
|
750 |
-
*
|
751 |
-
* @return bool
|
752 |
-
*/
|
753 |
-
function show_opt_in_on_themes_page() {
|
754 |
-
if ( ! $this->is_free_wp_org_theme() ) {
|
755 |
-
return false;
|
756 |
-
}
|
757 |
-
|
758 |
-
if ( ! $this->has_settings_menu() ) {
|
759 |
-
return true;
|
760 |
-
}
|
761 |
-
|
762 |
-
return $this->show_settings_with_tabs();
|
763 |
-
}
|
764 |
-
|
765 |
-
/**
|
766 |
-
* If `true` the opt-in should be shown on the product's main setting page.
|
767 |
-
*
|
768 |
-
* @author Vova Feldman (@svovaf)
|
769 |
-
* @since 2.4.5
|
770 |
-
*
|
771 |
-
* @return bool
|
772 |
-
*
|
773 |
-
* @uses show_opt_in_on_themes_page();
|
774 |
-
*/
|
775 |
-
function show_opt_in_on_setting_page() {
|
776 |
-
return ! $this->show_opt_in_on_themes_page();
|
777 |
-
}
|
778 |
-
|
779 |
-
/**
|
780 |
-
* If `true` the settings should be shown using tabs.
|
781 |
-
*
|
782 |
-
* @author Vova Feldman (@svovaf)
|
783 |
-
* @since 2.4.5
|
784 |
-
*
|
785 |
-
* @return bool
|
786 |
-
*/
|
787 |
-
function show_settings_with_tabs() {
|
788 |
-
return ( self::NAVIGATION_TABS === $this->_navigation );
|
789 |
-
}
|
790 |
-
|
791 |
-
/**
|
792 |
-
* Check if the context module is free wp.org theme.
|
793 |
-
*
|
794 |
-
* This method is helpful because:
|
795 |
-
* 1. wp.org themes are limited to a single submenu item,
|
796 |
-
* and sub-submenu items are most likely not allowed (never verified).
|
797 |
-
* 2. wp.org themes are not allowed to redirect the user
|
798 |
-
* after the theme activation, therefore, the agreed UX
|
799 |
-
* is showing the opt-in as a modal dialog box after
|
800 |
-
* activation (approved by @otto42, @emiluzelac, @greenshady, @grapplerulrich).
|
801 |
-
*
|
802 |
-
* @author Vova Feldman (@svovaf)
|
803 |
-
* @since 1.2.2.7
|
804 |
-
*
|
805 |
-
* @return bool
|
806 |
-
*/
|
807 |
-
function is_free_wp_org_theme() {
|
808 |
-
return (
|
809 |
-
$this->is_theme() &&
|
810 |
-
$this->is_org_repo_compliant() &&
|
811 |
-
! $this->is_premium()
|
812 |
-
);
|
813 |
-
}
|
814 |
-
|
815 |
-
/**
|
816 |
-
* Checks whether this a submenu item is visible.
|
817 |
-
*
|
818 |
-
* @author Vova Feldman (@svovaf)
|
819 |
-
* @since 1.2.2.6
|
820 |
-
* @since 1.2.2.7 Even if the menu item was specified to be hidden, when it is the context page, then show the submenu item so the user will have the right context page.
|
821 |
-
*
|
822 |
-
* @param string $slug
|
823 |
-
* @param bool $is_tabs_visibility_check This is used to decide if the associated tab should be shown or hidden.
|
824 |
-
*
|
825 |
-
* @return bool
|
826 |
-
*/
|
827 |
-
function is_submenu_item_visible( $slug, $is_tabs_visibility_check = false ) {
|
828 |
-
if ( $this->is_admin_page( $slug ) ) {
|
829 |
-
/**
|
830 |
-
* It is the current context page, so show the submenu item
|
831 |
-
* so the user will have the right context page, even if it
|
832 |
-
* was set to hidden.
|
833 |
-
*/
|
834 |
-
return true;
|
835 |
-
}
|
836 |
-
|
837 |
-
if ( ! $this->has_settings_menu() ) {
|
838 |
-
// No menu settings at all.
|
839 |
-
return false;
|
840 |
-
}
|
841 |
-
|
842 |
-
if (
|
843 |
-
! $is_tabs_visibility_check &&
|
844 |
-
$this->is_org_repo_compliant() &&
|
845 |
-
$this->show_settings_with_tabs()
|
846 |
-
) {
|
847 |
-
/**
|
848 |
-
* wp.org themes are limited to a single submenu item, and
|
849 |
-
* sub-submenu items are most likely not allowed (never verified).
|
850 |
-
*/
|
851 |
-
return false;
|
852 |
-
}
|
853 |
-
|
854 |
-
return $this->_menu->is_submenu_item_visible( $slug );
|
855 |
-
}
|
856 |
-
|
857 |
-
/**
|
858 |
-
* Check if a Freemius page should be accessible via the UI.
|
859 |
-
*
|
860 |
-
* @author Vova Feldman (@svovaf)
|
861 |
-
* @since 1.2.2.7
|
862 |
-
*
|
863 |
-
* @param string $slug
|
864 |
-
*
|
865 |
-
* @return bool
|
866 |
-
*/
|
867 |
-
function is_page_visible( $slug ) {
|
868 |
-
if ( $this->is_admin_page( $slug ) ) {
|
869 |
-
return true;
|
870 |
-
}
|
871 |
-
|
872 |
-
return $this->_menu->is_submenu_item_visible( $slug, true, true );
|
873 |
-
}
|
874 |
-
|
875 |
-
/**
|
876 |
-
* @author Vova Feldman (@svovaf)
|
877 |
-
* @since 1.0.9
|
878 |
-
*/
|
879 |
-
private function _version_updates_handler() {
|
880 |
-
if ( ! isset( $this->_storage->sdk_version ) || $this->_storage->sdk_version != $this->version ) {
|
881 |
-
// Freemius version upgrade mode.
|
882 |
-
$this->_storage->sdk_last_version = $this->_storage->sdk_version;
|
883 |
-
$this->_storage->sdk_version = $this->version;
|
884 |
-
|
885 |
-
if ( empty( $this->_storage->sdk_last_version ) ||
|
886 |
-
version_compare( $this->_storage->sdk_last_version, $this->version, '<' )
|
887 |
-
) {
|
888 |
-
$this->_storage->sdk_upgrade_mode = true;
|
889 |
-
$this->_storage->sdk_downgrade_mode = false;
|
890 |
-
} else {
|
891 |
-
$this->_storage->sdk_downgrade_mode = true;
|
892 |
-
$this->_storage->sdk_upgrade_mode = false;
|
893 |
-
|
894 |
-
}
|
895 |
-
|
896 |
-
$this->do_action( 'sdk_version_update', $this->_storage->sdk_last_version, $this->version );
|
897 |
-
}
|
898 |
-
|
899 |
-
$plugin_version = $this->get_plugin_version();
|
900 |
-
if ( ! isset( $this->_storage->plugin_version ) || $this->_storage->plugin_version != $plugin_version ) {
|
901 |
-
// Plugin version upgrade mode.
|
902 |
-
$this->_storage->plugin_last_version = $this->_storage->plugin_version;
|
903 |
-
$this->_storage->plugin_version = $plugin_version;
|
904 |
-
|
905 |
-
if ( empty( $this->_storage->plugin_last_version ) ||
|
906 |
-
version_compare( $this->_storage->plugin_last_version, $plugin_version, '<' )
|
907 |
-
) {
|
908 |
-
$this->_storage->plugin_upgrade_mode = true;
|
909 |
-
$this->_storage->plugin_downgrade_mode = false;
|
910 |
-
} else {
|
911 |
-
$this->_storage->plugin_downgrade_mode = true;
|
912 |
-
$this->_storage->plugin_upgrade_mode = false;
|
913 |
-
}
|
914 |
-
|
915 |
-
if ( ! empty( $this->_storage->plugin_last_version ) ) {
|
916 |
-
// Different version of the plugin was installed before, therefore it's an update.
|
917 |
-
$this->_storage->is_plugin_new_install = false;
|
918 |
-
}
|
919 |
-
|
920 |
-
$this->do_action( 'plugin_version_update', $this->_storage->plugin_last_version, $plugin_version );
|
921 |
-
}
|
922 |
-
}
|
923 |
-
|
924 |
-
#--------------------------------------------------------------------------------
|
925 |
-
#region Data Migration on SDK Update
|
926 |
-
#--------------------------------------------------------------------------------
|
927 |
-
|
928 |
-
/**
|
929 |
-
* @author Vova Feldman (@svovaf)
|
930 |
-
* @since 1.1.5
|
931 |
-
*
|
932 |
-
* @param string $sdk_prev_version
|
933 |
-
* @param string $sdk_version
|
934 |
-
*/
|
935 |
-
function _sdk_version_update( $sdk_prev_version, $sdk_version ) {
|
936 |
-
/**
|
937 |
-
* @since 1.1.7.3 Fixed unwanted connectivity test cleanup.
|
938 |
-
*/
|
939 |
-
if ( empty( $sdk_prev_version ) ) {
|
940 |
-
return;
|
941 |
-
}
|
942 |
-
|
943 |
-
if ( version_compare( $sdk_prev_version, '2.1.0', '<' ) &&
|
944 |
-
version_compare( $sdk_version, '2.1.0', '>=' )
|
945 |
-
) {
|
946 |
-
$this->_storage->handle_gdpr_admin_notice = true;
|
947 |
-
}
|
948 |
-
|
949 |
-
if ( version_compare( $sdk_prev_version, '2.0.0', '<' ) &&
|
950 |
-
version_compare( $sdk_version, '2.0.0', '>=' )
|
951 |
-
) {
|
952 |
-
$this->migrate_to_subscriptions_collection();
|
953 |
-
|
954 |
-
$this->consolidate_licenses();
|
955 |
-
|
956 |
-
// Clear trial_plan since it's now loaded from the plans collection when needed.
|
957 |
-
$this->_storage->remove( 'trial_plan', true, false );
|
958 |
-
}
|
959 |
-
|
960 |
-
if ( version_compare( $sdk_prev_version, '1.2.3', '<' ) &&
|
961 |
-
version_compare( $sdk_version, '1.2.3', '>=' )
|
962 |
-
) {
|
963 |
-
/**
|
964 |
-
* Starting from version 1.2.3, paths are stored as relative instead of absolute and some of them can be
|
965 |
-
* invalid.
|
966 |
-
*
|
967 |
-
* @author Leo Fajardo (@leorw)
|
968 |
-
*/
|
969 |
-
$this->remove_invalid_paths();
|
970 |
-
}
|
971 |
-
|
972 |
-
if ( version_compare( $sdk_prev_version, '1.1.5', '<' ) &&
|
973 |
-
version_compare( $sdk_version, '1.1.5', '>=' )
|
974 |
-
) {
|
975 |
-
// On version 1.1.5 merged connectivity and is_on data.
|
976 |
-
if ( isset( $this->_storage->connectivity_test ) ) {
|
977 |
-
if ( ! isset( $this->_storage->is_on ) ) {
|
978 |
-
unset( $this->_storage->connectivity_test );
|
979 |
-
} else {
|
980 |
-
$connectivity_data = $this->_storage->connectivity_test;
|
981 |
-
$connectivity_data['is_active'] = $this->_storage->is_on['is_active'];
|
982 |
-
$connectivity_data['timestamp'] = $this->_storage->is_on['timestamp'];
|
983 |
-
|
984 |
-
// Override.
|
985 |
-
$this->_storage->connectivity_test = $connectivity_data;
|
986 |
-
|
987 |
-
// Remove previous structure.
|
988 |
-
unset( $this->_storage->is_on );
|
989 |
-
}
|
990 |
-
|
991 |
-
}
|
992 |
-
}
|
993 |
-
|
994 |
-
if (
|
995 |
-
version_compare( $sdk_prev_version, '2.2.1', '<' ) &&
|
996 |
-
version_compare( $sdk_version, '2.2.1', '>=' )
|
997 |
-
) {
|
998 |
-
/**
|
999 |
-
* Clear the file cache without storing the previous path since it could be a wrong path. For example,
|
1000 |
-
* in the versions of the SDK lower than 2.2.1, it's possible for the path of an add-on to be the same
|
1001 |
-
* as the parent plugin's when the add-on was auto-installed since the relevant method names were not
|
1002 |
-
* skipped in the logic that determines the right path in the `get_caller_main_file_and_type` method
|
1003 |
-
* (e.g. `try_activate_plugin`). Since it was an auto-installation, the caller was the parent plugin
|
1004 |
-
* and so its path was used. In case the stored path is wrong, clearing the cache will resolve issues
|
1005 |
-
* related to data mix-up between plugins (e.g. titles and versions of an add-on and its parent plugin).
|
1006 |
-
*
|
1007 |
-
* @author Leo Fajardo (@leorw)
|
1008 |
-
* @since 2.2.1
|
1009 |
-
*/
|
1010 |
-
$this->clear_module_main_file_cache( false );
|
1011 |
-
}
|
1012 |
-
}
|
1013 |
-
|
1014 |
-
/**
|
1015 |
-
* @author Leo Fajardo (@leorw)
|
1016 |
-
* @since 2.0.0
|
1017 |
-
*
|
1018 |
-
* @param \FS_Storage $storage
|
1019 |
-
* @param bool|int|null $blog_id
|
1020 |
-
*/
|
1021 |
-
private static function migrate_install_plan_to_plan_id( FS_Storage $storage, $blog_id = null ) {
|
1022 |
-
if ( empty( $storage->sdk_version ) ) {
|
1023 |
-
// New installation of the plugin, no need to upgrade.
|
1024 |
-
return;
|
1025 |
-
}
|
1026 |
-
|
1027 |
-
if ( ! version_compare( $storage->sdk_version, '2.0.0', '<' ) ) {
|
1028 |
-
// Previous version is >= 2.0.0, so no need to migrate.
|
1029 |
-
return;
|
1030 |
-
}
|
1031 |
-
|
1032 |
-
// Alias.
|
1033 |
-
$module_type = $storage->get_module_type();
|
1034 |
-
$module_slug = $storage->get_module_slug();
|
1035 |
-
|
1036 |
-
$installs = self::get_all_sites( $module_type, $blog_id );
|
1037 |
-
$install = isset( $installs[ $module_slug ] ) ? $installs[ $module_slug ] : null;
|
1038 |
-
|
1039 |
-
if ( ! is_object( $install ) ) {
|
1040 |
-
return;
|
1041 |
-
}
|
1042 |
-
|
1043 |
-
if ( isset( $install->plan ) && is_object( $install->plan ) ) {
|
1044 |
-
if ( isset( $install->plan->id ) && ! empty( $install->plan->id ) ) {
|
1045 |
-
$install->plan_id = self::_decrypt( $install->plan->id );
|
1046 |
-
}
|
1047 |
-
|
1048 |
-
unset( $install->plan );
|
1049 |
-
|
1050 |
-
$installs[ $module_slug ] = clone $install;
|
1051 |
-
|
1052 |
-
self::set_account_option_by_module(
|
1053 |
-
$module_type,
|
1054 |
-
'sites',
|
1055 |
-
$installs,
|
1056 |
-
true,
|
1057 |
-
$blog_id
|
1058 |
-
);
|
1059 |
-
}
|
1060 |
-
}
|
1061 |
-
|
1062 |
-
/**
|
1063 |
-
* @author Leo Fajardo (@leorw)
|
1064 |
-
* @since 2.0.0
|
1065 |
-
*/
|
1066 |
-
private function migrate_to_subscriptions_collection() {
|
1067 |
-
if ( ! is_object( $this->_site ) ) {
|
1068 |
-
return;
|
1069 |
-
}
|
1070 |
-
|
1071 |
-
if ( isset( $this->_storage->subscription ) && is_object( $this->_storage->subscription ) ) {
|
1072 |
-
$this->_storage->subscriptions = array( fs_get_entity( $this->_storage->subscription, FS_Subscription::get_class_name() ) );
|
1073 |
-
}
|
1074 |
-
}
|
1075 |
-
|
1076 |
-
/**
|
1077 |
-
* @author Leo Fajardo (@leorw)
|
1078 |
-
* @since 2.0.0
|
1079 |
-
*/
|
1080 |
-
private function consolidate_licenses() {
|
1081 |
-
$plugin_licenses = self::get_account_option( 'licenses', WP_FS__MODULE_TYPE_PLUGIN );
|
1082 |
-
if ( isset( $plugin_licenses[ $this->_slug ] ) ) {
|
1083 |
-
$plugin_licenses = $plugin_licenses[ $this->_slug ];
|
1084 |
-
} else {
|
1085 |
-
$plugin_licenses = array();
|
1086 |
-
}
|
1087 |
-
|
1088 |
-
$theme_licenses = self::get_account_option( 'licenses', WP_FS__MODULE_TYPE_THEME );
|
1089 |
-
if ( isset( $theme_licenses[ $this->_slug ] ) ) {
|
1090 |
-
$theme_licenses = $theme_licenses[ $this->_slug ];
|
1091 |
-
} else {
|
1092 |
-
$theme_licenses = array();
|
1093 |
-
}
|
1094 |
-
|
1095 |
-
if ( empty( $plugin_licenses ) && empty( $theme_licenses ) ) {
|
1096 |
-
return;
|
1097 |
-
}
|
1098 |
-
|
1099 |
-
$all_licenses = array();
|
1100 |
-
$user_id_license_ids_map = array();
|
1101 |
-
|
1102 |
-
foreach ( $plugin_licenses as $user_id => $user_licenses ) {
|
1103 |
-
if ( is_array( $user_licenses ) ) {
|
1104 |
-
if ( ! isset( $user_license_ids[ $user_id ] ) ) {
|
1105 |
-
$user_id_license_ids_map[ $user_id ] = array();
|
1106 |
-
}
|
1107 |
-
|
1108 |
-
foreach ( $user_licenses as $user_license ) {
|
1109 |
-
$all_licenses[] = $user_license;
|
1110 |
-
$user_id_license_ids_map[ $user_id ][] = $user_license->id;
|
1111 |
-
}
|
1112 |
-
}
|
1113 |
-
}
|
1114 |
-
|
1115 |
-
foreach ( $theme_licenses as $user_id => $user_licenses ) {
|
1116 |
-
if ( is_array( $user_licenses ) ) {
|
1117 |
-
if ( ! isset( $user_license_ids[ $user_id ] ) ) {
|
1118 |
-
$user_id_license_ids_map[ $user_id ] = array();
|
1119 |
-
}
|
1120 |
-
|
1121 |
-
foreach ( $user_licenses as $user_license ) {
|
1122 |
-
$all_licenses[] = $user_license;
|
1123 |
-
$user_id_license_ids_map[ $user_id ][] = $user_license->id;
|
1124 |
-
}
|
1125 |
-
}
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
self::store_user_id_license_ids_map(
|
1129 |
-
$user_id_license_ids_map,
|
1130 |
-
$this->_module_id
|
1131 |
-
);
|
1132 |
-
|
1133 |
-
$this->_store_licenses( true, $this->_module_id, $all_licenses );
|
1134 |
-
}
|
1135 |
-
|
1136 |
-
/**
|
1137 |
-
* Remove invalid paths.
|
1138 |
-
*
|
1139 |
-
* @author Leo Fajardo (@leorw)
|
1140 |
-
* @since 1.2.3
|
1141 |
-
*/
|
1142 |
-
private function remove_invalid_paths() {
|
1143 |
-
// Remove invalid path that is still associated with the current slug if there's any.
|
1144 |
-
$file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
|
1145 |
-
foreach ( $file_slug_map as $plugin_basename => $slug ) {
|
1146 |
-
if ( $slug === $this->_slug &&
|
1147 |
-
$plugin_basename !== $this->_plugin_basename &&
|
1148 |
-
! file_exists( $this->get_absolute_path( $plugin_basename ) )
|
1149 |
-
) {
|
1150 |
-
unset( $file_slug_map[ $plugin_basename ] );
|
1151 |
-
self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
|
1152 |
-
|
1153 |
-
break;
|
1154 |
-
}
|
1155 |
-
}
|
1156 |
-
}
|
1157 |
-
|
1158 |
-
/**
|
1159 |
-
* @author Vova Feldman (@svovaf)
|
1160 |
-
* @since 1.2.2.7
|
1161 |
-
*
|
1162 |
-
* @param string $plugin_prev_version
|
1163 |
-
* @param string $plugin_version
|
1164 |
-
*/
|
1165 |
-
function _after_version_update( $plugin_prev_version, $plugin_version ) {
|
1166 |
-
if ( $this->is_theme() ) {
|
1167 |
-
// Expire the cache of the previous tabs since the theme may
|
1168 |
-
// have setting updates.
|
1169 |
-
$this->_cache->expire( 'tabs' );
|
1170 |
-
$this->_cache->expire( 'tabs_stylesheets' );
|
1171 |
-
}
|
1172 |
-
}
|
1173 |
-
|
1174 |
-
/**
|
1175 |
-
* A special migration logic for the $_accounts, executed for all the plugins in the system:
|
1176 |
-
* - Moves some data to the network level storage.
|
1177 |
-
* - If the plugin's connection was skipped for all sites, set the plugin as if it was network skipped.
|
1178 |
-
* - If the plugin's connection was ignored for all sites, don't do anything in terms of the network connection.
|
1179 |
-
* - If the plugin was connected to all sites by the same super-admin, set the plugin as if was network opted-in for all sites.
|
1180 |
-
* - If there's at least one site that was connected by a super-admin, find the "main super-admin" (the one that installed the majority of the plugin installs) and set the plugin as if was network activated with the main super-admin, set all the sites that were skipped or opted-in with a different user to delegated mode. Then, prompt the currently logged super-admin to choose what to do with the ignored sites.
|
1181 |
-
* - If there are any sites in the network which the connection decision was not yet taken for, set this plugin into network activation mode so a super-admin can choose what to do with the rest of the sites.
|
1182 |
-
*
|
1183 |
-
* @author Vova Feldman (@svovaf)
|
1184 |
-
* @since 2.0.0
|
1185 |
-
*/
|
1186 |
-
private static function migrate_accounts_to_network() {
|
1187 |
-
$sites = self::get_sites();
|
1188 |
-
$sites_count = count( $sites );
|
1189 |
-
$connection_status = array();
|
1190 |
-
$plugin_slugs = array();
|
1191 |
-
foreach ( $sites as $site ) {
|
1192 |
-
$blog_id = self::get_site_blog_id( $site );
|
1193 |
-
|
1194 |
-
self::$_accounts->migrate_to_network( $blog_id );
|
1195 |
-
|
1196 |
-
/**
|
1197 |
-
* Build a list of all Freemius powered plugins slugs.
|
1198 |
-
*/
|
1199 |
-
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array(), $blog_id );
|
1200 |
-
foreach ( $id_slug_type_path_map as $module_id => $data ) {
|
1201 |
-
if ( WP_FS__MODULE_TYPE_PLUGIN === $data['type'] ) {
|
1202 |
-
$plugin_slugs[ $data['slug'] ] = true;
|
1203 |
-
}
|
1204 |
-
}
|
1205 |
-
|
1206 |
-
$installs = self::get_account_option( 'sites', WP_FS__MODULE_TYPE_PLUGIN, $blog_id );
|
1207 |
-
|
1208 |
-
if ( is_array( $installs ) ) {
|
1209 |
-
foreach ( $installs as $slug => $install ) {
|
1210 |
-
if ( ! isset( $connection_status[ $slug ] ) ) {
|
1211 |
-
$connection_status[ $slug ] = array();
|
1212 |
-
}
|
1213 |
-
|
1214 |
-
if ( is_object( $install ) &&
|
1215 |
-
FS_Site::is_valid_id( $install->id ) &&
|
1216 |
-
FS_User::is_valid_id( $install->user_id )
|
1217 |
-
) {
|
1218 |
-
$connection_status[ $slug ][ $blog_id ] = $install->user_id;
|
1219 |
-
}
|
1220 |
-
}
|
1221 |
-
}
|
1222 |
-
}
|
1223 |
-
|
1224 |
-
foreach ( $plugin_slugs as $slug => $true ) {
|
1225 |
-
if ( ! isset( $connection_status[ $slug ] ) ) {
|
1226 |
-
$connection_status[ $slug ] = array();
|
1227 |
-
}
|
1228 |
-
|
1229 |
-
foreach ( $sites as $site ) {
|
1230 |
-
$blog_id = self::get_site_blog_id( $site );
|
1231 |
-
|
1232 |
-
if ( isset( $connection_status[ $slug ][ $blog_id ] ) ) {
|
1233 |
-
continue;
|
1234 |
-
}
|
1235 |
-
|
1236 |
-
$storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $slug );
|
1237 |
-
|
1238 |
-
$is_anonymous = $storage->get( 'is_anonymous', null, $blog_id );
|
1239 |
-
|
1240 |
-
if ( ! is_null( $is_anonymous ) ) {
|
1241 |
-
// Since 1.1.3 is_anonymous is an array.
|
1242 |
-
if ( is_array( $is_anonymous ) && isset( $is_anonymous['is'] ) ) {
|
1243 |
-
$is_anonymous = $is_anonymous['is'];
|
1244 |
-
}
|
1245 |
-
|
1246 |
-
if ( is_bool( $is_anonymous ) && true === $is_anonymous ) {
|
1247 |
-
$connection_status[ $slug ][ $blog_id ] = 'skipped';
|
1248 |
-
}
|
1249 |
-
}
|
1250 |
-
|
1251 |
-
if ( ! isset( $connection_status[ $slug ][ $blog_id ] ) ) {
|
1252 |
-
$connection_status[ $slug ][ $blog_id ] = 'ignored';
|
1253 |
-
}
|
1254 |
-
}
|
1255 |
-
}
|
1256 |
-
|
1257 |
-
$super_admins = array();
|
1258 |
-
|
1259 |
-
foreach ( $connection_status as $slug => $blogs_status ) {
|
1260 |
-
$skips = 0;
|
1261 |
-
$ignores = 0;
|
1262 |
-
$connections = 0;
|
1263 |
-
$opted_in_users = array();
|
1264 |
-
$opted_in_super_admins = array();
|
1265 |
-
|
1266 |
-
$storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $slug );
|
1267 |
-
|
1268 |
-
foreach ( $blogs_status as $blog_id => $status_or_user_id ) {
|
1269 |
-
if ( 'skipped' === $status_or_user_id ) {
|
1270 |
-
$skips ++;
|
1271 |
-
} else if ( 'ignored' === $status_or_user_id ) {
|
1272 |
-
$ignores ++;
|
1273 |
-
} else if ( FS_User::is_valid_id( $status_or_user_id ) ) {
|
1274 |
-
$connections ++;
|
1275 |
-
|
1276 |
-
if ( ! isset( $opted_in_users[ $status_or_user_id ] ) ) {
|
1277 |
-
$opted_in_users[ $status_or_user_id ] = array();
|
1278 |
-
}
|
1279 |
-
|
1280 |
-
$opted_in_users[ $status_or_user_id ][] = $blog_id;
|
1281 |
-
|
1282 |
-
if ( isset( $super_admins[ $status_or_user_id ] ) ||
|
1283 |
-
self::is_super_admin( $status_or_user_id )
|
1284 |
-
) {
|
1285 |
-
// Cache super-admin data.
|
1286 |
-
$super_admins[ $status_or_user_id ] = true;
|
1287 |
-
|
1288 |
-
// Remember opted-in super-admins for the plugin.
|
1289 |
-
$opted_in_super_admins[ $status_or_user_id ] = true;
|
1290 |
-
}
|
1291 |
-
}
|
1292 |
-
}
|
1293 |
-
|
1294 |
-
$main_super_admin_user_id = null;
|
1295 |
-
$all_migrated = false;
|
1296 |
-
if ( $sites_count == $skips ) {
|
1297 |
-
// All sites were skipped -> network skip by copying the anonymous mode from any of the sites.
|
1298 |
-
$storage->is_anonymous_ms = $storage->is_anonymous;
|
1299 |
-
|
1300 |
-
$all_migrated = true;
|
1301 |
-
} else if ( $sites_count == $ignores ) {
|
1302 |
-
// Don't do anything, still in activation mode.
|
1303 |
-
|
1304 |
-
$all_migrated = true;
|
1305 |
-
} else if ( 0 < count( $opted_in_super_admins ) ) {
|
1306 |
-
// Find the super-admin with the majority of installs.
|
1307 |
-
$max_installs_by_super_admin = 0;
|
1308 |
-
foreach ( $opted_in_super_admins as $user_id => $true ) {
|
1309 |
-
$installs_count = count( $opted_in_users[ $user_id ] );
|
1310 |
-
|
1311 |
-
if ( $installs_count > $max_installs_by_super_admin ) {
|
1312 |
-
$max_installs_by_super_admin = $installs_count;
|
1313 |
-
$main_super_admin_user_id = $user_id;
|
1314 |
-
}
|
1315 |
-
}
|
1316 |
-
|
1317 |
-
if ( $sites_count == $connections && 1 == count( $opted_in_super_admins ) ) {
|
1318 |
-
// Super-admin opted-in for all sites in the network.
|
1319 |
-
$storage->is_network_connected = true;
|
1320 |
-
|
1321 |
-
$all_migrated = true;
|
1322 |
-
}
|
1323 |
-
|
1324 |
-
// Store network user.
|
1325 |
-
$storage->network_user_id = $main_super_admin_user_id;
|
1326 |
-
|
1327 |
-
$storage->network_install_blog_id = ( $sites_count == $connections ) ?
|
1328 |
-
// Since all sites are opted-in, associating with the main site.
|
1329 |
-
get_current_blog_id() :
|
1330 |
-
// Associating with the 1st found opted-in site.
|
1331 |
-
$opted_in_users[ $main_super_admin_user_id ][0];
|
1332 |
-
|
1333 |
-
/**
|
1334 |
-
* Make sure we migrate the plan ID of the network install, otherwise, if after the migration
|
1335 |
-
* the 1st page that will be loaded is the network level WP Admin and $storage->network_install_blog_id
|
1336 |
-
* is different than the main site of the network, the $this->_site will not be set since the plan_id
|
1337 |
-
* will be empty.
|
1338 |
-
*/
|
1339 |
-
$storage->migrate_to_network();
|
1340 |
-
self::migrate_install_plan_to_plan_id( $storage, $storage->network_install_blog_id );
|
1341 |
-
} else {
|
1342 |
-
// At least one opt-in. All the opt-in were created by a non-super-admin.
|
1343 |
-
if ( 0 == $ignores ) {
|
1344 |
-
// All sites were opted-in or skipped, all by non-super-admin. So delegate all.
|
1345 |
-
$storage->store( 'is_delegated_connection', true, true );
|
1346 |
-
|
1347 |
-
$all_migrated = true;
|
1348 |
-
}
|
1349 |
-
}
|
1350 |
-
|
1351 |
-
if ( ! $all_migrated ) {
|
1352 |
-
/**
|
1353 |
-
* Delegate all sites that were:
|
1354 |
-
* 1) Opted-in by a user that is NOT the main-super-admin.
|
1355 |
-
* 2) Skipped and non of the sites was opted-in by a super-admin. If any site was opted-in by a super-admin, there will be a main-super-admin, and we consider the skip as if it was done by that user.
|
1356 |
-
*/
|
1357 |
-
foreach ( $blogs_status as $blog_id => $status_or_user_id ) {
|
1358 |
-
if ( $status_or_user_id == $main_super_admin_user_id ) {
|
1359 |
-
continue;
|
1360 |
-
}
|
1361 |
-
|
1362 |
-
if ( FS_User::is_valid_id( $status_or_user_id ) ||
|
1363 |
-
( 'skipped' === $status_or_user_id && is_null( $main_super_admin_user_id ) )
|
1364 |
-
) {
|
1365 |
-
$storage->store( 'is_delegated_connection', true, $blog_id );
|
1366 |
-
}
|
1367 |
-
}
|
1368 |
-
}
|
1369 |
-
|
1370 |
-
|
1371 |
-
if ( ( $connections + $skips > 0 ) ) {
|
1372 |
-
if ( $ignores > 0 ) {
|
1373 |
-
/**
|
1374 |
-
* If admin already opted-in or skipped in any of the network sites, and also
|
1375 |
-
* have sites which the connection decision was not yet taken, set this plugin
|
1376 |
-
* into network activation mode so the super-admin can choose what to do with
|
1377 |
-
* the rest of the sites.
|
1378 |
-
*/
|
1379 |
-
self::set_network_upgrade_mode( $storage );
|
1380 |
-
}
|
1381 |
-
}
|
1382 |
-
}
|
1383 |
-
}
|
1384 |
-
|
1385 |
-
/**
|
1386 |
-
* Set a module into network upgrade mode.
|
1387 |
-
*
|
1388 |
-
* @author Vova Feldman (@svovaf)
|
1389 |
-
* @since 2.0.0
|
1390 |
-
*
|
1391 |
-
* @param \FS_Storage $storage
|
1392 |
-
*
|
1393 |
-
* @return bool
|
1394 |
-
*/
|
1395 |
-
private static function set_network_upgrade_mode( FS_Storage $storage ) {
|
1396 |
-
return $storage->is_network_activation = true;
|
1397 |
-
}
|
1398 |
-
|
1399 |
-
/**
|
1400 |
-
* Will return true after upgrading to the SDK with the network level integration,
|
1401 |
-
* when the super-admin involvement is required regarding the rest of the sites.
|
1402 |
-
*
|
1403 |
-
* @author Vova Feldman (@svovaf)
|
1404 |
-
* @since 2.0.0
|
1405 |
-
*
|
1406 |
-
* @return bool
|
1407 |
-
*/
|
1408 |
-
function is_network_upgrade_mode() {
|
1409 |
-
return $this->_storage->get( 'is_network_activation' );
|
1410 |
-
}
|
1411 |
-
|
1412 |
-
/**
|
1413 |
-
* Clear flag after the upgrade mode completion.
|
1414 |
-
*
|
1415 |
-
* @author Vova Feldman (@svovaf)
|
1416 |
-
* @since 2.0.0
|
1417 |
-
*
|
1418 |
-
* @return bool True if network activation was on and now completed.
|
1419 |
-
*/
|
1420 |
-
private function network_upgrade_mode_completed() {
|
1421 |
-
if ( fs_is_network_admin() && $this->is_network_upgrade_mode() ) {
|
1422 |
-
$this->_storage->remove( 'is_network_activation' );
|
1423 |
-
|
1424 |
-
return true;
|
1425 |
-
}
|
1426 |
-
|
1427 |
-
return false;
|
1428 |
-
}
|
1429 |
-
|
1430 |
-
#endregion
|
1431 |
-
|
1432 |
-
/**
|
1433 |
-
* This action is connected to the 'plugins_loaded' hook and helps to determine
|
1434 |
-
* if this is a new plugin installation or a plugin update.
|
1435 |
-
*
|
1436 |
-
* There are 3 different use-cases:
|
1437 |
-
* 1) New plugin installation right with Freemius:
|
1438 |
-
* 1.1 _activate_plugin_event_hook() will be executed first
|
1439 |
-
* 1.2 Since $this->_storage->is_plugin_new_install is not set,
|
1440 |
-
* and $this->_storage->plugin_last_version is not set,
|
1441 |
-
* $this->_storage->is_plugin_new_install will be set to TRUE.
|
1442 |
-
* 1.3 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
|
1443 |
-
* be already set to TRUE.
|
1444 |
-
*
|
1445 |
-
* 2) Plugin update, didn't have Freemius before, and now have the SDK:
|
1446 |
-
* 2.1 _activate_plugin_event_hook() will not be executed, because
|
1447 |
-
* the activation hook do NOT fires on updates since WP 3.1.
|
1448 |
-
* 2.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
|
1449 |
-
* be empty, therefore, it will be set to FALSE.
|
1450 |
-
*
|
1451 |
-
* 3) Plugin update, had Freemius in prev version as well:
|
1452 |
-
* 3.1 _version_updates_handler() will be executed 1st, since FS was installed
|
1453 |
-
* before, $this->_storage->plugin_last_version will NOT be empty,
|
1454 |
-
* therefore, $this->_storage->is_plugin_new_install will be set to FALSE.
|
1455 |
-
* 3.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install is
|
1456 |
-
* already set, therefore, it will not be modified.
|
1457 |
-
*
|
1458 |
-
* Use-case #3 is backward compatible, #3.1 will be executed since 1.0.9.
|
1459 |
-
*
|
1460 |
-
* NOTE:
|
1461 |
-
* The only fallback of this mechanism is if an admin updates a plugin based on use-case #2,
|
1462 |
-
* and then, the next immediate PageView is the plugin's main settings page, it will not
|
1463 |
-
* show the opt-in right away. The reason it will happen is because Freemius execution
|
1464 |
-
* will be turned off till the plugin is fully loaded at least once
|
1465 |
-
* (till $this->_storage->was_plugin_loaded is TRUE).
|
1466 |
-
*
|
1467 |
-
* @author Vova Feldman (@svovaf)
|
1468 |
-
* @since 1.1.9
|
1469 |
-
*
|
1470 |
-
*/
|
1471 |
-
function _plugins_loaded() {
|
1472 |
-
// Update flag that plugin was loaded with Freemius at least once.
|
1473 |
-
$this->_storage->was_plugin_loaded = true;
|
1474 |
-
|
1475 |
-
/**
|
1476 |
-
* Bug fix - only set to false when it's a plugin, due to the
|
1477 |
-
* execution sequence of the theme hooks and our methods, if
|
1478 |
-
* this will be set for themes, Freemius will always assume
|
1479 |
-
* it's a theme update.
|
1480 |
-
*
|
1481 |
-
* @author Vova Feldman (@svovaf)
|
1482 |
-
* @since 1.2.2.2
|
1483 |
-
*/
|
1484 |
-
if ( $this->is_plugin() &&
|
1485 |
-
! isset( $this->_storage->is_plugin_new_install )
|
1486 |
-
) {
|
1487 |
-
$this->_storage->is_plugin_new_install = (
|
1488 |
-
! is_plugin_active( $this->_plugin_basename ) &&
|
1489 |
-
empty( $this->_storage->plugin_last_version )
|
1490 |
-
);
|
1491 |
-
}
|
1492 |
-
}
|
1493 |
-
|
1494 |
-
/**
|
1495 |
-
* Add special parameter to WP admin AJAX calls so when we
|
1496 |
-
* process AJAX calls we can identify its source properly.
|
1497 |
-
*
|
1498 |
-
* @author Leo Fajardo (@leorw)
|
1499 |
-
* @since 2.0.0
|
1500 |
-
*/
|
1501 |
-
static function _enrich_ajax_url() {
|
1502 |
-
$admin_param = is_network_admin() ?
|
1503 |
-
'_fs_network_admin' :
|
1504 |
-
'_fs_blog_admin';
|
1505 |
-
?>
|
1506 |
-
<script type="text/javascript">
|
1507 |
-
(function ($) {
|
1508 |
-
$(document).ajaxSend(function (event, jqxhr, settings) {
|
1509 |
-
if (settings.url &&
|
1510 |
-
-1 < settings.url.indexOf('admin-ajax.php') &&
|
1511 |
-
! ( settings.url.indexOf( '<?php echo $admin_param ?>' ) > 0 )
|
1512 |
-
) {
|
1513 |
-
if (
|
1514 |
-
'string' === typeof settings.data &&
|
1515 |
-
settings.data.indexOf( 'action=heartbeat' ) > 0
|
1516 |
-
) {
|
1517 |
-
return;
|
1518 |
-
}
|
1519 |
-
|
1520 |
-
if (settings.url.indexOf('?') > 0) {
|
1521 |
-
settings.url += '&';
|
1522 |
-
} else {
|
1523 |
-
settings.url += '?';
|
1524 |
-
}
|
1525 |
-
|
1526 |
-
settings.url += '<?php echo $admin_param ?>=true';
|
1527 |
-
}
|
1528 |
-
});
|
1529 |
-
})(jQuery);
|
1530 |
-
</script>
|
1531 |
-
<?php
|
1532 |
-
}
|
1533 |
-
|
1534 |
-
/**
|
1535 |
-
* Opens the support forum subemenu item in a new browser page.
|
1536 |
-
*
|
1537 |
-
* @author Vova Feldman (@svovaf)
|
1538 |
-
* @since 2.1.4
|
1539 |
-
*/
|
1540 |
-
static function _open_support_forum_in_new_page() {
|
1541 |
-
?>
|
1542 |
-
<script type="text/javascript">
|
1543 |
-
(function ($) {
|
1544 |
-
$('.fs-submenu-item.wp-support-forum').parent().attr( { target: '_blank', rel: 'noopener noreferrer' } );
|
1545 |
-
})(jQuery);
|
1546 |
-
</script>
|
1547 |
-
<?php
|
1548 |
-
}
|
1549 |
-
|
1550 |
-
/**
|
1551 |
-
* @author Vova Feldman (@svovaf)
|
1552 |
-
* @since 1.0.9
|
1553 |
-
*/
|
1554 |
-
private function register_constructor_hooks() {
|
1555 |
-
$this->_logger->entrance();
|
1556 |
-
|
1557 |
-
if ( is_admin() ) {
|
1558 |
-
add_action( 'admin_init', array( &$this, '_hook_action_links_and_register_account_hooks' ) );
|
1559 |
-
|
1560 |
-
if ( $this->is_plugin() ) {
|
1561 |
-
if ( self::is_plugin_install_page() && true !== fs_request_get_bool( 'fs_allow_updater_and_dialog' ) ) {
|
1562 |
-
/**
|
1563 |
-
* Unless the `fs_allow_updater_and_dialog` URL param exists and its value is `true`, make
|
1564 |
-
* Freemius-related updates unavailable on the "Add Plugins" admin page (/plugin-install.php)
|
1565 |
-
* so that they won't interfere with the .org plugins' functionalities on that page (e.g.
|
1566 |
-
* updating of a .org plugin).
|
1567 |
-
*/
|
1568 |
-
add_filter( 'site_transient_update_plugins', array( 'Freemius', '_remove_fs_updates_from_plugin_install_page' ), 10, 2 );
|
1569 |
-
} else if ( self::is_plugins_page() || self::is_updates_page() ) {
|
1570 |
-
/**
|
1571 |
-
* On the "Plugins" and "Updates" admin pages, if there are premium or non–org-compliant plugins, modify their details dialog URLs (add a Freemius-specific param) so that the SDK can determine if the plugin information dialog should show information from Freemius.
|
1572 |
-
*
|
1573 |
-
* @author Leo Fajardo (@leorw)
|
1574 |
-
* @since 2.2.3
|
1575 |
-
*/
|
1576 |
-
add_action( 'admin_footer', array( 'Freemius', '_prepend_fs_allow_updater_and_dialog_flag_url_param' ) );
|
1577 |
-
}
|
1578 |
-
|
1579 |
-
$plugin_dir = dirname( $this->_plugin_dir_path ) . '/';
|
1580 |
-
|
1581 |
-
/**
|
1582 |
-
* @since 1.2.2
|
1583 |
-
*
|
1584 |
-
* Hook to both free and premium version activations to support
|
1585 |
-
* auto deactivation on the other version activation.
|
1586 |
-
*/
|
1587 |
-
register_activation_hook(
|
1588 |
-
$plugin_dir . $this->_free_plugin_basename,
|
1589 |
-
array( &$this, '_activate_plugin_event_hook' )
|
1590 |
-
);
|
1591 |
-
|
1592 |
-
register_activation_hook(
|
1593 |
-
$plugin_dir . $this->premium_plugin_basename(),
|
1594 |
-
array( &$this, '_activate_plugin_event_hook' )
|
1595 |
-
);
|
1596 |
-
} else {
|
1597 |
-
add_action( 'after_switch_theme', array( &$this, '_activate_theme_event_hook' ), 10, 2 );
|
1598 |
-
|
1599 |
-
add_action( 'admin_footer', array( &$this, '_style_premium_theme' ) );
|
1600 |
-
}
|
1601 |
-
|
1602 |
-
/**
|
1603 |
-
* Part of the mechanism to identify new plugin install vs. plugin update.
|
1604 |
-
*
|
1605 |
-
* @author Vova Feldman (@svovaf)
|
1606 |
-
* @since 1.1.9
|
1607 |
-
*/
|
1608 |
-
if ( empty( $this->_storage->was_plugin_loaded ) ) {
|
1609 |
-
/**
|
1610 |
-
* During the plugin activation (not theme), 'plugins_loaded' will be already executed
|
1611 |
-
* when the logic gets here since the activation logic first add the activate plugins,
|
1612 |
-
* then triggers 'plugins_loaded', and only then include the code of the plugin that
|
1613 |
-
* is activated. Which means that _plugins_loaded() will NOT be executed during the
|
1614 |
-
* plugin activation, and that IS intentional.
|
1615 |
-
*
|
1616 |
-
* @author Vova Feldman (@svovaf)
|
1617 |
-
*/
|
1618 |
-
if ( $this->is_plugin() &&
|
1619 |
-
$this->is_activation_mode( false ) &&
|
1620 |
-
0 == did_action( 'plugins_loaded' )
|
1621 |
-
) {
|
1622 |
-
add_action( 'plugins_loaded', array( &$this, '_plugins_loaded' ) );
|
1623 |
-
} else {
|
1624 |
-
// If was activated before, then it was already loaded before.
|
1625 |
-
$this->_plugins_loaded();
|
1626 |
-
}
|
1627 |
-
}
|
1628 |
-
|
1629 |
-
if ( ! self::is_ajax() ) {
|
1630 |
-
if ( ! $this->is_addon() ) {
|
1631 |
-
add_action( 'init', array( &$this, '_add_default_submenu_items' ), WP_FS__LOWEST_PRIORITY );
|
1632 |
-
}
|
1633 |
-
}
|
1634 |
-
|
1635 |
-
if ( $this->_storage->handle_gdpr_admin_notice ) {
|
1636 |
-
add_action( 'init', array( &$this, '_maybe_show_gdpr_admin_notice' ) );
|
1637 |
-
}
|
1638 |
-
|
1639 |
-
add_action( 'init', array( &$this, '_maybe_add_gdpr_optin_ajax_handler') );
|
1640 |
-
add_action( 'init', array( &$this, '_maybe_add_pricing_ajax_handler' ) );
|
1641 |
-
}
|
1642 |
-
|
1643 |
-
if ( $this->is_plugin() ) {
|
1644 |
-
if ( $this->_is_network_active ) {
|
1645 |
-
add_action( 'wpmu_new_blog', array( $this, '_after_new_blog_callback' ), 10, 6 );
|
1646 |
-
}
|
1647 |
-
|
1648 |
-
register_deactivation_hook( $this->_plugin_main_file_path, array( &$this, '_deactivate_plugin_hook' ) );
|
1649 |
-
}
|
1650 |
-
|
1651 |
-
if ( is_multisite() ) {
|
1652 |
-
add_action( 'deactivate_blog', array( &$this, '_after_site_deactivated_callback' ) );
|
1653 |
-
add_action( 'archive_blog', array( &$this, '_after_site_deactivated_callback' ) );
|
1654 |
-
add_action( 'make_spam_blog', array( &$this, '_after_site_deactivated_callback' ) );
|
1655 |
-
add_action( 'deleted_blog', array( &$this, '_after_site_deleted_callback' ), 10, 2 );
|
1656 |
-
|
1657 |
-
add_action( 'activate_blog', array( &$this, '_after_site_reactivated_callback' ) );
|
1658 |
-
add_action( 'unarchive_blog', array( &$this, '_after_site_reactivated_callback' ) );
|
1659 |
-
add_action( 'make_ham_blog', array( &$this, '_after_site_reactivated_callback' ) );
|
1660 |
-
}
|
1661 |
-
|
1662 |
-
if ( $this->is_theme() &&
|
1663 |
-
self::is_customizer() &&
|
1664 |
-
$this->apply_filters( 'show_customizer_upsell', true )
|
1665 |
-
) {
|
1666 |
-
// Register customizer upsell.
|
1667 |
-
add_action( 'customize_register', array( &$this, '_customizer_register' ) );
|
1668 |
-
}
|
1669 |
-
|
1670 |
-
add_action( 'admin_init', array( &$this, '_redirect_on_clicked_menu_link' ), WP_FS__LOWEST_PRIORITY );
|
1671 |
-
|
1672 |
-
if ( $this->is_theme() && ! $this->is_migration() ) {
|
1673 |
-
add_action( 'admin_init', array( &$this, '_add_tracking_links' ) );
|
1674 |
-
}
|
1675 |
-
|
1676 |
-
add_action( 'admin_init', array( &$this, '_add_license_activation' ) );
|
1677 |
-
add_action( 'admin_init', array( &$this, '_add_premium_version_upgrade_selection' ) );
|
1678 |
-
add_action( 'admin_init', array( &$this, '_add_beta_mode_update_handler' ) );
|
1679 |
-
add_action( 'admin_init', array( &$this, '_add_user_change_option' ) );
|
1680 |
-
|
1681 |
-
$this->add_ajax_action( 'update_billing', array( &$this, '_update_billing_ajax_action' ) );
|
1682 |
-
$this->add_ajax_action( 'start_trial', array( &$this, '_start_trial_ajax_action' ) );
|
1683 |
-
$this->add_ajax_action( 'set_data_debug_mode', array( &$this, '_set_data_debug_mode' ) );
|
1684 |
-
$this->add_ajax_action( 'toggle_whitelabel_mode', array( &$this, '_toggle_whitelabel_mode_ajax_handler' ) );
|
1685 |
-
|
1686 |
-
if ( $this->_is_network_active && fs_is_network_admin() ) {
|
1687 |
-
$this->add_ajax_action( 'network_activate', array( &$this, '_network_activate_ajax_action' ) );
|
1688 |
-
}
|
1689 |
-
|
1690 |
-
$this->add_ajax_action( 'install_premium_version', array(
|
1691 |
-
&$this,
|
1692 |
-
'_install_premium_version_ajax_action'
|
1693 |
-
) );
|
1694 |
-
|
1695 |
-
$this->add_ajax_action( 'submit_affiliate_application', array( &$this, '_submit_affiliate_application' ) );
|
1696 |
-
|
1697 |
-
$this->add_action( 'after_plans_sync', array( &$this, '_check_for_trial_plans' ) );
|
1698 |
-
|
1699 |
-
$this->add_action( 'sdk_version_update', array( &$this, '_sdk_version_update' ), WP_FS__DEFAULT_PRIORITY, 2 );
|
1700 |
-
|
1701 |
-
$this->add_action(
|
1702 |
-
'plugin_version_update',
|
1703 |
-
array( &$this, '_after_version_update' ),
|
1704 |
-
WP_FS__DEFAULT_PRIORITY,
|
1705 |
-
2
|
1706 |
-
);
|
1707 |
-
$this->add_filter( 'after_code_type_change', array( &$this, '_after_code_type_change' ) );
|
1708 |
-
|
1709 |
-
add_action( 'admin_init', array( &$this, '_add_trial_notice' ) );
|
1710 |
-
add_action( 'admin_init', array( &$this, '_add_affiliate_program_notice' ) );
|
1711 |
-
add_action( 'admin_enqueue_scripts', array( &$this, '_enqueue_common_css' ) );
|
1712 |
-
|
1713 |
-
/**
|
1714 |
-
* Handle request to reset anonymous mode for `get_reconnect_url()`.
|
1715 |
-
*
|
1716 |
-
* @author Vova Feldman (@svovaf)
|
1717 |
-
* @since 1.2.1.5
|
1718 |
-
*/
|
1719 |
-
if ( fs_request_is_action( 'reset_anonymous_mode' ) &&
|
1720 |
-
$this->get_unique_affix() === fs_request_get( 'fs_unique_affix' )
|
1721 |
-
) {
|
1722 |
-
add_action( 'admin_init', array( &$this, 'connect_again' ) );
|
1723 |
-
}
|
1724 |
-
}
|
1725 |
-
|
1726 |
-
/**
|
1727 |
-
* Register the required hooks right after the settings parse is completed.
|
1728 |
-
*
|
1729 |
-
* @author Vova Feldman (@svovaf)
|
1730 |
-
* @since 2.3.1
|
1731 |
-
*/
|
1732 |
-
private function register_after_settings_parse_hooks() {
|
1733 |
-
if ( is_admin() &&
|
1734 |
-
$this->is_theme() &&
|
1735 |
-
$this->is_premium() &&
|
1736 |
-
! $this->has_active_valid_license()
|
1737 |
-
) {
|
1738 |
-
$this->add_ajax_action(
|
1739 |
-
'delete_theme_update_data',
|
1740 |
-
array( &$this, '_delete_theme_update_data_action' )
|
1741 |
-
);
|
1742 |
-
}
|
1743 |
-
|
1744 |
-
if ( $this->show_settings_with_tabs() ) {
|
1745 |
-
/**
|
1746 |
-
* Include the required hooks to capture the theme settings' page tabs
|
1747 |
-
* and cache them.
|
1748 |
-
*
|
1749 |
-
* @author Vova Feldman (@svovaf)
|
1750 |
-
* @since 1.2.2.7
|
1751 |
-
*/
|
1752 |
-
if ( ! $this->_cache->has_valid( 'tabs' ) ) {
|
1753 |
-
add_action( 'admin_footer', array( &$this, '_tabs_capture' ) );
|
1754 |
-
// Add license activation AJAX callback.
|
1755 |
-
$this->add_ajax_action( 'store_tabs', array( &$this, '_store_tabs_ajax_action' ) );
|
1756 |
-
|
1757 |
-
add_action( 'admin_enqueue_scripts', array( &$this, '_store_tabs_styles' ), 9999999 );
|
1758 |
-
}
|
1759 |
-
|
1760 |
-
add_action(
|
1761 |
-
'admin_footer',
|
1762 |
-
array( &$this, '_add_freemius_tabs' ),
|
1763 |
-
/**
|
1764 |
-
* The tabs JS code must be executed after the tabs capture logic (_tabs_capture()).
|
1765 |
-
* That's why the priority is 11 while the tabs capture logic is added
|
1766 |
-
* with priority 10.
|
1767 |
-
*
|
1768 |
-
* @author Vova Feldman (@svovaf)
|
1769 |
-
*/
|
1770 |
-
11
|
1771 |
-
);
|
1772 |
-
}
|
1773 |
-
|
1774 |
-
if ( ! self::is_ajax() ) {
|
1775 |
-
if ( ! $this->is_addon() || $this->is_only_premium() ) {
|
1776 |
-
add_action(
|
1777 |
-
( $this->_is_network_active && fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu',
|
1778 |
-
array( &$this, '_prepare_admin_menu' ),
|
1779 |
-
WP_FS__LOWEST_PRIORITY
|
1780 |
-
);
|
1781 |
-
}
|
1782 |
-
}
|
1783 |
-
}
|
1784 |
-
|
1785 |
-
/**
|
1786 |
-
* Makes Freemius-related updates unavailable on the "Add Plugins" admin page (/plugin-install.php) so that
|
1787 |
-
* they won't interfere with the .org plugins' functionalities on that page (e.g. updating of a .org plugin).
|
1788 |
-
*
|
1789 |
-
* @author Leo Fajardo (@leorw)
|
1790 |
-
* @since 2.2.3
|
1791 |
-
*
|
1792 |
-
* @param object $updates
|
1793 |
-
* @param string|null $transient
|
1794 |
-
*
|
1795 |
-
* @return object
|
1796 |
-
*/
|
1797 |
-
static function _remove_fs_updates_from_plugin_install_page( $updates, $transient = null ) {
|
1798 |
-
if ( is_object( $updates ) && isset( $updates->response ) ) {
|
1799 |
-
foreach ( $updates->response as $file => $plugin ) {
|
1800 |
-
if ( isset( $plugin->package ) && false !== strpos( $plugin->package, 'api.freemius' ) ) {
|
1801 |
-
unset( $updates->response[ $file ] );
|
1802 |
-
}
|
1803 |
-
}
|
1804 |
-
}
|
1805 |
-
|
1806 |
-
return $updates;
|
1807 |
-
}
|
1808 |
-
|
1809 |
-
/**
|
1810 |
-
* Prepends the `fs_allow_updater_and_dialog` param to the plugin information URLs to tell the SDK to handle
|
1811 |
-
* the information that is shown on the plugin details dialog that is shown when the relevant link is clicked.
|
1812 |
-
*
|
1813 |
-
* @author Leo Fajardo (@leorw)
|
1814 |
-
* @since 2.2.3
|
1815 |
-
*
|
1816 |
-
* @return string
|
1817 |
-
*/
|
1818 |
-
static function _prepend_fs_allow_updater_and_dialog_flag_url_param() {
|
1819 |
-
$slug_basename_map = array();
|
1820 |
-
foreach ( self::$_instances as $instance ) {
|
1821 |
-
if ( ! $instance->is_plugin() ) {
|
1822 |
-
continue;
|
1823 |
-
}
|
1824 |
-
|
1825 |
-
$slug_basename_map[ $instance->get_slug() ] = $instance->premium_plugin_basename();
|
1826 |
-
}
|
1827 |
-
?>
|
1828 |
-
<script type="text/javascript">
|
1829 |
-
(function( $ ) {
|
1830 |
-
var slugBasenameMap = <?php echo json_encode( $slug_basename_map ) ?>;
|
1831 |
-
for ( var slug in slugBasenameMap ) {
|
1832 |
-
var basename = slugBasenameMap[ slug ];
|
1833 |
-
|
1834 |
-
// Try to get the plugin rows if on the "Plugins" page.
|
1835 |
-
var $pluginRows = $( '.wp-list-table.plugins tr[data-plugin="' + basename + '"]');
|
1836 |
-
|
1837 |
-
if ( 0 === $pluginRows.length ) {
|
1838 |
-
// Try to get the plugin rows if on the "Updates" page.
|
1839 |
-
var $pluginCheckbox = $( '#update-plugins-table input[type="checkbox"][value="' + basename + '"]' );
|
1840 |
-
if ( 0 !== $pluginCheckbox.length ) {
|
1841 |
-
$pluginRows = $pluginCheckbox.parents( 'tr:first' );
|
1842 |
-
}
|
1843 |
-
}
|
1844 |
-
|
1845 |
-
if ( 0 === $pluginRows.length ) {
|
1846 |
-
// No plugin rows found.
|
1847 |
-
continue;
|
1848 |
-
}
|
1849 |
-
|
1850 |
-
// Find the "View details" links and add the `fs_allow_updater_and_dialog` param to the URL.
|
1851 |
-
$pluginRows.find( 'a[href*="plugin-install.php?tab=plugin-information"]' ).each(function() {
|
1852 |
-
var $this = $( this ),
|
1853 |
-
href = $this.attr( 'href' ).replace( '?tab=', '?fs_allow_updater_and_dialog=true&tab=');
|
1854 |
-
|
1855 |
-
$this.attr( 'href', href );
|
1856 |
-
});
|
1857 |
-
}
|
1858 |
-
})( jQuery );
|
1859 |
-
</script>
|
1860 |
-
<?php
|
1861 |
-
}
|
1862 |
-
|
1863 |
-
/**
|
1864 |
-
* @author Leo Fajardo (@leorw)
|
1865 |
-
* @since 2.3.0
|
1866 |
-
*/
|
1867 |
-
static function _maybe_add_beta_label_styles() {
|
1868 |
-
$has_any_beta_version = false;
|
1869 |
-
|
1870 |
-
foreach ( self::$_instances as $instance ) {
|
1871 |
-
if ( $instance->is_beta() ) {
|
1872 |
-
$has_any_beta_version = true;
|
1873 |
-
break;
|
1874 |
-
}
|
1875 |
-
}
|
1876 |
-
|
1877 |
-
if ( $has_any_beta_version ) {
|
1878 |
-
fs_enqueue_local_style( 'fs_plugins', '/admin/plugins.css' );
|
1879 |
-
}
|
1880 |
-
}
|
1881 |
-
|
1882 |
-
/**
|
1883 |
-
* @author Leo Fajardo (@leorw)
|
1884 |
-
* @since 2.3.0
|
1885 |
-
*/
|
1886 |
-
static function _maybe_add_beta_label_to_plugins_and_handle_confirmation() {
|
1887 |
-
$beta_data = array();
|
1888 |
-
|
1889 |
-
foreach ( self::$_instances as $instance ) {
|
1890 |
-
if ( ! $instance->is_premium() ) {
|
1891 |
-
continue;
|
1892 |
-
}
|
1893 |
-
|
1894 |
-
/**
|
1895 |
-
* If there's an available beta version update, a confirmation message will be shown when the
|
1896 |
-
* "Update now" link on the "Plugins" or "Themes" page is clicked.
|
1897 |
-
*/
|
1898 |
-
$has_beta_update = $instance->has_beta_update();
|
1899 |
-
|
1900 |
-
$is_beta = (
|
1901 |
-
// The "Beta" label is added separately for themes.
|
1902 |
-
$instance->is_plugin() &&
|
1903 |
-
$instance->is_beta()
|
1904 |
-
);
|
1905 |
-
|
1906 |
-
if ( ! $is_beta && ! $has_beta_update ) {
|
1907 |
-
continue;
|
1908 |
-
}
|
1909 |
-
|
1910 |
-
$beta_data[ $instance->get_plugin_basename() ] = array( 'is_installed_version_beta' => $is_beta );
|
1911 |
-
|
1912 |
-
if ( ! $has_beta_update ) {
|
1913 |
-
continue;
|
1914 |
-
}
|
1915 |
-
|
1916 |
-
$beta_data[ $instance->get_plugin_basename() ]['beta_version_update_confirmation_message'] = sprintf(
|
1917 |
-
'%s %s',
|
1918 |
-
sprintf(
|
1919 |
-
fs_esc_attr_inline(
|
1920 |
-
'An update to a Beta version will replace your installed version of %s with the latest Beta release - use with caution, and not on production sites. You have been warned.',
|
1921 |
-
'beta-version-update-caution',
|
1922 |
-
$instance->get_slug()
|
1923 |
-
),
|
1924 |
-
$instance->get_plugin_title()
|
1925 |
-
),
|
1926 |
-
fs_esc_attr_inline( 'Would you like to proceed with the update?', 'update-confirmation', $instance->get_slug() )
|
1927 |
-
);
|
1928 |
-
}
|
1929 |
-
|
1930 |
-
if ( empty( $beta_data ) ) {
|
1931 |
-
return;
|
1932 |
-
}
|
1933 |
-
?>
|
1934 |
-
<script type="text/javascript">
|
1935 |
-
( function( $ ) {
|
1936 |
-
var betaData = <?php echo json_encode( $beta_data ) ?>;
|
1937 |
-
|
1938 |
-
for ( var pluginBasename in betaData ) {
|
1939 |
-
if ( ! betaData.hasOwnProperty( pluginBasename ) ) {
|
1940 |
-
continue;
|
1941 |
-
}
|
1942 |
-
|
1943 |
-
if ( ! betaData[ pluginBasename ].is_installed_version_beta ) {
|
1944 |
-
continue;
|
1945 |
-
}
|
1946 |
-
|
1947 |
-
var $parentContainer = $( '.wp-list-table.plugins tr[data-plugin="' + pluginBasename + '"]' );
|
1948 |
-
if ( 0 === $parentContainer.length ) {
|
1949 |
-
continue;
|
1950 |
-
}
|
1951 |
-
|
1952 |
-
$parentContainer.find( '.plugin-title > strong:first-child').append(
|
1953 |
-
'<span class="fs-tag fs-info"><?php fs_esc_js_echo_inline( 'Beta', 'beta' ) ?></span>'
|
1954 |
-
);
|
1955 |
-
}
|
1956 |
-
|
1957 |
-
setTimeout( function() {
|
1958 |
-
// Wait a little bit before adding the event handler, otherwise, it will be overridden by the core WP logic.
|
1959 |
-
$( '.plugins .update-message .update-link, .themes .theme .update-message' ).on( 'click', function() {
|
1960 |
-
var $parentContainer = $( this ).parents( 'tr:first' );
|
1961 |
-
pluginBasename = ( 0 !== $parentContainer.length ) ?
|
1962 |
-
$parentContainer.data( 'plugin' ) :
|
1963 |
-
$( this ).parents( '.theme:first' ).data( 'slug' );
|
1964 |
-
|
1965 |
-
if (
|
1966 |
-
betaData[ pluginBasename ] &&
|
1967 |
-
betaData[ pluginBasename ].beta_version_update_confirmation_message &&
|
1968 |
-
! confirm( betaData[ pluginBasename ].beta_version_update_confirmation_message )
|
1969 |
-
) {
|
1970 |
-
return false;
|
1971 |
-
}
|
1972 |
-
} );
|
1973 |
-
}, 20 );
|
1974 |
-
} )( jQuery );
|
1975 |
-
</script>
|
1976 |
-
<?php
|
1977 |
-
}
|
1978 |
-
|
1979 |
-
/**
|
1980 |
-
* Keeping the uninstall hook registered for free or premium plugin version may result to a fatal error that
|
1981 |
-
* could happen when a user tries to uninstall either version while one of them is still active. Uninstalling a
|
1982 |
-
* plugin will trigger inclusion of the free or premium version and if one of them is active during the
|
1983 |
-
* uninstallation, a fatal error may occur in case the plugin's class or functions are already defined.
|
1984 |
-
*
|
1985 |
-
* @author Leo Fajardo (@leorw)
|
1986 |
-
*
|
1987 |
-
* @since 1.2.0
|
1988 |
-
*/
|
1989 |
-
private function unregister_uninstall_hook() {
|
1990 |
-
$uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
|
1991 |
-
unset( $uninstallable_plugins[ $this->_free_plugin_basename ] );
|
1992 |
-
unset( $uninstallable_plugins[ $this->premium_plugin_basename() ] );
|
1993 |
-
|
1994 |
-
update_option( 'uninstall_plugins', $uninstallable_plugins );
|
1995 |
-
}
|
1996 |
-
|
1997 |
-
/**
|
1998 |
-
* @since 1.2.0 Invalidate module's main file cache, otherwise, FS_Plugin_Updater will not fetch updates.
|
1999 |
-
*
|
2000 |
-
* @param bool $store_prev_path
|
2001 |
-
*/
|
2002 |
-
private function clear_module_main_file_cache( $store_prev_path = true ) {
|
2003 |
-
if ( ! isset( $this->_storage->plugin_main_file ) ||
|
2004 |
-
empty( $this->_storage->plugin_main_file->path )
|
2005 |
-
) {
|
2006 |
-
return;
|
2007 |
-
}
|
2008 |
-
|
2009 |
-
if ( ! $store_prev_path ) {
|
2010 |
-
/**
|
2011 |
-
* Storing the previous path is not needed when clearing the cache after an SDK version update since
|
2012 |
-
* the main purpose of the cache clearing in that event is to correct a wrong plugin main file path
|
2013 |
-
* which causes data mix-up between plugins (e.g. titles and versions of an add-on and its parent plugin).
|
2014 |
-
*
|
2015 |
-
* @author Leo Fajardo (@leorw)
|
2016 |
-
* @since 2.2.1
|
2017 |
-
*/
|
2018 |
-
unset( $this->_storage->plugin_main_file->path );
|
2019 |
-
} else {
|
2020 |
-
$plugin_main_file = clone $this->_storage->plugin_main_file;
|
2021 |
-
|
2022 |
-
// Store cached path (2nd layer cache).
|
2023 |
-
$plugin_main_file->prev_path = $plugin_main_file->path;
|
2024 |
-
|
2025 |
-
// Clear cached path.
|
2026 |
-
unset( $plugin_main_file->path );
|
2027 |
-
|
2028 |
-
$this->_storage->plugin_main_file = $plugin_main_file;
|
2029 |
-
}
|
2030 |
-
|
2031 |
-
/**
|
2032 |
-
* Clear global cached path.
|
2033 |
-
*
|
2034 |
-
* @author Leo Fajardo (@leorw)
|
2035 |
-
* @since 1.2.2
|
2036 |
-
*/
|
2037 |
-
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map' );
|
2038 |
-
unset( $id_slug_type_path_map[ $this->_module_id ]['path'] );
|
2039 |
-
self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
|
2040 |
-
}
|
2041 |
-
|
2042 |
-
/**
|
2043 |
-
* @author Leo Fajardo (@leorw)
|
2044 |
-
* @since 2.0.0
|
2045 |
-
*/
|
2046 |
-
function _hook_action_links_and_register_account_hooks() {
|
2047 |
-
if ( $this->is_migration() ) {
|
2048 |
-
return;
|
2049 |
-
}
|
2050 |
-
|
2051 |
-
$this->_add_tracking_links();
|
2052 |
-
|
2053 |
-
if ( self::is_plugins_page() && $this->is_plugin() ) {
|
2054 |
-
$this->hook_plugin_action_links();
|
2055 |
-
}
|
2056 |
-
|
2057 |
-
$this->_register_account_hooks();
|
2058 |
-
}
|
2059 |
-
|
2060 |
-
/**
|
2061 |
-
* @author Vova Feldman (@svovaf)
|
2062 |
-
* @since 1.0.9
|
2063 |
-
*/
|
2064 |
-
private function _register_account_hooks() {
|
2065 |
-
if ( ! is_admin() ) {
|
2066 |
-
return;
|
2067 |
-
}
|
2068 |
-
|
2069 |
-
/**
|
2070 |
-
* Always show the deactivation feedback form since we added
|
2071 |
-
* automatic free version deactivation upon premium code activation.
|
2072 |
-
*
|
2073 |
-
* @since 1.2.1.6
|
2074 |
-
*/
|
2075 |
-
$this->add_ajax_action(
|
2076 |
-
'submit_uninstall_reason',
|
2077 |
-
array( &$this, '_submit_uninstall_reason_action' )
|
2078 |
-
);
|
2079 |
-
|
2080 |
-
$this->add_ajax_action(
|
2081 |
-
'cancel_subscription_or_trial',
|
2082 |
-
array( &$this, 'cancel_subscription_or_trial_ajax_action' )
|
2083 |
-
);
|
2084 |
-
|
2085 |
-
if ( ! $this->is_addon() || $this->is_parent_plugin_installed() ) {
|
2086 |
-
if ( ( $this->is_plugin() && self::is_plugins_page() ) ||
|
2087 |
-
( $this->is_theme() && self::is_themes_page() )
|
2088 |
-
) {
|
2089 |
-
add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
|
2090 |
-
}
|
2091 |
-
}
|
2092 |
-
}
|
2093 |
-
|
2094 |
-
/**
|
2095 |
-
* Leverage backtrace to find caller plugin file path.
|
2096 |
-
*
|
2097 |
-
* @author Vova Feldman (@svovaf)
|
2098 |
-
* @since 1.0.6
|
2099 |
-
*
|
2100 |
-
* @param bool $is_init Is initiation sequence.
|
2101 |
-
*
|
2102 |
-
* @return string
|
2103 |
-
*/
|
2104 |
-
private function _find_caller_plugin_file( $is_init = false ) {
|
2105 |
-
// Try to load the cached value of the file path.
|
2106 |
-
if ( isset( $this->_storage->plugin_main_file ) ) {
|
2107 |
-
$plugin_main_file = $this->_storage->plugin_main_file;
|
2108 |
-
if ( ! empty( $plugin_main_file->path ) ) {
|
2109 |
-
$absolute_path = $this->get_absolute_path( $plugin_main_file->path );
|
2110 |
-
if ( file_exists( $absolute_path ) ) {
|
2111 |
-
return $absolute_path;
|
2112 |
-
}
|
2113 |
-
}
|
2114 |
-
}
|
2115 |
-
|
2116 |
-
/**
|
2117 |
-
* @since 1.2.1
|
2118 |
-
*
|
2119 |
-
* `clear_module_main_file_cache()` is clearing the plugin's cached path on
|
2120 |
-
* deactivation. Therefore, if any plugin/theme was initiating `Freemius`
|
2121 |
-
* with that plugin's slug, it was overriding the empty plugin path with a wrong path.
|
2122 |
-
*
|
2123 |
-
* So, we've added a special mechanism with a 2nd layer of cache that uses `prev_path`
|
2124 |
-
* when the class instantiator isn't the module.
|
2125 |
-
*/
|
2126 |
-
if ( ! $is_init ) {
|
2127 |
-
// Fetch prev path cache.
|
2128 |
-
if ( isset( $this->_storage->plugin_main_file ) &&
|
2129 |
-
! empty( $this->_storage->plugin_main_file->prev_path )
|
2130 |
-
) {
|
2131 |
-
$absolute_path = $this->get_absolute_path( $this->_storage->plugin_main_file->prev_path );
|
2132 |
-
if ( file_exists( $absolute_path ) ) {
|
2133 |
-
return $absolute_path;
|
2134 |
-
}
|
2135 |
-
}
|
2136 |
-
|
2137 |
-
wp_die(
|
2138 |
-
$this->get_text_inline( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.', 'failed-finding-main-path' ) .
|
2139 |
-
" Module: {$this->_slug}; SDK: " . WP_FS__SDK_VERSION . ";",
|
2140 |
-
$this->get_text_inline( 'Error', 'error' ),
|
2141 |
-
array( 'back_link' => true )
|
2142 |
-
);
|
2143 |
-
}
|
2144 |
-
|
2145 |
-
/**
|
2146 |
-
* @since 1.2.1
|
2147 |
-
*
|
2148 |
-
* Only the original instantiator that calls dynamic_init can modify the module's path.
|
2149 |
-
*/
|
2150 |
-
// Find caller module.
|
2151 |
-
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
|
2152 |
-
$this->_storage->plugin_main_file = (object) array(
|
2153 |
-
'path' => $id_slug_type_path_map[ $this->_module_id ]['path'],
|
2154 |
-
);
|
2155 |
-
|
2156 |
-
return $this->get_absolute_path( $id_slug_type_path_map[ $this->_module_id ]['path'] );
|
2157 |
-
}
|
2158 |
-
|
2159 |
-
/**
|
2160 |
-
* @author Leo Fajardo (@leorw)
|
2161 |
-
* @since 1.2.3
|
2162 |
-
*
|
2163 |
-
* @param string $path
|
2164 |
-
*
|
2165 |
-
* @return string
|
2166 |
-
*/
|
2167 |
-
private function get_relative_path( $path ) {
|
2168 |
-
$module_root_dir = $this->get_module_root_dir_path();
|
2169 |
-
if ( 0 === strpos( $path, $module_root_dir ) ) {
|
2170 |
-
$path = substr( $path, strlen( $module_root_dir ) );
|
2171 |
-
}
|
2172 |
-
|
2173 |
-
return $path;
|
2174 |
-
}
|
2175 |
-
|
2176 |
-
/**
|
2177 |
-
* @author Leo Fajardo (@leorw)
|
2178 |
-
* @since 1.2.3
|
2179 |
-
*
|
2180 |
-
* @param string $path
|
2181 |
-
* @param string|bool $module_type
|
2182 |
-
*
|
2183 |
-
* @return string
|
2184 |
-
*/
|
2185 |
-
private function get_absolute_path( $path, $module_type = false ) {
|
2186 |
-
$module_root_dir = $this->get_module_root_dir_path( $module_type );
|
2187 |
-
if ( 0 !== strpos( $path, $module_root_dir ) ) {
|
2188 |
-
$path = fs_normalize_path( $module_root_dir . $path );
|
2189 |
-
}
|
2190 |
-
|
2191 |
-
return $path;
|
2192 |
-
}
|
2193 |
-
|
2194 |
-
/**
|
2195 |
-
* @author Leo Fajardo (@leorw)
|
2196 |
-
* @since 1.2.3
|
2197 |
-
*
|
2198 |
-
* @param string|bool $module_type
|
2199 |
-
*
|
2200 |
-
* @return string
|
2201 |
-
*/
|
2202 |
-
private function get_module_root_dir_path( $module_type = false ) {
|
2203 |
-
$is_plugin = empty( $module_type ) ?
|
2204 |
-
$this->is_plugin() :
|
2205 |
-
( WP_FS__MODULE_TYPE_PLUGIN === $module_type );
|
2206 |
-
|
2207 |
-
return fs_normalize_path( trailingslashit( $is_plugin ?
|
2208 |
-
WP_PLUGIN_DIR :
|
2209 |
-
get_theme_root( get_stylesheet() ) ) );
|
2210 |
-
}
|
2211 |
-
|
2212 |
-
/**
|
2213 |
-
* @author Leo Fajardo (@leorw)
|
2214 |
-
*
|
2215 |
-
* @param number $module_id
|
2216 |
-
* @param string $slug
|
2217 |
-
*
|
2218 |
-
* @since 1.2.2
|
2219 |
-
*/
|
2220 |
-
private function store_id_slug_type_path_map( $module_id, $slug ) {
|
2221 |
-
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
|
2222 |
-
|
2223 |
-
$store_option = false;
|
2224 |
-
|
2225 |
-
if ( ! isset( $id_slug_type_path_map[ $module_id ] ) ) {
|
2226 |
-
$id_slug_type_path_map[ $module_id ] = array(
|
2227 |
-
'slug' => $slug
|
2228 |
-
);
|
2229 |
-
|
2230 |
-
$store_option = true;
|
2231 |
-
} else if (
|
2232 |
-
isset( $id_slug_type_path_map[ $module_id ]['slug'] ) &&
|
2233 |
-
$slug !== $id_slug_type_path_map[ $module_id ]['slug']
|
2234 |
-
) {
|
2235 |
-
$id_slug_type_path_map[ $module_id ]['slug'] = $slug;
|
2236 |
-
$store_option = true;
|
2237 |
-
}
|
2238 |
-
|
2239 |
-
if ( empty( $id_slug_type_path_map[ $module_id ]['path'] ) ||
|
2240 |
-
/**
|
2241 |
-
* This verification is for cases when suddenly the same module
|
2242 |
-
* is installed but with a different folder name.
|
2243 |
-
*
|
2244 |
-
* @author Vova Feldman (@svovaf)
|
2245 |
-
* @since 1.2.3
|
2246 |
-
*/
|
2247 |
-
! file_exists( $this->get_absolute_path(
|
2248 |
-
$id_slug_type_path_map[ $module_id ]['path'],
|
2249 |
-
$id_slug_type_path_map[ $module_id ]['type']
|
2250 |
-
) )
|
2251 |
-
) {
|
2252 |
-
$caller_main_file_and_type = $this->get_caller_main_file_and_type();
|
2253 |
-
|
2254 |
-
$id_slug_type_path_map[ $module_id ]['type'] = $caller_main_file_and_type->module_type;
|
2255 |
-
$id_slug_type_path_map[ $module_id ]['path'] = $caller_main_file_and_type->path;
|
2256 |
-
|
2257 |
-
$store_option = true;
|
2258 |
-
}
|
2259 |
-
|
2260 |
-
if ( $store_option ) {
|
2261 |
-
self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
|
2262 |
-
}
|
2263 |
-
}
|
2264 |
-
|
2265 |
-
/**
|
2266 |
-
* Identifies the caller type: plugin or theme.
|
2267 |
-
*
|
2268 |
-
* @author Leo Fajardo (@leorw)
|
2269 |
-
* @since 1.2.2
|
2270 |
-
*
|
2271 |
-
* @author Vova Feldman (@svovaf)
|
2272 |
-
* @since 1.2.2.3 Find the earliest module in the call stack that calls to the SDK. This fix is for cases when
|
2273 |
-
* add-ons are relying on loading the SDK from the parent module, and also allows themes including the
|
2274 |
-
* SDK an internal file instead of directly from functions.php.
|
2275 |
-
* @since 1.2.1.7 Knows how to handle cases when an add-on includes the parent module logic.
|
2276 |
-
*/
|
2277 |
-
private function get_caller_main_file_and_type() {
|
2278 |
-
self::require_plugin_essentials();
|
2279 |
-
|
2280 |
-
$all_plugins = fs_get_plugins( true );
|
2281 |
-
$all_plugins_paths = array();
|
2282 |
-
|
2283 |
-
// Get active plugin's main files real full names (might be symlinks).
|
2284 |
-
foreach ( $all_plugins as $relative_path => $data ) {
|
2285 |
-
if ( false === strpos( fs_normalize_path( $relative_path ), '/' ) ) {
|
2286 |
-
/**
|
2287 |
-
* Ignore plugins that don't have a folder (e.g. Hello Dolly) since they
|
2288 |
-
* can't really include the SDK.
|
2289 |
-
*
|
2290 |
-
* @author Vova Feldman
|
2291 |
-
* @since 1.2.1.7
|
2292 |
-
*/
|
2293 |
-
continue;
|
2294 |
-
}
|
2295 |
-
|
2296 |
-
$all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
|
2297 |
-
}
|
2298 |
-
|
2299 |
-
$caller_file_candidate = false;
|
2300 |
-
$caller_map = array();
|
2301 |
-
$module_type = WP_FS__MODULE_TYPE_PLUGIN;
|
2302 |
-
$themes_dir = fs_normalize_path( get_theme_root( get_stylesheet() ) );
|
2303 |
-
$plugin_dir_to_skip = false;
|
2304 |
-
|
2305 |
-
for ( $i = 1, $bt = debug_backtrace(), $len = count( $bt ); $i < $len; $i ++ ) {
|
2306 |
-
if ( empty( $bt[ $i ]['file'] ) ) {
|
2307 |
-
continue;
|
2308 |
-
}
|
2309 |
-
|
2310 |
-
if ( $i > 1 && ! empty( $bt[ $i - 1 ]['file'] ) && $bt[ $i ]['file'] === $bt[ $i - 1 ]['file'] ) {
|
2311 |
-
// If file same as the prev file in the stack, skip it.
|
2312 |
-
continue;
|
2313 |
-
}
|
2314 |
-
|
2315 |
-
if ( ! empty( $bt[ $i ]['function'] ) && in_array( $bt[ $i ]['function'], array(
|
2316 |
-
'do_action',
|
2317 |
-
'apply_filter',
|
2318 |
-
// The string split is stupid, but otherwise, theme check
|
2319 |
-
// throws info notices.
|
2320 |
-
'requir' . 'e_once',
|
2321 |
-
'requir' . 'e',
|
2322 |
-
'includ' . 'e_once',
|
2323 |
-
'includ' . 'e',
|
2324 |
-
'install_and_activate_plugin',
|
2325 |
-
'try_activate_plugin',
|
2326 |
-
'activate_plugin'
|
2327 |
-
) )
|
2328 |
-
) {
|
2329 |
-
if ( 'activate_plugin' === $bt[ $i ]['function'] ) {
|
2330 |
-
/**
|
2331 |
-
* Store the directory of the activator plugin so that any other file that starts with it
|
2332 |
-
* cannot be mistakenly chosen as a candidate caller file.
|
2333 |
-
*
|
2334 |
-
* @author Leo Fajardo
|
2335 |
-
*
|
2336 |
-
* @since 2.3.0
|
2337 |
-
*/
|
2338 |
-
$caller_file_path = fs_normalize_path( $bt[ $i ]['file'] );
|
2339 |
-
|
2340 |
-
foreach ( $all_plugins_paths as $plugin_path ) {
|
2341 |
-
$plugin_dir = fs_normalize_path( dirname( $plugin_path ) . '/' );
|
2342 |
-
if ( false !== strpos( $caller_file_path, $plugin_dir ) ) {
|
2343 |
-
$plugin_dir_to_skip = $plugin_dir;
|
2344 |
-
|
2345 |
-
break;
|
2346 |
-
}
|
2347 |
-
}
|
2348 |
-
}
|
2349 |
-
|
2350 |
-
// Ignore call stack hooks and files inclusion.
|
2351 |
-
continue;
|
2352 |
-
}
|
2353 |
-
|
2354 |
-
$caller_file_path = fs_normalize_path( $bt[ $i ]['file'] );
|
2355 |
-
|
2356 |
-
if ( ! empty( $plugin_dir_to_skip ) ) {
|
2357 |
-
/**
|
2358 |
-
* Skip if it's an activator plugin file to avoid mistakenly choosing it as a candidate caller file.
|
2359 |
-
*
|
2360 |
-
* @author Leo Fajardo
|
2361 |
-
*
|
2362 |
-
* @since 2.3.0
|
2363 |
-
*/
|
2364 |
-
if ( 0 === strpos( $caller_file_path, $plugin_dir_to_skip ) ) {
|
2365 |
-
continue;
|
2366 |
-
}
|
2367 |
-
}
|
2368 |
-
|
2369 |
-
if ( 'functions.php' === basename( $caller_file_path ) ) {
|
2370 |
-
/**
|
2371 |
-
* 1. Assumes that theme's starting execution file is functions.php.
|
2372 |
-
* 2. This complex logic fixes symlink issues (e.g. with Vargant).
|
2373 |
-
*
|
2374 |
-
* @author Vova Feldman (@svovaf)
|
2375 |
-
* @since 1.2.2.5
|
2376 |
-
*/
|
2377 |
-
|
2378 |
-
if ( $caller_file_path == fs_normalize_path( realpath( trailingslashit( $themes_dir ) . basename( dirname( $caller_file_path ) ) . '/' . basename( $caller_file_path ) ) ) ) {
|
2379 |
-
$module_type = WP_FS__MODULE_TYPE_THEME;
|
2380 |
-
|
2381 |
-
/**
|
2382 |
-
* Relative path of the theme, e.g.:
|
2383 |
-
* `my-theme/functions.php`
|
2384 |
-
*
|
2385 |
-
* @author Leo Fajardo (@leorw)
|
2386 |
-
*/
|
2387 |
-
$caller_file_candidate = basename( dirname( $caller_file_path ) ) .
|
2388 |
-
'/' .
|
2389 |
-
basename( $caller_file_path );
|
2390 |
-
|
2391 |
-
continue;
|
2392 |
-
}
|
2393 |
-
}
|
2394 |
-
|
2395 |
-
$caller_file_hash = md5( $caller_file_path );
|
2396 |
-
|
2397 |
-
if ( ! isset( $caller_map[ $caller_file_hash ] ) ) {
|
2398 |
-
foreach ( $all_plugins_paths as $plugin_path ) {
|
2399 |
-
if ( empty( $plugin_path ) ) {
|
2400 |
-
continue;
|
2401 |
-
}
|
2402 |
-
|
2403 |
-
if ( false !== strpos( $caller_file_path, fs_normalize_path( dirname( $plugin_path ) . '/' ) ) ) {
|
2404 |
-
$caller_map[ $caller_file_hash ] = fs_normalize_path( $plugin_path );
|
2405 |
-
break;
|
2406 |
-
}
|
2407 |
-
}
|
2408 |
-
}
|
2409 |
-
|
2410 |
-
if ( isset( $caller_map[ $caller_file_hash ] ) ) {
|
2411 |
-
$module_type = WP_FS__MODULE_TYPE_PLUGIN;
|
2412 |
-
$caller_file_candidate = plugin_basename( $caller_map[ $caller_file_hash ] );
|
2413 |
-
}
|
2414 |
-
}
|
2415 |
-
|
2416 |
-
return (object) array(
|
2417 |
-
'module_type' => $module_type,
|
2418 |
-
'path' => $caller_file_candidate
|
2419 |
-
);
|
2420 |
-
}
|
2421 |
-
|
2422 |
-
#----------------------------------------------------------------------------------
|
2423 |
-
#region Deactivation Feedback Form
|
2424 |
-
#----------------------------------------------------------------------------------
|
2425 |
-
|
2426 |
-
/**
|
2427 |
-
* Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
|
2428 |
-
* page.
|
2429 |
-
*
|
2430 |
-
* @author Vova Feldman (@svovaf)
|
2431 |
-
* @author Leo Fajardo (@leorw)
|
2432 |
-
*
|
2433 |
-
* @since 1.1.2
|
2434 |
-
*/
|
2435 |
-
function _add_deactivation_feedback_dialog_box() {
|
2436 |
-
$subscription_cancellation_dialog_box_template_params = $this->apply_filters( 'show_deactivation_subscription_cancellation', true ) ?
|
2437 |
-
$this->_get_subscription_cancellation_dialog_box_template_params() :
|
2438 |
-
array();
|
2439 |
-
|
2440 |
-
/**
|
2441 |
-
* @since 2.3.0 Developers can optionally hide the deactivation feedback form using the 'show_deactivation_feedback_form' filter.
|
2442 |
-
*/
|
2443 |
-
$show_deactivation_feedback_form = true;
|
2444 |
-
if ( $this->has_filter( 'show_deactivation_feedback_form' ) ) {
|
2445 |
-
$show_deactivation_feedback_form = $this->apply_filters( 'show_deactivation_feedback_form', true );
|
2446 |
-
} else if ( $this->is_addon() ) {
|
2447 |
-
/**
|
2448 |
-
* If the add-on's 'show_deactivation_feedback_form' is not set, try to inherit the value from the parent.
|
2449 |
-
*/
|
2450 |
-
$show_deactivation_feedback_form = $this->get_parent_instance()->apply_filters( 'show_deactivation_feedback_form', true );
|
2451 |
-
}
|
2452 |
-
|
2453 |
-
$uninstall_confirmation_message = $this->apply_filters( 'uninstall_confirmation_message', '' );
|
2454 |
-
|
2455 |
-
if (
|
2456 |
-
empty( $subscription_cancellation_dialog_box_template_params ) &&
|
2457 |
-
! $show_deactivation_feedback_form &&
|
2458 |
-
empty( $uninstall_confirmation_message )
|
2459 |
-
) {
|
2460 |
-
return;
|
2461 |
-
}
|
2462 |
-
|
2463 |
-
$vars = array( 'id' => $this->_module_id );
|
2464 |
-
|
2465 |
-
if ( $show_deactivation_feedback_form ) {
|
2466 |
-
/* Check the type of user:
|
2467 |
-
* 1. Long-term (long-term)
|
2468 |
-
* 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
|
2469 |
-
* 3. Short-term (short-term)
|
2470 |
-
*/
|
2471 |
-
$is_long_term_user = true;
|
2472 |
-
|
2473 |
-
// Check if the site is at least 2 days old.
|
2474 |
-
$time_installed = $this->_storage->install_timestamp;
|
2475 |
-
|
2476 |
-
// Difference in seconds.
|
2477 |
-
$date_diff = time() - $time_installed;
|
2478 |
-
|
2479 |
-
// Convert seconds to days.
|
2480 |
-
$date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) );
|
2481 |
-
|
2482 |
-
if ( $date_diff_days < 2 ) {
|
2483 |
-
$is_long_term_user = false;
|
2484 |
-
}
|
2485 |
-
|
2486 |
-
$is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user );
|
2487 |
-
|
2488 |
-
if ( $is_long_term_user ) {
|
2489 |
-
$user_type = 'long-term';
|
2490 |
-
} else {
|
2491 |
-
if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
|
2492 |
-
$user_type = 'non-registered-and-non-anonymous-short-term';
|
2493 |
-
} else {
|
2494 |
-
$user_type = 'short-term';
|
2495 |
-
}
|
2496 |
-
}
|
2497 |
-
|
2498 |
-
$uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
|
2499 |
-
|
2500 |
-
$vars['reasons'] = $uninstall_reasons;
|
2501 |
-
}
|
2502 |
-
|
2503 |
-
$vars['subscription_cancellation_dialog_box_template_params'] = &$subscription_cancellation_dialog_box_template_params;
|
2504 |
-
$vars['show_deactivation_feedback_form'] = $show_deactivation_feedback_form;
|
2505 |
-
$vars['uninstall_confirmation_message'] = $uninstall_confirmation_message;
|
2506 |
-
|
2507 |
-
/**
|
2508 |
-
* Load the HTML template for the deactivation feedback dialog box.
|
2509 |
-
*
|
2510 |
-
* @todo Deactivation form core functions should be loaded only once! Otherwise, when there are multiple Freemius powered plugins the same code is loaded multiple times. The only thing that should be loaded differently is the various deactivation reasons object based on the state of the plugin.
|
2511 |
-
*/
|
2512 |
-
fs_require_template( 'forms/deactivation/form.php', $vars );
|
2513 |
-
}
|
2514 |
-
|
2515 |
-
/**
|
2516 |
-
* @author Leo Fajardo (@leorw)
|
2517 |
-
* @since 1.1.2
|
2518 |
-
*
|
2519 |
-
* @param string $user_type
|
2520 |
-
*
|
2521 |
-
* @return array The uninstall reasons for the specified user type.
|
2522 |
-
*/
|
2523 |
-
function _get_uninstall_reasons( $user_type = 'long-term' ) {
|
2524 |
-
$module_type = $this->_module_type;
|
2525 |
-
|
2526 |
-
$internal_message_template_var = array(
|
2527 |
-
'id' => $this->_module_id
|
2528 |
-
);
|
2529 |
-
|
2530 |
-
$plan = $this->get_plan();
|
2531 |
-
|
2532 |
-
if ( $this->is_registered() && is_object( $plan ) && $plan->has_technical_support() ) {
|
2533 |
-
$contact_support_template = fs_get_template( 'forms/deactivation/contact.php', $internal_message_template_var );
|
2534 |
-
} else {
|
2535 |
-
$contact_support_template = '';
|
2536 |
-
}
|
2537 |
-
|
2538 |
-
$reason_found_better_plugin = array(
|
2539 |
-
'id' => self::REASON_FOUND_A_BETTER_PLUGIN,
|
2540 |
-
'text' => sprintf( $this->get_text_inline( 'I found a better %s', 'reason-found-a-better-plugin' ), $module_type ),
|
2541 |
-
'input_type' => 'textfield',
|
2542 |
-
'input_placeholder' => sprintf( $this->get_text_inline( "What's the %s's name?", 'placeholder-plugin-name' ), $module_type ),
|
2543 |
-
);
|
2544 |
-
|
2545 |
-
$reason_temporary_deactivation = array(
|
2546 |
-
'id' => self::REASON_TEMPORARY_DEACTIVATION,
|
2547 |
-
'text' => sprintf(
|
2548 |
-
$this->get_text_inline( "It's a temporary %s. I'm just debugging an issue.", 'reason-temporary-x' ),
|
2549 |
-
strtolower( $this->is_plugin() ?
|
2550 |
-
$this->get_text_inline( 'Deactivation', 'deactivation' ) :
|
2551 |
-
$this->get_text_inline( 'Theme Switch', 'theme-switch' )
|
2552 |
-
)
|
2553 |
-
),
|
2554 |
-
'input_type' => '',
|
2555 |
-
'input_placeholder' => ''
|
2556 |
-
);
|
2557 |
-
|
2558 |
-
$reason_other = array(
|
2559 |
-
'id' => self::REASON_OTHER,
|
2560 |
-
'text' => $this->get_text_inline( 'Other', 'reason-other' ),
|
2561 |
-
'input_type' => 'textfield',
|
2562 |
-
'input_placeholder' => ''
|
2563 |
-
);
|
2564 |
-
|
2565 |
-
$long_term_user_reasons = array(
|
2566 |
-
array(
|
2567 |
-
'id' => self::REASON_NO_LONGER_NEEDED,
|
2568 |
-
'text' => sprintf( $this->get_text_inline( 'I no longer need the %s', 'reason-no-longer-needed' ), $module_type ),
|
2569 |
-
'input_type' => '',
|
2570 |
-
'input_placeholder' => ''
|
2571 |
-
),
|
2572 |
-
$reason_found_better_plugin,
|
2573 |
-
array(
|
2574 |
-
'id' => self::REASON_NEEDED_FOR_A_SHORT_PERIOD,
|
2575 |
-
'text' => sprintf( $this->get_text_inline( 'I only needed the %s for a short period', 'reason-needed-for-a-short-period' ), $module_type ),
|
2576 |
-
'input_type' => '',
|
2577 |
-
'input_placeholder' => ''
|
2578 |
-
),
|
2579 |
-
array(
|
2580 |
-
'id' => self::REASON_BROKE_MY_SITE,
|
2581 |
-
'text' => sprintf( $this->get_text_inline( 'The %s broke my site', 'reason-broke-my-site' ), $module_type ),
|
2582 |
-
'input_type' => '',
|
2583 |
-
'input_placeholder' => '',
|
2584 |
-
'internal_message' => $contact_support_template
|
2585 |
-
),
|
2586 |
-
array(
|
2587 |
-
'id' => self::REASON_SUDDENLY_STOPPED_WORKING,
|
2588 |
-
'text' => sprintf( $this->get_text_inline( 'The %s suddenly stopped working', 'reason-suddenly-stopped-working' ), $module_type ),
|
2589 |
-
'input_type' => '',
|
2590 |
-
'input_placeholder' => '',
|
2591 |
-
'internal_message' => $contact_support_template
|
2592 |
-
)
|
2593 |
-
);
|
2594 |
-
|
2595 |
-
if ( $this->is_paying() ) {
|
2596 |
-
$long_term_user_reasons[] = array(
|
2597 |
-
'id' => self::REASON_CANT_PAY_ANYMORE,
|
2598 |
-
'text' => $this->get_text_inline( "I can't pay for it anymore", 'reason-cant-pay-anymore' ),
|
2599 |
-
'input_type' => 'textfield',
|
2600 |
-
'input_placeholder' => $this->get_text_inline( 'What price would you feel comfortable paying?', 'placeholder-comfortable-price' )
|
2601 |
-
);
|
2602 |
-
}
|
2603 |
-
|
2604 |
-
$reason_dont_share_info = array(
|
2605 |
-
'id' => self::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION,
|
2606 |
-
'text' => $this->get_text_inline( "I don't like to share my information with you", 'reason-dont-like-to-share-my-information' ),
|
2607 |
-
'input_type' => '',
|
2608 |
-
'input_placeholder' => ''
|
2609 |
-
);
|
2610 |
-
|
2611 |
-
/**
|
2612 |
-
* If the current user has selected the "don't share data" reason in the deactivation feedback modal, inform the
|
2613 |
-
* user by showing additional message that he doesn't have to share data and can just choose to skip the opt-in
|
2614 |
-
* (the Skip button is included in the message to show). This message will only be shown if anonymous mode is
|
2615 |
-
* enabled and the user's account is currently not in pending activation state (similar to the way the Skip
|
2616 |
-
* button in the opt-in form is shown/hidden).
|
2617 |
-
*/
|
2618 |
-
if ( $this->is_enable_anonymous() && ! $this->is_pending_activation() ) {
|
2619 |
-
$reason_dont_share_info['internal_message'] = fs_get_template( 'forms/deactivation/retry-skip.php', $internal_message_template_var );
|
2620 |
-
}
|
2621 |
-
|
2622 |
-
$uninstall_reasons = array(
|
2623 |
-
'long-term' => $long_term_user_reasons,
|
2624 |
-
'non-registered-and-non-anonymous-short-term' => array(
|
2625 |
-
array(
|
2626 |
-
'id' => self::REASON_DIDNT_WORK,
|
2627 |
-
'text' => sprintf( $this->get_text_inline( "The %s didn't work", 'reason-didnt-work' ), $module_type ),
|
2628 |
-
'input_type' => '',
|
2629 |
-
'input_placeholder' => ''
|
2630 |
-
),
|
2631 |
-
$reason_dont_share_info,
|
2632 |
-
$reason_found_better_plugin
|
2633 |
-
),
|
2634 |
-
'short-term' => array(
|
2635 |
-
array(
|
2636 |
-
'id' => self::REASON_COULDNT_MAKE_IT_WORK,
|
2637 |
-
'text' => $this->get_text_inline( "I couldn't understand how to make it work", 'reason-couldnt-make-it-work' ),
|
2638 |
-
'input_type' => '',
|
2639 |
-
'input_placeholder' => '',
|
2640 |
-
'internal_message' => $contact_support_template
|
2641 |
-
),
|
2642 |
-
$reason_found_better_plugin,
|
2643 |
-
array(
|
2644 |
-
'id' => self::REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE,
|
2645 |
-
'text' => sprintf( $this->get_text_inline( "The %s is great, but I need specific feature that you don't support", 'reason-great-but-need-specific-feature' ), $module_type ),
|
2646 |
-
'input_type' => 'textarea',
|
2647 |
-
'input_placeholder' => $this->get_text_inline( 'What feature?', 'placeholder-feature' )
|
2648 |
-
),
|
2649 |
-
array(
|
2650 |
-
'id' => self::REASON_NOT_WORKING,
|
2651 |
-
'text' => sprintf( $this->get_text_inline( 'The %s is not working', 'reason-not-working' ), $module_type ),
|
2652 |
-
'input_type' => 'textarea',
|
2653 |
-
'input_placeholder' => $this->get_text_inline( "Kindly share what didn't work so we can fix it for future users...", 'placeholder-share-what-didnt-work' )
|
2654 |
-
),
|
2655 |
-
array(
|
2656 |
-
'id' => self::REASON_NOT_WHAT_I_WAS_LOOKING_FOR,
|
2657 |
-
'text' => $this->get_text_inline( "It's not what I was looking for", 'reason-not-what-i-was-looking-for' ),
|
2658 |
-
'input_type' => 'textarea',
|
2659 |
-
'input_placeholder' => $this->get_text_inline( "What you've been looking for?", 'placeholder-what-youve-been-looking-for' )
|
2660 |
-
),
|
2661 |
-
array(
|
2662 |
-
'id' => self::REASON_DIDNT_WORK_AS_EXPECTED,
|
2663 |
-
'text' => sprintf( $this->get_text_inline( "The %s didn't work as expected", 'reason-didnt-work-as-expected' ), $module_type ),
|
2664 |
-
'input_type' => 'textarea',
|
2665 |
-
'input_placeholder' => $this->get_text_inline( 'What did you expect?', 'placeholder-what-did-you-expect' )
|
2666 |
-
)
|
2667 |
-
)
|
2668 |
-
);
|
2669 |
-
|
2670 |
-
// Randomize the reasons for the current user type.
|
2671 |
-
shuffle( $uninstall_reasons[ $user_type ] );
|
2672 |
-
|
2673 |
-
// Keep the following reasons as the last items in the list.
|
2674 |
-
$uninstall_reasons[ $user_type ][] = $reason_temporary_deactivation;
|
2675 |
-
$uninstall_reasons[ $user_type ][] = $reason_other;
|
2676 |
-
|
2677 |
-
$uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
|
2678 |
-
|
2679 |
-
return $uninstall_reasons[ $user_type ];
|
2680 |
-
}
|
2681 |
-
|
2682 |
-
/**
|
2683 |
-
* Called after the user has submitted his reason for deactivating the plugin.
|
2684 |
-
*
|
2685 |
-
* @author Leo Fajardo (@leorw)
|
2686 |
-
* @since 1.1.2
|
2687 |
-
*/
|
2688 |
-
function _submit_uninstall_reason_action() {
|
2689 |
-
$this->_logger->entrance();
|
2690 |
-
|
2691 |
-
$this->check_ajax_referer( 'submit_uninstall_reason' );
|
2692 |
-
|
2693 |
-
$reason_id = fs_request_get( 'reason_id' );
|
2694 |
-
|
2695 |
-
// Check if the given reason ID is an unsigned integer.
|
2696 |
-
if ( ! ctype_digit( $reason_id ) ) {
|
2697 |
-
exit;
|
2698 |
-
}
|
2699 |
-
|
2700 |
-
$reason_info = trim( fs_request_get( 'reason_info', '' ) );
|
2701 |
-
if ( ! empty( $reason_info ) ) {
|
2702 |
-
$reason_info = substr( $reason_info, 0, 128 );
|
2703 |
-
}
|
2704 |
-
|
2705 |
-
$reason = (object) array(
|
2706 |
-
'id' => $reason_id,
|
2707 |
-
'info' => $reason_info,
|
2708 |
-
'is_anonymous' => fs_request_get_bool( 'is_anonymous' )
|
2709 |
-
);
|
2710 |
-
|
2711 |
-
$this->_storage->store( 'uninstall_reason', $reason );
|
2712 |
-
|
2713 |
-
/**
|
2714 |
-
* If the module type is "theme", trigger the uninstall event here (on theme deactivation) since themes do
|
2715 |
-
* not support uninstall hook.
|
2716 |
-
*
|
2717 |
-
* @author Leo Fajardo (@leorw)
|
2718 |
-
* @since 1.2.2
|
2719 |
-
*/
|
2720 |
-
if ( $this->is_theme() ) {
|
2721 |
-
if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
|
2722 |
-
FS_Plugin_Updater::instance( $this )->delete_update_data();
|
2723 |
-
}
|
2724 |
-
|
2725 |
-
$this->_uninstall_plugin_event( false );
|
2726 |
-
$this->remove_sdk_reference();
|
2727 |
-
}
|
2728 |
-
|
2729 |
-
// Print '1' for successful operation.
|
2730 |
-
echo 1;
|
2731 |
-
exit;
|
2732 |
-
}
|
2733 |
-
|
2734 |
-
/**
|
2735 |
-
* @author Leo Fajardo (@leorw)
|
2736 |
-
* @since 2.1.4
|
2737 |
-
*/
|
2738 |
-
function cancel_subscription_or_trial_ajax_action() {
|
2739 |
-
$this->_logger->entrance();
|
2740 |
-
|
2741 |
-
$this->check_ajax_referer( 'cancel_subscription_or_trial' );
|
2742 |
-
|
2743 |
-
$result = $this->cancel_subscription_or_trial( fs_request_get( 'plugin_id', $this->get_id() ), false );
|
2744 |
-
|
2745 |
-
if ( $this->is_api_error( $result ) ) {
|
2746 |
-
$this->shoot_ajax_failure( $result->error->message );
|
2747 |
-
}
|
2748 |
-
|
2749 |
-
$this->shoot_ajax_success();
|
2750 |
-
}
|
2751 |
-
|
2752 |
-
/**
|
2753 |
-
* @author Leo Fajardo (@leorw)
|
2754 |
-
* @since 2.1.4
|
2755 |
-
*
|
2756 |
-
* @param number $plugin_id
|
2757 |
-
*
|
2758 |
-
* @return object
|
2759 |
-
*/
|
2760 |
-
private function cancel_subscription_or_trial( $plugin_id ) {
|
2761 |
-
$fs = null;
|
2762 |
-
if ( $plugin_id == $this->get_id() ) {
|
2763 |
-
$fs = $this;
|
2764 |
-
} else if ( $this->is_addon_activated( $plugin_id ) ) {
|
2765 |
-
$fs = self::get_instance_by_id( $plugin_id );
|
2766 |
-
}
|
2767 |
-
|
2768 |
-
$result = null;
|
2769 |
-
|
2770 |
-
if ( ! is_null( $fs ) ) {
|
2771 |
-
$result = $fs->is_paid_trial() ?
|
2772 |
-
$fs->_cancel_trial() :
|
2773 |
-
$fs->_downgrade_site();
|
2774 |
-
}
|
2775 |
-
|
2776 |
-
return $result;
|
2777 |
-
}
|
2778 |
-
|
2779 |
-
/**
|
2780 |
-
* @author Leo Fajardo (@leorw)
|
2781 |
-
* @since 2.0.2
|
2782 |
-
*/
|
2783 |
-
function _delete_theme_update_data_action() {
|
2784 |
-
FS_Plugin_Updater::instance( $this )->delete_update_data();
|
2785 |
-
}
|
2786 |
-
|
2787 |
-
#endregion
|
2788 |
-
|
2789 |
-
#----------------------------------------------------------------------------------
|
2790 |
-
#region Instance
|
2791 |
-
#----------------------------------------------------------------------------------
|
2792 |
-
|
2793 |
-
/**
|
2794 |
-
* Main singleton instance.
|
2795 |
-
*
|
2796 |
-
* @author Vova Feldman (@svovaf)
|
2797 |
-
* @since 1.0.0
|
2798 |
-
*
|
2799 |
-
* @param number $module_id
|
2800 |
-
* @param string|bool $slug
|
2801 |
-
* @param bool $is_init Is initiation sequence.
|
2802 |
-
*
|
2803 |
-
* @return Freemius|false
|
2804 |
-
*/
|
2805 |
-
static function instance( $module_id, $slug = false, $is_init = false ) {
|
2806 |
-
if ( empty( $module_id ) ) {
|
2807 |
-
return false;
|
2808 |
-
}
|
2809 |
-
|
2810 |
-
/**
|
2811 |
-
* Load the essential static data prior to initiating FS_Plugin_Manager since there's an essential MS network migration logic that needs to be executed prior to the initiation.
|
2812 |
-
*/
|
2813 |
-
self::_load_required_static();
|
2814 |
-
|
2815 |
-
if ( ! is_numeric( $module_id ) ) {
|
2816 |
-
if ( ! $is_init && true === $slug ) {
|
2817 |
-
$is_init = true;
|
2818 |
-
}
|
2819 |
-
|
2820 |
-
$slug = $module_id;
|
2821 |
-
|
2822 |
-
$module = FS_Plugin_Manager::instance( $slug )->get();
|
2823 |
-
|
2824 |
-
if ( is_object( $module ) ) {
|
2825 |
-
$module_id = $module->id;
|
2826 |
-
}
|
2827 |
-
}
|
2828 |
-
|
2829 |
-
$key = 'm_' . $module_id;
|
2830 |
-
|
2831 |
-
if ( ! isset( self::$_instances[ $key ] ) ) {
|
2832 |
-
self::$_instances[ $key ] = new Freemius( $module_id, $slug, $is_init );
|
2833 |
-
}
|
2834 |
-
|
2835 |
-
return self::$_instances[ $key ];
|
2836 |
-
}
|
2837 |
-
|
2838 |
-
/**
|
2839 |
-
* @author Vova Feldman (@svovaf)
|
2840 |
-
* @since 1.0.6
|
2841 |
-
*
|
2842 |
-
* @param number $addon_id
|
2843 |
-
*
|
2844 |
-
* @return bool
|
2845 |
-
*/
|
2846 |
-
private static function has_instance( $addon_id ) {
|
2847 |
-
return isset( self::$_instances[ 'm_' . $addon_id ] );
|
2848 |
-
}
|
2849 |
-
|
2850 |
-
/**
|
2851 |
-
* @author Leo Fajardo (@leorw)
|
2852 |
-
* @since 1.2.2
|
2853 |
-
*
|
2854 |
-
* @param string|number $id_or_slug
|
2855 |
-
* @param string $module_type
|
2856 |
-
*
|
2857 |
-
* @return number|false
|
2858 |
-
*/
|
2859 |
-
private static function get_module_id( $id_or_slug, $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
|
2860 |
-
if ( is_numeric( $id_or_slug ) ) {
|
2861 |
-
return $id_or_slug;
|
2862 |
-
}
|
2863 |
-
|
2864 |
-
foreach ( self::$_instances as $instance ) {
|
2865 |
-
// Also check the module type since there can be a plugin and a theme with the same slug.
|
2866 |
-
if ( ( $module_type === $instance->get_module_type() ) && ( $id_or_slug === $instance->get_slug() ) ) {
|
2867 |
-
return $instance->get_id();
|
2868 |
-
}
|
2869 |
-
}
|
2870 |
-
|
2871 |
-
return false;
|
2872 |
-
}
|
2873 |
-
|
2874 |
-
/**
|
2875 |
-
* @author Vova Feldman (@svovaf)
|
2876 |
-
* @since 1.0.6
|
2877 |
-
*
|
2878 |
-
* @param number $id
|
2879 |
-
*
|
2880 |
-
* @return false|Freemius
|
2881 |
-
*/
|
2882 |
-
static function get_instance_by_id( $id ) {
|
2883 |
-
return isset ( self::$_instances[ 'm_' . $id ] ) ?
|
2884 |
-
self::$_instances[ 'm_' . $id ] :
|
2885 |
-
false;
|
2886 |
-
}
|
2887 |
-
|
2888 |
-
/**
|
2889 |
-
*
|
2890 |
-
* @author Vova Feldman (@svovaf)
|
2891 |
-
* @since 1.0.1
|
2892 |
-
*
|
2893 |
-
* @param string $plugin_file
|
2894 |
-
* @param string $module_type
|
2895 |
-
*
|
2896 |
-
* @return false|Freemius
|
2897 |
-
*/
|
2898 |
-
static function get_instance_by_file( $plugin_file, $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
|
2899 |
-
$slug = self::find_slug_by_basename( $plugin_file );
|
2900 |
-
|
2901 |
-
return ( false !== $slug ) ?
|
2902 |
-
self::instance( self::get_module_id( $slug, $module_type ) ) :
|
2903 |
-
false;
|
2904 |
-
}
|
2905 |
-
|
2906 |
-
/**
|
2907 |
-
* @author Vova Feldman (@svovaf)
|
2908 |
-
* @since 1.0.6
|
2909 |
-
*
|
2910 |
-
* @return false|Freemius
|
2911 |
-
*/
|
2912 |
-
function get_parent_instance() {
|
2913 |
-
return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
|
2914 |
-
}
|
2915 |
-
|
2916 |
-
/**
|
2917 |
-
* @author Vova Feldman (@svovaf)
|
2918 |
-
* @since 1.0.6
|
2919 |
-
*
|
2920 |
-
* @param string|number $id_or_slug
|
2921 |
-
*
|
2922 |
-
* @return false|Freemius
|
2923 |
-
*/
|
2924 |
-
function get_addon_instance( $id_or_slug ) {
|
2925 |
-
$addon_id = self::get_module_id( $id_or_slug );
|
2926 |
-
|
2927 |
-
return self::instance( $addon_id );
|
2928 |
-
}
|
2929 |
-
|
2930 |
-
#endregion ------------------------------------------------------------------
|
2931 |
-
|
2932 |
-
/**
|
2933 |
-
* @author Vova Feldman (@svovaf)
|
2934 |
-
* @since 1.0.6
|
2935 |
-
*
|
2936 |
-
* @return bool
|
2937 |
-
*/
|
2938 |
-
function is_parent_plugin_installed() {
|
2939 |
-
$is_active = self::has_instance( $this->_plugin->parent_plugin_id );
|
2940 |
-
|
2941 |
-
if ( $is_active ) {
|
2942 |
-
return true;
|
2943 |
-
}
|
2944 |
-
|
2945 |
-
/**
|
2946 |
-
* Parent module might be a theme. If that's the case, the add-on's FS
|
2947 |
-
* instance will be loaded prior to the theme's FS instance, therefore,
|
2948 |
-
* we need to check if it's active with a "look ahead".
|
2949 |
-
*
|
2950 |
-
* @author Vova Feldman
|
2951 |
-
* @since 1.2.2.3
|
2952 |
-
*/
|
2953 |
-
global $fs_active_plugins;
|
2954 |
-
if ( is_object( $fs_active_plugins ) && is_array( $fs_active_plugins->plugins ) ) {
|
2955 |
-
$active_theme = wp_get_theme();
|
2956 |
-
|
2957 |
-
foreach ( $fs_active_plugins->plugins as $sdk => $module ) {
|
2958 |
-
if ( WP_FS__MODULE_TYPE_THEME === $module->type ) {
|
2959 |
-
if ( $module->plugin_path == $active_theme->get_stylesheet() ) {
|
2960 |
-
// Parent module is a theme and it's currently active.
|
2961 |
-
return true;
|
2962 |
-
}
|
2963 |
-
}
|
2964 |
-
}
|
2965 |
-
}
|
2966 |
-
|
2967 |
-
return false;
|
2968 |
-
}
|
2969 |
-
|
2970 |
-
/**
|
2971 |
-
* Check if add-on parent plugin in activation mode.
|
2972 |
-
*
|
2973 |
-
* @author Vova Feldman (@svovaf)
|
2974 |
-
* @since 1.0.7
|
2975 |
-
*
|
2976 |
-
* @return bool
|
2977 |
-
*/
|
2978 |
-
function is_parent_in_activation() {
|
2979 |
-
$parent_fs = $this->get_parent_instance();
|
2980 |
-
if ( ! is_object( $parent_fs ) ) {
|
2981 |
-
return false;
|
2982 |
-
}
|
2983 |
-
|
2984 |
-
return ( $parent_fs->is_activation_mode() );
|
2985 |
-
}
|
2986 |
-
|
2987 |
-
/**
|
2988 |
-
* Is plugin in activation mode.
|
2989 |
-
*
|
2990 |
-
* @author Vova Feldman (@svovaf)
|
2991 |
-
* @since 1.0.7
|
2992 |
-
*
|
2993 |
-
* @param bool $and_on
|
2994 |
-
*
|
2995 |
-
* @return bool
|
2996 |
-
*/
|
2997 |
-
function is_activation_mode( $and_on = true ) {
|
2998 |
-
return fs_is_network_admin() ?
|
2999 |
-
$this->is_network_activation_mode( $and_on ) :
|
3000 |
-
$this->is_site_activation_mode( $and_on );
|
3001 |
-
}
|
3002 |
-
|
3003 |
-
/**
|
3004 |
-
* Is plugin in activation mode.
|
3005 |
-
*
|
3006 |
-
* @author Vova Feldman (@svovaf)
|
3007 |
-
* @since 1.0.7
|
3008 |
-
*
|
3009 |
-
* @param bool $and_on
|
3010 |
-
*
|
3011 |
-
* @return bool
|
3012 |
-
*/
|
3013 |
-
function is_site_activation_mode( $and_on = true ) {
|
3014 |
-
return (
|
3015 |
-
( $this->is_on() || ! $and_on ) &&
|
3016 |
-
(
|
3017 |
-
( $this->is_premium() && true === $this->_storage->require_license_activation ) ||
|
3018 |
-
(
|
3019 |
-
( ! $this->is_registered() ||
|
3020 |
-
( $this->is_only_premium() && ! $this->has_features_enabled_license() ) ) &&
|
3021 |
-
( ! $this->is_enable_anonymous() ||
|
3022 |
-
( ! $this->is_anonymous() && ! $this->is_pending_activation() ) )
|
3023 |
-
)
|
3024 |
-
)
|
3025 |
-
);
|
3026 |
-
}
|
3027 |
-
|
3028 |
-
/**
|
3029 |
-
* Checks if the SDK in network activation mode.
|
3030 |
-
*
|
3031 |
-
* @author Leo Fajardo (@leorw)
|
3032 |
-
* @since 2.0.0
|
3033 |
-
*
|
3034 |
-
* @param bool $and_on
|
3035 |
-
*
|
3036 |
-
* @return bool
|
3037 |
-
*/
|
3038 |
-
private function is_network_activation_mode( $and_on = true ) {
|
3039 |
-
if ( ! $this->_is_network_active ) {
|
3040 |
-
// Not network activated.
|
3041 |
-
return false;
|
3042 |
-
}
|
3043 |
-
|
3044 |
-
if ( $this->is_network_upgrade_mode() ) {
|
3045 |
-
// Special flag to enforce network activation mode to decide what to do with the sites that are not yet opted-in nor skipped.
|
3046 |
-
return true;
|
3047 |
-
}
|
3048 |
-
|
3049 |
-
if ( ! $this->is_site_activation_mode( $and_on ) ) {
|
3050 |
-
// Whether the context is single site or the network, if the plugin is no longer in activation mode then it is not in network activation mode as well.
|
3051 |
-
return false;
|
3052 |
-
}
|
3053 |
-
|
3054 |
-
if ( $this->is_network_delegated_connection() ) {
|
3055 |
-
// Super-admin delegated the connection to the site admins -> not activation mode.
|
3056 |
-
return false;
|
3057 |
-
}
|
3058 |
-
|
3059 |
-
if ( $this->is_network_anonymous() && true !== $this->_storage->require_license_activation ) {
|
3060 |
-
// Super-admin skipped the connection network wide -> not activation mode.
|
3061 |
-
return false;
|
3062 |
-
}
|
3063 |
-
|
3064 |
-
if ( $this->is_network_registered() ) {
|
3065 |
-
// Super-admin connected at least one site -> not activation mode.
|
3066 |
-
return false;
|
3067 |
-
}
|
3068 |
-
|
3069 |
-
return true;
|
3070 |
-
}
|
3071 |
-
|
3072 |
-
/**
|
3073 |
-
* Check if current page is the opt-in/pending-activation page.
|
3074 |
-
*
|
3075 |
-
* @author Vova Feldman (@svovaf)
|
3076 |
-
* @since 1.2.1.7
|
3077 |
-
*
|
3078 |
-
* @return bool
|
3079 |
-
*/
|
3080 |
-
function is_activation_page() {
|
3081 |
-
if ( $this->_menu->is_activation_page( $this->show_opt_in_on_themes_page() ) ) {
|
3082 |
-
return true;
|
3083 |
-
}
|
3084 |
-
|
3085 |
-
if ( ! $this->is_activation_mode() ) {
|
3086 |
-
return false;
|
3087 |
-
}
|
3088 |
-
|
3089 |
-
// Check if current page is matching the activation page.
|
3090 |
-
return $this->is_matching_url( $this->get_activation_url() );
|
3091 |
-
}
|
3092 |
-
|
3093 |
-
/**
|
3094 |
-
* Check if URL path's are matching and that all querystring
|
3095 |
-
* arguments of the $sub_url exist in the $url with the same values.
|
3096 |
-
*
|
3097 |
-
* WARNING:
|
3098 |
-
* 1. This method doesn't check if the sub/domain are matching.
|
3099 |
-
* 2. Ignore case sensitivity.
|
3100 |
-
*
|
3101 |
-
* @author Vova Feldman (@svovaf)
|
3102 |
-
* @since 1.2.1.7
|
3103 |
-
*
|
3104 |
-
* @param string $sub_url
|
3105 |
-
* @param string $url If argument is not set, check if the sub_url matching the current's page URL.
|
3106 |
-
*
|
3107 |
-
* @return bool
|
3108 |
-
*/
|
3109 |
-
private function is_matching_url( $sub_url, $url = '' ) {
|
3110 |
-
if ( empty( $url ) ) {
|
3111 |
-
$url = $_SERVER['REQUEST_URI'];
|
3112 |
-
}
|
3113 |
-
|
3114 |
-
$url = strtolower( $url );
|
3115 |
-
$sub_url = strtolower( $sub_url );
|
3116 |
-
|
3117 |
-
if ( parse_url( $sub_url, PHP_URL_PATH ) !== parse_url( $url, PHP_URL_PATH ) ) {
|
3118 |
-
// Different path - DO NOT OVERRIDE PAGE.
|
3119 |
-
return false;
|
3120 |
-
}
|
3121 |
-
|
3122 |
-
$url_params = array();
|
3123 |
-
parse_str( parse_url( $url, PHP_URL_QUERY ), $url_params );
|
3124 |
-
|
3125 |
-
$sub_url_params = array();
|
3126 |
-
parse_str( parse_url( $sub_url, PHP_URL_QUERY ), $sub_url_params );
|
3127 |
-
|
3128 |
-
foreach ( $sub_url_params as $key => $val ) {
|
3129 |
-
if ( ! isset( $url_params[ $key ] ) || $val != $url_params[ $key ] ) {
|
3130 |
-
// Not matching query string - DO NOT OVERRIDE PAGE.
|
3131 |
-
return false;
|
3132 |
-
}
|
3133 |
-
}
|
3134 |
-
|
3135 |
-
return true;
|
3136 |
-
}
|
3137 |
-
|
3138 |
-
/**
|
3139 |
-
* Get the basenames of all active plugins for specific blog. Including network activated plugins.
|
3140 |
-
*
|
3141 |
-
* @author Vova Feldman (@svovaf)
|
3142 |
-
* @since 2.0.0
|
3143 |
-
*
|
3144 |
-
* @param int $blog_id
|
3145 |
-
*
|
3146 |
-
* @return string[]
|
3147 |
-
*/
|
3148 |
-
private static function get_active_plugins_basenames( $blog_id = 0 ) {
|
3149 |
-
if ( is_multisite() && $blog_id > 0 ) {
|
3150 |
-
$active_basenames = get_blog_option( $blog_id, 'active_plugins' );
|
3151 |
-
} else {
|
3152 |
-
$active_basenames = get_option( 'active_plugins' );
|
3153 |
-
}
|
3154 |
-
|
3155 |
-
if ( ! is_array( $active_basenames ) ) {
|
3156 |
-
$active_basenames = array();
|
3157 |
-
}
|
3158 |
-
|
3159 |
-
if ( is_multisite() ) {
|
3160 |
-
$network_active_basenames = get_site_option( 'active_sitewide_plugins' );
|
3161 |
-
|
3162 |
-
if ( is_array( $network_active_basenames ) && ! empty( $network_active_basenames ) ) {
|
3163 |
-
$active_basenames = array_merge( $active_basenames, array_keys( $network_active_basenames ) );
|
3164 |
-
}
|
3165 |
-
}
|
3166 |
-
|
3167 |
-
return $active_basenames;
|
3168 |
-
}
|
3169 |
-
|
3170 |
-
/**
|
3171 |
-
* @author Leo Fajardo (@leorw)
|
3172 |
-
* @since 2.3.0
|
3173 |
-
*
|
3174 |
-
* @param int $blog_id
|
3175 |
-
*
|
3176 |
-
* @return array
|
3177 |
-
*/
|
3178 |
-
static function get_active_plugins_directories_map( $blog_id = 0 ) {
|
3179 |
-
$active_basenames = self::get_active_plugins_basenames( $blog_id );
|
3180 |
-
|
3181 |
-
$map = array();
|
3182 |
-
|
3183 |
-
foreach ( $active_basenames as $active_basename ) {
|
3184 |
-
$active_basename = fs_normalize_path( $active_basename );
|
3185 |
-
|
3186 |
-
if ( false === strpos( $active_basename, '/' ) ) {
|
3187 |
-
continue;
|
3188 |
-
}
|
3189 |
-
|
3190 |
-
$map[ dirname( $active_basename ) ] = true;
|
3191 |
-
}
|
3192 |
-
|
3193 |
-
return $map;
|
3194 |
-
}
|
3195 |
-
|
3196 |
-
/**
|
3197 |
-
* Get collection of all active plugins. Including network activated plugins.
|
3198 |
-
*
|
3199 |
-
* @author Vova Feldman (@svovaf)
|
3200 |
-
* @since 1.0.9
|
3201 |
-
*
|
3202 |
-
* @param int $blog_id Since 2.0.0
|
3203 |
-
*
|
3204 |
-
* @return array[string]array
|
3205 |
-
*/
|
3206 |
-
private static function get_active_plugins( $blog_id = 0 ) {
|
3207 |
-
self::require_plugin_essentials();
|
3208 |
-
|
3209 |
-
$active_plugin = array();
|
3210 |
-
$all_plugins = fs_get_plugins();
|
3211 |
-
$active_plugins_basenames = self::get_active_plugins_basenames( $blog_id );
|
3212 |
-
|
3213 |
-
foreach ( $active_plugins_basenames as $plugin_basename ) {
|
3214 |
-
$active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ];
|
3215 |
-
}
|
3216 |
-
|
3217 |
-
return $active_plugin;
|
3218 |
-
}
|
3219 |
-
|
3220 |
-
/**
|
3221 |
-
* Get collection of all site active plugins for a specified blog.
|
3222 |
-
*
|
3223 |
-
* @author Vova Feldman (@svovaf)
|
3224 |
-
* @since 2.0.0
|
3225 |
-
*
|
3226 |
-
* @param int $blog_id
|
3227 |
-
*
|
3228 |
-
* @return array[string]array
|
3229 |
-
*/
|
3230 |
-
private static function get_site_active_plugins( $blog_id = 0 ) {
|
3231 |
-
$active_basenames = ( is_multisite() && $blog_id > 0 ) ?
|
3232 |
-
get_blog_option( $blog_id, 'active_plugins' ) :
|
3233 |
-
get_option( 'active_plugins' );
|
3234 |
-
|
3235 |
-
$active = array();
|
3236 |
-
|
3237 |
-
if ( ! is_array( $active_basenames ) ) {
|
3238 |
-
return $active;
|
3239 |
-
}
|
3240 |
-
|
3241 |
-
foreach ( $active_basenames as $basename ) {
|
3242 |
-
$active[ $basename ] = array(
|
3243 |
-
'is_active' => true,
|
3244 |
-
'Version' => '1.0', // Dummy version.
|
3245 |
-
'slug' => self::get_plugin_slug( $basename ),
|
3246 |
-
);
|
3247 |
-
}
|
3248 |
-
|
3249 |
-
return $active;
|
3250 |
-
}
|
3251 |
-
|
3252 |
-
/**
|
3253 |
-
* Get collection of all plugins with their activation status for a specified blog.
|
3254 |
-
*
|
3255 |
-
* @author Vova Feldman (@svovaf)
|
3256 |
-
* @since 1.1.8
|
3257 |
-
*
|
3258 |
-
* @param int $blog_id Since 2.0.0
|
3259 |
-
*
|
3260 |
-
* @return array Key is the plugin file path and the value is an array of the plugin data.
|
3261 |
-
*/
|
3262 |
-
private static function get_all_plugins( $blog_id = 0 ) {
|
3263 |
-
self::require_plugin_essentials();
|
3264 |
-
|
3265 |
-
$all_plugins = fs_get_plugins();
|
3266 |
-
|
3267 |
-
$active_plugins_basenames = self::get_active_plugins_basenames( $blog_id );
|
3268 |
-
|
3269 |
-
foreach ( $all_plugins as $basename => &$data ) {
|
3270 |
-
// By default set to inactive (next foreach update the active plugins).
|
3271 |
-
$data['is_active'] = false;
|
3272 |
-
// Enrich with plugin slug.
|
3273 |
-
$data['slug'] = self::get_plugin_slug( $basename );
|
3274 |
-
}
|
3275 |
-
|
3276 |
-
// Flag active plugins.
|
3277 |
-
foreach ( $active_plugins_basenames as $basename ) {
|
3278 |
-
if ( isset( $all_plugins[ $basename ] ) ) {
|
3279 |
-
$all_plugins[ $basename ]['is_active'] = true;
|
3280 |
-
}
|
3281 |
-
}
|
3282 |
-
|
3283 |
-
return $all_plugins;
|
3284 |
-
}
|
3285 |
-
|
3286 |
-
/**
|
3287 |
-
* Get collection of all plugins and if they are network level activated.
|
3288 |
-
*
|
3289 |
-
* @author Vova Feldman (@svovaf)
|
3290 |
-
* @since 2.0.0
|
3291 |
-
*
|
3292 |
-
* @return array Key is the plugin basename and the value is an array of the plugin data.
|
3293 |
-
*/
|
3294 |
-
private static function get_network_plugins() {
|
3295 |
-
self::require_plugin_essentials();
|
3296 |
-
|
3297 |
-
$all_plugins = fs_get_plugins();
|
3298 |
-
|
3299 |
-
$network_active_basenames = is_multisite() ?
|
3300 |
-
get_site_option( 'active_sitewide_plugins' ) :
|
3301 |
-
array();
|
3302 |
-
|
3303 |
-
foreach ( $all_plugins as $basename => &$data ) {
|
3304 |
-
// By default set to inactive (next foreach update the active plugins).
|
3305 |
-
$data['is_active'] = false;
|
3306 |
-
// Enrich with plugin slug.
|
3307 |
-
$data['slug'] = self::get_plugin_slug( $basename );
|
3308 |
-
}
|
3309 |
-
|
3310 |
-
// Flag active plugins.
|
3311 |
-
foreach ( $network_active_basenames as $basename ) {
|
3312 |
-
if ( isset( $all_plugins[ $basename ] ) ) {
|
3313 |
-
$all_plugins[ $basename ]['is_active'] = true;
|
3314 |
-
}
|
3315 |
-
}
|
3316 |
-
|
3317 |
-
return $all_plugins;
|
3318 |
-
}
|
3319 |
-
|
3320 |
-
/**
|
3321 |
-
* Cached result of get_site_transient( 'update_plugins' )
|
3322 |
-
*
|
3323 |
-
* @author Vova Feldman (@svovaf)
|
3324 |
-
* @since 1.1.8
|
3325 |
-
*
|
3326 |
-
* @var object
|
3327 |
-
*/
|
3328 |
-
private static $_plugins_info;
|
3329 |
-
|
3330 |
-
/**
|
3331 |
-
* Helper function to get specified plugin's slug.
|
3332 |
-
*
|
3333 |
-
* @author Vova Feldman (@svovaf)
|
3334 |
-
* @since 1.1.8
|
3335 |
-
*
|
3336 |
-
* @param $basename
|
3337 |
-
*
|
3338 |
-
* @return string
|
3339 |
-
*/
|
3340 |
-
private static function get_plugin_slug( $basename ) {
|
3341 |
-
if ( ! isset( self::$_plugins_info ) ) {
|
3342 |
-
self::$_plugins_info = get_site_transient( 'update_plugins' );
|
3343 |
-
}
|
3344 |
-
|
3345 |
-
$slug = '';
|
3346 |
-
|
3347 |
-
if ( is_object( self::$_plugins_info ) ) {
|
3348 |
-
if ( isset( self::$_plugins_info->no_update ) &&
|
3349 |
-
isset( self::$_plugins_info->no_update[ $basename ] ) &&
|
3350 |
-
! empty( self::$_plugins_info->no_update[ $basename ]->slug )
|
3351 |
-
) {
|
3352 |
-
$slug = self::$_plugins_info->no_update[ $basename ]->slug;
|
3353 |
-
} else if ( isset( self::$_plugins_info->response ) &&
|
3354 |
-
isset( self::$_plugins_info->response[ $basename ] ) &&
|
3355 |
-
! empty( self::$_plugins_info->response[ $basename ]->slug )
|
3356 |
-
) {
|
3357 |
-
$slug = self::$_plugins_info->response[ $basename ]->slug;
|
3358 |
-
}
|
3359 |
-
}
|
3360 |
-
|
3361 |
-
if ( empty( $slug ) ) {
|
3362 |
-
// Try to find slug from FS data.
|
3363 |
-
$slug = self::find_slug_by_basename( $basename );
|
3364 |
-
}
|
3365 |
-
|
3366 |
-
if ( empty( $slug ) ) {
|
3367 |
-
// Fallback to plugin's folder name.
|
3368 |
-
$slug = dirname( $basename );
|
3369 |
-
}
|
3370 |
-
|
3371 |
-
return $slug;
|
3372 |
-
}
|
3373 |
-
|
3374 |
-
private static $_statics_loaded = false;
|
3375 |
-
|
3376 |
-
/**
|
3377 |
-
* Load static resources.
|
3378 |
-
*
|
3379 |
-
* @author Vova Feldman (@svovaf)
|
3380 |
-
* @since 1.0.1
|
3381 |
-
*/
|
3382 |
-
private static function _load_required_static() {
|
3383 |
-
if ( self::$_statics_loaded ) {
|
3384 |
-
return;
|
3385 |
-
}
|
3386 |
-
|
3387 |
-
self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
|
3388 |
-
|
3389 |
-
self::$_static_logger->entrance();
|
3390 |
-
|
3391 |
-
self::$_accounts = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true );
|
3392 |
-
|
3393 |
-
if ( is_multisite() ) {
|
3394 |
-
$has_skipped_migration = (
|
3395 |
-
// 'id_slug_type_path_map' - was never stored on older versions, therefore, not exists on the site level.
|
3396 |
-
null === self::$_accounts->get_option( 'id_slug_type_path_map', null, false ) &&
|
3397 |
-
// 'file_slug_map' stored on the site level, so it was running an SDK version before it was integrated with MS-network.
|
3398 |
-
null !== self::$_accounts->get_option( 'file_slug_map', null, false )
|
3399 |
-
);
|
3400 |
-
|
3401 |
-
/**
|
3402 |
-
* If the file_slug_map exists on the site level but doesn't exist on the
|
3403 |
-
* network level storage, it means that we need to process the storage with migration.
|
3404 |
-
*
|
3405 |
-
* The code in this `if` scope will only be executed once and only for the first site that will execute it because once we migrate the storage data, file_slug_map will be already set in the network level storage.
|
3406 |
-
*
|
3407 |
-
* @author Vova Feldman (@svovaf)
|
3408 |
-
* @since 2.0.0
|
3409 |
-
*/
|
3410 |
-
if (
|
3411 |
-
( $has_skipped_migration && true !== self::$_accounts->get_option( 'ms_migration_complete', false, true ) ) ||
|
3412 |
-
( null === self::$_accounts->get_option( 'file_slug_map', null, true ) &&
|
3413 |
-
null !== self::$_accounts->get_option( 'file_slug_map', null, false ) )
|
3414 |
-
) {
|
3415 |
-
self::migrate_options_to_network();
|
3416 |
-
}
|
3417 |
-
}
|
3418 |
-
|
3419 |
-
self::$_global_admin_notices = FS_Admin_Notices::instance( 'global' );
|
3420 |
-
|
3421 |
-
if ( ! WP_FS__DEMO_MODE ) {
|
3422 |
-
add_action( ( fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu', array(
|
3423 |
-
'Freemius',
|
3424 |
-
'_add_debug_section'
|
3425 |
-
) );
|
3426 |
-
}
|
3427 |
-
|
3428 |
-
add_action( "wp_ajax_fs_toggle_debug_mode", array( 'Freemius', '_toggle_debug_mode' ) );
|
3429 |
-
|
3430 |
-
self::add_ajax_action_static( 'get_debug_log', array( 'Freemius', '_get_debug_log' ) );
|
3431 |
-
|
3432 |
-
self::add_ajax_action_static( 'get_db_option', array( 'Freemius', '_get_db_option' ) );
|
3433 |
-
|
3434 |
-
self::add_ajax_action_static( 'set_db_option', array( 'Freemius', '_set_db_option' ) );
|
3435 |
-
|
3436 |
-
if ( 0 == did_action( 'plugins_loaded' ) ) {
|
3437 |
-
add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 );
|
3438 |
-
}
|
3439 |
-
|
3440 |
-
add_action( 'admin_footer', array( 'Freemius', '_enrich_ajax_url' ) );
|
3441 |
-
add_action( 'admin_footer', array( 'Freemius', '_open_support_forum_in_new_page' ) );
|
3442 |
-
|
3443 |
-
if ( self::is_plugins_page() || self::is_themes_page() ) {
|
3444 |
-
add_action( 'admin_print_footer_scripts', array( 'Freemius', '_maybe_add_beta_label_styles' ), 9 );
|
3445 |
-
|
3446 |
-
/**
|
3447 |
-
* Specifically use this hook so that the JS event handlers will work properly on the "Themes"
|
3448 |
-
* page.
|
3449 |
-
*
|
3450 |
-
* @author Leo Fajardo (@leorw)
|
3451 |
-
* @since 2.3.0
|
3452 |
-
*/
|
3453 |
-
add_action( 'admin_footer-' . self::get_current_page(), array( 'Freemius', '_maybe_add_beta_label_to_plugins_and_handle_confirmation') );
|
3454 |
-
}
|
3455 |
-
|
3456 |
-
self::$_statics_loaded = true;
|
3457 |
-
}
|
3458 |
-
|
3459 |
-
/**
|
3460 |
-
* @author Leo Fajardo (@leorw)
|
3461 |
-
*
|
3462 |
-
* @since 2.1.3
|
3463 |
-
*/
|
3464 |
-
private static function migrate_options_to_network() {
|
3465 |
-
self::migrate_accounts_to_network();
|
3466 |
-
|
3467 |
-
// Migrate API options from site level to network level.
|
3468 |
-
$api_network_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true, true );
|
3469 |
-
$api_network_options->migrate_to_network();
|
3470 |
-
|
3471 |
-
// Migrate API cache to network level storage.
|
3472 |
-
FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME )->migrate_to_network();
|
3473 |
-
|
3474 |
-
self::$_accounts->set_option( 'ms_migration_complete', true, true );
|
3475 |
-
}
|
3476 |
-
|
3477 |
-
#----------------------------------------------------------------------------------
|
3478 |
-
#region Localization
|
3479 |
-
#----------------------------------------------------------------------------------
|
3480 |
-
|
3481 |
-
/**
|
3482 |
-
* Load framework's text domain.
|
3483 |
-
*
|
3484 |
-
* @author Vova Feldman (@svovaf)
|
3485 |
-
* @since 1.2.1
|
3486 |
-
*/
|
3487 |
-
static function _load_textdomain() {
|
3488 |
-
if ( ! is_admin() ) {
|
3489 |
-
return;
|
3490 |
-
}
|
3491 |
-
|
3492 |
-
global $fs_active_plugins;
|
3493 |
-
|
3494 |
-
// Works both for plugins and themes.
|
3495 |
-
load_plugin_textdomain(
|
3496 |
-
'freemius',
|
3497 |
-
false,
|
3498 |
-
$fs_active_plugins->newest->sdk_path . '/languages/'
|
3499 |
-
);
|
3500 |
-
}
|
3501 |
-
|
3502 |
-
#endregion
|
3503 |
-
|
3504 |
-
#----------------------------------------------------------------------------------
|
3505 |
-
#region Debugging
|
3506 |
-
#----------------------------------------------------------------------------------
|
3507 |
-
|
3508 |
-
/**
|
3509 |
-
* @author Vova Feldman (@svovaf)
|
3510 |
-
* @since 1.0.8
|
3511 |
-
*/
|
3512 |
-
static function _add_debug_section() {
|
3513 |
-
if ( ! is_super_admin() ) {
|
3514 |
-
// Add debug page only for super-admins.
|
3515 |
-
return;
|
3516 |
-
}
|
3517 |
-
|
3518 |
-
self::$_static_logger->entrance();
|
3519 |
-
|
3520 |
-
$title = sprintf( '%s [v.%s]', fs_text_inline( 'Freemius Debug' ), WP_FS__SDK_VERSION );
|
3521 |
-
|
3522 |
-
if ( WP_FS__DEV_MODE ) {
|
3523 |
-
// Add top-level debug menu item.
|
3524 |
-
$hook = FS_Admin_Menu_Manager::add_page(
|
3525 |
-
$title,
|
3526 |
-
$title,
|
3527 |
-
'manage_options',
|
3528 |
-
'freemius',
|
3529 |
-
array( 'Freemius', '_debug_page_render' )
|
3530 |
-
);
|
3531 |
-
} else {
|
3532 |
-
// Add hidden debug page.
|
3533 |
-
$hook = FS_Admin_Menu_Manager::add_subpage(
|
3534 |
-
null,
|
3535 |
-
$title,
|
3536 |
-
$title,
|
3537 |
-
'manage_options',
|
3538 |
-
'freemius',
|
3539 |
-
array( 'Freemius', '_debug_page_render' )
|
3540 |
-
);
|
3541 |
-
}
|
3542 |
-
|
3543 |
-
if ( ! empty( $hook ) ) {
|
3544 |
-
add_action( "load-$hook", array( 'Freemius', '_debug_page_actions' ) );
|
3545 |
-
}
|
3546 |
-
}
|
3547 |
-
|
3548 |
-
/**
|
3549 |
-
* @author Vova Feldman (@svovaf)
|
3550 |
-
* @since 1.1.7.3
|
3551 |
-
*/
|
3552 |
-
static function _toggle_debug_mode() {
|
3553 |
-
if ( ! is_super_admin() ) {
|
3554 |
-
return;
|
3555 |
-
}
|
3556 |
-
|
3557 |
-
$is_on = fs_request_get( 'is_on', false, 'post' );
|
3558 |
-
|
3559 |
-
if ( fs_request_is_post() && in_array( $is_on, array( 0, 1 ) ) ) {
|
3560 |
-
update_option( 'fs_debug_mode', $is_on );
|
3561 |
-
|
3562 |
-
// Turn on/off storage logging.
|
3563 |
-
FS_Logger::_set_storage_logging( ( 1 == $is_on ) );
|
3564 |
-
}
|
3565 |
-
|
3566 |
-
exit;
|
3567 |
-
}
|
3568 |
-
|
3569 |
-
/**
|
3570 |
-
* @author Vova Feldman (@svovaf)
|
3571 |
-
* @since 1.2.1.6
|
3572 |
-
*/
|
3573 |
-
static function _get_debug_log() {
|
3574 |
-
$logs = FS_Logger::load_db_logs(
|
3575 |
-
fs_request_get( 'filters', false, 'post' ),
|
3576 |
-
! empty( $_POST['limit'] ) && is_numeric( $_POST['limit'] ) ? $_POST['limit'] : 200,
|
3577 |
-
! empty( $_POST['offset'] ) && is_numeric( $_POST['offset'] ) ? $_POST['offset'] : 0
|
3578 |
-
);
|
3579 |
-
|
3580 |
-
self::shoot_ajax_success( $logs );
|
3581 |
-
}
|
3582 |
-
|
3583 |
-
/**
|
3584 |
-
* @author Vova Feldman (@svovaf)
|
3585 |
-
* @since 1.2.1.7
|
3586 |
-
*/
|
3587 |
-
static function _get_db_option() {
|
3588 |
-
check_admin_referer( 'fs_get_db_option' );
|
3589 |
-
|
3590 |
-
$option_name = fs_request_get( 'option_name' );
|
3591 |
-
|
3592 |
-
if ( ! is_super_admin() ||
|
3593 |
-
! fs_starts_with( $option_name, 'fs_' )
|
3594 |
-
) {
|
3595 |
-
self::shoot_ajax_failure();
|
3596 |
-
}
|
3597 |
-
|
3598 |
-
$value = get_option( $option_name );
|
3599 |
-
|
3600 |
-
$result = array(
|
3601 |
-
'name' => $option_name,
|
3602 |
-
);
|
3603 |
-
|
3604 |
-
if ( false !== $value ) {
|
3605 |
-
if ( ! is_string( $value ) ) {
|
3606 |
-
$value = json_encode( $value );
|
3607 |
-
}
|
3608 |
-
|
3609 |
-
$result['value'] = $value;
|
3610 |
-
}
|
3611 |
-
|
3612 |
-
self::shoot_ajax_success( $result );
|
3613 |
-
}
|
3614 |
-
|
3615 |
-
/**
|
3616 |
-
* @author Vova Feldman (@svovaf)
|
3617 |
-
* @since 1.2.1.7
|
3618 |
-
*/
|
3619 |
-
static function _set_db_option() {
|
3620 |
-
check_admin_referer( 'fs_set_db_option' );
|
3621 |
-
|
3622 |
-
$option_name = fs_request_get( 'option_name' );
|
3623 |
-
|
3624 |
-
if ( ! is_super_admin() ||
|
3625 |
-
! fs_starts_with( $option_name, 'fs_' )
|
3626 |
-
) {
|
3627 |
-
self::shoot_ajax_failure();
|
3628 |
-
}
|
3629 |
-
|
3630 |
-
$option_value = fs_request_get( 'option_value' );
|
3631 |
-
|
3632 |
-
if ( ! empty( $option_value ) ) {
|
3633 |
-
update_option( $option_name, $option_value );
|
3634 |
-
}
|
3635 |
-
|
3636 |
-
self::shoot_ajax_success();
|
3637 |
-
}
|
3638 |
-
|
3639 |
-
/**
|
3640 |
-
* @author Vova Feldman (@svovaf)
|
3641 |
-
* @since 1.0.8
|
3642 |
-
*/
|
3643 |
-
static function _debug_page_actions() {
|
3644 |
-
self::_clean_admin_content_section();
|
3645 |
-
|
3646 |
-
if ( fs_request_is_action( 'restart_freemius' ) ) {
|
3647 |
-
check_admin_referer( 'restart_freemius' );
|
3648 |
-
|
3649 |
-
if ( ! is_multisite() ) {
|
3650 |
-
// Clear accounts data.
|
3651 |
-
self::$_accounts->clear( null, true );
|
3652 |
-
} else {
|
3653 |
-
$sites = self::get_sites();
|
3654 |
-
foreach ( $sites as $site ) {
|
3655 |
-
$blog_id = self::get_site_blog_id( $site );
|
3656 |
-
self::$_accounts->clear( $blog_id, true );
|
3657 |
-
}
|
3658 |
-
|
3659 |
-
// Clear network level storage.
|
3660 |
-
self::$_accounts->clear( true, true );
|
3661 |
-
}
|
3662 |
-
|
3663 |
-
// Clear SDK reference cache.
|
3664 |
-
delete_option( 'fs_active_plugins' );
|
3665 |
-
} else if ( fs_request_is_action( 'clear_updates_data' ) ) {
|
3666 |
-
check_admin_referer( 'clear_updates_data' );
|
3667 |
-
|
3668 |
-
if ( ! is_multisite() ) {
|
3669 |
-
set_site_transient( 'update_plugins', null );
|
3670 |
-
set_site_transient( 'update_themes', null );
|
3671 |
-
} else {
|
3672 |
-
$current_blog_id = get_current_blog_id();
|
3673 |
-
|
3674 |
-
$sites = self::get_sites();
|
3675 |
-
foreach ( $sites as $site ) {
|
3676 |
-
switch_to_blog( self::get_site_blog_id( $site ) );
|
3677 |
-
|
3678 |
-
set_site_transient( 'update_plugins', null );
|
3679 |
-
set_site_transient( 'update_themes', null );
|
3680 |
-
}
|
3681 |
-
|
3682 |
-
switch_to_blog( $current_blog_id );
|
3683 |
-
}
|
3684 |
-
} else if ( fs_request_is_action( 'simulate_trial' ) ) {
|
3685 |
-
check_admin_referer( 'simulate_trial' );
|
3686 |
-
|
3687 |
-
$fs = freemius( fs_request_get( 'module_id' ) );
|
3688 |
-
|
3689 |
-
// Update SDK install to at least 24 hours before.
|
3690 |
-
$fs->_storage->install_timestamp = ( time() - WP_FS__TIME_24_HOURS_IN_SEC );
|
3691 |
-
// Unset the trial shown timestamp.
|
3692 |
-
unset( $fs->_storage->trial_promotion_shown );
|
3693 |
-
} else if ( fs_request_is_action( 'simulate_network_upgrade' ) ) {
|
3694 |
-
check_admin_referer( 'simulate_network_upgrade' );
|
3695 |
-
|
3696 |
-
$fs = freemius( fs_request_get( 'module_id' ) );
|
3697 |
-
|
3698 |
-
self::set_network_upgrade_mode( $fs->_storage );
|
3699 |
-
} else if ( fs_request_is_action( 'delete_install' ) ) {
|
3700 |
-
check_admin_referer( 'delete_install' );
|
3701 |
-
|
3702 |
-
self::_delete_site_by_slug(
|
3703 |
-
fs_request_get( 'slug' ),
|
3704 |
-
fs_request_get( 'module_type' ),
|
3705 |
-
true,
|
3706 |
-
fs_request_get( 'blog_id', null )
|
3707 |
-
);
|
3708 |
-
} else if ( fs_request_is_action( 'delete_user' ) ) {
|
3709 |
-
check_admin_referer( 'delete_user' );
|
3710 |
-
|
3711 |
-
self::delete_user( fs_request_get( 'user_id' ) );
|
3712 |
-
} else if ( fs_request_is_action( 'download_logs' ) ) {
|
3713 |
-
check_admin_referer( 'download_logs' );
|
3714 |
-
|
3715 |
-
$download_url = FS_Logger::download_db_logs(
|
3716 |
-
fs_request_get( 'filters', false, 'post' )
|
3717 |
-
);
|
3718 |
-
|
3719 |
-
if ( false === $download_url ) {
|
3720 |
-
wp_die( 'Oops... there was an error while generating the logs download file. Please try again and if it doesn\'t work contact support@freemius.com.' );
|
3721 |
-
}
|
3722 |
-
|
3723 |
-
fs_redirect( $download_url );
|
3724 |
-
} else if ( fs_request_is_action( 'migrate_options_to_network' ) ) {
|
3725 |
-
check_admin_referer( 'migrate_options_to_network' );
|
3726 |
-
|
3727 |
-
self::migrate_options_to_network();
|
3728 |
-
}
|
3729 |
-
}
|
3730 |
-
|
3731 |
-
/**
|
3732 |
-
* @author Vova Feldman (@svovaf)
|
3733 |
-
* @since 1.0.8
|
3734 |
-
*/
|
3735 |
-
static function _debug_page_render() {
|
3736 |
-
self::$_static_logger->entrance();
|
3737 |
-
|
3738 |
-
if ( ! is_multisite() ) {
|
3739 |
-
$all_plugins_installs = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN );
|
3740 |
-
$all_themes_installs = self::get_all_sites( WP_FS__MODULE_TYPE_THEME );
|
3741 |
-
} else {
|
3742 |
-
$sites = self::get_sites();
|
3743 |
-
|
3744 |
-
$all_plugins_installs = array();
|
3745 |
-
$all_themes_installs = array();
|
3746 |
-
|
3747 |
-
foreach ( $sites as $site ) {
|
3748 |
-
$blog_id = self::get_site_blog_id( $site );
|
3749 |
-
|
3750 |
-
$plugins_installs = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN, $blog_id );
|
3751 |
-
|
3752 |
-
foreach ( $plugins_installs as $slug => $install ) {
|
3753 |
-
if ( ! isset( $all_plugins_installs[ $slug ] ) ) {
|
3754 |
-
$all_plugins_installs[ $slug ] = array();
|
3755 |
-
}
|
3756 |
-
|
3757 |
-
$install->blog_id = $blog_id;
|
3758 |
-
|
3759 |
-
$all_plugins_installs[ $slug ][] = $install;
|
3760 |
-
}
|
3761 |
-
|
3762 |
-
$themes_installs = self::get_all_sites( WP_FS__MODULE_TYPE_THEME, $blog_id );
|
3763 |
-
|
3764 |
-
foreach ( $themes_installs as $slug => $install ) {
|
3765 |
-
if ( ! isset( $all_themes_installs[ $slug ] ) ) {
|
3766 |
-
$all_themes_installs[ $slug ] = array();
|
3767 |
-
}
|
3768 |
-
|
3769 |
-
$install->blog_id = $blog_id;
|
3770 |
-
|
3771 |
-
$all_themes_installs[ $slug ][] = $install;
|
3772 |
-
}
|
3773 |
-
}
|
3774 |
-
}
|
3775 |
-
|
3776 |
-
$licenses_by_module_type = self::get_all_licenses_by_module_type();
|
3777 |
-
|
3778 |
-
$vars = array(
|
3779 |
-
'plugin_sites' => $all_plugins_installs,
|
3780 |
-
'theme_sites' => $all_themes_installs,
|
3781 |
-
'users' => self::get_all_users(),
|
3782 |
-
'addons' => self::get_all_addons(),
|
3783 |
-
'account_addons' => self::get_all_account_addons(),
|
3784 |
-
'plugin_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_PLUGIN ],
|
3785 |
-
'theme_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_THEME ]
|
3786 |
-
);
|
3787 |
-
|
3788 |
-
fs_enqueue_local_style( 'fs_debug', '/admin/debug.css' );
|
3789 |
-
fs_require_once_template( 'debug.php', $vars );
|
3790 |
-
}
|
3791 |
-
|
3792 |
-
#endregion
|
3793 |
-
|
3794 |
-
#----------------------------------------------------------------------------------
|
3795 |
-
#region Connectivity Issues
|
3796 |
-
#----------------------------------------------------------------------------------
|
3797 |
-
|
3798 |
-
/**
|
3799 |
-
* Check if Freemius should be turned on for the current plugin install.
|
3800 |
-
*
|
3801 |
-
* Note:
|
3802 |
-
* $this->_is_on is updated in has_api_connectivity()
|
3803 |
-
*
|
3804 |
-
* @author Vova Feldman (@svovaf)
|
3805 |
-
* @since 1.0.9
|
3806 |
-
*
|
3807 |
-
* @return bool
|
3808 |
-
*/
|
3809 |
-
function is_on() {
|
3810 |
-
self::$_static_logger->entrance();
|
3811 |
-
|
3812 |
-
if ( isset( $this->_is_on ) ) {
|
3813 |
-
return $this->_is_on;
|
3814 |
-
}
|
3815 |
-
|
3816 |
-
// If already installed or pending then sure it's on :)
|
3817 |
-
if ( $this->is_registered() || $this->is_pending_activation() ) {
|
3818 |
-
$this->_is_on = true;
|
3819 |
-
|
3820 |
-
return true;
|
3821 |
-
}
|
3822 |
-
|
3823 |
-
return false;
|
3824 |
-
}
|
3825 |
-
|
3826 |
-
/**
|
3827 |
-
* @author Vova Feldman (@svovaf)
|
3828 |
-
* @since 1.1.7.3
|
3829 |
-
*
|
3830 |
-
* @param bool $flush_if_no_connectivity
|
3831 |
-
*
|
3832 |
-
* @return bool
|
3833 |
-
*/
|
3834 |
-
private function should_run_connectivity_test( $flush_if_no_connectivity = false ) {
|
3835 |
-
if ( ! isset( $this->_storage->connectivity_test ) ) {
|
3836 |
-
// Connectivity test was never executed, or cache was cleared.
|
3837 |
-
return true;
|
3838 |
-
}
|
3839 |
-
|
3840 |
-
if ( WP_FS__PING_API_ON_IP_OR_HOST_CHANGES ) {
|
3841 |
-
if ( WP_FS__IS_HTTP_REQUEST ) {
|
3842 |
-
if ( $_SERVER['HTTP_HOST'] != $this->_storage->connectivity_test['host'] ) {
|
3843 |
-
// Domain changed.
|
3844 |
-
return true;
|
3845 |
-
}
|
3846 |
-
|
3847 |
-
if ( WP_FS__REMOTE_ADDR != $this->_storage->connectivity_test['server_ip'] ) {
|
3848 |
-
// Server IP changed.
|
3849 |
-
return true;
|
3850 |
-
}
|
3851 |
-
}
|
3852 |
-
}
|
3853 |
-
|
3854 |
-
if ( $this->_storage->connectivity_test['is_connected'] &&
|
3855 |
-
$this->_storage->connectivity_test['is_active']
|
3856 |
-
) {
|
3857 |
-
// API connected and Freemius is active - no need to run connectivity check.
|
3858 |
-
return false;
|
3859 |
-
}
|
3860 |
-
|
3861 |
-
if ( $flush_if_no_connectivity ) {
|
3862 |
-
/**
|
3863 |
-
* If explicitly asked to flush when no connectivity - do it only
|
3864 |
-
* if at least 10 sec passed from the last API connectivity test.
|
3865 |
-
*/
|
3866 |
-
return ( isset( $this->_storage->connectivity_test['timestamp'] ) &&
|
3867 |
-
( WP_FS__SCRIPT_START_TIME - $this->_storage->connectivity_test['timestamp'] ) > 10 );
|
3868 |
-
}
|
3869 |
-
|
3870 |
-
/**
|
3871 |
-
* @since 1.1.7 Don't check for connectivity on plugin downgrade.
|
3872 |
-
*/
|
3873 |
-
$version = $this->get_plugin_version();
|
3874 |
-
if ( version_compare( $version, $this->_storage->connectivity_test['version'], '>' ) ) {
|
3875 |
-
// If it's a plugin version upgrade and Freemius is off or no connectivity, run connectivity test.
|
3876 |
-
return true;
|
3877 |
-
}
|
3878 |
-
|
3879 |
-
return false;
|
3880 |
-
}
|
3881 |
-
|
3882 |
-
/**
|
3883 |
-
* @author Vova Feldman (@svovaf)
|
3884 |
-
* @since 1.1.7.4
|
3885 |
-
*
|
3886 |
-
* @param int|null $blog_id Since 2.0.0.
|
3887 |
-
* @param bool $is_gdpr_test Since 2.0.2. Perform only the GDPR test.
|
3888 |
-
*
|
3889 |
-
* @return object|false
|
3890 |
-
*/
|
3891 |
-
private function ping( $blog_id = null, $is_gdpr_test = false ) {
|
3892 |
-
if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY ) {
|
3893 |
-
return false;
|
3894 |
-
}
|
3895 |
-
|
3896 |
-
$version = $this->get_plugin_version();
|
3897 |
-
|
3898 |
-
$is_update = $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() );
|
3899 |
-
|
3900 |
-
return $this->get_api_plugin_scope()->ping(
|
3901 |
-
$this->get_anonymous_id( $blog_id ),
|
3902 |
-
array(
|
3903 |
-
'is_update' => json_encode( $is_update ),
|
3904 |
-
'version' => $version,
|
3905 |
-
'sdk' => $this->version,
|
3906 |
-
'is_admin' => json_encode( is_admin() ),
|
3907 |
-
'is_ajax' => json_encode( self::is_ajax() ),
|
3908 |
-
'is_cron' => json_encode( self::is_cron() ),
|
3909 |
-
'is_gdpr_test' => $is_gdpr_test,
|
3910 |
-
'is_http' => json_encode( WP_FS__IS_HTTP_REQUEST ),
|
3911 |
-
)
|
3912 |
-
);
|
3913 |
-
}
|
3914 |
-
|
3915 |
-
/**
|
3916 |
-
* Check if there's any connectivity issue to Freemius API.
|
3917 |
-
*
|
3918 |
-
* @author Vova Feldman (@svovaf)
|
3919 |
-
* @since 1.0.9
|
3920 |
-
*
|
3921 |
-
* @param bool $flush_if_no_connectivity
|
3922 |
-
*
|
3923 |
-
* @return bool
|
3924 |
-
*/
|
3925 |
-
function has_api_connectivity( $flush_if_no_connectivity = false ) {
|
3926 |
-
$this->_logger->entrance();
|
3927 |
-
|
3928 |
-
if ( isset( $this->_has_api_connection ) && ( $this->_has_api_connection || ! $flush_if_no_connectivity ) ) {
|
3929 |
-
return $this->_has_api_connection;
|
3930 |
-
}
|
3931 |
-
|
3932 |
-
if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY &&
|
3933 |
-
isset( $this->_storage->connectivity_test ) &&
|
3934 |
-
true === $this->_storage->connectivity_test['is_connected']
|
3935 |
-
) {
|
3936 |
-
unset( $this->_storage->connectivity_test );
|
3937 |
-
}
|
3938 |
-
|
3939 |
-
if ( ! $this->should_run_connectivity_test( $flush_if_no_connectivity ) ) {
|
3940 |
-
$this->_has_api_connection = $this->_storage->connectivity_test['is_connected'];
|
3941 |
-
/**
|
3942 |
-
* @since 1.1.6 During dev mode, if there's connectivity - turn Freemius on regardless the configuration.
|
3943 |
-
*
|
3944 |
-
* @since 1.2.1.5 If the user running the premium version then ignore the 'is_active' flag and turn Freemius on to enable license key activation.
|
3945 |
-
*/
|
3946 |
-
$this->_is_on = $this->_storage->connectivity_test['is_active'] ||
|
3947 |
-
$this->is_premium() ||
|
3948 |
-
( WP_FS__DEV_MODE && $this->_has_api_connection && ! WP_FS__SIMULATE_FREEMIUS_OFF );
|
3949 |
-
|
3950 |
-
return $this->_has_api_connection;
|
3951 |
-
}
|
3952 |
-
|
3953 |
-
$pong = $this->ping();
|
3954 |
-
$is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
|
3955 |
-
|
3956 |
-
if ( ! $is_connected ) {
|
3957 |
-
// API failure.
|
3958 |
-
$this->_add_connectivity_issue_message( $pong );
|
3959 |
-
}
|
3960 |
-
|
3961 |
-
if ( $is_connected ) {
|
3962 |
-
FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
|
3963 |
-
}
|
3964 |
-
|
3965 |
-
$this->store_connectivity_info( $pong, $is_connected );
|
3966 |
-
|
3967 |
-
return $this->_has_api_connection;
|
3968 |
-
}
|
3969 |
-
|
3970 |
-
/**
|
3971 |
-
* @author Vova Feldman (@svovaf)
|
3972 |
-
* @since 1.1.7.4
|
3973 |
-
*
|
3974 |
-
* @param object $pong
|
3975 |
-
* @param bool $is_connected
|
3976 |
-
*/
|
3977 |
-
private function store_connectivity_info( $pong, $is_connected ) {
|
3978 |
-
$this->_logger->entrance();
|
3979 |
-
|
3980 |
-
$version = $this->get_plugin_version();
|
3981 |
-
|
3982 |
-
if ( ! $is_connected || WP_FS__SIMULATE_FREEMIUS_OFF ) {
|
3983 |
-
$is_active = false;
|
3984 |
-
} else {
|
3985 |
-
$is_active = ( isset( $pong->is_active ) && true == $pong->is_active );
|
3986 |
-
}
|
3987 |
-
|
3988 |
-
$is_active = $this->apply_filters(
|
3989 |
-
'is_on',
|
3990 |
-
$is_active,
|
3991 |
-
$this->is_plugin_update(),
|
3992 |
-
$version
|
3993 |
-
);
|
3994 |
-
|
3995 |
-
$this->_storage->connectivity_test = array(
|
3996 |
-
'is_connected' => $is_connected,
|
3997 |
-
'host' => $_SERVER['HTTP_HOST'],
|
3998 |
-
'server_ip' => WP_FS__REMOTE_ADDR,
|
3999 |
-
'is_active' => $is_active,
|
4000 |
-
'timestamp' => WP_FS__SCRIPT_START_TIME,
|
4001 |
-
// Last version with connectivity attempt.
|
4002 |
-
'version' => $version,
|
4003 |
-
);
|
4004 |
-
|
4005 |
-
$this->_has_api_connection = $is_connected;
|
4006 |
-
$this->_is_on = $is_active || ( WP_FS__DEV_MODE && $is_connected && ! WP_FS__SIMULATE_FREEMIUS_OFF );
|
4007 |
-
}
|
4008 |
-
|
4009 |
-
/**
|
4010 |
-
* Force turning Freemius on.
|
4011 |
-
*
|
4012 |
-
* @author Vova Feldman (@svovaf)
|
4013 |
-
* @since 1.1.8.1
|
4014 |
-
*
|
4015 |
-
* @return bool TRUE if successfully turned on.
|
4016 |
-
*/
|
4017 |
-
private function turn_on() {
|
4018 |
-
$this->_logger->entrance();
|
4019 |
-
|
4020 |
-
if ( $this->is_on() || ! isset( $this->_storage->connectivity_test['is_active'] ) ) {
|
4021 |
-
return false;
|
4022 |
-
}
|
4023 |
-
|
4024 |
-
$updated_connectivity = $this->_storage->connectivity_test;
|
4025 |
-
$updated_connectivity['is_active'] = true;
|
4026 |
-
$updated_connectivity['timestamp'] = WP_FS__SCRIPT_START_TIME;
|
4027 |
-
$this->_storage->connectivity_test = $updated_connectivity;
|
4028 |
-
|
4029 |
-
$this->_is_on = true;
|
4030 |
-
|
4031 |
-
return true;
|
4032 |
-
}
|
4033 |
-
|
4034 |
-
/**
|
4035 |
-
* Anonymous and unique site identifier (Hash).
|
4036 |
-
*
|
4037 |
-
* @author Vova Feldman (@svovaf)
|
4038 |
-
* @since 1.1.0
|
4039 |
-
*
|
4040 |
-
* @param null|int $blog_id Since 2.0.0
|
4041 |
-
*
|
4042 |
-
* @return string
|
4043 |
-
*/
|
4044 |
-
function get_anonymous_id( $blog_id = null ) {
|
4045 |
-
$unique_id = self::$_accounts->get_option( 'unique_id', null, $blog_id );
|
4046 |
-
|
4047 |
-
if ( empty( $unique_id ) || ! is_string( $unique_id ) ) {
|
4048 |
-
$key = fs_strip_url_protocol( get_site_url( $blog_id ) );
|
4049 |
-
|
4050 |
-
$secure_auth = SECURE_AUTH_KEY;
|
4051 |
-
if ( empty( $secure_auth ) ||
|
4052 |
-
false !== strpos( $secure_auth, ' ' ) ||
|
4053 |
-
'put your unique phrase here' === $secure_auth
|
4054 |
-
) {
|
4055 |
-
// Protect against default auth key.
|
4056 |
-
$secure_auth = md5( microtime() );
|
4057 |
-
}
|
4058 |
-
|
4059 |
-
/**
|
4060 |
-
* Base the unique identifier on the WP secure authentication key. Which
|
4061 |
-
* turns the key into a secret anonymous identifier. This will help us
|
4062 |
-
* to avoid duplicate installs generation on the backend upon opt-in.
|
4063 |
-
*
|
4064 |
-
* @author Vova Feldman (@svovaf)
|
4065 |
-
* @since 1.2.3
|
4066 |
-
*/
|
4067 |
-
$unique_id = md5( $key . $secure_auth );
|
4068 |
-
|
4069 |
-
self::$_accounts->set_option( 'unique_id', $unique_id, true, $blog_id );
|
4070 |
-
}
|
4071 |
-
|
4072 |
-
$this->_logger->departure( $unique_id );
|
4073 |
-
|
4074 |
-
return $unique_id;
|
4075 |
-
}
|
4076 |
-
|
4077 |
-
/**
|
4078 |
-
* @author Vova Feldman (@svovaf)
|
4079 |
-
* @since 1.1.7.4
|
4080 |
-
*
|
4081 |
-
* @return \WP_User
|
4082 |
-
*/
|
4083 |
-
static function _get_current_wp_user() {
|
4084 |
-
self::require_pluggable_essentials();
|
4085 |
-
self::wp_cookie_constants();
|
4086 |
-
|
4087 |
-
return wp_get_current_user();
|
4088 |
-
}
|
4089 |
-
|
4090 |
-
/**
|
4091 |
-
* Define cookie constants which are required by Freemius::_get_current_wp_user() since
|
4092 |
-
* it uses wp_get_current_user() which needs the cookie constants set. When a plugin
|
4093 |
-
* is network activated the cookie constants are only configured after the network
|
4094 |
-
* plugins activation, therefore, if we don't define those constants WP will throw
|
4095 |
-
* PHP warnings/notices.
|
4096 |
-
*
|
4097 |
-
* @author Vova Feldman (@svovaf)
|
4098 |
-
* @since 2.1.1
|
4099 |
-
*/
|
4100 |
-
private static function wp_cookie_constants() {
|
4101 |
-
if ( defined( 'LOGGED_IN_COOKIE' ) &&
|
4102 |
-
( defined( 'AUTH_COOKIE' ) || defined( 'SECURE_AUTH_COOKIE' ) )
|
4103 |
-
) {
|
4104 |
-
return;
|
4105 |
-
}
|
4106 |
-
|
4107 |
-
/**
|
4108 |
-
* Used to guarantee unique hash cookies
|
4109 |
-
*
|
4110 |
-
* @since 1.5.0
|
4111 |
-
*/
|
4112 |
-
if ( ! defined( 'COOKIEHASH' ) ) {
|
4113 |
-
$siteurl = get_site_option( 'siteurl' );
|
4114 |
-
if ( $siteurl ) {
|
4115 |
-
define( 'COOKIEHASH', md5( $siteurl ) );
|
4116 |
-
} else {
|
4117 |
-
define( 'COOKIEHASH', '' );
|
4118 |
-
}
|
4119 |
-
}
|
4120 |
-
|
4121 |
-
if ( ! defined( 'LOGGED_IN_COOKIE' ) ) {
|
4122 |
-
define( 'LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH );
|
4123 |
-
}
|
4124 |
-
|
4125 |
-
/**
|
4126 |
-
* @since 2.5.0
|
4127 |
-
*/
|
4128 |
-
if ( ! defined( 'AUTH_COOKIE' ) ) {
|
4129 |
-
define( 'AUTH_COOKIE', 'wordpress_' . COOKIEHASH );
|
4130 |
-
}
|
4131 |
-
|
4132 |
-
/**
|
4133 |
-
* @since 2.6.0
|
4134 |
-
*/
|
4135 |
-
if ( ! defined( 'SECURE_AUTH_COOKIE' ) ) {
|
4136 |
-
define( 'SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH );
|
4137 |
-
}
|
4138 |
-
}
|
4139 |
-
|
4140 |
-
/**
|
4141 |
-
* @author Vova Feldman (@svovaf)
|
4142 |
-
* @since 2.1.0
|
4143 |
-
*
|
4144 |
-
* @return int
|
4145 |
-
*/
|
4146 |
-
static function get_current_wp_user_id() {
|
4147 |
-
$wp_user = self::_get_current_wp_user();
|
4148 |
-
|
4149 |
-
return $wp_user->ID;
|
4150 |
-
}
|
4151 |
-
|
4152 |
-
/**
|
4153 |
-
* @author Vova Feldman (@svovaf)
|
4154 |
-
* @since 1.2.1.7
|
4155 |
-
*
|
4156 |
-
* @param string $email
|
4157 |
-
*
|
4158 |
-
* @return bool
|
4159 |
-
*/
|
4160 |
-
static function is_valid_email( $email ) {
|
4161 |
-
if ( false === filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
|
4162 |
-
return false;
|
4163 |
-
}
|
4164 |
-
|
4165 |
-
$parts = explode( '@', $email );
|
4166 |
-
|
4167 |
-
if ( 2 !== count( $parts ) || empty( $parts[1] ) ) {
|
4168 |
-
return false;
|
4169 |
-
}
|
4170 |
-
|
4171 |
-
$blacklist = array(
|
4172 |
-
'admin.',
|
4173 |
-
'webmaster.',
|
4174 |
-
'localhost.',
|
4175 |
-
'dev.',
|
4176 |
-
'development.',
|
4177 |
-
'test.',
|
4178 |
-
'stage.',
|
4179 |
-
'staging.',
|
4180 |
-
);
|
4181 |
-
|
4182 |
-
// Make sure domain is not one of the blacklisted.
|
4183 |
-
foreach ( $blacklist as $invalid ) {
|
4184 |
-
if ( 0 === strpos( $parts[1], $invalid ) ) {
|
4185 |
-
return false;
|
4186 |
-
}
|
4187 |
-
}
|
4188 |
-
|
4189 |
-
// Get the UTF encoded domain name.
|
4190 |
-
$domain = idn_to_ascii( $parts[1] ) . '.';
|
4191 |
-
|
4192 |
-
return ( checkdnsrr( $domain, 'MX' ) || checkdnsrr( $domain, 'A' ) );
|
4193 |
-
}
|
4194 |
-
|
4195 |
-
/**
|
4196 |
-
* Generate API connectivity issue message.
|
4197 |
-
*
|
4198 |
-
* @author Vova Feldman (@svovaf)
|
4199 |
-
* @since 1.0.9
|
4200 |
-
*
|
4201 |
-
* @param mixed $api_result
|
4202 |
-
* @param bool $is_first_failure
|
4203 |
-
*/
|
4204 |
-
function _add_connectivity_issue_message( $api_result, $is_first_failure = true ) {
|
4205 |
-
if ( ! $this->is_premium() && $this->_enable_anonymous ) {
|
4206 |
-
// Don't add message if it's the free version and can run anonymously.
|
4207 |
-
return;
|
4208 |
-
}
|
4209 |
-
|
4210 |
-
if ( ! function_exists( 'wp_nonce_url' ) ) {
|
4211 |
-
require_once ABSPATH . 'wp-includes/functions.php';
|
4212 |
-
}
|
4213 |
-
|
4214 |
-
$current_user = self::_get_current_wp_user();
|
4215 |
-
// $admin_email = get_option( 'admin_email' );
|
4216 |
-
$admin_email = $current_user->user_email;
|
4217 |
-
|
4218 |
-
// Aliases.
|
4219 |
-
$deactivate_plugin_title = $this->esc_html_inline( 'That\'s exhausting, please deactivate', 'deactivate-plugin-title' );
|
4220 |
-
$deactivate_plugin_desc = $this->esc_html_inline( 'We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future.', 'deactivate-plugin-desc' );
|
4221 |
-
$install_previous_title = $this->esc_html_inline( 'Let\'s try your previous version', 'install-previous-title' );
|
4222 |
-
$install_previous_desc = $this->esc_html_inline( 'Uninstall this version and install the previous one.', 'install-previous-desc' );
|
4223 |
-
$fix_issue_title = $this->esc_html_inline( 'Yes - I\'m giving you a chance to fix it', 'fix-issue-title' );
|
4224 |
-
$fix_issue_desc = $this->esc_html_inline( 'We will do our best to whitelist your server and resolve this issue ASAP. You will get a follow-up email to %s once we have an update.', 'fix-issue-desc' );
|
4225 |
-
/* translators: %s: product title (e.g. "Awesome Plugin" requires an access to...) */
|
4226 |
-
$x_requires_access_to_api = $this->esc_html_inline( '%s requires an access to our API.', 'x-requires-access-to-api' );
|
4227 |
-
$sysadmin_title = $this->esc_html_inline( 'I\'m a system administrator', 'sysadmin-title' );
|
4228 |
-
$happy_to_resolve_issue_asap = $this->esc_html_inline( 'We are sure it\'s an issue on our side and more than happy to resolve it for you ASAP if you give us a chance.', 'happy-to-resolve-issue-asap' );
|
4229 |
-
|
4230 |
-
$message = false;
|
4231 |
-
if ( is_object( $api_result ) &&
|
4232 |
-
isset( $api_result->error ) &&
|
4233 |
-
isset( $api_result->error->code )
|
4234 |
-
) {
|
4235 |
-
switch ( $api_result->error->code ) {
|
4236 |
-
case 'curl_missing':
|
4237 |
-
$missing_methods = '';
|
4238 |
-
if ( is_array( $api_result->missing_methods ) &&
|
4239 |
-
! empty( $api_result->missing_methods )
|
4240 |
-
) {
|
4241 |
-
foreach ( $api_result->missing_methods as $m ) {
|
4242 |
-
if ( 'curl_version' === $m ) {
|
4243 |
-
continue;
|
4244 |
-
}
|
4245 |
-
|
4246 |
-
if ( ! empty( $missing_methods ) ) {
|
4247 |
-
$missing_methods .= ', ';
|
4248 |
-
}
|
4249 |
-
|
4250 |
-
$missing_methods .= sprintf( '<code>%s</code>', $m );
|
4251 |
-
}
|
4252 |
-
|
4253 |
-
if ( ! empty( $missing_methods ) ) {
|
4254 |
-
$missing_methods = sprintf(
|
4255 |
-
'<br><br><b>%s</b> %s',
|
4256 |
-
$this->esc_html_inline( 'Disabled method(s):', 'curl-disabled-methods' ),
|
4257 |
-
$missing_methods
|
4258 |
-
);
|
4259 |
-
}
|
4260 |
-
}
|
4261 |
-
|
4262 |
-
$message = sprintf(
|
4263 |
-
$x_requires_access_to_api . ' ' .
|
4264 |
-
$this->esc_html_inline( 'We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server.', 'curl-missing-message' ) . ' ' .
|
4265 |
-
$missing_methods .
|
4266 |
-
' %s',
|
4267 |
-
'<b>' . $this->get_plugin_name() . '</b>',
|
4268 |
-
sprintf(
|
4269 |
-
'<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
|
4270 |
-
sprintf(
|
4271 |
-
'<a class="fs-resolve" data-type="curl" href="#"><b>%s</b></a>%s',
|
4272 |
-
$this->get_text_inline( 'I don\'t know what is cURL or how to install it, help me!', 'curl-missing-no-clue-title' ),
|
4273 |
-
' - ' . sprintf(
|
4274 |
-
$this->get_text_inline( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'curl-missing-no-clue-desc' ),
|
4275 |
-
'<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
|
4276 |
-
)
|
4277 |
-
),
|
4278 |
-
sprintf(
|
4279 |
-
'<b>%s</b> - %s',
|
4280 |
-
$sysadmin_title,
|
4281 |
-
esc_html( sprintf( $this->get_text_inline( 'Great, please install cURL and enable it in your php.ini file. In addition, search for the \'disable_functions\' directive in your php.ini file and remove any disabled methods starting with \'curl_\'. To make sure it was successfully activated, use \'phpinfo()\'. Once activated, deactivate the %s and reactivate it back again.', 'curl-missing-sysadmin-desc' ), $this->get_module_label( true ) ) )
|
4282 |
-
),
|
4283 |
-
sprintf(
|
4284 |
-
'<a href="%s"><b>%s</b></a> - %s',
|
4285 |
-
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $this->_plugin_basename . '&plugin_status=all&paged=1&s=', 'deactivate-plugin_' . $this->_plugin_basename ),
|
4286 |
-
$deactivate_plugin_title,
|
4287 |
-
$deactivate_plugin_desc
|
4288 |
-
)
|
4289 |
-
)
|
4290 |
-
);
|
4291 |
-
break;
|
4292 |
-
case 'cloudflare_ddos_protection':
|
4293 |
-
$message = sprintf(
|
4294 |
-
$x_requires_access_to_api . ' ' .
|
4295 |
-
$this->esc_html_inline( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.', 'cloudflare-blocks-connection-message' ) . ' ' .
|
4296 |
-
$happy_to_resolve_issue_asap .
|
4297 |
-
' %s',
|
4298 |
-
'<b>' . $this->get_plugin_name() . '</b>',
|
4299 |
-
sprintf(
|
4300 |
-
'<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
|
4301 |
-
sprintf(
|
4302 |
-
'<a class="fs-resolve" data-type="cloudflare" href="#"><b>%s</b></a>%s',
|
4303 |
-
$fix_issue_title,
|
4304 |
-
' - ' . sprintf(
|
4305 |
-
$fix_issue_desc,
|
4306 |
-
'<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
|
4307 |
-
)
|
4308 |
-
),
|
4309 |
-
sprintf(
|
4310 |
-
'<a href="%s" target="_blank" rel="noopener noreferrer"><b>%s</b></a> - %s',
|
4311 |
-
sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
|
4312 |
-
$install_previous_title,
|
4313 |
-
$install_previous_desc
|
4314 |
-
),
|
4315 |
-
sprintf(
|
4316 |
-
'<a href="%s"><b>%s</b></a> - %s',
|
4317 |
-
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $this->_plugin_basename . '&plugin_status=all&paged=1&s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
|
4318 |
-
$deactivate_plugin_title,
|
4319 |
-
$deactivate_plugin_desc
|
4320 |
-
)
|
4321 |
-
)
|
4322 |
-
);
|
4323 |
-
break;
|
4324 |
-
case 'squid_cache_block':
|
4325 |
-
$message = sprintf(
|
4326 |
-
$x_requires_access_to_api . ' ' .
|
4327 |
-
$this->esc_html_inline( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.', 'squid-blocks-connection-message' ) .
|
4328 |
-
' %s',
|
4329 |
-
'<b>' . $this->get_plugin_name() . '</b>',
|
4330 |
-
sprintf(
|
4331 |
-
'<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
|
4332 |
-
sprintf(
|
4333 |
-
'<a class="fs-resolve" data-type="squid" href="#"><b>%s</b></a> - %s',
|
4334 |
-
$this->esc_html_inline( 'I don\'t know what is Squid or ACL, help me!', 'squid-no-clue-title' ),
|
4335 |
-
sprintf(
|
4336 |
-
$this->esc_html_inline( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'squid-no-clue-desc' ),
|
4337 |
-
'<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
|
4338 |
-
)
|
4339 |
-
),
|
4340 |
-
sprintf(
|
4341 |
-
'<b>%s</b> - %s',
|
4342 |
-
$sysadmin_title,
|
4343 |
-
sprintf(
|
4344 |
-
$this->esc_html_inline( 'Great, please whitelist the following domains: %s. Once you are done, deactivate the %s and activate it again.', 'squid-sysadmin-desc' ),
|
4345 |
-
// We use a filter since the plugin might require additional API connectivity.
|
4346 |
-
'<b>' . implode( ', ', $this->apply_filters( 'api_domains', array(
|
4347 |
-
'api.freemius.com',
|
4348 |
-
'wp.freemius.com'
|
4349 |
-
) ) ) . '</b>',
|
4350 |
-
$this->_module_type
|
4351 |
-
)
|
4352 |
-
),
|
4353 |
-
sprintf(
|
4354 |
-
'<a href="%s"><b>%s</b></a> - %s',
|
4355 |
-
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $this->_plugin_basename . '&plugin_status=all&paged=1&s=', 'deactivate-plugin_' . $this->_plugin_basename ),
|
4356 |
-
$deactivate_plugin_title,
|
4357 |
-
$deactivate_plugin_desc
|
4358 |
-
)
|
4359 |
-
)
|
4360 |
-
);
|
4361 |
-
break;
|
4362 |
-
// default:
|
4363 |
-
// $message = $this->get_text_inline( 'connectivity-test-fails-message' );
|
4364 |
-
// break;
|
4365 |
-
}
|
4366 |
-
}
|
4367 |
-
|
4368 |
-
$message_id = 'failed_connect_api';
|
4369 |
-
$type = 'error';
|
4370 |
-
|
4371 |
-
$connectivity_test_fails_message = $this->esc_html_inline( 'From unknown reason, the API connectivity test failed.', 'connectivity-test-fails-message' );
|
4372 |
-
|
4373 |
-
if ( false === $message ) {
|
4374 |
-
if ( $is_first_failure ) {
|
4375 |
-
// First attempt failed.
|
4376 |
-
$message = sprintf(
|
4377 |
-
$x_requires_access_to_api . ' ' .
|
4378 |
-
$connectivity_test_fails_message . ' ' .
|
4379 |
-
$this->esc_html_inline( 'It\'s probably a temporary issue on our end. Just to be sure, with your permission, would it be o.k to run another connectivity test?', 'connectivity-test-maybe-temporary' ) . '<br><br>' .
|
4380 |
-
'%s',
|
4381 |
-
'<b>' . $this->get_plugin_name() . '</b>',
|
4382 |
-
sprintf(
|
4383 |
-
'<div id="fs_firewall_issue_options">%s %s</div>',
|
4384 |
-
sprintf(
|
4385 |
-
'<a class="button button-primary fs-resolve" data-type="retry_ping" href="#">%s</a>',
|
4386 |
-
$this->get_text_inline( 'Yes - do your thing', 'yes-do-your-thing' )
|
4387 |
-
),
|
4388 |
-
sprintf(
|
4389 |
-
'<a href="%s" class="button">%s</a>',
|
4390 |
-
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $this->_plugin_basename . '&plugin_status=all&paged=1&s=', 'deactivate-plugin_' . $this->_plugin_basename ),
|
4391 |
-
$this->get_text_inline( 'No - just deactivate', 'no-deactivate' )
|
4392 |
-
)
|
4393 |
-
)
|
4394 |
-
);
|
4395 |
-
|
4396 |
-
$message_id = 'failed_connect_api_first';
|
4397 |
-
$type = 'promotion';
|
4398 |
-
} else {
|
4399 |
-
// Second connectivity attempt failed.
|
4400 |
-
$message = sprintf(
|
4401 |
-
$x_requires_access_to_api . ' ' .
|
4402 |
-
$connectivity_test_fails_message . ' ' .
|
4403 |
-
$happy_to_resolve_issue_asap .
|
4404 |
-
' %s',
|
4405 |
-
'<b>' . $this->get_plugin_name() . '</b>',
|
4406 |
-
sprintf(
|
4407 |
-
'<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
|
4408 |
-
sprintf(
|
4409 |
-
'<a class="fs-resolve" data-type="general" href="#"><b>%s</b></a>%s',
|
4410 |
-
$fix_issue_title,
|
4411 |
-
' - ' . sprintf(
|
4412 |
-
$fix_issue_desc,
|
4413 |
-
'<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
|
4414 |
-
)
|
4415 |
-
),
|
4416 |
-
sprintf(
|
4417 |
-
'<a href="%s" target="_blank" rel="noopener noreferrer"><b>%s</b></a> - %s',
|
4418 |
-
sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
|
4419 |
-
$install_previous_title,
|
4420 |
-
$install_previous_desc
|
4421 |
-
),
|
4422 |
-
sprintf(
|
4423 |
-
'<a href="%s"><b>%s</b></a> - %s',
|
4424 |
-
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $this->_plugin_basename . '&plugin_status=all&paged=1&s=', 'deactivate-plugin_' . $this->_plugin_basename ),
|
4425 |
-
$deactivate_plugin_title,
|
4426 |
-
$deactivate_plugin_desc
|
4427 |
-
)
|
4428 |
-
)
|
4429 |
-
);
|
4430 |
-
}
|
4431 |
-
}
|
4432 |
-
|
4433 |
-
$this->_admin_notices->add_sticky(
|
4434 |
-
$message,
|
4435 |
-
$message_id,
|
4436 |
-
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
|
4437 |
-
$type
|
4438 |
-
);
|
4439 |
-
}
|
4440 |
-
|
4441 |
-
/**
|
4442 |
-
* Handle user request to resolve connectivity issue.
|
4443 |
-
* This method will send an email to Freemius API technical staff for resolution.
|
4444 |
-
* The email will contain server's info and installed plugins (might be caching issue).
|
4445 |
-
*
|
4446 |
-
* @author Vova Feldman (@svovaf)
|
4447 |
-
* @since 1.0.9
|
4448 |
-
*/
|
4449 |
-
function _email_about_firewall_issue() {
|
4450 |
-
$this->_admin_notices->remove_sticky( 'failed_connect_api' );
|
4451 |
-
|
4452 |
-
$pong = $this->ping();
|
4453 |
-
|
4454 |
-
$is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
|
4455 |
-
|
4456 |
-
if ( $is_connected ) {
|
4457 |
-
FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
|
4458 |
-
|
4459 |
-
$this->store_connectivity_info( $pong, $is_connected );
|
4460 |
-
|
4461 |
-
echo $this->get_after_plugin_activation_redirect_url();
|
4462 |
-
exit;
|
4463 |
-
}
|
4464 |
-
|
4465 |
-
$current_user = self::_get_current_wp_user();
|
4466 |
-
$admin_email = $current_user->user_email;
|
4467 |
-
|
4468 |
-
$error_type = fs_request_get( 'error_type', 'general' );
|
4469 |
-
|
4470 |
-
switch ( $error_type ) {
|
4471 |
-
case 'squid':
|
4472 |
-
$title = 'Squid ACL Blocking Issue';
|
4473 |
-
break;
|
4474 |
-
case 'cloudflare':
|
4475 |
-
$title = 'CloudFlare Blocking Issue';
|
4476 |
-
break;
|
4477 |
-
default:
|
4478 |
-
$title = 'API Connectivity Issue';
|
4479 |
-
break;
|
4480 |
-
}
|
4481 |
-
|
4482 |
-
$custom_email_sections = array();
|
4483 |
-
|
4484 |
-
// Add 'API Error' custom email section.
|
4485 |
-
$custom_email_sections['api_error'] = array(
|
4486 |
-
'title' => 'API Error',
|
4487 |
-
'rows' => array(
|
4488 |
-
'ping' => array(
|
4489 |
-
'API Error',
|
4490 |
-
is_string( $pong ) ? htmlentities( $pong ) : json_encode( $pong )
|
4491 |
-
),
|
4492 |
-
)
|
4493 |
-
);
|
4494 |
-
|
4495 |
-
// Send email with technical details to resolve API connectivity issues.
|
4496 |
-
$this->send_email(
|
4497 |
-
'api@freemius.com', // recipient
|
4498 |
-
$title . ' [' . $this->get_plugin_name() . ']', // subject
|
4499 |
-
$custom_email_sections,
|
4500 |
-
array( "Reply-To: $admin_email <$admin_email>" ) // headers
|
4501 |
-
);
|
4502 |
-
|
4503 |
-
$this->_admin_notices->add_sticky(
|
4504 |
-
sprintf(
|
4505 |
-
$this->get_text_inline( 'Thank for giving us the chance to fix it! A message was just sent to our technical staff. We will get back to you as soon as we have an update to %s. Appreciate your patience.', 'fix-request-sent-message' ),
|
4506 |
-
'<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
|
4507 |
-
),
|
4508 |
-
'server_details_sent'
|
4509 |
-
);
|
4510 |
-
|
4511 |
-
// Action was taken, tell that API connectivity troubleshooting should be off now.
|
4512 |
-
|
4513 |
-
echo "1";
|
4514 |
-
exit;
|
4515 |
-
}
|
4516 |
-
|
4517 |
-
/**
|
4518 |
-
* Handle connectivity test retry approved by the user.
|
4519 |
-
*
|
4520 |
-
* @author Vova Feldman (@svovaf)
|
4521 |
-
* @since 1.1.7.4
|
4522 |
-
*/
|
4523 |
-
function _retry_connectivity_test() {
|
4524 |
-
$this->_admin_notices->remove_sticky( 'failed_connect_api_first' );
|
4525 |
-
|
4526 |
-
$pong = $this->ping();
|
4527 |
-
|
4528 |
-
$is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
|
4529 |
-
|
4530 |
-
if ( $is_connected ) {
|
4531 |
-
FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
|
4532 |
-
|
4533 |
-
$this->store_connectivity_info( $pong, $is_connected );
|
4534 |
-
|
4535 |
-
echo $this->get_after_plugin_activation_redirect_url();
|
4536 |
-
} else {
|
4537 |
-
// Add connectivity issue message after 2nd failed attempt.
|
4538 |
-
$this->_add_connectivity_issue_message( $pong, false );
|
4539 |
-
|
4540 |
-
echo "1";
|
4541 |
-
}
|
4542 |
-
|
4543 |
-
exit;
|
4544 |
-
}
|
4545 |
-
|
4546 |
-
static function _add_firewall_issues_javascript() {
|
4547 |
-
$params = array();
|
4548 |
-
fs_require_once_template( 'firewall-issues-js.php', $params );
|
4549 |
-
}
|
4550 |
-
|
4551 |
-
#endregion
|
4552 |
-
|
4553 |
-
#----------------------------------------------------------------------------------
|
4554 |
-
#region Email
|
4555 |
-
#----------------------------------------------------------------------------------
|
4556 |
-
|
4557 |
-
/**
|
4558 |
-
* Generates and sends an HTML email with customizable sections.
|
4559 |
-
*
|
4560 |
-
* @author Leo Fajardo (@leorw)
|
4561 |
-
* @since 1.1.2
|
4562 |
-
*
|
4563 |
-
* @param string $to_address
|
4564 |
-
* @param string $subject
|
4565 |
-
* @param array $sections
|
4566 |
-
* @param array $headers
|
4567 |
-
*
|
4568 |
-
* @return bool Whether the email contents were sent successfully.
|
4569 |
-
*/
|
4570 |
-
private function send_email(
|
4571 |
-
$to_address,
|
4572 |
-
$subject,
|
4573 |
-
$sections = array(),
|
4574 |
-
$headers = array()
|
4575 |
-
) {
|
4576 |
-
$default_sections = $this->get_email_sections();
|
4577 |
-
|
4578 |
-
// Insert new sections or replace the default email sections.
|
4579 |
-
if ( is_array( $sections ) && ! empty( $sections ) ) {
|
4580 |
-
foreach ( $sections as $section_id => $custom_section ) {
|
4581 |
-
if ( ! isset( $default_sections[ $section_id ] ) ) {
|
4582 |
-
// If the section does not exist, add it.
|
4583 |
-
$default_sections[ $section_id ] = $custom_section;
|
4584 |
-
} else {
|
4585 |
-
// If the section already exists, override it.
|
4586 |
-
$current_section = $default_sections[ $section_id ];
|
4587 |
-
|
4588 |
-
// Replace the current section's title if a custom section title exists.
|
4589 |
-
if ( isset( $custom_section['title'] ) ) {
|
4590 |
-
$current_section['title'] = $custom_section['title'];
|
4591 |
-
}
|
4592 |
-
|
4593 |
-
// Insert new rows under the current section or replace the default rows.
|
4594 |
-
if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
|
4595 |
-
foreach ( $custom_section['rows'] as $row_id => $row ) {
|
4596 |
-
$current_section['rows'][ $row_id ] = $row;
|
4597 |
-
}
|
4598 |
-
}
|
4599 |
-
|
4600 |
-
$default_sections[ $section_id ] = $current_section;
|
4601 |
-
}
|
4602 |
-
}
|
4603 |
-
}
|
4604 |
-
|
4605 |
-
$vars = array( 'sections' => $default_sections );
|
4606 |
-
$message = fs_get_template( 'email.php', $vars );
|
4607 |
-
|
4608 |
-
// Set the type of email to HTML.
|
4609 |
-
$headers[] = 'Content-type: text/html; charset=UTF-8';
|
4610 |
-
|
4611 |
-
$header_string = implode( "\r\n", $headers );
|
4612 |
-
|
4613 |
-
return wp_mail(
|
4614 |
-
$to_address,
|
4615 |
-
$subject,
|
4616 |
-
$message,
|
4617 |
-
$header_string
|
4618 |
-
);
|
4619 |
-
}
|
4620 |
-
|
4621 |
-
/**
|
4622 |
-
* Generates the data for the sections of the email content.
|
4623 |
-
*
|
4624 |
-
* @author Leo Fajardo (@leorw)
|
4625 |
-
* @since 1.1.2
|
4626 |
-
*
|
4627 |
-
* @return array
|
4628 |
-
*/
|
4629 |
-
private function get_email_sections() {
|
4630 |
-
// Retrieve the current user's information so that we can get the user's email, first name, and last name below.
|
4631 |
-
$current_user = self::_get_current_wp_user();
|
4632 |
-
|
4633 |
-
// Retrieve the cURL version information so that we can get the version number below.
|
4634 |
-
$curl_version_information = curl_version();
|
4635 |
-
|
4636 |
-
$active_plugin = self::get_active_plugins();
|
4637 |
-
|
4638 |
-
// Generate the list of active plugins separated by new line.
|
4639 |
-
$active_plugin_string = '';
|
4640 |
-
foreach ( $active_plugin as $plugin ) {
|
4641 |
-
$active_plugin_string .= sprintf(
|
4642 |
-
'<a href="%s">%s</a> [v%s]<br>',
|
4643 |
-
$plugin['PluginURI'],
|
4644 |
-
$plugin['Name'],
|
4645 |
-
$plugin['Version']
|
4646 |
-
);
|
4647 |
-
}
|
4648 |
-
|
4649 |
-
$server_ip = WP_FS__REMOTE_ADDR;
|
4650 |
-
|
4651 |
-
// Add PHP info for deeper investigation.
|
4652 |
-
ob_start();
|
4653 |
-
phpinfo();
|
4654 |
-
$php_info = ob_get_clean();
|
4655 |
-
|
4656 |
-
$api_domain = substr( FS_API__ADDRESS, strpos( FS_API__ADDRESS, ':' ) + 3 );
|
4657 |
-
|
4658 |
-
// Generate the default email sections.
|
4659 |
-
$sections = array(
|
4660 |
-
'sdk' => array(
|
4661 |
-
'title' => 'SDK',
|
4662 |
-
'rows' => array(
|
4663 |
-
'fs_version' => array( 'FS Version', $this->version ),
|
4664 |
-
'curl_version' => array( 'cURL Version', $curl_version_information['version'] )
|
4665 |
-
)
|
4666 |
-
),
|
4667 |
-
'plugin' => array(
|
4668 |
-
'title' => ucfirst( $this->get_module_type() ),
|
4669 |
-
'rows' => array(
|
4670 |
-
'name' => array( 'Name', $this->get_plugin_name() ),
|
4671 |
-
'version' => array( 'Version', $this->get_plugin_version() )
|
4672 |
-
)
|
4673 |
-
),
|
4674 |
-
'api' => array(
|
4675 |
-
'title' => 'API Subdomain',
|
4676 |
-
'rows' => array(
|
4677 |
-
'dns' => array(
|
4678 |
-
'DNS_CNAME',
|
4679 |
-
function_exists( 'dns_get_record' ) ?
|
4680 |
-
var_export( dns_get_record( $api_domain, DNS_CNAME ), true ) :
|
4681 |
-
'dns_get_record() disabled/blocked'
|
4682 |
-
),
|
4683 |
-
'ip' => array(
|
4684 |
-
'IP',
|
4685 |
-
function_exists( 'gethostbyname' ) ?
|
4686 |
-
gethostbyname( $api_domain ) :
|
4687 |
-
'gethostbyname() disabled/blocked'
|
4688 |
-
),
|
4689 |
-
),
|
4690 |
-
),
|
4691 |
-
'site' => array(
|
4692 |
-
'title' => 'Site',
|
4693 |
-
'rows' => array(
|
4694 |
-
'unique_id' => array( 'Unique ID', $this->get_anonymous_id() ),
|
4695 |
-
'address' => array( 'Address', site_url() ),
|
4696 |
-
'host' => array(
|
4697 |
-
'HTTP_HOST',
|
4698 |
-
( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' )
|
4699 |
-
),
|
4700 |
-
'hosting' => array(
|
4701 |
-
'Hosting Company' => fs_request_has( 'hosting_company' ) ?
|
4702 |
-
fs_request_get( 'hosting_company' ) :
|
4703 |
-
'Unknown',
|
4704 |
-
),
|
4705 |
-
'server_addr' => array(
|
4706 |
-
'SERVER_ADDR',
|
4707 |
-
'<a href="http://www.projecthoneypot.org/ip_' . $server_ip . '">' . $server_ip . '</a>'
|
4708 |
-
)
|
4709 |
-
)
|
4710 |
-
),
|
4711 |
-
'user' => array(
|
4712 |
-
'title' => 'User',
|
4713 |
-
'rows' => array(
|
4714 |
-
'email' => array( 'Email', $current_user->user_email ),
|
4715 |
-
'first' => array( 'First', $current_user->user_firstname ),
|
4716 |
-
'last' => array( 'Last', $current_user->user_lastname )
|
4717 |
-
)
|
4718 |
-
),
|
4719 |
-
'plugins' => array(
|
4720 |
-
'title' => 'Plugins',
|
4721 |
-
'rows' => array(
|
4722 |
-
'active_plugins' => array( 'Active Plugins', $active_plugin_string )
|
4723 |
-
)
|
4724 |
-
),
|
4725 |
-
'php_info' => array(
|
4726 |
-
'title' => 'PHP Info',
|
4727 |
-
'rows' => array(
|
4728 |
-
'info' => array( $php_info )
|
4729 |
-
),
|
4730 |
-
)
|
4731 |
-
);
|
4732 |
-
|
4733 |
-
// Allow the sections to be modified by other code.
|
4734 |
-
$sections = $this->apply_filters( 'email_template_sections', $sections );
|
4735 |
-
|
4736 |
-
return $sections;
|
4737 |
-
}
|
4738 |
-
|
4739 |
-
#endregion
|
4740 |
-
|
4741 |
-
#----------------------------------------------------------------------------------
|
4742 |
-
#region Initialization
|
4743 |
-
#----------------------------------------------------------------------------------
|
4744 |
-
|
4745 |
-
/**
|
4746 |
-
* Init plugin's Freemius instance.
|
4747 |
-
*
|
4748 |
-
* @author Vova Feldman (@svovaf)
|
4749 |
-
* @since 1.0.1
|
4750 |
-
*
|
4751 |
-
* @param number $id
|
4752 |
-
* @param string $public_key
|
4753 |
-
* @param bool $is_live
|
4754 |
-
* @param bool $is_premium
|
4755 |
-
*/
|
4756 |
-
function init( $id, $public_key, $is_live = true, $is_premium = true ) {
|
4757 |
-
$this->_logger->entrance();
|
4758 |
-
|
4759 |
-
$this->dynamic_init( array(
|
4760 |
-
'id' => $id,
|
4761 |
-
'public_key' => $public_key,
|
4762 |
-
'is_live' => $is_live,
|
4763 |
-
'is_premium' => $is_premium,
|
4764 |
-
) );
|
4765 |
-
}
|
4766 |
-
|
4767 |
-
/**
|
4768 |
-
* Dynamic initiator, originally created to support initiation
|
4769 |
-
* with parent_id for add-ons.
|
4770 |
-
*
|
4771 |
-
* @author Vova Feldman (@svovaf)
|
4772 |
-
* @since 1.0.6
|
4773 |
-
*
|
4774 |
-
* @param array $plugin_info
|
4775 |
-
*
|
4776 |
-
* @throws Freemius_Exception
|
4777 |
-
*/
|
4778 |
-
function dynamic_init( array $plugin_info ) {
|
4779 |
-
$this->_logger->entrance();
|
4780 |
-
|
4781 |
-
$this->parse_settings( $plugin_info );
|
4782 |
-
|
4783 |
-
$this->register_after_settings_parse_hooks();
|
4784 |
-
|
4785 |
-
if ( $this->should_stop_execution() ) {
|
4786 |
-
return;
|
4787 |
-
}
|
4788 |
-
|
4789 |
-
if ( ! $this->is_registered() ) {
|
4790 |
-
if ( $this->is_anonymous() ) {
|
4791 |
-
// If user skipped, no need to test connectivity.
|
4792 |
-
$this->_has_api_connection = true;
|
4793 |
-
$this->_is_on = true;
|
4794 |
-
} else {
|
4795 |
-
if ( ! $this->has_api_connectivity() ) {
|
4796 |
-
if ( $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) ||
|
4797 |
-
$this->_admin_notices->has_sticky( 'failed_connect_api' )
|
4798 |
-
) {
|
4799 |
-
if ( ! $this->_enable_anonymous || $this->is_premium() ) {
|
4800 |
-
// If anonymous mode is disabled, add firewall admin-notice message.
|
4801 |
-
add_action( 'admin_footer', array( 'Freemius', '_add_firewall_issues_javascript' ) );
|
4802 |
-
|
4803 |
-
$ajax_action_suffix = $this->_slug . ( $this->is_theme() ? ':theme' : '' );
|
4804 |
-
add_action( "wp_ajax_fs_resolve_firewall_issues_{$ajax_action_suffix}", array(
|
4805 |
-
&$this,
|
4806 |
-
'_email_about_firewall_issue'
|
4807 |
-
) );
|
4808 |
-
|
4809 |
-
add_action( "wp_ajax_fs_retry_connectivity_test_{$ajax_action_suffix}", array(
|
4810 |
-
&$this,
|
4811 |
-
'_retry_connectivity_test'
|
4812 |
-
) );
|
4813 |
-
|
4814 |
-
/**
|
4815 |
-
* Currently the admin notice manager relies on the module's type and slug. The new AJAX actions manager uses module IDs, hence, consider to replace the if block above with the commented code below after adjusting the admin notices manager to work with module IDs.
|
4816 |
-
*
|
4817 |
-
* @author Vova Feldman (@svovaf)
|
4818 |
-
* @since 2.0.0
|
4819 |
-
*/
|
4820 |
-
/*$this->add_ajax_action( 'resolve_firewall_issues', array(
|
4821 |
-
&$this,
|
4822 |
-
'_email_about_firewall_issue'
|
4823 |
-
) );
|
4824 |
-
|
4825 |
-
$this->add_ajax_action( 'retry_connectivity_test', array(
|
4826 |
-
&$this,
|
4827 |
-
'_retry_connectivity_test'
|
4828 |
-
) );*/
|
4829 |
-
}
|
4830 |
-
}
|
4831 |
-
|
4832 |
-
return;
|
4833 |
-
} else {
|
4834 |
-
$this->_admin_notices->remove_sticky( array(
|
4835 |
-
'failed_connect_api_first',
|
4836 |
-
'failed_connect_api',
|
4837 |
-
) );
|
4838 |
-
|
4839 |
-
if ( $this->_anonymous_mode ) {
|
4840 |
-
// Simulate anonymous mode.
|
4841 |
-
$this->_is_anonymous = true;
|
4842 |
-
}
|
4843 |
-
}
|
4844 |
-
}
|
4845 |
-
}
|
4846 |
-
|
4847 |
-
/**
|
4848 |
-
* This should be executed even if Freemius is off for the core module,
|
4849 |
-
* otherwise, the add-ons dialogbox won't work properly. This is esepcially
|
4850 |
-
* relevant when the developer decided to turn FS off for existing users.
|
4851 |
-
*
|
4852 |
-
* @author Vova Feldman (@svovaf)
|
4853 |
-
*/
|
4854 |
-
if ( $this->is_user_in_admin() &&
|
4855 |
-
'plugin-information' === fs_request_get( 'tab', false ) &&
|
4856 |
-
$this->should_use_freemius_updater_and_dialog() &&
|
4857 |
-
(
|
4858 |
-
( $this->is_addon() && $this->get_slug() == fs_request_get( 'plugin', false ) ) ||
|
4859 |
-
( $this->has_addons() && $this->get_id() == fs_request_get( 'parent_plugin_id', false ) )
|
4860 |
-
)
|
4861 |
-
) {
|
4862 |
-
require_once WP_FS__DIR_INCLUDES . '/fs-plugin-info-dialog.php';
|
4863 |
-
|
4864 |
-
new FS_Plugin_Info_Dialog( $this->is_addon() ? $this->get_parent_instance() : $this );
|
4865 |
-
}
|
4866 |
-
|
4867 |
-
// Check if Freemius is on for the current plugin.
|
4868 |
-
// This MUST be executed after all the plugin variables has been loaded.
|
4869 |
-
if ( ! $this->is_registered() && ! $this->is_on() ) {
|
4870 |
-
return;
|
4871 |
-
}
|
4872 |
-
|
4873 |
-
if ( $this->has_api_connectivity() ) {
|
4874 |
-
if ( self::is_cron() ) {
|
4875 |
-
$this->hook_callback_to_sync_cron();
|
4876 |
-
} else if ( $this->is_user_in_admin() ) {
|
4877 |
-
/**
|
4878 |
-
* Schedule daily data sync cron if:
|
4879 |
-
*
|
4880 |
-
* 1. User opted-in (for tracking).
|
4881 |
-
* 2. If skipped, but later upgraded (opted-in via upgrade).
|
4882 |
-
*
|
4883 |
-
* @author Vova Feldman (@svovaf)
|
4884 |
-
* @since 1.1.7.3
|
4885 |
-
*
|
4886 |
-
*/
|
4887 |
-
if ( $this->is_registered() ) {
|
4888 |
-
if ( ! $this->is_sync_cron_on() && $this->is_tracking_allowed() ) {
|
4889 |
-
$this->schedule_sync_cron();
|
4890 |
-
}
|
4891 |
-
}
|
4892 |
-
|
4893 |
-
/**
|
4894 |
-
* Check if requested for manual blocking background sync.
|
4895 |
-
*/
|
4896 |
-
if ( fs_request_has( 'background_sync' ) ) {
|
4897 |
-
$this->run_manual_sync();
|
4898 |
-
}
|
4899 |
-
}
|
4900 |
-
}
|
4901 |
-
|
4902 |
-
if ( $this->is_registered() ) {
|
4903 |
-
$this->hook_callback_to_install_sync();
|
4904 |
-
}
|
4905 |
-
|
4906 |
-
if ( $this->is_addon() ) {
|
4907 |
-
if ( $this->is_parent_plugin_installed() ) {
|
4908 |
-
// Link to parent FS.
|
4909 |
-
$this->_parent = self::get_instance_by_id( $this->_plugin->parent_plugin_id );
|
4910 |
-
|
4911 |
-
// Get parent plugin reference.
|
4912 |
-
$this->_parent_plugin = $this->_parent->get_plugin();
|
4913 |
-
}
|
4914 |
-
}
|
4915 |
-
|
4916 |
-
if ( $this->is_user_in_admin() ) {
|
4917 |
-
if ( $this->is_addon() ) {
|
4918 |
-
if ( ! $this->is_parent_plugin_installed() ) {
|
4919 |
-
$parent_name = $this->get_option( $plugin_info, 'parent_name', null );
|
4920 |
-
|
4921 |
-
if ( isset( $plugin_info['parent'] ) ) {
|
4922 |
-
$parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
|
4923 |
-
}
|
4924 |
-
|
4925 |
-
$this->_admin_notices->add(
|
4926 |
-
( ! empty( $parent_name ) ?
|
4927 |
-
sprintf( $this->get_text_x_inline( '%s cannot run without %s.', 'addonX cannot run without pluginY', 'addon-x-cannot-run-without-y' ), $this->get_plugin_name(), $parent_name ) :
|
4928 |
-
sprintf( $this->get_text_x_inline( '%s cannot run without the plugin.', 'addonX cannot run...', 'addon-x-cannot-run-without-parent' ), $this->get_plugin_name() )
|
4929 |
-
),
|
4930 |
-
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
|
4931 |
-
'error'
|
4932 |
-
);
|
4933 |
-
|
4934 |
-
return;
|
4935 |
-
} else {
|
4936 |
-
$is_network_admin = fs_is_network_admin();
|
4937 |
-
|
4938 |
-
if ( ! $this->_parent->is_registered() && $this->is_registered() ) {
|
4939 |
-
// If add-on activated and parent not, automatically install parent for the user.
|
4940 |
-
$this->activate_parent_account( $this->_parent );
|
4941 |
-
} else if (
|
4942 |
-
$this->_parent->is_registered() &&
|
4943 |
-
! $this->is_registered() &&
|
4944 |
-
/**
|
4945 |
-
* If not registered for add-on and the following conditions for the add-on are met, activate add-on account.
|
4946 |
-
* * Network active and in network admin - network activate add-on account.
|
4947 |
-
* * Network active and not in network admin - activate add-on account for the current blog.
|
4948 |
-
* * Not network active and not in network admin - activate add-on account for the current blog.
|
4949 |
-
*
|
4950 |
-
* If not registered for add-on, not network active, and in network admin, do not handle the add-on activation.
|
4951 |
-
*
|
4952 |
-
* @author Leo Fajardo (@leorw)
|
4953 |
-
* @since 2.3.0
|
4954 |
-
*/
|
4955 |
-
( $this->is_network_active() || ! $is_network_admin )
|
4956 |
-
) {
|
4957 |
-
$premium_license = null;
|
4958 |
-
|
4959 |
-
if (
|
4960 |
-
! $this->has_free_plan() &&
|
4961 |
-
$this->is_bundle_license_auto_activation_enabled() &&
|
4962 |
-
$this->_parent->is_activated_with_bundle_license()
|
4963 |
-
) {
|
4964 |
-
/**
|
4965 |
-
* If the add-on has no free plan, try to activate the account only when there's a bundle license.
|
4966 |
-
*
|
4967 |
-
* @author Leo Fajardo (@leorw)
|
4968 |
-
* @since 2.4.0
|
4969 |
-
*/
|
4970 |
-
$bundle_license = $this->get_active_parent_license( $this->_parent->_get_license()->secret_key, false );
|
4971 |
-
|
4972 |
-
if (
|
4973 |
-
is_object( $bundle_license ) &&
|
4974 |
-
! empty( $bundle_license->products ) &&
|
4975 |
-
in_array( $this->get_id(), $bundle_license->products )
|
4976 |
-
) {
|
4977 |
-
$premium_license = $bundle_license;
|
4978 |
-
}
|
4979 |
-
}
|
4980 |
-
|
4981 |
-
if ( $this->has_free_plan() || is_object( $premium_license) ) {
|
4982 |
-
// If parent plugin activated, automatically install add-on for the user.
|
4983 |
-
$this->_activate_addon_account(
|
4984 |
-
$this->_parent,
|
4985 |
-
( $this->is_network_active() && $is_network_admin ) ?
|
4986 |
-
true :
|
4987 |
-
get_current_blog_id(),
|
4988 |
-
$premium_license
|
4989 |
-
);
|
4990 |
-
}
|
4991 |
-
}
|
4992 |
-
|
4993 |
-
// @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic.
|
4994 |
-
if ( $this->is_premium() ) {
|
4995 |
-
// Remove add-on download admin-notice.
|
4996 |
-
$this->_parent->_admin_notices->remove_sticky( array(
|
4997 |
-
'addon_plan_upgraded_' . $this->_slug,
|
4998 |
-
'no_addon_license_' . $this->_slug,
|
4999 |
-
) );
|
5000 |
-
}
|
5001 |
-
|
5002 |
-
// $this->deactivate_premium_only_addon_without_license();
|
5003 |
-
}
|
5004 |
-
}
|
5005 |
-
|
5006 |
-
add_action( 'admin_init', array( &$this, '_admin_init_action' ) );
|
5007 |
-
|
5008 |
-
// if ( $this->is_registered() ||
|
5009 |
-
// $this->is_anonymous() ||
|
5010 |
-
// $this->is_pending_activation()
|
5011 |
-
// ) {
|
5012 |
-
// $this->_init_admin();
|
5013 |
-
// }
|
5014 |
-
}
|
5015 |
-
|
5016 |
-
/**
|
5017 |
-
* Should be called outside `$this->is_user_in_admin()` scope
|
5018 |
-
* because the updater has some logic that needs to be executed
|
5019 |
-
* during AJAX calls.
|
5020 |
-
*
|
5021 |
-
* Currently we need to hook to the `http_request_host_is_external` filter.
|
5022 |
-
* In the future, there might be additional logic added.
|
5023 |
-
*
|
5024 |
-
* @author Vova Feldman
|
5025 |
-
* @since 1.2.1.6
|
5026 |
-
*/
|
5027 |
-
if (
|
5028 |
-
$this->should_use_freemius_updater_and_dialog() &&
|
5029 |
-
(
|
5030 |
-
$this->is_premium() ||
|
5031 |
-
/**
|
5032 |
-
* If not premium but the premium version is installed, also instantiate the updater so that the
|
5033 |
-
* plugin information dialog of the premium version will have the information from the server.
|
5034 |
-
*
|
5035 |
-
* @author Leo Fajardo (@leorw)
|
5036 |
-
* @since 2.2.3
|
5037 |
-
*/
|
5038 |
-
( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->premium_plugin_basename() ) ) )
|
5039 |
-
) &&
|
5040 |
-
$this->has_release_on_freemius()
|
5041 |
-
) {
|
5042 |
-
FS_Plugin_Updater::instance( $this );
|
5043 |
-
}
|
5044 |
-
|
5045 |
-
$this->do_action( 'initiated' );
|
5046 |
-
|
5047 |
-
if ( $this->_storage->prev_is_premium !== $this->_plugin->is_premium ) {
|
5048 |
-
if ( isset( $this->_storage->prev_is_premium ) ) {
|
5049 |
-
$this->apply_filters(
|
5050 |
-
'after_code_type_change',
|
5051 |
-
// New code type.
|
5052 |
-
$this->_plugin->is_premium
|
5053 |
-
);
|
5054 |
-
} else {
|
5055 |
-
// Set for code type for the first time.
|
5056 |
-
$this->_storage->prev_is_premium = $this->_plugin->is_premium;
|
5057 |
-
}
|
5058 |
-
}
|
5059 |
-
|
5060 |
-
if ( ! $this->is_addon() ) {
|
5061 |
-
if ( $this->is_registered() ) {
|
5062 |
-
// Fix for upgrade from versions < 1.0.9.
|
5063 |
-
if ( ! isset( $this->_storage->activation_timestamp ) ) {
|
5064 |
-
$this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
|
5065 |
-
}
|
5066 |
-
|
5067 |
-
$this->do_action( 'after_init_plugin_registered' );
|
5068 |
-
} else if ( $this->is_anonymous() ) {
|
5069 |
-
$this->do_action( 'after_init_plugin_anonymous' );
|
5070 |
-
} else if ( $this->is_pending_activation() ) {
|
5071 |
-
$this->do_action( 'after_init_plugin_pending_activations' );
|
5072 |
-
}
|
5073 |
-
} else {
|
5074 |
-
if ( $this->is_registered() ) {
|
5075 |
-
$this->do_action( 'after_init_addon_registered' );
|
5076 |
-
} else if ( $this->is_anonymous() ) {
|
5077 |
-
$this->do_action( 'after_init_addon_anonymous' );
|
5078 |
-
} else if ( $this->is_pending_activation() ) {
|
5079 |
-
$this->do_action( 'after_init_addon_pending_activations' );
|
5080 |
-
}
|
5081 |
-
}
|
5082 |
-
}
|
5083 |
-
|
5084 |
-
/**
|
5085 |
-
* @author Leo Fajardo (@leorw)
|
5086 |
-
* @since 2.2.3
|
5087 |
-
*
|
5088 |
-
* @return bool
|
5089 |
-
*/
|
5090 |
-
private function should_use_freemius_updater_and_dialog() {
|
5091 |
-
return (
|
5092 |
-
/**
|
5093 |
-
* Allow updater and dialog when the `fs_allow_updater_and_dialog` URL query param exists and has `true`
|
5094 |
-
* value, or when the current page is not the "Add Plugins" page (/plugin-install.php) and the `action`
|
5095 |
-
* URL query param doesn't exist or its value is not `install-plugin` so that there will be no conflicts
|
5096 |
-
* with the .org plugins' functionalities (e.g. installation from the "Add Plugins" page and viewing
|
5097 |
-
* plugin details from .org).
|
5098 |
-
*/
|
5099 |
-
( true === fs_request_get_bool( 'fs_allow_updater_and_dialog' ) ) ||
|
5100 |
-
(
|
5101 |
-
! self::is_plugin_install_page() &&
|
5102 |
-
// Disallow updater and dialog when installing a plugin, otherwise .org "add-on" plugins will be affected.
|
5103 |
-
( 'install-plugin' !== fs_request_get( 'action' ) )
|
5104 |
-
)
|
5105 |
-
);
|
5106 |
-
}
|
5107 |
-
|
5108 |
-
/**
|
5109 |
-
* @author Leo Fajardo (@leorw)
|
5110 |
-
*
|
5111 |
-
* @since 1.2.1.5
|
5112 |
-
*/
|
5113 |
-
function _stop_tracking_callback() {
|
5114 |
-
$this->_logger->entrance();
|
5115 |
-
|
5116 |
-
$this->check_ajax_referer( 'stop_tracking' );
|
5117 |
-
|
5118 |
-
$result = $this->stop_tracking( fs_is_network_admin() );
|
5119 |
-
|
5120 |
-
if ( true === $result ) {
|
5121 |
-
self::shoot_ajax_success();
|
5122 |
-
}
|
5123 |
-
|
5124 |
-
$this->_logger->api_error( $result );
|
5125 |
-
|
5126 |
-
self::shoot_ajax_failure(
|
5127 |
-
sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type ) .
|
5128 |
-
( $this->is_api_error( $result ) && isset( $result->error ) ?
|
5129 |
-
$result->error->message :
|
5130 |
-
var_export( $result, true ) )
|
5131 |
-
);
|
5132 |
-
}
|
5133 |
-
|
5134 |
-
/**
|
5135 |
-
* @author Leo Fajardo (@leorw)
|
5136 |
-
* @since 1.2.1.5
|
5137 |
-
*/
|
5138 |
-
function _allow_tracking_callback() {
|
5139 |
-
$this->_logger->entrance();
|
5140 |
-
|
5141 |
-
$this->check_ajax_referer( 'allow_tracking' );
|
5142 |
-
|
5143 |
-
$result = $this->allow_tracking( fs_is_network_admin() );
|
5144 |
-
|
5145 |
-
if ( true === $result ) {
|
5146 |
-
self::shoot_ajax_success();
|
5147 |
-
}
|
5148 |
-
|
5149 |
-
$this->_logger->api_error( $result );
|
5150 |
-
|
5151 |
-
self::shoot_ajax_failure(
|
5152 |
-
sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type ) .
|
5153 |
-
( $this->is_api_error( $result ) && isset( $result->error ) ?
|
5154 |
-
$result->error->message :
|
5155 |
-
var_export( $result, true ) )
|
5156 |
-
);
|
5157 |
-
}
|
5158 |
-
|
5159 |
-
/**
|
5160 |
-
* Opt-out from usage tracking.
|
5161 |
-
*
|
5162 |
-
* Note: This will not delete the account information but will stop all tracking.
|
5163 |
-
*
|
5164 |
-
* Returns:
|
5165 |
-
* 1. FALSE - If the user never opted-in.
|
5166 |
-
* 2. TRUE - If successfully opted-out.
|
5167 |
-
* 3. object - API result on failure.
|
5168 |
-
*
|
5169 |
-
* @author Leo Fajardo (@leorw)
|
5170 |
-
* @since 1.2.1.5
|
5171 |
-
*
|
5172 |
-
* @return bool|object
|
5173 |
-
*/
|
5174 |
-
function stop_site_tracking() {
|
5175 |
-
$this->_logger->entrance();
|
5176 |
-
|
5177 |
-
if ( ! $this->is_registered() ) {
|
5178 |
-
// User never opted-in.
|
5179 |
-
return false;
|
5180 |
-
}
|
5181 |
-
|
5182 |
-
if ( $this->is_tracking_prohibited() ) {
|
5183 |
-
// Already disconnected.
|
5184 |
-
return true;
|
5185 |
-
}
|
5186 |
-
|
5187 |
-
// Send update to FS.
|
5188 |
-
$result = $this->get_api_site_scope()->call( '/?fields=is_disconnected', 'put', array(
|
5189 |
-
'is_disconnected' => true
|
5190 |
-
) );
|
5191 |
-
|
5192 |
-
if ( ! $this->is_api_result_entity( $result ) ||
|
5193 |
-
! isset( $result->is_disconnected ) ||
|
5194 |
-
! $result->is_disconnected
|
5195 |
-
) {
|
5196 |
-
$this->_logger->api_error( $result );
|
5197 |
-
|
5198 |
-
return $result;
|
5199 |
-
}
|
5200 |
-
|
5201 |
-
$this->_site->is_disconnected = $result->is_disconnected;
|
5202 |
-
$this->_store_site();
|
5203 |
-
|
5204 |
-
$this->clear_sync_cron();
|
5205 |
-
|
5206 |
-
// Successfully disconnected.
|
5207 |
-
return true;
|
5208 |
-
}
|
5209 |
-
|
5210 |
-
/**
|
5211 |
-
* Opt-out network from usage tracking.
|
5212 |
-
*
|
5213 |
-
* Note: This will not delete the account information but will stop all tracking.
|
5214 |
-
*
|
5215 |
-
* Returns:
|
5216 |
-
* 1. FALSE - If the user never opted-in.
|
5217 |
-
* 2. TRUE - If successfully opted-out.
|
5218 |
-
* 3. object - API result on failure.
|
5219 |
-
*
|
5220 |
-
* @author Leo Fajardo (@leorw)
|
5221 |
-
* @since 1.2.1.5
|
5222 |
-
*
|
5223 |
-
* @return bool|object
|
5224 |
-
*/
|
5225 |
-
function stop_network_tracking() {
|
5226 |
-
$this->_logger->entrance();
|
5227 |
-
|
5228 |
-
if ( ! $this->is_registered() ) {
|
5229 |
-
// User never opted-in.
|
5230 |
-
return false;
|
5231 |
-
}
|
5232 |
-
|
5233 |
-
$install_id_2_blog_id = array();
|
5234 |
-
$installs_map = $this->get_blog_install_map();
|
5235 |
-
|
5236 |
-
$opt_out_all = true;
|
5237 |
-
|
5238 |
-
$params = array();
|
5239 |
-
foreach ( $installs_map as $blog_id => $install ) {
|
5240 |
-
if ( $install->is_tracking_prohibited() ) {
|
5241 |
-
// Already opted-out.
|
5242 |
-
continue;
|
5243 |
-
}
|
5244 |
-
|
5245 |
-
if ( $this->is_site_delegated_connection( $blog_id ) ) {
|
5246 |
-
// Opt-out only from non-delegated installs.
|
5247 |
-
$opt_out_all = false;
|
5248 |
-
continue;
|
5249 |
-
}
|
5250 |
-
|
5251 |
-
$params[] = array( 'id' => $install->id );
|
5252 |
-
|
5253 |
-
$install_id_2_blog_id[ $install->id ] = $blog_id;
|
5254 |
-
}
|
5255 |
-
|
5256 |
-
if ( empty( $install_id_2_blog_id ) ) {
|
5257 |
-
return true;
|
5258 |
-
}
|
5259 |
-
|
5260 |
-
$params[] = array( 'is_disconnected' => true );
|
5261 |
-
|
5262 |
-
// Send update to FS.
|
5263 |
-
$result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params );
|
5264 |
-
|
5265 |
-
if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
|
5266 |
-
$this->_logger->api_error( $result );
|
5267 |
-
|
5268 |
-
return $result;
|
5269 |
-
}
|
5270 |
-
|
5271 |
-
foreach ( $result->installs as $r_install ) {
|
5272 |
-
$blog_id = $install_id_2_blog_id[ $r_install->id ];
|
5273 |
-
$install = $installs_map[ $blog_id ];
|
5274 |
-
$install->is_disconnected = $r_install->is_disconnected;
|
5275 |
-
$this->_store_site( true, $blog_id, $install );
|
5276 |
-
}
|
5277 |
-
|
5278 |
-
$this->clear_sync_cron( $opt_out_all );
|
5279 |
-
|
5280 |
-
// Successfully disconnected.
|
5281 |
-
return true;
|
5282 |
-
}
|
5283 |
-
|
5284 |
-
/**
|
5285 |
-
* Opt-out from usage tracking.
|
5286 |
-
*
|
5287 |
-
* Note: This will not delete the account information but will stop all tracking.
|
5288 |
-
*
|
5289 |
-
* Returns:
|
5290 |
-
* 1. FALSE - If the user never opted-in.
|
5291 |
-
* 2. TRUE - If successfully opted-out.
|
5292 |
-
* 3. object - API result on failure.
|
5293 |
-
*
|
5294 |
-
* @author Leo Fajardo (@leorw)
|
5295 |
-
* @since 1.2.1.5
|
5296 |
-
*
|
5297 |
-
* @param bool $is_network_action
|
5298 |
-
*
|
5299 |
-
* @return bool|object
|
5300 |
-
*/
|
5301 |
-
function stop_tracking( $is_network_action = false ) {
|
5302 |
-
$this->_logger->entrance();
|
5303 |
-
|
5304 |
-
return $is_network_action ?
|
5305 |
-
$this->stop_network_tracking() :
|
5306 |
-
$this->stop_site_tracking();
|
5307 |
-
}
|
5308 |
-
|
5309 |
-
/**
|
5310 |
-
* Opt-in back into usage tracking.
|
5311 |
-
*
|
5312 |
-
* Note: This will only work if the user opted-in previously.
|
5313 |
-
*
|
5314 |
-
* Returns:
|
5315 |
-
* 1. FALSE - If the user never opted-in.
|
5316 |
-
* 2. TRUE - If successfully opted-in back to usage tracking.
|
5317 |
-
* 3. object - API result on failure.
|
5318 |
-
*
|
5319 |
-
* @author Leo Fajardo (@leorw)
|
5320 |
-
* @since 1.2.1.5
|
5321 |
-
*
|
5322 |
-
* @return bool|object
|
5323 |
-
*/
|
5324 |
-
function allow_site_tracking() {
|
5325 |
-
$this->_logger->entrance();
|
5326 |
-
|
5327 |
-
if ( ! $this->is_registered() ) {
|
5328 |
-
// User never opted-in.
|
5329 |
-
return false;
|
5330 |
-
}
|
5331 |
-
|
5332 |
-
if ( $this->is_tracking_allowed() ) {
|
5333 |
-
// Tracking already allowed.
|
5334 |
-
return true;
|
5335 |
-
}
|
5336 |
-
|
5337 |
-
$result = $this->get_api_site_scope()->call( '/?is_disconnected', 'put', array(
|
5338 |
-
'is_disconnected' => false
|
5339 |
-
) );
|
5340 |
-
|
5341 |
-
if ( ! $this->is_api_result_entity( $result ) ||
|
5342 |
-
! isset( $result->is_disconnected ) ||
|
5343 |
-
$result->is_disconnected
|
5344 |
-
) {
|
5345 |
-
$this->_logger->api_error( $result );
|
5346 |
-
|
5347 |
-
return $result;
|
5348 |
-
}
|
5349 |
-
|
5350 |
-
$this->_site->is_disconnected = $result->is_disconnected;
|
5351 |
-
$this->_store_site();
|
5352 |
-
|
5353 |
-
$this->schedule_sync_cron();
|
5354 |
-
|
5355 |
-
// Successfully reconnected.
|
5356 |
-
return true;
|
5357 |
-
}
|
5358 |
-
|
5359 |
-
/**
|
5360 |
-
* Opt-in network back into usage tracking.
|
5361 |
-
*
|
5362 |
-
* Note: This will only work if the user opted-in previously.
|
5363 |
-
*
|
5364 |
-
* Returns:
|
5365 |
-
* 1. FALSE - If the user never opted-in.
|
5366 |
-
* 2. TRUE - If successfully opted-in back to usage tracking.
|
5367 |
-
* 3. object - API result on failure.
|
5368 |
-
*
|
5369 |
-
* @author Leo Fajardo (@leorw)
|
5370 |
-
* @since 1.2.1.5
|
5371 |
-
*
|
5372 |
-
* @return bool|object
|
5373 |
-
*/
|
5374 |
-
function allow_network_tracking() {
|
5375 |
-
$this->_logger->entrance();
|
5376 |
-
|
5377 |
-
if ( ! $this->is_registered() ) {
|
5378 |
-
// User never opted-in.
|
5379 |
-
return false;
|
5380 |
-
}
|
5381 |
-
|
5382 |
-
$install_id_2_blog_id = array();
|
5383 |
-
$installs_map = $this->get_blog_install_map();
|
5384 |
-
|
5385 |
-
$params = array();
|
5386 |
-
foreach ( $installs_map as $blog_id => $install ) {
|
5387 |
-
if ( $install->is_tracking_allowed() ) {
|
5388 |
-
continue;
|
5389 |
-
}
|
5390 |
-
|
5391 |
-
$params[] = array( 'id' => $install->id );
|
5392 |
-
|
5393 |
-
$install_id_2_blog_id[ $install->id ] = $blog_id;
|
5394 |
-
}
|
5395 |
-
|
5396 |
-
if ( empty( $install_id_2_blog_id ) ) {
|
5397 |
-
return true;
|
5398 |
-
}
|
5399 |
-
|
5400 |
-
$params[] = array( 'is_disconnected' => false );
|
5401 |
-
|
5402 |
-
// Send update to FS.
|
5403 |
-
$result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params );
|
5404 |
-
|
5405 |
-
|
5406 |
-
if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
|
5407 |
-
$this->_logger->api_error( $result );
|
5408 |
-
|
5409 |
-
return $result;
|
5410 |
-
}
|
5411 |
-
|
5412 |
-
foreach ( $result->installs as $r_install ) {
|
5413 |
-
$blog_id = $install_id_2_blog_id[ $r_install->id ];
|
5414 |
-
$install = $installs_map[ $blog_id ];
|
5415 |
-
$install->is_disconnected = $r_install->is_disconnected;
|
5416 |
-
$this->_store_site( true, $blog_id, $install );
|
5417 |
-
}
|
5418 |
-
|
5419 |
-
$this->schedule_sync_cron();
|
5420 |
-
|
5421 |
-
// Successfully reconnected.
|
5422 |
-
return true;
|
5423 |
-
}
|
5424 |
-
|
5425 |
-
/**
|
5426 |
-
* Opt-in back into usage tracking.
|
5427 |
-
*
|
5428 |
-
* Note: This will only work if the user opted-in previously.
|
5429 |
-
*
|
5430 |
-
* Returns:
|
5431 |
-
* 1. FALSE - If the user never opted-in.
|
5432 |
-
* 2. TRUE - If successfully opted-in back to usage tracking.
|
5433 |
-
* 3. object - API result on failure.
|
5434 |
-
*
|
5435 |
-
* @author Leo Fajardo (@leorw)
|
5436 |
-
* @since 1.2.1.5
|
5437 |
-
*
|
5438 |
-
* @param bool $is_network_action
|
5439 |
-
*
|
5440 |
-
* @return bool|object
|
5441 |
-
*/
|
5442 |
-
function allow_tracking( $is_network_action = false ) {
|
5443 |
-
$this->_logger->entrance();
|
5444 |
-
|
5445 |
-
return $is_network_action ?
|
5446 |
-
$this->allow_network_tracking() :
|
5447 |
-
$this->allow_site_tracking();
|
5448 |
-
}
|
5449 |
-
|
5450 |
-
/**
|
5451 |
-
* If user opted-in and later disabled usage-tracking,
|
5452 |
-
* re-allow tracking for licensing and updates.
|
5453 |
-
*
|
5454 |
-
* @author Leo Fajardo (@leorw)
|
5455 |
-
* @since 1.2.1.5
|
5456 |
-
*
|
5457 |
-
* @param bool $is_context_single_site
|
5458 |
-
*/
|
5459 |
-
private function reconnect_locally( $is_context_single_site = false ) {
|
5460 |
-
$this->_logger->entrance();
|
5461 |
-
|
5462 |
-
if ( ! $this->is_registered() ) {
|
5463 |
-
return;
|
5464 |
-
}
|
5465 |
-
|
5466 |
-
if ( ! fs_is_network_admin() || $is_context_single_site ) {
|
5467 |
-
if ( $this->is_tracking_prohibited() ) {
|
5468 |
-
$this->_site->is_disconnected = false;
|
5469 |
-
$this->_store_site();
|
5470 |
-
}
|
5471 |
-
} else {
|
5472 |
-
$installs_map = $this->get_blog_install_map();
|
5473 |
-
foreach ( $installs_map as $blog_id => $install ) {
|
5474 |
-
/**
|
5475 |
-
* @var FS_Site $install
|
5476 |
-
*/
|
5477 |
-
if ( $install->is_tracking_prohibited() ) {
|
5478 |
-
$install->is_disconnected = false;
|
5479 |
-
$this->_store_site( true, $blog_id, $install );
|
5480 |
-
}
|
5481 |
-
}
|
5482 |
-
}
|
5483 |
-
}
|
5484 |
-
|
5485 |
-
/**
|
5486 |
-
* @author Vova Feldman (@svovaf)
|
5487 |
-
* @since 2.3.2
|
5488 |
-
*
|
5489 |
-
* @return bool
|
5490 |
-
*/
|
5491 |
-
function is_extensions_tracking_allowed() {
|
5492 |
-
return ( true === $this->apply_filters(
|
5493 |
-
'is_extensions_tracking_allowed',
|
5494 |
-
$this->_storage->get( 'is_extensions_tracking_allowed', null )
|
5495 |
-
) );
|
5496 |
-
}
|
5497 |
-
|
5498 |
-
/**
|
5499 |
-
* @author Vova Feldman (@svovaf)
|
5500 |
-
* @since 2.3.2
|
5501 |
-
*/
|
5502 |
-
function _update_tracking_permission_callback() {
|
5503 |
-
$this->_logger->entrance();
|
5504 |
-
|
5505 |
-
$this->check_ajax_referer( 'update_tracking_permission' );
|
5506 |
-
|
5507 |
-
$is_enabled = fs_request_get_bool( 'is_enabled', null );
|
5508 |
-
|
5509 |
-
if ( ! is_bool( $is_enabled ) ) {
|
5510 |
-
self::shoot_ajax_failure();
|
5511 |
-
}
|
5512 |
-
|
5513 |
-
$permission = fs_request_get( 'permission' );
|
5514 |
-
|
5515 |
-
switch ( $permission ) {
|
5516 |
-
case 'extensions':
|
5517 |
-
$this->update_extensions_tracking_flag( $is_enabled );
|
5518 |
-
break;
|
5519 |
-
default:
|
5520 |
-
$permission = 'no_match';
|
5521 |
-
}
|
5522 |
-
|
5523 |
-
if ( 'no_match' === $permission ) {
|
5524 |
-
self::shoot_ajax_failure();
|
5525 |
-
}
|
5526 |
-
|
5527 |
-
self::shoot_ajax_success( array(
|
5528 |
-
'permissions' => array(
|
5529 |
-
$permission => $is_enabled,
|
5530 |
-
)
|
5531 |
-
) );
|
5532 |
-
}
|
5533 |
-
|
5534 |
-
/**
|
5535 |
-
* @author Leo Fajardo (@leorw)
|
5536 |
-
* @since 2.3.2
|
5537 |
-
*
|
5538 |
-
* @param bool|null $is_enabled
|
5539 |
-
*/
|
5540 |
-
function update_extensions_tracking_flag( $is_enabled ) {
|
5541 |
-
if ( is_bool( $is_enabled ) ) {
|
5542 |
-
$this->_storage->store( 'is_extensions_tracking_allowed', $is_enabled );
|
5543 |
-
}
|
5544 |
-
}
|
5545 |
-
|
5546 |
-
/**
|
5547 |
-
* Parse plugin's settings (as defined by the plugin dev).
|
5548 |
-
*
|
5549 |
-
* @author Vova Feldman (@svovaf)
|
5550 |
-
* @since 1.1.7.3
|
5551 |
-
*
|
5552 |
-
* @param array $plugin_info
|
5553 |
-
*
|
5554 |
-
* @throws \Freemius_Exception
|
5555 |
-
*/
|
5556 |
-
private function parse_settings( &$plugin_info ) {
|
5557 |
-
$this->_logger->entrance();
|
5558 |
-
|
5559 |
-
$id = $this->get_numeric_option( $plugin_info, 'id', false );
|
5560 |
-
$public_key = $this->get_option( $plugin_info, 'public_key', false );
|
5561 |
-
$secret_key = $this->get_option( $plugin_info, 'secret_key', null );
|
5562 |
-
$parent_id = $this->get_numeric_option( $plugin_info, 'parent_id', null );
|
5563 |
-
$parent_name = $this->get_option( $plugin_info, 'parent_name', null );
|
5564 |
-
|
5565 |
-
/**
|
5566 |
-
* @author Vova Feldman (@svovaf)
|
5567 |
-
* @since 1.1.9 Try to pull secret key from external config.
|
5568 |
-
*/
|
5569 |
-
if ( is_null( $secret_key ) && defined( "WP_FS__{$this->_slug}_SECRET_KEY" ) ) {
|
5570 |
-
$secret_key = constant( "WP_FS__{$this->_slug}_SECRET_KEY" );
|
5571 |
-
}
|
5572 |
-
|
5573 |
-
if ( isset( $plugin_info['parent'] ) ) {
|
5574 |
-
$parent_id = $this->get_numeric_option( $plugin_info['parent'], 'id', null );
|
5575 |
-
// $parent_slug = $this->get_option( $plugin_info['parent'], 'slug', null );
|
5576 |
-
// $parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null );
|
5577 |
-
// $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
|
5578 |
-
}
|
5579 |
-
|
5580 |
-
if ( false === $id ) {
|
5581 |
-
throw new Freemius_Exception( array(
|
5582 |
-
'error' => array(
|
5583 |
-
'type' => 'ParameterNotSet',
|
5584 |
-
'message' => 'Plugin id parameter is not set.',
|
5585 |
-
'code' => 'plugin_id_not_set',
|
5586 |
-
'http' => 500,
|
5587 |
-
)
|
5588 |
-
) );
|
5589 |
-
}
|
5590 |
-
if ( false === $public_key ) {
|
5591 |
-
throw new Freemius_Exception( array(
|
5592 |
-
'error' => array(
|
5593 |
-
'type' => 'ParameterNotSet',
|
5594 |
-
'message' => 'Plugin public_key parameter is not set.',
|
5595 |
-
'code' => 'plugin_public_key_not_set',
|
5596 |
-
'http' => 500,
|
5597 |
-
)
|
5598 |
-
) );
|
5599 |
-
}
|
5600 |
-
|
5601 |
-
$plugin = ( $this->_plugin instanceof FS_Plugin ) ?
|
5602 |
-
$this->_plugin :
|
5603 |
-
new FS_Plugin();
|
5604 |
-
|
5605 |
-
$premium_suffix = $this->get_option( $plugin_info, 'premium_suffix', '(Premium)' );
|
5606 |
-
|
5607 |
-
$plugin->update( array(
|
5608 |
-
'id' => $id,
|
5609 |
-
'type' => $this->get_option( $plugin_info, 'type', $this->_module_type ),
|
5610 |
-
'public_key' => $public_key,
|
5611 |
-
'slug' => $this->_slug,
|
5612 |
-
'premium_slug' => $this->get_option( $plugin_info, 'premium_slug', "{$this->_slug}-premium" ),
|
5613 |
-
'parent_plugin_id' => $parent_id,
|
5614 |
-
'version' => $this->get_plugin_version(),
|
5615 |
-
'title' => $this->get_plugin_name( $premium_suffix ),
|
5616 |
-
'file' => $this->_plugin_basename,
|
5617 |
-
'is_premium' => $this->get_bool_option( $plugin_info, 'is_premium', true ),
|
5618 |
-
'premium_suffix' => $premium_suffix,
|
5619 |
-
'is_live' => $this->get_bool_option( $plugin_info, 'is_live', true ),
|
5620 |
-
'affiliate_moderation' => $this->get_option( $plugin_info, 'has_affiliation' ),
|
5621 |
-
'bundle_id' => $this->get_option( $plugin_info, 'bundle_id', null ),
|
5622 |
-
'bundle_public_key' => $this->get_option( $plugin_info, 'bundle_public_key', null ),
|
5623 |
-
) );
|
5624 |
-
|
5625 |
-
if ( $plugin->is_updated() ) {
|
5626 |
-
// Update plugin details.
|
5627 |
-
$this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->store( $plugin );
|
5628 |
-
}
|
5629 |
-
// Set the secret key after storing the plugin, we don't want to store the key in the storage.
|
5630 |
-
$this->_plugin->secret_key = $secret_key;
|
5631 |
-
|
5632 |
-
/**
|
5633 |
-
* If the product is network integrated and activated and the current view is in the network level Admin dashboard, if the product's network-level menu located differently from the sub-site level, then use the network menu details (when set).
|
5634 |
-
*
|
5635 |
-
* @author Vova Feldman
|
5636 |
-
* @since 2.4.5
|
5637 |
-
*/
|
5638 |
-
if ( $this->is_network_active() && fs_is_network_admin() ) {
|
5639 |
-
if ( isset( $plugin_info['menu_network'] ) &&
|
5640 |
-
is_array( $plugin_info['menu_network'] ) &&
|
5641 |
-
! empty( $plugin_info['menu_network'] )
|
5642 |
-
) {
|
5643 |
-
$plugin_info['menu'] = $plugin_info['menu_network'];
|
5644 |
-
}
|
5645 |
-
}
|
5646 |
-
|
5647 |
-
if ( ! isset( $plugin_info['menu'] ) ) {
|
5648 |
-
$plugin_info['menu'] = array();
|
5649 |
-
|
5650 |
-
if ( ! empty( $this->_storage->sdk_last_version ) &&
|
5651 |
-
version_compare( $this->_storage->sdk_last_version, '1.1.2', '<=' )
|
5652 |
-
) {
|
5653 |
-
// Backward compatibility to 1.1.2
|
5654 |
-
$plugin_info['menu']['slug'] = isset( $plugin_info['menu_slug'] ) ?
|
5655 |
-
$plugin_info['menu_slug'] :
|
5656 |
-
$this->_slug;
|
5657 |
-
}
|
5658 |
-
}
|
5659 |
-
|
5660 |
-
$this->_menu = FS_Admin_Menu_Manager::instance(
|
5661 |
-
$this->_module_id,
|
5662 |
-
$this->_module_type,
|
5663 |
-
$this->get_unique_affix()
|
5664 |
-
);
|
5665 |
-
|
5666 |
-
$this->_menu->init( $plugin_info['menu'], $this->is_addon() );
|
5667 |
-
|
5668 |
-
$this->_has_addons = $this->get_bool_option( $plugin_info, 'has_addons', false );
|
5669 |
-
$this->_has_paid_plans = $this->get_bool_option( $plugin_info, 'has_paid_plans', true );
|
5670 |
-
$this->_has_premium_version = $this->get_bool_option( $plugin_info, 'has_premium_version', $this->_has_paid_plans );
|
5671 |
-
$this->_ignore_pending_mode = $this->get_bool_option( $plugin_info, 'ignore_pending_mode', false );
|
5672 |
-
$this->_is_org_compliant = $this->get_bool_option( $plugin_info, 'is_org_compliant', true );
|
5673 |
-
$this->_is_premium_only = $this->get_bool_option( $plugin_info, 'is_premium_only', false );
|
5674 |
-
if ( $this->_is_premium_only ) {
|
5675 |
-
// If premium only plugin, disable anonymous mode.
|
5676 |
-
$this->_enable_anonymous = false;
|
5677 |
-
$this->_anonymous_mode = false;
|
5678 |
-
} else {
|
5679 |
-
$this->_enable_anonymous = $this->get_bool_option( $plugin_info, 'enable_anonymous', true );
|
5680 |
-
$this->_anonymous_mode = $this->get_bool_option( $plugin_info, 'anonymous_mode', false );
|
5681 |
-
}
|
5682 |
-
$this->_permissions = $this->get_option( $plugin_info, 'permissions', array() );
|
5683 |
-
$this->_is_bundle_license_auto_activation_enabled = $this->get_option( $plugin_info, 'bundle_license_auto_activation', false );
|
5684 |
-
|
5685 |
-
if ( ! empty( $plugin_info['trial'] ) ) {
|
5686 |
-
$this->_trial_days = $this->get_numeric_option(
|
5687 |
-
$plugin_info['trial'],
|
5688 |
-
'days',
|
5689 |
-
// Default to 0 - trial without days specification.
|
5690 |
-
0
|
5691 |
-
);
|
5692 |
-
|
5693 |
-
$this->_is_trial_require_payment = $this->get_bool_option( $plugin_info['trial'], 'is_require_payment', false );
|
5694 |
-
}
|
5695 |
-
|
5696 |
-
$this->_navigation = $this->get_option(
|
5697 |
-
$plugin_info,
|
5698 |
-
'navigation',
|
5699 |
-
$this->is_free_wp_org_theme() ?
|
5700 |
-
self::NAVIGATION_TABS :
|
5701 |
-
self::NAVIGATION_MENU
|
5702 |
-
);
|
5703 |
-
}
|
5704 |
-
|
5705 |
-
/**
|
5706 |
-
* @param string[] $options
|
5707 |
-
* @param string $key
|
5708 |
-
* @param mixed $default
|
5709 |
-
*
|
5710 |
-
* @return bool
|
5711 |
-
*/
|
5712 |
-
private function get_option( &$options, $key, $default = false ) {
|
5713 |
-
return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
|
5714 |
-
}
|
5715 |
-
|
5716 |
-
private function get_bool_option( &$options, $key, $default = false ) {
|
5717 |
-
return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
|
5718 |
-
}
|
5719 |
-
|
5720 |
-
private function get_numeric_option( &$options, $key, $default = false ) {
|
5721 |
-
return isset( $options[ $key ] ) && is_numeric( $options[ $key ] ) ? $options[ $key ] : $default;
|
5722 |
-
}
|
5723 |
-
|
5724 |
-
/**
|
5725 |
-
* Gate keeper.
|
5726 |
-
*
|
5727 |
-
* @author Vova Feldman (@svovaf)
|
5728 |
-
* @since 1.1.7.3
|
5729 |
-
*
|
5730 |
-
* @return bool
|
5731 |
-
*/
|
5732 |
-
private function should_stop_execution() {
|
5733 |
-
if ( empty( $this->_storage->was_plugin_loaded ) ) {
|
5734 |
-
/**
|
5735 |
-
* Don't execute Freemius until plugin was fully loaded at least once,
|
5736 |
-
* to give the opportunity for the activation hook to run before pinging
|
5737 |
-
* the API for connectivity test. This logic is relevant for the
|
5738 |
-
* identification of new plugin install vs. plugin update.
|
5739 |
-
*
|
5740 |
-
* @author Vova Feldman (@svovaf)
|
5741 |
-
* @since 1.1.9
|
5742 |
-
*/
|
5743 |
-
return true;
|
5744 |
-
}
|
5745 |
-
|
5746 |
-
if ( $this->is_activation_mode() ) {
|
5747 |
-
if ( ! is_admin() ) {
|
5748 |
-
/**
|
5749 |
-
* If in activation mode, don't execute Freemius outside of the
|
5750 |
-
* admin dashboard.
|
5751 |
-
*
|
5752 |
-
* @author Vova Feldman (@svovaf)
|
5753 |
-
* @since 1.1.7.3
|
5754 |
-
*/
|
5755 |
-
return true;
|
5756 |
-
}
|
5757 |
-
|
5758 |
-
if ( ! WP_FS__IS_HTTP_REQUEST ) {
|
5759 |
-
/**
|
5760 |
-
* If in activation and executed without HTTP context (e.g. CLI, Cronjob),
|
5761 |
-
* then don't start Freemius.
|
5762 |
-
*
|
5763 |
-
* @author Vova Feldman (@svovaf)
|
5764 |
-
* @since 1.1.6.3
|
5765 |
-
*
|
5766 |
-
* @link https://wordpress.org/support/topic/errors-in-the-freemius-class-when-running-in-wordpress-in-cli
|
5767 |
-
*/
|
5768 |
-
return true;
|
5769 |
-
}
|
5770 |
-
|
5771 |
-
if ( self::is_cron() ) {
|
5772 |
-
/**
|
5773 |
-
* If in activation mode, don't execute Freemius during wp crons
|
5774 |
-
* (wp crons have HTTP context - called as HTTP request).
|
5775 |
-
*
|
5776 |
-
* @author Vova Feldman (@svovaf)
|
5777 |
-
* @since 1.1.7.3
|
5778 |
-
*/
|
5779 |
-
return true;
|
5780 |
-
}
|
5781 |
-
|
5782 |
-
if ( self::is_ajax() &&
|
5783 |
-
! $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) &&
|
5784 |
-
! $this->_admin_notices->has_sticky( 'failed_connect_api' )
|
5785 |
-
) {
|
5786 |
-
/**
|
5787 |
-
* During activation, if running in AJAX mode, unless there's a sticky
|
5788 |
-
* connectivity issue notice, don't run Freemius.
|
5789 |
-
*
|
5790 |
-
* @author Vova Feldman (@svovaf)
|
5791 |
-
* @since 1.1.7.3
|
5792 |
-
*/
|
5793 |
-
return true;
|
5794 |
-
}
|
5795 |
-
}
|
5796 |
-
|
5797 |
-
return false;
|
5798 |
-
}
|
5799 |
-
|
5800 |
-
/**
|
5801 |
-
* Triggered after code type has changed.
|
5802 |
-
*
|
5803 |
-
* @author Vova Feldman (@svovaf)
|
5804 |
-
* @since 1.1.9.1
|
5805 |
-
*/
|
5806 |
-
function _after_code_type_change() {
|
5807 |
-
$this->_logger->entrance();
|
5808 |
-
|
5809 |
-
if ( $this->is_theme() ) {
|
5810 |
-
// Expire the cache of the previous tabs since the theme may
|
5811 |
-
// have setting updates after code type has changed.
|
5812 |
-
$this->_cache->expire( 'tabs' );
|
5813 |
-
$this->_cache->expire( 'tabs_stylesheets' );
|
5814 |
-
}
|
5815 |
-
|
5816 |
-
if ( $this->is_registered() ) {
|
5817 |
-
if ( ! $this->is_addon() ) {
|
5818 |
-
add_action(
|
5819 |
-
is_admin() ? 'admin_init' : 'init',
|
5820 |
-
array( &$this, '_plugin_code_type_changed' )
|
5821 |
-
);
|
5822 |
-
}
|
5823 |
-
|
5824 |
-
if ( $this->is_premium() ) {
|
5825 |
-
// Purge cached payments after switching to the premium version.
|
5826 |
-
// @todo This logic doesn't handle purging the cache for serviceware module upgrade.
|
5827 |
-
$this->get_api_user_scope()->purge_cache( "/plugins/{$this->_module_id}/payments.json?include_addons=true" );
|
5828 |
-
}
|
5829 |
-
}
|
5830 |
-
}
|
5831 |
-
|
5832 |
-
/**
|
5833 |
-
* Handles plugin's code type change (free <--> premium).
|
5834 |
-
*
|
5835 |
-
* @author Vova Feldman (@svovaf)
|
5836 |
-
* @since 1.0.9
|
5837 |
-
*/
|
5838 |
-
function _plugin_code_type_changed() {
|
5839 |
-
$this->_logger->entrance();
|
5840 |
-
|
5841 |
-
if ( $this->is_premium() ) {
|
5842 |
-
$this->reconnect_locally();
|
5843 |
-
|
5844 |
-
// Activated premium code.
|
5845 |
-
$this->do_action( 'after_premium_version_activation' );
|
5846 |
-
|
5847 |
-
// Remove all sticky messages related to download of the premium version.
|
5848 |
-
$this->_admin_notices->remove_sticky( array(
|
5849 |
-
'trial_started',
|
5850 |
-
'plan_upgraded',
|
5851 |
-
'plan_changed',
|
5852 |
-
'license_activated',
|
5853 |
-
) );
|
5854 |
-
|
5855 |
-
$notice = '';
|
5856 |
-
if ( ! $this->is_only_premium() ) {
|
5857 |
-
$notice = sprintf( $this->get_text_inline( 'Premium %s version was successfully activated.', 'premium-activated-message' ), $this->_module_type );
|
5858 |
-
}
|
5859 |
-
|
5860 |
-
$license_notice = $this->get_license_network_activation_notice();
|
5861 |
-
if ( ! empty( $license_notice ) ) {
|
5862 |
-
$notice .= ' ' . $license_notice;
|
5863 |
-
}
|
5864 |
-
|
5865 |
-
if ( ! empty( $notice ) ) {
|
5866 |
-
$this->_admin_notices->add_sticky(
|
5867 |
-
trim( $notice ),
|
5868 |
-
'premium_activated',
|
5869 |
-
$this->get_text_x_inline( 'W00t',
|
5870 |
-
'Used to express elation, enthusiasm, or triumph (especially in electronic communication).', 'woot' ) . '!'
|
5871 |
-
);
|
5872 |
-
}
|
5873 |
-
} else {
|
5874 |
-
// Remove sticky message related to premium code activation.
|
5875 |
-
$this->_admin_notices->remove_sticky( 'premium_activated' );
|
5876 |
-
|
5877 |
-
// Activated free code (after had the premium before).
|
5878 |
-
$this->do_action( 'after_free_version_reactivation' );
|
5879 |
-
|
5880 |
-
if ( $this->is_paying() && ! $this->is_premium() ) {
|
5881 |
-
$this->_admin_notices->add_sticky(
|
5882 |
-
sprintf(
|
5883 |
-
/* translators: %s: License type (e.g. you have a professional license) */
|
5884 |
-
$this->get_text_inline( 'You have a %s license.', 'you-have-x-license' ),
|
5885 |
-
$this->get_plan_title()
|
5886 |
-
) . $this->get_complete_upgrade_instructions(),
|
5887 |
-
'plan_upgraded',
|
5888 |
-
$this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
|
5889 |
-
);
|
5890 |
-
}
|
5891 |
-
}
|
5892 |
-
|
5893 |
-
// Schedule code type changes event.
|
5894 |
-
$this->schedule_install_sync();
|
5895 |
-
|
5896 |
-
/**
|
5897 |
-
* Unregister the uninstall hook for the other version of the plugin (with different code type) to avoid
|
5898 |
-
* triggering a fatal error when uninstalling that plugin. For example, after deactivating the "free" version
|
5899 |
-
* of a specific plugin, its uninstall hook should be unregistered after the "premium" version has been
|
5900 |
-
* activated. If we don't do that, a fatal error will occur when we try to uninstall the "free" version since
|
5901 |
-
* the main file of the "free" version will be loaded first before calling the hooked callback. Since the
|
5902 |
-
* free and premium versions are almost identical (same class or have same functions), a fatal error like
|
5903 |
-
* "Cannot redeclare class MyClass" or "Cannot redeclare my_function()" will occur.
|
5904 |
-
*/
|
5905 |
-
$this->unregister_uninstall_hook();
|
5906 |
-
|
5907 |
-
$this->clear_module_main_file_cache();
|
5908 |
-
|
5909 |
-
// Update is_premium of latest version.
|
5910 |
-
$this->_storage->prev_is_premium = $this->_plugin->is_premium;
|
5911 |
-
}
|
5912 |
-
|
5913 |
-
#endregion
|
5914 |
-
|
5915 |
-
#----------------------------------------------------------------------------------
|
5916 |
-
#region Add-ons
|
5917 |
-
#----------------------------------------------------------------------------------
|
5918 |
-
|
5919 |
-
/**
|
5920 |
-
* Check if add-on installed and activated on site.
|
5921 |
-
*
|
5922 |
-
* @author Vova Feldman (@svovaf)
|
5923 |
-
* @since 1.0.6
|
5924 |
-
*
|
5925 |
-
* @param string|number $id_or_slug
|
5926 |
-
* @param bool|null $is_premium Since 1.2.1.7 can check for specified add-on version.
|
5927 |
-
*
|
5928 |
-
* @return bool
|
5929 |
-
*/
|
5930 |
-
function is_addon_activated( $id_or_slug, $is_premium = null ) {
|
5931 |
-
$this->_logger->entrance();
|
5932 |
-
|
5933 |
-
$addon_id = self::get_module_id( $id_or_slug );
|
5934 |
-
$is_activated = self::has_instance( $addon_id );
|
5935 |
-
|
5936 |
-
if ( ! $is_activated ) {
|
5937 |
-
return false;
|
5938 |
-
}
|
5939 |
-
|
5940 |
-
if ( is_bool( $is_premium ) ) {
|
5941 |
-
// Check if the specified code version is activate.
|
5942 |
-
$addon = $this->get_addon_instance( $addon_id );
|
5943 |
-
$is_activated = ( $is_premium === $addon->is_premium() );
|
5944 |
-
}
|
5945 |
-
|
5946 |
-
return $is_activated;
|
5947 |
-
}
|
5948 |
-
|
5949 |
-
/**
|
5950 |
-
* Check if add-on was connected to install
|
5951 |
-
*
|
5952 |
-
* @author Vova Feldman (@svovaf)
|
5953 |
-
* @since 1.1.7
|
5954 |
-
*
|
5955 |
-
* @param string|number $id_or_slug
|
5956 |
-
*
|
5957 |
-
* @return bool
|
5958 |
-
*/
|
5959 |
-
function is_addon_connected( $id_or_slug ) {
|
5960 |
-
$this->_logger->entrance();
|
5961 |
-
|
5962 |
-
$sites = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN );
|
5963 |
-
|
5964 |
-
$addon_id = self::get_module_id( $id_or_slug );
|
5965 |
-
$addon = $this->get_addon( $addon_id );
|
5966 |
-
$slug = $addon->slug;
|
5967 |
-
if ( ! isset( $sites[ $slug ] ) ) {
|
5968 |
-
return false;
|
5969 |
-
}
|
5970 |
-
|
5971 |
-
$site = $sites[ $slug ];
|
5972 |
-
|
5973 |
-
$plugin = FS_Plugin_Manager::instance( $addon_id )->get();
|
5974 |
-
|
5975 |
-
if ( $plugin->parent_plugin_id != $this->_plugin->id ) {
|
5976 |
-
// The given slug do NOT belong to any of the plugin's add-ons.
|
5977 |
-
return false;
|
5978 |
-
}
|
5979 |
-
|
5980 |
-
return ( is_object( $site ) &&
|
5981 |
-
is_numeric( $site->id ) &&
|
5982 |
-
is_numeric( $site->user_id ) &&
|
5983 |
-
FS_Plugin_Plan::is_valid_id( $site->plan_id )
|
5984 |
-
);
|
5985 |
-
}
|
5986 |
-
|
5987 |
-
/**
|
5988 |
-
* Determines if add-on installed.
|
5989 |
-
*
|
5990 |
-
* NOTE: This is a heuristic and only works if the folder/file named as the slug.
|
5991 |
-
*
|
5992 |
-
* @author Vova Feldman (@svovaf)
|
5993 |
-
* @since 1.0.6
|
5994 |
-
*
|
5995 |
-
* @param string|number $id_or_slug
|
5996 |
-
*
|
5997 |
-
* @return bool
|
5998 |
-
*/
|
5999 |
-
function is_addon_installed( $id_or_slug ) {
|
6000 |
-
$this->_logger->entrance();
|
6001 |
-
|
6002 |
-
$addon_id = self::get_module_id( $id_or_slug );
|
6003 |
-
|
6004 |
-
return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $addon_id ) ) );
|
6005 |
-
}
|
6006 |
-
|
6007 |
-
/**
|
6008 |
-
* Get add-on basename.
|
6009 |
-
*
|
6010 |
-
* @author Vova Feldman (@svovaf)
|
6011 |
-
* @since 1.0.6
|
6012 |
-
*
|
6013 |
-
* @param string|number $id_or_slug
|
6014 |
-
*
|
6015 |
-
* @return string
|
6016 |
-
*/
|
6017 |
-
function get_addon_basename( $id_or_slug ) {
|
6018 |
-
$addon_id = self::get_module_id( $id_or_slug );
|
6019 |
-
|
6020 |
-
if ( $this->is_addon_activated( $addon_id ) ) {
|
6021 |
-
return self::instance( $addon_id )->get_plugin_basename();
|
6022 |
-
}
|
6023 |
-
|
6024 |
-
$addon = $this->get_addon( $addon_id );
|
6025 |
-
$premium_basename = "{$addon->premium_slug}/{$addon->slug}.php";
|
6026 |
-
|
6027 |
-
if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $premium_basename ) ) ) {
|
6028 |
-
return $premium_basename;
|
6029 |
-
}
|
6030 |
-
|
6031 |
-
$all_plugins = $this->get_all_plugins();
|
6032 |
-
|
6033 |
-
foreach ( $all_plugins as $basename => $data ) {
|
6034 |
-
if ( $addon->slug === $data['slug'] ||
|
6035 |
-
$addon->premium_slug === $data['slug']
|
6036 |
-
) {
|
6037 |
-
return $basename;
|
6038 |
-
}
|
6039 |
-
}
|
6040 |
-
|
6041 |
-
$free_basename = "{$addon->slug}/{$addon->slug}.php";
|
6042 |
-
|
6043 |
-
return $free_basename;
|
6044 |
-
}
|
6045 |
-
|
6046 |
-
/**
|
6047 |
-
* Get installed add-ons instances.
|
6048 |
-
*
|
6049 |
-
* @author Vova Feldman (@svovaf)
|
6050 |
-
* @since 1.0.6
|
6051 |
-
*
|
6052 |
-
* @return Freemius[]
|
6053 |
-
*/
|
6054 |
-
function get_installed_addons() {
|
6055 |
-
if ( $this->is_addon() ) {
|
6056 |
-
// Add-on cann
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|