Skip to content

Instantly share code, notes, and snippets.

View wpo365's full-sized avatar

WPO365 wpo365

View GitHub Profile
@wpo365
wpo365 / wordpress.signinwithmicrosoft.shortcode
Last active April 27, 2020 19:36
WordPress + Office 365 "Sign in with Microsoft" shortcode for WordPress
[wpo365-sign-in-with-microsoft-v2-sc]
<!-- For details visit https://www.wpo365.com/authentication-shortcode/ -->
<div>
<style>
.wpo365-mssignin-wrapper {
box-sizing: border-box;
display: block;
width: 100%;
padding: 12px 12px 24px 12px;
text-align: center;
@wpo365
wpo365 / handlebarsjs.index.html
Last active October 14, 2019 11:35
Simple handlebars.js template that covers most of the basics from https://handlebarsjs.com/
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.4.2/handlebars.js"></script>
</head>
<body>
<script id="entry-template" type="text/x-handlebars-template">
<div class="entry-main">
{{! #gallery is a so-called block expression for which a custom helper has been registered }}
{{#gallery posts}}
@wpo365
wpo365 / .htaccess
Last active October 21, 2019 06:08
Requires a user to be signed into WordPress when accessing files e.g. in the wp-content directory. To configure authentication for designates directories, you must additionally configure .htaccess to create the proxy in the first place. See the 2nd file in this gist for an example. In this example, WordPress is installed in a subdirectory called…
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
# BEGIN THIS DL-FILE.PHP ADDITION
RewriteCond %{REQUEST_URI} ^.*wp-content/.*
RewriteRule ^wp-content/uploads/(.*)$ dl-file.php?file=$1 [QSA,L]
# END THIS DL-FILE.PHP ADDITION
@wpo365
wpo365 / cbs.intranet.list.template.html
Last active November 22, 2019 06:44
Default Handlebars template that can be used (and customized) when surfacing SharePoint Online search results in WordPress using the WPO365 (WordPress + Office 365) plugin (see https://www.wpo365.com/working-with-handlebars-templates/ for details).
<content>
<script id="jshelpers">
if (!!window.wpo365
&& 'registerHandlebarsHelper' in window.wpo365
&& 'handlebarsSafeString' in window.wpo365
&& 'moment' in window.wpo365) {
window.wpo365.registerHandlebarsHelper('formatSummary',
function (summary) {
return window.wpo365.handlebarsSafeString(
summary
@wpo365
wpo365 / ed.intranet.list.template.html
Created November 22, 2019 06:45
Default Handlebars template that can be used (and customized) when surfacing Microsoft Graph user results in WordPress using the WPO365 (WordPress + Office 365) plugin (see https://www.wpo365.com/working-with-handlebars-templates/ for details).
<content>
<script id="jshelpers">
</script>
<header id="header" type="x-handlebars-template">
<style>
.pintraItemCell {
position: relative;
outline: transparent;
min-height: 54px;
padding: 10px;
@wpo365
wpo365 / wordpress.displayerrormessage.shortcode
Created November 22, 2019 16:06
WordPress + Office 365 "Display error message" shortcode for WordPress (for details see https://www.wpo365.com/error-page/)
[wpo365-display-error-message-sc]
@wpo365
wpo365 / functions.php
Last active April 27, 2020 19:37
Add a Sign in with Microsoft button to your (default or custom) WordPress login form. See https://docs.wpo365.com/article/74-add-sign-in-with-microsoft-button-to-a-wordpress-login-form for details.
add_action( 'login_form', 'sign_in_with_microsoft', 10, 1 );
function sign_in_with_microsoft( $input = '' ) {
?>
<!-- For details visit https://docs.wpo365.com/article/74-add-sign-in-with-microsoft-button-to-a-wordpress-login-form -->
<div>
<style>
.wpo365-mssignin-wrapper {
box-sizing: border-box;
display: block;
@wpo365
wpo365 / cbs.intranet.events.template.html
Last active April 19, 2020 18:19
Example of a Handlebars template that can be used (and customized) when surfacing calendar events as tabular data from a Microsoft SharePoint Online search query result in WordPress using the WPO365 (WordPress + Office 365) plugin (see https://www.wpo365.com/ for details).
<content>
<script id="jshelpers">
if (!!window.wpo365
&& 'registerHandlebarsHelper' in window.wpo365
&& 'handlebarsSafeString' in window.wpo365
&& 'moment' in window.wpo365) {
window.wpo365.registerHandlebarsHelper('formatSummary',
function (summary) {
return window.wpo365.handlebarsSafeString(
summary
@wpo365
wpo365 / wpo365-hooks.php
Last active June 6, 2023 08:15
An example of a plugin that hooks into the various WPO365 login hooks and filters. See https://docs.wpo365.com/article/82-developer-hooks for details.
<?php
/**
* Plugin Name: WPO365 Hooks (samples)
* Plugin URI: https://www.wpo365.com/downloads/wordpress-office-365-hooks/
* Description: An example of a plugin that hooks into the various WPO365 login hooks.
* Version: 0.5
* Author: marco@wpo365.com
* Author URI: https://www.wpo365.com
* License: GPL2+
*/
@wpo365
wpo365 / yammer.feed.template.html
Created May 25, 2020 19:54
Default Handlebars template that can be used (and customized) when embedding a Yammer feed in WordPress page or post using the WPO365 (WordPress + Office 365) plugin (see https://www.wpo365.com/working-with-handlebars-templates/ for details).
<content>
<script id="jshelpers">
if (!!window.wpo365
&& 'registerHandlebarsHelper' in window.wpo365
&& 'handlebarsSafeString' in window.wpo365
&& 'moment' in window.wpo365) {
window.wpo365.registerHandlebarsHelper('formatSummary',
function (summary) {
return window.wpo365.handlebarsSafeString(
summary