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.0.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.0.0 * @since 1.0.0 */ function includes() { // Functions // require_once( 'includes/alg-wc-add-to-cart-button-labels-functions.php' ); // Settings require_once( 'includes/admin/class-alg-wc-add-to-cart-button-labels-settings-section.php' ); $settings = array(); $settings[] = require_once( 'includes/admin/class-alg-wc-add-to-cart-button-labels-settings-general.php' ); $settings[] = require_once( 'includes/admin/class-alg-wc-add-to-cart-button-labels-settings-per-product-type.php' ); $settings[] = require_once( 'includes/admin/class-alg-wc-add-to-cart-button-labels-settings-per-category.php' ); $settings[] = require_once( 'includes/admin/class-alg-wc-add-to-cart-button-labels-settings-per-product.php' ); if ( is_admin() && get_option( 'alg_wc_add_to_cart_button_labels_version', '' ) !== $this->version ) { foreach ( $settings as $section ) { foreach ( $section->get_settings() as $value ) { if ( isset( $value['default'] ) && isset( $value['id'] ) ) { add_option( $value['id'], $value['default'], '', 'no' ); } } } update_option( 'alg_wc_add_to_cart_button_labels_version', $this->version ); } // Core require_once( 'includes/class-alg-wc-add-to-cart-button-labels-core.php' ); } /** * Add Add to Cart Button Labels 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-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();