. * **/ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } register_uninstall_hook( __FILE__, array( 'AWOOS_Custom_Sale', 'uninstall' ) ); /** * Class AWOOS_Custom_Sale * * Main AWOOS class, initialized the plugin * * @class AWOOS_Custom_Sale * @version 1.0.0 * @author Artem Abramovich */ class AWOOS_Custom_Sale { /** * Instance of AWOOS_Custom_Sale. * * @since 1.0.0 * @access private * @var object $instance The instance of AWOOS_Custom_Sale. */ private static $instance; /** * Plugin version. * * @since 1.0.0 * @var string $version Plugin version number. */ public $version; /** * Plugin name. * * @since 1.0.0 * @var string $name Plugin name. */ public $name; /** * Object settings. * * @since 1.0.0 * @var string $admin_settings */ public $admin_settings; /** * Object Front end. * * @since 1.0.0 * @var string $admin_settings */ public $front_end; /** * Construct. * * @since 1.0.0 */ public function __construct() { $this->version = $this->get_plugin_data()['ver']; $this->name = $this->get_plugin_data()['name']; // Check if WooCommerce is active require_once ABSPATH . '/wp-admin/includes/plugin.php'; if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) && ! function_exists( 'WC' ) ) { return; } $this->init(); } /** * Get the name and version of the plugin * * @return array * @since 1.0.0 */ public function get_plugin_data() { return get_file_data( __FILE__, array( 'ver' => 'Version', 'name' => 'Plugin Name', ) ); } /** * Init. * * Initialize plugin parts. * * * @since 1.0.0 */ public function init() { if ( version_compare( PHP_VERSION, '5.6', 'lt' ) ) { add_action( 'admin_notices', array( $this, 'php_version_notice' ) ); } if ( is_admin() ) { /** * Settings */ require_once plugin_dir_path( __FILE__ ) . 'includes/admin/class-awoos-admin-settings.php'; $this->admin_settings = new AWOOS_Admin_Settings(); } if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { /** * Front end */ require_once plugin_dir_path( __FILE__ ) . 'includes/class-awoos-front-end.php'; $this->front_end = new AWOOS_Front_End(); } // Plugin update function add_action( 'admin_init', array( $this, 'plugin_update' ) ); // Load textdomain $this->load_textdomain(); global $pagenow; if ( 'plugins.php' === $pagenow ) { // Plugins page add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_plugin_action_links' ), 10, 2 ); } } /** * Textdomain. * * Load the textdomain based on WP language. * * @since 1.0.0 */ public function load_textdomain() { $locale = apply_filters( 'plugin_locale', get_locale(), 'art-woocommerce-custom-sale' ); // Load textdomain load_textdomain( 'art-woocommerce-custom-sale', WP_LANG_DIR . '/art-woocommerce-custom-sale/art-woocommerce-custom-sale-' . $locale . '.mo' ); load_plugin_textdomain( 'art-woocommerce-custom-sale', false, basename( dirname( __FILE__ ) ) . '/languages' ); } /** * Instance. * * An global instance of the class. Used to retrieve the instance * to use on other files/plugins/themes. * * @return object Instance of the class. * @since 1.0.0 */ public static function instance() { if ( is_null( self::$instance ) ) : self::$instance = new self(); endif; return self::$instance; } /** * Update plugin. * * Plugin update function, update data when required. * * @since 1.0.0 */ public function plugin_update() { $settings = get_option( 'awoos_format' ); update_option( 'awoos_format', isset( $settings ) ? $settings : 'sale' ); } /** * Plugin action links. * * Add links to the plugins.php page below the plugin name * and besides the 'activate', 'edit', 'delete' action links. * * @param array $links List of existing links. * @param string $file Name of the current plugin being looped. * * @return array List of modified links. * @since 1.0.0 * */ public function add_plugin_action_links( $links, $file ) { if ( plugin_basename( __FILE__ ) === $file ) : $links = array_merge( array( '' . __( 'Settings', 'art-woocommerce-custom-sale' ) . '', ), $links ); endif; return $links; } /** * Display PHP 5.6 required notice. * * Display a notice when the required PHP version is not met. * * @since 1.0.0 */ public function php_version_notice() { ?>

name ), PHP_VERSION ); ?>

method_name(); ?> * * @return object AWOOS_Custom_Sale class object. * @since 1.0.0 * */ if ( ! function_exists( 'awoos_custom_sale' ) ) : function awoos_custom_sale() { return AWOOS_Custom_Sale::instance(); } endif; awoos_custom_sale(); // Backwards compatibility $GLOBALS['awoos'] = awoos_custom_sale();