| Server IP : 89.108.64.180 / Your IP : 216.73.217.92 Web Server : Apache/2.4.41 (Ubuntu) System : Linux 89-108-64-180.cloudvps.regruhosting.ru 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-root ( 1010) PHP Version : 8.0.30 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/omapart.ru/wp-content/plugins/mphb-woocommerce/includes/ |
Upload File : |
<?php
namespace MPHBW;
class Dependencies {
const WOO_VERSION = '3.2.6';
const MPHB_VERSION = '2.4.0';
public function __construct(){
add_action( 'admin_notices', array( $this, 'checkAndShowNotice' ) );
}
/**
* Check plugin dependencies. Don't use before plugins_loaded action
*
* @return boolean
*/
public function check(){
return $this->checkMPHB() && $this->checkWoocommerce();
}
private function isMPHBActive(){
return mphbw_is_plugin_active( 'motopress-hotel-booking/motopress-hotel-booking.php' ) ||
mphbw_is_plugin_active( 'motopress-hotel-booking-lite/motopress-hotel-booking.php' );
}
private function isMPHBCorrectVersion(){
if ( !function_exists( 'MPHB' ) ) {
return false;
}
$mphb = MPHB();
return method_exists( $mphb, 'getVersion' ) &&
version_compare( $mphb->getVersion(), self::MPHB_VERSION, '>=' );
}
private function checkMPHB(){
return $this->isMPHBActive() && $this->isMPHBCorrectVersion();
}
private function isWoocommerceActive(){
return mphbw_is_plugin_active( 'woocommerce/woocommerce.php' );
}
private function isWoocommerceCorrectVersion(){
if ( !function_exists( 'wc' ) ) {
return false;
}
$woocommerce = wc();
return $woocommerce && property_exists( $woocommerce, 'version' ) &&
version_compare( $woocommerce->version, self::WOO_VERSION, '>=' );
}
private function checkWoocommerce(){
return $this->isWoocommerceActive() && $this->isWoocommerceCorrectVersion();
}
/**
*
* @return bool
*/
public function checkCurrency(){
$mphbCurrency = MPHB()->settings()->currency()->getCurrencyCode();
$wooCurrency = get_woocommerce_currency();
return $mphbCurrency == $wooCurrency;
}
function checkAndShowNotice(){
if ( !$this->checkMPHB() ) {
echo '<div class="error"><p>' . sprintf( __( 'Hotel Booking WooCommerce Payments plugin requires Hotel Booking plugin version %s or higher.', 'mphb-woocommerce' ), self::MPHB_VERSION ) . '</p></div>';
}
if ( !$this->checkWoocommerce() ) {
echo '<div class="error"><p>' . sprintf( __( 'Hotel Booking WooCommerce Payments requires WooCommerce plugin version %s or higher.', 'mphb-woocommerce' ), self::WOO_VERSION ) . '</p></div>';
}
if ( $this->checkMPHB() && $this->checkWoocommerce() && !$this->checkCurrency() ) {
echo '<div class="error"><p>' . sprintf( __( 'Hotel Booking WooCommerce Payments requires equal currencies set up in WooCommerce(%s) and Hotel Booking(%s).', 'mphb-woocommerce' ), get_woocommerce_currency(), MPHB()->settings()->currency()->getCurrencyCode() ) . '</p></div>';
}
}
}