| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 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,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/themes/dt-the7/inc/ |
Upload File : |
<?php
/**
* Sidebar columns layout parser.
*
* @package The7
*/
defined( 'ABSPATH' ) || exit;
/**
* Class The7_Sidebar_Layout_Parser
*/
class The7_Sidebar_Layout_Parser {
protected $widgets_count = 0;
protected $columns = array();
protected $columns_count = 0;
public function __construct( $columns_layout = '' ) {
$this->columns = $this->parse_columns( $columns_layout );
$this->columns_count = count( $this->columns );
}
public function get_columns() {
return $this->columns;
}
public function get_columns_count() {
return $this->columns_count;
}
protected function parse_columns( $columns_layout = '' ) {
if ( ! $columns_layout ) {
return array();
}
return array_map( array( $this, 'get_column_class' ), explode( '+', $columns_layout ) );
}
protected function get_column_class( $string = '' ) {
$clear_string = trim( $string );
$clear_string = str_replace( '/', '-', $clear_string );
return 'wf-' . $clear_string;
}
public function filter_dynamic_sidebar_params( $params = array() ) {
if ( isset( $this->columns[ $this->widgets_count ] ) ) {
$this->flush_default_widgets_cache();
$column = $this->columns[ $this->widgets_count ];
$params[0]['before_widget'] = preg_replace('/(class=[\'"])(.*?)([\'"])/', '$1$2 wf-cell ' . $column . '$3', $params[0]['before_widget']);
if ( $this->widgets_count >= ( $this->columns_count - 1 ) ) {
$this->widgets_count = 0;
} else {
$this->widgets_count++;
}
}
return $params;
}
public function add_sidebar_columns() {
add_filter( 'dynamic_sidebar_params', array( $this, 'filter_dynamic_sidebar_params' ) );
}
public function remove_sidebar_columns() {
remove_filter( 'dynamic_sidebar_params', array( $this, 'filter_dynamic_sidebar_params' ) );
}
private function flush_default_widgets_cache() {
wp_cache_delete('widget_recent_comments', 'widget');
wp_cache_delete('widget_recent_posts', 'widget');
}
}