Well, I finally had a bit of time to dig Lester Chan’s code and I’m happy to say I have a working solution.
I really do not like to follow others code and do reverse engineering, but in this case there was no choice, since I needed this feature for my client and it appeared that Lester has no time to check this.
To remind you, the problem was when trying to use the plugin with Custom Post Type and with non-default permalinks structure.
My solution deals only with using the stand alone page, and not with the popup option (In the matter of fact, I am using the stand alone email page and taking the div with the form in order to pop it up into a nice colorbox window, since popups are so 90’s and part of the time blocked..)
Line numbers inside the code are referring to latest WP-Email ver2.5.2.
Go to line 234, you will find this block of code in lines 234-261
switch($email_type) {
// E-Mail Standalone Page
case 1:
if(!empty($using_permalink)) {
if(substr($email_link, -1, 1) != '/') {
$email_link= $email_link.'/';
}
if(is_page()) {
if(empty($email_page_text)) {
$email_text = stripslashes($email_options['page_text']);
} else {
$email_text = $email_page_text;
}
$email_link = $email_link.'emailpage/';
} else {
$email_link = $email_link.'email/';
}
} else {
if(is_page()) {
if(empty($email_page_text)) {
$email_text = stripslashes($email_options['page_text']);
} else {
$email_text = $email_page_text;
}
}
$email_link = $email_link.'&email=1';
}
break;
You should replace it with this:
switch($email_type) {
// E-Mail Standalone Page
case 1:
if(!empty($using_permalink)) {
if(substr($email_link, -1, 1) != '/') {
$email_link= $email_link.'/';
}
if(is_page()) {
if(empty($email_page_text)) {
$email_text = stripslashes($email_options['page_text']);
} else {
$email_text = $email_page_text;
}
$email_link = $email_link.'emailpage/';
}
elseif (is_singular() && !is_singular('post')) {
$email_link = $email_link.'?email=1';
}
else {
$email_link = $email_link.'email/';
}
} else {
if(is_page()) {
if(empty($email_page_text)) {
$email_text = stripslashes($email_options['page_text']);
} else {
$email_text = $email_page_text;
}
}
$email_link = $email_link.'&email=1';
}
break;
What I have actually changed, is adding these lines to 249-251 –
elseif (is_singular() && !is_singular('post')) {
$email_link = $email_link.'?email=1';
}
It will tell WP that if you are in a case of using non-default permalinks, and you are on a single page of a non-post type (aka, custom post type), than to populate the email page with a query variable ?email=1.
Well, it works for me, and opening the standalone and also of course my nice colorbox.
I hope it will help some of you.
Lester Chan, if you add this as a version fix, I’d be happy if you could grant me a small credit of thanks inside the plugin ??