PluginProbe
Tourfic – AI Powered Travel Booking, Hotel Booking & Car Rental WordPress Plugin / 2.23.2
Tourfic – AI Powered Travel Booking, Hotel Booking & Car Rental WordPress Plugin v2.23.2
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 2.23.2, at tourfic.php

279 lines 10.0 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 – Travel Booking, Hotel Booking & Car Rental WordPress Plugin
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.2
11 * Tested up to: 7.0
12 * WC tested up to: 10.9
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.2';
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 require __DIR__ . '/vendor/autoload.php';
79
80 //Check if WooCommerce is active, and if it isn't, disable the plugin.
81 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
82 add_action( 'admin_notices', array( $this, 'tf_is_woo' ) );
83
84 //Ajax install & activate WooCommerce
85 add_action( "wp_ajax_tf_ajax_install_plugin", "wp_ajax_install_plugin" );
86 }
87
88 $this->init_hooks();
89 }
90
91 /**
92 * Define Tourfic Constants.
93 */
94 private function define_constants() {
95 define( 'TOURFIC', self::VERSION );
96 define( 'TF_VERSION', self::VERSION );
97 define( 'TF_MINIMUM_PHP_VERSION', self::MINIMUM_PHP_VERSION );
98 define( 'TF_MINIMUM_WC_VERSION', self::MINIMUM_WC_VERSION );
99 define( 'TF_URL', plugin_dir_url( __FILE__ ) );
100 define( 'TF_TEMPLATES_URL', TF_URL . 'templates/' );
101 define( 'TF_ADMIN_URL', TF_URL . 'admin/' );
102 define( 'TF_ASSETS_URL', TF_URL . 'assets/' );
103 define( 'TF_ASSETS_APP_URL', TF_ASSETS_URL . 'app/' );
104 define( 'TF_ASSETS_ADMIN_URL', TF_ASSETS_URL . 'admin/' );
105 define( 'TF_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
106 define( 'TF_ADMIN_PATH', TF_PATH . 'inc/Admin/' );
107 define( 'TF_INC_PATH', TF_PATH . 'inc/' );
108 define( 'TF_TEMPLATE_PATH', TF_PATH . 'templates/' );
109 define( 'TF_TEMPLATE_PART_PATH', TF_TEMPLATE_PATH . 'template-parts/' );
110 define( 'TF_OPTIONS_PATH', TF_ADMIN_PATH . 'options/' );
111 define( 'TF_ASSETS_PATH', TF_PATH . 'assets/' );
112 define( 'TF_EMAIL_TEMPLATES_PATH', TF_ADMIN_PATH . 'Emails/templates/' );
113 }
114
115 /**
116 * Hook into actions and filters.
117 */
118 private function init_hooks() {
119 // Load the text domain for translation.
120 add_action( 'init', array( $this, 'tf_load_textdomain' ) );
121 // plugin loaded action hook.
122 add_action( 'init', array( $this, 'init_plugin' ), 0 );
123 //Compatibility with custom order tables for the WooCommerce plugin
124 add_action( 'before_woocommerce_init', array( $this, 'tf_woocommerce_compatibility' ) );
125 }
126
127 /**
128 * Init the plugin after plugins_loaded so environment variables are set.
129 */
130 public function init_plugin() {
131 // autoloader
132 require_once TF_PATH . 'autoloader.php';
133
134 // Initialize the appsero
135 $this->appsero_init_tracker_tourfic();
136
137 if ( class_exists( "\Tourfic\Classes\Base" ) ) {
138 \Tourfic\Classes\Base::instance();
139 } else {
140 add_action( 'admin_notices', function () {
141 ?>
142 <div class="notice notice-error">
143 <p><?php esc_html_e( 'Something went Wrong. Please Reinstall the Tourfic Plugin ', 'tourfic' ); ?></p>
144 </div>
145 <?php
146 } );
147
148 return;
149 }
150 }
151
152 /**
153 * Include required core files used in admin and on the frontend.
154 */
155 public function includes() {}
156
157 function tf_load_textdomain() {
158 $locale = apply_filters( 'plugin_locale', get_locale(), 'tourfic' );
159 // Allow upgrade safe, site specific language files in /wp-content/languages/tourfic/
160 load_textdomain( 'tourfic', WP_LANG_DIR . '/tourfic/tourfic-' . $locale . '.mo' );
161 // // Then check for a language file in /wp-content/plugins/tourfic/lang/ (this will be overriden by any file already loaded)
162 // load_plugin_textdomain( 'tourfic', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
163 }
164
165 /**
166 * Called when WooCommerce is inactive to display an inactive notice.
167 *
168 * @since 1.0
169 */
170 function tf_is_woo() {
171 if ( current_user_can( 'activate_plugins' ) ) {
172 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) && ! file_exists( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) {
173 ?>
174 <div id="message" class="error">
175 <p>
176 <?php
177 /* translators: %1$s is return strong tag %2$s is return closeing of strong tag */
178 printf(esc_html__( 'Tourfic requires %1$s WooCommerce %2$s to be activated.', 'tourfic' ),
179 '<strong><a href="plugin-install.php?s=woocommerce&tab=search&type=term">', '</a></strong>'
180 ); ?>
181 </p>
182 <p>
183 <a class="button-primary" href="<?php echo esc_url( admin_url( 'plugin-install.php?s=woocommerce&tab=search&type=term' ) ); ?>">
184 <?php esc_html_e( 'Install Now', 'tourfic' ); ?>
185 </a>
186 </p>
187 </div>
188
189 <!-- <script>
190 jQuery(document).on('click', '#tf_wooinstall', function (e) {
191 e.preventDefault();
192 var current = jQuery(this);
193 var plugin_slug = current.attr("data-plugin-slug");
194 var ajax_url = '</?php echo esc_url( admin_url( 'admin-ajax.php' ) )?>';
195
196 current.addClass('updating-message').text('Installing...');
197
198 var data = {
199 action: 'tf_ajax_install_plugin',
200 _ajax_nonce: '</?php echo esc_html( wp_create_nonce( 'updates' ) ); ?>',
201 slug: plugin_slug,
202 };
203
204 jQuery.post(ajax_url, data, function (response) {
205 current.removeClass('updating-message');
206 current.addClass('updated-message').text('Installing...');
207 current.attr("href", response.data.activateUrl);
208 })
209 .fail(function () {
210 current.removeClass('updating-message').text('Install Failed');
211 })
212 .always(function () {
213 current.removeClass('install-now updated-message').addClass('activate-now button-primary').text('Activating...');
214 current.unbind(e);
215 current[0].click();
216 });
217 });
218 </script> -->
219
220 <?php
221 } elseif ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) && file_exists( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) {
222 ?>
223
224 <div id="message" class="error">
225 <?php /* translators: %1$s: WooCommerce plugin url start, %2$s: WooCommerce plugin url end */ ?>
226 <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>
227 <p>
228 <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"
229 class="button activate-now button-primary"><?php esc_html_e( 'Activate', 'tourfic' ); ?></a></p>
230 </div>
231 <?php
232 } elseif ( version_compare( get_option( 'woocommerce_db_version' ), '2.5', '<' ) ) {
233 ?>
234
235 <div id="message" class="error">
236 <?php /* translators: %1$s: strong tag start, %2$s: strong tag end, %3$s: plugin url start, %4$s: plugin url end */ ?>
237 <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>
238 </div>
239
240 <?php
241 }
242 }
243 }
244
245 function tf_woocommerce_compatibility() {
246 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
247 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
248 }
249 }
250
251 /**
252 * Initialize the plugin tracker
253 *
254 * @return void
255 */
256 public function appsero_init_tracker_tourfic() {
257
258 $client = new Appsero\Client( '19134f1b-2838-4a45-ac05-772b7dfc9850', 'Travel and Hotel Booking Solution for WooCommerce - Tourfic', __FILE__ );
259
260 // Change Admin notice text
261 $notice = sprintf( $client->__trans( 'Want to help make <strong>%1$s</strong> even more awesome? Allow %1$s to collect non-sensitive diagnostic data and usage information. I agree to get Important Product Updates & Discount related information on my email from %1$s (I can unsubscribe anytime).' ), $client->name );
262 $client->insights()->notice( $notice );
263
264 // Active insights
265 $client->insights()->init();
266
267 }
268 }
269
270 Tourfic::instance();
271
272 function tf_active_template_settings_callback() {
273 //all code goes here if need
274 update_option( 'tourfic_template_installed', true );
275 }
276
277 //Register activation hook
278 register_activation_hook( __FILE__, 'tf_active_template_settings_callback' );
279