original_string: public function add_region($region, $custom = true) {
          global $SESSION;
          $this->check_not_yet_loaded();
          if ($custom) {
              if (array_key_exists($region, $this->regions)) {
                  // This here is EXACTLY why we should not be adding block regions into a page. It should
                  // ALWAYS be done in a theme layout.
                  debugging('A custom region conflicts with a block region in the theme.', DEBUG_DEVELOPER);
              }
              // We need to register this custom region against the page type being used.
              // This allows us to check, when performing block actions, that unrecognised regions can be worked with.
              $type = $this->page->pagetype;
              if (!isset($SESSION->custom_block_regions)) {
                  $SESSION->custom_block_regions = array($type => array($region));
              } else if (!isset($SESSION->custom_block_regions[$type])) {
                  $SESSION->custom_block_regions[$type] = array($region);
              } else if (!in_array($region, $SESSION->custom_block_regions[$type])) {
                  $SESSION->custom_block_regions[$type][] = $region;
              }
          }
          $this->regions[$region] = 1;
  
          // Checking the actual property instead of calling get_default_region as it ends up in a recursive call.
          if (empty($this->defaultregion)) {
              $this->set_default_region($region);
          }
      }
code: public function add_region($region, $custom = true) {
          global $SESSION;
          $this->check_not_yet_loaded();
          if ($custom) {
              if (array_key_exists($region, $this->regions)) {
                  // This here is EXACTLY why we should not be adding block regions into a page. It should
                  // ALWAYS be done in a theme layout.
                  debugging('A custom region conflicts with a block region in the theme.', DEBUG_DEVELOPER);
              }
              // We need to register this custom region against the page type being used.
              // This allows us to check, when performing block actions, that unrecognised regions can be worked with.
              $type = $this->page->pagetype;
              if (!isset($SESSION->custom_block_regions)) {
                  $SESSION->custom_block_regions = array($type => array($region));
              } else if (!isset($SESSION->custom_block_regions[$type])) {
                  $SESSION->custom_block_regions[$type] = array($region);
              } else if (!in_array($region, $SESSION->custom_block_regions[$type])) {
                  $SESSION->custom_block_regions[$type][] = $region;
              }
          }
          $this->regions[$region] = 1;
  
          // Checking the actual property instead of calling get_default_region as it ends up in a recursive call.
          if (empty($this->defaultregion)) {
              $this->set_default_region($region);
          }
      }
code_tokens: public function add_region ( $ region , $ custom = true ) { global $ SESSION ; $ this -> check_not_yet_loaded ( ) ; if ( $ custom ) { if ( array_key_exists ( $ region , $ this -> regions ) ) { // This here is EXACTLY why we should not be adding block regions into a page. It should // ALWAYS be done in a theme layout. debugging ( 'A custom region conflicts with a block region in the theme.' , DEBUG_DEVELOPER ) ; } // We need to register this custom region against the page type being used. // This allows us to check, when performing block actions, that unrecognised regions can be worked with. $ type = $ this -> page -> pagetype ; if ( ! isset ( $ SESSION -> custom_block_regions ) ) { $ SESSION -> custom_block_regions = array ( $ type => array ( $ region ) ) ; } else if ( ! isset ( $ SESSION -> custom_block_regions [ $ type ] ) ) { $ SESSION -> custom_block_regions [ $ type ] = array ( $ region ) ; } else if ( ! in_array ( $ region , $ SESSION -> custom_block_regions [ $ type ] ) ) { $ SESSION -> custom_block_regions [ $ type ] [ ] = $ region ; } } $ this -> regions [ $ region ] = 1 ; // Checking the actual property instead of calling get_default_region as it ends up in a recursive call. if ( empty ( $ this -> defaultregion ) ) { $ this -> set_default_region ( $ region ) ; } }
docstring: Add a region to a page
  
  @param string $region add a named region where blocks may appear on the current page.
  This is an internal name, like 'side-pre', not a string to display in the UI.
  @param bool $custom True if this is a custom block region, being added by the page rather than the theme layout.
docstring_tokens: Add a region to a page