Skip to content

Instantly share code, notes, and snippets.

Avatar
🦋
in the zone

Myles McNamara tripflex

🦋
in the zone
View GitHub Profile
@tripflex
tripflex / functions.php
Created Oct 21, 2020
Minimum file dimensions when using WP Job Manager Field Editor
View functions.php
<?php
add_filter( 'job_manager_upload_file_pre_upload', 'smyles_check_min_upload_dimensions', 9999, 3 );
/**
* Check Min Upload Dimensions
*
*
* @param array $file Array of $_FILE data to upload.
* @param array $args Optional file arguments
* @param array $allowed_mime_types Array of allowed mime types from field config or defaults
@tripflex
tripflex / functions.php
Created Oct 21, 2020
Require minimum file uploads when using WP Job Manager Field Editor
View functions.php
<?php
add_filter( 'submit_job_form_validate_fields', 'smyles_check_min_upload_files', 9999, 3 );
/**
* Check Min Uploaded Files
*
* @param $no_errors
* @param $fields
* @param $values
*
@tripflex
tripflex / functions.php
Created Oct 16, 2020
[job_apply] shortcode from get parameter when using WP Job Manager Field Editor
View functions.php
<?php
add_shortcode( 'job_apply_from_get', 'smyles_job_apply_from_get' );
function smyles_job_apply_from_get( $atts, $content = '' ) {
if( ! isset( $_GET['job_id'] ) ){
return '';
}
$job_id = absint( $_GET['job_id'] );
@tripflex
tripflex / functions.php
Created Oct 12, 2020
Shortcode to output Listing or Post slug/permalink/post name
View functions.php
<?php
add_shortcode( 'smyles_post_name', 'smyles_return_post_name' );
function smyles_return_post_name( $atts, $content = '' ){
$post = get_post();
return $post->post_name;
}
@tripflex
tripflex / functions.php
Last active Oct 8, 2020
Set field default value based on selected package when using WP Job Manager Field Editor
View functions.php
<?php
add_filter( 'submit_job_form_fields', 'smyles_custom_default_per_package', 101 );
function smyles_custom_default_per_package( $fields ) {
$packages_config = array(
// The key should be the ID of the product (look at the ID when editing the product in the URL bar)
'11111' => array(
// Array key should be the exact meta key
'job_type' => 'freelance',
@tripflex
tripflex / functions.php
Created Sep 14, 2020
Initialize Select2 on standard dropdown fields when using WP Job Manager Field Editor
View functions.php
<?php
// ^ there should ONLY be one of these at the top of child theme's functions.php file or use the Code Snippets plugin
add_action( 'submit_job_form_start', 'my_custom_jquery_init_select2_on_selects' );
function my_custom_jquery_init_select2_on_selects(){
echo "<script>jQuery( function($){ $( '.jmfe-select-field' ).select2(); });</script>";
}
@tripflex
tripflex / functions.php
Created Sep 9, 2020
Output og:image tag for Resume featured image when using WP Job Manager Field Editor
View functions.php
<?php
add_action( 'wp_head', 'smyles_output_resume_og_image' );
function smyles_output_resume_og_image() {
if( is_singular('resume') ) {
echo '<meta property="og:image" content="' . get_the_post_thumbnail_url( get_the_ID(), 'full' ) . '" />';
}
}
@tripflex
tripflex / functions.php
Created Aug 31, 2020
Set candidate_photo as featured image/thumbnail for Resumes when using WP Job Manager Field Editor
View functions.php
<?php
add_action( 'resume_manager_update_resume_data', 'smyles_set_featured_image_from_candidate_photo', 9999, 2 );
function smyles_set_featured_image_from_candidate_photo( $resume_id, $values ){
if( isset( $values['resume_fields'] ) ){
$candidate_photo = isset( $values['resume_fields']['candidate_photo'] ) ? $values['resume_fields']['candidate_photo'] : false;
@tripflex
tripflex / functions.php
Created Aug 21, 2020
Set max file uploads for gallery_images when using WP Job Manager Field Editor
View functions.php
<?php
add_filter( 'submit_job_form_fields', 'smyles_custom_max_images_per_package', 101 );
function smyles_custom_max_images_per_package( $fields ) {
$max_packages = array(
// The key should be the ID of the product (look at the ID when editing the product in the URL bar)
'11111' => array(
// Array key should be the exact meta key
'gallery_images' => 1,
@tripflex
tripflex / functions.php
Created Aug 4, 2020
Change WorkScout "Apply for job" and "Apply For This Job" to say "Login to Apply" when user is not logged in
View functions.php
<?php
add_filter( 'gettext', 'smyles_change_apply_button_text', 10, 3 );
function smyles_change_apply_button_text( $translation, $text, $domain ) {
if ( $text === 'Apply for job' && ! is_user_logged_in() ) {
return __( 'Login to Apply' );
}
You can’t perform that action at this time.