Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /home/claqxcrl/confenda.com/wp-content/themes/beevent/functions/metacore/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/claqxcrl/confenda.com/wp-content/themes/beevent/functions/metacore/core-options.php
<?php
/**
 * Meta Options Core
 * 
 */
global $core_options;

$core_options = new CsCoreControl();

function cms_options($params = array())
{
    global $pagenow, $core_options;

    wp_enqueue_style('core-options');

    $tem_div = array('div','span','div');
    $tem_table = array('tr','th','td');
    /* Find Type */
    if (is_admin() && !empty($params['id']) && isset($core_options)) {
        /* Taxonomys */
        if($pagenow == 'edit-tags.php'){
            global $tag;

            $t_id = $tag->term_id;
            $cat_meta = get_option("category_$t_id");
            // get value
            if(!empty($cat_meta[$params['id']])){
                $params['value'] = $cat_meta[$params['id']];
            }
            // render id
            $params['id'] = "Cat_meta[".$params['id']."]";

            $core_options->taxonomy($params);
        }
        /* Post or Page */
        elseif ($pagenow=='post-new.php' || $pagenow=='post.php'){
            global $post;
            /* Get cms meta data opject */
            $beevent_meta = json_decode(get_post_meta($post->ID, '_cms_meta_data', true));
            
            if(!empty($beevent_meta)){
                foreach ($beevent_meta as $key => $meta){
                    $beevent_meta->$key = rawurldecode($meta);
                }
            }
            
            // Render params id
            $params['id'] = "_cms_".$params['id'];
            // Get value
            if(!empty($beevent_meta->$params['id'])){
                $params['value'] = $beevent_meta->$params['id'];
            } else {
                $params['value'] = null;
            }

            $core_options->metabox($params);
        }
    } else {
        _e('Error', 'beevent');
    }
    wp_enqueue_script('core-options');
}

class CsCoreControl
{

    function __construct()
    {
        add_action('admin_enqueue_scripts', array(
            $this,
            'Scripts'
        ));
        add_action('save_post', array($this, 'save_meta_boxes'));
    }
    /* script */
    function Scripts()
    {
        wp_register_style('core-options', get_template_directory_uri() . '/functions/metacore/assets/css/core.options.css');
        wp_register_script('core-options', get_template_directory_uri() . '/functions/metacore/assets/js/core.options.js');
    }
    private function renderType($params){
        if(isset($params['type'])){
            switch ($params['type']){
				
				case 'text':
                    return $this->text($params);
                    break;
                
                case 'switch':
                    return $this->xswitch($params);
                    break;
        
                case 'images':
                    $params['field'] = 'multiple';
                    return $this->images($params);
                    break;
                case 'imegesselect':
                    return $this->imegesselect($params);
                    break;
              
            }
        }
    }
	private function text($params)
    {
        ob_start();
        ?>
        <div class="text-field csfield">
        <?php
        $indent = '';
        if(!empty($params['icon'])){
            $indent = 'text-indent';
            echo '<i class="'.$params['icon'].'"></i>';
        }
        ?>
	    <input type="text"
	    name="<?php echo esc_attr($params['id']); ?>"
		id="<?php echo esc_attr($params['id']); ?>"
		class="xvalue <?php echo esc_attr($indent); ?>"
		value="<?php if(isset($params['value'])){ echo esc_attr($params['value']);} ?>"
		placeholder="<?php if(isset($params['placeholder'])){ echo esc_attr($params['placeholder']);} ?>" />
        </div>
        <?php
        return ob_get_clean();
    }
	
    private function select($params)
    {
    	$data = '';
    	
    	if(!empty($params['follow'])){
    		$data = ' data-follow="'.rawurlencode(json_encode($params['follow'])).'"';
    	}
    	
        ob_start();
        ?>
        <div class="select-field csfield">
        <select name="<?php echo esc_attr($params['id']); ?>" id="<?php echo esc_attr($params['id']); ?>"<?php echo esc_html($data,'beevent'); ?>>
        	<?php foreach ($params['options'] as $key => $option): ?>
        		<option value="<?php echo esc_attr($key); ?>" <?php if(isset($params['value']) && ($params['value'] == $key)){ echo "selected"; } ?>><?php echo esc_attr($option); ?></option>
        	<?php endforeach; ?>
        </select>
        </div>
	    <?php
        return ob_get_clean();
    }
	
    private function imegesselect($params){
        ob_start();
        ?>
        <div class="image-field csfield clearfix">
            <ul>
                <?php foreach ($params['options'] as $key => $image): ?>
                <li data-value="<?php echo esc_attr($key); ?>" class="<?php if($params['value'] == $key) { echo 'active'; } ?>"><img src="<?php echo esc_url($image) ?>"></li>
                <?php endforeach; ?>
            </ul>
            <input type="hidden" name="<?php echo esc_attr($params['id']); ?>" id="<?php echo esc_attr($params['id']); ?>" class="xvalue" value="<?php echo esc_attr($params['value']); ?>"/>
        </div>
	    <?php
        return ob_get_clean();
    }

    private function xswitch($params){
        $options = array('on' => 'on', 'off' => 'off');
        /** custom values */
        if(!empty($params['options'])){
            $options = $params['options'];
        }
        /** data follow */
        $data = array(' ');
        if(!empty($params['follow'])){
            $data[] = 'data-follow="'.rawurlencode(json_encode($params['follow'])).'"';
        }
        $data[] = 'data-on="'.$options['on'].'"';
        $data[] = 'data-off="'.$options['off'].'"';
        ob_start();
        ?>
        <div class="switch-field csfield<?php if($params['value'] == $options['on']){ echo ' on'; } else { echo ' off'; } ?>"<?php echo implode(' ', $data); ?>>
            <span></span>
            <input type="hidden" name="<?php echo esc_attr($params['id']); ?>" id="<?php echo esc_attr($params['id']); ?>" class="xvalue" value="<?php echo esc_attr($params['value']); ?>"/>
        </div>
        <?php
        return ob_get_clean();
    }
    /* Template */
    public function metabox($params){
        ob_start();
        ?>
		<div id="cs_metabox_field_<?php echo esc_attr($params['id']); ?>" class="cs_metabox_field clearfix">
		  <?php if(isset($params['label'])): ?>
		    <label class="field-title" for="<?php echo esc_attr($params['id']); ?>"><?php echo esc_attr($params['label']); ?></label>
	      <?php endif; ?>
	      <div class="field<?php if(isset($params['class'])){ echo ' class="'.$params['class'].'"'; } ?>">
	          <?php echo ''.$this->renderType($params); ?>
	      </div>
	      <?php if(isset($params['desc'])): ?>
	      <p class="field-desc"><?php echo esc_attr($params['desc']); ?></p>
	      <?php endif; ?>
		</div>
        <?php
        echo ob_get_clean();
    }
    /**
     * Save post update CMS data.
     *
     */
    public function save_meta_boxes($post_id)
	{
	    /* doing save. */
		if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
			return;
		}
		/* array cms meta */
        $beevent_meta = array();
        
        /* find cms meta key. */
		foreach($_POST as $key => $value) {
			if(strstr($key, '_cms_')) {
			    
			    if($key === '_cms_single_portf_media'){
			        
			       $beevent_meta[$key] = $value;
			    } else {
			    
			       $beevent_meta[$key] = rawurlencode($value);
			    }
			}
		}
		/* update _cms_meta_data. */
		if(!empty($beevent_meta)){
		  update_post_meta($post_id, '_cms_meta_data', json_encode($beevent_meta));
		}
	}
}

ZeroDay Forums Mini