Your IP : 216.73.216.164


Current Path : /var/www/html/afc2023/wp-content/plugins/eea-pricing/
Upload File :
Current File : /var/www/html/afc2023/wp-content/plugins/eea-pricing/eea-pricing.php

<?php
/*
  Plugin Name: Price Modifier For Event Espresso 4
  Author: Aparna
  Description: Enables selling additional items with event registration.
  Author URI: http://aparnascodex.com
  Plugin URI:  http://aparnascodex.com/downloads/price-modifier-for-event-espresso-4
  Version: 1.0.1
 */

include_once 'license_settings.php';

define('EDD_SL_PRICING_STORE_URL', 'http://aparnascodex.com');
define('EDD_SL_PRICING_ITEM_NAME', 'Price Modifier For Event Espresso 4');
define('EDD_EE_Pricing_Addon_LICENSE_PAGE', 'espresso_pricing');

define('EE_PRICE_CORE_VERSION_REQUIRED', '4.9.26.rc.0000');
define('EE_PRICE_VERSION', '1.0.1');
define('EE_PRICE_PLUGIN_FILE', __FILE__);
 
if (!class_exists('EDD_SL_Plugin_Updater')) {
    
    include('licensing/EDD_SL_Plugin_Updater.php');
}

$license_key = trim(get_option('ssa_ee_pricing_license_key'));

$edd_updater = new EDD_SL_Plugin_Updater(EDD_SL_PRICING_STORE_URL, __FILE__, array(
    'version'   => '1.0.1',       // current version number
    'license'   => $license_key,    // license key (used get_option above to retrieve from DB)
    'item_name'     => EDD_SL_PRICING_ITEM_NAME,    // name of this plugin
    'author'    => 'Aparna', // author of this plugin
    'url'           => home_url()
));



/**
 *    captures plugin activation errors for debugging
 */
function ssa_price_plugin_activation_errors()
{

    if (WP_DEBUG) {
        echo $activation_errors = ob_get_contents();
        
    }
}
add_action('activated_plugin', 'ssa_price_plugin_activation_errors');

/**
 *    registers addon with EE core
 */
function ssa_load_espresso_pricing_file()
{
    if (class_exists('EE_Addon')) {
        // new_addon version
        $key = get_option('ssa_ee_pricing_license_key');
        $status = get_option('ssa_ee_pricing_license_status');
        if($key !='' && $status =='valid')
        {
            require_once(plugin_dir_path(__FILE__) . 'EE_Pricing.class.php');
            EE_Pricing::register_addon();
        }
           
    } else {
        add_action('admin_notices', 'ssa_price_activation_error');
    }
}
add_action('AHEE__EE_System__load_espresso_addons', 'ssa_load_espresso_pricing_file', 11);
 
/**
 *    verifies that addon was activated
 */
function ssa_price_addon_activation_check()
{
    if (! did_action('AHEE__EE_System__load_espresso_addons')) {
        add_action('admin_notices', 'ssa_price_activation_error');
    }
}
add_action('init', 'ssa_price_addon_activation_check', 1);

/**
 *    displays activation error admin notice
 */
function ssa_price_activation_error()
{
    unset($_GET[ 'activate' ]);
    unset($_REQUEST[ 'activate' ]);
    if (! function_exists('deactivate_plugins')) {
        require_once(ABSPATH . 'wp-admin/includes/plugin.php');
    }
    deactivate_plugins(plugin_basename(EE_PRICE_PLUGIN_FILE));
    ?>
  <div class="error">
    <p><?php printf(__('<b>"Event Espresso - Pricing" </b> add on could not be activated. Please ensure that Event Espresso version %1$s or higher is active', 'wordprice'), EE_PRICE_CORE_VERSION_REQUIRED); ?></p>
  </div>
<?php
}


function ssa_create_price_tbl()
{

    global $wpdb;
    
    $type_table = $wpdb->prefix.'esp_question_price_type';
    $price_table = $wpdb->prefix.'esp_question_price_opt';
    
    if ($wpdb->get_var("show tables like '$type_table'") != $type_table) {
        $sql = "CREATE TABLE " . $type_table . " (
        id int NOT NULL AUTO_INCREMENT,
        qst_id int,
        type varchar(15),
        Primary Key (id)
        );";
 
        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);
    }
    if ($wpdb->get_var("SHOW COLUMNS FROM $type_table LIKE 'taxable'") != 'taxable') {
             $sql = "ALTER TABLE $type_table ADD COLUMN (taxable int)";
            $wpdb->query($sql);
    }
    if ($wpdb->get_var("show tables like '$price_table'") != $price_table) {
        $sql = "CREATE TABLE " . $price_table . " (
        id int NOT NULL AUTO_INCREMENT,
        qst_id int,
        OPT_DESC varchar(200),
        OPT_PRICE float(5),
        Primary Key (id)
        );";
 
        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);
    }
}
register_activation_hook(__FILE__, 'ssa_create_price_tbl');

add_action( 'upgrader_process_complete', 'ssa_upgrate_table',10, 2);

function ssa_upgrate_table( $upgrader_object, $options ) {
    global $wpdb;
    
    $type_table = $wpdb->prefix.'esp_question_price_type';
    $current_plugin_path_name = plugin_basename( __FILE__ );

    if ($options['action'] == 'update' && $options['type'] == 'plugin' ){
       foreach($options['plugins'] as $each_plugin){
          if ($each_plugin==$current_plugin_path_name){
            
             if ($wpdb->get_var("SHOW COLUMNS FROM $type_table LIKE 'taxable'") != 'taxable') {
                $sql = "ALTER TABLE $type_table ADD COLUMN (taxable int)";
                $wpdb->query($sql);
            }

          }
       }
    }
}