Skip to content

Instantly share code, notes, and snippets.

@kevinwhoffman
kevinwhoffman / add-styles-to-visual-editor.php
Last active January 30, 2022 14:15
Add customizer styles to visual editor
<?php
/**
* Adds styles from customizer to head of TinyMCE iframe.
* These styles are added before all other TinyMCE stylesheets.
* h/t Otto.
*/
function kwh_add_editor_style( $mceInit ) {
// This example works with Twenty Sixteen.
$background_color = get_theme_mod( 'background_color' );
$styles = '.mce-content-body { background-color: #' . $background_color . '; }';
@devudit
devudit / attachment.php
Last active April 2, 2017 09:36
Add custom field to attachments in wordpress
<?php
/**
*
* @wordpress-plugin
* Plugin Name: Attachment custom fields
* Plugin URI: http://uditrawat.com
* Description: Custom fields for Attachments
* Version: 10.3
* Author: Udit Rawat
* Author URI: http://uditrawat.com
@tristen
tristen / index.html
Created April 28, 2016 18:48
Full height sidebar with scrollable content
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<link href='site.css' rel='stylesheet' />
</head>
<body>
@dpalomar
dpalomar / .gitattributes
Created April 8, 2016 12:43
Fixing CRLF with gitattributes
From this [issue](https://github.com/puphpet/puphpet/issues/1025#issuecomment-157059174):
I know that this issue is closed, but as I spent a lot of time to understand what was going on, I made some researches and I can explain why this happen, and you can fix it.
Using git config core.autocrlf true can help, but not on a multi-developpers project.
This command has to be the same on each developper machine, and that's not always the case.
You have to use the .gitattributes provided in the puphpet archive and edit it as follow (carefull, this file need to be in your project root)
You also need to use an IDE that allow you to save/edit files as LF (like phpstorm). You can check the type of the file in the bottom right corner, in the status bar (you'll see LF or CRLF while a file is opened)
@danielwrobert
danielwrobert / webpack.config.js
Last active February 1, 2022 10:18
Example Webpack Config File
const path = require( 'path' );
const webpack = require( 'webpack' );
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = ( env, options ) => {
return {
entry: './src/block.js',
output: {
path: path.resolve( __dirname, 'build' ),
@hvgeertruy
hvgeertruy / scroll.js
Last active March 28, 2024 21:41
Vanilla Javascript scroller. Done the easy way.
//Custom scroll animator w/ easing support & requestAnimationFrame, who needs jQuery ^ ^
//Supports window (use 'window') and element (use document.querySelector(...)[0]) scrolling
//Want features? Use jQuery.
//properties:
// - Element: [required] The element you want the scroll to apply to. Use 'window' for window
// - To: [required] the offset (in px) to scroll to. Note that it will add this to the current position
// - Duration: [required] the duration (in ms) for the scrolling animation
// - Direction: [optional] (default: 'horizontal') The direction for the scrolling animation (horizontal | vertical)
@primozcigler
primozcigler / class-pt-customize-control-range.php
Created March 17, 2015 10:07
Footer widgets layout customizer control.
<?php
/**
* Range Control Class
*/
class WP_Customize_Range_Control extends WP_Customize_Control {
/**
* @access public
* @var string
@oscb
oscb / WC_Widget_Layered_Nav_Categories.php
Last active May 20, 2024 21:37
Add Category Filters to Woocommerce Layered Nav
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Layered Navigation Widget extended to include Categories
*
* @author Oscar Bazaldua
* @category Widgets
@mrgarymartin
mrgarymartin / gist:9fc8a3272a00e88cc16b
Last active April 13, 2017 09:00
Wordpress File Uploader for images in custom post types
<?php
/*******************************************************Podcast Meta-boxes *******************/
//Add Metabox
//Source: http://wordpress.stackexchange.com/questions/139841/add-metabox-with-media-uploader-in-a-custom-post-type
add_action( 'add_meta_boxes', 'add_upload_file_metaboxes' );
function add_upload_file_metaboxes() {
add_meta_box( 'swp_file_upload', 'File Upload', 'swp_file_upload', 'videos', 'normal', 'default' );
}
@SgtPooki
SgtPooki / scroll.easing.js
Last active April 6, 2023 06:05 — forked from dezinezync/scroll.easing.js
ScrollTo easing
function scrollTo(Y, duration, easingFunction, callback) {
var start = Date.now(),
elem = document.documentElement.scrollTop?document.documentElement:document.body,
from = elem.scrollTop;
if(from === Y) {
callback();
return; /* Prevent scrolling to the Y point if already there */
}