Changeset 3154426
- Timestamp:
- 09/19/2024 10:00:47 AM (19 months ago)
- Location:
- pmpro-discord-add-on
- Files:
-
- 144 added
- 4 edited
-
tags/1.2.21 (added)
-
tags/1.2.21/.gitignore (added)
-
tags/1.2.21/CHANGELOG.txt (added)
-
tags/1.2.21/README.md (added)
-
tags/1.2.21/assets (added)
-
tags/1.2.21/assets/css (added)
-
tags/1.2.21/assets/css/ets-pmpro-discord-style.css (added)
-
tags/1.2.21/assets/css/ets-pmpro-discord-style.min.css (added)
-
tags/1.2.21/assets/css/skeletabs.css (added)
-
tags/1.2.21/assets/images (added)
-
tags/1.2.21/assets/images/ets-logo.png (added)
-
tags/1.2.21/assets/images/icon.png (added)
-
tags/1.2.21/assets/images/ravisoni.png (added)
-
tags/1.2.21/assets/images/spinner.gif (added)
-
tags/1.2.21/assets/images/user-original.png (added)
-
tags/1.2.21/assets/js (added)
-
tags/1.2.21/assets/js/ets-pmpro-add-discord-script.js (added)
-
tags/1.2.21/assets/js/ets-pmpro-add-discord-script.min.js (added)
-
tags/1.2.21/assets/js/jquery.wordpress.js (added)
-
tags/1.2.21/assets/js/skeletabs.js (added)
-
tags/1.2.21/includes (added)
-
tags/1.2.21/includes/classes (added)
-
tags/1.2.21/includes/classes/class-discord-addon-admin-notices.php (added)
-
tags/1.2.21/includes/classes/class-discord-addon-logs.php (added)
-
tags/1.2.21/includes/classes/class-discord-addon-utils.php (added)
-
tags/1.2.21/includes/classes/class-discord-api.php (added)
-
tags/1.2.21/includes/classes/class-pmpro-discord-admin-setting.php (added)
-
tags/1.2.21/includes/functions.php (added)
-
tags/1.2.21/includes/pages (added)
-
tags/1.2.21/includes/pages/advanced.php (added)
-
tags/1.2.21/includes/pages/appearance.php (added)
-
tags/1.2.21/includes/pages/discord-role-level-map.php (added)
-
tags/1.2.21/includes/pages/discord-settings.php (added)
-
tags/1.2.21/includes/pages/documentation.php (added)
-
tags/1.2.21/includes/pages/error_log.php (added)
-
tags/1.2.21/includes/pages/get-support.php (added)
-
tags/1.2.21/includes/template (added)
-
tags/1.2.21/includes/template/notification (added)
-
tags/1.2.21/includes/template/notification/review (added)
-
tags/1.2.21/includes/template/notification/review/review.php (added)
-
tags/1.2.21/languages (added)
-
tags/1.2.21/languages/pmpro-discord.pot (added)
-
tags/1.2.21/libraries (added)
-
tags/1.2.21/libraries/action-scheduler (added)
-
tags/1.2.21/libraries/action-scheduler/README.md (added)
-
tags/1.2.21/libraries/action-scheduler/action-scheduler.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_ActionClaim.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_ActionFactory.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_AdminView.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_AsyncRequest_QueueRunner.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_Compatibility.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_DataController.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_DateTime.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_Exception.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_FatalErrorMonitor.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_InvalidActionException.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_ListTable.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_LogEntry.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_NullLogEntry.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_OptionLock.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_QueueCleaner.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_QueueRunner.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_Versions.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_WPCommentCleaner.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/ActionScheduler_wcSystemStatus.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/WP_CLI (added)
-
tags/1.2.21/libraries/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/WP_CLI/Migration_Command.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/WP_CLI/ProgressBar.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts/ActionScheduler.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts/ActionScheduler_Abstract_ListTable.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts/ActionScheduler_Abstract_RecurringSchedule.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts/ActionScheduler_Abstract_Schedule.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts/ActionScheduler_Abstract_Schema.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts/ActionScheduler_Lock.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts/ActionScheduler_Logger.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts/ActionScheduler_Store.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/abstracts/ActionScheduler_TimezoneHelper.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/actions (added)
-
tags/1.2.21/libraries/action-scheduler/classes/actions/ActionScheduler_Action.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/actions/ActionScheduler_CanceledAction.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/actions/ActionScheduler_FinishedAction.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/actions/ActionScheduler_NullAction.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/data-stores (added)
-
tags/1.2.21/libraries/action-scheduler/classes/data-stores/ActionScheduler_DBLogger.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/data-stores/ActionScheduler_HybridStore.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/data-stores/ActionScheduler_wpCommentLogger.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostStatusRegistrar.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_PostTypeRegistrar.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration/ActionMigrator.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration/BatchFetcher.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration/Config.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration/Controller.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration/DryRun_ActionMigrator.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration/DryRun_LogMigrator.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration/LogMigrator.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration/Runner.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/migration/Scheduler.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/schedules (added)
-
tags/1.2.21/libraries/action-scheduler/classes/schedules/ActionScheduler_CanceledSchedule.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/schedules/ActionScheduler_CronSchedule.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/schedules/ActionScheduler_IntervalSchedule.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/schedules/ActionScheduler_NullSchedule.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/schedules/ActionScheduler_Schedule.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/schedules/ActionScheduler_SimpleSchedule.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/schema (added)
-
tags/1.2.21/libraries/action-scheduler/classes/schema/ActionScheduler_LoggerSchema.php (added)
-
tags/1.2.21/libraries/action-scheduler/classes/schema/ActionScheduler_StoreSchema.php (added)
-
tags/1.2.21/libraries/action-scheduler/deprecated (added)
-
tags/1.2.21/libraries/action-scheduler/deprecated/ActionScheduler_Abstract_QueueRunner_Deprecated.php (added)
-
tags/1.2.21/libraries/action-scheduler/deprecated/ActionScheduler_AdminView_Deprecated.php (added)
-
tags/1.2.21/libraries/action-scheduler/deprecated/ActionScheduler_Schedule_Deprecated.php (added)
-
tags/1.2.21/libraries/action-scheduler/deprecated/ActionScheduler_Store_Deprecated.php (added)
-
tags/1.2.21/libraries/action-scheduler/deprecated/functions.php (added)
-
tags/1.2.21/libraries/action-scheduler/functions.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib (added)
-
tags/1.2.21/libraries/action-scheduler/lib/WP_Async_Request.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/CronExpression.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/CronExpression_AbstractField.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/CronExpression_DayOfMonthField.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/CronExpression_DayOfWeekField.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/CronExpression_FieldFactory.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/CronExpression_FieldInterface.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/CronExpression_HoursField.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/CronExpression_MinutesField.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/CronExpression_MonthField.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/CronExpression_YearField.php (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/LICENSE (added)
-
tags/1.2.21/libraries/action-scheduler/lib/cron-expression/README.md (added)
-
tags/1.2.21/libraries/action-scheduler/license.txt (added)
-
tags/1.2.21/license.txt (added)
-
tags/1.2.21/pmpro-discord.php (added)
-
tags/1.2.21/readme.txt (added)
-
tags/1.2.21/uninstall.php (added)
-
trunk/CHANGELOG.txt (modified) (1 diff)
-
trunk/includes/classes/class-discord-api.php (modified) (7 diffs)
-
trunk/pmpro-discord.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pmpro-discord-add-on/trunk/CHANGELOG.txt
r3139125 r3154426 1 = 1.2.21 = 2 - Implemented Single Sign-On (SSO) feature with Discord - allowing users to authenticate via the "Connect with Discord" button without needing to manually create an account if one already exists 3 - Added logic to check if a member has already been added to the Discord guild to prevent duplicate additions - optimizing role management and avoiding unnecessary API calls 4 1 5 = 1.2.20 = 2 6 - Added handling for cases where Discord user email does not exist, ensuring a temporary email is used. -
pmpro-discord-add-on/trunk/includes/classes/class-discord-api.php
r3139125 r3154426 450 450 $guild_response = wp_remote_post( $guilds_memeber_api_url, $guild_args ); 451 451 452 $response_arr = json_decode( wp_remote_retrieve_body( $guild_response ), true ); 453 452 454 ets_pmpro_discord_log_api_response( $user_id, $guilds_memeber_api_url, $guild_args, $guild_response ); 453 455 if ( ets_pmpro_discord_check_api_errors( $guild_response ) ) { … … 460 462 461 463 update_user_meta( $user_id, '_ets_pmpro_discord_role_id', $discord_role ); 464 462 465 if ( $discord_role && $discord_role != 'none' && isset( $user_id ) ) { 463 466 $this->put_discord_role_api( $user_id, $discord_role ); … … 636 639 wp_signon( $credentials, '' ); 637 640 $discord_user_id = sanitize_text_field( trim( get_user_meta( $user_id, '_ets_pmpro_discord_user_id', true ) ) ); 638 $this->add_discord_member_in_guild( $discord_user_id, $user_id, $access_token ); 641 642 //Do not call add member to guild if the member is connected via discord, check for usermeta. 643 $last_joined_date = trim( get_user_meta( $user_id, '_ets_pmpro_discord_join_date', true) ); 644 645 if(!$last_joined_date){ 646 $this->add_discord_member_in_guild( $discord_user_id, $user_id, $access_token ); 647 } 639 648 if ( $_COOKIE['ets_discord_page'] ) { 640 649 wp_safe_redirect( urldecode_deep( $_COOKIE['ets_discord_page'] ) ); … … 657 666 $access_token = sanitize_text_field( trim( $res_body['access_token'] ) ); 658 667 update_user_meta( $user_id, '_ets_pmpro_discord_access_token', $access_token ); 668 659 669 if ( array_key_exists( 'refresh_token', $res_body ) ) { 660 670 $refresh_token = sanitize_text_field( trim( $res_body['refresh_token'] ) ); 661 671 update_user_meta( $user_id, '_ets_pmpro_discord_refresh_token', $refresh_token ); 662 672 } 673 663 674 if ( array_key_exists( 'expires_in', $res_body ) ) { 664 675 $expires_in = $res_body['expires_in']; … … 668 679 update_user_meta( $user_id, '_ets_pmpro_discord_expires_in', $token_expiry_time ); 669 680 } 681 670 682 $user_body = $this->get_discord_current_user( $access_token ); 671 683 … … 676 688 update_user_meta( $user_id, '_ets_pmpro_discord_username', $discord_user_name_with_number ); 677 689 } 690 678 691 if ( is_array( $user_body ) && array_key_exists( 'id', $user_body ) ) { 679 692 $_ets_pmpro_discord_user_id = sanitize_text_field( trim( $user_body['id'] ) ); 680 if ( $discord_exist_user_id == $_ets_pmpro_discord_user_id ) { 693 694 if ( $discord_exist_user_id == $_ets_pmpro_discord_user_id ) { 681 695 $_ets_pmpro_discord_role_id = sanitize_text_field( trim( get_user_meta( $user_id, '_ets_pmpro_discord_role_id', true ) ) ); 682 if ( ! empty( $_ets_pmpro_discord_role_id ) && $_ets_pmpro_discord_role_id != 'none' ) { 696 697 // Get the expected role based on the current membership level 698 $expected_role_id = $this->get_expected_discord_role( $user_id ); 699 700 // Only delete and reassign if the current role doesn't match the expected role 701 if ( !empty($_ets_pmpro_discord_role_id) && $_ets_pmpro_discord_role_id != 'none' && $_ets_pmpro_discord_role_id != $expected_role_id ) { 683 702 $this->delete_discord_role( $user_id, $_ets_pmpro_discord_role_id ); 684 703 } 685 704 } 705 706 // Update the user meta with the Discord user ID 686 707 update_user_meta( $user_id, '_ets_pmpro_discord_user_id', $_ets_pmpro_discord_user_id ); 687 708 } 688 689 } 709 } 710 711 /* 712 * Function to get the expected Discord role based on the user's current membership level 713 */ 714 private function get_expected_discord_role( $user_id ) { 715 $current_membership_level_id = pmpro_getMembershipLevelForUser( $user_id )->ID; 716 $role_mapping = json_decode( get_option( 'ets_pmpor_discord_role_mapping' ), true ); 717 718 if ( isset( $role_mapping['pmpro_level_id_' . $current_membership_level_id] ) ) { 719 return sanitize_text_field( $role_mapping['pmpro_level_id_' . $current_membership_level_id] ); 720 } 721 return 'none'; 722 } 723 724 690 725 691 726 /** … … 746 781 delete_user_meta( $user_id, '_ets_pmpro_discord_username' ); 747 782 delete_user_meta( $user_id, '_ets_pmpro_discord_expires_in' ); 783 delete_user_meta( $user_id, '_ets_pmpro_discord_join_date' ); 748 784 749 785 } -
pmpro-discord-add-on/trunk/pmpro-discord.php
r3139125 r3154426 4 4 * Plugin URI: https://www.expresstechsoftwares.com/step-by-step-documentation-guide-on-how-to-connect-pmpro-and-discord-server-using-discord-addon 5 5 * Description: Connect your PaidMebershipPro site to your discord server, enable your members to be part of your community. 6 * Version: 1.2.2 06 * Version: 1.2.21 7 7 * Author: ExpressTech Software Solutions Pvt. Ltd., Strangers Studios 8 8 * Author URI: https://www.expresstechsoftwares.com … … 15 15 16 16 // create plugin version constant. 17 define( 'ETS_PMPRO_VERSION', '1.2.2 0' );17 define( 'ETS_PMPRO_VERSION', '1.2.21' ); 18 18 19 19 // create plugin url constant. -
pmpro-discord-add-on/trunk/readme.txt
r3139125 r3154426 8 8 Tested up to: 6.5 9 9 Requires PHP: 7.0 10 Stable tag: 1.2.2 010 Stable tag: 1.2.21 11 11 License: GPLv2 12 12 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.