PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / includes / admin / dashboard-widgets.php

dashboard-widgets.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at includes/admin/dashboard-widgets.php

62 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Dashboard Widgets
4 *
5 * @package Give
6 * @subpackage Admin/Dashboard
7 * @copyright Copyright (c) 2016, GiveWP
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 use Give\DonationForms\V2\DonationFormsAdminPage;
13
14 // Exit if accessed directly.
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Add donation forms count to dashboard "At a glance" widget
21 *
22 * @since 1.0
23 *
24 * @param $items
25 *
26 * @return array
27 */
28 function give_dashboard_at_a_glance_widget( $items ) {
29
30 $num_posts = wp_count_posts( 'give_forms' );
31
32 if ( $num_posts && $num_posts->publish ) {
33
34 $text = sprintf(
35 /* translators: %s: number of posts published */
36 _n( '%s GiveWP Form', '%s GiveWP Forms', $num_posts->publish, 'give' ),
37 $num_posts->publish
38 );
39
40 $text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
41
42 if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
43 $text = sprintf(
44 '<a class="give-forms-count" href="%1$s">%2$s</a>',
45 DonationFormsAdminPage::getUrl(),
46 $text
47 );
48 } else {
49 $text = sprintf(
50 '<span class="give-forms-count">%1$s</span>',
51 $text
52 );
53 }
54
55 $items[] = $text;
56 }
57
58 return $items;
59 }
60
61 add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 );
62