Feb
18

Subscribe2 Widget Form – an alternate

WordPress  
Off

The wordpress subscribe 2 plugin is great – however the form in the widget bothers me. I have raised this  before. I’d prefer something with less “clicks” required  and less real estate occupied on the sidebar.

The original widget form:

Original subscribe 2 form

Original subscribe 2 form

Variations on alternate form:

(Note everything else works / is the original subscribe 2.  Only the form html and validating code has changed slightly).

Alternate subscribe form

Alternate subscribe form

Alternate in a wider sidebar

Alternate with title for subscribe form

Alternate with title for subscribe form

Customising the original is usually not a good idea….

I began developing an  ‘alternate’ widget leveraging off Mathews code, to be able to pickup any version changes and just work “on top” as an extra.   It worked but not ideally.  So I stopped and  decided to write the code changes up again and try to persuade Matthew to implement in the next version – I’ve done the testing and validation and itemised the code changes and provided an updated  file. Please add your voice to the call . A donation to him would not hurt either!

Test it out

You may test this alternate form out at my play site.  Subscribe and unsubscribe as you wish.  This is purely so you will see it is still the same plugin!

Download

The edited subscribe2.php   I have called subscribe2-alt (right click and save as). I suggest you copy and rename the plugin folder.  Deactivate the unedited version, but keep it there (so you can see when updates are made – you may need/want them).

The form code changes

These code changes are for version 4.13.   Both the css and html validate 100%.  In each section, comment out the line that is commented out here and replace with the other line/s below.   I have incremented the line numbers as they would when you edit it.  Thus if you are just looking at the code,you may need to look at the line numbers a bit earlier, or search on the text.

CSS for buttons

Note that I have included css for the submit buttons.      I tested on some of the ithemes themes.  The sidebars were narrower than some of my own themes and I wanted the buttons on the same page.  I experiemented with “Undo” instead of “unsubscribe” but decided that it was not user friendly and would not pickup translations as “Undo” was not in the Subscribe2 translation file.   So instead I reduced the padding and margins as much as I could without it looking too bad. If your theme’s sidebar is wider, I suggest spacing the buttons a bit more, ore moving the code and let your theme style the form.    EG: 0.5em on padding and the right margin.

line 79:

/* amr comment out:       $this->form = "<form method=\"post\" action=\"\"><p>" . __('Your email:', 'subscribe2') . "<br /><input type=\"text\" name=\"email\" value=\"\" size=\"20\" /><br /><input type=\"radio\" name=\"s2_action\" value=\"subscribe\" checked=\"checked\" />" . __('Subscribe', 'subscribe2') . "&nbsp;&nbsp;&nbsp;<input type=\"radio\" name=\"s2_action\" value=\"unsubscribe\" />" . __('Unsubscribe', 'subscribe2') . "<br /><input type=\"submit\" value=\"" . __('Send', 'subscribe2') . "\" /></p></form>\r\n"; */

replace with

$this->form = '<form method="post" action="' .'"><input type="text" name="email" value="' .__('Email address', 'subscribe2').'" size="20" />' .'<input style="padding: 0 ; margin-right:0.02em;" type="submit" name="wsubscribe" value="' . __('Subscribe', 'subscribe2') . '" />' .'<input style="padding: 0 ;" type="submit" name="wunsubscribe" value="' . __('Unsubscribe', 'subscribe2') . '" /></form>';

approx line 2319:

/* amr comment out:  if (isset($_POST['s2_action'])) {*/

replace with

if ((isset($_POST['wsubscribe'])) || (isset($_POST['wunsubscribe']))) {

approx line 2337:

/* amr comment out: if ('subscribe' == $_POST['s2_action']) { */

replace with

if (isset ($_POST['wsubscribe'])) {

approx line 2337:

/* amr comment out: } elseif ('unsubscribe' == $_POST['s2_action']) { */

replace with

} elseif (isset( $_POST['wunsubscribe'])) {

approx line 2358:

/* amr comment out:  } elseif ('unsubscribe' == $_POST['s2_action']) { */

replace with

} elseif (isset( $_POST['wunsubscribe'])) {

Another change request for another day

I’d like to re organise the admin area for my clients.  They don’t need to see the more complicated configuration.   They are interested in their subscribers however.  So I would like to have two levels of administration and improve the layout of the subscriber list, keeping it to just the list info.    I’d be happy to do this if work has not already been done on it.

Related posts:

  1. Subscribe2 widget markup and css Please refer to updated instructions. The wordpress subscribe 2 plugin is great. Version 4.9 just released – a wonderful alternative...
  2. Subscribe2 Admin – manage subscribers I had remarked that I thought the Subscribe 2 admin subscriber could do with a few tweaks.  I was asked...
  3. A Duh! moment – better widgets For a relatively intelligent person (qualified for Mensa, albeit before kids and other brain challenging occurences), I still have some...
  4. Shortcode a widget in a page or post Shortcodize a widget - Use any widget in a shortcode in a page or post...
Categories : WordPress

WP Questions

Preferred Web Host

Web hosting by ICDSoft Icdsoft - Why? They are good and reasonable, used them since 2001. Read more