| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: King Addons |
| 5 |
* Description: 4,000+ ready Elementor sections, 650+ templates, 70+ FREE widgets for Elementor, and features like Live Search, Popups, Carousels, Image Hotspots, and Parallax Backgrounds. |
| 6 |
* Author URI: https://kingaddons.com/ |
| 7 |
* Author: KingAddons.com |
| 8 |
* Version: 51.1.36 |
| 9 |
* Text Domain: king-addons |
| 10 |
* Requires at least: 6.0 |
| 11 |
* Requires PHP: 7.4 |
| 12 |
* License: GPLv3 |
| 13 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 14 |
*/ |
| 15 |
|
| 16 |
/** @noinspection SpellCheckingInspection */ |
| 17 |
if (!defined('ABSPATH')) { |
| 18 |
exit; // Exit if accessed directly. |
| 19 |
} |
| 20 |
|
| 21 |
// Load plugin textdomain immediately to prevent early translation loading notices. |
| 22 |
load_plugin_textdomain('king-addons'); |
| 23 |
|
| 24 |
/** PLUGIN VERSION */ |
| 25 |
const KING_ADDONS_VERSION = '51.1.36'; |
| 26 |
|
| 27 |
/** DEFINES */ |
| 28 |
define('KING_ADDONS_PATH', plugin_dir_path(__FILE__)); |
| 29 |
define('KING_ADDONS_URL', plugins_url('/', __FILE__)); |
| 30 |
|
| 31 |
/** ASSETS KEY - It's using to have the unique wp_register (style, script) handle */ |
| 32 |
const KING_ADDONS_ASSETS_UNIQUE_KEY = 'king-addons'; |
| 33 |
|
| 34 |
require_once(KING_ADDONS_PATH . 'includes/helpers/Global/global-constants.php'); |
| 35 |
|
| 36 |
if (!function_exists('king_addons_freemius')) { |
| 37 |
// Create a helper function for easy SDK access. |
| 38 |
function king_addons_freemius() |
| 39 |
{ |
| 40 |
global $king_addons_freemius; |
| 41 |
|
| 42 |
if (!isset($king_addons_freemius)) { |
| 43 |
// Include Freemius SDK. |
| 44 |
require_once dirname(__FILE__) . '/freemius/start.php'; |
| 45 |
|
| 46 |
/** @noinspection PhpUnhandledExceptionInspection */ |
| 47 |
$king_addons_freemius = fs_dynamic_init(array( |
| 48 |
'id' => '16154', |
| 49 |
'slug' => 'king-addons', |
| 50 |
'premium_slug' => 'king-addons-pro', |
| 51 |
'type' => 'plugin', |
| 52 |
'public_key' => 'pk_eac3624cbc14c1846cf1ab9abbd68', |
| 53 |
'is_premium' => false, // temp |
| 54 |
'premium_suffix' => 'pro', |
| 55 |
// If your plugin is a serviceware, set this option to false. |
| 56 |
'has_premium_version' => true, |
| 57 |
'has_addons' => false, |
| 58 |
'has_paid_plans' => false, // temp |
| 59 |
'has_affiliation' => 'all', |
| 60 |
'menu' => array( |
| 61 |
'slug' => 'king-addons', |
| 62 |
'first-path' => 'plugins.php', |
| 63 |
'pricing' => false, |
| 64 |
'contact' => false, |
| 65 |
'support' => false, |
| 66 |
), |
| 67 |
)); |
| 68 |
} |
| 69 |
|
| 70 |
return $king_addons_freemius; |
| 71 |
} |
| 72 |
|
| 73 |
// Init Freemius. |
| 74 |
king_addons_freemius(); |
| 75 |
// Signal that SDK was initiated. |
| 76 |
do_action('king_addons_freemius_loaded'); |
| 77 |
king_addons_freemius()->add_filter('show_deactivation_subscription_cancellation', '__return_false'); |
| 78 |
king_addons_freemius()->add_filter('deactivate_on_activation', '__return_false'); |
| 79 |
} |
| 80 |
|
| 81 |
if (!function_exists('king_addons_doActivation')) { |
| 82 |
function king_addons_doActivation() |
| 83 |
{ |
| 84 |
add_option('king_addons_plugin_activated', true); |
| 85 |
if (false === get_option('king_addons_optionActivationTime')) { |
| 86 |
add_option('king_addons_optionActivationTime', absint(intval(strtotime('now')))); |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
register_activation_hook(__FILE__, 'king_addons_doActivation'); |
| 91 |
} |
| 92 |
|
| 93 |
if (!function_exists('king_addons_doDectivation')) { |
| 94 |
function king_addons_doDectivation() |
| 95 |
{ |
| 96 |
delete_option('king_addons_HFB_flushed_rewrite_rules'); |
| 97 |
delete_option('king_addons_optionActivationTime'); |
| 98 |
} |
| 99 |
|
| 100 |
register_deactivation_hook(__FILE__, 'king_addons_doDectivation'); |
| 101 |
} |
| 102 |
|
| 103 |
if (!function_exists('king_addons_doRedirect_after_activation')) { |
| 104 |
function king_addons_doRedirect_after_activation() |
| 105 |
{ |
| 106 |
if (did_action('elementor/loaded')) { |
| 107 |
if (get_option('king_addons_plugin_activated', false)) { |
| 108 |
delete_option('king_addons_plugin_activated'); |
| 109 |
wp_redirect(admin_url('admin.php?page=king-addons')); |
| 110 |
exit; |
| 111 |
} |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
add_action('admin_init', 'king_addons_doRedirect_after_activation'); |
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* Main function |
| 120 |
* |
| 121 |
* @return void |
| 122 |
* @since 1.0.0 |
| 123 |
* @access public |
| 124 |
*/ |
| 125 |
if (!function_exists('king_addons_doPlugin')) { |
| 126 |
/** @noinspection PhpMissingReturnTypeInspection */ |
| 127 |
function king_addons_doPlugin() |
| 128 |
{ |
| 129 |
require_once(KING_ADDONS_PATH . 'includes/Core.php'); |
| 130 |
} |
| 131 |
// Using after_setup_theme to fix: PHP Notice: Function _load_textdomain_just_in_time was called incorrectly. |
| 132 |
add_action('after_setup_theme', 'king_addons_doPlugin'); |
| 133 |
} |
| 134 |
|
| 135 |
/** |
| 136 |
* Register Assets |
| 137 |
* |
| 138 |
* @return void |
| 139 |
* @since 1.0.0 |
| 140 |
* @access public |
| 141 |
*/ |
| 142 |
if (!function_exists('king_addons_registerAssets')) { |
| 143 |
/** @noinspection PhpMissingReturnTypeInspection */ |
| 144 |
function king_addons_registerAssets() |
| 145 |
{ |
| 146 |
require_once(KING_ADDONS_PATH . 'includes/RegisterAssets.php'); |
| 147 |
} |
| 148 |
|
| 149 |
add_action('wp_loaded', 'king_addons_registerAssets'); |
| 150 |
} |
| 151 |
|
| 152 |
/** |
| 153 |
* Hides spaming notices from another plugins on the plugin settings page |
| 154 |
* |
| 155 |
* @return void |
| 156 |
* @since 1.0.0 |
| 157 |
* @access public |
| 158 |
*/ |
| 159 |
if (!function_exists('king_addons_hideAnotherNotices')) { |
| 160 |
/** @noinspection PhpMissingReturnTypeInspection */ |
| 161 |
function king_addons_hideAnotherNotices() |
| 162 |
{ |
| 163 |
$current_screen = get_current_screen()->id; |
| 164 |
// error_log($current_screen); |
| 165 |
if ( |
| 166 |
$current_screen == 'toplevel_page_king-addons' || |
| 167 |
$current_screen == 'toplevel_page_king-addons-templates' || |
| 168 |
$current_screen == 'toplevel_page_king-addons-popup-builder' || |
| 169 |
$current_screen == 'edit-king-addons-el-hf' || |
| 170 |
$current_screen == 'edit-king-addons-fb-sub' || |
| 171 |
$current_screen == 'header-footer_page_king-addons-el-hf-settings' || |
| 172 |
$current_screen == 'king-addons_page_king-addons-ai-settings' || |
| 173 |
$current_screen == 'king-addons_page_king-addons-pricing' || |
| 174 |
$current_screen == 'king-addons_page_king-addons-settings' |
| 175 |
) { |
| 176 |
// Remove all notices |
| 177 |
remove_all_actions('user_admin_notices'); |
| 178 |
remove_all_actions('admin_notices'); |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
add_action('in_admin_header', 'king_addons_hideAnotherNotices', 99); |
| 183 |
} |
| 184 |
|
| 185 |
/** |
| 186 |
* Apply styles to the plugin menu icon because some plugins broke the menu icon styles |
| 187 |
* |
| 188 |
* @return void |
| 189 |
* @since 24.8.25 |
| 190 |
* @access public |
| 191 |
*/ |
| 192 |
if (!function_exists('king_addons_styleMenuIcon')) { |
| 193 |
/** @noinspection PhpMissingReturnTypeInspection */ |
| 194 |
function king_addons_styleMenuIcon() |
| 195 |
{ |
| 196 |
wp_enqueue_style('king-addons-plugin-style-menu-icon', plugin_dir_url(__FILE__) . 'includes/admin/css/menu-icon.css', '', KING_ADDONS_VERSION); |
| 197 |
if (get_current_screen()->id == 'king-addons_page_king-addons-pricing') { |
| 198 |
wp_enqueue_style('king-addons-plugin-style-pricing', plugin_dir_url(__FILE__) . 'includes/admin/css/pricing.css', '', KING_ADDONS_VERSION); |
| 199 |
} |
| 200 |
} |
| 201 |
|
| 202 |
add_action('admin_enqueue_scripts', 'king_addons_styleMenuIcon'); |
| 203 |
} |
| 204 |
|
| 205 |
/** |
| 206 |
* Add "Upgrade to Pro" link to the Plugins list table. |
| 207 |
* |
| 208 |
* @param array $links Existing plugin action links. |
| 209 |
* |
| 210 |
* @return array Modified action links with Upgrade link. |
| 211 |
* @since 24.12.78 |
| 212 |
*/ |
| 213 |
if (! function_exists('king_addons_add_action_links')) { |
| 214 |
function king_addons_add_action_links(array $links): array |
| 215 |
{ |
| 216 |
// Pricing page with UTM parameters for tracking. |
| 217 |
$pro_url = 'https://kingaddons.com/pricing/?utm_source=kng-plugin-list&utm_medium=wp-plugins-page&utm_campaign=kng'; |
| 218 |
|
| 219 |
// Prepend the Upgrade link. |
| 220 |
$links['go_pro'] = sprintf( |
| 221 |
'<a href="%1$s" target="_blank" class="king-addons-plugins-gopro">%2$s</a>', |
| 222 |
esc_url($pro_url), |
| 223 |
esc_html__('Upgrade to Pro', 'king-addons') |
| 224 |
); |
| 225 |
|
| 226 |
return $links; |
| 227 |
} |
| 228 |
|
| 229 |
if (!king_addons_freemius()->can_use_premium_code__premium_only()) { |
| 230 |
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'king_addons_add_action_links'); |
| 231 |
add_filter('network_admin_plugin_action_links_' . plugin_basename(__FILE__), 'king_addons_add_action_links'); |
| 232 |
} |
| 233 |
} |