includes();
// Admin
if ( is_admin() ) {
$this->admin();
}
}
/**
* Show action links on the plugin screen.
*
* @version 1.2.0
* @since 1.0.0
* @param mixed $links
* @return array
*/
function action_links( $links ) {
$custom_links = array();
$custom_links[] = '' . __( 'Settings', 'woocommerce' ) . '';
if ( 'add-to-cart-button-labels-for-woocommerce.php' === basename( __FILE__ ) ) {
$custom_links[] = '' .
__( 'Unlock All', 'add-to-cart-button-labels-for-woocommerce' ) . '';
}
return array_merge( $custom_links, $links );
}
/**
* Include required core files used in admin and on the frontend.
*
* @version 1.2.0
* @since 1.0.0
*/
function includes() {
// Functions
require_once( 'includes/alg-wc-add-to-cart-button-labels-functions.php' );
// Core
$this->core = require_once( 'includes/class-alg-wc-add-to-cart-button-labels-core.php' );
}
/**
* admin.
*
* @version 1.2.0
* @since 1.2.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-add-to-cart-button-labels-settings-section.php' );
$this->settings = array();
$this->settings['general'] = require_once( 'includes/settings/class-alg-wc-add-to-cart-button-labels-settings-general.php' );
$this->settings['all-products'] = require_once( 'includes/settings/class-alg-wc-add-to-cart-button-labels-settings-all-products.php' );
$this->settings['per-product-type'] = require_once( 'includes/settings/class-alg-wc-add-to-cart-button-labels-settings-per-product-type.php' );
$this->settings['per-category'] = require_once( 'includes/settings/class-alg-wc-add-to-cart-button-labels-settings-per-category.php' );
$this->settings['per-product'] = require_once( 'includes/settings/class-alg-wc-add-to-cart-button-labels-settings-per-product.php' );
// Version updated
if ( get_option( 'alg_wc_add_to_cart_button_labels_version', '' ) !== $this->version ) {
add_action( 'admin_init', array( $this, 'version_updated' ) );
}
}
/**
* version_updated.
*
* @version 1.2.0
* @since 1.2.0
*/
function version_updated() {
update_option( 'alg_wc_add_to_cart_button_labels_version', $this->version );
}
/**
* Add Add to Cart Button Labels settings tab to WooCommerce settings.
*
* @version 1.2.0
* @since 1.0.0
*/
function add_woocommerce_settings_tab( $settings ) {
$settings[] = require_once( 'includes/settings/class-alg-wc-settings-add-to-cart-button-labels.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_add_to_cart_button_labels' ) ) {
/**
* Returns the main instance of Alg_WC_Add_To_Cart_Button_Labels to prevent the need to use globals.
*
* @version 1.0.0
* @since 1.0.0
* @return Alg_WC_Add_To_Cart_Button_Labels
*/
function alg_wc_add_to_cart_button_labels() {
return Alg_WC_Add_To_Cart_Button_Labels::instance();
}
}
alg_wc_add_to_cart_button_labels();