Skip to content

Instantly share code, notes, and snippets.

@wpscholar
wpscholar / replace-wp-dashboard.php
Last active December 3, 2024 23:58
Replace the default WordPress dashboard with a custom one
<?php
/**
* Plugin Name: Replace WordPress Dashboard
* Description: Replaces the default WordPress dashboard with a custom one.
* Author: Micah Wood
* Author URI: http://micahwood.me
* Version: 0.1
* License: GPL3
*/
@kloon
kloon / functions.php
Last active July 5, 2023 10:05
WooCommerce add Delete Account button to My Account page This is very dangerous functionality and can cause your whole WordPress installation to break
<?php
// Delete Account Functionality
add_action( 'woocommerce_after_my_account', 'woo_delete_account_button' );
function woo_delete_account_button() {
?>
<a href="<?php echo add_query_arg( 'wc-api', 'wc-delete-account', home_url( '/' ) ) ?>" class="button">Delete Account</a>
<?php
}
add_action( 'woocommerce_api_' . strtolower( 'wc-delete-account' ), 'woo_handle_account_delete' );
@BFTrick
BFTrick / my-woocommerce-modifications.php
Last active August 7, 2017 09:03
A WordPress plugin that modifies the WooCommerce category page. It remove the title, price, and add to cart button. Reference this WordPress Answers question (http://wordpress.stackexchange.com/questions/61398/hide-price-title-in-store-thumbnail-dispay) to see why I made it.
<?php
/*
Plugin Name: My WooCommerce Modifications
Plugin URI: http://woothemes.com/
Description: Modificatinos to my WooCommerce site
Version: 1.0
Author: Patrick Rauland
Author URI: http://www.patrickrauland.com/
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
@jameskoster
jameskoster / functions.php
Last active July 16, 2017 17:30
WooCommerce - customise a product tab
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {
$tabs['description']['callback'] = 'woo_custom_description_tab_content'; // Custom description callback
return $tabs;
}
function woo_custom_description_tab_content() {
echo '<h2>Custom Description</h2>';
@kloon
kloon / functions.php
Last active March 4, 2024 19:36
WooCommerce total order weight column on orders page
<?php
add_filter( 'manage_edit-shop_order_columns', 'woo_order_weight_column' );
function woo_order_weight_column( $columns ) {
$columns['total_weight'] = __( 'Weight', 'woocommerce' );
return $columns;
}
add_action( 'manage_shop_order_posts_custom_column', 'woo_custom_order_weight_column', 2 );
function woo_custom_order_weight_column( $column ) {
global $post, $woocommerce, $the_order;
# WordPress SEO - XML Sitemap Rewrite Fix - for subfolder install
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^sitemap_index.xml$ /wordpress/index.php?sitemap=1 [L]
RewriteRule ^locations.kml$ /wordpress/index.php?sitemap=wpseo_local_kml [L]
RewriteRule ^geo_sitemap.xml$ /wordpress/index.php?sitemap=wpseo_local [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /wordpress/index.php?sitemap=$1&sitemap_n=$2 [L]
# END WordPress SEO - XML Sitemap Rewrite Fix
@charleslouis
charleslouis / custom-search-acf-wordpress.php
Last active December 15, 2023 09:11
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}
@thetrickster
thetrickster / bc-disable-country-redirect.js
Created July 8, 2013 01:21
Disable visitors of a certain country or countries access to your site by redirecting them to another page in Business Catalyst
var userCountryCode = "{module_visitorcountrycode}";
var disallowedCountryCodes = ["US", "UK"];
var redirectBlockedUsersURL = "/country-blocked.html";
(function($) {
$.each(disallowedCountryCodes, function(i,val) {
if ( val == userCountryCode ) {
window.location = redirectBlockedUsersURL;
}
});
@maor
maor / ninja-forms-countries-dd.php
Last active March 27, 2019 03:10
Ninja Forms countries dropdown select field
<?php
/**
* Add a new <select> field, pre-populated with all countries in our tiny, tiny world.
*
* @author Maor Chasen
*/
function aff_register_ninja_forms_fields() {
$args = array(
@corsonr
corsonr / gist:6103979
Created July 29, 2013 12:27
WooCommerce - Restrict countries shipping list
<?php
/**
* WooCommerce Extra Feature
* --------------------------
*
* Restrict shipping countries list
*
*/
function woo_override_checkout_fields( $fields ) {