| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The plugin bootstrap file |
| 5 |
* |
| 6 |
* This file is read by WordPress to generate the plugin information in the plugin |
| 7 |
* admin area. This file also includes all of the dependencies used by the plugin, |
| 8 |
* registers the activation and deactivation functions, and defines a function |
| 9 |
* that starts the plugin. |
| 10 |
* |
| 11 |
* @link wpdirectorykit.com |
| 12 |
* @since 1.0.0 |
| 13 |
* @package Wpdirectorykit |
| 14 |
* |
| 15 |
* @wordpress-plugin |
| 16 |
* Plugin Name: WP Directory Kit |
| 17 |
* Plugin URI: https://wpdirectorykit.com/plugins/wpdirectorykit.html |
| 18 |
* Description: Build your Directory portal, demos for Real Estate Agencies and Car Dealership included |
| 19 |
* Version: 1.5.3 |
| 20 |
* Requires PHP: 7.0 |
| 21 |
* Author: wpdirectorykit.com |
| 22 |
* Author URI: https://wpdirectorykit.com |
| 23 |
* License: GPL-2.0+ |
| 24 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 25 |
* Text Domain: wpdirectorykit |
| 26 |
* Domain Path: /languages |
| 27 |
* |
| 28 |
* Elementor tested up to: 3.33.1 |
| 29 |
* Elementor Pro tested up to: 3.23.2 |
| 30 |
* |
| 31 |
* Copyright (C) SWIT Sandi Winter IT. |
| 32 |
* |
| 33 |
*/ |
| 34 |
|
| 35 |
// If this file is called directly, abort. |
| 36 |
if (! defined('WPINC')) { |
| 37 |
die; |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Currently plugin version. |
| 42 |
* Start at version 1.0.0 and use SemVer - https://semver.org |
| 43 |
* Rename this for your plugin and update it as you release new versions. |
| 44 |
*/ |
| 45 |
define('WPDIRECTORYKIT_VERSION', '1.5.3'); |
| 46 |
define('WPDIRECTORYKIT_NAME', 'wdk'); |
| 47 |
define('WPDIRECTORYKIT_PATH', plugin_dir_path(__FILE__)); |
| 48 |
define('WPDIRECTORYKIT_URL', plugin_dir_url(__FILE__)); |
| 49 |
|
| 50 |
/** |
| 51 |
* The code that runs during plugin activation. |
| 52 |
* This action is documented in includes/class-wpdirectorykit-activator.php |
| 53 |
*/ |
| 54 |
function activate_wpdirectorykit() |
| 55 |
{ |
| 56 |
require_once plugin_dir_path(__FILE__) . 'includes/class-wpdirectorykit-activator.php'; |
| 57 |
Wpdirectorykit_Activator::activate(); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* The code that runs during plugin deactivation. |
| 62 |
* This action is documented in includes/class-wpdirectorykit-deactivator.php |
| 63 |
*/ |
| 64 |
function deactivate_wpdirectorykit() |
| 65 |
{ |
| 66 |
require_once plugin_dir_path(__FILE__) . 'includes/class-wpdirectorykit-deactivator.php'; |
| 67 |
Wpdirectorykit_Deactivator::deactivate(); |
| 68 |
} |
| 69 |
|
| 70 |
register_activation_hook(__FILE__, 'activate_wpdirectorykit'); |
| 71 |
register_deactivation_hook(__FILE__, 'deactivate_wpdirectorykit'); |
| 72 |
|
| 73 |
/** |
| 74 |
* The core plugin class that is used to define internationalization, |
| 75 |
* admin-specific hooks, and public-facing site hooks. |
| 76 |
*/ |
| 77 |
require plugin_dir_path(__FILE__) . 'includes/class-wpdirectorykit.php'; |
| 78 |
|
| 79 |
|
| 80 |
if (file_exists(WPDIRECTORYKIT_PATH . 'premium_functions.php') && !defined('WDK_FS_DISABLE')) { |
| 81 |
require_once WPDIRECTORYKIT_PATH . 'premium_functions.php'; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Begins execution of the plugin. |
| 86 |
* |
| 87 |
* Since everything within the plugin is registered via hooks, |
| 88 |
* then kicking off the plugin from this point in the file does |
| 89 |
* not affect the page life cycle. |
| 90 |
* |
| 91 |
* @since 1.0.0 |
| 92 |
*/ |
| 93 |
function run_wpdirectorykit() |
| 94 |
{ |
| 95 |
|
| 96 |
$plugin = new Wpdirectorykit(); |
| 97 |
$plugin->run(); |
| 98 |
} |
| 99 |
run_wpdirectorykit(); |
| 100 |
|
| 101 |
|
| 102 |
/* |
| 103 |
* Add admin notify |
| 104 |
* @param (string) $key unique key of notify, prefix included related plugin |
| 105 |
* @param (string) $text test of message |
| 106 |
* @param (function) $callback_filter custom function should be return true if not need show |
| 107 |
* @param (string) $class notify alert class, by default 'notice notice-error' |
| 108 |
* @return boolen true |
| 109 |
*/ |
| 110 |
function wdk_notify_admin($key = '', $text = 'Custom Text of message', $callback_filter = '', $class = 'notice notice-error') |
| 111 |
{ |
| 112 |
$key = 'wdk_notify_' . $key; |
| 113 |
$key_dismiss = $key . '_dismiss'; |
| 114 |
|
| 115 |
add_action('admin_notices', function () use ($key_dismiss, $text, $class, $callback_filter) { |
| 116 |
|
| 117 |
$user_id = get_current_user_id(); |
| 118 |
|
| 119 |
// Already dismissed |
| 120 |
if (get_user_meta($user_id, $key_dismiss, true)) { |
| 121 |
return; |
| 122 |
} |
| 123 |
|
| 124 |
// Optional filter |
| 125 |
if (!empty($callback_filter) && $callback_filter()) { |
| 126 |
return; |
| 127 |
} |
| 128 |
|
| 129 |
// Nonce URL |
| 130 |
$url = wp_nonce_url( |
| 131 |
add_query_arg($key_dismiss, '1'), |
| 132 |
$key_dismiss . '_nonce' |
| 133 |
); |
| 134 |
|
| 135 |
?> |
| 136 |
<div class="<?php echo esc_attr($class); ?> is-dismissible"> |
| 137 |
<p><?php echo $text; // safe if you control it |
| 138 |
?></p> |
| 139 |
<a href="<?php echo esc_url($url); ?>"><button type="button" class="notice-dismiss"></button></a> |
| 140 |
</div> |
| 141 |
<?php |
| 142 |
}); |
| 143 |
|
| 144 |
// Handle dismiss |
| 145 |
add_action('admin_init', function () use ($key_dismiss) { |
| 146 |
|
| 147 |
if (!isset($_GET[$key_dismiss])) { |
| 148 |
return; |
| 149 |
} |
| 150 |
|
| 151 |
if (!isset($_GET['_wpnonce']) || !wp_verify_nonce($_GET['_wpnonce'], $key_dismiss . '_nonce')) { |
| 152 |
return; |
| 153 |
} |
| 154 |
|
| 155 |
$user_id = get_current_user_id(); |
| 156 |
|
| 157 |
update_user_meta($user_id, $key_dismiss, 1); |
| 158 |
|
| 159 |
wp_redirect(remove_query_arg([$key_dismiss, '_wpnonce'])); |
| 160 |
exit; |
| 161 |
}); |
| 162 |
|
| 163 |
return true; |
| 164 |
} |
| 165 |
|