original_string: protected function add_button_before(array &$params, $row, $button,
              $before = '', $alwaysadd = true) {
  
          if ($button !== '|' && $this->find_button($params, $button)) {
              return true;
          }
          $row = $this->fix_row($params, $row);
  
          $field = 'theme_advanced_buttons' . $row;
          $old = $params[$field];
  
          // Empty = add at start.
          if ($before === '') {
              $params[$field] = $button . ',' . $old;
              return true;
          }
  
          // Try to add before given plugin.
          $params[$field] = preg_replace('~(,|^)(' . preg_quote($before) . ')(,|$)~',
                  '$1' . $button . ',$2$3', $old);
          if ($params[$field] !== $old) {
              return true;
          }
  
          // If always adding, recurse to add it empty.
          if ($alwaysadd) {
              return $this->add_button_before($params, $row, $button);
          }
  
          // Otherwise return false (failed to add).
          return false;
      }
code: protected function add_button_before(array &$params, $row, $button,
              $before = '', $alwaysadd = true) {
  
          if ($button !== '|' && $this->find_button($params, $button)) {
              return true;
          }
          $row = $this->fix_row($params, $row);
  
          $field = 'theme_advanced_buttons' . $row;
          $old = $params[$field];
  
          // Empty = add at start.
          if ($before === '') {
              $params[$field] = $button . ',' . $old;
              return true;
          }
  
          // Try to add before given plugin.
          $params[$field] = preg_replace('~(,|^)(' . preg_quote($before) . ')(,|$)~',
                  '$1' . $button . ',$2$3', $old);
          if ($params[$field] !== $old) {
              return true;
          }
  
          // If always adding, recurse to add it empty.
          if ($alwaysadd) {
              return $this->add_button_before($params, $row, $button);
          }
  
          // Otherwise return false (failed to add).
          return false;
      }
code_tokens: protected function add_button_before ( array & $ params , $ row , $ button , $ before = '' , $ alwaysadd = true ) { if ( $ button !== '|' && $ this -> find_button ( $ params , $ button ) ) { return true ; } $ row = $ this -> fix_row ( $ params , $ row ) ; $ field = 'theme_advanced_buttons' . $ row ; $ old = $ params [ $ field ] ; // Empty = add at start. if ( $ before === '' ) { $ params [ $ field ] = $ button . ',' . $ old ; return true ; } // Try to add before given plugin. $ params [ $ field ] = preg_replace ( '~(,|^)(' . preg_quote ( $ before ) . ')(,|$)~' , '$1' . $ button . ',$2$3' , $ old ) ; if ( $ params [ $ field ] !== $ old ) { return true ; } // If always adding, recurse to add it empty. if ( $ alwaysadd ) { return $ this -> add_button_before ( $ params , $ row , $ button ) ; } // Otherwise return false (failed to add). return false ; }
docstring: Adds a button to the editor.
  
  Specify the location of this button using the $before variable. If you
  leave this blank, the button will be added at the start.
  
  If you want to try different possible locations depending on existing
  plugins you can set $alwaysadd to false and check the return value
  to see if it succeeded.
  
  Note: button will not be added if it is already present in any row
  (separator is an exception).
  
  The following example will add the button 'newbutton' before the
  'existingbutton' if it exists or in the end of the last row otherwise:
  <pre>
  if ($row = $this->find_button($params, 'existingbutton')) {
  $this->add_button_before($params, $row, 'newbutton', 'existingbutton');
  } else {
  $this->add_button_after($params, $this->count_button_rows($params), 'newbutton');
  }
  </pre>
  
  @param array $params TinyMCE init parameters array
  @param int $row Row to add button to (1 to 10)
  @param string $button Identifier of button/plugin
  @param string $before Adds button directly before the named plugin
  @param bool $alwaysadd If specified $before string not found, add at start
  @return bool True if added or button already exists (in any row)
docstring_tokens: Adds a button to the editor .