Skip to content

Instantly share code, notes, and snippets.

@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 / theme.json
Last active August 22, 2023 08:04
core/heading settings
"core/heading":{
"typography":{
"fontWeight":"700"
},
"spacing":{
"margin":{
"top":"0",
"bottom":"1.25rem"
}
},
@tiborp
tiborp / bootstrap-wide.css
Created April 25, 2014 19:47
Extra media queries for BIG screens
// Extra big for Twitter Bootstrap
@media screen and (min-width: 1400px) {
.container {
width: 1370px;
}
}
@media screen and (min-width: 1600px) {
.container {
width: 1570px;
<?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 / functions.php
Last active February 3, 2022 09:53
Add span tag around WordPress menu item
<?php
/**
* Add span to menu items with icon class so we can hide the text and show icons instead
*
* @link http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items
*/
add_filter( 'walker_nav_menu_start_el', 'hrt_span_to_nav_menu', 10, 4 );
function hrt_span_to_nav_menu( $item_output, $item, $depth, $args ) {
if ( isset( $item->classes ) && !empty( $item->classes ) ) {
@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