|
1
|
|
|
<?php |
|
2
|
|
|
namespace Podium\Config; |
|
3
|
|
|
|
|
4
|
|
|
class PodiumCoreProperties |
|
5
|
|
|
{ |
|
6
|
|
|
/** |
|
7
|
|
|
* @var mixed |
|
8
|
|
|
*/ |
|
9
|
|
|
protected $templateUrl; |
|
10
|
|
|
|
|
11
|
|
|
public function __construct() |
|
12
|
|
|
{ |
|
13
|
|
|
$this->templateUrl = $this->getTemplateURL(); // set property so that we can access it from child class |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
private function getTemplateURL() |
|
17
|
|
|
{ |
|
18
|
|
|
return basename(get_page_template()); // get the template file url ( example: test.php ) |
|
19
|
|
|
} |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
class Settings extends PodiumCoreProperties |
|
23
|
|
|
{ |
|
24
|
|
|
public function displaySidebar() |
|
25
|
|
|
{ |
|
26
|
|
|
// return bool |
|
27
|
|
|
|
|
28
|
|
|
$rules = $this->excludedSidebarSettings(); // get rules from private function |
|
29
|
|
|
$postType = get_post_type(); |
|
30
|
|
|
$postID = get_the_ID(); |
|
31
|
|
|
|
|
32
|
|
|
foreach (get_the_category() as $category) { |
|
33
|
|
|
$taxonomyID = $category->term_id; |
|
34
|
|
|
$categoryID = $category->cat_ID; |
|
35
|
|
|
break; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
if (in_array($this->templateUrl, $rules['excludeByFileName'], true)) { |
|
39
|
|
|
// if the current template has been excluded |
|
40
|
|
|
return false; |
|
41
|
|
|
} elseif (isset($postType) && in_array($postType, $rules['excludeByPostByType'], true)) { |
|
42
|
|
|
return false; |
|
43
|
|
|
} elseif (isset($taxonomyID) && in_array($taxonomyID, $rules['excludeByTaxonomyID'], true)) { |
|
44
|
|
|
return false; |
|
45
|
|
|
} elseif (isset($postID) && in_array($postID, $rules['excludeByPostID'], true)) { |
|
46
|
|
|
return false; |
|
47
|
|
|
} elseif (isset($categoryID) && in_array($categoryID, $rules['excludeByCategoryID'], true)) { |
|
48
|
|
|
return false; |
|
49
|
|
|
} else { |
|
50
|
|
|
return true; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param $contentHasSidebarClass |
|
57
|
|
|
* @param $contentNoSidebarClass |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getContentClass($contentHasSidebarClass = 'medium-8', $contentNoSidebarClass = 'medium-12') |
|
61
|
|
|
{ |
|
62
|
|
|
// return bool |
|
63
|
|
|
|
|
64
|
|
|
if ($this->displaySidebar()) { |
|
65
|
|
|
return $contentHasSidebarClass; |
|
66
|
|
|
} else { |
|
67
|
|
|
return $contentNoSidebarClass; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param $walker_object |
|
74
|
|
|
* @param $canvas |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getMenu($walker_object, $canvas = 'onCanvass') |
|
77
|
|
|
{ |
|
78
|
|
|
if (has_nav_menu('main-nav')) { |
|
79
|
|
|
// check if menu exists |
|
80
|
|
|
if ('onCanvass' == $canvas) { |
|
81
|
|
|
// check if the menu is off-canvas |
|
82
|
|
|
$onCanvas = [ |
|
83
|
|
|
'theme_location' => 'main-nav', |
|
84
|
|
|
'menu' => '', |
|
85
|
|
|
'container' => false, |
|
86
|
|
|
'items_wrap' => '<ul id="%1$s" class="%2$s show-for-medium" data-dropdown-menu>%3$s</ul>', |
|
87
|
|
|
'container_class' => '', |
|
88
|
|
|
'container_id' => '', |
|
89
|
|
|
'menu_class' => 'dropdown menu', |
|
90
|
|
|
'menu_id' => '', |
|
91
|
|
|
'echo' => true, |
|
92
|
|
|
'fallback_cb' => 'wp_nav_menu', |
|
93
|
|
|
'before' => '', |
|
94
|
|
|
'after' => '', |
|
95
|
|
|
'link_before' => '', |
|
96
|
|
|
'link_after' => '', |
|
97
|
|
|
'depth' => 0, |
|
98
|
|
|
'walker' => $walker_object |
|
99
|
|
|
]; |
|
100
|
|
|
|
|
101
|
|
|
wp_nav_menu($onCanvas); |
|
102
|
|
|
|
|
103
|
|
|
} elseif ('offCanvas' == $canvas) { |
|
104
|
|
|
$offCanvas = [ |
|
105
|
|
|
'theme_location' => 'main-nav', |
|
106
|
|
|
'menu' => '', |
|
107
|
|
|
'container' => '', |
|
108
|
|
|
'container_class' => '', |
|
109
|
|
|
'container_id' => '', |
|
110
|
|
|
'menu_class' => 'button-group', |
|
111
|
|
|
'menu_id' => '', |
|
112
|
|
|
'echo' => true, |
|
113
|
|
|
'fallback_cb' => 'wp_nav_menu', |
|
114
|
|
|
'before' => '', |
|
115
|
|
|
'after' => '', |
|
116
|
|
|
'link_before' => '', |
|
117
|
|
|
'link_after' => '', |
|
118
|
|
|
'items_wrap' => '<ul class="off-canvas-list %2$s" role="navigation">%3$s</ul>', |
|
119
|
|
|
'depth' => 0, |
|
120
|
|
|
'walker' => $walker_object |
|
121
|
|
|
]; |
|
122
|
|
|
|
|
123
|
|
|
wp_nav_menu($offCanvas); |
|
124
|
|
|
|
|
125
|
|
|
} else { |
|
126
|
|
|
// if no type - wrong parameter error |
|
127
|
|
|
echo "<div class='alert label'>error invalid canvas value use: onCanvass or offCanvas (default: 'onCanvass')</div>"; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
} else { |
|
131
|
|
|
// no menu |
|
132
|
|
|
echo "<div class='alert label'>Menus do not exist please create one</div>"; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
// make chnages to this method |
|
138
|
|
|
/** |
|
139
|
|
|
* @return mixed |
|
140
|
|
|
*/ |
|
141
|
|
|
private function excludedSidebarSettings() |
|
142
|
|
|
{ |
|
143
|
|
|
// Sidebars will be displayed by default. to explode some pages change these settings |
|
144
|
|
|
|
|
145
|
|
|
$excludedRules = []; |
|
146
|
|
|
|
|
147
|
|
|
// Add to this list to remove the sidebar from template files. |
|
148
|
|
|
$excludedRules['excludeByFileName'] = [ |
|
149
|
|
|
|
|
150
|
|
|
// 'test.php', |
|
151
|
|
|
// 'page.php', |
|
152
|
|
|
]; |
|
153
|
|
|
|
|
154
|
|
|
// Add to this list to remove the sidebar by post type. |
|
155
|
|
|
$excludedRules['excludeByPostByType'] = [ |
|
156
|
|
|
|
|
157
|
|
|
// 'page', |
|
158
|
|
|
// 'cart', |
|
159
|
|
|
]; |
|
160
|
|
|
|
|
161
|
|
|
// Add to this list to remove the sidebar by taxonomy ID. |
|
162
|
|
|
$excludedRules['excludeByTaxonomyID'] = [ |
|
163
|
|
|
|
|
164
|
|
|
// '43', |
|
165
|
|
|
// '1234', |
|
166
|
|
|
]; |
|
167
|
|
|
|
|
168
|
|
|
// Add to this list to remove the sidebar from pages by ID. |
|
169
|
|
|
|
|
170
|
|
|
// note: NOT recommended to use this feature. Use only if you have no choice. |
|
171
|
|
|
// however you can add dynamic functionality to this file. |
|
172
|
|
|
$excludedRules['excludeByPostID'] = [ |
|
173
|
|
|
|
|
174
|
|
|
// '2', |
|
175
|
|
|
|
|
176
|
|
|
// '256', |
|
177
|
|
|
// '823', |
|
178
|
|
|
]; |
|
179
|
|
|
|
|
180
|
|
|
// Add to this list to remove the sidebar from categories by ID. |
|
181
|
|
|
|
|
182
|
|
|
// note: NOT recommended to use this feature. Use only if you have no choice. |
|
183
|
|
|
// however you can add dynamic functionality to this file. |
|
184
|
|
|
$excludedRules['excludeByCategoryID'] = [ |
|
185
|
|
|
|
|
186
|
|
|
// 2, |
|
187
|
|
|
|
|
188
|
|
|
// '5', |
|
189
|
|
|
// '12', |
|
190
|
|
|
]; |
|
191
|
|
|
|
|
192
|
|
|
return $excludedRules; |
|
193
|
|
|
} |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
define('WPCF7_AUTOP', false); |
|
197
|
|
|
|