Version Description
- 02/01/2016 =
- Change - Removed the unneeded prefixes of the class methods.
- Tested - With the current WordPress version (4.7)
- Improvement - Change the deprecated 'wpml_active_languages' function to 'wpml_get_active_languages'
Download this release
Release Info
Developer | sormano |
Plugin | WPML Widgets |
Version | 1.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.4 to 1.0.5
- readme.txt +8 -4
- wpml-widgets.php +26 -26
readme.txt
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
=== WPML Widgets ===
|
2 |
Contributors: sormano
|
3 |
-
|
4 |
-
Tags: WPML, WPML widget, Wordpress Multilanguage, Wordpress Multilanguage widget, WPML widget selector
|
5 |
Requires at least: 3.6
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -31,6 +30,11 @@ WPML Widgets is a ultra lightweight plugin, so there will be (about) zero extra
|
|
31 |
|
32 |
== Changelog ==
|
33 |
|
|
|
|
|
|
|
|
|
|
|
34 |
= 1.0.4 - 25/04/2014 =
|
35 |
* Fix - Escape url in admin
|
36 |
|
1 |
=== WPML Widgets ===
|
2 |
Contributors: sormano
|
3 |
+
Tags: WPML, WPML widget, WordPress Multilanguage, WordPress Multilanguage widget, WPML widget selector
|
|
|
4 |
Requires at least: 3.6
|
5 |
+
Tested up to: 4.7
|
6 |
+
Stable tag: 1.0.5
|
7 |
License: GPLv3 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
30 |
|
31 |
== Changelog ==
|
32 |
|
33 |
+
= 1.0.5 - 02/01/2016 =
|
34 |
+
* Change - Removed the unneeded prefixes of the class methods.
|
35 |
+
* Tested - With the current WordPress version (4.7)
|
36 |
+
* Improvement - Change the deprecated 'wpml_active_languages' function to 'wpml_get_active_languages'
|
37 |
+
|
38 |
= 1.0.4 - 25/04/2014 =
|
39 |
* Fix - Escape url in admin
|
40 |
|
wpml-widgets.php
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
-
<?
|
2 |
/*
|
3 |
* Plugin Name: WPML Widgets
|
4 |
-
* Plugin URI: http://
|
5 |
* Description: Easily select which widgets you want to show for which languages
|
6 |
-
* Version: 1.0.
|
7 |
* Author: Jeroen Sormani
|
8 |
-
* Author URI: http://
|
9 |
-
|
|
|
10 |
|
11 |
/*
|
12 |
* Copyright Jeroen Sormani
|
@@ -45,11 +46,10 @@ class WPML_Widgets {
|
|
45 |
|
46 |
|
47 |
/**
|
48 |
-
*
|
49 |
*
|
50 |
* @since 1.0.0
|
51 |
-
* @
|
52 |
-
* @var object $instance The instance of WPML_Widgets.
|
53 |
*/
|
54 |
private static $instance;
|
55 |
|
@@ -63,7 +63,7 @@ class WPML_Widgets {
|
|
63 |
|
64 |
// check if WPML is activated
|
65 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) :
|
66 |
-
|
67 |
endif;
|
68 |
|
69 |
if ( ! in_array( 'sitepress-multilingual-cms/sitepress.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) :
|
@@ -74,13 +74,13 @@ class WPML_Widgets {
|
|
74 |
endif;
|
75 |
|
76 |
// Add dropdown to widgets
|
77 |
-
add_action( 'in_widget_form', array( $this, '
|
78 |
|
79 |
// Update dropdown value on widget update
|
80 |
-
add_filter( 'widget_update_callback', array( $this, '
|
81 |
|
82 |
// Filter widgets by language
|
83 |
-
add_filter( 'widget_display_callback', array( $this, '
|
84 |
|
85 |
}
|
86 |
|
@@ -117,24 +117,24 @@ class WPML_Widgets {
|
|
117 |
* @param null $form Return null if new fields are added.
|
118 |
* @param array $instance An array of the widget's settings.
|
119 |
*/
|
120 |
-
public function
|
121 |
|
122 |
-
$languages =
|
123 |
|
124 |
?><p>
|
125 |
<label for='wpml_language'><?php _e( 'Display on language:', 'wpml-widgets' ); ?> </label>
|
126 |
<select id='wpml_language' name='wpml_language'><?php
|
127 |
-
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
|
134 |
-
|
135 |
|
136 |
-
|
137 |
-
|
138 |
|
139 |
</select>
|
140 |
</p><?php
|
@@ -155,7 +155,7 @@ class WPML_Widgets {
|
|
155 |
* @param array $this2 Class of ..?.
|
156 |
* @return array List of modified instance.
|
157 |
*/
|
158 |
-
public function
|
159 |
|
160 |
$instance['wpml_language'] = $_POST['wpml_language'];
|
161 |
|
@@ -176,7 +176,7 @@ class WPML_Widgets {
|
|
176 |
* @param array $args List of args.
|
177 |
* @return array List of modified widget instance.
|
178 |
*/
|
179 |
-
public function
|
180 |
|
181 |
if ( isset( $instance['wpml_language'] ) && $instance['wpml_language'] != ICL_LANGUAGE_CODE && $instance['wpml_language'] != 'all' ) :
|
182 |
return false;
|
@@ -190,7 +190,7 @@ class WPML_Widgets {
|
|
190 |
/**
|
191 |
* Nag message.
|
192 |
*
|
193 |
-
* Display a nag message when WPML is not
|
194 |
*
|
195 |
* @since 1.0.3
|
196 |
*/
|
@@ -231,7 +231,7 @@ class WPML_Widgets {
|
|
231 |
*/
|
232 |
if ( ! function_exists( 'WPML_Widgets' ) ) :
|
233 |
|
234 |
-
|
235 |
return WPML_Widgets::instance();
|
236 |
}
|
237 |
|
1 |
+
<?php
|
2 |
/*
|
3 |
* Plugin Name: WPML Widgets
|
4 |
+
* Plugin URI: http://jeroensormani.com
|
5 |
* Description: Easily select which widgets you want to show for which languages
|
6 |
+
* Version: 1.0.5
|
7 |
* Author: Jeroen Sormani
|
8 |
+
* Author URI: http://jeroensormani.com
|
9 |
+
* Text domain: wpml-widgets
|
10 |
+
*/
|
11 |
|
12 |
/*
|
13 |
* Copyright Jeroen Sormani
|
46 |
|
47 |
|
48 |
/**
|
49 |
+
* Instance of WPML_Widgets.
|
50 |
*
|
51 |
* @since 1.0.0
|
52 |
+
* @var WPML_Widgets $instance The instance of WPML_Widgets.
|
|
|
53 |
*/
|
54 |
private static $instance;
|
55 |
|
63 |
|
64 |
// check if WPML is activated
|
65 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) :
|
66 |
+
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
67 |
endif;
|
68 |
|
69 |
if ( ! in_array( 'sitepress-multilingual-cms/sitepress.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) :
|
74 |
endif;
|
75 |
|
76 |
// Add dropdown to widgets
|
77 |
+
add_action( 'in_widget_form', array( $this, 'widget_dropdown' ), 10, 3 );
|
78 |
|
79 |
// Update dropdown value on widget update
|
80 |
+
add_filter( 'widget_update_callback', array( $this, 'widget_update' ), 10, 4 );
|
81 |
|
82 |
// Filter widgets by language
|
83 |
+
add_filter( 'widget_display_callback', array( $this, 'display_widget' ), 10, 3 );
|
84 |
|
85 |
}
|
86 |
|
117 |
* @param null $form Return null if new fields are added.
|
118 |
* @param array $instance An array of the widget's settings.
|
119 |
*/
|
120 |
+
public function widget_dropdown( $widget, $form, $instance ) {
|
121 |
|
122 |
+
$languages = wpml_get_active_languages();
|
123 |
|
124 |
?><p>
|
125 |
<label for='wpml_language'><?php _e( 'Display on language:', 'wpml-widgets' ); ?> </label>
|
126 |
<select id='wpml_language' name='wpml_language'><?php
|
127 |
+
foreach ( $languages as $language ) :
|
128 |
|
129 |
+
$wpml_language = isset( $instance['wpml_language'] ) ? $instance['wpml_language'] : null;
|
130 |
+
?><option <?php selected( $language['code'], $wpml_language ); ?> value='<?php echo $language['code']; ?>'><?php
|
131 |
+
echo $language['native_name'];
|
132 |
+
?></option><?php
|
133 |
|
134 |
+
endforeach;
|
135 |
|
136 |
+
$selected = ( ! isset( $instance['wpml_language'] ) || 'all' == $instance['wpml_language'] ) ? true : false;
|
137 |
+
?><option <?php selected( $selected ); ?> value='all'><?php _e( 'All Languages', 'wpml-widgets' ); ?></option>
|
138 |
|
139 |
</select>
|
140 |
</p><?php
|
155 |
* @param array $this2 Class of ..?.
|
156 |
* @return array List of modified instance.
|
157 |
*/
|
158 |
+
public function widget_update( $instance, $new_instance, $old_instance, $this2 ) {
|
159 |
|
160 |
$instance['wpml_language'] = $_POST['wpml_language'];
|
161 |
|
176 |
* @param array $args List of args.
|
177 |
* @return array List of modified widget instance.
|
178 |
*/
|
179 |
+
public function display_widget( $instance, $widget, $args ) {
|
180 |
|
181 |
if ( isset( $instance['wpml_language'] ) && $instance['wpml_language'] != ICL_LANGUAGE_CODE && $instance['wpml_language'] != 'all' ) :
|
182 |
return false;
|
190 |
/**
|
191 |
* Nag message.
|
192 |
*
|
193 |
+
* Display a nag message when WPML is not activated.
|
194 |
*
|
195 |
* @since 1.0.3
|
196 |
*/
|
231 |
*/
|
232 |
if ( ! function_exists( 'WPML_Widgets' ) ) :
|
233 |
|
234 |
+
function WPML_Widgets() {
|
235 |
return WPML_Widgets::instance();
|
236 |
}
|
237 |
|