-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 62be037
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
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' ); | ||
|
||
?> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.