Changeset 2835905
- Timestamp:
- 12/19/2022 09:13:32 AM (3 years ago)
- Location:
- easy-digital-downloads-putler-connector/trunk
- Files:
-
- 2 added
- 5 edited
-
classes/class-putler-connector.php (modified) (33 diffs)
-
classes/class-putler-edd-connector-db.php (modified) (3 diffs)
-
classes/class-putler-edd-connector-json.php (modified) (20 diffs)
-
edd-putler-connector.php (modified) (6 diffs)
-
languages (added)
-
languages/easy-digital-downloads-putler-connector.pot (added)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easy-digital-downloads-putler-connector/trunk/classes/class-putler-connector.php
r2820426 r2835905 1 1 <?php 2 /** 3 * Class for Putler connector. 4 * 5 * @package easy-digital-downloads-putler-connector/classes/ 6 * @version 1.0.0 7 */ 8 2 9 if ( ! defined( 'ABSPATH' ) ) { 3 10 exit; … … 6 13 if ( ! class_exists( 'Putler_Connector' ) ) { 7 14 15 /** 16 * Putler Connector class. 17 */ 8 18 class Putler_Connector { 9 19 20 /** 21 * Email address. 22 * 23 * @var string $email_address 24 */ 10 25 private $email_address = ''; 26 27 /** 28 * The API token. 29 * 30 * @var string $api_token 31 */ 11 32 private $api_token = ''; 33 34 /** 35 * The version number. 36 * 37 * @var float $version 38 */ 12 39 private $version; 40 41 /** 42 * API URL. 43 * 44 * @var string $api_url 45 */ 13 46 private $api_url; 47 48 /** 49 * Setting URL. 50 * 51 * @var string $settings_url 52 */ 14 53 public $settings_url; 15 54 55 /** 56 * Variable to hold instance of Putler_Connector 57 * 58 * @var $instance 59 */ 16 60 protected static $instance = null; 17 61 … … 53 97 } 54 98 55 // Show a message when no web tokens found 99 // Show a message when no web tokens found. 56 100 if ( empty( $this->api_token ) && ! empty( $settings ) ) { 57 101 add_action( 'admin_notices', array( $this, 'putler_desktop_deprecated' ) ); … … 71 115 */ 72 116 public function get_plugin_info() { 73 74 $data = array( 75 'epc_version' => EPC_VERSION, 76 'edd_version' => EDD_VERSION, 117 wp_send_json( 118 array( 119 'epc_version' => EPC_VERSION, 120 'edd_version' => EDD_VERSION, 121 ) 77 122 ); 78 79 die( json_encode( $data ) );80 123 } 81 124 … … 84 127 */ 85 128 public function request_handler() { 86 $url_path = basename( trim( parse_url( add_query_arg( array() ), PHP_URL_PATH ), '/' ) );129 $url_path = basename( trim( wp_parse_url( add_query_arg( array() ), PHP_URL_PATH ), '/' ) ); 87 130 88 131 if ( 'ptwp-putler-connector' === $url_path ) { 89 $method_name = ( ! empty( $_REQUEST['action'] ) ) ? trim( sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) ) : ''; 132 $method_name = ( ! empty( $_REQUEST['action'] ) ) ? trim( sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification 90 133 91 134 if ( ! empty( $method_name ) && is_callable( array( $this, $method_name ) ) ) { … … 100 143 public function putler_desktop_deprecated() { 101 144 if ( empty( $this->api_token ) || empty( $this->email_address ) ) { 102 echo '<div id="putler_configure_message" class="updated fade error"><p>' . sprintf( __( 'Putler Connector for Putler desktop has deprecated. Please upgrade to %s.', 'easy-digital-downloads-putler-connector' ), '<strong><a href="https://web.putler.com/" target="_blank">Putler Web</a></strong>' ) . '</p></div>'; 145 /* translators: Putler URL */ 146 echo wp_kses_post( '<div id="putler_configure_message" class="updated fade error"><p>' . sprintf( __( 'Putler Connector for Putler desktop has deprecated. Please upgrade to <strong><a href="%s" target="_blank">Putler Web</a></strong>.', 'easy-digital-downloads-putler-connector' ), 'https://web.putler.com/' ) . '</p></div>' ); 103 147 } 104 148 } … … 122 166 case 'Alphanumeric': 123 167 for ( $i = 0; $i < $str_length; $i ++ ) { 124 $str_random .= $str_alphanumeric[ rand( 0, strlen( $str_alphanumeric ) - 1 ) ];168 $str_random .= $str_alphanumeric[ wp_rand( 0, strlen( $str_alphanumeric ) - 1 ) ]; 125 169 } 126 170 break; 127 171 case 'Alphabets': 128 172 for ( $i = 0; $i < $str_length; $i ++ ) { 129 $str_random .= $str_alphabet[ rand( 0, strlen( $str_alphabet ) - 1 ) ];173 $str_random .= $str_alphabet[ wp_rand( 0, strlen( $str_alphabet ) - 1 ) ]; 130 174 } 131 175 break; … … 178 222 } 179 223 180 if ( ( ! empty( $_REQUEST['action'] ) && PUTLER_GATEWAY_PREFIX . '_activate' === sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) ) || ( empty( $this->api_token ) || empty( $this->email_address ) ) ) { 224 if ( ( ! empty( $_REQUEST['action'] ) && PUTLER_GATEWAY_PREFIX . '_activate' === sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) ) || ( empty( $this->api_token ) || empty( $this->email_address ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification 181 225 $authenticate = 1; 182 226 } … … 185 229 $display_msg = __( 'Trying to Connect to Putler...', 'easy-digital-downloads-putler-connector' ); 186 230 } else { 187 if ( ! empty( $_REQUEST['post_activation'] ) ) { // For handling display of message post activation.231 if ( ! empty( sanitize_text_field( wp_unslash( $_REQUEST['post_activation'] ) ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification 188 232 $display_msg = __( 'Your transactions are getting synced with Putler. Please check after some time.', 'easy-digital-downloads-putler-connector' ); 189 233 } 190 234 } 191 235 192 echo '<div class="wrap" id="putler_connector_settings_page" style="font-size: 1.1em;"> 193 <h1>' . __( 'Putler Connector', 'easy-digital-downloads-putler-connector' ) . '</h1> <br/> 194 <div>' . wp_kses_post( $display_msg ) . '</div> 195 </div>'; 236 echo wp_kses_post( 237 '<div class="wrap" id="putler_connector_settings_page" style="font-size: 1.1em;"> 238 <h1>' . __( 'Putler Connector', 'weasy-digital-downloads-putler-connector' ) . '</h1> <br/> 239 <div>' . $display_msg . '</div> 240 </div>' 241 ); 196 242 197 243 if ( 1 === $authenticate ) { … … 206 252 207 253 $authenticate = 1; 208 if ( ! empty( $this->api_token ) && ! empty( $this->email_address ) ) { // for existing users 254 if ( ! empty( $this->api_token ) && ! empty( $this->email_address ) ) { // for existing users. 209 255 210 256 $result = $this->validate_api_info( $this->api_token, $this->email_address, 'validate', array( 'Site-URL' => site_url() ) ); … … 215 261 216 262 if ( ( ! empty( $result['response']['code'] ) && 200 === $result['response']['code'] ) && 217 ( ! empty( $res_body['ack'] ) && 'Success' === $res_body['ack'] ) ) {263 ( ! empty( $res_body['ack'] ) && 'Success' === $res_body['ack'] ) ) { 218 264 $authenticate = 0; 219 265 … … 244 290 245 291 <?php 246 247 // $msg = __('Authentication Failed.', 'easy-digital-downloads-putler-connector').' <a href="">Try again</a>';248 // $this->show_message($msg);249 292 exit; 250 293 } … … 262 305 263 306 <?php 264 // $msg = __('Authentication Failed.', 'easy-digital-downloads-putler-connector').' <a href="">Try again</a>';265 // $this->show_message($msg);266 307 exit; 267 308 } … … 278 319 } 279 320 280 // getting temp token 321 // getting temp token. 281 322 $result = $this->validate_api_info( $this->api_token, $this->email_address, 'get_temp_token', array( 'Site-URL' => site_url() ) ); 282 323 … … 286 327 287 328 if ( ( ! empty( $result['response']['code'] ) && 200 === $result['response']['code'] ) && 288 ( ! empty( $res_body['ack'] ) && 'Success' === $res_body['ack'] ) ) {329 ( ! empty( $res_body['ack'] ) && 'Success' === $res_body['ack'] ) ) { 289 330 290 331 $msg = __( 'Authenticating...', 'easy-digital-downloads-putler-connector' ); … … 315 356 316 357 if (current_timestamp - start_timestamp >= 30000) { 317 jQuery("#putler_connector_settings_page").html('<h1><?php echo __( 'Putler Connector', 'easy-digital-downloads-putler-connector' ); ?></h1>' +358 jQuery("#putler_connector_settings_page").html('<h1><?php echo esc_html__( 'Putler Connector', 'easy-digital-downloads-putler-connector' ); ?></h1>' + 318 359 '<br/>' + 319 360 '<div style="background: lightyellow;border: 0.2em solid #c5c593;border-radius: 0.2em;padding: 0.75em 1em;">' + … … 347 388 348 389 if ( empty( $existing_user ) ) { 349 $msg = __( 'Authentication Failed.', 'easy-digital-downloads-putler-connector' ) . '<br/> <br/> <div class="notice notice-error"> ' . __( 'Please make sure that you have added an ' . PUTLER_GATEWAY . ' account in Putler. If you do not have a Putler account, you can create one for free and enjoy trial for 14 days.', 'easy-digital-downloads-putler-connector' ) . ' <strong><i><a href="https://web.putler.com/#!/signup" target="_blank">' . __( 'Try Putler for free!', 'easy-digital-downloads-putler-connector' ) . '</a></i></strong>. <br/> <br/>' . __( 'Once the ' . PUTLER_GATEWAY . ' account has been added successfully, please click ', 'easy-digital-downloads-putler-connector') . '<a href="">' . __( 'here', 'easy-digital-downloads-putler-connector' ) . '.</a> </div>';390 $msg = __( 'Authentication Failed.', 'easy-digital-downloads-putler-connector' ) . '<br/> <br/> <div class="notice notice-error"> ' . sprintf( /* translators: %s: Name of ecommerce gateway */ esc_html__( 'Please make sure that you have added an %s account in Putler. If you do not have a Putler account, you can create one for free and enjoy trial for 14 days.', 'easy-digital-downloads-putler-connector' ), PUTLER_GATEWAY ) . ' <strong><i><a href="https://web.putler.com/#!/signup" target="_blank">' . __( 'Try Putler for free!', 'easy-digital-downloads-putler-connector' ) . '</a></i></strong>. <br/> <br/>' . sprintf( /* translators: %s: Name of ecommerce gateway */ esc_html__( 'Once the %s account has been added successfully, please click ', 'easy-digital-downloads-putler-connector' ), PUTLER_GATEWAY ) . '<a href="">' . __( 'here', 'easy-digital-downloads-putler-connector' ) . '.</a> </div>'; 350 391 } else { 351 392 $msg = __( 'Authentication Failed.', 'easy-digital-downloads-putler-connector' ) . ' ' . __( 'You would need to reset the account in ', 'easy-digital-downloads-putler-connector' ) . ' <strong><a href="https://web.putler.com/" target="_blank">' . __( 'Putler Web ', 'easy-digital-downloads-putler-connector' ) . '</a></strong>'; … … 379 420 } 380 421 } 381 382 ob_clean(); 383 echo json_encode( $response ); 384 die(); 422 wp_send_json( $response ); 385 423 } 386 424 … … 418 456 419 457 if ( ! ( ( ! empty( $result['response']['code'] ) && 200 === $result['response']['code'] ) && 420 ( ! empty( $res_body['ack'] ) && 'Success' === $res_body['ack'] ) ) ) {458 ( ! empty( $res_body['ack'] ) && 'Success' === $res_body['ack'] ) ) ) { 421 459 $msg = __( 'Authentication Failed.', 'easy-digital-downloads-putler-connector' ) . ' <a href="">Try again</a>'; 422 460 $this->show_message( $msg ); … … 434 472 $this->show_message( $msg ); 435 473 } 436 437 ob_clean(); 438 echo json_encode( $response ); 439 die(); 474 wp_send_json( $response ); 440 475 } 441 476 … … 456 491 ); 457 492 458 // save settings 493 // save settings. 459 494 $settings = array(); 460 495 461 $this->email_address = $settings['email_address'] = ( ! empty( $_SERVER['HTTP_X_PUTLER_EMAIL'] ) ) ? sanitize_email( wp_unslash( $_SERVER['HTTP_X_PUTLER_EMAIL'] ) ) : ''; 462 $this->api_token = $settings['api_token'] = ( ! empty( $_SERVER['HTTP_X_PUTLER_AUTH_TOKEN'] ) ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_PUTLER_AUTH_TOKEN'] ) ) : ''; 496 $this->email_address = ( ! empty( $_SERVER['HTTP_X_PUTLER_EMAIL'] ) ) ? sanitize_email( wp_unslash( $_SERVER['HTTP_X_PUTLER_EMAIL'] ) ) : ''; 497 $settings['email_address'] = $this->email_address; 498 $this->api_token = ( ! empty( $_SERVER['HTTP_X_PUTLER_AUTH_TOKEN'] ) ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_PUTLER_AUTH_TOKEN'] ) ) : ''; 499 $settings['api_token'] = $this->api_token; 463 500 464 501 $result = $this->validate_api_info( … … 478 515 479 516 if ( ( ! empty( $result['response']['code'] ) && 200 === $result['response']['code'] ) && 480 ( ! empty( $res_body['ack'] ) && 'Success' === $res_body['ack'] ) ) {517 ( ! empty( $res_body['ack'] ) && 'Success' === $res_body['ack'] ) ) { 481 518 482 519 delete_option( 'putler_connector_temp_token' ); … … 508 545 $this->show_message( $msg ); 509 546 } 510 511 ob_clean(); 512 echo json_encode( $response ); 513 die(); 547 wp_send_json( $response ); 514 548 } 515 549 … … 540 574 */ 541 575 private function validate_api_info( $token = '', $email = '', $action = '', $headers = array() ) { 542 // Validate with API server 576 // Validate with API server. 543 577 return wp_remote_post( 544 578 $this->api_url, … … 546 580 'headers' => array_merge( 547 581 array( 548 'Authorization' => 'Basic ' . base64_encode( $email . ':' . $token ), 582 'Authorization' => 'Basic ' . base64_encode( $email . ':' . $token ), // phpcs:ignore 549 583 'User-Agent' => 'Putler Connector/' . $this->version, 550 584 ), … … 599 633 */ 600 634 public function generate_valid_xml_from_array( $array = array(), $node_block = PUTLER_GATEWAY, $node_name = 'node' ) { 601 $xml = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";635 $xml = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n"; 602 636 $xml .= '<!--email_off--><' . $node_block . '>' . "\n"; 603 637 $xml .= $this->generate_xml_from_array( $array, $node_name ); … … 618 652 return false; 619 653 } 620 $auth = base64_decode( $code ); 654 $auth = base64_decode( $code ); // phpcs:ignore 621 655 $credentials = array(); 622 656 if ( ! empty( $auth ) ) { … … 628 662 return false; 629 663 } 630 if ( $email != $this->email_address || $token != $this->api_token ) {664 if ( $email !== $this->email_address || $token !== $this->api_token ) { 631 665 return false; 632 666 } … … 651 685 } 652 686 653 echo $this->generate_valid_xml_from_array( $response ); 687 echo $this->generate_valid_xml_from_array( $response ); // phpcs:ignore WordPress.Security.EscapeOutput 654 688 die; 655 689 } … … 662 696 /** 663 697 * Variable declaration 698 * 664 699 * @var $edd_putler_connector Putler_EDD_Connector_JSON 665 700 */ 666 $authentication_code = ( ! empty( $_REQUEST['AUTH'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['AUTH'] ) ) : ''; 701 $authentication_code = ( ! empty( $_REQUEST['AUTH'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['AUTH'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification 667 702 if ( ! $this->is_valid_request( $authentication_code ) ) { 668 703 $this->send_response( … … 674 709 } 675 710 676 if ( empty( $_REQUEST['STARTDATE'] ) || empty( $_REQUEST['ENDDATE'] ) ) {711 if ( empty( sanitize_text_field( wp_unslash( $_REQUEST['STARTDATE'] ) ) ) || empty( sanitize_text_field( wp_unslash( $_REQUEST['ENDDATE'] ) ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification 677 712 $this->send_response( 678 713 array( … … 682 717 ); 683 718 } 684 update_option( 'sa_' . PUTLER_GATEWAY_PREFIX . '_last_updated', current_time( 'Y-m-d H:i:s' ) ); // updating the last synced time 685 686 $offset = ( ! empty( $_REQUEST['OFFSET'] ) ) ? intval( sanitize_text_field( wp_unslash( $_REQUEST['OFFSET'] ) ) ) : 0; 687 $sub_offset = ( ! empty( $_REQUEST['SUBOFFSET'] ) ) ? intval( sanitize_text_field( wp_unslash( $_REQUEST['SUBOFFSET'] ) ) ) : 0; 688 $limit = ( ! empty( $_REQUEST['LIMIT'] ) ) ? intval( sanitize_text_field( wp_unslash( $_REQUEST['LIMIT'] ) ) ) : 100; 689 $type = ( ! empty( $_REQUEST['REQUESTTYPE'] ) ) ? strtolower( sanitize_text_field( wp_unslash( $_REQUEST['REQUESTTYPE'] ) ) ) : 'history'; 690 691 // Getting the data from ecommerce plugins 719 update_option( 'sa_' . PUTLER_GATEWAY_PREFIX . '_last_updated', current_time( 'Y-m-d H:i:s' ) ); // updating the last synced time. 720 721 $offset = ( ! empty( $_REQUEST['OFFSET'] ) ) ? intval( sanitize_text_field( wp_unslash( $_REQUEST['OFFSET'] ) ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification 722 $sub_offset = ( ! empty( $_REQUEST['SUBOFFSET'] ) ) ? intval( sanitize_text_field( wp_unslash( $_REQUEST['SUBOFFSET'] ) ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification 723 $limit = ( ! empty( $_REQUEST['LIMIT'] ) ) ? intval( sanitize_text_field( wp_unslash( $_REQUEST['LIMIT'] ) ) ) : 100; // phpcs:ignore WordPress.Security.NonceVerification 724 $type = ( ! empty( $_REQUEST['REQUESTTYPE'] ) ) ? strtolower( sanitize_text_field( wp_unslash( $_REQUEST['REQUESTTYPE'] ) ) ) : 'history'; // phpcs:ignore WordPress.Security.NonceVerification 725 726 // Getting the data from ecommerce plugins. 692 727 $params = array( 693 'start_date' => sanitize_text_field( wp_unslash( $_REQUEST['STARTDATE'] ) ), 694 'end_date' => sanitize_text_field( wp_unslash( $_REQUEST['ENDDATE'] ) ), 728 'start_date' => sanitize_text_field( wp_unslash( $_REQUEST['STARTDATE'] ) ), // phpcs:ignore WordPress.Security.NonceVerification 729 'end_date' => sanitize_text_field( wp_unslash( $_REQUEST['ENDDATE'] ) ), // phpcs:ignore WordPress.Security.NonceVerification 695 730 'offset' => $offset, 696 731 'sub_offset' => $sub_offset, … … 720 755 'OFFSET' => $offset, 721 756 ); 722 update_option( 'sa_' . PUTLER_GATEWAY_PREFIX . '_last_updated', current_time( 'Y-m-d H:i:s' ) ); // updating the last synced time 757 update_option( 'sa_' . PUTLER_GATEWAY_PREFIX . '_last_updated', current_time( 'Y-m-d H:i:s' ) ); // updating the last synced time. 723 758 } else { 724 759 $response = array( -
easy-digital-downloads-putler-connector/trunk/classes/class-putler-edd-connector-db.php
r2820426 r2835905 1 1 <?php 2 /** 3 * Class for handling the db updates. 4 * 5 * @package easy-digital-downloads-putler-connector/classes/ 6 * @version 1.0.0 7 */ 8 2 9 if ( ! defined( 'ABSPATH' ) ) { 3 10 exit; // Exit if accessed directly. … … 5 12 6 13 if ( ! class_exists( 'Putler_EDD_Connector_DB' ) ) { 14 15 /** 16 * Class Putler_EDD_Connector_DB 17 */ 7 18 class Putler_EDD_Connector_DB { 8 19 /** … … 15 26 // For multisite table prefix. 16 27 if ( is_multisite() ) { 17 $blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" ); 28 $blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" ); // WPCS: cache ok, db call ok. 18 29 foreach ( $blog_ids as $id ) { 19 30 if ( empty( $id ) ) { -
easy-digital-downloads-putler-connector/trunk/classes/class-putler-edd-connector-json.php
r2820426 r2835905 1 1 <?php 2 2 /** 3 * Handle all JSON related stuffs here. 3 * Class for handling the JSON API related mapping. 4 * 5 * @package easy-digital-downloads-putler-connector/classes/ 6 * @version 1.0.0 4 7 */ 5 8 … … 37 40 /** 38 41 * In EDD_Payment class, it does not contain modified_date. So to solve this, we are saving the modified date 42 * 39 43 * @var array 40 44 */ … … 43 47 /** 44 48 * Class Putler_EDD_Connector_JSON constructor 45 *46 49 */ 47 50 public function __construct() { … … 89 92 } 90 93 $current_time = time(); 91 $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->prefix}eddpc_subscription (subscription_id, modified_time) VALUES(%d, %d) ON DUPLICATE KEY UPDATE modified_time=%d", intval( $id ), $current_time, $current_time ) ); 94 $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->prefix}eddpc_subscription (subscription_id, modified_time) VALUES(%d, %d) ON DUPLICATE KEY UPDATE modified_time=%d", intval( $id ), $current_time, $current_time ) ); // WPCS: cache ok, db call ok. 92 95 } 93 96 … … 177 180 } 178 181 $all_orders = array(); 179 $start_date = date( 'Y-m-d H:i:s', $start_date_time );180 $end_date = date( 'Y-m-d H:i:s', $end_date_time );182 $start_date = $this->params['start_date']; 183 $end_date = $this->params['end_date']; 181 184 $offset = intval( $this->params['offset'] ); 182 185 $limit = intval( $this->params['limit'] ); … … 187 190 // Reason for using raw query: In EDD there are some limitations 188 191 // 1. edd_get_payments function return orders only based on created date. It does not return based on modified date. Also there is no option to do that. In our case we need only modified date. 192 $payments = array(); 189 193 if ( version_compare( '3.0', EDD_VERSION, '<' ) ) { 190 194 if ( 'history' === $request_type ) { 191 195 // For historical import, don't check in the notes. 192 $order_query = $wpdb->prepare( 193 "SELECT order_tbl.id as order_id,order_tbl.date_modified as order_modified,order_tbl.date_modified as note_modified FROM `{$wpdb->prefix}edd_orders` as order_tbl WHERE order_tbl.date_modified BETWEEN %s AND %s LIMIT %d OFFSET %d;", 194 array( 195 $start_date, 196 $end_date, 197 $limit, 198 $offset, 199 ) 200 ); 196 $payments = $wpdb->get_results( 197 $wpdb->prepare( 198 "SELECT order_tbl.id as order_id,order_tbl.date_modified as order_modified,order_tbl.date_modified as note_modified FROM `{$wpdb->prefix}edd_orders` as order_tbl WHERE order_tbl.date_modified BETWEEN %s AND %s LIMIT %d OFFSET %d;", 199 array( 200 $start_date, 201 $end_date, 202 $limit, 203 $offset, 204 ) 205 ), 206 OBJECT 207 ); // WPCS: cache ok, db call ok. 201 208 } else { 202 209 // For refresh import, do check in the notes tables also. 203 $order_query = $wpdb->prepare( 204 "SELECT order_tbl.id as order_id,order_tbl.date_modified as order_modified,MAX(notes_tbl.date_modified) as note_modified FROM `{$wpdb->prefix}edd_orders` as order_tbl INNER JOIN `{$wpdb->prefix}edd_notes` notes_tbl on order_tbl.id = notes_tbl.object_id AND (order_tbl.date_modified BETWEEN %s AND %s OR notes_tbl.date_modified BETWEEN %s AND %s) GROUP BY order_id LIMIT %d OFFSET %d;", 205 array( 206 $start_date, 207 $end_date, 208 $start_date, 209 $end_date, 210 $limit, 211 $offset, 212 ) 213 ); 210 $payments = $wpdb->get_results( 211 $wpdb->prepare( 212 "SELECT order_tbl.id as order_id,order_tbl.date_modified as order_modified,MAX(notes_tbl.date_modified) as note_modified FROM `{$wpdb->prefix}edd_orders` as order_tbl INNER JOIN `{$wpdb->prefix}edd_notes` notes_tbl on order_tbl.id = notes_tbl.object_id AND (order_tbl.date_modified BETWEEN %s AND %s OR notes_tbl.date_modified BETWEEN %s AND %s) GROUP BY order_id LIMIT %d OFFSET %d;", 213 array( 214 $start_date, 215 $end_date, 216 $start_date, 217 $end_date, 218 $limit, 219 $offset, 220 ) 221 ), 222 OBJECT 223 ); // WPCS: cache ok, db call ok. 214 224 } 215 225 } else { 216 226 if ( 'history' === $request_type ) { 217 227 // For historical import, don't check in the comments table. 218 $order_query = $wpdb->prepare( 219 "SELECT order_tbl.id as order_id,order_tbl.post_modified_gmt as order_modified,order_tbl.post_modified_gmt as note_modified FROM `{$wpdb->prefix}posts` as order_tbl WHERE order_tbl.post_type='edd_payment' AND order_tbl.post_modified_gmt BETWEEN %s AND %s LIMIT %d OFFSET %d;", 220 array( 221 $start_date, 222 $end_date, 223 $limit, 224 $offset, 225 ) 226 ); 228 $payments = $wpdb->get_results( 229 $wpdb->prepare( 230 "SELECT order_tbl.id as order_id,order_tbl.post_modified_gmt as order_modified,order_tbl.post_modified_gmt as note_modified FROM `{$wpdb->prefix}posts` as order_tbl WHERE order_tbl.post_type='edd_payment' AND order_tbl.post_modified_gmt BETWEEN %s AND %s LIMIT %d OFFSET %d;", 231 array( 232 $start_date, 233 $end_date, 234 $limit, 235 $offset, 236 ) 237 ), 238 OBJECT 239 ); // WPCS: cache ok, db call ok. 227 240 } else { 228 241 // For refresh import, do check in the comments tables also. 229 $order_query = $wpdb->prepare( 230 "SELECT order_tbl.ID as order_id,order_tbl.post_modified_gmt as order_modified,MAX(notes_tbl.comment_date_gmt) as note_modified FROM `{$wpdb->prefix}posts` as order_tbl INNER JOIN `{$wpdb->prefix}comments` notes_tbl on order_tbl.ID = notes_tbl.comment_post_ID AND order_tbl.post_type='edd_payment' AND (order_tbl.post_modified_gmt BETWEEN %s AND %s OR notes_tbl.comment_date_gmt BETWEEN %s AND %s) GROUP BY order_id LIMIT %d OFFSET %d;", 231 array( 232 $start_date, 233 $end_date, 234 $start_date, 235 $end_date, 236 $limit, 237 $offset, 238 ) 239 ); 240 } 241 } 242 $payments = $wpdb->get_results( $order_query, OBJECT ); 242 $payments = $wpdb->get_results( 243 $wpdb->prepare( 244 "SELECT order_tbl.ID as order_id,order_tbl.post_modified_gmt as order_modified,MAX(notes_tbl.comment_date_gmt) as note_modified FROM `{$wpdb->prefix}posts` as order_tbl INNER JOIN `{$wpdb->prefix}comments` notes_tbl on order_tbl.ID = notes_tbl.comment_post_ID AND order_tbl.post_type='edd_payment' AND (order_tbl.post_modified_gmt BETWEEN %s AND %s OR notes_tbl.comment_date_gmt BETWEEN %s AND %s) GROUP BY order_id LIMIT %d OFFSET %d;", 245 array( 246 $start_date, 247 $end_date, 248 $start_date, 249 $end_date, 250 $limit, 251 $offset, 252 ) 253 ), 254 OBJECT 255 ); // WPCS: cache ok, db call ok. 256 } 257 } 243 258 if ( ! empty( $payments ) && is_array( $payments ) ) { 244 259 foreach ( $payments as $payment ) { … … 412 427 $results = $wpdb->get_col( 413 428 $wpdb->prepare( 414 "SELECT option_value FROM `{$wpdb->prefix}options` WHERE option_name LIKE '_transient_eddpc_json_deleted_%'AND SUBSTRING_INDEX( option_name, '_transient_eddpc_json_deleted_', -1 ) between %d and %d;",429 "SELECT option_value FROM `{$wpdb->prefix}options` WHERE option_name LIKE %s AND SUBSTRING_INDEX( option_name, '_transient_eddpc_json_deleted_', -1 ) between %d and %d;", 415 430 array( 431 $wpdb->esc_like( '_transient_eddpc_json_deleted_' ) . '%', 416 432 $start_date_time, 417 433 $end_date_time, 418 434 ) 419 435 ) 420 ); 436 ); // WPCS: cache ok, db call ok. 421 437 422 438 if ( ! empty( $results ) ) { … … 451 467 return array(); 452 468 } 453 if ( in_array( $subscription_id, self::$processed_created_subscriptions ) ) {469 if ( in_array( $subscription_id, self::$processed_created_subscriptions, true ) ) { 454 470 return array(); 455 471 } … … 516 532 return array(); 517 533 } 518 if ( in_array( $subscription_id, self::$processed_meta_subscriptions ) ) {534 if ( in_array( $subscription_id, self::$processed_meta_subscriptions, true ) ) { 519 535 return array(); 520 536 } … … 792 808 ); 793 809 794 if ( $is_subscription_order && 'DELETE' != $this->get_order_status( $order ) ) {810 if ( $is_subscription_order && 'DELETE' !== $this->get_order_status( $order ) ) { 795 811 foreach ( $subscription_orders as $subscription ) { 796 812 $created_subscription = $this->format_subscription_created_meta_info( $subscription ); … … 865 881 return array(); 866 882 } 867 $modified_subscriptions = $wpdb->get_results( $wpdb->prepare( "SELECT subscription_id FROM {$wpdb->prefix}eddpc_subscription WHERE modified_time >= %d && modified_time <= %d", $start_date_time, $end_date_time ), ARRAY_A ); 883 $modified_subscriptions = $wpdb->get_results( $wpdb->prepare( "SELECT subscription_id FROM {$wpdb->prefix}eddpc_subscription WHERE modified_time >= %d && modified_time <= %d", $start_date_time, $end_date_time ), ARRAY_A ); // WPCS: cache ok, db call ok. 868 884 if ( empty( $modified_subscriptions ) ) { 869 885 return array(); … … 901 917 } 902 918 $used_coupons = array(); 903 if ( ! empty( $order->discounts ) && ! empty( $order->discounts ) && 'none' != $order->discounts ) {919 if ( ! empty( $order->discounts ) && ! empty( $order->discounts ) && 'none' !== $order->discounts ) { 904 920 $discount = $this->calculate_order_discounts( $order ); 905 921 // NOTE: EDD does not provide amount of each discount code and if more than … … 928 944 } 929 945 $discount = 0; 930 if ( ! empty( $order->discounts ) && 'none' != $order->discounts ) {946 if ( ! empty( $order->discounts ) && 'none' !== $order->discounts ) { 931 947 $cart_details = ( ! empty( $order->payment_meta['cart_details'] ) ) ? $order->payment_meta['cart_details'] : array(); 932 948 if ( is_array( $cart_details ) ) { … … 1140 1156 } 1141 1157 if ( ! empty( $subscription_orders ) ) { 1142 if ( ! in_array( $product_id, $all_subscription_product_ids ) && 'meta' === $type ) {1158 if ( ! in_array( $product_id, $all_subscription_product_ids, true ) && 'meta' === $type ) { 1143 1159 continue; 1144 1160 } … … 1185 1201 'handle' => ! empty( $product->post_name ) ? $product->post_name : null, 1186 1202 'status' => $this->get_product_status( $product ), 1187 'description' => null, // $product->get_description(),1203 'description' => null, 1188 1204 'quantity' => abs( ! empty( $line_item['quantity'] ) ? intval( $line_item['quantity'] ) : 0 ), 1189 1205 'discount' => $this->format_price( ! empty( $line_item['discount'] ) ? floatval( $line_item['discount'] ) : 0, 0 ), … … 1399 1415 $modified_date = null; 1400 1416 if ( version_compare( '3.0', EDD_VERSION, '<' ) ) { 1401 $customer_details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}edd_customers WHERE id = %d ", $customer->id ) ); 1417 $customer_details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}edd_customers WHERE id = %d ", $customer->id ) ); // WPCS: cache ok, db call ok. 1402 1418 if ( ! empty( $customer_details->date_modified ) ) { 1403 1419 $modified_date = $this->format_date( $customer_details->date_modified, null ); … … 1674 1690 if ( strtotime( $date_1 ) > strtotime( $date_2 ) ) { 1675 1691 return 1; 1676 } else if ( strtotime( $date_1 ) < strtotime( $date_2 ) ) {1692 } elseif ( strtotime( $date_1 ) < strtotime( $date_2 ) ) { 1677 1693 return - 1; 1678 1694 } else { … … 1819 1835 break; 1820 1836 default: 1821 if ( in_array( $order_status, $paid_order_statuses ) ) {1837 if ( in_array( $order_status, $paid_order_statuses, true ) ) { 1822 1838 $new_order_status = 'completed'; 1823 1839 } else { … … 1835 1851 * @param string $date date. 1836 1852 * @param string $default default value. 1837 * @param bool $convert_to_utc need to convert time to GMT?1853 * @param bool $convert_to_utc flag to determine whether convert time to GMT or not. 1838 1854 * @param string $format In which format do we need to convert. 1839 1855 * … … 1848 1864 } 1849 1865 if ( is_numeric( $date ) ) { 1850 return date( $format, $date ); 1851 } 1852 1853 return date( $format, strtotime( $date ) ); 1866 return date( $format, $date ); // phpcs:ignore 1867 } 1868 1869 return date( $format, strtotime( $date ) ); // phpcs:ignore 1854 1870 } 1855 1871 -
easy-digital-downloads-putler-connector/trunk/edd-putler-connector.php
r2820426 r2835905 1 1 <?php 2 2 /** 3 * Plugin Name: Easy Digital Downloads Putler Connector3 * Plugin Name: Putler Connector for Easy Digital Downloads 4 4 * Plugin URI: http://putler.com/connector/edd/ 5 5 * Description: Track Easy Digital Downloads transactions data with Putler. Insightful reporting that grows your business. … … 11 11 * License: GPL 3.0 12 12 * Copyright (c) 2016 - 2022 Putler. All rights reserved. 13 * 14 * @package easy-digital-downloads-putler-connector 13 15 */ 14 16 … … 21 23 } 22 24 23 include_once 'classes/class-putler-edd-connector-db.php';25 require_once 'classes/class-putler-edd-connector-db.php'; 24 26 25 27 register_activation_hook( __FILE__, 'eddpc_activate' ); … … 54 56 add_action( 'admin_notices', 'eddpc_admin_notices' ); 55 57 56 if ( ( ! in_array( 'woocommerce-putler-connector/woocommerce-putler-connector.php', $active_plugins ) && ! array_key_exists( 'woocommerce-putler-connector/woocommerce-putler-connector.php', $active_plugins ) )57 && ( ! in_array( 'jigoshop-putler-connector/jigoshop-putler-connector.php', $active_plugins) && ! array_key_exists( 'jigoshop-putler-connector/jigoshop-putler-connector.php', $active_plugins ) )58 && ( ! in_array( 'wp-e-commerce-putler-connector/wpec-putler-connector.php', $active_plugins) && ! array_key_exists( 'wp-e-commerce-putler-connector/wpec-putler-connector.php', $active_plugins ) ) ) {58 if ( ( ! in_array( 'woocommerce-putler-connector/woocommerce-putler-connector.php', $active_plugins, true ) && ! array_key_exists( 'woocommerce-putler-connector/woocommerce-putler-connector.php', $active_plugins ) ) 59 && ( ! in_array( 'jigoshop-putler-connector/jigoshop-putler-connector.php', $active_plugins, true ) && ! array_key_exists( 'jigoshop-putler-connector/jigoshop-putler-connector.php', $active_plugins ) ) 60 && ( ! in_array( 'wp-e-commerce-putler-connector/wpec-putler-connector.php', $active_plugins, true ) && ! array_key_exists( 'wp-e-commerce-putler-connector/wpec-putler-connector.php', $active_plugins ) ) ) { 59 61 60 62 $eddpc_notice_msg = ''; 61 63 62 if ( in_array( 'easy-digital-downloads/easy-digital-downloads.php', $active_plugins ) || array_key_exists( 'easy-digital-downloads/easy-digital-downloads.php', $active_plugins ) ) {64 if ( in_array( 'easy-digital-downloads/easy-digital-downloads.php', $active_plugins, true ) || array_key_exists( 'easy-digital-downloads/easy-digital-downloads.php', $active_plugins ) ) { 63 65 64 66 if ( ! defined( 'PUTLER_GATEWAY' ) ) { … … 80 82 } else { 81 83 $eddpc_notice_msg = '<div id="notice" class="error"><p>' . 82 '<b>' . __( ' Easy Digital Downloads Putler Connector', 'putler_connector' ) . '</b> ' . __( 'add-on requires', 'putler_connector' ) . ' <a href="https://wordpress.org/plugins/easy-digital-downloads/">' . __( 'Easy Digital Downloads', 'putler_connector' ) . '</a> ' . __( 'plugin. Please install and activate it.', 'putler_connector' ) .84 '<b>' . __( 'Putler Connector for Easy Digital Downloads', 'putler_connector' ) . '</b> ' . __( 'add-on requires', 'putler_connector' ) . ' <a href="https://wordpress.org/plugins/easy-digital-downloads/">' . __( 'Easy Digital Downloads', 'putler_connector' ) . '</a> ' . __( 'plugin. Please install and activate it.', 'putler_connector' ) . 83 85 '</p></div>'; 84 86 } … … 121 123 // Delete the redirect transient. 122 124 delete_option( '_eddpc_activation_redirect' ); 123 wp_ redirect( admin_url( 'tools.php?page=putler_connector&action=eddpc_activate' ) );125 wp_safe_redirect( admin_url( 'tools.php?page=putler_connector&action=eddpc_activate' ) ); 124 126 exit; 125 127 } -
easy-digital-downloads-putler-connector/trunk/readme.txt
r2820426 r2835905 1 === Easy Digital Downloads Putler Connector===1 === Putler Connector for Easy Digital Downloads === 2 2 Contributors: putler, storeapps 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CPTHCDC382KVA … … 19 19 20 20 **Get started within minutes** 21 Once activated, Easy Digital Downloads Putler Connectorsends past orders and subscriptions to Putler using Putler's Inbound API. Once the connection is made, future orders and subscriptions are sent to Putler automatically.21 Once activated, Putler Connector for Easy Digital Downloads sends past orders and subscriptions to Putler using Putler's Inbound API. Once the connection is made, future orders and subscriptions are sent to Putler automatically. 22 22 23 23 > **Note:** Keep in mind that you need a **Putler** account (Free or Paid), and a **Easy Digital Downloads** based store to use this plugin. [**Try Putler for free!**](https://web.putler.com/#!/signup) … … 159 159 == Changelog == 160 160 161 = 3.1.0 (19.12.2022) = 162 * New: WordPress Standards compatible 163 * New: POT file 164 161 165 = 3.0.0 (18.11.2022) = 162 166 * New: Easy Digital Downloads v3.1.0.2 compatible … … 226 230 == Upgrade Notice == 227 231 232 = 3.1.0 = 233 WordPress Standards compatible, POT file 234 228 235 = 3.0.0 = 229 236 Easy Digital Downloads v3.1.0.2 compatible, WordPress v6.1.1 compatible, Compatibility with latest Putler API
Note: See TracChangeset
for help on using the changeset viewer.