Skip to content

Instantly share code, notes, and snippets.

@mbijon
mbijon / wordpress-remove-media_buttons.php
Last active July 10, 2023 23:30
Remove 'Add Media' button from above WP editor, per post-type
function check_post_type_and_remove_media_buttons() {
global $current_screen;
// use 'post', 'page' or 'custom-post-type-name'
if( 'post' == $current_screen->post_type ) add_action( 'media_buttons_context' , create_function('', 'return;') );
}
add_action('admin_head','check_post_type_and_remove_media_buttons');
@grtaylor2
grtaylor2 / woocommerce.css
Created November 29, 2013 19:21
Clean Woo Commerce CSS -- Replace the plugin's woocommerce.css file with a decompressed formatted stylesheet. This is the original CSS with no edits -- the code is just formatted in a way that makes edits much easier.
/*Stylesheet cleaned up and organized by Marketing Press*/
.clear {
clear:both
}
.nobr {
white-space:nowrap;
}
@jameslaws
jameslaws / ninja-forms-field-groups.php
Created December 11, 2013 15:04
Group Fields in Ninja Forms This code allows you to group fields by adding the nf-open-field-group to the first field in a group and nf-close-field-group to the last field in a group. Fields must already be in proper order.
<?php
function nfjal_open_field_group( $field_id, $data ) {
if ( !$class = $data['class'] ) {
$class = '';
}
if ( strstr( $class, 'nf-open-field-group' ) ) {
$class = nfjal_get_group_wrap_class( $class );
echo '<div class="' . $class . '">';
}
@kane-c
kane-c / woocommerce-force-shipping-pickup.php
Created July 23, 2014 05:40
WordPress WooCommerce: Force local pickup as the only shipping option when products in the cart require it.
<?php
// Force pickup as a shipping option if one or more products in the catalog is marked as pickup only.
// To do this, add a shipping class with the slug 'pickup-only' then set products with that class as required.
// Add this script to your theme's functions.php or similar.
function hideShippingWhenPickupRequired($rates, $package)
{
foreach ($package['contents'] as $item) {
$product = $item['data'];
$shippingClass = $product->get_shipping_class();
@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 */
}
@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' );
}
@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
@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
@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)
@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' ),