Instantly share code, notes, and snippets.

in the zone

Myles McNamara tripflex

View GitHub Profile
tripflex / functions.php
Created Feb 22, 2019
Set user role to employer when job submitted using WP Job Manager Field Editor
View functions.php
add_action( 'job_manager_job_submitted', 'smyles_set_user_as_employer_on_submit' );
function smyles_set_user_as_employer_on_submit(){
if( $user_id = get_current_user_id() ){
$user = new WP_User( $user_id );
if( ! in_array( 'employer', (array) $user->roles ) ){
// You can add the role (keeping subscriber or other roles)
tripflex / functions.php
Last active Feb 19, 2019
StackOverflow WordPress User Profile Dynamic Child Taxonomy Dropdown Example
View functions.php
function slcustom_user_profile_fields( $user ){
$categories = smyles_get_taxonomy_hierarchy( 'project_category' );
$parent_category = $user->parent_category;
$child_category = $user->child_category;
// $parent_category = 52; // used for testing
// $child_category = 82; // used for testing
$parent_has_children = ! empty( $parent_category ) && $categories[ $parent_category ] && ! empty( $categories[ $parent_category ]->children );
// Creative way to use wp_localize_script which creates a JS variable from array
tripflex / DeviceManager.ts
Last active Feb 9, 2019
Google Core IoT checkDeviceOnline/isDeviceOnline - Check if a device is online using Firebase Function, parsing timestamps or using iot commands
View DeviceManager.ts
const { google } = require('googleapis')
interface Credential { };
interface Device {
id: string;
name?: string;
readonly numId?: string;
credentials: Credential[];
"config": any[];
"lastHeartbeatTime": string;
tripflex / functions.php
Created Feb 8, 2019
Output FontAwesome icon instead of field value when using WP Job Manager Field Editor
View functions.php
// ^ there should only be one of these at the top of your child theme's functions.php file
// Syntax for filter is field_editor_output_as_value_METAKEY (replacing METAKEY with the actual meta key)
// MAKE SURE YOU REPLACE "METAKEY" below to match the meta key of the field you want to use this for!
add_filter( 'field_editor_output_as_value_METAKEY', 'smyles_output_font_awesome_icon_for_value', 10, 4 );
function smyles_output_font_awesome_icon_for_value( $field_value, $meta_key, $listing_id, $args ){
$field_value = esc_attr( $field_value );
tripflex / functions.php
Last active Feb 8, 2019
Add additional Structured Data to WP Job Manager when using WP Job Manager Field Editor (baseSalary in this example)
View functions.php
add_filter( 'wpjm_get_job_listing_structured_data', 'smyles_add_field_to_job_structured_data', 10, 2 );
* Add baseSalary to Structured Data
* This is just an EXAMPLE of how to set this up, it's up to you to match the correct format required,
* and to determine what fields to use, and how to set it up based on your site.
tripflex / functions.php
Created Jan 22, 2019
Redirect to specific page after a new job application has been submitted when using WP Job Manager Field Editor (READ COMMENTS!!)
View functions.php
add_filter( 'new_job_application', 'smyles_redirect_after_new_job_application', 10, 2 );
function smyles_redirect_after_new_job_application( $application_id, $job_id ) {
// You must manually input the URL to redirect to below, currently there is no way to pull this value as it is not
// saved in any settings or configurations
// This also does not show any kind of notification to the user that their application has been submitted.
// It is recommended that you instead use a template override (
tripflex / functions.php
Created Jan 21, 2019
Remove sMyles Licensing menu item and page (WARNING! YOU WILL NOT BE ABLE TO ACTIVE BY REMOVING THIS!)
View functions.php
function smyles_remove_smyles_licensing_menu_page() {
$page = remove_submenu_page( 'index.php', 'smyles-licenses' );
add_action( 'admin_menu', 'smyles_remove_smyles_licensing_menu_page', 999 );
View jquery.maskMoney.js
* jquery-maskmoney - v3.1.1
* jQuery plugin to mask data entry in the input text in the form of money (currency)
* Made by Diego Plentz
* Under MIT License
(function ($) {
"use strict";
tripflex / functions.php
Last active Feb 11, 2019
WP Job Manager Resumes redirect after Resume Submission (or show apply if creating for application) when using WP Job Manager Field Editor
View functions.php
add_filter( 'submit_resume_steps', 'replace_resume_done_with_redirect' );
function replace_resume_done_with_redirect( $steps ) {
$steps['done'] = array(
'priority' => 30,
'handler' => function() {
do_action( 'resume_manager_resume_submitted', WP_Resume_Manager_Form_Submit_Resume::instance()->get_resume_id() );
$job_id = WP_Resume_Manager_Form_Submit_Resume::instance()->get_job_id();
tripflex / DialogLoader.vue
Last active Feb 11, 2019
Vuetify Dialog Loader Component (with SnackBar) component that can be used locally or globally ( )
View DialogLoader.vue
<!-- Using hide-overlay below allows for clicking while progress showing-->
v-bind:style="{ zIndex: options.zIndex }"