WPSEO_GSC_Bulk_Action

Class WPSEO_GSC_Bulk_Action.

Defined (1)

The class is defined in the following location(s).

/admin/google_search_console/class-gsc-bulk-action.php  
  1. class WPSEO_GSC_Bulk_Action { 
  2.  
  3. /** 
  4. * Setting the listener on the bulk action post 
  5. */ 
  6. public function __construct() { 
  7. if ( wp_verify_nonce( filter_input( INPUT_POST, 'wpseo_gsc_nonce' ), 'wpseo_gsc_nonce' ) ) { 
  8. $this->handle_bulk_action(); 
  9.  
  10. /** 
  11. * Handles the bulk action when there is an action posted 
  12. */ 
  13. private function handle_bulk_action() { 
  14. if ( $bulk_action = $this->determine_bulk_action() ) { 
  15. $this->run_bulk_action( $bulk_action, $this->posted_issues() ); 
  16.  
  17. wp_redirect( filter_input( INPUT_POST, '_wp_http_referer' ) ); 
  18. exit; 
  19.  
  20. /** 
  21. * Determine which bulk action is selected and return that value 
  22. * @return string|bool 
  23. */ 
  24. private function determine_bulk_action() { 
  25. // If posted action is the selected one above the table, return that value. 
  26. if ( ( $action = filter_input( INPUT_POST, 'action' ) ) && $action !== '-1' ) { 
  27. return $action; 
  28.  
  29. // If posted action is the selected one below the table, return that value. 
  30. if ( ( $action = filter_input( INPUT_POST, 'action2' ) ) && $action !== '-1' ) { 
  31. return $action; 
  32.  
  33. return false; 
  34.  
  35. /** 
  36. * Get the posted issues and return them 
  37. * @return array 
  38. */ 
  39. private function posted_issues() { 
  40. if ( $issues = filter_input( INPUT_POST, 'wpseo_crawl_issues', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ) ) { 
  41. return $issues; 
  42.  
  43. // Fallback if issues are empty. 
  44. return array(); 
  45.  
  46. /** 
  47. * Runs the bulk action 
  48. * @param string $bulk_action Action type. 
  49. * @param array $issues Set of issues to apply to. 
  50. */ 
  51. private function run_bulk_action( $bulk_action, $issues ) { 
  52. switch ( $bulk_action ) { 
  53. case 'mark_as_fixed' : 
  54. array_map( array( $this, 'action_mark_as_fixed' ), $issues ); 
  55.  
  56. break; 
  57.  
  58. /** 
  59. * Marks the issue as fixed 
  60. * @param string $issue Issue URL. 
  61. * @return string 
  62. */ 
  63. private function action_mark_as_fixed( $issue ) { 
  64. new WPSEO_GSC_Marker( $issue ); 
  65.  
  66. return $issue;