Skip to content

Commit 849c068

Browse files
committed
Fix for plugin_load_textdomain
1 parent 951323b commit 849c068

File tree

1 file changed

+47
-39
lines changed

1 file changed

+47
-39
lines changed

ReduxCore/framework.php

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ public function __construct( $sections = array(), $args = array(), $extra_tabs =
418418

419419
$params = array(
420420
'dir_name' => 'notice',
421-
'server_file' => 'http://www.reduxframework.com/' . 'wp-content/uploads/redux/redux_notice.json',
421+
'server_file' => 'http://reduxframework.com/' . 'wp-content/uploads/redux/redux_notice.json',
422422
'interval' => 3,
423423
'cookie_id' => 'redux_blast',
424424
);
@@ -630,7 +630,12 @@ private function _internationalization() {
630630
$locale = strtolower( $locale ) . '_' . strtoupper( $locale );
631631
}
632632
}
633-
load_textdomain( 'redux-framework', self::$_dir . 'languages/' . $locale . '.mo' );
633+
if ( ReduxFramework::$_is_plugin ) {
634+
load_plugin_textdomain( 'redux-framework', self::$_dir . 'languages/' . $locale . '.mo' );
635+
} else {
636+
load_textdomain( 'redux-framework', self::$_dir . 'languages/' . $locale . '.mo' );
637+
}
638+
634639
}
635640
// _internationalization()
636641

@@ -935,7 +940,7 @@ public function get_wordpress_data( $type = false, $args = array() ) {
935940
$taxonomies = $args['taxonomies'];
936941
unset ( $args['taxonomies'] );
937942
$terms = get_terms( $taxonomies, $args ); // this will get nothing
938-
if ( ! empty ( $terms ) && !is_a($terms, 'WP_Error') ) {
943+
if ( ! empty ( $terms ) && ! is_a( $terms, 'WP_Error' ) ) {
939944
foreach ( $terms as $term ) {
940945
$data[ $term->term_id ] = $term->name;
941946
}
@@ -2041,7 +2046,7 @@ public function _register_settings() {
20412046
}
20422047

20432048
if ( isset ( $section['customizer_only'] ) && $section['customizer_only'] == true ) {
2044-
$section['panel'] = false;
2049+
$section['panel'] = false;
20452050
$this->sections[ $k ] = $section;
20462051
}
20472052

@@ -2759,19 +2764,19 @@ public function ajax_save() {
27592764
'status' => __( 'Invalid security credential. Please reload the page and try again.', 'redux-framework' ),
27602765
'action' => ''
27612766
) );
2762-
2767+
27632768
die();
27642769
}
2765-
2766-
if (!current_user_can ( $this->args['page_permissions'] )) {
2770+
2771+
if ( ! current_user_can( $this->args['page_permissions'] ) ) {
27672772
echo json_encode( array(
27682773
'status' => __( 'Invalid user capability. Please reload the page and try again.', 'redux-framework' ),
27692774
'action' => ''
27702775
) );
2771-
2776+
27722777
die();
27732778
}
2774-
2779+
27752780
$redux = ReduxFrameworkInstances::get_instance( $_POST['opt_name'] );
27762781

27772782
if ( ! empty ( $_POST['data'] ) && ! empty ( $redux->args['opt_name'] ) ) {
@@ -2811,17 +2816,17 @@ public function ajax_save() {
28112816
$redux->set_options( $redux->_validate_options( $values ) );
28122817

28132818
$do_reload = false;
2814-
if (isset($this->reload_fields) && !empty($this->reload_fields)) {
2815-
if (!empty($this->transients['changed_values'])) {
2816-
foreach ($this->reload_fields as $idx => $val) {
2817-
if ( array_key_exists ( $val, $this->transients['changed_values'] )) {
2819+
if ( isset( $this->reload_fields ) && ! empty( $this->reload_fields ) ) {
2820+
if ( ! empty( $this->transients['changed_values'] ) ) {
2821+
foreach ( $this->reload_fields as $idx => $val ) {
2822+
if ( array_key_exists( $val, $this->transients['changed_values'] ) ) {
28182823
$do_reload = true;
28192824
}
28202825
}
28212826
}
28222827
}
2823-
2824-
if ( $do_reload || ( isset ( $values['defaults'] ) && ! empty ( $values['defaults'] ) ) || ( isset ( $values['defaults-section'] ) && ! empty ( $values['defaults-section'] ) )) {
2828+
2829+
if ( $do_reload || ( isset ( $values['defaults'] ) && ! empty ( $values['defaults'] ) ) || ( isset ( $values['defaults-section'] ) && ! empty ( $values['defaults-section'] ) ) ) {
28252830
echo json_encode( array( 'status' => 'success', 'action' => 'reload' ) );
28262831
die ();
28272832
}
@@ -3101,9 +3106,9 @@ public function section_menu( $k, $section, $suffix = "", $sections = array() )
31013106
}
31023107

31033108
$string = "";
3104-
if ( ( ( isset ( $this->args['icon_type'] ) && $this->args['icon_type'] == 'image' ) || ( isset ( $section['icon_type'] ) && $section['icon_type'] == 'image' ) ) || ( isset($section['icon']) && strpos( $section['icon'], '/' ) !== false ) ) {
3109+
if ( ( ( isset ( $this->args['icon_type'] ) && $this->args['icon_type'] == 'image' ) || ( isset ( $section['icon_type'] ) && $section['icon_type'] == 'image' ) ) || ( isset( $section['icon'] ) && strpos( $section['icon'], '/' ) !== false ) ) {
31053110
//if( !empty( $this->args['icon_type'] ) && $this->args['icon_type'] == 'image' ) {
3106-
$icon = ( ! isset ( $section['icon'] ) ) ? '' : '<img class="image_icon_type" src="' . esc_url($section['icon']) . '" /> ';
3111+
$icon = ( ! isset ( $section['icon'] ) ) ? '' : '<img class="image_icon_type" src="' . esc_url( $section['icon'] ) . '" /> ';
31073112
} else {
31083113
if ( ! empty ( $section['icon_class'] ) ) {
31093114
$icon_class = ' ' . $section['icon_class'];
@@ -3112,7 +3117,7 @@ public function section_menu( $k, $section, $suffix = "", $sections = array() )
31123117
} else {
31133118
$icon_class = '';
31143119
}
3115-
$icon = ( ! isset ( $section['icon'] ) ) ? '<i class="el el-cog' . esc_attr($icon_class) . '"></i> ' : '<i class="' . esc_attr($section['icon']) . esc_attr($icon_class) . '"></i> ';
3120+
$icon = ( ! isset ( $section['icon'] ) ) ? '<i class="el el-cog' . esc_attr( $icon_class ) . '"></i> ' : '<i class="' . esc_attr( $section['icon'] ) . esc_attr( $icon_class ) . '"></i> ';
31163121
}
31173122
if ( strpos( $icon, 'el-icon-' ) !== false ) {
31183123
$icon = str_replace( 'el-icon-', 'el el-', $icon );
@@ -3130,7 +3135,7 @@ public function section_menu( $k, $section, $suffix = "", $sections = array() )
31303135
}
31313136

31323137
if ( isset ( $section['type'] ) && $section['type'] == "divide" ) {
3133-
$string .= '<li class="divide' . esc_attr($section['class']) . '">&nbsp;</li>';
3138+
$string .= '<li class="divide' . esc_attr( $section['class'] ) . '">&nbsp;</li>';
31343139
} else if ( ! isset ( $section['subsection'] ) || $section['subsection'] != true ) {
31353140

31363141
// DOVY! REPLACE $k with $section['ID'] when used properly.
@@ -3139,14 +3144,14 @@ public function section_menu( $k, $section, $suffix = "", $sections = array() )
31393144
$subsectionsClass = $subsections ? ' hasSubSections' : '';
31403145
$subsectionsClass .= ( ! isset ( $section['fields'] ) || empty ( $section['fields'] ) ) ? ' empty_section' : '';
31413146
$extra_icon = $subsections ? '<span class="extraIconSubsections"><i class="el el-chevron-down">&nbsp;</i></span>' : '';
3142-
$string .= '<li id="' . esc_attr($k . $suffix) . '_section_group_li" class="redux-group-tab-link-li' . esc_attr($hide_section) . esc_attr($section['class']) . esc_attr($subsectionsClass) . '">';
3143-
$string .= '<a href="javascript:void(0);" id="' . esc_attr($k . $suffix) . '_section_group_li_a" class="redux-group-tab-link-a" data-key="' . esc_attr($k) . '" data-rel="' . esc_attr($k . $suffix) . '">' . $extra_icon . $icon . '<span class="group_title">' . wp_kses_post($section['title']) . '</span></a>';
3147+
$string .= '<li id="' . esc_attr( $k . $suffix ) . '_section_group_li" class="redux-group-tab-link-li' . esc_attr( $hide_section ) . esc_attr( $section['class'] ) . esc_attr( $subsectionsClass ) . '">';
3148+
$string .= '<a href="javascript:void(0);" id="' . esc_attr( $k . $suffix ) . '_section_group_li_a" class="redux-group-tab-link-a" data-key="' . esc_attr( $k ) . '" data-rel="' . esc_attr( $k . $suffix ) . '">' . $extra_icon . $icon . '<span class="group_title">' . wp_kses_post( $section['title'] ) . '</span></a>';
31443149

31453150
$nextK = $k;
31463151

31473152
// Make sure you can make this a subsection
31483153
if ( $subsections ) {
3149-
$string .= '<ul id="' . esc_attr($nextK . $suffix) . '_section_group_li_subsections" class="subsection">';
3154+
$string .= '<ul id="' . esc_attr( $nextK . $suffix ) . '_section_group_li_subsections" class="subsection">';
31503155
$doLoop = true;
31513156

31523157
while ( $doLoop ) {
@@ -3173,7 +3178,7 @@ public function section_menu( $k, $section, $suffix = "", $sections = array() )
31733178

31743179
if ( ( isset ( $this->args['icon_type'] ) && $this->args['icon_type'] == 'image' ) || ( isset ( $sections[ $nextK ]['icon_type'] ) && $sections[ $nextK ]['icon_type'] == 'image' ) ) {
31753180
//if( !empty( $this->args['icon_type'] ) && $this->args['icon_type'] == 'image' ) {
3176-
$icon = ( ! isset ( $sections[ $nextK ]['icon'] ) ) ? '' : '<img class="image_icon_type" src="' . esc_url($sections[ $nextK ]['icon']) . '" /> ';
3181+
$icon = ( ! isset ( $sections[ $nextK ]['icon'] ) ) ? '' : '<img class="image_icon_type" src="' . esc_url( $sections[ $nextK ]['icon'] ) . '" /> ';
31773182
} else {
31783183
if ( ! empty ( $sections[ $nextK ]['icon_class'] ) ) {
31793184
$icon_class = ' ' . $sections[ $nextK ]['icon_class'];
@@ -3182,15 +3187,15 @@ public function section_menu( $k, $section, $suffix = "", $sections = array() )
31823187
} else {
31833188
$icon_class = '';
31843189
}
3185-
$icon = ( ! isset ( $sections[ $nextK ]['icon'] ) ) ? '' : '<i class="' . esc_attr($sections[ $nextK ]['icon']) . esc_attr($icon_class) . '"></i> ';
3190+
$icon = ( ! isset ( $sections[ $nextK ]['icon'] ) ) ? '' : '<i class="' . esc_attr( $sections[ $nextK ]['icon'] ) . esc_attr( $icon_class ) . '"></i> ';
31863191
}
31873192
if ( strpos( $icon, 'el-icon-' ) !== false ) {
31883193
$icon = str_replace( 'el-icon-', 'el el-', $icon );
31893194
}
31903195

31913196
$section[ $nextK ]['class'] = isset ( $section[ $nextK ]['class'] ) ? $section[ $nextK ]['class'] : '';
3192-
$string .= '<li id="' . esc_attr($nextK . $suffix) . '_section_group_li" class="redux-group-tab-link-li ' . esc_attr($hide_sub) . esc_attr($section[ $nextK ]['class']) . ( $icon ? ' hasIcon' : '' ) . '">';
3193-
$string .= '<a href="javascript:void(0);" id="' . esc_attr($nextK . $suffix) . '_section_group_li_a" class="redux-group-tab-link-a" data-key="' . esc_attr($nextK) . '" data-rel="' . esc_attr($nextK . $suffix) . '">' . $icon . '<span class="group_title">' . wp_kses_post($sections[ $nextK ]['title']) . '</span></a>';
3197+
$string .= '<li id="' . esc_attr( $nextK . $suffix ) . '_section_group_li" class="redux-group-tab-link-li ' . esc_attr( $hide_sub ) . esc_attr( $section[ $nextK ]['class'] ) . ( $icon ? ' hasIcon' : '' ) . '">';
3198+
$string .= '<a href="javascript:void(0);" id="' . esc_attr( $nextK . $suffix ) . '_section_group_li_a" class="redux-group-tab-link-a" data-key="' . esc_attr( $nextK ) . '" data-rel="' . esc_attr( $nextK . $suffix ) . '">' . $icon . '<span class="group_title">' . wp_kses_post( $sections[ $nextK ]['title'] ) . '</span></a>';
31943199
$string .= '</li>';
31953200
}
31963201
}
@@ -3863,66 +3868,69 @@ public function create_data_string( $data = array() ) {
38633868

38643869
return $data_string;
38653870
}
3866-
3871+
38673872
/**
38683873
* Parses the string into variables without the max_input_vars limitation.
38693874
*
38703875
* @since 3.5.7.11
38713876
* @author harunbasic
38723877
* @access public
3878+
*
38733879
* @param string $string
3880+
*
38743881
* @return array $result
3875-
*/
3882+
*/
38763883
function redux_parse_str( $string ) {
38773884
if ( '' == $string ) {
38783885
return false;
38793886
}
38803887

38813888
$result = array();
3882-
$pairs = explode( '&', $string );
3889+
$pairs = explode( '&', $string );
38833890

38843891
foreach ( $pairs as $key => $pair ) {
38853892
// use the original parse_str() on each element
38863893
parse_str( $pair, $params );
38873894

38883895
$k = key( $params );
38893896

3890-
if( ! isset( $result[$k] ) ) {
3897+
if ( ! isset( $result[ $k ] ) ) {
38913898
$result += $params;
38923899
} else {
3893-
$result[$k] = $this->redux_array_merge_recursive_distinct( $result[$k], $params[$k] );
3900+
$result[ $k ] = $this->redux_array_merge_recursive_distinct( $result[ $k ], $params[ $k ] );
38943901
}
38953902
}
38963903

38973904
return $result;
3898-
}
3899-
3905+
}
3906+
39003907

39013908
/**
39023909
* Merge arrays without converting values with duplicate keys to arrays as array_merge_recursive does.
3903-
*
39043910
* As seen here http://php.net/manual/en/function.array-merge-recursive.php#92195
39053911
*
39063912
* @since 3.5.7.11
39073913
* @author harunbasic
39083914
* @access public
3915+
*
39093916
* @param array $array1
39103917
* @param array $array2
3918+
*
39113919
* @return array $merged
39123920
*/
39133921
function redux_array_merge_recursive_distinct( array $array1, array $array2 ) {
39143922
$merged = $array1;
3915-
3923+
39163924
foreach ( $array2 as $key => $value ) {
3917-
if ( is_array( $value ) && isset( $merged[$key] ) && is_array( $merged[$key] ) ) {
3918-
$merged[$key] = $this->redux_array_merge_recursive_distinct ( $merged[$key], $value );
3925+
if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
3926+
$merged[ $key ] = $this->redux_array_merge_recursive_distinct( $merged[ $key ], $value );
39193927
} else {
3920-
$merged[$key] = $value;
3928+
$merged[ $key ] = $value;
39213929
}
39223930
}
39233931

39243932
return $merged;
3925-
}
3933+
}
39263934
}
39273935

39283936
// ReduxFramework

0 commit comments

Comments
 (0)