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

WordPress Plugin Development

WordPress Plugin Development

WordPress Plugin Development - Dari pemula sampai manula, dari ide doang sampai jadi uang.

Slide ini dipresentasikan saat workshop IMMatic 2012. Sayang bagian live coding tidak ada di dalam slide ini dan hanya bisa diikuti peserta workshop. :)

http://dropsugar.com

Mochammad Masbuchin

July 08, 2012
Tweet

More Decks by Mochammad Masbuchin

Other Decks in Programming

Transcript

  1. Sekilas • Manfaat Bikin WordPress Plugin • Struktur • Bikin

    Plugin + Admin Menu • Publikasi & Duitisasi Sunday, July 8, 2012
  2. Sekilas • Manfaat Bikin WordPress Plugin • Struktur • Bikin

    Plugin + Admin Menu • Publikasi & Duitisasi Istilah Opo Meneh Iki? Sunday, July 8, 2012
  3. Manfaat Bikin Plugin? • Mengumpulkan Email List • Link Building

    • Duit, $$$ • Cari Muka Sunday, July 8, 2012
  4. Manfaat Bikin Plugin? • Mengumpulkan Email List • Link Building

    • Duit, $$$ • Cari Muka Sunday, July 8, 2012
  5. Struktur WordPress Plugin • Informasi & Lisensi • Action &

    Filter Hooks • Halaman Administrasi http://codex.wordpress.org/Writing_a_Plugin Kalau rilis free, ndak masalah kalau minta uang donasi Sunday, July 8, 2012
  6. Informasi & Lisensi <?php /* Plugin  Name:  Nama  Plugin Plugin

     URI:  http://halaman-­‐web.com/plugin-­‐anda Description:  Deskripsi  plugin  anda Version:  Versi  Plugin  anda,  misal:  1.0 Author:  Nama  Ente Author  URI:  http://alamat-­‐web-­‐anda.com License:  Lisensi,  kalau  dirilis  free  pakai  GPL,  kalau  endak,  bisa  dicopyright   aja. */ ?> nama-plugin.php <?php /*    Copyright  YEAR    PLUGIN_AUTHOR_NAME    (email  :  PLUGIN  AUTHOR  EMAIL)        This  program  is  free  software;  you  can  redistribute  it  and/or  modify        it  under  the  terms  of  the  GNU  General  Public  License,  version  2,  as          published  by  the  Free  Software  Foundation.        This  program  is  distributed  in  the  hope  that  it  will  be  useful,        but  WITHOUT  ANY  WARRANTY;  without  even  the  implied  warranty  of        MERCHANTABILITY  or  FITNESS  FOR  A  PARTICULAR  PURPOSE.    See  the        GNU  General  Public  License  for  more  details.        You  should  have  received  a  copy  of  the  GNU  General  Public  License        along  with  this  program;  if  not,  write  to  the  Free  Software        Foundation,  Inc.,  51  Franklin  St,  Fifth  Floor,  Boston,  MA    02110-­‐1301    USA */ ?> License? Tinggal Ctrl+C + Ctrl+V ajah. http://www.idea.org/blog/2011/07/22/open-source-vs- proprietary-software/ Sunday, July 8, 2012
  7. Informasi & Lisensi <?php /* Plugin  Name:  Nama  Plugin Plugin

     URI:  http://halaman-­‐web.com/plugin-­‐anda Description:  Deskripsi  plugin  anda Version:  Versi  Plugin  anda,  misal:  1.0 Author:  Nama  Ente Author  URI:  http://alamat-­‐web-­‐anda.com License:  Lisensi,  kalau  dirilis  free  pakai  GPL,  kalau  endak,  bisa  dicopyright   aja. */ ?> nama-plugin.php <?php /*    Copyright  YEAR    PLUGIN_AUTHOR_NAME    (email  :  PLUGIN  AUTHOR  EMAIL)        This  program  is  free  software;  you  can  redistribute  it  and/or  modify        it  under  the  terms  of  the  GNU  General  Public  License,  version  2,  as          published  by  the  Free  Software  Foundation.        This  program  is  distributed  in  the  hope  that  it  will  be  useful,        but  WITHOUT  ANY  WARRANTY;  without  even  the  implied  warranty  of        MERCHANTABILITY  or  FITNESS  FOR  A  PARTICULAR  PURPOSE.    See  the        GNU  General  Public  License  for  more  details.        You  should  have  received  a  copy  of  the  GNU  General  Public  License        along  with  this  program;  if  not,  write  to  the  Free  Software        Foundation,  Inc.,  51  Franklin  St,  Fifth  Floor,  Boston,  MA    02110-­‐1301    USA */ ?> License? Tinggal Ctrl+C + Ctrl+V ajah. http://www.idea.org/blog/2011/07/22/open-source-vs- proprietary-software/ Sunday, July 8, 2012
  8. Action • Sebuah kejadian tertentu di WordPress, dari eksekusi sampai

    tampil ke browser. http://codex.wordpress.org/Plugin_API Sunday, July 8, 2012
  9. Action, contoh • wp_head, di atas halaman, sebelum </head> •

    wp_footer, di bawah halaman sebelum </body> • user_register, dieksekusi setelah pendaftaran • Selengkapnya: • http://codex.wordpress.org/Plugin_API/ Action_Reference Ada sekitar 587 Action Hooks yang ada di wp Sunday, July 8, 2012
  10. Filter • Sebuah kejadian membawa data yang bisa kita modifikasi

    sebelum dimasukkan database atau ditampilkan di browser. Sunday, July 8, 2012
  11. Filter • Sebuah kejadian membawa data yang bisa kita modifikasi

    sebelum dimasukkan database atau ditampilkan di browser. Ngapusi.. Boong Lu! Sunday, July 8, 2012
  12. Filter • Sebuah kejadian membawa data yang bisa kita modifikasi

    sebelum dimasukkan database atau ditampilkan di browser. Ngapusi.. Boong Lu! Tenanan, Cak. Beneran! Sunday, July 8, 2012
  13. Filter • Sebuah kejadian membawa data yang bisa kita modifikasi

    sebelum dimasukkan database atau ditampilkan di browser. Ngapusi.. Boong Lu! Tenanan, Cak. Beneran! Beri Contoh dong! Sunday, July 8, 2012
  14. Filter, contoh • the_content, dieksekusi saat konten mau ditampilkan ke

    visitor. Kita bisa memodifikasi isi tulisan sebelum tampil memakai filter ini. • wp_insert_post_data, kita bisa memodifikasi isi tulisan sebelum masuk ke database. • Selengkapnya: http://codex.wordpress.org/ Plugin_API/Filter_Reference Sunday, July 8, 2012
  15. <?php add_action( 'admin_menu', 'my_plugin_menu' ); function my_plugin_menu() { ! add_options_page(

    'My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options' ); } Action! Menambahkan Menu di Admin 1 2 Sunday, July 8, 2012
  16. <?php add_action( 'admin_menu', 'my_plugin_menu' ); function my_plugin_menu() { ! add_options_page(

    'My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options' ); } function my_plugin_options() { ! if ( !current_user_can( 'manage_options' ) ) { ! ! wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); ! } ! echo '<div class="wrap">'; ! echo '<p>Here is where the form would go if I actually had options.</p>'; ! echo '</div>'; } ?> Action! Menambahkan Menu di Admin Tampilkan Menu 1 2 3 Sunday, July 8, 2012
  17. <?php add_action( 'admin_menu', 'my_plugin_menu' ); function my_plugin_menu() { ! add_options_page(

    'My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options' ); } function my_plugin_options() { ! if ( !current_user_can( 'manage_options' ) ) { ! ! wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); ! } ! echo '<div class="wrap">'; ! echo '<p>Here is where the form would go if I actually had options.</p>'; ! echo '</div>'; } ?> Action! Menambahkan Menu di Admin Tampilkan Menu 1 2 3 Wah gitu doang ya! Ho oh, cyiiin! Sunday, July 8, 2012
  18. Bikin Plugin: • Siapkan & Nyalakan Web Server • Install

    WordPress • Buat wp-content/plugins/nama-plugin/nama- plugin.php <<=== misal: Filter-Porn Sunday, July 8, 2012
  19. Bikin Plugin: • Siapkan & Nyalakan Web Server • Install

    WordPress • Buat wp-content/plugins/nama-plugin/nama- plugin.php <<=== misal: Filter-Porn • Buat Informasi & Lisensi Sunday, July 8, 2012
  20. Bikin Plugin: • Siapkan & Nyalakan Web Server • Install

    WordPress • Buat wp-content/plugins/nama-plugin/nama- plugin.php <<=== misal: Filter-Porn • Buat Informasi & Lisensi • Buat Action / Filter Sunday, July 8, 2012