Version Description
- Released 2019-10-09
- Updating compatibility with WordPress 5.3
- Fixing JavaScript error in WordPress 5.3
Download this release
Release Info
Developer | ronalfy |
Plugin | User Profile Picture |
Version | 2.3.6 |
Comparing to | |
See all releases |
Code changes from version 2.3.5 to 2.3.6
- dist/blocks.build.js +1 -1
- gutenberg/class-gutenberg.php +40 -15
- gutenberg/index.php +2 -0
- metronet-profile-picture.php +197 -214
- readme.txt +9 -4
- src/block/profile.js +1 -1
dist/blocks.build.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(e,t,r){"use strict";function o(e){return"[object Array]"===T.call(e)}function n(e){return"[object ArrayBuffer]"===T.call(e)}function i(e){return"undefined"!==typeof FormData&&e instanceof FormData}function a(e){return"undefined"!==typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function l(e){return"string"===typeof e}function s(e){return"number"===typeof e}function p(e){return"undefined"===typeof e}function c(e){return null!==e&&"object"===typeof e}function u(e){return"[object Date]"===T.call(e)}function m(e){return"[object File]"===T.call(e)}function f(e){return"[object Blob]"===T.call(e)}function h(e){return"[object Function]"===T.call(e)}function d(e){return c(e)&&h(e.pipe)}function g(e){return"undefined"!==typeof URLSearchParams&&e instanceof URLSearchParams}function b(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function w(){return("undefined"===typeof navigator||"ReactNative"!==navigator.product)&&("undefined"!==typeof window&&"undefined"!==typeof document)}function C(e,t){if(null!==e&&"undefined"!==typeof e)if("object"!==typeof e&&(e=[e]),o(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}function v(){function e(e,r){"object"===typeof t[r]&&"object"===typeof e?t[r]=v(t[r],e):t[r]=e}for(var t={},r=0,o=arguments.length;r<o;r++)C(arguments[r],e);return t}function E(e,t,r){return C(t,function(t,o){e[o]=r&&"function"===typeof t?_(t,r):t}),e}var _=r(4),y=r(15),T=Object.prototype.toString;e.exports={isArray:o,isArrayBuffer:n,isBuffer:y,isFormData:i,isArrayBufferView:a,isString:l,isNumber:s,isObject:c,isUndefined:p,isDate:u,isFile:m,isBlob:f,isFunction:h,isStream:d,isURLSearchParams:g,isStandardBrowserEnv:w,forEach:C,merge:v,extend:E,trim:b}},function(e,t,r){"use strict";(function(t){function o(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var n=r(0),i=r(18),a={"Content-Type":"application/x-www-form-urlencoded"},l={adapter:function(){var e;return"undefined"!==typeof XMLHttpRequest?e=r(5):"undefined"!==typeof t&&(e=r(5)),e}(),transformRequest:[function(e,t){return i(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(o(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(o(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"===typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};l.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],function(e){l.headers[e]={}}),n.forEach(["post","put","patch"],function(e){l.headers[e]=n.merge(a)}),e.exports=l}).call(t,r(17))},function(e,t,r){var o,n;!function(){"use strict";function r(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var n=typeof o;if("string"===n||"number"===n)e.push(o);else if(Array.isArray(o)&&o.length){var a=r.apply(null,o);a&&e.push(a)}else if("object"===n)for(var l in o)i.call(o,l)&&o[l]&&e.push(l)}}return e.join(" ")}var i={}.hasOwnProperty;"undefined"!==typeof e&&e.exports?(r.default=r,e.exports=r):(o=[],void 0!==(n=function(){return r}.apply(t,o))&&(e.exports=n))}()},function(e,t,r){e.exports=r(14)},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),o=0;o<r.length;o++)r[o]=arguments[o];return e.apply(t,r)}}},function(e,t,r){"use strict";var o=r(0),n=r(19),i=r(21),a=r(22),l=r(23),s=r(6);e.exports=function(e){return new Promise(function(t,p){var c=e.data,u=e.headers;o.isFormData(c)&&delete u["Content-Type"];var m=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",h=e.auth.password||"";u.Authorization="Basic "+btoa(f+":"+h)}if(m.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),m.timeout=e.timeout,m.onreadystatechange=function(){if(m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in m?a(m.getAllResponseHeaders()):null,o=e.responseType&&"text"!==e.responseType?m.response:m.responseText,i={data:o,status:m.status,statusText:m.statusText,headers:r,config:e,request:m};n(t,p,i),m=null}},m.onerror=function(){p(s("Network Error",e,null,m)),m=null},m.ontimeout=function(){p(s("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",m)),m=null},o.isStandardBrowserEnv()){var d=r(24),g=(e.withCredentials||l(e.url))&&e.xsrfCookieName?d.read(e.xsrfCookieName):void 0;g&&(u[e.xsrfHeaderName]=g)}if("setRequestHeader"in m&&o.forEach(u,function(e,t){"undefined"===typeof c&&"content-type"===t.toLowerCase()?delete u[t]:m.setRequestHeader(t,e)}),e.withCredentials&&(m.withCredentials=!0),e.responseType)try{m.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"===typeof e.onDownloadProgress&&m.addEventListener("progress",e.onDownloadProgress),"function"===typeof e.onUploadProgress&&m.upload&&m.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){m&&(m.abort(),p(e),m=null)}),void 0===c&&(c=null),m.send(c)})}},function(e,t,r){"use strict";var o=r(20);e.exports=function(e,t,r,n,i){var a=new Error(e);return o(a,t,r,n,i)}},function(e,t,r){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,r){"use strict";function o(e){this.message=e}o.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},o.prototype.__CANCEL__=!0,e.exports=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});r(10)},function(e,t,r){"use strict";var o=r(11),n=(r.n(o),r(12)),i=(r.n(n),r(13)),a=r(32),l=r(2),s=r.n(l),__=wp.i18n.__,p=wp.blocks.registerBlockType,c=wp.element,u=(c.Component,c.Fragment),m=wp.editor.RichText,f={profileName:{type:"string",default:""},profileTitle:{type:"string",default:""},profileContent:{type:"string",default:""},profileAlignment:{type:"string"},profileImgURL:{type:"string",source:"attribute",attribute:"src",selector:"img",default:""},profileImgID:{type:"number",default:""},profileURL:{type:"string",default:""},profileBackgroundColor:{type:"string",default:"#f2f2f2"},profileTextColor:{type:"string",default:"#32373c"},profileViewPostsBackgroundColor:{type:"string",default:"#cf6d38"},profileViewPostsTextColor:{type:"string",default:"#FFFFFF"},profileViewPostsWidth:{type:"number",default:100},profileFontSize:{type:"number",default:18},profileAvatarShape:{type:"string",default:"square"},showName:{type:"bool",default:!0},showTitle:{type:"bool",default:!0},showDescription:{type:"bool",default:!0},showViewPosts:{type:"bool",default:!0},user_id:{type:"number",default:0}};p("mpp/user-profile",{title:__("User Profile Legacy","metronet-profile-picture"),icon:wp.element.createElement("svg",{id:"Layer_1","data-name":"Layer 1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 753.53 979.74"},wp.element.createElement("title",null,"upp"),wp.element.createElement("path",{d:"M806.37,185.9c0,40.27-30.49,72.9-68.11,72.9s-68.17-32.63-68.17-72.9S700.62,113,738.26,113,806.37,145.64,806.37,185.9Z",transform:"translate(-123.47 -11)",fill:"#4063ad"}),wp.element.createElement("path",{d:"M330.36,183.8c0,40.27-30.49,72.9-68.12,72.9s-68.17-32.63-68.17-72.9,30.52-72.87,68.17-72.87S330.36,143.56,330.36,183.8Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M331.3,888.13V698.21H329c-31.64,0-57.28-27.45-57.28-61.29V336.5a118.37,118.37,0,0,1,5.43-34.79H179.84c-31.94,0-56.37,31.57-56.37,56.34V601.46h48.32V888.13Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M388.59,636.92V990.74H611.88V636.92H671.5V336.5c0-30.63-27.64-69.57-69.6-69.57H398.56c-39.44,0-69.61,38.94-69.61,69.57V636.92Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M584.3,101c0,49.69-37.63,90-84,90S416.12,150.67,416.12,101s37.66-90,84.14-90S584.3,51.27,584.3,101Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M820.61,303.79H724.08a121.69,121.69,0,0,1,4.7,32.71V636.92c0,33.84-25.64,61.29-57.28,61.29h-2.33v192H828.7V603.54H877V360.16C877,335.36,854.62,303.79,820.61,303.79Z",transform:"translate(-123.47 -11)",fill:"#4063ad"})),category:"mpp",attributes:f,edit:a.a,save:function(e){var t=e.attributes,r=t.profileName,o=t.profileTitle,n=t.profileContent,i=t.profileAlignment,a=t.profileImgURL,l=(t.profileImgID,t.profileFontSize),p=t.profileBackgroundColor,c=t.profileTextColor,f=(t.profileLinkColor,t.profileAvatarShape),h=t.profileViewPostsBackgroundColor,d=t.profileViewPostsTextColor,g=t.profileURL,b=t.showTitle,w=t.showName,C=t.showDescription,v=t.showViewPosts;return wp.element.createElement(u,null,wp.element.createElement("div",{className:s()("mpp-profile-wrap",i,f,"mt-font-size-"+l,"mpp-block-profile"),style:{backgroundColor:p,color:c}},wp.element.createElement("div",{className:s()("mpp-profile-gutenberg-wrap","mpp-block-profile"),style:{backgroundColor:p,color:c}},wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement("img",{className:"mpp-profile-avatar",src:a,alt:"avatar"}))),wp.element.createElement("div",{className:"mpp-content-wrap"},r&&!!r.length&&w&&wp.element.createElement(m.Content,{tagName:"h2",className:"mpp-profile-name",style:{color:c},value:r}),o&&!!o.length&&b&&wp.element.createElement(m.Content,{tagName:"p",className:"mpp-profile-title",style:{color:c},value:o}),n&&!!n.length&&C&&wp.element.createElement(m.Content,{tagName:"div",className:"mpp-profile-text",value:n}))),g&&!!g.length&&wp.element.createElement("div",{className:"mpp-gutenberg-view-posts"},v&&wp.element.createElement("div",{className:"mpp-profile-view-posts",style:{backgroundColor:h,color:d}},wp.element.createElement("a",{href:g,style:{backgroundColor:h,color:d}},__("View Posts","metronet-profile-picture"))))))}}),p("mpp/user-profile-enhanced",{title:__("User Profile","metronet-profile-picture"),icon:wp.element.createElement("svg",{id:"Layer_1","data-name":"Layer 1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 753.53 979.74"},wp.element.createElement("title",null,"upp"),wp.element.createElement("path",{d:"M806.37,185.9c0,40.27-30.49,72.9-68.11,72.9s-68.17-32.63-68.17-72.9S700.62,113,738.26,113,806.37,145.64,806.37,185.9Z",transform:"translate(-123.47 -11)",fill:"#4063ad"}),wp.element.createElement("path",{d:"M330.36,183.8c0,40.27-30.49,72.9-68.12,72.9s-68.17-32.63-68.17-72.9,30.52-72.87,68.17-72.87S330.36,143.56,330.36,183.8Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M331.3,888.13V698.21H329c-31.64,0-57.28-27.45-57.28-61.29V336.5a118.37,118.37,0,0,1,5.43-34.79H179.84c-31.94,0-56.37,31.57-56.37,56.34V601.46h48.32V888.13Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M388.59,636.92V990.74H611.88V636.92H671.5V336.5c0-30.63-27.64-69.57-69.6-69.57H398.56c-39.44,0-69.61,38.94-69.61,69.57V636.92Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M584.3,101c0,49.69-37.63,90-84,90S416.12,150.67,416.12,101s37.66-90,84.14-90S584.3,51.27,584.3,101Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M820.61,303.79H724.08a121.69,121.69,0,0,1,4.7,32.71V636.92c0,33.84-25.64,61.29-57.28,61.29h-2.33v192H828.7V603.54H877V360.16C877,335.36,854.62,303.79,820.61,303.79Z",transform:"translate(-123.47 -11)",fill:"#4063ad"})),category:"mpp",getEditWrapperProps:function(e){},edit:i.a,save:function(){return null}})},function(e,t){},function(e,t){},function(e,t,r){"use strict";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t}function a(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=r(3),s=r.n(l),p=r(2),c=r.n(p),u=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),m=wp.element,f=m.Component,h=m.Fragment,__=wp.i18n.__,d=wp.components,g=d.PanelBody,b=d.Placeholder,w=(d.QueryControls,d.RangeControl),C=d.SelectControl,v=d.Spinner,E=d.TextControl,_=d.ToggleControl,y=(d.Toolbar,d.withAPIData,d.ColorPalette,d.Button),T=wp.editor,P=T.InspectorControls,S=(T.BlockControls,T.MediaUpload),N=T.RichText,x=(T.AlignmentToolbar,T.PanelColorSettings),k=function(e){function t(){n(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));e.get_users=function(){s.a.post(mpp_gutenberg.rest_url+"/get_users",{},{headers:{"X-WP-Nonce":mpp_gutenberg.nonce}}).then(function(t){var r,n=Array(),i=Array(),a=0,l="",s=0,p="",c="",u="",m="",f="";$.each(t.data,function(e,t){n[t.ID]={profile_pictures:t.profile_pictures,has_profile_picture:t.has_profile_picture,display_name:t.display_name,description:t.description,is_user_logged_in:t.is_user_logged_in,profile_picture_id:t.profile_picture_id,default_image:t.default_image,permalink:t.permalink},t.is_user_logged_in&&(a=t.ID),i.push({value:t.ID,label:t.display_name})}),0!==e.props.attributes.user_id&&(a=e.props.attributes.user_id);var h=n[a];h.has_profile_picture?(l=e.props.attributes.profileImgURL.length>0?e.props.attributes.profileImgURL:h.profile_pictures.thumbnail,s=e.props.attributes.profileImgID.length>0?e.props.attributes.profileImgID:h.profile_picture_id,p=e.props.attributes.profileName.length>0?e.props.attributes.profileName:h.display_name,u=e.props.attributes.profileTitle.length>0?e.props.attributes.profileTitle:"",m=h.permalink,c=e.props.attributes.profileContent.length>0?e.props.attributes.profileContent:h.description,f=e.props.attributes.showWebsite):(p=e.props.attributes.profileName.length>0?e.props.attributes.profileName:h.display_name,u=e.props.attributes.profileTitle.length>0?e.props.attributes.profileTitle:"",c=e.props.attributes.profileContent.length>0?e.props.attributes.profileContent:h.description,l=e.props.attributes.profileImgURL.length>0?e.props.attributes.profileImgURL:h.default_image,s=e.props.attributes.profileImgID.length>0?e.props.attributes.profileImgID:0,m=h.permalink,f=e.props.attributes.showWebsite),void 0==c&&(c=""),e.setState((r={loading:!1,users:n,active_user:a,user_list:i,profile_picture:l,profile_picture_id:s},o(r,"active_user",a),o(r,"profile_name",p),o(r,"profile_name_unfiltered",h.display_name),o(r,"profile_title",u),o(r,"profile_description",c),o(r,"profile_url",m),o(r,"show_website",f),r)),e.props.setAttributes(o({profileContent:c,profileName:p,profileTitle:u,profileURL:m,profileImgID:s,profileImgURL:l,showWebsite:f,showSocialMedia:!0},"profileName",h.display_name))})},e.on_user_change=function(t){var r=e.state.users[t],n="",i=0,a="";r.has_profile_picture?(n=e.state.users[t].profile_pictures.thumbnail,i=e.state.users[t].profile_picture_id):(n=mpp_gutenberg.mystery_man,i=0);var l=e.state.users[t].description;void 0===l&&(l=""),a=e.state.users[t].display_name,e.props.setAttributes(o({profileName:a,profileContent:l,profileTitle:"",profileURL:e.state.users[t].permalink,profileImgURL:n,tabbedAuthorSubHeading:"",tabbedAuthorProfileTitle:"",socialFacebook:"",socialGitHub:"",socialInstagram:"",socialLinkedIn:"",socialPinterest:"",socialTwitter:"",socialWordPress:"",socialYouTube:""},"profileName",e.state.users[t].display_name)),e.setState({profile_name_unfiltered:e.state.users[t].display_name,profile_name:a,profile_description:l,profile_title:"",profile_picture:n,profile_picture_id:i,active_user:t,profile_url:e.state.users[t].permalink,socialFacebook:"",socialGitHub:"",socialInstagram:"",socialLinkedIn:"",socialPinterest:"",socialTwitter:"",socialWordPress:"",socialYouTube:""}),e.getLatestPosts()},e.getLatestPosts=function(){e.setState({loadingLatestPosts:!0});s.a.post(mpp_gutenberg.rest_url+"/get_posts",{user_id:e.state.active_user},{headers:{"X-WP-Nonce":mpp_gutenberg.nonce}}).then(function(t){var r=t.data,o=r.map(function(e){return wp.element.createElement("li",{key:e.ID},wp.element.createElement("a",{href:e.permalink},e.post_title))});e.setState({loadingLatestPosts:!1,latestPosts:o})})},e.componentDidMount=function(){e.get_users()},e.handleImageChange=function(t,r){e.setState({profile_picture:r,profile_picture_id:t})},e.onChangeName=function(t){e.setState({profile_name:t})},e.onChangeTitle=function(t){e.setState({profile_title:t})},e.onChangeProfileText=function(t){e.setState({profile_description:t})},e.onThemeChange=function(t){e.setState({theme:t})},e.handleFacebookChange=function(t){e.setState({socialFacebook:t})},e.handleYouTubeChange=function(t){e.setState({socialYouTube:t})},e.handleGitHubChange=function(t){e.setState({socialGitHub:t})},e.handleLinkedInChange=function(t){e.setState({socialLinkedIn:t})},e.handleTwitterChange=function(t){e.setState({socialTwitter:t})},e.handleWordPressChange=function(t){e.setState({socialWordPress:t})},e.handleWebsiteChange=function(t){e.setState({website:t}),""!==t&&e.props.setAttributes({showWebsite:!0})},e.handleInstagramChange=function(t){e.setState({socialInstagram:t})},e.handlePinterestChange=function(t){e.setState({socialPinterest:t})},e.handleSocialMediaChange=function(t){e.setState({showSocialMedia:t}),e.props.setAttributes({showSocialMedia:t})},e.handleSocialMediaOptionChange=function(t){e.setState({socialMediaOptions:t})},e.onChangeTabbedProfileText=function(t){e.setState({tabbedAuthorProfile:t})},e.onChangeTabbedSubHeading=function(t){e.setState({tabbedAuthorSubHeading:t})},e.onChangeActiveProfileTab=function(){e.setState({activeTab:"profile"})},e.onChangeActivePostTab=function(){e.setState({activeTab:"latest",loadingLatestPosts:!0}),e.getLatestPosts()},e.onChangetabbedAuthorProfile=function(t){e.setState({tabbedAuthorProfile:t})},e.onChangetabbedAuthorProfileHeading=function(t){e.setState({tabbedAuthorProfileHeading:t})},e.onChangetabbedAuthorLatestPosts=function(t){e.setState({tabbedAuthorLatestPosts:t})},e.onChangeProfileTabColor=function(t){e.setState({profileTabColor:t}),e.props.setAttributes({profileTabColor:t})},e.onChangePostsTabColor=function(t){e.setState({profileTabPostsColor:t}),e.props.setAttributes({profileTabPostsColor:t})},e.onChangePostsTabHeadlineColor=function(t){e.setState({profileTabHeadlineColor:t}),e.props.setAttributes({profileTabHeadlineColor:t})},e.onChangeProfileTabPostColorText=function(t){e.setState({profileTabPostsTextColor:t}),e.props.setAttributes({profileTabPostsTextColor:t})},e.onChangeProfileTabHeadlineColorText=function(t){e.setState({profileTabHeadlineTextColor:t}),e.props.setAttributes({profileTabHeadlineTextColor:t})},e.onChangeProfileTabColorText=function(t){e.setState({profileTabTextColor:t}),e.props.setAttributes({profileTabTextColor:t})},e.onLatestPostsChange=function(t){e.setState({profileLatestPostsOptionsValue:t})},e.onCompactAlignmentChange=function(t){e.setState({profileCompactAlignment:t})};var r=Array();return r.push({value:"regular",label:__("Regular","metronet-profile-picture")}),r.push({value:"profile",label:__("Profile","metronet-profile-picture")}),r.push({value:"tabbed",label:__("Tabbed","metronet-profile-picture")}),r.push({value:"compact",label:__("Compact","metronet-profile-picture")}),e.state={loading:!0,users:!1,user_list:!1,profile_picture:e.props.attributes.profileImgURL,profile_picture_id:e.props.attributes.profileImgID,active_user:!1,profile_description:"",profile_name:"",profile_name_unfiltered:"",profile_title:"",show_website:e.props.attributes.showWebsite,profileViewPosts:e.props.attributes.profileViewPosts,profileViewWebsite:e.props.attributes.profileViewWebsite,theme:e.props.attributes.theme,themes:r,socialFacebook:e.props.attributes.socialFacebook,socialGitHub:e.props.attributes.socialGitHub,socialLinkedIn:e.props.attributes.socialLinkedIn,socialPinterest:e.props.attributes.socialPinterest,socialTwitter:e.props.attributes.socialTwitter,socialWordPress:e.props.attributes.socialWordPress,socialYouTube:e.props.attributes.socialYouTube,socialInstagram:e.props.attributes.socialInstagram,website:e.props.attributes.website,showSocialMedia:!0,socialMediaOptions:e.props.attributes.socialMediaOptions,socialMediaColors:e.props.attributes.socialMediaColors,tabbedAuthorProfile:e.props.attributes.tabbedAuthorProfile,tabbedAuthorLatestPosts:e.props.attributes.tabbedAuthorLatestPosts,tabbedAuthorSubHeading:e.props.attributes.tabbedAuthorSubHeading,tabbedAuthorProfileHeading:e.props.attributes.tabbedAuthorProfileHeading,activeTab:"profile",loadingLatestPosts:!0,latestPosts:{},profileTabColor:e.props.attributes.profileTabColor,profileTabHeadlineColor:e.props.attributes.profileTabHeadlineColor,profileTabPostsColor:e.props.attributes.profileTabPostsColor,profileTabHeadlineTextColor:e.props.attributes.profileTabHeadlineTextColor,profileTabTextColor:e.props.attributes.profileTabTextColor,profileTabPostsTextColor:e.props.attributes.profileTabPostsTextColor,profileLatestPostsOptionsValue:e.props.attributes.profileLatestPostsOptionsValue,profileCompactAlignment:e.props.attributes.profileCompactAlignment},e}return a(t,e),u(t,[{key:"render",value:function(){var e=this,t=this.props,r=t.attributes,o=r.profileName,n=r.profileTitle,i=r.profileContent,a=r.profileAlignment,l=r.profileImgURL,s=r.profileImgID,p=r.profileURL,u=r.profileFontSize,m=r.buttonFontSize,f=r.headerFontSize,d=r.profileBackgroundColor,T=r.profileTextColor,k=r.profileAvatarShape,A=r.profileViewPostsBackgroundColor,I=r.profileViewPostsTextColor,L=r.profileViewPosts,O=r.profileViewWebsite,V=r.showTitle,H=r.showName,R=r.showDescription,M=r.showViewPosts,B=r.showPostsWidth,U=(r.showSocialMedia,r.showWebsite),D=(r.theme,r.theme_list,r.socialFacebook,r.socialGitHub,r.socialLinkedIn,r.socialPinterest,r.socialTwitter,r.socialWordPress,r.socialYouTube,r.socialMediaColors),F=r.profileWebsiteBackgroundColor,W=r.profileWebsiteTextColor,j=r.padding,z=r.border,q=r.borderRounded,Z=r.borderColor,G=r.profileLinkColor,Y=(r.tabbedAuthorProfile,r.tabbedAuthorSubHeading,r.tabbedAuthorProfileTitle),X=(r.profileLatestPostsOptionsValue,t.attributes,t.isSelected,t.editable,t.className,t.setAttributes);this.state.profile_pictures;s=this.state.profile_picture_id,l=this.state.profile_picture,o=this.state.profile_name,i=this.state.profile_description,n=this.state.profile_title,p=this.state.profile_url,B=""!==this.state.website&&this.props.attributes.showWebsite?"":"100%",X({showPostsWidth:B});var $=function(e){return X({profileBackgroundColor:e})},J=function(e){return X({profileTextColor:e})},K=function(e){return X({profileViewPostsBackgroundColor:e})},Q=function(e){return X({profileViewPostsTextColor:e})},ee=function(e){return X({profileWebsiteBackgroundColor:e})},te=function(e){return X({profileWebsiteTextColor:e})},re=function(e){return X({socialMediaColors:e})},oe=function(e){return X({borderColor:e})},ne=function(e){return X({profileLinkColor:e})},ie=[{value:"square",label:__("Square","metronet-profile-picture")},{value:"round",label:__("Round","metronet-profile-picture")}],ae=[{value:"colors",label:__("Brand Colors","metronet-profile-picture")},{value:"custom",label:__("Custom","metronet-profile-picture")}],le=[{value:"none",label:__("None","metronet-profile-picture")},{value:"white",label:__("White","metronet-profile-picture")},{value:"light",label:__("Light","metronet-profile-picture")},{value:"black",label:__("Black","metronet-profile-picture")},{value:"magenta",label:__("Magenta","metronet-profile-picture")},{value:"blue",label:__("Blue","metronet-profile-picture")},{value:"green",label:__("Green","metronet-profile-picture")}],se=[{value:"left",label:__("Left","metronet-profile-picture")},{value:"center",label:__("Center","metronet-profile-picture")},{value:"right",label:__("Right","metronet-profile-picture")}],pe="none",ce="";return"center"===this.state.profileCompactAlignment&&(pe="none",ce="0 auto"),"left"===this.state.profileCompactAlignment&&(pe="left",ce="0"),"right"===this.state.profileCompactAlignment&&(pe="right",ce="0"),wp.element.createElement(h,null,this.state.loading&&wp.element.createElement(h,null,wp.element.createElement(b,null,wp.element.createElement("div",null,wp.element.createElement("svg",{id:"Layer_1","data-name":"Layer 1",xmlns:"http://www.w3.org/2000/svg",width:"125px",height:"125px",viewBox:"0 0 753.53 979.74"},wp.element.createElement("title",null,"upp"),wp.element.createElement("path",{d:"M806.37,185.9c0,40.27-30.49,72.9-68.11,72.9s-68.17-32.63-68.17-72.9S700.62,113,738.26,113,806.37,145.64,806.37,185.9Z",transform:"translate(-123.47 -11)",fill:"#4063ad"}),wp.element.createElement("path",{d:"M330.36,183.8c0,40.27-30.49,72.9-68.12,72.9s-68.17-32.63-68.17-72.9,30.52-72.87,68.17-72.87S330.36,143.56,330.36,183.8Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M331.3,888.13V698.21H329c-31.64,0-57.28-27.45-57.28-61.29V336.5a118.37,118.37,0,0,1,5.43-34.79H179.84c-31.94,0-56.37,31.57-56.37,56.34V601.46h48.32V888.13Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M388.59,636.92V990.74H611.88V636.92H671.5V336.5c0-30.63-27.64-69.57-69.6-69.57H398.56c-39.44,0-69.61,38.94-69.61,69.57V636.92Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M584.3,101c0,49.69-37.63,90-84,90S416.12,150.67,416.12,101s37.66-90,84.14-90S584.3,51.27,584.3,101Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M820.61,303.79H724.08a121.69,121.69,0,0,1,4.7,32.71V636.92c0,33.84-25.64,61.29-57.28,61.29h-2.33v192H828.7V603.54H877V360.16C877,335.36,854.62,303.79,820.61,303.79Z",transform:"translate(-123.47 -11)",fill:"#4063ad"})),wp.element.createElement("div",{className:"mpp-spinner"},wp.element.createElement(v,null))))),!this.state.loading&&wp.element.createElement(h,null,wp.element.createElement(P,null,wp.element.createElement(g,{title:__("User Profile Settings","metronet-profile-picture")},wp.element.createElement(C,{label:__("Select a user","metronet-profile-picture"),value:this.state.active_user,options:this.state.user_list,onChange:function(t){e.on_user_change(t),X({user_id:Number(t)})}}),wp.element.createElement(C,{label:__("Select a theme","metronet-profile-picture"),value:this.state.theme,options:this.state.themes,onChange:function(t){e.onThemeChange(t),X({theme:t})}}),"compact"===this.state.theme&&wp.element.createElement(C,{label:__("Select an alignment","metronet-profile-picture"),value:this.state.profileCompactAlignment,options:se,onChange:function(t){e.onCompactAlignmentChange(t),X({profileCompactAlignment:t})}}),wp.element.createElement(C,{label:__("Avatar Shape","metronet-profile-picture"),description:__("Choose between a round or square avatar shape.","metronet-profile-picture"),options:ie,value:k,onChange:function(t){return e.props.setAttributes({profileAvatarShape:t})}}),"tabbed"!==this.state.theme&&wp.element.createElement(E,{label:__("Website","metronet-profile-picture"),value:this.state.website,onChange:function(t){e.props.setAttributes({website:t}),e.handleWebsiteChange(t)}}),wp.element.createElement(_,{label:__("Show Name","metronet-profile-picture"),checked:H,onChange:function(){return e.props.setAttributes({showName:!H})}}),wp.element.createElement(_,{label:__("Show Title","metronet-profile-picture"),checked:V,onChange:function(){return e.props.setAttributes({showTitle:!V})}}),wp.element.createElement(_,{label:__("Show Description","metronet-profile-picture"),checked:R,onChange:function(){return e.props.setAttributes({showDescription:!R})}}),"tabbed"!==this.state.theme&&wp.element.createElement(h,null,wp.element.createElement(_,{label:__("Show View Posts","metronet-profile-picture"),checked:M,onChange:function(){return e.props.setAttributes({showViewPosts:!M})}}),M&&wp.element.createElement(E,{label:__("View Posts Text","metronet-profile-picture"),value:L,onChange:function(t){e.props.setAttributes({profileViewPosts:t})}}),wp.element.createElement(_,{label:__("Show Website","metronet-profile-picture"),checked:this.state.show_website,onChange:function(t){e.props.setAttributes({showWebsite:t}),e.setState({show_website:t})}}),this.state.show_website&&wp.element.createElement(E,{label:__("View Website Text","metronet-profile-picture"),value:O,onChange:function(t){e.props.setAttributes({profileViewWebsite:t})}})),wp.element.createElement(_,{label:__("Show Social Media","metronet-profile-picture"),checked:this.state.showSocialMedia,onChange:function(t){e.props.setAttributes({showSocialMedia:t}),e.handleSocialMediaChange(t)}})),"tabbed"===this.state.theme&&wp.element.createElement(g,{title:__("User Profile Settings","metronet-profile-picture")},wp.element.createElement(C,{label:__("Select a theme","metronet-profile-picture"),value:this.state.latestPostsTheme,options:{},onChange:function(t){e.on_user_change(t),X({user_id:Number(t)})}})),wp.element.createElement(g,{title:__("Colors","metronet-profile-picture"),initialOpen:!1},wp.element.createElement(x,{title:__("Background Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:d,onChange:$,label:__("Background Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Text Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:T,onChange:J,label:__("Text Color","metronet-profile-picture")}]}),"profile"===this.state.theme&&wp.element.createElement(x,{title:__("Link Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:G,onChange:ne,label:__("Link Color","metronet-profile-picture")}]}),"tabbed"===this.state.theme&&wp.element.createElement(h,null,wp.element.createElement(x,{title:__("Profile Tab Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabColor,onChange:this.onChangeProfileTabColor,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Profile Tab Color Text","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabTextColor,onChange:this.onChangeProfileTabColorText,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Profile Posts Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabPostsColor,onChange:this.onChangePostsTabColor,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Profile Post Color Text","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabPostsTextColor,onChange:this.onChangeProfileTabPostColorText,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Profile Headline Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabHeadlineColor,onChange:this.onChangePostsTabHeadlineColor,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Profile Headline Color Text","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabHeadlineColorText,onChange:this.onChangeProfileTabHeadlineColorText,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(C,{label:__("Select a Post Theme","metronet-profile-picture"),value:this.state.profileLatestPostsOptionsValue,options:le,onChange:function(t){e.onLatestPostsChange(t),X({profileLatestPostsOptionsValue:t})}})),"tabbed"!==this.state.theme&&"profile"!==this.state.theme&&wp.element.createElement(h,null,wp.element.createElement(x,{title:__("View Posts Background Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:A,onChange:K,label:__("View Posts Background","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("View Posts Text Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:I,onChange:Q,label:__("View Posts Text Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Website Background Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:F,onChange:ee,label:__("View Website Background","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("View Website Text Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:W,onChange:te,label:__("View Website Text Color","metronet-profile-picture")}]}))),wp.element.createElement(g,{title:__("Spacing and Font Settings","metronet-profile-picture"),initialOpen:!1},wp.element.createElement(w,{label:__("Header Font Size","metronet-profile-picture"),value:f,onChange:function(t){return e.props.setAttributes({headerFontSize:t})},min:14,max:32,step:1}),wp.element.createElement(w,{label:__("Font Size","metronet-profile-picture"),value:u,onChange:function(t){return e.props.setAttributes({profileFontSize:t})},min:14,max:24,step:1}),"tabbed"!==this.state.theme&&wp.element.createElement(w,{label:__("Button Size","metronet-profile-picture"),value:m,onChange:function(t){return e.props.setAttributes({buttonFontSize:t})},min:10,max:24,step:1}),wp.element.createElement(w,{label:__("Padding","metronet-profile-picture"),value:j,onChange:function(t){return e.props.setAttributes({padding:t})},min:0,max:60,step:1}),wp.element.createElement(w,{label:__("Border","metronet-profile-picture"),value:z,onChange:function(t){return e.props.setAttributes({border:t})},min:0,max:10,step:1}),wp.element.createElement(w,{label:__("Border Rounded","metronet-profile-picture"),value:q,onChange:function(t){return e.props.setAttributes({borderRounded:t})},min:0,max:10,step:1}),wp.element.createElement(x,{title:__("Border Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:Z,onChange:oe,label:__("Border Color","metronet-profile-picture")}]})),wp.element.createElement(g,{title:__("Social Media Settings","metronet-profile-picture"),initialOpen:!1},wp.element.createElement(C,{label:__("Social Media Colors","metronet-profile-picture"),value:this.state.socialMediaOptions,options:ae,onChange:function(t){X({socialMediaOptions:t}),e.handleSocialMediaOptionChange(t)}}),"custom"===this.state.socialMediaOptions&&wp.element.createElement(x,{title:__("Social Media Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:D,onChange:re,label:__("Social Media Color","metronet-profile-picture")}]}),wp.element.createElement(E,{label:__("Facebook","metronet-profile-picture"),value:this.state.socialFacebook,onChange:function(t){e.props.setAttributes({socialFacebook:t}),e.handleFacebookChange(t)}}),wp.element.createElement(E,{label:__("Twitter","metronet-profile-picture"),value:this.state.socialTwitter,onChange:function(t){e.props.setAttributes({socialTwitter:t}),e.handleTwitterChange(t)}}),wp.element.createElement(E,{label:__("Instagram","metronet-profile-picture"),value:this.state.socialInstagram,onChange:function(t){e.props.setAttributes({socialInstagram:t}),e.handleInstagramChange(t)}}),wp.element.createElement(E,{label:__("LinkedIn","metronet-profile-picture"),value:this.state.socialLinkedIn,onChange:function(t){e.props.setAttributes({socialLinkedIn:t}),e.handleLinkedInChange(t)}}),wp.element.createElement(E,{label:__("YouTube","metronet-profile-picture"),value:this.state.socialYouTube,onChange:function(t){e.props.setAttributes({socialYouTube:t}),e.handleYouTubeChange(t)}}),wp.element.createElement(E,{label:__("GitHub","metronet-profile-picture"),value:this.state.socialGitHub,onChange:function(t){e.props.setAttributes({socialGitHub:t}),e.handleGitHubChange(t)}}),wp.element.createElement(E,{label:__("Pinterest","metronet-profile-picture"),value:this.state.socialPinterest,onChange:function(t){e.props.setAttributes({socialPinterest:t}),e.handlePinterestChange(t)}}),wp.element.createElement(E,{label:__("WordPress","metronet-profile-picture"),value:this.state.socialWordPress,onChange:function(t){e.props.setAttributes({socialWordPress:t}),e.handleWordPressChange(t)}}))),"tabbed"!==this.state.theme&&wp.element.createElement("div",{className:c()("mpp-enhanced-profile-wrap",this.state.theme,a,k,"mpp-block-profile"),style:{padding:j+"px",border:z+"px solid "+Z,borderRadius:q+"px",backgroundColor:d,color:T,float:pe,margin:ce}},"regular"===this.state.theme&&wp.element.createElement(h,null,wp.element.createElement("div",{className:c()("mpp-profile-gutenberg-wrap","mt-font-size-"+u)},wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement(S,{buttonProps:{className:"change-image"},onSelect:function(t){e.handleImageChange(t.id,t.url),X({profileImgID:t.id,profileImgURL:t.url})},type:"image",value:s,render:function(e){var t=e.open;return wp.element.createElement(y,{onClick:t},s?wp.element.createElement("img",{className:"profile-avatar",src:l,alt:"avatar"}):wp.element.createElement("img",{src:l,alt:"placeholder"}))}}))),wp.element.createElement("div",{className:"mpp-content-wrap"},H&&wp.element.createElement(N,{tagName:"h2",placeholder:__("Add name","metronet-profile-picture"),value:o,className:"mpp-profile-name",style:{color:T,fontSize:f+"px"},onChange:function(t){e.onChangeName(t),X({profileName:t})}}),V&&wp.element.createElement(N,{tagName:"p",placeholder:__("Add title","atomic-blocks"),value:n,className:"mpp-profile-title",style:{color:T},onChange:function(t){e.onChangeTitle(t),X({profileTitle:t})}}),R&&wp.element.createElement(N,{tagName:"div",className:"mpp-profile-text",placeholder:__("Add profile text...","metronet-profile-picture"),value:i,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeProfileText(t),X({profileContent:t})}}))),p&&!!p.length&&wp.element.createElement("div",{className:"mpp-gutenberg-view-posts",style:{width:B}},M&&wp.element.createElement("div",{className:"mpp-profile-view-posts",style:{backgroundColor:A,color:I,width:B,fontSize:m+"px"}},wp.element.createElement("a",{href:p,style:{backgroundColor:A,color:I}},L)),""!=this.state.website&&U&&wp.element.createElement("div",{className:"mpp-profile-view-website",style:{backgroundColor:F,color:W,fontSize:m+"px"}},wp.element.createElement("a",{href:this.state.website,style:{backgroundColor:F,color:W}},O)))),"profile"===this.state.theme&&wp.element.createElement("div",{className:c()("mpp-profile-gutenberg-wrap","mt-font-size-"+u)},H&&wp.element.createElement(N,{tagName:"h2",placeholder:__("Add name","metronet-profile-picture"),value:o,className:"mpp-profile-name",style:{color:T,fontSize:f+"px"},onChange:function(t){e.onChangeName(t),X({profileName:t})}}),wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement(S,{buttonProps:{className:"change-image"},onSelect:function(t){e.handleImageChange(t.id,t.url),X({profileImgID:t.id,profileImgURL:t.url})},type:"image",value:s,render:function(e){var t=e.open;return wp.element.createElement(y,{onClick:t},s?wp.element.createElement("img",{className:"profile-avatar",src:l,alt:"avatar"}):wp.element.createElement("img",{src:l,alt:"placeholder"}))}}))),R&&wp.element.createElement(N,{tagName:"div",className:"mpp-profile-text",placeholder:__("Add profile text...","metronet-profile-picture"),value:i,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeProfileText(t),X({profileContent:t})}}),wp.element.createElement("div",{className:"mpp-profile-meta",style:{fontSize:m+"px"}},M&&wp.element.createElement("div",{className:"mpp-profile-link alignleft"},wp.element.createElement("a",{href:this.state.profile_url,style:{color:G}},__("View all posts by","metronet-profile-picture")," ",this.state.profile_name_unfiltered)),""!=this.state.website&&U&&wp.element.createElement("div",{className:"mpp-profile-link alignright"},wp.element.createElement("a",{href:this.state.website,style:{color:G}},__("Website","metronet-profile-picture"))))),"compact"===this.state.theme&&wp.element.createElement("div",{className:c()("mpp-profile-gutenberg-wrap","mt-font-size-"+u)},H&&wp.element.createElement(N,{tagName:"h2",placeholder:__("Add name","metronet-profile-picture"),value:o,className:"mpp-profile-name",style:{color:T,fontSize:f+"px"},onChange:function(t){e.onChangeName(t),X({profileName:t})}}),wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement(S,{buttonProps:{className:"change-image"},onSelect:function(t){e.handleImageChange(t.id,t.url),X({profileImgID:t.id,profileImgURL:t.url})},type:"image",value:s,render:function(e){var t=e.open;return wp.element.createElement(y,{onClick:t},s?wp.element.createElement("img",{className:"profile-avatar",src:l,alt:"avatar"}):wp.element.createElement("img",{src:l,alt:"placeholder"}))}}))),R&&wp.element.createElement(N,{tagName:"div",className:"mpp-profile-text",placeholder:__("Add profile text...","metronet-profile-picture"),value:i,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeProfileText(t),X({profileContent:t})}}),wp.element.createElement("div",{className:"mpp-compact-meta"},M&&wp.element.createElement("div",{className:"mpp-profile-view-posts",style:{backgroundColor:A,color:I,width:"90%",margin:"0 auto 10px auto",fontSize:m+"px"}},wp.element.createElement("a",{href:p,style:{backgroundColor:A,color:I}},__("View Posts","metronet-profile-picture"))),""!=this.state.website&&U&&wp.element.createElement("div",{className:"mpp-profile-view-website",style:{backgroundColor:F,color:W,fontSize:m+"px",width:"90%",margin:"0 auto"}},wp.element.createElement("a",{href:this.state.website,style:{backgroundColor:F,color:W}},__("View Website","metronet-profile-picture"))))),1==this.state.showSocialMedia&&("regular"===this.state.theme||"compact"===this.state.theme||"profile"===this.state.theme)&&wp.element.createElement("div",{className:"mpp-social"},""!=this.state.socialFacebook&&wp.element.createElement("a",{href:this.state.socialFacebook},wp.element.createElement("svg",{className:"icon icon-facebook",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#facebook"}))),""!=this.state.socialTwitter&&wp.element.createElement("a",{href:this.state.socialTwitter},wp.element.createElement("svg",{className:"icon icon-twitter",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#twitter"}))),""!=this.state.socialInstagram&&wp.element.createElement("a",{href:this.state.socialInstagram},wp.element.createElement("svg",{className:"icon icon-instagram",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#instagram"}))),""!=this.state.socialPinterest&&wp.element.createElement("a",{href:this.state.socialPinterest},wp.element.createElement("svg",{className:"icon icon-pinterest",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#pinterest"}))),""!=this.state.socialLinkedIn&&wp.element.createElement("a",{href:this.state.socialLinkedIn},wp.element.createElement("svg",{className:"icon icon-linkedin",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#linkedin"}))),""!=this.state.socialYouTube&&wp.element.createElement("a",{href:this.state.socialYouTube},wp.element.createElement("svg",{className:"icon icon-youtube",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#youtube"}))),""!=this.state.socialGitHub&&wp.element.createElement("a",{href:this.state.socialGitHub},wp.element.createElement("svg",{className:"icon icon-github",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#github"}))),""!=this.state.socialWordPress&&wp.element.createElement("a",{href:this.state.socialWordPress},wp.element.createElement("svg",{className:"icon icon-wordpress",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#wordpress"}))))),"tabbed"===this.state.theme&&wp.element.createElement(h,null,wp.element.createElement("div",{className:c()("mpp-author-tabbed",this.state.theme,a,k,"mpp-block-profile")},wp.element.createElement("ul",{className:"mpp-author-tabs"},wp.element.createElement("li",{className:c()("mpp-tab-profile","profile"===this.state.activeTab?"active":""),onClick:this.onChangeActiveProfileTab,style:{backgroundColor:this.state.profileTabColor,color:this.state.profileTabTextColor}},wp.element.createElement(N,{tagName:"span",placeholder:__("Add tab name.","metronet-profile-picture"),value:this.state.tabbedAuthorProfile,formattingControls:[],onChange:function(t){e.onChangetabbedAuthorProfile(t),X({tabbedAuthorProfile:t})}})),wp.element.createElement("li",{className:c()("mpp-tab-posts","latest"===this.state.activeTab?"active":""),onClick:this.onChangeActivePostTab,style:{backgroundColor:this.state.profileTabPostsColor,color:this.state.profileTabPostsTextColor}},wp.element.createElement(N,{tagName:"span",placeholder:__("Add tab name.","metronet-profile-picture"),value:this.state.tabbedAuthorLatestPosts,formattingControls:[],onChange:function(t){e.onChangetabbedAuthorLatestPosts(t),X({tabbedAuthorLatestPosts:t})}}))),wp.element.createElement("div",{className:"mpp-tab-wrapper",style:{padding:j+"px",border:z+"px solid "+Z,borderRadius:q+"px",backgroundColor:d,color:T}},"profile"===this.state.activeTab&&wp.element.createElement(h,null,wp.element.createElement("div",{className:"mpp-author-social-wrapper"},wp.element.createElement("div",{className:"mpp-author-heading"},wp.element.createElement(N,{tagName:"div",className:"mpp-author-profile-heading",value:this.state.tabbedAuthorProfileHeading,formattingControls:[],onChange:function(t){e.onChangetabbedAuthorProfileHeading(t),X({profileTabHeadlineTextColor:t})},style:{backgroundColor:this.state.profileTabHeadlineColor,color:this.state.profileTabHeadlineTextColor}})),this.state.showSocialMedia&&wp.element.createElement("div",{className:"mpp-author-social"},wp.element.createElement("div",{className:"mpp-social"},""!=this.state.socialFacebook&&wp.element.createElement("a",{href:this.state.socialFacebook},wp.element.createElement("svg",{className:"icon icon-facebook",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#facebook"}))),""!=this.state.socialTwitter&&wp.element.createElement("a",{href:this.state.socialTwitter},wp.element.createElement("svg",{className:"icon icon-twitter",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#twitter"}))),""!=this.state.socialInstagram&&wp.element.createElement("a",{href:this.state.socialInstagram},wp.element.createElement("svg",{className:"icon icon-instagram",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#instagram"}))),""!=this.state.socialPinterest&&wp.element.createElement("a",{href:this.state.socialPinterest},wp.element.createElement("svg",{className:"icon icon-pinterest",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#pinterest"}))),""!=this.state.socialLinkedIn&&wp.element.createElement("a",{href:this.state.socialLinkedIn},wp.element.createElement("svg",{className:"icon icon-linkedin",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#linkedin"}))),""!=this.state.socialYouTube&&wp.element.createElement("a",{href:this.state.socialYouTube},wp.element.createElement("svg",{className:"icon icon-youtube",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#youtube"}))),""!=this.state.socialGitHub&&wp.element.createElement("a",{href:this.state.socialGitHub},wp.element.createElement("svg",{className:"icon icon-github",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#github"}))),""!=this.state.socialWordPress&&wp.element.createElement("a",{href:this.state.socialWordPress},wp.element.createElement("svg",{className:"icon icon-wordpress",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#wordpress"})))))),wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement(S,{buttonProps:{className:"change-image"},onSelect:function(t){e.handleImageChange(t.id,t.url),X({profileImgID:t.id,profileImgURL:t.url})},type:"image",value:s,render:function(e){var t=e.open;return wp.element.createElement(y,{onClick:t},s?wp.element.createElement("img",{className:"profile-avatar",src:l,alt:"avatar"}):wp.element.createElement("img",{src:l,alt:"placeholder"}))}}),wp.element.createElement(N,{tagName:"div",className:"mpp-author-profile-sub-heading",placeholder:__("Add profile description...","metronet-profile-picture"),value:this.state.tabbedAuthorSubHeading,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeTabbedSubHeading(t),X({tabbedAuthorSubHeading:t})}}))),wp.element.createElement("div",{className:"mpp-tabbed-profile-information"},V&&wp.element.createElement(N,{tagName:"div",className:"mpp-author-profile-title",placeholder:__("Add profile title...","metronet-profile-picture"),value:Y,formattingControls:["bold","italic","strikethrough","link"],onChange:function(e){X({tabbedAuthorProfileTitle:e})}}),H&&wp.element.createElement(N,{tagName:"h2",placeholder:__("Add name","metronet-profile-picture"),value:o,className:"mpp-profile-name",style:{color:T,fontSize:f+"px"},onChange:function(t){e.onChangeName(t),X({profileName:t})}}),R&&wp.element.createElement(N,{tagName:"div",className:c()("mpp-profile-text","mt-font-size-"+u),placeholder:__("Add profile text...","metronet-profile-picture"),value:i,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeProfileText(t),X({profileContent:t})}}))),"latest"===this.state.activeTab&&wp.element.createElement(h,null,this.state.loadingLatestPosts&&wp.element.createElement(h,null,wp.element.createElement("div",null,wp.element.createElement("div",{className:"mpp-spinner"},wp.element.createElement(v,null)))),!this.state.loadingLatestPosts&&wp.element.createElement(h,null,wp.element.createElement("ul",{className:c()("mpp-author-tab-content",this.state.profileLatestPostsOptionsValue)},this.state.latestPosts))))))))}}]),t}(f);t.a=k},function(e,t,r){"use strict";function o(e){var t=new a(e),r=i(a.prototype.request,t);return n.extend(r,a.prototype,t),n.extend(r,t),r}var n=r(0),i=r(4),a=r(16),l=r(1),s=o(l);s.Axios=a,s.create=function(e){return o(n.merge(l,e))},s.Cancel=r(8),s.CancelToken=r(30),s.isCancel=r(7),s.all=function(e){return Promise.all(e)},s.spread=r(31),e.exports=s,e.exports.default=s},function(e,t){e.exports=function(e){return null!=e&&null!=e.constructor&&"function"===typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,r){"use strict";function o(e){this.defaults=e,this.interceptors={request:new a,response:new a}}var n=r(1),i=r(0),a=r(25),l=r(26);o.prototype.request=function(e){"string"===typeof e&&(e=i.merge({url:arguments[0]},arguments[1])),e=i.merge(n,{method:"get"},this.defaults,e),e.method=e.method.toLowerCase();var t=[l,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)r=r.then(t.shift(),t.shift());return r},i.forEach(["delete","get","head","options"],function(e){o.prototype[e]=function(t,r){return this.request(i.merge(r||{},{method:e,url:t}))}}),i.forEach(["post","put","patch"],function(e){o.prototype[e]=function(t,r,o){return this.request(i.merge(o||{},{method:e,url:t,data:r}))}}),e.exports=o},function(e,t){function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function n(e){if(c===setTimeout)return setTimeout(e,0);if((c===r||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.call(this,e,0)}}}function i(e){if(u===clearTimeout)return clearTimeout(e);if((u===o||!u)&&clearTimeout)return u=clearTimeout,clearTimeout(e);try{return u(e)}catch(t){try{return u.call(null,e)}catch(t){return u.call(this,e)}}}function a(){d&&f&&(d=!1,f.length?h=f.concat(h):g=-1,h.length&&l())}function l(){if(!d){var e=n(a);d=!0;for(var t=h.length;t;){for(f=h,h=[];++g<t;)f&&f[g].run();g=-1,t=h.length}f=null,d=!1,i(e)}}function s(e,t){this.fun=e,this.array=t}function p(){}var c,u,m=e.exports={};!function(){try{c="function"===typeof setTimeout?setTimeout:r}catch(e){c=r}try{u="function"===typeof clearTimeout?clearTimeout:o}catch(e){u=o}}();var f,h=[],d=!1,g=-1;m.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];h.push(new s(e,t)),1!==h.length||d||n(l)},s.prototype.run=function(){this.fun.apply(null,this.array)},m.title="browser",m.browser=!0,m.env={},m.argv=[],m.version="",m.versions={},m.on=p,m.addListener=p,m.once=p,m.off=p,m.removeListener=p,m.removeAllListeners=p,m.emit=p,m.prependListener=p,m.prependOnceListener=p,m.listeners=function(e){return[]},m.binding=function(e){throw new Error("process.binding is not supported")},m.cwd=function(){return"/"},m.chdir=function(e){throw new Error("process.chdir is not supported")},m.umask=function(){return 0}},function(e,t,r){"use strict";var o=r(0);e.exports=function(e,t){o.forEach(e,function(r,o){o!==t&&o.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[o])})}},function(e,t,r){"use strict";var o=r(6);e.exports=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(o("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},function(e,t,r){"use strict";e.exports=function(e,t,r,o,n){return e.config=t,r&&(e.code=r),e.request=o,e.response=n,e}},function(e,t,r){"use strict";function o(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var n=r(0);e.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(n.isURLSearchParams(t))i=t.toString();else{var a=[];n.forEach(t,function(e,t){null!==e&&"undefined"!==typeof e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),a.push(o(t)+"="+o(e))}))}),i=a.join("&")}return i&&(e+=(-1===e.indexOf("?")?"?":"&")+i),e}},function(e,t,r){"use strict";var o=r(0),n=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,i,a={};return e?(o.forEach(e.split("\n"),function(e){if(i=e.indexOf(":"),t=o.trim(e.substr(0,i)).toLowerCase(),r=o.trim(e.substr(i+1)),t){if(a[t]&&n.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}}),a):a}},function(e,t,r){"use strict";var o=r(0);e.exports=o.isStandardBrowserEnv()?function(){function e(e){var t=e;return r&&(n.setAttribute("href",t),t=n.href),n.setAttribute("href",t),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}var t,r=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");return t=e(window.location.href),function(r){var n=o.isString(r)?e(r):r;return n.protocol===t.protocol&&n.host===t.host}}():function(){return function(){return!0}}()},function(e,t,r){"use strict";var o=r(0);e.exports=o.isStandardBrowserEnv()?function(){return{write:function(e,t,r,n,i,a){var l=[];l.push(e+"="+encodeURIComponent(t)),o.isNumber(r)&&l.push("expires="+new Date(r).toGMTString()),o.isString(n)&&l.push("path="+n),o.isString(i)&&l.push("domain="+i),!0===a&&l.push("secure"),document.cookie=l.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,r){"use strict";function o(){this.handlers=[]}var n=r(0);o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=o},function(e,t,r){"use strict";function o(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var n=r(0),i=r(27),a=r(7),l=r(1),s=r(28),p=r(29);e.exports=function(e){return o(e),e.baseURL&&!s(e.url)&&(e.url=p(e.baseURL,e.url)),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),n.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||l.adapter)(e).then(function(t){return o(e),t.data=i(t.data,t.headers,e.transformResponse),t},function(t){return a(t)||(o(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,r){"use strict";var o=r(0);e.exports=function(e,t,r){return o.forEach(r,function(r){e=r(e,t)}),e}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";function o(e){if("function"!==typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var r=this;e(function(e){r.reason||(r.reason=new n(e),t(r.reason))})}var n=r(8);o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o(function(t){e=t}),cancel:e}},e.exports=o},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){"use strict";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t}function a(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=r(3),s=r.n(l),p=r(2),c=r.n(p),u=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),m=wp.element,f=m.Component,h=m.Fragment,__=wp.i18n.__,d=wp.components,g=d.PanelBody,b=d.Placeholder,w=(d.QueryControls,d.RangeControl),C=d.SelectControl,v=d.Spinner,E=(d.TextControl,d.ToggleControl),_=(d.Toolbar,d.withAPIData,d.ColorPalette,d.Button),y=wp.editor,T=y.InspectorControls,P=y.BlockControls,S=y.MediaUpload,N=y.RichText,x=y.AlignmentToolbar,k=y.PanelColorSettings,A=function(e){function t(){n(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return e.get_users=function(){s.a.post(mpp_gutenberg.rest_url+"/get_users",{},{headers:{"X-WP-Nonce":mpp_gutenberg.nonce}}).then(function(t){var r,n=Array(),i=Array(),a=0,l="",s=0,p="",c="",u="",m="";$.each(t.data,function(e,t){n[t.ID]={profile_pictures:t.profile_pictures,has_profile_picture:t.has_profile_picture,display_name:t.display_name,description:t.description,is_user_logged_in:t.is_user_logged_in,profile_picture_id:t.profile_picture_id,default_image:t.default_image,permalink:t.permalink},t.is_user_logged_in&&(a=t.ID),i.push({value:t.ID,label:t.display_name})}),0!==e.props.attributes.user_id&&(a=e.props.attributes.user_id);var f=n[a];f.has_profile_picture?(l=e.props.attributes.profileImgURL.length>0?e.props.attributes.profileImgURL:f.profile_pictures.thumbnail,s=e.props.attributes.profileImgID.length>0?e.props.attributes.profileImgID:f.profile_picture_id,p=e.props.attributes.profileName.length>0?e.props.attributes.profileName:f.display_name,u=e.props.attributes.profileTitle.length>0?e.props.attributes.profileTitle:"",m=f.permalink,c=e.props.attributes.profileContent.length>0?e.props.attributes.profileContent:f.description):(p=e.props.attributes.profileName.length>0?e.props.attributes.profileName:f.display_name,u=e.props.attributes.profileTitle.length>0?e.props.attributes.profileTitle:"",c=e.props.attributes.profileContent.length>0?e.props.attributes.profileContent:f.description,l=e.props.attributes.profileImgURL.length>0?e.props.attributes.profileImgURL:f.default_image,s=e.props.attributes.profileImgID.length>0?e.props.attributes.profileImgID:0,m=f.permalink),void 0==c&&(c=""),e.setState((r={loading:!1,users:n,active_user:a,user_list:i,profile_picture:l,profile_picture_id:s},o(r,"active_user",a),o(r,"profile_name",p),o(r,"profile_title",u),o(r,"profile_description",c),o(r,"profile_url",m),r)),e.props.setAttributes({profileContent:c,profileName:p,profileTitle:u,profileURL:m,profileImgID:s,profileImgURL:l})})},e.on_user_change=function(t){var r=e.state.users[t],o="",n=0;r.has_profile_picture?(o=e.state.users[t].profile_pictures.thumbnail,n=e.state.users[t].profile_picture_id):(o=mpp_gutenberg.mystery_man,n=0);var i=e.state.users[t].description;void 0===i&&(i=""),e.props.setAttributes({profileName:e.state.users[t].display_name,profileContent:i,profileTitle:"",profileURL:e.state.users[t].permalink,profileImgURL:o}),e.setState({profile_name:e.state.users[t].display_name,profile_description:i,profile_title:"",profile_picture:o,profile_picture_id:n,active_user:t,profile_url:e.state.users[t].permalink})},e.componentDidMount=function(){e.get_users()},e.handleImageChange=function(t,r){e.setState({profile_picture:r,profile_picture_id:t})},e.onChangeName=function(t){e.setState({profile_name:t})},e.onChangeTitle=function(t){e.setState({profile_title:t})},e.onChangeProfileText=function(t){e.setState({profile_description:t})},e.state={loading:!0,users:!1,user_list:!1,profile_picture:!1,profile_picture_id:0,active_user:!1,profile_description:"",profile_name:"",profile_title:""},e}return a(t,e),u(t,[{key:"render",value:function(){var e=this,t=this.props,r=t.attributes,o=r.profileName,n=r.profileTitle,i=r.profileContent,a=r.profileAlignment,l=r.profileImgURL,s=r.profileImgID,p=r.profileURL,u=r.profileFontSize,m=r.profileBackgroundColor,f=r.profileTextColor,d=r.profileAvatarShape,y=r.profileViewPostsBackgroundColor,A=r.profileViewPostsTextColor,I=r.showTitle,L=r.showName,O=r.showDescription,V=r.showViewPosts,H=(t.attributes,t.isSelected,t.editable,t.className,t.setAttributes);this.state.profile_pictures;s=this.state.profile_picture_id,l=this.state.profile_picture,o=this.state.profile_name,i=this.state.profile_description,n=this.state.profile_title,p=this.state.profile_url;var R=function(e){return H({profileBackgroundColor:e})},M=function(e){return H({profileTextColor:e})},B=function(e){return H({profileViewPostsBackgroundColor:e})},U=function(e){return H({profileViewPostsTextColor:e})},D=[{value:"square",label:__("Square","metronet-profile-picture")},{value:"round",label:__("Round","metronet-profile-picture")}];return wp.element.createElement(h,null,this.state.loading&&wp.element.createElement(h,null,wp.element.createElement(b,null,__("Loading...","metronet-profile-picture"),wp.element.createElement(v,null))),!this.state.loading&&wp.element.createElement(h,null,wp.element.createElement(T,null,wp.element.createElement(g,{title:__("User Profile Settings","metronet-profile-picture")},wp.element.createElement(C,{label:__("Select a user","metronet-profile-picture"),value:this.state.active_user,options:this.state.user_list,onChange:function(t){e.on_user_change(t),H({user_id:Number(t)})}}),wp.element.createElement(w,{label:__("Font Size","metronet-profile-picture"),value:u,onChange:function(t){return e.props.setAttributes({profileFontSize:t})},min:14,max:24,step:1}),wp.element.createElement(C,{label:__("Avatar Shape","metronet-profile-picture"),description:__("Choose between a round or square avatar shape.","metronet-profile-picture"),options:D,value:d,onChange:function(t){return e.props.setAttributes({profileAvatarShape:t})}}),wp.element.createElement(k,{title:__("Background Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:m,onChange:R,label:__("Background Color","metronet-profile-picture")}]}),wp.element.createElement(k,{title:__("Text Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:f,onChange:M,label:__("Text Color","metronet-profile-picture")}]}),wp.element.createElement(k,{title:__("View Posts Background Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:y,onChange:B,label:__("View Posts Background","metronet-profile-picture")}]}),wp.element.createElement(k,{title:__("View Posts Text Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:A,onChange:U,label:__("View Posts Text Color","metronet-profile-picture")}]}),wp.element.createElement(E,{label:__("Show Name","metronet-profile-picture"),checked:L,onChange:function(){return e.props.setAttributes({showName:!L})}}),wp.element.createElement(E,{label:__("Show Title","metronet-profile-picture"),checked:I,onChange:function(){return e.props.setAttributes({showTitle:!I})}}),wp.element.createElement(E,{label:__("Show Description","metronet-profile-picture"),checked:O,onChange:function(){return e.props.setAttributes({showDescription:!O})}}),wp.element.createElement(E,{label:__("Show View Posts","metronet-profile-picture"),checked:V,onChange:function(){return e.props.setAttributes({showViewPosts:!V})}}))),wp.element.createElement(P,{key:"controls"},wp.element.createElement(x,{value:a,onChange:function(e){return H({profileAlignment:e})}})),wp.element.createElement("div",{className:c()("mpp-profile-wrap","legacy",a,d,"mt-font-size-"+u,"mpp-block-profile"),style:{backgroundColor:m,color:f}},wp.element.createElement("div",{className:c()("mpp-profile-gutenberg-wrap")},wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement(S,{buttonProps:{className:"change-image"},onSelect:function(t){e.handleImageChange(t.id,t.url),H({profileImgID:t.id,profileImgURL:t.url})},type:"image",value:s,render:function(e){var t=e.open;return wp.element.createElement(_,{onClick:t},s?wp.element.createElement("img",{class:"profile-avatar",src:l,alt:"avatar"}):wp.element.createElement("img",{src:l,alt:"placeholder"}))}}))),wp.element.createElement("div",{className:"mpp-content-wrap"},L&&wp.element.createElement(N,{tagName:"h2",placeholder:__("Add name","metronet-profile-picture"),value:o,className:"mpp-profile-name",style:{color:f},onChange:function(t){e.onChangeName(t),H({profileName:t})}}),I&&wp.element.createElement(N,{tagName:"p",placeholder:__("Add title","atomic-blocks"),value:n,className:"mpp-profile-title",style:{color:f},onChange:function(t){e.onChangeTitle(t),H({profileTitle:t})}}),O&&wp.element.createElement(N,{tagName:"div",className:"mpp-profile-text",placeholder:__("Add profile text...","metronet-profile-picture"),value:i,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeProfileText(t),H({profileContent:t})}}))),p&&!!p.length&&wp.element.createElement("div",{className:"mpp-gutenberg-view-posts"},V&&wp.element.createElement("div",{className:"mpp-profile-view-posts",style:{backgroundColor:y,color:A}},wp.element.createElement("a",{href:p,style:{backgroundColor:y,color:A}},__("View Posts","metronet-profile-picture")))))))}}]),t}(f);t.a=A}]);
|
1 |
+
!function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(e,t,r){"use strict";function o(e){return"[object Array]"===T.call(e)}function n(e){return"[object ArrayBuffer]"===T.call(e)}function i(e){return"undefined"!==typeof FormData&&e instanceof FormData}function a(e){return"undefined"!==typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function l(e){return"string"===typeof e}function s(e){return"number"===typeof e}function p(e){return"undefined"===typeof e}function c(e){return null!==e&&"object"===typeof e}function u(e){return"[object Date]"===T.call(e)}function m(e){return"[object File]"===T.call(e)}function f(e){return"[object Blob]"===T.call(e)}function h(e){return"[object Function]"===T.call(e)}function d(e){return c(e)&&h(e.pipe)}function g(e){return"undefined"!==typeof URLSearchParams&&e instanceof URLSearchParams}function b(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function w(){return("undefined"===typeof navigator||"ReactNative"!==navigator.product)&&("undefined"!==typeof window&&"undefined"!==typeof document)}function C(e,t){if(null!==e&&"undefined"!==typeof e)if("object"!==typeof e&&(e=[e]),o(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}function v(){function e(e,r){"object"===typeof t[r]&&"object"===typeof e?t[r]=v(t[r],e):t[r]=e}for(var t={},r=0,o=arguments.length;r<o;r++)C(arguments[r],e);return t}function E(e,t,r){return C(t,function(t,o){e[o]=r&&"function"===typeof t?_(t,r):t}),e}var _=r(4),y=r(15),T=Object.prototype.toString;e.exports={isArray:o,isArrayBuffer:n,isBuffer:y,isFormData:i,isArrayBufferView:a,isString:l,isNumber:s,isObject:c,isUndefined:p,isDate:u,isFile:m,isBlob:f,isFunction:h,isStream:d,isURLSearchParams:g,isStandardBrowserEnv:w,forEach:C,merge:v,extend:E,trim:b}},function(e,t,r){"use strict";(function(t){function o(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var n=r(0),i=r(18),a={"Content-Type":"application/x-www-form-urlencoded"},l={adapter:function(){var e;return"undefined"!==typeof XMLHttpRequest?e=r(5):"undefined"!==typeof t&&(e=r(5)),e}(),transformRequest:[function(e,t){return i(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(o(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(o(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"===typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};l.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],function(e){l.headers[e]={}}),n.forEach(["post","put","patch"],function(e){l.headers[e]=n.merge(a)}),e.exports=l}).call(t,r(17))},function(e,t,r){var o,n;!function(){"use strict";function r(){for(var e=[],t=0;t<arguments.length;t++){var o=arguments[t];if(o){var n=typeof o;if("string"===n||"number"===n)e.push(o);else if(Array.isArray(o)&&o.length){var a=r.apply(null,o);a&&e.push(a)}else if("object"===n)for(var l in o)i.call(o,l)&&o[l]&&e.push(l)}}return e.join(" ")}var i={}.hasOwnProperty;"undefined"!==typeof e&&e.exports?(r.default=r,e.exports=r):(o=[],void 0!==(n=function(){return r}.apply(t,o))&&(e.exports=n))}()},function(e,t,r){e.exports=r(14)},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),o=0;o<r.length;o++)r[o]=arguments[o];return e.apply(t,r)}}},function(e,t,r){"use strict";var o=r(0),n=r(19),i=r(21),a=r(22),l=r(23),s=r(6);e.exports=function(e){return new Promise(function(t,p){var c=e.data,u=e.headers;o.isFormData(c)&&delete u["Content-Type"];var m=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",h=e.auth.password||"";u.Authorization="Basic "+btoa(f+":"+h)}if(m.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),m.timeout=e.timeout,m.onreadystatechange=function(){if(m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in m?a(m.getAllResponseHeaders()):null,o=e.responseType&&"text"!==e.responseType?m.response:m.responseText,i={data:o,status:m.status,statusText:m.statusText,headers:r,config:e,request:m};n(t,p,i),m=null}},m.onerror=function(){p(s("Network Error",e,null,m)),m=null},m.ontimeout=function(){p(s("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",m)),m=null},o.isStandardBrowserEnv()){var d=r(24),g=(e.withCredentials||l(e.url))&&e.xsrfCookieName?d.read(e.xsrfCookieName):void 0;g&&(u[e.xsrfHeaderName]=g)}if("setRequestHeader"in m&&o.forEach(u,function(e,t){"undefined"===typeof c&&"content-type"===t.toLowerCase()?delete u[t]:m.setRequestHeader(t,e)}),e.withCredentials&&(m.withCredentials=!0),e.responseType)try{m.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"===typeof e.onDownloadProgress&&m.addEventListener("progress",e.onDownloadProgress),"function"===typeof e.onUploadProgress&&m.upload&&m.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){m&&(m.abort(),p(e),m=null)}),void 0===c&&(c=null),m.send(c)})}},function(e,t,r){"use strict";var o=r(20);e.exports=function(e,t,r,n,i){var a=new Error(e);return o(a,t,r,n,i)}},function(e,t,r){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,r){"use strict";function o(e){this.message=e}o.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},o.prototype.__CANCEL__=!0,e.exports=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});r(10)},function(e,t,r){"use strict";var o=r(11),n=(r.n(o),r(12)),i=(r.n(n),r(13)),a=r(32),l=r(2),s=r.n(l),__=wp.i18n.__,p=wp.blocks.registerBlockType,c=wp.element,u=(c.Component,c.Fragment),m=wp.editor.RichText,f={profileName:{type:"string",default:""},profileTitle:{type:"string",default:""},profileContent:{type:"string",default:""},profileAlignment:{type:"string"},profileImgURL:{type:"string",source:"attribute",attribute:"src",selector:"img",default:""},profileImgID:{type:"number",default:""},profileURL:{type:"string",default:""},profileBackgroundColor:{type:"string",default:"#f2f2f2"},profileTextColor:{type:"string",default:"#32373c"},profileViewPostsBackgroundColor:{type:"string",default:"#cf6d38"},profileViewPostsTextColor:{type:"string",default:"#FFFFFF"},profileViewPostsWidth:{type:"number",default:100},profileFontSize:{type:"number",default:18},profileAvatarShape:{type:"string",default:"square"},showName:{type:"bool",default:!0},showTitle:{type:"bool",default:!0},showDescription:{type:"bool",default:!0},showViewPosts:{type:"bool",default:!0},user_id:{type:"number",default:0}};p("mpp/user-profile",{title:__("User Profile Legacy","metronet-profile-picture"),icon:wp.element.createElement("svg",{id:"Layer_1","data-name":"Layer 1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 753.53 979.74"},wp.element.createElement("title",null,"upp"),wp.element.createElement("path",{d:"M806.37,185.9c0,40.27-30.49,72.9-68.11,72.9s-68.17-32.63-68.17-72.9S700.62,113,738.26,113,806.37,145.64,806.37,185.9Z",transform:"translate(-123.47 -11)",fill:"#4063ad"}),wp.element.createElement("path",{d:"M330.36,183.8c0,40.27-30.49,72.9-68.12,72.9s-68.17-32.63-68.17-72.9,30.52-72.87,68.17-72.87S330.36,143.56,330.36,183.8Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M331.3,888.13V698.21H329c-31.64,0-57.28-27.45-57.28-61.29V336.5a118.37,118.37,0,0,1,5.43-34.79H179.84c-31.94,0-56.37,31.57-56.37,56.34V601.46h48.32V888.13Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M388.59,636.92V990.74H611.88V636.92H671.5V336.5c0-30.63-27.64-69.57-69.6-69.57H398.56c-39.44,0-69.61,38.94-69.61,69.57V636.92Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M584.3,101c0,49.69-37.63,90-84,90S416.12,150.67,416.12,101s37.66-90,84.14-90S584.3,51.27,584.3,101Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M820.61,303.79H724.08a121.69,121.69,0,0,1,4.7,32.71V636.92c0,33.84-25.64,61.29-57.28,61.29h-2.33v192H828.7V603.54H877V360.16C877,335.36,854.62,303.79,820.61,303.79Z",transform:"translate(-123.47 -11)",fill:"#4063ad"})),category:"mpp",attributes:f,edit:a.a,save:function(e){var t=e.attributes,r=t.profileName,o=t.profileTitle,n=t.profileContent,i=t.profileAlignment,a=t.profileImgURL,l=(t.profileImgID,t.profileFontSize),p=t.profileBackgroundColor,c=t.profileTextColor,f=(t.profileLinkColor,t.profileAvatarShape),h=t.profileViewPostsBackgroundColor,d=t.profileViewPostsTextColor,g=t.profileURL,b=t.showTitle,w=t.showName,C=t.showDescription,v=t.showViewPosts;return wp.element.createElement(u,null,wp.element.createElement("div",{className:s()("mpp-profile-wrap",i,f,"mt-font-size-"+l,"mpp-block-profile"),style:{backgroundColor:p,color:c}},wp.element.createElement("div",{className:s()("mpp-profile-gutenberg-wrap","mpp-block-profile"),style:{backgroundColor:p,color:c}},wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement("img",{className:"mpp-profile-avatar",src:a,alt:"avatar"}))),wp.element.createElement("div",{className:"mpp-content-wrap"},r&&!!r.length&&w&&wp.element.createElement(m.Content,{tagName:"h2",className:"mpp-profile-name",style:{color:c},value:r}),o&&!!o.length&&b&&wp.element.createElement(m.Content,{tagName:"p",className:"mpp-profile-title",style:{color:c},value:o}),n&&!!n.length&&C&&wp.element.createElement(m.Content,{tagName:"div",className:"mpp-profile-text",value:n}))),g&&!!g.length&&wp.element.createElement("div",{className:"mpp-gutenberg-view-posts"},v&&wp.element.createElement("div",{className:"mpp-profile-view-posts",style:{backgroundColor:h,color:d}},wp.element.createElement("a",{href:g,style:{backgroundColor:h,color:d}},__("View Posts","metronet-profile-picture"))))))}}),p("mpp/user-profile-enhanced",{title:__("User Profile","metronet-profile-picture"),icon:wp.element.createElement("svg",{id:"Layer_1","data-name":"Layer 1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 753.53 979.74"},wp.element.createElement("title",null,"upp"),wp.element.createElement("path",{d:"M806.37,185.9c0,40.27-30.49,72.9-68.11,72.9s-68.17-32.63-68.17-72.9S700.62,113,738.26,113,806.37,145.64,806.37,185.9Z",transform:"translate(-123.47 -11)",fill:"#4063ad"}),wp.element.createElement("path",{d:"M330.36,183.8c0,40.27-30.49,72.9-68.12,72.9s-68.17-32.63-68.17-72.9,30.52-72.87,68.17-72.87S330.36,143.56,330.36,183.8Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M331.3,888.13V698.21H329c-31.64,0-57.28-27.45-57.28-61.29V336.5a118.37,118.37,0,0,1,5.43-34.79H179.84c-31.94,0-56.37,31.57-56.37,56.34V601.46h48.32V888.13Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M388.59,636.92V990.74H611.88V636.92H671.5V336.5c0-30.63-27.64-69.57-69.6-69.57H398.56c-39.44,0-69.61,38.94-69.61,69.57V636.92Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M584.3,101c0,49.69-37.63,90-84,90S416.12,150.67,416.12,101s37.66-90,84.14-90S584.3,51.27,584.3,101Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M820.61,303.79H724.08a121.69,121.69,0,0,1,4.7,32.71V636.92c0,33.84-25.64,61.29-57.28,61.29h-2.33v192H828.7V603.54H877V360.16C877,335.36,854.62,303.79,820.61,303.79Z",transform:"translate(-123.47 -11)",fill:"#4063ad"})),category:"mpp",getEditWrapperProps:function(e){},edit:i.a,save:function(){return null}})},function(e,t){},function(e,t){},function(e,t,r){"use strict";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t}function a(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=r(3),s=r.n(l),p=r(2),c=r.n(p),u=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),m=wp.element,f=m.Component,h=m.Fragment,__=wp.i18n.__,d=wp.components,g=d.PanelBody,b=d.Placeholder,w=(d.QueryControls,d.RangeControl),C=d.SelectControl,v=d.Spinner,E=d.TextControl,_=d.ToggleControl,y=(d.Toolbar,d.withAPIData,d.ColorPalette,d.Button),T=wp.editor,P=T.InspectorControls,S=(T.BlockControls,T.MediaUpload),N=T.RichText,x=(T.AlignmentToolbar,T.PanelColorSettings),k=function(e){function t(){n(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));e.get_users=function(){s.a.post(mpp_gutenberg.rest_url+"/get_users",{},{headers:{"X-WP-Nonce":mpp_gutenberg.nonce}}).then(function(t){var r,n=Array(),i=Array(),a=0,l="",s=0,p="",c="",u="",m="",f="";jQuery.each(t.data,function(e,t){n[t.ID]={profile_pictures:t.profile_pictures,has_profile_picture:t.has_profile_picture,display_name:t.display_name,description:t.description,is_user_logged_in:t.is_user_logged_in,profile_picture_id:t.profile_picture_id,default_image:t.default_image,permalink:t.permalink},t.is_user_logged_in&&(a=t.ID),i.push({value:t.ID,label:t.display_name})}),0!==e.props.attributes.user_id&&(a=e.props.attributes.user_id);var h=n[a];h.has_profile_picture?(l=e.props.attributes.profileImgURL.length>0?e.props.attributes.profileImgURL:h.profile_pictures.thumbnail,s=e.props.attributes.profileImgID.length>0?e.props.attributes.profileImgID:h.profile_picture_id,p=e.props.attributes.profileName.length>0?e.props.attributes.profileName:h.display_name,u=e.props.attributes.profileTitle.length>0?e.props.attributes.profileTitle:"",m=h.permalink,c=e.props.attributes.profileContent.length>0?e.props.attributes.profileContent:h.description,f=e.props.attributes.showWebsite):(p=e.props.attributes.profileName.length>0?e.props.attributes.profileName:h.display_name,u=e.props.attributes.profileTitle.length>0?e.props.attributes.profileTitle:"",c=e.props.attributes.profileContent.length>0?e.props.attributes.profileContent:h.description,l=e.props.attributes.profileImgURL.length>0?e.props.attributes.profileImgURL:h.default_image,s=e.props.attributes.profileImgID.length>0?e.props.attributes.profileImgID:0,m=h.permalink,f=e.props.attributes.showWebsite),void 0==c&&(c=""),e.setState((r={loading:!1,users:n,active_user:a,user_list:i,profile_picture:l,profile_picture_id:s},o(r,"active_user",a),o(r,"profile_name",p),o(r,"profile_name_unfiltered",h.display_name),o(r,"profile_title",u),o(r,"profile_description",c),o(r,"profile_url",m),o(r,"show_website",f),r)),e.props.setAttributes(o({profileContent:c,profileName:p,profileTitle:u,profileURL:m,profileImgID:s,profileImgURL:l,showWebsite:f,showSocialMedia:!0},"profileName",h.display_name))})},e.on_user_change=function(t){var r=e.state.users[t],n="",i=0,a="";r.has_profile_picture?(n=e.state.users[t].profile_pictures.thumbnail,i=e.state.users[t].profile_picture_id):(n=mpp_gutenberg.mystery_man,i=0);var l=e.state.users[t].description;void 0===l&&(l=""),a=e.state.users[t].display_name,e.props.setAttributes(o({profileName:a,profileContent:l,profileTitle:"",profileURL:e.state.users[t].permalink,profileImgURL:n,tabbedAuthorSubHeading:"",tabbedAuthorProfileTitle:"",socialFacebook:"",socialGitHub:"",socialInstagram:"",socialLinkedIn:"",socialPinterest:"",socialTwitter:"",socialWordPress:"",socialYouTube:""},"profileName",e.state.users[t].display_name)),e.setState({profile_name_unfiltered:e.state.users[t].display_name,profile_name:a,profile_description:l,profile_title:"",profile_picture:n,profile_picture_id:i,active_user:t,profile_url:e.state.users[t].permalink,socialFacebook:"",socialGitHub:"",socialInstagram:"",socialLinkedIn:"",socialPinterest:"",socialTwitter:"",socialWordPress:"",socialYouTube:""}),e.getLatestPosts()},e.getLatestPosts=function(){e.setState({loadingLatestPosts:!0});s.a.post(mpp_gutenberg.rest_url+"/get_posts",{user_id:e.state.active_user},{headers:{"X-WP-Nonce":mpp_gutenberg.nonce}}).then(function(t){var r=t.data,o=r.map(function(e){return wp.element.createElement("li",{key:e.ID},wp.element.createElement("a",{href:e.permalink},e.post_title))});e.setState({loadingLatestPosts:!1,latestPosts:o})})},e.componentDidMount=function(){e.get_users()},e.handleImageChange=function(t,r){e.setState({profile_picture:r,profile_picture_id:t})},e.onChangeName=function(t){e.setState({profile_name:t})},e.onChangeTitle=function(t){e.setState({profile_title:t})},e.onChangeProfileText=function(t){e.setState({profile_description:t})},e.onThemeChange=function(t){e.setState({theme:t})},e.handleFacebookChange=function(t){e.setState({socialFacebook:t})},e.handleYouTubeChange=function(t){e.setState({socialYouTube:t})},e.handleGitHubChange=function(t){e.setState({socialGitHub:t})},e.handleLinkedInChange=function(t){e.setState({socialLinkedIn:t})},e.handleTwitterChange=function(t){e.setState({socialTwitter:t})},e.handleWordPressChange=function(t){e.setState({socialWordPress:t})},e.handleWebsiteChange=function(t){e.setState({website:t}),""!==t&&e.props.setAttributes({showWebsite:!0})},e.handleInstagramChange=function(t){e.setState({socialInstagram:t})},e.handlePinterestChange=function(t){e.setState({socialPinterest:t})},e.handleSocialMediaChange=function(t){e.setState({showSocialMedia:t}),e.props.setAttributes({showSocialMedia:t})},e.handleSocialMediaOptionChange=function(t){e.setState({socialMediaOptions:t})},e.onChangeTabbedProfileText=function(t){e.setState({tabbedAuthorProfile:t})},e.onChangeTabbedSubHeading=function(t){e.setState({tabbedAuthorSubHeading:t})},e.onChangeActiveProfileTab=function(){e.setState({activeTab:"profile"})},e.onChangeActivePostTab=function(){e.setState({activeTab:"latest",loadingLatestPosts:!0}),e.getLatestPosts()},e.onChangetabbedAuthorProfile=function(t){e.setState({tabbedAuthorProfile:t})},e.onChangetabbedAuthorProfileHeading=function(t){e.setState({tabbedAuthorProfileHeading:t})},e.onChangetabbedAuthorLatestPosts=function(t){e.setState({tabbedAuthorLatestPosts:t})},e.onChangeProfileTabColor=function(t){e.setState({profileTabColor:t}),e.props.setAttributes({profileTabColor:t})},e.onChangePostsTabColor=function(t){e.setState({profileTabPostsColor:t}),e.props.setAttributes({profileTabPostsColor:t})},e.onChangePostsTabHeadlineColor=function(t){e.setState({profileTabHeadlineColor:t}),e.props.setAttributes({profileTabHeadlineColor:t})},e.onChangeProfileTabPostColorText=function(t){e.setState({profileTabPostsTextColor:t}),e.props.setAttributes({profileTabPostsTextColor:t})},e.onChangeProfileTabHeadlineColorText=function(t){e.setState({profileTabHeadlineTextColor:t}),e.props.setAttributes({profileTabHeadlineTextColor:t})},e.onChangeProfileTabColorText=function(t){e.setState({profileTabTextColor:t}),e.props.setAttributes({profileTabTextColor:t})},e.onLatestPostsChange=function(t){e.setState({profileLatestPostsOptionsValue:t})},e.onCompactAlignmentChange=function(t){e.setState({profileCompactAlignment:t})};var r=Array();return r.push({value:"regular",label:__("Regular","metronet-profile-picture")}),r.push({value:"profile",label:__("Profile","metronet-profile-picture")}),r.push({value:"tabbed",label:__("Tabbed","metronet-profile-picture")}),r.push({value:"compact",label:__("Compact","metronet-profile-picture")}),e.state={loading:!0,users:!1,user_list:!1,profile_picture:e.props.attributes.profileImgURL,profile_picture_id:e.props.attributes.profileImgID,active_user:!1,profile_description:"",profile_name:"",profile_name_unfiltered:"",profile_title:"",show_website:e.props.attributes.showWebsite,profileViewPosts:e.props.attributes.profileViewPosts,profileViewWebsite:e.props.attributes.profileViewWebsite,theme:e.props.attributes.theme,themes:r,socialFacebook:e.props.attributes.socialFacebook,socialGitHub:e.props.attributes.socialGitHub,socialLinkedIn:e.props.attributes.socialLinkedIn,socialPinterest:e.props.attributes.socialPinterest,socialTwitter:e.props.attributes.socialTwitter,socialWordPress:e.props.attributes.socialWordPress,socialYouTube:e.props.attributes.socialYouTube,socialInstagram:e.props.attributes.socialInstagram,website:e.props.attributes.website,showSocialMedia:!0,socialMediaOptions:e.props.attributes.socialMediaOptions,socialMediaColors:e.props.attributes.socialMediaColors,tabbedAuthorProfile:e.props.attributes.tabbedAuthorProfile,tabbedAuthorLatestPosts:e.props.attributes.tabbedAuthorLatestPosts,tabbedAuthorSubHeading:e.props.attributes.tabbedAuthorSubHeading,tabbedAuthorProfileHeading:e.props.attributes.tabbedAuthorProfileHeading,activeTab:"profile",loadingLatestPosts:!0,latestPosts:{},profileTabColor:e.props.attributes.profileTabColor,profileTabHeadlineColor:e.props.attributes.profileTabHeadlineColor,profileTabPostsColor:e.props.attributes.profileTabPostsColor,profileTabHeadlineTextColor:e.props.attributes.profileTabHeadlineTextColor,profileTabTextColor:e.props.attributes.profileTabTextColor,profileTabPostsTextColor:e.props.attributes.profileTabPostsTextColor,profileLatestPostsOptionsValue:e.props.attributes.profileLatestPostsOptionsValue,profileCompactAlignment:e.props.attributes.profileCompactAlignment},e}return a(t,e),u(t,[{key:"render",value:function(){var e=this,t=this.props,r=t.attributes,o=r.profileName,n=r.profileTitle,i=r.profileContent,a=r.profileAlignment,l=r.profileImgURL,s=r.profileImgID,p=r.profileURL,u=r.profileFontSize,m=r.buttonFontSize,f=r.headerFontSize,d=r.profileBackgroundColor,T=r.profileTextColor,k=r.profileAvatarShape,A=r.profileViewPostsBackgroundColor,I=r.profileViewPostsTextColor,L=r.profileViewPosts,O=r.profileViewWebsite,V=r.showTitle,H=r.showName,R=r.showDescription,M=r.showViewPosts,B=r.showPostsWidth,U=(r.showSocialMedia,r.showWebsite),D=(r.theme,r.theme_list,r.socialFacebook,r.socialGitHub,r.socialLinkedIn,r.socialPinterest,r.socialTwitter,r.socialWordPress,r.socialYouTube,r.socialMediaColors),F=r.profileWebsiteBackgroundColor,W=r.profileWebsiteTextColor,j=r.padding,z=r.border,q=r.borderRounded,Z=r.borderColor,G=r.profileLinkColor,Y=(r.tabbedAuthorProfile,r.tabbedAuthorSubHeading,r.tabbedAuthorProfileTitle),X=(r.profileLatestPostsOptionsValue,t.attributes,t.isSelected,t.editable,t.className,t.setAttributes);this.state.profile_pictures;s=this.state.profile_picture_id,l=this.state.profile_picture,o=this.state.profile_name,i=this.state.profile_description,n=this.state.profile_title,p=this.state.profile_url,B=""!==this.state.website&&this.props.attributes.showWebsite?"":"100%",X({showPostsWidth:B});var $=function(e){return X({profileBackgroundColor:e})},J=function(e){return X({profileTextColor:e})},Q=function(e){return X({profileViewPostsBackgroundColor:e})},K=function(e){return X({profileViewPostsTextColor:e})},ee=function(e){return X({profileWebsiteBackgroundColor:e})},te=function(e){return X({profileWebsiteTextColor:e})},re=function(e){return X({socialMediaColors:e})},oe=function(e){return X({borderColor:e})},ne=function(e){return X({profileLinkColor:e})},ie=[{value:"square",label:__("Square","metronet-profile-picture")},{value:"round",label:__("Round","metronet-profile-picture")}],ae=[{value:"colors",label:__("Brand Colors","metronet-profile-picture")},{value:"custom",label:__("Custom","metronet-profile-picture")}],le=[{value:"none",label:__("None","metronet-profile-picture")},{value:"white",label:__("White","metronet-profile-picture")},{value:"light",label:__("Light","metronet-profile-picture")},{value:"black",label:__("Black","metronet-profile-picture")},{value:"magenta",label:__("Magenta","metronet-profile-picture")},{value:"blue",label:__("Blue","metronet-profile-picture")},{value:"green",label:__("Green","metronet-profile-picture")}],se=[{value:"left",label:__("Left","metronet-profile-picture")},{value:"center",label:__("Center","metronet-profile-picture")},{value:"right",label:__("Right","metronet-profile-picture")}],pe="none",ce="";return"center"===this.state.profileCompactAlignment&&(pe="none",ce="0 auto"),"left"===this.state.profileCompactAlignment&&(pe="left",ce="0"),"right"===this.state.profileCompactAlignment&&(pe="right",ce="0"),wp.element.createElement(h,null,this.state.loading&&wp.element.createElement(h,null,wp.element.createElement(b,null,wp.element.createElement("div",null,wp.element.createElement("svg",{id:"Layer_1","data-name":"Layer 1",xmlns:"http://www.w3.org/2000/svg",width:"125px",height:"125px",viewBox:"0 0 753.53 979.74"},wp.element.createElement("title",null,"upp"),wp.element.createElement("path",{d:"M806.37,185.9c0,40.27-30.49,72.9-68.11,72.9s-68.17-32.63-68.17-72.9S700.62,113,738.26,113,806.37,145.64,806.37,185.9Z",transform:"translate(-123.47 -11)",fill:"#4063ad"}),wp.element.createElement("path",{d:"M330.36,183.8c0,40.27-30.49,72.9-68.12,72.9s-68.17-32.63-68.17-72.9,30.52-72.87,68.17-72.87S330.36,143.56,330.36,183.8Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M331.3,888.13V698.21H329c-31.64,0-57.28-27.45-57.28-61.29V336.5a118.37,118.37,0,0,1,5.43-34.79H179.84c-31.94,0-56.37,31.57-56.37,56.34V601.46h48.32V888.13Z",transform:"translate(-123.47 -11)",fill:"#a34d9c"}),wp.element.createElement("path",{d:"M388.59,636.92V990.74H611.88V636.92H671.5V336.5c0-30.63-27.64-69.57-69.6-69.57H398.56c-39.44,0-69.61,38.94-69.61,69.57V636.92Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M584.3,101c0,49.69-37.63,90-84,90S416.12,150.67,416.12,101s37.66-90,84.14-90S584.3,51.27,584.3,101Z",transform:"translate(-123.47 -11)",fill:"#f4831f"}),wp.element.createElement("path",{d:"M820.61,303.79H724.08a121.69,121.69,0,0,1,4.7,32.71V636.92c0,33.84-25.64,61.29-57.28,61.29h-2.33v192H828.7V603.54H877V360.16C877,335.36,854.62,303.79,820.61,303.79Z",transform:"translate(-123.47 -11)",fill:"#4063ad"})),wp.element.createElement("div",{className:"mpp-spinner"},wp.element.createElement(v,null))))),!this.state.loading&&wp.element.createElement(h,null,wp.element.createElement(P,null,wp.element.createElement(g,{title:__("User Profile Settings","metronet-profile-picture")},wp.element.createElement(C,{label:__("Select a user","metronet-profile-picture"),value:this.state.active_user,options:this.state.user_list,onChange:function(t){e.on_user_change(t),X({user_id:Number(t)})}}),wp.element.createElement(C,{label:__("Select a theme","metronet-profile-picture"),value:this.state.theme,options:this.state.themes,onChange:function(t){e.onThemeChange(t),X({theme:t})}}),"compact"===this.state.theme&&wp.element.createElement(C,{label:__("Select an alignment","metronet-profile-picture"),value:this.state.profileCompactAlignment,options:se,onChange:function(t){e.onCompactAlignmentChange(t),X({profileCompactAlignment:t})}}),wp.element.createElement(C,{label:__("Avatar Shape","metronet-profile-picture"),description:__("Choose between a round or square avatar shape.","metronet-profile-picture"),options:ie,value:k,onChange:function(t){return e.props.setAttributes({profileAvatarShape:t})}}),"tabbed"!==this.state.theme&&wp.element.createElement(E,{label:__("Website","metronet-profile-picture"),value:this.state.website,onChange:function(t){e.props.setAttributes({website:t}),e.handleWebsiteChange(t)}}),wp.element.createElement(_,{label:__("Show Name","metronet-profile-picture"),checked:H,onChange:function(){return e.props.setAttributes({showName:!H})}}),wp.element.createElement(_,{label:__("Show Title","metronet-profile-picture"),checked:V,onChange:function(){return e.props.setAttributes({showTitle:!V})}}),wp.element.createElement(_,{label:__("Show Description","metronet-profile-picture"),checked:R,onChange:function(){return e.props.setAttributes({showDescription:!R})}}),"tabbed"!==this.state.theme&&wp.element.createElement(h,null,wp.element.createElement(_,{label:__("Show View Posts","metronet-profile-picture"),checked:M,onChange:function(){return e.props.setAttributes({showViewPosts:!M})}}),M&&wp.element.createElement(E,{label:__("View Posts Text","metronet-profile-picture"),value:L,onChange:function(t){e.props.setAttributes({profileViewPosts:t})}}),wp.element.createElement(_,{label:__("Show Website","metronet-profile-picture"),checked:this.state.show_website,onChange:function(t){e.props.setAttributes({showWebsite:t}),e.setState({show_website:t})}}),this.state.show_website&&wp.element.createElement(E,{label:__("View Website Text","metronet-profile-picture"),value:O,onChange:function(t){e.props.setAttributes({profileViewWebsite:t})}})),wp.element.createElement(_,{label:__("Show Social Media","metronet-profile-picture"),checked:this.state.showSocialMedia,onChange:function(t){e.props.setAttributes({showSocialMedia:t}),e.handleSocialMediaChange(t)}})),"tabbed"===this.state.theme&&wp.element.createElement(g,{title:__("User Profile Settings","metronet-profile-picture")},wp.element.createElement(C,{label:__("Select a theme","metronet-profile-picture"),value:this.state.latestPostsTheme,options:{},onChange:function(t){e.on_user_change(t),X({user_id:Number(t)})}})),wp.element.createElement(g,{title:__("Colors","metronet-profile-picture"),initialOpen:!1},wp.element.createElement(x,{title:__("Background Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:d,onChange:$,label:__("Background Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Text Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:T,onChange:J,label:__("Text Color","metronet-profile-picture")}]}),"profile"===this.state.theme&&wp.element.createElement(x,{title:__("Link Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:G,onChange:ne,label:__("Link Color","metronet-profile-picture")}]}),"tabbed"===this.state.theme&&wp.element.createElement(h,null,wp.element.createElement(x,{title:__("Profile Tab Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabColor,onChange:this.onChangeProfileTabColor,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Profile Tab Color Text","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabTextColor,onChange:this.onChangeProfileTabColorText,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Profile Posts Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabPostsColor,onChange:this.onChangePostsTabColor,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Profile Post Color Text","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabPostsTextColor,onChange:this.onChangeProfileTabPostColorText,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Profile Headline Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabHeadlineColor,onChange:this.onChangePostsTabHeadlineColor,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Profile Headline Color Text","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:this.state.profileTabHeadlineColorText,onChange:this.onChangeProfileTabHeadlineColorText,label:__("Color","metronet-profile-picture")}]}),wp.element.createElement(C,{label:__("Select a Post Theme","metronet-profile-picture"),value:this.state.profileLatestPostsOptionsValue,options:le,onChange:function(t){e.onLatestPostsChange(t),X({profileLatestPostsOptionsValue:t})}})),"tabbed"!==this.state.theme&&"profile"!==this.state.theme&&wp.element.createElement(h,null,wp.element.createElement(x,{title:__("View Posts Background Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:A,onChange:Q,label:__("View Posts Background","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("View Posts Text Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:I,onChange:K,label:__("View Posts Text Color","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("Website Background Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:F,onChange:ee,label:__("View Website Background","metronet-profile-picture")}]}),wp.element.createElement(x,{title:__("View Website Text Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:W,onChange:te,label:__("View Website Text Color","metronet-profile-picture")}]}))),wp.element.createElement(g,{title:__("Spacing and Font Settings","metronet-profile-picture"),initialOpen:!1},wp.element.createElement(w,{label:__("Header Font Size","metronet-profile-picture"),value:f,onChange:function(t){return e.props.setAttributes({headerFontSize:t})},min:14,max:32,step:1}),wp.element.createElement(w,{label:__("Font Size","metronet-profile-picture"),value:u,onChange:function(t){return e.props.setAttributes({profileFontSize:t})},min:14,max:24,step:1}),"tabbed"!==this.state.theme&&wp.element.createElement(w,{label:__("Button Size","metronet-profile-picture"),value:m,onChange:function(t){return e.props.setAttributes({buttonFontSize:t})},min:10,max:24,step:1}),wp.element.createElement(w,{label:__("Padding","metronet-profile-picture"),value:j,onChange:function(t){return e.props.setAttributes({padding:t})},min:0,max:60,step:1}),wp.element.createElement(w,{label:__("Border","metronet-profile-picture"),value:z,onChange:function(t){return e.props.setAttributes({border:t})},min:0,max:10,step:1}),wp.element.createElement(w,{label:__("Border Rounded","metronet-profile-picture"),value:q,onChange:function(t){return e.props.setAttributes({borderRounded:t})},min:0,max:10,step:1}),wp.element.createElement(x,{title:__("Border Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:Z,onChange:oe,label:__("Border Color","metronet-profile-picture")}]})),wp.element.createElement(g,{title:__("Social Media Settings","metronet-profile-picture"),initialOpen:!1},wp.element.createElement(C,{label:__("Social Media Colors","metronet-profile-picture"),value:this.state.socialMediaOptions,options:ae,onChange:function(t){X({socialMediaOptions:t}),e.handleSocialMediaOptionChange(t)}}),"custom"===this.state.socialMediaOptions&&wp.element.createElement(x,{title:__("Social Media Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:D,onChange:re,label:__("Social Media Color","metronet-profile-picture")}]}),wp.element.createElement(E,{label:__("Facebook","metronet-profile-picture"),value:this.state.socialFacebook,onChange:function(t){e.props.setAttributes({socialFacebook:t}),e.handleFacebookChange(t)}}),wp.element.createElement(E,{label:__("Twitter","metronet-profile-picture"),value:this.state.socialTwitter,onChange:function(t){e.props.setAttributes({socialTwitter:t}),e.handleTwitterChange(t)}}),wp.element.createElement(E,{label:__("Instagram","metronet-profile-picture"),value:this.state.socialInstagram,onChange:function(t){e.props.setAttributes({socialInstagram:t}),e.handleInstagramChange(t)}}),wp.element.createElement(E,{label:__("LinkedIn","metronet-profile-picture"),value:this.state.socialLinkedIn,onChange:function(t){e.props.setAttributes({socialLinkedIn:t}),e.handleLinkedInChange(t)}}),wp.element.createElement(E,{label:__("YouTube","metronet-profile-picture"),value:this.state.socialYouTube,onChange:function(t){e.props.setAttributes({socialYouTube:t}),e.handleYouTubeChange(t)}}),wp.element.createElement(E,{label:__("GitHub","metronet-profile-picture"),value:this.state.socialGitHub,onChange:function(t){e.props.setAttributes({socialGitHub:t}),e.handleGitHubChange(t)}}),wp.element.createElement(E,{label:__("Pinterest","metronet-profile-picture"),value:this.state.socialPinterest,onChange:function(t){e.props.setAttributes({socialPinterest:t}),e.handlePinterestChange(t)}}),wp.element.createElement(E,{label:__("WordPress","metronet-profile-picture"),value:this.state.socialWordPress,onChange:function(t){e.props.setAttributes({socialWordPress:t}),e.handleWordPressChange(t)}}))),"tabbed"!==this.state.theme&&wp.element.createElement("div",{className:c()("mpp-enhanced-profile-wrap",this.state.theme,a,k,"mpp-block-profile"),style:{padding:j+"px",border:z+"px solid "+Z,borderRadius:q+"px",backgroundColor:d,color:T,float:pe,margin:ce}},"regular"===this.state.theme&&wp.element.createElement(h,null,wp.element.createElement("div",{className:c()("mpp-profile-gutenberg-wrap","mt-font-size-"+u)},wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement(S,{buttonProps:{className:"change-image"},onSelect:function(t){e.handleImageChange(t.id,t.url),X({profileImgID:t.id,profileImgURL:t.url})},type:"image",value:s,render:function(e){var t=e.open;return wp.element.createElement(y,{onClick:t},s?wp.element.createElement("img",{className:"profile-avatar",src:l,alt:"avatar"}):wp.element.createElement("img",{src:l,alt:"placeholder"}))}}))),wp.element.createElement("div",{className:"mpp-content-wrap"},H&&wp.element.createElement(N,{tagName:"h2",placeholder:__("Add name","metronet-profile-picture"),value:o,className:"mpp-profile-name",style:{color:T,fontSize:f+"px"},onChange:function(t){e.onChangeName(t),X({profileName:t})}}),V&&wp.element.createElement(N,{tagName:"p",placeholder:__("Add title","atomic-blocks"),value:n,className:"mpp-profile-title",style:{color:T},onChange:function(t){e.onChangeTitle(t),X({profileTitle:t})}}),R&&wp.element.createElement(N,{tagName:"div",className:"mpp-profile-text",placeholder:__("Add profile text...","metronet-profile-picture"),value:i,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeProfileText(t),X({profileContent:t})}}))),p&&!!p.length&&wp.element.createElement("div",{className:"mpp-gutenberg-view-posts",style:{width:B}},M&&wp.element.createElement("div",{className:"mpp-profile-view-posts",style:{backgroundColor:A,color:I,width:B,fontSize:m+"px"}},wp.element.createElement("a",{href:p,style:{backgroundColor:A,color:I}},L)),""!=this.state.website&&U&&wp.element.createElement("div",{className:"mpp-profile-view-website",style:{backgroundColor:F,color:W,fontSize:m+"px"}},wp.element.createElement("a",{href:this.state.website,style:{backgroundColor:F,color:W}},O)))),"profile"===this.state.theme&&wp.element.createElement("div",{className:c()("mpp-profile-gutenberg-wrap","mt-font-size-"+u)},H&&wp.element.createElement(N,{tagName:"h2",placeholder:__("Add name","metronet-profile-picture"),value:o,className:"mpp-profile-name",style:{color:T,fontSize:f+"px"},onChange:function(t){e.onChangeName(t),X({profileName:t})}}),wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement(S,{buttonProps:{className:"change-image"},onSelect:function(t){e.handleImageChange(t.id,t.url),X({profileImgID:t.id,profileImgURL:t.url})},type:"image",value:s,render:function(e){var t=e.open;return wp.element.createElement(y,{onClick:t},s?wp.element.createElement("img",{className:"profile-avatar",src:l,alt:"avatar"}):wp.element.createElement("img",{src:l,alt:"placeholder"}))}}))),R&&wp.element.createElement(N,{tagName:"div",className:"mpp-profile-text",placeholder:__("Add profile text...","metronet-profile-picture"),value:i,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeProfileText(t),X({profileContent:t})}}),wp.element.createElement("div",{className:"mpp-profile-meta",style:{fontSize:m+"px"}},M&&wp.element.createElement("div",{className:"mpp-profile-link alignleft"},wp.element.createElement("a",{href:this.state.profile_url,style:{color:G}},__("View all posts by","metronet-profile-picture")," ",this.state.profile_name_unfiltered)),""!=this.state.website&&U&&wp.element.createElement("div",{className:"mpp-profile-link alignright"},wp.element.createElement("a",{href:this.state.website,style:{color:G}},__("Website","metronet-profile-picture"))))),"compact"===this.state.theme&&wp.element.createElement("div",{className:c()("mpp-profile-gutenberg-wrap","mt-font-size-"+u)},H&&wp.element.createElement(N,{tagName:"h2",placeholder:__("Add name","metronet-profile-picture"),value:o,className:"mpp-profile-name",style:{color:T,fontSize:f+"px"},onChange:function(t){e.onChangeName(t),X({profileName:t})}}),wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement(S,{buttonProps:{className:"change-image"},onSelect:function(t){e.handleImageChange(t.id,t.url),X({profileImgID:t.id,profileImgURL:t.url})},type:"image",value:s,render:function(e){var t=e.open;return wp.element.createElement(y,{onClick:t},s?wp.element.createElement("img",{className:"profile-avatar",src:l,alt:"avatar"}):wp.element.createElement("img",{src:l,alt:"placeholder"}))}}))),R&&wp.element.createElement(N,{tagName:"div",className:"mpp-profile-text",placeholder:__("Add profile text...","metronet-profile-picture"),value:i,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeProfileText(t),X({profileContent:t})}}),wp.element.createElement("div",{className:"mpp-compact-meta"},M&&wp.element.createElement("div",{className:"mpp-profile-view-posts",style:{backgroundColor:A,color:I,width:"90%",margin:"0 auto 10px auto",fontSize:m+"px"}},wp.element.createElement("a",{href:p,style:{backgroundColor:A,color:I}},__("View Posts","metronet-profile-picture"))),""!=this.state.website&&U&&wp.element.createElement("div",{className:"mpp-profile-view-website",style:{backgroundColor:F,color:W,fontSize:m+"px",width:"90%",margin:"0 auto"}},wp.element.createElement("a",{href:this.state.website,style:{backgroundColor:F,color:W}},__("View Website","metronet-profile-picture"))))),1==this.state.showSocialMedia&&("regular"===this.state.theme||"compact"===this.state.theme||"profile"===this.state.theme)&&wp.element.createElement("div",{className:"mpp-social"},""!=this.state.socialFacebook&&wp.element.createElement("a",{href:this.state.socialFacebook},wp.element.createElement("svg",{className:"icon icon-facebook",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#facebook"}))),""!=this.state.socialTwitter&&wp.element.createElement("a",{href:this.state.socialTwitter},wp.element.createElement("svg",{className:"icon icon-twitter",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#twitter"}))),""!=this.state.socialInstagram&&wp.element.createElement("a",{href:this.state.socialInstagram},wp.element.createElement("svg",{className:"icon icon-instagram",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#instagram"}))),""!=this.state.socialPinterest&&wp.element.createElement("a",{href:this.state.socialPinterest},wp.element.createElement("svg",{className:"icon icon-pinterest",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#pinterest"}))),""!=this.state.socialLinkedIn&&wp.element.createElement("a",{href:this.state.socialLinkedIn},wp.element.createElement("svg",{className:"icon icon-linkedin",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#linkedin"}))),""!=this.state.socialYouTube&&wp.element.createElement("a",{href:this.state.socialYouTube},wp.element.createElement("svg",{className:"icon icon-youtube",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#youtube"}))),""!=this.state.socialGitHub&&wp.element.createElement("a",{href:this.state.socialGitHub},wp.element.createElement("svg",{className:"icon icon-github",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#github"}))),""!=this.state.socialWordPress&&wp.element.createElement("a",{href:this.state.socialWordPress},wp.element.createElement("svg",{className:"icon icon-wordpress",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#wordpress"}))))),"tabbed"===this.state.theme&&wp.element.createElement(h,null,wp.element.createElement("div",{className:c()("mpp-author-tabbed",this.state.theme,a,k,"mpp-block-profile")},wp.element.createElement("ul",{className:"mpp-author-tabs"},wp.element.createElement("li",{className:c()("mpp-tab-profile","profile"===this.state.activeTab?"active":""),onClick:this.onChangeActiveProfileTab,style:{backgroundColor:this.state.profileTabColor,color:this.state.profileTabTextColor}},wp.element.createElement(N,{tagName:"span",placeholder:__("Add tab name.","metronet-profile-picture"),value:this.state.tabbedAuthorProfile,formattingControls:[],onChange:function(t){e.onChangetabbedAuthorProfile(t),X({tabbedAuthorProfile:t})}})),wp.element.createElement("li",{className:c()("mpp-tab-posts","latest"===this.state.activeTab?"active":""),onClick:this.onChangeActivePostTab,style:{backgroundColor:this.state.profileTabPostsColor,color:this.state.profileTabPostsTextColor}},wp.element.createElement(N,{tagName:"span",placeholder:__("Add tab name.","metronet-profile-picture"),value:this.state.tabbedAuthorLatestPosts,formattingControls:[],onChange:function(t){e.onChangetabbedAuthorLatestPosts(t),X({tabbedAuthorLatestPosts:t})}}))),wp.element.createElement("div",{className:"mpp-tab-wrapper",style:{padding:j+"px",border:z+"px solid "+Z,borderRadius:q+"px",backgroundColor:d,color:T}},"profile"===this.state.activeTab&&wp.element.createElement(h,null,wp.element.createElement("div",{className:"mpp-author-social-wrapper"},wp.element.createElement("div",{className:"mpp-author-heading"},wp.element.createElement(N,{tagName:"div",className:"mpp-author-profile-heading",value:this.state.tabbedAuthorProfileHeading,formattingControls:[],onChange:function(t){e.onChangetabbedAuthorProfileHeading(t),X({profileTabHeadlineTextColor:t})},style:{backgroundColor:this.state.profileTabHeadlineColor,color:this.state.profileTabHeadlineTextColor}})),this.state.showSocialMedia&&wp.element.createElement("div",{className:"mpp-author-social"},wp.element.createElement("div",{className:"mpp-social"},""!=this.state.socialFacebook&&wp.element.createElement("a",{href:this.state.socialFacebook},wp.element.createElement("svg",{className:"icon icon-facebook",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#facebook"}))),""!=this.state.socialTwitter&&wp.element.createElement("a",{href:this.state.socialTwitter},wp.element.createElement("svg",{className:"icon icon-twitter",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#twitter"}))),""!=this.state.socialInstagram&&wp.element.createElement("a",{href:this.state.socialInstagram},wp.element.createElement("svg",{className:"icon icon-instagram",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#instagram"}))),""!=this.state.socialPinterest&&wp.element.createElement("a",{href:this.state.socialPinterest},wp.element.createElement("svg",{className:"icon icon-pinterest",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#pinterest"}))),""!=this.state.socialLinkedIn&&wp.element.createElement("a",{href:this.state.socialLinkedIn},wp.element.createElement("svg",{className:"icon icon-linkedin",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#linkedin"}))),""!=this.state.socialYouTube&&wp.element.createElement("a",{href:this.state.socialYouTube},wp.element.createElement("svg",{className:"icon icon-youtube",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#youtube"}))),""!=this.state.socialGitHub&&wp.element.createElement("a",{href:this.state.socialGitHub},wp.element.createElement("svg",{className:"icon icon-github",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#github"}))),""!=this.state.socialWordPress&&wp.element.createElement("a",{href:this.state.socialWordPress},wp.element.createElement("svg",{className:"icon icon-wordpress",role:"img",style:{fill:"custom"===this.state.socialMediaOptions?D:""}},wp.element.createElement("use",{href:"#wordpress"})))))),wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement(S,{buttonProps:{className:"change-image"},onSelect:function(t){e.handleImageChange(t.id,t.url),X({profileImgID:t.id,profileImgURL:t.url})},type:"image",value:s,render:function(e){var t=e.open;return wp.element.createElement(y,{onClick:t},s?wp.element.createElement("img",{className:"profile-avatar",src:l,alt:"avatar"}):wp.element.createElement("img",{src:l,alt:"placeholder"}))}}),wp.element.createElement(N,{tagName:"div",className:"mpp-author-profile-sub-heading",placeholder:__("Add profile description...","metronet-profile-picture"),value:this.state.tabbedAuthorSubHeading,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeTabbedSubHeading(t),X({tabbedAuthorSubHeading:t})}}))),wp.element.createElement("div",{className:"mpp-tabbed-profile-information"},V&&wp.element.createElement(N,{tagName:"div",className:"mpp-author-profile-title",placeholder:__("Add profile title...","metronet-profile-picture"),value:Y,formattingControls:["bold","italic","strikethrough","link"],onChange:function(e){X({tabbedAuthorProfileTitle:e})}}),H&&wp.element.createElement(N,{tagName:"h2",placeholder:__("Add name","metronet-profile-picture"),value:o,className:"mpp-profile-name",style:{color:T,fontSize:f+"px"},onChange:function(t){e.onChangeName(t),X({profileName:t})}}),R&&wp.element.createElement(N,{tagName:"div",className:c()("mpp-profile-text","mt-font-size-"+u),placeholder:__("Add profile text...","metronet-profile-picture"),value:i,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeProfileText(t),X({profileContent:t})}}))),"latest"===this.state.activeTab&&wp.element.createElement(h,null,this.state.loadingLatestPosts&&wp.element.createElement(h,null,wp.element.createElement("div",null,wp.element.createElement("div",{className:"mpp-spinner"},wp.element.createElement(v,null)))),!this.state.loadingLatestPosts&&wp.element.createElement(h,null,wp.element.createElement("ul",{className:c()("mpp-author-tab-content",this.state.profileLatestPostsOptionsValue)},this.state.latestPosts))))))))}}]),t}(f);t.a=k},function(e,t,r){"use strict";function o(e){var t=new a(e),r=i(a.prototype.request,t);return n.extend(r,a.prototype,t),n.extend(r,t),r}var n=r(0),i=r(4),a=r(16),l=r(1),s=o(l);s.Axios=a,s.create=function(e){return o(n.merge(l,e))},s.Cancel=r(8),s.CancelToken=r(30),s.isCancel=r(7),s.all=function(e){return Promise.all(e)},s.spread=r(31),e.exports=s,e.exports.default=s},function(e,t){e.exports=function(e){return null!=e&&null!=e.constructor&&"function"===typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,r){"use strict";function o(e){this.defaults=e,this.interceptors={request:new a,response:new a}}var n=r(1),i=r(0),a=r(25),l=r(26);o.prototype.request=function(e){"string"===typeof e&&(e=i.merge({url:arguments[0]},arguments[1])),e=i.merge(n,{method:"get"},this.defaults,e),e.method=e.method.toLowerCase();var t=[l,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)r=r.then(t.shift(),t.shift());return r},i.forEach(["delete","get","head","options"],function(e){o.prototype[e]=function(t,r){return this.request(i.merge(r||{},{method:e,url:t}))}}),i.forEach(["post","put","patch"],function(e){o.prototype[e]=function(t,r,o){return this.request(i.merge(o||{},{method:e,url:t,data:r}))}}),e.exports=o},function(e,t){function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function n(e){if(c===setTimeout)return setTimeout(e,0);if((c===r||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.call(this,e,0)}}}function i(e){if(u===clearTimeout)return clearTimeout(e);if((u===o||!u)&&clearTimeout)return u=clearTimeout,clearTimeout(e);try{return u(e)}catch(t){try{return u.call(null,e)}catch(t){return u.call(this,e)}}}function a(){d&&f&&(d=!1,f.length?h=f.concat(h):g=-1,h.length&&l())}function l(){if(!d){var e=n(a);d=!0;for(var t=h.length;t;){for(f=h,h=[];++g<t;)f&&f[g].run();g=-1,t=h.length}f=null,d=!1,i(e)}}function s(e,t){this.fun=e,this.array=t}function p(){}var c,u,m=e.exports={};!function(){try{c="function"===typeof setTimeout?setTimeout:r}catch(e){c=r}try{u="function"===typeof clearTimeout?clearTimeout:o}catch(e){u=o}}();var f,h=[],d=!1,g=-1;m.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];h.push(new s(e,t)),1!==h.length||d||n(l)},s.prototype.run=function(){this.fun.apply(null,this.array)},m.title="browser",m.browser=!0,m.env={},m.argv=[],m.version="",m.versions={},m.on=p,m.addListener=p,m.once=p,m.off=p,m.removeListener=p,m.removeAllListeners=p,m.emit=p,m.prependListener=p,m.prependOnceListener=p,m.listeners=function(e){return[]},m.binding=function(e){throw new Error("process.binding is not supported")},m.cwd=function(){return"/"},m.chdir=function(e){throw new Error("process.chdir is not supported")},m.umask=function(){return 0}},function(e,t,r){"use strict";var o=r(0);e.exports=function(e,t){o.forEach(e,function(r,o){o!==t&&o.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[o])})}},function(e,t,r){"use strict";var o=r(6);e.exports=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(o("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},function(e,t,r){"use strict";e.exports=function(e,t,r,o,n){return e.config=t,r&&(e.code=r),e.request=o,e.response=n,e}},function(e,t,r){"use strict";function o(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var n=r(0);e.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(n.isURLSearchParams(t))i=t.toString();else{var a=[];n.forEach(t,function(e,t){null!==e&&"undefined"!==typeof e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),a.push(o(t)+"="+o(e))}))}),i=a.join("&")}return i&&(e+=(-1===e.indexOf("?")?"?":"&")+i),e}},function(e,t,r){"use strict";var o=r(0),n=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,i,a={};return e?(o.forEach(e.split("\n"),function(e){if(i=e.indexOf(":"),t=o.trim(e.substr(0,i)).toLowerCase(),r=o.trim(e.substr(i+1)),t){if(a[t]&&n.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}}),a):a}},function(e,t,r){"use strict";var o=r(0);e.exports=o.isStandardBrowserEnv()?function(){function e(e){var t=e;return r&&(n.setAttribute("href",t),t=n.href),n.setAttribute("href",t),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}var t,r=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");return t=e(window.location.href),function(r){var n=o.isString(r)?e(r):r;return n.protocol===t.protocol&&n.host===t.host}}():function(){return function(){return!0}}()},function(e,t,r){"use strict";var o=r(0);e.exports=o.isStandardBrowserEnv()?function(){return{write:function(e,t,r,n,i,a){var l=[];l.push(e+"="+encodeURIComponent(t)),o.isNumber(r)&&l.push("expires="+new Date(r).toGMTString()),o.isString(n)&&l.push("path="+n),o.isString(i)&&l.push("domain="+i),!0===a&&l.push("secure"),document.cookie=l.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,r){"use strict";function o(){this.handlers=[]}var n=r(0);o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=o},function(e,t,r){"use strict";function o(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var n=r(0),i=r(27),a=r(7),l=r(1),s=r(28),p=r(29);e.exports=function(e){return o(e),e.baseURL&&!s(e.url)&&(e.url=p(e.baseURL,e.url)),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),n.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||l.adapter)(e).then(function(t){return o(e),t.data=i(t.data,t.headers,e.transformResponse),t},function(t){return a(t)||(o(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,r){"use strict";var o=r(0);e.exports=function(e,t,r){return o.forEach(r,function(r){e=r(e,t)}),e}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";function o(e){if("function"!==typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var r=this;e(function(e){r.reason||(r.reason=new n(e),t(r.reason))})}var n=r(8);o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o(function(t){e=t}),cancel:e}},e.exports=o},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){"use strict";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t}function a(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=r(3),s=r.n(l),p=r(2),c=r.n(p),u=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),m=wp.element,f=m.Component,h=m.Fragment,__=wp.i18n.__,d=wp.components,g=d.PanelBody,b=d.Placeholder,w=(d.QueryControls,d.RangeControl),C=d.SelectControl,v=d.Spinner,E=(d.TextControl,d.ToggleControl),_=(d.Toolbar,d.withAPIData,d.ColorPalette,d.Button),y=wp.editor,T=y.InspectorControls,P=y.BlockControls,S=y.MediaUpload,N=y.RichText,x=y.AlignmentToolbar,k=y.PanelColorSettings,A=function(e){function t(){n(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return e.get_users=function(){s.a.post(mpp_gutenberg.rest_url+"/get_users",{},{headers:{"X-WP-Nonce":mpp_gutenberg.nonce}}).then(function(t){var r,n=Array(),i=Array(),a=0,l="",s=0,p="",c="",u="",m="";$.each(t.data,function(e,t){n[t.ID]={profile_pictures:t.profile_pictures,has_profile_picture:t.has_profile_picture,display_name:t.display_name,description:t.description,is_user_logged_in:t.is_user_logged_in,profile_picture_id:t.profile_picture_id,default_image:t.default_image,permalink:t.permalink},t.is_user_logged_in&&(a=t.ID),i.push({value:t.ID,label:t.display_name})}),0!==e.props.attributes.user_id&&(a=e.props.attributes.user_id);var f=n[a];f.has_profile_picture?(l=e.props.attributes.profileImgURL.length>0?e.props.attributes.profileImgURL:f.profile_pictures.thumbnail,s=e.props.attributes.profileImgID.length>0?e.props.attributes.profileImgID:f.profile_picture_id,p=e.props.attributes.profileName.length>0?e.props.attributes.profileName:f.display_name,u=e.props.attributes.profileTitle.length>0?e.props.attributes.profileTitle:"",m=f.permalink,c=e.props.attributes.profileContent.length>0?e.props.attributes.profileContent:f.description):(p=e.props.attributes.profileName.length>0?e.props.attributes.profileName:f.display_name,u=e.props.attributes.profileTitle.length>0?e.props.attributes.profileTitle:"",c=e.props.attributes.profileContent.length>0?e.props.attributes.profileContent:f.description,l=e.props.attributes.profileImgURL.length>0?e.props.attributes.profileImgURL:f.default_image,s=e.props.attributes.profileImgID.length>0?e.props.attributes.profileImgID:0,m=f.permalink),void 0==c&&(c=""),e.setState((r={loading:!1,users:n,active_user:a,user_list:i,profile_picture:l,profile_picture_id:s},o(r,"active_user",a),o(r,"profile_name",p),o(r,"profile_title",u),o(r,"profile_description",c),o(r,"profile_url",m),r)),e.props.setAttributes({profileContent:c,profileName:p,profileTitle:u,profileURL:m,profileImgID:s,profileImgURL:l})})},e.on_user_change=function(t){var r=e.state.users[t],o="",n=0;r.has_profile_picture?(o=e.state.users[t].profile_pictures.thumbnail,n=e.state.users[t].profile_picture_id):(o=mpp_gutenberg.mystery_man,n=0);var i=e.state.users[t].description;void 0===i&&(i=""),e.props.setAttributes({profileName:e.state.users[t].display_name,profileContent:i,profileTitle:"",profileURL:e.state.users[t].permalink,profileImgURL:o}),e.setState({profile_name:e.state.users[t].display_name,profile_description:i,profile_title:"",profile_picture:o,profile_picture_id:n,active_user:t,profile_url:e.state.users[t].permalink})},e.componentDidMount=function(){e.get_users()},e.handleImageChange=function(t,r){e.setState({profile_picture:r,profile_picture_id:t})},e.onChangeName=function(t){e.setState({profile_name:t})},e.onChangeTitle=function(t){e.setState({profile_title:t})},e.onChangeProfileText=function(t){e.setState({profile_description:t})},e.state={loading:!0,users:!1,user_list:!1,profile_picture:!1,profile_picture_id:0,active_user:!1,profile_description:"",profile_name:"",profile_title:""},e}return a(t,e),u(t,[{key:"render",value:function(){var e=this,t=this.props,r=t.attributes,o=r.profileName,n=r.profileTitle,i=r.profileContent,a=r.profileAlignment,l=r.profileImgURL,s=r.profileImgID,p=r.profileURL,u=r.profileFontSize,m=r.profileBackgroundColor,f=r.profileTextColor,d=r.profileAvatarShape,y=r.profileViewPostsBackgroundColor,A=r.profileViewPostsTextColor,I=r.showTitle,L=r.showName,O=r.showDescription,V=r.showViewPosts,H=(t.attributes,t.isSelected,t.editable,t.className,t.setAttributes);this.state.profile_pictures;s=this.state.profile_picture_id,l=this.state.profile_picture,o=this.state.profile_name,i=this.state.profile_description,n=this.state.profile_title,p=this.state.profile_url;var R=function(e){return H({profileBackgroundColor:e})},M=function(e){return H({profileTextColor:e})},B=function(e){return H({profileViewPostsBackgroundColor:e})},U=function(e){return H({profileViewPostsTextColor:e})},D=[{value:"square",label:__("Square","metronet-profile-picture")},{value:"round",label:__("Round","metronet-profile-picture")}];return wp.element.createElement(h,null,this.state.loading&&wp.element.createElement(h,null,wp.element.createElement(b,null,__("Loading...","metronet-profile-picture"),wp.element.createElement(v,null))),!this.state.loading&&wp.element.createElement(h,null,wp.element.createElement(T,null,wp.element.createElement(g,{title:__("User Profile Settings","metronet-profile-picture")},wp.element.createElement(C,{label:__("Select a user","metronet-profile-picture"),value:this.state.active_user,options:this.state.user_list,onChange:function(t){e.on_user_change(t),H({user_id:Number(t)})}}),wp.element.createElement(w,{label:__("Font Size","metronet-profile-picture"),value:u,onChange:function(t){return e.props.setAttributes({profileFontSize:t})},min:14,max:24,step:1}),wp.element.createElement(C,{label:__("Avatar Shape","metronet-profile-picture"),description:__("Choose between a round or square avatar shape.","metronet-profile-picture"),options:D,value:d,onChange:function(t){return e.props.setAttributes({profileAvatarShape:t})}}),wp.element.createElement(k,{title:__("Background Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:m,onChange:R,label:__("Background Color","metronet-profile-picture")}]}),wp.element.createElement(k,{title:__("Text Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:f,onChange:M,label:__("Text Color","metronet-profile-picture")}]}),wp.element.createElement(k,{title:__("View Posts Background Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:y,onChange:B,label:__("View Posts Background","metronet-profile-picture")}]}),wp.element.createElement(k,{title:__("View Posts Text Color","metronet-profile-picture"),initialOpen:!1,colorSettings:[{value:A,onChange:U,label:__("View Posts Text Color","metronet-profile-picture")}]}),wp.element.createElement(E,{label:__("Show Name","metronet-profile-picture"),checked:L,onChange:function(){return e.props.setAttributes({showName:!L})}}),wp.element.createElement(E,{label:__("Show Title","metronet-profile-picture"),checked:I,onChange:function(){return e.props.setAttributes({showTitle:!I})}}),wp.element.createElement(E,{label:__("Show Description","metronet-profile-picture"),checked:O,onChange:function(){return e.props.setAttributes({showDescription:!O})}}),wp.element.createElement(E,{label:__("Show View Posts","metronet-profile-picture"),checked:V,onChange:function(){return e.props.setAttributes({showViewPosts:!V})}}))),wp.element.createElement(P,{key:"controls"},wp.element.createElement(x,{value:a,onChange:function(e){return H({profileAlignment:e})}})),wp.element.createElement("div",{className:c()("mpp-profile-wrap","legacy",a,d,"mt-font-size-"+u,"mpp-block-profile"),style:{backgroundColor:m,color:f}},wp.element.createElement("div",{className:c()("mpp-profile-gutenberg-wrap")},wp.element.createElement("div",{className:"mpp-profile-image-wrapper"},wp.element.createElement("div",{className:"mpp-profile-image-square"},wp.element.createElement(S,{buttonProps:{className:"change-image"},onSelect:function(t){e.handleImageChange(t.id,t.url),H({profileImgID:t.id,profileImgURL:t.url})},type:"image",value:s,render:function(e){var t=e.open;return wp.element.createElement(_,{onClick:t},s?wp.element.createElement("img",{class:"profile-avatar",src:l,alt:"avatar"}):wp.element.createElement("img",{src:l,alt:"placeholder"}))}}))),wp.element.createElement("div",{className:"mpp-content-wrap"},L&&wp.element.createElement(N,{tagName:"h2",placeholder:__("Add name","metronet-profile-picture"),value:o,className:"mpp-profile-name",style:{color:f},onChange:function(t){e.onChangeName(t),H({profileName:t})}}),I&&wp.element.createElement(N,{tagName:"p",placeholder:__("Add title","atomic-blocks"),value:n,className:"mpp-profile-title",style:{color:f},onChange:function(t){e.onChangeTitle(t),H({profileTitle:t})}}),O&&wp.element.createElement(N,{tagName:"div",className:"mpp-profile-text",placeholder:__("Add profile text...","metronet-profile-picture"),value:i,formattingControls:["bold","italic","strikethrough","link"],onChange:function(t){e.onChangeProfileText(t),H({profileContent:t})}}))),p&&!!p.length&&wp.element.createElement("div",{className:"mpp-gutenberg-view-posts"},V&&wp.element.createElement("div",{className:"mpp-profile-view-posts",style:{backgroundColor:y,color:A}},wp.element.createElement("a",{href:p,style:{backgroundColor:y,color:A}},__("View Posts","metronet-profile-picture")))))))}}]),t}(f);t.a=A}]);
|
gutenberg/class-gutenberg.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
<?php
|
2 |
-
// Prevent direct file access
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
die( 'No direct access' );
|
5 |
}
|
@@ -17,6 +17,9 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
17 |
* @since 2.0.0
|
18 |
*/
|
19 |
class Metronet_Profile_Picture_Gutenberg {
|
|
|
|
|
|
|
20 |
public function __construct() {
|
21 |
if ( ! function_exists( 'register_block_type' ) ) {
|
22 |
return;
|
@@ -24,10 +27,13 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
24 |
|
25 |
add_action( 'init', array( $this, 'register_block' ) );
|
26 |
add_action( 'enqueue_block_assets', array( $this, 'add_gutenberg_styles' ) );
|
27 |
-
add_action( 'enqueue_block_editor_assets', array( $this,'add_gutenberg_scripts' ) );
|
28 |
add_action( 'admin_footer', array( $this, 'load_gutenblock_svgs' ) );
|
29 |
}
|
30 |
|
|
|
|
|
|
|
31 |
public function register_block() {
|
32 |
register_block_type(
|
33 |
'mpp/user-profile',
|
@@ -38,12 +44,12 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
38 |
register_block_type(
|
39 |
'mpp/user-profile-enhanced',
|
40 |
array(
|
41 |
-
'attributes'
|
42 |
-
'profileName'
|
43 |
'type' => 'string',
|
44 |
'default' => '',
|
45 |
),
|
46 |
-
'theme'
|
47 |
'type' => 'string',
|
48 |
'default' => 'regular',
|
49 |
),
|
@@ -59,7 +65,7 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
59 |
'type' => 'string',
|
60 |
'default' => __( 'View Posts', 'metronet-profile-picture' ),
|
61 |
),
|
62 |
-
'profileViewWebsite'
|
63 |
'type' => 'string',
|
64 |
'default' => __( 'View Website', 'metronet-profile-picture' ),
|
65 |
),
|
@@ -89,7 +95,7 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
89 |
),
|
90 |
'borderRounded' => array(
|
91 |
'type' => 'int',
|
92 |
-
'default' => 0
|
93 |
),
|
94 |
'borderColor' => array(
|
95 |
'type' => 'string',
|
@@ -104,7 +110,7 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
104 |
'default' => '#32373c',
|
105 |
),
|
106 |
'profileViewPostsBackgroundColor' => array(
|
107 |
-
'type'
|
108 |
'default' => '#cf6d38',
|
109 |
),
|
110 |
'profileViewPostsTextColor' => array(
|
@@ -279,6 +285,11 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
279 |
);
|
280 |
}
|
281 |
|
|
|
|
|
|
|
|
|
|
|
282 |
public function display_frontend( $attributes ) {
|
283 |
if ( is_admin() ) {
|
284 |
return;
|
@@ -322,7 +333,7 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
322 |
</a>
|
323 |
</div><!-- .mpp-profile-view-posts -->
|
324 |
<?php endif; ?>
|
325 |
-
<?php if ( ''
|
326 |
<div class="mpp-profile-view-website" style="background: <?php echo esc_attr( $attributes['profileWebsiteBackgroundColor'] ); ?>;color: <?php echo esc_attr( $attributes['profileWebsiteTextColor'] ); ?>; font-size: <?php echo esc_attr( $attributes['buttonFontSize'] ); ?>px;">
|
327 |
<a href="<?php echo esc_url( $attributes['website'] ); ?>" style="background: <?php echo esc_attr( $attributes['profileWebsiteBackgroundColor'] ); ?>; color: <?php echo esc_attr( $attributes['profileWebsiteTextColor'] ); ?>;">
|
328 |
<?php
|
@@ -395,7 +406,7 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
395 |
</div>
|
396 |
<?php endif; /* Compact theme end */ ?>
|
397 |
<?php if ( true === $attributes['showSocialMedia'] && ( 'regular' === $attributes['theme'] || 'compact' === $attributes['theme'] || 'profile' === $attributes['theme'] ) ) : ?>
|
398 |
-
<?php echo $this->get_social_icons( $attributes ); ?>
|
399 |
<?php endif; ?>
|
400 |
</div><!-- .mpp-profile-gutenberg-wrap -->
|
401 |
</div><!-- .mpp-profile-wrap -->
|
@@ -430,7 +441,7 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
430 |
</div><!-- .mpp-author-social-wrapper -->
|
431 |
<?php if ( $attributes['showSocialMedia'] ) : ?>
|
432 |
<div class="mpp-author-social">
|
433 |
-
<?php echo $this->get_social_icons( $attributes ); ?>
|
434 |
</div>
|
435 |
<?php endif; ?>
|
436 |
</div><!-- .mpp-author-social-wrapper -->
|
@@ -486,6 +497,11 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
486 |
return ob_get_clean();
|
487 |
}
|
488 |
|
|
|
|
|
|
|
|
|
|
|
489 |
public function get_social_icons( $attributes ) {
|
490 |
ob_start();
|
491 |
?>
|
@@ -542,7 +558,7 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
542 |
<?php if ( ! empty( $attributes['socialWordPress'] ) ) : ?>
|
543 |
<a href="<?php echo esc_url( $attributes['socialWordPress'] ); ?>">
|
544 |
<svg class="icon icon-wordpress" role="img" style="<?php echo 'custom' === $attributes['socialMediaOptions'] ? 'fill:' . esc_attr( $attributes['socialMediaColors'] ) . ';' : ''; ?>">
|
545 |
-
<use href="#wordpress"></use
|
546 |
</svg>
|
547 |
</a>
|
548 |
<?php endif; ?>
|
@@ -551,6 +567,9 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
551 |
return ob_get_clean();
|
552 |
}
|
553 |
|
|
|
|
|
|
|
554 |
public function load_gutenblock_svgs() {
|
555 |
if ( '' !== get_post_type() ) {
|
556 |
// Define SVG sprite file.
|
@@ -577,6 +596,9 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
577 |
}
|
578 |
}
|
579 |
|
|
|
|
|
|
|
580 |
public function add_gutenberg_scripts() {
|
581 |
|
582 |
wp_enqueue_script( 'mpp_gutenberg', Metronet_Profile_Picture::get_plugin_url( 'dist/blocks.build.js' ), array( 'wp-blocks', 'wp-element' ), METRONET_PROFILE_PICTURE_VERSION, true );
|
@@ -595,7 +617,7 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
595 |
wp_script_add_data( 'mpp_gutenberg', 'data', $content );
|
596 |
}
|
597 |
|
598 |
-
// Pass in REST URL
|
599 |
wp_localize_script(
|
600 |
'mpp_gutenberg',
|
601 |
'mpp_gutenberg',
|
@@ -609,11 +631,14 @@ class Metronet_Profile_Picture_Gutenberg {
|
|
609 |
wp_enqueue_style( 'mpp_gutenberg', Metronet_Profile_Picture::get_plugin_url( '/dist/blocks.editor.build.css' ), array(), METRONET_PROFILE_PICTURE_VERSION, 'all' );
|
610 |
}
|
611 |
|
|
|
|
|
|
|
612 |
public function add_gutenberg_styles() {
|
613 |
if ( is_admin() ) {
|
614 |
return;
|
615 |
}
|
616 |
-
// Ensure script debug allows non-minified scripts
|
617 |
wp_enqueue_style( 'mpp_gutenberg', Metronet_Profile_Picture::get_plugin_url( '/dist/blocks.style.build.css' ), array(), METRONET_PROFILE_PICTURE_VERSION, 'all' );
|
618 |
wp_enqueue_script( 'mpp_gutenberg_tabs', Metronet_Profile_Picture::get_plugin_url( 'js/mpp-frontend.js' ), array( 'jquery' ), METRONET_PROFILE_PICTURE_VERSION, true );
|
619 |
|
1 |
+
<?php // phpcs:ignore
|
2 |
+
// Prevent direct file access.
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
die( 'No direct access' );
|
5 |
}
|
17 |
* @since 2.0.0
|
18 |
*/
|
19 |
class Metronet_Profile_Picture_Gutenberg {
|
20 |
+
/**
|
21 |
+
* Class constructor.
|
22 |
+
*/
|
23 |
public function __construct() {
|
24 |
if ( ! function_exists( 'register_block_type' ) ) {
|
25 |
return;
|
27 |
|
28 |
add_action( 'init', array( $this, 'register_block' ) );
|
29 |
add_action( 'enqueue_block_assets', array( $this, 'add_gutenberg_styles' ) );
|
30 |
+
add_action( 'enqueue_block_editor_assets', array( $this, 'add_gutenberg_scripts' ) );
|
31 |
add_action( 'admin_footer', array( $this, 'load_gutenblock_svgs' ) );
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
+
* Register the main User Profile Picture block.
|
36 |
+
*/
|
37 |
public function register_block() {
|
38 |
register_block_type(
|
39 |
'mpp/user-profile',
|
44 |
register_block_type(
|
45 |
'mpp/user-profile-enhanced',
|
46 |
array(
|
47 |
+
'attributes' => array(
|
48 |
+
'profileName' => array(
|
49 |
'type' => 'string',
|
50 |
'default' => '',
|
51 |
),
|
52 |
+
'theme' => array(
|
53 |
'type' => 'string',
|
54 |
'default' => 'regular',
|
55 |
),
|
65 |
'type' => 'string',
|
66 |
'default' => __( 'View Posts', 'metronet-profile-picture' ),
|
67 |
),
|
68 |
+
'profileViewWebsite' => array(
|
69 |
'type' => 'string',
|
70 |
'default' => __( 'View Website', 'metronet-profile-picture' ),
|
71 |
),
|
95 |
),
|
96 |
'borderRounded' => array(
|
97 |
'type' => 'int',
|
98 |
+
'default' => 0,
|
99 |
),
|
100 |
'borderColor' => array(
|
101 |
'type' => 'string',
|
110 |
'default' => '#32373c',
|
111 |
),
|
112 |
'profileViewPostsBackgroundColor' => array(
|
113 |
+
'type' => 'string',
|
114 |
'default' => '#cf6d38',
|
115 |
),
|
116 |
'profileViewPostsTextColor' => array(
|
285 |
);
|
286 |
}
|
287 |
|
288 |
+
/**
|
289 |
+
* Display the front-end for the Gutenberg block.
|
290 |
+
*
|
291 |
+
* @param array $attributes Array of block attributes.
|
292 |
+
*/
|
293 |
public function display_frontend( $attributes ) {
|
294 |
if ( is_admin() ) {
|
295 |
return;
|
333 |
</a>
|
334 |
</div><!-- .mpp-profile-view-posts -->
|
335 |
<?php endif; ?>
|
336 |
+
<?php if ( '' !== $attributes['website'] && $attributes['showWebsite'] ) : ?>
|
337 |
<div class="mpp-profile-view-website" style="background: <?php echo esc_attr( $attributes['profileWebsiteBackgroundColor'] ); ?>;color: <?php echo esc_attr( $attributes['profileWebsiteTextColor'] ); ?>; font-size: <?php echo esc_attr( $attributes['buttonFontSize'] ); ?>px;">
|
338 |
<a href="<?php echo esc_url( $attributes['website'] ); ?>" style="background: <?php echo esc_attr( $attributes['profileWebsiteBackgroundColor'] ); ?>; color: <?php echo esc_attr( $attributes['profileWebsiteTextColor'] ); ?>;">
|
339 |
<?php
|
406 |
</div>
|
407 |
<?php endif; /* Compact theme end */ ?>
|
408 |
<?php if ( true === $attributes['showSocialMedia'] && ( 'regular' === $attributes['theme'] || 'compact' === $attributes['theme'] || 'profile' === $attributes['theme'] ) ) : ?>
|
409 |
+
<?php echo $this->get_social_icons( $attributes ); // phpcs:ignore ?>
|
410 |
<?php endif; ?>
|
411 |
</div><!-- .mpp-profile-gutenberg-wrap -->
|
412 |
</div><!-- .mpp-profile-wrap -->
|
441 |
</div><!-- .mpp-author-social-wrapper -->
|
442 |
<?php if ( $attributes['showSocialMedia'] ) : ?>
|
443 |
<div class="mpp-author-social">
|
444 |
+
<?php echo $this->get_social_icons( $attributes ); // phpcs:ignore ?>
|
445 |
</div>
|
446 |
<?php endif; ?>
|
447 |
</div><!-- .mpp-author-social-wrapper -->
|
497 |
return ob_get_clean();
|
498 |
}
|
499 |
|
500 |
+
/**
|
501 |
+
* Get the social icons for the block.
|
502 |
+
*
|
503 |
+
* @param array $attributes Gutenberg attributes.
|
504 |
+
*/
|
505 |
public function get_social_icons( $attributes ) {
|
506 |
ob_start();
|
507 |
?>
|
558 |
<?php if ( ! empty( $attributes['socialWordPress'] ) ) : ?>
|
559 |
<a href="<?php echo esc_url( $attributes['socialWordPress'] ); ?>">
|
560 |
<svg class="icon icon-wordpress" role="img" style="<?php echo 'custom' === $attributes['socialMediaOptions'] ? 'fill:' . esc_attr( $attributes['socialMediaColors'] ) . ';' : ''; ?>">
|
561 |
+
<use href="#wordpress"></use><?php // phpcs:ignore ?>
|
562 |
</svg>
|
563 |
</a>
|
564 |
<?php endif; ?>
|
567 |
return ob_get_clean();
|
568 |
}
|
569 |
|
570 |
+
/**
|
571 |
+
* Add SVGs for the social icons in the block.
|
572 |
+
*/
|
573 |
public function load_gutenblock_svgs() {
|
574 |
if ( '' !== get_post_type() ) {
|
575 |
// Define SVG sprite file.
|
596 |
}
|
597 |
}
|
598 |
|
599 |
+
/**
|
600 |
+
* Add Gutenberg scripts.
|
601 |
+
*/
|
602 |
public function add_gutenberg_scripts() {
|
603 |
|
604 |
wp_enqueue_script( 'mpp_gutenberg', Metronet_Profile_Picture::get_plugin_url( 'dist/blocks.build.js' ), array( 'wp-blocks', 'wp-element' ), METRONET_PROFILE_PICTURE_VERSION, true );
|
617 |
wp_script_add_data( 'mpp_gutenberg', 'data', $content );
|
618 |
}
|
619 |
|
620 |
+
// Pass in REST URL.
|
621 |
wp_localize_script(
|
622 |
'mpp_gutenberg',
|
623 |
'mpp_gutenberg',
|
631 |
wp_enqueue_style( 'mpp_gutenberg', Metronet_Profile_Picture::get_plugin_url( '/dist/blocks.editor.build.css' ), array(), METRONET_PROFILE_PICTURE_VERSION, 'all' );
|
632 |
}
|
633 |
|
634 |
+
/**
|
635 |
+
* Add Gutenberg styles.
|
636 |
+
*/
|
637 |
public function add_gutenberg_styles() {
|
638 |
if ( is_admin() ) {
|
639 |
return;
|
640 |
}
|
641 |
+
// Ensure script debug allows non-minified scripts.
|
642 |
wp_enqueue_style( 'mpp_gutenberg', Metronet_Profile_Picture::get_plugin_url( '/dist/blocks.style.build.css' ), array(), METRONET_PROFILE_PICTURE_VERSION, 'all' );
|
643 |
wp_enqueue_script( 'mpp_gutenberg_tabs', Metronet_Profile_Picture::get_plugin_url( 'js/mpp-frontend.js' ), array( 'jquery' ), METRONET_PROFILE_PICTURE_VERSION, true );
|
644 |
|
gutenberg/index.php
CHANGED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php // phpcs:ignore
|
2 |
+
// no direct access.
|
metronet-profile-picture.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: User Profile Picture
|
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/metronet-profile-picture/
|
5 |
Description: Use the native WP uploader on your user profile page.
|
6 |
Author: Ronald Huereca
|
7 |
-
Version: 2.3.
|
8 |
Requires at least: 3.5
|
9 |
Author URI: https://www.mediaron.com
|
10 |
Contributors: ronalfy
|
@@ -12,7 +12,7 @@ Text Domain: metronet-profile-picture
|
|
12 |
Domain Path: /languages
|
13 |
*/
|
14 |
|
15 |
-
define( 'METRONET_PROFILE_PICTURE_VERSION', '2.3.
|
16 |
define( 'METRONET_PROFILE_PICTURE_PLUGIN_NAME', 'User Profile Picture' );
|
17 |
define( 'METRONET_PROFILE_PICTURE_DIR', plugin_dir_path( __FILE__ ) );
|
18 |
define( 'METRONET_PROFILE_PICTURE_URL', plugins_url( '/', __FILE__ ) );
|
@@ -34,20 +34,40 @@ define( 'METRONET_PROFILE_PICTURE_FILE', __FILE__ );
|
|
34 |
*/
|
35 |
class Metronet_Profile_Picture {
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
private $plugin_path = '';
|
41 |
|
42 |
/**
|
43 |
* __construct()
|
44 |
*
|
45 |
* Class constructor
|
46 |
-
*
|
47 |
*/
|
48 |
public function __construct() {
|
49 |
|
50 |
-
//* Localization Code */
|
51 |
load_plugin_textdomain( 'metronet-profile-picture', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
52 |
|
53 |
$this->plugin_path = plugin_basename( __FILE__ );
|
@@ -57,40 +77,40 @@ class Metronet_Profile_Picture {
|
|
57 |
add_action( 'init', array( $this, 'init' ) );
|
58 |
add_action( 'personal_options', array( $this, 'insert_upload_form' ) );
|
59 |
|
60 |
-
//Scripts
|
61 |
add_action( 'admin_print_scripts-user-edit.php', array( $this, 'print_media_scripts' ) );
|
62 |
add_action( 'admin_print_scripts-profile.php', array( $this, 'print_media_scripts' ) );
|
63 |
|
64 |
add_action( 'wp_enqueue_scripts', array( $this, 'profile_print_media_scripts' ), 9 );
|
65 |
-
add_action( 'acf/input/admin_enqueue_scripts', array( $this, 'profile_print_media_scripts' ), 9 ); //Advanced Custom Field compatibility
|
66 |
|
67 |
-
//Styles
|
68 |
add_action( 'admin_print_styles-user-edit.php', array( $this, 'print_media_styles' ) );
|
69 |
add_action( 'admin_print_styles-profile.php', array( $this, 'print_media_styles' ) );
|
70 |
|
71 |
-
//Ajax
|
72 |
add_action( 'wp_ajax_metronet_add_thumbnail', array( $this, 'ajax_add_thumbnail' ) );
|
73 |
add_action( 'wp_ajax_metronet_get_thumbnail', array( $this, 'ajax_get_thumbnail' ) );
|
74 |
add_action( 'wp_ajax_metronet_remove_thumbnail', array( $this, 'ajax_remove_thumbnail' ) );
|
75 |
|
76 |
-
//User update action
|
77 |
add_action( 'edit_user_profile_update', array( $this, 'save_user_profile' ) );
|
78 |
add_action( 'personal_options_update', array( $this, 'save_user_profile' ) );
|
79 |
|
80 |
-
//User Avatar override
|
81 |
add_filter( 'get_avatar', array( $this, 'avatar_override' ), 10, 6 );
|
82 |
add_filter( 'pre_get_avatar_data', array( $this, 'pre_avatar_override' ), 10, 2 );
|
83 |
|
84 |
-
//Rest API
|
85 |
add_action( 'rest_api_init', array( $this, 'rest_api_register' ) );
|
86 |
|
87 |
-
//Avatar check overridden - Can be overridden using a higher priority
|
88 |
add_filter( 'mpp_hide_avatar_override', '__return_true', 5 );
|
89 |
|
90 |
// Determine if to load Gutenberg or not.
|
91 |
$options = $this->get_options();
|
92 |
if ( 'on' === $options['load_gutenberg'] ) {
|
93 |
-
// Include Gutenberg
|
94 |
add_filter( 'block_categories', array( $this, 'add_block_category' ), 10, 2 );
|
95 |
include_once self::get_plugin_dir( '/gutenberg/class-gutenberg.php' );
|
96 |
new Metronet_Profile_Picture_Gutenberg();
|
@@ -103,8 +123,8 @@ class Metronet_Profile_Picture {
|
|
103 |
*
|
104 |
* @since 2.3.0
|
105 |
*
|
106 |
-
* @param array
|
107 |
-
* @param object $post Post to attach it to
|
108 |
*
|
109 |
* @return array New Categories
|
110 |
*/
|
@@ -125,7 +145,6 @@ class Metronet_Profile_Picture {
|
|
125 |
* Register the settings menu for User Profile Picture
|
126 |
*
|
127 |
* @since 2.3.0
|
128 |
-
*
|
129 |
*/
|
130 |
public function register_settings_menu() {
|
131 |
$hook = add_menu_page(
|
@@ -143,15 +162,14 @@ class Metronet_Profile_Picture {
|
|
143 |
* Admin page for User Profile Picture
|
144 |
*
|
145 |
* @since 2.3.0
|
146 |
-
*
|
147 |
*/
|
148 |
public function admin_page() {
|
149 |
if ( isset( $_POST['submit'] ) && isset( $_POST['options'] ) ) {
|
150 |
check_admin_referer( 'save_mpp_options' );
|
151 |
-
$this->update_options(
|
152 |
printf( '<div class="updated"><p><strong>%s</strong></p></div>', esc_html__( 'Your options have been saved.', 'metronet-profile-picture' ) );
|
153 |
}
|
154 |
-
// Get options and defaults
|
155 |
$options = $this->get_options();
|
156 |
?>
|
157 |
<div class="wrap">
|
@@ -183,7 +201,6 @@ class Metronet_Profile_Picture {
|
|
183 |
* @since 2.3.0
|
184 |
*
|
185 |
* @param array $options Array of options.
|
186 |
-
*
|
187 |
*/
|
188 |
do_action( 'mpp_user_profile_admin_settings_after_row', $options );
|
189 |
?>
|
@@ -196,7 +213,6 @@ class Metronet_Profile_Picture {
|
|
196 |
* @since 2.3.0
|
197 |
*
|
198 |
* @param array $options Array of options.
|
199 |
-
*
|
200 |
*/
|
201 |
do_action( 'mpp_user_profile_admin_settings_after_table', $options );
|
202 |
?>
|
@@ -211,6 +227,7 @@ class Metronet_Profile_Picture {
|
|
211 |
*
|
212 |
* @since 2.3.0
|
213 |
*
|
|
|
214 |
*/
|
215 |
public function get_options() {
|
216 |
$options = get_option( 'mpp_options', false );
|
@@ -229,7 +246,7 @@ class Metronet_Profile_Picture {
|
|
229 |
*
|
230 |
* @since 2.3.0
|
231 |
* @access public
|
232 |
-
* @param array $options array of options to save
|
233 |
* @return void
|
234 |
*/
|
235 |
public function update_options( $options ) {
|
@@ -247,7 +264,6 @@ class Metronet_Profile_Picture {
|
|
247 |
* @since 2.3.0
|
248 |
*
|
249 |
* @param array $options An array of sanitized POST options
|
250 |
-
*
|
251 |
*/
|
252 |
$options = apply_filters( 'mpp_options_sanitized', $options );
|
253 |
update_option( 'mpp_options', $options );
|
@@ -259,7 +275,6 @@ class Metronet_Profile_Picture {
|
|
259 |
* @access private
|
260 |
*
|
261 |
* @since 2.3.0
|
262 |
-
*
|
263 |
*/
|
264 |
private function get_defaults() {
|
265 |
$defaults = array(
|
@@ -272,18 +287,16 @@ class Metronet_Profile_Picture {
|
|
272 |
* @since 2.3.1
|
273 |
*
|
274 |
* @param array $defaults An array of option defaults.
|
275 |
-
*
|
276 |
*/
|
277 |
$defaults = apply_filters( 'mpp_options_defaults', $defaults );
|
278 |
return $defaults;
|
279 |
}
|
280 |
|
281 |
/**
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
*/
|
287 |
public function ajax_add_thumbnail() {
|
288 |
if ( ! current_user_can( 'upload_files' ) ) {
|
289 |
die( '' );
|
@@ -296,9 +309,9 @@ class Metronet_Profile_Picture {
|
|
296 |
}
|
297 |
check_ajax_referer( "mt-update-post_$post_id" );
|
298 |
|
299 |
-
//Save user meta
|
300 |
update_user_option( $user_id, 'metronet_post_id', $post_id );
|
301 |
-
update_user_option( $user_id, 'metronet_image_id', $thumbnail_id ); //Added via this thread (Props Solinx) - https://wordpress.org/support/topic/storing-image-id-directly-as-user-meta-data
|
302 |
set_post_thumbnail( $post_id, $thumbnail_id );
|
303 |
|
304 |
if ( has_post_thumbnail( $post_id ) ) {
|
@@ -335,10 +348,9 @@ class Metronet_Profile_Picture {
|
|
335 |
} //end ajax_add_thumbnail
|
336 |
|
337 |
/**
|
338 |
-
*
|
339 |
*
|
340 |
* Retrieves a thumbnail based on a passed post id ($_POST)
|
341 |
-
*
|
342 |
*/
|
343 |
public function ajax_get_thumbnail() {
|
344 |
if ( ! current_user_can( 'upload_files' ) ) {
|
@@ -388,14 +400,13 @@ class Metronet_Profile_Picture {
|
|
388 |
'logged_in_user_id' => get_current_user_id(),
|
389 |
)
|
390 |
);
|
391 |
-
}
|
392 |
|
393 |
/**
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
*/
|
399 |
public function ajax_remove_thumbnail() {
|
400 |
if ( ! current_user_can( 'upload_files' ) ) {
|
401 |
die( '' );
|
@@ -412,7 +423,7 @@ class Metronet_Profile_Picture {
|
|
412 |
$thumb_html .= sprintf( '<div id="metronet-click-edit">%s</div>', esc_html__( 'Click to Edit', 'metronet-profile-picture' ) );
|
413 |
$thumb_html .= '</a>';
|
414 |
|
415 |
-
//Save user meta and update thumbnail
|
416 |
update_user_option( $user_id, 'metronet_image_id', 0 );
|
417 |
delete_post_meta( $post_id, '_thumbnail_id' );
|
418 |
wp_send_json(
|
@@ -430,23 +441,26 @@ class Metronet_Profile_Picture {
|
|
430 |
}
|
431 |
|
432 |
/**
|
433 |
-
*
|
434 |
*
|
435 |
* Overrides an avatar with a profile image
|
436 |
*
|
437 |
-
* @param string $avatar SRC to the avatar
|
438 |
-
* @param mixed
|
439 |
-
* @param int
|
440 |
-
* @param string $default URL to the default image
|
441 |
-
* @param string $alt Alternative text
|
442 |
-
|
|
|
|
|
|
|
443 |
public function avatar_override( $avatar, $id_or_email, $size, $default, $alt, $args = array() ) {
|
444 |
global $pagenow;
|
445 |
if ( 'options-discussion.php' === $pagenow ) {
|
446 |
-
return $avatar; //Stop overriding gravatars on options-discussion page
|
447 |
}
|
448 |
|
449 |
-
//Get user data
|
450 |
if ( is_numeric( $id_or_email ) ) {
|
451 |
$user = get_user_by( 'id', (int) $id_or_email );
|
452 |
} elseif ( is_object( $id_or_email ) ) {
|
@@ -469,13 +483,13 @@ class Metronet_Profile_Picture {
|
|
469 |
}
|
470 |
$user_id = $user->ID;
|
471 |
|
472 |
-
//Determine if user has an avatar override
|
473 |
$avatar_override = get_user_option( 'metronet_avatar_override', $user_id );
|
474 |
if ( ! $avatar_override || 'on' !== $avatar_override ) {
|
475 |
return $avatar;
|
476 |
}
|
477 |
|
478 |
-
//Build classes array based on passed in args, else set defaults - see get_avatar in /wp-includes/pluggable.php
|
479 |
$classes = array(
|
480 |
'avatar',
|
481 |
sprintf( 'avatar-%s', esc_attr( $size ) ),
|
@@ -490,10 +504,10 @@ class Metronet_Profile_Picture {
|
|
490 |
}
|
491 |
}
|
492 |
|
493 |
-
//Get custom filter classes
|
494 |
$classes = (array) apply_filters( 'mpp_avatar_classes', $classes );
|
495 |
|
496 |
-
//Determine if the user has a profile image
|
497 |
$custom_avatar = mt_profile_img(
|
498 |
$user_id,
|
499 |
array(
|
@@ -510,20 +524,19 @@ class Metronet_Profile_Picture {
|
|
510 |
return $avatar;
|
511 |
}
|
512 |
return $custom_avatar;
|
513 |
-
}
|
514 |
|
515 |
/**
|
516 |
-
* pre_avatar_override()
|
517 |
-
*
|
518 |
* Overrides an avatar with a profile image
|
519 |
*
|
520 |
-
* @param array $args Arguments to determine the avatar dimensions
|
521 |
-
* @param mixed $id_or_email
|
|
|
522 |
* @return array $args Overridden URL or default if none can be found
|
523 |
**/
|
524 |
public function pre_avatar_override( $args, $id_or_email ) {
|
525 |
|
526 |
-
//Get user data
|
527 |
if ( is_numeric( $id_or_email ) ) {
|
528 |
$user = get_user_by( 'id', (int) $id_or_email );
|
529 |
} elseif ( is_object( $id_or_email ) ) {
|
@@ -546,7 +559,7 @@ class Metronet_Profile_Picture {
|
|
546 |
}
|
547 |
$user_id = $user->ID;
|
548 |
|
549 |
-
// Get the post the user is attached to
|
550 |
$size = $args['size'];
|
551 |
|
552 |
$profile_post_id = absint( get_user_option( 'metronet_post_id', $user_id ) );
|
@@ -555,7 +568,7 @@ class Metronet_Profile_Picture {
|
|
555 |
}
|
556 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
557 |
|
558 |
-
// Attempt to get the image in the right size
|
559 |
$avatar_image = get_the_post_thumbnail_url( $profile_post_id, array( $size, $size ) );
|
560 |
if ( empty( $avatar_image ) ) {
|
561 |
return $args;
|
@@ -565,11 +578,9 @@ class Metronet_Profile_Picture {
|
|
565 |
}
|
566 |
|
567 |
/**
|
568 |
-
* get_plugin_dir()
|
569 |
-
*
|
570 |
* Returns an absolute path to a plugin item
|
571 |
*
|
572 |
-
* @param
|
573 |
*
|
574 |
* @return string An absolute path (e.g., /htdocs/ithemes/wp-content/.../css/image.png)
|
575 |
*/
|
@@ -584,15 +595,13 @@ class Metronet_Profile_Picture {
|
|
584 |
|
585 |
|
586 |
/**
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
* @return string An absolute url (e.g., http://www.domain.com/plugin_url/.../css/image.png)
|
593 |
-
*/
|
594 |
public static function get_plugin_url( $path = '' ) {
|
595 |
-
$dir
|
596 |
if ( ! empty( $path ) && is_string( $path ) ) {
|
597 |
$dir .= '/' . ltrim( $path, '/' );
|
598 |
}
|
@@ -600,18 +609,16 @@ class Metronet_Profile_Picture {
|
|
600 |
}
|
601 |
|
602 |
/**
|
603 |
-
* get_post_id
|
604 |
-
*
|
605 |
* Gets a post id for the user - Creates a post if a post doesn't exist
|
606 |
*
|
607 |
-
* @param int user_id User ID of the user
|
608 |
* @return int post_id
|
609 |
-
|
610 |
private function get_post_id( $user_id = 0 ) {
|
611 |
|
612 |
$user = get_user_by( 'id', $user_id );
|
613 |
|
614 |
-
//Get/Create Profile Picture Post
|
615 |
$post_args = array(
|
616 |
'post_type' => 'mt_pp',
|
617 |
'author' => $user_id,
|
@@ -632,22 +639,20 @@ class Metronet_Profile_Picture {
|
|
632 |
$post_id = $post->ID;
|
633 |
}
|
634 |
return $post_id;
|
635 |
-
}
|
636 |
|
637 |
/**
|
638 |
-
* get_post_thumbnail_editor_link
|
639 |
-
*
|
640 |
* Retrieve a crop-image link (HTML) based on the passed post_id
|
641 |
*
|
642 |
-
* @param int post_id Post ID to find the featured image for
|
643 |
* @return string html
|
644 |
-
|
645 |
private function get_post_thumbnail_editor_link( $post_id ) {
|
646 |
ob_start();
|
647 |
if ( has_post_thumbnail( $post_id ) && defined( 'PTE_VERSION' ) ) {
|
648 |
-
//Post Thumbnail Editor compatibility - http://wordpress.org/extend/plugins/post-thumbnail-editor
|
649 |
$post_thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
|
650 |
-
$pte_url
|
651 |
array(
|
652 |
'page' => 'pte-edit',
|
653 |
'pte-id' => $post_thumbnail_id,
|
@@ -655,42 +660,36 @@ class Metronet_Profile_Picture {
|
|
655 |
admin_url( 'upload.php' )
|
656 |
);
|
657 |
printf( ' - <a href="%s">%s</a>', esc_url( $pte_url ), esc_html__( 'Crop Thumbnail', 'metronet-profile-picture' ) );
|
658 |
-
}
|
659 |
return ob_get_clean();
|
660 |
-
}
|
661 |
|
662 |
/**
|
663 |
-
*
|
664 |
-
*
|
665 |
-
* Gets a user ID for the user
|
666 |
-
*
|
667 |
-
*@return int user_id
|
668 |
*
|
|
|
669 |
*/
|
670 |
public function get_user_id() {
|
671 |
-
//Get user ID
|
672 |
$user_id = isset( $_GET['user_id'] ) ? absint( $_GET['user_id'] ) : 0; // phpcs:ignore
|
673 |
if ( 0 === $user_id && IS_PROFILE_PAGE ) {
|
674 |
$current_user = wp_get_current_user();
|
675 |
$user_id = $current_user->ID;
|
676 |
}
|
677 |
return $user_id;
|
678 |
-
}
|
679 |
|
680 |
/**
|
681 |
-
* init()
|
682 |
-
*
|
683 |
* Initializes plugin localization, post types, updaters, plugin info, and adds actions/filters
|
684 |
-
*
|
685 |
*/
|
686 |
public function init() {
|
687 |
|
688 |
-
// For the admin interface
|
689 |
add_action( 'admin_menu', array( $this, 'register_settings_menu' ) );
|
690 |
add_action( 'plugin_action_links_' . METRONET_PROFILE_PICTURE_SLUG, array( $this, 'plugin_settings_link' ) );
|
691 |
|
692 |
-
add_theme_support( 'post-thumbnails' ); //This should be part of the theme, but the plugin registers it just in case.
|
693 |
-
//Register post types
|
694 |
$post_type_args = array(
|
695 |
'public' => false,
|
696 |
'publicly_queryable' => false,
|
@@ -727,8 +726,7 @@ class Metronet_Profile_Picture {
|
|
727 |
add_image_size( 'profile_150', 150, 150, true );
|
728 |
add_image_size( 'profile_300', 300, 300, true );
|
729 |
}
|
730 |
-
|
731 |
-
}//end function init
|
732 |
|
733 |
/**
|
734 |
* Adds a plugin settings link.
|
@@ -737,9 +735,10 @@ class Metronet_Profile_Picture {
|
|
737 |
*
|
738 |
* @param array $settings The settings array for the plugin.
|
739 |
*
|
|
|
740 |
*/
|
741 |
public function plugin_settings_link( $settings ) {
|
742 |
-
$admin_anchor
|
743 |
'<a href="%s">%s</a>',
|
744 |
esc_url( admin_url( 'admin.php?page=mpp' ) ),
|
745 |
esc_html__( 'Settings', 'metronet-profile-picture' )
|
@@ -759,13 +758,11 @@ class Metronet_Profile_Picture {
|
|
759 |
}
|
760 |
|
761 |
/**
|
762 |
-
* insert_upload_form
|
763 |
-
*
|
764 |
* Adds an upload form to the user profile page and outputs profile image if there is one
|
765 |
*/
|
766 |
public function insert_upload_form() {
|
767 |
if ( ! current_user_can( 'upload_files' ) ) {
|
768 |
-
return; //Users must be author or greater
|
769 |
}
|
770 |
|
771 |
$user_id = $this->get_user_id();
|
@@ -808,16 +805,16 @@ class Metronet_Profile_Picture {
|
|
808 |
<div id="metronet-override-avatar">
|
809 |
<input type="hidden" name="metronet-user-avatar" value="off" />
|
810 |
<?php
|
811 |
-
//Get the user avatar override option - If not set, see if there's a filter override.
|
812 |
$user_avatar_override = get_user_option( 'metronet_avatar_override', $user_id );
|
813 |
-
$checked
|
814 |
if ( $user_avatar_override ) {
|
815 |
$checked = checked( 'on', $user_avatar_override, false );
|
816 |
} else {
|
817 |
$checked = checked( true, apply_filters( 'mpp_avatar_override', false ), false );
|
818 |
}
|
819 |
|
820 |
-
//Filter for hiding the override interface. If this option is set to true, the mpp_avatar_override filter is ignored and override is enabled by default
|
821 |
$hide_override = apply_filters( 'mpp_hide_avatar_override', false );
|
822 |
if ( $hide_override ) :
|
823 |
?>
|
@@ -835,14 +832,11 @@ class Metronet_Profile_Picture {
|
|
835 |
* Allow other plugins to run code after the user profile picture UI.
|
836 |
*
|
837 |
* @since 2.3.0
|
838 |
-
*
|
839 |
*/
|
840 |
do_action( 'mpp_user_profile_form', $user_id );
|
841 |
} //end insert_upload_form
|
842 |
|
843 |
/**
|
844 |
-
* profile_print_media_scripts
|
845 |
-
*
|
846 |
* Output media scripts for thickbox and media uploader
|
847 |
**/
|
848 |
public function profile_print_media_scripts() {
|
@@ -852,8 +846,6 @@ class Metronet_Profile_Picture {
|
|
852 |
}
|
853 |
|
854 |
/**
|
855 |
-
* print_media_scripts
|
856 |
-
*
|
857 |
* Output media scripts for thickbox and media uploader
|
858 |
**/
|
859 |
public function print_media_scripts() {
|
@@ -933,12 +925,13 @@ class Metronet_Profile_Picture {
|
|
933 |
<?php
|
934 |
} //end print_media_scripts
|
935 |
|
|
|
|
|
|
|
936 |
public function print_media_styles() {
|
937 |
} //end print_media_styles
|
938 |
|
939 |
/**
|
940 |
-
* rest_get_users_permissions_callback()
|
941 |
-
*
|
942 |
* Gets permissions for the get users rest api endpoint.
|
943 |
*
|
944 |
* @return bool true if the user has permission, false if not
|
@@ -948,10 +941,8 @@ class Metronet_Profile_Picture {
|
|
948 |
}
|
949 |
|
950 |
/**
|
951 |
-
|
952 |
-
|
953 |
-
* Registers REST API endpoint
|
954 |
-
**/
|
955 |
public function rest_api_register() {
|
956 |
register_rest_field(
|
957 |
'user',
|
@@ -994,7 +985,7 @@ class Metronet_Profile_Picture {
|
|
994 |
'permission_callback' => array( $this, 'rest_get_users_permissions_callback' ),
|
995 |
)
|
996 |
);
|
997 |
-
// keep it for backward compatibility
|
998 |
register_rest_route(
|
999 |
'mpp/v1',
|
1000 |
'/user/(?P<id>\d+)',
|
@@ -1012,11 +1003,11 @@ class Metronet_Profile_Picture {
|
|
1012 |
}
|
1013 |
|
1014 |
/**
|
1015 |
-
* rest_api_get_users()
|
1016 |
-
*
|
1017 |
* Gets users for the Gutenberg block
|
1018 |
*
|
1019 |
-
* @param array $request WP REST API array
|
|
|
|
|
1020 |
**/
|
1021 |
public function rest_api_get_users( $request ) {
|
1022 |
|
@@ -1037,8 +1028,8 @@ class Metronet_Profile_Picture {
|
|
1037 |
$user_results = $user_query->get_results();
|
1038 |
$return = array();
|
1039 |
foreach ( $user_results as $result ) {
|
1040 |
-
//Get attachment ID
|
1041 |
-
$profile_post_id
|
1042 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
1043 |
if ( ! $post_thumbnail_id ) {
|
1044 |
$result->data->has_profile_picture = false;
|
@@ -1047,17 +1038,17 @@ class Metronet_Profile_Picture {
|
|
1047 |
$result->data->profile_pictures = array(
|
1048 |
'avatar' => get_avatar( $result->data->ID ),
|
1049 |
);
|
1050 |
-
$result->data->is_user_logged_in = ( get_current_user_id() == $result->data->ID ) ? true : false;
|
1051 |
$return[ $result->data->ID ] = $result->data;
|
1052 |
continue;
|
1053 |
}
|
1054 |
$result->data->description = get_user_meta( $result->data->ID, 'description', true );
|
1055 |
$result->data->display_name = $result->data->display_name;
|
1056 |
$result->data->has_profile_picture = true;
|
1057 |
-
$result->data->is_user_logged_in = ( get_current_user_id() == $result->data->ID ) ? true : false;
|
1058 |
$result->data->description = get_user_meta( $result->data->ID, 'description', true );
|
1059 |
|
1060 |
-
//Get attachment URL
|
1061 |
$attachment_url = wp_get_attachment_url( $post_thumbnail_id );
|
1062 |
|
1063 |
$result->data->profile_picture_id = $post_thumbnail_id;
|
@@ -1079,13 +1070,11 @@ class Metronet_Profile_Picture {
|
|
1079 |
}
|
1080 |
|
1081 |
/**
|
1082 |
-
* rest_api_change_profile_image()
|
1083 |
-
*
|
1084 |
* Changes a profile image for a user.
|
1085 |
*
|
1086 |
-
* @param array $request WP REST API array
|
1087 |
*
|
1088 |
-
* @return
|
1089 |
**/
|
1090 |
public function rest_api_change_profile_image( $request ) {
|
1091 |
|
@@ -1102,9 +1091,9 @@ class Metronet_Profile_Picture {
|
|
1102 |
|
1103 |
$post_id = $this->get_post_id( $user_id );
|
1104 |
|
1105 |
-
//Save user meta
|
1106 |
update_user_option( $user_id, 'metronet_post_id', $post_id );
|
1107 |
-
update_user_option( $user_id, 'metronet_image_id', $media_id ); //Added via this thread (Props Solinx) - https://wordpress.org/support/topic/storing-image-id-directly-as-user-meta-data
|
1108 |
|
1109 |
set_post_thumbnail( $post_id, $media_id );
|
1110 |
|
@@ -1122,13 +1111,11 @@ class Metronet_Profile_Picture {
|
|
1122 |
}
|
1123 |
|
1124 |
/**
|
1125 |
-
* rest_api_put_profile()
|
1126 |
-
*
|
1127 |
* Adds a profile picture to a user
|
1128 |
*
|
1129 |
-
* @param array $request WP REST API array
|
1130 |
*
|
1131 |
-
* @return
|
1132 |
**/
|
1133 |
public function rest_api_put_profile( $request ) {
|
1134 |
|
@@ -1150,9 +1137,9 @@ class Metronet_Profile_Picture {
|
|
1150 |
}
|
1151 |
|
1152 |
$post_id = $this->get_post_id( $user_id );
|
1153 |
-
//Save user meta
|
1154 |
update_user_option( $user_id, 'metronet_post_id', $post_id );
|
1155 |
-
update_user_option( $user_id, 'metronet_image_id', $media_id ); //Added via this thread (Props Solinx) - https://wordpress.org/support/topic/storing-image-id-directly-as-user-meta-data
|
1156 |
|
1157 |
set_post_thumbnail( $post_id, $media_id );
|
1158 |
|
@@ -1170,9 +1157,9 @@ class Metronet_Profile_Picture {
|
|
1170 |
}
|
1171 |
|
1172 |
/**
|
1173 |
-
* rest_api_get_posts_for_user()
|
1174 |
-
*
|
1175 |
* Returns the 5 most recent posts for the user
|
|
|
|
|
1176 |
**/
|
1177 |
public function rest_api_get_posts_for_user( $request ) {
|
1178 |
$user_id = absint( $request['user_id'] );
|
@@ -1197,10 +1184,12 @@ class Metronet_Profile_Picture {
|
|
1197 |
wp_send_json( $posts );
|
1198 |
}
|
1199 |
/**
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
|
|
|
|
1204 |
public function rest_api_get_profile_for_user( $object, $field_name, $request ) {
|
1205 |
$user_id = $object['id'];
|
1206 |
$user = get_user_by( 'id', $user_id );
|
@@ -1208,16 +1197,16 @@ class Metronet_Profile_Picture {
|
|
1208 |
return new WP_Error( 'mpp_no_user', __( 'User not found.', 'metronet-profile-picture' ), array( 'status' => 404 ) );
|
1209 |
}
|
1210 |
|
1211 |
-
// No capability check here because we're just returning user profile data
|
1212 |
|
1213 |
-
//Get attachment ID
|
1214 |
$profile_post_id = absint( get_user_option( 'metronet_post_id', $user_id ) );
|
1215 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
1216 |
if ( ! $post_thumbnail_id ) {
|
1217 |
return new WP_Error( 'mpp_no_profile_picture', __( 'Profile picture not found.', 'metronet-profile-picture' ), array( 'status' => 404 ) );
|
1218 |
}
|
1219 |
|
1220 |
-
//Get attachment URL
|
1221 |
$attachment_url = wp_get_attachment_url( $post_thumbnail_id );
|
1222 |
|
1223 |
return array(
|
@@ -1231,11 +1220,9 @@ class Metronet_Profile_Picture {
|
|
1231 |
}
|
1232 |
|
1233 |
/**
|
1234 |
-
* rest_api_get_profile()
|
1235 |
-
*
|
1236 |
* Returns a profile for the user
|
1237 |
*
|
1238 |
-
* @param array $data WP REST API array
|
1239 |
*
|
1240 |
* @return json image URLs matched to sizes
|
1241 |
**/
|
@@ -1246,14 +1233,14 @@ class Metronet_Profile_Picture {
|
|
1246 |
return new WP_Error( 'mpp_no_user', __( 'User not found.', 'metronet-profile-picture' ), array( 'status' => 404 ) );
|
1247 |
}
|
1248 |
|
1249 |
-
//Get attachment ID
|
1250 |
$profile_post_id = absint( get_user_option( 'metronet_post_id', $user_id ) );
|
1251 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
1252 |
if ( ! $post_thumbnail_id ) {
|
1253 |
return new WP_Error( 'mpp_no_profile_picture', __( 'Profile picture not found.', 'metronet-profile-picture' ), array( 'status' => 404 ) );
|
1254 |
}
|
1255 |
|
1256 |
-
//Get attachment URL
|
1257 |
$attachment_url = wp_get_attachment_url( $post_thumbnail_id );
|
1258 |
|
1259 |
return array(
|
@@ -1263,28 +1250,35 @@ class Metronet_Profile_Picture {
|
|
1263 |
}
|
1264 |
|
1265 |
/**
|
1266 |
-
* rest_api_validate()
|
1267 |
-
*
|
1268 |
* Makes sure the ID we are passed is numeric
|
|
|
|
|
|
|
|
|
|
|
|
|
1269 |
**/
|
1270 |
public function rest_api_validate( $param, $request, $key ) {
|
1271 |
return is_numeric( $param );
|
1272 |
}
|
1273 |
|
1274 |
/**
|
1275 |
-
* rest_api_validate()
|
1276 |
-
*
|
1277 |
* Sanitizes user ID
|
|
|
|
|
|
|
|
|
|
|
|
|
1278 |
**/
|
1279 |
public function rest_api_sanitize( $param, $request, $key ) {
|
1280 |
return absint( $param );
|
1281 |
}
|
1282 |
|
1283 |
/**
|
1284 |
-
* save_user_profile()
|
1285 |
-
*
|
1286 |
* Saves user profile fields
|
1287 |
-
*
|
|
|
1288 |
**/
|
1289 |
public function save_user_profile( $user_id ) {
|
1290 |
if ( ! isset( $_POST['metronet-user-avatar'] ) ) {
|
@@ -1294,7 +1288,7 @@ class Metronet_Profile_Picture {
|
|
1294 |
|
1295 |
flush_rewrite_rules( true );
|
1296 |
|
1297 |
-
$user_avatar =
|
1298 |
if ( 'on' === $user_avatar ) {
|
1299 |
update_user_option( $user_id, 'metronet_avatar_override', 'on' );
|
1300 |
} else {
|
@@ -1302,29 +1296,32 @@ class Metronet_Profile_Picture {
|
|
1302 |
}
|
1303 |
} //end save_user_profile
|
1304 |
|
1305 |
-
}
|
1306 |
-
|
|
|
1307 |
global $mt_pp;
|
1308 |
if ( class_exists( 'Metronet_Profile_Picture' ) ) {
|
1309 |
if ( get_bloginfo( 'version' ) >= '3.5' ) {
|
1310 |
add_action( 'plugins_loaded', 'mt_mpp_instantiate', 10 );
|
1311 |
}
|
1312 |
}
|
|
|
|
|
|
|
|
|
1313 |
function mt_mpp_instantiate() {
|
1314 |
global $mt_pp;
|
1315 |
$mt_pp = new Metronet_Profile_Picture();
|
1316 |
}
|
1317 |
/**
|
1318 |
-
*
|
1319 |
-
*
|
1320 |
-
* Adds a profile image
|
1321 |
*
|
1322 |
-
* @param $user_id
|
1323 |
-
* @param $args
|
1324 |
-
* size - string || array (see get_the_post_thumbnail)
|
1325 |
-
* attr - string || array (see get_the_post_thumbnail)
|
1326 |
-
* echo - bool (true or false) - whether to echo the image or return it
|
1327 |
-
*/
|
1328 |
function mt_profile_img( $user_id, $args = array() ) {
|
1329 |
$profile_post_id = absint( get_user_option( 'metronet_post_id', $user_id ) );
|
1330 |
|
@@ -1338,11 +1335,11 @@ function mt_profile_img( $user_id, $args = array() ) {
|
|
1338 |
'echo' => true,
|
1339 |
);
|
1340 |
$args = wp_parse_args( $args, $defaults );
|
1341 |
-
extract( $args ); //
|
1342 |
|
1343 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
1344 |
|
1345 |
-
//Return false or echo nothing if there is no post thumbnail
|
1346 |
if ( ! $post_thumbnail_id ) {
|
1347 |
if ( $echo ) {
|
1348 |
echo '';
|
@@ -1352,7 +1349,7 @@ function mt_profile_img( $user_id, $args = array() ) {
|
|
1352 |
return;
|
1353 |
}
|
1354 |
|
1355 |
-
//Implode Classes if set and array - dev note: edge case
|
1356 |
if ( is_array( $attr ) && isset( $attr['class'] ) ) {
|
1357 |
if ( is_array( $attr['class'] ) ) {
|
1358 |
$attr['class'] = implode( ' ', $attr['class'] );
|
@@ -1366,11 +1363,10 @@ function mt_profile_img( $user_id, $args = array() ) {
|
|
1366 |
*
|
1367 |
* Filter outputted HTML.
|
1368 |
*
|
1369 |
-
* @param string $post_thumbnail img tag with formed HTML
|
1370 |
-
* @param int $profile_post_id The profile in which the image is attached
|
1371 |
-
* @param int $profile_thumbnail_id The thumbnail ID for the attached image
|
1372 |
-
* @param int $user_id The user id for which the image is attached
|
1373 |
-
*
|
1374 |
*/
|
1375 |
$post_thumbnail = apply_filters( 'mpp_thumbnail_html', $post_thumbnail, $profile_post_id, $post_thumbnail_id, $user_id );
|
1376 |
if ( $echo ) {
|
@@ -1381,25 +1377,22 @@ function mt_profile_img( $user_id, $args = array() ) {
|
|
1381 |
} //end mt_profile_img
|
1382 |
|
1383 |
/**
|
1384 |
-
* mt_author_box
|
1385 |
-
*
|
1386 |
* Adds a profile author box
|
1387 |
*
|
1388 |
* @since 2.2.0
|
1389 |
*
|
1390 |
-
* @param int
|
1391 |
-
* @param array $attributes See defaults in function for all attributes
|
1392 |
*
|
1393 |
* @return string User profile box if user exists
|
1394 |
-
|
1395 |
-
*/
|
1396 |
function mt_author_box( $user_id = 0, $attributes = array() ) {
|
1397 |
$user = get_user_by( 'id', $user_id );
|
1398 |
if ( false === $user ) {
|
1399 |
return '';
|
1400 |
}
|
1401 |
$defaults = array(
|
1402 |
-
'theme' => 'regular', /*
|
1403 |
'profileAvatarShape' => 'square', /* Can be 'square' or 'rounded' */
|
1404 |
'padding' => 10,
|
1405 |
'border' => 1,
|
@@ -1441,7 +1434,7 @@ function mt_author_box( $user_id = 0, $attributes = array() ) {
|
|
1441 |
'socialGitHub' => '',
|
1442 |
'socialMediaOptions' => 'brand', /* can be brand or custom */
|
1443 |
'socialMediaColors' => '#000000', /* Only applicable if socialMediaOptions is custom */
|
1444 |
-
'profileCompactAlignment' => 'center',
|
1445 |
/* Tabbed Attributes */
|
1446 |
'tabbedAuthorProfileTitle' => '',
|
1447 |
'tabbedAuthorSubHeading' => '',
|
@@ -1487,9 +1480,9 @@ function mt_author_box( $user_id = 0, $attributes = array() ) {
|
|
1487 |
<?php esc_html_e( 'View Posts', 'metronet-profile-picture' ); ?></a>
|
1488 |
</div><!-- .mpp-profile-view-posts -->
|
1489 |
<?php endif; ?>
|
1490 |
-
<?php if ( ''
|
1491 |
<div class="mpp-profile-view-website" style="background: <?php echo esc_attr( $attributes['profileWebsiteBackgroundColor'] ); ?>;color: <?php echo esc_attr( $attributes['profileWebsiteTextColor'] ); ?>; font-size: <?php echo esc_attr( $attributes['buttonFontSize'] ); ?>px;">
|
1492 |
-
<a href="<?php echo esc_url( $attributes['website'] )
|
1493 |
</div><!-- .mpp-profile-view-website -->
|
1494 |
<?php endif; ?>
|
1495 |
</div><!-- .mpp-gutenberg-view-posts -->
|
@@ -1552,7 +1545,7 @@ function mt_author_box( $user_id = 0, $attributes = array() ) {
|
|
1552 |
</div>
|
1553 |
<?php endif; /* Compact theme end */ ?>
|
1554 |
<?php if ( true === $attributes['showSocialMedia'] && ( 'regular' === $attributes['theme'] || 'compact' === $attributes['theme'] || 'profile' === $attributes['theme'] ) ) : ?>
|
1555 |
-
<?php echo mpp_get_social_icons( $attributes ); ?>
|
1556 |
<?php endif; ?>
|
1557 |
</div><!-- .mpp-profile-gutenberg-wrap -->
|
1558 |
</div><!-- .mpp-profile-wrap -->
|
@@ -1587,7 +1580,7 @@ function mt_author_box( $user_id = 0, $attributes = array() ) {
|
|
1587 |
</div><!-- .mpp-author-social-wrapper -->
|
1588 |
<?php if ( $attributes['showSocialMedia'] ) : ?>
|
1589 |
<div class="mpp-author-social">
|
1590 |
-
<?php echo mpp_get_social_icons( $attributes ); ?>
|
1591 |
</div>
|
1592 |
<?php endif; ?>
|
1593 |
</div><!-- .mpp-author-social-wrapper -->
|
@@ -1641,22 +1634,19 @@ function mt_author_box( $user_id = 0, $attributes = array() ) {
|
|
1641 |
wp_enqueue_style( 'mpp_gutenberg', Metronet_Profile_Picture::get_plugin_url( '/css/front-end-gutenberg.css' ), array(), METRONET_PROFILE_PICTURE_VERSION, 'all' );
|
1642 |
wp_enqueue_script( 'mpp_gutenberg_tabs', Metronet_Profile_Picture::get_plugin_url( 'js/mpp-frontend' . $min_or_not . '.js' ), array( 'jquery' ), METRONET_PROFILE_PICTURE_VERSION, true );
|
1643 |
add_action( 'wp_footer', 'mpp_load_gutenblock_svgs' );
|
1644 |
-
echo ob_get_clean();
|
1645 |
}
|
1646 |
/**
|
1647 |
-
* mpp_get_social_icons
|
1648 |
-
*
|
1649 |
* Get social icons based on passed attributes
|
1650 |
*
|
1651 |
* @see mt_author_box for attribute valies
|
1652 |
*
|
1653 |
* @since 2.2.0
|
1654 |
*
|
1655 |
-
* @param array $attributes See defaults in function mt_author_box for all attributes
|
1656 |
*
|
1657 |
* @return string User social icons
|
1658 |
-
|
1659 |
-
*/
|
1660 |
function mpp_get_social_icons( $attributes ) {
|
1661 |
ob_start();
|
1662 |
?>
|
@@ -1675,7 +1665,7 @@ function mpp_get_social_icons( $attributes ) {
|
|
1675 |
</svg>
|
1676 |
</a>
|
1677 |
<?php endif; ?>
|
1678 |
-
<?php if ( !empty( $attributes['socialInstagram'] ) ) : ?>
|
1679 |
<a href="<?php echo esc_url( $attributes['socialInstagram'] ); ?>">
|
1680 |
<svg class="icon icon-instagram" role="img" style="<?php echo 'custom' === $attributes['socialMediaOptions'] ? 'fill:' . esc_attr( $attributes['socialMediaColors'] ) . ';' : ''; ?>">
|
1681 |
<use href="#instagram"></use>
|
@@ -1703,7 +1693,7 @@ function mpp_get_social_icons( $attributes ) {
|
|
1703 |
</svg>
|
1704 |
</a>
|
1705 |
<?php endif; ?>
|
1706 |
-
<?php if( ! empty( $attributes['socialGitHub'] ) ) : ?>
|
1707 |
<a href="<?php echo esc_url( $attributes['socialGitHub'] ); ?>">
|
1708 |
<svg class="icon icon-github" role="img" style="<?php echo 'custom' === $attributes['socialMediaOptions'] ? 'fill:' . esc_attr( $attributes['socialMediaColors'] ) . ';' : ''; ?>">
|
1709 |
<use href="#github"></use>
|
@@ -1713,7 +1703,7 @@ function mpp_get_social_icons( $attributes ) {
|
|
1713 |
<?php if ( ! empty( $attributes['socialWordPress'] ) ) : ?>
|
1714 |
<a href="<?php echo esc_url( $attributes['socialWordPress'] ); ?>">
|
1715 |
<svg class="icon icon-wordpress" role="img" style="<?php echo 'custom' === $attributes['socialMediaOptions'] ? 'fill:' . esc_attr( $attributes['socialMediaColors'] ) . ';' : ''; ?>">
|
1716 |
-
<use href="#wordpress"></use
|
1717 |
</svg>
|
1718 |
</a>
|
1719 |
<?php endif; ?>
|
@@ -1722,21 +1712,15 @@ function mpp_get_social_icons( $attributes ) {
|
|
1722 |
return ob_get_clean();
|
1723 |
}
|
1724 |
/**
|
1725 |
-
* mpp_load_gutenblock_svgs
|
1726 |
-
*
|
1727 |
* Load social icons in footer of theme
|
1728 |
*
|
1729 |
* @since 2.2.0
|
1730 |
-
|
1731 |
-
* @return html Echo sprite for social icons
|
1732 |
-
*
|
1733 |
-
*/
|
1734 |
function mpp_load_gutenblock_svgs() {
|
1735 |
/**
|
1736 |
* Allow other plugins to run code from inside this SVG block.
|
1737 |
*
|
1738 |
* @since 2.3.0
|
1739 |
-
*
|
1740 |
*/
|
1741 |
do_action( 'mpp_svg_start' );
|
1742 |
if ( '' !== get_post_type() ) {
|
@@ -1766,7 +1750,6 @@ function mpp_load_gutenblock_svgs() {
|
|
1766 |
* Allow other plugins to run code from inside this SVG block at the end.
|
1767 |
*
|
1768 |
* @since 2.3.0
|
1769 |
-
*
|
1770 |
*/
|
1771 |
do_action( 'mpp_svg_end' );
|
1772 |
}
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/metronet-profile-picture/
|
5 |
Description: Use the native WP uploader on your user profile page.
|
6 |
Author: Ronald Huereca
|
7 |
+
Version: 2.3.6
|
8 |
Requires at least: 3.5
|
9 |
Author URI: https://www.mediaron.com
|
10 |
Contributors: ronalfy
|
12 |
Domain Path: /languages
|
13 |
*/
|
14 |
|
15 |
+
define( 'METRONET_PROFILE_PICTURE_VERSION', '2.3.6' );
|
16 |
define( 'METRONET_PROFILE_PICTURE_PLUGIN_NAME', 'User Profile Picture' );
|
17 |
define( 'METRONET_PROFILE_PICTURE_DIR', plugin_dir_path( __FILE__ ) );
|
18 |
define( 'METRONET_PROFILE_PICTURE_URL', plugins_url( '/', __FILE__ ) );
|
34 |
*/
|
35 |
class Metronet_Profile_Picture {
|
36 |
|
37 |
+
/**
|
38 |
+
* Defines the plugin URL
|
39 |
+
*
|
40 |
+
* @since 1.0.0
|
41 |
+
* @access private
|
42 |
+
* @var string $plugin_url
|
43 |
+
*/
|
44 |
+
private $plugin_url = '';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Defines the plugin absolute directory
|
48 |
+
*
|
49 |
+
* @since 1.0.0
|
50 |
+
* @access private
|
51 |
+
* @var string $plugin_dir
|
52 |
+
*/
|
53 |
+
private $plugin_dir = '';
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Defines the plugin path
|
57 |
+
*
|
58 |
+
* @since 1.0.0
|
59 |
+
* @access private
|
60 |
+
* @var string $plugin_path
|
61 |
+
*/
|
62 |
private $plugin_path = '';
|
63 |
|
64 |
/**
|
65 |
* __construct()
|
66 |
*
|
67 |
* Class constructor
|
|
|
68 |
*/
|
69 |
public function __construct() {
|
70 |
|
|
|
71 |
load_plugin_textdomain( 'metronet-profile-picture', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
72 |
|
73 |
$this->plugin_path = plugin_basename( __FILE__ );
|
77 |
add_action( 'init', array( $this, 'init' ) );
|
78 |
add_action( 'personal_options', array( $this, 'insert_upload_form' ) );
|
79 |
|
80 |
+
// Scripts.
|
81 |
add_action( 'admin_print_scripts-user-edit.php', array( $this, 'print_media_scripts' ) );
|
82 |
add_action( 'admin_print_scripts-profile.php', array( $this, 'print_media_scripts' ) );
|
83 |
|
84 |
add_action( 'wp_enqueue_scripts', array( $this, 'profile_print_media_scripts' ), 9 );
|
85 |
+
add_action( 'acf/input/admin_enqueue_scripts', array( $this, 'profile_print_media_scripts' ), 9 ); // Advanced Custom Field compatibility.
|
86 |
|
87 |
+
// Styles.
|
88 |
add_action( 'admin_print_styles-user-edit.php', array( $this, 'print_media_styles' ) );
|
89 |
add_action( 'admin_print_styles-profile.php', array( $this, 'print_media_styles' ) );
|
90 |
|
91 |
+
// Ajax.
|
92 |
add_action( 'wp_ajax_metronet_add_thumbnail', array( $this, 'ajax_add_thumbnail' ) );
|
93 |
add_action( 'wp_ajax_metronet_get_thumbnail', array( $this, 'ajax_get_thumbnail' ) );
|
94 |
add_action( 'wp_ajax_metronet_remove_thumbnail', array( $this, 'ajax_remove_thumbnail' ) );
|
95 |
|
96 |
+
// User update action.
|
97 |
add_action( 'edit_user_profile_update', array( $this, 'save_user_profile' ) );
|
98 |
add_action( 'personal_options_update', array( $this, 'save_user_profile' ) );
|
99 |
|
100 |
+
// User Avatar override.
|
101 |
add_filter( 'get_avatar', array( $this, 'avatar_override' ), 10, 6 );
|
102 |
add_filter( 'pre_get_avatar_data', array( $this, 'pre_avatar_override' ), 10, 2 );
|
103 |
|
104 |
+
// Rest API.
|
105 |
add_action( 'rest_api_init', array( $this, 'rest_api_register' ) );
|
106 |
|
107 |
+
// Avatar check overridden - Can be overridden using a higher priority.
|
108 |
add_filter( 'mpp_hide_avatar_override', '__return_true', 5 );
|
109 |
|
110 |
// Determine if to load Gutenberg or not.
|
111 |
$options = $this->get_options();
|
112 |
if ( 'on' === $options['load_gutenberg'] ) {
|
113 |
+
// Include Gutenberg.
|
114 |
add_filter( 'block_categories', array( $this, 'add_block_category' ), 10, 2 );
|
115 |
include_once self::get_plugin_dir( '/gutenberg/class-gutenberg.php' );
|
116 |
new Metronet_Profile_Picture_Gutenberg();
|
123 |
*
|
124 |
* @since 2.3.0
|
125 |
*
|
126 |
+
* @param array $categories Array of available categories.
|
127 |
+
* @param object $post Post to attach it to.
|
128 |
*
|
129 |
* @return array New Categories
|
130 |
*/
|
145 |
* Register the settings menu for User Profile Picture
|
146 |
*
|
147 |
* @since 2.3.0
|
|
|
148 |
*/
|
149 |
public function register_settings_menu() {
|
150 |
$hook = add_menu_page(
|
162 |
* Admin page for User Profile Picture
|
163 |
*
|
164 |
* @since 2.3.0
|
|
|
165 |
*/
|
166 |
public function admin_page() {
|
167 |
if ( isset( $_POST['submit'] ) && isset( $_POST['options'] ) ) {
|
168 |
check_admin_referer( 'save_mpp_options' );
|
169 |
+
$this->update_options( wp_unslash( filter_input( INPUT_POST, 'options' ) ) );
|
170 |
printf( '<div class="updated"><p><strong>%s</strong></p></div>', esc_html__( 'Your options have been saved.', 'metronet-profile-picture' ) );
|
171 |
}
|
172 |
+
// Get options and defaults.
|
173 |
$options = $this->get_options();
|
174 |
?>
|
175 |
<div class="wrap">
|
201 |
* @since 2.3.0
|
202 |
*
|
203 |
* @param array $options Array of options.
|
|
|
204 |
*/
|
205 |
do_action( 'mpp_user_profile_admin_settings_after_row', $options );
|
206 |
?>
|
213 |
* @since 2.3.0
|
214 |
*
|
215 |
* @param array $options Array of options.
|
|
|
216 |
*/
|
217 |
do_action( 'mpp_user_profile_admin_settings_after_table', $options );
|
218 |
?>
|
227 |
*
|
228 |
* @since 2.3.0
|
229 |
*
|
230 |
+
* @return array $options Array of admin options.
|
231 |
*/
|
232 |
public function get_options() {
|
233 |
$options = get_option( 'mpp_options', false );
|
246 |
*
|
247 |
* @since 2.3.0
|
248 |
* @access public
|
249 |
+
* @param array $options array of options to save.
|
250 |
* @return void
|
251 |
*/
|
252 |
public function update_options( $options ) {
|
264 |
* @since 2.3.0
|
265 |
*
|
266 |
* @param array $options An array of sanitized POST options
|
|
|
267 |
*/
|
268 |
$options = apply_filters( 'mpp_options_sanitized', $options );
|
269 |
update_option( 'mpp_options', $options );
|
275 |
* @access private
|
276 |
*
|
277 |
* @since 2.3.0
|
|
|
278 |
*/
|
279 |
private function get_defaults() {
|
280 |
$defaults = array(
|
287 |
* @since 2.3.1
|
288 |
*
|
289 |
* @param array $defaults An array of option defaults.
|
|
|
290 |
*/
|
291 |
$defaults = apply_filters( 'mpp_options_defaults', $defaults );
|
292 |
return $defaults;
|
293 |
}
|
294 |
|
295 |
/**
|
296 |
+
* Add a thumbnail via Ajax.
|
297 |
+
*
|
298 |
+
* Adds a thumbnail to user meta and returns thumbnail html.
|
299 |
+
*/
|
|
|
300 |
public function ajax_add_thumbnail() {
|
301 |
if ( ! current_user_can( 'upload_files' ) ) {
|
302 |
die( '' );
|
309 |
}
|
310 |
check_ajax_referer( "mt-update-post_$post_id" );
|
311 |
|
312 |
+
// Save user meta.
|
313 |
update_user_option( $user_id, 'metronet_post_id', $post_id );
|
314 |
+
update_user_option( $user_id, 'metronet_image_id', $thumbnail_id ); // Added via this thread (Props Solinx) - https://wordpress.org/support/topic/storing-image-id-directly-as-user-meta-data.
|
315 |
set_post_thumbnail( $post_id, $thumbnail_id );
|
316 |
|
317 |
if ( has_post_thumbnail( $post_id ) ) {
|
348 |
} //end ajax_add_thumbnail
|
349 |
|
350 |
/**
|
351 |
+
* Retrieve a thumbnail via Ajax.
|
352 |
*
|
353 |
* Retrieves a thumbnail based on a passed post id ($_POST)
|
|
|
354 |
*/
|
355 |
public function ajax_get_thumbnail() {
|
356 |
if ( ! current_user_can( 'upload_files' ) ) {
|
400 |
'logged_in_user_id' => get_current_user_id(),
|
401 |
)
|
402 |
);
|
403 |
+
}
|
404 |
|
405 |
/**
|
406 |
+
* Remove a thumbnail via Ajax.
|
407 |
+
*
|
408 |
+
* Removes a featured thumbnail.
|
409 |
+
*/
|
|
|
410 |
public function ajax_remove_thumbnail() {
|
411 |
if ( ! current_user_can( 'upload_files' ) ) {
|
412 |
die( '' );
|
423 |
$thumb_html .= sprintf( '<div id="metronet-click-edit">%s</div>', esc_html__( 'Click to Edit', 'metronet-profile-picture' ) );
|
424 |
$thumb_html .= '</a>';
|
425 |
|
426 |
+
// Save user meta and update thumbnail.
|
427 |
update_user_option( $user_id, 'metronet_image_id', 0 );
|
428 |
delete_post_meta( $post_id, '_thumbnail_id' );
|
429 |
wp_send_json(
|
441 |
}
|
442 |
|
443 |
/**
|
444 |
+
* Override an Avatar with a User Profile Picture.
|
445 |
*
|
446 |
* Overrides an avatar with a profile image
|
447 |
*
|
448 |
+
* @param string $avatar SRC to the avatar.
|
449 |
+
* @param mixed $id_or_email The ID or email address.
|
450 |
+
* @param int $size Size of the image.
|
451 |
+
* @param string $default URL to the default image.
|
452 |
+
* @param string $alt Alternative text.
|
453 |
+
* @param array $args Misc. args for the avatar.
|
454 |
+
*
|
455 |
+
* @return string Avatar.
|
456 |
+
*/
|
457 |
public function avatar_override( $avatar, $id_or_email, $size, $default, $alt, $args = array() ) {
|
458 |
global $pagenow;
|
459 |
if ( 'options-discussion.php' === $pagenow ) {
|
460 |
+
return $avatar; // Stop overriding gravatars on options-discussion page.
|
461 |
}
|
462 |
|
463 |
+
// Get user data.
|
464 |
if ( is_numeric( $id_or_email ) ) {
|
465 |
$user = get_user_by( 'id', (int) $id_or_email );
|
466 |
} elseif ( is_object( $id_or_email ) ) {
|
483 |
}
|
484 |
$user_id = $user->ID;
|
485 |
|
486 |
+
// Determine if user has an avatar override.
|
487 |
$avatar_override = get_user_option( 'metronet_avatar_override', $user_id );
|
488 |
if ( ! $avatar_override || 'on' !== $avatar_override ) {
|
489 |
return $avatar;
|
490 |
}
|
491 |
|
492 |
+
// Build classes array based on passed in args, else set defaults - see get_avatar in /wp-includes/pluggable.php.
|
493 |
$classes = array(
|
494 |
'avatar',
|
495 |
sprintf( 'avatar-%s', esc_attr( $size ) ),
|
504 |
}
|
505 |
}
|
506 |
|
507 |
+
// Get custom filter classes.
|
508 |
$classes = (array) apply_filters( 'mpp_avatar_classes', $classes );
|
509 |
|
510 |
+
// Determine if the user has a profile image.
|
511 |
$custom_avatar = mt_profile_img(
|
512 |
$user_id,
|
513 |
array(
|
524 |
return $avatar;
|
525 |
}
|
526 |
return $custom_avatar;
|
527 |
+
}
|
528 |
|
529 |
/**
|
|
|
|
|
530 |
* Overrides an avatar with a profile image
|
531 |
*
|
532 |
+
* @param array $args Arguments to determine the avatar dimensions.
|
533 |
+
* @param mixed $id_or_email The ID or email address.
|
534 |
+
*
|
535 |
* @return array $args Overridden URL or default if none can be found
|
536 |
**/
|
537 |
public function pre_avatar_override( $args, $id_or_email ) {
|
538 |
|
539 |
+
// Get user data.
|
540 |
if ( is_numeric( $id_or_email ) ) {
|
541 |
$user = get_user_by( 'id', (int) $id_or_email );
|
542 |
} elseif ( is_object( $id_or_email ) ) {
|
559 |
}
|
560 |
$user_id = $user->ID;
|
561 |
|
562 |
+
// Get the post the user is attached to.
|
563 |
$size = $args['size'];
|
564 |
|
565 |
$profile_post_id = absint( get_user_option( 'metronet_post_id', $user_id ) );
|
568 |
}
|
569 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
570 |
|
571 |
+
// Attempt to get the image in the right size.
|
572 |
$avatar_image = get_the_post_thumbnail_url( $profile_post_id, array( $size, $size ) );
|
573 |
if ( empty( $avatar_image ) ) {
|
574 |
return $args;
|
578 |
}
|
579 |
|
580 |
/**
|
|
|
|
|
581 |
* Returns an absolute path to a plugin item
|
582 |
*
|
583 |
+
* @param string $path Relative path to make absolute (e.g., /css/image.png).
|
584 |
*
|
585 |
* @return string An absolute path (e.g., /htdocs/ithemes/wp-content/.../css/image.png)
|
586 |
*/
|
595 |
|
596 |
|
597 |
/**
|
598 |
+
* Returns an absolute url to a plugin item
|
599 |
+
*
|
600 |
+
* @param string $path Relative path to plugin (e.g., /css/image.png).
|
601 |
+
* @return string An absolute url (e.g., http://www.domain.com/plugin_url/.../css/image.png)
|
602 |
+
*/
|
|
|
|
|
603 |
public static function get_plugin_url( $path = '' ) {
|
604 |
+
$dir = rtrim( plugin_dir_url( __FILE__ ), '/' );
|
605 |
if ( ! empty( $path ) && is_string( $path ) ) {
|
606 |
$dir .= '/' . ltrim( $path, '/' );
|
607 |
}
|
609 |
}
|
610 |
|
611 |
/**
|
|
|
|
|
612 |
* Gets a post id for the user - Creates a post if a post doesn't exist
|
613 |
*
|
614 |
+
* @param int $user_id User ID of the user.
|
615 |
* @return int post_id
|
616 |
+
*/
|
617 |
private function get_post_id( $user_id = 0 ) {
|
618 |
|
619 |
$user = get_user_by( 'id', $user_id );
|
620 |
|
621 |
+
// Get/Create Profile Picture Post.
|
622 |
$post_args = array(
|
623 |
'post_type' => 'mt_pp',
|
624 |
'author' => $user_id,
|
639 |
$post_id = $post->ID;
|
640 |
}
|
641 |
return $post_id;
|
642 |
+
}
|
643 |
|
644 |
/**
|
|
|
|
|
645 |
* Retrieve a crop-image link (HTML) based on the passed post_id
|
646 |
*
|
647 |
+
* @param int $post_id Post ID to find the featured image for.
|
648 |
* @return string html
|
649 |
+
*/
|
650 |
private function get_post_thumbnail_editor_link( $post_id ) {
|
651 |
ob_start();
|
652 |
if ( has_post_thumbnail( $post_id ) && defined( 'PTE_VERSION' ) ) {
|
653 |
+
// Post Thumbnail Editor compatibility - http://wordpress.org/extend/plugins/post-thumbnail-editor/.
|
654 |
$post_thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
|
655 |
+
$pte_url = add_query_arg(
|
656 |
array(
|
657 |
'page' => 'pte-edit',
|
658 |
'pte-id' => $post_thumbnail_id,
|
660 |
admin_url( 'upload.php' )
|
661 |
);
|
662 |
printf( ' - <a href="%s">%s</a>', esc_url( $pte_url ), esc_html__( 'Crop Thumbnail', 'metronet-profile-picture' ) );
|
663 |
+
}
|
664 |
return ob_get_clean();
|
665 |
+
}
|
666 |
|
667 |
/**
|
668 |
+
* Gets a user ID for the user.
|
|
|
|
|
|
|
|
|
669 |
*
|
670 |
+
* @return int user_id
|
671 |
*/
|
672 |
public function get_user_id() {
|
673 |
+
// Get user ID.
|
674 |
$user_id = isset( $_GET['user_id'] ) ? absint( $_GET['user_id'] ) : 0; // phpcs:ignore
|
675 |
if ( 0 === $user_id && IS_PROFILE_PAGE ) {
|
676 |
$current_user = wp_get_current_user();
|
677 |
$user_id = $current_user->ID;
|
678 |
}
|
679 |
return $user_id;
|
680 |
+
}
|
681 |
|
682 |
/**
|
|
|
|
|
683 |
* Initializes plugin localization, post types, updaters, plugin info, and adds actions/filters
|
|
|
684 |
*/
|
685 |
public function init() {
|
686 |
|
687 |
+
// For the admin interface.
|
688 |
add_action( 'admin_menu', array( $this, 'register_settings_menu' ) );
|
689 |
add_action( 'plugin_action_links_' . METRONET_PROFILE_PICTURE_SLUG, array( $this, 'plugin_settings_link' ) );
|
690 |
|
691 |
+
add_theme_support( 'post-thumbnails' ); // This should be part of the theme, but the plugin registers it just in case.
|
692 |
+
// Register post types.
|
693 |
$post_type_args = array(
|
694 |
'public' => false,
|
695 |
'publicly_queryable' => false,
|
726 |
add_image_size( 'profile_150', 150, 150, true );
|
727 |
add_image_size( 'profile_300', 300, 300, true );
|
728 |
}
|
729 |
+
}
|
|
|
730 |
|
731 |
/**
|
732 |
* Adds a plugin settings link.
|
735 |
*
|
736 |
* @param array $settings The settings array for the plugin.
|
737 |
*
|
738 |
+
* @return array Settings array.
|
739 |
*/
|
740 |
public function plugin_settings_link( $settings ) {
|
741 |
+
$admin_anchor = sprintf(
|
742 |
'<a href="%s">%s</a>',
|
743 |
esc_url( admin_url( 'admin.php?page=mpp' ) ),
|
744 |
esc_html__( 'Settings', 'metronet-profile-picture' )
|
758 |
}
|
759 |
|
760 |
/**
|
|
|
|
|
761 |
* Adds an upload form to the user profile page and outputs profile image if there is one
|
762 |
*/
|
763 |
public function insert_upload_form() {
|
764 |
if ( ! current_user_can( 'upload_files' ) ) {
|
765 |
+
return; // Users must be author or greater.
|
766 |
}
|
767 |
|
768 |
$user_id = $this->get_user_id();
|
805 |
<div id="metronet-override-avatar">
|
806 |
<input type="hidden" name="metronet-user-avatar" value="off" />
|
807 |
<?php
|
808 |
+
// Get the user avatar override option - If not set, see if there's a filter override.
|
809 |
$user_avatar_override = get_user_option( 'metronet_avatar_override', $user_id );
|
810 |
+
$checked = '';
|
811 |
if ( $user_avatar_override ) {
|
812 |
$checked = checked( 'on', $user_avatar_override, false );
|
813 |
} else {
|
814 |
$checked = checked( true, apply_filters( 'mpp_avatar_override', false ), false );
|
815 |
}
|
816 |
|
817 |
+
// Filter for hiding the override interface. If this option is set to true, the mpp_avatar_override filter is ignored and override is enabled by default.
|
818 |
$hide_override = apply_filters( 'mpp_hide_avatar_override', false );
|
819 |
if ( $hide_override ) :
|
820 |
?>
|
832 |
* Allow other plugins to run code after the user profile picture UI.
|
833 |
*
|
834 |
* @since 2.3.0
|
|
|
835 |
*/
|
836 |
do_action( 'mpp_user_profile_form', $user_id );
|
837 |
} //end insert_upload_form
|
838 |
|
839 |
/**
|
|
|
|
|
840 |
* Output media scripts for thickbox and media uploader
|
841 |
**/
|
842 |
public function profile_print_media_scripts() {
|
846 |
}
|
847 |
|
848 |
/**
|
|
|
|
|
849 |
* Output media scripts for thickbox and media uploader
|
850 |
**/
|
851 |
public function print_media_scripts() {
|
925 |
<?php
|
926 |
} //end print_media_scripts
|
927 |
|
928 |
+
/**
|
929 |
+
* Output stylesheet for media page.
|
930 |
+
*/
|
931 |
public function print_media_styles() {
|
932 |
} //end print_media_styles
|
933 |
|
934 |
/**
|
|
|
|
|
935 |
* Gets permissions for the get users rest api endpoint.
|
936 |
*
|
937 |
* @return bool true if the user has permission, false if not
|
941 |
}
|
942 |
|
943 |
/**
|
944 |
+
* Registers REST API endpoints
|
945 |
+
*/
|
|
|
|
|
946 |
public function rest_api_register() {
|
947 |
register_rest_field(
|
948 |
'user',
|
985 |
'permission_callback' => array( $this, 'rest_get_users_permissions_callback' ),
|
986 |
)
|
987 |
);
|
988 |
+
// keep it for backward compatibility.
|
989 |
register_rest_route(
|
990 |
'mpp/v1',
|
991 |
'/user/(?P<id>\d+)',
|
1003 |
}
|
1004 |
|
1005 |
/**
|
|
|
|
|
1006 |
* Gets users for the Gutenberg block
|
1007 |
*
|
1008 |
+
* @param array $request WP REST API array.
|
1009 |
+
*
|
1010 |
+
* @return array A list of users.
|
1011 |
**/
|
1012 |
public function rest_api_get_users( $request ) {
|
1013 |
|
1028 |
$user_results = $user_query->get_results();
|
1029 |
$return = array();
|
1030 |
foreach ( $user_results as $result ) {
|
1031 |
+
// Get attachment ID.
|
1032 |
+
$profile_post_id = absint( get_user_option( 'metronet_post_id', $result->data->ID ) );
|
1033 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
1034 |
if ( ! $post_thumbnail_id ) {
|
1035 |
$result->data->has_profile_picture = false;
|
1038 |
$result->data->profile_pictures = array(
|
1039 |
'avatar' => get_avatar( $result->data->ID ),
|
1040 |
);
|
1041 |
+
$result->data->is_user_logged_in = ( get_current_user_id() == $result->data->ID ) ? true : false; // phpcs:ignore
|
1042 |
$return[ $result->data->ID ] = $result->data;
|
1043 |
continue;
|
1044 |
}
|
1045 |
$result->data->description = get_user_meta( $result->data->ID, 'description', true );
|
1046 |
$result->data->display_name = $result->data->display_name;
|
1047 |
$result->data->has_profile_picture = true;
|
1048 |
+
$result->data->is_user_logged_in = ( get_current_user_id() == $result->data->ID ) ? true : false; // phpcs:ignore
|
1049 |
$result->data->description = get_user_meta( $result->data->ID, 'description', true );
|
1050 |
|
1051 |
+
// Get attachment URL.
|
1052 |
$attachment_url = wp_get_attachment_url( $post_thumbnail_id );
|
1053 |
|
1054 |
$result->data->profile_picture_id = $post_thumbnail_id;
|
1070 |
}
|
1071 |
|
1072 |
/**
|
|
|
|
|
1073 |
* Changes a profile image for a user.
|
1074 |
*
|
1075 |
+
* @param array $request WP REST API array.
|
1076 |
*
|
1077 |
+
* @return array image URLs matched to sizes
|
1078 |
**/
|
1079 |
public function rest_api_change_profile_image( $request ) {
|
1080 |
|
1091 |
|
1092 |
$post_id = $this->get_post_id( $user_id );
|
1093 |
|
1094 |
+
// Save user meta.
|
1095 |
update_user_option( $user_id, 'metronet_post_id', $post_id );
|
1096 |
+
update_user_option( $user_id, 'metronet_image_id', $media_id ); // Added via this thread (Props Solinx) - https://wordpress.org/support/topic/storing-image-id-directly-as-user-meta-data.
|
1097 |
|
1098 |
set_post_thumbnail( $post_id, $media_id );
|
1099 |
|
1111 |
}
|
1112 |
|
1113 |
/**
|
|
|
|
|
1114 |
* Adds a profile picture to a user
|
1115 |
*
|
1116 |
+
* @param array $request WP REST API array.
|
1117 |
*
|
1118 |
+
* @return array image URLs matched to sizes
|
1119 |
**/
|
1120 |
public function rest_api_put_profile( $request ) {
|
1121 |
|
1137 |
}
|
1138 |
|
1139 |
$post_id = $this->get_post_id( $user_id );
|
1140 |
+
// Save user meta.
|
1141 |
update_user_option( $user_id, 'metronet_post_id', $post_id );
|
1142 |
+
update_user_option( $user_id, 'metronet_image_id', $media_id ); // Added via this thread (Props Solinx) - https://wordpress.org/support/topic/storing-image-id-directly-as-user-meta-data.
|
1143 |
|
1144 |
set_post_thumbnail( $post_id, $media_id );
|
1145 |
|
1157 |
}
|
1158 |
|
1159 |
/**
|
|
|
|
|
1160 |
* Returns the 5 most recent posts for the user
|
1161 |
+
*
|
1162 |
+
* @param array $request The REST Request data.
|
1163 |
**/
|
1164 |
public function rest_api_get_posts_for_user( $request ) {
|
1165 |
$user_id = absint( $request['user_id'] );
|
1184 |
wp_send_json( $posts );
|
1185 |
}
|
1186 |
/**
|
1187 |
+
* Returns an attachment image ID and profile image if available
|
1188 |
+
*
|
1189 |
+
* @param array $object REST object.
|
1190 |
+
* @param string $field_name The field to update.
|
1191 |
+
* @param array $request The request made.
|
1192 |
+
**/
|
1193 |
public function rest_api_get_profile_for_user( $object, $field_name, $request ) {
|
1194 |
$user_id = $object['id'];
|
1195 |
$user = get_user_by( 'id', $user_id );
|
1197 |
return new WP_Error( 'mpp_no_user', __( 'User not found.', 'metronet-profile-picture' ), array( 'status' => 404 ) );
|
1198 |
}
|
1199 |
|
1200 |
+
// No capability check here because we're just returning user profile data.
|
1201 |
|
1202 |
+
// Get attachment ID.
|
1203 |
$profile_post_id = absint( get_user_option( 'metronet_post_id', $user_id ) );
|
1204 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
1205 |
if ( ! $post_thumbnail_id ) {
|
1206 |
return new WP_Error( 'mpp_no_profile_picture', __( 'Profile picture not found.', 'metronet-profile-picture' ), array( 'status' => 404 ) );
|
1207 |
}
|
1208 |
|
1209 |
+
// Get attachment URL.
|
1210 |
$attachment_url = wp_get_attachment_url( $post_thumbnail_id );
|
1211 |
|
1212 |
return array(
|
1220 |
}
|
1221 |
|
1222 |
/**
|
|
|
|
|
1223 |
* Returns a profile for the user
|
1224 |
*
|
1225 |
+
* @param array $data WP REST API array.
|
1226 |
*
|
1227 |
* @return json image URLs matched to sizes
|
1228 |
**/
|
1233 |
return new WP_Error( 'mpp_no_user', __( 'User not found.', 'metronet-profile-picture' ), array( 'status' => 404 ) );
|
1234 |
}
|
1235 |
|
1236 |
+
// Get attachment ID.
|
1237 |
$profile_post_id = absint( get_user_option( 'metronet_post_id', $user_id ) );
|
1238 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
1239 |
if ( ! $post_thumbnail_id ) {
|
1240 |
return new WP_Error( 'mpp_no_profile_picture', __( 'Profile picture not found.', 'metronet-profile-picture' ), array( 'status' => 404 ) );
|
1241 |
}
|
1242 |
|
1243 |
+
// Get attachment URL.
|
1244 |
$attachment_url = wp_get_attachment_url( $post_thumbnail_id );
|
1245 |
|
1246 |
return array(
|
1250 |
}
|
1251 |
|
1252 |
/**
|
|
|
|
|
1253 |
* Makes sure the ID we are passed is numeric
|
1254 |
+
*
|
1255 |
+
* @param mixed $param The paramater to validate.
|
1256 |
+
* @param array $request The REST request.
|
1257 |
+
* @param mixed $key The key to check.
|
1258 |
+
*
|
1259 |
+
* @return bool Whether to the parameter is numeric or not.
|
1260 |
**/
|
1261 |
public function rest_api_validate( $param, $request, $key ) {
|
1262 |
return is_numeric( $param );
|
1263 |
}
|
1264 |
|
1265 |
/**
|
|
|
|
|
1266 |
* Sanitizes user ID
|
1267 |
+
*
|
1268 |
+
* @param mixed $param The paramater to validate.
|
1269 |
+
* @param array $request The REST request.
|
1270 |
+
* @param mixed $key The key to check.
|
1271 |
+
*
|
1272 |
+
* @return int Sanitized user ID.
|
1273 |
**/
|
1274 |
public function rest_api_sanitize( $param, $request, $key ) {
|
1275 |
return absint( $param );
|
1276 |
}
|
1277 |
|
1278 |
/**
|
|
|
|
|
1279 |
* Saves user profile fields
|
1280 |
+
*
|
1281 |
+
* @param int $user_id The User ID to save.
|
1282 |
**/
|
1283 |
public function save_user_profile( $user_id ) {
|
1284 |
if ( ! isset( $_POST['metronet-user-avatar'] ) ) {
|
1288 |
|
1289 |
flush_rewrite_rules( true );
|
1290 |
|
1291 |
+
$user_avatar = filter_input( INPUT_POST, 'metronet-user-avatar' );
|
1292 |
if ( 'on' === $user_avatar ) {
|
1293 |
update_user_option( $user_id, 'metronet_avatar_override', 'on' );
|
1294 |
} else {
|
1296 |
}
|
1297 |
} //end save_user_profile
|
1298 |
|
1299 |
+
}
|
1300 |
+
|
1301 |
+
// instantiate the class.
|
1302 |
global $mt_pp;
|
1303 |
if ( class_exists( 'Metronet_Profile_Picture' ) ) {
|
1304 |
if ( get_bloginfo( 'version' ) >= '3.5' ) {
|
1305 |
add_action( 'plugins_loaded', 'mt_mpp_instantiate', 10 );
|
1306 |
}
|
1307 |
}
|
1308 |
+
|
1309 |
+
/**
|
1310 |
+
* Instantiate User Profile Picture.
|
1311 |
+
*/
|
1312 |
function mt_mpp_instantiate() {
|
1313 |
global $mt_pp;
|
1314 |
$mt_pp = new Metronet_Profile_Picture();
|
1315 |
}
|
1316 |
/**
|
1317 |
+
* Template tag for outputting a profile image.
|
|
|
|
|
1318 |
*
|
1319 |
+
* @param int $user_id The user ID for the user to retrieve the image for.
|
1320 |
+
* @param mixed $args Arguments for custom output.
|
1321 |
+
* size - string || array (see get_the_post_thumbnail).
|
1322 |
+
* attr - string || array (see get_the_post_thumbnail).
|
1323 |
+
* echo - bool (true or false) - whether to echo the image or return it.
|
1324 |
+
*/
|
1325 |
function mt_profile_img( $user_id, $args = array() ) {
|
1326 |
$profile_post_id = absint( get_user_option( 'metronet_post_id', $user_id ) );
|
1327 |
|
1335 |
'echo' => true,
|
1336 |
);
|
1337 |
$args = wp_parse_args( $args, $defaults );
|
1338 |
+
extract( $args ); // phpcs:ignore
|
1339 |
|
1340 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
1341 |
|
1342 |
+
// Return false or echo nothing if there is no post thumbnail.
|
1343 |
if ( ! $post_thumbnail_id ) {
|
1344 |
if ( $echo ) {
|
1345 |
echo '';
|
1349 |
return;
|
1350 |
}
|
1351 |
|
1352 |
+
// Implode Classes if set and array - dev note: edge case.
|
1353 |
if ( is_array( $attr ) && isset( $attr['class'] ) ) {
|
1354 |
if ( is_array( $attr['class'] ) ) {
|
1355 |
$attr['class'] = implode( ' ', $attr['class'] );
|
1363 |
*
|
1364 |
* Filter outputted HTML.
|
1365 |
*
|
1366 |
+
* @param string $post_thumbnail img tag with formed HTML.
|
1367 |
+
* @param int $profile_post_id The profile in which the image is attached.
|
1368 |
+
* @param int $profile_thumbnail_id The thumbnail ID for the attached image.
|
1369 |
+
* @param int $user_id The user id for which the image is attached.
|
|
|
1370 |
*/
|
1371 |
$post_thumbnail = apply_filters( 'mpp_thumbnail_html', $post_thumbnail, $profile_post_id, $post_thumbnail_id, $user_id );
|
1372 |
if ( $echo ) {
|
1377 |
} //end mt_profile_img
|
1378 |
|
1379 |
/**
|
|
|
|
|
1380 |
* Adds a profile author box
|
1381 |
*
|
1382 |
* @since 2.2.0
|
1383 |
*
|
1384 |
+
* @param int $user_id The user ID for the user to retrieve the profile for.
|
1385 |
+
* @param array $attributes See defaults in function for all attributes.
|
1386 |
*
|
1387 |
* @return string User profile box if user exists
|
1388 |
+
*/
|
|
|
1389 |
function mt_author_box( $user_id = 0, $attributes = array() ) {
|
1390 |
$user = get_user_by( 'id', $user_id );
|
1391 |
if ( false === $user ) {
|
1392 |
return '';
|
1393 |
}
|
1394 |
$defaults = array(
|
1395 |
+
'theme' => 'regular', /* Can be regular, compact, profile, or tabbed */
|
1396 |
'profileAvatarShape' => 'square', /* Can be 'square' or 'rounded' */
|
1397 |
'padding' => 10,
|
1398 |
'border' => 1,
|
1434 |
'socialGitHub' => '',
|
1435 |
'socialMediaOptions' => 'brand', /* can be brand or custom */
|
1436 |
'socialMediaColors' => '#000000', /* Only applicable if socialMediaOptions is custom */
|
1437 |
+
'profileCompactAlignment' => 'center', // Can be left, center, or right.
|
1438 |
/* Tabbed Attributes */
|
1439 |
'tabbedAuthorProfileTitle' => '',
|
1440 |
'tabbedAuthorSubHeading' => '',
|
1480 |
<?php esc_html_e( 'View Posts', 'metronet-profile-picture' ); ?></a>
|
1481 |
</div><!-- .mpp-profile-view-posts -->
|
1482 |
<?php endif; ?>
|
1483 |
+
<?php if ( '' !== $attributes['website'] && $attributes['showWebsite'] ) : ?>
|
1484 |
<div class="mpp-profile-view-website" style="background: <?php echo esc_attr( $attributes['profileWebsiteBackgroundColor'] ); ?>;color: <?php echo esc_attr( $attributes['profileWebsiteTextColor'] ); ?>; font-size: <?php echo esc_attr( $attributes['buttonFontSize'] ); ?>px;">
|
1485 |
+
<a href="<?php echo esc_url( $attributes['website'] ); ?>" style="background: <?php echo esc_attr( $attributes['profileWebsiteBackgroundColor'] ); ?>; color: <?php echo esc_attr( $attributes['profileWebsiteTextColor'] ); ?>;"><?php esc_html_e( 'View Website', 'metronet-profile-picture' ); ?></a>
|
1486 |
</div><!-- .mpp-profile-view-website -->
|
1487 |
<?php endif; ?>
|
1488 |
</div><!-- .mpp-gutenberg-view-posts -->
|
1545 |
</div>
|
1546 |
<?php endif; /* Compact theme end */ ?>
|
1547 |
<?php if ( true === $attributes['showSocialMedia'] && ( 'regular' === $attributes['theme'] || 'compact' === $attributes['theme'] || 'profile' === $attributes['theme'] ) ) : ?>
|
1548 |
+
<?php echo mpp_get_social_icons( $attributes ); // phpcs:ignore ?>
|
1549 |
<?php endif; ?>
|
1550 |
</div><!-- .mpp-profile-gutenberg-wrap -->
|
1551 |
</div><!-- .mpp-profile-wrap -->
|
1580 |
</div><!-- .mpp-author-social-wrapper -->
|
1581 |
<?php if ( $attributes['showSocialMedia'] ) : ?>
|
1582 |
<div class="mpp-author-social">
|
1583 |
+
<?php echo mpp_get_social_icons( $attributes ); // phpcs:ignore ?>
|
1584 |
</div>
|
1585 |
<?php endif; ?>
|
1586 |
</div><!-- .mpp-author-social-wrapper -->
|
1634 |
wp_enqueue_style( 'mpp_gutenberg', Metronet_Profile_Picture::get_plugin_url( '/css/front-end-gutenberg.css' ), array(), METRONET_PROFILE_PICTURE_VERSION, 'all' );
|
1635 |
wp_enqueue_script( 'mpp_gutenberg_tabs', Metronet_Profile_Picture::get_plugin_url( 'js/mpp-frontend' . $min_or_not . '.js' ), array( 'jquery' ), METRONET_PROFILE_PICTURE_VERSION, true );
|
1636 |
add_action( 'wp_footer', 'mpp_load_gutenblock_svgs' );
|
1637 |
+
echo ob_get_clean(); // phpcs:ignore
|
1638 |
}
|
1639 |
/**
|
|
|
|
|
1640 |
* Get social icons based on passed attributes
|
1641 |
*
|
1642 |
* @see mt_author_box for attribute valies
|
1643 |
*
|
1644 |
* @since 2.2.0
|
1645 |
*
|
1646 |
+
* @param array $attributes See defaults in function mt_author_box for all attributes.
|
1647 |
*
|
1648 |
* @return string User social icons
|
1649 |
+
*/
|
|
|
1650 |
function mpp_get_social_icons( $attributes ) {
|
1651 |
ob_start();
|
1652 |
?>
|
1665 |
</svg>
|
1666 |
</a>
|
1667 |
<?php endif; ?>
|
1668 |
+
<?php if ( ! empty( $attributes['socialInstagram'] ) ) : ?>
|
1669 |
<a href="<?php echo esc_url( $attributes['socialInstagram'] ); ?>">
|
1670 |
<svg class="icon icon-instagram" role="img" style="<?php echo 'custom' === $attributes['socialMediaOptions'] ? 'fill:' . esc_attr( $attributes['socialMediaColors'] ) . ';' : ''; ?>">
|
1671 |
<use href="#instagram"></use>
|
1693 |
</svg>
|
1694 |
</a>
|
1695 |
<?php endif; ?>
|
1696 |
+
<?php if ( ! empty( $attributes['socialGitHub'] ) ) : ?>
|
1697 |
<a href="<?php echo esc_url( $attributes['socialGitHub'] ); ?>">
|
1698 |
<svg class="icon icon-github" role="img" style="<?php echo 'custom' === $attributes['socialMediaOptions'] ? 'fill:' . esc_attr( $attributes['socialMediaColors'] ) . ';' : ''; ?>">
|
1699 |
<use href="#github"></use>
|
1703 |
<?php if ( ! empty( $attributes['socialWordPress'] ) ) : ?>
|
1704 |
<a href="<?php echo esc_url( $attributes['socialWordPress'] ); ?>">
|
1705 |
<svg class="icon icon-wordpress" role="img" style="<?php echo 'custom' === $attributes['socialMediaOptions'] ? 'fill:' . esc_attr( $attributes['socialMediaColors'] ) . ';' : ''; ?>">
|
1706 |
+
<use href="#wordpress"></use><?php // phpcs:ignore ?>
|
1707 |
</svg>
|
1708 |
</a>
|
1709 |
<?php endif; ?>
|
1712 |
return ob_get_clean();
|
1713 |
}
|
1714 |
/**
|
|
|
|
|
1715 |
* Load social icons in footer of theme
|
1716 |
*
|
1717 |
* @since 2.2.0
|
1718 |
+
*/
|
|
|
|
|
|
|
1719 |
function mpp_load_gutenblock_svgs() {
|
1720 |
/**
|
1721 |
* Allow other plugins to run code from inside this SVG block.
|
1722 |
*
|
1723 |
* @since 2.3.0
|
|
|
1724 |
*/
|
1725 |
do_action( 'mpp_svg_start' );
|
1726 |
if ( '' !== get_post_type() ) {
|
1750 |
* Allow other plugins to run code from inside this SVG block at the end.
|
1751 |
*
|
1752 |
* @since 2.3.0
|
|
|
1753 |
*/
|
1754 |
do_action( 'mpp_svg_end' );
|
1755 |
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: ronalfy, Alaadiaa
|
3 |
Tags: users, user profile, gravatar, avatar, blocks, block
|
4 |
Requires at least: 3.5
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag: 2.3.
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -126,6 +126,11 @@ Yes, but you'll have to set a new profile image per site. This is currently a l
|
|
126 |
|
127 |
== Changelog ==
|
128 |
|
|
|
|
|
|
|
|
|
|
|
129 |
= 2.3.5 =
|
130 |
* Released 2019-09-17
|
131 |
* Added option in Gutenberg block to customize the View Posts and View Website text.
|
@@ -330,5 +335,5 @@ Yes, but you'll have to set a new profile image per site. This is currently a l
|
|
330 |
|
331 |
== Upgrade Notice ==
|
332 |
|
333 |
-
= 2.3.
|
334 |
-
|
2 |
Contributors: ronalfy, Alaadiaa
|
3 |
Tags: users, user profile, gravatar, avatar, blocks, block
|
4 |
Requires at least: 3.5
|
5 |
+
Tested up to: 5.3
|
6 |
+
Stable tag: 2.3.6
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
+
= 2.3.6 =
|
130 |
+
* Released 2019-10-09
|
131 |
+
* Updating compatibility with WordPress 5.3
|
132 |
+
* Fixing JavaScript error in WordPress 5.3
|
133 |
+
|
134 |
= 2.3.5 =
|
135 |
* Released 2019-09-17
|
136 |
* Added option in Gutenberg block to customize the View Posts and View Website text.
|
335 |
|
336 |
== Upgrade Notice ==
|
337 |
|
338 |
+
= 2.3.6 =
|
339 |
+
Ensuring plugin works with WordPress 5.3.
|
src/block/profile.js
CHANGED
@@ -100,7 +100,7 @@ class MPP_Gutenberg_Enhanced extends Component {
|
|
100 |
let profile_title = '';
|
101 |
let profile_url = '';
|
102 |
let show_website = '';
|
103 |
-
|
104 |
users[value.ID] = {
|
105 |
profile_pictures: value.profile_pictures,
|
106 |
has_profile_picture: value.has_profile_picture,
|
100 |
let profile_title = '';
|
101 |
let profile_url = '';
|
102 |
let show_website = '';
|
103 |
+
jQuery.each( response.data, function( key, value ) {
|
104 |
users[value.ID] = {
|
105 |
profile_pictures: value.profile_pictures,
|
106 |
has_profile_picture: value.has_profile_picture,
|