Skip to content

Instantly share code, notes, and snippets.

View jrtashjian's full-sized avatar
🪓
Axe-ceptional at axing code

JR Tashjian jrtashjian

🪓
Axe-ceptional at axing code
View GitHub Profile
@jrtashjian
jrtashjian / functions.php
Created January 16, 2019 18:35
Filter: curatewp_template_dir
<?php
add_filter( 'curatewp_template_dir', function( $template_dir ) {
// Change the template directory in your Parent or Child theme.
return 'curation_templates';
} );
@jrtashjian
jrtashjian / functions.php
Created January 16, 2019 18:33
Filter: curatewp_section_layout_args
<?php
add_filter( 'curatewp_section_layout_args', function( $layout_args, $section ) {
// Change all section featured posts layout to the "Hero".
$layout_args['layout-featured-posts'] = 'hero';
return $layout_args;
}, 10, 2 );
@jrtashjian
jrtashjian / functions.php
Last active January 16, 2019 18:37
Filter: curatewp_section_objects_cache_time
<?php
add_filter( 'curatewp_section_objects_cache_time', function() {
// Change the cache time to hourly.
return HOUR_IN_SECONDS;
} );
@jrtashjian
jrtashjian / functions.php
Created January 16, 2019 18:29
Filter: curatewp_section_posts
<?php
add_filter( 'curatewp_section_posts', function( $curated_posts, $section ) {
// Filter out a post with the ID of 25.
return array_filter( $curated_posts, function( $post_id ) {
return 25 !== $post_id;
} );
}, 10, 2 );
@jrtashjian
jrtashjian / functions.php
Last active January 16, 2019 18:36
Filter: curatewp_section_object_query_args
<?php
add_filter( 'curatewp_section_object_query_args', function( $query_args, $section ) {
// Alter the query args for a specific section.
if ( 'your-section-name' === $section->post_name ) {
$query_args[ 'category__no_in' ] = [ 2, 54 ];
}
// Pass back the altered query arguments.
@jrtashjian
jrtashjian / functions.php
Last active January 16, 2019 18:36
Filter: curatewp_section_cache_time
<?php
add_filter( 'curatewp_section_cache_time', function() {
// Change the cache time to hourly.
return HOUR_IN_SECONDS;
} );
@jrtashjian
jrtashjian / functions.php
Created January 16, 2019 18:14
filter: curatewp_load_layout_css
<?php
// Prevent loading the layout css.
add_filter( 'curatewp_load_layout_css', '__return_false' );
<?php
/**
* Add the 'current-menu-ancestor' class to a parent page menu item where the child page is not part of the menu.
*
* @param array $classes The CSS classes that are applied to the menu item's <li> element
* @param WP_Post $item The current menu item
*
* @return array The filtered CSS classes.
*/
<?php
/**
* Generate markup for the featured image above each page.
*
* If a featured image does not exist for the current page we will try and pull one from the parent page. If we still
* haven't found a featured image we will try and pull one from the 'page_on_front' (when using a static front-page).
* Otherwise we show nothing.
*/
function featured_image( $size = 'post-thumbnail' )
<?php
// OH GOD NO
$object = new ClassName();
class ClassName {
function method_one()
{
global $object;
$object->method_two();