class-configuration-structure.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\ConfigurationUI
  6. */
  7. /**
  8. * Class WPSEO_Configuration_Structure
  9. */
  10. class WPSEO_Configuration_Structure {
  11. /**
  12. * Registered steps.
  13. *
  14. * @var array
  15. */
  16. protected $steps = [];
  17. /**
  18. * List of fields for each configuration step.
  19. *
  20. * This list does not include the fields for the 'postTypeVisibility'
  21. * step as that list will be generated on the fly.
  22. *
  23. * @var array
  24. */
  25. private $fields = [
  26. 'environment_type' => [ 'environment_type' ],
  27. 'siteType' => [ 'siteType' ],
  28. 'publishingEntity' => [
  29. 'publishingEntity',
  30. 'publishingEntityType',
  31. 'publishingEntityCompanyInfo',
  32. 'publishingEntityCompanyName',
  33. 'publishingEntityCompanyLogo',
  34. 'publishingEntityPersonId',
  35. 'profileUrlFacebook',
  36. 'profileUrlTwitter',
  37. 'profileUrlInstagram',
  38. 'profileUrlLinkedIn',
  39. 'profileUrlMySpace',
  40. 'profileUrlPinterest',
  41. 'profileUrlYouTube',
  42. 'profileUrlWikipedia',
  43. ],
  44. 'multipleAuthors' => [ 'multipleAuthors' ],
  45. 'titleTemplate' => [
  46. 'titleIntro',
  47. 'siteName',
  48. 'separator',
  49. ],
  50. 'newsletter' => [
  51. 'mailchimpSignup',
  52. 'suggestions',
  53. ],
  54. 'success' => [ 'successMessage' ],
  55. ];
  56. /**
  57. * WPSEO_Configuration_Structure constructor.
  58. */
  59. public function initialize() {
  60. $this->add_step( 'environment-type', __( 'Environment', 'wordpress-seo' ), $this->fields['environment_type'] );
  61. $this->add_step( 'site-type', __( 'Site type', 'wordpress-seo' ), $this->fields['siteType'] );
  62. $this->add_step(
  63. 'publishing-entity',
  64. __( 'Organization or person', 'wordpress-seo' ),
  65. $this->fields['publishingEntity']
  66. );
  67. $fields = [ 'postTypeVisibility' ];
  68. $post_type_factory = new WPSEO_Config_Factory_Post_Type();
  69. foreach ( $post_type_factory->get_fields() as $post_type_field ) {
  70. $fields[] = $post_type_field->get_identifier();
  71. }
  72. $this->add_step( 'post-type-visibility', __( 'Search engine visibility', 'wordpress-seo' ), $fields );
  73. $this->add_step(
  74. 'multiple-authors',
  75. __( 'Multiple authors', 'wordpress-seo' ),
  76. $this->fields['multipleAuthors']
  77. );
  78. $this->add_step( 'title-template', __( 'Title settings', 'wordpress-seo' ), $this->fields['titleTemplate'] );
  79. $this->add_step( 'newsletter', __( 'Continue learning', 'wordpress-seo' ), $this->fields['newsletter'], true, true );
  80. $this->add_step( 'success', __( 'Success!', 'wordpress-seo' ), $this->fields['success'], true, true );
  81. }
  82. /**
  83. * Add a step to the structure
  84. *
  85. * @param string $identifier Identifier for this step.
  86. * @param string $title Title to display for this step.
  87. * @param array $fields Fields to use on the step.
  88. * @param bool $navigation Show navigation buttons.
  89. * @param bool $full_width Wheter the step content is full width or not.
  90. */
  91. protected function add_step( $identifier, $title, $fields, $navigation = true, $full_width = false ) {
  92. $this->steps[ $identifier ] = [
  93. 'title' => $title,
  94. 'fields' => $fields,
  95. 'hideNavigation' => ! (bool) $navigation,
  96. 'fullWidth' => $full_width,
  97. ];
  98. }
  99. /**
  100. * Retrieve the registered steps.
  101. *
  102. * @return array
  103. */
  104. public function retrieve() {
  105. return $this->steps;
  106. }
  107. }