This file contains hidden or 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
| @mixin colcalc($spacing, $columns) { | |
| // First let us reset any previous margins and clears | |
| // As 2 columns is the first use there's no need to reset, so we make it conditional | |
| @if $columns > 2 { | |
| $previous_columns: $columns - 1; | |
| &:nth-child(#{$previous_columns}n) { | |
| margin-right: $spacing; | |
| } | |
| &:nth-child(#{$previous_columns}n+1) { | |
| clear: none; |
This file contains hidden or 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 | |
| $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); | |
| if ( ! empty( $privacy_policy_page_id ) ) { | |
| $privacy_policy_page_url = get_the_permalink( $privacy_policy_page_id ); | |
| ?> | |
| <a href="<?php echo $privacy_policy_page_url; ?>">Privacy Policy</a> | |
| <?php } ?> |
This file contains hidden or 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 post has any parents | |
| function is_child($post_id) { | |
| $post = get_post($post_id); | |
| $parent = $post->post_parent; | |
| if( $parent != 0 ) { | |
| return true; | |
| } else { | |
| return false; | |
| } |
This file contains hidden or 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 | |
| // Return a neat file size | |
| function nice_file_size($file_url, $precision = 2) { | |
| $nice_file_size = null; | |
| $attachment_id = attachment_url_to_postid($file_url); // Gets ID of file from URL | |
| $file_path = get_attached_file( $attachment_id ); // Gets path using ID | |
| if ( is_writable( $file_path ) ) { // Locally an error is thrown due to file not being writable | |
| $size = filesize( $file_path ); // NB filesize only works with the path to the file NOT a URL | |
| $base = log($size, 1024); | |
| $suffixes = array('', 'KB', 'MB', 'GG', 'TB'); |
This file contains hidden or 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 | |
| // Setting reserved image sizes on theme activation | |
| add_action( 'after_switch_theme', 'enforce_image_size_options' ); | |
| function enforce_image_size_options() { | |
| update_option( 'thumbnail_size_w', 160 ); | |
| update_option( 'thumbnail_size_h', 160 ); | |
| update_option( 'thumbnail_crop', 1 ); | |
| update_option( 'medium_size_w', 660 ); | |
| update_option( 'medium_size_h', 440 ); | |
| update_option( 'medium_crop', 1 ); |
This file contains hidden or 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
| const { dispatchAction } = require('./dispatchAction'); | |
| exports.configuration = [{ | |
| type: 'button', | |
| label: '#', | |
| insertString: '#', | |
| backgroundColor: '#803FF6' | |
| }, { | |
| type: 'button', | |
| label: '#FFF', |
This file contains hidden or 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 | |
| // If the post does not have a featured image | |
| function feat_img_fallback($post_id, $image_size = 'thumbnail') { | |
| if ( has_post_thumbnail($post_id) ) { | |
| $image_id = get_post_thumbnail_id($post_id); | |
| $image_src = wp_get_attachment_image_src($image_id, $image_size); | |
| $image_url = $image_src[0]; | |
| } else { | |
| $image_url = get_bloginfo('template_directory') . '/images/placeholder.png'; | |
| } |
This file contains hidden or 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 | |
| // Works with thumbnail, medium, large and full | |
| function has_thumbnail_size($size, $post_id) { | |
| if ( has_post_thumbnail($post_id) ) { | |
| $image_id = get_post_thumbnail_id($post_id); | |
| $image_attributes = wp_get_attachment_image_src($image_id, 'full'); | |
| $image_width = $image_attributes[1]; | |
| $image_height = $image_attributes[2]; | |
| $media_width = $size . '_size_w'; | |
| $media_width = get_option($media_width); |
This file contains hidden or 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 | |
| // If the post does not have a featured image | |
| function feat_img_fallback($image_size, $post_id, $alt) { | |
| if ( has_post_thumbnail($post_id) ) { | |
| $image_id = get_post_thumbnail_id($post_id); | |
| $image_src = wp_get_attachment_image_src($image_id, $image_size); | |
| $image_url = $image_src[0]; | |
| $image = '<img src="' . $image_url . '" alt="' . $alt . '">'; | |
| } else { | |
| $image_width = $image_size . '_size_w'; |
This file contains hidden or 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 | |
| // Get the URL of the first page using a specific template | |
| function url_from_template( $template_name ) { | |
| $args = array( | |
| 'post_type' => 'page', | |
| 'fields' => 'ids', | |
| 'nopaging' => true, | |
| 'meta_key' => '_wp_page_template', | |
| 'meta_value' => $template_name | |
| ); |