define_constants(); $this->asowp_save_output_settings(); $this->asowp_save_pages_settings(); $this->asowp_define_borders(); $this->asowp_define_shapes(); $this->asowp_define_fixingMethods(); register_activation_hook(__FILE__, array($this, 'activate')); register_deactivation_hook(__FILE__, array($this, 'deactivate')); add_action('admin_init', [$this, 'auto_deactivate_when_woocommerce_is_inactive']); add_filter('plugin_action_links', [$this, 'modify_action_links'], 99, 2); add_action('plugins_loaded', array($this, 'init_plugin')); add_action('admin_notices', [$this, 'check_woocommerce_install_and_version']); add_action('admin_notices', [$this, 'check_config_pageselected']); add_action('admin_notices', [$this, 'permalink_notice']); } public function modify_action_links($actions, $plugin_file) { include_once(ABSPATH . 'wp-admin/includes/plugin.php'); if ($plugin_file == plugin_basename(__FILE__)) { if (is_plugin_active('woocommerce/woocommerce.php')) { if (isset($actions['activate'])) { unset($actions['activate']); } $actions['go_pro'] = sprintf('%s', 'https://signsdesigner.us/all-signs-customizer-product/', 'color:#35b747;font-weight:bold', __('Get Premium!', 'all-signs-options-free')); $actions['go_docs'] = sprintf('%s', 'https://docs.signsdesigner.us/docs/asowp-wp-documentation/', 'color:#35b747;font-weight:bold', __('Go Docs!', 'all-signs-options-free')); } } return $actions; } public function auto_deactivate_when_woocommerce_is_inactive() { // Vérifie si WooCommerce est désactivé if (!is_plugin_active('woocommerce/woocommerce.php') && is_plugin_active(plugin_basename(__FILE__))) { // Désactive votre plugin deactivate_plugins(plugin_basename(__FILE__)); } } /** * Initializes the All_Signs_Options() class * * Checks for an existing All_Signs_Options() instance * and if it doesn't find one, creates it. */ public static function init() { static $instance = false; if (!$instance) { $instance = new ASOWP_All_Signs_Options_Free(); } return $instance; } /** * Magic getter to bypass referencing plugin. * * @param $prop * * @return mixed */ public function __get($prop) { if (array_key_exists($prop, $this->container)) { return $this->container[$prop]; } return $this->{$prop}; } /** * Magic isset to bypass referencing plugin. * * @param $prop * * @return mixed */ public function __isset($prop) { return isset($this->{$prop}) || isset($this->container[$prop]); } /** * Define the constants * * @return void */ public function define_constants() { define('ASOWP_VERSION', $this->version); define('ASOWP_ID', 3107); define('ASOWP_FILE', __FILE__); define('ASOWP_PATH', dirname(ASOWP_FILE)); define('ASOWP_INCLUDES', ASOWP_PATH . '/includes'); define('ASOWP_URL', plugins_url('', ASOWP_FILE)); define('ASOWP_ASSETS', ASOWP_URL . '/assets'); define("ASOWP_CHECK_TRANSIENT_EXPIRATION", 12 * HOUR_IN_SECONDS); // 12 hours define("ASOWP_CHECK_TRANSIENT_NAME", "wp_update_check_asowp_pro"); $upload_dir = wp_upload_dir(); $generation_path = $upload_dir['basedir'] . "/ASOWP/"; $generation_url = $upload_dir['baseurl'] . "/ASOWP/"; define('ASOWP_IMAGE_PATH', $generation_path . "images"); define('ASOWP_IMAGE_URL', $generation_url . "images"); define('ASOWP_ORDER_PATH', $generation_path . "ORDERS"); define('ASOWP_ORDER_URL', $generation_url . "ORDERS"); define('ASOWP_DATA_PATH', $generation_path . "data"); define('ASOWP_DATA_URL', $generation_url . "data"); } private function asowp_save_output_settings() { $output_settings = [ "zipName" => true, "calculateOutput" => true ]; $have_output_settings = get_option("asowp_output_options"); if ($have_output_settings == false) { update_option("asowp_output_options", $output_settings); } } private function asowp_save_pages_settings() { $pages_settings = [ "configuratorPage" => 0, "templatePage" => 0, "buttons" => [ "productDesignButton" => 'Customize The Product', "productTemplateButton" => 'Design From Example', "templateAddToCartButton" => 'Add To Cart', "templateDesignButton" => 'Customize', "allTemplatesText" => 'All', "recapsButtonOnCart" => 'Sign Recaps' ], "others" => [ "titleBalise" => 'h1' ], ]; $have_pages_settings = get_option("asowp_config_page"); if ($have_pages_settings == false) { update_option("asowp_config_page", $pages_settings); } else { $differenceCles = array_diff_key($pages_settings, $have_pages_settings); if (count($differenceCles) > 0) { foreach ($differenceCles as $key => $value) { $have_pages_settings[$key] = $value; } update_option("asowp_config_page", $have_pages_settings); } } } private function asowp_define_borders() { $borders = [ [ 'name' => 'None', "icon" => ASOWP_ASSETS . '/images/borders/ic_border_none.svg', 'value' => 'none' ], [ 'name' => 'Normal', "icon" => ASOWP_ASSETS . '/images/borders/ic_border_thin.svg', 'value' => 'normal' ], ]; update_option("asowp_all_borders", $borders); } private function asowp_define_shapes() { $shapes = [ [ 'name' => 'Oval', "icon" => ASOWP_ASSETS . '/images/shapes/ic_shape_oval.svg', 'value' => 'oval' ], [ 'name' => 'Square', "icon" => ASOWP_ASSETS . '/images/shapes/ic_shape_square.svg', 'value' => 'square' ], [ 'name' => 'Triangle', "icon" => ASOWP_ASSETS . '/images/shapes/ic_shape_triangle.svg', 'value' => 'triangle' ], ]; update_option("asowp_all_shapes", $shapes); } private function asowp_define_fixingMethods() { $fixingMethods = [ [ 'name' => 'None', "description" => "", "icon" => ASOWP_ASSETS . '/images/fixing-methodes/ic_fixmethod_none.svg', "popImg" => "", 'type' => 'none' ], [ 'name' => 'Adhesive Tape', "description" => "", "icon" => ASOWP_ASSETS . '/images/fixing-methodes/ic_fixmethod_adhesive_tape.svg', "popImg" => "", 'type' => 'adhesive-tape' ], [ 'name' => 'Screw', "description" => "", "icon" => ASOWP_ASSETS . '/images/fixing-methodes/ic_fixmethod_screw.svg', "popImg" => "", 'type' => 'screw' ], ]; update_option("asowp_all_fixingMethods", $fixingMethods); } /** * Load the plugin after all plugins are loaded * * @return void */ public function init_plugin() { $this->includes(); $this->init_hooks(); } /** * Placeholder for activation function * * Nothing being called here yet. */ public function activate() { if (is_plugin_active('woocommerce/woocommerce.php')) { $installed = get_option('ASOWP_installed'); if (!$installed) { update_option('ASOWP_installed', time()); } update_option('ASOWP_version', ASOWP_VERSION); } } /** * Placeholder for deactivation function * * Nothing being called here yet. */ public function deactivate() { } /** * Include the required files * * @return void */ public function includes() { //require_once ASOWP_INCLUDES . '/Assets.php'; if ($this->is_request('admin')) { require_once ASOWP_INCLUDES . '/Admin.php'; } if ($this->is_request('frontend')) { require_once ASOWP_INCLUDES . '/Frontend.php'; } if ($this->is_request('ajax')) { // require_once ASOWP_INCLUDES . '/class-ajax.php'; } require_once ASOWP_INCLUDES . '/Api.php'; require_once ASOWP_INCLUDES . '/asowp-post-type.php'; require_once ASOWP_INCLUDES . '/asowp-design.php'; require_once ASOWP_INCLUDES . '/asowp-product-config.php'; require_once ASOWP_INCLUDES . '/Functions.php'; require_once ASOWP_INCLUDES . '/Public.php'; } /** * Initialize the hooks * * @return void */ public function init_hooks() { add_action('init', array($this, 'init_classes')); (new ASOWP_Post_Type())->init_hooks(); (new ASOWP_Product_Config())->init_hooks(); (new ASOWP_Design())->init_hooks(); // Localize our plugin add_action('init', array($this, 'localization_setup')); } /** * Instantiate the required classes * * @return void */ public function init_classes() { if ($this->is_request('admin')) { $this->container['admin'] = new ASOWP\ASOWP_Admin(); } if ($this->is_request('frontend')) { $this->container['frontend'] = new ASOWP\ASOWP_Frontend(); } if ($this->is_request('ajax')) { // $this->container['ajax'] = new ASOWP\Ajax(); } $this->container['api'] = new ASOWP\Api(); $this->container['public'] = new ASOWP\ASOWP_Public(); //$this->container['assets'] = new ASOWP\Assets(); } /** * Initialize plugin for localization * * @uses load_plugin_textdomain() */ public function localization_setup() { load_plugin_textdomain("all-signs-options-free", false, dirname(plugin_basename(__FILE__)) . '/languages/'); } /** * What type of request is this? * * @param string $type admin, ajax, cron or frontend. * * @return bool */ private function is_request($type) { switch ($type) { case 'admin': return is_admin(); case 'ajax': return defined('DOING_AJAX'); case 'rest': return defined('REST_REQUEST'); case 'cron': return defined('DOING_CRON'); case 'frontend': return (!is_admin() || defined('DOING_AJAX')) && !defined('DOING_CRON'); } } public function check_config_pageselected() { if (class_exists('WooCommerce')) { $PageSettings = get_option('asowp_config_page', []); if (count($PageSettings) == 0) { ?>
here', "all-signs-options-free"); ?>
here', "all-signs-options-free"); ?>
install_plugin_button('woocommerce', 'woocommerce.php', 'WooCommerce', array(), __('WooCommerce activated', "all-signs-options-free"), __('Activate WooCommerce', "all-signs-options-free"), __('Install WooCommerce', "all-signs-options-free")); ?>