Skip to content

Instantly share code, notes, and snippets.

Avatar

generatepress

View GitHub Profile
@generatepress
generatepress / gist:35c505f1aac124edf071f9008061ee6d
Created Aug 6, 2020
Don't close off-canvas panel on menu item click
View gist:35c505f1aac124edf071f9008061ee6d
<script>
var slideoutLinks = document.querySelectorAll( '.slideout-navigation ul a' );
for ( var i = 0; i < slideoutLinks.length; i++ ) {
slideoutLinks[i].removeEventListener( 'click', closeOffsideOnAction, false );
};
</script>
View gist:8379abe390179c9fe828f2d6aa068eef
function generateblocks_get_parsed_content( $content = '' ) {
if ( ! function_exists( 'has_blocks' ) ) {
return;
}
if ( ! $content && has_blocks( get_the_ID() ) ) {
global $post;
if ( ! is_object( $post ) ) {
return;
View gist:0d423140a25713facb6cc4db94e38ca6
add_filter( 'generate_premium_url_args', function( $args ) {
$args['ref'] = 123; // Add your affiliate ID
return $args;
} );
@generatepress
generatepress / gist:565683b10cca65050d7fb3a006efbc29
Created Jul 19, 2019
Add search button with icon to the navigation search
View gist:565683b10cca65050d7fb3a006efbc29
add_filter( 'generate_navigation_search_output', function() {
printf(
'<form method="get" class="search-form navigation-search" action="%1$s">
<input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
<input type="submit" class="search-button" value="&#xf002;">
</form>',
esc_url( home_url( '/' ) ),
esc_attr( get_search_query() ),
esc_attr_x( 'Search', 'label', 'generatepress' )
);
View gist:2bb2667c9413e29579288687add966de
add_filter( 'generate_typography_default_fonts', function( $fonts ) {
if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) {
return $fonts;
}
$all_fonts = Bsf_Custom_Fonts_Taxonomy::get_fonts();
if ( ! empty( $all_fonts ) ) {
foreach ( $all_fonts as $font_family_name => $fonts_url ) {
$fonts[] = $font_family_name;
@generatepress
generatepress / comments.php
Created Jul 18, 2019
Move comment form above list of comments.
View comments.php
<?php
/**
* The template for displaying Comments.
*
* The area of the page that contains both current comments
* and the comment form. The actual display of comments is
* handled by a callback to generate_comment() which is
* located in the inc/template-tags.php file.
*
* @package GeneratePress
@generatepress
generatepress / gist:64ee0304f3fd166f02df341fc9cc0968
Created Jul 2, 2019
Adding a search icon to the GP search form button
View gist:64ee0304f3fd166f02df341fc9cc0968
add_filter( 'generate_search_button', function() {
return '&#xf002;';
} );
@generatepress
generatepress / gist:179434f97888af190ee1d65e36402962
Created May 5, 2019
Make Dispatch Custom Post Navigation work with any custom post type
View gist:179434f97888af190ee1d65e36402962
<div id="post-nav">
<?php global $post;
$prevPost = get_previous_post(false);
$post_type = get_post_type();
if($prevPost) {
$args = array(
'posts_per_page' => 1,
'include' => $prevPost->ID,
'post_type' => $post_type,
View gist:bb5b5b84350f725ba3deaf5ee126c4cc
add_filter( 'generate_logo_href', function( $url ) {
if ( function_exists( 'pll_home_url' ) ) {
return pll_home_url();
}
return $url;
} );
@generatepress
generatepress / gist:4f76e08e7198841bef15f9347afe7454
Created Mar 26, 2019
Don't show Elements if Polylang language doesn't match
View gist:4f76e08e7198841bef15f9347afe7454
function generate_elements_ignore_languages( $post_id ) {
if ( function_exists( 'pll_get_post_language' ) && function_exists( 'pll_current_language' ) ) {
$language = pll_get_post_language( $post_id, 'locale' );
if ( $language && $language !== pll_current_language( 'locale' ) ) {
return false;
}
}
return $post_id;
You can’t perform that action at this time.