linked-variation
Last commit date
admin
3 years ago
images
3 years ago
includes
3 years ago
languages
3 years ago
public
3 years ago
LICENSE.txt
3 years ago
README.txt
3 years ago
linked-variation.php
3 years ago
linked-variation.php
118 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Plugin Name: Advanced Linked Variations for WooCommerce |
| 5 | * Plugin URI: https://www.thedotstore.com/ |
| 6 | * Description: Linked Variation for WooCommerce is a plugin that provides product variations. |
| 7 | * Version: 1.0.1 |
| 8 | * Author: theDotstore |
| 9 | * Author URI: https://www.thedotstore.com |
| 10 | * Text Domain: linked-variation |
| 11 | * Domain Path: /languages/ |
| 12 | */ |
| 13 | // If this file is called directly, abort. |
| 14 | if ( !defined( 'ABSPATH' ) ) { |
| 15 | die; |
| 16 | } |
| 17 | |
| 18 | if ( !defined( 'DSALV_PLUGIN_VERSION' ) ) { |
| 19 | define( 'DSALV_PLUGIN_VERSION', '1.0.1' ); |
| 20 | } |
| 21 | if ( !defined( 'DSALV_PLUGIN_URL' ) ) { |
| 22 | define( 'DSALV_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 23 | } |
| 24 | if ( !defined( 'DSALV_PLUGIN_NAME' ) ) { |
| 25 | define( 'DSALV_PLUGIN_NAME', 'Advanced Linked Variations for WooCommerce' ); |
| 26 | } |
| 27 | 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' ) ) { |
| 28 | /** |
| 29 | * The code that runs during plugin activation. |
| 30 | * This action is documented in includes/class-linked-variation-activator.php |
| 31 | */ |
| 32 | if ( !function_exists( 'activate_ds_advanced_linked_variations' ) ) { |
| 33 | function activate_ds_advanced_linked_variations() |
| 34 | { |
| 35 | require plugin_dir_path( __FILE__ ) . 'includes/class-linked-variation-activator.php'; |
| 36 | DSALV_Free_advanced_linked_variations_Activator::activate(); |
| 37 | } |
| 38 | |
| 39 | } |
| 40 | /** |
| 41 | * The code that runs during plugin deactivation. |
| 42 | * This action is documented in includes/class-linked-variation-deactivator.php |
| 43 | */ |
| 44 | if ( !function_exists( 'deactivate_ds_advanced_linked_variations' ) ) { |
| 45 | function deactivate_ds_advanced_linked_variations() |
| 46 | { |
| 47 | require plugin_dir_path( __FILE__ ) . 'includes/class-linked-variation-deactivator.php'; |
| 48 | DSALV_Free_advanced_linked_variations_Deactivator::deactivate(); |
| 49 | } |
| 50 | } |
| 51 | register_activation_hook( __FILE__, 'activate_ds_advanced_linked_variations' ); |
| 52 | register_deactivation_hook( __FILE__, 'deactivate_ds_advanced_linked_variations' ); |
| 53 | /** |
| 54 | * The core plugin class that is used to define internationalization, |
| 55 | * admin-specific hooks, and public-facing site hooks. |
| 56 | */ |
| 57 | require plugin_dir_path( __FILE__ ) . 'includes/class-linked-variation.php'; |
| 58 | /** |
| 59 | * Begins execution of the plugin. |
| 60 | * |
| 61 | * Since everything within the plugin is registered via hooks, |
| 62 | * then kicking off the plugin from this point in the file does |
| 63 | * not affect the page life cycle. |
| 64 | * |
| 65 | * @since 1.0.0 |
| 66 | */ |
| 67 | if ( !function_exists( 'run_ds_free_advanced_linked_variations' ) ) { |
| 68 | function run_ds_free_advanced_linked_variations() |
| 69 | { |
| 70 | $plugin = new DSALV_Advanced_Linked_Variations(); |
| 71 | $plugin->run(); |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Check Initialize plugin in case of WooCommerce plugin is missing. |
| 78 | * |
| 79 | * @since 1.0.0 |
| 80 | */ |
| 81 | if ( !function_exists( 'dsalv_initialize_plugin' ) ) { |
| 82 | function dsalv_initialize_plugin() |
| 83 | { |
| 84 | |
| 85 | 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' )) ) { |
| 86 | add_action( 'admin_notices', 'dsalv_plugin_admin_notice' ); |
| 87 | } else { |
| 88 | run_ds_free_advanced_linked_variations(); |
| 89 | } |
| 90 | |
| 91 | // Load the plugin text domain for translation. |
| 92 | load_plugin_textdomain( 'linked-variation', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 93 | } |
| 94 | |
| 95 | } |
| 96 | add_action( 'plugins_loaded', 'dsalv_initialize_plugin' ); |
| 97 | |
| 98 | /** |
| 99 | * Show admin notice in case of WooCommerce plugin is missing. |
| 100 | * |
| 101 | * @since 1.0.0 |
| 102 | */ |
| 103 | if ( !function_exists( 'dsalv_plugin_admin_notice' ) ) { |
| 104 | function dsalv_plugin_admin_notice() |
| 105 | { |
| 106 | $dsalv_plugin_name = esc_html__( 'Advanced Linked Variations', 'linked-variation' ); |
| 107 | $wc_plugin = esc_html__( 'WooCommerce', 'linked-variation' ); |
| 108 | ?> |
| 109 | <div class="error"> |
| 110 | <p> |
| 111 | <?php |
| 112 | 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>' ) ; |
| 113 | ?> |
| 114 | </p> |
| 115 | </div> |
| 116 | <?php |
| 117 | } |
| 118 | } |