Skip to content

Instantly share code, notes, and snippets.

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

Myles McNamara tripflex

🦋
in the zone
View GitHub Profile
@tripflex
tripflex / gist:697c6c478f8824e3a31f
Created March 4, 2015 00:14
Set telephone field type to default to UK country code
jQuery(function(a){a(".jmfe-phone").intlTelInput({ defaultCountry: "gb" })});
@tripflex
tripflex / gist:fe673a7dbf26bf5168b0
Created March 14, 2015 20:25
Output image if checkbox is checked example
<?php
$huntfish_license = get_custom_field('huntfish_license');
if( (int) $huntfish_license === 1 ):
?>
<a href="" target="_blank"><img src="huntfish_license.png" /></a>
<?php
@tripflex
tripflex / gist:4d2d84815689daa033be
Last active August 29, 2015 14:17
Output multiple file upload images with links
<?php
$sample_gallery_images = get_custom_field( 'sample_gallery_images' );
// If field value is empty don't output anything
if( ! empty( $sample_gallery_images ) ){
// If it's an array that means there are multiple images
if( is_array( $sample_gallery_images ) ){
foreach( $sample_gallery_images as $gallery_image ){
// This outputs an image with a link to the image itself with a line break after each image
@tripflex
tripflex / phone.min.js
Created March 14, 2015 21:58
Set default phone field type flag to South African
jQuery(function(a){a(".jmfe-phone").intlTelInput({ defaultCountry: "za" })});
@tripflex
tripflex / gist:1019f3ade7e1e6e0e97f
Created March 19, 2015 22:23
Output image thumbnail with link to full size image
<?php
$sample_gallery_images = get_custom_field( 'sample_gallery_images' );
// If field value is empty don't output anything
if( ! empty( $sample_gallery_images ) && function_exists( 'job_manager_get_resized_image' ) ){
// If it's an array that means there are multiple images
if( is_array( $sample_gallery_images ) ){
foreach( $sample_gallery_images as $gallery_image ){
@tripflex
tripflex / gist:2744c7b61231d670baf6
Created March 30, 2015 22:54
Only output field if it has a value
<?php
$some_field = get_job_field( 'some_meta_key' );
if( ! empty( $some_field ) ) {
echo "<h3>Some Field:</h3>";
echo $some_field;
}
?>
@tripflex
tripflex / gist:78ac7fc8f313e681bf74
Last active August 29, 2015 14:18
Get custom field arrays
<?php
$jmfe = WP_Job_Manager_Field_Editor_Fields::get_instance();
$job_fields = $jmfe->get_fields( 'job', 'custom' );
$company_fields = $jmfe->get_fields( 'company', 'custom' );
?>
@tripflex
tripflex / job-submit.php
Created April 1, 2015 18:37
Output specific fields in a table
<?php
/**
* Job Submission Form
*/
if ( ! defined( 'ABSPATH' ) ) exit;
global $job_manager;
?>
<form action="<?php echo $action; ?>" method="post" id="submit-job-form" class="job-manager-form" enctype="multipart/form-data">
@tripflex
tripflex / gist:66f2eb890d5fc07ff324
Created April 3, 2015 20:44
Custom validation for number with decimals
<?php
add_filter('submit_job_form_validate_fields', 'check_price_job_field');
function check_price_job_field( $has_error, $fields, $values ){
// Return true if this field doesn't exist (to prevent errors if you dont have field created)
if( ! isset( $values['job']['price'] ) ) return true;
if( empty( $values['job']['price'] ) || ! is_float( $values['job']['price'] ) ){
@tripflex
tripflex / functions.php
Created April 7, 2015 01:06
Get WordPress image attachment ID by URL
if( ! function_exists( 'get_attachment_id_from_url' ) ){
function get_attachment_id_from_url( $attachment_url = '' ) {
global $wpdb;
$attachment_id = FALSE;
// If there is no url, return.
if ( '' == $attachment_url ) return;