Skip to content

Instantly share code, notes, and snippets.

View khleomix's full-sized avatar

JC Palmes khleomix

View GitHub Profile
$header_graphic = get_field( 'header_graphic' );
highlight_string("<?php\n\$header_graphic =\n" . var_export($header_graphic, true) . ";\n?>");
@khleomix
khleomix / editor.css
Created January 17, 2022 16:29
ACF Block Style Reset - CSS
/* ----- ACF Block Style Reset -------------------- */
body .acf-block-fields,
.edit-post-sidebar {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
font-size: 13px;
line-height: 1.4em;
}
.acf-field input[type="text"],
.acf-field input[type="password"],
@khleomix
khleomix / homepage-block-template.php
Last active February 16, 2022 20:33
Block template function for the homepage.
<?php
/**
* Block template for Homepage
*
* @author JC Palmes
*/
function homepage_block_template() {
$current_id = isset( $_GET['post'] ) ? $_GET['post'] : '';
$current_post = isset( $_GET['post'] ) ? get_post($current_id) : '';
@khleomix
khleomix / _admin.scss
Created February 7, 2022 17:53
ACF Block Style Reset - SCSS
body .acf-block-fields,
.edit-post-sidebar {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
font-size: 13px;
line-height: 1.4em;
.acf-field {
input[type="text"],
input[type="password"],
@khleomix
khleomix / hooks.php
Last active February 16, 2022 20:31
ACF Custom Block Category
<?php
/**
* Adds a Custom Block category to the Gutenberg category list.
* Use in acf_register_block_type ( [ 'category' => 'custom-blocks' ] ).
*
* @param array $categories The existing categories.
* @param object $post The current post.
* @return array The updated array of categories.
* @author JC Palmes
*/
@khleomix
khleomix / allowed-blocks.php
Last active February 16, 2022 20:30
Disable/Allow core Gutenberg Blocks
<?php
/**
* Modify the available blocks for the Gutenberg editor
*
*/
namespace Theme\Theme\Blocks;
use \WP_Block_Type_Registry;
@khleomix
khleomix / acf.php
Last active February 16, 2022 22:10
Load icon files dynamically as ACF select options
<?php
/**
* Load icons dynamically into the `icon_picker` select field.
*
* @param array $field field options.
* @return array new field choices.
*
* @author JC Palmes
*/
function acf_load_icon_picker_field_choices( $field ) {
@khleomix
khleomix / return-trim-the-content.php
Created February 25, 2022 17:17
Limit the content length and retain markup
<?php
/**
* Limit the content length.
*
* @author JC Palmes
*
* @param array $args Parameters include length and more.
*
* @return string The content.
*/
@khleomix
khleomix / vimeo-video.php
Last active March 4, 2022 16:48
Vimeo Background
<?php
/**
* Shortcode to display Vimeo video.
*
* @param array $args Parameters include vimeo_id and more.
* @author JC Palmes
*/
function embed_vimeo_video( $args = [] ) {
// Set defaults.
@khleomix
khleomix / wistia-player.php
Created March 4, 2022 19:51
Wistia Background Video
<?php
/**
* MODULE - Wistia Player.
*
* Autoplay nuted Wistia Video in the background and remove from DOM when done.
*/
/**
* Accepts 'class','wistia_id'.
*/