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/wp-content/plugins/modern-events-calendar-lite/app/addons/VC.php
<?php
/** no direct access **/
defined('MECEXEC') or die();

/**
 * Webnus MEC VC addon class
 * @author Webnus <[email protected]>
 */
class MEC_addon_VC 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 VC addon
     * @author Webnus <[email protected]>
     */
    public function init()
    {
        // Visual Composer is not installed
        if(!function_exists('vc_map')) return false;
        
        $this->factory->action('vc_before_init', array($this, 'map'));
        return true;
    }
    
    /**
     * Register the addon in VC
     * @author Webnus <[email protected]>
     */
    public function map()
    {
        $calendar_posts = get_posts(array('post_type'=>'mec_calendars', 'posts_per_page'=>'-1'));
        
        $calendars = array();
        foreach($calendar_posts as $calendar_post) $calendars[$calendar_post->post_title] = $calendar_post->ID;
        
        vc_map(array(
            'name'=>esc_html__('Modern Events Calendar', 'modern-events-calendar-lite'),
            'base'=>'MEC',
            'class'=>'',
            'controls'=>'full',
            'icon'=>$this->main->asset('img/ico-mec-vc.png'),
            'category'=>esc_html__('Content', 'modern-events-calendar-lite'),
            'params'=>array(
               array(
                  'type'=>'dropdown',
                  'holder'=>'div',
                  'class'=>'',
                  'heading'=>esc_html__('Shortcode', 'modern-events-calendar-lite'),
                  'param_name'=>'id',
                  'value'=>$calendars,
                  'description'=>esc_html__('Select from predefined shortcodes', 'modern-events-calendar-lite')
               )
            )
        ));
    }
}