function vtprd_pricing_deal_msgs_advanced($atts)
{
    global $vtprd_rules_set, $vtprd_setup_options, $vtprd_info;
    extract(shortcode_atts(array('group1_type' => 'cart', 'group1_and_or_wholestore_msgs_only' => 'and', 'group1_wholestore_msgs_only' => 'no', 'and_or_group1_to_group2' => 'and', 'group2_rules' => '', 'group2_and_or_roles' => 'and', 'group2_roles' => '', 'and_or_group2_to_group3' => 'and', 'group3_product_category' => '', 'group3_and_or_plugin_category' => 'or', 'group3_plugin_category' => ''), $atts));
    //override default value with supplied parameters...
    vtprd_set_selected_timezone();
    $vtprd_rules_set = get_option('vtprd_rules_set');
    $output = '<div class="vtprd-advanced-deal-msg-area">';
    $msg_counter = 0;
    //echo 'incoming attributes= ' .$atts. '<br>'; //mwnt
    $sizeof_rules_set = sizeof($vtprd_rules_set);
    for ($i = 0; $i < $sizeof_rules_set; $i++) {
        if ($vtprd_rules_set[$i]->rule_status != 'publish') {
            continue;
        }
        $rule_is_date_valid = vtprd_rule_date_validity_test($i);
        if (!$rule_is_date_valid) {
            continue;
        }
        if (defined('VTPRD_PRO_DIRNAME') && $vtprd_setup_options['use_lifetime_max_limits'] == 'yes') {
            //IP is immediately available, check against Lifetime limits
            $rule_has_reached_lifetime_limit = vtprd_rule_lifetime_validity_test($i, 'shortcode');
            if ($rule_has_reached_lifetime_limit) {
                continue;
            }
        }
        //v1.0.9.3 new skipt test
        if ($vtprd_rules_set[$i]->discount_product_full_msg == $vtprd_info['default_full_msg']) {
            //v1.1.0.5
            continue;
        }
        $status = array('group1_type' => '', 'group1_wholestore_msgs_only' => '', 'group2_rules' => '', 'group2_roles' => '', 'group3_product_category' => '', 'group3_plugin_category' => '', 'group1' => '', 'group2' => '', 'group3' => '', 'total' => '');
        //SET Status success/failed for each parameter
        switch ($group1_type) {
            case 'cart':
                if ($vtprd_rules_set[$i]->rule_execution_type == 'display') {
                    $status['group1_type'] = 'failed';
                } else {
                    $status['group1_type'] = 'success';
                }
                break;
            case 'catalog':
                if ($vtprd_rules_set[$i]->rule_execution_type == 'cart') {
                    $status['group1_type'] = 'failed';
                } else {
                    $status['group1_type'] = 'success';
                }
                break;
            case 'all':
                $status['group1_type'] = 'success';
                break;
            default:
                $status['group1_type'] = 'failed';
                break;
        }
        if ($group1_wholestore_msgs_only == 'yes') {
            if ($vtprd_rules_set[$i]->inPop == 'wholeStore' || $vtprd_rules_set[$i]->actionPop == 'wholeStore') {
                $status['group1_wholestore_msgs_only'] = 'success';
            } else {
                $status['group1_wholestore_msgs_only'] = 'failed';
            }
        } else {
            $status['group1_wholestore_msgs_only'] = 'success';
        }
        if ($group2_roles > ' ') {
            $userRole = vtprd_get_current_user_role();
            //mwn04142014
            if ($userRole = 'notLoggedIn') {
                $userRole_name = 'Not logged in (just visiting)';
            } else {
                $userRole_name = translate_user_role($userRole);
            }
            $group2_roles_array = explode(",", $group2_roles);
            //remove comma separator, make list an array
            if (in_array($userRole_name, $group2_roles_array)) {
                $status['group2_roles'] = 'success';
            } else {
                $status['group2_roles'] = 'failed';
            }
        } else {
            $status['group2_roles'] = 'success';
        }
        if ($group2_rules > ' ') {
            $group2_rules_array = explode(",", $group2_rules);
            //remove comma separator, make list an array
            if (in_array($vtprd_rules_set[$i]->post_id, $group2_rules_array)) {
                $status['group2_rules'] = 'success';
            } else {
                $status['group2_rules'] = 'failed';
            }
        } else {
            $status['group2_rules'] = 'success';
        }
        if ($group3_product_category > ' ') {
            $group3_product_category_array = explode(",", $group3_product_category);
            //remove comma separator, make list an array
            if (array_intersect($vtprd_rules_set[$i]->prodcat_in_checked, $group3_product_category_array) || array_intersect($vtprd_rules_set[$i]->prodcat_out_checked, $group3_product_category_array)) {
                $status['group3_product_category'] = 'success';
            } else {
                $status['group3_product_category'] = 'failed';
            }
        } else {
            $status['group3_product_category'] = 'success';
        }
        if ($group3_plugin_category > ' ') {
            $group3_plugin_category_array = explode(",", $group3_plugin_category);
            //remove comma separator, make list an array
            if (array_intersect($vtprd_rules_set[$i]->rulecat_in_checked, $group3_plugin_category_array) || array_intersect($vtprd_rules_set[$i]->rulecat_out_checked, $group3_plugin_category_array)) {
                $status['group3_plugin_category'] = 'success';
            } else {
                $status['group3_plugin_category'] = 'failed';
            }
        } else {
            $status['group3_plugin_category'] = 'success';
        }
        //Evaluate status settings
        //evaluate group1
        switch ($group1_and_or_wholestore_msgs_only) {
            case 'and':
                if ($status['group1_type'] == 'success' && $status['group1_wholestore_msgs_only'] == 'success') {
                    $status['group1'] = 'success';
                } else {
                    $status['group1'] = 'failed';
                }
                break;
            case 'or':
                if ($status['group1_type'] == 'success' || $status['group1_wholestore_msgs_only'] == 'success') {
                    $status['group1'] = 'success';
                } else {
                    $status['group1'] = 'failed';
                }
                break;
            default:
                $status['group1'] = 'failed';
                break;
        }
        //evaluate group2
        switch ($group2_and_or_roles) {
            case 'and':
                if ($status['group2_rules'] == 'success' && $status['group2_roles'] == 'success') {
                    $status['group2'] = 'success';
                } else {
                    $status['group2'] = 'failed';
                }
                break;
            case 'or':
                if ($status['group2_rules'] == 'success' || $status['group2_roles'] == 'success') {
                    $status['group2'] = 'success';
                } else {
                    $status['group2'] = 'failed';
                }
                break;
            default:
                $status['group2'] = 'failed';
                break;
        }
        //evaluate group3
        switch ($group3_and_or_plugin_category) {
            case 'and':
                if ($status['group3_product_category'] == 'success' && $status['group3_plugin_category'] == 'success') {
                    $status['group3'] = 'success';
                } else {
                    $status['group3'] = 'failed';
                }
                break;
            case 'or':
                if ($status['group3_product_category'] == 'success' || $status['group3_plugin_category'] == 'success') {
                    $status['group3'] = 'success';
                } else {
                    $status['group3'] = 'failed';
                }
                break;
            default:
                $status['group3'] = 'failed';
                break;
        }
        //evaluate all 3 groups together
        switch (true) {
            case $and_or_group1_to_group2 == 'and' && $and_or_group2_to_group3 == 'and':
                if ($status['group1'] == 'success' && $status['group2'] == 'success' && $status['group3'] == 'success') {
                    $status['total'] = 'success';
                } else {
                    $status['total'] = 'failed';
                }
                break;
            case $and_or_group1_to_group2 == 'and' && $and_or_group2_to_group3 == 'or':
                if ($status['group1'] == 'success' && $status['group2'] == 'success' || $status['group3'] == 'success') {
                    $status['total'] = 'success';
                } else {
                    $status['total'] = 'failed';
                }
                break;
            case $and_or_group1_to_group2 == 'or' && $and_or_group2_to_group3 == 'and':
                if (($status['group1'] == 'success' || $status['group2'] == 'success') && $status['group3'] == 'success') {
                    $status['total'] = 'success';
                } else {
                    $status['total'] = 'failed';
                }
                break;
            case $and_or_group1_to_group2 == 'or' && $and_or_group2_to_group3 == 'or':
                if ($status['group1'] == 'success' || $status['group2'] == 'success' || $status['group3'] == 'success') {
                    $status['total'] = 'success';
                } else {
                    $status['total'] = 'failed';
                }
                break;
        }
        if ($status['total'] == 'success') {
            $msg_counter++;
            $output .= '<span class="vtprd-advanced-deal-msg" id="vtprd-advanced-deal-msg-' . $vtprd_rules_set[$i]->post_id . '">';
            $output .= stripslashes($vtprd_rules_set[$i]->discount_product_full_msg);
            $output .= '</span>';
            $output .= '<span class="vtprd-line-skip-with-display-block"></span>';
        }
    }
    //end 'for' loop
    if ($msg_counter == 0) {
        return;
    }
    //close owning div
    $output .= '</div>';
    //  vtprd_enqueue_front_end_css();
    return $output;
}
Ejemplo n.º 2
0
function vtprd_apply_rules_to_single_product($product_id, $price = null)
{
    global $post, $vtprd_cart, $vtprd_cart_item, $vtprd_info, $vtprd_rules_set, $vtprd_rule;
    vtprd_set_selected_timezone();
    vtprd_load_vtprd_cart_for_single_product_price($product_id, $price);
    $vtprd_info['current_processing_request'] = 'display';
    $vtprd_apply_rules = new VTPRD_Apply_Rules();
    //also moves the data to $vtprd_info
    vtprd_move_vtprd_single_product_to_session($product_id);
    //return formatted price; if discounted, store price, orig price and you_save in session id
    //  if no discount, formatted DB price returned, no session variable stored
    //price result stored in $vtprd_info['product_session_info']
    return;
}
 public function vtprd_controller_init()
 {
     global $vtprd_setup_options;
     //$product->get_rating_count() odd error at checkout... woocommerce/templates/single-product-reviews.php on line 20
     //  (Fatal error: Call to a member function get_rating_count() on a non-object)
     global $product;
     load_plugin_textdomain('vtprd', null, dirname(plugin_basename(__FILE__)) . '/languages');
     //v1.0.8.4  moved here above defs
     //v1.0.9.3 info not avail here
     //if ($vtprd_setup_options['discount_taken_where'] == 'discountCoupon') { //v1.0.9.0  doesn't apply if 'discountUnitPrice'
     //v1.0.8.5 begin
     // instead of translation, using filter to allow title change!!!!!!!!
     //  this propagates throughout all plugin code execution through global...
     $coupon_title = apply_filters('vtprd_coupon_code_discount_title', '');
     if ($coupon_title) {
         global $vtprd_info;
         $vtprd_info['coupon_code_discount_deal_title'] = $coupon_title;
     }
     // }  //v1.0.9.0
     /*
     // Sample filter execution ==>>  put into your theme's functions.php file, so it's not affected by plugin updates
           function coupon_code_discount_title() {
             return 'different coupon title';  //<<==  Change this text to be the title you want!!!
           }
           add_filter('vtprd_coupon_code_discount_title', 'coupon_code_discount_title', 10);         
     */
     //v1.0.8.5 end
     //Split off for AJAX add-to-cart, etc for Class resources.  Loads for is_Admin and true INIT loads are kept here.
     //require_once ( VTPRD_DIRNAME . '/core/vtprd-load-execution-resources.php' );
     require_once VTPRD_DIRNAME . '/core/vtprd-backbone.php';
     require_once VTPRD_DIRNAME . '/core/vtprd-rules-classes.php';
     require_once VTPRD_DIRNAME . '/admin/vtprd-rules-ui-framework.php';
     require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-functions.php';
     require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-theme-functions.php';
     require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-cart-validation.php';
     //  require_once  ( VTPRD_DIRNAME . '/woo-integration/vtprd-parent-definitions.php');    //v1.0.8.4  moved above
     require_once VTPRD_DIRNAME . '/core/vtprd-cart-classes.php';
     //************
     //changed for AJAX add-to-cart, removed the is_admin around these resources => didn't work, for whatever reason...
     if (defined('VTPRD_PRO_DIRNAME')) {
         require_once VTPRD_PRO_DIRNAME . '/core/vtprd-apply-rules.php';
         require_once VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php';
     } else {
         require_once VTPRD_DIRNAME . '/core/vtprd-apply-rules.php';
     }
     $vtprd_setup_options = get_option('vtprd_setup_options');
     //put the setup_options into the global namespace
     //**************************
     //v1.0.9.0 begin
     //**************************
     switch (true) {
         case is_admin():
             //absolutely REQUIRED!!!
             $do_nothing;
             break;
         case $vtprd_setup_options['discount_taken_where'] == 'discountCoupon':
             $do_nothing;
             break;
         case $vtprd_setup_options['discount_taken_where'] == 'discountUnitPrice':
             //turn off switches not allowed for "discountUnitPrice" ==> done on the fly, rather than at update time...
             $vtprd_setup_options['show_checkout_purchases_subtotal'] = 'none';
             $vtprd_setup_options['show_checkout_discount_total_line'] = 'no';
             $vtprd_setup_options['checkout_new_subtotal_line'] = 'no';
             $vtprd_setup_options['show_cartWidget_purchases_subtotal'] = 'none';
             $vtprd_setup_options['show_cartWidget_discount_total_line'] = 'no';
             $vtprd_setup_options['cartWidget_new_subtotal_line'] = 'no';
             break;
         default:
             // supply default for new variables as needed for upgrade v1.0.8.9 => v1.0.9.0 as needed
             $vtprd_setup_options['discount_taken_where'] = 'discountCoupon';
             $vtprd_setup_options['give_more_or_less_discount'] = 'more';
             $vtprd_setup_options['show_unit_price_cart_discount_crossout'] = 'yes';
             //v1.0.9.3 ==> for help when switching to unit pricing...
             $vtprd_setup_options['show_unit_price_cart_discount_computation'] = 'no';
             //v1.0.9.3
             update_option('vtprd_setup_options', $vtprd_setup_options);
             //v1.0.9.1
             break;
     }
     //v1.0.9.0 end
     if (function_exists('vtprd_debug_options')) {
         vtprd_debug_options();
         //v1.0.5
     }
     /*  **********************************
             Set GMT time zone for Store 
         Since Web Host can be on a different
         continent, with a different *Day* and Time,
         than the actual store.  Needed for Begin/end date processing
         **********************************  */
     vtprd_set_selected_timezone();
     if (is_admin()) {
         add_filter('plugin_action_links_' . VTPRD_PLUGIN_SLUG, array($this, 'vtprd_custom_action_links'));
         require_once VTPRD_DIRNAME . '/admin/vtprd-setup-options.php';
         require_once VTPRD_DIRNAME . '/admin/vtprd-rules-ui.php';
         if (defined('VTPRD_PRO_DIRNAME')) {
             require_once VTPRD_PRO_DIRNAME . '/admin/vtprd-rules-update.php';
             require_once VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php';
         } else {
             require_once VTPRD_DIRNAME . '/admin/vtprd-rules-update.php';
         }
         require_once VTPRD_DIRNAME . '/admin/vtprd-show-help-functions.php';
         require_once VTPRD_DIRNAME . '/admin/vtprd-checkbox-classes.php';
         require_once VTPRD_DIRNAME . '/admin/vtprd-rules-delete.php';
         $this->vtprd_admin_init();
         //v1.0.7.1 begin
         /* v1.1.0.1  replaced with new notification at admin_init
            if ( (defined('VTPRD_PRO_DIRNAME')) &&
                 (version_compare(VTPRD_PRO_VERSION, VTPRD_MINIMUM_PRO_VERSION) < 0) ) {    //'<0' = 1st value is lower  
              add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_version_mismatch') );            
            }
            */
         //v1.0.7.1 end
         /* //v1.0.9.3 moved to functions to be run at admin-init time
            if ($vtprd_setup_options['discount_taken_where'] == 'discountCoupon') { //v1.0.9.3  doesn't apply if 'discountUnitPrice'
            //v1.0.7.4 begin  
              //****************************************
              //INSIST that coupons be enabled in woo, in order for this plugin to work!!
              //****************************************
              //always check if the manually created coupon codes are there - if not create them.
              vtprd_woo_maybe_create_coupon_types();        
              $coupons_enabled = get_option( 'woocommerce_enable_coupons' ) == 'no' ? false : true;
              if (!$coupons_enabled) {  
                add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_coupon_enable_required') );            
              } 
            }
            */
         // don't have to do this EXCEPT at install time....
         //    $this->vtprd_maybe_add_wholesale_role(); //v1.0.9.0
         //v1.0.7.4 end
     } else {
         add_action("wp_enqueue_scripts", array(&$this, 'vtprd_enqueue_frontend_scripts'), 1);
         //priority 1 to run 1st, so front-end-css can be overridden by another file with a dependancy
     }
     /*
         if (is_admin()){ 
     
     //LIFETIME logid cleanup...
     //  LogID logic from wpsc-admin/init.php
     if(defined('VTPRD_PRO_DIRNAME')) {
       switch( true ) {
         case ( isset( $_REQUEST['wpsc_admin_action2'] ) && ($_REQUEST['wpsc_admin_action2'] == 'purchlog_bulk_modify') )  :
                vtprd_maybe_lifetime_log_bulk_modify();
            break; 
         case ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_purchlog') ) :
                vtprd_maybe_lifetime_log_roll_out_cntl();
            break;                                             
       } 
         
       if (version_compare(VTPRD_PRO_VERSION, VTPRD_MINIMUM_PRO_VERSION) < 0) {    //'<0' = 1st value is lower  
         add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_version_mismatch') );            
       }          
     }
     
     //****************************************
     //INSIST that coupons be enabled in woo, in order for this plugin to work!!
     //****************************************
     $coupons_enabled = get_option( 'woocommerce_enable_coupons' ) == 'no' ? false : true;
     if (!$coupons_enabled) {  
       add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_coupon_enable_required') );            
     } 
         } 
     */
     return;
 }
Ejemplo n.º 4
0
 public function vtprd_controller_init()
 {
     //error_log( print_r(  'Function begin - vtprd_controller_init', true ) );
     global $vtprd_setup_options;
     //$product->get_rating_count() odd error at checkout... woocommerce/templates/single-product-reviews.php on line 20
     //  (Fatal error: Call to a member function get_rating_count() on a non-object)
     global $product;
     load_plugin_textdomain('vtprd', null, dirname(plugin_basename(__FILE__)) . '/languages');
     //v1.0.8.4  moved here above defs
     //v1.0.9.3 info not avail here
     //if ($vtprd_setup_options['discount_taken_where'] == 'discountCoupon') { //v1.0.9.0  doesn't apply if 'discountUnitPrice'
     //v1.0.8.5 begin
     // instead of translation, using filter to allow title change!!!!!!!!
     //  this propagates throughout all plugin code execution through global...
     $coupon_title = apply_filters('vtprd_coupon_code_discount_title', '');
     if ($coupon_title) {
         global $vtprd_info;
         $vtprd_info['coupon_code_discount_deal_title'] = $coupon_title;
     }
     // }  //v1.0.9.0
     /*
     // Sample filter execution ==>>  put into your theme's functions.php file, so it's not affected by plugin updates
           function coupon_code_discount_title() {
             return 'different coupon title';  //<<==  Change this text to be the title you want!!!
           }
           add_filter('vtprd_coupon_code_discount_title', 'coupon_code_discount_title', 10);         
     */
     //v1.0.8.5 end
     //Split off for AJAX add-to-cart, etc for Class resources.  Loads for is_Admin and true INIT loads are kept here.
     //require_once ( VTPRD_DIRNAME . '/core/vtprd-load-execution-resources.php' );
     require_once VTPRD_DIRNAME . '/core/vtprd-backbone.php';
     require_once VTPRD_DIRNAME . '/core/vtprd-rules-classes.php';
     require_once VTPRD_DIRNAME . '/admin/vtprd-rules-ui-framework.php';
     require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-functions.php';
     require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-theme-functions.php';
     require_once VTPRD_DIRNAME . '/woo-integration/vtprd-parent-cart-validation.php';
     //  require_once  ( VTPRD_DIRNAME . '/woo-integration/vtprd-parent-definitions.php');    //v1.0.8.4  moved above
     require_once VTPRD_DIRNAME . '/core/vtprd-cart-classes.php';
     require_once VTPRD_DIRNAME . '/core/vtprd-cron-class.php';
     //v1.1.6
     //***************
     //v1.1.5 begin
     // Licensing and Phone Home ONLY occurs when the purchased PRO version is installed
     //***************
     require_once VTPRD_DIRNAME . '/admin/vtprd-license-options.php';
     global $vtprd_license_options;
     $vtprd_license_options = get_option('vtprd_license_options');
     $this->vtprd_init_update_license();
     if ($vtprd_setup_options['debugging_mode_on'] == 'yes') {
         error_log(print_r('Begin FREE plugin, vtprd_license_options= ', true));
         error_log(var_export($vtprd_license_options, true));
     }
     /*
     //*********************************************************
       VTPRD_PRO_DIRNAME trigger for Pro functionality...
       ONLY if PRO is active 
        if fatal status, deactivate PRO
        if pending status and ADMIN, load PRO stuff
        if pending status and EXECUTION, load FREE stuff
       Otherwise, load FREE
     //*********************************************************
     */
     //v1.1.6 begin
     /*
     NOW DO IN A CRON JOB
         //moved here
         if (is_admin) {
           $test_done_elsewhere = true;
         } else {
     //error_log( print_r(  'vtprd_maybe_recheck_license_activation CART ', true ) ); 
           vtprd_maybe_recheck_license_activation(); //v1.1.6  added 1/12hr license recheck to SHOP function too.
         }
     */
     //v1.1.6 end
     $avanti = false;
     //v1.1.5
     //VTPRD_PRO_VERSION only exists if PRO version is installed and active
     if (defined('VTPRD_PRO_VERSION')) {
         switch (true) {
             //if fatal status, set Pro to deactivate during admin_init
             /* v1.1.6.3 version_status issues are NO LONger a deactivation action!
                case ( ($vtprd_license_options['state'] == 'suspended-by-vendor')
                                   ||
                       ( ($vtprd_license_options['pro_plugin_version_status'] != 'valid') &&
                         ($vtprd_license_options['pro_plugin_version_status'] != null)) ) :  //null = default
                */
             case $vtprd_license_options['state'] == 'suspended-by-vendor':
                 //set up deactivate during admin_init - it's not available yet! done out of vtprd_maybe_pro_deactivate_action
                 $vtprd_license_options['pro_deactivate'] = 'yes';
                 update_option('vtprd_license_options', $vtprd_license_options);
                 break;
                 //if admin and (good or warning status)
             //if admin and (good or warning status)
             case is_admin():
                 define('VTPRD_PRO_DIRNAME', VTPRD_PRO_DIRNAME_IF_ACTIVE);
                 $avanti = true;
                 //v1.1.5
                 if ($vtprd_setup_options['debugging_mode_on'] == 'yes') {
                     error_log(print_r('is_admin, VTPRD_PRO_DIRNAME defined ', true));
                 }
                 break;
                 //if frontend execution and all good status
             //if frontend execution and all good status
             default:
                 if ($vtprd_license_options['status'] == 'valid' && $vtprd_license_options['state'] == 'active' && $vtprd_license_options['pro_plugin_version_status'] == 'valid') {
                     define('VTPRD_PRO_DIRNAME', VTPRD_PRO_DIRNAME_IF_ACTIVE);
                     $avanti = true;
                     //v1.1.5
                     if ($vtprd_setup_options['debugging_mode_on'] == 'yes') {
                         error_log(print_r('During Execution, VTPRD_PRO_DIRNAME defined ', true));
                     }
                     //so CRON JOB ONLY RUN if PRO is active
                     //v1.1.6.3 Refactored.  Demo no longer available, due to HACKING
                     add_action('vtprd_twice_daily_scheduled_events', 'vtprd_recheck_license_activation');
                     /* 
                     //v1.1.6.1 begin                                                          
                     if ($vtprd_license_options['prod_or_test'] == 'demo') {
                       add_action( 'vtprd_thrice_daily_scheduled_events', 'vtprd_recheck_license_activation' ); 
                     } else {
                       //for a non-demo, only do twice per day
                       remove_action( 'vtprd_thrice_daily_scheduled_events', 'vtprd_recheck_license_activation' ); 
                       add_action( 'vtprd_twice_daily_scheduled_events', 'vtprd_recheck_license_activation' ); 
                     }
                     //v1.1.6.1 end
                     */
                     //v1.1.6.3 end
                 }
                 break;
         }
     }
     //***************
     //v1.1.5  end
     //***************
     $vtprd_setup_options = get_option('vtprd_setup_options');
     //put the setup_options into the global namespace
     //**************************
     //v1.0.9.0 begin
     //**************************
     switch (true) {
         case is_admin():
             //absolutely REQUIRED!!!
             $do_nothing;
             break;
         case $vtprd_setup_options['discount_taken_where'] == 'discountCoupon':
             $do_nothing;
             break;
         case $vtprd_setup_options['discount_taken_where'] == 'discountUnitPrice':
             //turn off switches not allowed for "discountUnitPrice" ==> done on the fly, rather than at update time...
             $vtprd_setup_options['show_checkout_purchases_subtotal'] = 'none';
             $vtprd_setup_options['show_checkout_discount_total_line'] = 'no';
             $vtprd_setup_options['checkout_new_subtotal_line'] = 'no';
             $vtprd_setup_options['show_cartWidget_purchases_subtotal'] = 'none';
             $vtprd_setup_options['show_cartWidget_discount_total_line'] = 'no';
             $vtprd_setup_options['cartWidget_new_subtotal_line'] = 'no';
             break;
         default:
             // supply default for new variables as needed for upgrade v1.0.8.9 => v1.0.9.0 as needed
             $vtprd_setup_options['discount_taken_where'] = 'discountCoupon';
             $vtprd_setup_options['give_more_or_less_discount'] = 'more';
             $vtprd_setup_options['show_unit_price_cart_discount_crossout'] = 'yes';
             //v1.0.9.3 ==> for help when switching to unit pricing...
             $vtprd_setup_options['show_unit_price_cart_discount_computation'] = 'no';
             //v1.0.9.3
             update_option('vtprd_setup_options', $vtprd_setup_options);
             //v1.0.9.1
             break;
     }
     //v1.0.9.0 end
     if (function_exists('vtprd_debug_options')) {
         vtprd_debug_options();
         //v1.0.5
     }
     /*  **********************************
             Set GMT time zone for Store 
         Since Web Host can be on a different
         continent, with a different *Day* and Time,
         than the actual store.  Needed for Begin/end date processing
         **********************************  */
     vtprd_set_selected_timezone();
     if (is_admin()) {
         add_filter('plugin_action_links_' . VTPRD_PLUGIN_SLUG, array($this, 'vtprd_custom_action_links'));
         require_once VTPRD_DIRNAME . '/admin/vtprd-setup-options.php';
         require_once VTPRD_DIRNAME . '/admin/vtprd-rules-ui.php';
         //if ((defined('VTPRD_PRO_DIRNAME')) )  {     //v1.1.5
         if ($avanti) {
             //v1.1.5
             require_once VTPRD_PRO_DIRNAME . '/admin/vtprd-rules-update.php';
             require_once VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php';
         } else {
             require_once VTPRD_DIRNAME . '/admin/vtprd-rules-update.php';
         }
         require_once VTPRD_DIRNAME . '/admin/vtprd-show-help-functions.php';
         require_once VTPRD_DIRNAME . '/admin/vtprd-checkbox-classes.php';
         require_once VTPRD_DIRNAME . '/admin/vtprd-rules-delete.php';
         $this->vtprd_admin_process();
         //v1.1.5
         //v1.0.7.1 begin
         /* v1.1.0.1  replaced with new notification at admin_init
            if ( (defined('VTPRD_PRO_DIRNAME')) &&
                 (version_compare(VTPRD_PRO_VERSION, VTPRD_MINIMUM_PRO_VERSION) < 0) ) {    //'<0' = 1st value is lower  
              add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_version_mismatch') );            
            }
            */
         //v1.0.7.1 end
         /* //v1.0.9.3 moved to functions to be run at admin-init time
            if ($vtprd_setup_options['discount_taken_where'] == 'discountCoupon') { //v1.0.9.3  doesn't apply if 'discountUnitPrice'
            //v1.0.7.4 begin  
              //****************************************
              //INSIST that coupons be enabled in woo, in order for this plugin to work!!
              //****************************************
              //always check if the manually created coupon codes are there - if not create them.
              vtprd_woo_maybe_create_coupon_types();        
              $coupons_enabled = get_option( 'woocommerce_enable_coupons' ) == 'no' ? false : true;
              if (!$coupons_enabled) {  
                add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_coupon_enable_required') );            
              } 
            }
            */
         // don't have to do this EXCEPT at install time....
         //    $this->vtprd_maybe_add_wholesale_role(); //v1.0.9.0
         //v1.0.7.4 end
         //*******************************************************************************
         //v1.1.6 BEGIN
         //v1.1.6  Commented the else, and CHANGED for below - apply-rules CAN be executed in ADMIN, if pricing is called.  need the resources, so put back into MAINLINE!
         //**************
         /* 
         } else {
         
             add_action( "wp_enqueue_scripts", array(&$this, 'vtprd_enqueue_frontend_scripts'), 1 );    //priority 1 to run 1st, so front-end-css can be overridden by another file with a dependancy
             
             //v1.1.5  BEGIN
              // the 'plugin_version_valid' switches are set in ADMIN, but only used in the Front End
             //if (defined('VTPRD_PRO_DIRNAME'))  {      //v1.1.5  
             if ($avanti) {                              //v1.1.5                 
               require_once  ( VTPRD_PRO_DIRNAME . '/core/vtprd-apply-rules.php' );
               require_once  ( VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php' );
               if ( $vtprd_setup_options['debugging_mode_on'] == 'yes' ){   
                 error_log( print_r(  'Free Plugin begin, Loaded PRO plugin apply-rules', true ) );
               }                   
             } else {       
               require_once  ( VTPRD_DIRNAME .     '/core/vtprd-apply-rules.php' );
               if ( $vtprd_setup_options['debugging_mode_on'] == 'yes' ){   
                 error_log( print_r(  'Free Plugin begin, Loaded PFREE plugin apply-rules', true ) );
               }           
             }
             //v1.1.5  End
         
         }
         */
     }
     add_action("wp_enqueue_scripts", array(&$this, 'vtprd_enqueue_frontend_scripts'), 1);
     //priority 1 to run 1st, so front-end-css can be overridden by another file with a dependancy
     //v1.1.5  BEGIN
     // the 'plugin_version_valid' switches are set in ADMIN, but only used in the Front End
     //if (defined('VTPRD_PRO_DIRNAME'))  {      //v1.1.5
     if ($avanti) {
         //v1.1.5
         require_once VTPRD_PRO_DIRNAME . '/core/vtprd-apply-rules.php';
         require_once VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php';
         if ($vtprd_setup_options['debugging_mode_on'] == 'yes') {
             error_log(print_r('Free Plugin begin, Loaded PRO plugin apply-rules, settings= ', true));
             error_log(var_export($vtprd_setup_options, true));
         }
     } else {
         require_once VTPRD_DIRNAME . '/core/vtprd-apply-rules.php';
         if ($vtprd_setup_options['debugging_mode_on'] == 'yes') {
             error_log(print_r('Free Plugin begin, Loaded PFREE plugin apply-rules', true));
         }
     }
     //v1.1.5  End
     //*******************************************************************************
     //v1.1.6 END
     //*******************************************************************************
     /*
         if (is_admin()){ 
     
     //LIFETIME logid cleanup...
     //  LogID logic from wpsc-admin/init.php
     if(defined('VTPRD_PRO_DIRNAME')) {
       switch( true ) {
         case ( isset( $_REQUEST['wpsc_admin_action2'] ) && ($_REQUEST['wpsc_admin_action2'] == 'purchlog_bulk_modify') )  :
                vtprd_maybe_lifetime_log_bulk_modify();
            break; 
         case ( isset( $_REQUEST['wpsc_admin_action'] ) && ($_REQUEST['wpsc_admin_action'] == 'delete_purchlog') ) :
                vtprd_maybe_lifetime_log_roll_out_cntl();
            break;                                             
       } 
         
       if (version_compare(VTPRD_PRO_VERSION, VTPRD_MINIMUM_PRO_VERSION) < 0) {    //'<0' = 1st value is lower  
         add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_version_mismatch') );            
       }          
     }
     
     //****************************************
     //INSIST that coupons be enabled in woo, in order for this plugin to work!!
     //****************************************
     $coupons_enabled = get_option( 'woocommerce_enable_coupons' ) == 'no' ? false : true;
     if (!$coupons_enabled) {  
       add_action( 'admin_notices',array(&$this, 'vtprd_admin_notice_coupon_enable_required') );            
     } 
         } 
     */
     //v1.1.5  BEGIN ==>> shifted down here!
     //*********************************
     //don't run in admin, this is ONLY for executions
     //*********************************
     /*
     if (is_admin() ) { 
        $skip_this = true; 
     } else {
         // the 'plugin_version_valid' switches are set in ADMIN, but only used in the Front End
        if (defined('VTPRD_PRO_DIRNAME'))  {                  
          require_once  ( VTPRD_PRO_DIRNAME . '/core/vtprd-apply-rules.php' );
          require_once  ( VTPRD_PRO_DIRNAME . '/woo-integration/vtprd-lifetime-functions.php' );
          if ( $vtprd_setup_options['debugging_mode_on'] == 'yes' ){   
            error_log( print_r(  'Free Plugin begin, Loaded PRO plugin apply-rules', true ) );
          }                   
        } else {       
          require_once  ( VTPRD_DIRNAME .     '/core/vtprd-apply-rules.php' );
          if ( $vtprd_setup_options['debugging_mode_on'] == 'yes' ){   
            error_log( print_r(  'Free Plugin begin, Loaded PFREE plugin apply-rules', true ) );
          }           
        }
        
     }
     */
     //v1.1.5  end
     return;
 }