Skip to content

Instantly share code, notes, and snippets.

@webaware
Created October 3, 2012 23:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webaware/3830445 to your computer and use it in GitHub Desktop.
Save webaware/3830445 to your computer and use it in GitHub Desktop.
Example of simple widget for WP Flexible Map plugin
<?php
// drop this code into your theme's functions.php file and edit the array properties below
add_action('widgets_init', 'widgetsInitExampleMap');
function widgetsInitExampleMap() {
register_widget('ExampleMapWidget');
}
class ExampleMapWidget extends WP_Widget {
/**
* initialise widget
*/
public function __construct() {
parent::__construct('example-map', 'Example Map', array(
'classname' => 'widget-example-map',
'description' => 'Simple example of a map widget'
));
}
/**
* show widget content
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
* @param array $instance The settings for the particular instance of the widget
*/
public function widget($args, $instance) {
echo $args['before_widget'];
echo flexmap_show_map(array(
'center' => '-34.916721,138.828878',
'width' => 200,
'height' => 200,
'zoom' => 12,
'maptype' => 'roadmap',
'hidemaptype' => 'true',
));
echo $args['after_widget'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment