Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Making things. All the things. Ahh!

Macario James macariojames

💭
Making things. All the things. Ahh!
View GitHub Profile
@macariojames
macariojames / functions.php
Created Feb 21, 2020
Remove all classes from anchors in navwalker menus (WordPress)
View functions.php
//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 / yoast-to-bottom.php
Last active Sep 1, 2019
Move Yoast to the bottom of Dashboard editor
View yoast-to-bottom.php
<?php
/* Move Yoast to bottom of Dashboard editor*/
function yoast_to_bottom() {
return 'low';
}
if ( defined('WPSEO_VERSION'))
add_filter( 'wpseo_metabox_prio', 'yoast_to_bottom');
@macariojames
macariojames / functions.php
Created Aug 28, 2019
WordPress: color code posts by "Status" in Dashboard
View functions.php
/* Color code posts by "Status in Dashboard ~mj */
function mj_color_code_posts_by_status() {
?>
<style>
.status-draft { background-color: #ffff99 !important; }
.status-future { background-color: #ccff99 !important; }
.status-pending { background-color: #87c5d6 !important; }
.status-private { background-color:#ffcc99; }
.status-publish { background-color: #fff !important; }
@macariojames
macariojames / external-links.js
Last active Jan 29, 2020
Add icon to all external links
View external-links.js
@macariojames
macariojames / searchform.php
Last active Sep 1, 2019
AJAX Search Lite function_exists() - WordPress Plugin shortcode
View searchform.php
<?php
// When manually inputting shortcodes in WordPress themes with do_shortcode() i like to
// do a if (function_exists()) just in case something breaks.
// The plugin AJAX Search Lite didn't have anything in the documentation regarding what function
// is actually called so i had to look for it in the plugin files; it took 20 seconds.
// Figured this would help to save you 20 seconds. Cheers and peace ~mj
if( function_exists('wd_asl')) {
echo do_shortcode('[wpdreams_ajaxsearchlite]');
@macariojames
macariojames / position-offset-userway.css
Last active Aug 1, 2019
Offset position of Userway.org widget
View position-offset-userway.css
// So I needed to change the position of the floating widget on mobile for my site since
// I have a fixed footer navbar. After not seeing any controls in the .js file, figured i'd just override it
// via CSS. Here you go.
// (Yes, using '!important' is crappy, but it was necessary to get this done.) ~mj
@media screen and (max-width: 768px) {
body .userway.userway_p3 {
bottom: 65px!important;
}
}
@macariojames
macariojames / print-necessary-template-directory.php
Last active Sep 1, 2019
WordPress: function to display template directory based on needs, such as CSS, images, js files, etc.
View print-necessary-template-directory.php
<?php
// echo relevant directory ~mj
function print_dir($type) {
if($type === '')
$dir = get_template_directory_uri();
else if ($type === 'js')
$dir = get_template_directory_uri() . '/public/js/';
else if ($type === 'css')
@macariojames
macariojames / select-option-disable.js
Last active Apr 17, 2019
Disabling Form Select Option based on value (Gravity Form)
View select-option-disable.js
// 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 / header.php
Last active Sep 1, 2019
WordPress redirect non-logged in user to a page/site
View header.php
<?php
// put this in header.php
if (!is_user_logged_in()) {
wp_redirect( 'https://www.yourdomain.com');
exit;
} ?>
View local-horizontal-slim-10_7.css
#mc_embed_signup form{text-align:center;padding:10px 0}.mc-field-group{display:inline-block}#mc_embed_signup input.email{font-family:"Open Sans","Helvetica Neue",Arial,Helvetica,Verdana,sans-serif;font-size:15px;border:1px solid #ABB0B2;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;color:#343434;background-color:#fff;box-sizing:border-box;height:32px;padding:0 .4em;display:inline-block;margin:0;width:350px;vertical-align:top}#mc_embed_signup label{display:block;font-size:16px;padding-bottom:10px;font-weight:700}#mc_embed_signup .clear{display:inline-block}#mc_embed_signup .button{font-size:13px;border:none;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;letter-spacing:.03em;color:#fff;background-color:#aaa;box-sizing:border-box;height:32px;line-height:32px;padding:0 18px;display:inline-block;margin:0;transition:all .23s ease-in-out 0s}#mc_embed_signup .button:hover{background-color:#777;cursor:pointer}#mc_embed_signup div#mce-responses{float:left;top:-1.4em;padding:0 .5
You can’t perform that action at this time.