HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: /datos/www/expodubai.colombia.co/wp-content/plugins/modern-events-calendar-lite/app/addons/KC.php
<?php
/** no direct access **/
defined('MECEXEC') or die();

/**
 * Webnus MEC King Composer addon class
 * @author Webnus <[email protected]>
 */
class MEC_addon_KC extends MEC_base
{
    /**
     * @var MEC_factory
     */
    public $factory;

    /**
     * @var MEC_main
     */
    public $main;

    /**
     * Constructor method
     * @author Webnus <[email protected]>
     */
    public function __construct()
    {
        // MEC Factory class
        $this->factory = $this->getFactory();
        
        // MEC Main class
        $this->main = $this->getMain();
    }
    
    /**
     * Initialize the KC addon
     * @author Webnus <[email protected]>
     * @return boolean
     */
    public function init()
    {
        // King Composer is not installed
        if(!function_exists('kc_add_map')) return false;
        
        $this->factory->action('init', array($this, 'map'));
        return true;
    }
    
    /**
     * Register the addon in KC
     * @author Webnus <[email protected]>
     */
    public function map()
    {
        $calendar_posts = get_posts(array('post_type'=>'mec_calendars', 'posts_per_page'=>'-1'));
        
        $calendars_name = $calendars_number = array();
        foreach($calendar_posts as $calendar_post)
        {
            $calendars_name[] = $calendar_post->post_title;
            $calendars_number[] = $calendar_post->ID;
        }

        $calendars_array  = array_combine($calendars_number, $calendars_name);

        kc_add_map(array
        (
            'MEC' => array(
                'name' => esc_html__('Modern Events Calendar', 'modern-events-calendar-lite'),
                'icon' => 'mec-kingcomposer-icon',
                'category' => esc_html__('Content', 'modern-events-calendar-lite'),
                'params' => array(
                    'General' => array(
                        array(
                            'name' => 'id',
                            'label' => esc_html__('Shortcode', 'modern-events-calendar-lite'),
                            'type' => 'select',
                            'options' => $calendars_array,
                            'description' => esc_html__('Select from predefined shortcodes', 'modern-events-calendar-lite'),
                        ),
                    ),
                )
            ),
        ));
    }
}