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 / functions.php
Last active September 22, 2023 17:39
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 / functions.php
Created September 7, 2023 22:22
Disable CSV multi field output on WorkScout Overview Area with WP Job Manager Field Editor
<?php
add_filter( 'field_editor_workscout_overview_output_csv', '__return_false' );
@tripflex
tripflex / functions.php
Created September 2, 2023 19:55
WP Job Manager Keywords Search Disregard Order of Terms (untested)
<?php
function smyles_custom_posts_search($search, $wp_query) {
global $wpdb;
if (empty($search)) {
return $search; // skip processing - no search term in query
}
$q = $wp_query->query_vars;
@tripflex
tripflex / functions.php
Last active August 13, 2023 18:16
Programmatically create a WooCommerce Subscription and associated WooCommerce Order
<?php
public function give_user_subscription( $product, $user_id, $note = '' ){
// First make sure all required functions and classes exist
if( ! function_exists( 'wc_create_order' ) || ! function_exists( 'wcs_create_subscription' ) || ! class_exists( 'WC_Subscriptions_Product' ) ){
return false;
}
$order = wc_create_order( array( 'customer_id' => $user_id ) );
@tripflex
tripflex / functions.php
Last active June 15, 2023 21:07
Set field default value based on selected package when using WP Job Manager Field Editor
<?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
Last active June 14, 2023 20:31
WP Job Manager Resumes redirect after Resume Submission (or show apply if creating for application) when using WP Job Manager Field Editor
<?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
tripflex / functions.php
Created August 24, 2021 00:09
Remove specific fields from submit form based on current user role when using WP Job Manager Field Editor
<?php
add_filter( 'submit_job_form_fields', 'smyles_remove_fields_by_user_role', 999999999999 );
function smyles_remove_fields_by_user_role( $fields ){
$fields_to_remove = array( 'job_salary', 'some_other_meta_key' );
$user = wp_get_current_user();
if ( in_array( 'employer', (array) $user->roles ) ) {
@tripflex
tripflex / leaflet-clusters.css
Created May 18, 2023 19:20
Leaflet Marker Cluster Default Colors
.marker-cluster-small {
background-color: rgba(181,226,140,.6)
}
.marker-cluster-small div {
background-color: rgba(110,204,57,.6)
}
.marker-cluster-medium {
background-color: rgba(241,211,87,.6)
@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
@tripflex
tripflex / functions.php
Created January 22, 2019 17:22
Redirect to specific page after a new job application has been submitted when using WP Job Manager Field Editor (READ COMMENTS!!)
<?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 (https://wpjobmanager.com/document/template-overrides/)