| 1 |
<?php |
| 2 |
/** |
| 3 |
* Widget Name: PC Switcher Widget |
| 4 |
* Plugin URI: https://github.com/thingsym/multi-device-switcher |
| 5 |
* Description: PC Switcher Widget add-on for the Multi Device Switcher. Use this widget to add the PC Switcher to a widget. |
| 6 |
* Version: 1.6.1 |
| 7 |
* Author: thingsym |
| 8 |
* Author URI: http://www.thingslabo.com/ |
| 9 |
* License: GPL2 |
| 10 |
* Text Domain: multi-device-switcher |
| 11 |
* Domain Path: /languages/ |
| 12 |
*/ |
| 13 |
|
| 14 |
/** |
| 15 |
* Copyright 2013 thingsym (http://www.thingslabo.com/) |
| 16 |
* |
| 17 |
* This program is free software; you can redistribute it and/or modify |
| 18 |
* it under the terms of the GNU General Public License as published by |
| 19 |
* the Free Software Foundation; either version 2 of the License, or |
| 20 |
* (at your option) any later version. |
| 21 |
* |
| 22 |
* This program is distributed in the hope that it will be useful, |
| 23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 |
* GNU General Public License for more details. |
| 26 |
* |
| 27 |
* You should have received a copy of the GNU General Public License |
| 28 |
* along with this program; if not, write to the Free Software |
| 29 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA |
| 30 |
*/ |
| 31 |
|
| 32 |
/** |
| 33 |
* PC Switcher Widget |
| 34 |
* |
| 35 |
* @since 1.2 |
| 36 |
*/ |
| 37 |
if ( class_exists( 'Multi_Device_Switcher' ) ) { |
| 38 |
add_action( 'widgets_init', 'pc_switcher_load_widgets' ); |
| 39 |
} |
| 40 |
|
| 41 |
function pc_switcher_load_widgets() { |
| 42 |
register_widget( 'PC_Switcher' ); |
| 43 |
} |
| 44 |
|
| 45 |
class PC_Switcher extends WP_Widget { |
| 46 |
|
| 47 |
function __construct() { |
| 48 |
load_plugin_textdomain( 'multi-device-switcher', false, dirname( plugin_basename( __MULTI_DEVICE_SWITCHER_FILE__ ) ) . '/languages/' ); |
| 49 |
|
| 50 |
$widget_ops = array( |
| 51 |
'classname' => 'widget_pc_switcher', |
| 52 |
'description' => __( 'Add the PC Switcher to a widget.', 'multi-device-switcher' ) |
| 53 |
); |
| 54 |
parent::__construct( 'pc-switcher', __( 'PC Switcher', 'multi-device-switcher' ), $widget_ops ); |
| 55 |
$this->alt_option_name = 'widget_pc_switcher'; |
| 56 |
} |
| 57 |
|
| 58 |
function widget( $args, $instance ) { |
| 59 |
if ( ! function_exists( 'multi_device_switcher_add_pc_switcher' ) ) { |
| 60 |
return; |
| 61 |
} |
| 62 |
|
| 63 |
global $multi_device_switcher; |
| 64 |
$name = $multi_device_switcher->get_device_theme(); |
| 65 |
|
| 66 |
if ( $name && 'None' !== $name ) { |
| 67 |
echo $args['before_widget']; |
| 68 |
multi_device_switcher_add_pc_switcher(); |
| 69 |
echo $args['after_widget']; |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
function update( $new_instance, $old_instance ) { |
| 74 |
$instance = $old_instance; |
| 75 |
|
| 76 |
return $instance; |
| 77 |
} |
| 78 |
|
| 79 |
function form( $instance ) { |
| 80 |
} |
| 81 |
} |
| 82 |
|