Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Plugin Name: YOUR PLUGIN NAME
*/
include( dirname( __FILE__ ) . '/lib/requirements-check.php' );
$your_plugin_requirements_check = new YOUR_PREFIX_Requirements_Check( array(
'title' => 'YOUR PLUGIN NAME',
'php' => '5.4',
@rachelmccollin
rachelmccollin / dashboard_widget_function.php
Last active March 16, 2018 01:03
WPMU DEV Admin Messages
function rmcc_add_dashboard_widget() {
wp_add_dashboard_widget( 'rmcc_dashboard_welcome', 'Welcome', 'rmcc_welcome_widget_callback' );
}
add_action( 'wp_dashboard_setup', 'rmcc_add_dashboard_widget' );
@luisabarca
luisabarca / get-vimeo-private-video-thumb.php
Last active April 20, 2020 02:15
Get a thumbnail from Vimeo private videos
<?php
// You need Vimeo API https://github.com/vimeo/vimeo.php
require 'path-to-your-lib/vimeo/vimeo.php';
// Get this from your account
$vimeo_client_id = 'xxxxx';
$vimeo_client_secret = 'xxxxxxxxxxx';
// This has to be generated on your site, plugin or theme
$vimeo_token = 'xxxxxx';
@MikeNGarrett
MikeNGarrett / wp-cli-install-rec-plugins
Last active July 12, 2021 07:18
Chained WordPress CLI commands to install and activate recommended plugins.
# wordpress-seo provides ability to edit meta information and provides sitemap.
# w3-total-cache provides advanced caching no matter the server technology available.
# better-wp-security provides brute force protection and a number of WordPress enhancements.
# google-analytics-for-wordpress provides robust Google Analytics integration through the Google API.
# redirection detects 404s and 301s and allows admins to set up redirects in the WP admin.
# ewww-image-optimizer provides automatic optimization of uploaded images with local libraries instead of cloud-based services.
# backupwordpress simple backup solution that can store backups above web root.
# relevanssi provides better site search using a local index.
# cloudflare is the best. Free automatic CDN and security solution.
# jarvis is a quick search for the WordPress admin. Indespensible.
<?php
/*
* Plugin Name: Remove crazy counts slowing down my dashboard
* Plugin URI: https://pmgarman.me
* Description: Those comment counts are such a pain when you have a lot of comments
* Author: Patrick Garman
* Author URI: https://pmgarman.me
* Version: 1.0.0
* License: GPLv2
*/
@nickcernis
nickcernis / mailchimp-popup-for-wordpress.md
Last active July 28, 2022 14:49
MailChimp Popup Script that works with WordPress sites

MailChimp's default popup scripts can break on WordPress sites that use jQuery/jQuery UI unless you include their embed code as the final elements before the closing body tag.

Including them in this way isn't always possible or easy with WordPress.

The code below is an alternative implementation of the loader that forces MailChimp's popup scripts to appear below all other scripts upon page load.

To use it, modify the baseUrl, uuid, and lid attributes with the ones from the original popup script that MailChimp supplies.

@bekarice
bekarice / wc-disable-any-repeat-purchase.php
Last active July 26, 2023 12:19
Disables Repeat Purchase for any WooCommerce product
<?php
/**
* Disables repeat purchase for products / variations
*
* @param bool $purchasable true if product can be purchased
* @param \WC_Product $product the WooCommerce product
* @return bool $purchasable the updated is_purchasable check
*/
function sv_disable_repeat_purchase( $purchasable, $product ) {
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@tamarazuk
tamarazuk / wc-order-status-manager-order-is-editable.php
Last active February 15, 2016 01:03
WooCommerce Order Status Manager: Allow orders with custom statuses to be edited
function sv_wc_order_status_manager_order_is_editable( $editable, $order ) {
// list the slugs of all order statuses that should be editable.
// Note 'pending', 'on-hold', 'auto-draft' are editable by default
$editable_custom_statuses = array( 'packaging', 'awaiting-shipment' );
if ( in_array( $order->get_status(), $editable_custom_statuses ) ) {
$editable = true;
}
@chriscoyier
chriscoyier / frontendplugins.md
Last active March 3, 2021 17:31
How WordPress Plugins Should Handle Front End Resources

How WordPress Plugins Should Handle Front End Resources

This is a WORK IN PROGRESS intended for fleshing out and feedback

It's very common for people to be unhappy with how a WordPress plugin adds front end resources to their site. If a plugin needs CSS, the plugin will add a <link> element to that CSS. If the plugin needs JavaScript, it will add a <script> to that JavaScript.

Plugins do this because it works. It's damn important for a WordPress plugin to work, even in adverse conditions. They rightfully want good ratings and little customer support.

But this comes at the cost of additional HTTP requests. In optimizing front end performance of a site, reducing the number of HTTP requests is a huge thing. Front end developers want to decide and control how front end resources are being handled, and WordPress plugins don't typically make this easy on them.