the struggle is real developing wordpress plugins
play

The Struggle is Real: Developing WordPress Plugins Daniel Simanek - PowerPoint PPT Presentation

The Struggle is Real: Developing WordPress Plugins Daniel Simanek <daniel.simanek@wisc.edu> Research and Graduate Education Throwing Things Classes Filter all the Things No Magic Code like everyone Is Stupid Break the (WordPress)


  1. The Struggle is Real: Developing WordPress Plugins Daniel Simanek <daniel.simanek@wisc.edu> Research and Graduate Education

  2. Throwing Things Classes

  3. Filter all the Things No Magic

  4. Code like everyone Is Stupid Break the (WordPress) Glass

  5. Vanilla WordPress Workflow Pending Draft Published

  6. Hot Swap Workflow Pending Draft Published Parent Pending Draft Child

  7. Object Classes

  8. lunchbox->num_grapes = 4;

  9. lunchbox->num_grapes = 4; The programming 101 idea of objects ...

  10. black_box->get_child();

  11. ??

  12. Fewer function parameters Less to remember

  13. Function scoping plugin_function_prefix_function_name() plugin_function_prefix_foo() plugin_function_prefix_example() plugin_function_prefix_foo_bar() plugin_function_prefix_bar() plugin_function_prefix_test() plugin_function_prefix_do_something() plugin_function_prefix_my_amazing_function()

  14. Function scoping $this->function_name() OR Class_Name::function_name()

  15. Order And Structure

  16. Readability And Maintainability

  17. PHP Kinda Sucks ...

  18. PHP Kinda Sucks ... http://phpsadness.com/

  19. Return Value?

  20. What is FALSE as an INT?

  21. Don’t be like PHP ...

  22. and pass errors in return values ...

  23. and pass errors in return values ... Throw Exceptions!

  24. What does PHP do if I don’t check for errors?

  25. PHP keeps going, no matter what ...

  26. Death by exception

  27. Use Constants

  28. … and not Magic Numbers

  29. What are Magic Numbers?

  30. What are Magic Numbers? if( $x == 32 ) for( range( 1, 52 ) as $card ) if( $x == ‘supercalifragilisticexpialidocious’ )

  31. if( $x == 32 ) for( range( 1, 52 ) as $card ) if( $x == ‘supercalifragilisticexpialidocious’ ) Why are Magic Numbers bad?

  32. Why are Magic Numbers bad? for( range( 1, $deck_size ) as $card ) if( $x == $freezing_point ) if( $x == $song_name )

  33. Magic Numbers, WordPress Style $cat_id = 7; $post_id = 527; $user_id = 64;

  34. Two versions of Constants Global Class

  35. BYO Filters

  36. Using apply_filters() apply_filters( ‘name_of_my_filter’, $value_to_be_filtered ); e.g. apply_filters( ‘hot_swap/use_cloning’, $cloning_enabled );

  37. Naming Filters hot_swap/excluded_post_types hot_swap/use_cloning my_awesome_plugin/options/save search_plugin/results hot_pocket/remove_from_microwave

  38. Only call apply_filters() once per filter

  39. Break out of WordPress

  40. Code like everyone is stupid

  41. Code like everyone is stupid Objects/classes

  42. Code like everyone is stupid Objects/classes Throwing exceptions

  43. Code like everyone is stupid Constants Objects/classes Throwing exceptions

  44. Questions?

  45. The Struggle is Real: Developing WordPress Plugins Daniel Simanek <daniel.simanek@wisc.edu> Research and Graduate Education

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend