HEX
Server: Apache/2.4.57 (Debian)
System: Linux web-server-k8s-e92jnr3j-6f99bff6b6-rp2wg 6.1.0-22-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.94-1 (2024-06-21) x86_64
User: apache (48)
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,
Upload Files
File: /var/www/sites/1250.info/wp-content/plugins/nm-custom-code/includes/elementor/widgets/posts.php
<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/* Class: Widget - NM_Elementor_Posts  */
class NM_Elementor_Posts extends \Elementor\Widget_Base {
    
    public function __construct( $data = [], $args = null ) {
        parent::__construct( $data, $args );
   }
    
	public function get_name() {
		return 'nm-posts';
	}
    
	public function get_title() {
		return __( 'Posts', 'nm-framework-admin' );
	}

	public function get_icon() {
		return 'eicon-posts-grid';
	}

	public function get_categories() {
        return [ 'savoy-theme' ];
	}
    
	protected function _register_controls() {
        
        $this->start_controls_section(
			'section_posts_settings',
			[
				'label' => __( 'Posts', 'nm-framework-admin' ),
			]
		);
        
        $this->add_control(
            'num_posts',
            [
                'label'     => __( 'Number of Posts', 'nm-framework-admin' ),
                'type'      => Controls_Manager::NUMBER,
                'min'       => 1,
                'max'       => 1000,
                'step'      => 1,
                'default'   => '4',
            ]
        );
        $this->add_control(
			'columns',
			[
				'label'         => __( 'Columns', 'nm-framework-admin' ),
				'type'          => Controls_Manager::SELECT,
                'separator'     => 'before',
                'default'       => '4',
				'options'       => [
                    '2'	=> '2',
                    '3'	=> '3',
                    '4'	=> '4',
                    '5'	=> '5',
				],
			]
		);
        $this->add_control(
			'orderby',
			[
				'label'         => __( 'Order By', 'nm-framework-admin' ),
				'type'          => Controls_Manager::SELECT,
                'separator'     => 'before',
                'default'       => 'none',
				'options'       => [
                    'none'	        => 'None',
                    'ID'	        => 'ID',
                    'author'	    => 'Author',
                    'title'	        => 'Title',
                    'name'	        => 'Name',
                    'date'	        => 'Date',
                    'rand'	        => 'Random',
                    'comment_count' => 'Commen Count',
                    'menu_order'	=> 'Menu Order',
                    'post__in'	     => 'IDs Option',
				],
			]
		);
        $this->add_control(
			'order',
			[
				'label'         => __( 'Order', 'nm-framework-admin' ),
				'type'          => Controls_Manager::SELECT,
                'separator'     => 'before',
                'default'       => 'asc',
				'options'       => [
                    'desc'	        => 'Descending',
                    'asc'	        => 'Ascending',
				],
			]
		);
        if ( function_exists( 'nm_get_post_categories' ) ) {
            $post_categories = array_flip( nm_get_post_categories() );
            
            $this->add_control(
                'category',
                [
                    'label'         => __( 'Category', 'nm-framework-admin' ),
                    'type'          => Controls_Manager::SELECT,
                    'options'       => $post_categories,
                    'default'   => '',
                ]
            );
        }
        $this->add_control(
			'post_ids',
			[
				'label'         => __( 'IDs', 'nm-framework-admin' ),
				'type'          => Controls_Manager::TEXT,
                'separator'     => 'before',
                'description'   => __( 'Filter posts by entering a comma separated list of IDs.', 'nm-framework-admin' ),
			]
		);
        $this->add_control(
			'image_type',
			[
				'label'         => __( 'Image Type', 'nm-framework-admin' ),
				'type'          => Controls_Manager::SELECT,
                'separator'     => 'before',
                'default'       => 'standard',
				'options'       => [
                    'standard'	    => 'Standard image',
                    'background'    => 'CSS background image',
				],
			]
		);
        $this->add_control(
			'post_excerpt',
			[
				'label'         => __( 'Post Excerpt', 'nm-framework-admin' ),
				'type'          => Controls_Manager::SWITCHER,
				'separator'     => 'before',
                'return_value'  => '1',
                'default'       => '',
			]
		);
        
		$this->end_controls_section();
        
    }

	protected function render() {
        $posts = $this->get_settings_for_display();
        
        $settings = array();
        
        // IDs: Using "id/ids" as widget-control ID cause error in Elementor editor (widgets can't be deleted): https://github.com/elementor/elementor/issues/5933
        if ( isset( $posts['post_ids'] ) && ! empty( $posts['post_ids'] ) ) {
            $settings['ids'] = $posts['post_ids'];
        }
        unset( $posts['post_ids'] );
        
        foreach( $posts as $setting => $value ) {
            if ( substr( $setting, 0, 1 ) === '_' ) { break; } // Break loop if setting name starts with "_" (Elementor adds this to its own settings)
            if ( empty( $value ) && $value !== '0' ) { continue; } // Don't add empty settings, except "0" values
            
            $settings[$setting] = $value;
        }
        
        echo nm_shortcode_posts( $settings );
    }

}