Add filter to profile support link fields

This commit is contained in:
Tetrakern 2024-10-30 12:07:50 +01:00
parent 9f6861b1c6
commit 83ba5069fa
2 changed files with 37 additions and 16 deletions

View File

@ -1217,6 +1217,25 @@ Filters the CSS compiled from settings and theme options before it is minified a
--- ---
### `apply_filters( 'fictioneer_filter_profile_fields_support', $fields, $profile_user )`
Filters the intermediate output array of support profile fields in `includes/functions/users/_admin-profile.php` before it is imploded with `'<br>'` and rendered. You can use the filter to remove or add fields, but be aware that they will not be saved without further custom code. See `fictioneer_update_my_user_profile()` in the same file.
**Parameters:**
* $fields (string[]) Prepared HTML for each support field. The default keys are `'patreon'`, `'kofi'`, `'subscribestar'`, `'paypal'`, and `'donation'`.
* $profile_user (WP_User) The profile user object.
**Example:**
```php
function child_add_custom_profile_support_field( $fields, $profile_user ) {
$fields['custom'] = '<input name="fictioneer_user_custom_link" type="text" id="fictioneer_user_custom_link" value="' . esc_attr( get_the_author_meta( 'fictioneer_user_custom_link', $profile_user->ID ) ) . '" class="regular-text" placeholder="https://..."><p class="description">Custom donation link</p>';
return $fields;
}
add_filter( 'fictioneer_filter_profile_fields_support', 'child_add_custom_profile_support_field', 10, 2 );
```
---
### `apply_filters( 'fictioneer_filter_recommendations_card_args', $card_args, $args )` ### `apply_filters( 'fictioneer_filter_recommendations_card_args', $card_args, $args )`
Filters the arguments passed to the `partials/_card-recommendation` template part in the `fictioneer_recommendations_list( $args )` function, normally added via the `fictioneer_recommendations_after_content` hook. Filters the arguments passed to the `partials/_card-recommendation` template part in the `fictioneer_recommendations_list( $args )` function, normally added via the `fictioneer_recommendations_after_content` hook.

View File

@ -2011,22 +2011,24 @@ function fictioneer_admin_profile_author( $profile_user ) {
<tr class="user-support-links-wrap"> <tr class="user-support-links-wrap">
<th><?php _e( 'Support Links', 'fictioneer' ); ?></th> <th><?php _e( 'Support Links', 'fictioneer' ); ?></th>
<td> <td>
<fieldset> <fieldset><?php
<input name="fictioneer_user_patreon_link" type="text" id="fictioneer_user_patreon_link" value="<?php echo esc_attr( get_the_author_meta( 'fictioneer_user_patreon_link', $profile_user->ID ) ); ?>" class="regular-text" placeholder="https://..."> $fields = [];
<p class="description"><?php _e( 'Patreon link', 'fictioneer' ); ?></p>
<br> $fields['patreon'] = '<input name="fictioneer_user_patreon_link" type="text" id="fictioneer_user_patreon_link" value="' . esc_attr( get_the_author_meta( 'fictioneer_user_patreon_link', $profile_user->ID ) ) . '" class="regular-text" placeholder="https://..."><p class="description">' . __( 'Patreon link', 'fictioneer' ) . '</p>';
<input name="fictioneer_user_kofi_link" type="text" id="fictioneer_user_kofi_link" value="<?php echo esc_attr( get_the_author_meta( 'fictioneer_user_kofi_link', $profile_user->ID ) ); ?>" class="regular-text" placeholder="https://...">
<p class="description"><?php _e( 'Ko-Fi link', 'fictioneer' ); ?></p> $fields['kofi'] = '<input name="fictioneer_user_kofi_link" type="text" id="fictioneer_user_kofi_link" value="' . esc_attr( get_the_author_meta( 'fictioneer_user_kofi_link', $profile_user->ID ) ) . '" class="regular-text" placeholder="https://..."><p class="description">' . __( 'Ko-Fi link', 'fictioneer' ) . '</p>';
<br>
<input name="fictioneer_user_subscribestar_link" type="text" id="fictioneer_user_subscribestar_link" value="<?php echo esc_attr( get_the_author_meta( 'fictioneer_user_subscribestar_link', $profile_user->ID ) ); ?>" class="regular-text" placeholder="https://..."> $fields['subscribestar'] = '<input name="fictioneer_user_subscribestar_link" type="text" id="fictioneer_user_subscribestar_link" value="' . esc_attr( get_the_author_meta( 'fictioneer_user_subscribestar_link', $profile_user->ID ) ) . '" class="regular-text" placeholder="https://...">
<p class="description"><?php _e( 'SubscribeStar link', 'fictioneer' ); ?></p> <p class="description">' . __( 'SubscribeStar link', 'fictioneer' ) . '</p>';
<br>
<input name="fictioneer_user_paypal_link" type="text" id="fictioneer_user_paypal_link" value="<?php echo esc_attr( get_the_author_meta( 'fictioneer_user_paypal_link', $profile_user->ID ) ); ?>" class="regular-text" placeholder="https://..."> $fields['paypal'] = '<input name="fictioneer_user_paypal_link" type="text" id="fictioneer_user_paypal_link" value="' . esc_attr( get_the_author_meta( 'fictioneer_user_paypal_link', $profile_user->ID ) ) . '" class="regular-text" placeholder="https://..."><p class="description">' . __( 'PayPal link', 'fictioneer' ). '</p>';
<p class="description"><?php _e( 'PayPal link', 'fictioneer' ); ?></p>
<br> $fields['donation'] = '<input name="fictioneer_user_donation_link" type="text" id="fictioneer_user_donation_link" value="' . esc_attr( get_the_author_meta( 'fictioneer_user_donation_link', $profile_user->ID ) ) . '" class="regular-text" placeholder="https://..."><p class="description">' . __( 'Generic donation link', 'fictioneer' ) . '</p>';
<input name="fictioneer_user_donation_link" type="text" id="fictioneer_user_donation_link" value="<?php echo esc_attr( get_the_author_meta( 'fictioneer_user_donation_link', $profile_user->ID ) ); ?>" class="regular-text" placeholder="https://...">
<p class="description"><?php _e( 'Generic donation link', 'fictioneer' ); ?></p> $fields = apply_filters( 'fictioneer_filter_profile_fields_support', $fields, $profile_user );
</fieldset>
echo implode( '<br>', $fields );
?></fieldset>
</td> </td>
</tr> </tr>
<?php // <--- End HTML <?php // <--- End HTML