Plugin Directory

Changeset 3360992


Ignore:
Timestamp:
09/13/2025 11:52:56 AM (7 months ago)
Author:
payping
Message:

Improved plugin performance

Location:
payping-gravityforms/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • payping-gravityforms/trunk/README.txt

    r3357079 r3360992  
    2727This plugin follows strict privacy guidelines. When using the api.payping.ir service, user data is securely transmitted and stored following industry best practices.
    2828
     29== External services ==
     30
     31This plugin connects to the PayPing payment API in order to create and verify Gravity Forms payments.
     32It is required to redirect payers to the gateway and to verify transactions on return.
     33
     34**What is sent and when**
     35- On form submission (before redirect): amount, callback URL, and a description/reference for the order are sent to PayPing's `/v3/pay` endpoint to create a payment.
     36- On return from the gateway: the transaction reference received from PayPing is sent to `/v3/pay/verify` to confirm the payment result.
     37- Your PayPing API key (Bearer token) is sent in the `Authorization` header for both requests.
     38- No card information is handled by this plugin. Cardholder data is entered on PayPing's pages.
     39
     40**Service provider**
     41PayPing — https://payping.ir/ 
     42Terms of Service: https://payping.io/terms/ 
     43Privacy Policy: https://payping.io/terms/
     44
     45**API documentation**
     46https://docs.payping.io/
     47
    2948
    3049== Changelog ==
  • payping-gravityforms/trunk/chart.php

    r3357079 r3360992  
    11<?php
    22
    3 class GFPersian_Chart_payping {
     3class Payping_GravityForms_Chart {
    44
    55   
     
    255255                $sales_label = __( "تعداد کل پرداخت های  پی‌پینگ این فرم", "payping-gravityforms" );
    256256
    257                 $transaction_totals = GFPersian_DB_payping::get_transaction_totals( $form_id );
     257                $transaction_totals = Payping_GravityForms_database::get_transaction_totals( $form_id );
    258258                $total_sales        = empty( $transaction_totals["active"]["transactions"] ) ? 0 : $transaction_totals["active"]["transactions"];
    259259                $total_revenue      = empty( $transaction_totals["active"]["revenue"] ) ? 0 : $transaction_totals["active"]["revenue"];
     
    312312                $sales_label = esc_html__( "تعداد کل پرداخت های  همه روشهای این فرم", "payping-gravityforms" );
    313313
    314                 $transaction_totals = GFPersian_DB_payping::get_transaction_totals_gateways( $form_id );
     314                $transaction_totals = Payping_GravityForms_database::get_transaction_totals_gateways( $form_id );
    315315                $total_sales        = empty( $transaction_totals["active"]["transactions"] ) ? 0 : $transaction_totals["active"]["transactions"];
    316316                $total_revenue      = empty( $transaction_totals["active"]["revenue"] ) ? 0 : $transaction_totals["active"]["revenue"];
     
    373373                $sales_label = esc_html__( "تعداد کل پرداخت های درگاه پی‌پینگ", "payping-gravityforms" );
    374374
    375                 $transaction_totals = GFPersian_DB_payping::get_transaction_totals_this_gateway();
     375                $transaction_totals = Payping_GravityForms_database::get_transaction_totals_this_gateway();
    376376                $total_sales        = empty( $transaction_totals["active"]["transactions"] ) ? 0 : $transaction_totals["active"]["transactions"];
    377377                $total_revenue      = empty( $transaction_totals["active"]["revenue"] ) ? 0 : $transaction_totals["active"]["revenue"];
     
    431431                $sales_label = esc_html__( "تعداد کل پرداخت های همه فرمهای سایت", "payping-gravityforms" );
    432432
    433                 $transaction_totals = GFPersian_DB_payping::get_transaction_totals_site();
     433                $transaction_totals = Payping_GravityForms_database::get_transaction_totals_site();
    434434                $total_sales        = empty( $transaction_totals["active"]["transactions"] ) ? 0 : $transaction_totals["active"]["transactions"];
    435435                $total_revenue      = empty( $transaction_totals["active"]["revenue"] ) ? 0 : $transaction_totals["active"]["revenue"];
     
    530530            $dt      = "points: { symbol: 'diamond', fillColor: '#058DC7' }, color: '#058DC7'}";
    531531            $t       = esc_html__( 'پی‌پینگ این فرم', 'payping-gravityforms' );
    532             $tblname = GFPersian_DB_payping::get_entry_table_name();
     532            $tblname = Payping_GravityForms_database::get_entry_table_name();
    533533            $query = $wpdb->prepare(
    534534                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    550550            $dt      = "points: { symbol: 'square', fillColor: '#50B432' }, color: '#50B432'}";
    551551            $t       = esc_html__( 'همه روشهای این فرم', 'payping-gravityforms' );
    552             $tblname = GFPersian_DB_payping::get_entry_table_name();
     552            $tblname = Payping_GravityForms_database::get_entry_table_name();
    553553            $query = $wpdb->prepare(
    554554                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    569569            $dt      = "}";
    570570            $t       = esc_html__( "همه فرمهای پی‌پینگ", 'payping-gravityforms' );
    571             $tblname = GFPersian_DB_payping::get_entry_table_name();
     571            $tblname = Payping_GravityForms_database::get_entry_table_name();
    572572            $query = $wpdb->prepare(
    573573                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    588588            $dt      = "points: { symbol: 'triangle', fillColor: '#AA4643' }, color: '#AA4643'}";
    589589            $t       = esc_html__( "همه فرمهای سایت", 'payping-gravityforms' );
    590             $tblname = GFPersian_DB_payping::get_entry_table_name();
     590            $tblname = Payping_GravityForms_database::get_entry_table_name();
    591591            $query = $wpdb->prepare(
    592592                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    710710            $dt      = "points: { symbol: 'diamond', fillColor: '#058DC7' }, color: '#058DC7'}";
    711711            $t       = esc_html__( "پی‌پینگ این فرم", 'payping-gravityforms' );
    712             $tblname = GFPersian_DB_payping::get_entry_table_name();
     712            $tblname = Payping_GravityForms_database::get_entry_table_name();
    713713            $query = $wpdb->prepare(
    714714                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    730730            $dt      = "points: { symbol: 'square', fillColor: '#50B432' }, color: '#50B432'}";
    731731            $t       = esc_html__( "همه روشهای این فرم", 'payping-gravityforms' );
    732             $tblname = GFPersian_DB_payping::get_entry_table_name();
     732            $tblname = Payping_GravityForms_database::get_entry_table_name();
    733733            $query = $wpdb->prepare(
    734734                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    749749            $dt      = "}";
    750750            $t       = esc_html__( "همه فرمهای پی‌پینگ", 'payping-gravityforms' );
    751             $tblname = GFPersian_DB_payping::get_entry_table_name();
     751            $tblname = Payping_GravityForms_database::get_entry_table_name();
    752752            $query = $wpdb->prepare(
    753753                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    768768            $dt      = "points: { symbol: 'triangle', fillColor: '#AA4643' }, color: '#AA4643'}";
    769769            $t       = esc_html__( "همه فرم های سایت", 'payping-gravityforms' );
    770             $tblname = GFPersian_DB_payping::get_entry_table_name();
     770            $tblname = Payping_GravityForms_database::get_entry_table_name();
    771771            $query = $wpdb->prepare(
    772772                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    948948            $dt      = "points: { symbol: 'diamond', fillColor: '#058DC7' }, color: '#058DC7'}";
    949949            $t       = esc_html__( "پی‌پینگ این فرم", 'payping-gravityforms' );
    950             $tblname = GFPersian_DB_payping::get_entry_table_name();
     950            $tblname = Payping_GravityForms_database::get_entry_table_name();
    951951            $query = $wpdb->prepare(
    952952                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    968968            $dt      = "points: { symbol: 'square', fillColor: '#50B432' }, color: '#50B432'}";
    969969            $t       = esc_html__( "همه روشهای این فرم", 'payping-gravityforms' );
    970             $tblname = GFPersian_DB_payping::get_entry_table_name();
     970            $tblname = Payping_GravityForms_database::get_entry_table_name();
    971971            $query = $wpdb->prepare(
    972972                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    987987            $dt      = "}";
    988988            $t       = esc_html__( "همه فرمهای پی‌پینگ", 'payping-gravityforms' );
    989             $tblname = GFPersian_DB_payping::get_entry_table_name();
     989            $tblname = Payping_GravityForms_database::get_entry_table_name();
    990990            $query = $wpdb->prepare(
    991991                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    10061006            $dt      = "points: { symbol: 'triangle', fillColor: '#AA4643' }, color: '#AA4643'}";
    10071007            $t       = esc_html__( "همه فرمهای پی‌پینگ", 'payping-gravityforms' );
    1008             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1008            $tblname = Payping_GravityForms_database::get_entry_table_name();
    10091009            $query = $wpdb->prepare(
    10101010                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    12251225            $dt      = "points: { symbol: 'diamond', fillColor: '#058DC7' }, color: '#058DC7'}";
    12261226            $t       = esc_html__( "پی‌پینگ این فرم", 'payping-gravityforms' );
    1227             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1227            $tblname = Payping_GravityForms_database::get_entry_table_name();
    12281228            $query = $wpdb->prepare(
    12291229                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    12451245            $dt      = "points: { symbol: 'square', fillColor: '#50B432' }, color: '#50B432'}";
    12461246            $t       = esc_html__( "همه روشهای این فرم", 'payping-gravityforms' );
    1247             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1247            $tblname = Payping_GravityForms_database::get_entry_table_name();
    12481248            $query = $wpdb->prepare(
    12491249                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    12641264            $dt      = "color: '#EDC240'}";
    12651265            $t       = esc_html__( "همه فرمهای پی‌پینگ", 'payping-gravityforms' );
    1266             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1266            $tblname = Payping_GravityForms_database::get_entry_table_name();
    12671267            $query = $wpdb->prepare(
    12681268                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    12831283            $dt      = "points: { symbol: 'triangle', fillColor: '#AA4643' }, color: '#AA4643'}";
    12841284            $t       = esc_html__( "همه فرم های سایت", 'payping-gravityforms' );
    1285             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1285            $tblname = Payping_GravityForms_database::get_entry_table_name();
    12861286            $query = $wpdb->prepare(
    12871287                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    14051405            $dt = "points: { symbol: 'diamond', fillColor: '#058DC7' }, color: '#058DC7'}";
    14061406            $t  = esc_html__( "پی‌پینگ این فرم", 'payping-gravityforms' );
    1407             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1407            $tblname = Payping_GravityForms_database::get_entry_table_name();
    14081408            $query = $wpdb->prepare(
    14091409                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    14251425            $dt      = "points: { symbol: 'square', fillColor: '#50B432' }, color: '#50B432'}";
    14261426            $t       = esc_html__( "همه روشهای این فرم", 'payping-gravityforms' );
    1427             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1427            $tblname = Payping_GravityForms_database::get_entry_table_name();
    14281428            $query = $wpdb->prepare(
    14291429                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    14441444            $dt      = "}";
    14451445            $t       = esc_html__( "همه فرمهای پی‌پینگ", 'payping-gravityforms' );
    1446             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1446            $tblname = Payping_GravityForms_database::get_entry_table_name();
    14471447            $query = $wpdb->prepare(
    14481448                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    14631463            $dt      = "points: { symbol: 'triangle', fillColor: '#AA4643' }, color: '#AA4643'}";
    14641464            $t       = esc_html__( "همه فرمهای سایت", 'payping-gravityforms' );
    1465             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1465            $tblname = Payping_GravityForms_database::get_entry_table_name();
    14661466            $query = $wpdb->prepare(
    14671467                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    15791579            $dt      = "points: { symbol: 'diamond', fillColor: '#058DC7' }, color: '#058DC7'}";
    15801580            $t       = esc_html__( "پی‌پینگ این فرم", 'payping-gravityforms' );
    1581             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1581            $tblname = Payping_GravityForms_database::get_entry_table_name();
    15821582            $query = $wpdb->prepare(
    15831583                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    15991599            $dt      = "points: { symbol: 'square', fillColor: '#50B432' }, color: '#50B432'}";
    16001600            $t       = esc_html__( "همه روشهای این فرم", 'payping-gravityforms' );
    1601             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1601            $tblname = Payping_GravityForms_database::get_entry_table_name();
    16021602            $query = $wpdb->prepare(
    16031603                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    16181618            $dt      = "}";
    16191619            $t       = esc_html__( "همه فرمهای پی‌پینگ", 'payping-gravityforms' );
    1620             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1620            $tblname = Payping_GravityForms_database::get_entry_table_name();
    16211621            $query = $wpdb->prepare(
    16221622                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    16361636            $dt      = "points: { symbol: 'triangle', fillColor: '#AA4643' }, color: '#AA4643'}";
    16371637            $t       = esc_html__( "همه فرم های سایت", 'payping-gravityforms' );
    1638             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1638            $tblname = Payping_GravityForms_database::get_entry_table_name();
    16391639            $query = $wpdb->prepare(
    16401640                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    17961796            $dt      = "points: { symbol: 'diamond', fillColor: '#058DC7' }, color: '#058DC7'}";
    17971797            $t       = esc_html__( "پی‌پینگ این فرم", 'payping-gravityforms' );
    1798             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1798            $tblname = Payping_GravityForms_database::get_entry_table_name();
    17991799            $query = $wpdb->prepare(
    18001800                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    18161816            $dt      = "points: { symbol: 'square', fillColor: '#50B432' }, color: '#50B432'}";
    18171817            $t       = esc_html__( "همه روشهای این فرم", 'payping-gravityforms' );
    1818             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1818            $tblname = Payping_GravityForms_database::get_entry_table_name();
    18191819            $query = $wpdb->prepare(
    18201820                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    18351835            $dt      = "}";
    18361836            $t       = esc_html__( "همه فرمهای پی‌پینگ", 'payping-gravityforms' );
    1837             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1837            $tblname = Payping_GravityForms_database::get_entry_table_name();
    18381838            $query = $wpdb->prepare(
    18391839                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
     
    18541854            $dt      = "points: { symbol: 'triangle', fillColor: '#AA4643' }, color: '#AA4643'}";
    18551855            $t       = esc_html__( "همه فرمهای سایت", 'payping-gravityforms' );
    1856             $tblname = GFPersian_DB_payping::get_entry_table_name();
     1856            $tblname = Payping_GravityForms_database::get_entry_table_name();
    18571857            $query = $wpdb->prepare(
    18581858                "SELECT CONVERT_TZ(l.payment_date, '+00:00', %s) as date, sum(l.payment_amount) as amount_sold, count(l.id) as new_sales
  • payping-gravityforms/trunk/database.php

    r3099658 r3360992  
    55}
    66
    7 class GFPersian_DB_payping {
     7class Payping_GravityForms_database {
    88
    99    private static $method = 'payping';
  • payping-gravityforms/trunk/payping-gravityforms.php

    r3357079 r3360992  
    1111License: GPLv3 or later
    1212License URI: https://www.gnu.org/licenses/gpl-3.0.html
     13Text Domain: payping-gravityforms
    1314*/
    14 if (!defined('ABSPATH')) exit;
     15if ( ! defined('ABSPATH') ) exit;
    1516
    16 
    17 
    18 function callback_for_setting_up_scripts() {
    19    
    20     if ( ! class_exists("GFPersian_Payments") ) {
     17add_action('admin_enqueue_scripts', 'payping_gravityforms_admin_assets');
     18function payping_gravityforms_admin_assets() {
     19    if ( ! class_exists('GFPersian_Payments') ) {
    2120        return;
    2221    }
    2322
    24     $screen = get_current_screen();
    25     if ( $screen && ( $screen->id === "toplevel_page_gf_settings" || strpos($screen->id, "gravityforms") !== false ) ) {
    26         wp_enqueue_script( "gf-admin-scripts", plugin_dir_url( __FILE__ ) . "assets/js/scripts.js", array(), false, true );
    27         wp_enqueue_script( "shamsi-chart", esc_url(GFPersian_Payments::get_base_url()) . "/assets/js/shamsi_chart.js", array("jquery"), null, true );
    28         wp_register_script( "jquery-ui-jdatepicker", GFPersian_Payments::get_base_url() . "/assets/js/jalali-datepicker.js", array("jquery","jquery-migrate","jquery-ui-core",), GFCommon::$version, true );
    29         wp_enqueue_script( "jquery-ui-jdatepicker" );
     23    $screen = function_exists('get_current_screen') ? get_current_screen() : null;
     24    if ( $screen && ( $screen->id === 'toplevel_page_gf_settings' || strpos($screen->id, 'gravityforms') !== false ) ) {
     25
     26        wp_enqueue_script(
     27            'payping-gravityforms-admin-scripts',
     28            plugin_dir_url(__FILE__) . 'assets/js/scripts.js',
     29            array('jquery'),
     30            false,
     31            true
     32        );
     33
     34        wp_enqueue_script(
     35            'payping-gravityforms-shamsi-chart',
     36            esc_url( GFPersian_Payments::get_base_url() ) . '/assets/js/shamsi_chart.js',
     37            array('jquery'),
     38            null,
     39            true
     40        );
     41
     42        wp_register_script(
     43            'payping-gravityforms-jalali-datepicker',
     44            esc_url( GFPersian_Payments::get_base_url() ) . '/assets/js/jalali-datepicker.js',
     45            array('jquery','jquery-migrate','jquery-ui-core'),
     46            GFCommon::$version,
     47            true
     48        );
     49        wp_enqueue_script('payping-gravityforms-jalali-datepicker');
    3050
    3151        wp_localize_script(
    32             "gf-admin-scripts",
    33             "myLocalizedData",
     52            'payping-gravityforms-admin-scripts',
     53            'paypingGformData',
    3454            array(
    35                 "ajaxurl" => admin_url("admin-ajax.php"),
    36                 "gf_payping_update_feed_active_nonce" => wp_create_nonce("gf_payping_update_feed_active"),
    37                 "deactivate_message" => esc_html__("درگاه غیر فعال است", "payping-gravityforms"),
    38                 "activate_message" => esc_html__("درگاه فعال است", "payping-gravityforms"),
    39                 "ajax_error_message" => esc_html__("خطای Ajax رخ داده است", "payping-gravityforms")
     55                'ajaxUrl'                 => admin_url('admin-ajax.php'),
     56                'nonceUpdateFeedActive'   => wp_create_nonce('payping_gravityforms_update_feed_active'),
     57                'msgDeactivate'           => esc_html__('درگاه غیر فعال است', 'payping-gravityforms'),
     58                'msgActivate'             => esc_html__('درگاه فعال است', 'payping-gravityforms'),
     59                'msgAjaxError'            => esc_html__('خطای Ajax رخ داده است', 'payping-gravityforms'),
    4060            )
    4161        );
    4262
    4363        wp_enqueue_style(
    44             "admin-styles-enqueue", plugin_dir_url( __FILE__ ) . "assets/css/styles.css"
     64            'payping-gravityforms-admin-styles',
     65            plugin_dir_url(__FILE__) . 'assets/css/styles.css'
    4566        );
    46        
     67
    4768        if ( is_rtl() ) {
    48             $custom_css = " table.gforms_form_settings th { text-align: right !important; }";
    49             wp_add_inline_style( "admin-styles-enqueue", $custom_css );
     69            wp_add_inline_style(
     70                'payping-gravityforms-admin-styles',
     71                'table.gforms_form_settings th { text-align: right !important; }'
     72            );
    5073        }
    5174    }
    5275}
    53 add_action( "admin_enqueue_scripts", "callback_for_setting_up_scripts" );
    5476
     77require_once plugin_dir_path(__FILE__) . 'payping.php';
    5578
    56 require_once('payping.php');
    57 
  • payping-gravityforms/trunk/payping.php

    r3357079 r3360992  
    66}
    77
    8 register_activation_hook( __FILE__, array( 'GFPersian_Gateway_payping', "add_permissions" ) );
    9 add_action( 'init', array( 'GFPersian_Gateway_payping', 'init' ) );
     8register_activation_hook( __FILE__, array( 'Payping_GravityForms_Gateway', "add_permissions" ) );
     9add_action( 'init', array( 'Payping_GravityForms_Gateway', 'init' ) );
    1010
    1111require_once( 'database.php' );
    1212require_once( 'chart.php' );
    1313
    14 class GFPersian_Gateway_payping {
     14class Payping_GravityForms_Gateway {
    1515
    1616    //Dont Change this Parameter if you are legitimate !!!
     
    3131       
    3232        if ( ! self::is_gravityforms_supported() ) {
    33             add_action( 'admin_notices', array( __CLASS__, 'admin_notice_gf_support' ) );
     33            add_action( 'admin_notices', array( __CLASS__, 'admin_notice_gravityforms_support' ) );
    3434
    3535            return false;
     
    6565            }
    6666
    67             add_action( 'wp_ajax_gf_payping_update_feed_active', array( __CLASS__, 'update_feed_active' ) );
     67            add_action( 'wp_ajax_payping_gravityforms_update_feed_active', array( __CLASS__, 'update_feed_active' ) );
    6868        }
    6969        if ( get_option( "ppgf_payping_configured" ) ) {
     
    7878
    7979        // --------------------------------------------------------------------------------------------
    80         add_filter( 'gf_payment_gateways', array( __CLASS__, 'gravityformspayping' ), 2 );
     80        add_filter( 'payping_gravityforms_payment_gateways', array( __CLASS__, 'gravityformspayping' ), 2 );
    8181        do_action( 'gravityforms_gateways' );
    8282        do_action( 'gravityforms_payping' );
     
    9393
    9494    // -------------------------------------------------
    95     public static function admin_notice_gf_support() {
     95    public static function admin_notice_gravityforms_support() {
    9696        $class_safe   = 'notice notice-error';
    9797        $message_safe = sprintf( esc_html__( "درگاه پی‌پینگ نیاز به گرویتی فرم نسخه %s به بالا دارد. برای بروز رسانی هسته گرویتی فرم به %sسایت گرویتی فرم فارسی%s مراجعه نمایید .", "payping-gravityforms" ), self::$min_gravityforms_version, "<a href='http:///11378' target='_blank'>", "</a>" );
     
    114114        );
    115115
    116         return apply_filters( self::$author . '_gf_payping_detail', apply_filters( self::$author . '_gf_gateway_detail', $payping, $form, $entry ), $form, $entry );
     116        return apply_filters( self::$author . '_gravityforms_payping_detail', apply_filters( self::$author . '_gravityforms_gateway_detail', $payping, $form, $entry ), $form, $entry );
    117117    }
    118118
     
    137137    private static function setup() {
    138138        if ( get_option( "ppgf_payping_version" ) != self::$version ) {
    139             GFPersian_DB_payping::update_table();
     139            Payping_GravityForms_database::update_table();
    140140            update_option( "ppgf_payping_version", self::$version );
    141141        }
     
    218218            die( esc_html__( "شما مجوز کافی برای این کار را ندارید . سطح دسترسی شما پایین تر از حد مجاز است . ", "payping-gravityforms" ) );
    219219        }
    220         GFPersian_DB_payping::drop_tables();
     220        Payping_GravityForms_database::drop_tables();
    221221        delete_option( "ppgf_payping_settings" );
    222222        delete_option( "ppgf_payping_configured" );
     
    326326    public static function get_config_by_entry( $entry ) {
    327327        $feed_id = gform_get_meta( $entry["id"], "payping_feed_id" );
    328         $feed    = ! empty( $feed_id ) ? GFPersian_DB_payping::get_feed( $feed_id ) : '';
     328        $feed    = ! empty( $feed_id ) ? Payping_GravityForms_database::get_feed( $feed_id ) : '';
    329329        $return  = ! empty( $feed ) ? $feed : false;
    330330
    331         return apply_filters( self::$author . '_gf_payping_get_config_by_entry', apply_filters( self::$author . '_gf_gateway_get_config_by_entry', $return, $entry ), $entry );
     331        return apply_filters( self::$author . '_gravityforms_payping_get_config_by_entry', apply_filters( self::$author . '_gravityforms_gateway_get_config_by_entry', $return, $entry ), $entry );
    332332    }
    333333
     
    388388        }
    389389
    390         $configs = GFPersian_DB_payping::get_feed_by_form( $form["id"], true );
    391 
    392         $configs = apply_filters( self::$author . '_gf_payping_get_active_configs', apply_filters( self::$author . '_gf_gateway_get_active_configs', $configs, $form ), $form );
     390        $configs = Payping_GravityForms_database::get_feed_by_form( $form["id"], true );
     391
     392        $configs = apply_filters( self::$author . '_gravityforms_payping_get_active_configs', apply_filters( self::$author . '_gravityforms_gateway_get_active_configs', $configs, $form ), $form );
    393393
    394394        $return = false;
     
    404404        }
    405405
    406         self::$config = apply_filters( self::$author . '_gf_payping_get_active_config', apply_filters( self::$author . '_gf_gateway_get_active_config', $return, $form ), $form );
     406        self::$config = apply_filters( self::$author . '_gravityforms_payping_get_active_config', apply_filters( self::$author . '_gravityforms_gateway_get_active_config', $return, $form ), $form );
    407407
    408408        return self::$config;
     
    415415            self::config_page();
    416416        } else if ( $view == "stats" ) {
    417             GFPersian_Chart_payping::stats_page();
     417            Payping_GravityForms_Chart::stats_page();
    418418        } else {
    419419            self::list_page( '' );
     
    429429
    430430        if ( rgpost( 'action' ) == "delete" ) {
    431             check_admin_referer( "list_action", "gf_payping_list" );
     431            check_admin_referer( "list_action", "gravityforms_payping_list" );
    432432            $id = absint( rgpost( "action_argument" ) );
    433             GFPersian_DB_payping::delete_feed( $id );
     433            Payping_GravityForms_database::delete_feed( $id );
    434434            ?>
    435435            <div class="updated fade"
     
    437437        } else if ( ! empty( $_POST["bulk_action"] ) ) {
    438438
    439             check_admin_referer( "list_action", "gf_payping_list" );
     439            check_admin_referer( "list_action", "gravityforms_payping_list" );
    440440            $selected_feeds = rgpost( "feed" );
    441441            if ( is_array( $selected_feeds ) ) {
    442442                foreach ( $selected_feeds as $feed_id ) {
    443                     GFPersian_DB_payping::delete_feed( $feed_id );
     443                    Payping_GravityForms_database::delete_feed( $feed_id );
    444444                }
    445445            }
     
    467467
    468468            <form id="confirmation_list_form" method="post">
    469                 <?php wp_nonce_field( 'list_action', 'gf_payping_list' ) ?>
     469                <?php wp_nonce_field( 'list_action', 'gravityforms_payping_list' ) ?>
    470470                <input type="hidden" id="action" name="action"/>
    471471                <input type="hidden" id="action_argument" name="action_argument"/>
     
    518518                    <?php
    519519                    if ( $arg != 'per-form' ) {
    520                         $settings = GFPersian_DB_payping::get_feeds();
     520                        $settings = Payping_GravityForms_database::get_feeds();
    521521                    } else {
    522                         $settings = GFPersian_DB_payping::get_feed_by_form( rgget( 'id' ), false );
     522                        $settings = Payping_GravityForms_database::get_feed_by_form( rgget( 'id' ), false );
    523523                    }
    524524
     
    635635    // -------------------------------------------------
    636636    public static function update_feed_active() {
    637         check_ajax_referer( 'gf_payping_update_feed_active', 'gf_payping_update_feed_active' );
     637        check_ajax_referer( 'gravityforms_payping_update_feed_active', 'gravityforms_payping_update_feed_active' );
    638638   
    639639        $id   = absint( rgpost( 'feed_id' ) ); // Sanitize as an integer
    640         $feed = GFPersian_DB_payping::get_feed( $id );
     640        $feed = Payping_GravityForms_database::get_feed( $id );
    641641   
    642642        $form_id = intval( $feed["form_id"] ); // Sanitize as an integer
     
    644644        $meta = esc_sql( $feed["meta"] ); // Escape SQL data
    645645   
    646         GFPersian_DB_payping::update_feed( $id, $form_id, $is_active, $meta );
     646        Payping_GravityForms_database::update_feed( $id, $form_id, $is_active, $meta );
    647647    }
    648648   
     
    873873                $payment_string .= '</select>';
    874874
    875                 echo '<label for="payment_status">' . esc_html__( 'وضعیت پرداخت :', 'payping-gravityforms' ) . '</label> ' . $payment_string . '<br/><br/>';
     875                //echo '<label for="payment_status">' . esc_html__( 'وضعیت پرداخت :', 'payping-gravityforms' ) . '</label> ' . $payment_string . '<br/><br/>';
     876                echo '<label for="payment_status">'
     877                    . esc_html__( 'وضعیت پرداخت :', 'payping-gravityforms' )
     878                    . '</label> '
     879                    . wp_kses_post( $payment_string )
     880                    . '<br/><br/>';
    876881
    877882                ?>
     
    10181023
    10191024        if ( rgpost( "uninstall" ) ) {
    1020             check_admin_referer( "uninstall", "gf_payping_uninstall" );
     1025            check_admin_referer( "uninstall", "gravityforms_payping_uninstall" );
    10211026            self::uninstall();
    10221027            echo wp_kses_post('<div class="updated fade" style="padding:20px;">' . esc_html__( "درگاه با موفقیت غیرفعال شد و اطلاعات مربوط به آن نیز از بین رفت برای فعالسازی مجدد میتوانید از طریق افزونه های وردپرس اقدام نمایید .", "payping-gravityforms" ) . '</div>');
     
    10251030        } else if ( isset( $_POST["gf_payping_submit"] ) ) {
    10261031
    1027             check_admin_referer( "update", "gf_payping_update" );
     1032            check_admin_referer( "update", "gravityforms_payping_update" );
    10281033            $settings = array(
    1029                 "merchent" => rgpost( 'gf_payping_merchent' ),
     1034                "merchent" => rgpost( 'gravityforms_payping_token' ),
    10301035                "gname"    => rgpost( 'gf_payping_gname' ),
    10311036            );
     
    10621067        <form action="" method="post">
    10631068
    1064             <?php wp_nonce_field( "update", "gf_payping_update" ) ?>
     1069            <?php wp_nonce_field( "update", "gravityforms_payping_update" ) ?>
    10651070
    10661071            <h3>
     
    10871092                <tr>
    10881093                    <th scope="row"><label
    1089                                 for="gf_payping_merchent"><?php esc_html_e( "کد توکن", "payping-gravityforms" ); ?></label>
     1094                                for="gravityforms_payping_token"><?php esc_html_e( "کد توکن", "payping-gravityforms" ); ?></label>
    10901095                    </th>
    10911096                    <td>
    10921097                        <input style="width:350px;text-align:left;direction:ltr !important" type="text"
    1093                                id="gf_payping_merchent" name="gf_payping_merchent"
     1098                               id="gravityforms_payping_token" name="gravityforms_payping_token"
    10941099                               value="<?php echo esc_html( sanitize_text_field( rgar( $settings, 'merchent' ) ) ); ?>"/>
    10951100                    </td>
     
    11681173                "meta"      => array(),
    11691174                "is_active" => true
    1170             ) : GFPersian_DB_payping::get_feed( $id );
    1171             $get_feeds = GFPersian_DB_payping::get_feeds();
     1175            ) : Payping_GravityForms_database::get_feed( $id );
     1176            $get_feeds = Payping_GravityForms_database::get_feeds();
    11721177            $form_name = '';
    11731178
     
    12361241                $config = apply_filters( self::$author . '_gform_payping_save_config', $config );
    12371242
    1238                 $id = GFPersian_DB_payping::update_feed( $id, $config["form_id"], $config["is_active"], $config["meta"] );
     1243                $id = Payping_GravityForms_database::update_feed( $id, $config["form_id"], $config["is_active"], $config["meta"] );
    12391244
    12401245                $redirect_url = esc_url(admin_url('admin.php?page=gravityforms_payping&view=edit&id=' . $id . '&updated=true'));
     
    12861291                            <label for="export_form"><?php esc_html_e( 'یک فید انتخاب کنید', 'payping-gravityforms' ) ?></label>
    12871292                            <?php
    1288                             $feeds = GFPersian_DB_payping::get_feeds();
     1293                            $feeds = Payping_GravityForms_database::get_feeds();
    12891294                            if ( RG_CURRENT_VIEW != 'entry' ) { ?>
    12901295                                <select name="form_switcher" id="form_switcher"
     
    13911396                                                        value=""><?php esc_html_e( "یک فرم انتخاب نمایید", "payping-gravityforms" ); ?> </option>
    13921397                                                <?php
    1393                                                 $available_forms = GFPersian_DB_payping::get_available_forms();
     1398                                                $available_forms = Payping_GravityForms_database::get_available_forms();
    13941399                                                foreach ( $available_forms as $current_form ) {
    13951400                                                    $selected = absint( $current_form->id ) == $_get_form_id ? 'selected="selected"' : ''; ?>
     
    16851690
    16861691            var form = [];
    1687             form = <?php echo ! empty( $form ) ? GFCommon::json_encode( $form ) : GFCommon::json_encode( array() ) ?>;
     1692            //form = <?php //echo ! empty( $form ) ? GFCommon::json_encode( $form ) : GFCommon::json_encode( array() ) ?>;
     1693            form = <?php echo wp_json_encode( ! empty( $form ) ? $form : array() ); ?>;
    16881694
    16891695            jQuery(document).ready(function ($) {
     
    17281734
    17291735                <?php foreach ( $condition_field_ids as $i => $field_id ) : ?>
    1730                 selectedField = "<?php echo str_replace( '"', '\"', $field_id )?>";
    1731                 selectedValue = "<?php echo str_replace( '"', '\"', $condition_values[ '' . $i . '' ] )?>";
    1732                 selectedOperator = "<?php echo str_replace( '"', '\"', $condition_operators[ '' . $i . '' ] )?>";
    1733                 RefreshConditionRow("gf_payping_<?php echo $i;?>__conditional", selectedField, selectedOperator, selectedValue, <?php echo $i;?>);
     1736                //selectedField = "<?php //echo str_replace( '"', '\"', $field_id )?>";
     1737                //selectedValue = "<?php //echo str_replace( '"', '\"', $condition_values[ '' . $i . '' ] )?>";
     1738                //selectedOperator = "<?php //echo str_replace( '"', '\"', $condition_operators[ '' . $i . '' ] )?>";
     1739                //RefreshConditionRow("gf_payping_<?php //echo $i;?>__conditional", selectedField, selectedOperator, selectedValue, <?php //echo $i;?>);
     1740                selectedField = <?php echo wp_json_encode( isset($field_id) ? $field_id : "" ); ?>;
     1741                selectedValue = <?php echo wp_json_encode( isset($condition_values[ "" . $i . "" ]) ? $condition_values[ "" . $i . "" ] : "" ); ?>;
     1742                selectedOperator = <?php echo wp_json_encode( isset($condition_operators[ "" . $i . "" ]) ? $condition_operators[ "" . $i . "" ] : "" ); ?>;
     1743                RefreshConditionRow("gf_payping_<?php echo esc_js( $i ); ?>__conditional", selectedField, selectedOperator, selectedValue, <?php echo esc_js( $i ); ?>);
    17341744                <?php endforeach;?>
    17351745            });
     
    17691779
    17701780                if (selectedOperator == '' || selectedOperator == 'is' || selectedOperator == 'isnot') {
    1771                     if (field["type"] == "post_category" && field["displayAllCategories"]) {
    1772                         str += '<?php $dd = wp_dropdown_categories( array(
    1773                             "class"        => "condition_field_value",
    1774                             "orderby"      => "name",
    1775                             "id"           => "gf_dropdown_cat_id",
    1776                             "name"         => "gf_dropdown_cat_name",
    1777                             "hierarchical" => true,
    1778                             "hide_empty"   => 0,
    1779                             "echo"         => false
    1780                         ) ); echo str_replace( "\n", "", str_replace( "'", "\\'", $dd ) ); ?>';
    1781                         str = str.replace("gf_dropdown_cat_id", "" + input + "_value").replace("gf_dropdown_cat_name", name);
    1782                     }
     1781                    if ($field["type"] == "post_category" && $field["displayAllCategories"]) {
     1782                        str += '<?php
     1783                            $dd = wp_dropdown_categories( array(
     1784                                "class"        => "condition_field_value",
     1785                                "orderby"      => "name",
     1786                                "id"           => "gf_dropdown_cat_id",
     1787                                "name"         => "gf_dropdown_cat_name",
     1788                                "hierarchical" => true,
     1789                                "hide_empty"   => 0,
     1790                                "echo"         => false
     1791                            ) );
     1792                            echo esc_js( str_replace( "\n", "", str_replace( "\'", "\\'", $dd ) ) ); /*echo str_replace( "\n", "", str_replace( "'", "\\'", $dd ) ); ?>'; */
     1793                        ?>';
     1794
     1795                        str = str.replace("gf_dropdown_cat_id", "" + input + "_value")
     1796                                .replace("gf_dropdown_cat_name", name);
     1797                    }
    17831798                    else if (field.choices) {
    17841799                        var isAnySelected = false;
     
    18071822                if (is_text) {
    18081823                    selectedValue = selectedValue ? selectedValue.replace(/'/g, "&#039;") : "";
    1809                     str += "<input type='text' class='condition_field_value' style='padding:3px' placeholder='<?php _e( "یک مقدار وارد نمایید", "gravityformspayping" ); ?>' id='" + input + "_value' name='" + name + "' value='" + selectedValue + "'>";
     1824                    str += "<input type='text' class='condition_field_value' style='padding:3px' placeholder='<?php esc_attr_e( "یک مقدار وارد نمایید", "payping-gravityforms" ); ?>' id='" + input + "_value' name='" + name + "' value='" + selectedValue + "'>";
    18101825                }
    18111826                return str;
     
    18781893        do_action( 'ppgf_payping_request_1', $confirmation, $form, $entry, $ajax );
    18791894
    1880         if ( apply_filters( 'gf_payping_request_return', apply_filters( 'ppgf_gateway_request_return', false, $confirmation, $form, $entry, $ajax ), $confirmation, $form, $entry, $ajax ) ) {
     1895        if ( apply_filters( 'gravityforms_payping_request_return', apply_filters( 'ppgf_gateway_request_return', false, $confirmation, $form, $entry, $ajax ), $confirmation, $form, $entry, $ajax ) ) {
    18811896            return $confirmation;
    18821897        }
     
    20742089            $entry = GFPersian_Payments::get_entry( $entry_id );
    20752090            $ReturnPath = self::Return_URL( $form['id'], $entry_id );
    2076             $ResNumber  = apply_filters( 'gf_payping_res_number', apply_filters( 'ppgf_gateway_res_number', $entry_id, $entry, $form ), $entry, $form );
     2091            $ResNumber  = apply_filters( 'gravityforms_payping_res_number', apply_filters( 'ppgf_gateway_res_number', $entry_id, $entry, $form ), $entry, $form );
    20772092        } else {
    20782093            $Amount      = absint( 10000 );
     
    21102125            $headers = array(
    21112126                'X-Platform'         => 'GravityForms',
    2112                 'X-Platform-Version' => '2.5.1',
     2127                'X-Platform-Version' => '2.5.0',
    21132128                "Accept" => "application/json",
    21142129                "Authorization" => "Bearer " . self::get_merchent(),
     
    22022217
    22032218        // ـــ ۱) گذر از فیلترهای سفارشی و پیش‌شرط‌ها
    2204         if ( apply_filters( 'gf_gateway_payping_return', apply_filters( 'ppgf_gateway_verify_return', false ) ) ) {
     2219        if ( apply_filters( 'gravityforms_gateway_payping_return', apply_filters( 'ppgf_gateway_verify_return', false ) ) ) {
    22052220            return;
    22062221        }
     
    22342249
    22352250        $config = ( $payment_type === 'custom' )
    2236             ? apply_filters( self::$author . '_gf_payping_config', [], $form, $entry )
     2251            ? apply_filters( self::$author . '_gravityforms_payping_config', [], $form, $entry )
    22372252            : self::get_config_by_entry( $entry );
    22382253
     
    22602275        // ـــ ۵) واکشی و پاک‌سازی دادهٔ برگشتی درگاه
    22612276        //----------------------------------------------
    2262         $raw_data     = isset( $_REQUEST['data'] ) ? wp_unslash( $_REQUEST['data'] ) : '';
     2277        //$raw_data     = isset( $_REQUEST['data'] ) ? wp_unslash( $_REQUEST['data'] ) : '';
     2278        $raw_data = isset( $_REQUEST['data'] ) ? sanitize_textarea_field( wp_unslash( $_REQUEST['data'] ) ) : '';
    22632279        $responseData = json_decode( $raw_data, true ) ?: [];
    22642280        $status          = isset( $_REQUEST['status'] ) ? absint( $_REQUEST['status'] ) : null;
     
    25942610
    25952611        // اعلان‌ها و تاییدیه
    2596         if ( apply_filters( self::$author . '_gf_payping_verify', true, $form, $entry ) ) {
     2612        if ( apply_filters( self::$author . '_gravityforms_payping_verify', true, $form, $entry ) ) {
    25972613            GFPersian_Payments::notification( $form, $entry );
    25982614            GFPersian_Payments::confirmation(  $form, $entry, $duplicate ? 'پرداخت قبلاً تأیید شده بود.' : '' );
Note: See TracChangeset for help on using the changeset viewer.