Home > Tech > Wordpress > WordPress Plugin for Splash Screen
WordPress Plugin for Splash Screen

WordPress Plugin for Splash Screen

If you have an adult website, which could include a website about condoms, or drinking alcohol, or “mature” rated video games, you really need a splash screen that tells the visitor to go away if they are under age.  Of course, “adult” would also include your traditional “pr0n” website, which may contain nudity or something even “better.”

With WordPress, this can be done via their “plugin” feature, which I’ve created for your enjoyment and downloading.  This is my first “real” plugin for WordPress so I’m not really sure I’ve done it properly but it does work on my local setup using EASYPHP, as well as hosted on a real server.

How it works:
Basically, a cookie is created when the visitor clicks on “I Agree”, and as long as this cookie is there, the splash screen will no longer appear.  Once the cookie is gone, the splash screen will re-appear before the visitor is allowed to continue on to the blog.  If you don’t know what a browser cookie is, read this.

To install:
First download the ZIP file onto your computer.  Then, extract the zip file content and copy the directory “splashscreen” to the plugin directory located at “wp-content/plugins”. If you’ve never installed a plugin, you should probably read the WordPress documentation here.

To use:
First, login as an administrator.  Next, click on the “Plugins” menu item on the left side (v2.7+). If you installed the plugin properly, you should see “Splashscreen” listed. If you do not see it, there’s a problem with the installation.  Click on “Activate” on the right side of this plugin.
splashscreenmenu

Next, click on down arrow to the right of “Settings” to open up the list of options.  There should be a new item there called “SplashScreen.”

If you do not see this item, return to the “Plugins” admin menu to make sure that this plugin is activated.

Now, click on “SplashScreen” and you will get the “SplashScreen Settings” page as shown below.

On this screen, click the box to the right of “Enable Splash Screen” to enable this feature.

Below this selection, make sure to select “template” for your default template.  We’ll cover how to change this later.  Now, click on “Update.”

splashscreensetting

At this point, you can click on “Visit site” at the upper left corner of the administration page to view your website.  If you are using the default WordPress template, you will get something that looks like the image below.

splashscreen

As is, if you click on “I Do Not Agree,” you’ll be taken to google.com.  If you click on “I Agree,” you will be taken to your regular blog page.  Using the default SplashScreen template, once you have clicked on “I Agree” once, you will not see this splash screen again until you close your browser and re-launch and re-open the website.

You can see a demo of this plugin at an adult website — alexisbreeze.com. Obviously, don’t go there if you don’t want to see pr0n.  Actually, there’s just some bikini pictures there right now but if you see this post later on, there might be more.

To customize:
You can change the splash screen to your needs by copying the file “template.htm” to another name.  Do not change “template.htm” so that you can use this as your backup in case you screw something up.  The extension must be “.htm” for the plugin to be able to find your template and list it for selection. For example, you can copy it to “mysplash.htm”.

If you don’t know anything about HTML, you probably should not be touching the template, or just change the text only and nothing else.

The file will look like the code below.

<?php get_header(); ?>
<SCRIPT LANGUAGE="JavaScript">
   <!-- hide from old browsers
   function setCookie(name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
   }
   function setsplash() {
      setCookie("splash", "1", "", "/");
   }
//-->
</SCRIPT>
<div align="center">
   <h3>To enter this website, you must agree to the terms below.<h3>
   <table border="0" align="center">
   <tr>
      <td colspan="2">
         <FORM>
         <P><TEXTAREA NAME="comments" COLS="70" ROWS="7" READONLY>The material contained
 herein is intended for mature audiences and is not suitable for persons under the age of 18. If you are under
 18 or feel you would be offended by this type of material, please exit this site.

By using this website, you agree to the Terms of Service below. Please read them carefully. This Terms of
 Service is a binding contract between you and this website. If you do not agree with any of these terms,
 please exit this website.

TERMS OF SERVICE:
Blah Blah Blah</TEXTAREA><br />
      </td>
   </tr>
   <tr>
      <td align="left"><h2><a onclick="setsplash()" href="">I Agree</a></h2></td>
      <td align="right"><h2><a href="http://google.com/">I Do Not Agree</a></h2></td>
   </tr>
</table>
</div>

<?php get_footer(); ?>

Do NOT change anything above the “div” shown in yellow.  You can pretty much change everything between the 2 yellow lines, except for the code that is in cyan (the light blue color).  Whatever link you create to go to your blog must contain the call to the “setsplash” javascript function which sets the cookie that tells the plugin that the visitor has seen the splash screen.

For example, if you want to ask the visitor if they are “18 and over”, replace the text, “I Agree” with that text.

Also, you will have to add your own text for your “terms of service” and add it where it now says, “Blah Blah Blah.”

As is, this template will cause the splash screen to appear once until the browser is closed.  Then the cookie is erased automatically and the visitor will once again see the splash screen.

However, if you want the browser to remember that the splash screen was already shown on the visitor’s computer, you can replace the “setsplash” function with the one below.  By doing this, the cookie will remain even after the browser is closed.  Replace the area in green highlights above with the following code.

function setsplash() {
   var exp = new Date();
   var expDays = 365;
   exp.setTime(exp.getTime() + (expDays * 24 * 60 * 60 * 1000));
   setCookie("splash", "1", exp, "/");
}

By the way, when you click on the “Update” button in the setup screen, it automatically clears the cookie so that you will be able to test the splash screen without having to manually delete the cookie or close your browser.

To download:
Download version 0.01 (beta) here. [Get the latest version below]
Hopefully, there will be people that will find this plugin to be useful. If you find this plugin useful, please encourage me to do more coding by making a small donation.

Updated May 14, 2009:
Version 0.20 is released.
Updated December 3, 2009:
Version 0.30 is released.

132 comments

  1. Is it possible to have the splash screen appear only when the visitor wants to access certain pages?

    • Yes, I think that would be possible to add as a feature in the next version.

      Is this for something like a “adults only” section that would be in a specific category?

  2. Hi,

    great plugin. Thanks !

    Arnauld

  3. Having it for certain pages or posts would be a bonus, otherwise the plugin is cool.

    Keep up the good work.

  4. “Is this for something like a “adults only” section that would be in a specific category?”

    Yes, exactly. Especially for stuff on special pages. For example, if it’s blog that has fiction posted on pages, there could be some that have adult concepts and others that are free for the kids. Or think of the artists: they may have galleries on a few pages that are perfectly okay for 6 year olds to look at and then another page where they’ve got some pictures that are for adults only.

    I think that would be very very useful if you could use the splashscreen in a flexible way like that! :)

    • Got it Juno. The correct way would be to be able to set specific posts as “adult” and if it comes up on ANY page (e.g. archive, search), it should bring up the splash page. I’m not positive how to do it right now, but I’ll try to figure it out.

  5. After looking at this request for checking on a specific list of pages, it doesn’t look like it can be done without having to modify the theme you’re using because archive.php and search.php will show the content in question.

    If the plugin was looking for the specific URL of the post, this would not work because if a visitor used the archive or search feature, they would be able to see the content.

    If anybody can think of a way to do this without having to change the theme files, let me know and I’ll implement it.

  6. can this plugin be modded to display a a text for a certain period than redirect the user to another page? and if he comes back with the cookie set, redirect him straight without displaying the splashscreen?

    • I’m not sure I understand your question. You want to “display text,” meaning text other than on the splash screen? You mean like a pop-up or do you mean text shown along with your regular home page?

      Then it goes to “another page,” which I assume is a page you’ve created. For this page to set the cookie, you will have to put code in there to do so. A regular WordPress page cannot do this for you.

      If that page does set the cookie, the splash screen will not show.

  7. Where’s template.htm stored?

  8. My bad. found it in wp-content/plugins/splashscreen/ , of course. My FTP client wasnt refreshing the server view.

  9. Works like a charm. I desperately needed a plugin like this for about two weeks now. Tried to implement something from WordPressHero, but it was a half-baked explanation that led nowhere. Cheers, mate! You really saved my butt!

  10. Could the extension of ‘htm’ be changed to ‘php’ in this line of splashscreen.php:
    if( !is_dir($dir . $file) && strtolower($ext) == ‘htm’ )

    Thanks,
    Peter

    • I could (or you could), but then splashscreen.php would be included in the list of templates. I could change it to “.tpl”, or create a subdirectory with only the templates in them.

      Is there a specific reason why you need this?

  11. Yes, there is a specific reason I would like this. I have a custom splash screen page (ageverify.php) that I would like to use as the splashscreen that has some php in it: (print $domain = GetHostByName($REMOTE_ADDR);)
    It’s not absolutely necessary but….
    I have the ageverify.php page going to another php file also which records electronic signatures in the database. Maybe I should just something else rather than your plugin to do this?
    Not sure if I’ve explained myself well enough. If not, I could email you the file so maybe you could see what I’m saying. I don’t mean to cause any undue problems or anything. Thanks for any help/advice you are able to give.
    Pete

    • There’s a misunderstanding. Just because the template file has .htm extensions, does not mean they cannot contain PHP code in it.

      In fact, the sample template.htm file contain PHP code for outputting the header and footer via WordPress. Take a look at that sample file to see how it’s being done.

      Hope that helps.

  12. love the plug-in, BUT…

    it disables the RSS link for feedburner. the splash page won’t go away in order for someone to subscribe. this doesn’t make sense to me since it is not even on my domain.

    • So you want your RSS links to be live while the splash page is displayed? I guess this is basically the opposite request to the person that wanted only specific pages to show the splash page.

      Actually, I was thinking that some pages (e.g. terms of service, copyright notice) might want to be exempt from the splash page as well.

      What I need to do is to allow the admin to enter a list of pages that are exempt from the splash screen. I think this would be reasonable to implement. I’ll add this to the top of the to-do list.

  13. even if they have clicked to enter the site and are on the main content, once they click the rss feed (using Feedburner) the splash screen comes back up.

    in reality i just need a splash screen if a user is entering to the index page for the first time (or even better if they are not logged in) – like most sites.

    • Oh sorry, I misunderstood your 1st comment. I’m not familiar with how Feedburner works but there must be a conflict with the plug-in. If you are using a specific Feedbuner plug-in, let me know which one and I’ll have to look at their code to see what is going on.

      If you wrote your own plugin, tell me which WP hook you are using, and/or cookies and I’ll try to figure out where the conflict is.

  14. First off, thanks for this amazing plugin. It rocks!

    I’m having the same issue with the RSS feeds. Because the rss reader is trying to access the feed from the site, it’s hitting the splash page and not returning the feed.

    Is there a workaround for this?

    thanks!

  15. Great job.

    But I need help lil bit. It adds cookie but I don’t want it to add cookie. I want if visitor see splash page everytime when he join my site again.

    how can I do that?

    ps: sorry that my english isn’t good as I would like.

    keep up the good works.

    • The way this plugin works, the cookie is required to remember that the splash screen has been displayed.

      If you mean that you want the splash screen to appear again when they return to the site, it will do so if they closed the browser because the cookie will be gone between sessions.

      Hope that helps.

  16. Thanx for reply.

    Well, actually I want the splash page to appear again when they return the site without close browser. How can I do that?

    • I think what you want is just a “homepage” which can be done via:
      Administration > Settings > Reading > Front Page Displays > Static Page
      Then select the “homepage” that you want displayed.

      This has nothing to do with the plugin or cookies.

      Hope that’s what you wanted.

  17. my english sucks. :( dude, I want splash screen but I want when you click “Enter the site” delete cookie automaticly. Not at browser restart. Hope you understand.

    Thanx again for your reply. Keep up the good works.

    • I’m not understanding you. If you delete the cookie, the splash screen will re-appear and you will not be able to see your blog. The cookie is what causes the splash screen to NOT appear.

      Let me try to understand exactly what you want. If I go to your blog, I see the splash screen. I click on “I agree” and get to your blog. What do you want to happen at this point? You say you want the splash screen to re-appear without having to close the browser. So, I continue to navigate your blog and at what point does the splash screen re-appear again?

  18. first, let me say – brilliant and thank you.

    now, onto the small problem.

    If someone logs onto “painandwonder.com” and clicks “enter” they go right in. If someone logs onto “www.painandwonder.com” and clicks “enter” they get the same splashscreen and have to click “enter” again.

    Any ideas on how to get it to go right into the website no matter which “link” they go to?

    Thanks for your help in advance.

    • To make this work, change the setsplash function in the template you are using to the one as follows:

      function setsplash() {
      setCookie(“splash”, “1″, “”, “/”, “.painandwonder.com”);
      }

      Notice that there is a period in front of the domain name. This will make the cookie work for all subdomains (including www) in most browsers. If it does not work, please let me know what browser you are using.

  19. Work in wordpress 2.8?

  20. And how the search engines works with this plugin?
    There are some restrictions?

  21. hi!
    can i have a page with a flash animation as a splash page?

    i’m have some problems doing that

    thanks

  22. Hi, This plugin is exactly what I need, but it doesn’t seem to work under 2.8.2

    I’ve installed and activated, but there’s no screen like the one above for setting the template – can I do that somehow in the code, do you think?

    Thank you for your excellent work!

    S

    • I just tried it with 2.8.2 and it works fine as far as I can tell. The settings screen is located under “Settings” in the Admin screen on the left side.

  23. I've been experimenting with your plugin and I think it's great. I'm developing a WordPress website where I need a splash-screen to ask users to select between 2 languages. I can can get the plugin to work fine and it remembers a cookie for the first language, but then no cookie is set if someone clicks on the second language and the user sees the splascreen again – there's no way into the website.

    Is it possible to get the plugin to set 2 different types of cookies, depending on which language is selected?

    • Sure. Try this:

      <td align="left"><h2><a onclick="setsplash()" href="/lang1/">Lang 1</a></h2></td>
      <td align="right"><h2><a onclick="setsplash()" href="/lang2/">Lang 2</a></h2></td>

      Hope that helps.

  24. can you use this for a specific page rather than the whole site?

  25. great thanks!

  26. Hi, looks cool. Question: does this block Google's search activity when they want to index a site? G.

  27. How can I use this two record two different values in the cookie. For example, if they click on English (instead of I Agree) they will be redirected to "index.php/?lang=en", if they click on Spanish (instead of Do Not Agree) they will be redirected to "index.php/?lang=sp"

    • You can set the cookie name by changing the setcookie call. The first parameter is the name of the cookie (e..g.):
      setCookie("splash1", "1", exp, "/");
      setCookie("splash2", "1", exp, "/");

      But doing this will not work with the plugin because you will have to change the plugin PHP code to check for 2 different cookies instead of just one.

      Instead of doing it that way, I suggest you set an entirely different cookie for the language selection (e.g. "lang"). This way, you can keep the splashscreen plugin code unchanged and when you need to find out what language you are using, check your "lang" cookie instead.

  28. Thanks for your answer…
    Would it be possible to only change the value in the cookie. Than, instead of looking for two cookies, the PHP code could redirect according to the value it finds in the cookie…i.e. to link1 if value=1 or link2 if value=2 ? Do you know how we could modify the code to do so ?

    • I don't understand why the PHP code needs to redirect according to a cookie when the template itself can simply redirect to 2 different URL locations.

      In other words, if you click on link 1, it would simple go to URL 1, and click on link 2, and it would go to URL 2. No need to check any cookies.

      If you just want the value in the cookie to be different, use:
      setCookie("splash", "1",exp,"/");
      setCookie("splash", "2",exp,"/");

      Then, later in your website, you can check for the cookie "splash" for 1 or 2.

  29. Installed the update and cant find the SETSPLASH() function to change the cookies

    function setsplash() {
    var exp = new Date();
    var expDays = 365;
    exp.setTime(exp.getTime() + (expDays * 24 * 60 * 60 * 1000));
    setCookie("splash", "1", exp, "/");
    }

    Perhaps the next version could have this as a setting in the options? In the meantime – what exactly do I replace with the code above?

    Thanks Again! Great Plug In

    • The code should replace the existing setsplash function in the template. I've changed the post above so that it is now highlighted in green.

      Having this setting in the plugin option is a great idea. I'll put that on my list.

  30. It would be nice if there was a setting for only the home page, or specific pages. An include path might be more effective than an exclude path.

    Also, the plugin would destroy a site's SEO. It should check for known robots agent and exempt them from the splash screen.

    • I guess ideally I should have an exclude path list OR an include path list (selectable) because different sites seem to need different things. I don't think that would be real hard to do. It's just that I don't need it on my site so there's no reason for me to do it.

      Regarding your second idea/request, I think that's a super idea, and I need it for my own site but I don't know how to do it. Do you know where there's some documentation on this so I can learn about it and implement it? Thanks for any help. As repayment, I will put it in the plugin for everyone to use.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Hotwire: 4-Star Hotels at 2 Star Prices; Save 50%
Scroll To Top