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 / gist:b61c1cf65103daf7cdca
Created June 11, 2015 21:40
WordPress wp_get_object_terms convert $taxonomies SQL-formatted (comma-separated and quoted) to array
// Because get_object_terms filter was not included until WP 4.2+ we have to use wp_get_object_terms for backwards compatibility.
// Unfortunately this means taxonomies are passed like this: ( 'resume_category', 'resume_skill' ), so we have to remove the quotes,
// and then use explode to convert it into an array of taxonomies.
$tax_array = explode( ", ", str_replace( "'", "", $taxonomies ) );
@tripflex
tripflex / functions.php
Created June 17, 2015 22:58
Remove specific products from Products 3rd Party Plugin dropdown in Submit Listing page
add_filter( 'submit_job_form_fields', 'heynwa_custom_job_fields', 999999999999 );
function heynwa_custom_job_fields( $fields ) {
if ( isset( $fields[ 'company' ][ 'products' ] ) ){
if( isset( $fields['company']['products']['options'] ) && ! empty( $fields['company']['products']['options'] ) ){
$options = $fields['company']['products']['options'];
// To find out the specific ID of the "products" you can either add &debug to the end of the URL when viewing the company fields
@tripflex
tripflex / gist:dc063f2d3101f0d5388c
Created June 24, 2015 00:34
Easy FB Like Box execute shortcode output using PHP
<?php
$facebook_url = get_custom_field('fb_lbox_custom');
if( $facebook_url ) echo do_shortcode( '[easy-fb-like-box url="' . $facebook_url . '" width="370" height="430" theme="light" faces="true" header="false" posts="true" border="false"]' );
@tripflex
tripflex / gist:ea0bfa7525c1808e3d0a
Last active August 29, 2015 14:24
Auto populate candidate_email meta key with current user's email address
<?php
// !!! Don't add the <?php above if you're adding this to the end of your functions.php file !!!
add_filter( 'field_editor_auto_populate_candidate_email', 'auto_populate_candidate_email_field' );
function auto_populate_candidate_email_field( $field_value ){
// If field value is already set (means it was pulled from user meta) then return that value
// or if user is not logged in return whatever $field_value is already set as
if( ! empty( $field_value ) || ! is_user_logged_in() ) return $field_value;
@tripflex
tripflex / functions.php
Last active January 26, 2025 09:22
How to remove default company fields from WP Job Manager (this example for Listify)
<?php
// Add your own function to filter the fields
add_filter( 'submit_job_form_fields', 'remove_listify_submit_job_form_fields', 9999999999 );
// This is your function which takes the fields, modifies them, and returns them
// You can see the fields which can be changed here: https://github.com/mikejolley/WP-Job-Manager/blob/master/includes/forms/class-wp-job-manager-form-submit-job.php
function remove_listify_submit_job_form_fields( $fields ) {
if( ! isset( $fields['company'] ) ) return $fields;
@tripflex
tripflex / image.php
Created July 27, 2015 22:31
Show image based on field selection
<?php
$is_veteran = get_custom_field( 'is_veteran' );
// Assuming the full URL to the image is //domain.com/banners/veteran.png
// if the value of the selection is "veteran" then it would form that full URL
if( ! empty( $is_veteran ) ){
echo "<img src=\"//domain.com/banners/{$is_veteran}.png\"></a>";
}
@tripflex
tripflex / remove-span-tags-from-html.php
Last active December 3, 2021 10:26
Remove a specific span tag from HTML while preserving/keeping the inside content using PHP and DOMDocument
<?php
$content = '<span style="font-family: helvetica; font-size: 12pt;"><div>asdf</div><span>TWO</span>Business owners are fearful of leading. They would rather follow the leader than embrace a bold move that challenges their confidence. </span>';
$dom = new DOMDocument();
// Use LIBXML for preventing output of doctype, <html>, and <body> tags
$dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$xpath = new DOMXPath($dom);
@tripflex
tripflex / style.css
Created August 19, 2015 22:35
[Listify Theme] - Change field editor <li> display style to match Listify (circles with checks)
#jmfe-wrap-METAKEY {
list-style: none;
display: inline-block;
margin-right: 8px;
}
#jmfe-custom-METAKEY:before {
display: inline-block;
font-family: Ionicons;
speak: none;
@tripflex
tripflex / tunlr
Last active August 26, 2015 01:04 — forked from phiggins42/tunlr
tunlr!
#!/usr/bin/env node
/*
tunlr - simple SSH tunnel management
usage: tunlr [options] [command]
options:
-q quiet. suppress console output.
@tripflex
tripflex / get_theme_name.php
Created September 10, 2015 18:06
Method for WordPress to get theme name based on parent theme
<?php
/**
* Get current site Theme Name
*
* This method will get the theme name by default from parent theme, and
* if not set it will return the textdomain.
*
*
* @since 1.3.5