Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin maintenance #19

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
vendor
composer.lock
14 changes: 14 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "ayesh/oembed-plus",
"keywords": ["wordpress", "plugin"],
"type": "wordpress-plugin",
"authors": [
{
"name": "Ayesh",
"email": "ayesh@aye.sh"
}
],
"require": {
"php": "^7.1|^8.0"
}
}
4 changes: 2 additions & 2 deletions oembed-plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: oEmbed Plus
* Plugin URI: https://php.watch/articles/wordpress-facebook-instagram-oembed
* Version: 1.6
* Version: 1.7
* Description: Adds support for embedding Facebook and Instagram posts in Block Editor and Classic Editor.
* Licence: GPLv2 or later
* Author: Ayesh Karunaratne
Expand All @@ -19,7 +19,7 @@
});

add_filter('oembed_fetch_url', static function ($provider_url): string {
if (strpos($provider_url, 'https://graph.facebook.com/v8.0/') !== 0) {
if (strpos($provider_url, 'https://graph.facebook.com/v14.0/') !== 0) {
return $provider_url;
}

Expand Down
12 changes: 9 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: ayeshrajans
Tags: embed, facebook, instagram, oembed
Requires at least: 4.9
Tested up to: 5.6
Stable tag: 1.6
Tested up to: 6.1
Stable tag: 1.7
Requires PHP: 7.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -88,7 +88,13 @@ define('OEMBED_PLUS_HIDE_ADMIN_UI', true);
**1.5**

- Updates to the readme file to make it more clear that this plugin supports both Classic Editor and Block Editor.

**1.6**

- Updated the plugin minimum WordPress core requirement to 4.9, along with relevant compatibility changes. The plugin works on all WordPress versions from 4.9 through 5.6 and up.

**1.7**
- Test with WordPress 6.1.
- Use a newer version of the Graph API.
- Added Instagram Reels support.
- Added fb.watch support.
29 changes: 15 additions & 14 deletions src/Embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@

class Embed {
private static $providerPatterns = [
'#https?://www\.facebook\.com/.*/posts/.*#i' => ['https://graph.facebook.com/v8.0/oembed_post', true],
'#https?://www\.facebook\.com/.*/activity/.*#i' => ['https://graph.facebook.com/v8.0/oembed_post', true],
'#https?://www\.facebook\.com/.*/photos/.*#i' => ['https://graph.facebook.com/v8.0/oembed_post', true],
'#https?://www\.facebook\.com/photo(s/|\.php).*#i' => ['https://graph.facebook.com/v8.0/oembed_post', true],
'#https?://www\.facebook\.com/permalink\.php.*#i' => ['https://graph.facebook.com/v8.0/oembed_post', true],
'#https?://www\.facebook\.com/media/.*#i' => ['https://graph.facebook.com/v8.0/oembed_post', true],
'#https?://www\.facebook\.com/questions/.*#i' => ['https://graph.facebook.com/v8.0/oembed_post', true],
'#https?://www\.facebook\.com/notes/.*#i' => ['https://graph.facebook.com/v8.0/oembed_post', true],
'#https?://www\.facebook\.com/.*/videos/.*#i' => ['https://graph.facebook.com/v8.0/oembed_video', true],
'#https?://www\.facebook\.com/video\.php.*#i' => ['https://graph.facebook.com/v8.0/oembed_video', true],
'#https?://www\.facebook\.com/watch/?\?v=\d+#i' => ['https://graph.facebook.com/v8.0/oembed_video', true],

'#https?://(www\.)?instagr(\.am|am\.com)/(p|tv)/.*#i' => ['https://graph.facebook.com/v8.0/instagram_oembed', true],
'#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' => ['https://graph.facebook.com/v8.0/instagram_oembed', true],
'#https?://www\.facebook\.com/.*/posts/.*#i' => ['https://graph.facebook.com/v14.0/oembed_post', true],
'#https?://www\.facebook\.com/.*/activity/.*#i' => ['https://graph.facebook.com/v14.0/oembed_post', true],
'#https?://www\.facebook\.com/.*/photos/.*#i' => ['https://graph.facebook.com/v14.0/oembed_post', true],
'#https?://www\.facebook\.com/photo(s/|\.php).*#i' => ['https://graph.facebook.com/v14.0/oembed_post', true],
'#https?://www\.facebook\.com/permalink\.php.*#i' => ['https://graph.facebook.com/v14.0/oembed_post', true],
'#https?://www\.facebook\.com/media/.*#i' => ['https://graph.facebook.com/v14.0/oembed_post', true],
'#https?://www\.facebook\.com/questions/.*#i' => ['https://graph.facebook.com/v14.0/oembed_post', true],
'#https?://www\.facebook\.com/notes/.*#i' => ['https://graph.facebook.com/v14.0/oembed_post', true],
'#https?://www\.facebook\.com/.*/videos/.*#i' => ['https://graph.facebook.com/v14.0/oembed_video', true],
'#https?://www\.facebook\.com/video\.php.*#i' => ['https://graph.facebook.com/v14.0/oembed_video', true],
'#https?://www\.facebook\.com/watch/?\?v=\d+#i' => ['https://graph.facebook.com/v14.0/oembed_video', true],
'#https?://(www\.)?fb\.watch/*#i'=> ['https://graph.facebook.com/v14.0/oembed_video', true],

'#https?://(www\.)?instagr(\.am|am\.com)/(p|tv|reel)/.*#i' => ['https://graph.facebook.com/v14.0/instagram_oembed', true],
'#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' => ['https://graph.facebook.com/v14.0/instagram_oembed', true],
];

private $app_id;
Expand Down