From 0f9f5a4b12a024d14a6bf0d2739af214e255b4fd Mon Sep 17 00:00:00 2001 From: nick-funk Date: Fri, 23 Aug 2019 16:33:42 -0600 Subject: [PATCH 1/7] Allow users to select their talk version and embed v5 comments CORL-462 --- inc/class-talk-settings-page.php | 43 ++++++++++++++++++++++++++++++++ inc/comments-template.php | 28 ++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/inc/class-talk-settings-page.php b/inc/class-talk-settings-page.php index f47c28cd..f977ad69 100644 --- a/inc/class-talk-settings-page.php +++ b/inc/class-talk-settings-page.php @@ -76,6 +76,15 @@ function() { 'about-talk' ); register_setting( 'talk-settings', 'coral_talk_container_classes' ); + + add_settings_field( + 'coral_talk_version', + __( 'Talk version', 'coral-project-talk' ), + array( $this, 'render_version_field' ), + 'talk-settings', + 'about-talk' + ); + register_setting( 'talk-settings', 'coral_talk_version' ); } /** @@ -145,6 +154,40 @@ public function render_container_classes_field() { + + + +if ( empty( $talk_url) ): + exit(); +endif; + +if ( $talk_version == "4" ) : ?>
+
+ + Date: Mon, 26 Aug 2019 09:57:15 -0600 Subject: [PATCH 2/7] Replace all displayed text instances of `Talk` with `Coral` or similar. CORL-462 --- README.md | 24 +++++++++++--------- codesniffer.ruleset.xml | 4 ++-- inc/class-talk-default-comments-settings.php | 4 ++-- inc/class-talk-settings-page.php | 22 +++++++++--------- inc/talk-settings-static-content.php | 8 +++---- talk.php | 6 ++--- 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 328e9ddb..bec9026e 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,27 @@ -# Coral Project Talk +# Coral Plugin -This plugin replaces standard WordPress commenting with [Talk](https://coralproject.net/products/talk.html) from the [Coral Project](https://coralproject.net). +This plugin replaces standard WordPress commenting with [Coral](https://coralproject.net/products/talk.html) from the [Coral Project](https://coralproject.net). ## Setup -First, you'll need a server running your own instance of Talk. See the [Talk Docs](https://docs.coralproject.net/talk/) for more info about that. +First, you'll need a server running your own instance of Coral. See the [Coral Docs](https://docs.coralproject.net/talk/) for more info about that. Then... -1. Add the hostname of your WordPress site to the whitelist in the settings of your Talk instance. +1. Add the hostname of your WordPress site to the whitelist in the settings of your Coral instance. 1. Install and activate this plugin as you would any other WordPress plugin. 1. Go to `https://mysite.com/wp-admin/options-general.php?page=talk-settings` -1. Enter the URL of your Talk instance and click Save. +1. Enter the URL of your Coral instance and click Save. ## HTTPS and Dev Mode -Your site must be served over `https` in order to integrate with Talk **unless** Talk is set to dev mode. +Your site must be served over `https` in order to integrate with Coral **unless** Coral is set to dev mode. -If you're installing Talk with Docker, you can do that by adding `NODE_ENV=dev` to the environment variables in your [`docker-compose.yml`](https://docs.coralproject.net/talk/installation-from-docker/). Otherwise, any method of setting `process.env.NODE_ENV = 'dev'` will do the trick. +If you're installing Coral with Docker, you can do that by adding `NODE_ENV=dev` to the environment variables in your [`docker-compose.yml`](https://docs.coralproject.net/talk/installation-from-docker/). Otherwise, any method of setting `process.env.NODE_ENV = 'dev'` will do the trick. ## Theme usage -If your theme uses WordPress' standard `comments_template()` to render comments forms, the output will be overridden by the Talk embed code. +If your theme uses WordPress' standard `comments_template()` to render comments forms, the output will be overridden by the Coral embed code. If you are building a custom theme, we recommend using `coral_talk_comments_template()` instead of the usual `comments_template()` for performance reasons. @@ -29,7 +29,7 @@ Note that comments can still be turned on or off for an invidual post: ![Discussion meta box](lib/img/discussion-meta-box.png) -[`comments_open()`](https://codex.wordpress.org/Function_Reference/comments_open) will still work when Coral Project Talk is active, but other functions like [`get_comments_number()`](https://codex.wordpress.org/Template_Tags/get_comments_number) that reference the `wp_comments` database table may not. +[`comments_open()`](https://codex.wordpress.org/Function_Reference/comments_open) will still work when the Coral Plugin is active, but other functions like [`get_comments_number()`](https://codex.wordpress.org/Template_Tags/get_comments_number) that reference the `wp_comments` database table may not. We recommend something like: @@ -40,6 +40,8 @@ if ( comments_open() ) { ``` ## Version -Talk version <= `v3.9.1` use talk-wp-plugin `v0.0.6` +Coral version <= `v3.9.1` use plugin version `v0.0.6` -Talk version >= `4.0.0` use talk-wp-plugin `v0.1.0` +Coral version >= `4.0.0` use plugin version `v0.1.0` + +Coral version >= `5.0.0` use plugin version `v0.2.0` diff --git a/codesniffer.ruleset.xml b/codesniffer.ruleset.xml index 285ba128..bfd11c21 100644 --- a/codesniffer.ruleset.xml +++ b/codesniffer.ruleset.xml @@ -1,6 +1,6 @@ - - PHP_CodeSniffer standard for the Coral Project Talk plugin + + PHP_CodeSniffer standard for the Coral Project plugin diff --git a/inc/class-talk-default-comments-settings.php b/inc/class-talk-default-comments-settings.php index cc339c6f..5749ea46 100644 --- a/inc/class-talk-default-comments-settings.php +++ b/inc/class-talk-default-comments-settings.php @@ -15,7 +15,7 @@ public function __construct() { } ); add_action( 'post_comment_status_meta_box-options', function() { printf( '

%s

', - esc_html__( 'Comments managed by Coral Project Talk', 'coral-project-talk' ) + esc_html__( 'Comments managed by Coral Project', 'coral-project-talk' ) ); } ); } @@ -30,7 +30,7 @@ public function options_discussion_notice() { if ( 'options-discussion' === $screen->base ) { coral_talk_print_admin_notice( 'success', - __( 'Comments are managed by Coral Project Talk. (%ssettings%s)', 'coral-project-talk' ) + __( 'Comments are managed by Coral Project. (%ssettings%s)', 'coral-project-talk' ) ); } } diff --git a/inc/class-talk-settings-page.php b/inc/class-talk-settings-page.php index f977ad69..bc708c90 100644 --- a/inc/class-talk-settings-page.php +++ b/inc/class-talk-settings-page.php @@ -20,8 +20,8 @@ public function __construct() { */ public function register_settings_page() { add_options_page( - __( 'Talk Settings', 'coral-project-talk' ), - __( 'Talk Settings', 'coral-project-talk' ), + __( 'Coral Settings', 'coral-project-talk' ), + __( 'Coral Settings', 'coral-project-talk' ), 'manage_options', 'talk-settings', array( $this, 'render_settings_page' ) @@ -37,7 +37,7 @@ public function register_settings_page() { public function setup_settings_page() { add_settings_section( 'about-talk', - __( 'About Talk', 'coral-project-talk' ), + __( 'About Coral', 'coral-project-talk' ), function() { require_once( CORAL_PROJECT_TALK_DIR . '/inc/talk-settings-static-content.php' ); }, @@ -46,7 +46,7 @@ function() { add_settings_field( 'coral_talk_base_url', - __( 'Talk Server Base URL', 'coral-project-talk' ), + __( 'Server Base URL', 'coral-project-talk' ), array( $this, 'render_base_url_field' ), 'talk-settings', 'about-talk' @@ -58,7 +58,7 @@ function() { add_settings_field( 'coral_talk_static_url', - __( 'Talk Static Asset URL', 'coral-project-talk' ), + __( 'Static Asset URL', 'coral-project-talk' ), array( $this, 'render_static_url_field' ), 'talk-settings', 'about-talk' @@ -70,7 +70,7 @@ function() { add_settings_field( 'coral_talk_container_classes', - __( 'Talk Embed Container CSS Classes', 'coral-project-talk' ), + __( 'Embed Container CSS Classes', 'coral-project-talk' ), array( $this, 'render_container_classes_field' ), 'talk-settings', 'about-talk' @@ -79,7 +79,7 @@ function() { add_settings_field( 'coral_talk_version', - __( 'Talk version', 'coral-project-talk' ), + __( 'Version', 'coral-project-talk' ), array( $this, 'render_version_field' ), 'talk-settings', 'about-talk' @@ -108,12 +108,12 @@ public function render_base_url_field() { -

The root url of the installed Talk application. This is the same value as TALK_ROOT_URL defined in the Talk application configuration.

+

The root url of the installed Coral application. This is the same value as ROOT_URL defined in the Coral application configuration.

" /> -

The root url where static Talk assets should be served from. This is the same value as TALK_STATIC_URI defined in the Talk application configuration.

+

The root url where static Coral assets should be served from. This is the same value as STATIC_URI defined in the Coral application configuration.

-

+

', '' ); ?>

', '' ); ?>

-

+

', '' diff --git a/talk.php b/talk.php index e9d76d07..a740e059 100644 --- a/talk.php +++ b/talk.php @@ -1,8 +1,8 @@ Date: Mon, 26 Aug 2019 15:31:23 -0600 Subject: [PATCH 3/7] Set the storyID when embedding v5 comment streams Allows Coral to properly distinguish which post we're coming from. Without this, the Stories area will accept new posts as stories, and they will be distinct, but all named the same as the first post ever created (very confusing to moderators). CORL-462 --- inc/comments-template.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/comments-template.php b/inc/comments-template.php index 3df15821..d169c62c 100644 --- a/inc/comments-template.php +++ b/inc/comments-template.php @@ -40,6 +40,7 @@ id: "coral_thread", autoRender: true, rootURL: "", + storyID: "", }); }; (d.head || d.body).appendChild(s); From 5ee42aad592085542645dad81aee61a5698f65a3 Mon Sep 17 00:00:00 2001 From: nick-funk Date: Mon, 26 Aug 2019 15:35:39 -0600 Subject: [PATCH 4/7] When embedding the comments, fall back to v4 if Coral version is not v5 This is due to the fact that v4 covers all previous versions of comments and not just v4. CORL-462 --- inc/comments-template.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/inc/comments-template.php b/inc/comments-template.php index d169c62c..abfee504 100644 --- a/inc/comments-template.php +++ b/inc/comments-template.php @@ -19,16 +19,6 @@ exit(); endif; -if ( $talk_version == "4" ) : ?> -

- -
+
+ + Date: Mon, 26 Aug 2019 15:38:14 -0600 Subject: [PATCH 5/7] Bump plugin version 0.2.0 due to new v5 support changes CORL-462 --- talk.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/talk.php b/talk.php index a740e059..01afe370 100644 --- a/talk.php +++ b/talk.php @@ -3,7 +3,7 @@ * Plugin Name: Coral Project * Plugin URI: https://coralproject.net * Description: A plugin to replace stock WP commenting with Coral Project comments. - * Version: 0.1.0 + * Version: 0.2.0 * Author: Alley Interactive, The Coral Project * Author URI: https://www.alleyinteractive.com * License: Apache 2.0 From bde45ed366e158c7fd5b7a90b5729fc651ad2cd5 Mon Sep 17 00:00:00 2001 From: nick-funk Date: Tue, 3 Sep 2019 09:32:55 -0600 Subject: [PATCH 6/7] Pull talk version retrieval into a re-usable variable CORL-462 --- inc/class-talk-settings-page.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/class-talk-settings-page.php b/inc/class-talk-settings-page.php index bc708c90..559e76bf 100644 --- a/inc/class-talk-settings-page.php +++ b/inc/class-talk-settings-page.php @@ -160,6 +160,7 @@ public function render_container_classes_field() { * @since 0.0.3 */ public function render_version_field() { + $talk_version = esc_attr( get_option( 'coral_talk_version' ) ) ?>