[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  <?php
   2  /**
   3   * List Table API: WP_Privacy_Data_Export_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_Export_Requests_Table class.
  16   *
  17   * @since 4.9.6
  18   */
  19  class WP_Privacy_Data_Export_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 = 'export_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       * 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          /** This filter is documented in wp-admin/includes/ajax-actions.php */
  48          $exporters       = apply_filters( 'wp_privacy_personal_data_exporters', array() );
  49          $exporters_count = count( $exporters );
  50          $status          = $item->status;
  51          $request_id      = $item->ID;
  52          $nonce           = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
  53  
  54          $download_data_markup = '<span class="export-personal-data" ' .
  55              'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' .
  56              'data-request-id="' . esc_attr( $request_id ) . '" ' .
  57              'data-nonce="' . esc_attr( $nonce ) .
  58              '">';
  59  
  60          $download_data_markup .= '<span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download personal data' ) . '</button></span>' .
  61              '<span class="export-personal-data-processing hidden">' . __( 'Downloading data...' ) . ' <span class="export-progress"></span></span>' .
  62              '<span class="export-personal-data-success hidden"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download personal data again' ) . '</button></span>' .
  63              '<span class="export-personal-data-failed hidden">' . __( 'Download failed.' ) . ' <button type="button" class="button-link export-personal-data-handle">' . __( 'Retry' ) . '</button></span>';
  64  
  65          $download_data_markup .= '</span>';
  66  
  67          $row_actions['download-data'] = $download_data_markup;
  68  
  69          if ( 'request-completed' !== $status ) {
  70              $complete_request_markup  = '<span>';
  71              $complete_request_markup .= sprintf(
  72                  '<a href="%s" class="complete-request" aria-label="%s">%s</a>',
  73                  esc_url(
  74                      wp_nonce_url(
  75                          add_query_arg(
  76                              array(
  77                                  'action'     => 'complete',
  78                                  'request_id' => array( $request_id ),
  79                              ),
  80                              admin_url( 'export-personal-data.php' )
  81                          ),
  82                          'bulk-privacy_requests'
  83                      )
  84                  ),
  85                  esc_attr(
  86                      sprintf(
  87                          /* translators: %s: Request email. */
  88                          __( 'Mark export request for &#8220;%s&#8221; as completed.' ),
  89                          $item->email
  90                      )
  91                  ),
  92                  __( 'Complete request' )
  93              );
  94              $complete_request_markup .= '</span>';
  95          }
  96  
  97          if ( ! empty( $complete_request_markup ) ) {
  98              $row_actions['complete-request'] = $complete_request_markup;
  99          }
 100  
 101          return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) );
 102      }
 103  
 104      /**
 105       * Displays the next steps column.
 106       *
 107       * @since 4.9.6
 108       *
 109       * @param WP_User_Request $item Item being shown.
 110       */
 111  	public function column_next_steps( $item ) {
 112          $status = $item->status;
 113  
 114          switch ( $status ) {
 115              case 'request-pending':
 116                  esc_html_e( 'Waiting for confirmation' );
 117                  break;
 118              case 'request-confirmed':
 119                  /** This filter is documented in wp-admin/includes/ajax-actions.php */
 120                  $exporters       = apply_filters( 'wp_privacy_personal_data_exporters', array() );
 121                  $exporters_count = count( $exporters );
 122                  $request_id      = $item->ID;
 123                  $nonce           = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
 124  
 125                  echo '<div class="export-personal-data" ' .
 126                      'data-send-as-email="1" ' .
 127                      'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' .
 128                      'data-request-id="' . esc_attr( $request_id ) . '" ' .
 129                      'data-nonce="' . esc_attr( $nonce ) .
 130                      '">';
 131  
 132                  ?>
 133                  <span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle"><?php _e( 'Send export link' ); ?></button></span>
 134                  <span class="export-personal-data-processing hidden"><?php _e( 'Sending email...' ); ?> <span class="export-progress"></span></span>
 135                  <span class="export-personal-data-success success-message hidden"><?php _e( 'Email sent.' ); ?></span>
 136                  <span class="export-personal-data-failed hidden"><?php _e( 'Email could not be sent.' ); ?> <button type="button" class="button-link export-personal-data-handle"><?php _e( 'Retry' ); ?></button></span>
 137                  <?php
 138  
 139                  echo '</div>';
 140                  break;
 141              case 'request-failed':
 142                  echo '<button type="submit" class="button-link" name="privacy_action_email_retry[' . $item->ID . ']" id="privacy_action_email_retry[' . $item->ID . ']">' . __( 'Retry' ) . '</button>';
 143                  break;
 144              case 'request-completed':
 145                  echo '<a href="' . esc_url(
 146                      wp_nonce_url(
 147                          add_query_arg(
 148                              array(
 149                                  'action'     => 'delete',
 150                                  'request_id' => array( $item->ID ),
 151                              ),
 152                              admin_url( 'export-personal-data.php' )
 153                          ),
 154                          'bulk-privacy_requests'
 155                      )
 156                  ) . '">' . esc_html__( 'Remove request' ) . '</a>';
 157                  break;
 158          }
 159      }
 160  }


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref