Skip to content

Instantly share code, notes, and snippets.

View macariojames's full-sized avatar
💭
Making things. All the things. Ahh!

Macario James macariojames

💭
Making things. All the things. Ahh!
View GitHub Profile
@macariojames
macariojames / select-option-disable.js
Last active June 25, 2022 21:52
Disabling Form Select Option based on value (Gravity Form)
// This was specifically for Gravity Form i wanted to disable options based on a null value.
// In the dropdown I had, some values were used as headers so people would know the type of
// item they were selecting -- in this case the dropdown was for liquor/wine selection
// Before to put the "true" part after disabled rather than leaving it blank
// or it won't work in any browser but Chrome (Mac).
// gForm disable select options with null or '|0' value
$('.gform_body select option[value="null|0"]').attr("disabled","true");
@macariojames
macariojames / mailchimp-custom.js
Last active March 25, 2022 13:16
MailChimp hide form on successful submit and thank you message; jQuery
// Add a surrounding <div> for all the ish don't want to keep once submission is successful
<script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script>
<script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[1]='FNAME';ftypes[1]='text';fnames[0]='EMAIL';ftypes[0]='email';}(jQuery));
//var $mcj = jQuery.noConflict(true);
</script>
<script>
$(function(){
//$("#mcm_hide_on_submit").hide();
$(".button").on("click", function(){
@macariojames
macariojames / functions.php
Last active August 4, 2021 13:30
Change wp-login.php page title // Remove "WordPress" from login page
<?php
// Put this in your functions.php file
// Changes wp-login.php page title
// Here I'm removing the default "WordPress" at the end of it ~mj
function custom_login_title( $login_title ) {
return str_replace(array( ' &lsaquo;', ' &#8212; WordPress'), array( ' &lsaquo;', ''),$login_title );
}
add_filter( 'login_title', 'custom_login_title' );
@macariojames
macariojames / functions.php
Created February 21, 2020 21:26
Remove all classes from anchors in navwalker menus (WordPress)
//Put this in your functions.php or custom functionality plugin
// remove all classes from anchors in menus ~mj
function mj_remove_classes_from_all_menu_anchors( $atts ) {
$atts['class'] = ''; // not it's blank; if you add classes like 'example1 class2', it'll add classes ~mj
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'mj_remove_classes_from_all_menu_anchors', 10 );
@macariojames
macariojames / external-links.js
Last active January 29, 2020 14:46
Add icon to all external links
@macariojames
macariojames / remove-article-tag-yoast-wpseo-wordpress.php
Last active September 1, 2019 15:08
Remove article:tag meta from Yoast WordPress SEO plugin
<?php
// Put in functions.php or custom functionality plugin.
// Remove article:tag meta that Yoast's WordPress SEO outputs ~mj
function remove_wpseo_fb_tags_categories() {
global $wpseo_og;
remove_action('wpseo_opengraph', array($wpseo_og, 'tags'), 16);
remove_action('wpseo_opengraph', array($wpseo_og, 'category'), 17);
}
add_action('wpseo_opengraph', 'remove_wpseo_fb_tags_categories');
@macariojames
macariojames / add-img-responsive-class-images-wordpress.php
Last active September 1, 2019 15:07
Add .img-responsive class to all images uploaded/added in WordPress
<?php
/**
* @desc Add .img-responsive to all post images ~mj
*/
function add_post_img_responsive_class($attr) {
$attr['class'] .= ' img-responsive'; // note the leading space
return $attr;
}
add_filter('wp_get_attachment_image_attributes', 'add_post_img_responsive_class');
@macariojames
macariojames / core-emails.php
Last active September 1, 2019 15:06
ACF Advanced Forms - Custom Reply-to
<?php
// add this to `core-emails.php` file in the ACF Advanced Forms plugin ~mj
// From header
$from = af_resolve_field_includes( $email['from'], $fields );
$replyto = af_get_field( 'email');
$headers[] = 'From:' . $from;
// only have reply-to to Customer if it's admin
@macariojames
macariojames / display-field-name-acf-admin.php
Last active September 1, 2019 15:05
Display field_name for ACF field names back-end in development if Administrator
<?php
// Display ACF field names for development for Administrator only
function display_acf_field_names( $field ) {
echo $field['_name'];
}
if(is_admin() && !current_user_can('manage_options')) {
add_action( 'acf/render_field', 'display_acf_field_names', 10, 1 );
@macariojames
macariojames / get_real_host.php
Last active September 1, 2019 15:04
WordPress: Use different MySQL login credentials depending on your host (localhost, sandbox, production, etc.)
<?php
/* I use this in a separate config-properties.php or otherwise named file
* which is then included by wp-config.php ~mj */
function getRealHost() {
list($realHost,) = explode(':',$_SERVER['HTTP_HOST']);
return $realHost;
}