HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: 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_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpprm/wp-content/themes/ronneby/inc/widgets/widget-news-categories-list.php
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
require_once(dirname(__FILE__).'/widget.php');

class crum_news_categories_list extends SB_WP_Widget {
	
	protected $widget_base_id = 'crum_news_categories_list';
	protected $widget_name = 'Widget: News categories list';
	
	protected $options;
	
	 public function __construct() {
		$this->widget_params = array(
			'description' => __('News categories list widget', 'dfd')
		);
		
		$this->options = array(
			array(
				'title', 'text', '', 
				'label' => __('Title', 'dfd'), 
				'input'=>'text', 
				'filters'=>'widget_title', 
				'on_update'=>'esc_attr',
			),

			array(
				'cat', 'array', '',
				'label' => __('News categories IDs', 'dfd'),
				'input' => 'wp_category_checklist',
			)
		);
		
        parent::__construct();
    }
	
	function widget( $args, $instance ) {
        extract( $args );
		$this->setInstances($instance, 'filter');
		
		$title = $this->getInstance('title');
		$categories = (array) $this->getInstance('cat');
		
        echo $before_widget;
		
        if ( ! empty( $title ) ) {
            echo $before_title . $title . $after_title;
		}
		?>

		<div class="row">
			<ul>
				<?php foreach ($categories as $cat) : ?>
				<?php 
					$cat_obj = get_category_by_slug($cat);
					if (empty($cat_obj) || !is_object($cat_obj)) {
						continue;
					}
					
					$cat_link = get_category_link($cat_obj);
					$cat_name = $cat_obj->name;
				?>
				<li class="six column"><a href="<?php echo esc_url($cat_link); ?>"><?php echo $cat_name; ?></a></li>
				<?php endforeach; ?>
			</ul>
		</div>

		<?php
        echo $after_widget;
    }
	
}