Comparing sensitive data, confidential files or internal emails?

Most legal and privacy policies prohibit uploading sensitive data online. Diffchecker Desktop ensures your confidential information never leaves your computer. Work offline and compare documents securely.

Untitled diff

Created Diff never expires
6 removals
72 lines
29 additions
94 lines
<?php if ( ! defined( 'ABSPATH' ) ) { die( 'Tranquility - the highest manifestation of power!' ); }
<?php if ( ! defined( 'ABSPATH' ) ) { die( 'Tranquility - the highest manifestation of power!' ); }


class Widget_Online_Support extends WP_Widget {
class Widget_Online_Support extends WP_Widget {


/**
/**
* Widget constructor.
* Widget constructor.
*/
*/
private $options;
private $options;
private $prefix;
private $prefix;
function __construct() {
function __construct() {


$widget_ops = array( 'description' => __( 'Display online support infomation', 'unyson' ) );
$widget_ops = array( 'description' => __( 'Display online support infomation', 'unyson' ) );
parent::__construct( false, __( 'Online Support', 'unyson' ), $widget_ops );
parent::__construct( false, __( 'Online Support', 'unyson' ), $widget_ops );
$this->options = array(
$this->options = array(
'title' => array(
'title' => array(
'type' => 'text',
'type' => 'text',
'label' => __('Widget Title', 'unyson'),
'label' => __('Widget Title', 'unyson'),
),
),
'block' => array(
'block' => array(
'type' => 'addable-box',
'type' => 'addable-box',
'label' => __('Apartment', 'unyson'),
'label' => __('Apartment', 'unyson'),
'box-options' => array(
'box-options' => array(
'skype' => array( 'type' => 'text', 'label' => __('Skype', 'unyson'), ),
'skype' => array( 'type' => 'text', 'label' => __('Skype', 'unyson'), ),
'tel' => array( 'type' => 'text', 'label' => __('Telephone', 'unyson'), ),
'tel' => array( 'type' => 'text', 'label' => __('Telephone', 'unyson'), ),
'desc' => array( 'type' => 'text', 'label' => __('Aparment name', 'unyson'), ),
'desc' => array( 'type' => 'text', 'label' => __('Aparment name', 'unyson'), ),
),
),
'box-controls' => array( // buttons next to (x) remove box button
'box-controls' => array( // buttons next to (x) remove box button
'control-id' => '<small class="dashicons dashicons-smiley"></small>',
'control-id' => '<small class="dashicons dashicons-smiley"></small>',
),
),
'limit' => 0, // limit the number of boxes that can be added
'limit' => 0, // limit the number of boxes that can be added
'add-button-text' => __('Add New', 'unyson'),
'add-button-text' => __('Add New', 'unyson'),
'sortable' => true,
'sortable' => true,
),
),

);
);
$this->prefix = 'online_support';
$this->prefix = 'online_support';
}
}


function widget( $args, $instance ) {
function widget( $args, $instance ) {
extract( $args );
extract( $args );
$params = array();
$params = array();


foreach ( $instance as $key => $value ) {
foreach ( $instance as $key => $value ) {
$params[ $key ] = $value;
$params[ $key ] = $value;
}
}


$filepath = dirname( __FILE__ ) . '/views/widget.php';
$filepath = dirname( __FILE__ ) . '/views/widget.php';


$instance = $params;
$instance = $params;


if ( file_exists( $filepath ) ) {
if ( file_exists( $filepath ) ) {
include( $filepath );
include( $filepath );
}
}
}
}


function update( $new_instance, $old_instance ) {
function update( $new_instance, $old_instance ) {
return fw_get_options_values_from_input($this->options, FW_Request::POST($this->prefix, array()));
return fw_get_options_values_from_input(
$this->options,
FW_Request::POST(fw_html_attr_name_to_array_multi_key($this->get_field_name($this->prefix)), array())
);
}
}


function form( $values ) {
function form( $values ) {


echo '<div class="fw-force-xs fw-theme-admin-widget-wrap" id="fw-widget-options-'. esc_attr($this->prefix) .'">';
$prefix = $this->get_field_id($this->prefix);
$id = 'fw-widget-options-'. $prefix;

echo '<div class="fw-force-xs fw-theme-admin-widget-wrap" id="'. esc_attr($id) .'">';
$this->print_widget_javascript($id);
echo fw()->backend->render_options($this->options, $values, array(
echo fw()->backend->render_options($this->options, $values, array(
'id_prefix' => $this->prefix .'-',
'id_prefix' => $prefix .'-',
'name_prefix' => $this->prefix,
'name_prefix' => $this->get_field_name($this->prefix),
));
));
echo '</div>';
echo '</div>';


return $values;
return $values;
}
}


private function print_widget_javascript($id) {
?><script type="text/javascript">
jQuery(function($) {
var selector = '#<?php echo esc_js($id) ?>', timeoutId;

$(selector).on('remove', function(){ // ReInit options on html replace (on widget Save)
clearTimeout(timeoutId);
timeoutId = setTimeout(function(){ // wait a few milliseconds for html replace to finish
fwEvents.trigger('fw:options:init', { $elements: $(selector) });
}, 100);
});
});
</script><?php
}

}
}