クラス
MemberEditPage
説明 説明
Syncing will allow a user to login to their Welcart account by logging in with their Amazon account. Unsyncing will disallow this feature.
By default, users who created their Welcart account via their Amazon account will have sync turned on, while users who created their Welcart account via the default signup page will have to manually sync their Amazon account. Again, this feature only works if the Welcart account email and Amazon account email are the same.
ファイル: src/Views/MemberEditPage/MemberEditPage.php
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | class MemberEditPage { const COMP_JS_SLUG = 'wcexaap-login-option-component' ; /** * AmazonPay module instance * * @var AmazonPay */ public $module ; /** * Sets `$module` member var with dependency injection. * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param AmazonPay $module */ public function __construct(AmazonPay $module ) { $this ->module = $module ; } /** * Register hook for adding sync option field to member page * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return void */ public function init() { add_filter( 'usces_filter_apply_addressform' , [ $this , 'allowLoginSetting' ], 10, 3); } /** * Prepends Amazon allow login option to member information edit table * * @author Evan D Shaw <evandanielshaw@gmail.com> * @global \usc_e_shop $usces * @param string $formtag * @param string $type * @param string $data * @return string */ public function allowLoginSetting( $formtag , $type , $data ) { global $usces ; $url = '' ; if (isset( $_SERVER [ 'REQUEST_URI' ])) { $url = esc_url_raw(wp_unslash( $_SERVER [ 'REQUEST_URI' ])); } if (! $usces ->is_member_page( $url )) { return $formtag ; } if (! $usces ->is_member_logged_in()) { return $formtag ; } $semantic = new Semantic(); $semantic ->loadButtonCss(); $semantic ->loadLoaderCss(); $semantic ->loadIconCss(); $semantic ->loadTransitionCss(); $semantic ->loadPopupCss(); $semantic ->loadSemanticJS(); wp_enqueue_script( self::COMP_JS_SLUG, WCEXAAP_PLUGIN_URL . '/dist/amazonSyncLogin.js' , [Semantic::JS_SLUG], WCEXAAP_VERSION, true ); wp_set_script_translations(self::COMP_JS_SLUG, 'wcexaap' , WCEXAAP_LANGDIR); wp_localize_script( self::COMP_JS_SLUG, AmazonPay::L10N, array_merge ( $this ->module->getScriptInjectionVariables(), [ 'synced' => ( new MemberMeta((int) $_SESSION [ 'usces_member' ][ 'ID' ]))->getAllowAmazonToWelcartLogin(), ] ) ); return '<div id="' . AmazonPay::VUE_APP_MOUNT_EL . '"></div>' . $formtag ; } } |
- __construct — Sets `$module` member var with dependency injection.
- allowLoginSetting — Prepends Amazon allow login option to member information edit table
- init — Register hook for adding sync option field to member page