[WordPress] Widget Image

widget

 

<?php

/* MENU ‘Menus’ PADA HALAMAN ADMIN */
/* digunakan untuk kostumasi navbar */
register_nav_menu ( “primary”, “Primary” );

/* MENU ‘Widgets’ PADA HALAMAN ADMIN */
/* digunakan untuk kostumasi sidebar */
$args = array(
‘id’ => ‘sidebar’,
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=”widget-title”>’,
‘after_title’ => ‘</h3>’
);

register_sidebar($args);

$foot = array(
‘id’ => ‘footer’,
‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=”widget-title”>’,
‘after_title’ => ‘</h3>’
);

register_sidebar($foot);

function jawaipsum ( $atts )
{
echo ( is_home() ) ? ‘<li>Jawa Ipsum</li>’ : NULL;
}
add_shortcode( ‘jawaipsum’, ‘jawaipsum’ );

class Rweb_widget extends WP_Widget {
public function __construct()
{
parent::__construct ( ‘rweb’, ‘Rweb Widget’, array ( ‘description’ => ‘Ini simpel widget gaweanku.’) );
}
public function widget ( $args, $instance )
{
echo ‘<aside class=”widget”>’;
echo ‘<h3 class=”widget-title”>’.$instance[‘title’].'</h3>’;
echo ‘<img src=”‘.$instance[‘gambar’].'” width=”150″ height=”150″>’;
echo ‘</aside>’;
}
public function form ( $instance )
{
echo ‘<p>’;
echo ‘<label>Title : </label>’;
echo ‘<input class=”widefat” type=”text” name=”‘.$this->get_field_name(‘title’).'” value=”‘.$instance[‘title’].'”>’;
echo ‘</p>’;
echo ‘<label>Gambar : </label>’;
echo ‘<input class=”widefat” name=”‘.$this->get_field_name(‘gambar’).'” type=”text” value=”‘.$instance[‘gambar’].'” />’;
echo ‘<p></p>’;
}
public function update ( $new_instance, $old_instance )
{
$instance = array();
$instance[‘title’] = $new_instance[‘title’];
$instance[‘gambar’] = $new_instance[‘gambar’] ;
return $instance;
}
}
add_action ( ‘widgets_init’, create_function(”,’return register_widget(“Rweb_widget”);’));
?>

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s