Skip to content

Commit 4548e88

Browse files
committed
Added translation support
1 parent 3628243 commit 4548e88

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

class-shortcode-widget.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
class Shortcode_Widget extends WP_Widget {
88

99
function __construct() {
10-
$widget_ops = array('classname' => 'shortcode_widget', 'description' => __('Shortcode or HTML or Plain Text','shortcode-widget'));
10+
$widget_ops = array('classname' => 'shortcode_widget', 'description' => __('Shortcode or HTML or Plain Text', SHORTCODE_WIDGET_TEXT_DOMAIN));
1111
$control_ops = array('width' => 400, 'height' => 350);
12-
parent::__construct('shortcode-widget', __('Shortcode Widget','shortcode-widget'), $widget_ops, $control_ops);
12+
parent::__construct('shortcode-widget', __('Shortcode Widget', SHORTCODE_WIDGET_TEXT_DOMAIN), $widget_ops, $control_ops);
1313
}
1414

1515
function widget( $args, $instance ) {
@@ -39,12 +39,12 @@ function form( $instance ) {
3939
$title = strip_tags($instance['title']);
4040
$text = esc_textarea($instance['text']);
4141
?>
42-
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','shortcode-widget'); ?></label>
42+
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', SHORTCODE_WIDGET_TEXT_DOMAIN); ?></label>
4343
<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>
4444

4545
<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
4646

47-
<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs','shortcode-widget'); ?></label></p>
47+
<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs', SHORTCODE_WIDGET_TEXT_DOMAIN); ?></label></p>
4848
<?php
4949
}
5050
}

index.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
<?php
22
/*
33
Plugin Name: Shortcode Widget
4-
Plugin URI: http://www.IaMmE.in
4+
Plugin URI: http://wordpress.org/extend/plugins/shortcode-widget/
55
Description: Adds a text-like widget that allows you to write shortcode in it. (Just whats missing in the default text widget)
66
Author: gagan0123
77
Author URI: http://gagan.pro/
8-
Version: 0.1
8+
Version: 0.2
99
Text Domain: shortcode-widget
1010
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
1111
*/
1212

13+
define('SHORTCODE_WIDGET_TEXT_DOMAIN','shortcode_widget');
14+
1315
require_once('class-shortcode-widget.php');
1416

1517
function shortcode_widget_init(){
1618
register_widget('Shortcode_Widget');
1719
}
1820
add_action('widgets_init','shortcode_widget_init');
1921

22+
function shortcode_widget_load_text_domain(){
23+
load_plugin_textdomain( SHORTCODE_WIDGET_TEXT_DOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
24+
}
25+
add_action('plugins_loaded','shortcode_widget_load_text_domain');
2026
?>

readme.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contributors: gagan0123
33
Tags: Shortcode, Widget
44
Requires at least: 3.3
5-
Tested up to: 3.5
6-
Stable tag: 0.1
5+
Tested up to: 3.5.1
6+
Stable tag: 0.2
77
License: GPLv2 or later
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

@@ -21,3 +21,4 @@ Adds a text-like widget that allows you to write shortcode in it. (Just whats mi
2121

2222
== Changelog ==
2323
0.1 Added the shortcode widget
24+
0.2 Added translation support

0 commit comments

Comments
 (0)