| @@ -15,10 +15,14 @@ | ||
| 15 | 15 | * |
| 16 | 16 | * @return void |
| 17 | 17 | */ |
| 18 | 18 | public function __construct() { |
| 19 | - add_action( 'transition_post_status', array( &$this, 'transition_post_status' ), 10, 3 ); | |
| 20 | - add_action( 'delete_post', array( &$this, 'delete_post' ) ); | |
| 19 | + if ( ! get_option( 'patchstack_activity_log_posts', 0 ) ) { | |
| 20 | + return; | |
| 21 | + } | |
| 22 | + | |
| 23 | + add_action( 'transition_post_status', [ &$this, 'transition_post_status' ], 10, 3 ); | |
| 24 | + add_action( 'delete_post', [ &$this, 'delete_post' ] ); | |
| 21 | 25 | } |
| 22 | 26 | |
| 23 | 27 | /** |
| 24 | 28 | * Determine the title. |
| @@ -28,9 +32,9 @@ | ||
| 28 | 32 | */ |
| 29 | 33 | protected function _draft_or_post_title( $post = 0 ) { |
| 30 | 34 | $title = esc_html( get_the_title( $post ) ); |
| 31 | 35 | if ( empty( $title ) ) { |
| 32 | - return __( '(no title)', 'patchstack' ); | |
| 36 | + return esc_attr__( '(no title)', 'patchstack' ); | |
| 33 | 37 | } |
| 34 | 38 | |
| 35 | 39 | return $title; |
| 36 | 40 | } |
| @@ -67,14 +71,14 @@ | ||
| 67 | 71 | return; |
| 68 | 72 | } |
| 69 | 73 | |
| 70 | 74 | $this->insert( |
| 71 | - array( | |
| 75 | + [ | |
| 72 | 76 | 'object' => 'post', |
| 73 | 77 | 'object_id' => $post->ID, |
| 74 | 78 | 'action' => $action, |
| 75 | 79 | 'object_name' => $this->_draft_or_post_title( $post->ID ), |
| 76 | - ) | |
| 80 | + ] | |
| 77 | 81 | ); |
| 78 | 82 | } |
| 79 | 83 | |
| 80 | 84 | /** |
| @@ -88,9 +92,9 @@ | ||
| 88 | 92 | return; |
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 | $post = get_post( $post_id ); |
| 92 | - if ( in_array( $post->post_status, array( 'auto-draft', 'inherit' ) ) ) { | |
| 96 | + if ( in_array( $post->post_status, [ 'auto-draft', 'inherit' ] ) ) { | |
| 93 | 97 | return; |
| 94 | 98 | } |
| 95 | 99 | |
| 96 | 100 | // Skip for menu items. |
| @@ -98,13 +102,13 @@ | ||
| 98 | 102 | return; |
| 99 | 103 | } |
| 100 | 104 | |
| 101 | 105 | $this->insert( |
| 102 | - array( | |
| 106 | + [ | |
| 103 | 107 | 'object' => 'post', |
| 104 | 108 | 'object_id' => $post->ID, |
| 105 | 109 | 'action' => 'deleted', |
| 106 | 110 | 'object_name' => $this->_draft_or_post_title( $post->ID ), |
| 107 | - ) | |
| 111 | + ] | |
| 108 | 112 | ); |
| 109 | 113 | } |
| 110 | 114 | } |