add-ons
4 years ago
donors
2 years ago
emails
3 years ago
forms
1 year ago
payments
2 years ago
reports
4 years ago
settings
2 years ago
shortcodes
4 years ago
tools
1 year ago
upgrades
3 years ago
views
3 years ago
abstract-admin-settings-page.php
2 years ago
admin-actions.php
2 years ago
admin-filters.php
3 years ago
admin-footer.php
2 years ago
admin-pages.php
2 years ago
class-addon-activation-banner.php
4 years ago
class-admin-settings.php
4 years ago
class-api-keys-table.php
4 years ago
class-blank-slate.php
3 years ago
class-give-admin.php
5 years ago
class-give-html-elements.php
6 years ago
class-i18n-module.php
4 years ago
dashboard-widgets.php
3 years ago
give-metabox-functions.php
3 years ago
import-functions.php
2 years ago
misc-functions.php
2 years ago
plugins.php
3 years ago
setting-page-functions.php
6 years ago
dashboard-widgets.php
62 lines
| 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 |