| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: Easy Subscribe |
| 5 |
* Description: Easy way to integrate the form and collect subscribers. |
| 6 |
* Version: 1.5.4 |
| 7 |
* Requires at least: 6.4 |
| 8 |
* Requires PHP: 7.4 |
| 9 |
* Author: Devnet |
| 10 |
* Author URI: https://devnet.hr |
| 11 |
* License: GPL-2.0+ |
| 12 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 13 |
* Text Domain: easy-subscribe |
| 14 |
*/ |
| 15 |
use Devnet\EasySubscribe\Includes\Activator; |
| 16 |
use Devnet\EasySubscribe\Includes\Deactivator; |
| 17 |
use Devnet\EasySubscribe\Includes\Plugin; |
| 18 |
use Devnet\EasySubscribe\Includes\Uninstaller; |
| 19 |
// If this file is called directly, abort. |
| 20 |
if ( !defined( 'ABSPATH' ) ) { |
| 21 |
exit; |
| 22 |
} |
| 23 |
if ( function_exists( 'devnet_esub_fs' ) ) { |
| 24 |
devnet_esub_fs()->set_basename( false, __FILE__ ); |
| 25 |
} else { |
| 26 |
if ( !function_exists( 'devnet_esub_fs' ) ) { |
| 27 |
// Create a helper function for easy SDK access. |
| 28 |
function devnet_esub_fs() { |
| 29 |
global $devnet_esub_fs; |
| 30 |
if ( !isset( $devnet_esub_fs ) ) { |
| 31 |
// Include Freemius SDK. |
| 32 |
require_once __DIR__ . '/vendor/freemius/wordpress-sdk/start.php'; |
| 33 |
$devnet_esub_fs = fs_dynamic_init( [ |
| 34 |
'id' => '14904', |
| 35 |
'slug' => 'easy-subscribe', |
| 36 |
'premium_slug' => 'easy-subscribe-pro', |
| 37 |
'type' => 'plugin', |
| 38 |
'public_key' => 'pk_fb60e997a9379fa986e287711e169', |
| 39 |
'is_premium' => false, |
| 40 |
'premium_suffix' => '(Pro)', |
| 41 |
'has_addons' => true, |
| 42 |
'has_paid_plans' => true, |
| 43 |
'is_org_compliant' => true, |
| 44 |
'trial' => [ |
| 45 |
'days' => 7, |
| 46 |
'is_require_payment' => true, |
| 47 |
], |
| 48 |
'menu' => [ |
| 49 |
'slug' => 'easy-subscribe', |
| 50 |
'first-path' => 'admin.php?page=easy-subscribe', |
| 51 |
], |
| 52 |
'is_live' => true, |
| 53 |
] ); |
| 54 |
} |
| 55 |
return $devnet_esub_fs; |
| 56 |
} |
| 57 |
|
| 58 |
// Init Freemius. |
| 59 |
devnet_esub_fs(); |
| 60 |
// Signal that SDK was initiated. |
| 61 |
do_action( 'devnet_esub_fs_loaded' ); |
| 62 |
} |
| 63 |
/* |
| 64 |
* Show the contact submenu item only when the user have a valid non-expired license. |
| 65 |
* |
| 66 |
* @param $is_visible The filtered value. Whether the submenu item should be visible or not. |
| 67 |
* @param $menu_id The ID of the submenu item. |
| 68 |
* |
| 69 |
* @return bool If true, the menu item should be visible. |
| 70 |
*/ |
| 71 |
if ( !function_exists( 'devnet_esub_is_submenu_visible' ) ) { |
| 72 |
function devnet_esub_is_submenu_visible( $is_visible, $menu_id ) { |
| 73 |
if ( 'contact' != $menu_id ) { |
| 74 |
return $is_visible; |
| 75 |
} |
| 76 |
return devnet_esub_fs()->can_use_premium_code(); |
| 77 |
} |
| 78 |
|
| 79 |
} |
| 80 |
/* |
| 81 |
* TODO: do uninstall logic. |
| 82 |
*/ |
| 83 |
if ( !function_exists( 'devnet_esub_fs_uninstall_cleanup' ) ) { |
| 84 |
function devnet_esub_fs_uninstall_cleanup() { |
| 85 |
require_once plugin_dir_path( __FILE__ ) . 'includes/uninstaller.php'; |
| 86 |
Uninstaller::cleanup(); |
| 87 |
} |
| 88 |
|
| 89 |
} |
| 90 |
if ( !function_exists( 'devnet_esub_fs_custom_icon' ) ) { |
| 91 |
function devnet_esub_fs_custom_icon() { |
| 92 |
return dirname( __FILE__ ) . '/assets/images/logo.png'; |
| 93 |
} |
| 94 |
|
| 95 |
} |
| 96 |
/* |
| 97 |
* Run Freemius actions and filters. |
| 98 |
*/ |
| 99 |
if ( function_exists( 'devnet_esub_fs' ) ) { |
| 100 |
devnet_esub_fs()->add_filter( |
| 101 |
'is_submenu_visible', |
| 102 |
'devnet_esub_is_submenu_visible', |
| 103 |
10, |
| 104 |
2 |
| 105 |
); |
| 106 |
devnet_esub_fs()->add_action( 'after_uninstall', 'devnet_esub_fs_uninstall_cleanup' ); |
| 107 |
devnet_esub_fs()->add_filter( 'plugin_icon', 'devnet_esub_fs_custom_icon' ); |
| 108 |
} |
| 109 |
function devnet_esub_options() { |
| 110 |
$options = [ |
| 111 |
'general' => get_option( 'devnet_esub_general' ), |
| 112 |
'forms' => [ |
| 113 |
'devnet_esub_form' => get_option( 'devnet_esub_form' ), |
| 114 |
], |
| 115 |
'messages' => get_option( 'devnet_esub_messages' ), |
| 116 |
]; |
| 117 |
return $options; |
| 118 |
} |
| 119 |
|
| 120 |
function activate_plugin_easy_subscribe() { |
| 121 |
require_once plugin_dir_path( __FILE__ ) . 'includes/activator.php'; |
| 122 |
Activator::activate(); |
| 123 |
} |
| 124 |
|
| 125 |
function deactivate_plugin_easy_subscribe() { |
| 126 |
require_once plugin_dir_path( __FILE__ ) . 'includes/deactivator.php'; |
| 127 |
Deactivator::deactivate(); |
| 128 |
} |
| 129 |
|
| 130 |
register_activation_hook( __FILE__, 'activate_plugin_easy_subscribe' ); |
| 131 |
register_deactivation_hook( __FILE__, 'deactivate_plugin_easy_subscribe' ); |
| 132 |
function run_devnet_easy_subscribe_update() { |
| 133 |
$db_version = (int) get_option( 'devnet_esub_db_version' ); |
| 134 |
if ( !$db_version || $db_version < DEVNET_ESUB_DB_VERSION ) { |
| 135 |
require_once plugin_dir_path( __FILE__ ) . 'includes/activator.php'; |
| 136 |
Activator::update_table(); |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
function run_devnet_easy_subscribe() { |
| 141 |
require plugin_dir_path( __FILE__ ) . 'includes/plugin.php'; |
| 142 |
$plugin = new Plugin(); |
| 143 |
$plugin->run(); |
| 144 |
} |
| 145 |
|
| 146 |
define( 'DEVNET_ESUB_VERSION', '1.5.4' ); |
| 147 |
define( 'DEVNET_ESUB_DB_VERSION', 3 ); |
| 148 |
define( 'DEVNET_ESUB_NAME', 'Easy Subscribe' ); |
| 149 |
define( 'DEVNET_ESUB_SLUG', plugin_basename( __FILE__ ) ); |
| 150 |
define( 'DEVNET_ESUB_OPTIONS', devnet_esub_options() ); |
| 151 |
run_devnet_easy_subscribe_update(); |
| 152 |
run_devnet_easy_subscribe(); |
| 153 |
} |