Skip to content

Instantly share code, notes, and snippets.

@passatgt
passatgt / check_scf_upgrade.php
Created October 13, 2024 10:26
A small snippet to notify users if they accidentally installed Secure Custom Fields instead of Advanced Custom Fields.
<?php
if ( ! function_exists( 'check_scf_upgrade' ) ) :
function check_scf_upgrade() {
add_action( 'admin_notices', function(){
if(!get_user_meta(get_current_user_id(), 'acf_upgrade_notice_dismissed', true) && class_exists( 'ACF_Admin' ) && !method_exists('ACF_Admin', 'setup_help_tab')) {
?>
<div class="notice notice-error acf-upgrade-notice is-dismissible">
<p><strong>Advanced Custom Fields is no longer available through WordPress.org.</strong> Please update to the latest version following these instructions:</p>
@passatgt
passatgt / listmonk-custom-colors.css
Created August 29, 2024 20:54
Changing Listmonk admin blue color to your own brand color
:root {
--primary-color: #35c287;
--primary-color-opaque: #35c287 40;
--primary-color-light: #35c287 80;
}
html a, html .button.is-ghost, html .button.is-ghost:hover, html .button.is-ghost.is-hovered, html .breadcrumb a, html .menu-list a.is-active, html .panel-list a:hover, html .panel-block.is-active .panel-icon, html .navbar-item.is-tab.is-active, html .carousel-arrow .icon, html .copy-text:hover, html .autocomplete a.dropdown-item:hover, html .autocomplete .dropdown .dropdown-menu .has-link a:hover, html .dropdown .dropdown-menu .has-link .autocomplete a:hover, html .autocomplete a.dropdown-item.is-hovered, html .autocomplete .dropdown .dropdown-menu .has-link a.is-hovered, html .dropdown .dropdown-menu .has-link .autocomplete a.is-hovered, html section.lists .view:hover, html .log-view .lines .timestamp, html a.navbar-item:focus, html a.navbar-item:focus-within, html a.navbar-item:hover, html a.navbar-item.is-active, html .navbar-link:focus, html .navbar-link:focus-within, html .navbar-link:hover,
@passatgt
passatgt / orders-google-map.php
Created December 28, 2023 12:27
Save coordinates of the billing address and show them on a map
<?php
//Save coorindates of the billing address when order marked completed using google geocode API and save it to order meta
add_action('woocommerce_order_status_completed', function($order_id) {
$order = wc_get_order($order_id);
$billing_address = $order->get_formatted_billing_address();
// Replace spaces with '+' for URL encoding
$formatted_address = str_replace(' ', '+', $billing_address);
$api_key = 'YOUR GOOGLE API KEY';
@passatgt
passatgt / shipping-cache-test-block.php
Created December 5, 2023 17:09
Shipping rate test plugin for checkout blocks bug(?)
<?php
/*
Plugin Name: shipping-cache-test-block
Version: 1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@passatgt
passatgt / validate-wc-hu-postcodes.php
Last active November 15, 2023 09:42
Validate hungarian postcodes in WooCommerce
<?php
add_filter('woocommerce_validate_postcode', function($valid, $postcode, $country){
if($country != 'HU') return $valid;
$postcode = intval($postcode);
$valid_postcodes = array(1007, 1011, 1012, 1013, 1014, 1015, 1016, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1051, 1052, 1053, 1054, 1055, 1056, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1121, 1122, 1123, 1124, 1125, 1126, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1161, 1162, 1163, 1164, 1165, 1171, 1172, 1173, 1174, 1181, 1182, 1183, 1184, 1185, 1186, 1188, 1191, 11
@passatgt
passatgt / CustomShortcutsLink.swift
Last active April 4, 2023 15:44
Custom ShortcutsLink in your SwiftUI Form
@passatgt
passatgt / wc-my-orders-products-search.php
Created September 9, 2022 15:57
WooCommerce product search for My Account / Orders
//Create search bar on the top of the my account / orders page
add_action('woocommerce_before_account_orders', function(){
?>
<form method="get">
<input type="text" name="keyword" placeholder="Keresés" value="<?php echo esc_attr($_GET['keyword']); ?>">
<input type="submit" value="Keresés" />
</form>
<?php
$customer_orders = false;
@passatgt
passatgt / add-to-cart-form-shortcode.php
Created August 26, 2021 20:11
WooCommerce Add To Cart Form Shortcode that supports variable products too
add_shortcode( 'add-to-cart-form', function($atts) {
global $post;
//Get shortcode attributes
$a = shortcode_atts( array(
'id' => 0
), $atts );
//Find the product and set it to global
$product_data = get_post( $a['id'] );
@passatgt
passatgt / wc-custom-store-management-link.js
Created April 3, 2021 12:38
jQuery way to add custom storage management links in WooCommerce dashboard
@passatgt
passatgt / shop_order_info_column.php
Created May 29, 2020 12:11
Add order item details into the order manager table in WooCommerce
add_filter( 'manage_edit-shop_order_columns', function($columns) {
$columns['order_info'] = 'Rendelés infók';
return $columns;
});
add_action( 'manage_shop_order_posts_custom_column', function( $column ) {
global $the_order;
if ( 'order_info' === $column ) {
echo $the_order->get_billing_email();
$line_items = $the_order->get_items();