Skip to content

Commit 4910341

Browse files
committed
wrap strings for gettext. escape. build resulting strings with variables
1 parent ac5a431 commit 4910341

13 files changed

+236
-207
lines changed

fb-admin-menu.php

+40-40
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function fb_notify_user_of_plugin_conflicts()
201201

202202
//if there are more than 1 plugins relying on Open Graph, warn the user on this plugins page
203203
if ( $num_conflicting >= 1 ) {
204-
fb_admin_dialog( sprintf( __( 'You have plugins installed that could potentially conflict with the Facebook plugin. Please consider disabling the following plugins on the %sPlugins Settings page%s:', 'facebook' ) . '<br />' . implode($conflicting_plugins), '<a href="plugins.php" aria-label="Plugins 0">', '</a>' ), true);
204+
fb_admin_dialog( sprintf( __( 'You have plugins installed that could potentially conflict with the Facebook plugin. Please consider disabling the following plugins on the %s:', 'facebook' ) . '<br />' . implode($conflicting_plugins), '<a href="plugins.php" aria-label="Plugins 0">' . esc_html( __( 'Plugins Settings page', 'facebook' ) ) . '</a>' ), true);
205205
}
206206
}
207207

@@ -311,44 +311,44 @@ function fb_settings_page() {
311311
?>
312312
<div class="wrap">
313313
<div class="facebook-logo"></div>
314-
<h2><?php echo esc_html__( 'Facebook for WordPress', 'facebook' ) . ' ' . fb_get_like_button($like_button_options); ?></h2>
314+
<h2><?php echo esc_html( sprintf( __( '%s for WordPress', 'facebook' ), 'Facebook' ) ) . ' ' . fb_get_like_button($like_button_options); ?></h2>
315315
<?php settings_errors(); ?>
316316
<form method="post" action="options.php">
317317
<?php
318318
settings_fields( 'fb_options' );
319319

320320
if ( !isset( $facebook ) ) {
321-
echo '<h2>' . esc_html__( 'Step 1: Create an App', 'facebook' ) . '</h2>';
322-
echo '<p><strong>' . sprintf( esc_html( __( 'If you already have a Facebook app for this website, skip to %sStep 2%s.', 'facebook' ) ), '<a href="#step-2">', '</a>' ) . '</strong></p><br>';
323-
echo '<p>' . sprintf( esc_html( __( 'If you don\'t already have an app for this website, go to %s and click the "Create New App" button. You\'ll see a dialog like the one below. Fill this in and click "Continue".', 'facebook' ) ), '<a href="https://developers.facebook.com/apps" target="_blank">https://developers.facebook.com/apps</a>' );
321+
echo '<h2>' . esc_html( __( 'Step 1: Create an App', 'facebook' ) ) . '</h2>';
322+
echo '<p><strong>' . sprintf( esc_html( __( 'If you already have a Facebook app for this website, skip to %s.', 'facebook' ) ), '<a href="#step-2">' . esc_html( __( 'Step 2', 'facebook' ) ) . '</a>' ) . '</strong></p><br>';
323+
echo '<p>' . sprintf( esc_html( __( 'If you don\'t already have an app for this website, go to %s and click the "Create New App" button. You\'ll see a dialog like the one below. Fill this in and click "Continue".', 'facebook' ) ), '<a href="https://developers.facebook.com/apps" target="_blank">https://developers.facebook.com/apps</a>' );
324324
echo '<p><img src="' . plugins_url( 'images/nux_create_app.png', __FILE__ ) . '"></p>';
325-
echo '<p>Here are for some recommendations for filling this form out.</p>';
325+
echo '<p>' . esc_html( __( 'Here are for some recommendations for filling this form out.', 'facebook' ) ) . '</p>';
326326

327-
echo '<b> App Name: </b>' . esc_html( get_bloginfo('name') ) . '<br />';
328-
echo '<b> App Namespace: </b>' . esc_html( strtolower(str_replace( ' ', '-', get_bloginfo('name') ) ) ) . '<br />';
327+
echo '<b>' . esc_html( __( 'App Name:', 'facebook' ) ) . '</b>' . esc_html( get_bloginfo('name') ) . '<br />';
328+
echo '<b>' . esc_html( __( 'App Namespace:', 'facebook' ) ) . '</b>' . esc_html( strtolower(str_replace( ' ', '-', get_bloginfo('name') ) ) ) . '<br />';
329329

330-
echo '<h2 id="step-2">' . esc_html__( 'Step 2: Set up the App', 'facebook' ) . '</h2>';
331-
echo sprintf( esc_html( __( 'Next, set up your app so that it looks like the settings below. Make sure you set your app\'s icon and image, too. If you already have an app and skipped Step 1, you can view your app settings by going to %s', 'facebook' ) ), '<a href="https://developers.facebook.com/apps">https://developers.facebook.com/apps</a>.</p>' );
330+
echo '<h2 id="step-2">' . esc_html( __( 'Step 2: Set up the App', 'facebook' ) ) . '</h2>';
331+
echo sprintf( esc_html( __( 'Next, set up your app so that it looks like the settings below. Make sure you set your app\'s icon and image, too. If you already have an app and skipped Step 1, you can view your app settings by going to %s', 'facebook' ) ), '<a href="https://developers.facebook.com/apps">https://developers.facebook.com/apps</a>.</p>' );
332332

333-
echo '<p>Here are for some recommendations for filling this form out, based on where this plugin is installed.</p>';
333+
echo '<p>' . esc_html( __( 'Here are for some recommendations for filling this form out, based on where this plugin is installed.', 'facebook' ) ) . '</p>';
334334
echo '<b> App Domains: </b>' . esc_html( parse_url( home_url('/'), PHP_URL_HOST ) ) . '<br />';
335335
echo '<b> Site URL and Mobile Web URL: </b>' . esc_html( get_bloginfo( 'wpurl' ) ) . '<br />';
336336

337337
echo '<p><img src="' . esc_url( plugins_url( 'images/nux_app_settings.png', __FILE__ ) ) . '" style="border: 1px solid #ccc; margin: 5px; padding: 5px;"></p>';
338338

339-
echo '<h2>' . esc_html__( 'Step 3: WordPress settings', 'facebook' ) . '</h2>';
340-
echo '<p>' . esc_html__( 'Now, based on what you entered in Step 2, fill in the settings below and Save. Once saved, additional options will appear on this page.', 'facebook' ) . '</p>';
339+
echo '<h2>' . esc_html( __( 'Step 3: WordPress settings', 'facebook' ) ) . '</h2>';
340+
echo '<p>' . esc_html( __( 'Now, based on what you entered in Step 2, fill in the settings below and Save. Once saved, additional options will appear on this page.', 'facebook' ) ) . '</p>';
341341
fb_get_main_settings_fields();
342342
}
343343
else {
344-
echo '<h2>' . esc_html__( 'Main Settings', 'facebook' ) . '</h2>';
344+
echo '<h2>' . esc_html( __( 'Main Settings', 'facebook' ) ) . '</h2>';
345345

346-
echo '<p>' . sprintf( esc_html( __( 'Get your App ID, Secret, and Namespace at %s. %sIf you already have a Facebook app for this website, it\'s important that you use the same information below%s.', 'facebook' ) ), '<a href="https://developers.facebook.com/apps">https://developers.facebook.com/apps</a>', '<strong>', '</strong>' ) . '</p>';
346+
echo '<p>' . sprintf( esc_html( __( 'Get your App ID, Secret, and Namespace at %s.', 'facebook' ) ) . '<strong>' . esc_html( __( 'If you already have a Facebook app for this website, it\'s important that you use the same information below.', 'facebook' ) ) . '</strong>', '<a href="https://developers.facebook.com/apps">https://developers.facebook.com/apps</a>' ) . '</p>';
347347
fb_get_main_settings_fields();
348348

349-
echo '<h2>' . esc_html__( 'Post and Page Settings', 'facebook' ) . '</h2>';
349+
echo '<h2>' . esc_html( __( 'Post and Page Settings', 'facebook' ) ) . '</h2>';
350350

351-
echo '<p>' . sprintf( esc_html( __( 'These settings affect Pages and Posts only. Additional Social Plugins are also available in the %sWidgets settings%s.', 'facebook' ) ), '<a href="widgets.php">', '</a>' );
351+
echo '<p>' . esc_html( __( 'These settings affect Pages and Posts only.', 'facebook' ) ) . ' ' . sprintf( esc_html( __( 'Additional Social Plugins are also available in the %s.', 'facebook' ) ), '<a href="widgets.php">' . esc_html( __( 'Widgets settings', 'facebook' ) ) . '</a>' );
352352

353353
fb_notify_user_of_plugin_conflicts();
354354
fb_get_social_publisher_fields();
@@ -373,7 +373,7 @@ function fb_settings_page() {
373373
function fb_insights_admin($appid = 0) {
374374
$payload = json_encode( fb_get_settings($appid) );
375375

376-
echo '<img src="http://www.facebook.com/impression.php?plugin=wordpress&payload=' . $payload . '">';
376+
echo '<img src="http://www.facebook.com/impression.php?plugin=wordpress&payload=' . $payload . '" width="1" height="1" alt=" " />';
377377
}
378378

379379
function fb_get_debug_output($appid = 0) {
@@ -383,7 +383,7 @@ function fb_get_debug_output($appid = 0) {
383383

384384
$debug['wp_ver'] = $bloginfo;
385385

386-
echo '<a href="#" id="debug-output-link" onclick="fbShowDebugInfo(); return false">debug info</a><div id="debug-output">' . esc_html( json_encode($debug) ) . '</div>';
386+
echo '<a href="#" id="debug-output-link" onclick="fbShowDebugInfo(); return false">' . esc_html( __( 'debug info', 'facebook' ) ) . '</a><div id="debug-output">' . esc_html( json_encode($debug) ) . '</div>';
387387
}
388388

389389
function fb_get_settings($appid) {
@@ -482,16 +482,16 @@ function fb_get_main_settings_fields() {
482482
function fb_add_settings_pages() {
483483
add_submenu_page(
484484
'edit-comments.php',
485-
_x('Facebook', 'admin page title', 'facebook'),
486-
_x('Facebook', 'admin menu title', 'facebook'),
485+
'Facebook',
486+
'Facebook',
487487
'moderate_comments',
488488
'fb_comments',
489489
'fb_settings_page'
490490
);
491491
add_submenu_page(
492492
'facebook-settings',
493-
_x('Insights', 'admin page title', 'facebook'),
494-
_x('Insights', 'admin menu title', 'facebook'),
493+
_x( 'Insights', 'Facebook insights stats tool', 'facebook' ),
494+
_x( 'Insights', 'Facebook insights stats tool', 'facebook' ),
495495
'publish_posts',
496496
'fb_insights',
497497
'fb_insights_page'
@@ -505,43 +505,43 @@ function fb_options_validate($input) {
505505
foreach ($input as $key=>$value) {
506506
switch ($key) {
507507
case 'app_id':
508-
$label = 'App ID';
508+
$label = __( 'App ID', 'facebook' );
509509
if (fb_options_validate_present($value, $label)) {
510510
$value = fb_options_validate_integer($value, $label);
511511
}
512512
break;
513513
case 'app_secret':
514-
$label = 'App secret';
514+
$label = __( 'App secret', 'facebook' );
515515
if (fb_options_validate_present($value, $label)) {
516516
$value = fb_options_validate_hex($value, $label);
517517
}
518518
break;
519519
case 'app_namespace':
520-
$label = 'App namespace';
520+
$label = __( 'App namespace', 'facebook' );
521521
$value = fb_options_validate_namespace($value, $label);
522522
break;
523523
case 'social_publisher':
524-
$label_prefix = "The Social Publisher's";
524+
$label_prefix = __( 'The Social Publisher\'s', 'facebook' );
525525
$value = fb_options_validate_plugin($value, $label_prefix);
526526
break;
527527
case 'recommendations_bar':
528-
$label_prefix = "The Recommendations Bar's";
528+
$label_prefix = __( 'The Recommendations Bar\'s', 'facebook' );
529529
$value = fb_options_validate_plugin($value, $label_prefix);
530530
break;
531531
case 'like':
532-
$label_prefix = "The Like Button's";
532+
$label_prefix = __( 'The Like Button\'s', 'facebook' );
533533
$value = fb_options_validate_plugin($value, $label_prefix);
534534
break;
535535
case 'subscribe':
536-
$label_prefix = "The Subscribe Button's";
536+
$label_prefix = __( 'The Subscribe Button\'s', 'facebook' );
537537
$value = fb_options_validate_plugin($value, $label_prefix);
538538
break;
539539
case 'send':
540-
$label_prefix = "The Send Button's";
540+
$label_prefix = __( 'The Send Button\'s', 'facebook' );
541541
$value = fb_options_validate_plugin($value, $label_prefix);
542542
break;
543543
case 'comments':
544-
$label_prefix = "The Comments Box's";
544+
$label_prefix = __( 'The Comments Box\'s', 'facebook' );
545545
$value = fb_options_validate_plugin($value, $label_prefix);
546546
break;
547547
default:
@@ -556,7 +556,7 @@ function fb_options_validate($input) {
556556

557557
function fb_options_validate_present($value, $label) {
558558
if ($value == '') {
559-
add_settings_error('fb_options', '', "$label must be present");
559+
add_settings_error('fb_options', '', sprintf( __( '%s must be present', 'facebook' ), $label ) );
560560
return false;
561561
}
562562
return true;
@@ -568,7 +568,7 @@ function fb_options_validate_integer($value, $label, $sanitize=true) {
568568
}
569569
if (!preg_match('/^[0-9]+$/', $value)) {
570570
$value = preg_replace('/[^0-9]/', '', $value);
571-
add_settings_error('fb_options', '', "$label has been converted to an integer");
571+
add_settings_error('fb_options', '', sprintf( __( '%s has been converted to an integer', 'facebook' ), $label ) );
572572
}
573573
return $value;
574574
}
@@ -579,7 +579,7 @@ function fb_options_validate_hex($value, $label, $sanitize=true) {
579579
}
580580
if (!preg_match('/^[0-9a-f]+$/i', $value)) {
581581
$value = preg_replace('/[^0-9a-f]/', '', strtolower($value));
582-
add_settings_error('fb_options', '', "$label has been converted to a hex string");
582+
add_settings_error('fb_options', '', sprintf( __( '%s has been converted to a hex string', 'facebook' ), $label ) );
583583
}
584584
return $value;
585585
}
@@ -590,7 +590,7 @@ function fb_options_validate_namespace($value, $label, $sanitize=true) {
590590
}
591591
if ($value != '' && !preg_match('/^[-_a-z]+$/', $value)) {
592592
$value = preg_replace('/[^-_a-z]/', '', strtolower($value));
593-
add_settings_error('fb_options', '', "$label has been converted to contain only lowercase letters, dashes and underscores");
593+
add_settings_error('fb_options', '', sprintf( __( '%s has been converted to contain only lowercase letters, dashes and underscores', 'facebook' ), $label ) );
594594
}
595595
return $value;
596596
}
@@ -607,16 +607,16 @@ function fb_options_validate_plugin($array, $label_prefix, $sanitize=true) {
607607
$label = '';
608608
switch ($key) {
609609
case 'trigger':
610-
$label = "$label_prefix trigger";
610+
$label = sprintf( __( '%s trigger', 'facebook' ), $label_prefix );
611611
break;
612612
case 'read_time':
613-
$label = "$label_prefix read time";
613+
$label = sprintf( __( '%s read time', 'facebook' ), $label_prefix );
614614
break;
615615
case 'width':
616-
$label = "$label_prefix width";
616+
$label = sprintf( __( '%s width', 'facebook' ), $label_prefix );
617617
break;
618618
case 'num_posts':
619-
$label = "$label_prefix number of posts";
619+
$label = sprintf( __( '%s number of posts', 'facebook' ), $label_prefix );
620620
break;
621621
}
622622
if ($label != '' && fb_options_validate_present($value, $label)) {

fb-core.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function fb_install_warning() {
1616
$page = (isset($_GET['page']) ? $_GET['page'] : null);
1717

1818
if ((empty($options['app_id']) || empty($options['app_secret'])) && $page != 'facebook-settings' && current_user_can( 'manage_options' ) ) {
19-
fb_admin_dialog( sprintf( __('You must %sconfigure the plugin%s to enable Facebook for WordPress.', 'facebook' ), '<a href="admin.php?page=facebook-settings">', '</a>' ), true);
19+
fb_admin_dialog( sprintf( __('You must %s to enable Facebook for WordPress.', 'facebook' ), '<a href="admin.php?page=facebook-settings">' . esc_html( __( 'configure the plugin', 'facebook' ) ) . '</a>' ), true);
2020
}
2121
}
2222

@@ -31,11 +31,11 @@ function fb_ssl_warning() {
3131
$page = (isset($_GET['page']) ? $_GET['page'] : null);
3232

3333
if ( ! wp_http_supports( array( 'ssl' => true ) ) && current_user_can( 'manage_options' ) ) {
34-
$msg = 'SSL must be enabled on your server for Facebook Social Publisher to work.';
34+
$msg = __( 'SSL must be enabled on your server for Facebook Social Publisher to work.', 'facebook' );
3535
if ( $options['social_publisher']['enabled'] ) {
3636
unset($options['social_publisher']['enabled']);
3737
update_option( 'fb_options', $options );
38-
$msg .= ' As a result, Social Publisher has been disabled.';
38+
$msg .= ' ' . __( 'As a result, Social Publisher has been disabled.', 'facebook' );
3939
}
4040
fb_admin_dialog( __( $msg, 'facebook' ), true );
4141
}
@@ -218,14 +218,14 @@ function fb_get_locale() {
218218

219219
// convert locales like "es" to "es_ES", in case that works for the given locale (sometimes it does)
220220
if (strlen($locale) == 2) {
221-
$locale = strtolower($locale).'_'.strtoupper($locale);
221+
$locale = strtolower($locale) . '_' . strtoupper($locale);
222222
}
223223

224224
// convert things like de-DE to de_DE
225-
$locale = str_replace('-', '_', $locale);
225+
$locale = str_replace( '-', '_', $locale );
226226

227227
// check to see if the locale is a valid FB one, if not, use en_US as a fallback
228-
if ( !in_array($locale, $fb_valid_fb_locales) ) {
228+
if ( ! in_array( $locale, $fb_valid_fb_locales ) ) {
229229
$locale = 'en_US';
230230
}
231231

@@ -238,5 +238,5 @@ function fb_get_locale() {
238238
* @since 1.0
239239
*/
240240
function fb_style() {
241-
wp_enqueue_style( 'fb', plugins_url( 'style/style.min.css', __FILE__ ), array(), '1.0' );
241+
wp_enqueue_style( 'fb', plugins_url( 'style/style' . ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min' ) . '.css', __FILE__ ), array(), '1.0' );
242242
}

fb-login.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function fb_check_connected_accounts() {
3838
fb_update_user_meta($current_user->ID, 'fb_data', $fb_user_data);
3939
}
4040
else {
41-
fb_admin_dialog( sprintf( __('Facebook social publishing is enabled. %sLink your Facebook account to your WordPress account</a> to get full functionality, including adding new Posts to your Timeline.', 'facebook' ), '<a href="#" onclick="authFacebook(); return false;">' ), true);
41+
fb_admin_dialog( __( 'Facebook social publishing is enabled.', 'facebook' ) . ' ' . sprintf( __( '%s to get full functionality, including adding new Posts to your Timeline.', 'facebook' ), '<a href="#" onclick="authFacebook(); return false;">' . esc_html( __( 'Link your Facebook account to your WordPress account', 'facebook' ) ) . '</a>' ), true);
4242
}
4343
}
4444
else {

0 commit comments

Comments
 (0)