This file contains 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 | |
// place [content_here] shortcode where you want to place your hooked element | |
function apuri_hero_hook_function( $atts, $content = null ) { | |
ob_start(); | |
do_action( 'prefix_content_here' ); | |
return ob_get_clean(); | |
} |
This file contains 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 | |
// Based on https://gist.github.com/diggeddy/b71bf07aa55eecb0c34191f9fe05d224 | |
// justom some styles to display as 4col grid | |
add_action( 'wp_head', function () { ?> | |
<style> | |
@media (min-width: 600px) { | |
.wp-block-post-template.is-flex-container.is-flex-container.columns-4>div, .wp-block-query-loop.is-flex-container.is-flex-container.columns-4>div { | |
width: calc(25% - 0.9375em); | |
} |
This file contains 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
// not sure if this is ok, but it works on my local generatepress site | |
function prefix_mobile_quicklinks() { | |
if ( wp_is_mobile() && function_exists( 'generate_after_footer' ) ) : | |
do_action( 'mobile_quicklinks' ); | |
endif; | |
} | |
add_action( 'generate_after_footer', 'prefix_mobile_quicklinks' ); |
This file contains 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_svg_to_upload_mimes( $upload_mimes ) { | |
$upload_mimes['svg'] = 'image/svg+xml'; | |
$upload_mimes['svgz'] = 'image/svg+xml'; | |
return $upload_mimes; | |
} | |
add_filter( 'upload_mimes', 'add_svg_to_upload_mimes', 10, 1 ); |
This file contains 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 | |
/** | |
* Add or remove capabilities from user roles | |
* @link https://kinsta.com/blog/wordpress-user-roles/ | |
*// | |
function modify_role_caps() { | |
// Get roles | |
$author = get_role( 'author' ); | |
$editor = get_role( 'editor' ); |
This file contains 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 | |
// Design your own Accordions | |
// remove the <?php part at the begining of the file when including in your child theme | |
// this snippet contains basic functionality at the moment I will develop it further, so drop by again in a while | |
function thisbit_accordion_script() { ?> | |
<script id="toggler"> | |
// Reusable function for togglig one ore more elements in a page. | |
// Add the class click-me to elements you want to triger the clicking. |
This file contains 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 | |
/** | |
* Template name: Apuri home | |
* Description: Single Query Multiple Loops for a Performant Sectioned Homepage With GeneratePress | |
* @package WordPress | |
* @subpackage GeneratePress | |
* @link https://code.tutsplus.com/tutorials/how-to-code-multiple-loops-while-only-querying-the-database-once--cms-25703 | |
* @link https://wpmudev.com/blog/how-to-use-one-query-to-run-multiple-loops/ | |
* @todo Add transients in the query to serve from there instead of DB where applicable | |
* Author: @thisbit |
This file contains 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 | |
/** | |
* Template name: Custom search | |
* Description: Search and filter accross two loops of two different CPTS | |
* @todo create two loops over same cpt with different taxonomies | |
* @todo create radiobuttons instead of select | |
* @todo maybe in time add ajax | |
* @todo maybe rather custom fields rather then taxonomies | |
* Warn: this is a work in progress |
This file contains 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 | |
/** | |
* This is a gist that goes with the following tutorial | |
* @link https://thisbit.medium.com/animated-design-system-with-generatepresss-and-generateblocks-responsive-fluid-typography-292e02eeeb15 | |
*/ | |
function prefix_load_assets( ) { | |
wp_enqueue_style( 'prefix-type', get_stylesheet_directory_uri() . '/assets/css/prefix-typography.css', false, '1.0.0', 'all'); | |
} |
This file contains 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 | |
/** | |
* User role condition template, I prefer to use capabilities but here goes | |
**/ | |
function apuri_allowed_block_types_per_usergroup() { | |
$user = wp_get_current_user(); // if used in theme | |
$allowed_roles = array( | |
'contributor', |