Version Description
(2013.04.05) = * Apply Postie Time Correction to date: command * Add support for Post Formats * Add support for Post Status * Add warning if Admin username is invalid * Fixed bug where date: was not always being detected in html emails * Improved handling of attachments and mapping to file extensions for template selection * Video templates now include scale="tofit" * Add support for older png mime type * New filter postie_filter_email. Used to map "from" to any other email. Allows custom user mapping.
Download this release
Release Info
Developer | WayneAllen |
Plugin | Postie |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.40 to 1.5.0
- Revision +0 -2
- config_form.php +170 -166
- docs/Changes.txt +17 -0
- docs/Postie.txt +1 -1
- docs/TODO.txt +5 -17
- docs/Usage.txt +9 -4
- filterPostie.php.sample +57 -59
- postie-functions.php +226 -125
- postie.php +29 -14
- readme.html +19 -4
- readme.txt +27 -5
- templates/video1_templates.php +5 -5
- test/inlineimageTest.php +7 -5
- test/postie-functionsTest.php +121 -42
- test/wpstub.php +17 -2
Revision
CHANGED
@@ -1,2 +0,0 @@
|
|
1 |
-
Revision: 683827
|
2 |
-
Last Changed Date: 2013-03-16 17:23:28 -0700 (Sat, 16 Mar 2013)
|
|
|
|
config_form.php
CHANGED
@@ -172,40 +172,40 @@
|
|
172 |
<td>
|
173 |
<select name='postie-settings[interval]' id='postie-settings-interval'>
|
174 |
<option value="weekly" <?php
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
<option value="daily"<?php
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
<option value="hourly" <?php
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
<option value="twiceperhour" <?php
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
<option value="tenminutes" <?php
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
<option value="fiveminutes" <?php
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
<option value="manual" <?php
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
</select>
|
210 |
</td>
|
211 |
</tr>
|
@@ -232,7 +232,7 @@
|
|
232 |
<div id="simpleTabs-content-2" class="simpleTabs-content">
|
233 |
<table class='form-table'>
|
234 |
|
235 |
-
<?php echo BuildBooleanSelect(__("Allow Anyone To Post Via Email"), "postie-settings[turn_authorization_off]", $turn_authorization_off, "Changing this to yes is
|
236 |
<tr>
|
237 |
<th scope="row">
|
238 |
<?php _e('Roles That Can Post:', 'postie') ?><br />
|
@@ -268,32 +268,7 @@
|
|
268 |
</table>
|
269 |
</td>
|
270 |
</tr>
|
271 |
-
|
272 |
-
<th width="33%" valign="top" scope="row"><?php _e('Post status:', 'postie') ?> </th>
|
273 |
-
<td>
|
274 |
-
<select name='postie-settings[post_status]' id='postie-settings-post_status'>
|
275 |
-
<option value="publish" <?php
|
276 |
-
if ($post_status == "publish") {
|
277 |
-
echo "selected";
|
278 |
-
}
|
279 |
-
?>>Published</option>
|
280 |
-
<option value="draft" <?php
|
281 |
-
if ($post_status == "draft") {
|
282 |
-
echo "selected";
|
283 |
-
}
|
284 |
-
?>>Draft</option>
|
285 |
-
<option value="pending" <?php
|
286 |
-
if ($post_status == "pending") {
|
287 |
-
echo "selected";
|
288 |
-
}
|
289 |
-
?>>Pending Review</option>
|
290 |
-
<option value="private" <?php
|
291 |
-
if ($post_status == "private") {
|
292 |
-
echo "selected";
|
293 |
-
}
|
294 |
-
?>>Private</option>
|
295 |
-
</select> </td>
|
296 |
-
</tr>
|
297 |
<?php echo BuildTextArea("Authorized Addresses", "postie-settings[authorized_addresses]", $authorized_addresses, "Put each email address on a single line. Posts from emails in this list will be treated as if they came from the admin. If you would prefer to have users post under their own name - create a WordPress user with the correct access level."); ?>
|
298 |
<tr>
|
299 |
<th width="33%" valign="top" scope="row">
|
@@ -331,6 +306,35 @@
|
|
331 |
<input type='text' name='postie-settings[default_post_tags]' id='postie-settings-default_post_tags' value='<?php echo esc_attr($default_post_tags) ?>' />
|
332 |
</td>
|
333 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
<tr>
|
335 |
<th width="33%" valign="top" scope="row"><?php _e('Default Title:', 'postie') ?> </th>
|
336 |
<td>
|
@@ -432,8 +436,8 @@
|
|
432 |
<input type='hidden' id='postie-settings-selected_imagetemplate' name='postie-settings[selected_imagetemplate]'
|
433 |
value="<?php echo esc_attr($selected_imagetemplate) ?>" />
|
434 |
<select name='imagetemplateselect' id='imagetemplateselect'
|
435 |
-
onchange="changeStyle('imageTemplatePreview','postie-settings-imagetemplate',
|
436 |
-
|
437 |
<?php
|
438 |
include('templates/image_templates.php');
|
439 |
$styleOptions = $imageTemplates;
|
@@ -456,7 +460,7 @@
|
|
456 |
|
457 |
<?php _e('Preview', 'postie'); ?>
|
458 |
<div id='imageTemplatePreview'></div>
|
459 |
-
<textarea onchange='changeStyle("imageTemplatePreview", "postie-settings-imagetemplate", "imagetemplateselect",
|
460 |
"postie-settings-selected_imagetemplate", "smiling.jpg", true);' cols='70' rows='7' id='postie-settings-imagetemplate' name='postie-settings[imagetemplate]'>
|
461 |
<?php echo esc_attr($imagetemplate) ?>
|
462 |
</textarea>
|
@@ -483,7 +487,7 @@
|
|
483 |
<input type='hidden' id='postie-settings-selected_video1template' name='postie-settings[selected_video1template]'
|
484 |
value="<?php echo esc_attr($selected_video1template) ?>" />
|
485 |
<select name='video1templateselect' id='video1templateselect'
|
486 |
-
onchange="changeStyle('video1TemplatePreview','postie-settings-video1template', 'video1templateselect', 'postie-settings-selected_video1template','hi.mp4');" />
|
487 |
<?php
|
488 |
include('templates/video1_templates.php');
|
489 |
$styleOptions = $video1Templates;
|
@@ -506,15 +510,15 @@
|
|
506 |
|
507 |
<?php _e('Preview', 'postie'); ?>
|
508 |
<div id='video1TemplatePreview'></div>
|
509 |
-
<textarea onchange="changeStyle('video1TemplatePreview','postie-settings-video1template',
|
510 |
-
'video1templateselect', 'postie-settings-selected_video1template','hi.mp4',true);" cols='70' rows='7' id='postie-settings-video1template'
|
511 |
name='postie-settings[video1template]'><?php echo esc_attr($video1template) ?></textarea>
|
512 |
</td>
|
513 |
</tr>
|
514 |
<tr>
|
515 |
<th width="33%" valign="top" scope="row">
|
516 |
-
<?php _e('Video 1 file
|
517 |
-
<?php _e('Use
|
518 |
<td>
|
519 |
<br/><input name='postie-settings[video1types]' type="text" id='postie-settings-video1types'
|
520 |
value="<?php if ($video1types != '') echo esc_attr($video1types); ?>" size="40" />
|
@@ -530,8 +534,8 @@
|
|
530 |
<input type='hidden' id='postie-settings-selected_video2template' name='postie-settings[selected_video2template]'
|
531 |
value="<?php echo esc_attr($selected_video2template) ?>" />
|
532 |
<select name='video2templateselect' id='video2templateselect'
|
533 |
-
onchange="changeStyle('video2TemplatePreview','postie-settings-video2template',
|
534 |
-
|
535 |
<?php
|
536 |
include('templates/video2_templates.php');
|
537 |
$styleOptions = $video2Templates;
|
@@ -553,8 +557,8 @@
|
|
553 |
|
554 |
<?php _e('Preview', 'postie'); ?>
|
555 |
<div id='video2TemplatePreview'></div>
|
556 |
-
<textarea onchange="changeStyle('video2TemplatePreview','postie-settings-video2template',
|
557 |
-
'video2templateselect', 'postie-settings-selected_video2template','hi.flv',true);" cols='70' rows='7' id='postie-settings-video2template'
|
558 |
name='postie-settings[video2template]'>
|
559 |
<?php echo esc_attr($video2template) ?>
|
560 |
</textarea>
|
@@ -562,8 +566,8 @@
|
|
562 |
</tr>
|
563 |
<tr>
|
564 |
<th width="33%" valign="top" scope="row">
|
565 |
-
<?php _e('Video 2 file
|
566 |
-
<?php _e('Use
|
567 |
</th>
|
568 |
<td>
|
569 |
<br/><input name='postie-settings[video2types]' type="text" id='postie-settings-video2types'
|
@@ -580,8 +584,8 @@
|
|
580 |
<input type='hidden' id='postie-settings-selected_audiotemplate' name='postie-settings[selected_audiotemplate]'
|
581 |
value="<?php echo esc_attr($selected_audiotemplate) ?>" />
|
582 |
<select name='audiotemplateselect' id='audiotemplateselect'
|
583 |
-
onchange="changeStyle('audioTemplatePreview','postie-settings-audiotemplate',
|
584 |
-
|
585 |
<?php
|
586 |
include('templates/audio_templates.php');
|
587 |
$styleOptions = $audioTemplates;
|
@@ -604,15 +608,15 @@
|
|
604 |
|
605 |
<?php _e('Preview', 'postie'); ?>
|
606 |
<div id='audioTemplatePreview'></div>
|
607 |
-
<textarea onchange="changeStyle('audioTemplatePreview','postie-settings-audiotemplate',
|
608 |
-
'audiotemplateselect', 'postie-settings-selected_audiotemplate','funky.mp3', true);" cols='70' rows='7' id='postie-settings-audiotemplate'
|
609 |
name='postie-settings[audiotemplate]'><?php echo esc_attr($audiotemplate) ?></textarea>
|
610 |
</td>
|
611 |
</tr>
|
612 |
<tr>
|
613 |
<th width="33%" valign="top" scope="row">
|
614 |
-
<?php _e('Audio file
|
615 |
-
<span class='recommendation'><?php _e('Use the audio template for these
|
616 |
|
617 |
</th>
|
618 |
<td>
|
@@ -709,96 +713,96 @@
|
|
709 |
|
710 |
<?php $iconDir = get_option('siteurl') . '/' . PLUGINDIR . '/postie/icons'; ?>
|
711 |
<script type="text/javascript">
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
});
|
721 |
-
|
722 |
-
function changeIconSet(selectBox, size) {
|
723 |
-
var iconSet=document.getElementById('postie-settings-icon_set');
|
724 |
-
var iconSize=document.getElementById('postie-settings-icon_size');
|
725 |
-
var preview=document.getElementById('postie-settings-attachment_preview');
|
726 |
-
var iconDir = '<?php echo $iconDir ?>/';
|
727 |
-
if (size==true) {
|
728 |
-
var hiddenInput=iconSize
|
729 |
-
} else {
|
730 |
-
var hiddenInput=iconSet;
|
731 |
-
}
|
732 |
-
for(i=0; i<selectBox.options.length; i++) {
|
733 |
-
if (selectBox.options[i].selected == true) {
|
734 |
-
hiddenInput.value=selectBox.options[i].value;
|
735 |
-
}
|
736 |
-
}
|
737 |
-
var fileTypes= new Array('doc', 'pdf', 'xls', 'ppt');
|
738 |
-
preview.innerHTML='';
|
739 |
-
for (j=0; j<fileTypes.length; j++) {
|
740 |
-
preview.innerHTML+="<img src='" + iconDir + iconSet.value + '/' +
|
741 |
-
fileTypes[j] + '-' + iconSize.value + ".png' />";
|
742 |
-
}
|
743 |
-
preview.innerHTML+='<br />Here is some sample text with a link to a ' +
|
744 |
-
'word document that I think you might find interesting<br />' +
|
745 |
-
"<a href='#'><img style='text-decoration:none' src='" +
|
746 |
-
iconDir + iconSet.value + '/doc' +
|
747 |
-
'-' + iconSize.value + ".png' />Interesting document</a>";
|
748 |
-
}
|
749 |
-
|
750 |
-
function changeStyle(preview,template,select,selected,sample,custom) {
|
751 |
-
var preview = document.getElementById(preview);
|
752 |
-
var pageStyles = document.getElementById(select);
|
753 |
-
var selectedStyle;
|
754 |
-
var hiddenStyle=document.getElementById(selected);
|
755 |
-
var pageStyle = document.getElementById(template);
|
756 |
-
if (custom==true) {
|
757 |
-
selectedStyle=pageStyles.options[pageStyles.options.length-1];
|
758 |
-
selectedStyle.value=pageStyle.value;
|
759 |
-
selectedStyle.selected=true;
|
760 |
-
} else {
|
761 |
-
for(i=0; i<pageStyles.options.length; i++) {
|
762 |
-
if (pageStyles.options[i].selected == true) {
|
763 |
-
selectedStyle=pageStyles.options[i];
|
764 |
-
}
|
765 |
-
}
|
766 |
-
}
|
767 |
-
hiddenStyle.value=selectedStyle.innerHTML
|
768 |
-
var previewHTML=selectedStyle.value;
|
769 |
-
var fileLink = '<?php echo $templateDir ?>/' + sample;
|
770 |
-
var thumb = '<?php echo $templateDir ?>/' + sample.replace(/\.jpg/,
|
771 |
-
'-150x150.jpg');
|
772 |
-
var medium = '<?php echo $templateDir ?>/' + sample.replace(/\.jpg/,
|
773 |
-
'-300x200.jpg');
|
774 |
-
var large = '<?php echo $templateDir ?>/' + sample.replace(/\.jpg/,
|
775 |
-
'-1024x682.jpg');
|
776 |
-
previewHTML=previewHTML.replace(/{FILELINK}/g, fileLink);
|
777 |
-
previewHTML=previewHTML.replace(/{IMAGE}/g, fileLink);
|
778 |
-
previewHTML=previewHTML.replace(/{FILENAME}/, sample);
|
779 |
-
previewHTML=previewHTML.replace(/{THUMB(NAIL|)}/, thumb);
|
780 |
-
previewHTML=previewHTML.replace(/{MEDIUM}/, medium);
|
781 |
-
previewHTML=previewHTML.replace(/{LARGE}/, large);
|
782 |
-
previewHTML=previewHTML.replace(/{CAPTION}/g, 'Spencer smiling');
|
783 |
-
preview.innerHTML=previewHTML;
|
784 |
-
pageStyle.value=selectedStyle.value;
|
785 |
-
}
|
786 |
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
804 |
</script>
|
172 |
<td>
|
173 |
<select name='postie-settings[interval]' id='postie-settings-interval'>
|
174 |
<option value="weekly" <?php
|
175 |
+
if ($interval == "weekly") {
|
176 |
+
echo "selected='selected'";
|
177 |
+
}
|
178 |
+
?>><?php _e('Once weekly', 'postie') ?></option>
|
179 |
<option value="daily"<?php
|
180 |
+
if ($interval == "daily") {
|
181 |
+
echo "selected='selected'";
|
182 |
+
}
|
183 |
+
?>><?php _e('daily', 'postie') ?></option>
|
184 |
<option value="hourly" <?php
|
185 |
+
if ($interval == "hourly") {
|
186 |
+
echo "selected='selected'";
|
187 |
+
}
|
188 |
+
?>><?php _e('hourly', 'postie') ?></option>
|
189 |
<option value="twiceperhour" <?php
|
190 |
+
if ($interval == "twiceperhour") {
|
191 |
+
echo "selected='selected'";
|
192 |
+
}
|
193 |
+
?>><?php _e('twice per hour', 'postie') ?></option>
|
194 |
<option value="tenminutes" <?php
|
195 |
+
if ($interval == "tenminutes") {
|
196 |
+
echo "selected='selected'";
|
197 |
+
}
|
198 |
+
?>><?php _e('every ten minutes', 'postie') ?></option>
|
199 |
<option value="fiveminutes" <?php
|
200 |
+
if ($interval == "fiveminutes") {
|
201 |
+
echo "selected='selected'";
|
202 |
+
}
|
203 |
+
?>><?php _e('every five minutes', 'postie') ?></option>
|
204 |
<option value="manual" <?php
|
205 |
+
if ($interval == "manual") {
|
206 |
+
echo "selected='selected'";
|
207 |
+
}
|
208 |
+
?>><?php _e('check manually', 'postie') ?></option>
|
209 |
</select>
|
210 |
</td>
|
211 |
</tr>
|
232 |
<div id="simpleTabs-content-2" class="simpleTabs-content">
|
233 |
<table class='form-table'>
|
234 |
|
235 |
+
<?php echo BuildBooleanSelect(__("Allow Anyone To Post Via Email"), "postie-settings[turn_authorization_off]", $turn_authorization_off, "Changing this to yes <b style='color: red'>is not recommended</b> - anything that gets sent in will automatically be posted."); ?>
|
236 |
<tr>
|
237 |
<th scope="row">
|
238 |
<?php _e('Roles That Can Post:', 'postie') ?><br />
|
268 |
</table>
|
269 |
</td>
|
270 |
</tr>
|
271 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
<?php echo BuildTextArea("Authorized Addresses", "postie-settings[authorized_addresses]", $authorized_addresses, "Put each email address on a single line. Posts from emails in this list will be treated as if they came from the admin. If you would prefer to have users post under their own name - create a WordPress user with the correct access level."); ?>
|
273 |
<tr>
|
274 |
<th width="33%" valign="top" scope="row">
|
306 |
<input type='text' name='postie-settings[default_post_tags]' id='postie-settings-default_post_tags' value='<?php echo esc_attr($default_post_tags) ?>' />
|
307 |
</td>
|
308 |
</tr>
|
309 |
+
|
310 |
+
<tr>
|
311 |
+
<th width="33%" valign="top" scope="row"><?php _e('Default Post Status:', 'postie') ?> </th>
|
312 |
+
<td>
|
313 |
+
<select name='postie-settings[post_status]' id='postie-settings-post_status'>
|
314 |
+
<option value="publish" <?php
|
315 |
+
if ($post_status == "publish") {
|
316 |
+
echo "selected";
|
317 |
+
}
|
318 |
+
?>>Published</option>
|
319 |
+
<option value="draft" <?php
|
320 |
+
if ($post_status == "draft") {
|
321 |
+
echo "selected";
|
322 |
+
}
|
323 |
+
?>>Draft</option>
|
324 |
+
<option value="pending" <?php
|
325 |
+
if ($post_status == "pending") {
|
326 |
+
echo "selected";
|
327 |
+
}
|
328 |
+
?>>Pending Review</option>
|
329 |
+
<option value="private" <?php
|
330 |
+
if ($post_status == "private") {
|
331 |
+
echo "selected";
|
332 |
+
}
|
333 |
+
?>>Private</option>
|
334 |
+
</select>
|
335 |
+
</td>
|
336 |
+
</tr>
|
337 |
+
|
338 |
<tr>
|
339 |
<th width="33%" valign="top" scope="row"><?php _e('Default Title:', 'postie') ?> </th>
|
340 |
<td>
|
436 |
<input type='hidden' id='postie-settings-selected_imagetemplate' name='postie-settings[selected_imagetemplate]'
|
437 |
value="<?php echo esc_attr($selected_imagetemplate) ?>" />
|
438 |
<select name='imagetemplateselect' id='imagetemplateselect'
|
439 |
+
onchange="changeStyle('imageTemplatePreview', 'postie-settings-imagetemplate',
|
440 |
+
'imagetemplateselect', 'postie-settings-selected_imagetemplate', 'smiling.jpg');" >
|
441 |
<?php
|
442 |
include('templates/image_templates.php');
|
443 |
$styleOptions = $imageTemplates;
|
460 |
|
461 |
<?php _e('Preview', 'postie'); ?>
|
462 |
<div id='imageTemplatePreview'></div>
|
463 |
+
<textarea onchange='changeStyle("imageTemplatePreview", "postie-settings-imagetemplate", "imagetemplateselect",
|
464 |
"postie-settings-selected_imagetemplate", "smiling.jpg", true);' cols='70' rows='7' id='postie-settings-imagetemplate' name='postie-settings[imagetemplate]'>
|
465 |
<?php echo esc_attr($imagetemplate) ?>
|
466 |
</textarea>
|
487 |
<input type='hidden' id='postie-settings-selected_video1template' name='postie-settings[selected_video1template]'
|
488 |
value="<?php echo esc_attr($selected_video1template) ?>" />
|
489 |
<select name='video1templateselect' id='video1templateselect'
|
490 |
+
onchange="changeStyle('video1TemplatePreview', 'postie-settings-video1template', 'video1templateselect', 'postie-settings-selected_video1template', 'hi.mp4');" />
|
491 |
<?php
|
492 |
include('templates/video1_templates.php');
|
493 |
$styleOptions = $video1Templates;
|
510 |
|
511 |
<?php _e('Preview', 'postie'); ?>
|
512 |
<div id='video1TemplatePreview'></div>
|
513 |
+
<textarea onchange="changeStyle('video1TemplatePreview', 'postie-settings-video1template',
|
514 |
+
'video1templateselect', 'postie-settings-selected_video1template', 'hi.mp4', true);" cols='70' rows='7' id='postie-settings-video1template'
|
515 |
name='postie-settings[video1template]'><?php echo esc_attr($video1template) ?></textarea>
|
516 |
</td>
|
517 |
</tr>
|
518 |
<tr>
|
519 |
<th width="33%" valign="top" scope="row">
|
520 |
+
<?php _e('Video 1 file extensions:') ?><br /><span class='recommendation'>
|
521 |
+
<?php _e('Use video template 1 for files with these extensions (separated by commas)', 'postie') ?></span> </th>
|
522 |
<td>
|
523 |
<br/><input name='postie-settings[video1types]' type="text" id='postie-settings-video1types'
|
524 |
value="<?php if ($video1types != '') echo esc_attr($video1types); ?>" size="40" />
|
534 |
<input type='hidden' id='postie-settings-selected_video2template' name='postie-settings[selected_video2template]'
|
535 |
value="<?php echo esc_attr($selected_video2template) ?>" />
|
536 |
<select name='video2templateselect' id='video2templateselect'
|
537 |
+
onchange="changeStyle('video2TemplatePreview', 'postie-settings-video2template',
|
538 |
+
'video2templateselect', 'postie-settings-selected_video2template', 'hi.flv');" >
|
539 |
<?php
|
540 |
include('templates/video2_templates.php');
|
541 |
$styleOptions = $video2Templates;
|
557 |
|
558 |
<?php _e('Preview', 'postie'); ?>
|
559 |
<div id='video2TemplatePreview'></div>
|
560 |
+
<textarea onchange="changeStyle('video2TemplatePreview', 'postie-settings-video2template',
|
561 |
+
'video2templateselect', 'postie-settings-selected_video2template', 'hi.flv', true);" cols='70' rows='7' id='postie-settings-video2template'
|
562 |
name='postie-settings[video2template]'>
|
563 |
<?php echo esc_attr($video2template) ?>
|
564 |
</textarea>
|
566 |
</tr>
|
567 |
<tr>
|
568 |
<th width="33%" valign="top" scope="row">
|
569 |
+
<?php _e('Video 2 file extensions:') ?><br /><span class='recommendation'>
|
570 |
+
<?php _e('Use video template 2 for files with these extensions (separated by commas)', 'postie') ?></span> <br />
|
571 |
</th>
|
572 |
<td>
|
573 |
<br/><input name='postie-settings[video2types]' type="text" id='postie-settings-video2types'
|
584 |
<input type='hidden' id='postie-settings-selected_audiotemplate' name='postie-settings[selected_audiotemplate]'
|
585 |
value="<?php echo esc_attr($selected_audiotemplate) ?>" />
|
586 |
<select name='audiotemplateselect' id='audiotemplateselect'
|
587 |
+
onchange="changeStyle('audioTemplatePreview', 'postie-settings-audiotemplate',
|
588 |
+
'audiotemplateselect', 'postie-settings-selected_audiotemplate', 'funky.mp3', false);" >
|
589 |
<?php
|
590 |
include('templates/audio_templates.php');
|
591 |
$styleOptions = $audioTemplates;
|
608 |
|
609 |
<?php _e('Preview', 'postie'); ?>
|
610 |
<div id='audioTemplatePreview'></div>
|
611 |
+
<textarea onchange="changeStyle('audioTemplatePreview', 'postie-settings-audiotemplate',
|
612 |
+
'audiotemplateselect', 'postie-settings-selected_audiotemplate', 'funky.mp3', true);" cols='70' rows='7' id='postie-settings-audiotemplate'
|
613 |
name='postie-settings[audiotemplate]'><?php echo esc_attr($audiotemplate) ?></textarea>
|
614 |
</td>
|
615 |
</tr>
|
616 |
<tr>
|
617 |
<th width="33%" valign="top" scope="row">
|
618 |
+
<?php _e('Audio file extensions:') ?><br />
|
619 |
+
<span class='recommendation'><?php _e('Use the audio template for files with these extensions (separated by commas)', 'postie') ?></span> <br />
|
620 |
|
621 |
</th>
|
622 |
<td>
|
713 |
|
714 |
<?php $iconDir = get_option('siteurl') . '/' . PLUGINDIR . '/postie/icons'; ?>
|
715 |
<script type="text/javascript">
|
716 |
+
jQuery(document).ready(function() {
|
717 |
+
jQuery("#simpleTabs").simpleTabs({
|
718 |
+
fadeSpeed: "medium", // @param : low, medium, fast
|
719 |
+
defautContent: 1, // @param : number ( simpleTabs-nav-number)
|
720 |
+
autoNav: "false", // @param : true or false
|
721 |
+
closeTabs: "false" // @param : true or false;
|
722 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
723 |
|
724 |
+
});
|
725 |
+
|
726 |
+
function changeIconSet(selectBox, size) {
|
727 |
+
var iconSet = document.getElementById('postie-settings-icon_set');
|
728 |
+
var iconSize = document.getElementById('postie-settings-icon_size');
|
729 |
+
var preview = document.getElementById('postie-settings-attachment_preview');
|
730 |
+
var iconDir = '<?php echo $iconDir ?>/';
|
731 |
+
if (size == true) {
|
732 |
+
var hiddenInput = iconSize
|
733 |
+
} else {
|
734 |
+
var hiddenInput = iconSet;
|
735 |
+
}
|
736 |
+
for (i = 0; i < selectBox.options.length; i++) {
|
737 |
+
if (selectBox.options[i].selected == true) {
|
738 |
+
hiddenInput.value = selectBox.options[i].value;
|
739 |
+
}
|
740 |
+
}
|
741 |
+
var fileTypes = new Array('doc', 'pdf', 'xls', 'ppt');
|
742 |
+
preview.innerHTML = '';
|
743 |
+
for (j = 0; j < fileTypes.length; j++) {
|
744 |
+
preview.innerHTML += "<img src='" + iconDir + iconSet.value + '/' +
|
745 |
+
fileTypes[j] + '-' + iconSize.value + ".png' />";
|
746 |
+
}
|
747 |
+
preview.innerHTML += '<br />Here is some sample text with a link to a ' +
|
748 |
+
'word document that I think you might find interesting<br />' +
|
749 |
+
"<a href='#'><img style='text-decoration:none' src='" +
|
750 |
+
iconDir + iconSet.value + '/doc' +
|
751 |
+
'-' + iconSize.value + ".png' />Interesting document</a>";
|
752 |
+
}
|
753 |
+
|
754 |
+
function changeStyle(preview, template, select, selected, sample, custom) {
|
755 |
+
var preview = document.getElementById(preview);
|
756 |
+
var pageStyles = document.getElementById(select);
|
757 |
+
var selectedStyle;
|
758 |
+
var hiddenStyle = document.getElementById(selected);
|
759 |
+
var pageStyle = document.getElementById(template);
|
760 |
+
if (custom == true) {
|
761 |
+
selectedStyle = pageStyles.options[pageStyles.options.length - 1];
|
762 |
+
selectedStyle.value = pageStyle.value;
|
763 |
+
selectedStyle.selected = true;
|
764 |
+
} else {
|
765 |
+
for (i = 0; i < pageStyles.options.length; i++) {
|
766 |
+
if (pageStyles.options[i].selected == true) {
|
767 |
+
selectedStyle = pageStyles.options[i];
|
768 |
+
}
|
769 |
+
}
|
770 |
+
}
|
771 |
+
hiddenStyle.value = selectedStyle.innerHTML
|
772 |
+
var previewHTML = selectedStyle.value;
|
773 |
+
var fileLink = '<?php echo $templateDir ?>/' + sample;
|
774 |
+
var thumb = '<?php echo $templateDir ?>/' + sample.replace(/\.jpg/,
|
775 |
+
'-150x150.jpg');
|
776 |
+
var medium = '<?php echo $templateDir ?>/' + sample.replace(/\.jpg/,
|
777 |
+
'-300x200.jpg');
|
778 |
+
var large = '<?php echo $templateDir ?>/' + sample.replace(/\.jpg/,
|
779 |
+
'-1024x682.jpg');
|
780 |
+
previewHTML = previewHTML.replace(/{FILELINK}/g, fileLink);
|
781 |
+
previewHTML = previewHTML.replace(/{IMAGE}/g, fileLink);
|
782 |
+
previewHTML = previewHTML.replace(/{FILENAME}/, sample);
|
783 |
+
previewHTML = previewHTML.replace(/{THUMB(NAIL|)}/, thumb);
|
784 |
+
previewHTML = previewHTML.replace(/{MEDIUM}/, medium);
|
785 |
+
previewHTML = previewHTML.replace(/{LARGE}/, large);
|
786 |
+
previewHTML = previewHTML.replace(/{CAPTION}/g, 'Spencer smiling');
|
787 |
+
preview.innerHTML = previewHTML;
|
788 |
+
pageStyle.value = selectedStyle.value;
|
789 |
+
}
|
790 |
+
|
791 |
+
function showAdvanced(advancedId, arrowId) {
|
792 |
+
var advanced = document.getElementById(advancedId);
|
793 |
+
var arrow = document.getElementById(arrowId);
|
794 |
+
if (advanced.style.display == 'none') {
|
795 |
+
advanced.style.display = 'block';
|
796 |
+
arrow.innerHTML = '▼';
|
797 |
+
} else {
|
798 |
+
advanced.style.display = 'none';
|
799 |
+
arrow.innerHTML = '▶';
|
800 |
+
}
|
801 |
+
}
|
802 |
+
|
803 |
+
changeStyle('imageTemplatePreview', 'postie-settings-imagetemplate', 'imagetemplateselect', 'postie-settings-selected_imagetemplate', 'smiling.jpg', false);
|
804 |
+
changeStyle('audioTemplatePreview', 'postie-settings-audiotemplate', 'audiotemplateselect', 'postie-settings-selected_audiotemplate', 'funky.mp3', false);
|
805 |
+
changeStyle('video1TemplatePreview', 'postie-settings-video1template', 'video1templateselect', 'postie-settings-selected_video1template', 'hi.mp4', false);
|
806 |
+
changeStyle('video2TemplatePreview', 'postie-settings-video2template', 'video2templateselect', 'postie-settings-selected_video2template', 'hi.flv', false);
|
807 |
+
changeIconSet(document.getElementById('icon_set_select'));
|
808 |
</script>
|
docs/Changes.txt
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
== Upgrade Notice ==
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
= 1.4.18 =
|
4 |
Many method names have been changed. Any custom filters may need to be updated.
|
5 |
|
@@ -10,6 +15,18 @@ All script, style and body tags are stripped from html emails.
|
|
10 |
Attachments are now processed in the order they were attached.
|
11 |
|
12 |
== CHANGELOG ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
= 1.4.40 (2013.03.18) =
|
14 |
* Fixed bug where categories specified by ID were not being correctly identified
|
15 |
|
1 |
== Upgrade Notice ==
|
2 |
|
3 |
+
= 1.4.41 =
|
4 |
+
Post format is now supported. You can specify any of the WordPress supported post formats using the Post type syntax.
|
5 |
+
Post status can now be specified using the status: tag.
|
6 |
+
Post status setting was renamed to Default Post Status and moved to the Message tab.
|
7 |
+
|
8 |
= 1.4.18 =
|
9 |
Many method names have been changed. Any custom filters may need to be updated.
|
10 |
|
15 |
Attachments are now processed in the order they were attached.
|
16 |
|
17 |
== CHANGELOG ==
|
18 |
+
= 1.5.0 (2013.04.05) =
|
19 |
+
* Apply Postie Time Correction to date: command
|
20 |
+
* Add support for Post Formats
|
21 |
+
* Add support for Post Status
|
22 |
+
* Add warning if Admin username is invalid
|
23 |
+
* Fixed bug where date: was not always being detected in html emails
|
24 |
+
* Improved handling of attachments and mapping to file extensions for template selection
|
25 |
+
* Video templates now include scale="tofit"
|
26 |
+
* Add support for older png mime type
|
27 |
+
* New filter postie_filter_email. Used to map "from" to any other email. Allows custom user mapping.
|
28 |
+
|
29 |
+
|
30 |
= 1.4.40 (2013.03.18) =
|
31 |
* Fixed bug where categories specified by ID were not being correctly identified
|
32 |
|
docs/Postie.txt
CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
|
|
6 |
Tags: e-mail, email
|
7 |
Requires at least: 3.0
|
8 |
Tested up to: 3.5.1
|
9 |
-
Stable tag: 1.
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
6 |
Tags: e-mail, email
|
7 |
Requires at least: 3.0
|
8 |
Tested up to: 3.5.1
|
9 |
+
Stable tag: 1.5.0
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
docs/TODO.txt
CHANGED
@@ -1,42 +1,30 @@
|
|
1 |
provide a location for custom icons. update docs about location.
|
2 |
reply logic not adding to comments
|
3 |
hide/disable config options that don't apply
|
4 |
-
code to set featured image. Global setting (first picture is featured). Featured tag to enable per email. Enhance #img#
|
5 |
handle condition where only one of text/plain & text/html is supplied, but Preferred Text Type is set to the opposite.
|
6 |
replace native imap with flourish
|
7 |
replace MIME parser
|
8 |
debug assistance
|
9 |
-
setting for default post type
|
10 |
automatically create category if it doesn't exist. new option to allow this feature?
|
11 |
WP MU support
|
12 |
-
new command to set post status: published, draft, pending review, private
|
13 |
-
support setting "post format"
|
14 |
rework attachment logic. video files can come through as application/octect-stream. Mail parsing should separate attachments
|
15 |
into buckets? i.e. video, image, other. Each gets processed differently. I.e. when gallery in turned on images don't get embedded
|
16 |
but videos do.
|
17 |
-
|
|
|
|
|
|
|
18 |
|
19 |
standardize tags
|
20 |
fix postie settings http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
|
21 |
|
22 |
-- old todo --
|
23 |
-
* USE built-in php message decoding to improve speed
|
24 |
-
* Add custom fields
|
25 |
* support for flexible upload plugin
|
26 |
-
* iso 8859-2 support
|
27 |
-
* add private post function http://forum.robfelty.com/topic/how-to-private-posts-from-postie?replies=2#post-1515
|
28 |
* category per e-mail address
|
29 |
-
* Problem with some mail server
|
30 |
* Multiple emails should tie to a single account
|
31 |
* Each user should be able to have a default category
|
32 |
* Test for calling from the command line
|
33 |
* Support userid/domain as a valid username
|
34 |
-
* WP-switcher not compatiable http://www.alexking.org/index.php?content=software/wordpress/content.php#wp_120
|
35 |
-
* Test out a remote cron system
|
36 |
-
* Add support for http://unknowngenius.com/wp-plugins/faq.html#one-click
|
37 |
-
* www.cdavies.org/code/3gp-thumb.php.txt
|
38 |
-
* www.cdavies.org/permalink/watchingbrowserembeddedgpvideosinlinux.php
|
39 |
* Make it possible to post without a script at all
|
40 |
-
* TODO - fix corruption of rtf attachments
|
41 |
-
* TODO - add port checking in tests
|
42 |
* TODO - non-image uploads get ignored in content when using autogallery - see replaceimageplaceholders
|
1 |
provide a location for custom icons. update docs about location.
|
2 |
reply logic not adding to comments
|
3 |
hide/disable config options that don't apply
|
|
|
4 |
handle condition where only one of text/plain & text/html is supplied, but Preferred Text Type is set to the opposite.
|
5 |
replace native imap with flourish
|
6 |
replace MIME parser
|
7 |
debug assistance
|
8 |
+
setting for default post type/post format
|
9 |
automatically create category if it doesn't exist. new option to allow this feature?
|
10 |
WP MU support
|
|
|
|
|
11 |
rework attachment logic. video files can come through as application/octect-stream. Mail parsing should separate attachments
|
12 |
into buckets? i.e. video, image, other. Each gets processed differently. I.e. when gallery in turned on images don't get embedded
|
13 |
but videos do.
|
14 |
+
Add setting for category detection. I.e. checkboxes for [], -- and : styles. Default to all on.
|
15 |
+
Make sure all failures are sent to admin (option?) failed attachments, etc.
|
16 |
+
Comment not being created when subject contains category command []. I.e. listserv subject lines
|
17 |
+
code to set featured image. Global setting (first picture is featured). Featured tag to enable per email. Enhance #img# http://codex.wordpress.org/Function_Reference/set_post_thumbnail
|
18 |
|
19 |
standardize tags
|
20 |
fix postie settings http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
|
21 |
|
22 |
-- old todo --
|
|
|
|
|
23 |
* support for flexible upload plugin
|
|
|
|
|
24 |
* category per e-mail address
|
|
|
25 |
* Multiple emails should tie to a single account
|
26 |
* Each user should be able to have a default category
|
27 |
* Test for calling from the command line
|
28 |
* Support userid/domain as a valid username
|
|
|
|
|
|
|
|
|
|
|
29 |
* Make it possible to post without a script at all
|
|
|
|
|
30 |
* TODO - non-image uploads get ignored in content when using autogallery - see replaceimageplaceholders
|
docs/Usage.txt
CHANGED
@@ -3,6 +3,11 @@
|
|
3 |
* If you put in :start - the message processing won't start until it sees that string.
|
4 |
* If you put in :end - the message processing will stop once it sees that string.
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
= Post Date =
|
7 |
* Posts can have a specific publication date. Relative dates like "tomorrow", "monday", "first day of next month" are supported.
|
8 |
* date: date
|
@@ -32,9 +37,9 @@
|
|
32 |
* You can include images in the excerpt by using the shortcode #eimg1#,
|
33 |
#eimg2# etc.
|
34 |
|
35 |
-
= Post type =
|
36 |
-
You can specify the post type by including it as the first part of the subject
|
37 |
-
E.g.
|
38 |
|
39 |
= Categories =
|
40 |
* If you put a category name in the subject with a : it will be used
|
@@ -47,7 +52,7 @@
|
|
47 |
Gen: New News
|
48 |
|
49 |
The system will post that in General. Note you must turn on the "Match short category"
|
50 |
-
setting for this to work.
|
51 |
|
52 |
* All of the above also applies if you put the category in brackets []
|
53 |
* Using [] or you can post to multiple categories at once
|
3 |
* If you put in :start - the message processing won't start until it sees that string.
|
4 |
* If you put in :end - the message processing will stop once it sees that string.
|
5 |
|
6 |
+
= Post Status =
|
7 |
+
* Posts can have their status set to draft, publish, pending or private. This will override the Default Post Status set in the settings screen.
|
8 |
+
* status: private
|
9 |
+
* status: draft
|
10 |
+
|
11 |
= Post Date =
|
12 |
* Posts can have a specific publication date. Relative dates like "tomorrow", "monday", "first day of next month" are supported.
|
13 |
* date: date
|
37 |
* You can include images in the excerpt by using the shortcode #eimg1#,
|
38 |
#eimg2# etc.
|
39 |
|
40 |
+
= Post type/format =
|
41 |
+
You can specify the post type or format by including it as the first part of the subject.
|
42 |
+
E.g. aside//real subject
|
43 |
|
44 |
= Categories =
|
45 |
* If you put a category name in the subject with a : it will be used
|
52 |
Gen: New News
|
53 |
|
54 |
The system will post that in General. Note you must turn on the "Match short category"
|
55 |
+
setting for this to work (on by default).
|
56 |
|
57 |
* All of the above also applies if you put the category in brackets []
|
58 |
* Using [] or you can post to multiple categories at once
|
filterPostie.php.sample
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
* WARNING - WARNING - WARNING
|
4 |
* Do not put any custom filter code in the Postie directory. The standard WordPress
|
@@ -8,82 +9,79 @@
|
|
8 |
* to filterPostie.php and edit to your hearts content.
|
9 |
*
|
10 |
* Another option is to create your own plugin or add this code to your theme.
|
11 |
-
*/
|
12 |
|
13 |
/*
|
14 |
-
Plugin Name: Postie Filter
|
15 |
-
Plugin URI: Your URI
|
16 |
-
Description: Adds my own custom filter to messages posted by postie
|
17 |
-
Version: 1.0
|
18 |
-
Author: Your Name
|
19 |
-
Author URI: Your URI
|
20 |
-
*/
|
21 |
-
|
22 |
-
/*
|
23 |
* Any filter function you write should accept one argument, which is the post
|
24 |
-
|
25 |
-
'post_author'
|
26 |
-
'comment_author'
|
27 |
-
'comment_author_url'
|
28 |
-
'user_ID'
|
29 |
-
'email_author'
|
30 |
-
'post_date'
|
31 |
-
'post_date_gmt'
|
32 |
-
'post_content'
|
33 |
-
'post_title'
|
34 |
-
'post_modified'
|
35 |
-
'post_modified_gmt'
|
36 |
-
'ping_status'
|
37 |
-
'post_category'
|
38 |
-
'tags_input'
|
39 |
-
'comment_status'
|
40 |
-
'post_name'
|
41 |
-
'post_excerpt'
|
42 |
-
'ID'
|
43 |
-
'customImages'
|
44 |
-
'post_status'
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
|
|
|
|
|
48 |
|
49 |
-
|
50 |
-
*/
|
51 |
|
52 |
function filter_content($post) {
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
}
|
61 |
|
62 |
function filter_title($post) {
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
}
|
67 |
|
68 |
function auto_tag($post) {
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
}
|
77 |
|
78 |
function add_custom_field($post) {
|
79 |
-
|
80 |
-
|
81 |
-
return ($post);
|
82 |
}
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
|
89 |
?>
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
* WARNING - WARNING - WARNING
|
5 |
* Do not put any custom filter code in the Postie directory. The standard WordPress
|
9 |
* to filterPostie.php and edit to your hearts content.
|
10 |
*
|
11 |
* Another option is to create your own plugin or add this code to your theme.
|
12 |
+
*/
|
13 |
|
14 |
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
* Any filter function you write should accept one argument, which is the post
|
16 |
+
array, which contains the following fields:
|
17 |
+
'post_author'
|
18 |
+
'comment_author'
|
19 |
+
'comment_author_url'
|
20 |
+
'user_ID'
|
21 |
+
'email_author'
|
22 |
+
'post_date'
|
23 |
+
'post_date_gmt'
|
24 |
+
'post_content'
|
25 |
+
'post_title'
|
26 |
+
'post_modified'
|
27 |
+
'post_modified_gmt'
|
28 |
+
'ping_status'
|
29 |
+
'post_category'
|
30 |
+
'tags_input'
|
31 |
+
'comment_status'
|
32 |
+
'post_name'
|
33 |
+
'post_excerpt'
|
34 |
+
'ID'
|
35 |
+
'customImages'
|
36 |
+
'post_status'
|
37 |
+
|
38 |
+
Your function can modify any of these fields. It should then return the array
|
39 |
+
back. If you return null then the post will not be created.
|
40 |
+
*/
|
41 |
|
42 |
+
add_filter('postie_post', 'filter_title');
|
43 |
+
add_filter('postie_post', 'filter_content');
|
44 |
+
add_filter('postie_post', 'add_custom_field');
|
45 |
+
add_filter('postie_post', 'auto_tag');
|
46 |
|
47 |
+
add_filter('postie_filter_email', 'change_email');
|
|
|
48 |
|
49 |
function filter_content($post) {
|
50 |
+
//this function prepends a link to bookmark the category of the post
|
51 |
+
$this_cat = get_the_category($post['ID']);
|
52 |
+
//var_dump($this_cat);
|
53 |
+
$link = '<a href="' . get_category_link($this_cat[0]->term_id) .
|
54 |
+
'">Bookmark this category</a>' . "\n";
|
55 |
+
$post['post_content'] = $link . $post['post_content'];
|
56 |
+
return $post;
|
57 |
}
|
58 |
|
59 |
function filter_title($post) {
|
60 |
+
//this function appends "(via postie)" to the title (subject)
|
61 |
+
$post['post_title'] = $post['post_title'] . ' (via postie)';
|
62 |
+
return $post;
|
63 |
}
|
64 |
|
65 |
function auto_tag($post) {
|
66 |
+
// this function automatically inserts tags for a post
|
67 |
+
$my_tags = array('cooking', 'latex', 'wordpress');
|
68 |
+
foreach ($my_tags as $my_tag) {
|
69 |
+
if (stripos($post['post_content'], $my_tag) !== false)
|
70 |
+
array_push($post['tags_input'], $my_tag);
|
71 |
+
}
|
72 |
+
return $post;
|
73 |
}
|
74 |
|
75 |
function add_custom_field($post) {
|
76 |
+
add_post_meta($post['ID'], 'postie', 'postie');
|
77 |
+
return $post;
|
|
|
78 |
}
|
79 |
|
80 |
+
//changes the email to the admin email if the sender was from the example.com domain
|
81 |
+
function change_email($email) {
|
82 |
+
if (stristr($email, '@example.com'))
|
83 |
+
return get_option("admin_email");
|
84 |
+
return $email;
|
85 |
+
}
|
86 |
|
87 |
?>
|
postie-functions.php
CHANGED
@@ -1,12 +1,25 @@
|
|
1 |
<?php
|
2 |
|
3 |
/*
|
4 |
-
$Id: postie-functions.php
|
5 |
*/
|
6 |
|
7 |
//to turn on debug output add the following line to wp-config.php
|
8 |
//define('POSTIE_DEBUG', true);
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
if (!function_exists('mb_str_replace')) {
|
11 |
|
12 |
function mb_str_replace($search, $replace, $subject, &$count = 0) {
|
@@ -98,29 +111,41 @@ function DebugEcho($v) {
|
|
98 |
}
|
99 |
}
|
100 |
|
101 |
-
function tag_Date(&$content, $message_date) {
|
102 |
-
|
103 |
-
if (
|
104 |
-
$
|
105 |
-
|
106 |
-
|
107 |
-
DebugEcho(
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
113 |
-
$message_date = date($format, $newdate);
|
114 |
-
$content = trim(str_replace($matches[0], '', $content));
|
115 |
}
|
116 |
} else {
|
117 |
-
DebugEcho("
|
118 |
}
|
119 |
-
|
120 |
return $message_date;
|
121 |
}
|
122 |
|
123 |
-
function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config) {
|
124 |
|
125 |
$fulldebug = false;
|
126 |
|
@@ -131,6 +156,7 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config) {
|
|
131 |
"cids" => array(), //holds the cids for HTML email
|
132 |
"image_files" => array() //holds the files for each image
|
133 |
);
|
|
|
134 |
if (array_key_exists('message-id', $mimeDecodedEmail->headers)) {
|
135 |
EchoInfo("Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"]));
|
136 |
if ($fulldebug)
|
@@ -171,17 +197,17 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config) {
|
|
171 |
}
|
172 |
$message_date = HandleMessageEncoding($cte, $cs, $mimeDecodedEmail->headers["date"], $message_encoding, $message_dequote);
|
173 |
}
|
174 |
-
$message_date = tag_Date($content, $message_date);
|
175 |
|
176 |
list($post_date, $post_date_gmt, $delay) = filter_Delay($content, $message_date, $time_offset);
|
177 |
if ($fulldebug)
|
178 |
DebugEcho("post date: $content");
|
179 |
|
180 |
-
|
181 |
if ($fulldebug)
|
182 |
DebugEcho("post ubb: $content");
|
183 |
|
184 |
-
$post_categories =
|
185 |
if ($fulldebug)
|
186 |
DebugEcho("post category: $content");
|
187 |
|
@@ -193,12 +219,16 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config) {
|
|
193 |
if ($fulldebug)
|
194 |
DebugEcho("post comment: $content");
|
195 |
|
|
|
|
|
|
|
|
|
196 |
if ($converturls) {
|
197 |
$content = filter_Videos($content, $shortcode); //videos first so linkify doesn't mess with them
|
198 |
if ($fulldebug)
|
199 |
DebugEcho("post video: $content");
|
200 |
|
201 |
-
$content =
|
202 |
if ($fulldebug)
|
203 |
DebugEcho("post linkify: $content");
|
204 |
}
|
@@ -225,7 +255,7 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config) {
|
|
225 |
if ($fulldebug)
|
226 |
DebugEcho("post custom: $content");
|
227 |
|
228 |
-
$post_type = tag_PostType($subject);
|
229 |
if ($fulldebug)
|
230 |
DebugEcho("post type: $content");
|
231 |
|
@@ -267,11 +297,9 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config) {
|
|
267 |
|
268 |
if ($delay != 0 && $post_status == 'publish') {
|
269 |
$post_status = 'future';
|
270 |
-
} else {
|
271 |
-
$post_status = $post_status;
|
272 |
}
|
273 |
|
274 |
-
|
275 |
if ($fulldebug)
|
276 |
DebugEcho("post newline: $content");
|
277 |
|
@@ -283,7 +311,6 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config) {
|
|
283 |
if ($fulldebug)
|
284 |
DebugEcho("post end: $content");
|
285 |
|
286 |
-
|
287 |
DebugEcho("excerpt: $post_excerpt");
|
288 |
|
289 |
$details = array(
|
@@ -324,23 +351,31 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
|
|
324 |
EchoInfo("new post id is $post_id");
|
325 |
|
326 |
$is_reply = false;
|
327 |
-
$
|
|
|
|
|
328 |
|
329 |
$details = apply_filters('postie_post', $details);
|
330 |
|
331 |
DebugEcho(("Post postie_post filter"));
|
332 |
DebugDump($details);
|
333 |
|
|
|
|
|
|
|
334 |
if (empty($details)) {
|
335 |
// It is possible that the filter has removed the post, in which case, it should not be posted.
|
336 |
// And if we created a placeholder post (because this was not a reply to an existing post),
|
337 |
// then it should be removed
|
338 |
if (!$is_reply) {
|
339 |
wp_delete_post($post_id);
|
|
|
340 |
}
|
341 |
} else {
|
342 |
DisplayEmailPost($details);
|
343 |
-
|
|
|
|
|
344 |
if ($confirmation_email != '') {
|
345 |
if ($confirmation_email == 'sender') {
|
346 |
$recipients = array($postAuthorDetails['email']);
|
@@ -363,37 +398,39 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
|
|
363 |
* Adds support for handling Custom Post Types by adding the
|
364 |
* Custom Post Type name to the email subject separated by
|
365 |
* $custom_post_type_delim, e.g. "Movies // My Favorite Movie"
|
|
|
366 |
*/
|
367 |
-
function tag_PostType(&$subject) {
|
368 |
|
|
|
369 |
$custom_post_type_delim = "//";
|
370 |
if (strpos($subject, $custom_post_type_delim) !== FALSE) {
|
371 |
// Captures the custom post type in the subject before $custom_post_type_delim
|
372 |
$separated_subject = explode($custom_post_type_delim, $subject);
|
373 |
$custom_post_type = $separated_subject[0];
|
374 |
$subject = trim($separated_subject[1]);
|
375 |
-
DebugEcho("post type: found possible type '$custom_post_type'");
|
376 |
|
377 |
$custom_post_type = trim(strtolower($custom_post_type));
|
|
|
378 |
|
379 |
// Check if custom post type exists, if not, set default post type of 'post'
|
380 |
$known_post_types = get_post_types();
|
381 |
-
DebugDump($known_post_types);
|
|
|
382 |
|
383 |
if (in_array($custom_post_type, array_map('strtolower', $known_post_types))) {
|
384 |
-
$post_type = $custom_post_type;
|
385 |
DebugEcho("post type: found type '$post_type'");
|
386 |
-
|
387 |
-
|
|
|
|
|
388 |
}
|
389 |
-
} else {
|
390 |
-
$post_type = 'post';
|
391 |
}
|
392 |
|
393 |
return $post_type;
|
394 |
}
|
395 |
|
396 |
-
function
|
397 |
# It turns urls into links, and video urls into embedded players
|
398 |
//DebugEcho("begin: filter_linkify");
|
399 |
|
@@ -499,17 +536,20 @@ function make_links($text) {
|
|
499 |
*/
|
500 |
|
501 |
function getPostAuthorDetails(&$subject, &$content, &$mimeDecodedEmail) {
|
502 |
-
global $wpdb;
|
503 |
|
504 |
$theDate = $mimeDecodedEmail->headers['date'];
|
505 |
$theEmail = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
|
|
|
|
|
|
|
|
|
506 |
$regAuthor = get_user_by('email', $theEmail);
|
507 |
if ($regAuthor) {
|
508 |
$theAuthor = $regAuthor->user_login;
|
509 |
$theUrl = $regAuthor->user_url;
|
510 |
$theID = $regAuthor->ID;
|
511 |
} else {
|
512 |
-
$theAuthor = GetNameFromEmail($
|
513 |
$theUrl = '';
|
514 |
$theID = '';
|
515 |
}
|
@@ -539,8 +579,7 @@ function getPostAuthorDetails(&$subject, &$content, &$mimeDecodedEmail) {
|
|
539 |
$content = $newContents;
|
540 |
}
|
541 |
$theDetails = array(
|
542 |
-
'content' => "<div class='postmetadata alt'>On $theDate, $theAuthor" .
|
543 |
-
" posted:</div>",
|
544 |
'emaildate' => $theDate,
|
545 |
'author' => $theAuthor,
|
546 |
'comment_author_url' => $theUrl,
|
@@ -749,34 +788,36 @@ function POP3MessageFetch($server = NULL, $port = NULL, $email = NULL, $password
|
|
749 |
* @param array - categories to be posted to
|
750 |
* @param array - details of the post
|
751 |
*/
|
752 |
-
function PostToDB($details, $isReply, $
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
|
|
|
|
780 |
DebugEcho("Saving custom image fields");
|
781 |
//DebugDump($details['customImages']);
|
782 |
|
@@ -788,6 +829,8 @@ function PostToDB($details, $isReply, $postToDb = true, $customImageField = fals
|
|
788 |
}
|
789 |
}
|
790 |
}
|
|
|
|
|
791 |
}
|
792 |
}
|
793 |
|
@@ -813,7 +856,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
813 |
//global $charset, $encoding;
|
814 |
DebugEcho('----');
|
815 |
$meta_return = '';
|
816 |
-
DebugEcho("primary= " . $part->ctype_primary . ", secondary = " . $part->ctype_secondary);
|
817 |
|
818 |
DecodeBase64Part($part);
|
819 |
|
@@ -824,15 +867,9 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
824 |
|
825 |
if ($part->ctype_primary == "application" && $part->ctype_secondary == "octet-stream") {
|
826 |
if (property_exists($part, 'disposition') && $part->disposition == "attachment") {
|
827 |
-
|
828 |
-
foreach ($image_endings as $type) {
|
829 |
-
if (preg_match("/.$type\$/i", $part->d_parameters["filename"])) {
|
830 |
-
$part->ctype_primary = "image";
|
831 |
-
$part->ctype_secondary = $type;
|
832 |
-
break;
|
833 |
-
}
|
834 |
-
}
|
835 |
} else {
|
|
|
836 |
$mimeDecodedEmail = DecodeMIMEMail($part->body);
|
837 |
filter_PreferedText($mimeDecodedEmail, $prefer_text_type);
|
838 |
foreach ($mimeDecodedEmail->parts as $section) {
|
@@ -858,9 +895,39 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
858 |
} elseif (property_exists($part, 'd_parameters') && is_array($part->d_parameters) && array_key_exists('filename', $part->d_parameters)) {
|
859 |
$filename = $part->d_parameters['filename'];
|
860 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
861 |
|
862 |
-
|
863 |
-
switch (strtolower($part->ctype_primary)) {
|
864 |
case 'multipart':
|
865 |
DebugEcho("multipart: " . count($part->parts));
|
866 |
//DebugDump($part);
|
@@ -902,26 +969,27 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
902 |
$file_id = postie_media_handle_upload($part, $post_id, $poster);
|
903 |
if (!is_wp_error($file_id)) {
|
904 |
$file = wp_get_attachment_url($file_id);
|
905 |
-
$icon = chooseAttachmentIcon($file, $
|
906 |
$attachments["html"][$filename] = "<a href='$file'>" . $icon . $filename . '</a>' . "\n";
|
|
|
907 |
} else {
|
908 |
LogInfo($file_id->get_error_message());
|
909 |
}
|
910 |
} else {
|
911 |
-
DebugEcho("text attachment: skipping");
|
912 |
}
|
913 |
} else {
|
914 |
|
915 |
//go through each sub-section
|
916 |
-
if ($
|
917 |
//convert enriched text to HTML
|
918 |
DebugEcho("enriched");
|
919 |
-
$meta_return .=
|
920 |
-
} elseif ($
|
921 |
//strip excess HTML
|
922 |
DebugEcho("html");
|
923 |
$meta_return .= filter_CleanHtml($part->body) . "\n";
|
924 |
-
} elseif ($
|
925 |
DebugEcho("plain text");
|
926 |
//DebugDump($part);
|
927 |
|
@@ -941,7 +1009,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
941 |
$file_id = postie_media_handle_upload($part, $post_id, $poster);
|
942 |
if (!is_wp_error($file_id)) {
|
943 |
$file = wp_get_attachment_url($file_id);
|
944 |
-
$icon = chooseAttachmentIcon($file, $
|
945 |
$attachments["html"][$filename] = "<a href='$file'>" . $icon . $filename . '</a>' . "\n";
|
946 |
} else {
|
947 |
LogInfo($file_id->get_error_message());
|
@@ -962,7 +1030,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
962 |
}
|
963 |
|
964 |
$the_post = get_post($file_id);
|
965 |
-
$attachments["html"][$filename] = parseTemplate($file_id, $
|
966 |
if ($cid) {
|
967 |
$attachments["cids"][$cid] = array($file, count($attachments["html"]) - 1);
|
968 |
DebugEcho("CID Attachement: $cid");
|
@@ -983,15 +1051,15 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
983 |
$cid = trim($part->headers["content-id"], "<>");
|
984 |
DebugEcho("audio Attachement cid: $cid");
|
985 |
}
|
986 |
-
if (in_array($
|
987 |
-
DebugEcho("using audio template: $
|
988 |
$audioTemplate = $audiotemplate;
|
989 |
} else {
|
990 |
-
DebugEcho("using default audio template: $
|
991 |
-
$icon = chooseAttachmentIcon($file, $
|
992 |
$audioTemplate = '<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
|
993 |
}
|
994 |
-
$attachments["html"][$filename] = parseTemplate($file_id, $
|
995 |
} else {
|
996 |
LogInfo("audio error: " . $file_id->get_error_message());
|
997 |
}
|
@@ -1008,18 +1076,18 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
1008 |
DebugEcho("video Attachement cid: $cid");
|
1009 |
}
|
1010 |
//DebugDump($part);
|
1011 |
-
if (in_array(
|
1012 |
-
DebugEcho("using video1 template: $
|
1013 |
$videoTemplate = $video1template;
|
1014 |
-
} elseif (in_array(
|
1015 |
-
DebugEcho("using video2 template: $
|
1016 |
$videoTemplate = $video2template;
|
1017 |
} else {
|
1018 |
-
DebugEcho("using default template: $
|
1019 |
-
$icon = chooseAttachmentIcon($file, $
|
1020 |
$videoTemplate = '<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
|
1021 |
}
|
1022 |
-
$attachments["html"][$filename] = parseTemplate($file_id, $
|
1023 |
//echo "videoTemplate = $videoTemplate\n";
|
1024 |
} else {
|
1025 |
LogInfo($file_id->get_error_message());
|
@@ -1027,10 +1095,10 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
1027 |
break;
|
1028 |
|
1029 |
default:
|
1030 |
-
DebugEcho("found file type: " . $
|
1031 |
-
if (in_array(
|
1032 |
//pgp signature - then forget it
|
1033 |
-
if ($
|
1034 |
DebugEcho("found pgp-signature - done");
|
1035 |
break;
|
1036 |
}
|
@@ -1038,7 +1106,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
1038 |
if (!is_wp_error($file_id)) {
|
1039 |
$file = wp_get_attachment_url($file_id);
|
1040 |
DebugEcho("uploaded $file_id ($file)");
|
1041 |
-
$icon = chooseAttachmentIcon($file, $
|
1042 |
DebugEcho("default: $icon $filename");
|
1043 |
$attachments["html"][$filename] = "<a href='$file'>" . $icon . $filename . '</a>' . "\n";
|
1044 |
if (array_key_exists('content-id', $part->headers)) {
|
@@ -1064,7 +1132,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
|
|
1064 |
return $meta_return;
|
1065 |
}
|
1066 |
|
1067 |
-
function
|
1068 |
// Array of tags with opening and closing
|
1069 |
$tagArray['img'] = array('open' => '<img src="', 'close' => '">');
|
1070 |
$tagArray['b'] = array('open' => '<b>', 'close' => '</b>');
|
@@ -1094,7 +1162,7 @@ function filter_ubb2HTML(&$text) {
|
|
1094 |
// This function turns Enriched Text into something similar to HTML
|
1095 |
// Very basic at the moment, only supports some functionality and dumps the rest
|
1096 |
// FIXME: fix colours: <color><param>FFFF,C2FE,0374</param>some text </color>
|
1097 |
-
function
|
1098 |
|
1099 |
$search = array(
|
1100 |
'/<bold>/',
|
@@ -1169,12 +1237,13 @@ function ValidatePoster(&$mimeDecodedEmail, $config) {
|
|
1169 |
$from = "";
|
1170 |
if (array_key_exists('from', $mimeDecodedEmail->headers)) {
|
1171 |
$from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
|
|
|
|
|
1172 |
} else {
|
1173 |
DebugEcho("No 'from' header found");
|
1174 |
DebugDump($mimeDecodedEmail->headers);
|
1175 |
}
|
1176 |
|
1177 |
-
|
1178 |
$resentFrom = "";
|
1179 |
if (array_key_exists('resent-from', $mimeDecodedEmail->headers)) {
|
1180 |
$resentFrom = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["resent-from"]));
|
@@ -1197,7 +1266,13 @@ function ValidatePoster(&$mimeDecodedEmail, $config) {
|
|
1197 |
$poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$admin_username'");
|
1198 |
}
|
1199 |
} elseif ($turn_authorization_off || isEmailAddressAuthorized($from, $authorized_addresses) || isEmailAddressAuthorized($resentFrom, $authorized_addresses)) {
|
|
|
|
|
1200 |
$poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$admin_username'");
|
|
|
|
|
|
|
|
|
1201 |
}
|
1202 |
|
1203 |
$validSMTP = isValidSmtpServer($mimeDecodedEmail, $smtp);
|
@@ -1259,28 +1334,31 @@ function filter_Start(&$content, $config) {
|
|
1259 |
*/
|
1260 |
function filter_RemoveSignature(&$content, $config) {
|
1261 |
if ($config['drop_signature']) {
|
1262 |
-
if (empty($config['sig_pattern_list']))
|
|
|
1263 |
return;
|
|
|
1264 |
//DebugEcho("looking for signature in: $content");
|
1265 |
|
1266 |
$pattern = '/^(' . implode('|', $config['sig_pattern_list']) . ')\s?$/m';
|
1267 |
-
DebugEcho("
|
1268 |
|
1269 |
$html = LoadDOM($content);
|
1270 |
if ($html !== false) {
|
1271 |
filter_RemoveSignatureWorker($html->root, $pattern);
|
1272 |
$content = $html->save();
|
1273 |
} else {
|
1274 |
-
DebugEcho("
|
1275 |
$arrcontent = explode("\n", $content);
|
1276 |
$strcontent = '';
|
1277 |
|
1278 |
for ($i = 0; $i < count($arrcontent); $i++) {
|
1279 |
$line = trim($arrcontent[$i]);
|
1280 |
if (preg_match($pattern, trim($line))) {
|
1281 |
-
DebugEcho("signature found: removing");
|
1282 |
break;
|
1283 |
}
|
|
|
1284 |
$strcontent .= $line;
|
1285 |
}
|
1286 |
$content = $strcontent;
|
@@ -1333,7 +1411,7 @@ function filter_End(&$content, $config) {
|
|
1333 |
}
|
1334 |
|
1335 |
//filter content for new lines
|
1336 |
-
function
|
1337 |
if ($config['filternewlines']) {
|
1338 |
|
1339 |
$search = array(
|
@@ -1430,7 +1508,7 @@ function DecodeBase64Part(&$part) {
|
|
1430 |
//DebugDump($part);
|
1431 |
if (isset($part->disposition) && $part->disposition == 'attachment') {
|
1432 |
$part->body = base64_decode($part->body);
|
1433 |
-
} else if (is_array($part->ctype_parameters) && array_key_exists('charset', $part->ctype_parameters)) {
|
1434 |
$part->body = iconv($part->ctype_parameters['charset'], 'UTF-8//TRANSLIT', base64_decode($part->body));
|
1435 |
DebugEcho("convertef from: " . $part->ctype_parameters['charset']);
|
1436 |
$part->ctype_parameters['charset'] = 'default'; //so we don't double decode
|
@@ -1462,6 +1540,17 @@ function tag_AllowCommentsOnPost(&$content) {
|
|
1462 |
return $comments_allowed;
|
1463 |
}
|
1464 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1465 |
/**
|
1466 |
* Needed to be able to modify the content to remove the usage of the delay tag
|
1467 |
*
|
@@ -1505,7 +1594,7 @@ function filter_Delay(&$content, $message_date = NULL, $offset = 0) {
|
|
1505 |
/**
|
1506 |
* This function takes the content of the message - looks for a subject at the begining surrounded by # and then removes that from the content
|
1507 |
*/
|
1508 |
-
function
|
1509 |
DebugEcho("Looking for subject in email body");
|
1510 |
if (substr($content, 0, 1) != "#") {
|
1511 |
DebugEcho("No subject found, using default [1]");
|
@@ -1555,6 +1644,12 @@ function postie_media_handle_upload($part, $post_id, $poster, $post_data = array
|
|
1555 |
EchoInfo("could not write to temp file: '$tmpFile' ");
|
1556 |
}
|
1557 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1558 |
$name = 'postie-media.' . $part->ctype_secondary;
|
1559 |
if (property_exists($part, 'ctype_parameters') && is_array($part->ctype_parameters)) {
|
1560 |
if (array_key_exists('name', $part->ctype_parameters) && $part->ctype_parameters['name'] != '') {
|
@@ -1640,7 +1735,7 @@ function postie_media_handle_upload($part, $post_id, $poster, $post_data = array
|
|
1640 |
if (!is_wp_error($id)) {
|
1641 |
$amd = wp_generate_attachment_metadata($id, $file);
|
1642 |
DebugEcho("wp_generate_attachment_metadata");
|
1643 |
-
DebugDump($amd);
|
1644 |
wp_update_attachment_metadata($id, $amd);
|
1645 |
DebugEcho("wp_update_attachment_metadata complete");
|
1646 |
} else {
|
@@ -1694,8 +1789,7 @@ function postie_handle_upload(&$file, $overrides = false, $time = null) {
|
|
1694 |
// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
|
1695 |
|
1696 |
$wp_filetype = wp_check_filetype($file['name']);
|
1697 |
-
DebugEcho("postie_handle_upload: detected file type for " . $file['name']);
|
1698 |
-
DebugDump($wp_filetype);
|
1699 |
|
1700 |
extract($wp_filetype);
|
1701 |
|
@@ -2211,7 +2305,7 @@ function GetSubject(&$mimeDecodedEmail, &$content, $config) {
|
|
2211 |
if (!array_key_exists('subject', $mimeDecodedEmail->headers) || empty($mimeDecodedEmail->headers['subject'])) {
|
2212 |
DebugEcho("No subject in email");
|
2213 |
if ($allow_subject_in_mail) {
|
2214 |
-
list($subject, $content) =
|
2215 |
} else {
|
2216 |
DebugEcho("Using default subject");
|
2217 |
$subject = $default_title;
|
@@ -2271,7 +2365,7 @@ function tag_Excerpt(&$content, $filterNewLines, $convertNewLines) {
|
|
2271 |
DebugEcho("excerpt found: $post_excerpt");
|
2272 |
if ($filterNewLines) {
|
2273 |
DebugEcho("filtering newlines from excerpt");
|
2274 |
-
|
2275 |
}
|
2276 |
}
|
2277 |
return $post_excerpt;
|
@@ -2281,7 +2375,7 @@ function tag_Excerpt(&$content, $filterNewLines, $convertNewLines) {
|
|
2281 |
* This function determines the categories ids for the post
|
2282 |
* @return array
|
2283 |
*/
|
2284 |
-
function
|
2285 |
$original_subject = $subject;
|
2286 |
$post_categories = array();
|
2287 |
$matchtypes = array();
|
@@ -2337,7 +2431,7 @@ function lookup_category($trial_category, $category_match) {
|
|
2337 |
//then category is a named and found
|
2338 |
return $term->term_id;
|
2339 |
}
|
2340 |
-
|
2341 |
$term = get_term_by('id', intval($trial_category), 'category');
|
2342 |
if ($term !== false) {
|
2343 |
DebugEcho("category: found by id $trial_category");
|
@@ -2345,7 +2439,7 @@ function lookup_category($trial_category, $category_match) {
|
|
2345 |
//then cateogry was an ID and found
|
2346 |
return $term->term_id;
|
2347 |
}
|
2348 |
-
|
2349 |
if ($category_match) {
|
2350 |
DebugEcho("category wildcard lookup: $trial_category");
|
2351 |
$sql_sub_name = 'SELECT term_id FROM ' . $wpdb->terms . ' WHERE name LIKE \'' . addslashes($trial_category) . '%\' limit 1';
|
@@ -2813,14 +2907,21 @@ function isMarkdownInstalled() {
|
|
2813 |
* and ensures that arrayed items are stored as such
|
2814 |
*/
|
2815 |
function config_ValidateSettings($in) {
|
2816 |
-
//
|
|
|
2817 |
$out = array();
|
2818 |
|
|
|
2819 |
// use the default as a template:
|
2820 |
// if a field is present in the defaults, we want to store it; otherwise we discard it
|
2821 |
$allowed_keys = config_GetDefaults();
|
2822 |
-
foreach ($allowed_keys as $key => $default)
|
2823 |
-
|
|
|
|
|
|
|
|
|
|
|
2824 |
|
2825 |
// some fields are always forced to lower case:
|
2826 |
$lowercase = array('authorized_addresses', 'smtp', 'supported_file_types', 'video1types', 'video2types', 'audiotypes');
|
1 |
<?php
|
2 |
|
3 |
/*
|
4 |
+
$Id: postie-functions.php 692601 2013-04-06 06:41:51Z WayneAllen $
|
5 |
*/
|
6 |
|
7 |
//to turn on debug output add the following line to wp-config.php
|
8 |
//define('POSTIE_DEBUG', true);
|
9 |
|
10 |
+
class PostiePostModifiers {
|
11 |
+
|
12 |
+
var $PostFormat = 'standard';
|
13 |
+
|
14 |
+
function apply($postid, $postdetails) {
|
15 |
+
|
16 |
+
if ($this->PostFormat != 'standard') {
|
17 |
+
set_post_format($postid, $this->PostFormat);
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
if (!function_exists('mb_str_replace')) {
|
24 |
|
25 |
function mb_str_replace($search, $replace, $subject, &$count = 0) {
|
111 |
}
|
112 |
}
|
113 |
|
114 |
+
function tag_Date(&$content, $message_date, $time_offset) {
|
115 |
+
$html = LoadDOM($content);
|
116 |
+
if ($html !== false) {
|
117 |
+
$es = $html->find('text');
|
118 |
+
DebugEcho("tag_Date: html " . count($es));
|
119 |
+
foreach ($es as $e) {
|
120 |
+
DebugEcho(trim($e->plaintext));
|
121 |
+
if (1 === preg_match("/^date:\s?(.*)$/im", trim($e->plaintext), $matches)) {
|
122 |
+
DebugEcho("tag_Date: found date tag $matches[1]");
|
123 |
+
$newdate = strtotime($matches[1]);
|
124 |
+
if (false !== $newdate) {
|
125 |
+
$t = date("H:i:s", $newdate);
|
126 |
+
DebugEcho("tag_Date: original time: $t");
|
127 |
+
|
128 |
+
$newdate = $newdate + $time_offset * 3600;
|
129 |
+
$t = date("H:i:s", $newdate);
|
130 |
+
DebugEcho("tag_Date: adjusted time: $t");
|
131 |
+
|
132 |
+
$format = "Y-m-d";
|
133 |
+
if ($t != '00:00:00') {
|
134 |
+
$format.= " H:i:s";
|
135 |
+
}
|
136 |
+
$message_date = date($format, $newdate);
|
137 |
+
$content = str_replace($matches[0], '', $content);
|
138 |
+
break;
|
139 |
+
}
|
140 |
}
|
|
|
|
|
141 |
}
|
142 |
} else {
|
143 |
+
DebugEcho("tag_Date: not html");
|
144 |
}
|
|
|
145 |
return $message_date;
|
146 |
}
|
147 |
|
148 |
+
function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $postmodifiers) {
|
149 |
|
150 |
$fulldebug = false;
|
151 |
|
156 |
"cids" => array(), //holds the cids for HTML email
|
157 |
"image_files" => array() //holds the files for each image
|
158 |
);
|
159 |
+
|
160 |
if (array_key_exists('message-id', $mimeDecodedEmail->headers)) {
|
161 |
EchoInfo("Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"]));
|
162 |
if ($fulldebug)
|
197 |
}
|
198 |
$message_date = HandleMessageEncoding($cte, $cs, $mimeDecodedEmail->headers["date"], $message_encoding, $message_dequote);
|
199 |
}
|
200 |
+
$message_date = tag_Date($content, $message_date, $time_offset);
|
201 |
|
202 |
list($post_date, $post_date_gmt, $delay) = filter_Delay($content, $message_date, $time_offset);
|
203 |
if ($fulldebug)
|
204 |
DebugEcho("post date: $content");
|
205 |
|
206 |
+
filter_Ubb2HTML($content);
|
207 |
if ($fulldebug)
|
208 |
DebugEcho("post ubb: $content");
|
209 |
|
210 |
+
$post_categories = tag_Categories($subject, $default_post_category, $category_match);
|
211 |
if ($fulldebug)
|
212 |
DebugEcho("post category: $content");
|
213 |
|
219 |
if ($fulldebug)
|
220 |
DebugEcho("post comment: $content");
|
221 |
|
222 |
+
$post_status = tag_Status($content, $post_status);
|
223 |
+
if ($fulldebug)
|
224 |
+
DebugEcho("post status: $content");
|
225 |
+
|
226 |
if ($converturls) {
|
227 |
$content = filter_Videos($content, $shortcode); //videos first so linkify doesn't mess with them
|
228 |
if ($fulldebug)
|
229 |
DebugEcho("post video: $content");
|
230 |
|
231 |
+
$content = filter_Linkify($content);
|
232 |
if ($fulldebug)
|
233 |
DebugEcho("post linkify: $content");
|
234 |
}
|
255 |
if ($fulldebug)
|
256 |
DebugEcho("post custom: $content");
|
257 |
|
258 |
+
$post_type = tag_PostType($subject, $postmodifiers);
|
259 |
if ($fulldebug)
|
260 |
DebugEcho("post type: $content");
|
261 |
|
297 |
|
298 |
if ($delay != 0 && $post_status == 'publish') {
|
299 |
$post_status = 'future';
|
|
|
|
|
300 |
}
|
301 |
|
302 |
+
filter_Newlines($content, $config);
|
303 |
if ($fulldebug)
|
304 |
DebugEcho("post newline: $content");
|
305 |
|
311 |
if ($fulldebug)
|
312 |
DebugEcho("post end: $content");
|
313 |
|
|
|
314 |
DebugEcho("excerpt: $post_excerpt");
|
315 |
|
316 |
$details = array(
|
351 |
EchoInfo("new post id is $post_id");
|
352 |
|
353 |
$is_reply = false;
|
354 |
+
$postmodifiers = new PostiePostModifiers();
|
355 |
+
|
356 |
+
$details = CreatePost($poster, $mimeDecodedEmail, $post_id, $is_reply, $config, $postmodifiers);
|
357 |
|
358 |
$details = apply_filters('postie_post', $details);
|
359 |
|
360 |
DebugEcho(("Post postie_post filter"));
|
361 |
DebugDump($details);
|
362 |
|
363 |
+
DebugEcho("Post modifiers");
|
364 |
+
DebugDump($postmodifiers);
|
365 |
+
|
366 |
if (empty($details)) {
|
367 |
// It is possible that the filter has removed the post, in which case, it should not be posted.
|
368 |
// And if we created a placeholder post (because this was not a reply to an existing post),
|
369 |
// then it should be removed
|
370 |
if (!$is_reply) {
|
371 |
wp_delete_post($post_id);
|
372 |
+
EchoInfo("postie_post filter cleared the post, not saving.");
|
373 |
}
|
374 |
} else {
|
375 |
DisplayEmailPost($details);
|
376 |
+
|
377 |
+
PostToDB($details, $is_reply, $custom_image_field, $postmodifiers);
|
378 |
+
|
379 |
if ($confirmation_email != '') {
|
380 |
if ($confirmation_email == 'sender') {
|
381 |
$recipients = array($postAuthorDetails['email']);
|
398 |
* Adds support for handling Custom Post Types by adding the
|
399 |
* Custom Post Type name to the email subject separated by
|
400 |
* $custom_post_type_delim, e.g. "Movies // My Favorite Movie"
|
401 |
+
* Also supports setting the Post Format.
|
402 |
*/
|
403 |
+
function tag_PostType(&$subject, $postmodifiers) {
|
404 |
|
405 |
+
$post_type = 'post';
|
406 |
$custom_post_type_delim = "//";
|
407 |
if (strpos($subject, $custom_post_type_delim) !== FALSE) {
|
408 |
// Captures the custom post type in the subject before $custom_post_type_delim
|
409 |
$separated_subject = explode($custom_post_type_delim, $subject);
|
410 |
$custom_post_type = $separated_subject[0];
|
411 |
$subject = trim($separated_subject[1]);
|
|
|
412 |
|
413 |
$custom_post_type = trim(strtolower($custom_post_type));
|
414 |
+
DebugEcho("post type: found possible type '$custom_post_type'");
|
415 |
|
416 |
// Check if custom post type exists, if not, set default post type of 'post'
|
417 |
$known_post_types = get_post_types();
|
418 |
+
//DebugDump($known_post_types);
|
419 |
+
//DebugDump(get_post_format_slugs());
|
420 |
|
421 |
if (in_array($custom_post_type, array_map('strtolower', $known_post_types))) {
|
|
|
422 |
DebugEcho("post type: found type '$post_type'");
|
423 |
+
$post_type = $custom_post_type;
|
424 |
+
} elseif (in_array($custom_post_type, array_keys(get_post_format_slugs()))) {
|
425 |
+
DebugEcho("post type: found format '$custom_post_type'");
|
426 |
+
$postmodifiers->PostFormat = $custom_post_type;
|
427 |
}
|
|
|
|
|
428 |
}
|
429 |
|
430 |
return $post_type;
|
431 |
}
|
432 |
|
433 |
+
function filter_Linkify($text) {
|
434 |
# It turns urls into links, and video urls into embedded players
|
435 |
//DebugEcho("begin: filter_linkify");
|
436 |
|
536 |
*/
|
537 |
|
538 |
function getPostAuthorDetails(&$subject, &$content, &$mimeDecodedEmail) {
|
|
|
539 |
|
540 |
$theDate = $mimeDecodedEmail->headers['date'];
|
541 |
$theEmail = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
|
542 |
+
|
543 |
+
$theEmail = apply_filters("postie_filter_email", $theEmail);
|
544 |
+
DebugEcho("getPostAuthorDetails: post email filter $theEmail");
|
545 |
+
|
546 |
$regAuthor = get_user_by('email', $theEmail);
|
547 |
if ($regAuthor) {
|
548 |
$theAuthor = $regAuthor->user_login;
|
549 |
$theUrl = $regAuthor->user_url;
|
550 |
$theID = $regAuthor->ID;
|
551 |
} else {
|
552 |
+
$theAuthor = GetNameFromEmail($theEmail);
|
553 |
$theUrl = '';
|
554 |
$theID = '';
|
555 |
}
|
579 |
$content = $newContents;
|
580 |
}
|
581 |
$theDetails = array(
|
582 |
+
'content' => "<div class='postmetadata alt'>On $theDate, $theAuthor" . " posted:</div>",
|
|
|
583 |
'emaildate' => $theDate,
|
584 |
'author' => $theAuthor,
|
585 |
'comment_author_url' => $theUrl,
|
788 |
* @param array - categories to be posted to
|
789 |
* @param array - details of the post
|
790 |
*/
|
791 |
+
function PostToDB($details, $isReply, $customImageField, $postmodifiers) {
|
792 |
+
|
793 |
+
if (!$isReply) {
|
794 |
+
$post_ID = wp_insert_post($details, true);
|
795 |
+
if (is_wp_error($post_ID)) {
|
796 |
+
EchoInfo("Error: " . $post_ID->get_error_message());
|
797 |
+
wp_delete_post($details['ID']);
|
798 |
+
}
|
799 |
+
} else {
|
800 |
+
$comment = array(
|
801 |
+
'comment_author' => $details['comment_author'],
|
802 |
+
'comment_post_ID' => $details['ID'],
|
803 |
+
'comment_author_email' => $details['email_author'],
|
804 |
+
'comment_date' => $details['post_date'],
|
805 |
+
'comment_date_gmt' => $details['post_date_gmt'],
|
806 |
+
'comment_content' => $details['post_content'],
|
807 |
+
'comment_author_url' => $details['comment_author_url'],
|
808 |
+
'comment_author_IP' => '',
|
809 |
+
'comment_approved' => 1,
|
810 |
+
'comment_agent' => '',
|
811 |
+
'comment_type' => '',
|
812 |
+
'comment_parent' => 0,
|
813 |
+
'user_id' => $details['user_ID']
|
814 |
+
);
|
815 |
+
|
816 |
+
$post_ID = wp_insert_comment($comment);
|
817 |
+
}
|
818 |
+
|
819 |
+
if ($post_ID) {
|
820 |
+
if ($customImageField) {
|
821 |
DebugEcho("Saving custom image fields");
|
822 |
//DebugDump($details['customImages']);
|
823 |
|
829 |
}
|
830 |
}
|
831 |
}
|
832 |
+
|
833 |
+
$postmodifiers->apply($post_ID, $details);
|
834 |
}
|
835 |
}
|
836 |
|
856 |
//global $charset, $encoding;
|
857 |
DebugEcho('----');
|
858 |
$meta_return = '';
|
859 |
+
DebugEcho("GetContent: primary= " . $part->ctype_primary . ", secondary = " . $part->ctype_secondary);
|
860 |
|
861 |
DecodeBase64Part($part);
|
862 |
|
867 |
|
868 |
if ($part->ctype_primary == "application" && $part->ctype_secondary == "octet-stream") {
|
869 |
if (property_exists($part, 'disposition') && $part->disposition == "attachment") {
|
870 |
+
//nothing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
871 |
} else {
|
872 |
+
DebugEcho("GetContent: decoding application/octet-stream");
|
873 |
$mimeDecodedEmail = DecodeMIMEMail($part->body);
|
874 |
filter_PreferedText($mimeDecodedEmail, $prefer_text_type);
|
875 |
foreach ($mimeDecodedEmail->parts as $section) {
|
895 |
} elseif (property_exists($part, 'd_parameters') && is_array($part->d_parameters) && array_key_exists('filename', $part->d_parameters)) {
|
896 |
$filename = $part->d_parameters['filename'];
|
897 |
}
|
898 |
+
$fileext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
899 |
+
|
900 |
+
DebugEcho("GetContent: file name '$filename'");
|
901 |
+
DebugEcho("GetContent: extension '$fileext'");
|
902 |
+
|
903 |
+
$mimetype_primary = strtolower($part->ctype_primary);
|
904 |
+
$mimetype_secondary = strtolower($part->ctype_secondary);
|
905 |
+
|
906 |
+
$typeinfo = wp_check_filetype($filename);
|
907 |
+
//DebugDump($typeinfo);
|
908 |
+
if (!empty($typeinfo['type'])) {
|
909 |
+
DebugEcho("GetContent: secondary lookup found " . $typeinfo['type']);
|
910 |
+
$mimeparts = explode('/', strtolower($typeinfo['type']));
|
911 |
+
$mimetype_primary = $mimeparts[0];
|
912 |
+
$mimetype_secondary = $mimeparts[1];
|
913 |
+
} else {
|
914 |
+
DebugEcho("GetContent: secondary lookup failed, checking configured extensions");
|
915 |
+
if (in_array($fileext, $audiotypes)) {
|
916 |
+
DebugEcho("GetContent: found audio extension");
|
917 |
+
$mimetype_primary = 'audio';
|
918 |
+
$mimetype_secondary = $fileext;
|
919 |
+
} elseif (in_array($fileext, array_merge($video1types, $video2types))) {
|
920 |
+
DebugEcho("GetContent: found video extension");
|
921 |
+
$mimetype_primary = 'video';
|
922 |
+
$mimetype_secondary = $fileext;
|
923 |
+
} else {
|
924 |
+
DebugEcho("GetContent: found no extension");
|
925 |
+
}
|
926 |
+
}
|
927 |
+
|
928 |
+
DebugEcho("GetContent: mimetype $mimetype_primary/$mimetype_secondary");
|
929 |
|
930 |
+
switch ($mimetype_primary) {
|
|
|
931 |
case 'multipart':
|
932 |
DebugEcho("multipart: " . count($part->parts));
|
933 |
//DebugDump($part);
|
969 |
$file_id = postie_media_handle_upload($part, $post_id, $poster);
|
970 |
if (!is_wp_error($file_id)) {
|
971 |
$file = wp_get_attachment_url($file_id);
|
972 |
+
$icon = chooseAttachmentIcon($file, $mimetype_primary, $mimetype_secondary, $icon_set, $icon_size);
|
973 |
$attachments["html"][$filename] = "<a href='$file'>" . $icon . $filename . '</a>' . "\n";
|
974 |
+
DebugEcho("text attachment: adding '$filename'");
|
975 |
} else {
|
976 |
LogInfo($file_id->get_error_message());
|
977 |
}
|
978 |
} else {
|
979 |
+
DebugEcho("text attachment: skipping '$filename'");
|
980 |
}
|
981 |
} else {
|
982 |
|
983 |
//go through each sub-section
|
984 |
+
if ($mimetype_secondary == 'enriched') {
|
985 |
//convert enriched text to HTML
|
986 |
DebugEcho("enriched");
|
987 |
+
$meta_return .= filter_Etf2HTML($part->body) . "\n";
|
988 |
+
} elseif ($mimetype_secondary == 'html') {
|
989 |
//strip excess HTML
|
990 |
DebugEcho("html");
|
991 |
$meta_return .= filter_CleanHtml($part->body) . "\n";
|
992 |
+
} elseif ($mimetype_secondary == 'plain') {
|
993 |
DebugEcho("plain text");
|
994 |
//DebugDump($part);
|
995 |
|
1009 |
$file_id = postie_media_handle_upload($part, $post_id, $poster);
|
1010 |
if (!is_wp_error($file_id)) {
|
1011 |
$file = wp_get_attachment_url($file_id);
|
1012 |
+
$icon = chooseAttachmentIcon($file, $mimetype_primary, $mimetype_secondary, $icon_set, $icon_size);
|
1013 |
$attachments["html"][$filename] = "<a href='$file'>" . $icon . $filename . '</a>' . "\n";
|
1014 |
} else {
|
1015 |
LogInfo($file_id->get_error_message());
|
1030 |
}
|
1031 |
|
1032 |
$the_post = get_post($file_id);
|
1033 |
+
$attachments["html"][$filename] = parseTemplate($file_id, $mimetype_primary, $imagetemplate, $filename);
|
1034 |
if ($cid) {
|
1035 |
$attachments["cids"][$cid] = array($file, count($attachments["html"]) - 1);
|
1036 |
DebugEcho("CID Attachement: $cid");
|
1051 |
$cid = trim($part->headers["content-id"], "<>");
|
1052 |
DebugEcho("audio Attachement cid: $cid");
|
1053 |
}
|
1054 |
+
if (in_array($fileext, $audiotypes)) {
|
1055 |
+
DebugEcho("using audio template: $mimetype_secondary");
|
1056 |
$audioTemplate = $audiotemplate;
|
1057 |
} else {
|
1058 |
+
DebugEcho("using default audio template: $mimetype_secondary");
|
1059 |
+
$icon = chooseAttachmentIcon($file, $mimetype_primary, $mimetype_secondary, $icon_set, $icon_size);
|
1060 |
$audioTemplate = '<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
|
1061 |
}
|
1062 |
+
$attachments["html"][$filename] = parseTemplate($file_id, $mimetype_primary, $audioTemplate, $filename);
|
1063 |
} else {
|
1064 |
LogInfo("audio error: " . $file_id->get_error_message());
|
1065 |
}
|
1076 |
DebugEcho("video Attachement cid: $cid");
|
1077 |
}
|
1078 |
//DebugDump($part);
|
1079 |
+
if (in_array($fileext, $video1types)) {
|
1080 |
+
DebugEcho("using video1 template: $fileext");
|
1081 |
$videoTemplate = $video1template;
|
1082 |
+
} elseif (in_array($fileext, $video2types)) {
|
1083 |
+
DebugEcho("using video2 template: $fileext");
|
1084 |
$videoTemplate = $video2template;
|
1085 |
} else {
|
1086 |
+
DebugEcho("using default template: $fileext");
|
1087 |
+
$icon = chooseAttachmentIcon($file, $mimetype_primary, $mimetype_secondary, $icon_set, $icon_size);
|
1088 |
$videoTemplate = '<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
|
1089 |
}
|
1090 |
+
$attachments["html"][$filename] = parseTemplate($file_id, $mimetype_primary, $videoTemplate, $filename);
|
1091 |
//echo "videoTemplate = $videoTemplate\n";
|
1092 |
} else {
|
1093 |
LogInfo($file_id->get_error_message());
|
1095 |
break;
|
1096 |
|
1097 |
default:
|
1098 |
+
DebugEcho("found file type: " . $mimetype_primary);
|
1099 |
+
if (in_array($mimetype_primary, $supported_file_types)) {
|
1100 |
//pgp signature - then forget it
|
1101 |
+
if ($mimetype_secondary == 'pgp-signature') {
|
1102 |
DebugEcho("found pgp-signature - done");
|
1103 |
break;
|
1104 |
}
|
1106 |
if (!is_wp_error($file_id)) {
|
1107 |
$file = wp_get_attachment_url($file_id);
|
1108 |
DebugEcho("uploaded $file_id ($file)");
|
1109 |
+
$icon = chooseAttachmentIcon($file, $mimetype_primary, $mimetype_secondary, $icon_set, $icon_size);
|
1110 |
DebugEcho("default: $icon $filename");
|
1111 |
$attachments["html"][$filename] = "<a href='$file'>" . $icon . $filename . '</a>' . "\n";
|
1112 |
if (array_key_exists('content-id', $part->headers)) {
|
1132 |
return $meta_return;
|
1133 |
}
|
1134 |
|
1135 |
+
function filter_Ubb2HTML(&$text) {
|
1136 |
// Array of tags with opening and closing
|
1137 |
$tagArray['img'] = array('open' => '<img src="', 'close' => '">');
|
1138 |
$tagArray['b'] = array('open' => '<b>', 'close' => '</b>');
|
1162 |
// This function turns Enriched Text into something similar to HTML
|
1163 |
// Very basic at the moment, only supports some functionality and dumps the rest
|
1164 |
// FIXME: fix colours: <color><param>FFFF,C2FE,0374</param>some text </color>
|
1165 |
+
function filter_Etf2HTML($content) {
|
1166 |
|
1167 |
$search = array(
|
1168 |
'/<bold>/',
|
1237 |
$from = "";
|
1238 |
if (array_key_exists('from', $mimeDecodedEmail->headers)) {
|
1239 |
$from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
|
1240 |
+
$from = apply_filters("postie_filter_email", $from);
|
1241 |
+
DebugEcho("ValidatePoster: post email filter $from");
|
1242 |
} else {
|
1243 |
DebugEcho("No 'from' header found");
|
1244 |
DebugDump($mimeDecodedEmail->headers);
|
1245 |
}
|
1246 |
|
|
|
1247 |
$resentFrom = "";
|
1248 |
if (array_key_exists('resent-from', $mimeDecodedEmail->headers)) {
|
1249 |
$resentFrom = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["resent-from"]));
|
1266 |
$poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$admin_username'");
|
1267 |
}
|
1268 |
} elseif ($turn_authorization_off || isEmailAddressAuthorized($from, $authorized_addresses) || isEmailAddressAuthorized($resentFrom, $authorized_addresses)) {
|
1269 |
+
DebugEcho("ValidatePoster: looking up default user $admin_username");
|
1270 |
+
|
1271 |
$poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$admin_username'");
|
1272 |
+
DebugEcho("ValidatePoster: found user '$poster'");
|
1273 |
+
if (empty($poster)) {
|
1274 |
+
EchoInfo("Your 'Admin username' setting '$admin_username' is not a valid WordPress user");
|
1275 |
+
}
|
1276 |
}
|
1277 |
|
1278 |
$validSMTP = isValidSmtpServer($mimeDecodedEmail, $smtp);
|
1334 |
*/
|
1335 |
function filter_RemoveSignature(&$content, $config) {
|
1336 |
if ($config['drop_signature']) {
|
1337 |
+
if (empty($config['sig_pattern_list'])) {
|
1338 |
+
DebugEcho("filter_RemoveSignature: no sig_pattern_list");
|
1339 |
return;
|
1340 |
+
}
|
1341 |
//DebugEcho("looking for signature in: $content");
|
1342 |
|
1343 |
$pattern = '/^(' . implode('|', $config['sig_pattern_list']) . ')\s?$/m';
|
1344 |
+
DebugEcho("filter_RemoveSignature: pattern: $pattern");
|
1345 |
|
1346 |
$html = LoadDOM($content);
|
1347 |
if ($html !== false) {
|
1348 |
filter_RemoveSignatureWorker($html->root, $pattern);
|
1349 |
$content = $html->save();
|
1350 |
} else {
|
1351 |
+
DebugEcho("filter_RemoveSignature: non-html");
|
1352 |
$arrcontent = explode("\n", $content);
|
1353 |
$strcontent = '';
|
1354 |
|
1355 |
for ($i = 0; $i < count($arrcontent); $i++) {
|
1356 |
$line = trim($arrcontent[$i]);
|
1357 |
if (preg_match($pattern, trim($line))) {
|
1358 |
+
DebugEcho("filter_RemoveSignature: signature found: removing");
|
1359 |
break;
|
1360 |
}
|
1361 |
+
|
1362 |
$strcontent .= $line;
|
1363 |
}
|
1364 |
$content = $strcontent;
|
1411 |
}
|
1412 |
|
1413 |
//filter content for new lines
|
1414 |
+
function filter_Newlines(&$content, $config) {
|
1415 |
if ($config['filternewlines']) {
|
1416 |
|
1417 |
$search = array(
|
1508 |
//DebugDump($part);
|
1509 |
if (isset($part->disposition) && $part->disposition == 'attachment') {
|
1510 |
$part->body = base64_decode($part->body);
|
1511 |
+
} else if (property_exists($part, 'ctype_parameters') && is_array($part->ctype_parameters) && array_key_exists('charset', $part->ctype_parameters)) {
|
1512 |
$part->body = iconv($part->ctype_parameters['charset'], 'UTF-8//TRANSLIT', base64_decode($part->body));
|
1513 |
DebugEcho("convertef from: " . $part->ctype_parameters['charset']);
|
1514 |
$part->ctype_parameters['charset'] = 'default'; //so we don't double decode
|
1540 |
return $comments_allowed;
|
1541 |
}
|
1542 |
|
1543 |
+
function tag_Status(&$content, $currentstatus) {
|
1544 |
+
$poststatus = $currentstatus;
|
1545 |
+
if (preg_match("/status:\s*(draft|publish|pending|private)/i", $content, $matches)) {
|
1546 |
+
DebugEcho("tag_Status: found status $matches[1]");
|
1547 |
+
DebugDump($matches);
|
1548 |
+
$content = preg_replace("/$matches[0]/i", "", $content);
|
1549 |
+
$poststatus = $matches[1];
|
1550 |
+
}
|
1551 |
+
return $poststatus;
|
1552 |
+
}
|
1553 |
+
|
1554 |
/**
|
1555 |
* Needed to be able to modify the content to remove the usage of the delay tag
|
1556 |
*
|
1594 |
/**
|
1595 |
* This function takes the content of the message - looks for a subject at the begining surrounded by # and then removes that from the content
|
1596 |
*/
|
1597 |
+
function tag_Subject($content, $defaultTitle) {
|
1598 |
DebugEcho("Looking for subject in email body");
|
1599 |
if (substr($content, 0, 1) != "#") {
|
1600 |
DebugEcho("No subject found, using default [1]");
|
1644 |
EchoInfo("could not write to temp file: '$tmpFile' ");
|
1645 |
}
|
1646 |
|
1647 |
+
//special case to deal with older png implementations
|
1648 |
+
if (strtolower($part->ctype_secondary == 'x-png')) {
|
1649 |
+
DebugEcho("postie_media_handle_upload: x-png found, renamed to png");
|
1650 |
+
$part->ctype_secondary = 'png';
|
1651 |
+
}
|
1652 |
+
|
1653 |
$name = 'postie-media.' . $part->ctype_secondary;
|
1654 |
if (property_exists($part, 'ctype_parameters') && is_array($part->ctype_parameters)) {
|
1655 |
if (array_key_exists('name', $part->ctype_parameters) && $part->ctype_parameters['name'] != '') {
|
1735 |
if (!is_wp_error($id)) {
|
1736 |
$amd = wp_generate_attachment_metadata($id, $file);
|
1737 |
DebugEcho("wp_generate_attachment_metadata");
|
1738 |
+
//DebugDump($amd);
|
1739 |
wp_update_attachment_metadata($id, $amd);
|
1740 |
DebugEcho("wp_update_attachment_metadata complete");
|
1741 |
} else {
|
1789 |
// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
|
1790 |
|
1791 |
$wp_filetype = wp_check_filetype($file['name']);
|
1792 |
+
DebugEcho("postie_handle_upload: detected file type for " . $file['name'] . " is " . $wp_filetype['type']);
|
|
|
1793 |
|
1794 |
extract($wp_filetype);
|
1795 |
|
2305 |
if (!array_key_exists('subject', $mimeDecodedEmail->headers) || empty($mimeDecodedEmail->headers['subject'])) {
|
2306 |
DebugEcho("No subject in email");
|
2307 |
if ($allow_subject_in_mail) {
|
2308 |
+
list($subject, $content) = tag_Subject($content, $default_title);
|
2309 |
} else {
|
2310 |
DebugEcho("Using default subject");
|
2311 |
$subject = $default_title;
|
2365 |
DebugEcho("excerpt found: $post_excerpt");
|
2366 |
if ($filterNewLines) {
|
2367 |
DebugEcho("filtering newlines from excerpt");
|
2368 |
+
filter_Newlines($post_excerpt, $convertNewLines);
|
2369 |
}
|
2370 |
}
|
2371 |
return $post_excerpt;
|
2375 |
* This function determines the categories ids for the post
|
2376 |
* @return array
|
2377 |
*/
|
2378 |
+
function tag_Categories(&$subject, $defaultCategory, $category_match) {
|
2379 |
$original_subject = $subject;
|
2380 |
$post_categories = array();
|
2381 |
$matchtypes = array();
|
2431 |
//then category is a named and found
|
2432 |
return $term->term_id;
|
2433 |
}
|
2434 |
+
|
2435 |
$term = get_term_by('id', intval($trial_category), 'category');
|
2436 |
if ($term !== false) {
|
2437 |
DebugEcho("category: found by id $trial_category");
|
2439 |
//then cateogry was an ID and found
|
2440 |
return $term->term_id;
|
2441 |
}
|
2442 |
+
|
2443 |
if ($category_match) {
|
2444 |
DebugEcho("category wildcard lookup: $trial_category");
|
2445 |
$sql_sub_name = 'SELECT term_id FROM ' . $wpdb->terms . ' WHERE name LIKE \'' . addslashes($trial_category) . '%\' limit 1';
|
2907 |
* and ensures that arrayed items are stored as such
|
2908 |
*/
|
2909 |
function config_ValidateSettings($in) {
|
2910 |
+
//DebugEcho("config_ValidateSettings");
|
2911 |
+
|
2912 |
$out = array();
|
2913 |
|
2914 |
+
//DebugDump($in);
|
2915 |
// use the default as a template:
|
2916 |
// if a field is present in the defaults, we want to store it; otherwise we discard it
|
2917 |
$allowed_keys = config_GetDefaults();
|
2918 |
+
foreach ($allowed_keys as $key => $default) {
|
2919 |
+
if (is_array($in)) {
|
2920 |
+
$out[$key] = array_key_exists($key, $in) ? $in[$key] : $default;
|
2921 |
+
} else {
|
2922 |
+
$out[$key] = $default;
|
2923 |
+
}
|
2924 |
+
}
|
2925 |
|
2926 |
// some fields are always forced to lower case:
|
2927 |
$lowercase = array('authorized_addresses', 'smtp', 'supported_file_types', 'video1types', 'video2types', 'audiotypes');
|
postie.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Postie
|
5 |
Plugin URI: http://PostiePlugin.com/
|
6 |
Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
|
7 |
-
Version: 1.
|
8 |
Author: Wayne Allen
|
9 |
Author URI: http://allens-home.com/
|
10 |
License: GPL2
|
@@ -27,7 +27,7 @@
|
|
27 |
*/
|
28 |
|
29 |
/*
|
30 |
-
$Id: postie.php
|
31 |
*/
|
32 |
|
33 |
define("POSTIE_ROOT", dirname(__FILE__));
|
@@ -165,13 +165,27 @@ function postie_warnings() {
|
|
165 |
|
166 |
add_action('admin_notices', 'postie_mbstring_warning');
|
167 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
}
|
169 |
|
170 |
function disable_kses_content() {
|
171 |
remove_filter('content_save_pre', 'wp_filter_post_kses');
|
172 |
}
|
173 |
|
174 |
-
|
175 |
function postie_whitelist($options) {
|
176 |
$added = array('postie-settings' => array('postie-settings'));
|
177 |
$options = add_option_whitelist($added, $options);
|
@@ -206,41 +220,42 @@ function check_postie() {
|
|
206 |
|
207 |
function postie_cron($interval = false) {
|
208 |
//Do not echo output in filters, it seems to break some installs
|
209 |
-
error_log("postie_cron: setting up cron task: $interval");
|
210 |
-
|
211 |
$schedules = wp_get_schedules();
|
212 |
-
error_log("postie_cron\n".print_r($schedules, true));
|
213 |
-
|
214 |
if (!$interval) {
|
215 |
$config = config_Read();
|
216 |
$interval = $config['interval'];
|
217 |
-
error_log("postie_cron: setting up cron task from config: $interval");
|
218 |
}
|
219 |
if (!$interval || $interval == '') {
|
220 |
$interval = 'hourly';
|
221 |
-
error_log("Postie: setting up cron task: defaulting to hourly");
|
222 |
}
|
223 |
if ($interval == 'manual') {
|
224 |
postie_decron();
|
225 |
-
error_log("postie_cron: clearing cron (manual)");
|
226 |
} else {
|
227 |
if (false === wp_schedule_event(time(), $interval, 'check_postie_hook')) {
|
228 |
-
error_log("postie_cron: Failed to set up cron task: $interval");
|
229 |
} else {
|
230 |
-
error_log("postie_cron: Set up cron task: $interval");
|
231 |
}
|
232 |
}
|
233 |
}
|
234 |
|
235 |
function postie_decron() {
|
236 |
-
error_log("postie_decron: clearing cron");
|
237 |
wp_clear_scheduled_hook('check_postie_hook');
|
238 |
}
|
239 |
|
240 |
/* here we add some more cron options for how often to check for e-mail */
|
|
|
241 |
function postie_more_reccurences($schedules) {
|
242 |
//Do not echo output in filters, it seems to break some installs
|
243 |
-
error_log("postie_more_reccurences: setting cron schedules");
|
244 |
$schedules['weekly'] = array('interval' => (60 * 60 * 24 * 7), 'display' => __('Once Weekly'));
|
245 |
$schedules['twiceperhour'] = array('interval' => 60 * 30, 'display' => __('Twice per hour'));
|
246 |
$schedules['tenminutes'] = array('interval' => 60 * 10, 'display' => __('Every 10 minutes'));
|
4 |
Plugin Name: Postie
|
5 |
Plugin URI: http://PostiePlugin.com/
|
6 |
Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
|
7 |
+
Version: 1.5.0
|
8 |
Author: Wayne Allen
|
9 |
Author URI: http://allens-home.com/
|
10 |
License: GPL2
|
27 |
*/
|
28 |
|
29 |
/*
|
30 |
+
$Id: postie.php 692601 2013-04-06 06:41:51Z WayneAllen $
|
31 |
*/
|
32 |
|
33 |
define("POSTIE_ROOT", dirname(__FILE__));
|
165 |
|
166 |
add_action('admin_notices', 'postie_mbstring_warning');
|
167 |
}
|
168 |
+
|
169 |
+
if (!function_exists('get_user_by')){
|
170 |
+
include ABSPATH . 'wp-includes/pluggable.php';
|
171 |
+
}
|
172 |
+
$adminuser = get_user_by( 'login', $config['admin_username']);
|
173 |
+
if ($adminuser === false) {
|
174 |
+
|
175 |
+
function postie_adminuser_warning() {
|
176 |
+
echo "<div id='postie-mbstring-warning' class='error'><p><strong>";
|
177 |
+
echo __('Warning: the Admin username is not a valid WordPress login. Postie may reject emails if this is not corrected.', 'postie');
|
178 |
+
echo "</strong></p></div>";
|
179 |
+
}
|
180 |
+
|
181 |
+
add_action('admin_notices', 'postie_adminuser_warning');
|
182 |
+
}
|
183 |
}
|
184 |
|
185 |
function disable_kses_content() {
|
186 |
remove_filter('content_save_pre', 'wp_filter_post_kses');
|
187 |
}
|
188 |
|
|
|
189 |
function postie_whitelist($options) {
|
190 |
$added = array('postie-settings' => array('postie-settings'));
|
191 |
$options = add_option_whitelist($added, $options);
|
220 |
|
221 |
function postie_cron($interval = false) {
|
222 |
//Do not echo output in filters, it seems to break some installs
|
223 |
+
//error_log("postie_cron: setting up cron task: $interval");
|
224 |
+
|
225 |
$schedules = wp_get_schedules();
|
226 |
+
//error_log("postie_cron\n" . print_r($schedules, true));
|
227 |
+
|
228 |
if (!$interval) {
|
229 |
$config = config_Read();
|
230 |
$interval = $config['interval'];
|
231 |
+
//error_log("postie_cron: setting up cron task from config: $interval");
|
232 |
}
|
233 |
if (!$interval || $interval == '') {
|
234 |
$interval = 'hourly';
|
235 |
+
//error_log("Postie: setting up cron task: defaulting to hourly");
|
236 |
}
|
237 |
if ($interval == 'manual') {
|
238 |
postie_decron();
|
239 |
+
//error_log("postie_cron: clearing cron (manual)");
|
240 |
} else {
|
241 |
if (false === wp_schedule_event(time(), $interval, 'check_postie_hook')) {
|
242 |
+
//error_log("postie_cron: Failed to set up cron task: $interval");
|
243 |
} else {
|
244 |
+
//error_log("postie_cron: Set up cron task: $interval");
|
245 |
}
|
246 |
}
|
247 |
}
|
248 |
|
249 |
function postie_decron() {
|
250 |
+
//error_log("postie_decron: clearing cron");
|
251 |
wp_clear_scheduled_hook('check_postie_hook');
|
252 |
}
|
253 |
|
254 |
/* here we add some more cron options for how often to check for e-mail */
|
255 |
+
|
256 |
function postie_more_reccurences($schedules) {
|
257 |
//Do not echo output in filters, it seems to break some installs
|
258 |
+
//error_log("postie_more_reccurences: setting cron schedules");
|
259 |
$schedules['weekly'] = array('interval' => (60 * 60 * 24 * 7), 'display' => __('Once Weekly'));
|
260 |
$schedules['twiceperhour'] = array('interval' => 60 * 30, 'display' => __('Twice per hour'));
|
261 |
$schedules['tenminutes'] = array('interval' => 60 * 10, 'display' => __('Every 10 minutes'));
|
readme.html
CHANGED
@@ -72,6 +72,10 @@ Then use the Task Scheduler control panel to call wget or cron.</p> <hr />
|
|
72 |
|
73 |
<h3>Upgrade Notice</h3>
|
74 |
<dl>
|
|
|
|
|
|
|
|
|
75 |
<dt>1.4.18</dt>
|
76 |
<dd>Many method names have been changed. Any custom filters may need to be updated.</dd>
|
77 |
<dt>1.4.10</dt>
|
@@ -88,6 +92,17 @@ Then use the Task Scheduler control panel to call wget or cron.</p> <hr />
|
|
88 |
<li>If you put in :end - the message processing will stop once it sees that string.</li>
|
89 |
</ul>
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
<h4>Post Date</h4>
|
92 |
|
93 |
<ul>
|
@@ -141,10 +156,10 @@ will get placed in the more recent post.</li>
|
|
141 |
</ul></li>
|
142 |
</ul>
|
143 |
|
144 |
-
<h4>Post type</h4>
|
145 |
|
146 |
-
<p>You can specify the post type by including it as the first part of the subject
|
147 |
-
E.g.
|
148 |
|
149 |
<h4>Categories</h4>
|
150 |
|
@@ -159,7 +174,7 @@ the first category that the system finds that matches - so if you put</p>
|
|
159 |
<p>Gen: New News</p>
|
160 |
|
161 |
<p>The system will post that in General. Note you must turn on the "Match short category"
|
162 |
-
setting for this to work.</p></li>
|
163 |
<li><p>All of the above also applies if you put the category in brackets []</p></li>
|
164 |
<li><p>Using [] or you can post to multiple categories at once</p>
|
165 |
|
72 |
|
73 |
<h3>Upgrade Notice</h3>
|
74 |
<dl>
|
75 |
+
<dt>1.4.41</dt>
|
76 |
+
<dd>Post format is now supported. You can specify any of the WordPress supported post formats using the Post type syntax.
|
77 |
+
Post status can now be specified using the status: tag.
|
78 |
+
Post status setting was renamed to Default Post Status and moved to the Message tab.</dd>
|
79 |
<dt>1.4.18</dt>
|
80 |
<dd>Many method names have been changed. Any custom filters may need to be updated.</dd>
|
81 |
<dt>1.4.10</dt>
|
92 |
<li>If you put in :end - the message processing will stop once it sees that string.</li>
|
93 |
</ul>
|
94 |
|
95 |
+
<h4>Post Status</h4>
|
96 |
+
|
97 |
+
<ul>
|
98 |
+
<li>Posts can have their status set to draft, publish, pending or private. This will override the Default Post Status set in the settings screen.
|
99 |
+
|
100 |
+
<ul>
|
101 |
+
<li>status: private</li>
|
102 |
+
<li>status: draft</li>
|
103 |
+
</ul></li>
|
104 |
+
</ul>
|
105 |
+
|
106 |
<h4>Post Date</h4>
|
107 |
|
108 |
<ul>
|
156 |
</ul></li>
|
157 |
</ul>
|
158 |
|
159 |
+
<h4>Post type/format</h4>
|
160 |
|
161 |
+
<p>You can specify the post type or format by including it as the first part of the subject.
|
162 |
+
E.g. aside//real subject</p>
|
163 |
|
164 |
<h4>Categories</h4>
|
165 |
|
174 |
<p>Gen: New News</p>
|
175 |
|
176 |
<p>The system will post that in General. Note you must turn on the "Match short category"
|
177 |
+
setting for this to work (on by default).</p></li>
|
178 |
<li><p>All of the above also applies if you put the category in brackets []</p></li>
|
179 |
<li><p>Using [] or you can post to multiple categories at once</p>
|
180 |
|
readme.txt
CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
|
|
6 |
Tags: e-mail, email
|
7 |
Requires at least: 3.0
|
8 |
Tested up to: 3.5.1
|
9 |
-
Stable tag: 1.
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
@@ -84,6 +84,11 @@ Then use the Task Scheduler control panel to call wget or cron.
|
|
84 |
* If you put in :start - the message processing won't start until it sees that string.
|
85 |
* If you put in :end - the message processing will stop once it sees that string.
|
86 |
|
|
|
|
|
|
|
|
|
|
|
87 |
= Post Date =
|
88 |
* Posts can have a specific publication date. Relative dates like "tomorrow", "monday", "first day of next month" are supported.
|
89 |
* date: date
|
@@ -113,9 +118,9 @@ Then use the Task Scheduler control panel to call wget or cron.
|
|
113 |
* You can include images in the excerpt by using the shortcode #eimg1#,
|
114 |
#eimg2# etc.
|
115 |
|
116 |
-
= Post type =
|
117 |
-
You can specify the post type by including it as the first part of the subject
|
118 |
-
E.g.
|
119 |
|
120 |
= Categories =
|
121 |
* If you put a category name in the subject with a : it will be used
|
@@ -128,7 +133,7 @@ Then use the Task Scheduler control panel to call wget or cron.
|
|
128 |
Gen: New News
|
129 |
|
130 |
The system will post that in General. Note you must turn on the "Match short category"
|
131 |
-
setting for this to work.
|
132 |
|
133 |
* All of the above also applies if you put the category in brackets []
|
134 |
* Using [] or you can post to multiple categories at once
|
@@ -416,6 +421,11 @@ It is also possible to turn the WordPress cron off. Please make sure something l
|
|
416 |
`define('DISABLE_WP_CRON', true);` is not in your wp-config.php file.
|
417 |
== Upgrade Notice ==
|
418 |
|
|
|
|
|
|
|
|
|
|
|
419 |
= 1.4.18 =
|
420 |
Many method names have been changed. Any custom filters may need to be updated.
|
421 |
|
@@ -426,6 +436,18 @@ All script, style and body tags are stripped from html emails.
|
|
426 |
Attachments are now processed in the order they were attached.
|
427 |
|
428 |
== CHANGELOG ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
= 1.4.40 (2013.03.18) =
|
430 |
* Fixed bug where categories specified by ID were not being correctly identified
|
431 |
|
6 |
Tags: e-mail, email
|
7 |
Requires at least: 3.0
|
8 |
Tested up to: 3.5.1
|
9 |
+
Stable tag: 1.5.0
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
84 |
* If you put in :start - the message processing won't start until it sees that string.
|
85 |
* If you put in :end - the message processing will stop once it sees that string.
|
86 |
|
87 |
+
= Post Status =
|
88 |
+
* Posts can have their status set to draft, publish, pending or private. This will override the Default Post Status set in the settings screen.
|
89 |
+
* status: private
|
90 |
+
* status: draft
|
91 |
+
|
92 |
= Post Date =
|
93 |
* Posts can have a specific publication date. Relative dates like "tomorrow", "monday", "first day of next month" are supported.
|
94 |
* date: date
|
118 |
* You can include images in the excerpt by using the shortcode #eimg1#,
|
119 |
#eimg2# etc.
|
120 |
|
121 |
+
= Post type/format =
|
122 |
+
You can specify the post type or format by including it as the first part of the subject.
|
123 |
+
E.g. aside//real subject
|
124 |
|
125 |
= Categories =
|
126 |
* If you put a category name in the subject with a : it will be used
|
133 |
Gen: New News
|
134 |
|
135 |
The system will post that in General. Note you must turn on the "Match short category"
|
136 |
+
setting for this to work (on by default).
|
137 |
|
138 |
* All of the above also applies if you put the category in brackets []
|
139 |
* Using [] or you can post to multiple categories at once
|
421 |
`define('DISABLE_WP_CRON', true);` is not in your wp-config.php file.
|
422 |
== Upgrade Notice ==
|
423 |
|
424 |
+
= 1.4.41 =
|
425 |
+
Post format is now supported. You can specify any of the WordPress supported post formats using the Post type syntax.
|
426 |
+
Post status can now be specified using the status: tag.
|
427 |
+
Post status setting was renamed to Default Post Status and moved to the Message tab.
|
428 |
+
|
429 |
= 1.4.18 =
|
430 |
Many method names have been changed. Any custom filters may need to be updated.
|
431 |
|
436 |
Attachments are now processed in the order they were attached.
|
437 |
|
438 |
== CHANGELOG ==
|
439 |
+
= 1.5.0 (2013.04.05) =
|
440 |
+
* Apply Postie Time Correction to date: command
|
441 |
+
* Add support for Post Formats
|
442 |
+
* Add support for Post Status
|
443 |
+
* Add warning if Admin username is invalid
|
444 |
+
* Fixed bug where date: was not always being detected in html emails
|
445 |
+
* Improved handling of attachments and mapping to file extensions for template selection
|
446 |
+
* Video templates now include scale="tofit"
|
447 |
+
* Add support for older png mime type
|
448 |
+
* New filter postie_filter_email. Used to map "from" to any other email. Allows custom user mapping.
|
449 |
+
|
450 |
+
|
451 |
= 1.4.40 (2013.03.18) =
|
452 |
* Fixed bug where categories specified by ID were not being correctly identified
|
453 |
|
templates/video1_templates.php
CHANGED
@@ -12,7 +12,7 @@ $small = '<object ' .
|
|
12 |
'autoplay="no" controller="true" ' .
|
13 |
'type="video/quicktime" ' .
|
14 |
'pluginspage="http://www.apple.com/quicktime/download/" ' .
|
15 |
-
'width="128" height="110">' .
|
16 |
'</embed> ' .
|
17 |
'</object>';
|
18 |
$medium = '<object ' .
|
@@ -27,7 +27,7 @@ $medium = '<object ' .
|
|
27 |
'autoplay="no" controller="true" ' .
|
28 |
'type="video/quicktime" ' .
|
29 |
'pluginspage="http://www.apple.com/quicktime/download/" ' .
|
30 |
-
'width="320" height="260">' .
|
31 |
'</embed> ' .
|
32 |
'</object>';
|
33 |
$medium_widescreen = '<object ' .
|
@@ -42,7 +42,7 @@ $medium_widescreen = '<object ' .
|
|
42 |
'autoplay="no" controller="true" ' .
|
43 |
'type="video/quicktime" ' .
|
44 |
'pluginspage="http://www.apple.com/quicktime/download/" ' .
|
45 |
-
'width="480" height="290">' .
|
46 |
'</embed> ' .
|
47 |
'</object>';
|
48 |
$large = '<object ' .
|
@@ -57,7 +57,7 @@ $large = '<object ' .
|
|
57 |
'autoplay="no" controller="true" ' .
|
58 |
'type="video/quicktime" ' .
|
59 |
'pluginspage="http://www.apple.com/quicktime/download/" ' .
|
60 |
-
'width="480" height="380">' .
|
61 |
'</embed> ' .
|
62 |
'</object>';
|
63 |
$large_widescreen = '<object ' .
|
@@ -72,7 +72,7 @@ $large_widescreen = '<object ' .
|
|
72 |
'autoplay="no" controller="true" ' .
|
73 |
'type="video/quicktime" ' .
|
74 |
'pluginspage="http://www.apple.com/quicktime/download/" ' .
|
75 |
-
'width="640" height="380">' .
|
76 |
'</embed> ' .
|
77 |
'</object>';
|
78 |
|
12 |
'autoplay="no" controller="true" ' .
|
13 |
'type="video/quicktime" ' .
|
14 |
'pluginspage="http://www.apple.com/quicktime/download/" ' .
|
15 |
+
'width="128" height="110" scale="tofit">' .
|
16 |
'</embed> ' .
|
17 |
'</object>';
|
18 |
$medium = '<object ' .
|
27 |
'autoplay="no" controller="true" ' .
|
28 |
'type="video/quicktime" ' .
|
29 |
'pluginspage="http://www.apple.com/quicktime/download/" ' .
|
30 |
+
'width="320" height="260" scale="tofit">' .
|
31 |
'</embed> ' .
|
32 |
'</object>';
|
33 |
$medium_widescreen = '<object ' .
|
42 |
'autoplay="no" controller="true" ' .
|
43 |
'type="video/quicktime" ' .
|
44 |
'pluginspage="http://www.apple.com/quicktime/download/" ' .
|
45 |
+
'width="480" height="290" scale="tofit">' .
|
46 |
'</embed> ' .
|
47 |
'</object>';
|
48 |
$large = '<object ' .
|
57 |
'autoplay="no" controller="true" ' .
|
58 |
'type="video/quicktime" ' .
|
59 |
'pluginspage="http://www.apple.com/quicktime/download/" ' .
|
60 |
+
'width="480" height="380" scale="tofit">' .
|
61 |
'</embed> ' .
|
62 |
'</object>';
|
63 |
$large_widescreen = '<object ' .
|
72 |
'autoplay="no" controller="true" ' .
|
73 |
'type="video/quicktime" ' .
|
74 |
'pluginspage="http://www.apple.com/quicktime/download/" ' .
|
75 |
+
'width="640" height="380" scale="tofit">' .
|
76 |
'</embed> ' .
|
77 |
'</object>';
|
78 |
|
test/inlineimageTest.php
CHANGED
@@ -11,7 +11,8 @@ class postiefunctions2Test extends PHPUnit_Framework_TestCase {
|
|
11 |
|
12 |
$isreply = false;
|
13 |
$mimeDecodedEmail = DecodeMIMEMail($email);
|
14 |
-
$
|
|
|
15 |
|
16 |
return $post;
|
17 |
}
|
@@ -57,7 +58,7 @@ class postiefunctions2Test extends PHPUnit_Framework_TestCase {
|
|
57 |
$config['convertnewline'] = true;
|
58 |
|
59 |
$post = $this->process_file("data/linebreaks.var", $config);
|
60 |
-
$this->assertEquals("Test<br />\nEen stuck TekstEen stuck TekstEen stuck TekstEen stuck Tekst<br />\nEen stuck TekstEen stuck Tekst<br />\n<br />\nEen stuck TekstEen stuck Tekst<br />\n", $post['post_content']);
|
61 |
}
|
62 |
|
63 |
function testjapaneseAttachment() {
|
@@ -79,7 +80,7 @@ class postiefunctions2Test extends PHPUnit_Framework_TestCase {
|
|
79 |
}
|
80 |
|
81 |
function testTagsImg() {
|
82 |
-
|
83 |
$config = config_GetDefaults();
|
84 |
$config['start_image_count_at_zero'] = true;
|
85 |
$config['imagetemplate'] = '<a href="{FILELINK}">{FILENAME}</a>';
|
@@ -93,6 +94,7 @@ class postiefunctions2Test extends PHPUnit_Framework_TestCase {
|
|
93 |
}
|
94 |
|
95 |
function testSig() {
|
|
|
96 |
$config = config_GetDefaults();
|
97 |
$config['prefer_text_type'] = 'html';
|
98 |
|
@@ -214,12 +216,12 @@ class postiefunctions2Test extends PHPUnit_Framework_TestCase {
|
|
214 |
$config['images_append'] = true;
|
215 |
$c = "test";
|
216 |
filter_ReplaceImagePlaceHolders($c, $attachements, $config);
|
217 |
-
$this->assertEquals("test[gallery]", $c);
|
218 |
|
219 |
$config['images_append'] = true;
|
220 |
$c = "test";
|
221 |
filter_ReplaceImagePlaceHolders($c, $attachements, $config);
|
222 |
-
$this->assertEquals("test[gallery]", $c);
|
223 |
|
224 |
$c = "test";
|
225 |
filter_ReplaceImagePlaceHolders($c, array(), $config);
|
11 |
|
12 |
$isreply = false;
|
13 |
$mimeDecodedEmail = DecodeMIMEMail($email);
|
14 |
+
$pm = new PostiePostModifiers();
|
15 |
+
$post = CreatePost('wayne', $mimeDecodedEmail, 1, $isreply, $config, $pm);
|
16 |
|
17 |
return $post;
|
18 |
}
|
58 |
$config['convertnewline'] = true;
|
59 |
|
60 |
$post = $this->process_file("data/linebreaks.var", $config);
|
61 |
+
$this->assertEquals("Test<br />\n<br />\nEen stuck TekstEen stuck TekstEen stuck TekstEen stuck Tekst<br />\n<br />\nEen stuck TekstEen stuck Tekst<br />\n<br />\n<br />\nEen stuck TekstEen stuck Tekst<br />\n", $post['post_content']);
|
62 |
}
|
63 |
|
64 |
function testjapaneseAttachment() {
|
80 |
}
|
81 |
|
82 |
function testTagsImg() {
|
83 |
+
echo "testTagsImg";
|
84 |
$config = config_GetDefaults();
|
85 |
$config['start_image_count_at_zero'] = true;
|
86 |
$config['imagetemplate'] = '<a href="{FILELINK}">{FILENAME}</a>';
|
94 |
}
|
95 |
|
96 |
function testSig() {
|
97 |
+
echo "testSig";
|
98 |
$config = config_GetDefaults();
|
99 |
$config['prefer_text_type'] = 'html';
|
100 |
|
216 |
$config['images_append'] = true;
|
217 |
$c = "test";
|
218 |
filter_ReplaceImagePlaceHolders($c, $attachements, $config);
|
219 |
+
$this->assertEquals("test\n[gallery]", $c);
|
220 |
|
221 |
$config['images_append'] = true;
|
222 |
$c = "test";
|
223 |
filter_ReplaceImagePlaceHolders($c, $attachements, $config);
|
224 |
+
$this->assertEquals("test\n[gallery]", $c);
|
225 |
|
226 |
$c = "test";
|
227 |
filter_ReplaceImagePlaceHolders($c, array(), $config);
|
test/postie-functionsTest.php
CHANGED
@@ -142,7 +142,27 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
|
|
142 |
$this->assertEquals("test", $content);
|
143 |
}
|
144 |
|
145 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
$config = config_GetDefaults();
|
147 |
$c = "test";
|
148 |
filter_End($c, $config);
|
@@ -163,67 +183,71 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
|
|
163 |
$c = "This is a test :end";
|
164 |
filter_End($c, $config);
|
165 |
$this->assertEquals("This is a test ", $c);
|
|
|
|
|
|
|
|
|
166 |
}
|
167 |
|
168 |
-
public function
|
169 |
$config = config_GetDefaults();
|
170 |
|
171 |
$c = "test";
|
172 |
-
|
173 |
$this->assertEquals("test", $c);
|
174 |
|
175 |
$c = "test";
|
176 |
-
|
177 |
$this->assertEquals("test", $c);
|
178 |
|
179 |
$c = "test\n";
|
180 |
-
|
181 |
$this->assertEquals("test ", $c);
|
182 |
|
183 |
$c = "test\r\n";
|
184 |
-
|
185 |
$this->assertEquals("test ", $c);
|
186 |
|
187 |
$c = "test\r";
|
188 |
-
|
189 |
$this->assertEquals("test ", $c);
|
190 |
|
191 |
$c = "test\n\n";
|
192 |
-
|
193 |
$this->assertEquals("test ", $c);
|
194 |
|
195 |
$c = "test\r\n\r\n";
|
196 |
-
|
197 |
$this->assertEquals("test ", $c);
|
198 |
|
199 |
$c = "test\r\n\r\ntest\n\ntest\rtest\r\ntest\ntest";
|
200 |
-
|
201 |
$this->assertEquals("test test test test test test", $c);
|
202 |
|
203 |
$config['convertnewline'] = true;
|
204 |
|
205 |
$c = "test\n";
|
206 |
-
|
207 |
$this->assertEquals("test<br />\n", $c);
|
208 |
|
209 |
$c = "test\n\n";
|
210 |
-
|
211 |
$this->assertEquals("test<br />\n", $c);
|
212 |
|
213 |
$c = "test\r";
|
214 |
-
|
215 |
$this->assertEquals("test<br />\n", $c);
|
216 |
|
217 |
$c = "test\r\n";
|
218 |
-
|
219 |
$this->assertEquals("test<br />\n", $c);
|
220 |
|
221 |
$c = "test\r\n\r\n";
|
222 |
-
|
223 |
$this->assertEquals("test<br />\n<br />\n", $c);
|
224 |
|
225 |
$c = "test\r\n\r\ntest\n\ntest\rtest\r\ntest\ntest";
|
226 |
-
|
227 |
$this->assertEquals("test<br />\n<br />\ntest<br />\ntest<br />\ntest<br />\ntest<br />\ntest", $c);
|
228 |
}
|
229 |
|
@@ -234,33 +258,35 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
|
|
234 |
}
|
235 |
|
236 |
public function testGetPostType() {
|
|
|
237 |
$subject = "test";
|
238 |
-
$this->assertEquals("post", tag_PostType($subject));
|
239 |
$this->assertEquals("test", $subject);
|
240 |
|
241 |
$subject = "custom//test";
|
242 |
-
$this->assertEquals("custom", tag_PostType($subject));
|
243 |
$this->assertEquals("test", $subject);
|
244 |
|
245 |
$subject = "//test";
|
246 |
-
$this->assertEquals("post", tag_PostType($subject));
|
247 |
$this->assertEquals("test", $subject);
|
248 |
|
249 |
$subject = "//";
|
250 |
-
$this->assertEquals("post", tag_PostType($subject));
|
251 |
$this->assertEquals("", $subject);
|
252 |
|
253 |
-
$subject = "
|
254 |
-
$this->assertEquals("
|
255 |
$this->assertEquals("test", $subject);
|
256 |
|
257 |
-
$subject = "
|
258 |
-
$this->assertEquals("
|
259 |
$this->assertEquals("test", $subject);
|
260 |
|
261 |
$subject = "video//test";
|
262 |
-
$this->assertEquals("
|
263 |
$this->assertEquals("test", $subject);
|
|
|
264 |
}
|
265 |
|
266 |
public function testGetPostExcerpt() {
|
@@ -397,6 +423,10 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
|
|
397 |
$c = "line 1\nline 2\n--";
|
398 |
filter_RemoveSignature($c, $config);
|
399 |
$this->assertEquals("line 1\nline 2\n", $c);
|
|
|
|
|
|
|
|
|
400 |
}
|
401 |
|
402 |
public function testmore_reccurences() {
|
@@ -503,60 +533,64 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
|
|
503 |
|
504 |
public function testtag_Date() {
|
505 |
$c = "";
|
506 |
-
$this->assertEquals(null, tag_Date($c, null));
|
507 |
$this->assertEquals("", $c);
|
508 |
|
509 |
$c = "date:";
|
510 |
-
$this->assertEquals(null, tag_Date($c, null));
|
511 |
$this->assertEquals("date:", $c);
|
512 |
|
513 |
$c = "date: nothing";
|
514 |
-
$this->assertEquals(null, tag_Date($c, null));
|
515 |
$this->assertEquals("date: nothing", $c);
|
516 |
|
517 |
$c = "date: 1";
|
518 |
-
$this->assertEquals(null, tag_Date($c, null));
|
519 |
$this->assertEquals("date: 1", $c);
|
520 |
|
521 |
$c = "date: 12/31/2013";
|
522 |
-
$this->assertEquals("2013-12-31", tag_Date($c, null));
|
523 |
$this->assertEquals("", $c);
|
524 |
|
525 |
$c = "date:12/31/2013";
|
526 |
-
$this->assertEquals("2013-12-31", tag_Date($c, null));
|
527 |
$this->assertEquals("", $c);
|
528 |
|
529 |
$c = "Date: 12/31/2013";
|
530 |
-
$this->assertEquals("2013-12-31", tag_Date($c, null));
|
531 |
$this->assertEquals("", $c);
|
532 |
|
533 |
$c = "DATE: 12/31/2013";
|
534 |
-
$this->assertEquals("2013-12-31", tag_Date($c, null));
|
535 |
$this->assertEquals("", $c);
|
536 |
|
537 |
$c = "date: 31-12-2013";
|
538 |
-
$this->assertEquals("2013-12-31", tag_Date($c, null));
|
539 |
$this->assertEquals("", $c);
|
540 |
|
541 |
$c = "date: 31.12.2013";
|
542 |
-
$this->assertEquals("2013-12-31", tag_Date($c, null));
|
543 |
$this->assertEquals("", $c);
|
544 |
|
545 |
$c = "date: Dec 31, 2013";
|
546 |
-
$this->assertEquals("2013-12-31", tag_Date($c, null));
|
547 |
$this->assertEquals("", $c);
|
548 |
|
549 |
$c = "date: 12/31/2013\nstuff";
|
550 |
-
$this->assertEquals("2013-12-31", tag_Date($c, null));
|
551 |
-
$this->assertEquals("
|
552 |
|
553 |
$c = "date: Dec 31, 2013 14:22";
|
554 |
-
$this->assertEquals("2013-12-31 14:22:00", tag_Date($c, null));
|
555 |
$this->assertEquals("", $c);
|
556 |
|
557 |
$c = "stuff\n\ndate: Dec 31, 2013 14:22\n\nmorestuff";
|
558 |
-
$this->assertEquals("2013-12-31 14:22:00", tag_Date($c, null));
|
559 |
$this->assertEquals("stuff\n\n\n\nmorestuff", $c);
|
|
|
|
|
|
|
|
|
560 |
}
|
561 |
|
562 |
function testtag_Excerpt() {
|
@@ -587,11 +621,56 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
|
|
587 |
|
588 |
$f = "moiré-pättern.png";
|
589 |
$this->assertEquals("moireCC81-paCC88ttern.png", filename_fix($f));
|
590 |
-
|
591 |
$f = "וְאָהַבְתָּ.png";
|
592 |
$this->assertEquals("D795D6B0D790D6B8D794D6B7D791D6B0D7AAD6BCD6B8.png", filename_fix($f));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
|
594 |
-
$this->assertEquals(
|
|
|
|
|
|
|
|
|
595 |
}
|
596 |
|
597 |
}
|
142 |
$this->assertEquals("test", $content);
|
143 |
}
|
144 |
|
145 |
+
public function testfilter_Start() {
|
146 |
+
$config = config_GetDefaults();
|
147 |
+
|
148 |
+
$c = "test";
|
149 |
+
filter_Start($c, $config);
|
150 |
+
$this->assertEquals("test", $c);
|
151 |
+
|
152 |
+
$c = ":start\ntest";
|
153 |
+
filter_Start($c, $config);
|
154 |
+
$this->assertEquals("\ntest", $c);
|
155 |
+
|
156 |
+
$c = "test/n:start\nsomething";
|
157 |
+
filter_Start($c, $config);
|
158 |
+
$this->assertEquals("\nsomething", $c);
|
159 |
+
|
160 |
+
$c = "<p>test</p><p>:start</p><p>something</p>";
|
161 |
+
filter_Start($c, $config);
|
162 |
+
$this->assertEquals("</p><p>something</p>", $c);
|
163 |
+
}
|
164 |
+
|
165 |
+
public function testfilter_End() {
|
166 |
$config = config_GetDefaults();
|
167 |
$c = "test";
|
168 |
filter_End($c, $config);
|
183 |
$c = "This is a test :end";
|
184 |
filter_End($c, $config);
|
185 |
$this->assertEquals("This is a test ", $c);
|
186 |
+
|
187 |
+
$c = "<p>This is a test</p><p>:end</p><div>some footer</div>";
|
188 |
+
filter_End($c, $config);
|
189 |
+
$this->assertEquals("<p>This is a test</p><p>", $c);
|
190 |
}
|
191 |
|
192 |
+
public function testfilter_Newlines() {
|
193 |
$config = config_GetDefaults();
|
194 |
|
195 |
$c = "test";
|
196 |
+
filter_Newlines($c, $config);
|
197 |
$this->assertEquals("test", $c);
|
198 |
|
199 |
$c = "test";
|
200 |
+
filter_Newlines($c, $config);
|
201 |
$this->assertEquals("test", $c);
|
202 |
|
203 |
$c = "test\n";
|
204 |
+
filter_Newlines($c, $config);
|
205 |
$this->assertEquals("test ", $c);
|
206 |
|
207 |
$c = "test\r\n";
|
208 |
+
filter_Newlines($c, $config);
|
209 |
$this->assertEquals("test ", $c);
|
210 |
|
211 |
$c = "test\r";
|
212 |
+
filter_Newlines($c, $config);
|
213 |
$this->assertEquals("test ", $c);
|
214 |
|
215 |
$c = "test\n\n";
|
216 |
+
filter_Newlines($c, $config);
|
217 |
$this->assertEquals("test ", $c);
|
218 |
|
219 |
$c = "test\r\n\r\n";
|
220 |
+
filter_Newlines($c, $config);
|
221 |
$this->assertEquals("test ", $c);
|
222 |
|
223 |
$c = "test\r\n\r\ntest\n\ntest\rtest\r\ntest\ntest";
|
224 |
+
filter_Newlines($c, $config);
|
225 |
$this->assertEquals("test test test test test test", $c);
|
226 |
|
227 |
$config['convertnewline'] = true;
|
228 |
|
229 |
$c = "test\n";
|
230 |
+
filter_Newlines($c, $config);
|
231 |
$this->assertEquals("test<br />\n", $c);
|
232 |
|
233 |
$c = "test\n\n";
|
234 |
+
filter_Newlines($c, $config);
|
235 |
$this->assertEquals("test<br />\n", $c);
|
236 |
|
237 |
$c = "test\r";
|
238 |
+
filter_Newlines($c, $config);
|
239 |
$this->assertEquals("test<br />\n", $c);
|
240 |
|
241 |
$c = "test\r\n";
|
242 |
+
filter_Newlines($c, $config);
|
243 |
$this->assertEquals("test<br />\n", $c);
|
244 |
|
245 |
$c = "test\r\n\r\n";
|
246 |
+
filter_Newlines($c, $config);
|
247 |
$this->assertEquals("test<br />\n<br />\n", $c);
|
248 |
|
249 |
$c = "test\r\n\r\ntest\n\ntest\rtest\r\ntest\ntest";
|
250 |
+
filter_Newlines($c, $config);
|
251 |
$this->assertEquals("test<br />\n<br />\ntest<br />\ntest<br />\ntest<br />\ntest<br />\ntest", $c);
|
252 |
}
|
253 |
|
258 |
}
|
259 |
|
260 |
public function testGetPostType() {
|
261 |
+
$pm = new PostiePostModifiers();
|
262 |
$subject = "test";
|
263 |
+
$this->assertEquals("post", tag_PostType($subject, $pm));
|
264 |
$this->assertEquals("test", $subject);
|
265 |
|
266 |
$subject = "custom//test";
|
267 |
+
$this->assertEquals("custom", tag_PostType($subject, $pm));
|
268 |
$this->assertEquals("test", $subject);
|
269 |
|
270 |
$subject = "//test";
|
271 |
+
$this->assertEquals("post", tag_PostType($subject, $pm));
|
272 |
$this->assertEquals("test", $subject);
|
273 |
|
274 |
$subject = "//";
|
275 |
+
$this->assertEquals("post", tag_PostType($subject, $pm));
|
276 |
$this->assertEquals("", $subject);
|
277 |
|
278 |
+
$subject = "custom2//test";
|
279 |
+
$this->assertEquals("custom2", tag_PostType($subject, $pm));
|
280 |
$this->assertEquals("test", $subject);
|
281 |
|
282 |
+
$subject = "Custom1 // test";
|
283 |
+
$this->assertEquals("custom1", tag_PostType($subject, $pm));
|
284 |
$this->assertEquals("test", $subject);
|
285 |
|
286 |
$subject = "video//test";
|
287 |
+
$this->assertEquals("post", tag_PostType($subject, $pm));
|
288 |
$this->assertEquals("test", $subject);
|
289 |
+
$this->assertEquals('video', $pm->PostFormat);
|
290 |
}
|
291 |
|
292 |
public function testGetPostExcerpt() {
|
423 |
$c = "line 1\nline 2\n--";
|
424 |
filter_RemoveSignature($c, $config);
|
425 |
$this->assertEquals("line 1\nline 2\n", $c);
|
426 |
+
|
427 |
+
$c = "test content<div><br></div><div>--</div><div>signature</div>";
|
428 |
+
filter_RemoveSignature($c, $config);
|
429 |
+
$this->assertEquals("test content<div><br></div>", $c);
|
430 |
}
|
431 |
|
432 |
public function testmore_reccurences() {
|
533 |
|
534 |
public function testtag_Date() {
|
535 |
$c = "";
|
536 |
+
$this->assertEquals(null, tag_Date($c, null, 0));
|
537 |
$this->assertEquals("", $c);
|
538 |
|
539 |
$c = "date:";
|
540 |
+
$this->assertEquals(null, tag_Date($c, null, 0));
|
541 |
$this->assertEquals("date:", $c);
|
542 |
|
543 |
$c = "date: nothing";
|
544 |
+
$this->assertEquals(null, tag_Date($c, null, 0));
|
545 |
$this->assertEquals("date: nothing", $c);
|
546 |
|
547 |
$c = "date: 1";
|
548 |
+
$this->assertEquals(null, tag_Date($c, null, 0));
|
549 |
$this->assertEquals("date: 1", $c);
|
550 |
|
551 |
$c = "date: 12/31/2013";
|
552 |
+
$this->assertEquals("2013-12-31", tag_Date($c, null, 0));
|
553 |
$this->assertEquals("", $c);
|
554 |
|
555 |
$c = "date:12/31/2013";
|
556 |
+
$this->assertEquals("2013-12-31", tag_Date($c, null, 0));
|
557 |
$this->assertEquals("", $c);
|
558 |
|
559 |
$c = "Date: 12/31/2013";
|
560 |
+
$this->assertEquals("2013-12-31", tag_Date($c, null, 0));
|
561 |
$this->assertEquals("", $c);
|
562 |
|
563 |
$c = "DATE: 12/31/2013";
|
564 |
+
$this->assertEquals("2013-12-31", tag_Date($c, null, 0));
|
565 |
$this->assertEquals("", $c);
|
566 |
|
567 |
$c = "date: 31-12-2013";
|
568 |
+
$this->assertEquals("2013-12-31", tag_Date($c, null, 0));
|
569 |
$this->assertEquals("", $c);
|
570 |
|
571 |
$c = "date: 31.12.2013";
|
572 |
+
$this->assertEquals("2013-12-31", tag_Date($c, null, 0));
|
573 |
$this->assertEquals("", $c);
|
574 |
|
575 |
$c = "date: Dec 31, 2013";
|
576 |
+
$this->assertEquals("2013-12-31", tag_Date($c, null, 0));
|
577 |
$this->assertEquals("", $c);
|
578 |
|
579 |
$c = "date: 12/31/2013\nstuff";
|
580 |
+
$this->assertEquals("2013-12-31", tag_Date($c, null, 0));
|
581 |
+
$this->assertEquals("\nstuff", $c);
|
582 |
|
583 |
$c = "date: Dec 31, 2013 14:22";
|
584 |
+
$this->assertEquals("2013-12-31 14:22:00", tag_Date($c, null, 0));
|
585 |
$this->assertEquals("", $c);
|
586 |
|
587 |
$c = "stuff\n\ndate: Dec 31, 2013 14:22\n\nmorestuff";
|
588 |
+
$this->assertEquals("2013-12-31 14:22:00", tag_Date($c, null, 0));
|
589 |
$this->assertEquals("stuff\n\n\n\nmorestuff", $c);
|
590 |
+
|
591 |
+
$c = "<p>stuff</p><p>date: Dec 31, 2013 14:22</p><p>morestuff</p>";
|
592 |
+
$this->assertEquals("2013-12-31 14:22:00", tag_Date($c, null, 0));
|
593 |
+
$this->assertEquals("<p>stuff</p><p></p><p>morestuff</p>", $c);
|
594 |
}
|
595 |
|
596 |
function testtag_Excerpt() {
|
621 |
|
622 |
$f = "moiré-pättern.png";
|
623 |
$this->assertEquals("moireCC81-paCC88ttern.png", filename_fix($f));
|
624 |
+
|
625 |
$f = "וְאָהַבְתָּ.png";
|
626 |
$this->assertEquals("D795D6B0D790D6B8D794D6B7D791D6B0D7AAD6BCD6B8.png", filename_fix($f));
|
627 |
+
|
628 |
+
$this->assertEquals("D09AD0BED0B3D0B0D182D0BE.png", filename_fix("Когато.png"));
|
629 |
+
}
|
630 |
+
|
631 |
+
function testtag_Status() {
|
632 |
+
|
633 |
+
$c = "";
|
634 |
+
$s = tag_Status($c, 'publish');
|
635 |
+
$this->assertEquals("", $c);
|
636 |
+
$this->assertEquals("publish", $s);
|
637 |
+
|
638 |
+
$c = "status:private";
|
639 |
+
$s = tag_Status($c, 'publish');
|
640 |
+
$this->assertEquals("", $c);
|
641 |
+
$this->assertEquals("private", $s);
|
642 |
+
|
643 |
+
$c = "status: private";
|
644 |
+
$s = tag_Status($c, 'publish');
|
645 |
+
$this->assertEquals("", $c);
|
646 |
+
$this->assertEquals("private", $s);
|
647 |
+
|
648 |
+
$c = "status:blah";
|
649 |
+
$s = tag_Status($c, 'publish');
|
650 |
+
$this->assertEquals("status:blah", $c);
|
651 |
+
$this->assertEquals("publish", $s);
|
652 |
+
|
653 |
+
$c = "multi\nstatus: private\nline";
|
654 |
+
$s = tag_Status($c, 'publish');
|
655 |
+
$this->assertEquals("multi\n\nline", $c);
|
656 |
+
$this->assertEquals("private", $s);
|
657 |
+
}
|
658 |
+
|
659 |
+
function testgetPostAuthorDetails() {
|
660 |
+
$s = "subject";
|
661 |
+
$c = "content";
|
662 |
+
$e = new stdClass();
|
663 |
+
$e->headers = array();
|
664 |
+
$e->headers['date'] = "Jan 1, 2013";
|
665 |
+
$e->headers['from'] = "wayne@postieplugin.com";
|
666 |
+
|
667 |
+
$r = getPostAuthorDetails($s, $c, $e);
|
668 |
|
669 |
+
$this->assertEquals($s, "subject");
|
670 |
+
$this->assertEquals($c, "content");
|
671 |
+
$this->assertEquals($r['author'], "wayne");
|
672 |
+
$this->assertEquals($r['email'], "wayne@postieplugin.com");
|
673 |
+
$this->assertEquals($r['emaildate'], "Jan 1, 2013");
|
674 |
}
|
675 |
|
676 |
}
|
test/wpstub.php
CHANGED
@@ -37,7 +37,7 @@ function get_option($option, $default = false) {
|
|
37 |
}
|
38 |
|
39 |
function get_post_types() {
|
40 |
-
return array("post", "page", "custom", "
|
41 |
}
|
42 |
|
43 |
function current_time() {
|
@@ -62,7 +62,18 @@ function __($t) {
|
|
62 |
return $t;
|
63 |
}
|
64 |
|
65 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
return array('ext' => 'xxx', 'type' => 'xxx/xxx');
|
67 |
}
|
68 |
|
@@ -157,4 +168,8 @@ function get_term_by() {
|
|
157 |
return $g_get_term_by;
|
158 |
}
|
159 |
|
|
|
|
|
|
|
|
|
160 |
?>
|
37 |
}
|
38 |
|
39 |
function get_post_types() {
|
40 |
+
return array("post", "page", "custom", "custom1", "Custom2");
|
41 |
}
|
42 |
|
43 |
function current_time() {
|
62 |
return $t;
|
63 |
}
|
64 |
|
65 |
+
function endsWith($haystack, $needle)
|
66 |
+
{
|
67 |
+
return substr($haystack, -strlen($needle)) == $needle;
|
68 |
+
}
|
69 |
+
|
70 |
+
function wp_check_filetype($filename) {
|
71 |
+
if (empty($filename))
|
72 |
+
return null;
|
73 |
+
if (endsWith($filename, ".png"))
|
74 |
+
return array('ext' => 'png', 'type' => 'image/png');
|
75 |
+
if (endsWith($filename, ".ics"))
|
76 |
+
return array('ext' => 'ics', 'type' => 'text/calendar');
|
77 |
return array('ext' => 'xxx', 'type' => 'xxx/xxx');
|
78 |
}
|
79 |
|
168 |
return $g_get_term_by;
|
169 |
}
|
170 |
|
171 |
+
function get_post_format_slugs() {
|
172 |
+
return array('standard' => 'standard', 'video' => 'video', 'image' => 'image', 'aside' => 'aside');
|
173 |
+
}
|
174 |
+
|
175 |
?>
|