Skip to content

Commit 7a73d00

Browse files
committed
updating enqueue for uses
1 parent a087062 commit 7a73d00

2 files changed

Lines changed: 6 additions & 130 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/.idea
2+
.DS_Store

Framework/Enqueue.php

Lines changed: 5 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php
22

33
namespace Billy\Framework;
44

@@ -30,15 +30,15 @@ class Enqueue {
3030
public function buildInclude($attrs, $footer)
3131
{
3232
if (isset($attrs['filter']) && !empty($attrs['filter'])) {
33-
33+
3434
$filterBy = key($attrs['filter']);
3535
$filterWith = reset($attrs['filter']);
3636

3737
if (!is_array($filterWith)) {
3838
$filterWith = [$filterWith];
3939
}
4040

41-
if (!$this->filterBy($filterBy, $attrs, $filterWith))
41+
if (!$this->filterBy($filterBy, $attrs, $filterWith))
4242
return;
4343
}
4444

@@ -81,7 +81,7 @@ protected function filterBy($by, $attrs, $with)
8181
*/
8282
public function admin($attrs, $footer = 'header')
8383
{
84-
add_action('admin_enqueue_scripts', function ($hook) use ($attrs, $footer)
84+
add_action('admin_enqueue_scripts', function ($hook) use ($attrs, $footer)
8585
{
8686
$attrs['hook'] = $hook;
8787
$this->buildInclude($attrs, $this->setFooterFlag($footer));
@@ -126,129 +126,4 @@ protected function setFooterFlag($footer)
126126
{
127127
return $footer === 'footer';
128128
}
129-
130-
/**
131-
* Filter by Hook (Wordpress standard panels),
132-
* if '*' is provided then pass as this means it
133-
* should work on all admin panels.
134-
*
135-
* @param $attrs
136-
* @param $filterWith
137-
* @return bool
138-
*/
139-
public function filterHook($attrs, $filterWith)
140-
{
141-
$hook = $attrs['hook'];
142-
143-
if ($filterWith[0] === '*')
144-
return true;
145-
146-
return array_search($hook, $filterWith) !== null;
147-
}
148-
149-
/**
150-
* Filter by Page, if '*' is provided then
151-
* check we are on a page before passing.
152-
* Else check all values using 'is_page()'
153-
*
154-
* @param $attrs
155-
* @param $filterWith
156-
* @return bool
157-
*/
158-
public function filterPage($attrs, $filterWith)
159-
{
160-
if ($filterWith[0] === '*' && is_page())
161-
return true;
162-
163-
foreach ($filterWith as $filter) {
164-
if (is_page($filter)) return true;
165-
}
166-
167-
return false;
168-
}
169-
170-
/**
171-
* Filter by Post, if '*' is provided then
172-
* check we are on a single before passing.
173-
* Else check all values using 'is_single()'
174-
*
175-
* @param $attrs
176-
* @param $filterWith
177-
* @return bool
178-
*/
179-
public function filterPost($attrs, $filterWith)
180-
{
181-
if ($filterWith[0] === '*' && is_single())
182-
return true;
183-
184-
foreach ($filterWith as $filter) {
185-
if (is_single($filter))
186-
return true;
187-
}
188-
189-
return false;
190-
}
191-
192-
/**
193-
* Filter by Category, if '*' is provided then
194-
* check we are on a category page before passing.
195-
* Else check all values using 'is_category()'
196-
*
197-
* @param $attrs
198-
* @param $filterWith
199-
* @return bool
200-
*/
201-
public function filterCategory($attrs, $filterWith)
202-
{
203-
if ($filterWith[0] === '*' && is_category())
204-
return true;
205-
206-
foreach ($filterWith as $filter) {
207-
if (is_category($filter))
208-
return true;
209-
}
210-
211-
return false;
212-
}
213-
214-
/**
215-
* Filter by Archive, check if the page is a archive
216-
* using 'is_archive()'.
217-
*
218-
* @param $attrs
219-
* @param $filterWith
220-
* @return bool
221-
*/
222-
public function filterArchive($attrs, $filterWith)
223-
{
224-
return is_archive();
225-
}
226-
227-
/**
228-
* Filter by Search, check if this is a search page
229-
* using 'is_search()'.
230-
*
231-
* @param $attrs
232-
* @param $filterWith
233-
* @return bool
234-
*/
235-
public function filterSearch($attrs, $filterWith)
236-
{
237-
return is_search();
238-
}
239-
240-
/**
241-
* Filter by Post Type, check all values using
242-
* 'get_post_type()'. Select all '*' is not
243-
* supported. In that case you 'filterPost'
244-
*
245-
* @param $attrs
246-
* @param $filterWith
247-
* @return bool
248-
*/
249-
public function filterPostType($attrs, $filterWith)
250-
{
251-
return array_search(get_post_type(), $filterWith) !== null;
252-
}
253-
254-
}
129+
}

0 commit comments

Comments
 (0)