This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fix for keyboard focus states on scroll position or timed based popup implementations | |
// | |
// forces the focus back to the element that was focused prior to popup open | |
// fixes focus bug when faking a click on existing element to bring up a modal window | |
// fixes accessibility issue where the user's focus was changed when the popup shows | |
// | |
/** | |
* Gets keyboard-focusable elements within a specified element | |
* @param {HTMLElement} [element=document] element |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Prerequisites: | |
* (1) All of your Gutenberg block Sass is in its own folder, or somewhere separated from the rest of your Sass. `components/blocks/*` is the location of the Sass in this example. | |
* (2) Your variables, mixins, functions, etc. are separated from the rest of your sass. Mixin/variables/function files DO NOT CONTAIN any styling whatsoever -- just definitions. | |
* (3) Do not use the class wp-block anywhere in your custom Gutenblock templates. | |
* | |
* Steps: | |
* 1. Create a new file, editor-style.scss, alongside your style.scss -- do not use an underscore to start filename as this is not a partial | |
* 2. Import your block Sass, your mixins, variables, and functions, as well as any external libraries, in patterns shown below |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Redirect single of CPT to page | |
*/ | |
if ( ! function_exists('kw_redirect_resource') ) { | |
add_action( 'template_redirect', 'kw_redirect_resource' ); | |
function shnj_redirect_resource() { | |
if ( is_singular( 'CUSTOM_POST_TYPE_NAME' ) ) : | |
//get the url by path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>H1 heading Medium length headline<h1> | |
<h2>H2 heading Medium length headline</h2> | |
<h3>H3 heading Medium length headline</h3> | |
<h3 class="heading--alternative">H3 heading Medium length headline</h3> | |
<h4>H4 heading Medium length headline</h4> | |
<h5>H5 heading Medium length headline</h5> | |
<h6>H6 heading Medium length headline</h6> | |
<a href="#">Hello i am a link</a> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur sapien ut sem auctor, id suscipit orci auctor. Nullam nec consequat magna. Aliquam vulputate condimentum sem vitae imperdiet. Duis dignissim ligula quis ligula aliquam, in dapibus sapien auctor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* All internal links should open in a new window with rel=noopener | |
* | |
*/ | |
if ( ! function_exists( 'force_external_links' ) ) { | |
add_filter('the_content', 'force_external_links'); | |
add_filter('acf_the_content', 'force_external_links'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Check if a WordPress page is "current", i.e. it's the current page or the ancestor of a current page | |
* | |
* @uses is_search() | |
* @uses get_post_type() | |
* @uses site_url() | |
* @uses get_permalink() | |
* @uses get_post_type_object() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get accessible post thumbnail images - fills alt attribute with post title if alt attribute is empty | |
* | |
* @param [type] $id The post ID being called. | |
* @param [type] $size The size of the image to call. Default thumbnail. | |
* | |
* @return void | |
*/ | |
function a11y_images_with_alt( $id, $size = 'thumbnail' ) { | |
$alt = get_post_meta( get_post_thumbnail_id( $id ), '_wp_attachment_image_alt', true ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Ran into an issue with a WP site where I needed to change an ACF select dropdown into a real WordPress taxonomy. Wrote this to move the data from an ACF select to taxonomy. This will create terms from an ACF select (manually, have to get the data from the ACF field editing interface). Then it will go through all posts and apply the new taxonomy term according to the ACF select value that already exists on the post. | |
* | |
* ⚠⚠⚠ WARNING ⚠⚠⚠ | |
* | |
* This is not a professional migration thing. If you use this: | |
* Put into `functions.php` or as your own `mu-plugin` file. | |
* Run on a local installation first. If you can run locally and export your DB back to live, even better. | |
* No idea how it'd perform if you had thousands of ACF fields. It worked OK for me with 250 potential ACF select values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function 8ii010b_scripts() { | |
// this adds your script to all pages on the site | |
wp_enqueue_script( 'custom-8ii010-js', get_template_directory_uri() . '/js/YOUR-JS-FILE.js', array(), '20151215', true ); | |
// this adds your script to all single posts | |
if ( is_singular('post') ) { | |
wp_enqueue_script( 'custom-8ii010-js', get_template_directory_uri() . '/js/YOUR-JS-FILE.js', array(), '20151215', true ); | |
} | |