| 1 |
<?php |
| 2 |
/** |
| 3 |
* Functions |
| 4 |
* |
| 5 |
* @package GamiPress\AI_Assistant\Functions |
| 6 |
* @since 1.0.0 |
| 7 |
* @version 1.0.0 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* Check if is a GamiPress page to render/enqueue our assets |
| 14 |
* |
| 15 |
* @since 1.0.0 |
| 16 |
*/ |
| 17 |
function gamipress_ai_assistant_is_valid_page() { |
| 18 |
|
| 19 |
if ( ( isset( $_GET['page'] ) && ( |
| 20 |
$_GET['page'] === 'gamipress' |
| 21 |
|| $_GET['page'] === 'gamipress_user_earnings' |
| 22 |
|| $_GET['page'] === 'edit_gamipress_user_earnings' |
| 23 |
|| $_GET['page'] === 'gamipress_logs' |
| 24 |
|| $_GET['page'] === 'edit_gamipress_logs' |
| 25 |
|| $_GET['page'] === 'gamipress_add_ons' |
| 26 |
|| $_GET['page'] === 'gamipress_assets' |
| 27 |
|| $_GET['page'] === 'gamipress_tools' |
| 28 |
|| $_GET['page'] === 'gamipress_settings' |
| 29 |
|| $_GET['page'] === 'gamipress_licenses' |
| 30 |
|| $_GET['page'] === 'gamipress_badge_builder' |
| 31 |
) |
| 32 |
) ) { |
| 33 |
return true; |
| 34 |
} |
| 35 |
|
| 36 |
global $typenow; |
| 37 |
|
| 38 |
if ( |
| 39 |
$typenow === 'points-type' |
| 40 |
|| $typenow === 'achievement-type' |
| 41 |
|| $typenow === 'rank-type' |
| 42 |
|| in_array( $typenow, gamipress_get_achievement_types_slugs() ) |
| 43 |
|| in_array( $typenow, gamipress_get_rank_types_slugs() ) |
| 44 |
) { |
| 45 |
return true; |
| 46 |
} |
| 47 |
|
| 48 |
return false; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Get all triggers slugs |
| 53 |
* |
| 54 |
* @since 1.0.0 |
| 55 |
* |
| 56 |
* @return array |
| 57 |
*/ |
| 58 |
function gamipress_ai_assistant_get_triggers_slugs( $original = false ) { |
| 59 |
|
| 60 |
$triggers = gamipress_get_activity_triggers(); |
| 61 |
$slugs = array(); |
| 62 |
|
| 63 |
foreach ( $triggers as $group => $group_triggers ) { |
| 64 |
foreach( $group_triggers as $trigger => $label ) { |
| 65 |
$slugs[] = $original ? $trigger : gamipress_ai_assistant_improve_slug( $trigger ); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
return $slugs; |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Trigger slugs replacements |
| 75 |
* |
| 76 |
* @since 1.0.0 |
| 77 |
* |
| 78 |
* @return array |
| 79 |
*/ |
| 80 |
function gamipress_ai_assistant_trigger_slugs_replacements() { |
| 81 |
$replacements = array( |
| 82 |
array( 'gamipress_affwp_', 'affiliatewp_' ), |
| 83 |
array( 'gamipress_ld_', 'learndash_' ), |
| 84 |
array( 'gamipress_wc_', 'woocommerce_' ), |
| 85 |
); |
| 86 |
|
| 87 |
if( defined( 'BP_PLATFORM_VERSION' ) ) { |
| 88 |
$replacements[] = array( 'gamipress_bp_', 'buddyboss_buddypress_' ); |
| 89 |
$replacements[] = array( 'gamipress_bbp_', 'buddyboss_bbpress_' ); |
| 90 |
} else { |
| 91 |
$replacements[] = array( 'gamipress_bp_', 'buddypress_' ); |
| 92 |
$replacements[] = array( 'gamipress_bbp_', 'bbpress_' ); |
| 93 |
} |
| 94 |
|
| 95 |
return $replacements; |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* Improve slug for the AI engine |
| 100 |
* |
| 101 |
* @since 1.0.0 |
| 102 |
* |
| 103 |
* @param string $slug |
| 104 |
* |
| 105 |
* @return string |
| 106 |
*/ |
| 107 |
function gamipress_ai_assistant_improve_slug( $slug ) { |
| 108 |
|
| 109 |
switch( $slug ) { |
| 110 |
case 'gamipress_register': |
| 111 |
case 'gamipress_login': |
| 112 |
case 'gamipress_new_comment': |
| 113 |
case 'gamipress_specific_new_comment': |
| 114 |
case 'gamipress_new_comment_post_type': |
| 115 |
case 'gamipress_user_post_comment': |
| 116 |
case 'gamipress_user_specific_post_comment': |
| 117 |
case 'gamipress_user_post_comment_post_type': |
| 118 |
case 'gamipress_spam_comment': |
| 119 |
case 'gamipress_specific_spam_comment': |
| 120 |
case 'gamipress_spam_comment_post_type': |
| 121 |
case 'gamipress_publish_post': |
| 122 |
case 'gamipress_delete_post': |
| 123 |
case 'gamipress_publish_page': |
| 124 |
case 'gamipress_delete_page': |
| 125 |
case 'gamipress_publish_post_type': |
| 126 |
case 'gamipress_delete_post_type': |
| 127 |
case 'gamipress_add_role': |
| 128 |
case 'gamipress_add_specific_role': |
| 129 |
case 'gamipress_set_role': |
| 130 |
case 'gamipress_set_specific_role': |
| 131 |
case 'gamipress_remove_role': |
| 132 |
case 'gamipress_remove_specific_role': |
| 133 |
case 'gamipress_update_user_meta_any_value': |
| 134 |
case 'gamipress_update_user_meta_specific_value': |
| 135 |
case 'gamipress_update_post_meta_any_value': |
| 136 |
case 'gamipress_update_post_meta_specific_value': |
| 137 |
// Site Interactions |
| 138 |
case 'gamipress_site_visit': |
| 139 |
case 'gamipress_post_visit': |
| 140 |
case 'gamipress_specific_post_visit': |
| 141 |
case 'gamipress_post_type_visit': |
| 142 |
case 'gamipress_user_post_visit': |
| 143 |
case 'gamipress_user_specific_post_visit': |
| 144 |
case 'gamipress_user_post_type_visit': |
| 145 |
$slug = str_replace( 'gamipress_', 'wordpress_', $slug ); |
| 146 |
break; |
| 147 |
// GamiPress |
| 148 |
case 'specific-achievement': |
| 149 |
case 'any-achievement': |
| 150 |
case 'all-achievements': |
| 151 |
case 'revoke-specific-achievement': |
| 152 |
case 'revoke-any-achievement': |
| 153 |
case 'earn-points': |
| 154 |
case 'points-balance': |
| 155 |
case 'gamipress_expend_points': |
| 156 |
case 'earn-rank': |
| 157 |
case 'revoke-rank': |
| 158 |
$slug = 'gamipress_' . $slug; |
| 159 |
break; |
| 160 |
default: |
| 161 |
foreach( gamipress_ai_assistant_trigger_slugs_replacements() as $replacement ) |
| 162 |
$slug = str_replace( $replacement[0], $replacement[1], $slug ); |
| 163 |
|
| 164 |
$slug = str_replace( 'gamipress_', '', $slug ); |
| 165 |
break; |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
return $slug; |
| 171 |
|
| 172 |
} |
| 173 |
|
| 174 |
/** |
| 175 |
* Restore slug |
| 176 |
* |
| 177 |
* @since 1.0.0 |
| 178 |
* |
| 179 |
* @param string $slug |
| 180 |
* |
| 181 |
* @return string |
| 182 |
*/ |
| 183 |
function gamipress_ai_assistant_restore_slug( $slug ) { |
| 184 |
|
| 185 |
switch( $slug ) { |
| 186 |
case 'wordpress_register': |
| 187 |
case 'wordpress_login': |
| 188 |
case 'wordpress_new_comment': |
| 189 |
case 'wordpress_specific_new_comment': |
| 190 |
case 'wordpress_new_comment_post_type': |
| 191 |
case 'wordpress_user_post_comment': |
| 192 |
case 'wordpress_user_specific_post_comment': |
| 193 |
case 'wordpress_user_post_comment_post_type': |
| 194 |
case 'wordpress_spam_comment': |
| 195 |
case 'wordpress_specific_spam_comment': |
| 196 |
case 'wordpress_spam_comment_post_type': |
| 197 |
case 'wordpress_publish_post': |
| 198 |
case 'wordpress_delete_post': |
| 199 |
case 'wordpress_publish_page': |
| 200 |
case 'wordpress_delete_page': |
| 201 |
case 'wordpress_publish_post_type': |
| 202 |
case 'wordpress_delete_post_type': |
| 203 |
case 'wordpress_add_role': |
| 204 |
case 'wordpress_add_specific_role': |
| 205 |
case 'wordpress_set_role': |
| 206 |
case 'wordpress_set_specific_role': |
| 207 |
case 'wordpress_remove_role': |
| 208 |
case 'wordpress_remove_specific_role': |
| 209 |
case 'wordpress_update_user_meta_any_value': |
| 210 |
case 'wordpress_update_user_meta_specific_value': |
| 211 |
case 'wordpress_update_post_meta_any_value': |
| 212 |
case 'wordpress_update_post_meta_specific_value': |
| 213 |
// Site Interactions |
| 214 |
case 'wordpress_site_visit': |
| 215 |
case 'wordpress_post_visit': |
| 216 |
case 'wordpress_specific_post_visit': |
| 217 |
case 'wordpress_post_type_visit': |
| 218 |
case 'wordpress_user_post_visit': |
| 219 |
case 'wordpress_user_specific_post_visit': |
| 220 |
case 'wordpress_user_post_type_visit': |
| 221 |
$slug = str_replace( 'wordpress_', 'gamipress_', $slug ); |
| 222 |
break; |
| 223 |
// GamiPress |
| 224 |
case 'gamipress_specific-achievement': |
| 225 |
case 'gamipress_any-achievement': |
| 226 |
case 'gamipress_all-achievements': |
| 227 |
case 'gamipress_revoke-specific-achievement': |
| 228 |
case 'gamipress_revoke-any-achievement': |
| 229 |
case 'gamipress_earn-points': |
| 230 |
case 'gamipress_points-balance': |
| 231 |
case 'gamipress_gamipress_expend_points': |
| 232 |
case 'gamipress_earn-rank': |
| 233 |
case 'gamipress_revoke-rank': |
| 234 |
$slug = str_replace( 'gamipress_', '', $slug ); |
| 235 |
break; |
| 236 |
default: |
| 237 |
foreach( gamipress_ai_assistant_trigger_slugs_replacements() as $replacement ) |
| 238 |
$slug = str_replace( $replacement[1], $replacement[0], $slug ); |
| 239 |
break; |
| 240 |
} |
| 241 |
|
| 242 |
return $slug; |
| 243 |
|
| 244 |
} |
| 245 |
|
| 246 |
/** |
| 247 |
* Get requirements ability properties |
| 248 |
* |
| 249 |
* @since 1.0.0 |
| 250 |
* |
| 251 |
* @return array |
| 252 |
*/ |
| 253 |
function gamipress_ai_assistant_get_requirements_properties( $post_type = '' ) { |
| 254 |
|
| 255 |
$properties = array( |
| 256 |
'trigger' => array( |
| 257 |
'description' => esc_html__( 'The trigger, event, activity, step or requirement to meet this requirement.', 'gamipress' ), |
| 258 |
'type' => 'string', |
| 259 |
'enum' => gamipress_ai_assistant_get_triggers_slugs(), |
| 260 |
), |
| 261 |
'times' => array( |
| 262 |
'description' => esc_html__( 'The number of times required to perform the trigger.', 'gamipress' ), |
| 263 |
'type' => 'integer', |
| 264 |
'default' => '1', |
| 265 |
), |
| 266 |
|
| 267 |
// Points required |
| 268 |
'points_condition' => array( |
| 269 |
'description' => esc_html__( 'The points condition.', 'gamipress' ) |
| 270 |
. esc_html__( 'Optional, only if requirement is related to points.', 'gamipress' ), |
| 271 |
'type' => 'string', |
| 272 |
'enum' => array_keys( gamipress_number_condition_options() ), |
| 273 |
), |
| 274 |
'points_required' => array( |
| 275 |
'description' => esc_html__( 'The points amount.', 'gamipress' ) |
| 276 |
. esc_html__( 'Optional, only if requirement is related to points.', 'gamipress' ), |
| 277 |
'type' => 'integer', |
| 278 |
), |
| 279 |
'points_type_required' => array( |
| 280 |
'description' => esc_html__( 'The points type.', 'gamipress' ) |
| 281 |
. esc_html__( 'Optional, only if requirement is related to points.', 'gamipress' ), |
| 282 |
'type' => 'string', |
| 283 |
// 'enum' => gamipress_get_points_types_slugs(), |
| 284 |
), |
| 285 |
|
| 286 |
// Post/type required |
| 287 |
'post_required' => array( |
| 288 |
'description' => esc_html__( 'ID or title of the required post.', 'gamipress' ) |
| 289 |
. sprintf( esc_html__( 'Optional, only if requirement is related to a specific %s.', 'gamipress' ), implode( ', ', gamipress_get_post_types_slugs() ) ) , |
| 290 |
'type' => 'string', |
| 291 |
), |
| 292 |
'post_type_required' => array( |
| 293 |
'description' => esc_html__( 'The post type.', 'gamipress' ) |
| 294 |
. sprintf( esc_html__( 'Optional, only if requirement is related to a specific %s.', 'gamipress' ), implode( ', ', gamipress_get_post_types_slugs() ) ) , |
| 295 |
'type' => 'string', |
| 296 |
'enum' => gamipress_get_post_types_slugs(), |
| 297 |
), |
| 298 |
); |
| 299 |
|
| 300 |
switch( $post_type ) { |
| 301 |
case 'points-award': |
| 302 |
$properties['points'] = array( |
| 303 |
'description' => esc_html__( 'The points amount to award.', 'gamipress' ) |
| 304 |
. esc_html__( 'Required.', 'gamipress' ), |
| 305 |
'type' => 'integer', |
| 306 |
'default' => '1', |
| 307 |
); |
| 308 |
// Comes from the parent! |
| 309 |
// $properties['points_type'] |
| 310 |
$properties['maximum_earnings'] = array( |
| 311 |
'description' => esc_html__( 'The maximum number of times the points can be awarded.', 'gamipress' ), |
| 312 |
'type' => 'integer', |
| 313 |
'default' => '1', |
| 314 |
); |
| 315 |
break; |
| 316 |
case 'points-deduct': |
| 317 |
$properties['points'] = array( |
| 318 |
'description' => esc_html__( 'The points amount to deduct.', 'gamipress' ) |
| 319 |
. esc_html__( 'Required.', 'gamipress' ), |
| 320 |
'type' => 'integer', |
| 321 |
'default' => '1', |
| 322 |
); |
| 323 |
// Comes from the parent! |
| 324 |
// $properties['points_type'] |
| 325 |
$properties['maximum_earnings'] = array( |
| 326 |
'description' => esc_html__( 'The maximum number of times the points can be deducted.', 'gamipress' ), |
| 327 |
'type' => 'integer', |
| 328 |
'default' => '1', |
| 329 |
); |
| 330 |
break; |
| 331 |
} |
| 332 |
|
| 333 |
return $properties; |
| 334 |
|
| 335 |
} |
| 336 |
|
| 337 |
/** |
| 338 |
* Process requirements |
| 339 |
* |
| 340 |
* @since 1.0.0 |
| 341 |
*/ |
| 342 |
function gamipress_ai_assistant_process_requirements( $requirements = array(), $parent_id = 0, $post_type = '' ) { |
| 343 |
|
| 344 |
// Used to access ability helper functions |
| 345 |
$ability = new GamiPress_AI_Assistant_Ability(); |
| 346 |
$parent_type = gamipress_get_post_type( $parent_id ); |
| 347 |
|
| 348 |
// Our types |
| 349 |
$points_type_slugs = gamipress_get_points_types_slugs(); |
| 350 |
$achievement_type_slugs = gamipress_get_achievement_types_slugs(); |
| 351 |
$rank_type_slugs = gamipress_get_rank_types_slugs(); |
| 352 |
$post_type_slugs = gamipress_get_post_types_slugs(); |
| 353 |
|
| 354 |
$updated_requirements = array(); |
| 355 |
|
| 356 |
// Requirements |
| 357 |
if( is_array( $requirements ) && count( $requirements ) ) { |
| 358 |
|
| 359 |
$triggers = gamipress_ai_assistant_get_triggers_slugs( true ); |
| 360 |
|
| 361 |
foreach( $requirements as $i => $r ) { |
| 362 |
|
| 363 |
$r = wp_parse_args( $r, array( |
| 364 |
'trigger' => '', |
| 365 |
'times' => 1, |
| 366 |
) ); |
| 367 |
|
| 368 |
$r['trigger'] = gamipress_ai_assistant_restore_slug( sanitize_key( trim( $r['trigger'] ) ) ); |
| 369 |
|
| 370 |
// Bail if not is a valid trigger |
| 371 |
if( ! in_array( $r['trigger'], $triggers ) ) { |
| 372 |
|
| 373 |
$r['trigger'] = 'gamipress_' . $r['trigger']; |
| 374 |
|
| 375 |
if( ! in_array( $r['trigger'], $triggers ) ) continue; |
| 376 |
} |
| 377 |
|
| 378 |
$requirement_data = array( |
| 379 |
'post_type' => $post_type, |
| 380 |
'post_status' => 'publish', |
| 381 |
'post_parent' => $parent_id, |
| 382 |
'menu_order' => $i, |
| 383 |
); |
| 384 |
|
| 385 |
$requirement_id = wp_insert_post( $requirement_data ); |
| 386 |
|
| 387 |
// Couldn't insert the requirement |
| 388 |
if( is_wp_error( $requirement_id ) ) continue; |
| 389 |
|
| 390 |
$data = array(); |
| 391 |
$data['ID'] = $requirement_id; |
| 392 |
$data['status'] = 'publish'; |
| 393 |
$data['trigger_type'] = $r['trigger']; |
| 394 |
$data['count'] = absint( $r['times'] ); |
| 395 |
|
| 396 |
$data['title'] = ''; |
| 397 |
$data['achievement_type'] = ''; |
| 398 |
$data['achievement_post'] = 0; |
| 399 |
$data['achievement_post_site_id'] = ''; |
| 400 |
$data['maximum_earnings'] = 1; |
| 401 |
|
| 402 |
// Points award/deduct |
| 403 |
if( in_array( $post_type, array( 'points-award', 'points-deduct' ) ) ) { |
| 404 |
$data['points'] = isset( $r['points'] ) ? absint( $r['points'] ) : 1; |
| 405 |
$data['points_type'] = $parent_type; |
| 406 |
$data['maximum_earnings'] = isset( $r['maximum_earnings'] ) ? absint( $r['maximum_earnings'] ) : 1; |
| 407 |
} |
| 408 |
|
| 409 |
// Points required |
| 410 |
if( isset( $r['points_condition'] ) |
| 411 |
|| isset( $r['points_required'] ) |
| 412 |
|| isset( $r['points_type_required'] ) ) { |
| 413 |
|
| 414 |
// Ensure the array keys to prevent PHP warnings |
| 415 |
$r = wp_parse_args( $r, array( |
| 416 |
'points_condition' => 'greater_or_equal', |
| 417 |
'points_required' => 1, |
| 418 |
'points_type_required' => '', |
| 419 |
) ); |
| 420 |
|
| 421 |
$options = array_keys( gamipress_number_condition_options() ); |
| 422 |
$data['points_condition'] = gamipress_validate_from_array( $r['points_condition'], $options, 'greater_or_equal' ); |
| 423 |
$data['points_required'] = absint( $r['points_required'] ); |
| 424 |
$data['points_type_required'] = gamipress_validate_from_array( $r['points_type_required'], $points_type_slugs, '' ); |
| 425 |
|
| 426 |
} |
| 427 |
|
| 428 |
// Post type |
| 429 |
if( isset( $r['post_type_required'] ) ) { |
| 430 |
|
| 431 |
switch ( $r['trigger'] ) { |
| 432 |
// post_type_required > achievement_type |
| 433 |
case 'any-achievement': |
| 434 |
case 'all-achievements': |
| 435 |
case 'revoke-any-achievement': |
| 436 |
$data['achievement_type'] = gamipress_validate_from_array( $r['post_type_required'], $achievement_type_slugs, '' ); |
| 437 |
break; |
| 438 |
// post_type_required > rank_type_required |
| 439 |
case 'earn-rank': |
| 440 |
case 'revoke-rank': |
| 441 |
$data['rank_type_required'] = gamipress_validate_from_array( $r['post_type_required'], $rank_type_slugs, '' ); |
| 442 |
break; |
| 443 |
// post_type_required |
| 444 |
default: |
| 445 |
$data['post_type_required'] = gamipress_validate_from_array( $r['post_type_required'], $post_type_slugs, '' ); |
| 446 |
break; |
| 447 |
} |
| 448 |
|
| 449 |
} |
| 450 |
|
| 451 |
// Post |
| 452 |
if( isset( $r['post_required'] ) ) { |
| 453 |
|
| 454 |
if( ! isset( $r['post_type_required'] ) ) $r['post_type_required'] = ''; |
| 455 |
|
| 456 |
switch ( $r['trigger'] ) { |
| 457 |
// post_required > achievement_post |
| 458 |
case 'specific-achievement': |
| 459 |
case 'revoke-specific-achievement': |
| 460 |
$post = $ability->get_post( $r['post_required'], array( |
| 461 |
'post_type' => gamipress_validate_from_array( $r['post_type_required'], $achievement_type_slugs, '' ) |
| 462 |
) ); |
| 463 |
|
| 464 |
if( ! $ability->is_response_error( $post ) ) |
| 465 |
$data['achievement_post'] = $post->ID; |
| 466 |
|
| 467 |
break; |
| 468 |
// post_required > rank_required |
| 469 |
case 'earn-rank': |
| 470 |
case 'revoke-rank': |
| 471 |
$post = $ability->get_post( $r['post_required'], array( |
| 472 |
'post_type' => gamipress_validate_from_array( $r['post_type_required'], $rank_type_slugs, '' ) |
| 473 |
) ); |
| 474 |
|
| 475 |
if( ! $ability->is_response_error( $post ) ) |
| 476 |
$data['rank_required'] = $post->ID; |
| 477 |
|
| 478 |
break; |
| 479 |
// post_required |
| 480 |
default: |
| 481 |
$post = $ability->get_post( $r['post_required'], array( |
| 482 |
'post_type' => gamipress_validate_from_array( $r['post_type_required'], $post_type_slugs, '' ) |
| 483 |
) ); |
| 484 |
|
| 485 |
if( ! $ability->is_response_error( $post ) ) |
| 486 |
$data['achievement_post'] = $post->ID; |
| 487 |
|
| 488 |
break; |
| 489 |
} |
| 490 |
|
| 491 |
} |
| 492 |
|
| 493 |
$updated_requirements[] = gamipress_update_requirement( $data, $i ); |
| 494 |
} |
| 495 |
} |
| 496 |
|
| 497 |
return $updated_requirements; |
| 498 |
|
| 499 |
} |
| 500 |
|
| 501 |
/** |
| 502 |
* Get requirements answer |
| 503 |
* |
| 504 |
* @param array $requirements |
| 505 |
* |
| 506 |
* @since 1.0.0 |
| 507 |
*/ |
| 508 |
function gamipress_ai_assistant_get_requirements_answer( $requirements = array() ) { |
| 509 |
|
| 510 |
// Bail if not requirements |
| 511 |
if ( empty( $requirements ) ) { |
| 512 |
return ''; |
| 513 |
} |
| 514 |
|
| 515 |
$requirements_answer = "\n"; |
| 516 |
|
| 517 |
foreach( $requirements as $requirement ) { |
| 518 |
|
| 519 |
$title = $requirement['title']; |
| 520 |
$requirements_answer .= '- ' . esc_html( $title ) . "\n"; |
| 521 |
|
| 522 |
} |
| 523 |
|
| 524 |
$requirements_answer .= "\n"; |
| 525 |
|
| 526 |
return $requirements_answer; |
| 527 |
} |