HEX
Server: LiteSpeed
System: Linux premium221.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: madepabj (2566)
PHP: 8.3.26
Disabled: NONE
Upload Files
File: //home/madepabj/hc-cosmetics.com/wp-content/plugins/dbea-extra/dbea-extra.php
<?php
/*
Plugin Name: DBea Extra
Plugin URI: http://snstheme.com
Description: Extra some featured for DBea theme.
Version: 1.1
Author URI: http://snstheme.com
License: GPL2+
*/

// don't load directly
if (!defined('ABSPATH'))
    die('-1');
$theme = wp_get_theme(); // gets the current theme
if ( 'DBea' == $theme->name || 'DBea' == $theme->parent_theme ) {
	class DBEA_Extra{
		function __construct(){
			// Load text domain
		    load_plugin_textdomain( 'dbea-extra', false, dirname( plugin_basename(__FILE__) ) . '/languages' );
		    require "lib/scssphp/scss.inc.php";
		    // $compiler = new ScssPhp\ScssPhp\Compiler();

			// echo $compiler->compileString('
			//   $color: #333;
			//   div { color: lighten($color, 20%); }
			// ')->getCss();
		}
	}
	function dbea_load_extra(){
		global $dbea_extra;
		$dbea_extra = new DBEA_Extra();
	}
	add_action( 'plugins_loaded', 'dbea_load_extra' );
	// Begin: Define Post Type: post-wcode
	class DBEA_PostWCode{
		function __construct(){
			add_action('init', array($this,'addPostWCodeType'));
		}
		function addPostWCodeType(){
			$labels = array(
				'name' => __( 'Post WCode', 'dbea-extra' ),
				'singular_name' => __( 'Post WCode', 'dbea-extra' ),
				'add_new' => __( 'Add New Post WCode', 'dbea-extra' ),
				'add_new_item' => __( 'Add New Post WCode', 'dbea-extra' ),
				'edit_item' => __( 'Edit Post WCode', 'dbea-extra' ),
				'new_item' => __( 'New Post WCode', 'dbea-extra' ),
				'view_item' => __( 'View Post WCode', 'dbea-extra' ),
				'search_items' => __( 'Search Post WCode', 'dbea-extra' ),
				'not_found' => __( 'No Post WCode found', 'dbea-extra' ),
				'not_found_in_trash' => __( 'No Post WCode found in Trash', 'dbea-extra' ),
				'parent_item_colon' => __( 'Parent Post WCode:', 'dbea-extra' ),
				'menu_name' => __( 'Post WCode', 'dbea-extra' ),
			);

			$args = array(
			    'labels' => $labels,
			    'exclude_from_search' => true,
	            'has_archive' => false,
	            'public' => true,
	            'menu_icon'   => 'dashicons-media-code',
	            'rewrite' => true,
	            'supports' => array('title', 'editor'),
	            'can_export' => true,
	            'show_in_nav_menus' => false
			);
			register_post_type( 'post-wcode', $args );
		}
	}
	function dbea_load_postwcode(){
		global $dbea_postwcode;
		$dbea_postwcode = new DBEA_PostWCode();
	}
	add_action( 'plugins_loaded', 'dbea_load_postwcode' );
	// End: Define Post Type: post-code
	// Begin: Define widget
	class DBEA_Widget_PostWCode extends WP_Widget {
	    public function __construct() {
	        parent::__construct(
				'postcode-widget',
				esc_html__( 'Post WCode', 'dbea-extra' ),
				array( "description" => esc_html__("Display somes shortcodes via slug of Post WCode", 'dbea-extra') )
			);
		}
		function widget($args, $instance) {
			extract($args);
	        $title = '';
	        if (isset($instance['title']))
			    $title = apply_filters('widget_title', $instance['title']);
	        $output = '';
	        if ($instance['name']) {
	            $output = do_shortcode('[dbea_postwcode name="' . $instance['name'] . '"]');
	        }
	        if (!$output) return;
	        //echo $before_widget;
			if ($title) {
				echo $before_title . $title . $after_title;
			}
	        echo $output;
	        //echo $after_widget;
		}
		function update($new_instance, $old_instance) {
			$instance = $old_instance;
	        $instance['title'] = $new_instance['title'];
	        $instance['name'] = $new_instance['name'];
			return $instance;
		}
		function form($instance) {
			$defaults = array();
			$instance = wp_parse_args((array) $instance, $defaults);
	        ?>
	        <p>
	            <label for="<?php echo $this->get_field_id('title'); ?>">
	                <?php esc_html_e('Title:', 'dbea-extra'); ?>
	                <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset($instance['title'])) echo $instance['title']; ?>" />
	            </label>
	        </p>
	        <p>
	            <label for="<?php echo $this->get_field_id('name'); ?>">
	                <?php esc_html_e('Slug of Post WCode:', 'dbea-extra'); ?>
	                <input type="text" class="widefat" id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" value="<?php if (isset($instance['name'])) echo $instance['name']; ?>" />
	            </label>
	        </p>
		    <?php
		}
	}
	class DBEA_Widget_Vertical_Menu extends WP_Widget {
		function __construct(){
			parent::__construct(
				'DBEA_Widget_Vertical_Menu',
				esc_html__( 'DBEA Vertical Menu', 'dbea' ),
				array( "description" => esc_html__("Add a vertical menu to your sidebar.", 'dbea') )
			);
		}
		function widget( $args, $instance ) {
			// Get menu
			$ver_menu = ! empty( $instance['ver_menu'] ) ? wp_get_nav_menu_object( $instance['ver_menu'] ) : false;
			if ( !$ver_menu )
				return;
			$instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
			echo $args['before_widget'];
			?>
			<div class="sns-vertical-menu hidden-md hidden-sm hidden-xs">
			<?php
				if ( !empty($instance['title']) )
					echo $args['before_title'] . $instance['title'] . $args['after_title'];
				?>
				<?php 
				$nav_menu_args = array(
					'fallback_cb' => '',
					'menu'        => $ver_menu
				);
				 wp_nav_menu( array(
	   				'container' => false, 
	   				'menu' => $ver_menu,
	   				'walker' => new dbea_Megamenu_Front,
	   				'menu_class' => 'vertical-style'
	       		) ); 
				?>
			</div>
			<div class="sns-respmenu hidden-lg">
			    <?php
			    if ( !empty($instance['title']) )
					echo $args['before_title'] . $instance['title'] . $args['after_title'];
	            wp_nav_menu( array(
	   				'container' => false, 
	   				'menu' => $ver_menu,
	   				'menu_class' => 'nav-sidebar resp-nav'
	           	) );
				?>
			</div>
			<?php
			echo $args['after_widget'];
		}

		function update( $new_instance, $old_instance ) {
			$instance = array();
			if ( ! empty( $new_instance['title'] ) ) {
				$instance['title'] = sanitize_text_field( $new_instance['title'] );
			}
			if ( ! empty( $new_instance['ver_menu'] ) ) {
				$instance['ver_menu'] = (int) $new_instance['ver_menu'];
			}
			return $instance;
		}

		function form( $instance ) {
			$title = isset( $instance['title'] ) ? $instance['title'] : '';
			$ver_menu = isset( $instance['ver_menu'] ) ? $instance['ver_menu'] : '';
			// Get menus
			$menus = wp_get_nav_menus();
			?>
			<div class="sns-vertical-menu-widget-form-controls" style="width: 100%; vertical-align: top; display: inline-block; margin-bottom: 15px;" <?php if ( empty( $menus ) ) { echo ' style="display:none" '; } ?>>
				<p>
					<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'dbea' ) ?></label>
					<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>"/>
				</p>
				<p>
					<label for="<?php echo $this->get_field_id( 'ver_menu' ); ?>"><?php esc_html_e( 'Select Menu:', 'dbea'); ?></label><br />
					<select id="<?php echo $this->get_field_id( 'ver_menu' ); ?>" name="<?php echo $this->get_field_name( 'ver_menu' ); ?>">
						<option value="0"><?php esc_html_e( '&mdash; Select &mdash;', 'dbea' ); ?></option>
						<?php foreach ( $menus as $menu ) : ?>
							<option value="<?php echo esc_attr( $menu->term_id ); ?>" <?php selected( $ver_menu, $menu->term_id ); ?>>
								<?php echo esc_html( $menu->name ); ?>
							</option>
						<?php endforeach; ?>
					</select>
				</p>
			</div>
			<?php
		}
	}
	function dbea_load_widgets() {
	    register_widget( 'DBEA_Widget_PostWCode' );
	    register_widget( 'DBEA_Widget_Vertical_Menu' );
	}
	add_action('widgets_init', 'dbea_load_widgets');
	// End: Define widget
	// Add Custom CSS for dbea_postwcode
	add_action( 'wp_head', 'dbea_load_postwcode_css', 1000 );
	function dbea_load_postwcode_css(){
		$args = array(
				'post_type' => 'post-wcode',
				'post_status' => 'publish', 
				'posts_per_page' => -1
		);
		$wcode = new WP_Query($args);
		$output = '';
		$output .= '<style type="text/css">';
		if ( $wcode->have_posts() ) {
			while ( $wcode->have_posts() ) { // echo '->'.get_the_ID().'<br/>';
				$wcode->the_post();
				$wcode_css = get_post_meta( get_the_ID(), '_wpb_post_custom_css', true );
				$wcode_css .= get_post_meta( get_the_ID(), '_wpb_shortcodes_custom_css', true );
			    if ( ! empty( $wcode_css ) ) {
			        $output .= $wcode_css;
			    }
			}
		}
	    $output .= '</style>';
	    wp_reset_postdata();
	    echo $output;
	}
}