| 1 |
<?php |
| 2 |
/* |
| 3 |
* SOFTWARE LICENSE INFORMATION |
| 4 |
* |
| 5 |
* Copyright (c) 2017 Buttonizer, all rights reserved. |
| 6 |
* |
| 7 |
* This file is part of Buttonizer |
| 8 |
* |
| 9 |
* For detailed information regarding to the licensing of |
| 10 |
* this software, please review the license.txt or visit: |
| 11 |
* https://buttonizer.pro/license/ |
| 12 |
*/ |
| 13 |
|
| 14 |
use Buttonizer\Core\Utils\Settings; |
| 15 |
use Buttonizer\Core\InitBootstrap; |
| 16 |
|
| 17 |
// Check Buttonizer Legacy enabled |
| 18 |
if ( |
| 19 |
// Check if legacy was forced |
| 20 |
Settings::getSetting("force_legacy", false) === true || |
| 21 |
|
| 22 |
// Check for older installations which did not yet decide |
| 23 |
(Settings::getSetting("finished_setup", false) === false && get_option("buttonizer_buttons", false) !== false) |
| 24 |
) { |
| 25 |
// Init legacy |
| 26 |
require_once BUTTONIZER_DIR . "/legacy.php"; |
| 27 |
} else { |
| 28 |
// Boot shared hooks (admin, redirect, page data, embed script, shortcode, admin bar, REST API) |
| 29 |
InitBootstrap::boot( |
| 30 |
\Buttonizer\Admin\Admin::class, |
| 31 |
\Buttonizer\Api\Api::class |
| 32 |
); |
| 33 |
|
| 34 |
// Google Analytics (legacy 2.x setting, buttonizer-specific) |
| 35 |
add_action('wp_enqueue_scripts', function () { |
| 36 |
if (Settings::isset("google_analytics")) { |
| 37 |
wp_register_script('google_analytics', 'https://www.googletagmanager.com/gtag/js?id=' . Settings::getSetting("google_analytics"), array(), false, true); |
| 38 |
|
| 39 |
wp_enqueue_script('google_analytics'); |
| 40 |
|
| 41 |
wp_add_inline_script('google_analytics', " |
| 42 |
window.dataLayer = window.dataLayer || []; |
| 43 |
function gtag(){dataLayer.push(arguments);} |
| 44 |
gtag('js', new Date()); |
| 45 |
|
| 46 |
gtag('config', '" . Settings::getSetting("google_analytics") . "');"); |
| 47 |
} |
| 48 |
}); |
| 49 |
} |
| 50 |
|