| @@ -134,8 +134,18 @@ | ||
| 134 | 134 | return apply_filters( 'give_is_success_page', $success_page ); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | + * @since 4.0.0 | |
| 139 | + * | |
| 140 | + * @return bool | |
| 141 | + */ | |
| 142 | +function give_is_campaign_page() { | |
| 143 | + $currentId = get_the_ID(); | |
| 144 | + | |
| 145 | + return (bool)get_post_meta( $currentId, 'give_campaign_id', true ); | |
| 146 | +} | |
| 147 | +/** | |
| 138 | 148 | * Send To Success Page |
| 139 | 149 | * |
| 140 | 150 | * Sends the user to the success page. |
| 141 | 151 | * |
| @@ -1247,21 +1257,24 @@ | ||
| 1247 | 1257 | |
| 1248 | 1258 | /** |
| 1249 | 1259 | * Show Form Goal Stats in Admin ( Listing and Detail page ) |
| 1250 | 1260 | * |
| 1261 | + * @since 3.16.0 Remove "give_donate_form_get_sales" filter logic | |
| 1262 | + * @since 3.14.0 Use the "give_get_form_earnings_stats" filter to ensure the correct value will be displayed in the form progress bar | |
| 1251 | 1263 | * @since 2.19.0 Prevent divide by zero issue in goal percentage calculation logic. |
| 1252 | 1264 | * |
| 1265 | + * @since 2.1.0 | |
| 1266 | + * | |
| 1253 | 1267 | * @param int $form_id Form ID. |
| 1254 | 1268 | * |
| 1255 | - * @since 2.1.0 | |
| 1256 | - * | |
| 1257 | 1269 | * @return string |
| 1258 | 1270 | */ |
| 1259 | 1271 | function give_admin_form_goal_stats( $form_id ) { |
| 1260 | - | |
| 1261 | 1272 | $html = ''; |
| 1262 | 1273 | $goal_stats = give_goal_progress_stats( $form_id ); |
| 1263 | - $percent_complete = $goal_stats['raw_goal'] ? round( ( $goal_stats['raw_actual'] / $goal_stats['raw_goal'] ), 3 ) * 100 : 0; | |
| 1274 | + $percent_complete = $goal_stats['raw_goal'] && is_numeric($goal_stats['raw_actual']) && is_numeric($goal_stats['raw_goal']) | |
| 1275 | + ? round(($goal_stats['raw_actual'] / $goal_stats['raw_goal']), 3) * 100 | |
| 1276 | + : 0; | |
| 1264 | 1277 | |
| 1265 | 1278 | $html .= sprintf( |
| 1266 | 1279 | '<div class="give-admin-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="%1$s"> |
| 1267 | 1280 | <span style="width:%1$s%%;"></span> |
| @@ -1279,11 +1292,14 @@ | ||
| 1279 | 1292 | $goal_stats['goal'], |
| 1280 | 1293 | ( 'donors' === $goal_stats['format'] ? __( 'donors', 'give' ) : ( 'donation' === $goal_stats['format'] ? __( 'donations', 'give' ) : '' ) ) |
| 1281 | 1294 | ); |
| 1282 | 1295 | |
| 1283 | - if ( $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ) { | |
| 1284 | - $html .= sprintf( '<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __( 'Goal achieved', 'give' ) ); | |
| 1285 | - } | |
| 1296 | + $opacity = $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ? 1 : 0; | |
| 1297 | + $html .= sprintf( | |
| 1298 | + '<span style="opacity:%s" class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', | |
| 1299 | + apply_filters('give_admin_goal_progress_achieved_opacity', $opacity), | |
| 1300 | + __('Goal achieved', 'give') | |
| 1301 | + ); | |
| 1286 | 1302 | |
| 1287 | 1303 | $html .= '</div>'; |
| 1288 | 1304 | |
| 1289 | 1305 | return $html; |
| @@ -1576,10 +1592,12 @@ | ||
| 1576 | 1592 | |
| 1577 | 1593 | /** |
| 1578 | 1594 | * Get the list of default parameters for the form shortcode. |
| 1579 | 1595 | * |
| 1596 | + * @since 3.2.1 Revert default display style to "onpage". | |
| 1597 | + * @since 2.4.1 | |
| 1598 | + * | |
| 1580 | 1599 | * @return array |
| 1581 | - * @since 2.4.1 | |
| 1582 | 1600 | */ |
| 1583 | 1601 | function give_get_default_form_shortcode_args() { |
| 1584 | 1602 | $default = [ |
| 1585 | 1603 | 'id' => '', |
| @@ -1586,10 +1604,10 @@ | ||
| 1586 | 1604 | 'show_title' => true, |
| 1587 | 1605 | 'show_goal' => true, |
| 1588 | 1606 | 'show_content' => '', |
| 1589 | 1607 | 'float_labels' => '', |
| 1590 | - 'display_style' => '', | |
| 1591 | - 'continue_button_title' => '', | |
| 1608 | + 'display_style' => '', | |
| 1609 | + 'continue_button_title' => '', | |
| 1592 | 1610 | |
| 1593 | 1611 | // This attribute belong to form template functionality. |
| 1594 | 1612 | // You can use this attribute to set modal open button background color. |
| 1595 | 1613 | 'button_color' => '#28C77B', |