class-bulk-description-editor-list-table.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Bulk Editor
  6. * @since 1.5.0
  7. */
  8. /**
  9. * Implements table for bulk description editing.
  10. */
  11. class WPSEO_Bulk_Description_List_Table extends WPSEO_Bulk_List_Table {
  12. /**
  13. * Current type for this class will be (meta) description.
  14. *
  15. * @var string
  16. */
  17. protected $page_type = 'description';
  18. /**
  19. * Settings with are used in __construct.
  20. *
  21. * @var array
  22. */
  23. protected $settings = [
  24. 'singular' => 'wpseo_bulk_description',
  25. 'plural' => 'wpseo_bulk_descriptions',
  26. 'ajax' => true,
  27. ];
  28. /**
  29. * The field in the database where meta field is saved.
  30. *
  31. * @var string
  32. */
  33. protected $target_db_field = 'metadesc';
  34. /**
  35. * The columns shown on the table.
  36. *
  37. * @return array
  38. */
  39. public function get_columns() {
  40. $columns = [
  41. 'col_existing_yoast_seo_metadesc' => __( 'Existing Yoast Meta Description', 'wordpress-seo' ),
  42. 'col_new_yoast_seo_metadesc' => __( 'New Yoast Meta Description', 'wordpress-seo' ),
  43. ];
  44. return $this->merge_columns( $columns );
  45. }
  46. /**
  47. * Parse the metadescription.
  48. *
  49. * @param string $column_name Column name.
  50. * @param object $record Data object.
  51. * @param string $attributes HTML attributes.
  52. *
  53. * @return string
  54. */
  55. protected function parse_page_specific_column( $column_name, $record, $attributes ) {
  56. switch ( $column_name ) {
  57. case 'col_new_yoast_seo_metadesc':
  58. return sprintf(
  59. '<textarea id="%1$s" name="%1$s" class="wpseo-new-metadesc" data-id="%2$s" aria-labelledby="col_new_yoast_seo_metadesc"></textarea>',
  60. esc_attr( 'wpseo-new-metadesc-' . $record->ID ),
  61. esc_attr( $record->ID )
  62. );
  63. case 'col_existing_yoast_seo_metadesc':
  64. // @todo Inconsistent return/echo behavior R.
  65. // I traced the escaping of the attributes to WPSEO_Bulk_List_Table::column_attributes. Alexander.
  66. // The output of WPSEO_Bulk_List_Table::parse_meta_data_field is properly escaped.
  67. // phpcs:ignore WordPress.Security.EscapeOutput
  68. echo $this->parse_meta_data_field( $record->ID, $attributes );
  69. break;
  70. }
  71. }
  72. } /* End of class */