Created
October 3, 2012 23:01
-
-
Save webaware/3830445 to your computer and use it in GitHub Desktop.
Example of simple widget for WP Flexible Map plugin
This file contains 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 | |
// 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