fork download
  1. <?php
  2.  
  3. add_filter( 'mce_buttons', function( $originalButtonsInFirstRow ){
  4. $buttonsToAdd = [
  5. //'new_button_ID_to_add' => 'put_it_after_button_ID',
  6. 'alignjustify' => 'alignright', //add justify after align right
  7. 'underline' => 'italic', //add underline after italic
  8. ];
  9. $newButtonsInFirstRow = [];
  10. foreach( $originalButtonsInFirstRow as $buttonID ){
  11. $newButtonsInFirstRow[] = $buttonID; //re-push originals to keep them intact
  12.  
  13. foreach( $buttonsToAdd as $newButtonID => $putItAfterButtonID ){
  14. //Firstly, chack whether the button was already added by us or not! (...!==true)
  15. if( ($putItAfterButtonID !== true) && ($buttonID == $putItAfterButtonID) ){
  16. $newButtonsInFirstRow[] = $newButtonID;
  17. $buttonsToAdd[$newButtonID] = true; //make a note that button was added
  18. }
  19. }
  20. }
  21.  
  22. //Now check, if all buttons where actually added (in case "put_it_after_button_ID" was missing...)
  23. foreach( $buttonsToAdd as $newButtonID => $putItAfterButtonID ){
  24. // check if the button was added (note the type check !== (negated ===))
  25. //if the button wasn't added, put it at the and of the buttons array
  26. if( $putItAfterButtonID !== true )
  27. $newButtonsInFirstRow[] = $newButtonID;
  28. }
  29.  
  30.  
  31. return $newButtonsInFirstRow;
  32. }, 5 );
Runtime error #stdin #stdout #stderr 0.01s 52488KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Call to undefined function add_filter() in /home/YkIDpM/prog.php on line 3