diff --git a/backend/src/Data/Transformers/CommentTransformer.php b/backend/src/Data/Transformers/CommentTransformer.php index 52b58bbe6..eec34a64a 100644 --- a/backend/src/Data/Transformers/CommentTransformer.php +++ b/backend/src/Data/Transformers/CommentTransformer.php @@ -15,6 +15,7 @@ public function __invoke( \WP_Comment $comment ) { 'author' => $comment->comment_author, 'authorEmail' => $comment->comment_author_email, 'authorIP' => $comment->comment_author_IP, + 'authorUrl' => get_author_posts_url( $comment->user_id ), 'content' => $comment->comment_content, 'date' => $date, 'editUrl' => admin_url( 'comment.php?action=editcomment&c=' ) . $comment->comment_ID, diff --git a/backend/src/Hooks/Actions/OnEnqueueScripts.php b/backend/src/Hooks/Actions/OnEnqueueScripts.php index 7b3750551..5ec62f30d 100644 --- a/backend/src/Hooks/Actions/OnEnqueueScripts.php +++ b/backend/src/Hooks/Actions/OnEnqueueScripts.php @@ -102,6 +102,15 @@ public function generate_frontend_config() { $current_user = $this->users->current( $this->user_transform ); + $wp_comments = get_option( 'default_comment_status' ); + if ( isset( $wp_comments ) ) { + if ( $wp_comments === 'closed' ) { + $wp_comment_status = 0; + } else { + $wp_comment_status = 1; + } + } + return [ 'adminURLs' => $this->site->get_admin_urls(), 'ajaxUrl' => admin_url( 'admin-ajax.php' ), @@ -124,6 +133,7 @@ public function generate_frontend_config() { 'pluginURL' => FL_ASSISTANT_URL, 'taxonomies' => $this->posts->get_taxononies(), 'userRoles' => $this->users->get_roles(), + 'wpCommentStatus' => $wp_comment_status, /* 'integrations' => [ diff --git a/src/apps/fl-comments/index.js b/src/apps/fl-comments/index.js index bfee8b1db..e760aad47 100644 --- a/src/apps/fl-comments/index.js +++ b/src/apps/fl-comments/index.js @@ -2,15 +2,19 @@ import { registerApp } from 'assistant' import { __ } from '@wordpress/i18n' import { addQueryArgs } from 'assistant/utils/url' import { currentUserCan } from 'assistant/utils/wordpress' +import { getSystemConfig } from 'data' import { Page } from 'assistant/ui' import { CommentsApp } from './app' import Icon from './icon' + +const { wpCommentStatus } = getSystemConfig() + registerApp( 'fl-comments', { label: __( 'Comments' ), root: CommentsApp, icon: Icon, - enabled: currentUserCan( 'moderate_comments' ), + enabled: currentUserCan( 'moderate_comments' ) && 1 == wpCommentStatus, accent: { color: '#FFCC00' }, diff --git a/src/render/app/side-bar/index.js b/src/render/app/side-bar/index.js index 94ebac9a3..10cf478f9 100644 --- a/src/render/app/side-bar/index.js +++ b/src/render/app/side-bar/index.js @@ -8,16 +8,11 @@ import { useMedia } from 'assistant/utils/react' import './style.scss' const Sidebar = ( { edge = 'right' } ) => { - const { window, isAppHidden } = useSystemState() + const { window, isAppHidden } = useSystemState() const { isMobile, isCompactHeight, application } = Env.useEnvironment() - const { - toggleIsShowingUI, - setWindow, - setIsAppHidden - } = getSystemActions() + const { toggleIsShowingUI, setWindow, setIsAppHidden } = getSystemActions() const isVeryCompactHeight = useMedia( { maxHeight: 400 } ) - const getMaxCount = () => { if ( isVeryCompactHeight ) { return 3 @@ -67,17 +62,18 @@ const Sidebar = ( { edge = 'right' } ) => { } ) return ( -
- { ! isBeaverBuilder && ( -
+ {! isBeaverBuilder && ( +
)} - -
+
- { apps.map( ( app, i ) => { + {apps.map( ( app, i ) => { const { label, handle, icon } = app const location = { pathname: `/${handle}`, - state: app, + state: app } const isSelected = pathname.startsWith( `/${handle}` ) return ( + > + {icon( { context: 'sidebar', isSelected } )} + ) } )}
- { ! isBeaverBuilder && ! isMobile && ( -
+ {! isBeaverBuilder && ! isMobile && ( +
)} diff --git a/src/system/ui/pages/comment/index.js b/src/system/ui/pages/comment/index.js index 668496204..08f218ce5 100644 --- a/src/system/ui/pages/comment/index.js +++ b/src/system/ui/pages/comment/index.js @@ -18,6 +18,7 @@ export const Comment = ( { location } ) => { postId, url, editUrl, + authorUrl } = item const { pluginURL } = getSystemConfig() const hero = `${pluginURL}img/comment-hero-a.jpg` @@ -248,6 +249,10 @@ export const Comment = ( { location } ) => { type: 'text', component: 'plain-text' }, + authorUrl: { + label: __( 'Author Url' ), + component: 'url' + }, date: { label: __( 'Submitted On' ), labelPlacement: 'beside', diff --git a/src/system/utils/wordpress/user.js b/src/system/utils/wordpress/user.js index a9e3f09d6..abf0adaf1 100644 --- a/src/system/utils/wordpress/user.js +++ b/src/system/utils/wordpress/user.js @@ -4,3 +4,4 @@ export const currentUserCan = ( cap ) => { const { currentUser } = getSystemConfig() return currentUser.capabilities[ cap ] ? true : false } +