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 | |
| function date_span_filter($start_date, $end_date) { | |
| if ( $start_date ) { | |
| // Dates should both be in a Y-m-d format | |
| $start_calendar_date = date('j F Y', strtotime($start_date)); | |
| if ( ! $end_date ) { | |
| // There is no range. Just return the required start date | |
| $date = $start_calendar_date; | |
| } else { | |
| if ( $start_date == $end_date ) { |
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 | |
| $download_file = get_sub_field('download_file'); | |
| $download_url = $download_file['url']; | |
| $download_path = pathinfo($download_url); | |
| $download_ext = $download_path['extension']; | |
| $download_size = filesize( get_attached_file( $download_file['id'] ) ); | |
| function format_bytes($size, $precision = 2) { | |
| $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 | |
| function get_orientation($image_file, $tolerance = '1.5') { | |
| // First let us determine what kind of file we are dealing with | |
| $path_parts = pathinfo($image_file); | |
| $extension = $path_parts['extension']; | |
| if ( $extension == 'svg' ) { | |
| // Vector svg | |
| $xmlget = simplexml_load_file($image_file); | |
| $xmlattributes = $xmlget->attributes(); | |
| $width = (string) $xmlattributes->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 | |
| // Useful during dev to show order number of fields within acf dashboard list | |
| function acf_field_group_columns($columns) { | |
| $columns['menu_order'] = __('Order'); | |
| return $columns; | |
| } // end function reference_columns | |
| add_filter('manage_edit-acf-field-group_columns', 'acf_field_group_columns', 20); | |
| function acf_field_group_columns_content($column, $post_id) { | |
| switch ($column) { |
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 ( is_archive() ) { | |
| $post_type = get_query_var( 'post_type' ); | |
| $og_url = get_post_type_archive_link( $post_type ); | |
| $og_title = post_type_archive_title('', false); | |
| $page_object = get_page_by_title( $og_title ); | |
| $post_id = $page_object->ID; | |
| } else { | |
| $og_url = get_permalink(); | |
| $og_title = get_the_title(); |
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 | |
| // Simplify the URL for display purposes. Remove http(s) the www and any queries. | |
| function url_simplify( $url ) { | |
| if ( $url ) { | |
| $url_parse = wp_parse_url( $url ); | |
| if( $url_parse ) { | |
| $url_host = $url_parse['host']; | |
| $url_host = str_replace( 'www.','',$url_host ); | |
| $url_simple = $url_host; | |
| if( array_key_exists('path', $url_parse) ) { |
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 ID of the first page using a specific template | |
| function page_id_from_template( $template_name ) { | |
| $args = array( | |
| 'post_type' => 'page', | |
| 'fields' => 'ids', | |
| 'nopaging' => true, | |
| 'meta_key' => '_wp_page_template', | |
| 'meta_value' => $template_name | |
| ); |
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 | |
| // Custom image sizes using Bootstrap 4 breakpoints | |
| // Set here to crop at a 4:3 aspect ratio | |
| add_action( 'after_setup_theme', 'add_image_sizes' ); | |
| function add_image_sizes() { | |
| add_image_size( 'sm', 576, 432, true ); | |
| add_image_size( 'md', 768, 576, true ); | |
| add_image_size( 'lg', 992, 744, true ); | |
| add_image_size( 'xl', 1200, 900, true ); | |
| } |
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
| {% set colours = ['red', 'blue', 'green', 'yellow'] %} | |
| {% for item in services %} | |
| <li class="{{ cycle(colours, loop.index0) }}"> | |
| <h3>{{ item.service_title }}</h3> | |
| </li> | |
| {% endfor %} |