Skip to content

Commit e26a131

Browse files
committed
* fixing screen-set widget issue.
* small changes at the gigya_raas.js file according to the log level.
1 parent a663480 commit e26a131

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

GigyaAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ public function init()
133133
'lang' => _gigParam( $this->global_options, 'lang', 'en' ),
134134
'sessionExpiration' => $session_expirations['sessionExpiration'],
135135
'rememberSessionExpiration' => $session_expirations['rememberSessionExpiration'],
136-
'logLevel' => $this->global_options['log_level'],
137136
);
138137

139138
/* Plugins shortcode activation switches */
@@ -168,6 +167,7 @@ public function init()
168167

169168
/* Load params to be available to client-side script */
170169
wp_localize_script( 'gigya_js', 'gigyaParams', $params );
170+
wp_localize_script( 'gigya_js', 'gigyaGlobalSettings', array( 'logLevel' => $this->global_options['log_level'] ) );
171171

172172
/* Checking that we have an API key and Gigya's plugin is turned on */
173173
$api_key = GIGYA__API_KEY;

features/raas/GigyaScreenSetWidget.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,15 @@ public function widget( $args, $instance ) {
5555

5656
echo '</div>';
5757

58-
$screen_set_setting = get_option( GIGYA__SETTINGS_SCREENSETS );
59-
$custom_screen_sets = array();
60-
if ( array_key_exists( 'custom_screen_sets', $screen_set_setting ) ) {
61-
$this->logger->error( 'Screen-Set widget error: The custom screen-set table is empty, Add the screen to "custom screen set" at "Screen-Sets" setting page.' );
62-
$custom_screen_sets = $screen_set_setting['custom_screen_sets'];
58+
$screen_set_settings = get_option( GIGYA__SETTINGS_SCREENSETS );
59+
$custom_screen_sets = array();
60+
if ( array_key_exists( 'custom_screen_sets', $screen_set_settings ) ) {
61+
$custom_screen_sets = $screen_set_settings['custom_screen_sets'];
6362
}
63+
if ( empty( $custom_screen_sets ) ) {
64+
$this->logger->debug( 'Screen-set widget error: The custom screen-set table is empty, please add the custom screen-set used in widget ' . $args['widget_id'] . ' to the "Screen-Sets" settings page. ' );
65+
}
66+
6467
foreach ( $custom_screen_sets as $screen_set ) {
6568
if ( ( ! empty( $screen_set['id'] ) ) && ( $screen_set['id'] == $instance['screenset_id'] ) ) {
6669
$instance['screenset_id'] = $screen_set['desktop'];
@@ -83,9 +86,13 @@ public function form( $instance ) {
8386
$select_error = array();
8487
$screen_sets_list = array();
8588
$selected_screen_set_id = esc_attr( _gigParam( $instance, 'screenset_id', '' ) );
86-
$custom_screen_sets = get_option( GIGYA__SETTINGS_SCREENSETS )['custom_screen_sets'];
89+
$screen_set_option = get_option( GIGYA__SETTINGS_SCREENSETS );
8790
$select_attrs['data-required'] = 'empty-selection';
88-
91+
if ( array_key_exists( 'custom_screen_sets', $screen_set_option ) ) {
92+
$custom_screen_sets = $screen_set_option['custom_screen_sets'];
93+
} else {
94+
$custom_screen_sets = '';
95+
}
8996
if ( ! empty( $custom_screen_sets ) ) {
9097
foreach ( $custom_screen_sets as $screen_set ) {
9198
if ( empty( $screen_set['desktop'] ) ) {
@@ -122,6 +129,7 @@ public function form( $instance ) {
122129
'attrs' => array( 'class' => 'invalid-gigya-screen-Set-option', 'selected' => 'true' )
123130
)
124131
);
132+
$this->logger->error( $form_error['error_message'] );
125133
echo _gigya_render_tpl( 'admin/tpl/error-message.tpl.php', $form_error );
126134
}
127135
} else {
@@ -182,7 +190,7 @@ public function form( $instance ) {
182190
*/
183191
public function update( $input_values, $db_values ) {
184192

185-
$valid = true;
193+
$valid = true;
186194

187195
$instance = array();
188196
if ( ! empty( $input_values ) and ! empty( $db_values ) ) {

features/raas/gigya_raas.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
/**
1717
* @class gigyaParams
1818
* @property {String} ajaxurl
19-
* @property {string} logLevel
2019
*/
2120
/**
2221
* @class gigyaRaasParams
@@ -34,6 +33,11 @@
3433
* @property raasWebScreen
3534
* @property raasLang
3635
*/
36+
/**
37+
* @class gigyaGlobalSettings
38+
* @property {string} logLevel
39+
40+
*/
3741

3842
var raasLogout = function () {
3943
gigya.accounts.logout({
@@ -117,7 +121,7 @@
117121
* @param eventObj.errorMessage
118122
*/
119123
var onScreenSetErrorHandler = function (eventObj) {
120-
if (gigyaParams.logLevel === 'debug') {
124+
if (gigyaGlobalSettings.logLevel === 'debug') {
121125
console.log('Error when loading SAP Customer Data Cloud screenset: ');
122126
console.log(eventObj.errorCode + " – " + eventObj.errorMessage);
123127
}

0 commit comments

Comments
 (0)