diff --git a/blocks-src/loginlinks/block.js b/blocks-src/loginlinks/block.js
index f5a5c08..d90f034 100644
--- a/blocks-src/loginlinks/block.js
+++ b/blocks-src/loginlinks/block.js
@@ -15,16 +15,15 @@ import './style.scss';
registerBlockType( metadata.name, {
edit: ({attributes, setAttributes}) => {
const {
- displayLinkToAdmin
+ displayLinkToAdmin,
+ displayLinkToEditProfile
} = attributes;
console.log(__('Display link to admin dashboard', 'okv-oauth'));
return
@@ -37,6 +36,15 @@ registerBlockType( metadata.name, {
}) }
/>
+
+ setAttributes({
+ displayLinkToEditProfile: !displayLinkToEditProfile
+ }) }
+ />
+
;
diff --git a/blocks-src/loginlinks/block.json b/blocks-src/loginlinks/block.json
index 7dce764..af4802e 100644
--- a/blocks-src/loginlinks/block.json
+++ b/blocks-src/loginlinks/block.json
@@ -5,6 +5,10 @@
"displayLinkToAdmin": {
"type": "boolean",
"default": false
+ },
+ "displayLinkToEditProfile": {
+ "type": "boolean",
+ "default": false
}
},
"category": "theme",
diff --git a/blocks-src/loginlinks/render.php b/blocks-src/loginlinks/render.php
index 8591763..e0afc5d 100644
--- a/blocks-src/loginlinks/render.php
+++ b/blocks-src/loginlinks/render.php
@@ -14,9 +14,18 @@
$contents = '';
if (!$isUserLoggedIn && get_option('users_can_register')) {
+ // if user is not logged in and has option can register.
$contents .= '' . __( 'Register' ) . ' ' . PHP_EOL;
-} elseif ($isUserLoggedIn && isset($attributes) && is_array($attributes) && array_key_exists('displayLinkToAdmin', $attributes) && true === $attributes['displayLinkToAdmin']) {
- $contents .= '' . __( 'Site Admin' ) . ' ' . PHP_EOL;
+} elseif ($isUserLoggedIn) {
+ // if user logged in.
+ if (isset($attributes) && is_array($attributes) && array_key_exists('displayLinkToAdmin', $attributes) && true === $attributes['displayLinkToAdmin']) {
+ // if block was set to display link to admin dashboard.
+ $contents .= '' . __( 'Site Admin' ) . ' ' . PHP_EOL;
+ }
+ if (isset($attributes) && is_array($attributes) && array_key_exists('displayLinkToEditProfile', $attributes) && true === $attributes['displayLinkToEditProfile']) {
+ // if block was set to display link to edit profile.
+ $contents .= '' . __('Edit Profile') . ' ' . PHP_EOL;
+ }
}
unset($isUserLoggedIn);
diff --git a/blocks/loginlinks/block.asset.php b/blocks/loginlinks/block.asset.php
index a0e47c1..0aa8da0 100644
--- a/blocks/loginlinks/block.asset.php
+++ b/blocks/loginlinks/block.asset.php
@@ -1 +1 @@
- array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-server-side-render'), 'version' => 'ff70017631adf4144639');
+ array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-server-side-render'), 'version' => 'e3ac22a67f944046c3c4');
diff --git a/blocks/loginlinks/block.js b/blocks/loginlinks/block.js
index aee65b1..87e21c3 100644
--- a/blocks/loginlinks/block.js
+++ b/blocks/loginlinks/block.js
@@ -1 +1 @@
-(()=>{"use strict";var e,o={688:(e,o,t)=>{const n=window.React,r=window.wp.blocks,l=window.wp.blockEditor,i=window.wp.i18n,a=window.wp.serverSideRender;var s=t.n(a);const d=window.wp.components,c=JSON.parse('{"u2":"rd-oauth/blocks-loginlinks"}');(0,r.registerBlockType)(c.u2,{edit:({attributes:e,setAttributes:o})=>{const{displayLinkToAdmin:t}=e;return console.log((0,i.__)("Display link to admin dashboard","okv-oauth")),(0,n.createElement)("p",{...(0,l.useBlockProps)()},(0,n.createElement)(s(),{block:"rd-oauth/blocks-loginlinks",attributes:e.attributes,label:"hello label",checked:"{displayLinkToAdmin}"}),(0,n.createElement)(l.InspectorControls,{key:"setting"},(0,n.createElement)("div",{id:"rd-oauth-loginlinks-controls",class:"components-panel__body is-opened"},(0,n.createElement)("fieldset",null,(0,n.createElement)(d.ToggleControl,{label:(0,i.__)("Display link to admin dashboard","okv-oauth"),checked:t,onChange:()=>o({displayLinkToAdmin:!t})})))))}})}},t={};function n(e){var r=t[e];if(void 0!==r)return r.exports;var l=t[e]={exports:{}};return o[e](l,l.exports,n),l.exports}n.m=o,e=[],n.O=(o,t,r,l)=>{if(!t){var i=1/0;for(c=0;c=l)&&Object.keys(n.O).every((e=>n.O[e](t[s])))?t.splice(s--,1):(a=!1,l0&&e[c-1][2]>l;c--)e[c]=e[c-1];e[c]=[t,r,l]},n.n=e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return n.d(o,{a:o}),o},n.d=(e,o)=>{for(var t in o)n.o(o,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},n.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{var e={961:0,646:0};n.O.j=o=>0===e[o];var o=(o,t)=>{var r,l,[i,a,s]=t,d=0;if(i.some((o=>0!==e[o]))){for(r in a)n.o(a,r)&&(n.m[r]=a[r]);if(s)var c=s(n)}for(o&&o(t);dn(688)));r=n.O(r)})();
\ No newline at end of file
+(()=>{"use strict";var e,o={688:(e,o,t)=>{const n=window.React,r=window.wp.blocks,l=window.wp.blockEditor,i=window.wp.i18n,a=window.wp.serverSideRender;var s=t.n(a);const d=window.wp.components,c=JSON.parse('{"u2":"rd-oauth/blocks-loginlinks"}');(0,r.registerBlockType)(c.u2,{edit:({attributes:e,setAttributes:o})=>{const{displayLinkToAdmin:t,displayLinkToEditProfile:r}=e;return console.log((0,i.__)("Display link to admin dashboard","okv-oauth")),(0,n.createElement)("p",{...(0,l.useBlockProps)()},(0,n.createElement)(s(),{block:"rd-oauth/blocks-loginlinks",attributes:e}),(0,n.createElement)(l.InspectorControls,{key:"setting"},(0,n.createElement)("div",{id:"rd-oauth-loginlinks-controls",class:"components-panel__body is-opened"},(0,n.createElement)("fieldset",null,(0,n.createElement)(d.ToggleControl,{label:(0,i.__)("Display link to admin dashboard","okv-oauth"),checked:t,onChange:()=>o({displayLinkToAdmin:!t})})),(0,n.createElement)("fieldset",null,(0,n.createElement)(d.ToggleControl,{label:(0,i.__)("Display link to edit profile","okv-oauth"),checked:r,onChange:()=>o({displayLinkToEditProfile:!r})})))))}})}},t={};function n(e){var r=t[e];if(void 0!==r)return r.exports;var l=t[e]={exports:{}};return o[e](l,l.exports,n),l.exports}n.m=o,e=[],n.O=(o,t,r,l)=>{if(!t){var i=1/0;for(c=0;c=l)&&Object.keys(n.O).every((e=>n.O[e](t[s])))?t.splice(s--,1):(a=!1,l0&&e[c-1][2]>l;c--)e[c]=e[c-1];e[c]=[t,r,l]},n.n=e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return n.d(o,{a:o}),o},n.d=(e,o)=>{for(var t in o)n.o(o,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},n.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{var e={961:0,646:0};n.O.j=o=>0===e[o];var o=(o,t)=>{var r,l,[i,a,s]=t,d=0;if(i.some((o=>0!==e[o]))){for(r in a)n.o(a,r)&&(n.m[r]=a[r]);if(s)var c=s(n)}for(o&&o(t);dn(688)));r=n.O(r)})();
\ No newline at end of file
diff --git a/blocks/loginlinks/block.json b/blocks/loginlinks/block.json
index 7767e49..aa04959 100644
--- a/blocks/loginlinks/block.json
+++ b/blocks/loginlinks/block.json
@@ -5,6 +5,10 @@
"displayLinkToAdmin": {
"type": "boolean",
"default": false
+ },
+ "displayLinkToEditProfile": {
+ "type": "boolean",
+ "default": false
}
},
"category": "theme",
diff --git a/blocks/loginlinks/render.php b/blocks/loginlinks/render.php
index 4e31af9..e0afc5d 100644
--- a/blocks/loginlinks/render.php
+++ b/blocks/loginlinks/render.php
@@ -14,9 +14,18 @@
$contents = '';
if (!$isUserLoggedIn && get_option('users_can_register')) {
- $contents .= '' . __('Register') . ' ' . PHP_EOL;
-} elseif ($isUserLoggedIn && isset($attributes) && is_array($attributes) && array_key_exists('displayLinkToAdmin', $attributes) && true === $attributes['displayLinkToAdmin']) {
- $contents .= '' . __('Site Admin') . ' ' . PHP_EOL;
+ // if user is not logged in and has option can register.
+ $contents .= '' . __( 'Register' ) . ' ' . PHP_EOL;
+} elseif ($isUserLoggedIn) {
+ // if user logged in.
+ if (isset($attributes) && is_array($attributes) && array_key_exists('displayLinkToAdmin', $attributes) && true === $attributes['displayLinkToAdmin']) {
+ // if block was set to display link to admin dashboard.
+ $contents .= '' . __( 'Site Admin' ) . ' ' . PHP_EOL;
+ }
+ if (isset($attributes) && is_array($attributes) && array_key_exists('displayLinkToEditProfile', $attributes) && true === $attributes['displayLinkToEditProfile']) {
+ // if block was set to display link to edit profile.
+ $contents .= '' . __('Edit Profile') . ' ' . PHP_EOL;
+ }
}
unset($isUserLoggedIn);