/wp-content/plugins/buddypress-group-email-subscription/screen-user-settings.php

https://github.com/livinglab/openlab · PHP · 129 lines · 96 code · 22 blank · 11 comment · 9 complexity · cc34f47d83f1b4f44b92451b4a73cb70 MD5 · raw file

  1. <?php
  2. /**
  3. * GES code meant to be run only on a user's "Settings > Email" page.
  4. *
  5. * @since 3.7.0
  6. */
  7. // adds forum notification options in the users settings->notifications page
  8. function ass_group_subscription_notification_settings() {
  9. // get forum type
  10. $forums = ass_get_forum_type();
  11. // no forums installed? stop now!
  12. if ( ! $forums ) {
  13. return;
  14. }
  15. ?>
  16. <table class="notification-settings zebra" id="groups-subscription-notification-settings">
  17. <thead>
  18. <tr>
  19. <th class="icon"><span class="bp-screen-reader-text"><?php esc_html_e( 'Item icon', 'buddypress-group-email-subscription' ); ?></span></th>
  20. <th class="title"><?php _e( 'Group Forum', 'buddypress-group-email-subscription' ) ?></th>
  21. <th class="yes"><?php _e( 'Yes', 'buddypress-group-email-subscription' ) ?></th>
  22. <th class="no"><?php _e( 'No', 'buddypress-group-email-subscription' )?></th>
  23. </tr>
  24. </thead>
  25. <tbody>
  26. <?php
  27. // only add the following options if BP's bundled forums are installed...
  28. // @todo add back these options for bbPress if possible.
  29. ?>
  30. <?php if ( $forums == 'buddypress' ) :
  31. if ( ! $replies_to_topic = bp_get_user_meta( bp_displayed_user_id(), 'ass_replies_to_my_topic', true ) ) {
  32. $replies_to_topic = 'yes';
  33. }
  34. if ( ! $replies_after_me = bp_get_user_meta( bp_displayed_user_id(), 'ass_replies_after_me_topic', true ) ) {
  35. $replies_after_me = 'yes';
  36. }
  37. ?>
  38. <tr>
  39. <td></td>
  40. <td><?php _e( 'A member replies in a forum topic you\'ve started', 'buddypress-group-email-subscription' ) ?></td>
  41. <td class="yes">
  42. <input type="radio" name="notifications[ass_replies_to_my_topic]" id="notification-ass-replies-to-my-topic-yes" value="yes" <?php checked( $replies_to_topic, 'yes', true ); ?>/>
  43. <label class="bp-screen-reader-text" for="notification-ass-replies-to-my-topic-yes"><?php esc_html_e( 'Yes, send email', 'buddypress-group-email-subscription' ); ?></label>
  44. </td>
  45. <td class="no">
  46. <input type="radio" name="notifications[ass_replies_to_my_topic]" value="no" id="notification-ass-replies-to-my-topic-no" <?php checked( $replies_to_topic, 'no', true ); ?>/>
  47. <label class="bp-screen-reader-text" for="notification-ass-replies-to-my-topic-no"><?php esc_html_e( 'Yes, send email', 'buddypress-group-email-subscription' ); ?></label>
  48. </td>
  49. </tr>
  50. <tr>
  51. <td></td>
  52. <td><?php _e( 'A member replies after you in a forum topic', 'buddypress-group-email-subscription' ) ?></td>
  53. <td class="yes">
  54. <input type="radio" name="notifications[ass_replies_after_me_topic]" id="notification-ass-replies-after-me-yes" value="yes" <?php checked( $replies_after_me, 'yes', true ); ?>/>
  55. <label class="bp-screen-reader-text" for="notification-ass-replies-after-me-no"><?php esc_html_e( 'Yes, send email', 'buddypress-group-email-subscription' ); ?></label>
  56. </td>
  57. <td class="no">
  58. <input type="radio" name="notifications[ass_replies_after_me_topic]" id="notification-ass-replies-after-me-no" value="no" <?php checked( $replies_after_me, 'no', true ); ?>/>
  59. <label class="bp-screen-reader-text" for="notification-ass-replies-after-me-yes"><?php esc_html_e( 'No, do not send email', 'buddypress-group-email-subscription' ); ?></label>
  60. </td>
  61. </tr>
  62. <?php endif; ?>
  63. <tr>
  64. <td></td>
  65. <td><?php _e( 'Receive notifications of your own posts?', 'buddypress-group-email-subscription' ) ?></td>
  66. <td class="yes">
  67. <input type="radio" name="notifications[ass_self_post_notification]" id="notification-ass-self-post-yes" value="yes" <?php if ( ass_self_post_notification( bp_displayed_user_id() ) ) { ?>checked="checked" <?php } ?>/>
  68. <label class="bp-screen-reader-text" for="notification-ass-self-post-yes"><?php esc_html_e( 'No, do not send email', 'buddypress-group-email-subscription' ); ?></label>
  69. </td>
  70. <td class="no">
  71. <input type="radio" name="notifications[ass_self_post_notification]" id="notification-ass-self-post-no" value="no" <?php if ( !ass_self_post_notification( bp_displayed_user_id() ) ) { ?>checked="checked" <?php } ?>/>
  72. <label class="bp-screen-reader-text" for="notification-ass-self-post-no"><?php esc_html_e( 'No, do not send email', 'buddypress-group-email-subscription' ); ?></label>
  73. </td>
  74. </tr>
  75. <?php do_action( 'ass_group_subscription_notification_settings' ); ?>
  76. </tbody>
  77. </table>
  78. <?php
  79. }
  80. add_action( 'bp_notification_settings', 'ass_group_subscription_notification_settings' );
  81. // Add a notice at end of email notification about how to change group email subscriptions
  82. function ass_add_notice_to_notifications_page() {
  83. ?>
  84. <div id="group-email-settings">
  85. <table class="notification-settings zebra">
  86. <thead>
  87. <tr>
  88. <th class="icon">&nbsp;</th>
  89. <th class="title"><?php _e( 'Individual Group Email Settings', 'buddypress-group-email-subscription' ); ?></th>
  90. </tr>
  91. </thead>
  92. <tbody>
  93. <tr>
  94. <td>&nbsp;</td>
  95. <td>
  96. <p><?php printf( __('To change the email notification settings for your groups, go to %s and click "Change" for each group.', 'buddypress-group-email-subscription' ), '<a href="'. bp_loggedin_user_domain() . trailingslashit( BP_GROUPS_SLUG ) . '">' . __( 'My Groups' ,'buddypress-group-email-subscription' ) . '</a>' ); ?></p>
  97. <?php if ( get_option( 'ass-global-unsubscribe-link' ) == 'yes' ) : ?>
  98. <p><a href="<?php echo wp_nonce_url( add_query_arg( 'ass_unsubscribe', 'all' ), 'ass_unsubscribe_all' ); ?>"><?php _e( "Or set all your group's email options to No Email", 'buddypress-group-email-subscription' ); ?></a></p>
  99. <?php endif; ?>
  100. </td>
  101. </tr>
  102. </tbody>
  103. </table>
  104. </div>
  105. <?php
  106. }
  107. add_action( 'bp_notification_settings', 'ass_add_notice_to_notifications_page', 9000 );