Skip to content

Instantly share code, notes, and snippets.

@momofone
momofone / functions.php
Created January 16, 2024 04:24
Format date for integration into Salesforce
<?php
add_filter( 'gform_save_field_value', 'jmd_date_format', 10, 4 );
function jmd_date_format( $value, $entry, $field, $form ) {
$fields = [
6 => 'm/d/Y',
22 => 'm/d/Y, h:i A'
];
<?php
// Usage: [recent_listings type="event" range="today" text="events added today"]
// Range examples: today, 3 days ago, 2 weeks ago, 1 week ago, 1 month ago (for all possible formats see: https://www.php.net/manual/en/datetime.formats.relative.php)
add_shortcode( 'recent_listings', 'jmd_count_recent' );
function jmd_count_recent( $atts ) {
$args=shortcode_atts( array (
'type' => 'event',
'range' => 'today',
'text' => ''
), $atts );
@momofone
momofone / functions.php
Created July 12, 2019 10:26
Runs on init. [Utility] remove once run.
<?php
add_action('init', 'jmd_phone_field_format');
function jmd_phone_field_format(){
$args = array(
'post_type' => 'job_listing',
'post_status' => 'publish',
'posts_per_page' => -1
@momofone
momofone / functions.php
Last active July 12, 2019 05:00
Add this code to functions.php in the child theme.
add_action('admin_enqueue_scripts', 'custom_admin_scripts' );
function custom_admin_scripts() {
global $pagenow;
if ( 'post.php' === $pagenow && isset($_GET['post']) && 'job_listing' === get_post_type( $_GET['post'] ) ) {
wp_enqueue_script( 'jquery-mask', get_stylesheet_directory_uri() .'/js/jquery.mask.js' , array('jquery'), null, true );
}
}
@momofone
momofone / inputmask.txt
Last active July 9, 2019 05:31
Phone number inputmask for users entering telephone numbers under 'Add Listing' (admins can override in backend if needed)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.10/jquery.mask.js"></script>
<script>
jQuery(document).ready(function($) {
$("#job_phone").mask("(999) 999-9999");
});
</script>
@momofone
momofone / functions.php
Created June 17, 2019 19:29
Fetch the listing author's others listings
<?php
// author posts (rename buddypress.js -> author.js and add to child theme in js directory)
add_shortcode( 'seller_posts', 'ml_author_posts' );
function ml_author_posts() {
if( 'job_listing' != get_post_type( $post_id ) ) {
return;
@momofone
momofone / create-etp-ticket.php
Created June 2, 2019 01:17
Create ETP Ticket Programmatically
<?php
Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance()->ticket_add( $event_id, [
'ticket_name' => 'Test ticket ' . uniqid(),
'ticket_provider' => 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main',
'ticket_price' => '100',
'tribe_ticket' => [
'mode' => 'global',
'event_capacity' => '100',
'capacity' => ''
],
@momofone
momofone / etp-mylisting.php
Last active May 8, 2021 09:21
Event Tickets Plus ticket ordering form into Mylisting Listing
<?php // <-- Omit this PHP tag prior to adding to functions.php
/* Re-hook WooTickets form - add to functions.php in Mylisting child theme */
add_action ( 'init', 'tribe_rehook_tickets_form' );
function tribe_rehook_tickets_form ( ) {
if ( ! class_exists('Tribe__Tickets_Plus__Commerce__WooCommerce__Main') ) return;
@momofone
momofone / products_menu.php
Created May 26, 2019 06:17
Woocommerce MA
<?php
add_filter ( 'woocommerce_account_menu_items', 'gmh_purchased_products_link', 40 );
add_action( 'init', 'gmh_add_products_endpoint' );
add_action( 'woocommerce_account_purchased-products_endpoint', 'gmh_populate_products_page' );
function gmh_purchased_products_link( $menu_links ){
return array_slice( $menu_links, 0, 2, true )
+ array( 'purchased-products' => 'Purchased Products' )
+ array_slice( $menu_links, 2, NULL, true );
function shopper_list_found_print ($query_args) {
$query_args = array (
'post_type' => 'shopper',
'tax_query' => array(
array(
'taxonomy' => 'shopper_categories',
'field' => 'slug',
'terms' => array('found'),