includes();
// Settings & Scripts
if ( is_admin() ) {
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_woocommerce_settings_tab' ) );
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'action_links' ) );
}
}
/**
* Show action links on the plugin screen
*
* @version 1.1.0
* @since 1.0.0
* @param mixed $links
* @return array
*/
function action_links( $links ) {
$custom_links = array();
$custom_links[] = '' . __( 'Settings', 'woocommerce' ) . '';
if ( 'left-to-free-shipping-for-woocommerce.php' === basename( __FILE__ ) ) {
$custom_links[] = '' . __( 'Unlock All', 'left-to-free-shipping-for-woocommerce' ) . '';
}
return array_merge( $custom_links, $links );
}
/**
* Include required core files used in admin and on the frontend.
*
* @version 1.1.0
* @since 1.0.0
*/
function includes() {
// Functions
require_once( 'includes/alg-wc-left-to-free-shipping-functions.php' );
// Settings
require_once( 'includes/admin/class-alg-wc-left-to-free-shipping-settings-section.php' );
$settings = array();
$settings[] = require_once( 'includes/admin/class-alg-wc-left-to-free-shipping-settings-general.php' );
if ( is_admin() && get_option( 'alg_wc_left_to_free_shipping_version', '' ) !== $this->version ) {
foreach ( $settings as $section ) {
foreach ( $section->get_settings() as $value ) {
if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
$autoload = isset( $value['autoload'] ) ? ( bool ) $value['autoload'] : true;
add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
}
}
}
update_option( 'alg_wc_left_to_free_shipping_version', $this->version );
}
// Widget
require_once( 'includes/class-alg-wc-widget-left-to-free-shipping.php' );
// Core
require_once( 'includes/class-alg-wc-left-to-free-shipping-core.php' );
}
/**
* Add Amount Left for Free Shipping settings tab to WooCommerce settings.
*
* @version 1.0.0
* @since 1.0.0
*/
function add_woocommerce_settings_tab( $settings ) {
$settings[] = include( 'includes/admin/class-alg-wc-settings-left-to-free-shipping.php' );
return $settings;
}
/**
* Get the plugin url.
*
* @version 1.0.0
* @since 1.0.0
* @return string
*/
function plugin_url() {
return untrailingslashit( plugin_dir_url( __FILE__ ) );
}
/**
* Get the plugin path.
*
* @version 1.0.0
* @since 1.0.0
* @return string
*/
function plugin_path() {
return untrailingslashit( plugin_dir_path( __FILE__ ) );
}
}
endif;
if ( ! function_exists( 'alg_wc_left_to_free_shipping' ) ) {
/**
* Returns the main instance of Alg_WC_Left_To_Free_Shipping to prevent the need to use globals.
*
* @version 1.0.0
* @since 1.0.0
* @return Alg_WC_Left_To_Free_Shipping
*/
function alg_wc_left_to_free_shipping() {
return Alg_WC_Left_To_Free_Shipping::instance();
}
}
alg_wc_left_to_free_shipping();