PluginProbe
Tourfic – AI Powered Travel Booking, Hotel Booking & Car Rental WordPress Plugin / trunk
Tourfic – AI Powered Travel Booking, Hotel Booking & Car Rental WordPress Plugin vtrunk
2.23.2 2.23.1 2.23.0 2.22.8 2.22.7 2.22.6 2.22.5 2.22.4 2.22.3 2.22.2 2.22.1 2.15.22 2.15.23 2.15.24 2.15.25 2.15.26 2.15.3 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 All 234 releases
tourfic / tourfic.php

tourfic.php in Tourfic – AI Powered Travel Booking, Hotel Booking & Car Rental WordPress Plugin trunk, at tourfic.php

258 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Tourfic – AI Powered Travel Booking, Hotel Booking & Car Rental
4 * Plugin URI: https://themefic.com/tourfic
5 * Description: The ultimate plugin for tour, travel, accommodation, and hotel bookings. Effortlessly manage your entire online travel booking system, including orders and any WooCommerce payment method.
6 * Author: Themefic
7 * Author URI: https://themefic.com
8 * Text Domain: tourfic
9 * Domain Path: /lang/
10 * Version: 2.23.4
11 * Tested up to: 7.1
12 * WC tested up to: 11.0
13 * Requires PHP: 7.4
14 * Elementor tested up to: 4.2
15 * License: GPLv2 or later
16 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
17 */
18
19 // Don't load directly
20 defined( 'ABSPATH' ) || exit;
21
22 final class Tourfic {
23
24 /**
25 * Plugin version.
26 *
27 * @var string
28 */
29
30 const VERSION = '2.23.4';
31
32 /**
33 * Minimum PHP version required.
34 *
35 * @var string
36 */
37 const MINIMUM_PHP_VERSION = '7.4';
38
39 /**
40 * Minimum WooCommerce version required.
41 *
42 * @var string
43 */
44 const MINIMUM_WC_VERSION = '3.0';
45
46 /**
47 * The single instance of the class.
48 *
49 * @var Tourfic
50 * @since 1.0.0
51 */
52 protected static $_instance = null;
53
54 /**
55 * Main Tourfic Instance.
56 *
57 * Ensures only one instance of Tourfic is loaded or can be loaded.
58 *
59 * @return Tourfic - Main instance.
60 * @see Tourfic()
61 * @since 1.0.0
62 * @static
63 */
64 public static function instance() {
65 if ( is_null( self::$_instance ) ) {
66 self::$_instance = new self();
67 }
68 return self::$_instance;
69 }
70
71 /**
72 * Tourfic Constructor.
73 */
74 public function __construct() {
75 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
76 $this->define_constants();
77
78 //Check if WooCommerce is active, and if it isn't, disable the plugin.
79 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
80 add_action( 'admin_notices', array( $this, 'tf_is_woo' ) );
81
82 //Ajax install & activate WooCommerce
83 add_action( "wp_ajax_tourfic_ajax_install_plugin", "wp_ajax_install_plugin" );
84 }
85
86 $this->init_hooks();
87 }
88
89 /**
90 * Define Tourfic Constants.
91 */
92 private function define_constants() {
93 define( 'TOURFIC', self::VERSION );
94 define( 'TOURFIC_VERSION', self::VERSION );
95 define( 'TOURFIC_MINIMUM_PHP_VERSION', self::MINIMUM_PHP_VERSION );
96 define( 'TOURFIC_MINIMUM_WC_VERSION', self::MINIMUM_WC_VERSION );
97 define( 'TOURFIC_URL', plugin_dir_url( __FILE__ ) );
98 define( 'TOURFIC_TEMPLATES_URL', TOURFIC_URL . 'templates/' );
99 define( 'TOURFIC_ADMIN_URL', TOURFIC_URL . 'admin/' );
100 define( 'TOURFIC_ASSETS_URL', TOURFIC_URL . 'assets/' );
101 define( 'TOURFIC_ASSETS_APP_URL', TOURFIC_ASSETS_URL . 'app/' );
102 define( 'TOURFIC_ASSETS_ADMIN_URL', TOURFIC_ASSETS_URL . 'admin/' );
103 define( 'TOURFIC_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
104 define( 'TOURFIC_ADMIN_PATH', TOURFIC_PATH . 'inc/Admin/' );
105 define( 'TOURFIC_INC_PATH', TOURFIC_PATH . 'inc/' );
106 define( 'TOURFIC_TEMPLATE_PATH', TOURFIC_PATH . 'templates/' );
107 define( 'TOURFIC_TEMPLATE_PART_PATH', TOURFIC_TEMPLATE_PATH . 'template-parts/' );
108 define( 'TOURFIC_OPTIONS_PATH', TOURFIC_ADMIN_PATH . 'options/' );
109 define( 'TOURFIC_ASSETS_PATH', TOURFIC_PATH . 'assets/' );
110 define( 'TOURFIC_EMAIL_TEMPLATES_PATH', TOURFIC_ADMIN_PATH . 'Emails/templates/' );
111 }
112
113 /**
114 * Hook into actions and filters.
115 */
116 private function init_hooks() {
117 // Load the text domain for translation.
118 add_action( 'init', array( $this, 'tf_load_textdomain' ) );
119 // plugin loaded action hook.
120 add_action( 'init', array( $this, 'init_plugin' ), 0 );
121 //Compatibility with custom order tables for the WooCommerce plugin
122 add_action( 'before_woocommerce_init', array( $this, 'tf_woocommerce_compatibility' ) );
123 }
124
125 /**
126 * Init the plugin after plugins_loaded so environment variables are set.
127 */
128 public function init_plugin() {
129 // autoloader
130 require_once TOURFIC_PATH . 'autoloader.php';
131
132 if ( class_exists( "\Tourfic\Classes\Base" ) ) {
133 \Tourfic\Classes\Base::instance();
134 } else {
135 add_action( 'admin_notices', function () {
136 ?>
137 <div class="notice notice-error">
138 <p><?php esc_html_e( 'Something went Wrong. Please Reinstall the Tourfic Plugin ', 'tourfic' ); ?></p>
139 </div>
140 <?php
141 } );
142
143 return;
144 }
145 }
146
147 /**
148 * Include required core files used in admin and on the frontend.
149 */
150 public function includes() {}
151
152 function tf_load_textdomain() {
153 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WordPress core hook.
154 $locale = apply_filters( 'plugin_locale', get_locale(), 'tourfic' );
155 // Allow upgrade safe, site specific language files in /wp-content/languages/tourfic/
156 load_textdomain( 'tourfic', WP_LANG_DIR . '/tourfic/tourfic-' . $locale . '.mo' );
157 // // Then check for a language file in /wp-content/plugins/tourfic/lang/ (this will be overriden by any file already loaded)
158 // load_plugin_textdomain( 'tourfic', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
159 }
160
161 /**
162 * Called when WooCommerce is inactive to display an inactive notice.
163 *
164 * @since 1.0
165 */
166 function tf_is_woo() {
167 if ( current_user_can( 'activate_plugins' ) ) {
168 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) && ! file_exists( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) {
169 ?>
170 <div id="message" class="error">
171 <p>
172 <?php
173 /* translators: %1$s is return strong tag %2$s is return closeing of strong tag */
174 printf(esc_html__( 'Tourfic requires %1$s WooCommerce %2$s to be activated.', 'tourfic' ),
175 '<strong><a href="plugin-install.php?s=woocommerce&tab=search&type=term">', '</a></strong>'
176 ); ?>
177 </p>
178 <p>
179 <a class="button-primary" href="<?php echo esc_url( admin_url( 'plugin-install.php?s=woocommerce&tab=search&type=term' ) ); ?>">
180 <?php esc_html_e( 'Install Now', 'tourfic' ); ?>
181 </a>
182 </p>
183 </div>
184
185 <!-- <script>
186 jQuery(document).on('click', '#tf_wooinstall', function (e) {
187 e.preventDefault();
188 var current = jQuery(this);
189 var plugin_slug = current.attr("data-plugin-slug");
190 var ajax_url = '</?php echo esc_url( admin_url( 'admin-ajax.php' ) )?>';
191
192 current.addClass('updating-message').text('Installing...');
193
194 var data = {
195 action: 'tourfic_ajax_install_plugin',
196 _ajax_nonce: '</?php echo esc_html( wp_create_nonce( 'updates' ) ); ?>',
197 slug: plugin_slug,
198 };
199
200 jQuery.post(ajax_url, data, function (response) {
201 current.removeClass('updating-message');
202 current.addClass('updated-message').text('Installing...');
203 current.attr("href", response.data.activateUrl);
204 })
205 .fail(function () {
206 current.removeClass('updating-message').text('Install Failed');
207 })
208 .always(function () {
209 current.removeClass('install-now updated-message').addClass('activate-now button-primary').text('Activating...');
210 current.unbind(e);
211 current[0].click();
212 });
213 });
214 </script> -->
215
216 <?php
217 } elseif ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) && file_exists( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) {
218 ?>
219
220 <div id="message" class="error">
221 <?php /* translators: %1$s: WooCommerce plugin url start, %2$s: WooCommerce plugin url end */ ?>
222 <p><?php printf( esc_html__( 'Tourfic requires %1$s WooCommerce %2$s to be activated.', 'tourfic' ), '<strong><a href="https://wordpress.org/plugins/woocommerce/" target="_blank" rel="noopener noreferrer">', '</a></strong>' ); ?></p>
223 <p>
224 <a href="<?php echo esc_url( get_admin_url() ); ?>plugins.php?_wpnonce=<?php echo esc_attr( wp_create_nonce( 'activate-plugin_woocommerce/woocommerce.php' ) ); ?>&action=activate&plugin=woocommerce/woocommerce.php"
225 class="button activate-now button-primary"><?php esc_html_e( 'Activate', 'tourfic' ); ?></a></p>
226 </div>
227 <?php
228 } elseif ( version_compare( get_option( 'woocommerce_db_version' ), '2.5', '<' ) ) {
229 ?>
230
231 <div id="message" class="error">
232 <?php /* translators: %1$s: strong tag start, %2$s: strong tag end, %3$s: plugin url start, %4$s: plugin url end */ ?>
233 <p><?php printf( esc_html__( '%1$sTourfic is inactive.%2$s This plugin requires WooCommerce 2.5 or newer. Please %3$supdate WooCommerce to version 2.5 or newer%4$s', 'tourfic' ), '<strong>', '</strong>', '<a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">', '&nbsp;&raquo;</a>' ); ?></p>
234 </div>
235
236 <?php
237 }
238 }
239 }
240
241 function tf_woocommerce_compatibility() {
242 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
243 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
244 }
245 }
246
247 }
248
249 Tourfic::instance();
250
251 function tourfic_active_template_settings_callback() {
252 //all code goes here if need
253 update_option( 'tourfic_template_installed', true );
254 }
255
256 //Register activation hook
257 register_activation_hook( __FILE__, 'tourfic_active_template_settings_callback' );
258