Skip to content

Commit bb96027

Browse files
committed
address review feedback; add ability to enable/disable canonical story URL
1 parent 718607f commit bb96027

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ Then you will need to:
1616

1717
## Story settings
1818

19-
The plugin uses the canonical URL for a Wordpress post for the Coral Story URL.
19+
The plugin supports enabling canonical URLs for a Wordpress post to be passed through to the Coral stream embed as the story URL.
2020

2121
The plugin also supports setting a story mode and sending it through to the Coral stream embed. To use, you can add a custom field in Wordpress called `coralStoryMode` and then set it to a valid story mode.
2222

2323
## HTTPS and Dev Mode
2424

2525
Your site must be served over `https` in order to integrate with Coral **unless** Coral is set to dev mode.
2626

27-
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/environment-variables#node_env). Otherwise, any method of setting `process.env.NODE_ENV = 'dev'` will do the trick.
27+
If you're installing Coral with Docker, you can do that by adding `NODE_ENV=development` to the environment variables in your [`docker-compose.yml`](https://docs.coralproject.net/environment-variables#node_env). Otherwise, any method of setting `NODE_ENV=development` will do the trick.
2828

2929
## Theme usage
3030

@@ -58,4 +58,4 @@ Coral version <= `v3.9.1` use plugin version `v0.0.6`
5858

5959
Coral version >= `4.0.0` use plugin version `v0.1.0`
6060

61-
Coral version >= `5.0.0` use plugin version `v0.2.1`
61+
Coral version >= `5.0.0` use plugin version `v1.0.0`

inc/class-talk-settings-page.php

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ function() {
127127
'about-talk'
128128
);
129129
register_setting( 'talk-settings', 'coral_custom_scroll_container' );
130+
131+
add_settings_field(
132+
'coral_enable_canonical_story_urls',
133+
__( 'Enable canonical story urls', 'coral-project-talk' ),
134+
array( $this, 'render_enable_canonical_story_urls_field' ),
135+
'talk-settings',
136+
'about-talk'
137+
);
138+
register_setting( 'talk-settings', 'coral_enable_canonical_story_urls' );
130139
}
131140

132141
/**
@@ -269,6 +278,42 @@ public function render_disable_default_fonts_field() {
269278
id="coral_disable_default_fonts"
270279
type="select"
271280
>
281+
<option value="false"
282+
<?php
283+
if ($default_fonts === "false")
284+
echo "selected=\"selected\""
285+
?>
286+
>
287+
false
288+
</option>
289+
<option value="true"
290+
<?php
291+
if ($default_fonts === "true")
292+
echo "selected=\"selected\""
293+
?>
294+
>
295+
true
296+
</option>
297+
</select>
298+
<p class="description">Disable default fonts will turn off font-face loading of Coral's default fonts.</p>
299+
<?php
300+
}
301+
302+
/**
303+
* Prints input field for disable default fonts setting.
304+
*
305+
* @since 1.0.0
306+
*/
307+
public function render_enable_canonical_story_urls_field() {
308+
$default_fonts = esc_attr( get_option( 'coral_enable_canonical_story_urls' ) )
309+
?>
310+
<select
311+
style="width: 600px; height: 40px;"
312+
name="coral_enable_canonical_story_urls"
313+
placeholder=""
314+
id="coral_enable_canonical_story_urls"
315+
type="select"
316+
>
272317
<option value="true"
273318
<?php
274319
if ($default_fonts === "true")
@@ -286,7 +331,7 @@ public function render_disable_default_fonts_field() {
286331
false
287332
</option>
288333
</select>
289-
<p class="description">Disable default fonts will turn off font-face loading of Coral's default fonts.</p>
334+
<p class="description">When enabled, the canonical story URL will be passed through to the Coral stream embed.</p>
290335
<?php
291336
}
292337

inc/comments-template.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
$coral_container_class_name = get_option( 'coral_container_class_name', null);
2020
$coral_disable_default_fonts = get_option( 'coral_disable_default_fonts' );
2121
$coral_custom_scroll_container = get_option( 'coral_custom_scroll_container', null );
22+
$enable_canonical_url = get_option( 'coral_enable_canonical_story_urls' );
2223
$canonical_url = wp_get_canonical_url();
2324
$storyMode = $post->coralStoryMode;
2425

@@ -34,6 +35,7 @@
3435
(function() {
3536
var d = document, s = d.createElement('script');
3637
const disableDefaultFonts = "<?php echo esc_attr( $coral_disable_default_fonts ); ?>" === "true";
38+
const storyURL = "<?php echo esc_attr( $enable_canonical_url ); ?>" === "true" ? "<?php echo esc_url( $canonical_url ); ?>" : undefined;
3739
s.src = "<?php echo esc_url( $talk_url . '/assets/js/embed.js' ); ?>"
3840
s.onload = function() {
3941
const customScrollContainer = document.getElementById("<?php echo esc_attr( $coral_custom_scroll_container ); ?>") || undefined;
@@ -46,7 +48,7 @@
4648
customFontsCSSURL: "<?php echo esc_url( $coral_custom_fonts_css_url ); ?>",
4749
disableDefaultFonts: disableDefaultFonts,
4850
customScrollContainer: customScrollContainer,
49-
storyURL: "<?php echo esc_url( $canonical_url ); ?>",
51+
storyURL: storyURL,
5052
storyMode: "<?php echo esc_attr( $storyMode ); ?>",
5153
});
5254
};

0 commit comments

Comments
 (0)