| 1 |
<?php |
| 2 |
/** |
| 3 |
* This template contains the notification manager. |
| 4 |
* |
| 5 |
* @version 1.0 |
| 6 |
* @package Friends |
| 7 |
*/ |
| 8 |
|
| 9 |
$disabled_post_formats = array(); |
| 10 |
foreach ( get_post_format_strings() as $post_format => $label ) { |
| 11 |
if ( get_user_option( 'friends_no_new_post_format_notification_' . $post_format ) ) { |
| 12 |
$disabled_post_formats[] = $post_format; |
| 13 |
} |
| 14 |
} |
| 15 |
$disabled_feed_parsers = array(); |
| 16 |
foreach ( $args['feed_parsers'] as $feed_parser => $label ) { |
| 17 |
if ( get_user_option( 'friends_no_new_post_by_parser_notification_' . $feed_parser ) ) { |
| 18 |
$disabled_feed_parsers[] = $feed_parser; |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
?><form method="post"> |
| 23 |
<?php wp_nonce_field( 'notification-manager' ); ?> |
| 24 |
<p class="explanation"><?php esc_html_e( 'The settings on this page apply just to you, other users can configure their own settings.', 'friends' ); ?></p> |
| 25 |
<table class="form-table"> |
| 26 |
<tbody> |
| 27 |
<tr> |
| 28 |
<th scope="row"> |
| 29 |
<?php |
| 30 |
esc_html_e( 'E-Mail Notifications', 'friends' ); |
| 31 |
?> |
| 32 |
</th> |
| 33 |
<td> |
| 34 |
<fieldset> |
| 35 |
<?php if ( isset( $args['no_friend_follower_notification'] ) ) : ?> |
| 36 |
<label for="friend_follower_notification"> |
| 37 |
<input name="friend_follower_notification" type="checkbox" id="friend_follower_notification" value="1" <?php checked( '1', ! $args['no_friend_follower_notification'] ); ?>> |
| 38 |
<span><?php esc_html_e( 'New Followers', 'friends' ); ?></span> |
| 39 |
<span><?php esc_html_e( '(via ActivityPub)', 'friends' ); ?></span> |
| 40 |
</label> |
| 41 |
<br /> |
| 42 |
<?php endif; ?> |
| 43 |
<label for="new_post_notification"> |
| 44 |
<input name="new_post_notification" type="checkbox" id="new_post_notification" value="1" <?php checked( '1', ! $args['no_new_post_notification'] ); ?>> |
| 45 |
<span><?php esc_html_e( 'New Posts', 'friends' ); ?></span> |
| 46 |
</label> |
| 47 |
</fieldset> |
| 48 |
<p class="description"><?php esc_html_e( 'When you disable post notifications, their individual configuration is disabled also.', 'friends' ); ?></p> |
| 49 |
|
| 50 |
<details class="options"> |
| 51 |
<summary> |
| 52 |
<?php echo esc_html( _x( 'By Post Format', 'e-mail notifications', 'friends' ) ); ?> |
| 53 |
<?php |
| 54 |
if ( count( $disabled_post_formats ) > 0 ) { |
| 55 |
echo esc_html( |
| 56 |
sprintf( |
| 57 |
// translators: %d: number of selected post formats. |
| 58 |
_n( '(%d disabled)', '(%d disabled)', count( $disabled_post_formats ), 'friends' ), |
| 59 |
count( $disabled_post_formats ) |
| 60 |
) |
| 61 |
); |
| 62 |
} |
| 63 |
?> |
| 64 |
</summary> |
| 65 |
<fieldset> |
| 66 |
<?php foreach ( get_post_format_strings() as $post_format => $label ) : ?> |
| 67 |
<label> |
| 68 |
<input name="new_post_format_notification_<?php echo esc_attr( $post_format ); ?>" type="checkbox" id="new_post_format_notification_<?php echo esc_attr( $post_format ); ?>" value="1" <?php checked( ! in_array( $post_format, $disabled_post_formats ) ); ?>> |
| 69 |
<span><?php echo esc_html( $label ); ?></span> |
| 70 |
</label> |
| 71 |
<?php endforeach; ?> |
| 72 |
</fieldset> |
| 73 |
</details> |
| 74 |
<p class="description"><?php esc_html_e( 'You can disable notifications for posts in specific post formats.', 'friends' ); ?></p> |
| 75 |
|
| 76 |
<details class="options"> |
| 77 |
<summary> |
| 78 |
<?php echo esc_html( _x( 'By Feed Parser', 'e-mail notifications', 'friends' ) ); ?> |
| 79 |
<?php |
| 80 |
if ( count( $disabled_feed_parsers ) > 0 ) { |
| 81 |
echo esc_html( |
| 82 |
sprintf( |
| 83 |
// translators: %d: number of selected feed parsers. |
| 84 |
_n( '(%d disabled)', '(%d disabled)', count( $disabled_feed_parsers ), 'friends' ), |
| 85 |
count( $disabled_feed_parsers ) |
| 86 |
) |
| 87 |
); |
| 88 |
} |
| 89 |
?> |
| 90 |
</summary> |
| 91 |
<fieldset> |
| 92 |
<?php foreach ( $args['feed_parsers'] as $feed_parser => $label ) : ?> |
| 93 |
<label> |
| 94 |
<input name="new_post_by_parser_notification_<?php echo esc_attr( $feed_parser ); ?>" type="checkbox" id="new_post_by_parser_notification_<?php echo esc_attr( $feed_parser ); ?>" value="1" <?php checked( ! in_array( $feed_parser, $disabled_feed_parsers ) ); ?>> |
| 95 |
<span><?php echo wp_kses( $label, array() ); ?></span> |
| 96 |
</label> |
| 97 |
<?php endforeach; ?> |
| 98 |
</fieldset> |
| 99 |
</details> |
| 100 |
<p class="description"><?php esc_html_e( 'You can disable notifications for posts arriving with specific feed parsers.', 'friends' ); ?></p> |
| 101 |
</td> |
| 102 |
</tr> |
| 103 |
<tr> |
| 104 |
<th scope="row"> |
| 105 |
<?php |
| 106 |
esc_html_e( 'Keyword Notifications', 'friends' ); |
| 107 |
?> |
| 108 |
</th> |
| 109 |
<td> |
| 110 |
<fieldset> |
| 111 |
<label> |
| 112 |
<input name="keyword_notification_override" type="checkbox" id="keyword_notification_override" value="1" <?php checked( ! $args['keyword_override_disabled'] ); ?>> |
| 113 |
<span><?php esc_html_e( 'Notify about matching keywords even if disabled above', 'friends' ); ?></span> |
| 114 |
</label> |
| 115 |
<p class="description"><?php esc_html_e( 'For example, even if you disabled post notifications, you can still get notified about posts containing specific keywords.', 'friends' ); ?></p> |
| 116 |
|
| 117 |
<ol id="keyword-notifications"> |
| 118 |
<li id="keyword-template" style="display: none"> |
| 119 |
<input type="checkbox" name="notification_keywords_enabled[0]" value="1" checked /> |
| 120 |
<input type="text" name="notification_keywords[0]" value="" placeholder="<?php esc_html_e( 'Keyword (regex allowed)', 'friends' ); ?>"> |
| 121 |
</li> |
| 122 |
<?php foreach ( $args['notification_keywords'] as $i => $entry ) : ?> |
| 123 |
<li> |
| 124 |
<input type="checkbox" name="notification_keywords_enabled[<?php echo esc_attr( $i + 1 ); ?>]" value="1" <?php checked( $entry['enabled'] ); ?> /> |
| 125 |
<input type="text" name="notification_keywords[<?php echo esc_attr( $i + 1 ); ?>]" value="<?php echo esc_attr( $entry['keyword'] ); ?>" placeholder="<?php esc_html_e( 'Keyword (regex allowed)', 'friends' ); ?>"> |
| 126 |
</li> |
| 127 |
<?php endforeach; ?> |
| 128 |
</ol> |
| 129 |
<a href="" id="admin-add-keyword"><?php esc_html_e( 'Add a notification keyword', 'friends' ); ?></a> |
| 130 |
</fieldset> |
| 131 |
<p class="description"><?php esc_html_e( 'Empty keywords will be deleted after saving. You can temporarily disable them with the checkbox.', 'friends' ); ?></p> |
| 132 |
</td> |
| 133 |
</tr> |
| 134 |
</tbody> |
| 135 |
</table> |
| 136 |
<p class="submit"> |
| 137 |
<input type="submit" id="submit" class="button button-primary" value="<?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_html_e( 'Save Changes' ); ?>"> |
| 138 |
</p> |
| 139 |
|
| 140 |
<h2><?php esc_html_e( 'Individual Friend Settings', 'friends' ); ?></h2> |
| 141 |
<table class="wp-list-table widefat fixed striped" style="margin-top: 2em; margin-bottom: 2em; margin-right: 1em"> |
| 142 |
<thead> |
| 143 |
<tr> |
| 144 |
<th class="column-primary column-friend"><?php esc_html_e( 'Friend', 'friends' ); ?></th> |
| 145 |
<th class="column-friends-page-feeds"><?php esc_html_e( 'Show on friends page', 'friends' ); ?></th> |
| 146 |
<th class="column-email-notification"><?php esc_html_e( 'E-Mail Notification', 'friends' ); ?></th> |
| 147 |
<th class="column-email-notification"><?php esc_html_e( 'Keyword Notification', 'friends' ); ?></th> |
| 148 |
<?php do_action( 'friends_notification_manager_header' ); ?> |
| 149 |
</tr> |
| 150 |
</thead> |
| 151 |
<tbody> |
| 152 |
<?php foreach ( $args['friend_users'] as $friend_user ) : ?> |
| 153 |
<tr> |
| 154 |
<td class="column-friend"> |
| 155 |
<a href="<?php echo esc_url( Friends\Admin::get_edit_friend_link( $friend_user->user_login ) ); ?>"><?php echo esc_html( $friend_user->display_name ); ?></a> |
| 156 |
<input type="hidden" name="friend_listed[]" value="<?php echo esc_attr( $friend_user->user_login ); ?>" /> |
| 157 |
</td> |
| 158 |
<td class="column-friends-page-feeds"> |
| 159 |
<input name="show_on_friends_page[<?php echo esc_attr( $friend_user->user_login ); ?>]" type="checkbox" id="show_on_friends_page" value="1" <?php checked( '1', ! in_array( $friend_user->user_login, $args['hide_from_friends_page'] ) ); ?> /> |
| 160 |
</td> |
| 161 |
<td class="column-email-notification"> |
| 162 |
<?php if ( $args['no_new_post_notification'] ) : ?> |
| 163 |
<input disabled="disabled" type="checkbox" <?php checked( '1', ! get_user_option( 'friends_no_new_post_notification_' . $friend_user->user_login ) ); ?> /> |
| 164 |
<input name="new_friend_post_notification[<?php echo esc_attr( $friend_user->user_login ); ?>]" type="hidden" value="<?php echo get_user_option( 'friends_no_new_post_notification_' . $friend_user->user_login ) ? '0' : '1'; ?>" /> |
| 165 |
<?php else : ?> |
| 166 |
<input name="new_friend_post_notification[<?php echo esc_attr( $friend_user->user_login ); ?>]" type="checkbox" id="friends_new_friend_post_notification" value="1" <?php checked( '1', ! get_user_option( 'friends_no_new_post_notification_' . $friend_user->user_login ) ); ?> <?php echo $args['no_new_post_notification'] ? 'disabled="disabled"' : ''; ?> |
| 167 |
/> |
| 168 |
<?php endif; ?> |
| 169 |
</td> |
| 170 |
<td class="column-keyword-notification"> |
| 171 |
<input name="keyword_notification[<?php echo esc_attr( $friend_user->user_login ); ?>]" type="checkbox" id="friends_keyword_notification" value="1" <?php checked( '1', ! get_user_option( 'friends_no_keyword_notification_' . $friend_user->user_login ) ); ?> <?php echo $args['no_keyword_notification'] ? 'disabled="disabled"' : ''; ?> |
| 172 |
/> |
| 173 |
</td> |
| 174 |
<?php do_action( 'friends_notification_manager_row', $friend_user ); ?> |
| 175 |
</tr> |
| 176 |
<?php endforeach; ?> |
| 177 |
</tbody> |
| 178 |
</table> |
| 179 |
<p class="submit"> |
| 180 |
<input type="submit" id="submit" class="button button-primary" value="<?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_html_e( 'Save Changes' ); ?>"> |
| 181 |
</p> |
| 182 |
</form> |
| 183 |
|