HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux vmi1674223.contaboserver.net 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 12:29:36 UTC 2024 x86_64
User: root (0)
PHP: 7.4.3-4ubuntu2.22
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,pcntl_unshare,
Upload Files
File: /var/www/html/onlineshop/wp-content/plugins/engotheme/widgets/contact-info.php
<?php

class Engotheme_Contact_Info_Widget extends Engotheme_Widget {

    
    private $params;
    public function __construct() {
        parent::__construct(
            // Base ID of your widget
            'engo_contact_info',
            // Widget name will appear in UI
            __('ENGO Contact Info Widget', 'engotheme'),
            // Widget description
            array( 'description' => __( 'Add contact information. ', 'engotheme' ), )
        );
        $this->widgetName = 'contact-info';
        
        $this->params = array(
            'title' => __('Title', 'engotheme'),
            'description' => __('Description', 'engotheme'),
            'company' => __('Company', 'engotheme'),
            'country' => __('Country', 'engotheme'),
            'locality' => __('Locality', 'engotheme'),
            'region' => __('Region', 'engotheme'),
            'street' => __('Street', 'engotheme'),
            'working-days' => __('Working Days', 'engotheme'),
            'working-hours' => __('Working Hours', 'engotheme'),
            'phone' => __('Phone', 'engotheme'),
            'mobile' => __('Mobile', 'engotheme'),
            'fax' => __('Fax', 'engotheme'),
            'skype' => __('Skype', 'engotheme'),
            'email-address' => __('Email Address', 'engotheme'),
            'email' => __('Email', 'engotheme'),
            'website-url' => __('Website URL', 'engotheme'),
            'website' => __('Website', 'engotheme')
        );
    }


    function widget($args, $instance) {
        extract( $args );
        extract( $instance );

        $title = apply_filters('widget_title', $instance['title']);
        echo    $before_widget;
            require($this->renderLayout( 'default'));
        echo    $after_widget;
    }

    function update($new_instance, $old_instance) {
        $instance = $old_instance;
        
        foreach ($this->params as $key => $value){
            $instance[$key] = $new_instance[$key];
            $instance[$key.'_class'] = $new_instance[$key.'_class'];
        }
        return $instance;
    }

    function form($instance) {
        $defaults = array('title' => __('Contact Info', 'engotheme'));
        $instance = wp_parse_args((array) $instance, $defaults);
        $array_class = array('phone', 'mobile', 'fax', 'skype', 'email', 'website' );
        foreach ($this->params as $key => $value) :
        ?>
            <p>
                <label for="<?php echo esc_attr( $this->get_field_id($key) ); ?>"><?php echo trim($value); ?>:</label>
                <?php if(in_array($key, $array_class)):?>
                    <input class="widefat" id="<?php echo esc_attr($this->get_field_id($key)); ?>" name="<?php echo esc_attr($this->get_field_name($key)); ?>" type="text" value="<?php if (isset($instance[$key])) echo esc_attr( $instance[$key] ); ?>" />
                    <label for="<?php echo esc_attr($this->get_field_id($key.'_class')); ?>"><?php echo 'Icon class '.$value ?>:</label>
                <input class="widefat" id="<?php echo esc_attr($this->get_field_id($key.'_class')); ?>" name="<?php echo esc_attr($this->get_field_name($key.'_class')); ?>" type="text" value="<?php if (isset($instance[$key.'_class'])) echo esc_attr( $instance[$key.'_class'] ); ?>" />
                <?php else: ?>
                    <input class="widefat" id="<?php echo esc_attr($this->get_field_id($key)); ?>" name="<?php echo esc_attr($this->get_field_name($key)); ?>" type="text" value="<?php if (isset($instance[$key])) echo esc_attr( $instance[$key] ); ?>" />
                <?php endif; ?>
            </p>
        <?php endforeach; ?>
        <script type="application/javascript">
        jQuery('.checkbox').on('click',function(){
            jQuery('.'+this.id).toggle();
        });
    </script>
    <?php
    }
}

register_widget( 'Engotheme_Contact_Info_Widget' );