| 1 |
<?php |
| 2 |
/** |
| 3 |
* @version 1.0 |
| 4 |
* @package Booking Calendar |
| 5 |
* @subpackage Check News, Version |
| 6 |
* @category Functions |
| 7 |
* |
| 8 |
* @author wpdevelop |
| 9 |
* @link https://wpbookingcalendar.com/ |
| 10 |
* @email info@wpbookingcalendar.com |
| 11 |
* |
| 12 |
* @modified 2024-09-03 |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 16 |
|
| 17 |
|
| 18 |
// ===================================================================================================================== |
| 19 |
// == Check News, Version == |
| 20 |
// ===================================================================================================================== |
| 21 |
|
| 22 |
define ('OBC_CHECK_URL', 'https://wpbookingcalendar.com/'); |
| 23 |
|
| 24 |
|
| 25 |
function wpbc_old_ajax_check_bk_news( $sub_url = '' ){ |
| 26 |
|
| 27 |
$v=array(); |
| 28 |
if (class_exists('wpdev_bk_personal')) $v[] = 'wpdev_bk_personal'; |
| 29 |
if (class_exists('wpdev_bk_biz_s')) $v[] = 'wpdev_bk_biz_s'; |
| 30 |
if (class_exists('wpdev_bk_biz_m')) $v[] = 'wpdev_bk_biz_m'; |
| 31 |
if (class_exists('wpdev_bk_biz_l')) $v[] = 'wpdev_bk_biz_l'; |
| 32 |
if (class_exists('wpdev_bk_multiuser')) $v[] = 'wpdev_bk_multiuser'; |
| 33 |
|
| 34 |
$obc_settings = array(); |
| 35 |
$ver = get_bk_option('bk_version_data'); |
| 36 |
if ( $ver !== false ) { $obc_settings = array( 'subscription_key'=>wp_json_encode($ver) ); } |
| 37 |
|
| 38 |
$params = array( |
| 39 |
'action' => 'get_news', |
| 40 |
'subscription_email' => isset($obc_settings['subscription_email'])?$obc_settings['subscription_email']:false, |
| 41 |
'subscription_key' => isset($obc_settings['subscription_key'])?$obc_settings['subscription_key']:false, |
| 42 |
'bk' => array('bk_ver'=>WPDEV_BK_VERSION, 'bk_url'=>WPBC_PLUGIN_URL,'bk_dir'=>WPBC_PLUGIN_DIR, 'bk_clss'=>$v), |
| 43 |
'siteurl' => get_option('siteurl'), |
| 44 |
'siteip' => wpbc_get_server_ip(), // FixIn: 9.8.14.3. |
| 45 |
'admin_email' => get_option('admin_email') |
| 46 |
); |
| 47 |
|
| 48 |
$request = new WP_Http(); |
| 49 |
if (empty($sub_url)) $sub_url = 'info/'; |
| 50 |
$result = $request->request( OBC_CHECK_URL . $sub_url, array( |
| 51 |
'method' => 'POST', |
| 52 |
'timeout' => 15, |
| 53 |
'body' => $params |
| 54 |
)); |
| 55 |
|
| 56 |
if (!is_wp_error($result) && ($result['response']['code']=='200') && (true) ) { |
| 57 |
|
| 58 |
$string = ($result['body']); //$string = str_replace( "'", ''', $string ); |
| 59 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 60 |
echo $string; |
| 61 |
echo ' <script type="text/javascript"> '; |
| 62 |
echo ' jQuery("#ajax_bk_respond").after( jQuery("#ajax_bk_respond #bk_news_loaded") );'; |
| 63 |
echo ' jQuery("#bk_news_loaded").slideUp(1).slideDown(1500);'; |
| 64 |
echo ' </script> '; |
| 65 |
|
| 66 |
} else /**/ |
| 67 |
{ // Some error appear |
| 68 |
echo '<div id="bk_errror_loading">'; |
| 69 |
if ( is_wp_error( $result ) ) { |
| 70 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 71 |
echo $result->get_error_message(); |
| 72 |
} else { |
| 73 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 74 |
echo $result['response']['message']; |
| 75 |
} |
| 76 |
echo '</div>'; |
| 77 |
echo ' <script type="text/javascript"> '; |
| 78 |
echo ' document.getElementById("bk_news").style.display="none";'; |
| 79 |
echo ' jQuery("#ajax_bk_respond").after( jQuery("#ajax_bk_respond #bk_errror_loading") );'; |
| 80 |
echo ' jQuery("#bk_errror_loading").slideUp(1).slideDown(1500);'; |
| 81 |
echo ' jQuery("#bk_news_section").animate({opacity:1},3000).slideUp(1500);'; |
| 82 |
echo ' </script> '; |
| 83 |
} |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
/** |
| 89 |
* Check if user defined to not show up_news section. |
| 90 |
* |
| 91 |
*/ |
| 92 |
function wpbc_is_show_up_news(){ |
| 93 |
|
| 94 |
$is_show = get_bk_option( 'booking_wpdev_copyright_adminpanel' ); |
| 95 |
|
| 96 |
if ( ( 'Off' === $is_show ) && ( ! wpbc_is_this_demo() ) && ( class_exists( 'wpdev_bk_personal' ) ) ) { |
| 97 |
return false; |
| 98 |
} else { |
| 99 |
return true; |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
function wpbc_old_ajax_check_bk_version(){ |
| 105 |
$v=array(); |
| 106 |
if (class_exists('wpdev_bk_personal')) $v[] = 'wpdev_bk_personal'; |
| 107 |
if (class_exists('wpdev_bk_biz_s')) $v[] = 'wpdev_bk_biz_s'; |
| 108 |
if (class_exists('wpdev_bk_biz_m')) $v[] = 'wpdev_bk_biz_m'; |
| 109 |
if (class_exists('wpdev_bk_biz_l')) $v[] = 'wpdev_bk_biz_l'; |
| 110 |
if (class_exists('wpdev_bk_multiuser')) $v[] = 'wpdev_bk_multiuser'; |
| 111 |
|
| 112 |
$obc_settings = array(); |
| 113 |
$params = array( |
| 114 |
'action' => 'set_register', |
| 115 |
'order_number' => isset( $_POST['order_num'] ) ? sanitize_text_field( wp_unslash( $_POST['order_num'] ) ) : false, // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 116 |
'bk' => array( 'bk_ver' => WPDEV_BK_VERSION, |
| 117 |
'bk_url' => WPBC_PLUGIN_URL, |
| 118 |
'bk_dir' => WPBC_PLUGIN_DIR, |
| 119 |
'bk_clss' => $v, |
| 120 |
), |
| 121 |
'siteurl' => get_option( 'siteurl' ), |
| 122 |
'siteip' => wpbc_get_server_ip(), // FixIn: 9.8.14.3. |
| 123 |
'admin_email' => get_option( 'admin_email' ), |
| 124 |
); |
| 125 |
|
| 126 |
update_bk_option( 'bk_version_data', serialize( $params ) ); |
| 127 |
|
| 128 |
$request = new WP_Http(); |
| 129 |
$result = $request->request( OBC_CHECK_URL . 'register/', array( |
| 130 |
'method' => 'POST', |
| 131 |
'timeout' => 15, |
| 132 |
'body' => $params |
| 133 |
)); |
| 134 |
|
| 135 |
if ( ! is_wp_error($result) |
| 136 |
&& ( $result['response']['code']=='200' ) |
| 137 |
&& ( true ) ) { |
| 138 |
|
| 139 |
$string = ($result['body']); //$string = str_replace( "'", ''', $string ); |
| 140 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 141 |
echo $string; |
| 142 |
echo ' <script type="text/javascript"> '; |
| 143 |
echo ' jQuery("#ajax_message").append( jQuery("#ajax_respond #bk_registration_info") );'; |
| 144 |
echo ' jQuery("#ajax_message").append( "<div id=\'bk_registration_info_reload\'>If page will not reload automatically, please refresh page after 60 seconds...</div>" );'; |
| 145 |
echo ' </script> '; |
| 146 |
|
| 147 |
} else { // Some error appear |
| 148 |
echo '<div id="bk_errror_loading" class="warning_message" >'; |
| 149 |
echo '<div class="info_message">'; esc_html_e('Warning! Some error occur, during sending registration request.' ,'booking'); echo '</div>'; |
| 150 |
|
| 151 |
if ( is_wp_error( $result ) ) { |
| 152 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 153 |
echo $result->get_error_message(); |
| 154 |
} else { |
| 155 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 156 |
echo $result['response']['message']; |
| 157 |
} |
| 158 |
echo '<br /><br />'; |
| 159 |
esc_html_e('Please refresh this page and if the same error appear again contact support by email (with info about order number and website) for finishing the registrations' ,'booking'); echo ' <a href="mailto:activate@wpbookingcalendar.com">activate@wpbookingcalendar.com</a>'; |
| 160 |
echo '</strong></div>'; |
| 161 |
echo ' <script type="text/javascript"> '; |
| 162 |
echo ' jQuery( "#ajax_message" ).html( "" );'; |
| 163 |
|
| 164 |
echo ' jQuery("#ajax_message").append( jQuery("#ajax_respond #bk_errror_loading") );'; |
| 165 |
echo ' jQuery("#bk_errror_loading").slideUp(1).slideDown(1500);'; |
| 166 |
|
| 167 |
echo ' jQuery("#recheck_version").animate({opacity:1},3000).slideUp(1500);'; |
| 168 |
echo ' </script> '; |
| 169 |
} |
| 170 |
} |