Skip to content
This repository was archived by the owner on Mar 3, 2024. It is now read-only.

Added additional i18n wrappers with 'rtw' textdomain #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions rapid-twitter-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class Rapid_Twitter_Widget extends WP_Widget {
function Rapid_Twitter_Widget() {
$widget_ops = array(
'classname' => 'widget_twitter widget_twitter--hidden',
'description' => __( 'Display your tweets from Twitter')
'description' => __( 'Display your tweets from Twitter', 'rtw' )
);
parent::WP_Widget( 'rapid-twitter', __( 'Rapid Twitter' ), $widget_ops );
parent::WP_Widget( 'rapid-twitter', __( 'Rapid Twitter', 'rtw' ), $widget_ops );

if ( is_active_widget(false, false, $this->id_base) ) {
add_action( 'wp_head', array(&$this, 'rapid_twitter_widget_style') );
Expand Down Expand Up @@ -95,19 +95,19 @@ function form( $instance ) {

//Title
echo '<p>';
echo '<label for="' . $this->get_field_id('title') . '">' . esc_html__('Title:') . '</label>';
echo '<label for="' . $this->get_field_id('title') . '">' . esc_html__('Title:', 'rtw') . '</label>';
echo '<input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" />';
echo '</p>';

//Username
echo '<p>';
echo '<label for="' . $this->get_field_id('account') . '">' . esc_html__('Twitter username:') . '</label>';
echo '<label for="' . $this->get_field_id('account') . '">' . esc_html__('Twitter username:', 'rtw') . '</label>';
echo '<input class="widefat" id="' . $this->get_field_id('account') . '" name="' . $this->get_field_name('account') . '" type="text" value="' . $account . '" />';
echo '</p>';

//Max Tweets
echo '<p>';
echo '<label for="' . $this->get_field_id('show') . '">' . esc_html__('Maximum number of tweets to show:') . '</label>';
echo '<label for="' . $this->get_field_id('show') . '">' . esc_html__('Maximum number of tweets to show:', 'rtw') . '</label>';
echo '<select id="' . $this->get_field_id('show') . '" name="' . $this->get_field_name('show') . '">';

for ( $i = 1; $i <= 20; ++$i )
Expand All @@ -122,7 +122,7 @@ function form( $instance ) {
echo '<input id="' . $this->get_field_id('hidereplies') . '" class="checkbox" type="checkbox" name="' . $this->get_field_name('hidereplies') . '"';
if ( $hidereplies )
echo ' checked="checked"';
echo ' /> ' . esc_html__('Hide replies');
echo ' /> ' . esc_html__('Hide replies', 'rtw');
echo '</label>';
echo '</p>';

Expand All @@ -131,7 +131,7 @@ function form( $instance ) {
echo '<label for="' . $this->get_field_id('includeretweets') . '"><input id="' . $this->get_field_id('includeretweets') . '" class="checkbox" type="checkbox" name="' . $this->get_field_name('includeretweets') . '"';
if ( $include_retweets )
echo ' checked="checked"';
echo ' /> ' . esc_html__('Include retweets');
echo ' /> ' . esc_html__('Include retweets', 'rtw');
echo '</label>';
echo '</p>';
}
Expand All @@ -143,7 +143,7 @@ function widget( $args, $instance ) {
$account = trim( urlencode( $instance['account'] ) );
if ( empty( $account ) ) return;
$title = apply_filters( 'widget_title', $instance['title'] );
if ( empty( $title ) ) $title = __( 'Twitter Updates' );
if ( empty( $title ) ) $title = __( 'Twitter Updates', 'rtw' );
$show = absint( $instance['show'] ); // # of Updates to show
if ( $show > 200 ) {
// Twitter paginates at 200 max tweets. update() should not have accepted greater than 20
Expand Down Expand Up @@ -232,8 +232,8 @@ function __construct() {

function init_settings_page() {
add_options_page(
'Rapid Twitter Widget Settings',
'Rapid Twitter Widget',
__( 'Rapid Twitter Widget Settings', 'rtw' ),
_x( 'Rapid Twitter Widget', 'options-general', 'rtw' ),
'manage_options',
'rapid-twitter-widget-settings',
array( &$this, 'output_settings_page' )
Expand All @@ -243,22 +243,22 @@ function init_settings_page() {
function init_options() {
add_settings_section(
'rapid_twitter_widget_api',
'Twitter API Details',
__( 'Twitter API Details', 'rtw' ),
array( &$this, 'output_options_intro' ),
'rapid-twitter-widget-settings'
);

add_settings_field(
'rapid_twitter_widget_key',
'Twitter consumer key',
__( 'Twitter consumer key', 'rtw' ),
array( &$this, 'output_key_field'),
'rapid-twitter-widget-settings',
'rapid_twitter_widget_api'
);

add_settings_field(
'rapid_twitter_widget_secret',
'Twitter consumer secret',
__( 'Twitter consumer secret', 'rtw' ),
array( &$this, 'output_secret_field'),
'rapid-twitter-widget-settings',
'rapid_twitter_widget_api'
Expand All @@ -269,7 +269,7 @@ function output_settings_page() {
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>Rapid Twitter Widget Settings</h2>
<h2><?php _e( 'Rapid Twitter Widget Settings', 'rtw' ) ?></h2>
<form method="post" action="<?php echo admin_url( 'options-general.php?page=rapid-twitter-widget-settings' ) ?>">
<?php
if ( ( 'update' == $_REQUEST['action'] ) && ( 'rapid-twitter-widget-settings' == $_REQUEST['page'] ) ) {
Expand All @@ -292,15 +292,11 @@ function output_settings_page() {
function output_options_intro() {
?>
<p>
To use the Rapid Twitter Widget, you need to
<a href="https://dev.twitter.com/apps/new" target="_blank">create an app</a>
on the Twitter website.
<?php echo sprintf( __( 'To use the Rapid Twitter Widget, you need to <a href="%s" target="_blank">create an app</a> on the Twitter website.', 'rtw' ), 'https://dev.twitter.com/apps/new' ) ?>
</p>

<p>
Be sure to fill out all the fields, just enter your website as the
callback URL.
</p>
<?php _e( 'Be sure to fill out all the fields, just enter your website as the callback URL.', 'rtw' ) ?></p>
<?php
}

Expand Down Expand Up @@ -391,7 +387,7 @@ function get_token() {
function set_options() {
$options = &$this->options;
if ( !wp_verify_nonce( $_POST['_wpnonce'], 'rapid_twitter_widget_option_group-options' ) ) {
echo '<div class="error"><p>Unable to verify form submission. Settings will not be saved.</p></div>';
echo '<div class="error"><p>' . __( 'Unable to verify form submission. Settings will not be saved.', 'rtw' ) . '</p></div>';
return;
}

Expand All @@ -406,15 +402,15 @@ function set_options() {
if ( $access_token ) {
//the key & secret are valid
update_option( 'rapid_twitter_widget_api', $options );
echo '<div class="updated"><p>Twitter application updated.</p></div>';
echo '<div class="updated"><p>' . __( 'Twitter application updated.', 'rtw' ) . '</p></div>';

//return the access token to the options array
$options['access_token'] = $access_token;

return true;
}
else {
echo '<div class="error"><p>API settings invalid. Please try again.</p></div>';
echo '<div class="error"><p>' . __( 'API settings invalid. Please try again.', 'rtw' ) . '</p></div>';

return false;
}
Expand Down