AVRIL_START_JANCOKALIVEAVRIL_END_JANCOK
| Server IP : dzynews.com / Your IP : 216.73.217.105 Web Server : nginx/1.30.3 System : Linux cloud-tdkldl-avd6 5.15.0-91-generic #101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 x86_64 User : www ( 1000) PHP Version : 8.2.31 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/dzynews.com/wp-content/themes/archive-document/Modules/Common/ |
Upload File : |
<?php
namespace B2\Modules\Common;
class Rewrite
{
public function init()
{
if (b2_get_option('normal_main', 'remove_category_tag')) {
add_filter('request', array($this, 'remove_category'));
add_filter('pre_term_link', array($this, 'pre_term_link'), 10, 2);
}
}
public function remove_category($query_vars)
{
if (!isset($_GET['page_id']) && !isset($_GET['pagename']) && !empty($query_vars['pagename'])) {
$pagename = $query_vars['pagename'];
if (strpos($pagename, '/') !== false) {
$pagename = explode('/', $pagename);
$pagename = end($pagename);
}
$categories = get_categories(['hide_empty' => false]);
$categories = wp_list_pluck($categories, 'slug');
if (in_array($pagename, $categories)) {
$query_vars['category_name'] = $pagename;
unset($query_vars['pagename']);
}
}
if (!isset($_GET['page_id']) && !isset($_GET['name']) && !empty($query_vars['name'])) {
$pagename = $query_vars['name'];
if (!$pagename)
return $query_vars;
if (!is_string($pagename))
return $query_vars;
if (strpos($pagename, '/') !== false) {
$pagename = explode('/', $pagename);
$pagename = end($pagename);
}
$categories = get_categories(['hide_empty' => false]);
$categories = wp_list_pluck($categories, 'slug');
if (in_array($pagename, $categories)) {
$query_vars['category_name'] = $pagename;
unset($query_vars['name']);
}
}
return $query_vars;
}
public function pre_term_link($term_link, $term)
{
if ($term->taxonomy === 'category') {
return '%category%';
}
return $term_link;
}
public static function get_custom_page_link($type)
{
$permalink_structure = get_option('permalink_structure');
$pages = b2_custom_page_arg();
if (isset($pages[$type])) {
$page = $pages[$type];
if ($permalink_structure) {
if (substr($permalink_structure, -1) === '/' && $page['key'] !== 'notify') {
return B2_HOME_URI . '/' . $page['key'].'/';
}
return B2_HOME_URI . '/' . $page['key'];
} else {
return B2_HOME_URI . '?b2_page=' . $page['key'];
}
}
}
}