The Whatever Plugins for WordPress

Posted September 17th, 2007 by Mike Cherim

Set up is a breeze: Copy it. Save it. Load it. Activate it. Use it for whatever.

If you’ve ever wanted an extra page for whatever in your WordPress admin, this is one way to get your wish. On this page you’ll find two scripts for a couple of open-ended plugins. One is the Whatever plugin, and the second one will give you a head start by offering you a Whatever Links plugin script. To use these scripts, just follow the simple instructions at the end of this post. These plugins should work without a problem on all (see comments) current WordPress versions. The protected content these plugins afford could be had via a password protected post or page, but this is more convenient as there’s a single login only and it’s rights managed.

The Whatever Plugin

Okay, here’s the first script. Use this plugin for whatever protected content you would like. Notes to yourself, a code snippet repository, even memos to others who have the appropriate rights.

<?php
  if ('whatever.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die ('<h2>Direct File Access Prohibited</h2>');
/*
Plugin Name: Whatever
Plugin URI: http://green-beast.com/blog/?p=202
Description: An open-ended plugin for snippets, notes, whatever you want.
Version: 1.0
Author: Mike Cherim
Author URI: http://green-beast.com/
*/
function wp_whatever() {
// If you want to change the name on the menu link, change below only
  add_menu_page('Whatever', 'Whatever', 7, __FILE__, 'wp_whatever_page');
} // the 7 above is the user level allowed to access the page
  add_action('admin_menu', 'wp_whatever');
function wp_whatever_page() { ?>
<div class="wrap what_wrap">
 <h2>The Whatever Plugin</h2>
  <p>Use this page for <strong>whatever</strong> you want.
  <br /><small>To edit or add content, please use your <a href="plugin-editor.php?file=whatever.php">plugin editor</a>.</small></p>
</div>
<!--Start editing below this point-->

 <div class="wrap">
  <h2>Your Content Heading</h2>
   <p>And this could be your content. It must be valid, so this is great for people who now their code.</p>
 </div>

<!--End editable-->
 <div class="wrap">
  <p class="submit what_cred">This &#8220;<?php echo wptexturize(get_settings(('blogname'))); ?>&#8221; admin page built upon the &#8220;Whatever&#8221; plugin by <a href="http://green-beast.com/">Mike Cherim</a> &raquo;</p>
 </div>
<?php } function whatever_admin_styles() { ?>
 <style type="text/css" media="screen">
  div.what_wrap p { margin : 0; }
  p.what_cred { color : #666; margin : 0; }
 </style>
<?php } add_action('admin_head', 'whatever_admin_styles'); ?>
 

Be sure to add valid markup when entering content in this page. For complete novices who do not code at all, neither of these plugins are for you since an understanding of writing code is a must.

Get the PHP Whatever plugin source file.

Now, here’s the second script. Use this plugin for whatever links you want. This script allows you to choose whether the page’s links open in a new window or not. The preference is not saved and defaults to same window launching on load.

<?php
  if ('whatever-links.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die ('<h2>Direct File Access Prohibited</h2>');
/*
Plugin Name: Whatever Links
Plugin URI: http://green-beast.com/blog/?p=202
Description: An open-ended plugin for whatever links to wherever.
Version: 1.0
Author: Mike Cherim
Author URI: http://green-beast.com/
*/
function wp_whatever_links() {
// If you want to change the name on the menu link, change below only
  add_menu_page('Whatever Links', 'Whatever Links', 7, __FILE__, 'wp_whatever_links_page');
} // the 7 above is the user level allowed to access the page
  add_action('admin_menu', 'wp_whatever_links');
function wp_whatever_links_page() {
// windows launching script
  if ($_POST['new']){
    $new = $_POST['new'];
    $new = stripslashes(strip_tags(trim($new)));
// there are better ways to do this JS but I am JS-stupid
    $nw=" onclick=\"target='_blank'\" onkeypress=\"target='_blank'\"";
    $nw_btn='<input type="submit" name="self" alt="Deactivate New Windows" value="Deactivate New Windows" /> <span class="what_text">New Windows <span class="what_on">On</span></span>';
  } else if ($_POST['self']) {
    $new = $_POST['self'];
    $self = stripslashes(strip_tags(trim($self)));
    $nw="";
    $nw_btn='<input type="submit" name="new" alt="Activate New Windows" value="Activate New Windows" /> <span class="what_text">New Windows <span class="what_off">Off</span></span>';
  } else {
    $nw="";
    $nw_btn='<input type="submit" name="new" alt="Activate New Windows" value="Activate New Windows" /> <span class="what_text">New Windows <span class="what_off">Off</span></span>';
  } ?>
<div class="wrap what_wrap">
 <h2>The Whatever Links Plugin</h2>
  <p>Use this page to store <strong>whatever links</strong> you want.</p>
<!--activation form-->
    <form id="what_form" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
      <fieldset>
        <legend><span>Launch&#8230;</span></legend>
          <p class="submit"><?php echo $nw_btn; ?></p>
      </fieldset>
    </form>
  <p><small>To edit or add links, please use your <a href="plugin-editor.php?file=whatever-links.php">plugin editor</a>.</small></p>
</div>
<!--Start editing below this point-->

 <div class="wrap">
  <h2>Your Links List</h2>
   <p>These are your important example links to wherever.</p>
     <ul>
       <li><a<?php echo $nw; ?> href="http://green-beast.com/">Mike Cherim</a></li>
     </ul>
 </div>

<!--End editable-->
 <div class="wrap">
  <p class="submit what_cred">This &#8220;<?php echo wptexturize(get_settings(('blogname'))); ?>&#8221; admin page built upon the &#8220;Whatever Links&#8221; plugin by <a<?php echo $nw; ?> href="http://green-beast.com/">Mike Cherim</a> &raquo;</p>
 </div>
<?php } function whatever_links_admin_styles() { ?>
 <style type="text/css" media="screen">
  div.what_wrap p { margin : 0; }
  form#what_form fieldset { margin : 0; padding : 0; }
  form#what_form legend span { position : absolute; top : -9000px; left : -9000px; }
  form#what_form p.submit { text-align : left; margin : 0; padding : 0; }
  form#what_form input { cursor : pointer; }
  p.what_cred { color : #666; margin : 0; }
  .what_text { color : #999; font-weight : bold; }
  .what_off { color : #ca0000; }
  .what_on { color : #669933; }
 </style>
<?php } add_action('admin_head', 'whatever_links_admin_styles'); ?>
 

To add more links to the page above, just copy and paste the link line and repeat as necessary. You might also want to copy the whole div to offer yourself several link categories.

Get the PHP Whatever Links plugin source file.

Simple Instructions for Both

Set up is a breeze: Copy it. Save it. Load it. Activate it. Use it for whatever. Here are the details about what exactly you need to do to use these plugins/scripts.

  1. Copy your preferred script in its entirety into a text file and save it, naming the “Whatever” plugin whatever.php, and the “Whatever Links” plugin whatever-links.php.
  2. Load the file into your WordPress plugins directory: /wp-content/plugins/ and make it writable by setting the permissions (CHMOD) to 666 so you can edit it from the plugin editor.
  3. In your WordPress admin, on the “Plugins” page, activate your new plugin. You’ll then see a link for your new page on the admin upper navigation menu. Check it out.
  4. Then use it as you see fit. If it’s the “Whatever” plugin you’ll add whatever, and if it’s the “Whatever Links” plugin you’ll probably want to add some links. You can access the file for editing from the page itself. A link is provided.

And that’s that! Questions or whatever? :beast:


4 Responses to: “The Whatever Plugins for WordPress”

  1. David Zemens responds:
    Posted: September 18th, 2007 at 11:10 am

    As I mentioned in an email I sent you, Mike, this is the error I get when installling in v2.1. The install seems to complete, but when I activate the plugin and try to modify the page, I continue to receive this same error:

    Warning: Cannot modify header information - headers already sent by (output started at /home/UserName/public_html/wp/wp-content/plugins/whatever.php:39) in /home/UserName/public_html/wp/wp-includes/pluggable.php on line 275

  2. David Zemens responds:
    Posted: September 18th, 2007 at 4:56 pm

    It may be a plugin conflict, MIke. I will be curious to see what other say. If someone else can make it work with v2.1, then I will set about tweaking my plugins on/off and see which one it conflicts with. No worries…thanks for the plugin.

Sorry. Comments are closed.




Note: This is the end of the usable page. The image(s) below are preloaded for performance only.