Plugin Directory

Changeset 3430729


Ignore:
Timestamp:
01/01/2026 07:35:42 PM (7 weeks ago)
Author:
artidomo
Message:

Version 2.0.0 - Complete rewrite with WooCommerce connector, One-Click-Connect, Webhook filtering, German Market/Germanized support

Location:
artidomo-print-on-demand/trunk
Files:
9 added
19 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • artidomo-print-on-demand/trunk/artidomo-print.php

    r2768501 r3430729  
    11<?php
    2 
    32/**
    4  * The plugin bootstrap file
    5  *
    6  * This file is read by WordPress to generate the plugin information in the plugin
    7  * admin area. This file also includes all of the dependencies used by the plugin,
    8  * registers the activation and deactivation functions, and defines a function
    9  * that starts the plugin.
    10  *
    11  * @link              www.artidomo.eu
    12  * @since             1.0.0
    13  * @package           Artidomo_Print
    14  *
    15  * @wordpress-plugin
    16  * Plugin Name:       artidomo print on-demand
    17  * Plugin URI:        https://www.artidomo.eu/
    18  * Description:       This is a short description of what the plugin does. It's displayed in the WordPress admin area.
    19  * Version:           1.0.0
    20  * Author:            Artidomo Team
    21  * Author URI:        https://www.artidomo.eu/impressum/
    22  * License:           GPL-3.0+
    23  * License URI:       http://www.gnu.org/licenses/gpl-3.0.html
    24  * Text Domain:       artidomo-print-on-demand
    25  * Domain Path:       /languages
     3 * Plugin Name: artidomo Print on Demand
     4 * Plugin URI: https://artidomo.eu
     5 * Description: Verbindet WooCommerce mit dem artidomo Fulfillment System für automatische Druckauftragsverarbeitung. Print on Demand, Poster, Wandbilder und mehr.
     6 * Version: 2.0.0
     7 * Author: artidomo
     8 * Author URI: https://artidomo.eu
     9 * Text Domain: artidomo-print-on-demand
     10 * Domain Path: /languages
     11 * Requires at least: 5.8
     12 * Requires PHP: 7.4
     13 * WC requires at least: 5.0
     14 * WC tested up to: 9.0
     15 * License: GPLv2 or later
     16 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    2617 */
    2718
    28 // If this file is called directly, abort.
    29 if (!defined('WPINC')) {
    30     die;
     19// Exit if accessed directly
     20if (!defined('ABSPATH')) {
     21    exit;
     22}
     23
     24// Plugin constants
     25define('ARTIDOMO_POD_VERSION', '2.0.0');
     26define('ARTIDOMO_POD_PLUGIN_DIR', plugin_dir_path(__FILE__));
     27define('ARTIDOMO_POD_PLUGIN_URL', plugin_dir_url(__FILE__));
     28define('ARTIDOMO_POD_PLUGIN_BASENAME', plugin_basename(__FILE__));
     29define('ARTIDOMO_POD_PLUGIN_SLUG', 'artidomo-print-on-demand');
     30
     31// Backend API URL (Production)
     32define('ARTIDOMO_POD_API_URL', 'https://portal.artidomo.eu/api');
     33
     34// Legacy constants for backwards compatibility
     35if (!defined('ARTIDOMO_VERSION')) {
     36    define('ARTIDOMO_VERSION', ARTIDOMO_POD_VERSION);
     37}
     38if (!defined('ARTIDOMO_PLUGIN_DIR')) {
     39    define('ARTIDOMO_PLUGIN_DIR', ARTIDOMO_POD_PLUGIN_DIR);
     40}
     41if (!defined('ARTIDOMO_PLUGIN_URL')) {
     42    define('ARTIDOMO_PLUGIN_URL', ARTIDOMO_POD_PLUGIN_URL);
     43}
     44if (!defined('ARTIDOMO_PLUGIN_BASENAME')) {
     45    define('ARTIDOMO_PLUGIN_BASENAME', ARTIDOMO_POD_PLUGIN_BASENAME);
     46}
     47if (!defined('ARTIDOMO_API_URL')) {
     48    define('ARTIDOMO_API_URL', ARTIDOMO_POD_API_URL);
    3149}
    3250
    3351/**
    34  * Currently plugin version.
    35  * Start at version 1.0.0 and use SemVer - https://semver.org
    36  * Rename this for your plugin and update it as you release new versions.
     52 * Check if WooCommerce is active
    3753 */
    38 define('ARTIDOMO_PRINT_VERSION', '1.0.0');
    39 define('ARTIDOMO_PRINT_PATH', plugin_dir_path(__FILE__));
    40 define('ARTIDOMO_API_SERVER_URL', 'https://www.artidomo.eu');
    41 define('ARTIDOMO_PRINT_URL', plugin_dir_url(__FILE__));
    42 
    43 /**
    44  * The code that runs during plugin activation.
    45  * This action is documented in includes/class-artidomo-print-activator.php
    46  */
    47 function activate_artidomo_print()
    48 {
    49     require_once plugin_dir_path(__FILE__) . 'includes/class-artidomo-print-activator.php';
    50     Artidomo_Print_Activator::activate();
     54function artidomo_pod_check_woocommerce() {
     55    if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
     56        add_action('admin_notices', 'artidomo_pod_woocommerce_missing_notice');
     57        return false;
     58    }
     59    return true;
    5160}
    5261
    5362/**
    54  * The code that runs during plugin deactivation.
    55  * This action is documented in includes/class-artidomo-print-deactivator.php
     63 * Admin notice if WooCommerce is not active
    5664 */
    57 function deactivate_artidomo_print()
    58 {
    59     require_once plugin_dir_path(__FILE__) . 'includes/class-artidomo-print-deactivator.php';
    60     Artidomo_Print_Deactivator::deactivate();
     65function artidomo_pod_woocommerce_missing_notice() {
     66    ?>
     67    <div class="notice notice-error">
     68        <p>
     69            <strong>artidomo Print on Demand</strong> benötigt WooCommerce.
     70            Bitte installiere und aktiviere <a href="<?php echo admin_url('plugin-install.php?s=woocommerce&tab=search&type=term'); ?>">WooCommerce</a> zuerst.
     71        </p>
     72    </div>
     73    <?php
    6174}
    6275
    63 register_activation_hook(__FILE__, 'activate_artidomo_print');
    64 register_deactivation_hook(__FILE__, 'deactivate_artidomo_print');
     76/**
     77 * Declare HPOS compatibility
     78 */
     79add_action('before_woocommerce_init', function() {
     80    if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
     81        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
     82    }
     83});
    6584
    6685/**
    67  * The core plugin class that is used to define internationalization,
    68  * admin-specific hooks, and public-facing site hooks.
     86 * Initialize the plugin
    6987 */
    70 require plugin_dir_path(__FILE__) . 'includes/class-artidomo-print.php';
     88function artidomo_pod_init() {
     89    // Check WooCommerce dependency
     90    if (!artidomo_pod_check_woocommerce()) {
     91        return;
     92    }
     93
     94    // Load classes
     95    require_once ARTIDOMO_POD_PLUGIN_DIR . 'includes/class-one-click-connect.php';
     96    require_once ARTIDOMO_POD_PLUGIN_DIR . 'includes/class-webhook-filter.php';
     97    require_once ARTIDOMO_POD_PLUGIN_DIR . 'includes/class-plugin-detector.php';
     98    require_once ARTIDOMO_POD_PLUGIN_DIR . 'includes/class-csv-handler.php';
     99    require_once ARTIDOMO_POD_PLUGIN_DIR . 'includes/class-plugin-updater.php';
     100    require_once ARTIDOMO_POD_PLUGIN_DIR . 'includes/class-checkout-fields.php';
     101    require_once ARTIDOMO_POD_PLUGIN_DIR . 'admin/class-admin-interface.php';
     102
     103    // Initialize components
     104    Artidomo_One_Click_Connect::init();
     105    Artidomo_Webhook_Filter::init();
     106    Artidomo_Plugin_Detector::init();
     107    Artidomo_CSV_Handler::init();
     108    Artidomo_POD_Plugin_Updater::init();
     109    Artidomo_Checkout_Fields::init();
     110    Artidomo_Admin_Interface::init();
     111}
     112add_action('plugins_loaded', 'artidomo_pod_init');
    71113
    72114/**
    73  * Begins execution of the plugin.
    74  *
    75  * Since everything within the plugin is registered via hooks,
    76  * then kicking off the plugin from this point in the file does
    77  * not affect the page life cycle.
    78  *
    79  * @since    1.0.0
     115 * Activation hook
    80116 */
    81 function run_artidomo_print()
    82 {
     117function artidomo_pod_activate() {
     118    // Check WooCommerce
     119    if (!artidomo_pod_check_woocommerce()) {
     120        deactivate_plugins(ARTIDOMO_POD_PLUGIN_BASENAME);
     121        wp_die(
     122            'artidomo Print on Demand benötigt WooCommerce. Bitte installiere WooCommerce zuerst.',
     123            'Plugin Activation Error',
     124            array('back_link' => true)
     125        );
     126    }
    83127
    84     $plugin = new Artidomo_Print();
    85     $plugin->run();
     128    // Create necessary database tables/options if needed
     129    update_option('artidomo_pod_version', ARTIDOMO_POD_VERSION);
     130    update_option('artidomo_pod_installed_at', current_time('mysql'));
     131
     132    // Migration: If coming from old artidomo-connector plugin, preserve settings
     133    $old_connected = get_option('artidomo_connected', false);
     134    if ($old_connected && !get_option('artidomo_pod_migrated', false)) {
     135        // Settings are already shared via legacy constants
     136        update_option('artidomo_pod_migrated', true);
     137    }
    86138}
    87 run_artidomo_print();
     139register_activation_hook(__FILE__, 'artidomo_pod_activate');
     140
     141/**
     142 * Deactivation hook
     143 */
     144function artidomo_pod_deactivate() {
     145    // Cleanup if needed (keep data by default)
     146    delete_transient('artidomo_connection_token');
     147}
     148register_deactivation_hook(__FILE__, 'artidomo_pod_deactivate');
Note: See TracChangeset for help on using the changeset viewer.