Skip to content

Instantly share code, notes, and snippets.

@yiedpozi
yiedpozi / custom-post-status.php
Last active August 2, 2021 19:47
Register custom post status and display it in the post status list
<?php
// Register post status
add_action( 'init', function() {
register_post_status( 'mysite-accepted', array(
'label' => _x( 'Accepted', 'post status label', 'mysite' ),
'label_count' => _n_noop( 'Accepted <span class="count">(%s)</span>', 'Accepted <span class="count">(%s)</span>', 'mysite' ),
) );
@yiedpozi
yiedpozi / functions.php
Last active March 26, 2023 22:04
Fix toyyibPay plugin - thank you page not showing order details
<?php
// Add this function in toyyibpay-for-woocommerce/index.php file
// Fix WooCommerce order key parameter that clashed with toyyibPay
add_filter( 'woocommerce_thankyou_order_key', function( $order_key ) {
if ( isset( $_GET['order_key'] ) && !empty( $_GET['order_key'] ) ) {
$order_key = wc_clean( wp_unslash( $_GET['order_key'] ) );
}
return $order_key;
} );
@yiedpozi
yiedpozi / functions.php
Last active June 3, 2021 08:26
Display variation name and its quantity in WooCommerce products management page (table version)
<?php
add_filter( 'manage_edit-product_columns', 'woocommerce_product_custom_columns' );
function woocommerce_product_custom_columns( $columns ) {
$new_columns = array();
foreach ( $columns as $key => $value ) {
$new_columns[ $key ] = $value;
// Add total variations column after stock status column
@yiedpozi
yiedpozi / functions.php
Created June 3, 2021 07:30
Display total stock and total variations in WooCommerce products management page
<?php
add_filter( 'manage_edit-product_columns', 'woocommerce_product_custom_columns' );
function woocommerce_product_custom_columns( $columns ) {
$new_columns = array();
foreach ( $columns as $key => $value ) {
$new_columns[ $key ] = $value;
// Add total variations column after stock status column
@yiedpozi
yiedpozi / trackingmy_track_button.html
Created October 14, 2020 08:50
Auto set input value based on URL parameter
<input type="text" id="TrackNo" maxlength="50">
<input type="button" value="TRACK" onclick="inputTrack()">
<script src="//www.tracking.my/track-button.js"></script>
<script>
var TrackNo = location.search.split('TrackNo=')[1] ? location.search.split('TrackNo=')[1] : '';
document.getElementById("TrackNo").value = TrackNo;
function inputTrack() {
var num = document.getElementById("TrackNo").value;
if(num===""){
@yiedpozi
yiedpozi / custom-post-type-menu-woocommerce
Created September 2, 2020 16:54
Highlight custom post type menu under WooCommerce
// Highlight custom post type menu registered under WooCommerce (sub menu)
add_action( 'admin_head', 'menu_highlight' );
function menu_highlight() {
global $parent_file, $submenu_file, $post_type;
if ( $post_type == 'custom_post_type' ) {
// We change $submenu_file to current $parent_file,
// so the $submenu_file for post type add and edit screen is same.
$submenu_file = $parent_file;
@yiedpozi
yiedpozi / functions.php
Created July 24, 2020 16:23
WooCommerce Checkout Shipping Additional Text
add_action( 'woocommerce_after_shipping_rate', 'checkout_shipping_additional_text', 20, 2 );
function checkout_shipping_additional_text( $method, $index ) {
if ( $method->get_method_id() == 'free_shipping' ) {
echo '<br>Pesanan akan diterima pada 3 - 5 hari bekerja';
}
}
@yiedpozi
yiedpozi / laravel_clear_all.txt
Created February 24, 2018 19:16
Laravel Command for Clear All
composer dump-autoload
php artisan clear-compiled
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan config:clear
php artisan migrate:refresh --seed
composer dump-autoload