is_wc_active() ) {
$this->includes();
$this->init();
add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
}
}
/**
* Check if WooCommerce is active
*
* @access private
* @since 1.0.0
* @return bool
*/
private function is_wc_active() {
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
}
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
$is_active = true;
} else {
$is_active = false;
}
// Do the WC active check
if ( false === $is_active ) {
add_action( 'admin_notices', array( $this, 'notice_activate_wc' ) );
}
return $is_active;
}
/**
* Display WC active notice
*
* @access public
* @since 1.0.0
*/
public function notice_activate_wc() {
?>
get_plugin_path() . '/include/wc-local-pickup-admin.php';
$this->admin = WC_Local_Pickup_admin::get_instance();
}
/**
* Initialize plugin
*
* @access private
* @since 1.0.0
*/
private function init() {
// Load plugin textdomain
add_action('plugins_loaded', array($this, 'load_textdomain'));
//load javascript in admin
add_action('admin_enqueue_scripts', array( $this, 'wc_esrc_enqueue' ) );
//callback for add action link for plugin page
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this , 'my_plugin_action_links' ));
//add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this , 'my_plugin_action_PRO_links' ));
}
/*
* include file on plugin load
*/
public function on_plugins_loaded() {
require_once $this->get_plugin_path() . '/include/customizer/wclp-customizer.php';
require_once $this->get_plugin_path() . '/include/customizer/wc-ready-pickup-email-customizer.php';
require_once $this->get_plugin_path() . '/include/customizer/wc-pickup-email-customizer.php';
}
/*
* load text domain
*/
public function load_textdomain(){
load_plugin_textdomain( 'advanced-local-pickup-for-woocommerce', false, plugin_dir_path( plugin_basename(__FILE__) ) . 'lang/' );
}
/**
* Gets the absolute plugin path without a trailing slash, e.g.
* /path/to/wp-content/plugins/plugin-directory.
*
* @return string plugin path
*/
public function get_plugin_path() {
if ( isset( $this->plugin_path ) ) {
return $this->plugin_path;
}
$this->plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) );
return $this->plugin_path;
}
public static function get_plugin_domain(){
return __FILE__;
}
/*
* plugin file directory function
*/
public function plugin_dir_url(){
return plugin_dir_url( __FILE__ );
}
/**
* Add plugin action links.
*
* Add a link to the settings page on the plugins.php page.
*
* @since 1.0.0
*
* @param array $links List of existing plugin action links.
* @return array List of modified plugin action links.
*/
function my_plugin_action_links( $links ) {
$links = array_merge( array(
'' . __( 'Settings', 'woocommerce' ) . ''
), $links );
return $links;
}
/*
* Add admin javascript
*/
public function wc_esrc_enqueue() {
// Add condition for css & js include for admin page
if(!isset($_GET['page'])) {
return;
}
if( $_GET['page'] != 'local_pickup') {
return;
}
// Add the color picker css file
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
// Add the WP Media
wp_enqueue_media();
// Add tiptip js and css file
wp_register_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION );
wp_enqueue_style( 'woocommerce_admin_styles' );
wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip.min.js', array( 'jquery' ), WC_VERSION, true );
wp_enqueue_script( 'jquery-tiptip' );
wp_enqueue_script( 'asrc-admin-js', plugin_dir_url(__FILE__) . 'assets/js/admin.js', array(), $this->version );
wp_enqueue_script( 'asrc-material-min-js', plugin_dir_url(__FILE__) . 'assets/js/material.min.js', array(), $this->version );
wp_enqueue_style( 'asrc-admin-css', plugin_dir_url(__FILE__) . 'assets/css/admin.css', array(), $this->version );
wp_enqueue_style( 'asrc-material-css', plugin_dir_url(__FILE__) . 'assets/css/material.css', array(), $this->version );
}
}
/**
* Returns an instance of zorem_woocommerce_advanced_salse_report_email.
*
* @since 1.6.5
* @version 1.6.5
*
* @return zorem_woocommerce_advanced_salse_report_email
*/
function wc_local_pickup() {
static $instance;
if ( ! isset( $instance ) ) {
$instance = new Woocommerce_local_pickup();
}
return $instance;
}
/**
* Register this class globally.
*
* Backward compatibility.
*/
$GLOBALS['wc_local_pickup'] = wc_local_pickup();