linked-variation
Last commit date
admin
1 week ago
images
1 week ago
includes
1 week ago
languages
1 week ago
public
1 week ago
LICENSE.txt
1 week ago
README.md
1 week ago
README.txt
1 week ago
linked-variation.php
1 week ago
linked-variation.php
138 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Plugin Name: Advanced Linked Variations for Woocommerce |
| 5 | * Plugin URI: https://wordpress.org/plugins/linked-variation/ |
| 6 | * Description: Advanced Linked Variation allows users to show various products or product variants as variations of a WooCommerce product, without adding it as that product’s variant in reality. |
| 7 | * Version: 1.0.5 |
| 8 | * Author: theDotstore |
| 9 | * Author URI: https://www.thedotstore.com |
| 10 | * License: GPL-2.0+ |
| 11 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 12 | * Text Domain: linked-variation |
| 13 | * Domain Path: /languages/ |
| 14 | * |
| 15 | * WC requires at least: 5.1 |
| 16 | * WC tested up to: 10.8.1 |
| 17 | * WP tested up to: 7.0 |
| 18 | * Requires PHP: 5.6 |
| 19 | * Requires at least: 4.4.0 |
| 20 | */ |
| 21 | // If this file is called directly, abort. |
| 22 | if ( !defined( 'ABSPATH' ) ) { |
| 23 | die; |
| 24 | } |
| 25 | |
| 26 | if ( !defined( 'DSALV_PLUGIN_VERSION' ) ) { |
| 27 | define( 'DSALV_PLUGIN_VERSION', '1.0.5' ); |
| 28 | } |
| 29 | if ( !defined( 'DSALV_PLUGIN_URL' ) ) { |
| 30 | define( 'DSALV_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 31 | } |
| 32 | if ( !defined( 'DSALV_PLUGIN_NAME' ) ) { |
| 33 | define( 'DSALV_PLUGIN_NAME', 'Advanced Linked Variations for Woocommerce' ); |
| 34 | } |
| 35 | if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) || function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) { |
| 36 | /** |
| 37 | * The code that runs during plugin activation. |
| 38 | * This action is documented in includes/class-linked-variation-activator.php |
| 39 | */ |
| 40 | if ( !function_exists( 'activate_ds_advanced_linked_variations' ) ) { |
| 41 | function activate_ds_advanced_linked_variations() |
| 42 | { |
| 43 | require plugin_dir_path( __FILE__ ) . 'includes/class-linked-variation-activator.php'; |
| 44 | DSALV_Free_advanced_linked_variations_Activator::activate(); |
| 45 | } |
| 46 | |
| 47 | } |
| 48 | /** |
| 49 | * The code that runs during plugin deactivation. |
| 50 | * This action is documented in includes/class-linked-variation-deactivator.php |
| 51 | */ |
| 52 | if ( !function_exists( 'deactivate_ds_advanced_linked_variations' ) ) { |
| 53 | function deactivate_ds_advanced_linked_variations() |
| 54 | { |
| 55 | require plugin_dir_path( __FILE__ ) . 'includes/class-linked-variation-deactivator.php'; |
| 56 | DSALV_Free_advanced_linked_variations_Deactivator::deactivate(); |
| 57 | } |
| 58 | } |
| 59 | register_activation_hook( __FILE__, 'activate_ds_advanced_linked_variations' ); |
| 60 | register_deactivation_hook( __FILE__, 'deactivate_ds_advanced_linked_variations' ); |
| 61 | /** |
| 62 | * The core plugin class that is used to define internationalization, |
| 63 | * admin-specific hooks, and public-facing site hooks. |
| 64 | */ |
| 65 | require plugin_dir_path( __FILE__ ) . 'includes/class-linked-variation.php'; |
| 66 | /** |
| 67 | * Begins execution of the plugin. |
| 68 | * |
| 69 | * Since everything within the plugin is registered via hooks, |
| 70 | * then kicking off the plugin from this point in the file does |
| 71 | * not affect the page life cycle. |
| 72 | * |
| 73 | * @since 1.0.0 |
| 74 | */ |
| 75 | if ( !function_exists( 'run_ds_free_advanced_linked_variations' ) ) { |
| 76 | function run_ds_free_advanced_linked_variations() |
| 77 | { |
| 78 | $plugin = new DSALV_Advanced_Linked_Variations(); |
| 79 | $plugin->run(); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Check Initialize plugin in case of WooCommerce plugin is missing. |
| 86 | * |
| 87 | * @since 1.0.0 |
| 88 | */ |
| 89 | if ( !function_exists( 'dsalv_initialize_plugin' ) ) { |
| 90 | function dsalv_initialize_plugin() |
| 91 | { |
| 92 | |
| 93 | if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) && (!function_exists( 'is_plugin_active_for_network' ) || !is_plugin_active_for_network( 'woocommerce/woocommerce.php' )) ) { |
| 94 | add_action( 'admin_notices', 'dsalv_plugin_admin_notice' ); |
| 95 | } else { |
| 96 | run_ds_free_advanced_linked_variations(); |
| 97 | } |
| 98 | |
| 99 | // Load the plugin text domain for translation. |
| 100 | load_plugin_textdomain( 'linked-variation', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 101 | } |
| 102 | |
| 103 | } |
| 104 | add_action( 'plugins_loaded', 'dsalv_initialize_plugin' ); |
| 105 | |
| 106 | /** |
| 107 | * Show admin notice in case of WooCommerce plugin is missing. |
| 108 | * |
| 109 | * @since 1.0.0 |
| 110 | */ |
| 111 | if ( !function_exists( 'dsalv_plugin_admin_notice' ) ) { |
| 112 | function dsalv_plugin_admin_notice() |
| 113 | { |
| 114 | $dsalv_plugin_name = esc_html__( 'Advanced Linked Variations', 'linked-variation' ); |
| 115 | $wc_plugin = esc_html__( 'WooCommerce', 'linked-variation' ); |
| 116 | ?> |
| 117 | <div class="error"> |
| 118 | <p> |
| 119 | <?php |
| 120 | echo sprintf( esc_html__( '%1$s requires %2$s to be installed & activated!', 'linked-variation' ), '<strong>' . esc_html( $dsalv_plugin_name ) . '</strong>', '<a href="' . esc_url( 'https://wordpress.org/plugins/woocommerce/' ) . '" target="_blank"><strong>' . esc_html( $wc_plugin ) . '</strong></a>' ) ; |
| 121 | ?> |
| 122 | </p> |
| 123 | </div> |
| 124 | <?php |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Plugin compability with WooCommerce HPOS |
| 130 | * |
| 131 | * @since 1.0.2 |
| 132 | */ |
| 133 | add_action( 'before_woocommerce_init', function () { |
| 134 | if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 135 | \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 136 | } |
| 137 | } ); |
| 138 |