Skip to content

Instantly share code, notes, and snippets.

View morganisok's full-sized avatar

Morgan Kay morganisok

View GitHub Profile
@morganisok
morganisok / vertical-alignment.json
Created February 17, 2022 23:32
Form with vertical alignment problems
{"0":{"title":"Vertical Alignment","description":"","labelPlacement":"top_label","descriptionPlacement":"below","button":{"type":"text","text":"Submit","imageUrl":"","width":"full","location":"inline","conditionalLogic":null,"id":"submit","layoutGridColumnSpan":3},"fields":[{"type":"address","id":8,"formId":153,"label":"Address","adminLabel":"","isRequired":false,"size":"large","errorMessage":"","visibility":"visible","addressType":"international","inputs":[{"id":"8.1","label":"Street Address","name":"","autocompleteAttribute":"address-line1"},{"id":"8.2","label":"Address Line 2","name":"","autocompleteAttribute":"address-line2"},{"id":"8.3","label":"City","name":"","autocompleteAttribute":"address-level2"},{"id":"8.4","label":"State \/ Province","name":"","autocompleteAttribute":"address-level1"},{"id":"8.5","label":"ZIP \/ Postal Code","name":"","autocompleteAttribute":"postal-code"},{"id":"8.6","label":"Country","name":"","autocompleteAttribute":"country-name"}],"description":"","allowsPrepopulate":false,"
<?php
add_filter( 'gform_form_settings_fields', function( $fields ) {
$test_group = [
[
'title' => 'Example Fields',
'fields' => [
[
'name' => 'input',
@morganisok
morganisok / All settings fields
Last active July 23, 2020 17:28
All GF settings fields
// Temporary test fields - will be deleted before merge
array(
'title' => esc_html__( 'Test all the fields', 'gravityforms' ),
'fields' => array(
array(
'name' => 'text',
'type' => 'text',
'label' => 'Text',
'description' => 'Here is a description of this text field.',
'feedback_callback' => function( $field, $value ) {
@morganisok
morganisok / gravityforms-export-2020-05-28.json
Created May 28, 2020 19:09
autocomplete attributes test form
{"0":{"title":"#16 autocomplete","description":"","labelPlacement":"top_label","descriptionPlacement":"below","button":{"type":"text","text":"Submit","imageUrl":""},"fields":[{"type":"text","id":1,"label":"Single Line Text","adminLabel":"","isRequired":false,"size":"medium","errorMessage":"","visibility":"visible","inputs":null,"formId":15,"description":"","allowsPrepopulate":false,"inputMask":false,"inputMaskValue":"","inputMaskIsCustom":false,"maxLength":"","inputType":"","labelPlacement":"","descriptionPlacement":"","subLabelPlacement":"","placeholder":"","cssClass":"","inputName":"","noDuplicates":false,"defaultValue":"","choices":"","conditionalLogic":"","productField":"","enablePasswordInput":"","multipleFiles":false,"maxFiles":"","calculationFormula":"","calculationRounding":"","enableCalculation":"","disableQuantity":false,"displayAllCategories":false,"useRichTextEditor":false,"fields":"","displayOnly":"","autocompleteAttribute":"given-name, name","enableAutocomplete":true,"layoutGroupId":"f294117d"},
@morganisok
morganisok / customizer.php
Created March 9, 2019 00:11
Customizer + Gutenberg + SASS color schemes
/**
* Add the Color Options section to the customizer
*
* @param $wp_customize
*/
function cgs_color_options_section( $wp_customize ) {
$wp_customize->add_section(
'cgs_color_options',
array(
'title' => esc_html__( 'Theme Color Scheme', 'cgs' ),
@morganisok
morganisok / gist:736252d41c7f81776ff0c992dddef2e0
Created December 1, 2016 23:49
Display clock-in/out times on master schedule
add_filter( 'wpaesm_single_shift_cell', 'corne768709_show_clockin_clockout', 10, 4 );
function corne768709_show_clockin_clockout( $shift_text, $priority, $shift_id, $employee ) {
$clock_times = 'Worked: ';
$clockin = get_post_meta( $shift_id, '_wpaesm_clockin', true );
if( '' !== $clockin ) {
$clock_times .= $clockin;
}
@morganisok
morganisok / gist:89fcf7d53cfdec56498d7035b1c66865
Created September 14, 2016 02:56
Prevent employees from seeing each other's shifts
add_filter( 'the_content', 'asdf_only_employees_see_shifts' );
function asdf_only_employees_see_shifts( $content ) {
if( is_singular( 'shift' ) && is_main_query() && !is_admin() ) {
$current_user = get_current_user_id();
$users = get_users( array(
'connected_type' => 'shifts_to_employees',
'connected_items' => get_the_id(),
add_filter( 'the_content', 'fireresource_show_available_employees' );
function fireresource_show_available_employees( $content ) {
if( is_singular( 'shift' ) && is_main_query() && !is_admin() ) {
$available_employees = get_post_meta( get_the_id(), '_wpaesm_shiftnotes', true );
if( $available_employees ) {
$new_content = '<p><strong>Available Employees:</strong>' . $available_employees . '</p>';
}
$content = $new_content . $content;
@morganisok
morganisok / gist:18e65878f000b1bd9f55637a0f43cff6
Created July 20, 2016 22:11
Cron job to make Employee Scheduler send shift reminders
<?php
// Scheduled Action Hook
function employee_scheduler_check_for_reminder( ) {
// get tomorrow's date in the correct format
$tomorrow = date( 'F j, Y', strtotime( '+1 day', date() ) );
// find all shifts scheduled for tomorrow
$args = array(
'post_type' => 'shift',
'meta_query' => array(
@morganisok
morganisok / gist:2edd0ec21722eda4f25ad8bd51d5ba40
Created June 15, 2016 20:00
Add a "Tweet This" link to blockquotes in WordPress
/**
* At the end of every blockquote, include a link to tweet the quote
*
* @param $content
*
* @return mixed
*/
function myprefix_add_twitter_link_to_blockquote( $content ) {
$content = preg_replace( '#(<blockquote><p>)(.*)(</p></blockquote>)#m', '$1 $2 <a href="http://twitter.com/intent/tweet?status=$2 via @twitterusername ' . get_the_permalink() . '" class="genericon genericon-twitter" target="_blank">Tweet This</a> $3', $content );