Skip to content

Commit

Permalink
Merge commit 'b1690a303ccca8ecd735f36e2ed2dcf9689bb333' into dev
Browse files Browse the repository at this point in the history
* commit 'b1690a303ccca8ecd735f36e2ed2dcf9689bb333':
  fixed warning #92
  • Loading branch information
FitoreGashi committed Dec 19, 2024
2 parents 50fc2e8 + b1690a3 commit f60da3a
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions rrze-faudir.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,12 @@ function render_faudir_block($attributes) {
throw new Exception('FAUDIR shortcode is not registered');
}

// Get default organization from options
// Get default organization from options with proper checks
$options = get_option('rrze_faudir_options', []);
$default_org = $options['default_organization'] ?? null;
$defaultOrgIdentifier = $default_org ? $default_org['id'] : '';
$default_org = isset($options['default_organization']) && is_array($options['default_organization'])
? $options['default_organization']
: [];
$defaultOrgIdentifier = isset($default_org['id']) ? $default_org['id'] : '';

// First check if we have function and orgnr
if (!empty($attributes['function'])) {
Expand All @@ -732,7 +734,7 @@ function render_faudir_block($attributes) {
'function' => $attributes['function'],
'orgnr' => !empty($attributes['orgnr']) ? $attributes['orgnr'] : $defaultOrgIdentifier
];
}
}
// Then check for category
else if (!empty($attributes['selectedCategory'])) {
$shortcode_atts = [
Expand All @@ -744,11 +746,6 @@ function render_faudir_block($attributes) {
if (!empty($attributes['selectedPersonIds'])) {
$shortcode_atts['identifier'] = implode(',', $attributes['selectedPersonIds']);
}

// Add default orgnr if none specified
if (empty($attributes['orgnr']) && !empty($defaultOrgIdentifier)) {
$shortcode_atts['orgnr'] = $defaultOrgIdentifier;
}
}
// Finally check for selectedPersonIds without category
else if (!empty($attributes['selectedPersonIds'])) {
Expand All @@ -758,11 +755,6 @@ function render_faudir_block($attributes) {
implode(',', $attributes['selectedPersonIds']) :
$attributes['selectedPersonIds']
];

// Add default orgnr if none specified
if (empty($attributes['orgnr']) && !empty($defaultOrgIdentifier)) {
$shortcode_atts['orgnr'] = $defaultOrgIdentifier;
}
}
else {
throw new Exception(__('Neither person IDs, function+orgnr, nor category were provided', 'rrze-faudir'));
Expand Down

0 comments on commit f60da3a

Please sign in to comment.