| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPCasa |
| 4 |
* |
| 5 |
* @package WPCasa |
| 6 |
* @author WPSight |
| 7 |
* @copyright 2026 Kybernetik Services LLC |
| 8 |
* @license GPL-2.0-or-later |
| 9 |
* |
| 10 |
* @wordpress-plugin |
| 11 |
* Plugin Name: WPCasa - Real Estate for WordPress |
| 12 |
* Plugin URI: https://wordpress.org/plugins/wpcasa/ |
| 13 |
* Description: Flexible WordPress plugin to create professional real estate websites and manage property listings with ease. |
| 14 |
* Version: 1.5.5 |
| 15 |
* Requires at least: 6.2 |
| 16 |
* Requires PHP: 7.2 |
| 17 |
* Author: WPSight |
| 18 |
* Author URI: https://wpcasa.com |
| 19 |
* Text Domain: wpcasa |
| 20 |
* License: GPL v2 or later |
| 21 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 22 |
*/ |
| 23 |
|
| 24 |
// Exit if accessed directly |
| 25 |
if ( ! defined( 'ABSPATH' ) ) { |
| 26 |
exit; |
| 27 |
} |
| 28 |
|
| 29 |
require __DIR__ . '/vendor/autoload.php'; |
| 30 |
|
| 31 |
/** |
| 32 |
* WPSight_Framework class |
| 33 |
*/ |
| 34 |
class WPSight_Framework { |
| 35 |
|
| 36 |
// Variables |
| 37 |
public $admin; |
| 38 |
public $post_types; |
| 39 |
public $agents; |
| 40 |
public $general; |
| 41 |
public $helpers; |
| 42 |
public $search; |
| 43 |
public $meta_boxes; |
| 44 |
|
| 45 |
// Add-ons |
| 46 |
public $admin_map_ui; |
| 47 |
public $listings_map; |
| 48 |
public $ninja_forms; |
| 49 |
public $advanced_search; |
| 50 |
public $contact_form_7; |
| 51 |
public $listing_pdf; |
| 52 |
public $currency_converter; |
| 53 |
public $dashboard; |
| 54 |
public $expire_listings; |
| 55 |
public $favorites; |
| 56 |
public $featured_listings; |
| 57 |
public $gravityforms; |
| 58 |
public $legacy; |
| 59 |
public $list_agents; |
| 60 |
public $listing_labels; |
| 61 |
public $polylang; |
| 62 |
public $pricing_tables; |
| 63 |
public $energy_efficiency; |
| 64 |
public $mortgage_calculator; |
| 65 |
public $app_connector; |
| 66 |
public $elementor; |
| 67 |
public $blocks; |
| 68 |
|
| 69 |
/** |
| 70 |
* Constructor - get the plugin hooked in and ready |
| 71 |
*/ |
| 72 |
public function __construct() { |
| 73 |
|
| 74 |
// Define constants |
| 75 |
|
| 76 |
if ( ! defined( 'WPSIGHT_NAME' ) ) |
| 77 |
define( 'WPSIGHT_NAME', 'WPCasa' ); |
| 78 |
|
| 79 |
if ( ! defined( 'WPSIGHT_DOMAIN' ) ) |
| 80 |
define( 'WPSIGHT_DOMAIN', 'wpcasa' ); |
| 81 |
|
| 82 |
if ( ! defined( 'WPSIGHT_SHOP_URL' ) ) |
| 83 |
define( 'WPSIGHT_SHOP_URL', 'https://wpcasa.com' ); |
| 84 |
|
| 85 |
if ( ! defined( 'WPSIGHT_AUTHOR' ) ) |
| 86 |
define( 'WPSIGHT_AUTHOR', 'WPSight' ); |
| 87 |
|
| 88 |
if( ! function_exists( 'get_plugin_data' ) ) { |
| 89 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 90 |
} |
| 91 |
$plugin_data = get_plugin_data( __FILE__, false, false ); |
| 92 |
|
| 93 |
define( 'WPSIGHT_VERSION', $plugin_data[ 'Version' ] ); |
| 94 |
define( 'WPSIGHT_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
| 95 |
define( 'WPSIGHT_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); |
| 96 |
|
| 97 |
// Cookie constants |
| 98 |
|
| 99 |
define( 'WPSIGHT_COOKIE_SEARCH_QUERY', WPSIGHT_DOMAIN . '_search_query' ); |
| 100 |
define( 'WPSIGHT_COOKIE_SEARCH_MAP', WPSIGHT_DOMAIN . '_search_map' ); |
| 101 |
|
| 102 |
// Include functions |
| 103 |
|
| 104 |
include( WPSIGHT_PLUGIN_DIR . '/functions/wpsight-general.php' ); |
| 105 |
include( WPSIGHT_PLUGIN_DIR . '/functions/wpsight-template.php' ); |
| 106 |
include( WPSIGHT_PLUGIN_DIR . '/functions/wpsight-listings.php' ); |
| 107 |
include( WPSIGHT_PLUGIN_DIR . '/functions/wpsight-agents.php' ); |
| 108 |
include( WPSIGHT_PLUGIN_DIR . '/functions/wpsight-search.php' ); |
| 109 |
include( WPSIGHT_PLUGIN_DIR . '/functions/wpsight-helpers.php' ); |
| 110 |
include( WPSIGHT_PLUGIN_DIR . '/functions/wpsight-admin.php' ); |
| 111 |
include( WPSIGHT_PLUGIN_DIR . '/functions/wpsight-meta-boxes.php' ); |
| 112 |
|
| 113 |
// Include classes |
| 114 |
|
| 115 |
include( WPSIGHT_PLUGIN_DIR . '/includes/class-wpsight-post-types.php' ); |
| 116 |
include( WPSIGHT_PLUGIN_DIR . '/includes/class-wpsight-api.php' ); |
| 117 |
include( WPSIGHT_PLUGIN_DIR . '/includes/class-wpsight-geocode.php' ); |
| 118 |
include( WPSIGHT_PLUGIN_DIR . '/includes/class-wpsight-listings.php' ); |
| 119 |
include( WPSIGHT_PLUGIN_DIR . '/includes/class-wpsight-agents.php' ); |
| 120 |
include( WPSIGHT_PLUGIN_DIR . '/includes/class-wpsight-general.php' ); |
| 121 |
include( WPSIGHT_PLUGIN_DIR . '/includes/class-wpsight-helpers.php' ); |
| 122 |
include( WPSIGHT_PLUGIN_DIR . '/includes/class-wpsight-search.php' ); |
| 123 |
include( WPSIGHT_PLUGIN_DIR . '/includes/class-wpsight-meta-boxes.php' ); |
| 124 |
include( WPSIGHT_PLUGIN_DIR . '/includes/class-wpsight-template.php' ); |
| 125 |
|
| 126 |
// Include shortcodes |
| 127 |
include( WPSIGHT_PLUGIN_DIR . '/includes/shortcodes/class-wpsight-shortcodes.php' ); |
| 128 |
|
| 129 |
// Include admin class |
| 130 |
include( WPSIGHT_PLUGIN_DIR . '/includes/admin/class-wpsight-admin.php' ); |
| 131 |
|
| 132 |
require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
| 133 |
|
| 134 |
// TODO: delete till wpcasa 2.0 |
| 135 |
if ( is_plugin_active( 'wpcasa-admin-map-ui/wpcasa-admin-map-ui.php' ) ) { |
| 136 |
deactivate_plugins( '/wpcasa-admin-map-ui/wpcasa-admin-map-ui.php' ); |
| 137 |
} |
| 138 |
|
| 139 |
// TODO: delete check till wpcasa 2.0 |
| 140 |
if ( ! is_plugin_active( 'wpcasa-admin-map-ui/wpcasa-admin-map-ui.php' ) ) { |
| 141 |
if ( ! class_exists( 'WPSight_Admin_Map_UI' ) ) { |
| 142 |
include_once( WPSIGHT_PLUGIN_DIR . '/includes/admin-map-ui/class-wpsight-admin-map-ui.php' ); |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
// TODO: delete till wpcasa 2.0 |
| 147 |
if ( is_plugin_active( 'wpcasa-listings-map/wpcasa-listings-map.php' ) ) { |
| 148 |
deactivate_plugins( '/wpcasa-listings-map/wpcasa-listings-map.php' ); |
| 149 |
} |
| 150 |
|
| 151 |
// TODO: delete check till wpcasa 2.0 |
| 152 |
if ( ! is_plugin_active( 'wpcasa-listings-map/wpcasa-listings-map.php' ) ) { |
| 153 |
if ( ! class_exists( 'WPSight_Listings_Map' ) ) { |
| 154 |
include( WPSIGHT_PLUGIN_DIR . '/includes/listings-map/class-wpsight-listings-map.php' ); |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
// Only instantiate admin class when in admin area |
| 159 |
if ( is_admin() ) |
| 160 |
$this->admin = new WPSight_Admin(); |
| 161 |
|
| 162 |
// Init classes |
| 163 |
$this->post_types = new WPSight_Post_Type_Listing(); |
| 164 |
$this->agents = new WPSight_Agents(); |
| 165 |
$this->general = new WPSight_General(); |
| 166 |
$this->helpers = new WPSight_Helpers(); |
| 167 |
$this->search = new WPSight_Search(); |
| 168 |
$this->meta_boxes = new WPSight_Meta_Boxes(); |
| 169 |
|
| 170 |
// Activation |
| 171 |
|
| 172 |
register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), [ $this->post_types, 'register_post_type_listing' ], 10 ); |
| 173 |
register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( 'WPSight_Agents', 'init_user_roles' ), 10 ); |
| 174 |
register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), function() { include_once('includes/class-wpsight-install.php'); }, 10 ); |
| 175 |
register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), 'flush_rewrite_rules', 15 ); |
| 176 |
register_activation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), [ $this, 'activation' ] ); |
| 177 |
register_deactivation_hook( basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ), array( 'WPSight_Agents', 'remove_user_roles' ) ); |
| 178 |
|
| 179 |
// Actions |
| 180 |
|
| 181 |
add_action( 'switch_theme', [ $this->post_types, 'register_post_type_listing' ], 10 ); |
| 182 |
add_action( 'switch_theme', 'flush_rewrite_rules', 15 ); |
| 183 |
add_action( 'wp_enqueue_scripts', [ $this, 'frontend_scripts' ] ); |
| 184 |
|
| 185 |
// Init action for add-ons to hook in |
| 186 |
do_action_ref_array( 'wpsight_init', [ &$this ] ); |
| 187 |
|
| 188 |
} |
| 189 |
|
| 190 |
/** |
| 191 |
* setChildClass() |
| 192 |
* |
| 193 |
* Set up the child plugin class |
| 194 |
* |
| 195 |
* @param $name |
| 196 |
* @param $addon_object |
| 197 |
* |
| 198 |
* @since 1.2.13 |
| 199 |
*/ |
| 200 |
|
| 201 |
public function setChildClass( $name, $addon_object ) { |
| 202 |
$this->{$name} = $addon_object; |
| 203 |
} |
| 204 |
|
| 205 |
/** |
| 206 |
* frontend_scripts() |
| 207 |
* |
| 208 |
* Register and enqueue scripts and css. |
| 209 |
* |
| 210 |
* @uses wp_enqueue_script() |
| 211 |
* @uses wp_localize_script() |
| 212 |
* @uses wp_enqueue_style() |
| 213 |
* @uses wpsight_get_option() |
| 214 |
* |
| 215 |
* @since 1.0.0 |
| 216 |
*/ |
| 217 |
public function frontend_scripts() { |
| 218 |
// Enqueue jQuery |
| 219 |
wp_enqueue_script( 'jquery' ); |
| 220 |
|
| 221 |
// Script debugging? |
| 222 |
$suffix = SCRIPT_DEBUG ? '' : '.min'; |
| 223 |
|
| 224 |
|
| 225 |
wp_enqueue_script( 'jquery-tiptip', WPSIGHT_PLUGIN_URL . '/assets/js/jquery.tipTip' . $suffix . '.js', [ 'jquery' ], '1.3', true ); |
| 226 |
wp_enqueue_script( 'jquery-cookie', WPSIGHT_PLUGIN_URL . '/assets/js/jquery.cookie.js', [ 'jquery' ], '1.4.1', true ); |
| 227 |
wp_enqueue_script( 'wpsight-listings-search', WPSIGHT_PLUGIN_URL . '/assets/js/wpsight-listings-search.js', [ 'jquery' ], WPSIGHT_VERSION, true ); |
| 228 |
|
| 229 |
// Localize scripts |
| 230 |
$data = [ |
| 231 |
'cookie_path' => COOKIEPATH, |
| 232 |
'cookie_search_query' => WPSIGHT_COOKIE_SEARCH_QUERY |
| 233 |
]; |
| 234 |
|
| 235 |
wp_localize_script( 'wpsight-listings-search', 'wpsight_localize', $data ); |
| 236 |
|
| 237 |
// Register the Google Maps API loader when a key is available. |
| 238 |
$api_key = wpsight_get_option( 'google_maps_api_key' ); |
| 239 |
|
| 240 |
if ( ! empty( $api_key ) && true === apply_filters( 'wpsight_google_maps', true ) ) { |
| 241 |
$api_url = add_query_arg( |
| 242 |
array( |
| 243 |
'key' => $api_key, |
| 244 |
'loading' => 'async', |
| 245 |
'callback' => 'wpsightGoogleMapsApiReady', |
| 246 |
), |
| 247 |
'//maps.googleapis.com/maps/api/js' |
| 248 |
); |
| 249 |
|
| 250 |
wp_register_script( |
| 251 |
'wpsight-google-maps-api-loader', |
| 252 |
WPSIGHT_PLUGIN_URL . '/assets/js/wpsight-google-maps-api-loader' . $suffix . '.js', |
| 253 |
array(), |
| 254 |
WPSIGHT_VERSION, |
| 255 |
array( 'in_footer' => false ) |
| 256 |
); |
| 257 |
|
| 258 |
wp_localize_script( |
| 259 |
'wpsight-google-maps-api-loader', |
| 260 |
'wpsightGoogleMapsApiLoader', |
| 261 |
array( |
| 262 |
'googleApiUrl' => apply_filters( 'wpsight_google_maps_endpoint', $api_url, $api_key ), |
| 263 |
) |
| 264 |
); |
| 265 |
|
| 266 |
wp_enqueue_script( 'wpsight-google-maps-api-loader' ); |
| 267 |
} |
| 268 |
|
| 269 |
if( true == apply_filters('wpsight_css', true) && wpsight_get_option('listings_css' ) ) { |
| 270 |
|
| 271 |
//if ( is_singular( 'listing' ) ) { |
| 272 |
wp_enqueue_style( 'wpsight', WPSIGHT_PLUGIN_URL . '/assets/css/wpsight' . $suffix . '.css', '', WPSIGHT_VERSION); |
| 273 |
|
| 274 |
if ( is_rtl() ) |
| 275 |
wp_enqueue_style( 'wpsight-rtl', WPSIGHT_PLUGIN_URL . '/assets/css/wpsight-rtl' . $suffix . '.css', '', WPSIGHT_VERSION ); |
| 276 |
//} |
| 277 |
|
| 278 |
} |
| 279 |
|
| 280 |
} |
| 281 |
|
| 282 |
/** |
| 283 |
* activation() |
| 284 |
* |
| 285 |
* Callback for register_activation_hook |
| 286 |
* to create a default listings page with |
| 287 |
* the [wpsight_listings] shortcode and |
| 288 |
* to create some default options to be |
| 289 |
* used by this plugin. |
| 290 |
* |
| 291 |
* @uses wpsight_get_option() |
| 292 |
* @uses wp_insert_post() |
| 293 |
* @uses wpsight_add_option() |
| 294 |
* |
| 295 |
* @since 1.0.0 |
| 296 |
*/ |
| 297 |
|
| 298 |
public function activation() { |
| 299 |
|
| 300 |
// Create listings page |
| 301 |
|
| 302 |
$page_data = [ |
| 303 |
'post_title' => _x( 'Listings', 'listings page title', 'wpcasa' ), |
| 304 |
'post_content' => '[wpsight_listings]', |
| 305 |
'post_type' => 'page', |
| 306 |
'post_status' => 'publish', |
| 307 |
'comment_status' => 'closed', |
| 308 |
'ping_status' => 'closed' |
| 309 |
]; |
| 310 |
|
| 311 |
$page_id = ! wpsight_get_option( 'listings_page' ) ? wp_insert_post( $page_data ) : false; |
| 312 |
|
| 313 |
// Add some default options |
| 314 |
|
| 315 |
$options = [ |
| 316 |
'listings_page' => $page_id, |
| 317 |
'listing_id' => __( 'ID-', 'wpcasa' ), |
| 318 |
'measurement_unit' => 'm2', |
| 319 |
'currency' => 'usd', |
| 320 |
'currency_symbol' => 'before', |
| 321 |
'currency_separator' => 'comma', |
| 322 |
'date_format' => get_option( 'date_format' ), |
| 323 |
'listings_css' => '1', |
| 324 |
'review_notice_timestamp' => current_time( 'timestamp' ), |
| 325 |
]; |
| 326 |
|
| 327 |
// Add default standard features |
| 328 |
foreach ( wpsight_details() as $option => $value ) |
| 329 |
$options[ $option ] = [ 'label' => $value['label'], 'unit' => $value['unit'] ]; |
| 330 |
|
| 331 |
// Add default rental periods |
| 332 |
foreach ( wpsight_rental_periods() as $option => $value ) |
| 333 |
$options[ $option ] = $value; |
| 334 |
|
| 335 |
foreach( $options as $option => $value ) { |
| 336 |
|
| 337 |
if( wpsight_get_option( $option ) ) |
| 338 |
continue; |
| 339 |
|
| 340 |
wpsight_add_option( $option, $value ); |
| 341 |
|
| 342 |
} |
| 343 |
|
| 344 |
} |
| 345 |
} |
| 346 |
|
| 347 |
/** |
| 348 |
* wpsight() |
| 349 |
* |
| 350 |
* The main function responsible for returning the one true wpsight Instance to functions everywhere. |
| 351 |
* Use this function like you would use a global variable, except without needing to declare the global. |
| 352 |
* |
| 353 |
* Example: <?php $wpsight = wpsight(); ?> |
| 354 |
* |
| 355 |
* @return object|bool $wpsight |
| 356 |
*/ |
| 357 |
function wpsight() { |
| 358 |
global $wpsight; |
| 359 |
|
| 360 |
// Don't activate plugin add-ons if theme still active |
| 361 |
|
| 362 |
if( wp_get_theme()->template == 'wpcasa' ) { |
| 363 |
remove_all_actions( 'wpsight_init' ); |
| 364 |
return false; |
| 365 |
} |
| 366 |
|
| 367 |
if ( ! isset( $wpsight ) ) |
| 368 |
$wpsight = new WPSight_Framework(); |
| 369 |
|
| 370 |
return $wpsight; |
| 371 |
} |
| 372 |
wpsight(); |
| 373 |
|
| 374 |
/** |
| 375 |
* wpsight_admin_notice_wpcasa() |
| 376 |
* |
| 377 |
* Make sure users first deactivate |
| 378 |
* the old WPCasa theme version. |
| 379 |
* Display error message if it is |
| 380 |
* still activated. |
| 381 |
* |
| 382 |
* @uses wp_get_theme() |
| 383 |
* |
| 384 |
* @since 1.0.0 |
| 385 |
*/ |
| 386 |
function wpsight_admin_notice_wpcasa() { |
| 387 |
|
| 388 |
if( wp_get_theme()->template != 'wpcasa' ) |
| 389 |
return; |
| 390 |
|
| 391 |
$error_notice = '<div class="error"><p>' . __( 'Please make sure to <strong>deactivate the WPCasa theme</strong> in order to use the WPCasa plugin version. For more information about how to switch please <a href="http://docs.wpsight.com/article/switching-from-theme-version/" target="_blank">read our docs</a>.', 'wpcasa' ) . '</p></div>'; |
| 392 |
echo wp_kses( $error_notice, array( 'div' => array( 'class' => array() ), 'p' => array(), 'strong' => array(), 'a' => array( 'href' => array() ) ) ); |
| 393 |
} |
| 394 |
add_action( 'admin_notices', 'wpsight_admin_notice_wpcasa' ); |
| 395 |
|
| 396 |
/** |
| 397 |
* wpsight_admin_plugins_delete_notice() |
| 398 |
* |
| 399 |
* Make sure users awera |
| 400 |
* that WPCasa Listing Map and |
| 401 |
* WPCasa admin map ui plugins |
| 402 |
* can be deleted |
| 403 |
* |
| 404 |
* @since 1.2.0 |
| 405 |
*/ |
| 406 |
function wpsight_admin_plugins_delete_notice() { |
| 407 |
|
| 408 |
$admin_map_ui = WP_PLUGIN_DIR . '/wpcasa-admin-map-ui/wpcasa-admin-map-ui.php'; |
| 409 |
$listing_map = WP_PLUGIN_DIR . '/wpcasa-listings-map/wpcasa-listings-map.php'; |
| 410 |
|
| 411 |
$plugin_name = ''; |
| 412 |
$count = 1; |
| 413 |
|
| 414 |
//if( file_exists( $admin_map_ui ) ) { |
| 415 |
if( in_array( $admin_map_ui, apply_filters( 'active_plugins', get_option( 'active_plugins') ) ) ) { |
| 416 |
|
| 417 |
$plugin_name .= '<strong>WPCasa Admin Map UI</strong>'; |
| 418 |
|
| 419 |
} |
| 420 |
|
| 421 |
//if( file_exists( $listing_map ) ) { |
| 422 |
if( in_array( $listing_map, apply_filters( 'active_plugins', get_option( 'active_plugins') ) ) ) { |
| 423 |
|
| 424 |
if( !empty( $plugin_name ) ) { |
| 425 |
|
| 426 |
$plugin_name .= ' ' . __( 'and' , 'wpcasa' ) . ' '; |
| 427 |
|
| 428 |
$count = 2; |
| 429 |
|
| 430 |
} |
| 431 |
|
| 432 |
$plugin_name .= '<strong>WPCasa Listings Map</strong>'; |
| 433 |
|
| 434 |
} |
| 435 |
|
| 436 |
if ( ! empty( $plugin_name ) ) { |
| 437 |
$message = sprintf( |
| 438 |
// Translators: %s is plugin name |
| 439 |
_n( |
| 440 |
'%s has been discontinued. The Functionality of the plugin has been integrated in WPCasa as of 1.2.0.</br>Feel free to remove the plugin.', |
| 441 |
'%s has been discontinued. The Functionality of both plugins has been integrated in WPCasa as of 1.2.0.</br>Feel free to remove both of those plugins.', |
| 442 |
$count, 'wpcasa' ), |
| 443 |
$plugin_name ); |
| 444 |
|
| 445 |
echo wp_kses( '<div class="notice notice-warning my-dismiss-notice is-dismissible"><p>' . $message . '</p></div>', array( 'div' => array( 'class' => array() ), 'p' => array() ) ); |
| 446 |
|
| 447 |
} |
| 448 |
|
| 449 |
} |
| 450 |
add_action( 'admin_notices', 'wpsight_admin_plugins_delete_notice' ); |
| 451 |
|
| 452 |
/** |
| 453 |
* |
| 454 |
* Redirect after single wpcasa activatation |
| 455 |
* Prevent multiple activation redirect |
| 456 |
* |
| 457 |
* @since 1.2.0 |
| 458 |
*/ |
| 459 |
function wpcasa_plugin_activate() { |
| 460 |
add_option('wpcasa_do_activation_redirect', true); |
| 461 |
} |
| 462 |
register_activation_hook(__FILE__, 'wpcasa_plugin_activate'); |
| 463 |
|
| 464 |
function wpcasa_activation_redirect() { |
| 465 |
if (get_option('wpcasa_do_activation_redirect', false)) { |
| 466 |
delete_option('wpcasa_do_activation_redirect'); |
| 467 |
if ( !isset($_GET['activate-multi']) ) { |
| 468 |
wp_safe_redirect( admin_url( 'index.php?page=wpsight-settings' )); |
| 469 |
exit(); |
| 470 |
} |
| 471 |
} |
| 472 |
} |
| 473 |
add_action( 'admin_init', 'wpcasa_activation_redirect' ); |
| 474 |
|
| 475 |
/** |
| 476 |
* Adds plugin upgrade notification |
| 477 |
* |
| 478 |
* @since 1.2.11 |
| 479 |
*/ |
| 480 |
function wpcasa_plugin_update_message( $data, $response ) { |
| 481 |
|
| 482 |
if( isset( $data[ 'upgrade_notice'] ) ) { |
| 483 |
|
| 484 |
$upgrade_notice = str_replace('<p>', '<span style="margin-top: 5px">', wpautop( $data['upgrade_notice'] ) ); |
| 485 |
$upgrade_notice = str_replace('</p>', '</span><br>', $upgrade_notice ); |
| 486 |
|
| 487 |
printf( |
| 488 |
'</p><p style="background-color: #d63638; padding: 10px; color: #f9f9f9; margin-top: 10px"><span style="margin-left: -25px"><strong>%s:</strong></span><br>%s', |
| 489 |
esc_html__( 'Important Upgrade Notice', 'wpcasa'), |
| 490 |
wp_kses_post( $upgrade_notice ) |
| 491 |
); |
| 492 |
} |
| 493 |
|
| 494 |
} |
| 495 |
add_action( 'in_plugin_update_message-wpcasa/wpcasa.php', 'wpcasa_plugin_update_message', 10, 2 ); |
| 496 |
|
| 497 |
function wpcasa_settings_value_change() { |
| 498 |
$wpcasa_settings = get_option('wpcasa'); |
| 499 |
$thousand_separator = $wpcasa_settings['currency_separator'] ?? ''; |
| 500 |
|
| 501 |
if ( ( 'comma' === $thousand_separator ) || ( 'dot' === $thousand_separator ) ) { |
| 502 |
switch ( $thousand_separator ) { |
| 503 |
case 'comma': |
| 504 |
$wpcasa_settings['currency_separator'] = ','; |
| 505 |
break; |
| 506 |
case 'dot': |
| 507 |
$wpcasa_settings['currency_separator'] = '.'; |
| 508 |
break; |
| 509 |
} |
| 510 |
update_option( 'wpcasa', $wpcasa_settings ); |
| 511 |
} |
| 512 |
} |
| 513 |
add_action( 'admin_init', 'wpcasa_settings_value_change' ); |
| 514 |
|