Example #1
0
 public function wppizza_include_shortcode_template($type, $atts = null)
 {
     /***************************************
     			[include category loop template]
     		***************************************/
     if ($type == 'category') {
         $options = $this->pluginOptions;
         $querys = array();
         /*********************************************************************
         				[as we have changed in v.2.8.7.4 to have the additives as array
         				so we can custom sort them but dont really want to screw up
         				anyones edited templates, re-map key and name]
         			*******************************************************************/
         $mapAdditives = array();
         if (isset($options['additives']) && is_array($options['additives'])) {
             foreach ($options['additives'] as $o => $a) {
                 if (is_array($a)) {
                     if ($a['sort'] == '') {
                         $a['sort'] = $o;
                     }
                     $mapAdditives[$a['sort']] = $a['name'];
                 } else {
                     /**in case we have not yet re-saved the additives**/
                     $mapAdditives[$o] = $a;
                 }
             }
         }
         //ksort($mapAdditives,SORT_NATURAL);//php 5.4 only
         uksort($mapAdditives, 'strnatcmp');
         $options['additives'] = $mapAdditives;
         /*******re-map additives inside loop too **************************/
         add_filter('wppizza_filter_loop_meta', array($this, 'wppizza_additives_remap'), 10, 1);
         /*******************************************************************
          *
          *	[end of additives re-mapping
          *
          ********************************************************************/
         /**********************************************************************************
          *
          *	[top 10 (or whatever) -> bestsellers ]
          *
          **********************************************************************************/
         if (isset($atts['bestsellers'])) {
             global $wpdb;
             /**wppizza posts to compare against, making sure posts still exists**/
             $wppPostsQuery = "SELECT ID FROM " . $wpdb->prefix . "posts where post_type='wppizza' AND post_status='publish' ";
             $wppPostsRes = $wpdb->get_results($wppPostsQuery, OBJECT_K);
             /**run the query**/
             $bestsellersQuery = "SELECT id,order_ini FROM " . $wpdb->prefix . $this->pluginOrderTable . " WHERE payment_status='COMPLETED' ";
             $bestsellersRes = $wpdb->get_results($bestsellersQuery);
             $bestsellers = array();
             /**loop through items and get quantities**/
             foreach ($bestsellersRes as $b => $bs) {
                 $thisOrderDetails = maybe_unserialize($bs->order_ini);
                 if (isset($thisOrderDetails['item']) && is_array($thisOrderDetails['item'])) {
                     foreach ($thisOrderDetails['item'] as $item) {
                         /**make sure this post still exists and has been sold more than 0 times**/
                         if (isset($wppPostsRes[$item['postId']]) && $item['quantity'] > 0) {
                             if (!isset($bestsellers[$item['postId']])) {
                                 $bestsellers[$item['postId']] = $item['quantity'];
                             } else {
                                 $bestsellers[$item['postId']] += $item['quantity'];
                             }
                         }
                     }
                 }
             }
             /*sort by quantity*/
             arsort($bestsellers);
             /*chunk to required bits*/
             $chunks = (int) $atts['bestsellers'];
             $bestsellers = array_chunk($bestsellers, $chunks, true);
             if (count($bestsellers) > 0) {
                 /**required bestsellers**/
                 $bestsellersIncl = implode(',', array_keys($bestsellers[0]));
             } else {
                 $bestsellersIncl = '';
             }
             /**get/set  id's **/
             $inclAtts = array();
             if ($bestsellersIncl != '') {
                 $inclAtts[] = $bestsellersIncl;
             }
             /**add distinctly set includes (if any)**/
             if (isset($atts['include'])) {
                 $inclAtts[] = $atts['include'];
             }
             /**finally set the includes id's**/
             $atts['include'] = implode(',', $inclAtts);
             /***add a filter that can be used if required for alternative sorting for example*****/
             $atts['include'] = apply_filters('wppizza_filter_bestsellers_include', $atts['include']);
             //alternatives if empty*/
             if ((!isset($atts['include']) || $atts['include'] == '') && isset($atts['ifempty'])) {
                 $atts['include'] = $atts['ifempty'];
             }
             /*distincly unset any category and header**/
             unset($atts['category']);
             /*unset all categories as query_vars below will hold an array of all the categories**/
             $atts['noheader'] = 1;
             /**omit header**/
             /*get and set all terms in the taxonomy and convert to array of all slugs for tax query */
             $terms = get_terms($this->pluginSlugCategoryTaxonomy);
             $query_var = wp_list_pluck($terms, 'slug');
             /** filter arguments -> sort output according to populariry (i.e how many tims an item has been bought)**/
             add_filter('wppizza_filter_loop', array($this, 'wppizza_filter_shortcode_post_in_args'), 10, 1);
             /**********************************************************
             				as bestsellers are not tied to a particular category
             				set some static variables so we can use it in the
             				loop templates
             			**********************************************************/
             $querys['bestsellers'] = new stdClass();
             $querys['bestsellers']->term_id = array_keys($query_var);
             $querys['bestsellers']->name = 'bestsellers';
             //should be a slug. no spaces etc
             $querys['bestsellers']->slug = $query_var;
             $querys['bestsellers']->category_id = 0;
             //unknown / not applicable
         }
         /**********************************************************************************
          *
          *	[single item]
          *
          **********************************************************************************/
         if (isset($atts['single'])) {
             $atts['include'] = (int) $atts['single'];
             unset($atts['category']);
             /*unset all categories as query_vars below will hold an array of all the categories**/
             $atts['noheader'] = 1;
             /**omit header**/
             /*get and set all terms in the taxonomy and convert to array of all slugs for tax query */
             $termDetails = wp_get_post_terms($atts['include'], WPPIZZA_TAXONOMY);
             if ($termDetails && !is_wp_error($termDetails)) {
                 $query_var = wp_list_pluck($termDetails, 'slug', 'term_id');
             } else {
                 /*cat find any, get all*/
                 $terms = get_terms($this->pluginSlugCategoryTaxonomy);
                 $query_var = wp_list_pluck($terms, 'slug');
             }
             /*indexed array of term to be able to set some sort of category id*/
             $termKeys = array_keys($query_var);
             /** filter arguments -> sort output according to populariry (i.e how many tims an item has been bought)**/
             add_filter('wppizza_filter_loop', array($this, 'wppizza_filter_shortcode_post_in_args'), 10, 1);
             /**********************************************************
             				as single items are not tied to a particular category
             				(they can be in several)
             				set some static variables so we can use it in the
             				loop templates
             			**********************************************************/
             $querys['single'] = new stdClass();
             $querys['single']->term_id = $termKeys;
             $querys['single']->name = 'single';
             //should be a slug. no spaces etc
             $querys['single']->slug = $query_var[$termKeys[0]];
             //get first slug
             $querys['single']->category_id = $termKeys[0];
             //just use the first we have
         }
         /**********************************************************************************
          *
          *	[select first category if none selected->used when using shortcode without category,
          *	unless we are looking for bestsellers]
          *
          **********************************************************************************/
         if (!isset($atts['category']) && !isset($atts['bestsellers']) && !isset($atts['single'])) {
             $termSort = $options['layout']['category_sort'];
             asort($termSort);
             reset($termSort);
             $firstTermId = key($termSort);
             /*get slug and taxonomy from id*/
             $querys[] = get_term_by('id', $firstTermId, $this->pluginSlugCategoryTaxonomy);
         }
         /**********************************************************************************
          *
          *	[category(ies) has/have been selected]
          *
          **********************************************************************************/
         if (isset($atts['category'])) {
             $catSlugsToArray = explode(',', $atts['category']);
             if (in_array('!all', $catSlugsToArray)) {
                 /**check if we are excluding some categories**/
                 $excludeCategory = array();
                 foreach ($catSlugsToArray as $sKey => $slug) {
                     if (substr($slug, 0, 1) == '-') {
                         $thisCategory = get_term_by('slug', $slug, $this->pluginSlugCategoryTaxonomy);
                         $excludeCategory[$thisCategory->term_id] = $thisCategory->term_id;
                     }
                 }
                 /**get all sorted ones*/
                 $termSort = $options['layout']['category_sort'];
                 asort($termSort);
                 foreach ($termSort as $termId => $sorter) {
                     if (!isset($excludeCategory[$termId])) {
                         //exclude if necessary
                         $querys[] = get_term_by('id', $termId, $this->pluginSlugCategoryTaxonomy);
                     }
                 }
                 /*********
                 						filter any empty ones if more cats in $options['layout']['category_sort'] for some reason than actual categories
                 
                 						temp solution for !all shortcode:
                 						in some (as yet unknown) cases/situations the sorted categories variable gets saved
                 						including some old/non existing ones and therefore consists of
                 						more than actually existing ones
                 						this can result in the last category being displayed multiple times when using !all shortcode
                 
                 						so - as to at least for now fix the symptoms - filter empty ones
                 					********/
                 $querys = array_filter($querys);
             } else {
                 foreach ($catSlugsToArray as $sKey => $slug) {
                     if (trim($slug) != '') {
                         //in case of using two commas omitting slug
                         /*get slug and taxonomy from slug*/
                         $querys[] = get_term_by('slug', $slug, $this->pluginSlugCategoryTaxonomy);
                     }
                 }
             }
         }
         /*exclude header*/
         if (isset($atts['noheader']) || $options['layout']['suppress_loop_headers']) {
             $noheader = 1;
         }
         /**if we want to capture the category id a menu item is currently in **/
         /**DEPRECATED ->this is not required anymore, but we'll leave it here in case someone is using an old customised loop template that wants this variable**/
         if ($options['layout']['items_group_sort_print_by_category']) {
             $getSlugDetails = 1;
         }
         /*show.hide additives at bottom of loop*/
         if (isset($atts['showadditives'])) {
             $showadditives = $atts['showadditives'];
         }
         $exclude = array();
         if (isset($atts['exclude'])) {
             $exclXplode = explode(",", $atts['exclude']);
             foreach ($exclXplode as $exclId) {
                 $exclude[$exclId] = $exclId;
             }
         }
         /*include specific items only -> overrides exclude*****/
         $include = array();
         if (isset($atts['include'])) {
             $exclude = array();
             /*empty exclude*/
             $inclXplode = explode(",", $atts['include']);
             foreach ($inclXplode as $inclId) {
                 $include[$inclId] = $inclId;
             }
         }
         /*set template style if !default*/
         $loStyle = '';
         if ($options['layout']['style'] != 'default') {
             $loStyle = '-' . $options['layout']['style'] . '';
         }
         /**check which template to use**/
         /*include template from theme if exists*/
         if ($template_file = locate_template(array($this->pluginLocateDir . 'wppizza-loop' . $loStyle . '.php'))) {
         } else {
             /*if template not in theme, fallback to template in plugin*/
             $template_file = '' . WPPIZZA_PATH . 'templates/wppizza-loop' . $loStyle . '.php';
         }
         /*cat count*/
         $catCount = count($querys);
         static $loopCount = 0;
         //set static in case there's more than one shortcode on page
         foreach ($querys as $query) {
             /**q vars**/
             if (isset($query) && $query) {
                 $query_var = $query->slug;
             }
             /*include the template**/
             include $template_file;
             do_action('wppizza_loop_template_end');
             $loopCount++;
         }
         return;
         //after loop
     }
     /***************************************
     			[include navigation template]
     		***************************************/
     if ($type == 'navigation') {
         extract(shortcode_atts(array('title' => ''), $atts));
         $child_of = 0;
         if (isset($atts['parent'])) {
             $query = get_term_by('slug', $atts['parent'], $this->pluginSlugCategoryTaxonomy);
             if ($query) {
                 $child_of = $query->term_id;
             }
         }
         $excludeIds = '';
         if (isset($atts['exclude'])) {
             $excludeIds = $atts['exclude'];
         }
         $post_type = $this->pluginSlug;
         $args = array('taxonomy' => $this->pluginSlugCategoryTaxonomy, 'orderby' => 'name', 'show_count' => 0, 'pad_counts' => 0, 'hierarchical' => 1, 'title_li' => $title, 'depth' => 0, 'exclude' => $excludeIds, 'child_of' => $child_of, 'show_option_none' => __('Nothing here'), 'hide_empty' => 1, 'echo' => 0);
         /***add a filter if required*****/
         $args = apply_filters('wppizza_filter_navigation', $args);
         /*check if the file exists in the theme, otherwise serve the file from the plugin directory if possible*/
         if ($template_file = locate_template(array($this->pluginLocateDir . 'wppizza-navigation.php'))) {
             include $template_file;
             return;
         }
         /*check if it exists in plugin directory (it should really BE there), otherwise we will have to serve defaults**/
         if (is_file('' . WPPIZZA_PATH . 'templates/wppizza-navigation.php')) {
             $template_file = '' . WPPIZZA_PATH . 'templates/wppizza-navigation.php';
             include $template_file;
             return;
         }
     }
     /***************************************
     			[include shopping cart template]
     		***************************************/
     if ($type == 'cart') {
         /**if request is ajax , return formatted tems**/
         if (isset($atts['request'])) {
             $request = $atts['request'];
         }
         /**variables to use in template**/
         $options = $this->pluginOptions;
         $cart = wppizza_order_summary($_SESSION[$this->pluginSession], $options, 'cart');
         $cart = apply_filters('wppizza_filter_order_summary', $cart);
         /**txt variables from settings->localization*/
         $txt = $options['localization'];
         /*put all text varibles into something easier to deal with**/
         /*check if we set width,height**/
         $style = array();
         if (isset($atts['width']) && $atts['width'] != '') {
             $style['width'] = 'width:' . esc_html($atts['width']) . '';
         }
         if (isset($atts['height']) && $atts['height'] != '') {
             $style['height'] = 'height:' . (int) $atts['height'] . 'px';
         }
         if (count($style) > 0) {
             $cartStyle['cart'] = ' style="' . implode(";", $style) . '"';
         }
         if (isset($style['width'])) {
             $cartStyle['width'] = ' style="' . $style['width'] . '"';
         }
         /**make cart sticky**/
         $stickycart = '';
         if (isset($atts['stickycart'])) {
             $stickycart = 'wppizza-cart-sticky';
         }
         /**display order info like discounts and delivery costs**/
         if (isset($atts['orderinfo'])) {
             $orderinfo = true;
         }
         /**display openingtimes above - depending on template - cart? **/
         if (isset($atts['openingtimes'])) {
             $openingTimes = wppizza_frontendOpeningTimes($options);
         }
         /*check if the file exists in the theme, otherwise serve the file from the plugin directory if possible*/
         if ($template_file = locate_template(array($this->pluginLocateDir . '' . $this->pluginSlug . '-cart.php'))) {
             include $template_file;
             return $cart;
         }
         /*check if it exists in plugin directory, otherwise we will have to serve defaults**/
         if (is_file('' . WPPIZZA_PATH . 'templates/' . $this->pluginSlug . '-cart.php')) {
             $template_file = '' . WPPIZZA_PATH . 'templates/' . $this->pluginSlug . '-cart.php';
             include $template_file;
             return $cart;
         }
     }
     /***************************************
     			[include order page template]
     		***************************************/
     if ($type == 'orderpage') {
         /*******get the variables***/
         $options = $this->pluginOptions;
         $cart = wppizza_order_summary($_SESSION[$this->pluginSession], $options, 'orderpage');
         $cart = apply_filters('wppizza_filter_order_summary', $cart);
         /**txt variables from settings->localization*/
         $txt = $options['localization'];
         /**formelements from settings->order form*/
         $formelements = $options['order_form'];
         /**allow filtering of order form form elements**/
         $formelements = apply_filters('wppizza_filter_formfields_order', $formelements);
         /**set session user vars as get vars to prefill form fields***/
         if (isset($_SESSION[$this->pluginSessionGlobal]['userdata']) && is_array($_SESSION[$this->pluginSessionGlobal]['userdata'])) {
             foreach ($_SESSION[$this->pluginSessionGlobal]['userdata'] as $k => $v) {
                 $_GET[$k] = $v;
             }
         }
         sort($formelements);
         if ($cart['shopopen']) {
             /**if the user is logged in , pre-enter the info we have (if prefill is selected in wppizza->order form settings. CHANGED IN VERSION 2.6.5.3***/
             if (is_user_logged_in()) {
                 global $current_user;
                 $getUserMeta = get_user_meta($current_user->ID);
                 foreach ($getUserMeta as $k => $v) {
                     /**for legacy reasons, strip wppizza_ from key*/
                     if (substr($k, 0, 8) == 'wppizza_') {
                         $k = substr($k, 8);
                     }
                     $userMeta[$k] = $v[0];
                 }
             }
             /***if we are adding get vars to the url (if a tip has been added for instance the page will be refreshed with vars appended), force prefill to be enabled and set values accordingly. ADDED IN VERSION 2.8.6**/
             /*
             	$_GET will also include session data set in $_SESSION[$this->pluginSessionGlobal]['userdata'] as they will not be appended to the url anymore (it's just ugly).
             	MODIFIED IN VERSION 2.8.8.3, but no changes made to this file
             */
             $isSelfPickup = !empty($_SESSION[$this->pluginSession]['selfPickup']) ? 1 : 0;
             /**check if self pickup has been selected and make fields required as set in order form settings, ADDED in 2.8.9.10*/
             foreach ($formelements as $elmKey => $elm) {
                 if (isset($_GET[$elm['key']])) {
                     $formelements[$elmKey]['prefill'] = 1;
                     $userMeta[$elm['key']] = $_GET[$elm['key']];
                 }
                 /**do NOT set required flag on selected elements on self-pickup. ADDED in 2.8.9.10 **/
                 if ($isSelfPickup == 1 && !$elm['required_on_pickup']) {
                     $formelements[$elmKey]['required'] = false;
                 }
                 /**DO set required flag on selected elements on self-pickup even if main required is false. ADDED in 2.10.2.1 **/
                 if ($isSelfPickup == 1 && $elm['required_on_pickup']) {
                     $formelements[$elmKey]['required'] = true;
                 }
             }
             /**add invisible div to order page be be able to still add things to cart and reload (for upsells etc)**/
             add_action('wppizza_order_form_inside_top', array($this, 'wppizza_invisible_cart'));
             /*check if the file exists in the theme, otherwise serve the file from the plugin directory if possible*/
             if ($template_file = locate_template(array($this->pluginLocateDir . '' . $this->pluginSlug . '-order.php'))) {
                 include $template_file;
                 return;
             }
             /*check if it exists in plugin directory, otherwise we will have to serve defaults**/
             if (is_file('' . WPPIZZA_PATH . 'templates/' . $this->pluginSlug . '-order.php')) {
                 $template_file = '' . WPPIZZA_PATH . 'templates/' . $this->pluginSlug . '-order.php';
                 include $template_file;
                 return;
             }
         } else {
             /**shop closed->to stop still active sessions**/
             print "<div class='wpppizza-order-shopclosed'><p>" . $cart['innercartinfo'] . "</p></div>";
         }
     }
     /***************************************
     			[include orderhistory template]
     		***************************************/
     if ($type == 'orderhistory') {
         /**just show the login form and return if user is not logged in**/
         if (!is_user_logged_in()) {
             $this->wppizza_do_login_form(null, true);
             return;
         } else {
             global $current_user;
             $current_user->ID;
             do_action('wppizza_get_orderhistory', $current_user->ID, $atts);
         }
     }
     /***************************************
     			[include confirmation page template]
     		***************************************/
     if ($type == 'confirmationpage') {
         /*******get the variables***/
         $options = $this->pluginOptions;
         $cart = wppizza_order_summary($_SESSION[$this->pluginSession], $options, $type);
         $cart = apply_filters('wppizza_filter_order_summary', $cart);
         /**check if tax was included in prices**/
         $taxIncluded = !empty($options['order']['item_tax_included']) ? true : false;
         /**txt variables from settings->localization additional vars > localization_confirmation_form*/
         $localize = array_merge($options['localization'], $options['localization_confirmation_form']);
         $txt = array();
         foreach ($localize as $k => $v) {
             $txt[$k] = $v['lbl'];
         }
         /**set session user vars as get vars to prefill form fields***/
         $userdata = array();
         if (isset($_SESSION[$this->pluginSessionGlobal]['userdata']) && is_array($_SESSION[$this->pluginSessionGlobal]['userdata'])) {
             foreach ($_SESSION[$this->pluginSessionGlobal]['userdata'] as $k => $v) {
                 $userdata[$k] = $v;
             }
         }
         /******************************************
         				output button and payment method
         				and associated costs
         			******************************************/
         $gwClass = new WPPIZZA_GATEWAYS();
         $getGateways = $gwClass->wppizza_instanciate_gateways_frontend();
         /**get wpml vars - should be done better one day using action hooks), but for the moment this will have to do**/
         $gwClass->wppizza_wpml_localization_gateways();
         /********************************************************
          *
          *
          *	output variables
          *
          *
          ********************************************************/
         /************************************************
         				link back to order page
         			************************************************/
         $orderpagelink = $cart['orderpagelink'];
         /************************************************
         				link to amend order
         			************************************************/
         $amendorderlink = $cart['amendorderlink'];
         /************************************************
         				order button
         			************************************************/
         $orderbutton = '';
         /**add required fields**/
         $addClass = '';
         /**add class if customised to - for example - use an overlay **/
         if (!empty($atts['hasClassAjax'])) {
             $addClass = 'class="wppizzaGwAjaxSubmit"';
         }
         if (!empty($atts['hasClassCustom'])) {
             $addClass = 'class="wppizzaGwCustom"';
         }
         $orderbutton .= '<input id="wppizza_hash" name="wppizza_hash" type="hidden" value="' . $atts['hash'] . '"/>';
         $orderbutton .= '<input id="wppizza-gateway" name="wppizza-gateway" ' . $addClass . ' type="hidden" value="' . $atts['gateway'] . '"/>';
         $orderbutton .= $gwClass->wppizza_gateway_standard_button($txt['confirm_now_button']);
         /************************************************
         				formelements to confirm
         				from settings->order form
         			************************************************/
         $confirmationelements = array();
         foreach ($options['confirmation_form'] as $elmKey => $elm) {
             if ($elm['enabled']) {
                 $confirmationelements[$elmKey] = $elm;
             }
         }
         sort($confirmationelements);
         /************************************************
         				submitted and filtered formelements
         			************************************************/
         $formelements = $options['order_form'];
         $formelements = apply_filters('wppizza_filter_formfields_confirmation', $formelements);
         sort($formelements);
         foreach ($formelements as $k => $oForm) {
             $key = $oForm['key'];
             if ($oForm['key'] == 'ctips' || !$oForm['enabled']) {
                 /***exclude disabled and tips (as those belong to order details)**/
                 unset($formelements[$k]);
             } else {
                 if ($oForm['type'] != 'select') {
                     $formelements[$k]['userVal'] = !empty($userdata[$key]) ? $userdata[$key] : '';
                 } else {
                     $formelements[$k]['userVal'] = !empty($oForm['value'][$userdata[$key]]) ? $oForm['value'][$userdata[$key]] : '';
                 }
             }
         }
         /************************************************
         				paymentmethod used
         			************************************************/
         $gatewayLabel = strtoupper($atts['gateway']);
         $getwayUsedIdent = $gatewayLabel;
         if (isset($getGateways[$getwayUsedIdent])) {
             $gatewayLabel = !empty($getGateways[$getwayUsedIdent]->gatewayName) ? $getGateways[$getwayUsedIdent]->gatewayName : $atts['gateway'];
             $gatewayLabel = !empty($getGateways[$getwayUsedIdent]->gatewayOptions['gateway_label']) ? $getGateways[$getwayUsedIdent]->gatewayOptions['gateway_label'] : $gatewayLabel;
         }
         /*************allow to add to paymentmethod by filter*****/
         $paymentmethod = array();
         $paymentmethod = apply_filters('wppizza_filter_paymentmethod_confirmation', $paymentmethod);
         sort($paymentmethod);
         foreach ($paymentmethod as $k => $oForm) {
             $key = $oForm['key'];
             if ($oForm['type'] != 'select') {
                 $paymentmethod[$k]['userVal'] = !empty($userdata[$key]) ? $userdata[$key] : '';
             } else {
                 $paymentmethod[$k]['userVal'] = !empty($oForm['value'][$userdata[$key]]) ? $oForm['value'][$userdata[$key]] : '';
             }
         }
         /***********************************************
         				output what needs outputting
         			***********************************************/
         /*check if the file exists in the theme, otherwise serve the file from the plugin directory if possible*/
         if ($template_file = locate_template(array($this->pluginLocateDir . '' . $this->pluginSlug . '-confirmation.php'))) {
             include $template_file;
             return;
         }
         /*check if it exists in plugin directory, otherwise we will have to serve defaults**/
         if (is_file('' . WPPIZZA_PATH . 'templates/' . $this->pluginSlug . '-confirmation.php')) {
             $template_file = '' . WPPIZZA_PATH . 'templates/' . $this->pluginSlug . '-confirmation.php';
             include $template_file;
             return;
         }
     }
     /*********************************************************
     			[include search box (using shortcode/widget)]
     			uses class to filter/add search variables
     		*********************************************************/
     if ($type == 'search') {
         /**only display for logged in users**/
         if (isset($atts['loggedinonly']) && !is_user_logged_in()) {
             return;
         }
         /**use class to filter/add search variables when using**/
         $searchvars = new WPPIZZA_SEARCH_VARS();
         $searchvars->atts = $atts;
         $searchvars->options = $this->pluginOptions;
         add_filter('get_search_form', array($searchvars, 'searchvars'));
         /**add hidden wppizza input elm**/
         get_search_form();
         /*output - now altered - search form**/
         remove_filter('get_search_form', array($searchvars, 'searchvars'));
         //** reset to original or we will always have the post_type appended to the serach form once it has been run**/
         return;
     }
     /*********************************************************
     			[additives]
     		*********************************************************/
     if ($type == 'additives') {
         $options = $this->pluginOptions;
         $additives = $options['additives'];
         if (is_array($additives) && count($additives) > 0) {
             asort($additives);
             $str = "<div class='wppizza_additives'>";
             foreach ($additives as $k => $additive) {
                 $str .= "<span class='wppizza_additive_" . $k . " wppizza_additive'><span class='wppizza_additive_id'>" . $k . "</span><span class='wppizza_additive_name_" . $k . " wppizza_additive_name'>" . $additive['name'] . "</span></span>";
             }
             $str .= "</div>";
             echo $str;
         }
         return;
     }
 }
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
		a bit hackish mind you, but thank's any way to the website
		that provided the original if i find it again, i insert the address here...
	* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
function wpizzaOpeningtimes()
{
    /*wrapper in case we have no options**/
    $options = get_option('wppizza');
    $openingtimes = wppizza_frontendOpeningTimes($options);
    return $openingtimes;
}
Example #3
0
        ob_start();
        $this->wppizza_include_shortcode_template($type, $atts);
        $markup = ob_get_clean();
        return $markup;
    }
}
/**********************************************
	[openingtimes]
	possible attributes:
	type='openingtimes' (required [str])
	example: 		[wppizza type='openingtimes']
	returns grouped opening times in a string
**********************************************/
if ($type == 'openingtimes') {
    $options = $this->pluginOptions;
    $markup = wppizza_frontendOpeningTimes($options);
}
/**********************************************
	[additives]
	possible attributes:
	type='additives' (required [str])
	example: 		[wppizza type='additives']
	returns additives in a html string
**********************************************/
if ($type == 'additives') {
    ob_start();
    $this->wppizza_include_shortcode_template($type, $atts);
    $markup = ob_get_clean();
    return $markup;
}
/**********************************************