wp-whatsapp
Last commit date
assets
1 month ago
blocks
1 month ago
cross-sell
1 month ago
includes
1 month ago
languages
1 month ago
vendor
1 month ago
vendor-prefixed
1 month ago
views
1 month ago
WhatsappPluginAdapter.php
1 month ago
index.php
1 month ago
readme.txt
1 month ago
whatsapp.php
1 month ago
wpml-config.xml
1 month ago
whatsapp.php
119 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @wordpress-plugin |
| 4 | * Plugin Name: WP Chat App |
| 5 | * Plugin URI: https://ninjateam.org/whatsapp-chat-wordpress/ |
| 6 | * Description: Integrate your WhatsApp experience directly into your website. This is one of the best way to connect and interact with your customer. |
| 7 | * Version: 3.8.2 |
| 8 | * Author: NinjaTeam |
| 9 | * Author URI: https://ninjateam.org |
| 10 | * Text Domain: wp-whatsapp |
| 11 | * Domain Path: /languages |
| 12 | */ |
| 13 | namespace NTA_WhatsApp; |
| 14 | |
| 15 | defined( 'ABSPATH' ) || exit; |
| 16 | |
| 17 | if ( function_exists( 'NTA_WhatsApp\\init' ) ) { |
| 18 | require_once plugin_dir_path( __FILE__ ) . 'includes/Fallback.php'; |
| 19 | add_action( |
| 20 | 'admin_init', |
| 21 | function () { |
| 22 | deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 23 | } |
| 24 | ); |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | if ( ! defined( 'NTA_WHATSAPP_VERSION' ) ) { |
| 29 | define( 'NTA_WHATSAPP_VERSION', '3.8.2' ); |
| 30 | } |
| 31 | |
| 32 | if ( ! defined( 'NTA_WHATSAPP_PLUGIN_URL' ) ) { |
| 33 | define( 'NTA_WHATSAPP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 34 | } |
| 35 | |
| 36 | if ( ! defined( 'NTA_WHATSAPP_PLUGIN_DIR' ) ) { |
| 37 | define( 'NTA_WHATSAPP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 38 | } |
| 39 | |
| 40 | if ( ! defined( 'NTA_WHATSAPP_BASE_NAME' ) ) { |
| 41 | define( 'NTA_WHATSAPP_BASE_NAME', plugin_basename( __FILE__ ) ); |
| 42 | } |
| 43 | |
| 44 | // Cross-sell module loader (gracefully no-op if cross-sell/ hasn't been synced yet). |
| 45 | if ( file_exists( __DIR__ . '/cross-sell/loader.php' ) ) { |
| 46 | require_once __DIR__ . '/cross-sell/loader.php'; |
| 47 | } |
| 48 | |
| 49 | spl_autoload_register( |
| 50 | function ( $class ) { |
| 51 | $prefix = __NAMESPACE__; // project-specific namespace prefix |
| 52 | $base_dir = __DIR__ . '/includes'; // base directory for the namespace prefix |
| 53 | |
| 54 | $len = strlen( $prefix ); |
| 55 | if ( strncmp( $prefix, $class, $len ) !== 0 ) { // does the class use the namespace prefix? |
| 56 | return; // no, move to the next registered autoloader |
| 57 | } |
| 58 | |
| 59 | $relative_class_name = substr( $class, $len ); |
| 60 | |
| 61 | // replace the namespace prefix with the base directory, replace namespace |
| 62 | // separators with directory separators in the relative class name, append |
| 63 | // with .php |
| 64 | $file = $base_dir . str_replace( '\\', '/', $relative_class_name ) . '.php'; |
| 65 | |
| 66 | if ( file_exists( $file ) ) { |
| 67 | require $file; |
| 68 | } |
| 69 | } |
| 70 | ); |
| 71 | |
| 72 | if ( file_exists( __DIR__ . '/includes/Review.php' ) ) { |
| 73 | require_once __DIR__ . '/includes/Review.php'; |
| 74 | } |
| 75 | |
| 76 | require_once __DIR__ . '/vendor/autoload.php'; |
| 77 | |
| 78 | spl_autoload_register(function ( $class ) { |
| 79 | $prefix = 'WhatsappScoped\\YayCommerce\\AdminShell\\'; |
| 80 | $base_dir = __DIR__ . '/vendor-prefixed/src/'; |
| 81 | $len = strlen( $prefix ); |
| 82 | if ( strncmp( $prefix, $class, $len ) !== 0 ) { |
| 83 | return; |
| 84 | } |
| 85 | $file = $base_dir . str_replace( '\\', '/', substr( $class, $len ) ) . '.php'; |
| 86 | if ( file_exists( $file ) ) { |
| 87 | require $file; |
| 88 | } |
| 89 | }); |
| 90 | |
| 91 | require_once __DIR__ . '/WhatsappPluginAdapter.php'; |
| 92 | |
| 93 | add_action( 'plugins_loaded', function() { |
| 94 | ( new \WhatsappPluginAdapter() )->init(); |
| 95 | }, 5 ); |
| 96 | |
| 97 | if ( ! function_exists( 'NTA_WhatsApp\\init' ) ) { |
| 98 | function init() { |
| 99 | Plugin::activate(); |
| 100 | PostType::getInstance(); |
| 101 | I18n::loadPluginTextdomain(); |
| 102 | Shortcode::getInstance(); |
| 103 | Popup::getInstance(); |
| 104 | Settings::getInstance(); |
| 105 | Upgrade::getInstance(); |
| 106 | Support\WPML::getInstance(); |
| 107 | Support\Woocommerce::getInstance(); |
| 108 | if ( function_exists( 'register_block_type' ) ) { |
| 109 | require_once plugin_dir_path( __FILE__ ) . 'blocks/src/init.php'; |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | |
| 115 | add_action( 'plugins_loaded', 'NTA_WhatsApp\\init' ); |
| 116 | |
| 117 | register_activation_hook( __FILE__, array( 'NTA_WhatsApp\\Plugin', 'activate' ) ); |
| 118 | register_deactivation_hook( __FILE__, array( 'NTA_WhatsApp\\Plugin', 'deactivate' ) ); |
| 119 |