[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/includes/ -> class-wp-privacy-data-removal-requests-list-table.php (source)

   1  <?php
   2  /**
   3   * List Table API: WP_Privacy_Data_Removal_Requests_List_Table class
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   * @since 4.9.6
   8   */
   9  
  10  if ( ! class_exists( 'WP_Privacy_Requests_Table' ) ) {
  11      require_once  ABSPATH . 'wp-admin/includes/class-wp-privacy-requests-table.php';
  12  }
  13  
  14  /**
  15   * WP_Privacy_Data_Removal_Requests_List_Table class.
  16   *
  17   * @since 4.9.6
  18   */
  19  class WP_Privacy_Data_Removal_Requests_List_Table extends WP_Privacy_Requests_Table {
  20      /**
  21       * Action name for the requests this table will work with.
  22       *
  23       * @since 4.9.6
  24       *
  25       * @var string $request_type Name of action.
  26       */
  27      protected $request_type = 'remove_personal_data';
  28  
  29      /**
  30       * Post type for the requests.
  31       *
  32       * @since 4.9.6
  33       *
  34       * @var string $post_type The post type.
  35       */
  36      protected $post_type = 'user_request';
  37  
  38      /**
  39       * Outputs the Actions column.
  40       *
  41       * @since 4.9.6
  42       *
  43       * @param WP_User_Request $item Item being shown.
  44       * @return string Email column markup.
  45       */
  46  	public function column_email( $item ) {
  47          $row_actions = array();
  48  
  49          // Allow the administrator to "force remove" the personal data even if confirmation has not yet been received.
  50          $status      = $item->status;
  51          $request_id  = $item->ID;
  52          $row_actions = array();
  53          if ( 'request-confirmed' !== $status ) {
  54              /** This filter is documented in wp-admin/includes/ajax-actions.php */
  55              $erasers       = apply_filters( 'wp_privacy_personal_data_erasers', array() );
  56              $erasers_count = count( $erasers );
  57              $nonce         = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
  58  
  59              $remove_data_markup = '<span class="remove-personal-data force-remove-personal-data" ' .
  60                  'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' .
  61                  'data-request-id="' . esc_attr( $request_id ) . '" ' .
  62                  'data-nonce="' . esc_attr( $nonce ) .
  63                  '">';
  64  
  65              $remove_data_markup .= '<span class="remove-personal-data-idle"><button type="button" class="button-link remove-personal-data-handle">' . __( 'Force erase personal data' ) . '</button></span>' .
  66                  '<span class="remove-personal-data-processing hidden">' . __( 'Erasing data...' ) . ' <span class="erasure-progress"></span></span>' .
  67                  '<span class="remove-personal-data-success hidden">' . __( 'Erasure completed.' ) . '</span>' .
  68                  '<span class="remove-personal-data-failed hidden">' . __( 'Force erasure has failed.' ) . ' <button type="button" class="button-link remove-personal-data-handle">' . __( 'Retry' ) . '</button></span>';
  69  
  70              $remove_data_markup .= '</span>';
  71  
  72              $row_actions['remove-data'] = $remove_data_markup;
  73          }
  74  
  75          if ( 'request-completed' !== $status ) {
  76              $complete_request_markup  = '<span>';
  77              $complete_request_markup .= sprintf(
  78                  '<a href="%s" class="complete-request" aria-label="%s">%s</a>',
  79                  esc_url(
  80                      wp_nonce_url(
  81                          add_query_arg(
  82                              array(
  83                                  'action'     => 'complete',
  84                                  'request_id' => array( $request_id ),
  85                              ),
  86                              admin_url( 'erase-personal-data.php' )
  87                          ),
  88                          'bulk-privacy_requests'
  89                      )
  90                  ),
  91                  esc_attr(
  92                      sprintf(
  93                          /* translators: %s: Request email. */
  94                          __( 'Mark export request for &#8220;%s&#8221; as completed.' ),
  95                          $item->email
  96                      )
  97                  ),
  98                  __( 'Complete request' )
  99              );
 100              $complete_request_markup .= '</span>';
 101          }
 102  
 103          if ( ! empty( $complete_request_markup ) ) {
 104              $row_actions['complete-request'] = $complete_request_markup;
 105          }
 106  
 107          return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) );
 108      }
 109  
 110      /**
 111       * Outputs the Next steps column.
 112       *
 113       * @since 4.9.6
 114       *
 115       * @param WP_User_Request $item Item being shown.
 116       */
 117  	public function column_next_steps( $item ) {
 118          $status = $item->status;
 119  
 120          switch ( $status ) {
 121              case 'request-pending':
 122                  esc_html_e( 'Waiting for confirmation' );
 123                  break;
 124              case 'request-confirmed':
 125                  /** This filter is documented in wp-admin/includes/ajax-actions.php */
 126                  $erasers       = apply_filters( 'wp_privacy_personal_data_erasers', array() );
 127                  $erasers_count = count( $erasers );
 128                  $request_id    = $item->ID;
 129                  $nonce         = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
 130  
 131                  echo '<div class="remove-personal-data" ' .
 132                      'data-force-erase="1" ' .
 133                      'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' .
 134                      'data-request-id="' . esc_attr( $request_id ) . '" ' .
 135                      'data-nonce="' . esc_attr( $nonce ) .
 136                      '">';
 137  
 138                  ?>
 139                  <span class="remove-personal-data-idle"><button type="button" class="button-link remove-personal-data-handle"><?php _e( 'Erase personal data' ); ?></button></span>
 140                  <span class="remove-personal-data-processing hidden"><?php _e( 'Erasing data...' ); ?> <span class="erasure-progress"></span></span>
 141                  <span class="remove-personal-data-success success-message hidden" ><?php _e( 'Erasure completed.' ); ?></span>
 142                  <span class="remove-personal-data-failed hidden"><?php _e( 'Data erasure has failed.' ); ?> <button type="button" class="button-link remove-personal-data-handle"><?php _e( 'Retry' ); ?></button></span>
 143                  <?php
 144  
 145                  echo '</div>';
 146  
 147                  break;
 148              case 'request-failed':
 149                  echo '<button type="submit" class="button-link" name="privacy_action_email_retry[' . $item->ID . ']" id="privacy_action_email_retry[' . $item->ID . ']">' . __( 'Retry' ) . '</button>';
 150                  break;
 151              case 'request-completed':
 152                  echo '<a href="' . esc_url(
 153                      wp_nonce_url(
 154                          add_query_arg(
 155                              array(
 156                                  'action'     => 'delete',
 157                                  'request_id' => array( $item->ID ),
 158                              ),
 159                              admin_url( 'erase-personal-data.php' )
 160                          ),
 161                          'bulk-privacy_requests'
 162                      )
 163                  ) . '">' . esc_html__( 'Remove request' ) . '</a>';
 164                  break;
 165          }
 166      }
 167  }


Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref