Skip to content

Commit 8d4470c

Browse files
Mike van den Hoekmvdhoek1
authored andcommitted
(feat): alter youtube embed url
1 parent 843a59c commit 8d4470c

4 files changed

Lines changed: 59 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,75 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [3.0.5] - 2023-03-10
8+
9+
### Added
10+
11+
- Add no-cookie to YouTube URL's.
12+
- Disable oembed.
13+
- Remove no cookie from YouTube channel url.
14+
715
## [3.0.4] - 2022-10-21
16+
817
### Changed
9-
- Replaced Composer plugin dependency check with runtime check.
18+
19+
- Replaced Composer plugin dependency check with runtime check.
1020

1121
## [3.0.3] - 2022-10-07
22+
1223
### Chore
13-
- Update dependencies + reference pdc-base plugin from BitBucket to GitHub
24+
25+
- Update dependencies + reference pdc-base plugin from BitBucket to GitHub.
1426

1527
## [3.0.2] - 2020-08-07
28+
1629
### Added
30+
1731
- Add revisions for FAQ entries (use [MB Revision](https://metabox.io/plugins/mb-revision/))
1832

1933
## [3.0.1] - 2020-08-05
34+
2035
### Fix
36+
2137
- View content of metabox sort clone field after moving it around.
2238

2339
## [3.0.0] - 2020-08-04
40+
2441
### Changed
25-
- Architecture change in the pdc-base plug-in, used as dependency, affects namespaces used
42+
43+
- Architecture change in the pdc-base plug-in, used as dependency, affects namespaces used.
2644

2745
## [2.0.3]
46+
2847
### Fix
29-
- Check if required file for `is_plugin_active` is already loaded, otherwise load it. Props @Jasper Heidebrink
48+
49+
- Check if required file for `is_plugin_active` is already loaded, otherwise load it. Props @Jasper Heidebrink.
50+
3051
### Add
52+
3153
- Remove docs in plugin, in favor of generating docs remote.
3254

3355
## [2.0.2]
56+
3457
### Fix
35-
- Fixed meta as object
58+
59+
- Fixed meta as object.
3660

3761
## [2.0.1]
62+
3863
### Fix
39-
- Fix if no faq is entered, the rest api fails
64+
65+
- Fix if no faq is entered, the rest api fails.
4066

4167
## [2.0.0]
68+
4269
### Features
43-
- Add documentation
44-
- Add tests
70+
71+
- Add documentation.
72+
- Add tests.
4573

4674
## [1.0.0]
75+
4776
### Features
48-
- Initial start
77+
78+
- Initial start.

pdc-faq.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin Name: PDC FAQ
55
* Plugin URI: https://www.openwebconcept.nl/
66
* Description: Plugin to create the frequently asked questions section for a PDC item.
7-
* Version: 3.0.4
7+
* Version: 3.0.5
88
* Author: Yard Digital Agency
99
* Author URI: https://www.yard.nl/
1010
* License: GPL-3.0

src/FAQ/Foundation/Plugin.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*/
1414
class Plugin extends BasePlugin
1515
{
16-
1716
/**
1817
* Name of the plugin.
1918
*
@@ -27,5 +26,5 @@ class Plugin extends BasePlugin
2726
*
2827
* @const string VERSION
2928
*/
30-
const VERSION = '3.0.4';
29+
const VERSION = '3.0.5';
3130
}

src/FAQ/RestAPI/FAQField.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
2-
/**
3-
* Ammends the FAQ field to a PDC item.
4-
*/
2+
53
namespace OWC\PDC\FAQ\RestAPI;
64

75
use OWC\PDC\Base\Support\CreatesFields;
@@ -12,35 +10,40 @@
1210
*/
1311
class FAQField extends CreatesFields
1412
{
15-
1613
/**
1714
* Create an additional field on an array.
18-
*
19-
* @param WP_Post $post
20-
*
21-
* @return array
2215
*/
2316
public function create(WP_Post $post): array
2417
{
2518
return array_map(function ($faq) {
2619
return [
2720
'question' => $faq['pdc_faq_question'] ?: '',
28-
'answer' => isset($faq['pdc_faq_answer']) ? apply_filters('the_content', $faq['pdc_faq_answer']) : ''
21+
'answer' => ! empty($faq['pdc_faq_answer']) ? \apply_filters('the_content', $this->filterContent($faq['pdc_faq_answer'])) : ''
2922
];
3023
}, $this->getFAQ($post));
3124
}
3225

3326
/**
3427
* Get faqs of a post.
35-
*
36-
* @param WP_Post $post
37-
*
38-
* @return array
3928
*/
40-
private function getFAQ(WP_Post $post)
29+
private function getFAQ(WP_Post $post): array
4130
{
42-
return array_filter(get_post_meta($post->ID, '_owc_pdc_faq_group', true) ?: [], function ($faq) {
31+
return array_filter(\get_post_meta($post->ID, '_owc_pdc_faq_group', true) ?: [], function ($faq) {
4332
return ! empty($faq['pdc_faq_question']) && ! empty($faq['pdc_faq_answer']);
4433
});
4534
}
35+
36+
/**
37+
* Add no cookie to YouTube URL.
38+
* Disable YouTube oembed.
39+
* Remove no cookie from YouTube channel url.
40+
*/
41+
protected function filterContent(string $content): string
42+
{
43+
$content = str_replace('youtube.com', 'youtube-nocookie.com', $content);
44+
$content = str_replace('?feature=oembed', '?feature=oembed&disablekb=1', $content);
45+
$content = str_replace('youtube-nocookie.com/channel', 'youtube.com/channel', $content);
46+
47+
return $content;
48+
}
4649
}

0 commit comments

Comments
 (0)