Skip to content

Instantly share code, notes, and snippets.

View j-mccarthy's full-sized avatar
💭
passing by

John McCarthy j-mccarthy

💭
passing by
  • flowethic
  • United Kingdom
View GitHub Profile
@j-mccarthy
j-mccarthy / valid-canadian-postal-code.php
Created May 11, 2020 04:06 — forked from james2doyle/valid-canadian-postal-code.php
Simple regex for Canadian postal codes in PHP
<?php
// test with: `php valid-canadian-postal-code.php`
$expression = '/^([a-zA-Z]\d[a-zA-Z])\ {0,1}(\d[a-zA-Z]\d)$/';
// lower, no space
$valid = (bool)preg_match($expression, 'k0a3m0');
var_dump($valid);
/**
* Remove thumbnail and title from specific product page
*/
function yourthemename_wc_remove_thumbnail_title_from_product() {
// add your product id here
if ( ! is_product( '475' ) ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
}
}
<?php
/**
* Template section where the event posts are displayed.
*/
?>
<aside class="events--filter">
<?php echo facetwp_display( 'facet', 'audience' ); ?>
</aside>
/**
* Query used to pull in post data for custom data array
*/
function get_all_events() {
$args = array(
// Type & Status Parameters
'post_type' => 'event',
'post_status' => 'published',
<?php
/**
* Customizer handler.
*
* @package jmccarthy\modularTheme\Customizer;
* @since 1.0.0
* @author jmccarthy
*
*/
namespace jmccarthy\modularTheme\Customizer;
/* Good Reviews */
/** Home page column layout - To be worked on */
.homepage-testimonial-wrap {
background-color: #f1f4f0;
padding-top: 3em;
margin-top: 4em;
}
.widget_grfwp_widget_reviews h2 {
text-align: center;
}
/** MailChimp for WordPress */
.mc4wp-form-fields {
max-width: 690px;
margin: 0 auto;
}
.mc4wp-form-fields label {
margin-right: 1em;
margin-left: 1em;
color: #fff;
}
@j-mccarthy
j-mccarthy / register_cmb2_metabox_after_title.php
Last active December 15, 2017 02:27
register cmb2 metabox after title on admin page edit screen
<?php
add_action( 'cmb2_init', 'source_banner_metabox' );
function source_banner_metabox() {
$prefix = '_source_demo_';
$cmb_demo = new_cmb2_box( array(
'id' => $prefix . 'metabox',
<?php
/**
* Source Genesis Child Theme
*
* @package Source
* @since 0.0.1
* @copyright Copyright (c) 2014, Contributors to the Source project
* @license GPL-2.0+
*/
@j-mccarthy
j-mccarthy / get_tax_meta.php
Created February 12, 2015 19:37
Tax meta class - repeater field
<?php
// Fields set-up
$repeater_fields[] = $camplight_event_meta->addText('event_info',array('name'=> 'Event specific info points '),true);
$my_meta->addRepeaterBlock('event_info_re_',array('inline' => true, 'name' => 'Repeater Block ','fields' => $repeater_fields));
// Front end template
$repeater_array = get_tax_meta( $not_sure_what_this_is, 'event_info_re_', true);
foreach($repeater_array as $arr) {