Hey – I did it!!! I now have a TITLE field.
Wow – so what did I do… holy moly – let’s see…………
I hope CutNPaste work good here!
So first: /inc/p2.js
function newPost(trigger) {
var thisForm = $(trigger.target);
var thisFormElements = $(‘#posttext, #tags, #my_title, :input’,thisForm).not(‘input[type=hidden]’);
var submitProgress = thisForm.find(‘span.progress’);
var posttext = $.trim($(‘#posttext’).val());
if(jQuery(‘.no-posts’)) jQuery(‘.no-posts’).hide();
if (“” == posttext) {
$(“label#posttext_error”).text(‘All fields are required’).show().focus();
return false;
}
var my_title = $.trim($(‘#my_title’).val());
if (“” == my_title) {
$(“label#posttext_error”).text(‘You need to add a TITLE’).show().focus();
return false;
} toggleUpdates(‘unewposts’);
if (typeof ajaxCheckPosts != “undefined”)
ajaxCheckPosts.abort();
$(“label#posttext_error”).hide();
thisFormElements.attr(‘disabled’, true);
thisFormElements.addClass(‘disabled’);
submitProgress.show();
var tags = $(‘#tags’).val();
if (tags == p2txt.tagit) tags = ”;
var args = {action: ‘prologue_new_post’, _ajax_post:nonce, posttext: posttext, my_title: my_title, tags: tags};
var errorMessage = ”;
$.ajax({
type: “POST”,
url: ajaxUrl,
data: args,
success: function(result) {
if (“0” == result)
errorMessage = p2txt.not_posted_error;
$(‘#posttext’).val(”);
$(‘#my_title’).val(”);
$(‘#tags’).val(p2txt.tagit);
Well – every where you see “my_title”
I also did the functions.php and added stuff:
function prologue_new_post() {
if( 'POST' != $_SERVER['REQUEST_METHOD'] || empty( $_POST['action'] ) || $_POST['action'] != 'prologue_new_post' ) {
die();
}
if ( !is_user_logged_in() ) {
die('<p>'.__('Error: not logged in.', 'p2').'</p>');
}
if( !current_user_can( 'publish_posts' ) ) {
die('<p>'.__('Error: not allowed to post.', 'p2').'</p>');
}
check_ajax_referer( 'ajaxnonce', '_ajax_post' );
$user_id = $current_user->user_id;
$post_content = $_POST['posttext'];
$post_title = trim( $_POST['my_title'] );
//$tags = trim( $_POST['tags'] );
//if ( $tags == __('Tag it', 'p2') || $tags == 'Tag it' ) $tags = '';
//$post_title = prologue_title_from_content( $post_content );
$post_id = wp_insert_post( array(
'post_author' => $user_id,
'post_title' => $post_title,
'post_content' => $post_content,
'post_status' => 'publish'
) );
echo $post_id? $post_id : '0';
exit;
}
There’s only one line here. And Comment out the part where it’s derived from the Content…
OH, I disabled TAGs, BTW… so be sure you uncomment that above if you want it… I may have deleted some lines, too…
Make a BACKUP!!
Don’t you love when people solve their own crap!?!?! LOL
Now I need to figure out the tabindex order… and how the posttext field gets focus on refresh… cuz then the tabindex gets out of order!!
OH – and I almost forgot – you of course have to add the HTML part to the form:
TITLE: <input id="my_title" type="text" autocomplete="off" value="" tabindex="1" size="30" name="my_title"/>
Not sure installation is the best forum for this, but this is an interesting & useful tip. Ta for sharing.
functions.php – i posted some code above (without the code tics!)
And sorry about the placement… I thought this was the area for ALL P2 related stuff…
I’ll see about looking where else to put this…
OH – I see what you mean by the wrong place to post this!!!
I’m really sorry folks. I began this post in the P2 Theme area and I assumed (and you know what they say about those who assume) it would post to the same “current” location by default.
Not very intuitive, IMHO…
Is there a moderator who can move this to the right location?
ok – weird, still… I’m in this:
http://ww.wp.xz.cn/tags/p2
and I see my post there… as a tag??…
This whole concept of tags is strange to me, which is why I removed TAGs from my P2 themed site! HAHA
well – back to the topic – even if it IS in the wrong place (which probably because I actually ADDED tags…)
Be sure to limit the number of characters. P2 already had for the other function, because it would strip 40 characters off the $content… Well – I’ll figure out how to apply that to my mods.
It’s something I wanted to do to the content, too, anyway!!! I don’t need long-winded descriptions of the women drinking beer pix!!!
If you are curious, then join in the fun!
http://www.womendrinkingbeer.com
🙂