Automatic Header Anchors for WordPress Without Plugin

Header Anchors for WordPress with only 3 lines of JS and No plugin?? Yes It’s so easy to set up… Thank you IT Cooking! The JS requires your headers to have an ID, and what better then a Table Of Content plugin to have them for free!

Header Anchors for WordPress Step by Step Process

Requisites

Required: A Snippet loader: we recommend Simple Custom CSS & JS

Simple Custom CSS and JS banner

Optional: A table of content plugin: we recommend TOP Table Of Contents

banner top toc

The JS snippet provided also adds ids to your headers…

Add this JS Snippet to Attach an Anchor to Headers

window.addEventListener("load", function(){
  // Loop through all your headers inside article section only
  // Headers shall be there thanks to TOC plugin, if not we just add them
  // AddOnly h2 and h3, add the headers you want
  $("article").find("h2, h3").each(function() {
    if (!this.id) {
      let id = this.textContent.replace(/[^a-zA-Z0-9]+/g, "-").toLowerCase();
      this.setAttribute('id', id);
    }
    $(this).append('<a class="anchor" href="#'+this.id+'"></a>');  // anchors after
    //$(this).prepend('<a class="anchor" href="#'+this.id+'"></a>'); // anchors before
    });
});

The JS appends/prepends a link with class .anchor to every h2/h3 found on the page, that have an id or not. Will add ids if missing. It does NOT add links to headers outside the article content (read more, etc).

Add this CSS to Format the Anchors

.anchor {
  visibility: hidden;
  text-decoration: none !important;
}
/* add more levels if you need */
h3:hover > .anchor, 
h2:hover > .anchor {
  visibility: visible;
}
.anchor::before { 
  content: "🔗";
}

Anchor is visible on hover, right side, and is an emoji. You can replace the emoji by an <i> from fontawesome if you like.

Result:

css js snippets to add anchor to headers

 

Best Debug PHP Function Around

 

When it comes to PHP debugging… You like to know what’s going on don’t you! So you are tired or using  var_dump($myVar) because the printout is messed up with your HTML? Here is the Grail: a beautiful Debug PHP Function.

This one will display the complete set of calls (backtrace) as well as the variable/class/array to print out, in a flashy Yellow/Purple/Red/Cyan color set different for each type of variable. The z-index or 999 and the set of styles associated will make sure that it’s always visible.

Continue reading Best Debug PHP Function Around

Meltdown and Spectre: Why the Commotion?

 

Another commotion is spreading across the Internet about a potential threat: Meltdown and Spectre critical vulnerabilities found in Intel and other ARM CPUs will be exploited and hackers will steal your money, erase your data and mow your cat, blah blah blah.

If hackers knew or could have exploited it, you would have noticed. Catching fire now is too late. “Spectre” vulnerability is 15 years old. Now, please remember the Year 2000 bug hoax and follow the money ????

I’d like to be the bearer of good news, because you are all wrong about this threat. NO NEED TO PANIC and here is why:

Continue reading Meltdown and Spectre: Why the Commotion?

WordPress: Fade Out Excerpt Behind Read More Link

How about an awesome Fade Out effect to “Read more…” link for your post feed? Search no more! Just one CSS hack and done! Themes just neglect this “Continue reading” link and leave it as is. Stuck on the left, no margin, no effects, barely noticeable, plain boring. This easy fade-out effect

Continue reading WordPress: Fade Out Excerpt Behind Read More Link

DDwrt: Free Ad-Blocking DNS Home Router

Unleash your router with DDwrt and transform it into a Free Ad-Blocking DNS Home Router!

You may already know about Ad-Blocking plugins such as ABP or uBlock Origin for Chrome and Firefox, and these work fine… for your computer browser. But these plugins cannot be installed on a media TV, nor on TV Set Top box, nor on a multimedia phone.

Unless I missed something, iPhone browsers are all the same as they rely on Apple’s web framework. I’ve tested different ones some time ago on my 5gs and their web rendering results are all the same (Safari, Dolphin, Firefox). Therefore, they cannot accept plugins, not even mentioning Ad-Blocking plugins. Boooo. Even so jailbreaking allows you to install a local dns blocker, this will break ads detection in many apps, rendering them useless.

Solution? Install the Ad-Blocking software on your router:

adblock-canvas+router

Continue reading DDwrt: Free Ad-Blocking DNS Home Router

Twitter Bootstrap Callout CSS Styles 3.x-4.x

 

Bootstrap Callout

The Bootstrap Callout styles in their documentation is really a nice way to draw attention to important information. For some reason these Callouts are not included in the actual Bootstrap distribution.

Here is my interpretation of the missing CSS code for generic Bootstrap Callouts. The color codes for the info, warning, and danger Callouts are a direct pull from their live CSS for the docs, so I added styles for default, success, and primary.

They include a nice background, color derived from Bootstrap color rules. They also include a transparent and a disabled class.

Continue reading Twitter Bootstrap Callout CSS Styles 3.x-4.x