Skip to content

Instantly share code, notes, and snippets.

View mikejolley's full-sized avatar

Mike Jolley mikejolley

View GitHub Profile
@mikejolley
mikejolley / functions.php
Created September 29, 2015 07:41
WooCommerce - Disable the non-admin access to dashboard feature
<?php
// Add the below line to your theme functions.php file
add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
@mikejolley
mikejolley / gist:f19bdc23ef5bd4123089
Created September 16, 2015 13:15
Add a region bias to geolocation in job manager
<?php
/**
* Add to functions.php. Replace country_code with a CCTLD
*/
function wp_job_manager_region_bias() {
return 'country_code';
}
add_filter( 'job_manager_geolocation_region_cctld', 'wp_job_manager_region_bias' );
@mikejolley
mikejolley / ipn-test.php
Last active September 5, 2024 01:54
Quick snippet/plugin/dropin to test IPN support
<?php
/**
* Plugin Name: PayPal Sandbox IPN Tester
* Description: Pings the IPN endpoint to see if your server can connect. Just head to <a href="/?ipn-test=1">yoursite.com/?ipn-test=1</a> whilst logged in as admin.
* Version: 1.0.0
* Author: WooThemes
* Requires at least: 4.1
* Tested up to: 4.3
*/
if ( ! defined( 'ABSPATH' ) ) {
add_filter( 'job_application_form_fields', 'alter_allowed_mime_types' );
function alter_allowed_mime_types( $fields ) {
$fields['application_attachment']['allowed_mime_types'] = array(
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'pdf' => 'application/pdf',
);
return $fields;
}
@mikejolley
mikejolley / functions.php
Last active September 9, 2015 09:01
Add a region bias when geocoding addresses.
<?php
/**
* Plugin Name: Listify Region Bias
*/
function listify_region_bias() {
return 'country_code';
}
add_filter( 'job_manager_geolocation_region_cctld', 'listify_region_bias' );
<?php
/**
* Hide Free Shipping for some states
*/
add_filter( 'woocommerce_package_rates', 'hide_all_shipping_when_free_is_available' , 10, 2 );
function hide_all_shipping_when_free_is_available( $rates, $package ) {
$excluded_states = array( 'AK', 'HI', 'GU', 'PR' );
if( isset( $rates['free_shipping'] ) AND in_array( WC()->customer->get_shipping_state(), $excluded_states ) ) {
<?php if ( ( $apply = get_the_job_application_method() ) && current_user_can( 'employer' ) ) :
wp_enqueue_script( 'wp-job-manager-job-application' );
?>
<div class="job_application application">
<?php do_action( 'job_application_start', $apply ); ?>
<input type="button" class="application_button button" value="<?php _e( 'Apply for job', 'wp-job-manager' ); ?>" />
<div class="application_details">
<?php
@mikejolley
mikejolley / functions.php
Created August 25, 2015 12:56
woocommerce_flat_rate_shipping_add_rate example for theme functions.php
<?php
add_action( 'woocommerce_flat_rate_shipping_add_rate', 'add_another_custom_flat_rate', 10, 2 );
function add_another_custom_flat_rate( $method, $rate ) {
$new_rate = $rate;
$new_rate['id'] .= ':' . 'next_day'; // Append a custom ID
$new_rate['label'] = 'Next Day'; // Rename to 'Rushed Shipping'
$new_rate['cost'] += 2; // Add $2 to the cost
<?php
if ( $attribute['is_taxonomy'] ) {
$values = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'ids' ) );
$links = array();
foreach ( $values as $value ) {
$term = get_term_by( 'id', $value, $attribute['name'] );
$links[] = '<a href="' . esc_url( get_term_link( $term->slug, $attribute['name'] ) ) . '">' . esc_html( $term->name ) . '</a>';
}
@mikejolley
mikejolley / gist:9f5adb8d194d7681e7b7
Last active April 18, 2023 22:49 — forked from corsonr/gist:6681929
WooCommerce - Create a product categories dropdown list in a shortcode
<?php
/**
* WooCommerce Extra Feature
* --------------------------
*
* Register a shortcode that creates a product categories dropdown list
*
* Use: [product_categories_dropdown orderby="title" count="0" hierarchical="0"]
*/