| @@ -14,10 +14,10 @@ | ||
| 14 | 14 | * |
| 15 | 15 | * @wordpress-plugin |
| 16 | 16 | * Plugin Name: WP Directory Kit |
| 17 | 17 | * Plugin URI: https://wpdirectorykit.com/plugins/wpdirectorykit.html |
| 18 | - * Description: Build your Directory portal, demos for Real Estate Agency and Car Dealership included | |
| 19 | - * Version: 1.3.8 | |
| 18 | + * Description: Build your Directory portal, demos for Real Estate Agencies and Car Dealership included | |
| 19 | + * Version: 1.5.9 | |
| 20 | 20 | * Requires PHP: 7.0 |
| 21 | 21 | * Author: wpdirectorykit.com |
| 22 | 22 | * Author URI: https://wpdirectorykit.com |
| 23 | 23 | * License: GPL-2.0+ |
| @@ -24,16 +24,18 @@ | ||
| 24 | 24 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 25 | 25 | * Text Domain: wpdirectorykit |
| 26 | 26 | * Domain Path: /languages |
| 27 | 27 | * |
| 28 | - * Elementor tested up to: 3.22.2 | |
| 29 | - * Elementor Pro tested up to: 3.23.2 | |
| 28 | + * Elementor tested up to: 4.2.1 | |
| 29 | + * Elementor Pro tested up to: 4.3.1 | |
| 30 | 30 | * |
| 31 | + * Copyright (C) SWIT Sandi Winter IT. | |
| 32 | + * | |
| 31 | 33 | */ |
| 32 | 34 | |
| 33 | 35 | // If this file is called directly, abort. |
| 34 | -if ( ! defined( 'WPINC' ) ) { | |
| 35 | - die; | |
| 36 | +if (! defined('WPINC')) { | |
| 37 | + die; | |
| 36 | 38 | } |
| 37 | 39 | |
| 38 | 40 | /** |
| 39 | 41 | * Currently plugin version. |
| @@ -39,20 +41,21 @@ | ||
| 39 | 41 | * Currently plugin version. |
| 40 | 42 | * Start at version 1.0.0 and use SemVer - https://semver.org |
| 41 | 43 | * Rename this for your plugin and update it as you release new versions. |
| 42 | 44 | */ |
| 43 | -define( 'WPDIRECTORYKIT_VERSION', '1.3.8' ); | |
| 44 | -define( 'WPDIRECTORYKIT_NAME', 'wdk' ); | |
| 45 | -define( 'WPDIRECTORYKIT_PATH', plugin_dir_path( __FILE__ ) ); | |
| 46 | -define( 'WPDIRECTORYKIT_URL', plugin_dir_url( __FILE__ ) ); | |
| 45 | +define('WPDIRECTORYKIT_VERSION', '1.5.9'); | |
| 46 | +define('WPDIRECTORYKIT_NAME', 'wdk'); | |
| 47 | +define('WPDIRECTORYKIT_PATH', plugin_dir_path(__FILE__)); | |
| 48 | +define('WPDIRECTORYKIT_URL', plugin_dir_url(__FILE__)); | |
| 47 | 49 | |
| 48 | 50 | /** |
| 49 | 51 | * The code that runs during plugin activation. |
| 50 | 52 | * This action is documented in includes/class-wpdirectorykit-activator.php |
| 51 | 53 | */ |
| 52 | -function activate_wpdirectorykit() { | |
| 53 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpdirectorykit-activator.php'; | |
| 54 | - Wpdirectorykit_Activator::activate(); | |
| 54 | +function activate_wpdirectorykit() | |
| 55 | +{ | |
| 56 | + require_once plugin_dir_path(__FILE__) . 'includes/class-wpdirectorykit-activator.php'; | |
| 57 | + Wpdirectorykit_Activator::activate(); | |
| 55 | 58 | } |
| 56 | 59 | |
| 57 | 60 | /** |
| 58 | 61 | * The code that runs during plugin deactivation. |
| @@ -57,25 +60,25 @@ | ||
| 57 | 60 | /** |
| 58 | 61 | * The code that runs during plugin deactivation. |
| 59 | 62 | * This action is documented in includes/class-wpdirectorykit-deactivator.php |
| 60 | 63 | */ |
| 61 | -function deactivate_wpdirectorykit() { | |
| 62 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wpdirectorykit-deactivator.php'; | |
| 63 | - Wpdirectorykit_Deactivator::deactivate(); | |
| 64 | +function deactivate_wpdirectorykit() | |
| 65 | +{ | |
| 66 | + require_once plugin_dir_path(__FILE__) . 'includes/class-wpdirectorykit-deactivator.php'; | |
| 67 | + Wpdirectorykit_Deactivator::deactivate(); | |
| 64 | 68 | } |
| 65 | 69 | |
| 66 | -register_activation_hook( __FILE__, 'activate_wpdirectorykit' ); | |
| 67 | -register_deactivation_hook( __FILE__, 'deactivate_wpdirectorykit' ); | |
| 70 | +register_activation_hook(__FILE__, 'activate_wpdirectorykit'); | |
| 71 | +register_deactivation_hook(__FILE__, 'deactivate_wpdirectorykit'); | |
| 68 | 72 | |
| 69 | 73 | /** |
| 70 | 74 | * The core plugin class that is used to define internationalization, |
| 71 | 75 | * admin-specific hooks, and public-facing site hooks. |
| 72 | 76 | */ |
| 73 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wpdirectorykit.php'; | |
| 77 | +require plugin_dir_path(__FILE__) . 'includes/class-wpdirectorykit.php'; | |
| 74 | 78 | |
| 75 | 79 | |
| 76 | -if(file_exists(WPDIRECTORYKIT_PATH . 'premium_functions.php') && !defined('WDK_FS_DISABLE')) | |
| 77 | -{ | |
| 80 | +if (file_exists(WPDIRECTORYKIT_PATH . 'premium_functions.php') && !defined('WDK_FS_DISABLE')) { | |
| 78 | 81 | require_once WPDIRECTORYKIT_PATH . 'premium_functions.php'; |
| 79 | 82 | } |
| 80 | 83 | |
| 81 | 84 | /** |
| @@ -86,17 +89,17 @@ | ||
| 86 | 89 | * not affect the page life cycle. |
| 87 | 90 | * |
| 88 | 91 | * @since 1.0.0 |
| 89 | 92 | */ |
| 90 | -function run_wpdirectorykit() { | |
| 93 | +function run_wpdirectorykit() | |
| 94 | +{ | |
| 91 | 95 | |
| 92 | - $plugin = new Wpdirectorykit(); | |
| 93 | - $plugin->run(); | |
| 94 | - | |
| 96 | + $plugin = new Wpdirectorykit(); | |
| 97 | + $plugin->run(); | |
| 95 | 98 | } |
| 96 | 99 | run_wpdirectorykit(); |
| 97 | 100 | |
| 98 | - | |
| 101 | + | |
| 99 | 102 | /* |
| 100 | 103 | * Add admin notify |
| 101 | 104 | * @param (string) $key unique key of notify, prefix included related plugin |
| 102 | 105 | * @param (string) $text test of message |
| @@ -103,35 +106,59 @@ | ||
| 103 | 106 | * @param (function) $callback_filter custom function should be return true if not need show |
| 104 | 107 | * @param (string) $class notify alert class, by default 'notice notice-error' |
| 105 | 108 | * @return boolen true |
| 106 | 109 | */ |
| 107 | -function wdk_notify_admin ($key = '', $text = 'Custom Text of message', $callback_filter = '', $class = 'notice notice-error') { | |
| 108 | - $key = 'wdk_notify_'.$key; | |
| 109 | - $key_diss = $key.'_dissmiss'; | |
| 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'; | |
| 110 | 114 | |
| 111 | - $wdk_notinstalled_admin_notice__error = function () use ($key_diss, $text, $class, $callback_filter) { | |
| 112 | - global $wpdb; | |
| 115 | + add_action('admin_notices', function () use ($key_dismiss, $text, $class, $callback_filter) { | |
| 116 | + | |
| 113 | 117 | $user_id = get_current_user_id(); |
| 114 | - if (!get_user_meta($user_id, $key_diss)) { | |
| 115 | - if(!empty($callback_filter)) if($callback_filter()) return false; | |
| 116 | 118 | |
| 117 | - $message = ''; | |
| 118 | - $message .= $text; | |
| 119 | - printf('<div class="%1$s" style="position:relative;"><p>%2$s</p><a href="?'.$key_diss.'"><button type="button" class="notice-dismiss"></button></a></div>', esc_html($class), ($message)); // WPCS: XSS ok, sanitization ok. | |
| 119 | + // Already dismissed | |
| 120 | + if (get_user_meta($user_id, $key_dismiss, true)) { | |
| 121 | + return; | |
| 120 | 122 | } |
| 121 | - }; | |
| 122 | 123 | |
| 123 | - add_action('admin_notices', function () use ($wdk_notinstalled_admin_notice__error) { | |
| 124 | - $wdk_notinstalled_admin_notice__error(); | |
| 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 esc_html($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 | |
| 125 | 142 | }); |
| 126 | 143 | |
| 127 | - $wdk_notinstalled_admin_notice__error_dismissed = function () use ($key_diss) { | |
| 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 | + | |
| 128 | 155 | $user_id = get_current_user_id(); |
| 129 | - if (isset($_GET[$key_diss])) | |
| 130 | - add_user_meta($user_id, $key_diss, 'true', true); | |
| 131 | - }; | |
| 132 | - add_action('admin_init', function () use ($wdk_notinstalled_admin_notice__error_dismissed) { | |
| 133 | - $wdk_notinstalled_admin_notice__error_dismissed(); | |
| 156 | + | |
| 157 | + update_user_meta($user_id, $key_dismiss, 1); | |
| 158 | + | |
| 159 | + wp_redirect(remove_query_arg([$key_dismiss, '_wpnonce'])); | |
| 160 | + exit; | |
| 134 | 161 | }); |
| 135 | 162 | |
| 136 | 163 | return true; |
| 137 | 164 | } |