Skip to content

Commit

Permalink
Update Notification metabox #1664
Browse files Browse the repository at this point in the history
  • Loading branch information
olatechpro committed Jul 30, 2024
1 parent a5cab5c commit ffa6db6
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 32 deletions.
2 changes: 1 addition & 1 deletion modules/notifications-log/notifications-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function init()
{
if (is_admin()) {
add_action('admin_enqueue_scripts', [$this, 'enqueueAdminScripts']);
add_action('publishpress_notif_post_metabox', [$this, 'postNotificationMetaBox']);
//add_action('publishpress_notif_post_metabox', [$this, 'postNotificationMetaBox']);
add_action('publishpress_admin_submenu', [$this, 'action_admin_submenu'], 20);

add_filter('set-screen-option', [$this, 'tableSetOptions'], 10, 3);
Expand Down
62 changes: 32 additions & 30 deletions modules/notifications/notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ public function add_post_meta_box()
}

$role_post_types = $this->get_post_types_for_module($this->module);

foreach ($role_post_types as $post_type) {
add_meta_box(
'publishpress-notifications',
Expand Down Expand Up @@ -627,46 +628,47 @@ public function notifications_meta_box()

$postType = get_post_type_object($post->post_type);

$notify_me_style = empty($followersWorkflows) ? 'display: none;' : '';
?>
<div id="pp_post_notify_box">
<a name="subscriptions"></a>
<div style="<?php echo esc_attr($notify_me_style); ?>">
<p>
<?php
esc_html_e(
'Enter any users, roles, or email address that should receive notifications from workflows.',
'publishpress'
); ?><?php
if (! empty($followersWorkflows)) : ?>&sup1;<?php
endif; ?>
</p>

<p>
<?php
esc_html_e(
'Enter any users, roles, or email address that should receive notifications from workflows.',
'publishpress'
); ?><?php
if (! empty($followersWorkflows)) : ?>&sup1;<?php
endif; ?>
</p>
<div id="pp_post_notify_users_box">
<?php
$users_to_notify = $this->get_users_to_notify($post->ID, 'id');
$roles_to_notify = $this->get_roles_to_notify($post->ID, 'slugs');
$emails_to_notify = $this->get_emails_to_notify($post->ID);

<div id="pp_post_notify_users_box">
<?php
$users_to_notify = $this->get_users_to_notify($post->ID, 'id');
$roles_to_notify = $this->get_roles_to_notify($post->ID, 'slugs');
$emails_to_notify = $this->get_emails_to_notify($post->ID);
$selected = array_merge($users_to_notify, $roles_to_notify, $emails_to_notify);

$selected = array_merge($users_to_notify, $roles_to_notify, $emails_to_notify);
$select_form_args = [
'list_class' => 'pp_post_notify_list',
];
$this->users_select_form($selected, $select_form_args); ?>

$select_form_args = [
'list_class' => 'pp_post_notify_list',
];
$this->users_select_form($selected, $select_form_args); ?>
</div>

<?php
if (empty($followersWorkflows)) : ?>
<p class="no-workflows"><?php
echo esc_html__(
'This won\'t have any effect unless you have at least one workflow targeting the "Users who selected "Notify me" for the content" option.',
'publishpress'
); ?></p>
<?php
endif; ?>
</div>

<?php
if (empty($followersWorkflows)) : ?>
<p class="no-workflows"><?php
echo esc_html__(
'This won\'t have any effect unless you have at least one workflow targeting the "Notify me" box.',
'publishpress'
); ?></p>
<?php
endif; ?>
<hr>

<?php
if (current_user_can('edit_pp_notif_workflows')) : ?>
<div class="pp_post_notify_workflows">
Expand Down
47 changes: 46 additions & 1 deletion publishpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -1197,11 +1197,12 @@ public function canUseBlockEditorForPostType($useBlockEditor, $postType)
*/
public function filterCapabilities($pluginCaps)
{

$caps = [
'pp_view_content_board',
'pp_view_calendar',
'pp_view_content_overview',
'pp_set_notification_channel',
'edit_post_subscriptions',
'pp_edit_editorial_metadata',
'pp_view_editorial_metadata',
'pp_delete_editorial_comment',
Expand Down Expand Up @@ -1420,6 +1421,50 @@ function () use ($message) {
register_activation_hook(
__FILE__,
function () {
global $wp_roles;

$genericCaps = [
'pp_view_calendar',
'pp_view_content_overview',
'pp_view_content_board',
'edit_post_subscriptions',
'pp_set_notification_channel',
'pp_delete_editorial_comment',
'pp_delete_others_editorial_comment',
'pp_edit_editorial_comment',
'pp_edit_others_editorial_comment',
];

$roles = [
'administrator' => $genericCaps,
'editor' => $genericCaps,
'author' => $genericCaps,
'contributor' => $genericCaps,
];

foreach ($roles as $role => $caps) {
if ($wp_roles->is_role($role)) {
$role = get_role($role);
foreach ($caps as $cap) {
$role->add_cap($cap);
}
}
}

// Additional capabilities
$roles = [
'administrator' => [apply_filters('pp_manage_roles_cap', 'pp_manage_roles')],
];

foreach ($roles as $role => $caps) {
if ($wp_roles->is_role($role)) {
$role = get_role($role);
foreach ($caps as $cap) {
$role->add_cap($cap);
}
}
}

update_option('pp_planner_activated', true);
}
);

0 comments on commit ffa6db6

Please sign in to comment.