Skip to content

Instantly share code, notes, and snippets.

@joeyz
Created October 9, 2014 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeyz/bb9ab7c92fc4d61ca88b to your computer and use it in GitHub Desktop.
Save joeyz/bb9ab7c92fc4d61ca88b to your computer and use it in GitHub Desktop.
Basic Widget Code
<?php
/*
Plugin Name: Custom Mini Cart
Plugin URI: https://www.zendesignfitm.com/
Description: A widget framework for jewelry dropdown.
Version: 1.0
Author: Joey Z
Author URI: https://www.zendesignfirm.com/
License: GPL
*/
class Jz_Mini_Cart_Widget extends WP_Widget {
/**
* Sets up the widgets name etc
*/
public function __construct() {
// widget actual processes
parent::__construct(
'jz_mini_cart_widget', // Base ID
__('Customized Mini Cart Widget', 'text_domain'), // Name
array( 'description' => __( 'Echoes WooCommerce mini cart.', 'text_domain' ), ) // Args
);
}
/**
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget( $args, $instance ) { ?>
<h1>WIDGET CONTENT GOES HERE</h1>
<?php }
/**
* Outputs the options form on admin
*
* @param array $instance The widget options
*/
public function form( $instance ) {
// outputs the options form on admin
}
/**
* Processing widget options on save
*
* @param array $new_instance The new options
* @param array $old_instance The previous options
*/
public function update( $new_instance, $old_instance ) {
// processes widget options to be saved
}
}
add_action('widgets_init',
create_function('', 'return register_widget("Jz_Mini_Cart_Widget");')
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment