HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpmuhibbah_err/wp-content/plugins/give/src/MultiFormGoals/ProgressBar/Query.php
<?php

namespace Give\MultiFormGoals\ProgressBar;

use wpdb;

/**
 * Get the Total, Count, and Average of the payment totals for published donations of a given set of forms.
 */
class Query
{

    /** @var array */
    protected $formIDs;

    /**
     * @var wpdb
     */
    protected $wpdb;

    /**
     * @var array $formIDs
     */
    public function __construct($formIDs)
    {
        global $wpdb;
        $this->wpdb = $wpdb;
        $this->formIDs = $formIDs;
    }

    /**
     * @since 3.14.0 Consider the donation mode (test or live) instead of querying both modes together
     * @return string
     */
    public function getSQL()
    {
        global $wpdb;
        $mode = give_is_test_mode() ? 'test' : 'live';
        $sql = "
            SELECT
                sum( revenue.amount ) as total,
                count( payment.ID ) as count
            FROM {$wpdb->posts} as payment
                JOIN {$wpdb->give_revenue} as revenue
                    ON revenue.donation_id = payment.ID
                JOIN {$wpdb->paymentmeta} paymentMode
                    ON payment.ID = paymentMode.donation_id AND paymentMode.meta_key = '_give_payment_mode'
            WHERE
                payment.post_type = 'give_payment'
                AND
                payment.post_status IN ( 'publish', 'give_subscription' )
                AND
                paymentMode.meta_value = '{$mode}'
        ";

        if ( ! empty($this->formIDs)) {
            $sql .= '
                AND
                revenue.form_id IN ( ' . $this->getFormsString() . ' )
            ';
        }

        return $sql;
    }

    /**
     * @return string
     */
    protected function getFormsString()
    {
        return implode(',', $this->formIDs);
    }

    /**
     * @return stdClass
     */
    public function getResults()
    {
        $sql = $this->getSQL();

        return $this->wpdb->get_row($sql);
    }
}