Wordpress Plugin
MFN has a Wordpress plugin that is available for integration with company websites for showing their company feed.
Description
The MFN Wordpress Plugin is a plugin which lets the user sync news items for a particular company from mfn.se into their Wordpress site. It also adds a WebSub compliant posthook that is used to automatically receive new news being published by mfn.se.
The plugin does not however provide any public views of the news items. This has to be implemented by the user of the plugin them self.
What it does
Once installed the plugin creates a few new things are added to your Wordpress site
A new post type
mfn_news
A new taxonomy
mfn-news-tag
New terms in the new taxonomy that describes news items
Adds Widgets: MFN News Feed Widget, MFN Archive Widget and the MFN Subscription Widget
Links
Releases zip of the plugin can be found at https://github.com/modfin/mfn-wp-plugin/releases
Composer https://packagist.org/packages/modfin/mfn-wp-plugin
Code at https://github.com/modfin/mfn-wp-plugin
The plugin should be compliant with both a standard WP installation and Bedrock version (https://roots.io/bedrock/)
Installation / Getting started
Start off by downloading the WP plugin, from the links above.
There are three ways to install the the plugin
Download and extract the zip package it into your
wp-content/plugins
directoryUpload the zip package through the built in installer of Wordpress at
http://your-site.com/wp-admin/plugin-install.php
(click the upload plugin button)Use composer (a tool for php dependency management), simply run:
$ composer require modfin/mfn-wp-plugin
Once installed, activate the plugin by pressing Activate. This will create the post type, the taxonomy and all the corresponding terms.
A new menu item, MFN News Items, should now have been added in the Admin menu.
Go to Settings - MFN Feed to locate the plugin settings
Fill in the information in the left column fields (Sync URL, Hub URL, Plugin URL and Entity Id, these fields are required to get things to work)
Click "Save".
Finally click "Sync all" in the right column
Now, if you go to MFN News Items in the Admin menu you should be able to view the feed and manage the news items individually, as well as the corresponding tags.
Constraints
The plugin has a WebSub posthook that enables MFN to inject news items when they are published. This means that the WP application must be initiated from within the plugin.
This puts some constraints on the folder structure of the Wordpress instance. In short, the plugin must be able to find wp-config.php to bootstrap the necessary parts. The plugin does this by traversing parent directories of the plugin, at a maximum height of 3. This should work for both Bedrock and a standard installation of Wordpress.
Configuration and management
Settings
Sync URL which is the URL to mfn.se and should, in most cases, be https://mfn.se
This url is used by the plugin to retrieve historical news that has been published on MFN or other news weirs. It a used when an admin click on Sync Latest or Sync All.
Hub URL which is the URL to MFNs WebSub Hub and should, in most cases, https://hub.mfn.se
This URL is used by the plugin to talk to the WebSub Hub in order to setup a HTTP Posthook subscription for the Plugin. This in order to let MFN push news when published into the Wordpress application.
Plugin URL which is the globally accessible url to the plugin. It is important that /wp-content/plugins/mfn-wp-plugin/posthook.php
is accessible from the internet, since this php file accepts and store news being pushed from MFN in the wordpress database. The Plugin url should however point to the base path of the plugin, eg. http://your-site.com/wp-content/plugins/mfn-wp-plugin
Entity Id which is a UUID that refers to a specific companies news feed in MFN. This id will be given to you by your contact at Modular Finance on request.
Custom Query experimental field used in certain cases, but should not normally be used.
Rewrite settings makes it possible to change the name of the custom post type mfn_news
as well as the archive name and singular name. When saving the changes it will apply directly to the URL.
Disable archive if checked, the news archive will no longer be reachable. (Can be useful if you want to prevent users from reaching the archive URL but access the press releases on the site).
Verify Signature is an option that is up to the user. Each press release sent from MFN is cryptographically signed in order for the receiver to be able to verify that it was indeed the sent from MFN. If this is turned on, a news item with a bad signatures will be dropped.
Use WPML will make the plugin compliant with https://wpml.org locale management.
Use Polylang will make the plugin compliant with https://polylang.pro locale management.
Reset Cache (On every new item insert, if checked, this will reset the db cache).
Status
In the status section we find five different parameters which is a result of
Subscription Id appears once the plugin has successfully subscribed via hub.mfn.se through a posthook. It should appear once you click the subscribe button below. The Subscription Id is a sensitive credential, and should not be shared. With this id, you can alter or end your subscription at MFN
Posthook Secret is generated when you click subscribe. It is random string which is used to verify messages from MFN, as described in the Verify Signature section above. It is used as a HMAC key in accordance to the specification w3 WebSub specification https://www.w3.org/TR/websub/. The Posthook Secret is a sensitive credential which give you rights to post content to the posthook. It should not be shared. Malicious actors could masquerade as MFN and sign any data with valid signatures before sending it to the WP plugin.
Posthook Name is generated when you click subscribe. It's a random string which is used as a token for posting messages to the plugin. Any call to the posthook must have this token included. Otherwise the call will be discarded.
Plugin URL is information about the plugin url added in the setting section. It should say Valid
Hub URL is information about the hub url added in the settings section. It should say Valid
Actions
There are two Sync actions
Sync Latest will sync the 10 most recently published items from MFN to the Wordpress site. This syncing function disregards what newswire who sent the item.
Sync All will sync all the news items from MFN for the entity ID. This syncing function disregards what newswire who sent the item.
You can use this functionality multiple times. The WP posts that are added to the database will not be overwritten, but terms associated with the item will.
The Subscribe function will register the WP plugins posthook with the WebSub hub, hub.mfn.se. If this is successful the Subscription Id in the status section will become visible. It is important here that your Plugin URL is valid and that posthook.php
is accessible from the Internet in order for it to work.
Attachments
In all press releases sent by MFN, there is an attachment section in the text body. However this is not always the case for stories sent from other newswires such as Cision or Globe.
The attachments does exist in the wp_postmeta
table and can be added through the theme.
The information is stored in these keys:
mfn_attachment_link
(Contains the a href link to the attachment)
mfn_attachment_data
(Contains further information about the attachment such as the content-type)