Created
January 27, 2018 05:05
-
-
Save wichaksono/0a29bd8bb7cbf2ace7bad5a792981a47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class My_Widget extends WP_Widget { | |
/** | |
* Mengatur Nama Widget | |
*/ | |
public function __construct() { | |
$widget_ops = array( | |
'classname' => 'my_widget', // class pada html | |
'description' => 'My Widget is awesome', // deskripsi tentang widget | |
); | |
/** | |
* parent::__construct($id_widget, $namaWidget, $options); | |
*/ | |
parent::__construct( 'my_widget', 'My Widget', $widget_ops ); | |
} | |
/** | |
* yang akan ditampilkan di website | |
*/ | |
public function widget( $args, $instance ) { | |
// code html | |
} | |
/** | |
* akan ditampilkan di halaman admin | |
*/ | |
public function form( $instance ) { | |
// code html | |
} | |
/** | |
* perintah simpan dan update | |
*/ | |
public function update( $new_instance, $old_instance ) { | |
// code saving | |
} | |
} | |
// implementasi widget | |
add_action( 'widgets_init', function(){ | |
register_widget( 'My_Widget' ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment