Skip to content

Instantly share code, notes, and snippets.

View tripflex's full-sized avatar
🦋
in the zone

Myles tripflex

🦋
in the zone
View GitHub Profile
@tripflex
tripflex / functions.php
Last active September 30, 2015 15:45
Example action hook field type to output shortcode
<?php
// There should only be one <?php at the top of your file, do not add this if it already exists
function custom_N01_Price_action( $field, $key ) {
echo do_shortcode('[table id=1]');
}
// Here the meta key is N01_Price, so the action would be job_manager_field_actionhook_N01_Price
add_action( 'job_manager_field_actionhook_N01_Price', 'custom_N01_Price_action', 10, 2 );
@tripflex
tripflex / term-multiselect.min.js
Created October 3, 2015 23:14
Set max categories to 5
jQuery(function(){
jQuery( '.job-manager-category-dropdown' ).chosen({ search_contains: true, max_selected_options: 5 });
});
@tripflex
tripflex / functions.php
Last active October 12, 2015 19:07
Remove preview step from WP Job Manager (only for suggestion, code is untested)
<?php
add_filter( 'submit_job_steps', 'my_custom_remove_preview_step' );
function my_custom_remove_preview_step( $steps ){
if( isset( $steps['preview'] ) ) unset( $steps['preview'] );
return $steps;
@tripflex
tripflex / functions.php
Created October 19, 2015 20:10
Set a specific option for jQuery UI Datepicker field type (this example sets max date to +30 days from now)
<?php
add_filter( 'job_manager_field_editor_date_args', 'my_custom_date_args' );
function my_custom_date_args( $args ){
$args['maxDate'] = '+30D';
return $args;
}
@tripflex
tripflex / functions.php
Last active May 12, 2022 12:12
Add your own custom auto output locations to WP Job Manager Field Editor auto output dropdown
<?php
// Add filter to call our custom function when setting up dropdown of output locations
add_filter( 'field_editor_output_options', 'my_custom_output_options', 10, 2 );
/**
* Add Custom Auto Output Locations for WPJM
*
* This custom function will add to the end of an array, a new set of output locations
* that will be visible in the WP Job Manager Field Editor auto output dropdown.
@tripflex
tripflex / content-single-job_listing.php
Created November 9, 2015 19:57
How to execute shortcode when used in a field
<?php
// You should only use this code below if the field is an "admin only" field.
// Using a field that is not admin only will allow any user to execute shortcodes from your site, and can cause security issues
$list_related_products = get_custom_field( 'list_related_products' );
echo do_shortcode( $list_related_products );
@tripflex
tripflex / functions.php
Last active September 14, 2020 19:00
How to turn a WP Job Manager Field Editor standard text field into a currency field with jQuery Mask Money ( https://github.com/plentz/jquery-maskmoney )
<?php
// ^ the <?php above should only be in your functions.php file ONCE, at the top ... do not include <?php if you're adding this to the end of your functions.php file
// Register our jQuery MaskMoney script in WordPress (does not output, only register)
add_action( 'wp_enqueue_scripts', 'my_custom_register_currency_script' );
// Call our function to output jQuery when the submit listing page is loaded
add_action( 'submit_job_form_job_fields_end', 'my_custom_output_currency_js' );
function my_custom_register_currency_script(){
// Register the script in WP .. does not output, only register
@tripflex
tripflex / functions.php
Created January 9, 2016 22:35
Set term-multiselect field max select options for WP Job Manager (place this in your theme's functions.php file)
<?php
add_filter( 'job_manager_chosen_multiselect_args', 'set_term_multiselect_max_opts' );
function set_term_multiselect_max_opts( $args ){
$args['max_selected_options'] = 5;
return $args;
}
@tripflex
tripflex / functions.php
Last active November 3, 2022 22:12
Field editor output value formatted as currency (when using auto output, shortcode, or widget)
<?php
// ^ the <?php above should only be in your functions.php file ONCE, at the top
// The filter is field_editor_output_as_value_METAKEY
// where you need to replace METAKEY with the actual meta key you want to filter the output for
// .... as you can see below you can also add multiple filters using the same function.
add_filter( 'field_editor_output_as_value_METAKEY', 'my_custom_format_value_as_currency' );
// Just uncomment the code below to use same handling for a different meta key
//add_filter( 'field_editor_output_as_value_ANOTHERMETAKEY', 'my_custom_format_value_as_currency' );
@tripflex
tripflex / functions.php
Created January 26, 2016 19:20
Execute shortcode from field value (when using Auto Output, Widget, or Shortcode) THIS MAY CAUSE SECURITY VULNERABILITIES
<?php
// ^ the <?php above should only be in your functions.php file ONCE, at the top
//
// This code is provided for educational purposes only
//
// Executing shortcodes from user input is not support or recommended as this will
// allow users to input any shortcode even ones you may not want them to use.
// I do not support this and will not be held liable for anything done to your site
// as a result of executing shortcodes from user input. Use at your own risk.