Skip to content

Instantly share code, notes, and snippets.

View espiat's full-sized avatar
🎯
Focusing

DER SPANIER espiat

🎯
Focusing
View GitHub Profile
@espiat
espiat / acf-future-posts.php
Created March 10, 2022 10:59 — forked from aderaaij/acf-future-posts.php
Advanced Custom Fields datepicker: Show only events with a date of today or in the future. Extra comments from Pasnon @ ACF Forums: f you needed to, you could also play with the comparison date, which is the first array in meta_query, currently set to date("Y-m-d") which is today; if you were to make it date("Y-m-d", strtotime("-1 day")) you cou…
<?php
/*
* Display posts only from today and in the future:
* http://old.support.advancedcustomfields.com/discussion/6000/how-to-sort-posts-by-acf-date-and-display-only-future-posts
* by Pasnon
*/
$date_args = array(
'post_type' => 'events',
@espiat
espiat / add-submenu-page_to_custom_post_type_example.php
Created March 9, 2022 13:54 — forked from Njengah/add-submenu-page_to_custom_post_type_example.php
Simple function to add submenu page to a custom post type menu in WordPress admin
<?php
// Hook
add_action('admin_menu', 'add_tutorial_cpt_submenu_example');
//Callback function
function add_tutorial_cpt_submenu_example(){
@espiat
espiat / add_move_payment_request_checkout_page.php
Created December 20, 2021 21:25 — forked from dougaitken/add_move_payment_request_checkout_page.php
Adds the Payment Request button (Apple Pay) on the checkout page then moves it to after the customer details (WooCommerce Stripe extension)
// Adds the Payment Request button (Apple Pay) on the checkout page then moves it to after the customer details.
// Replace `woocommerce_checkout_after_customer_details` with wherever you want to
add_filter( 'wc_stripe_show_payment_request_on_checkout', '__return_true' );
remove_action( 'woocommerce_checkout_before_customer_details', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_html' ), 1 );
remove_action( 'woocommerce_checkout_before_customer_details', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_separator_html' ), 2 );
add_action( 'woocommerce_checkout_after_customer_details', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_html' ), 1 );
add_action( 'woocommerce_checkout_after_customer_details', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_separator_html' ), 2 );
@espiat
espiat / move_stripeprbutton.php
Created December 20, 2021 21:25 — forked from dougaitken/move_stripeprbutton.php
Moving the WooCommerce Stripe Payment Request buttons below the add to cart button
/** Move Stripe Payment Request Button on product page **/
remove_action( 'woocommerce_after_add_to_cart_quantity', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_html' ), 1 );
remove_action( 'woocommerce_after_add_to_cart_quantity', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_separator_html' ), 2 );
add_action( 'woocommerce_after_add_to_cart_button', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_html' ), 2 );
add_action( 'woocommerce_after_add_to_cart_button', array( WC_Stripe_Payment_Request::instance(), 'display_payment_request_button_separator_html' ), 1 );
<?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
@espiat
espiat / functions.php
Created November 8, 2021 17:04 — forked from maddisondesigns/functions.php
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@espiat
espiat / README.md
Created August 5, 2021 12:54 — forked from smatplacid/README.md
Oxygen Child Theme Support

Oxygen 'Child Theme' Support

This function is for developers, which use Oxygen and still want to override plugin-files when it reads in their documentation such as

  1. Create a folder in your theme folder called search-filter.
  2. Copy the file wp-content\plugins\search-filter\templates\results.php from the templates folder in to the newly created folder in your theme – wp-content\themes\your-theme-name\search-filter\results.php

Where to put such files, if Oxygen is not a theme and won't uses themes ?

Usage

@espiat
espiat / functions.php
Created June 24, 2021 13:21 — forked from maxkostinevich/functions.php
WordPress: Export custom data to CSV
<?php
/**
* Export Data to CSV file
* Could be used in WordPress plugin or theme
*/
// A sample link to Download CSV, could be placed somewhere in plugin settings page
?>
<a href="<?php echo admin_url( 'admin.php?page=myplugin-settings-page' ) ?>&action=download_csv&_wpnonce=<?php echo wp_create_nonce( 'download_csv' )?>" class="page-title-action"><?php _e('Export to CSV','my-plugin-slug');?></a>
@espiat
espiat / .gitignore
Created June 23, 2021 12:17 — forked from salcode/.gitignore
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@espiat
espiat / gist:cf1a115229b3f09523f300d62c317eef
Created January 23, 2021 17:56 — forked from woogist/gist:5692886
Sample WooCommerce Points & Rewards 3rd Party Plugin Integration
<?php
// Add the action setting
add_filter( 'wc_points_rewards_action_settings', 'points_rewards_newsletter_action_settings' );
function points_rewards_newsletter_action_settings( $settings ) {
$settings[] = array(
'title' => __( 'Points earned for newsletter signup' ),
'desc_tip' => __( 'Enter the amount of points earned when a customer signs up for a newsletter via MailChimp.' ),