Skip to content

Instantly share code, notes, and snippets.

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;
/***********
* Hide sku
************/
function sv_remove_product_page_skus( $enabled ) {
if ( ! is_admin() && is_product() ) {
return false;
}
return $enabled;
}
*/ https://rudrastyh.com/woocommerce/before-and-after-add-to-cart.html */
// Before Add to Cart Button
add_action( 'woocommerce_before_add_to_cart_button', 'misha_before_add_to_cart_btn' );
function misha_before_add_to_cart_btn(){
echo 'Some custom text here';
}
// After Add to Cart Button
@mzdebo
mzdebo / ci-star-rating.php
Created February 22, 2021 16:29 — forked from nvourva/ci-star-rating.php
Ratings Plugin
<?php
/*
Plugin Name: CI Comment Rating
Description: Adds a star rating system to WordPress comments
Version: 1.0.0
Author: The CSSIgniter Team
Author URI: https://cssigniter.com/
*/
//Enqueue the plugin's styles.
////////////////////////////////////////////////////////////////////////////////////
// //
// Create a post from every image in wordpress media gallery //
// //
////////////////////////////////////////////////////////////////////////////////////
//If you have the image in your media library you can just loop through them and create post via wp_insert_post.
// using wp_insert_post() function
// snippet from the Codex
////////////////////////////////////////////////////////////////////////////////////
// //
// Add media size column to media library //
// //
////////////////////////////////////////////////////////////////////////////////////
// Add custom column to book list
function wh_column( $cols ) {
$cols["dimensions"] = "Dimensions (h)";
return $cols;
@mzdebo
mzdebo / readme.md
Created April 28, 2021 12:29 — forked from LeanSeverino1022/readme.md
[_Just enough wordpress] just enough stuff I need for now #wordpress
@mzdebo
mzdebo / gist:10bbeab85563c9256468ba0339ef2666
Created April 28, 2021 12:30 — forked from Pleiades/gist:b9711273719a401d52f3
Sample WordPress Action and Filter Hooks
Code Samples for Hooks And Filters Class
<?php
/* Filter the title to add a page number if necessary.
------------------------------------------------------------------------------------ */
add_filter( 'wp_title', 'page_numbered_wp_title', 10, 2 );
function page_numbered_wp_title( $title, $sep ) {
<?php
//hierarchical
//hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 );
//create a custom taxonomy name it topics for your posts
function create_topics_hierarchical_taxonomy() {
@mzdebo
mzdebo / wp_auto_thumbnail_functions.php
Created April 28, 2021 12:34 — forked from sosukeinu/wp_auto_thumbnail_functions.php
WP function auto featured image
<?php
/*
* This function will get the first image in this order:
*
* 1) Featured image
* 2) First image attached to post
* 3) First image URL in the content of the post
* 4) YouTube screenshot
* 5) Default images for different categories [SET MANUALLY]