예제 #1
0
    print "you cannot call this script directly";
    exit;
    //just for good measure
}
/**testing variables ****************************/
//sleep(2);//when testing jquery fadeins etc
/******************************************/
/**********get options********************/
$options = $this->pluginOptions;
/******************************************
	[supress errors unless debug]
******************************************/
if (empty($options['tools']['debug'])) {
    error_reporting(0);
}
$optionSizes = wppizza_sizes_available($options['sizes']);
//outputs an array $arr=array(['lbl']=>array(),['prices']=>array());
$output = '';
/*****************************************************************************************************************
*
*
*
*
*
*****************************************************************************************************************/
/*****************************************************
		[adding new additive]
	*****************************************************/
if ($_POST['vars']['field'] == 'additives' && $_POST['vars']['id'] >= 0) {
    $output = $this->wppizza_admin_section_additives($_POST['vars']['field'], $_POST['vars']['id'], '');
}
예제 #2
0
 function wppizza_admin_save_metaboxes($item_id, $item_details)
 {
     /** bypass, when doing "quickedit" (ajax) and /or "bulk edit"  as it will otherwsie loose all meta info (i.e prices, additives etc)!!!***/
     if (defined('DOING_AJAX') || isset($_GET['bulk_edit'])) {
         return;
     }
     /**bypass the below when activating plugin as we are installing the default items on first activation via wp_insert_post()**/
     if (!isset($_GET['activate'])) {
         /***as this function gets called when creating a new page, we will also insert some default values (as $_POST will be empty)**/
         // Check post type first
         if (isset($item_details->post_type) && $item_details->post_type == $this->pluginSlug) {
             //**additives array**//
             $itemMeta['additives'] = array();
             if (isset($_POST[$this->pluginSlug]['additives'])) {
                 foreach ($_POST[$this->pluginSlug]['additives'] as $k => $v) {
                     $itemMeta['additives'][$k] = (int) $_POST[$this->pluginSlug]['additives'][$k];
                 }
             }
             /**alt tax rate**/
             $itemMeta['item_tax_alt'] = false;
             if (isset($_POST[$this->pluginSlug]['item_tax_alt'])) {
                 $itemMeta['item_tax_alt'] = true;
             }
             /**set some default values (namely sizes and prices) when adding new page**/
             if (!isset($_POST[$this->pluginSlug]['sizes'])) {
                 $options = $this->pluginOptions;
                 $optionsSizes = wppizza_sizes_available($options['sizes']);
                 /**get no of price input fields of first available size option**/
                 reset($optionsSizes);
                 $first_key = key($optionsSizes);
                 $_POST[$this->pluginSlug]['sizes'] = $first_key;
                 if (isset($optionsSizes[$first_key]['price'])) {
                     $_POST[$this->pluginSlug]['prices'] = $optionsSizes[$first_key]['price'];
                 }
             }
             //**sizes**//
             $itemMeta['sizes'] = (int) $_POST[$this->pluginSlug]['sizes'];
             //**prices array**//
             $itemMeta['prices'] = array();
             if (isset($_POST[$this->pluginSlug]['prices'])) {
                 foreach ($_POST[$this->pluginSlug]['prices'] as $k => $v) {
                     $itemMeta['prices'][$k] = wppizza_validate_float_only($_POST[$this->pluginSlug]['prices'][$k], 2);
                 }
             }
             update_post_meta($item_id, $this->pluginSlug, $itemMeta);
         }
     }
 }