Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tommytomatoe committed Apr 6, 2017
0 parents commit 62be037
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Giving Grid Widget for WordPress

A super simple WordPress widget for Giving Grid.

Made with love in Knoxville, TN by Right Click Design, LLC
68 changes: 68 additions & 0 deletions givinggrid-widget-plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* Plugin Name: Giving Grid Widget Plugin
* Plugin URI: https://rightclickdesign.co
* Description: Adds a widget for Giving Grid (https://www.givinggrid.com/)
* Version: 1.0.1
* Author: Right Click Design, LLC
* Author URI: https://rightclickdesign.co
*/

class Givinggrid_Widget extends WP_Widget {

public function __construct() {
$widget_options = array( 'classname' => 'givinggrid_widget', 'description' => 'This is the Giving Grid Widget' );
parent::__construct( 'givinggrid_widget', 'Giving Grid Widget', $widget_options );
}

public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance[ 'title' ] );
$givinggrid_id = $instance[ 'givinggrid_id' ];
$blog_title = get_bloginfo( 'name' );
$tagline = get_bloginfo( 'description' );

echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title']; ?>

<div id="givinggrid-widget" data-gid="<?php echo $givinggrid_id ?>" data-wol="0"></div>

<?php echo $args['after_widget'];
}


public function form( $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
$givinggrid_id = ! empty( $instance['givinggrid_id'] ) ? $instance['givinggrid_id'] : ''; ?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label> <br/>
<input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'givinggrid_id' ); ?>">Giving Grid ID:</label><br/>
<input type="number" id="<?php echo $this->get_field_id( 'givinggrid_id' ); ?>" name="<?php echo $this->get_field_name( 'givinggrid_id' ); ?>" value="<?php echo esc_attr( $givinggrid_id ); ?>" />
</p>
<?php
}

public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
$instance[ 'givinggrid_id' ] = strip_tags( $new_instance[ 'givinggrid_id' ] );
return $instance;
}

}

function gg_widget_enqueue_scripts() {

// wp_register_script( 'givinggrid-js', plugins_url( 'js/givinggrid.js', __FILE__ ), array(), null, true );
wp_register_script( 'givinggrid-js', '//www.givinggrid.com/g/gin.js', array(), null, true );
wp_enqueue_script( 'givinggrid-js' );
}
add_action( 'wp_enqueue_scripts', 'gg_widget_enqueue_scripts' );

function register_givinggrid_widget() {
register_widget( 'Givinggrid_Widget' );
}
add_action( 'widgets_init', 'register_givinggrid_widget' );

?>
5 changes: 5 additions & 0 deletions js/givinggrid.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 62be037

Please sign in to comment.