Skip to content

Instantly share code, notes, and snippets.

/***********
* Hide sku
************/
function sv_remove_product_page_skus( $enabled ) {
if ( ! is_admin() && is_product() ) {
return false;
}
return $enabled;
}
https://stackoverflow.com/questions/39007426/adding-programmatically-a-custom-settings-tab-to-admin-product-data-in-woocommer
// Step 1 - Adding a custom tab to the Products Metabox
add_filter( 'woocommerce_product_data_tabs', 'add_shipping_costs_product_data_tab', 99 , 1 );
function add_shipping_costs_product_data_tab( $product_data_tabs ) {
$product_data_tabs['shipping-costs'] = array(
'label' => __( 'Shipping costs', 'my_theme_domain' ), // translatable
'target' => 'shipping_costs_product_data', // translatable
);
return $product_data_tabs;
<?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
@mzdebo
mzdebo / youzer_members_articles_tab
Created October 21, 2020 03:03
Youzer - Add shortcode to display current user posts in a custom tab
<?php
/**
* Author: Chanel via https://thehorsebc.world
*/
/**
* How to Use this
*
* Adapted for use with Youzer plugin via https://www.kainelabs.com
@mzdebo
mzdebo / gist:92c620f9912fc0d29b69259e749f2ed4
Created October 17, 2020 20:50 — forked from shanebp/gist:b73343e9c9a6509d2bbc47de80c881c1
add last_activity timestamp to all BP members
/*
* Paste in your theme functions.php or in bp-custom.php.
* Load the site in a browser
* Remove from your theme functions.php or bp-custom.php.
*/
function buddypress_add_last_activity() {
$members = get_users( 'fields=ID' );
// $members = get_users( 'fields=ID&role=subscriber' );
@mzdebo
mzdebo / register-post-type.php
Created October 2, 2020 14:40 — forked from justintadlock/register-post-type.php
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
@mzdebo
mzdebo / default-author.php
Created September 25, 2020 11:50 — forked from chrisguitarguy/default-author.php
Set a default author for posts on your WordPress site.
<?php
/*
Plugin Name: Default Author
Plugin URI: http://pmg.co
Description: Set a default author for all posts and pages
Version: 1.0
Text Domain: default-author
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: GPL2
@mzdebo
mzdebo / gist:664cd6f2f7869486be191f6c87849535
Last active September 3, 2020 11:12
WooCommerce Products Sort and Display by a Custom meta field
/**
* Add Publish Year sorting option to shop page / WC Product Settings - WooCommerce
*/
function thbc_publishyear_woocommerce_shop_ordering( $sort_args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'publishyear' == $orderby_value ) {
$sort_args['orderby'] = 'title';
$sort_args['order'] = 'asc'; //or desc
$sort_args['meta_key'] = 'publish-year';
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
<?php
/**
* Plugin Name: [Smush] - Bulk Delete Bak Images
* Plugin URI: https://premium.wpmudev.org/
* Description: Deletes all .bak images
* Author: Panos Lyrakis @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* License: GPLv2 or later
*/