PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.12.0
GiveWP – Donation Plugin and Fundraising Platform v2.12.0
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 2.31.0 All 254 releases
give / includes / admin / dashboard-widgets.php

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

60 lines 1.2 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 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Add donation forms count to dashboard "At a glance" widget
19 *
20 * @since 1.0
21 *
22 * @param $items
23 *
24 * @return array
25 */
26 function give_dashboard_at_a_glance_widget( $items ) {
27
28 $num_posts = wp_count_posts( 'give_forms' );
29
30 if ( $num_posts && $num_posts->publish ) {
31
32 $text = sprintf(
33 /* translators: %s: number of posts published */
34 _n( '%s GiveWP Form', '%s GiveWP Forms', $num_posts->publish, 'give' ),
35 $num_posts->publish
36 );
37
38 $text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
39
40 if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
41 $text = sprintf(
42 '<a class="give-forms-count" href="%1$s">%2$s</a>',
43 admin_url( 'edit.php?post_type=give_forms' ),
44 $text
45 );
46 } else {
47 $text = sprintf(
48 '<span class="give-forms-count">%1$s</span>',
49 $text
50 );
51 }
52
53 $items[] = $text;
54 }
55
56 return $items;
57 }
58
59 add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 );
60