Skip to content

Instantly share code, notes, and snippets.

@jan-koch
jan-koch / remove-woo-scripts.php
Created February 28, 2020 09:14
Remove WooCommerce related resources except on WooCommerce-based pages (products, cart, checkout, etc). Use on a testing environment before pasting this into your live website!
/**
* This code snippet removes JavaScript and CSS files loaded from WooCommerce if they are not necessary.
*
* Please test this on a staging copy of your website before putting this into the functions.php of your live website.
*/
add_action( 'wp_enqueue_scripts', 'my_remove_woo_assets', 99 );
function my_remove_woo_assets() {
if ( function_exists( 'is_woocommerce' ) ) { // Check if Woo is installed.
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { // Only run on non-Woo pages.
// Remove unnecessary stylesheets.
@brycejacobson
brycejacobson / single.php
Last active February 27, 2020 15:11
WordPress Post Navigation for Private Posts
<nav class="navigation post-navigation" role="navigation" aria-label="Posts">
<h2 class="screen-reader-text">Post Navigation</h2>
<div class="nav-links">
<?php
global $wpdb;
$results = $wpdb->get_results(
$wpdb->prepare(
"
SELECT *
FROM $wpdb->posts
@duongthanhthai
duongthanhthai / functions.php
Created October 25, 2019 09:18
Remove default admin dashboard widgets (Activity, WordPress News, Quick Draft and At a Glance) from the WordPress admin dashboard for all users.
function remove_dashboard_meta() {
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' ); // Activity
remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' ); // WordPress News
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); // Quick Draft
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); // At a Glance
}
add_action( 'admin_init', 'remove_dashboard_meta' );
@erikyo
erikyo / fancy-gallery.js
Last active January 24, 2022 03:34
fancybox 3 integration into wordpress Gutenberg gallery block
@chrisjreber
chrisjreber / side-by-side-images.jsx
Last active February 1, 2019 22:04
Photoshop Script - create merged before and after image
// Created by Chris Reber - [email protected]
// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop
// Settings
var maxHeight = 600;
@jan-koch
jan-koch / woo-add-custom-sku.php
Last active July 16, 2021 10:39
Add a custom SKU field to WooCommerce products.
<?php
function jk_add_custom_sku() {
$args = array(
'label' => __( 'Custom SKU', 'woocommerce' ),
'placeholder' => __( 'Enter custom SKU here', 'woocommerce' ),
'id' => 'jk_sku',
'desc_tip' => true,
'description' => __( 'This SKU is for internal use only.', 'woocommerce' ),
);
@gaearon
gaearon / modern_js.md
Last active October 25, 2024 06:12
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@microneer
microneer / gist:abe764ae031e88c5b0919b661a0c8ff9
Last active November 16, 2017 14:52 — forked from swalkinshaw/gist:2695510
WordPress: Mandatory Excerpt
// put this in functions.php or in your custom plugin or theme code.
$m = new Mandatory_Excerpt()
$m->add('post', 20 ); // will require all 'post' post types to have an excerpt at least 20 characters long
/**
* Helper class which removes specified metaboxes from specified pages. It manages setting up the hooks
* and calling them.
*
* @author: Michael Fielding
*
@amboutwe
amboutwe / yoast_seo_admin_user_remove_social.php
Last active November 1, 2023 22:59
Remove Yoast SEO Social Profiles From All Users
/* Remove Yoast SEO Social Profiles From All Users
* Credit: Yoast Developers
* Last Tested: Nov 01 2023 using Yoast SEO 21.5 on WordPress 6.3.2
*********
* Use this code to hide the fields shown under Admin > Users > Edit user
* Previously entered profiles will be included in schema
* To limit or remove user schema, use 'wpseo_schema_person_social_profiles' filter
* Link: https://developer.yoast.com/features/schema/pieces/person/#social-profiles
*/
<?php
$args = array(
'label' => '', // Text in Label
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post meta where id is the meta_key
'id' => '', // required
'name' => '', //name will set from id if empty