Skip to content

Instantly share code, notes, and snippets.

@Fab1en
Fab1en / custom_media_menu.js
Created January 21, 2013 15:32
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/
// 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({
@Fab1en
Fab1en / main.js
Last active December 13, 2015 18:08
How to vertically and horizontally align any block element on the screen with Javascript
// 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 / fiddle.css
Last active December 15, 2015 12:09
Three means to display help content.
.hidden{ display: none; }
@Fab1en
Fab1en / gist:d9366450c18f90f8ffe8
Created October 27, 2014 09:14
WP Customizer : click to edit posts
// 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 / 0_reuse_code.js
Created September 28, 2016 12:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Fab1en
Fab1en / BotUi.vue
Last active April 9, 2020 13:01
BotUI integration into VueJS
<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 / private-template.php
Last active June 25, 2019 21:34 — forked from Chris-leg/private-template.php
Page Privée
<?php
/*
Template Name: Private Page
*/
get_header(); ?>
<?php if(post_password_required()): ?>
<div id="primary" class="content-area">