Unverified Commit a3abbdc7 authored by kcristiano's avatar kcristiano Committed by GitHub

Merge pull request #134 from christianwach/shorts

Allow user-defined shortcode components to be rendered
parents 4c13ffc2 560ce5fc
...@@ -280,6 +280,11 @@ class CiviCRM_For_WordPress_Shortcodes { ...@@ -280,6 +280,11 @@ class CiviCRM_For_WordPress_Shortcodes {
// preprocess shortcode attributes // preprocess shortcode attributes
$args = $this->preprocess_atts( $atts ); $args = $this->preprocess_atts( $atts );
// sanity check for improperly constructed shortcode
if ( $args === FALSE ) {
return '<p>' . __( 'Do not know how to handle this shortcode.', 'civicrm' ) . '</p>';
}
// invoke() requires environment variables to be set // invoke() requires environment variables to be set
foreach ( $args as $key => $value ) { foreach ( $args as $key => $value ) {
if ( $value !== NULL ) { if ( $value !== NULL ) {
...@@ -325,6 +330,11 @@ class CiviCRM_For_WordPress_Shortcodes { ...@@ -325,6 +330,11 @@ class CiviCRM_For_WordPress_Shortcodes {
// pre-process shortcode and retrieve args // pre-process shortcode and retrieve args
$args = $this->preprocess_atts( $atts ); $args = $this->preprocess_atts( $atts );
// sanity check for improperly constructed shortcode
if ( $args === FALSE ) {
return '<p>' . __( 'Do not know how to handle this shortcode.', 'civicrm' ) . '</p>';
}
// get data for this shortcode // get data for this shortcode
$data = $this->get_data( $atts, $args ); $data = $this->get_data( $atts, $args );
...@@ -596,6 +606,7 @@ class CiviCRM_For_WordPress_Shortcodes { ...@@ -596,6 +606,7 @@ class CiviCRM_For_WordPress_Shortcodes {
'force' => $force, 'force' => $force,
); );
// construct args for known components
switch ( $component ) { switch ( $component ) {
case 'contribution': case 'contribution':
...@@ -622,8 +633,7 @@ class CiviCRM_For_WordPress_Shortcodes { ...@@ -622,8 +633,7 @@ class CiviCRM_For_WordPress_Shortcodes {
break; break;
default: default:
echo '<p>' . __( 'Do not know how to handle this shortcode', 'civicrm' ) . '</p>'; return FALSE;
return;
} }
break; break;
...@@ -658,11 +668,6 @@ class CiviCRM_For_WordPress_Shortcodes { ...@@ -658,11 +668,6 @@ class CiviCRM_For_WordPress_Shortcodes {
unset($args['id']); unset($args['id']);
break; break;
default:
echo '<p>' . __( 'Do not know how to handle this shortcode', 'civicrm' ) . '</p>';
return;
} }
/** /**
...@@ -676,7 +681,14 @@ class CiviCRM_For_WordPress_Shortcodes { ...@@ -676,7 +681,14 @@ class CiviCRM_For_WordPress_Shortcodes {
* @param array $shortcode_atts Shortcode attributes * @param array $shortcode_atts Shortcode attributes
* @return array $args Modified shortcode arguments * @return array $args Modified shortcode arguments
*/ */
return apply_filters( 'civicrm_shortcode_preprocess_atts', $args, $shortcode_atts ); $args = apply_filters( 'civicrm_shortcode_preprocess_atts', $args, $shortcode_atts );
// sanity check for path
if ( ! isset( $args['q'] ) ) {
return FALSE;
}
return $args;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment