Skip to content

Instantly share code, notes, and snippets.

@swoboda
swoboda / set-dashboard-meta-order.php
Created June 27, 2022 07:11
Make sure our widget is always on top
<?php
add_action( 'admin_init', 'set_dashboard_meta_order' );
/**
* Make sure our widget is always on top
*
*/
function set_dashboard_meta_order() {
$user_id = get_current_user_id();
$user_metabox_order = get_user_meta( $user_id, 'meta-box-order_dashboard' );
@swoboda
swoboda / subscription-auto-renew.php
Created July 18, 2020 17:48
WIP: AutomateWoo Trigger for Auto Renew Toggle
<?php
/**
* This is an example trigger that is triggered via a WordPress action and includes a user data item.
* Trigger with: do_action('my_custom_action', $user_id );
*/
class WPDesk_AutomateWoo_Subscription_Auto_Renew_Trigger extends AutomateWoo\Trigger {
/** @var array - Define which data items are set by this trigger, this determines which rules and actions will be available */
public $supplied_data_items = array( 'customer', 'subscription' );
@swoboda
swoboda / wpdesk-checkout-steps.php
Created June 19, 2020 07:48
Checkout steps in WP Desk Theme
<?php
add_action( 'genesis_after_header', 'wpdesk_checkout_steps', 25 );
/**
* Checkout Steps
*
*/
function wpdesk_checkout_steps() {
global $wp;
@swoboda
swoboda / gravity-forms-option-groups.php
Created May 26, 2020 21:26
Option groups in the Gravity Forms drop down field
<?php
// Do NOT include the opening php tag
add_filter( 'gform_field_choice_markup_pre_render', function ( $choice_markup, $choice, $field ) {
if ( $field->get_input_type() == 'select' ) {
$choice_value = rgar( $choice, 'value' );
if ( $choice_value === 'optgroup-start' ) {
return sprintf( '<optgroup label="%s">', esc_html( $choice['text'] ) );
} elseif ( $choice_value === 'optgroup-end' ) {
return '</optgroup>';
@swoboda
swoboda / functions.php
Created October 23, 2019 13:21
Allow Flexible Pricing sales display on non-WooCommerce pages
<?php
// Do NOT include the opening php tag
add_filter( 'wc_flexible_pricing_on_get_price', 'wpdesk_wc_flexible_pricing_on_get_price' );
/**
* Allow Flexible Pricing sales on non-WooCommerce pages
*
*/
function wpdesk_wc_flexible_pricing_on_get_price( $on_get_price ) {
if ( is_page() ) {
@swoboda
swoboda / gravity-forms-notification-help-scout-api-error.php
Created October 15, 2019 14:31
Programmatically Trigger Gravity Forms Notification on Help Scout Error
<?php
// Do NOT include the opening php tag
add_action( 'gform_gravityformshelpscout_post_process_feed', 'wpdesk_helpscout_authentication_mail', 10, 4 );
/**
* Email notification to admin about Gravity Forms Help Scout API authentication problem and create Help Scout conversation
*
*/
function wpdesk_helpscout_authentication_mail( $feed, $entry, $form, $addon ) {
@swoboda
swoboda / automatewoo-shortcodes.php
Created March 25, 2019 16:13
AutomateWoo - Shortcodes support in emails
<?php
// Do NOT include the opening php tag
/**
* Enable shortcodes in email content
*
*/
add_filter( 'automatewoo_email_content', 'do_shortcode' );
@swoboda
swoboda / woocommerce_wfirma_invoice_data.php
Last active March 14, 2019 19:44
Filtr do modyfikacji danych przesyłanych do API wFirma
<?php
Array(
[type] => normal
[series_id] => 3055245
[price_type] => netto
[disposaldate] => 2017-12-05
[date] => 2017-12-05
[currency] => PLN
[alreadypaid_initial] => 1.00
@swoboda
swoboda / fcf-wlasna-walidacja-nip.php
Last active March 17, 2023 08:01
Flexible Checkout Fields - Walidacja polskiego numeru NIP
<?php
// NIE kopiuj powyższego tagu otwierającego php
/**
* Funkcja do walidacji polskiego numeru NIP
*
*/
function wpdesk_fcf_validate_nip( $field_label, $value ) {
$valid = false;
@swoboda
swoboda / functions.php
Last active February 13, 2019 20:59
AutomateWoo - Custom Subscription Rule based on Billing Period
<?php
// Do NOT include the opening php tag
add_filter( 'automatewoo/rules/includes', 'wpdesk_automatewoo_rules' );
/**
* Custom Rules
*
*/
function wpdesk_automatewoo_rules( $rules ) {