Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What I Wish I'd Known When I Started

What I Wish I'd Known When I Started

WordPress provides many convenient functions, perhaps too many. All too often, new developers reinvent the wheel, as the cliche goes, when Core already has a function or utility to accomplish the same. Five years on and thinking back to when I started building WordPress plugins, I could’ve saved a lot of time and avoided a lot of anxiety if I’d known where to look.

Erick Hitter

June 13, 2015
Tweet

More Decks by Erick Hitter

Other Decks in Technology

Transcript

  1. What I Wish I’d Known When I Started Erick Hitter

    @ethitter https://ethitter.com/
  2. Link Functions •get_permalink()   •get_page_by_path(  'about'  )   •get_post_type_archive_link(  'waffles'

     )   •user_trailingslashit()   •get_year_link()   •get_adjacent_post()
  3. Link Functions •home_url(  '/'  )
 
 
 
 Many more

    in
 wp-­‐includes/link-­‐template.php.
  4. Ajax • Hook your function to one of two variable

    actions • Use the same action name with the request to admin-­‐ajax.php •check_ajax_referer() or use a nonce
  5. Database Interactions • Use custom post types and custom taxonomies

    instead. • If you must, always $wpdb-­‐>prepare() your queries.
  6. Database Interactions •$wpdb-­‐>get_var()   •$wpdb-­‐>get_col()   •$wpdb-­‐>get_row()   •$wpdb-­‐>insert(  $table,

     $data,  $format  )   •$wpdb-­‐>update(  $table,  $data,  $where,   $format,  $where_format  )   •$wpdb-­‐>query()