includes(); // Admin if ( is_admin() ) { $this->admin(); } } /** * Include required core files used in admin and on the frontend. * * @version 1.3.0 * @since 1.0.0 */ function includes() { // Functions require_once( 'includes/alg-wc-left-to-free-shipping-functions.php' ); // Widget require_once( 'includes/class-alg-wc-widget-left-to-free-shipping.php' ); // Core $this->core = require_once( 'includes/class-alg-wc-left-to-free-shipping-core.php' ); } /** * admin. * * @version 1.3.0 * @since 1.3.0 */ function admin() { // Action links add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'action_links' ) ); // Settings add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_woocommerce_settings_tab' ) ); require_once( 'includes/settings/class-alg-wc-left-to-free-shipping-settings-section.php' ); $this->settings = array(); $this->settings['general'] = require_once( 'includes/settings/class-alg-wc-left-to-free-shipping-settings-general.php' ); // Version updated if ( get_option( 'alg_wc_left_to_free_shipping_version', '' ) !== $this->version ) { add_action( 'admin_init', array( $this, 'version_updated' ) ); } } /** * 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', 'amount-left-free-shipping-woocommerce' ) . ''; } return array_merge( $custom_links, $links ); } /** * Add Amount Left for Free Shipping settings tab to WooCommerce settings. * * @version 1.3.0 * @since 1.0.0 */ function add_woocommerce_settings_tab( $settings ) { $settings[] = require_once( 'includes/settings/class-alg-wc-settings-left-to-free-shipping.php' ); return $settings; } /** * version_updated. * * @version 1.3.0 * @since 1.2.0 */ function version_updated() { update_option( 'alg_wc_left_to_free_shipping_version', $this->version ); } /** * 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();