Add a default value to Advanced Custom Fields hidden field

Advanced Custom Fields hidden field does not have a default value input.
Add one by implementing the code below. Personally I was using this to mark a registration form for a particular user type.

<?php
// add default value to hidden field
add_action('acf/render_field_settings/type=hidden', 'tb_hidden_default_render_field_settings');
add_filter('acf/prepare_field/type=hidden', 'tb_hidden_default_prepare_field');
      
function tb_hidden_default_render_field_settings($field){
acf_render_field_setting( $field, array(
    'label'			=> __('Default Value'),
    'instructions'	=> '',
    'name'			=> 'hidden_default',
    'type'			=> 'text',
    'ui'			=> 1,
  ), false);
}
function tb_hidden_default_prepare_field( $field ) {
  if( empty($field['hidden_default']) ) return $field;
  $field['value'] = $field["hidden_default"];
  $field['label'] = '';
  
  return $field;
}

Workaday Reading

When should you be using Web Workers?



"← Back to home When should you be using Web Workers? 2019-06-12 You should always use Web Workers. And in our current landscape of frameworks it’s virtually impossible. Did I get your attention with that? Good. Of course, as with any topic, there is nuance and I will lay that all out."

read »

Save only specific files to stash in git repository

The -m will set the message for the stash and multiple files can be specified.

git stash push -m 'put back on practice-signup-changes' apps/frontend/lib/helper/SignupHelper.php apps/frontend/modules/signup/templates/practiceSuccess.php

Workaday Reading

acf_register_block_type()



"Registers a custom block type in the Gutenberg editor. Blocks are the fundamental element of the Gutenberg editor. WordPress provides many default block types such as paragraph, heading and image. The acf_register_block_type() function can be used to add new block types via PHP."

read »

Workaday Reading

ACF 5.8 – Introducing ACF Blocks for Gutenberg



"There has been a lot of excitement surrounding Gutenberg, the new block-based WordPress editing experience. One of its most compelling features is the ability for developers to create their own custom block types. This opens up an endless array of possibilities for customization."

read »

Workaday Reading

Protect our Git Repos, Stop Foxtrots Now!



"Reading Time: 6 minutes Dancers gearing up to do the Foxtrot First, what is a foxtrot merge? A foxtrot merge is a specific sequence of git commits. A particularly nefarious sequence. Out in the open, in lush open grasslands, the sequence looks like this: But foxtrots are rarely seen in the open."

read »

Workaday Reading

8 Useful JavaScript Tricks



"Each programming language has its own tricks up in its sleeve. Many of them are known to developers, and yet some of them are pretty hackish. In this article, I will show you a couple of tricks I find useful. Some of them I've used in practice and others are the new way of solving old problems."

read »

Run Shortcode in WordPress Excerpts

Add this to your functions.php or your plugin.

add_filter( 'get_the_excerpt', 'shortcode_unautop');
add_filter( 'get_the_excerpt', 'do_shortcode');
add_filter( 'get_the_excerpt', 'do_shortcode', 5 );

Git –assume-unchanged

When installing apps locally some files have data which is unique to your install path or domain. For example I installed our app at EasyRx locally and the yaml setting for the domain used for cookies was tracked by git. I changed the value in my local install but then it showed up as a … Continued

How to convert your latin1 mysql table to utf8

Convert the existing columns content if there are unicode characters saved in non utf8 column: UPDATE `databasename`.`prescription_template_billing_item` SET description = @txt WHERE char_length(description) = LENGTH(@txt := CONVERT(BINARY CONVERT(description USING latin1) USING utf8)); Have MYSQL loop through . all of your tables and columns finding all the necessary columns which have types needing to be converted: … Continued