| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPPIZZA_MARKUP_FOODTYPE Class |
| 4 |
* |
| 5 |
* @package WPPIZZA |
| 6 |
* @subpackage WPPizza Additives |
| 7 |
* @copyright Copyright (c) 2015, Oliver Bach |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 3.12.14 |
| 10 |
* |
| 11 |
*/ |
| 12 |
if ( ! defined( 'ABSPATH' ) ) exit;/*Exit if accessed directly*/ |
| 13 |
|
| 14 |
/* ================================================================================================================================= * |
| 15 |
* |
| 16 |
* |
| 17 |
* |
| 18 |
* CLASS - WPPIZZA_MARKUP_FOODTYPE |
| 19 |
* |
| 20 |
* |
| 21 |
* |
| 22 |
* ================================================================================================================================= */ |
| 23 |
|
| 24 |
class WPPIZZA_MARKUP_FOODTYPE{ |
| 25 |
|
| 26 |
/****************************************************************************** |
| 27 |
* |
| 28 |
* |
| 29 |
* [construct] |
| 30 |
* |
| 31 |
* |
| 32 |
*******************************************************************************/ |
| 33 |
function __construct() { |
| 34 |
} |
| 35 |
|
| 36 |
/****************************************************************************** |
| 37 |
* |
| 38 |
* |
| 39 |
* [methods] |
| 40 |
* |
| 41 |
* |
| 42 |
*******************************************************************************/ |
| 43 |
/*************************************** |
| 44 |
[apply attributes] |
| 45 |
***************************************/ |
| 46 |
function attributes($atts=null){ |
| 47 |
/**get markup**/ |
| 48 |
$markup = $this->get_markup($atts); |
| 49 |
return $markup; |
| 50 |
} |
| 51 |
|
| 52 |
/*************************************** |
| 53 |
[markup] |
| 54 |
***************************************/ |
| 55 |
function get_markup($atts){ |
| 56 |
static $unique_id=0;$unique_id++; |
| 57 |
|
| 58 |
|
| 59 |
/********************* |
| 60 |
get all foodtype |
| 61 |
*********************/ |
| 62 |
$foodtype = wppizza_all_foodtype(); |
| 63 |
|
| 64 |
|
| 65 |
/********************* |
| 66 |
set unique id |
| 67 |
*********************/ |
| 68 |
$id = WPPIZZA_PREFIX.'-ftypes-'.$unique_id; |
| 69 |
|
| 70 |
/********************* |
| 71 |
set/add classes using attributes |
| 72 |
*********************/ |
| 73 |
$class= array(); |
| 74 |
$class[] = WPPIZZA_PREFIX.'-ftypes'; |
| 75 |
//add icon class |
| 76 |
$has_icons = array_filter(wppizza_array_column($foodtype, 'icon')); |
| 77 |
if(!empty($has_icons)){ |
| 78 |
$class[] = WPPIZZA_PREFIX.'-ftypes-icons'; |
| 79 |
} |
| 80 |
if(!empty($atts['class'])){ |
| 81 |
$class[] = esc_html($atts['class']); |
| 82 |
} |
| 83 |
|
| 84 |
/* |
| 85 |
implode for output |
| 86 |
*/ |
| 87 |
$class = trim(implode(' ', $class)); |
| 88 |
|
| 89 |
/********************* |
| 90 |
ini markup array |
| 91 |
*********************/ |
| 92 |
$markup = array(); |
| 93 |
|
| 94 |
/********************* |
| 95 |
get markup |
| 96 |
*********************/ |
| 97 |
if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/global/foodtype.php')){ |
| 98 |
require(WPPIZZA_TEMPLATE_DIR.'/markup/global/foodtype.php'); |
| 99 |
}else{ |
| 100 |
require(WPPIZZA_PATH.'templates/markup/global/foodtype.php'); |
| 101 |
} |
| 102 |
|
| 103 |
/********************* |
| 104 |
apply filter if required and implode for output |
| 105 |
*********************/ |
| 106 |
$markup = apply_filters('wppizza_filter_foodtype_widget_markup', $markup, $atts, $unique_id, $foodtype); |
| 107 |
$markup = trim(implode('', $markup)); |
| 108 |
|
| 109 |
|
| 110 |
return $markup; |
| 111 |
} |
| 112 |
|
| 113 |
} |
| 114 |
?> |