Basic Email Us Adding a subject Email Us Adding CC and BCC Email Us Adding body text Email Us
Category: 2021
WordPress add to menu on the fly
add_filter( ‘wp_nav_menu_items’, ‘your_custom_menu_item’, 10, 2 ); function your_custom_menu_item ( $items, $args ) { //if (is_front_page()) { $items .= ‘<li>Show whatever</li>’; }else{ $items .= ‘<li>Show something else</li>’; } if ( is_page( array( ‘meet-the-group’, ‘contact-us’ ) ) || is_front_page()) { // either in about us, or contact, or management page is in view //$items .= ‘<li>Show whatever</li>’; […]
Eliminate Load More in media file – WP – WordPress
add_filter( ‘media_library_infinite_scrolling’, ‘__return_true’ );
Print messages to the status bar
Print messages to the status bar Display recent or important information to your users in a way that will catch their eye. window.status = “Your message here”;
Page redirect with optional delay
Page redirect with optional delay A rather valuable little snippet to keep in your back pocket. setTimeout( “window.location.href = ‘http://website.com/'”, 5*1000 );
Smooth scroll to the top of the current page
Smooth scroll to the top of the current page const scrollToTop = () => { const c = document.documentElement.scrollTop || document.body.scrollTop; if (c > 0) { window.requestAnimationFrame(scrollToTop); window.scrollTo(0, c – c / 8); } }; scrollToTop();
Prevent Image Hotlinking with .htaccess
replace any incoming image request with my logo: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^https://davidwalsh.name/.*$ [NC] RewriteRule .*.(png|gif|jpe?g)$ [F,NC] </IfModule>
DOM and Vanilla JS
Ariel Jakubowski DOM tree structure Using JavaScript to Manipulate the DOM Accessing DOM Elements The query selector finds the first element or node that matches a specified parameter. The most common ways a query selector is used are to access elements of a certain type, elements with a certain id, and elements with a certain […]
Prevent JavaScript Hotlinking with .htaccess
RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^https://davidwalsh.name/.*$ [NC] RewriteRule \.(js)$ http://davidwalsh.name/hotlink.js [R,L] article hotlink.js file whose contents are a bit devious: window.location = ‘https://davidwalsh.name/’;
Prevent Image Hotlinking with .htaccess
replace any incoming image request with my logo: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^https://davidwalsh.name/.*$ [NC] RewriteRule .*.(png|gif|jpe?g)$ [F,NC] </IfModule> article