ACF/WordPress plugin to support publication retrieval from social networks.
I’m publishing this here because it might be useful to others, but USE OF THIS SCRIPT IS ENTIRELY AT YOUR OWN RISK. I accept no liability from its use.
This WordPress mu-plugin adds an ACF field type which asks for connection parameters for chosen network, connect, authenticate, and retrieve last publications.
This plugin is aimed at website developers and doesn’t provide any front-end rendering.
As I’m using this on lots of my clients websites, I’m really willing to improve its security, reliability and its features. Contact me if you need support, I’d be pleased to help and get feedback.
Supported networks :
- Youtube
Each field asks for connection information needed to retrieve the posts, for example the Facebook field asks for:
- API version
- App ID
- App Secret
- Target
A call to get_field returns an associative array of the retrieved last posts,
with each item containing following keys:
network: Network name, facebook, twitter, etc.url: URL of the post on the social networkdate: Publication date of the post (DateTimeobject)thumb: Array with following keys:src: Thumbnail URLwidth: Width of the thumbnailheight: Height of the thumbnailsrcset: Alternative URLs when available
caption: Associated text of the post
Example of displayed fields:
In your composer.json, add the repository:
{
"repositories": [
{ "type": "vcs", "url": "https://github.com/jerome-rdlv/social-network" }
]
}then:
composer require social-network:dev-master
Drop the plugin folder in your wp-content/mu-plugins/ directory, and
require it from another mu-plugin like wp-content/mu-plugins/index.php:
require_once __DIR__ .'/social-network/social-network.php`;This plugin has dependencies so if you chose manual installation you must
run composer install in plugin folder.
Configuration needed for each social network.
- Create an App on developer.facebook.com, the account you use doesn’t matter BUT the owner account of the target page must appear in App Roles / Roles screen as Administrators, Developers or Testers (I recommand this last one if the App account is not the owner account of the target page).
- Set website domain in App Settings (App Domains field)
- Click + Add Platform / Website and set Site URL
- Click + App Product / Facebook Login
- In Facebook Login Settings set Valid OAuth redirect URIs
(
https://xxxxx.xxx/wp-admin/URL of the website) - On App Dashboard, get App ID and App Secret and fill the corresponding inputs of your Social Network field
Authentication step (when using the connect button) must be done with the owner account of the target page, otherwise it wont work.
Facebook App should stay in development status.
Only target is needed, it is the identifier that appears at the end of the Instagram URL:
https://www.instagram.com/xxxxxxx
Target is the complete URL of the target page.
- Create an App on apps.twitter.com, the account you use doesn’t matter
- Set Callback URL (
/wp-admin/URL of the website) - In Keys and Access Tokens tab, get API Key and API Secret and fill the corresponding inputs of your Social Network field
- Improve this doc with installation and configuration information
- Internationalization
- Add support for Google+
This ACF field type is compatible with ACF 5 only.
