Skip to content

Instantly share code, notes, and snippets.

Avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@joshuadavidnelson
joshuadavidnelson / dwpb-example-filter-author-archive-post-types.php
Created Apr 24, 2022
Disable Blog Example: Add new post types to author archives. By default only posts are shown on author archives, if other post types are to appear on the author archives, pass them with this filter.
View dwpb-example-filter-author-archive-post-types.php
<?php
add_filter( 'dwpb_author_archive_post_types', 'dwpb_example_filter_author_archive_post_types', 10, 1 );
/**
* Example: Filter `dwpb_author_archive_post_types` for Disable Blog plugin.
*
* Add new post types to author archives.
*
* By default only posts are shown on author archives, if other post types are to appear
* on the author archives, pass them with this filter.
*
@joshuadavidnelson
joshuadavidnelson / multilingualpress-filter-draft-hreflangs.php
Created Mar 30, 2022
Filter the hreflang urls and remove any that are indicative of draft or otherwise non-published content. Assumes that linked translations that are not yet published will show up as /?p=123 instead of pretty permalink.
View multilingualpress-filter-draft-hreflangs.php
<?php
/**
* Filter the hreflang urls and remove any that are indicative of draft or otherwise non-published content.
*
* Linked translations that are not yet published will show up as /?p=123 instead of pretty permalink.
*
* @param array $urls the array of language => url hreflang urls.
* @return array
*/
add_filter( 'multilingualpress.hreflang_translations', 'filter_mlp_hreflang_translations' );
@joshuadavidnelson
joshuadavidnelson / stf-jquery-header-in-archives-only.php
Last active Jul 2, 2021
Place jQuery in the head on archive pages. You can use other conditionals in place of `is_archive()` to achieve this behavior for other conditions.
View stf-jquery-header-in-archives-only.php
<?php
/**
* Use this filter to force jquery to remain in the head section of the page on archives.
*
* @see https://wordpress.org/support/topic/exclude-jquery-for-other-archive-pages/
* @date 2021-07-02
*/
add_filter( 'stf_jquery_header', 'jdn_archive_header_scripts', 10 );
function jdn_archive_header_scripts( $bool ) {
@joshuadavidnelson
joshuadavidnelson / add-yoast-redirect.php
Last active Jun 28, 2022
Programmatically add a redirect to the Yoast SEO Premium redirects.
View add-yoast-redirect.php
<?php
/**
* Create a new redirect within the Yoast redirect system.
*
* @param string $origin_url redirecting from.
* @param string $destination_url redirecting to.
* @param int $type redirect code, defaults to 301.
* @param string $format the format, either 'plain' or 'regex', defaults to 'plain'.
* @return void
*/
@joshuadavidnelson
joshuadavidnelson / remove-genesis-layout-settings-from-customizer.php
Created Jan 1, 2020
Remove the Genesis Layout settings in Customizer
View remove-genesis-layout-settings-from-customizer.php
<?php
// Remove layout settings from customizer
add_filter( 'genesis_customizer_theme_settings_config', 'jdn_filter_genesis_customizer_theme_settings' );
function jdn_filter_genesis_customizer_theme_settings( $config ) {
if( isset( $config['genesis']['sections']['genesis_layout'] ) )
unset( $config['genesis']['sections']['genesis_layout'] );
return $config;
@joshuadavidnelson
joshuadavidnelson / grid-block.scss
Created Jul 31, 2019
css grid example with modernizr assisted fallback
View grid-block.scss
.grid-block {
float: left;
}
.grid {
$grid-gap: 9px;
// Columns!
@media screen and ( min-width: 600px ) { // responsive grid
display: grid;
@joshuadavidnelson
joshuadavidnelson / change-wp-user-password.sql
Created Jul 24, 2018
SQL for updating a user password in WordPress
View change-wp-user-password.sql
UPDATE wp_users
SET user_pass = MD5('newpassword')
WHERE ID = 55;
View scripts-to-footer-example.php
@joshuadavidnelson
joshuadavidnelson / custom-route-notification-multiple-fields.php
Last active Dec 8, 2017
Per emailed question, utilizing the example in my blog post "User Dropdown List & Custom Notification Routing in Gravity Forms" for multiple fields that have the custom 'user-emails' CSS class to email multiple people
View custom-route-notification-multiple-fields.php
<?php
/**
* Change the sent to email address in the notification
*
* @author Joshua David Nelson, josh@joshuadnelson.com
**/
// Route to user address from drop down list, update the '1' to the ID of your form
add_filter( 'gform_notification_1', 'route_user_email_notification', 10, 3 );
function route_user_email_notification( $notification, $form , $entry ) {
@joshuadavidnelson
joshuadavidnelson / gist:57210d6218e4039288973d0045a10159
Created May 5, 2017 — forked from dustyf/gist:b6e72a7a7fd05de9598e
Example WordPress Simple JSON Endpoint Plugin
View gist:57210d6218e4039288973d0045a10159
<?php
/**
* Plugin Name: WDS GIF API
* Plugin URI: http://webdevstudios.com
* Description: Adds a Custom Post Type to store GIFs and an API JSON Endpoint to access GIFs by a tag.
* Author: WebDevStudios
* Author URI: http://webdevstudios.com
* Version: 1.0.0
* License: GPLv2
*/