SharePoint Document Fetcher
A plugin that fetches content from a Sharepoint site, a workaround for displaying Word Documents as HTML within WordPress pages
by Darren Kandekore · github.com/kandekore/wordpresssharepointfetch
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/kandekore/wordpresssharepointfetch/archive/refs/heads/main.zipWordPress SharePoint Document Fetcher
Table of Contents
Description
A user may want to display the content of a Word Document on a webpage, conversion of .docx files to HTML is a complex task and may drain server resources if performed on demand.
This plugin is a workaround that fetches plain text or html content from a Sharepoint site and enables the user to add it to a WordPress using a shortcode. The user downloads and saves the word document as html and uploads to a SharePoint Site shared document folder allowing the user to continue to construct and edit the content in Word.
- The Motivation for building this application was I needed a method to display content from complex word documents on a WordPress page, keeping index links, tables and images intact.
- The application was built to provide a method of importing content to WordPress sites from SharePoint
- It solves the problem of having to rebuild documents to display on a website, it also presents an opportunity for end users to use SharePoint as a content managment system.
- The plugin presents future development opportunities of other ways to handle, display or distribute SharePoint documents
- Through the process of building this application I learned how to query the Microsoft Graph API to get drive and file ID's
Installation
Download a copy of the plugin using this link.
Upload and install the plugin to WordPress
Register an App in Azure AD
Create a Client Secret in Azure AD
Set API Permissions Sites.Read.All & Files.Read.All in Azure AD Microsoft Graph API. These permissions need to be consented to by an administrator during the Azure App Registration process.
Add credentials to plugin settings page

Usage
You create the document in Word either locally or on SharePoint
If the Word file is created on Sharepoint Download the .docx file. Save as a .html document in your desktop version of Word.
Upload the the .html to your SharePoint site
Zip and upload the images folder to the plugin
Add a shortcode on the page of where you want to display the doc

Testing
There is a "Test connection" button on the settings page
License
This application is covered under the GNU GPL licence
Contributors
Questions
Please contact me if you have any questions