""> 100
+    <plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
101
+    <plugin name="cordova-plugin-ionic-webview" spec="^5.0.0" />
102
+    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
103
+</widget>

+ 4 - 1
ionic.config.json

@@ -1,7 +1,10 @@
1 1
 {
2 2
   "name": "farmr3",
3 3
   "integrations": {
4
-    "capacitor": {}
4
+    "capacitor": {
5
+      "enabled": false
6
+    },
7
+    "cordova": {}
5 8
   },
6 9
   "type": "angular"
7 10
 }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1698 - 17353
package-lock.json


+ 97 - 2
package.json

@@ -19,13 +19,43 @@
19 19
     "@angular/platform-browser": "~13.2.2",
20 20
     "@angular/platform-browser-dynamic": "~13.2.2",
21 21
     "@angular/router": "~13.2.2",
22
+    "@awesome-cordova-plugins/barcode-scanner": "^5.37.1",
23
+    "@awesome-cordova-plugins/core": "^5.37.1",
24
+    "@awesome-cordova-plugins/file-transfer": "^5.37.1",
25
+    "@awesome-cordova-plugins/native-geocoder": "^5.41.0",
26
+    "@awesome-cordova-plugins/push": "^5.37.1",
27
+    "@awesome-cordova-plugins/status-bar": "^5.37.2",
28
+    "@awesome-cordova-plugins/stripe": "^5.37.1",
22 29
     "@capacitor/app": "1.1.1",
23 30
     "@capacitor/core": "3.5.0",
24 31
     "@capacitor/haptics": "1.1.4",
32
+    "@capacitor/ios": "3.5.0",
25 33
     "@capacitor/keyboard": "1.2.2",
26 34
     "@capacitor/status-bar": "1.0.8",
35
+    "@fortawesome/angular-fontawesome": "^0.10.1",
36
+    "@fortawesome/fontawesome-free": "^5.15.4",
37
+    "@fortawesome/fontawesome-svg-core": "^1.2.36",
38
+    "@fortawesome/free-brands-svg-icons": "^5.15.4",
39
+    "@fortawesome/free-regular-svg-icons": "^5.15.4",
40
+    "@fortawesome/free-solid-svg-icons": "^5.15.4",
41
+    "@ionic-native/android-permissions": "^5.30.0",
42
+    "@ionic-native/call-number": "^5.36.0",
43
+    "@ionic-native/core": "^5.36.0",
44
+    "@ionic-native/device": "^5.30.0",
45
+    "@ionic-native/email-composer": "^5.36.0",
46
+    "@ionic-native/facebook": "^5.36.0",
47
+    "@ionic-native/geolocation": "^5.36.0",
48
+    "@ionic-native/http": "^5.36.0",
49
+    "@ionic-native/in-app-browser": "^5.36.0",
50
+    "@ionic-native/native-geocoder": "^5.36.0",
51
+    "@ionic-native/paypal": "^5.30.0",
52
+    "@ionic-native/push": "^5.36.0",
53
+    "@ionic-native/sign-in-with-apple": "^5.36.0",
54
+    "@ionic-native/uid": "^5.30.0",
27 55
     "@ionic/angular": "^6.0.0",
56
+    "@ionic/cordova-builders": "^6.1.0",
28 57
     "rxjs": "~6.6.0",
58
+    "sharp": "^0.30.4",
29 59
     "tslib": "^2.2.0",
30 60
     "zone.js": "~0.11.4"
31 61
   },
@@ -41,11 +71,36 @@
41 71
     "@angular/language-service": "~13.2.2",
42 72
     "@capacitor/cli": "3.5.0",
43 73
     "@ionic/angular-toolkit": "^6.0.0",
74
+    "@ionic/storage-angular": "^3.0.6",
44 75
     "@types/jasmine": "~3.6.0",
45 76
     "@types/jasminewd2": "~2.0.3",
46 77
     "@types/node": "^12.11.1",
47 78
     "@typescript-eslint/eslint-plugin": "5.3.0",
48 79
     "@typescript-eslint/parser": "5.3.0",
80
+    "cordova-ios": "^6.2.0",
81
+    "cordova-plugin-add-swift-support": "^2.0.2",
82
+    "cordova-plugin-advanced-http": "^3.2.2",
83
+    "cordova-plugin-android-permissions": "^1.1.2",
84
+    "cordova-plugin-androidx": "^3.0.0",
85
+    "cordova-plugin-androidx-adapter": "^1.1.3",
86
+    "cordova-plugin-device": "2.0.2",
87
+    "cordova-plugin-email-composer": "^0.10.0",
88
+    "cordova-plugin-facebook-connect": "^3.2.0",
89
+    "cordova-plugin-file": "^6.0.2",
90
+    "cordova-plugin-file-transfer": "^1.7.1",
91
+    "cordova-plugin-geolocation": "^4.1.0",
92
+    "cordova-plugin-googlemaps": "^2.7.1",
93
+    "cordova-plugin-googlemaps-sdk": "github:mapsplugin/cordova-plugin-googlemaps-sdk",
94
+    "cordova-plugin-inappbrowser": "^5.0.0",
95
+    "cordova-plugin-ionic-keyboard": "^2.2.0",
96
+    "cordova-plugin-ionic-webview": "^5.0.0",
97
+    "cordova-plugin-nativegeocoder": "^3.4.1",
98
+    "cordova-plugin-sign-in-with-apple": "^0.1.2",
99
+    "cordova-plugin-splashscreen": "5.0.2",
100
+    "cordova-plugin-statusbar": "2.4.2",
101
+    "cordova-plugin-stripe": "^1.5.3",
102
+    "cordova-plugin-uid": "^1.3.0",
103
+    "cordova-support-google-services": "^1.4.1",
49 104
     "eslint": "^7.6.0",
50 105
     "eslint-plugin-import": "2.22.1",
51 106
     "eslint-plugin-jsdoc": "30.7.6",
@@ -58,9 +113,49 @@
58 113
     "karma-coverage-istanbul-reporter": "~3.0.2",
59 114
     "karma-jasmine": "~4.0.0",
60 115
     "karma-jasmine-html-reporter": "^1.5.0",
116
+    "mx.ferreyra.callnumber": "0.0.2",
61 117
     "protractor": "~7.0.0",
62 118
     "ts-node": "~8.3.0",
63 119
     "typescript": "~4.4.4"
64 120
   },
65
-  "description": "An Ionic project"
66
-}
121
+  "description": "An Ionic project",
122
+  "cordova": {
123
+    "plugins": {
124
+      "cordova-plugin-statusbar": {},
125
+      "cordova-plugin-device": {},
126
+      "cordova-plugin-splashscreen": {},
127
+      "cordova-plugin-ionic-webview": {},
128
+      "cordova-plugin-ionic-keyboard": {},
129
+      "cordova-plugin-geolocation": {},
130
+      "cordova-plugin-nativegeocoder": {
131
+        "LOCATION_WHEN_IN_USE_DESCRIPTION": "Use geocoder service"
132
+      },
133
+      "mx.ferreyra.callnumber": {},
134
+      "cordova-plugin-email-composer": {},
135
+      "call-number": {},
136
+      "cordova-plugin-inappbrowser": {},
137
+      "cordova-plugin-sign-in-with-apple": {},
138
+      "cordova-plugin-androidx": {},
139
+      "cordova-plugin-androidx-adapter": {},
140
+      "phonegap-plugin-push": {},
141
+      "cordova-plugin-file-transfer": {},
142
+      "cordova-plugin-stripe": {},
143
+      "com.paypal.cordova.mobilesdk": {},
144
+      "cordova-plugin-facebook-connect": {
145
+        "APP_ID": "4746807965342529",
146
+        "APP_NAME": "FarmSter",
147
+        "FACEBOOK_URL_SCHEME_SUFFIX": " ",
148
+        "OTHER_APP_SCHEMES": " ",
149
+        "FACEBOOK_AUTO_LOG_APP_EVENTS": "true",
150
+        "FACEBOOK_HYBRID_APP_EVENTS": "false",
151
+        "FACEBOOK_ADVERTISER_ID_COLLECTION": "true",
152
+        "FACEBOOK_ANDROID_SDK_VERSION": "11.3.0",
153
+        "FACEBOOK_IOS_SDK_VERSION": "11.1.0",
154
+        "FACEBOOK_BROWSER_SDK_VERSION": "v11.0"
155
+      }
156
+    },
157
+    "platforms": [
158
+      "ios"
159
+    ]
160
+  }
161
+}

+ 8 - 0
resources/README.md

@@ -0,0 +1,8 @@
1
+These are Cordova resources. You can replace icon.png and splash.png and run
2
+`ionic cordova resources` to generate custom icons and splash screens for your
3
+app. See `ionic cordova resources --help` for details.
4
+
5
+Cordova reference documentation:
6
+
7
+- Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html
8
+- Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/

BIN
resources/android/icon/drawable-hdpi-icon.png


BIN
resources/android/icon/drawable-ldpi-icon.png


BIN
resources/android/icon/drawable-mdpi-icon.png


BIN
resources/android/icon/drawable-xhdpi-icon.png


BIN
resources/android/icon/drawable-xxhdpi-icon.png


BIN
resources/android/icon/drawable-xxxhdpi-icon.png


BIN
resources/android/splash/drawable-land-hdpi-screen.png


BIN
resources/android/splash/drawable-land-ldpi-screen.png


BIN
resources/android/splash/drawable-land-mdpi-screen.png


BIN
resources/android/splash/drawable-land-xhdpi-screen.png


BIN
resources/android/splash/drawable-land-xxhdpi-screen.png


BIN
resources/android/splash/drawable-land-xxxhdpi-screen.png


BIN
resources/android/splash/drawable-port-hdpi-screen.png


BIN
resources/android/splash/drawable-port-ldpi-screen.png


BIN
resources/android/splash/drawable-port-mdpi-screen.png


BIN
resources/android/splash/drawable-port-xhdpi-screen.png


BIN
resources/android/splash/drawable-port-xxhdpi-screen.png


BIN
resources/android/splash/drawable-port-xxxhdpi-screen.png


+ 7 - 0
resources/android/xml/network_security_config.xml

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<network-security-config>
3
+    <domain-config cleartextTrafficPermitted="true">
4
+        <domain includeSubdomains="true">localhost</domain>
5
+        <domain includeSubdomains="true">tamtime.iamarray.xyz</domain>
6
+    </domain-config>
7
+</network-security-config>

BIN
resources/icon.png


BIN
resources/ios/icon/icon-1024.png


BIN
resources/ios/icon/icon-108@2x.png


BIN
resources/ios/icon/icon-20.png


BIN
resources/ios/icon/icon-20@2x.png


BIN
resources/ios/icon/icon-20@3x.png


BIN
resources/ios/icon/icon-24@2x.png


BIN
resources/ios/icon/icon-27.5@2x.png


BIN
resources/ios/icon/icon-29.png


BIN
resources/ios/icon/icon-29@2x.png


BIN
resources/ios/icon/icon-29@3x.png


BIN
resources/ios/icon/icon-40.png


BIN
resources/ios/icon/icon-40@2x.png


BIN
resources/ios/icon/icon-40@3x.png


BIN
resources/ios/icon/icon-44@2x.png


BIN
resources/ios/icon/icon-50.png


BIN
resources/ios/icon/icon-50@2x.png


BIN
resources/ios/icon/icon-60.png


BIN
resources/ios/icon/icon-60@2x.png


BIN
resources/ios/icon/icon-60@3x.png


BIN
resources/ios/icon/icon-72.png


BIN
resources/ios/icon/icon-72@2x.png


BIN
resources/ios/icon/icon-76.png


BIN
resources/ios/icon/icon-76@2x.png


BIN
resources/ios/icon/icon-83.5@2x.png


BIN
resources/ios/icon/icon-86@2x.png


BIN
resources/ios/icon/icon-98@2x.png


BIN
resources/ios/icon/icon.png


BIN
resources/ios/icon/icon@2x.png


BIN
resources/ios/splash/Default-1792h~iphone.png


BIN
resources/ios/splash/Default-2436h.png


BIN
resources/ios/splash/Default-2688h~iphone.png


BIN
resources/ios/splash/Default-568h@2x~iphone.png


BIN
resources/ios/splash/Default-667h.png


BIN
resources/ios/splash/Default-736h.png


BIN
resources/ios/splash/Default-Landscape-1792h~iphone.png


BIN
resources/ios/splash/Default-Landscape-2436h.png


BIN
resources/ios/splash/Default-Landscape-2688h~iphone.png


BIN
resources/ios/splash/Default-Landscape-736h.png


BIN
resources/ios/splash/Default-Landscape@2x~ipad.png


BIN
resources/ios/splash/Default-Landscape@~ipadpro.png


BIN
resources/ios/splash/Default-Landscape~ipad.png


BIN
resources/ios/splash/Default-Portrait@2x~ipad.png


BIN
resources/ios/splash/Default-Portrait@~ipadpro.png


BIN
resources/ios/splash/Default-Portrait~ipad.png


BIN
resources/ios/splash/Default@2x~iphone.png


BIN
resources/ios/splash/Default@2x~universal~anyany.png


BIN
resources/ios/splash/Default~iphone.png


BIN
resources/splash.png


+ 76 - 0
src/app/app-routing.module.ts

@@ -5,6 +5,82 @@ const routes: Routes = [
5 5
   {
6 6
     path: '',
7 7
     loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule)
8
+  },
9
+  {
10
+    path: 'home',
11
+    loadChildren: () => import('./home/home.module').then( m => m.HomePageModule)
12
+  },
13
+  {
14
+    path: 'register',
15
+    loadChildren: () => import('./register/register.module').then( m => m.RegisterPageModule)
16
+  },
17
+  {
18
+    path: 'login',
19
+    loadChildren: () => import('./login/login.module').then( m => m.LoginPageModule)
20
+  },
21
+  {
22
+    path: 'forgot-password',
23
+    loadChildren: () => import('./forgot-password/forgot-password.module').then( m => m.ForgotPasswordPageModule)
24
+  },
25
+  {
26
+    path: 'register-form',
27
+    loadChildren: () => import('./register-form/register-form.module').then( m => m.RegisterFormPageModule)
28
+  },
29
+  {
30
+    path: 'profile',
31
+    loadChildren: () => import('./profile/profile.module').then( m => m.ProfilePageModule)
32
+  },
33
+  {
34
+    path: 'reset-password',
35
+    loadChildren: () => import('./reset-password/reset-password.module').then( m => m.ResetPasswordPageModule)
36
+  },
37
+  {
38
+    path: 'placedetail',
39
+    loadChildren: () => import('./placedetail/placedetail.module').then( m => m.PlacedetailPageModule)
40
+  },
41
+  {
42
+    path: 'place',
43
+    loadChildren: () => import('./place/place.module').then( m => m.PlacePageModule)
44
+  },
45
+  {
46
+    path: 'province',
47
+    loadChildren: () => import('./province/province.module').then( m => m.ProvincePageModule)
48
+  },
49
+  {
50
+    path: 'gmap',
51
+    loadChildren: () => import('./gmap/gmap.module').then( m => m.GmapPageModule)
52
+  },
53
+  {
54
+    path: 'nearme',
55
+    loadChildren: () => import('./nearme/nearme.module').then( m => m.NearmePageModule)
56
+  },
57
+  {
58
+    path: 'sample',
59
+    loadChildren: () => import('./sample/sample.module').then( m => m.SamplePageModule)
60
+  },
61
+  {
62
+    path: 'product',
63
+    loadChildren: () => import('./product/product.module').then( m => m.ProductPageModule)
64
+  },
65
+  {
66
+    path: 'product-detail',
67
+    loadChildren: () => import('./product-detail/product-detail.module').then( m => m.ProductDetailPageModule)
68
+  },
69
+  {
70
+    path: 'tracking',
71
+    loadChildren: () => import('./tracking/tracking.module').then( m => m.TrackingPageModule)
72
+  },
73
+  {
74
+    path: 'news',
75
+    loadChildren: () => import('./news/news.module').then( m => m.NewsPageModule)
76
+  },
77
+  {
78
+    path: 'checkout',
79
+    loadChildren: () => import('./checkout/checkout.module').then( m => m.CheckoutPageModule)
80
+  },
81
+  {
82
+    path: 'pay',
83
+    loadChildren: () => import('./pay/pay.module').then( m => m.PayPageModule)
8 84
   }
9 85
 ];
10 86
 @NgModule({

+ 4 - 0
src/app/app.component.scss

@@ -0,0 +1,4 @@
1
+.product-title {
2
+    font-weight:bold;
3
+    font-size:20px;
4
+}

+ 43 - 1
src/app/app.component.ts

@@ -1,4 +1,9 @@
1 1
 import { Component } from '@angular/core';
2
+import { Storage } from '@ionic/storage-angular';
3
+import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
4
+import { Uid } from '@ionic-native/uid/ngx';
5
+import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
6
+
2 7
 
3 8
 @Component({
4 9
   selector: 'app-root',
@@ -6,5 +11,42 @@ import { Component } from '@angular/core';
6 11
   styleUrls: ['app.component.scss'],
7 12
 })
8 13
 export class AppComponent {
9
-  constructor() {}
14
+    constructor(private storage: Storage, private statusBar:StatusBar, private uid: Uid, private androidPermissions: AndroidPermissions) {
15
+
16
+        this.statusBar.overlaysWebView(true);
17
+
18
+
19
+    }
20
+    openQRCode() {
21
+        console.log("open QR Code");
22
+    }
23
+    async ngOnInit() {
24
+        // If using a custom driver:
25
+        // await this.storage.defineDriver(MyCustomDriver)
26
+        await this.storage.create();
27
+        //await this.getImei();
28
+    }
29
+    async getImei() {
30
+        const { hasPermission } = await this.androidPermissions.checkPermission(
31
+            this.androidPermissions.PERMISSION.READ_PHONE_STATE
32
+        );
33
+        console.log(hasPermission);
34
+
35
+        if (!hasPermission) {
36
+            const result = await this.androidPermissions.requestPermission(
37
+                this.androidPermissions.PERMISSION.READ_PHONE_STATE
38
+            );
39
+
40
+            if (!result.hasPermission) {
41
+                throw new Error('Permissions required');
42
+            }
43
+
44
+            // ok, a user gave us permission, we can get him identifiers after restart app
45
+            return;
46
+        }
47
+        console.log("UUID");
48
+        console.log(this.uid.UUID);
49
+        await this.storage.set('uid', this.uid.UUID);
50
+        return this.uid.IMEI
51
+    }
10 52
 }

+ 66 - 6
src/app/app.module.ts

@@ -7,11 +7,71 @@ import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
7 7
 import { AppRoutingModule } from './app-routing.module';
8 8
 import { AppComponent } from './app.component';
9 9
 
10
+import { HttpClientModule, HttpClient} from '@angular/common/http';
11
+
12
+// import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
13
+// import { library } from '@fortawesome/fontawesome-svg-core';
14
+import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
15
+import { fas } from '@fortawesome/free-solid-svg-icons';
16
+import { far } from '@fortawesome/free-regular-svg-icons';
17
+import { fab } from '@fortawesome/free-brands-svg-icons';
18
+
19
+import { Geolocation } from '@ionic-native/geolocation/ngx';
20
+import { NativeGeocoder } from '@ionic-native/native-geocoder/ngx';
21
+
22
+import { CallNumber } from '@ionic-native/call-number/ngx';
23
+import { EmailComposer } from '@ionic-native/email-composer/ngx';
24
+import { HTTP } from '@ionic-native/http/ngx';
25
+import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
26
+
27
+import { IonicStorageModule } from '@ionic/storage-angular';
28
+import { SignInWithApple } from '@ionic-native/sign-in-with-apple/ngx';
29
+
30
+import { PipeModule } from './pipe/pipe.module';
31
+import { Facebook } from '@ionic-native/facebook/ngx';
32
+
33
+import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx';
34
+import { PayPal } from '@ionic-native/paypal/ngx';
35
+import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
36
+import { Uid } from '@ionic-native/uid/ngx';
37
+import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
38
+import { Device } from '@ionic-native/device/ngx';
39
+
40
+//import { Stripe } from '@awesome-cordova-plugins/stripe/ngx';
41
+
42
+
43
+// import { IonicImageViewerModule } from 'ionic-img-viewer';
44
+
45
+
46
+// library.add(fas,far,fab);
47
+
10 48
 @NgModule({
11
-  declarations: [AppComponent],
12
-  entryComponents: [],
13
-  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
14
-  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
15
-  bootstrap: [AppComponent],
49
+    declarations: [AppComponent],
50
+    entryComponents: [],
51
+    imports: [HttpClientModule, BrowserModule, PipeModule,IonicModule.forRoot({_forceStatusbarPadding: true}), AppRoutingModule, FontAwesomeModule,   IonicStorageModule.forRoot()],
52
+    providers: [
53
+        Geolocation,
54
+        NativeGeocoder,
55
+        CallNumber,
56
+        EmailComposer,
57
+        InAppBrowser,
58
+        HTTP,
59
+        Facebook, 
60
+        StatusBar,
61
+        BarcodeScanner,
62
+        SignInWithApple,
63
+        PayPal,
64
+        AndroidPermissions,
65
+        Uid,
66
+        Device,
67
+        //Stripe,
68
+        { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
69
+    ],
70
+    bootstrap: [AppComponent],
16 71
 })
17
-export class AppModule {}
72
+export class AppModule {
73
+    constructor(library: FaIconLibrary) {
74
+        library.addIconPacks(fas, fab, far);
75
+    }
76
+
77
+}

+ 17 - 0
src/app/checkout/checkout-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { CheckoutPage } from './checkout.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: CheckoutPage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class CheckoutPageRoutingModule {}

+ 20 - 0
src/app/checkout/checkout.module.ts

@@ -0,0 +1,20 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { CheckoutPageRoutingModule } from './checkout-routing.module';
8
+
9
+import { CheckoutPage } from './checkout.page';
10
+
11
+@NgModule({
12
+  imports: [
13
+    CommonModule,
14
+    FormsModule,
15
+    IonicModule,
16
+    CheckoutPageRoutingModule
17
+  ],
18
+  declarations: [CheckoutPage]
19
+})
20
+export class CheckoutPageModule {}

+ 81 - 0
src/app/checkout/checkout.page.html

@@ -0,0 +1,81 @@
1
+<ion-header>
2
+  <ion-toolbar class='new-background-color'>
3
+    <ion-title>Checkout</ion-title>
4
+      <ion-buttons slot="end">
5
+          <ion-button (click)="dismiss()" color="light">
6
+            <ion-icon name="close-circle-outline"></ion-icon>
7
+          </ion-button>
8
+      </ion-buttons>
9
+  </ion-toolbar>
10
+</ion-header>
11
+
12
+<ion-content>
13
+    <ion-list>
14
+        <ion-list-header>
15
+            Recent Items
16
+        </ion-list-header>
17
+
18
+        <ion-item-sliding>
19
+            <ion-item>
20
+            <ion-avatar slot="start">
21
+                <img src="assets/images/fresh-durian.jpeg">
22
+            </ion-avatar>
23
+            <ion-label>
24
+                <h2>Durian</h2>
25
+                <p>Size M</p>
26
+            </ion-label>
27
+            <ion-label slot='end'>
28
+                3 * 100.00 = 
29
+            </ion-label>
30
+            <ion-label slot='end'>
31
+                300.00 THB
32
+            </ion-label>
33
+            </ion-item>
34
+            <ion-item-options side="end">
35
+                <ion-item-option (click)="unread(item)" color='danger'>Remove</ion-item-option>
36
+            </ion-item-options>
37
+        </ion-item-sliding>
38
+        <ion-item>
39
+            <ion-avatar slot="start">
40
+                <img src="assets/images/fresh-durian.jpeg">
41
+            </ion-avatar>
42
+            <ion-label>
43
+                <h2>Durian</h2>
44
+                <p>Size M</p>
45
+            </ion-label>
46
+            <ion-label slot='end'>
47
+                3 * 100 = 
48
+            </ion-label>
49
+            <ion-label slot='end'>
50
+                300.00 THB
51
+            </ion-label>
52
+        </ion-item>
53
+        <ion-item>
54
+            <ion-label slot="end">
55
+                <h2>Sub Total = </h2>
56
+            </ion-label>
57
+            <ion-label slot='end'>
58
+               600.00 THB
59
+            </ion-label>
60
+        </ion-item>
61
+        <ion-item>
62
+            <ion-label slot="end">
63
+                <h2>Vat 7%  = </h2>
64
+            </ion-label>
65
+            <ion-label slot='end'>
66
+               42.00 THB
67
+            </ion-label>
68
+        </ion-item>
69
+        <ion-item>
70
+            <ion-label slot="end">
71
+                <h2>Total = </h2>
72
+            </ion-label>
73
+            <ion-label slot='end'>
74
+               642.00 THB
75
+            </ion-label>
76
+        </ion-item>
77
+    </ion-list>
78
+    <ion-button expand="full" color="success" (click)="payWithPaypal()">Pay with PayPal</ion-button>
79
+
80
+
81
+</ion-content>

+ 0 - 0
src/app/checkout/checkout.page.scss


+ 24 - 0
src/app/checkout/checkout.page.spec.ts

@@ -0,0 +1,24 @@
1
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+import { IonicModule } from '@ionic/angular';
3
+
4
+import { CheckoutPage } from './checkout.page';
5
+
6
+describe('CheckoutPage', () => {
7
+  let component: CheckoutPage;
8
+  let fixture: ComponentFixture<CheckoutPage>;
9
+
10
+  beforeEach(waitForAsync(() => {
11
+    TestBed.configureTestingModule({
12
+      declarations: [ CheckoutPage ],
13
+      imports: [IonicModule.forRoot()]
14
+    }).compileComponents();
15
+
16
+    fixture = TestBed.createComponent(CheckoutPage);
17
+    component = fixture.componentInstance;
18
+    fixture.detectChanges();
19
+  }));
20
+
21
+  it('should create', () => {
22
+    expect(component).toBeTruthy();
23
+  });
24
+});

+ 56 - 0
src/app/checkout/checkout.page.ts

@@ -0,0 +1,56 @@
1
+import { Component, OnInit } from '@angular/core';
2
+import { ModalController, Platform } from '@ionic/angular';
3
+import { PayPal, PayPalPayment, PayPalConfiguration } from '@ionic-native/paypal/ngx';
4
+
5
+@Component({
6
+    selector: 'app-checkout',
7
+    templateUrl: './checkout.page.html',
8
+    styleUrls: ['./checkout.page.scss'],
9
+})
10
+export class CheckoutPage implements OnInit {
11
+
12
+    constructor(public modalController: ModalController, private payPal: PayPal) { }
13
+
14
+    ngOnInit() {
15
+    }
16
+
17
+    dismiss() {
18
+        // using the injected ModalController this page
19
+        // can "dismiss" itself and optionally pass back data
20
+        this.modalController.dismiss({
21
+            'dismissed': true
22
+        });
23
+    }
24
+
25
+    paymentAmount: string = '640';
26
+    currency: string = 'USD';
27
+    currencyIcon: string = 'USD';
28
+
29
+    payWithPaypal() {
30
+        this.payPal.init({
31
+            PayPalEnvironmentProduction: 'YOUR_PRODUCTION_CLIENT_ID',
32
+            PayPalEnvironmentSandbox: 'AVszPxWCuK3FGXKlgOCFu3gVXr8lFkKj9z1wUo9BYdestZbGRg5vDqWm_pqlLkhEu8KHsjP8NmfPhc_o'
33
+        }).then(() => {
34
+            // Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
35
+            this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
36
+                // Only needed if you get an "Internal Service Error" after PayPal login!
37
+                //payPalShippingAddressOption: 2 // PayPalShippingAddressOptionPayPal
38
+            })).then(() => {
39
+                let payment = new PayPalPayment(this.paymentAmount, this.currency, 'Description', 'sale');
40
+                this.payPal.renderSinglePaymentUI(payment).then((res) => {
41
+                    console.log(res);
42
+                    // Successfully paid
43
+                }, (error) => {
44
+                    console.log(error);
45
+                    // Error or render dialog closed without being successful
46
+                });
47
+            }, (error) => {
48
+                console.log(error);
49
+                // Error in configuration
50
+            });
51
+        }, (error) => {
52
+            console.log(error);
53
+            // Error in initialization, maybe PayPal isn't supported or something else
54
+        });
55
+    }
56
+}

+ 3 - 1
src/app/explore-container/explore-container.component.html

@@ -1,4 +1,6 @@
1 1
 <div id="container">
2 2
   <strong>{{ name }}</strong>
3 3
   <p>Explore <a target="_blank" rel="noopener noreferrer" href="https://ionicframework.com/docs/components">UI Components</a></p>
4
-</div>
4
+</div>
5
+<ion-title size="large">wellnessroute.info</ion-title>
6
+  <ion-title size="large">แผนที่สุขภาพ</ion-title>

+ 17 - 0
src/app/forgot-password/forgot-password-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { ForgotPasswordPage } from './forgot-password.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: ForgotPasswordPage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class ForgotPasswordPageRoutingModule {}

+ 20 - 0
src/app/forgot-password/forgot-password.module.ts

@@ -0,0 +1,20 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { ForgotPasswordPageRoutingModule } from './forgot-password-routing.module';
8
+
9
+import { ForgotPasswordPage } from './forgot-password.page';
10
+
11
+@NgModule({
12
+  imports: [
13
+    CommonModule,
14
+    FormsModule,
15
+    IonicModule,
16
+    ForgotPasswordPageRoutingModule
17
+  ],
18
+  declarations: [ForgotPasswordPage]
19
+})
20
+export class ForgotPasswordPageModule {}

+ 37 - 0
src/app/forgot-password/forgot-password.page.html

@@ -0,0 +1,37 @@
1
+<ion-header>
2
+  <ion-toolbar class="new-background-color">
3
+    <ion-buttons slot="end">
4
+      <ion-button (click)="dismiss()" color="light">ปิด</ion-button>
5
+    </ion-buttons>
6
+    <div class="hcs">
7
+      <img src="/assets/images/wellnessbar.svg" height="50" />    
8
+    </div>
9
+  </ion-toolbar>
10
+</ion-header>
11
+<ion-content>
12
+  <div><img src="/assets/images/image-006.jpg"></div>
13
+  <ion-grid>
14
+    <ion-row>
15
+      <ion-col>
16
+        <div class="ion-text-center">
17
+          <h1>ลืมรหัสผ่าน</h1>
18
+        </div>
19
+      </ion-col>
20
+    </ion-row>
21
+    <form>
22
+      <ion-row>
23
+        <ion-col>
24
+          <ion-item lines="full">
25
+            <ion-label position="floating">อีเมล์</ion-label>
26
+            <ion-input type="email" name="email" [(ngModel)]="email" inputmode="email"></ion-input>
27
+          </ion-item>
28
+        </ion-col>
29
+      </ion-row>
30
+      <ion-row>
31
+        <ion-col>
32
+          <ion-button type="submit" color="danger" expand="block" (click)="resetPassword()">ส่งรหัสผ่าน</ion-button>
33
+        </ion-col>
34
+      </ion-row>
35
+    </form>
36
+  </ion-grid>
37
+</ion-content>

+ 0 - 0
src/app/forgot-password/forgot-password.page.scss


+ 24 - 0
src/app/forgot-password/forgot-password.page.spec.ts

@@ -0,0 +1,24 @@
1
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+import { IonicModule } from '@ionic/angular';
3
+
4
+import { ForgotPasswordPage } from './forgot-password.page';
5
+
6
+describe('ForgotPasswordPage', () => {
7
+  let component: ForgotPasswordPage;
8
+  let fixture: ComponentFixture<ForgotPasswordPage>;
9
+
10
+  beforeEach(waitForAsync(() => {
11
+    TestBed.configureTestingModule({
12
+      declarations: [ ForgotPasswordPage ],
13
+      imports: [IonicModule.forRoot()]
14
+    }).compileComponents();
15
+
16
+    fixture = TestBed.createComponent(ForgotPasswordPage);
17
+    component = fixture.componentInstance;
18
+    fixture.detectChanges();
19
+  }));
20
+
21
+  it('should create', () => {
22
+    expect(component).toBeTruthy();
23
+  });
24
+});

+ 36 - 0
src/app/forgot-password/forgot-password.page.ts

@@ -0,0 +1,36 @@
1
+import { Component, OnInit } from '@angular/core';
2
+import { ModalController } from '@ionic/angular';
3
+import { WpServiceService } from '../wp-service.service';
4
+
5
+@Component({
6
+    selector: 'app-forgot-password',
7
+    templateUrl: './forgot-password.page.html',
8
+    styleUrls: ['./forgot-password.page.scss'],
9
+})
10
+export class ForgotPasswordPage implements OnInit {
11
+
12
+    email = "";
13
+
14
+    constructor(public modalController: ModalController, private wp:WpServiceService) { }
15
+
16
+    ngOnInit() {
17
+    }
18
+
19
+    async resetPassword() {
20
+        if( this.email == "" ) {
21
+            alert("Please Enter Valid Email");
22
+            return;
23
+        }
24
+        let r = await this.wp.resetPassword(this.email);
25
+        alert(r.msg);
26
+    }
27
+
28
+    dismiss() {
29
+        // using the injected ModalController this page
30
+        // can "dismiss" itself and optionally pass back data
31
+        this.modalController.dismiss({
32
+            'dismissed': true
33
+        });
34
+    }
35
+
36
+}

+ 17 - 0
src/app/gmap/gmap-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { GmapPage } from './gmap.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: GmapPage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class GmapPageRoutingModule {}

+ 20 - 0
src/app/gmap/gmap.module.ts

@@ -0,0 +1,20 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { GmapPageRoutingModule } from './gmap-routing.module';
8
+
9
+import { GmapPage } from './gmap.page';
10
+
11
+@NgModule({
12
+  imports: [
13
+    CommonModule,
14
+    FormsModule,
15
+    IonicModule,
16
+    GmapPageRoutingModule
17
+  ],
18
+  declarations: [GmapPage]
19
+})
20
+export class GmapPageModule {}

+ 9 - 0
src/app/gmap/gmap.page.html

@@ -0,0 +1,9 @@
1
+<ion-header>
2
+  <ion-toolbar>
3
+    <ion-title>gmap</ion-title>
4
+  </ion-toolbar>
5
+</ion-header>
6
+
7
+<ion-content>..
8
+<div #map id="map"></div>
9
+</ion-content>

+ 3 - 0
src/app/gmap/gmap.page.scss

@@ -0,0 +1,3 @@
1
+#map {
2
+    height: 300px;
3
+}

+ 24 - 0
src/app/gmap/gmap.page.spec.ts

@@ -0,0 +1,24 @@
1
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+import { IonicModule } from '@ionic/angular';
3
+
4
+import { GmapPage } from './gmap.page';
5
+
6
+describe('GmapPage', () => {
7
+  let component: GmapPage;
8
+  let fixture: ComponentFixture<GmapPage>;
9
+
10
+  beforeEach(waitForAsync(() => {
11
+    TestBed.configureTestingModule({
12
+      declarations: [ GmapPage ],
13
+      imports: [IonicModule.forRoot()]
14
+    }).compileComponents();
15
+
16
+    fixture = TestBed.createComponent(GmapPage);
17
+    component = fixture.componentInstance;
18
+    fixture.detectChanges();
19
+  }));
20
+
21
+  it('should create', () => {
22
+    expect(component).toBeTruthy();
23
+  });
24
+});

+ 72 - 0
src/app/gmap/gmap.page.ts

@@ -0,0 +1,72 @@
1
+import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
2
+import { ActivatedRoute, Router } from '@angular/router';
3
+import { WpServiceService } from '../wp-service.service';
4
+import { Geolocation } from '@ionic-native/geolocation/ngx';
5
+import { NativeGeocoder, NativeGeocoderResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder/ngx';
6
+
7
+declare var google: any;
8
+
9
+@Component({
10
+  selector: 'app-gmap',
11
+  templateUrl: './gmap.page.html',
12
+  styleUrls: ['./gmap.page.scss'],
13
+})
14
+export class GmapPage implements OnInit {
15
+  @Input() id: string;
16
+  data: any;
17
+  placelist: any;
18
+  latdynamic: any;
19
+  londynamic: any;
20
+  xxx: any;
21
+  yyy: any;
22
+  placeL: any;
23
+  map: any;
24
+  // @ViewChild('map', { static: false }) mapElement: ElementRef;
25
+  @ViewChild('map', { static: true }) mapRef: ElementRef;
26
+  // @ViewChild('map', { static: false }) mapElement: ElementRef;
27
+
28
+
29
+  constructor(private wpservice: WpServiceService, private route: ActivatedRoute, private router: Router, private geolocation: Geolocation) { }
30
+
31
+  ngOnInit() {
32
+    this.showMap();
33
+    // this.loadMap() 
34
+    let id = this.route.snapshot.paramMap.get('id') || this.id;
35
+    this.wpservice.getPlaceDetail(173).subscribe((data) => {
36
+      this.placelist = data;
37
+      this.latdynamic = data['acf']['gmap']['lat'];
38
+      this.londynamic = data['acf']['gmap']['lng'];
39
+
40
+      console.log("load Place Detail ...");
41
+      console.log(this.latdynamic);
42
+      console.log("load Lati ...");
43
+      console.log(this.londynamic);
44
+      console.log("load Lon ...");
45
+      console.log(data);
46
+      let xxx = this.londynamic;
47
+      const yyy = this.latdynamic;
48
+    }, error => {
49
+      console.log("errror ", error);
50
+    });
51
+
52
+    let watch = this.geolocation.watchPosition();
53
+    watch.subscribe((data) => {
54
+      // data can be a set of coordinates, or an error (if an error occurred).
55
+      // data.coords.latitude
56
+      // data.coords.longitude
57
+      console.log(data);
58
+    });
59
+  }
60
+
61
+  showMap() {
62
+    let location = new google.maps.LatLng(13.7643439, 100.6899729);
63
+    let options = {
64
+      center: location,
65
+      zoom: 15,
66
+      disableDefaultUI: true
67
+    }
68
+    this.map = new google.maps.Map(this.mapRef.nativeElement, options);
69
+    //this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
70
+  }
71
+
72
+}

+ 17 - 0
src/app/home/home-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { HomePage } from './home.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: HomePage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class HomePageRoutingModule {}

+ 26 - 0
src/app/home/home.module.ts

@@ -0,0 +1,26 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { HomePageRoutingModule } from './home-routing.module';
8
+
9
+import { HomePage } from './home.page';
10
+import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
11
+import { IonSlides } from '@ionic/angular';
12
+
13
+import { PipeModule } from '../pipe/pipe.module';
14
+
15
+@NgModule({
16
+  imports: [
17
+    CommonModule,
18
+    FormsModule,
19
+    IonicModule,
20
+      PipeModule,
21
+    HomePageRoutingModule,
22
+    FontAwesomeModule
23
+  ],
24
+  declarations: [HomePage]
25
+})
26
+export class HomePageModule {}

+ 0 - 0
src/app/home/home.page.290921.html


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor

tum/whitesports - Gogs: Simplico Git Service

Nenhuma Descrição

class-wp-admin-bar.php 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <?php
  2. /**
  3. * Toolbar API: WP_Admin_Bar class
  4. *
  5. * @package WordPress
  6. * @subpackage Toolbar
  7. * @since 3.1.0
  8. */
  9. /**
  10. * Core class used to implement the Toolbar API.
  11. *
  12. * @since 3.1.0
  13. */
  14. class WP_Admin_Bar {
  15. private $nodes = array();
  16. private $bound = false;
  17. public $user;
  18. /**
  19. * @param string $name
  20. * @return string|array|void
  21. */
  22. public function __get( $name ) {
  23. switch ( $name ) {
  24. case 'proto':
  25. return is_ssl() ? 'https://' : 'http://';
  26. case 'menu':
  27. _deprecated_argument( 'WP_Admin_Bar', '3.3.0', 'Modify admin bar nodes with WP_Admin_Bar::get_node(), WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(), not the <code>menu</code> property.' );
  28. return array(); // Sorry, folks.
  29. }
  30. }
  31. /**
  32. */
  33. public function initialize() {
  34. $this->user = new stdClass;
  35. if ( is_user_logged_in() ) {
  36. /* Populate settings we need for the menu based on the current user. */
  37. $this->user->blogs = get_blogs_of_user( get_current_user_id() );
  38. if ( is_multisite() ) {
  39. $this->user->active_blog = get_active_blog_for_user( get_current_user_id() );
  40. $this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
  41. $this->user->account_domain = $this->user->domain;
  42. } else {
  43. $this->user->active_blog = $this->user->blogs[ get_current_blog_id() ];
  44. $this->user->domain = trailingslashit( home_url() );
  45. $this->user->account_domain = $this->user->domain;
  46. }
  47. }
  48. add_action( 'wp_head', 'wp_admin_bar_header' );
  49. add_action( 'admin_head', 'wp_admin_bar_header' );
  50. if ( current_theme_supports( 'admin-bar' ) ) {
  51. /**
  52. * To remove the default padding styles from WordPress for the Toolbar, use the following code:
  53. * add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
  54. */
  55. $admin_bar_args = get_theme_support( 'admin-bar' );
  56. $header_callback = $admin_bar_args[0]['callback'];
  57. }
  58. if ( empty( $header_callback ) ) {
  59. $header_callback = '_admin_bar_bump_cb';
  60. }
  61. add_action( 'wp_head', $header_callback );
  62. wp_enqueue_script( 'admin-bar' );
  63. wp_enqueue_style( 'admin-bar' );
  64. /**
  65. * Fires after WP_Admin_Bar is initialized.
  66. *
  67. * @since 3.1.0
  68. */
  69. do_action( 'admin_bar_init' );
  70. }
  71. /**
  72. * Add a node (menu item) to the Admin Bar menu.
  73. *
  74. * @since 3.3.0
  75. *
  76. * @param array $node The attributes that define the node.
  77. */
  78. public function add_menu( $node ) {
  79. $this->add_node( $node );
  80. }
  81. /**
  82. * Remove a node from the admin bar.
  83. *
  84. * @since 3.1.0
  85. *
  86. * @param string $id The menu slug to remove.
  87. */
  88. public function remove_menu( $id ) {
  89. $this->remove_node( $id );
  90. }
  91. /**
  92. * Adds a node to the menu.
  93. *
  94. * @since 3.1.0
  95. * @since 4.5.0 Added the ability to pass 'lang' and 'dir' meta data.
  96. *
  97. * @param array $args {
  98. * Arguments for adding a node.
  99. *
  100. * @type string $id ID of the item.
  101. * @type string $title Title of the node.
  102. * @type string $parent Optional. ID of the parent node.
  103. * @type string $href Optional. Link for the item.
  104. * @type bool $group Optional. Whether or not the node is a group. Default false.
  105. * @type array $meta Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir',
  106. * 'onclick', 'target', 'title', 'tabindex'. Default empty.
  107. * }
  108. */
  109. public function add_node( $args ) {
  110. // Shim for old method signature: add_node( $parent_id, $menu_obj, $args ).
  111. if ( func_num_args() >= 3 && is_string( $args ) ) {
  112. $args = array_merge( array( 'parent' => $args ), func_get_arg( 2 ) );
  113. }
  114. if ( is_object( $args ) ) {
  115. $args = get_object_vars( $args );
  116. }
  117. // Ensure we have a valid title.
  118. if ( empty( $args['id'] ) ) {
  119. if ( empty( $args['title'] ) ) {
  120. return;
  121. }
  122. _doing_it_wrong( __METHOD__, __( 'The menu ID should not be empty.' ), '3.3.0' );
  123. // Deprecated: Generate an ID from the title.
  124. $args['id'] = esc_attr( sanitize_title( trim( $args['title'] ) ) );
  125. }
  126. $defaults = array(
  127. 'id' => false,
  128. 'title' => false,
  129. 'parent' => false,
  130. 'href' => false,
  131. 'group' => false,
  132. 'meta' => array(),
  133. );
  134. // If the node already exists, keep any data that isn't provided.
  135. $maybe_defaults = $this->get_node( $args['id'] );
  136. if ( $maybe_defaults ) {
  137. $defaults = get_object_vars( $maybe_defaults );
  138. }
  139. // Do the same for 'meta' items.
  140. if ( ! empty( $defaults['meta'] ) && ! empty( $args['meta'] ) ) {
  141. $args['meta'] = wp_parse_args( $args['meta'], $defaults['meta'] );
  142. }
  143. $args = wp_parse_args( $args, $defaults );
  144. $back_compat_parents = array(
  145. 'my-account-with-avatar' => array( 'my-account', '3.3' ),
  146. 'my-blogs' => array( 'my-sites', '3.3' ),
  147. );
  148. if ( isset( $back_compat_parents[ $args['parent'] ] ) ) {
  149. list( $new_parent, $version ) = $back_compat_parents[ $args['parent'] ];
  150. _deprecated_argument( __METHOD__, $version, sprintf( 'Use <code>%s</code> as the parent for the <code>%s</code> admin bar node instead of <code>%s</code>.', $new_parent, $args['id'], $args['parent'] ) );
  151. $args['parent'] = $new_parent;
  152. }
  153. $this->_set_node( $args );
  154. }
  155. /**
  156. * @param array $args
  157. */
  158. final protected function _set_node( $args ) {
  159. $this->nodes[ $args['id'] ] = (object) $args;
  160. }
  161. /**
  162. * Gets a node.
  163. *
  164. * @param string $id
  165. * @return object|void Node.
  166. */
  167. final public function get_node( $id ) {
  168. $node = $this->_get_node( $id );
  169. if ( $node ) {
  170. return clone $node;
  171. }
  172. }
  173. /**
  174. * @param string $id
  175. * @return object|void
  176. */
  177. final protected function _get_node( $id ) {
  178. if ( $this->bound ) {
  179. return;
  180. }
  181. if ( empty( $id ) ) {
  182. $id = 'root';
  183. }
  184. if ( isset( $this->nodes[ $id ] ) ) {
  185. return $this->nodes[ $id ];
  186. }
  187. }
  188. /**
  189. * @return array|void
  190. */
  191. final public function get_nodes() {
  192. $nodes = $this->_get_nodes();
  193. if ( ! $nodes ) {
  194. return;
  195. }
  196. foreach ( $nodes as &$node ) {
  197. $node = clone $node;
  198. }
  199. return $nodes;
  200. }
  201. /**
  202. * @return array|void
  203. */
  204. final protected function _get_nodes() {
  205. if ( $this->bound ) {
  206. return;
  207. }
  208. return $this->nodes;
  209. }
  210. /**
  211. * Add a group to a toolbar menu node.
  212. *
  213. * Groups can be used to organize toolbar items into distinct sections of a toolbar menu.
  214. *
  215. * @since 3.3.0
  216. *
  217. * @param array $args {
  218. * Array of arguments for adding a group.
  219. *
  220. * @type string $id ID of the item.
  221. * @type string $parent Optional. ID of the parent node. Default 'root'.
  222. * @type array $meta Meta data for the group including the following keys:
  223. * 'class', 'onclick', 'target', and 'title'.
  224. * }
  225. */
  226. final public function add_group( $args ) {
  227. $args['group'] = true;
  228. $this->add_node( $args );
  229. }
  230. /**
  231. * Remove a node.
  232. *
  233. * @param string $id The ID of the item.
  234. */
  235. public function remove_node( $id ) {
  236. $this->_unset_node( $id );
  237. }
  238. /**
  239. * @param string $id
  240. */
  241. final protected function _unset_node( $id ) {
  242. unset( $this->nodes[ $id ] );
  243. }
  244. /**
  245. */
  246. public function render() {
  247. $root = $this->_bind();
  248. if ( $root ) {
  249. $this->_render( $root );
  250. }
  251. }
  252. /**
  253. * @return object|void
  254. */
  255. final protected function _bind() {
  256. if ( $this->bound ) {
  257. return;
  258. }
  259. // Add the root node.
  260. // Clear it first, just in case. Don't mess with The Root.
  261. $this->remove_node( 'root' );
  262. $this->add_node(
  263. array(
  264. 'id' => 'root',
  265. 'group' => false,
  266. )
  267. );
  268. // Normalize nodes: define internal 'children' and 'type' properties.
  269. foreach ( $this->_get_nodes() as $node ) {
  270. $node->children = array();
  271. $node->type = ( $node->group ) ? 'group' : 'item';
  272. unset( $node->group );
  273. // The Root wants your orphans. No lonely items allowed.
  274. if ( ! $node->parent ) {
  275. $node->parent = 'root';
  276. }
  277. }
  278. foreach ( $this->_get_nodes() as $node ) {
  279. if ( 'root' === $node->id ) {
  280. continue;
  281. }
  282. // Fetch the parent node. If it isn't registered, ignore the node.
  283. $parent = $this->_get_node( $node->parent );
  284. if ( ! $parent ) {
  285. continue;
  286. }
  287. // Generate the group class (we distinguish between top level and other level groups).
  288. $group_class = ( 'root' === $node->parent ) ? 'ab-top-menu' : 'ab-submenu';
  289. if ( 'group' === $node->type ) {
  290. if ( empty( $node->meta['class'] ) ) {
  291. $node->meta['class'] = $group_class;
  292. } else {
  293. $node->meta['class'] .= ' ' . $group_class;
  294. }
  295. }
  296. // Items in items aren't allowed. Wrap nested items in 'default' groups.
  297. if ( 'item' === $parent->type && 'item' === $node->type ) {
  298. $default_id = $parent->id . '-default';
  299. $default = $this->_get_node( $default_id );
  300. // The default group is added here to allow groups that are
  301. // added before standard menu items to render first.
  302. if ( ! $default ) {
  303. // Use _set_node because add_node can be overloaded.
  304. // Make sure to specify default settings for all properties.
  305. $this->_set_node(
  306. array(
  307. 'id' => $default_id,
  308. 'parent' => $parent->id,
  309. 'type' => 'group',
  310. 'children' => array(),
  311. 'meta' => array(
  312. 'class' => $group_class,
  313. ),
  314. 'title' => false,
  315. 'href' => false,
  316. )
  317. );
  318. $default = $this->_get_node( $default_id );
  319. $parent->children[] = $default;
  320. }
  321. $parent = $default;
  322. // Groups in groups aren't allowed. Add a special 'container' node.
  323. // The container will invisibly wrap both groups.
  324. } elseif ( 'group' === $parent->type && 'group' === $node->type ) {
  325. $container_id = $parent->id . '-container';
  326. $container = $this->_get_node( $container_id );
  327. // We need to create a container for this group, life is sad.
  328. if ( ! $container ) {
  329. // Use _set_node because add_node can be overloaded.
  330. // Make sure to specify default settings for all properties.
  331. $this->_set_node(
  332. array(
  333. 'id' => $container_id,
  334. 'type' => 'container',
  335. 'children' => array( $parent ),
  336. 'parent' => false,
  337. 'title' => false,
  338. 'href' => false,
  339. 'meta' => array(),
  340. )
  341. );
  342. $container = $this->_get_node( $container_id );
  343. // Link the container node if a grandparent node exists.
  344. $grandparent = $this->_get_node( $parent->parent );
  345. if ( $grandparent ) {
  346. $container->parent = $grandparent->id;
  347. $index = array_search( $parent, $grandparent->children, true );
  348. if ( false === $index ) {
  349. $grandparent->children[] = $container;
  350. } else {
  351. array_splice( $grandparent->children, $index, 1, array( $container ) );
  352. }
  353. }
  354. $parent->parent = $container->id;
  355. }
  356. $parent = $container;
  357. }
  358. // Update the parent ID (it might have changed).
  359. $node->parent = $parent->id;
  360. // Add the node to the tree.
  361. $parent->children[] = $node;
  362. }
  363. $root = $this->_get_node( 'root' );
  364. $this->bound = true;
  365. return $root;
  366. }
  367. /**
  368. * @param object $root
  369. */
  370. final protected function _render( $root ) {
  371. // Add browser classes.
  372. // We have to do this here since admin bar shows on the front end.
  373. $class = 'nojq nojs';
  374. if ( wp_is_mobile() ) {
  375. $class .= ' mobile';
  376. }
  377. ?>
  378. <div id="wpadminbar" class="<?php echo $class; ?>">
  379. <?php if ( ! is_admin() && ! did_action( 'wp_body_open' ) ) { ?>
  380. <a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php _e( 'Skip to toolbar' ); ?></a>
  381. <?php } ?>
  382. <div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e( 'Toolbar' ); ?>">
  383. <?php
  384. foreach ( $root->children as $group ) {
  385. $this->_render_group( $group );
  386. }
  387. ?>
  388. </div>
  389. <?php if ( is_user_logged_in() ) : ?>
  390. <a class="screen-reader-shortcut" href="<?php echo esc_url( wp_logout_url() ); ?>"><?php _e( 'Log Out' ); ?></a>
  391. <?php endif; ?>
  392. </div>
  393. <?php
  394. }
  395. /**
  396. * @param object $node
  397. */
  398. final protected function _render_container( $node ) {
  399. if ( 'container' !== $node->type || empty( $node->children ) ) {
  400. return;
  401. }
  402. echo '<div id="' . esc_attr( 'wp-admin-bar-' . $node->id ) . '" class="ab-group-container">';
  403. foreach ( $node->children as $group ) {
  404. $this->_render_group( $group );
  405. }
  406. echo '</div>';
  407. }
  408. /**
  409. * @param object $node
  410. */
  411. final protected function _render_group( $node ) {
  412. if ( 'container' === $node->type ) {
  413. $this->_render_container( $node );
  414. return;
  415. }
  416. if ( 'group' !== $node->type || empty( $node->children ) ) {
  417. return;
  418. }
  419. if ( ! empty( $node->meta['class'] ) ) {
  420. $class = ' class="' . esc_attr( trim( $node->meta['class'] ) ) . '"';
  421. } else {
  422. $class = '';
  423. }
  424. echo "<ul id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>";
  425. foreach ( $node->children as $item ) {
  426. $this->_render_item( $item );
  427. }
  428. echo '</ul>';
  429. }
  430. /**
  431. * @param object $node
  432. */
  433. final protected function _render_item( $node ) {
  434. if ( 'item' !== $node->type ) {
  435. return;
  436. }
  437. $is_parent = ! empty( $node->children );
  438. $has_link = ! empty( $node->href );
  439. $is_root_top_item = 'root-default' === $node->parent;
  440. $is_top_secondary_item = 'top-secondary' === $node->parent;
  441. // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y.
  442. $tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : '';
  443. $aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : '';
  444. $menuclass = '';
  445. $arrow = '';
  446. if ( $is_parent ) {
  447. $menuclass = 'menupop ';
  448. $aria_attributes .= ' aria-haspopup="true"';
  449. }
  450. if ( ! empty( $node->meta['class'] ) ) {
  451. $menuclass .= $node->meta['class'];
  452. }
  453. // Print the arrow icon for the menu children with children.
  454. if ( ! $is_root_top_item && ! $is_top_secondary_item && $is_parent ) {
  455. $arrow = '<span class="wp-admin-bar-arrow" aria-hidden="true"></span>';
  456. }
  457. if ( $menuclass ) {
  458. $menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"';
  459. }
  460. echo "<li id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$menuclass>";
  461. if ( $has_link ) {
  462. $attributes = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir' );
  463. echo "<a class='ab-item'$aria_attributes href='" . esc_url( $node->href ) . "'";
  464. } else {
  465. $attributes = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir' );
  466. echo '<div class="ab-item ab-empty-item"' . $aria_attributes;
  467. }
  468. foreach ( $attributes as $attribute ) {
  469. if ( empty( $node->meta[ $attribute ] ) ) {
  470. continue;
  471. }
  472. if ( 'onclick' === $attribute ) {
  473. echo " $attribute='" . esc_js( $node->meta[ $attribute ] ) . "'";
  474. } else {
  475. echo " $attribute='" . esc_attr( $node->meta[ $attribute ] ) . "'";
  476. }
  477. }
  478. echo ">{$arrow}{$node->title}";
  479. if ( $has_link ) {
  480. echo '</a>';
  481. } else {
  482. echo '</div>';
  483. }
  484. if ( $is_parent ) {
  485. echo '<div class="ab-sub-wrapper">';
  486. foreach ( $node->children as $group ) {
  487. $this->_render_group( $group );
  488. }
  489. echo '</div>';
  490. }
  491. if ( ! empty( $node->meta['html'] ) ) {
  492. echo $node->meta['html'];
  493. }
  494. echo '</li>';
  495. }
  496. /**
  497. * Renders toolbar items recursively.
  498. *
  499. * @since 3.1.0
  500. * @deprecated 3.3.0 Use WP_Admin_Bar::_render_item() or WP_Admin_bar::render() instead.
  501. * @see WP_Admin_Bar::_render_item()
  502. * @see WP_Admin_Bar::render()
  503. *
  504. * @param string $id Unused.
  505. * @param object $node
  506. */
  507. public function recursive_render( $id, $node ) {
  508. _deprecated_function( __METHOD__, '3.3.0', 'WP_Admin_bar::render(), WP_Admin_Bar::_render_item()' );
  509. $this->_render_item( $node );
  510. }
  511. /**
  512. */
  513. public function add_menus() {
  514. // User-related, aligned right.
  515. add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 );
  516. add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 );
  517. add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 );
  518. add_action( 'admin_bar_menu', 'wp_admin_bar_recovery_mode_menu', 8 );
  519. // Site-related.
  520. add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 );
  521. add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
  522. add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
  523. add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
  524. add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 );
  525. add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 );
  526. // Content-related.
  527. if ( ! is_network_admin() && ! is_user_admin() ) {
  528. add_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 );
  529. add_action( 'admin_bar_menu', 'wp_admin_bar_new_content_menu', 70 );
  530. }
  531. add_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 );
  532. add_action( 'admin_bar_menu', 'wp_admin_bar_add_secondary_groups', 200 );
  533. /**
  534. * Fires after menus are added to the menu bar.
  535. *
  536. * @since 3.1.0
  537. */
  538. do_action( 'add_admin_bar_menus' );
  539. }
  540. }