Skip to content

Instantly share code, notes, and snippets.

@tiborp
tiborp / theme.json
Last active August 22, 2023 08:04
core/heading settings
"core/heading":{
"typography":{
"fontWeight":"700"
},
"spacing":{
"margin":{
"top":"0",
"bottom":"1.25rem"
}
},
<?php $menu_location = 'your-menu-location'; ?>
<?php if ( has_nav_menu( $menu_location ) ): ?>
<?php $menu_items = wp_get_nav_menu_items( wp_get_nav_menu_name( $menu_location ) ); ?>
<?php foreach ( $menu_items as $menu_item ): ?>
<a href="<?= esc_url( $menu_item->url ) ?>" target="<?= esc_attr( $menu_item->target ? : '_self' ) ?>"
class="footer__menu-link"><?= esc_html( $menu_item->title ) ?></a>
@tiborp
tiborp / filters.php
Created September 3, 2019 09:14
Move Yoast Metabox to bottom
<?php
// Move Yoast Metabox to bottom of edit screen
function move_yoast_to_bottom() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', __NAMESPACE__ . '\move_yoast_to_bottom');
@tiborp
tiborp / utitlity.php
Created June 26, 2019 09:56
Extract colors from a CSS or Sass file
<?php
/**
* Extract colors from a CSS or Sass file
*
* @param string $path the path to your CSS variables file
*/
function get_colors( $path ) {
$dir = get_stylesheet_directory();
if ( file_exists( $dir . $path ) ) {
@tiborp
tiborp / functions-admin.php
Created February 15, 2019 11:35
Re-order WordPress admin menu
<?php
/**
* Custom admin functions
*/
namespace Projectname;
// Move Pages above Media
function change_menu_order( $menu_order ) {
return array(
<?php
// WP_User_Query arguments
$args = array(
'role' => 'subscriber',
'number' => '10',
'order' => 'ASC',
'orderby' => 'id',
);
// The User Query
@tiborp
tiborp / functions-gforms.php
Last active January 12, 2019 07:50
Show ZIP before city in GravityForms
<?php
/**
* Custom hooks & filters for GravityForms
*/
namespace ProjectName;
/**
* Show zip-field before city field
* @link https://docs.gravityforms.com/gform_address_display_format/#examples
@tiborp
tiborp / reindex.php
Created February 20, 2017 12:05
Prevent auto indexing
/**
* See: http://www.wpallimport.com/documentation/advanced/action-reference/
*/
//Prevent auto indexing before first import
function drl_before_opleidingen_import($import_id) {
if( $import_id === 4) {
add_filter( 'searchwp_auto_reindex', '__return_false' );
}
}
@tiborp
tiborp / template-tags.php
Created December 1, 2016 12:35
Nifty inline SVG's
<?php
/**
* Return SVG markup.
*
* @param array $args {
* Parameters needed to display an SVG.
*
* @param string $icon Required. Use the icon filename, e.g. "facebook-square".
* @param string $title Optional. SVG title, e.g. "Facebook".
* @param string $desc Optional. SVG description, e.g. "Share this post on Facebook".
@tiborp
tiborp / custom.php
Last active May 9, 2017 20:16
Dynamically add Bootstrap column classes to footer widgets, depending on how many widgets are present
<?php
// Dynamically add Bootstrap column classes to footer widgets, depending on how many widgets are present
add_filter('dynamic_sidebar_params','tibs_footer_sidebar_params');
function tibs_footer_sidebar_params($params) {
$sidebar_id = $params[0]['id'];
if ( $sidebar_id == 'sidebar-footer' ) {