PluginProbe
Stream – Activity Log & Audit Trail / 3.6.1
Stream – Activity Log & Audit Trail v3.6.1
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
← All changes | classes/class-alerts.php +13 -48 3.10.03.6.1 View file →
@@ -24,13 +24,8 @@
24 24 */
25 25 const ALERTS_TRIGGERED_META_KEY = 'wp_stream_alerts_triggered';
26 26
27 27 /**
28 - * Capability required to access alerts.
29 - */
30 - const CAPABILITY = 'manage_options';
31 -
32 - /**
33 28 * Holds Instance of plugin object
34 29 *
35 30 * @var Plugin
36 31 */
@@ -284,12 +279,8 @@
284 279 $alerts = new \WP_Query( $args );
285 280 foreach ( $alerts->posts as $alert ) {
286 281 $alert = $this->get_alert( $alert->ID );
287 282
288 - if ( false === $alert ) {
289 - continue;
290 - }
291 -
292 283 $status = $alert->check_record( $record_id, $recordarr );
293 284 if ( $status ) {
294 285 $alert->send_alert( $record_id, $recordarr ); // @todo send_alert expects int, not array.
295 286 }
@@ -371,16 +362,16 @@
371 362 'show_ui' => true,
372 363 'show_in_menu' => false, // @see modify_admin_menu
373 364 'supports' => false,
374 365 'capabilities' => array(
375 - 'publish_posts' => self::CAPABILITY,
376 - 'edit_others_posts' => self::CAPABILITY,
377 - 'delete_posts' => self::CAPABILITY,
378 - 'delete_others_posts' => self::CAPABILITY,
379 - 'read_private_posts' => self::CAPABILITY,
380 - 'edit_post' => self::CAPABILITY,
381 - 'delete_post' => self::CAPABILITY,
382 - 'read_post' => self::CAPABILITY,
366 + 'publish_posts' => 'manage_options',
367 + 'edit_others_posts' => 'manage_options',
368 + 'delete_posts' => 'manage_options',
369 + 'delete_others_posts' => 'manage_options',
370 + 'read_private_posts' => 'manage_options',
371 + 'edit_post' => 'manage_options',
372 + 'delete_post' => 'manage_options',
373 + 'read_post' => 'manage_options',
383 374 ),
384 375 );
385 376
386 377 register_post_type( self::POST_TYPE, $args );
@@ -452,9 +443,9 @@
452 443 add_submenu_page(
453 444 $this->plugin->admin->records_page_slug,
454 445 __( 'Alerts', 'stream' ),
455 446 __( 'Alerts', 'stream' ),
456 - self::CAPABILITY,
447 + 'manage_options',
457 448 'edit.php?post_type=wp_stream_alerts'
458 449 );
459 450 }
460 451
@@ -517,15 +508,12 @@
517 508 *
518 509 * @return void
519 510 */
520 511 public function display_notification_box( $post = array() ) {
521 - $alert = null;
522 512 $alert_type = 'none';
523 513 if ( is_object( $post ) ) {
524 - $alert = $this->get_alert( $post->ID );
525 - if ( false !== $alert ) {
526 - $alert_type = $alert->alert_type;
527 - }
514 + $alert = $this->get_alert( $post->ID );
515 + $alert_type = $alert->alert_type;
528 516 }
529 517 $form = new Form_Generator();
530 518
531 519 $field_html = $form->render_field(
@@ -560,20 +548,13 @@
560 548 *
561 549 * @return void
562 550 */
563 551 public function load_alerts_settings() {
564 - if ( ! current_user_can( self::CAPABILITY ) ) {
565 - wp_send_json_error(
566 - array(
567 - 'message' => 'You do not have permission to do this.',
568 - )
569 - );
570 - }
571 552 $alert = array();
572 553 $post_id = wp_stream_filter_input( INPUT_POST, 'post_id' );
573 554 if ( ! empty( $post_id ) ) {
574 555 $alert = $this->get_alert( $post_id );
575 - if ( false === $alert ) {
556 + if ( ! $alert ) {
576 557 wp_send_json_error(
577 558 array(
578 559 'message' => 'Could not find alert.',
579 560 )
@@ -611,16 +592,13 @@
611 592 *
612 593 * @return void
613 594 */
614 595 public function display_triggers_box( $post = array() ) {
615 - $alert = false;
616 596 if ( is_object( $post ) ) {
617 597 $alert = $this->get_alert( $post->ID );
618 - }
619 - if ( false === $alert ) {
598 + } else {
620 599 $alert = array();
621 600 }
622 -
623 601 $form = new Form_Generator();
624 602 do_action( 'wp_stream_alert_trigger_form_display', $form, $alert );
625 603 // @TODO use human readable text.
626 604 echo '<label>' . esc_html__( 'Alert me when', 'stream' ) . '</label>';
@@ -753,15 +731,8 @@
753 731 * Save a new alert
754 732 */
755 733 public function save_new_alert() {
756 734 check_ajax_referer( 'save_alert', 'wp_stream_alerts_nonce' );
757 -
758 - if ( ! current_user_can( $this->plugin->admin->settings_cap ) ) {
759 - wp_die(
760 - esc_html__( "You don't have sufficient privileges to do this action.", 'stream' )
761 - );
762 - }
763 -
764 735 $trigger_author = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_author' );
765 736 $trigger_connector_and_context = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_context' );
766 737 if ( false !== strpos( $trigger_connector_and_context, '-' ) ) {
767 738 // This is a connector with a context such as posts-post.
@@ -827,14 +798,8 @@
827 798 /**
828 799 * Return HTML string of the Alert page controls.
829 800 */
830 801 public function get_new_alert_triggers_notifications() {
831 - if ( ! current_user_can( $this->plugin->admin->settings_cap ) ) {
832 - wp_die(
833 - esc_html__( "You don't have sufficient privileges to do this action.", 'stream' )
834 - );
835 - }
836 -
837 802 ob_start();
838 803 ?>
839 804 <fieldset class="inline-edit-col inline-edit-wp_stream_alerts inline-edit-add-new-triggers">
840 805 <legend class="inline-edit-legend">Add New</legend>