<?php
/*
Plugin Name: Zoom Font
Description: Zoom in or zoom out text size
Version: 1.0
Author: Ogah
Author URI: http://www.ddlgen.net/
*/
########### ZOOM WIDGET ###########
class Zoom extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_zoom', 'description' => __( "Zoom in or zoom out font size of wordpress") );
parent::__construct('zoom', __('Zoom Font'), $widget_ops);
}
function widget( $args, $instance ) {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? __('Zoom Font') : $instance['title'], $instance, $this->id_base);
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
?>
<form method='get' action=''><input type='number' name='zoom' size='4' value=''/> % <input type='submit' value='Zoom'/></form>
<?php
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
$title = strip_tags($instance['title']);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
<?php
}
}
function zoomfont() {
register_widget('Zoom');
}
add_action('widgets_init', 'zoomfont');
########## END ZOOM WIDGET ##########
if(isset($_GET['zoom'])) {
if(is_numeric($_GET['zoom'])) {
setcookie('zoom', $_GET['zoom']);
}
echo "<meta http-equiv='refresh' content='0; url=".$_SERVER['HTTP_REFERER']."'>\r\n";
}
function zoomtext() {
$zoom = $_COOKIE['zoom'];
echo '<style type="text/css">'."\r\nbody {\r\n\tfont-size: ".$zoom."%;\r\n}\r\n</style>\r\n";
}
if(isset($_COOKIE['zoom'])) {
add_filter('wp_head', 'zoomtext');
}