bp_docs_add_external_tinymce_buttons_row1

Adds BuddyPress Docs-specific TinyMCE plugin buttons to row 1 of the editor.

Description

(array) bp_docs_add_external_tinymce_buttons_row1( (array) $buttons ); 

Does some funny business to get things in a nice order

Includes: - tabindent - print

Returns (array)

$buttons Button list, with BP Docs buttons added

Parameters (1)

0. $buttons (array)
TinyMCE buttons

Usage

  1. if ( !function_exists( 'bp_docs_add_external_tinymce_buttons_row1' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-docs/includes/templatetags-edit.php'; 
  3.  
  4. // TinyMCE buttons 
  5. $buttons = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_docs_add_external_tinymce_buttons_row1($buttons); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/templatetags-edit.php  
  1. function bp_docs_add_external_tinymce_buttons_row1( $buttons ) { 
  2. // TinyMCE 4.0+ 
  3. $justify_right_key = array_search( 'alignright', $buttons ); 
  4.  
  5. // 3.0 
  6. if ( false === $justify_right_key ) { 
  7. $justify_right_key = array_search( 'justifyright', $buttons ); 
  8.  
  9. if ( $justify_right_key !== 0 ) { 
  10. // Shift the buttons one to the right and remove from original array 
  11. $count = count( $buttons ); 
  12. $new_buttons = array(); 
  13. for ( $i = $justify_right_key + 1; $i < $count; $i++ ) { 
  14. $new_buttons[] = $buttons[$i]; 
  15. unset( $buttons[$i] ); 
  16.  
  17. // Put the three pieces together 
  18. $buttons = array_merge( $buttons, array( 'tabindent' ), $new_buttons ); 
  19.  
  20. // Add the Print button just before the kitchen sink 
  21. $ks = array_pop( $buttons ); 
  22. $buttons = array_merge( $buttons, array( 'print' ), array( $ks ) ); 
  23.  
  24. // Fullscreen is kinda busted here, so remove it 
  25. $fs = array_search( 'fullscreen', $buttons ); 
  26. if ( false !== $fs ) { 
  27. unset( $buttons[ $fs ] ); 
  28.  
  29. // Reset indexes 
  30. $buttons = array_values( $buttons ); 
  31.  
  32. return $buttons;