summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Chatzimichos <tampakrap@gentoo.org>2013-03-10 12:10:26 +0100
committerTheo Chatzimichos <tampakrap@gentoo.org>2013-03-10 12:10:26 +0100
commit7aea9fc04bd42e2ac02a1925d3a02a76d391c3e7 (patch)
tree68c852c654cef340592f1001b6310e33827b130c /plugins/jetpack/modules/widgets/facebook-likebox.php
parentMake the script more silent (diff)
downloadblogs-gentoo-7aea9fc04bd42e2ac02a1925d3a02a76d391c3e7.tar.gz
blogs-gentoo-7aea9fc04bd42e2ac02a1925d3a02a76d391c3e7.tar.bz2
blogs-gentoo-7aea9fc04bd42e2ac02a1925d3a02a76d391c3e7.zip
update plugins
Diffstat (limited to 'plugins/jetpack/modules/widgets/facebook-likebox.php')
-rw-r--r--plugins/jetpack/modules/widgets/facebook-likebox.php57
1 files changed, 40 insertions, 17 deletions
diff --git a/plugins/jetpack/modules/widgets/facebook-likebox.php b/plugins/jetpack/modules/widgets/facebook-likebox.php
index 64d03f8a..f8ab2512 100644
--- a/plugins/jetpack/modules/widgets/facebook-likebox.php
+++ b/plugins/jetpack/modules/widgets/facebook-likebox.php
@@ -1,6 +1,15 @@
<?php
/**
+ * Register the widget for use in Appearance -> Widgets
+ */
+add_action( 'widgets_init', 'jetpack_facebook_likebox_init' );
+
+function jetpack_facebook_likebox_init() {
+ register_widget( 'WPCOM_Widget_Facebook_LikeBox' );
+}
+
+/**
* Facebook Like Box widget class
* Display a Facebook Like Box as a widget
* http://developers.facebook.com/docs/reference/plugins/like-box/
@@ -17,7 +26,14 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
private $allowed_colorschemes = array( 'light', 'dark' );
function __construct() {
- parent::__construct( 'facebook-likebox', __( 'Facebook Like Box', 'jetpack' ), array( 'classname' => 'widget_facebook_likebox', 'description' => __( 'Display a Facebook Like Box to connect visitors to your Facebook Page', 'jetpack' ) ) );
+ parent::__construct(
+ 'facebook-likebox',
+ apply_filters( 'jetpack_widget_name', __( 'Facebook Like Box', 'jetpack' ) ),
+ array(
+ 'classname' => 'widget_facebook_likebox',
+ 'description' => __( 'Display a Facebook Like Box to connect visitors to your Facebook Page', 'jetpack' )
+ )
+ );
}
function widget( $args, $instance ) {
@@ -29,7 +45,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
if ( empty( $like_args['href'] ) || ! $this->is_valid_facebook_url( $like_args['href'] ) ) {
if ( current_user_can('edit_theme_options') ) {
echo $before_widget;
- echo '<p>' . sprintf( __( 'It looks like your Facebook URL is incorrectly configured. Please check it in your <a href="%s">widget settings</a>.' ), admin_url( 'widgets.php' ) ) . '</p>';
+ echo '<p>' . sprintf( __( 'It looks like your Facebook URL is incorrectly configured. Please check it in your <a href="%s">widget settings</a>.', 'jetpack' ), admin_url( 'widgets.php' ) ) . '</p>';
echo $after_widget;
}
echo '<!-- Invalid Facebook Page URL -->';
@@ -244,26 +260,33 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
}
function guess_locale_from_lang( $lang ) {
- $lang = strtolower( str_replace( '-', '_', $lang ) );
+ if ( 'en' == $lang || 'en_US' == $lang || !$lang ) {
+ return 'en_US';
+ }
+
+ if ( !class_exists( 'GP_Locales' ) ) {
+ if ( !defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || !file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
+ return false;
+ }
+
+ require JETPACK__GLOTPRESS_LOCALES_PATH;
+ }
- if ( 5 == strlen( $lang ) ) {
- $lang = substr( $lang, 0, 3 ) . strtoupper( substr( $lang, 3, 2 ) );
- } else if ( 3 == strlen( $lang ) ) {
- $lang = $lang;
+ if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
+ // WP.com: get_locale() returns 'it'
+ $locale = GP_Locales::by_slug( $lang );
} else {
- $lang = $lang . '_' . strtoupper( $lang );
+ // Jetpack: get_locale() returns 'it_IT';
+ $locale = GP_Locales::by_field( 'wp_locale', $lang );
}
-
- if ( 'en_EN' == $lang ) {
- $lang = 'en_US';
- } else if ( 'he_HE' == $lang ) {
- $lang = 'he_IL';
- } else if ( 'ja_JA' == $lang )
- $lang = 'ja_JP';
- return $lang;
+ if ( !$locale || empty( $locale->facebook_locale ) ) {
+ return false;
+ }
+
+ return $locale->facebook_locale;
}
-
+
function get_locale() {
return $this->guess_locale_from_lang( get_locale() );
}