| 1 |
<?php |
| 2 |
|
| 3 |
namespace AgeGate\Integration; |
| 4 |
|
| 5 |
use AgeGate\Common\Integration; |
| 6 |
|
| 7 |
class Woof extends Integration |
| 8 |
{ |
| 9 |
public function exists() |
| 10 |
{ |
| 11 |
return class_exists('WOOF'); |
| 12 |
} |
| 13 |
|
| 14 |
public function init() |
| 15 |
{ |
| 16 |
if ($this->exists()) { |
| 17 |
|
| 18 |
add_filter('age_gate/init/content', function($content) { |
| 19 |
global $WOOF; |
| 20 |
|
| 21 |
if (!$WOOF instanceof \WOOF) { |
| 22 |
return $content; |
| 23 |
} |
| 24 |
|
| 25 |
if (method_exists($WOOF, 'get_really_current_term') && $term = $WOOF->get_really_current_term()) { |
| 26 |
// dd($term); |
| 27 |
$content = new \AgeGate\Common\Content($term, 'term'); |
| 28 |
} elseif ($WOOF->is_isset_in_request_data($WOOF->get_swoof_search_slug())) { |
| 29 |
global $wp_query; |
| 30 |
|
| 31 |
if (($wp_query->query_vars['taxonomy'] ?? false) && ($wp_query->query_vars['term'] ?? false)) { |
| 32 |
|
| 33 |
if ($term = get_term_by('slug', $wp_query->query_vars['term'], $wp_query->query_vars['taxonomy'])) { |
| 34 |
$content = new \AgeGate\Common\Content($term, 'term'); |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
return $content; |
| 40 |
}); |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|