WordPress Plugin: Open Files In New Tab or Window
October 7, 2014
wordpressOn a recent WordPress project I had a requirement that any files be opened in a new tab or window. Now this can be easily accomplished by the users when they create the post or page by linking to the file and marking the checkbox "Open Link In A New Window/Tab". But we all know users can't be trusted so in order to "double check" them I wrote a WordPress plugin that will hunt the page for anchor tags that link to something with a file extension, and simply add "target='_blank'" to them. Basically all the plugin does is enqueue a jQuery script that does the work. I got the idea to use the jQuery .filter() method from @nickf and the regular expression (because I suck at them) from @már-Örlygsson.
jQuery Open Files In New Tab Or Window
Links and References
Fork On Github WordPress Plugin Page jQuery Script Stackoverflow: Javascript regex for matching/extracting file extension Stackoverflow: jQuery Selector Regular Expressions
Active Projects
Here are some of the projects I am currently working on. Some are side projects, some are client projects, and some are just for fun. I like to build things and I like to share what I learn along the way. If you have any questions about any of these projects, feel free to reach out.
🏗️ JSONL Tools
I am working on a set of tools to help me work with JSONL. JSONL is a simple format for working with JSON data. I am working on a set of tools to help me work with JSONL data. I will use these tools to help me work with my own data as well as help me build my own APIs. Read more about this project in my blog post about building JSONL Tools.
🤖 Make Storytime
Personalized children's stories generated by AI. This is an app I am building with my kids.
📠 Fax Online
Yea, I know. But there is a long tail for everything and believe it or not there was an underserved market for people that need to send a fax online. Some people (like me!) just need to send a one time fax.
Read more about this micro Saas project in a blog post about building an online fax service.
🥑 Free URL Indexer
Free URL Indexer is a free tool to help you index your backlinks and get them into Google faster. It's a simple tool that I built to help me with my own SEO efforts and I decided to share it with the world. It's a free tool and I don't even ask for your email address. Just paste in your URL and click the button.
👉 See all projects