pi-woocommerce-order-date-time-and-type
Last commit date
admin
4 months ago
block
4 months ago
include
4 months ago
public
4 months ago
pi-woocommerce-order-date-time-and-type.php
4 months ago
pisol-dtt.pot
4 months ago
readme.txt
4 months ago
wpml-config.xml
4 months ago
pi-woocommerce-order-date-time-and-type.php
109 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: Order date, Order pickup, Order date time, Pickup Location, delivery date for WooCommerce |
| 4 | Plugin URI: https://woo-restaurant.com/ |
| 5 | Description: Set order delivery date, time and type for WooCommerce |
| 6 | Version: 3.0.49.91 |
| 7 | Author: PI Websolution |
| 8 | Author URI: https://www.piwebsolution.com |
| 9 | Text Domain: pisol-dtt |
| 10 | WC tested up to: 10.5 |
| 11 | License: GPL-2.0+ |
| 12 | */ |
| 13 | defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
| 14 | |
| 15 | include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 16 | |
| 17 | if(is_plugin_active( 'pi-woocommerce-order-date-time-and-type-pro/pi-woocommerce-order-date-time-and-type-pro.php')){ |
| 18 | deactivate_plugins(plugin_basename(__FILE__)); |
| 19 | return; |
| 20 | } |
| 21 | |
| 22 | /* |
| 23 | Making sure WooCommerce is there |
| 24 | */ |
| 25 | if(!is_plugin_active( 'woocommerce/woocommerce.php')){ |
| 26 | |
| 27 | add_action( 'admin_notices', function () { |
| 28 | ?> |
| 29 | <div class="error notice"> |
| 30 | <p><?php esc_html_e( 'Please Install and Activate WooCommerce plugin, without that this plugin cant work', 'pisol-dtt' ); ?></p> |
| 31 | </div> |
| 32 | <?php |
| 33 | } ); |
| 34 | deactivate_plugins(plugin_basename(__FILE__)); |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Declare compatible with HPOS new order table |
| 40 | */ |
| 41 | add_action( 'before_woocommerce_init', function() { |
| 42 | if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 43 | \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 44 | } |
| 45 | } ); |
| 46 | |
| 47 | define('PISOL_DTT_PLUGIN_VERSION', '3.0.49.91'); |
| 48 | define('PISOL_DTT_FREE_RESET_SETTING', false); |
| 49 | define('PISOL_DTT_URL', plugin_dir_url(__FILE__)); |
| 50 | define('PISOL_DTT_PATH', plugin_dir_path( __FILE__ )); |
| 51 | define('PISOL_DTT_BASE', plugin_basename(__FILE__)); |
| 52 | define('PISOL_DTT_PRICE', '$2.8 / month'); |
| 53 | define('PISOL_DTT_BUY_URL', 'https://www.piwebsolution.com/checkout/?add-to-cart=621&variation_id=679&utm_campaign=data-time&utm_source=website&utm_medium=direct-buy'); |
| 54 | |
| 55 | function pisol_dtt_plugin_link( $links ) { |
| 56 | $links = array_merge( array( |
| 57 | '<a href="' . esc_url( admin_url( '/admin.php?page=pisol-dtt' ) ) . '">' . __( 'Settings', 'pisol-dtt' ) . '</a>', |
| 58 | '<a style="color:#0a9a3e; font-weight:bold;" target="_blank" href="' . esc_url(PISOL_DTT_BUY_URL) . '">' . __( 'Buy PRO Version', 'pisol-dtt' ) . '</a>' |
| 59 | ), $links ); |
| 60 | return $links; |
| 61 | } |
| 62 | add_action( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'pisol_dtt_plugin_link' ); |
| 63 | |
| 64 | /** |
| 65 | * Activation function to redirect to setting page |
| 66 | * |
| 67 | * */ |
| 68 | register_activation_hook( __FILE__, 'pi_free_order_date_time_activation' ); |
| 69 | |
| 70 | function pi_free_order_date_time_activation(){ |
| 71 | add_option('pi_dtt_do_activation_redirect', true); |
| 72 | |
| 73 | pisol_dtt_option_time_slot::createDefaultTimeSlot(); |
| 74 | } |
| 75 | |
| 76 | add_action('admin_init', 'pi_free_order_date_time_redirect'); |
| 77 | function pi_free_order_date_time_redirect(){ |
| 78 | if (get_option('pi_dtt_do_activation_redirect', false)) { |
| 79 | delete_option('pi_dtt_do_activation_redirect'); |
| 80 | if(!isset($_GET['activate-multi'])) |
| 81 | { |
| 82 | wp_redirect("admin.php?page=pisol-dtt"); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | if ( ! function_exists( 'pisol_dtt_plugins_loaded' ) ) { |
| 88 | function pisol_dtt_plugins_loaded() { |
| 89 | load_plugin_textdomain( 'pisol-dtt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 90 | } |
| 91 | add_action( 'plugins_loaded', 'pisol_dtt_plugins_loaded', 0 ); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | |
| 96 | /** |
| 97 | * Checking Pro version |
| 98 | */ |
| 99 | function pi_dtt_pro_check(){ |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | /* This adds menu link */ |
| 105 | require_once plugin_dir_path( __FILE__ ).'include/includes.php'; |
| 106 | |
| 107 | |
| 108 | |
| 109 |