Skip to content

Instantly share code, notes, and snippets.

View tatianepires's full-sized avatar

Tatiane Pires tatianepires

View GitHub Profile
<?php
/**
* @summary filters an enqueued script tag and adds a noscript element after it
*
* @description filters an enqueued script tag (identified by the $handle variable) and
* adds a noscript element after it. If there is also an inline script enqueued
* after $handled, adds the noscript element after it.
*
* @access public
* @param string $tag The tag string sent by `script_loader_tag` filter on WP_Scripts::do_item
@tatianepires
tatianepires / tps-link-manager-metabox.php
Last active August 19, 2023 00:01
Add metabox to Link Manager
@tatianepires
tatianepires / tps-nav-menu-customization.php
Created September 17, 2016 21:46
WordPress: add class to LI and A elements output by wp_nav_menu()
<?php
// Add class to A element of .primary-menu
function tps_primary_menu_anchor_class($item_output, $item, $depth, $args) {
$item_output = preg_replace('/<a /', '<a class="nav-link" ', $item_output, 1);
return $item_output;
}
add_filter('walker_nav_menu_start_el', 'tps_primary_menu_anchor_class', 10, 4);
// Add class to LI element of .primary-menu
function tps_primary_menu_li_class($objects, $args) {
@tatianepires
tatianepires / tps-change-jetpack-related-posts.php
Last active September 27, 2016 13:46
Remove related posts from its default position and change the headline.
@tatianepires
tatianepires / tps-widget-select-categories-to-link.php
Last active July 10, 2016 08:25
Code for WordPress that adds a widget to select categories to be linked.