$data){ if(!empty($data['settings'])){ $js_settings[$slug] = $data['settings']; } } wp_localize_script('formlayer-pro-admin', 'formlayer_pro', [ 'nonce' => wp_create_nonce('formlayer_pro_admin_nonce'), 'ajax_url' => admin_url('admin-ajax.php'), 'admin_page_url' => admin_url('admin.php?page=formlayer'), 'settings' => $js_settings, 'html_templates' => \FormLayerPro\Templates::js_templates() ]); } static function formlayer_pro_free_version_nag(){ if(!defined('FORMLAYER_VERSION')){ return; } $dismissed_free = (int) get_option('formlayer_version_free_nag'); $dismissed_pro = (int) get_option('formlayer_version_pro_nag'); // Checking if time has passed since the dismiss. if(!empty($dismissed_free) && time() < $dismissed_pro && !empty($dismissed_pro) && time() < $dismissed_pro){ return; } $showing_error = false; if(version_compare(FORMLAYER_VERSION, FORMLAYER_PRO_VERSION) > 0 && (empty($dismissed_pro) || time() > $dismissed_pro)){ $showing_error = true; echo '

'.esc_html__('You are using an older version of FormLayer Pro. We recommend updating to the latest version to ensure seamless and uninterrupted use of the application.', 'formlayer-pro').'

'; }elseif(version_compare(FORMLAYER_VERSION, FORMLAYER_PRO_VERSION) < 0 && (empty($dismissed_free) || time() > $dismissed_free)){ $showing_error = true; echo '

'.esc_html__('You are using an older version of FormLayer. We recommend updating to the latest free version to ensure smooth and uninterrupted use of the application.', 'formlayer-pro').'

'; } if(!empty($showing_error)){ wp_register_script('formlayer-pro-version-notice', '', array('jquery'), FORMLAYER_PRO_VERSION, true ); wp_enqueue_script('formlayer-pro-version-notice'); wp_add_inline_script('formlayer-pro-version-notice', ' function formlayer_pro_dismiss_notice(e){ e.preventDefault(); let target = jQuery(e.target); if(!target.hasClass("notice-dismiss")){ return; } let jEle = target.closest("#formlayer-pro-version-notice"), type = jEle.data("type"); jEle.slideUp(); jQuery.post("'.admin_url('admin-ajax.php').'", { security : "'.wp_create_nonce('formlayer_version_notice').'", action: "formlayer_pro_version_notice", type: type }, function(res){ if(!res["success"]){ alert(res["data"]); } }).fail(function(data){ alert("There seems to be some issue dismissing this alert"); }); }'); } } }