| 1 |
<?php |
| 2 |
|
| 3 |
// Fixes bug with multiple buttonizer installs |
| 4 |
use Buttonizer\Core\Utils\Settings; |
| 5 |
if ( !defined( 'BUTTONIZER_DEFINED' ) ) { |
| 6 |
/* |
| 7 |
* License setup |
| 8 |
*/ |
| 9 |
$oButtonizer = new Buttonizer\Legacy\Licensing\License(); |
| 10 |
$oButtonizer->init(); |
| 11 |
if ( !function_exists( "ButtonizerLicense" ) ) { |
| 12 |
function ButtonizerLicense() { |
| 13 |
global $oButtonizer; |
| 14 |
return $oButtonizer->get(); |
| 15 |
} |
| 16 |
|
| 17 |
} |
| 18 |
// Define legacy data. |
| 19 |
// Defined after the license setup above on purpose: BUTTONIZER_LEGACY_REQUESTED_MIGRATION depends on |
| 20 |
// ButtonizerLicense() being initialized. In the free build we force it false so the user always lands on |
| 21 |
// the migration flow instead of the legacy editor (which is stripped from that build). |
| 22 |
define( "BUTTONIZER_LEGACY", true ); |
| 23 |
// This should be false to show migration |
| 24 |
define( "BUTTONIZER_LEGACY_REQUESTED_MIGRATION", false ); |
| 25 |
/* |
| 26 |
* Installation, removing and initiallization |
| 27 |
*/ |
| 28 |
$oButtonizerMaintain = new Buttonizer\Legacy\Utils\Maintain(true); |
| 29 |
/* |
| 30 |
* Buttonizer Admin Dashboard |
| 31 |
*/ |
| 32 |
if ( is_admin() ) { |
| 33 |
// Load Admin page |
| 34 |
new Buttonizer\Legacy\Admin\Admin(); |
| 35 |
} |
| 36 |
/** |
| 37 |
* Create Buttonizer API endpoints |
| 38 |
*/ |
| 39 |
add_action( 'rest_api_init', function () { |
| 40 |
new Buttonizer\Legacy\Api\Api(); |
| 41 |
} ); |
| 42 |
/** |
| 43 |
* Frontend |
| 44 |
*/ |
| 45 |
new Buttonizer\Legacy\Frontend\Ajax(); |
| 46 |
/* LAST FEW FUNCTIONS */ |
| 47 |
if ( !function_exists( "buttonizer_custom_connect_message" ) ) { |
| 48 |
function buttonizer_custom_connect_message( |
| 49 |
$message, |
| 50 |
$user_first_name, |
| 51 |
$plugin_title, |
| 52 |
$user_login, |
| 53 |
$site_link, |
| 54 |
$freemius_link |
| 55 |
) { |
| 56 |
return sprintf( |
| 57 |
__( 'Hey %1$s', 'buttonizer-multifunctional-button' ) . '!<br><br> |
| 58 |
<p>Thank you for trying out our plugin!</p><br> |
| 59 |
<p>Our goal is to provide you excellent support and make the Plugin better and more secure. We do that by tracking how our users are using the plugin, learning why they abandon it, which environments we need to continue supporting, etc. Those valuable data points are key to making data-driven decisions and lead to better UX (user experience), new features, better documentation and other good things.</p><br> |
| 60 |
<p>Click on Allow and Continue (blue button) so that we can learn how to improve our plugin and help you better when you have support issues.</p><br> |
| 61 |
<p>You can always use Buttonizer Free version without opting-in. Just click \'Skip\' (white button) if you don\'t want to opt-in.</p><br> |
| 62 |
<p>Click on the link below (<a href="https://community.buttonizer.pro/knowledgebase/58" target="_blank">or click here</a>) to have a quick overview what gets tracked.</p><br> |
| 63 |
<p>Much Buttonizing fun,<br /> |
| 64 |
<b>Team Buttonizer</b></p>', |
| 65 |
$user_first_name, |
| 66 |
'<b>' . $plugin_title . '</b>', |
| 67 |
'<b>' . $user_login . '</b>', |
| 68 |
$site_link, |
| 69 |
$freemius_link |
| 70 |
); |
| 71 |
} |
| 72 |
|
| 73 |
if ( $oButtonizer->get() ) { |
| 74 |
$oButtonizer->get()->add_filter( |
| 75 |
'connect_message', |
| 76 |
'buttonizer_custom_connect_message', |
| 77 |
10, |
| 78 |
6 |
| 79 |
); |
| 80 |
} |
| 81 |
} |
| 82 |
// The Freemius object is null in the free build (SDK is stripped), so guard every ->get() call. |
| 83 |
if ( $oButtonizer->get() ) { |
| 84 |
// Add Buttonizer Community |
| 85 |
$oButtonizer->get()->add_filter( 'support_forum_url', function ( $wp_org_support_url ) { |
| 86 |
return 'https://community.buttonizer.pro/'; |
| 87 |
} ); |
| 88 |
// Buttonizer icon |
| 89 |
$oButtonizer->get()->add_filter( 'plugin_icon', function () { |
| 90 |
return dirname( __FILE__ ) . '/assets/images/plugin-icon.png'; |
| 91 |
} ); |
| 92 |
} |
| 93 |
// Localization |
| 94 |
add_action( 'init', 'buttonizer_load_plugin_textdomain' ); |
| 95 |
function buttonizer_load_plugin_textdomain() { |
| 96 |
load_plugin_textdomain( 'buttonizer-multifunctional-button', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 97 |
} |
| 98 |
|
| 99 |
// System, buttonizer is loaded |
| 100 |
do_action( 'buttonizer_loaded' ); |
| 101 |
// Ok, define |
| 102 |
define( 'BUTTONIZER_DEFINED', '1.0' ); |
| 103 |
} |