This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* create new user */ | |
INSERT INTO `wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES (NULL, 'username', MD5('password'), 'User Nicename', 'email@domain.com', '', '0000-00-00 00:00:00.000000', '', '0', 'Full Name'); | |
/* add capabilities for user (ID 8) */ | |
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '8', 'wp_capabilities', 'a:1:{s:13:\"administrator\";s:1:\"1\";}'); | |
/* add wp user level for user (ID 8) */ | |
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '8', 'wp_user_level', '10'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Run a WP-CLI command one or more sites on WordPress multisite | |
* | |
* Reference: https://danielbachhuber.com/tip/run-wp-cli-command-wordpress-multisite/ | |
*/ | |
wp site list --field=url | xargs -n1 -I % wp --url=% option update my_option my_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The following query updates the wp_posts table to a certain post type based on being a page and not having a particular post ID. */ | |
UPDATE `wp_posts` | |
SET `post_type` = 'resource-center' | |
WHERE `post_type` = 'page' AND `ID` NOT IN (6364, 6382, 6371, 6403, 6521, 6418); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove <p> tags from images | |
*/ | |
function filter_ptags_on_images($content) { | |
$content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); | |
return preg_replace('/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content); | |
} | |
add_filter('acf_the_content', __NAMESPACE__ . '\\filter_ptags_on_images'); | |
add_filter('the_content', __NAMESPACE__ . '\\filter_ptags_on_images'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove All Yoast HTML Comments | |
// https://gist.github.com/paulcollett/4c81c4f6eb85334ba076 | |
if (defined('WPSEO_VERSION')){ | |
add_action('get_header',function (){ ob_start(function ($o){ | |
return preg_replace('/^<!--.*?[Y]oast.*?-->$/mi','',$o); }); }); | |
add_action('wp_head',function (){ ob_end_flush(); }, 999); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gravity Forms jQuery fix | |
*/ | |
function gc_deregister_default_jquery() { | |
wp_deregister_script('jquery'); | |
} | |
add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\gc_deregister_default_jquery'); | |
function inject_jquery_above_gravity_form($content = '') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add <span> around GF submit input to add caret | |
*/ | |
function gf_caret($button, $form) { | |
return '<span class="caret">' . $button . '</span>'; | |
} | |
add_filter( 'gform_submit_button', __NAMESPACE__ . '\\gf_caret', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Roots\Sage\Extras; | |
use Roots\Sage\Setup; | |
/** | |
* Add <body> classes | |
*/ | |
function body_class($classes) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WordPress dashicon support in front end | |
*/ | |
function load_dashicons_front_end() { | |
wp_enqueue_style('dashicons'); | |
} | |
add_action('wp_enqueue_scripts', 'load_dashicons_front_end'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WordPress SVG Upload support | |
*/ | |
function wp_add_svg_mime_support($mimes) { | |
$mimes['svg'] = 'image/svg+xml'; | |
return $mimes; | |
} | |
add_filter('upload_mimes', 'wp_add_svg_mime_support'); |