Skip to content

Instantly share code, notes, and snippets.

@SteveJonesDev
SteveJonesDev / accessible-menu.php
Last active May 21, 2024 13:05
Accessible WordPress Navigation Menu
<div class="menu-container">
<button class="menu-button" aria-expanded="false" aria-controls="site-header-menu" aria-label="<?php esc_attr_e( 'Menu', 'textdomain' ); ?>"></button>
<div id="site-header-menu" class="site-header-menu">
<?php
wp_nav_menu(
array(
'theme_location' => 'primary',
'container' => 'nav',
'container_class' => 'main-navigation',
'container_id' => 'site-navigation',
@wpscholar
wpscholar / .eslintignore
Last active March 14, 2022 10:21
Webpack 4 Config for WordPress plugin, theme, and block development
**/*.min.js
**/*.build.js
**/node_modules/**
**/vendor/**
build
coverage
cypress
node_modules
vendor
@balbuf
balbuf / wordpress-import-update.php
Created October 15, 2016 17:54
Force the WordPress importer to update existing posts instead of skipping them
<?php
/**
* When using the WordPress Importer, update existing
* posts instead of skipping them. Updates content according
* to the import file even if the existing post was updated
* more recently.
*
* To use, drop this file into your /mu-plugins/ folder or
* copy this code into your functions.php file.
@ZachWatkins
ZachWatkins / .codeshipignore
Last active April 28, 2022 15:05
Setup WordPress plugin or theme repository for continuous integration service's virtual machine environment
# RECOMMENDED BY WPENGINE
*~
.DS_Store
.svn
.cvs
*.bak
*.swp
Thumbs.db
# large/disallowed file types
@mgratch
mgratch / sg-push-wp-content-only.js
Last active February 7, 2017 03:59
Only check wp-content files when using advanced push for SiteGround staging.
var $ = jQuery;
$.each($(".databox").find("input[type='checkbox']"), function(){
var label = $(this).next("label").text();
if (label.indexOf('wp-content') > -1 && $(this).attr('disabled') !== true && $(this).attr('disabled') !== 'disabled'){
console.log('check-me');
$(this).attr('checked',true);
} else {
console.log('no-check');
$(this).attr('checked', false);
}
@codearachnid
codearachnid / filter_gf_select_optgroup.php
Last active July 16, 2024 15:51
Add the optgroup ability to Gravity Forms default select field.
/**
* Filter Gravity Forms select field display to wrap optgroups where defined
* USE:
* set the value of the select option to `optgroup` within the form editor. The
* filter will then automagically wrap the options following until the start of
* the next option group
*/
add_filter( 'gform_field_content', 'filter_gf_select_optgroup', 10, 2 );
function filter_gf_select_optgroup( $input, $field ) {
@sewmyheadon
sewmyheadon / bootstrap-gforms.php
Last active March 8, 2018 15:01
Add Bootstrap styles to Gravity Forms fields
/**
* Adding Bootstrap Styles to Gravity Forms
*/
add_filter("gform_field_content", "bootstrap_styles_for_gravityforms_fields", 10, 5);
function bootstrap_styles_for_gravityforms_fields($content, $field, $value, $lead_id, $form_id){
// Currently only applies to most common field types, but can be expanded.
if($field["type"] != 'hidden' && $field["type"] != 'list' && $field["type"] != 'multiselect' && $field["type"] != 'checkbox' && $field["type"] != 'fileupload' && $field["type"] != 'date' && $field["type"] != 'html' && $field["type"] != 'address') {
$content = str_replace('class=\'medium', 'class=\'form-control medium', $content);
# Apache .htaccess
RedirectMatch 301 ^/wp-content/uploads/(.*) http://livewebsite.com/wp-content/uploads/$1
# Nginx
location ~ ^/wp-content/uploads/(.*) {
rewrite ^/wp-content/uploads/(.*)$ http://livewebsite.com/wp-content/uploads/$1 redirect;
}