From 755da2c5ab1f201b52328e7f2535f37b2d606f86 Mon Sep 17 00:00:00 2001 From: shahid Date: Tue, 26 May 2020 16:40:30 +0530 Subject: [PATCH] added author url and show the comment app based on wordpress comment enable disable setting --- backend/src/Data/Transformers/CommentTransformer.php | 1 + backend/src/Hooks/Actions/OnEnqueueScripts.php | 11 +++++++++++ src/apps/fl-comments/index.js | 5 ++++- src/render/app/side-bar/index.js | 2 +- src/system/ui/pages/comment/index.js | 5 +++++ 5 files changed, 22 insertions(+), 2 deletions(-) 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 88557fc56..1e9c1906a 100644 --- a/backend/src/Hooks/Actions/OnEnqueueScripts.php +++ b/backend/src/Hooks/Actions/OnEnqueueScripts.php @@ -102,6 +102,16 @@ 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 +134,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..548202109 100644 --- a/src/apps/fl-comments/index.js +++ b/src/apps/fl-comments/index.js @@ -2,15 +2,18 @@ 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..8d244f49d 100644 --- a/src/render/app/side-bar/index.js +++ b/src/render/app/side-bar/index.js @@ -8,7 +8,7 @@ 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, diff --git a/src/system/ui/pages/comment/index.js b/src/system/ui/pages/comment/index.js index 668496204..f0ec66b73 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',