Skip to content

Instantly share code, notes, and snippets.

View paulmiller3000's full-sized avatar

Paul Miller paulmiller3000

View GitHub Profile
/**
* Get sections.
*
* @return array
*/
public function get_sections() {
$sections = array(
'' => __( 'Settings', 'p3k-galactica' ),
'log' => __( 'Log', 'p3k-galactica' ),
'results' => __( 'Sale Results', 'p3k-galactica' )
/**
* Output the settings
*/
public function output() {
global $current_section;
switch ($current_section) {
case 'results':
include 'partials/p3k-galactica-settings-results.php';
break;
<?php
/**
* Displays a table in the WC Settings page
*
* @link https://paulmiller3000.com
* @since 1.0.0
*
* @package P3k_Galactica
* @subpackage P3k_Galactica/admin
*
/**
* Load dependencies for additional WooCommerce settings
*
* @since 1.0.0
* @access private
*/
public function p3kg_add_settings( $settings ) {
$settings[] = include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-p3k-galactica-wc-settings.php';
$settings[] = include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-p3k-galactica-wc-table.php';
<?php
/**
* Displays a table in the WC Settings page
*
* @link https://paulmiller3000.com
* @since 1.0.0
*
* @package P3k_Galactica
* @subpackage P3k_Galactica/admin
*
@paulmiller3000
paulmiller3000 / parse-url-for-woo.js
Created October 23, 2019 13:53
Parse URL for WooCommerce
document.addEventListener('DOMContentLoaded', function() {
const currentUrl = window.location.pathname;
let parentCategory = false;
let productName = currentUrl.substr(18, (currentUrl.length - 18));
let slashCount = productName.match(/\//g);
// Count the number of slashes. If 1, this is a parent category
slashCount = slashCount ? slashCount.length : 0;
@paulmiller3000
paulmiller3000 / class-extend-woocommerce-stripe-webhook-handler.php
Created December 7, 2019 11:50
Extend WC_Stripe_Webhook_Handler to override the check_for_webhook function
<?php
/**
* Extend WC_Stripe_Webhook_Handler and override the check_for_webhook function
*
*/
if (!class_exists('My_Stripe_Webhook_Handler')) :
class My_Stripe_Webhook_Handler extends WC_Stripe_Webhook_Handler {
@paulmiller3000
paulmiller3000 / return-two-values-to-es6-function.html
Created December 10, 2019 19:11
How to Return Two Values to a Function in ES6
<!DOCTYPE html>
<html>
<head>
<title>How to Return Two Values to a Function in ES6</title>
</head>
<body>
<div class='container'>
<form action='#' onsubmit='funFunction();return false'>
<select name='vehicle-selector' id='vehicle-selector' required />
<option value='BaseStar'>BaseStar</option>
@paulmiller3000
paulmiller3000 / functions.php
Last active February 18, 2020 18:08
Register Advanced Custom Fields for WooCommerce with the WordPress API
<?php
/*
* Register ACF fields to WordPress API
* Tutorial: https://battlestardigital.com/wp-admin/post.php?post=2838&action=edit
*/
add_action( 'rest_api_init', 'bsd_register_acf_with_api' );
function bsd_register_acf_with_api() {
if (!function_exists('get_fields')) return;
@paulmiller3000
paulmiller3000 / quick_view_pro_display_acf_google_map
Last active February 23, 2020 19:04
Function to display Advanced Custom Fields Google Map in Quick View Pro modal
/*
* Display a map (saved from Advanced Custom Fields) in Quick View Pro modal
* Documentation: https://battlestardigital.com/adding-advanced-custom-fields-google-maps-to-woocommerce-quick-view-pro/
* HTML Source: https://www.advancedcustomfields.com/resources/google-map/
*/
private function bsd_qvp_display_map( $map) {
if ( $map ) {
?>
<div id="map" class="acf-map">
<div class="marker" data-lat="<?php echo esc_attr($map['lat']); ?>" data-lng="<?php echo esc_attr($map['lng']); ?>"></div>