Commit 41ad5e5c authored by Pawel Ginalski's avatar Pawel Ginalski
Browse files

Issue #3269173 by gbyte: Do not display indexNow override checkbox if...

Issue #3269173 by gbyte: Do not display indexNow override checkbox if verification key has not been added
parent 9b7f6df0
Loading
Loading
Loading
Loading
+28 −24
Original line number Diff line number Diff line
@@ -46,10 +46,10 @@ class FormHelper extends BaseFormHelper {
      : 0,
    ];

    if ($this->entityCategory === 'instance') {
      // If existing form entity is unpublished on load, assume it is a draft
      // and uncheck IndexNow. Check IndexNow when changing publishing status.
    if ($this->entityCategory === 'instance'
      && !$this->entityIsNew()
      if (!$this->entityIsNew()
        && $form_fragment['index_now']['#default_value']
        && isset($form_fragment['status'])
        && empty($form_fragment['status']['widget']['value']['#default_value'])) {
@@ -61,8 +61,7 @@ class FormHelper extends BaseFormHelper {

      // If form entity is new, only check IndexNow when publishing status
      // is checked.
    if ($this->entityCategory === 'instance'
      && $this->entityIsNew()
      if ($this->entityIsNew()
        && $form_fragment['index_now']['#default_value']
        && isset($form_fragment['status'])) {
        $form_fragment['index_now']['#states'] = [
@@ -71,7 +70,6 @@ class FormHelper extends BaseFormHelper {
      }

      // Sensibly place the IndexNow checkbox.
    if ($this->entityCategory === 'instance') {
      $form_fragment['index_now']['#group'] = 'footer';
      if (isset($form_fragment['status']['#weight'])) {
        $form_fragment['index_now']['#weight'] = $form_fragment['status']['#weight'] + 10;
@@ -79,6 +77,12 @@ class FormHelper extends BaseFormHelper {
      elseif (isset($form['actions']['submit']['#weight'])) {
        $form_fragment['index_now']['#weight'] = $form_fragment['actions']['submit']['#weight'] - 1;
      }

      // Remove access to IndexNow override checkbox if no verification key has
      // been added.
      if (SimplesitemapEnginesForm::getKeyLocation() === NULL) {
        $form_fragment['index_now']['#access'] = FALSE;
      }
    }

    return $this;