Skip to content

Instantly share code, notes, and snippets.

View pbearne's full-sized avatar

Paul Bearne pbearne

View GitHub Profile
@pbearne
pbearne / performance-conditional-options.php
Last active December 1, 2023 19:21
experimentally caching of the needed options per page
<?php
class CacheOptionPerPage {
private static $conditional_options_context;
private static $alloptions_names = array();
private static $alloptions_used = array();
private static $current_context;
add_filter( 'matador_jobs_pro_jobs_xml_jobboost_segments_remap', static function ( $segments ) {
$segments[19] = $segments[19] + array(
'cccountancy',
'celastingadvies',
'consultancy finance',
'corporate finance',
'finance & control'
);
$segments[20] = $segments[20] + array( 'financieel / administratief' . 'officemanagement', 'salarisadministratie' );
@pbearne
pbearne / matador_variable_job_taxonomies.php
Last active June 1, 2021 12:37
matador_variable_job_taxonomies example
add_filter( 'matador_variable_job_taxonomies', function( $taxonomies ) {
$taxonomies['city'] = array(
'key' => 'city',
'single' => _x( 'City', 'Job City Singular Name.', 'matador-jobs' ),
'plural' => _x( 'Cities', 'Job Cities Plural Name.', 'matador-jobs' ),
// 'slug' => matador\Matador::setting( 'taxonomy_slug_cities' ) ?: 'matador-cities', // Add a slug in you wich to contoll slug otherwise the it will be set to matador-{slug}
// 'args' => array( // yu can add args to contol now the taxonomy is disaplied in the WP admin
// 'show_admin_column' => true,
// 'show_in_menu' => true,
// 'show_in_nav_menus' => true,
add_action( 'init', function (){
if( isset( $_REQUEST['count_terms'] ) ){
$update_taxonomies = get_taxonomies(['object_type' => ['matador-job-listings']]);
foreach ($update_taxonomies as $update_taxonomy) {
$get_terms_args = array(
'taxonomy' => $update_taxonomy,
'fields' => 'ids',
'hide_empty' => false,
);
$update_terms = get_terms($get_terms_args);
add_filter('matador_template_button_classes', 'add_theme_button_classes');
function add_theme_button_classes( $classes ){
// add the classes used by your theme to the default Matador classes
return $classes . ' btn btn-primary btn-block';
}
@pbearne
pbearne / gist:16d4462762f96318d1f2082d3b79ad44
Last active November 9, 2023 22:15
re-order matador application form
add_filter( 'matador_application_form_args', function( $args ) {
$args['fields'] = matador_jobs_moveElementInArray( $args['fields'], 'mobile', array_search('phone', array_keys( $fields ) ) + 1 );
return $args;
}, 99 );
function matador_jobs_moveElementInArray($array, $toMove, $targetIndex) {
function mdocs_example_matador_bullhorn_import_fields( $fields ) {
$field_to_add = [
'customText10' => [ // Name of field per Bullhorn Field Mappings (not its label)
'name' => 'customText10', // Set name for meta when 'saveas' is 'meta'.
'type' => 'string', // Specify type for sanitization, default 'type'
'saveas' => 'meta', // Options are 'core', 'meta', 'custom'. Default 'custom'
],
];
return array_merge( $fields, $field_to_add );
}
@pbearne
pbearne / custom_schedule.php
Created September 23, 2020 14:35
Set Recurrence of Scheduled Matador Jobs Events
/**
* Customize Matador: Set Recurrence of Scheduled Events
*
* This function sets the recurrence of the Matador WP Cron from 'hourly'
* to the returned value. Warning: returned value must exist in the WordPress
* schedules array. Default values in the WP Schedules Array are 'hourly',
* 'twicedaily', and 'daily'. Example function uses a non-standard schedule,
* which will need to be registered in a separate function. Also, Matador Software
* provides this method as-is and will not support sites that run schedules at fewer
* than once per hour. Running more regularly will risk exceeding daily rate limits
@pbearne
pbearne / matador_applicant_candidate_privacy_consent_object
Created August 31, 2020 16:40
Filter example matador_applicant_candidate_privacy_consent_object
@pbearne
pbearne / block.js
Last active March 15, 2024 11:42
code to force server-side Gutenberg block to reload on a change to a Tax
/**
* BLOCK: serverside block that changes on page tax
*
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
*/
// Import CSS.
import './editor.scss';
import './style.scss';