Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍👦
My son is my everything

Cameron Jones cameronjonesweb

👨‍👦
My son is my everything
View GitHub Profile
View cameronjonesweb-delete-default-options.php
<?php
/**
* Delete the option setting for the default category
*
* @link https://cameronjonesweb.com.au/blog/how-to-remove-the-uncategorised-category-from-wordpress-and-woocommerce
*/
function cameronjonesweb_delete_default_category_option() {
if ( get_option( 'default_category' ) ) {
delete_option( 'default_category' );
}
View gutenberg-colour-scheme.php
<?php
function cameronjonesweb_colour_scheme() {
return array(
array(
'name' => 'White',
'slug' => 'white',
'color' => '#ffffff',
),
array(
View acf-options.php
<?php
function cameronjonesweb_acf_setup() {
acf_add_options_page(
array(
'page_title' => 'Theme Settings',
'menu_slug' => 'cameronjonesweb-theme-settings',
)
);
acf_add_local_field_group(
array(
View wrap-classic-block.php
<?php
function cameronjonesweb_wrap_classic_posts( $block_content, $block ) {
if ( is_null( $block['blockName'] ) && ! empty( trim( $block_content ) ) ) {
$output = '<div class="classic-block">';
$output .= $block_content;
$output .= '</div>';
$block_content = $output;
}
return $block_content;
}
View automatically-enqueue-block-stylesheet.php
<?php
add_filter( 'acf/register_block_type_args', 'cameronjonesweb_automatically_enqueue_block_stylesheet' );
function cameronjonesweb_automatically_enqueue_block_stylesheet( $args ) {
if ( empty( $args['enqueue_style'] ) ) {
$file = get_template_directory_uri() . '/blocks/' . ltrim( $args['name'], 'acf/' ) . '/block.css';
if ( file_exists( str_replace( get_template_directory_uri(), get_template_directory(), $file ) ) ) {
$args['enqueue_style'] = $file;
}
}
@cameronjonesweb
cameronjonesweb / media.js
Created Apr 25, 2020
Upload media to a custom input in the WordPress admin
View media.js
jQuery(document).ready(function($){
var custom_uploader;
var $btn;
$('.image_upload_button').click(function(e) {
@cameronjonesweb
cameronjonesweb / generate-edd-api-keys.php
Last active Feb 19, 2020
Automatically generate EDD API keys for each user
View generate-edd-api-keys.php
<?php
$user_id = 1;
$edd_api = new EDD_API();
$public_key = $edd_api->get_user_public_key( $user_id );
if ( empty( $public_key ) ) {
$edd_api->generate_api_key( $user_id );
}
@cameronjonesweb
cameronjonesweb / gform-field-content-filter.php
Created Feb 16, 2020
Render the_content in a gravity forms field
View gform-field-content-filter.php
<?php
$form_id = 1;
$field_id = 1;
add_filter( "gform_field_content_{$form_id}_{$field_id}", 'gfield_render_the_content', 10, 5 );
function gfield_render_the_content( $content, $field, $value, $lead_id, $form_id ) {
$content = apply_filters( 'the_content', get_the_content() );
return $content;
}
@cameronjonesweb
cameronjonesweb / round-gravity-forms-currency.php
Created Nov 25, 2019
Round currency fields with Gravity Forms
View round-gravity-forms-currency.php
add_filter( 'gform_currencies', 'cameronjonesweb_round_gravity_forms_currencies' );
function cameronjonesweb_round_gravity_forms_currencies( $currencies ) {
foreach ( $currencies as $key => $val ) {
$currencies[ $key ]['decimals'] = 0;
}
return $currencies;
}
View cpt-rewrites.php
<?php
add_action( 'init', 'rewrites' );
add_filter( 'post_type_link', 'filter_post_link', 1, 2 );
function rewrites() {
add_rewrite_tag( '%artist%', '([^/]+)' );
add_rewrite_rule(
'songs/([^/]+)/([^/]+)?$',
'index.php?artist=$matches[1]&songs=$matches[2]',
'top'
You can’t perform that action at this time.