Changeset 2052716
- Timestamp:
- 03/18/2019 02:33:17 PM (7 years ago)
- Location:
- makemydonation-imo/trunk
- Files:
-
- 2 edited
-
mmdimo.php (modified) (1 diff)
-
template.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
makemydonation-imo/trunk/mmdimo.php
r2052712 r2052716 52 52 add_shortcode( 'mmdimo_donation_link', 'shortcode_mmdimo_donation_link' ); 53 53 add_shortcode( 'mmdimo_donation_url', 'shortcode_mmdimo_donation_url' ); 54 add_shortcode( 'mmdimo_donations_count', 'shortcode_mmdimo_donations_count' ); 54 55 add_shortcode( 'mmdimo_donation_charity:name', 'shortcode_mmdimo_donation_charity_name' ); 55 56 add_shortcode( 'mmdimo_donation_charity:ein', 'shortcode_mmdimo_donation_charity_ein' ); -
makemydonation-imo/trunk/template.php
r2052714 r2052716 1 1 <?php 2 2 3 function the_mmdimo_donation_link( $before = '', $after = '', $echo = true, $content = NULL, $title = NULL, $target = NULL, $ein = NULL ) {4 $donation_link = get_the_mmdimo_donation_link(0, $content, $title, $target, $ein );3 function the_mmdimo_donation_link( $before = '', $after = '', $echo = true, $content = NULL, $title = NULL, $target = NULL, $ein = NULL, $display_count = FALSE ) { 4 $donation_link = get_the_mmdimo_donation_link(0, $content, $title, $target, $ein, $display_count); 5 5 6 6 if ( strlen($donation_link) == 0 ) { … … 18 18 } 19 19 20 function get_the_mmdimo_donation_link( $post = 0, $content = NULL, $title = NULL, $target = NULL, $ein = NULL ) {20 function get_the_mmdimo_donation_link( $post = 0, $content = NULL, $title = NULL, $target = NULL, $ein = NULL, $display_count = FALSE ) { 21 21 $url = get_the_mmdimo_donation_url( $post, $ein ); 22 22 $post = get_post( $post ); 23 $id = isset( $post->ID ) ? $post->ID : 0; 23 24 24 25 if ( is_null($content) ) { 25 26 $content = 'Donate'; 26 27 } 28 29 if ( $display_count ) { 30 $count = get_the_mmdimo_donations_count( $id ); 31 32 if ( $count ) { 33 $content .= ' (' . $count . ')'; 34 } 35 } 36 27 37 if ( is_null($title) ) { 28 38 $title = 'Make My Donation in Memory of ' . $post->post_title; … … 50 60 $target = isset($attr['target'] ) ? $attr['target'] : NULL; 51 61 $ein = isset($attr['ein'] ) ? $attr['ein'] : NULL; 62 $display_count = isset($attr['display_count'] ) && $attr['display_count'] ? TRUE : FALSE; 52 63 53 64 if (!$content) { … … 55 66 } 56 67 57 return get_the_mmdimo_donation_link(0, $content, $title, $target, $ein );68 return get_the_mmdimo_donation_link(0, $content, $title, $target, $ein, $display_count); 58 69 } 59 70 … … 121 132 } 122 133 134 function the_mmdimo_donations_count( $before = '', $after = '', $echo = true, $content = NULL ) { 135 $donations_count = get_the_mmdimo_donations_count(0, $content); 136 137 if ( strlen($donations_count) == 0 ) { 138 return; 139 } 140 141 $donations_count = $before . $donations_count . $after; 142 143 if ( $echo ) { 144 echo $donations_count; 145 } 146 else { 147 return $donations_count; 148 } 149 } 150 151 function get_the_mmdimo_donations_count( $post = 0, $content = NULL ) { 152 $post = get_post( $post ); 153 $id = isset( $post->ID ) ? $post->ID : 0; 154 $mmdimo_case = get_post_meta( $id, 'mmdimo_case', TRUE ); 155 156 require_once( MMDIMO_PLUGIN_DIR . '/api.php' ); 157 $donations_count = mmdimo_api_case_donations_load($mmdimo_case['id'], TRUE); 158 159 if ( $post->ID && $donations_count['total'] ) { 160 $count = sprintf(_n( '%s donation', '%s donations', $donations_count['total'], 'mmdimo' ), $donations_count['total']); 161 162 $content = '<span class="mmdimo-donation-count">' . $count . '</span>'; 163 164 return apply_filters( 'get_the_mmdimo_donations_count', $content, $post, $donations_count ); 165 } 166 167 return ''; 168 } 169 170 function shortcode_mmdimo_donations_count( $content = NULL ) { 171 if (!$content) { 172 $content = NULL; 173 } 174 175 return get_the_mmdimo_donations_count(0, $content); 176 } 177 123 178 function the_mmdimo_donation_charity_name( $before = '', $after = '', $echo = TRUE ) { 124 179 $charity_name = get_the_mmdimo_donation_charity_name();
Note: See TracChangeset
for help on using the changeset viewer.