Skip to content

Instantly share code, notes, and snippets.

View mikejolley's full-sized avatar

Mike Jolley mikejolley

View GitHub Profile
@mikejolley
mikejolley / gist:79f12043c18866f46fc6
Last active February 18, 2016 12:04
Restrict resume file allowed mime types
add_filter( 'submit_resume_form_fields', 'alter_allowed_mime_types' );
function alter_allowed_mime_types( $fields ) {
if ( ! empty( $fields['resume_fields']['resume_file'] ) ) {
$fields['resume_fields']['resume_file']['allowed_file_types'] = array(
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'pdf' => 'application/pdf',
);
}
return $fields;
@mikejolley
mikejolley / gist:485d52994a7643f799fa
Last active May 27, 2016 22:07
Add product tag and category classes to loops + post classes
/**
* Code placed in theme functions.php
*/
add_filter( 'post_class', 'wc_product_tag_post_class', 20, 3 );
function wc_product_tag_post_class( $classes, $class = '', $post_id = '' ) {
$tags = get_the_terms( $post_id, 'product_tag' );
if ( ! empty( $tags ) ) {
foreach ( $tags as $key => $value ) {
$classes[] = 'product-tag-' . $value->slug;
@mikejolley
mikejolley / gist:a0a53fdae65353f601ae
Created February 5, 2016 10:20
Show free shipping badge for products over 100
add_action( 'woocommerce_before_shop_loop_item_title', 'show_free_shipping_badge' );
function show_free_shipping_badge() {
global $post, $product;
if ( $product && $product->get_price() >= 100 ) {
echo '<span class="free-shipping">' . __( 'Free Shipping!'' ) . '</span>';
}
}
add_filter( 'woocommerce_enable_setup_wizard', '__return_false' );
@mikejolley
mikejolley / gist:27fe7edb343a078d97be
Created December 11, 2015 16:01
Enable deletion of expired jobs
// This will make sure expired jobs are deleted after XX days
add_filter( 'job_manager_delete_expired_jobs', '__return_true' );
// The default is 30 days, but you can change this with the following
add_filter( 'job_manager_delete_expired_jobs_days', 'change_job_manager_delete_expired_jobs_days' );
function change_job_manager_delete_expired_jobs_days() {
return 30; // change this to the number of days you desired
}
@mikejolley
mikejolley / gist:0c319756a630e37c8d40
Created November 24, 2015 09:54
Custom content before resume submission form.
add_action( 'submit_resume_form_start', 'submit_resume_form_start_content' );
function submit_resume_form_start_content() {
?>
Your content here
<?php
}
@mikejolley
mikejolley / functions.php
Created November 23, 2015 09:58
WP Job Manager - Changing Dashboard Columns
add_filter( 'job_manager_job_dashboard_columns', 'custom_job_manager_job_dashboard_columns' );
/**
* Columns are the existing columns found here: https://github.com/Automattic/WP-Job-Manager/blob/master/includes/class-wp-job-manager-shortcodes.php#L161-L166
*/
function custom_job_manager_job_dashboard_columns( $columns ) {
// Add a colunn
$columns['new_column'] = 'New Column Heading';
// Remove a column
<wpml-config>
<admin-texts>
<key name="job_manager_alerts_page_id" />
</admin-texts>
</wpml-config>
<?php
var_dump( current_time( 'timestamp' ) );
var_dump( strtotime( '-6 days', current_time( 'timestamp' ) ) );
var_dump( strtotime( 'midnight', current_time( 'timestamp' ) ) );
?>
@mikejolley
mikejolley / wpjm-update-access-test.php
Created October 8, 2015 14:51
Test server can access WPJobManager.com for updates
<?php
/**
* Plugin Name: WP Job Manager - Update access tester
* Description: Pings our site to see if your server can connect. Just head to <a href="/?wpjm-test=1">yoursite.com/?wpjm-test=1</a> whilst logged in as admin.
* Version: 1.0.0
* Author: Mike Jolley
* Requires at least: 4.1
* Tested up to: 4.3
*/
if ( ! defined( 'ABSPATH' ) ) {