Skip to content

Instantly share code, notes, and snippets.

View private-template.php
<?php
/*
Template Name: Private Page
*/
get_header(); ?>
<?php if(post_password_required()): ?>
<div id="primary" class="content-area">
@Fab1en
Fab1en / BotUi.vue
Last active Apr 9, 2020
BotUI integration into VueJS
View BotUi.vue
<template>
<div class="botui botui-container" v-botui-container>
<div class="botui-messages-container">
<div v-for="msg in messages" class="botui-message" :class="[{human: msg.human, bot: !msg.human}, msg.cssClass]" v-botui-scroll>
<transition name="slide-fade">
<div v-if="msg.visible" :class="[{human: msg.human, 'botui-message-content': true}, msg.type]">
<span v-if="msg.type == 'text'" v-text="msg.content" v-botui-markdown></span>
<iframe v-if="msg.type == 'embed'" :src="msg.content" frameborder="0" allowfullscreen scrolling="no"></iframe>
</div>
</transition>
@Fab1en
Fab1en / 0_reuse_code.js
Created Sep 28, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Fab1en
Fab1en / gist:d9366450c18f90f8ffe8
Created Oct 27, 2014
WP Customizer : click to edit posts
View gist:d9366450c18f90f8ffe8
// 1) Bind click events in the preview iframe.
(function( exports, $ ){
var api = wp.customize;
api.controlConstructor.myCustomControl = api.Control.extend({
ready: function() {
var control = this;
// wait for the preview iframe to be ready
var timer = setInterval(function(){
@Fab1en
Fab1en / fiddle.css
Last active Dec 15, 2015
Three means to display help content.
View fiddle.css
.hidden{ display: none; }
@Fab1en
Fab1en / main.js
Last active Dec 13, 2015
How to vertically and horizontally align any block element on the screen with Javascript
View main.js
// vertically and horizontally center a block on the browser screen
function centerBlock ($block){
var top = Math.floor(($(window).height() - $block.height())/2);
var left = Math.floor(($(window).width() - $block.width())/2);
$block.css('margin', top+'px '+left+'px');
}
// use it
centerBlock($('.myblock'));
$(window).resize(function(){
@Fab1en
Fab1en / custom_media_menu.js
Created Jan 21, 2013
Draft plugin example to add a javascript menu into the WP3.5 Media Library popup. Answer to this Wordpress stackexchange question : http://wordpress.stackexchange.com/questions/76980/add-a-menu-item-to-wordpress-3-5-media-manager/
View custom_media_menu.js
// for debug : trace every event
/*var originalTrigger = wp.media.view.MediaFrame.Post.prototype.trigger;
wp.media.view.MediaFrame.Post.prototype.trigger = function(){
console.log('Event Triggered:', arguments);
originalTrigger.apply(this, Array.prototype.slice.call(arguments));
}*/
// custom state : this controller contains your application logic
wp.media.controller.Custom = wp.media.controller.State.extend({