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 | |
| // A filter function to remove certain terms or categories | |
| function categories_filtered( $post_id, $term_slug ) { | |
| $category_objects = null; | |
| $categories = get_the_category( $post_id ); // Get the categories assigned to the post | |
| if ( ! empty( $categories ) ) { | |
| $category_ids = wp_list_pluck( $categories, 'term_id' ); // Convert list into array of cat IDs | |
| $excluded = get_category_by_slug( $term_slug ); // Get category object of term to be excluded | |
| $excluded_id = $excluded->term_id; // Get the ID of the excluded term | |
| $key = array_search( $excluded_id, $category_ids ); // Now get the array key of the excluded category |
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 vimeo_thumbnail( $video_embed, $referer_url, $width ) { | |
| if( strpos($video_embed, 'vimeo') !== false ) { | |
| preg_match('/src="(.+?)"/', $video_embed, $matches); // Finds the src element of the iframe | |
| $video_url = strtok($matches[1], '?'); // Removes all parameters from URL | |
| $curl = curl_init(); | |
| curl_setopt_array($curl, array( | |
| CURLOPT_URL => 'https://vimeo.com/api/oembed.json?url=' . $video_url . '&width=' . $width, | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_ENCODING => '', |
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 the ACF relationship field to always display the quota of posts | |
| */ | |
| function selected_or_fallback( $current_id, $total_required, $acf_relationship_name, $post_type = null) { | |
| $excluded = array( $current_id ); | |
| $obtained = 0; | |
| $related = array(); | |
| // Check to see if any posts have been selected via ACF relationship |
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
| .list { | |
| margin: 0; | |
| padding-left: 0; | |
| list-style-type: none; | |
| @media only screen and (min-width: $breakpoint-sm) { | |
| display: grid; | |
| grid-column-gap: 50px; | |
| grid-row-gap: 100px; | |
| grid-template-columns: repeat(2, 1fr); | |
| } |
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 | |
| // Project specific function that strips out parameters on a vimeo URL and adds a color param | |
| function add_color_to_vimeo( $iframe ) { | |
| if( strpos($iframe, 'vimeo') !== false ) { // Does the iframe contain vimeo | |
| preg_match('/src="(.+?)"/', $iframe, $matches); // Finds the src element of the iframe | |
| $src = $matches[1]; | |
| $clean_src = strtok($src, '?'); // Removes all parameters | |
| $new_params = array( | |
| 'color' => 'FEE600' // New color parameter | |
| ); |
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 list_favicons($favicon_folder, $tile_color = null) { | |
| /** | |
| * Looks in the theme's favicon folder for ico and png files, if files exist | |
| * a list of favicons will be generated within <head> | |
| * | |
| * To cover most devices, copy four files into the folder: | |
| * A standard favicon.ico which is a compilation of three PNG's 16, 32 and 48. | |
| * Two Apple device favicons: favicon-152.png and favicon-120.png | |
| * A Microsoft favicon: favicon-144.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 | |
| function add_favicons() { | |
| /** | |
| * Looks in the theme's favicon folder for ico and png files, if files exist | |
| * a list of favicons will be generated. | |
| * | |
| * To cover most devices, copy four files into the folder: | |
| * A standard favicon.ico which is a compilation of three PNG's 16, 32 and 48. | |
| * Two Apple device favicons favicon-152.png and favicon-120.png | |
| * A Microsoft favicon favicon-144.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 | |
| function remove_crap() { | |
| /** | |
| * This function removes redundant and unnecessary tags and scripts from | |
| * the head section of the site, a lot of this stuff is useful for blogs | |
| * but, generally, not utilised for a typical business website. | |
| * Whilst there is not necessarily a load-time advantage we might as well | |
| * keep the front-end tidy by removing everything we know is not required. | |
| * This function is hooked into the after_setup_theme hook, | |
| * which runs before the init hook. |
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
| <button class="reveal">-></button> | |
| <div id="nav" class="closed"> | |
| <!-- buttons --> | |
| </div> | |
| <script> | |
| $('.reveal').click(function(){ | |
| $('#nav').toggleClass( "open" ).toggleClass( "closed" ); | |
| }); | |
| </script> |