Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #135 from JMAConsulting/5.0
Browse files Browse the repository at this point in the history
Merge 5.0 changes to master
  • Loading branch information
monishdeb authored Jun 29, 2018
2 parents a02f920 + 2b9e900 commit dbf7a65
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 23 deletions.
6 changes: 3 additions & 3 deletions info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<author>JMA Consulting</author>
<email>[email protected]</email>
</maintainer>
<releaseDate>2016-03-30</releaseDate>
<version>1.5</version>
<releaseDate>2018-04-25</releaseDate>
<version>1.6</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
<ver>5.0</ver>
</compatibility>
<comments/>
<civix>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/*
Plugin Name: Grant Application Shortcode
Plugin URI: https://github.com/JMAConsulting/biz.jmaconsulting.grantapplications
Description: Allow grant application profiles to be used as shortcodes in Wordpress pages and posts
Version: 1.0
Author: JMA Consulting
Author URI: http://jmaconsulting.biz
License: AGPL3
*/
add_filter('civicrm_shortcode_preprocess_atts', array('CiviCRM_For_WordPress_Shortcodes_Grant', 'civicrm_shortcode_preprocess_atts'), 10, 2);

// FIXME: Uncomment to allow support for multiple shortcodes on pages.
//add_filter('civicrm_shortcode_get_data', array('CiviCRM_For_WordPress_Shortcodes_Grant', 'civicrm_shortcode_get_data'), 10, 3);

/**
* Define CiviCRM_For_WordPress_Shortcodes Class
*/
class CiviCRM_For_WordPress_Shortcodes_Grant {

function civicrm_shortcode_preprocess_atts($args, $shortcode_atts) {
if ($shortcode_atts['component'] == 'grant') {
$args['q'] = 'civicrm/grant/transact';
return $args;
}
}

// FIXME: Seems like multiple shortcodes don't work on a single page. Also,
function civicrm_shortcode_get_data($data, $atts, $args) {
if ($atts['component'] == 'grant') {
// get grant application page
$sql = "SELECT title, intro_text FROM civicrm_grant_app_page WHERE id = {$params['id']}";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$data['title'] = $dao->title;
$data['text'] = $dao->intro_text;
}
return $data;
}
}

}
20 changes: 0 additions & 20 deletions shortcode-wp/includes/civicrm.shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,6 @@ public function preprocess_atts( $atts ) {
$args['q'] = 'civicrm/contribute/transact';
break;

case 'grant':

$args['q'] = 'civicrm/grant/transact';
break;

case 'event':

switch ( $action ) {
Expand Down Expand Up @@ -731,21 +726,6 @@ public function get_data( $atts, $args ) {
}

break;

case 'grant':

// add grant application page ID
$params['id'] = $args['id'];

// get grant application page
$sql = "SELECT title, intro_text FROM civicrm_grant_app_page WHERE id = {$params['id']}";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$data['title'] = $dao->title;
$data['text'] = $dao->intro_text;
}

break;

case 'event':

Expand Down

0 comments on commit dbf7a65

Please sign in to comment.