Skip to content

Commit

Permalink
Tweaks and Shines
Browse files Browse the repository at this point in the history
Addeed missing function back to tools  library, revised flow of writing form to be less redundant and repetitive, made buttons more clear for submit to review.
  • Loading branch information
cogdog committed Dec 3, 2019
1 parent aa7b6f9 commit 9ac109f
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 102 deletions.
6 changes: 2 additions & 4 deletions class.truwriter-theme-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function get_settings() {
'section' => 'general',
'title' => '', // Not used for headings.
'desc' => 'Special Pages Setup',
'std' => 'Choose the pages for the two ones that create access to the writing form',
'std' => 'Choose the pages for the two ones that create access to the writingform',
'type' => 'heading'
);

Expand All @@ -183,8 +183,6 @@ public function get_settings() {

}



$this->settings['write_page'] = array(
'section' => 'general',
'title' => __( 'Page For Writing Form (Writing Pad)'),
Expand All @@ -211,7 +209,7 @@ public function get_settings() {
'type' => 'radio',
'std' => 'pending',
'choices' => array(
'pending' => 'Moderated: new submissions will not appear until an admin edits status in Wordpress',
'pending' => 'Moderated. New submissions are set with a <strong>Pending</strong> status and will not appear until an admin updates the status in Wordpress',
'publish' => 'Published immediately to site',
)
);
Expand Down
12 changes: 0 additions & 12 deletions includes/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,6 @@ function truwriter_register_theme_customizer( $wp_customize ) {
)
)
);


// ------ color controls for form and buttons

/*
.pretty-button-final, #writerform input.pretty-button-final { background: #0971B2; }
.pretty-button-update, #writerform input.pretty-button-update { background: #00B233; }
.writenew { background-color: #8ed9f6; }
.writedraft { background-color: #D1FAB6; }
.writeoops { background-color: #fad9d7; }
*/

// Final button color

Expand Down
6 changes: 1 addition & 5 deletions includes/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ function truwriter_comment_mod( $defaults ) {

function truwriter_tinymce_settings( $settings ) {

// $settings['file_picker_types'] = 'image';
$settings['images_upload_handler'] = 'function (blobInfo, success, failure) {
var xhr, formData;
Expand Down Expand Up @@ -231,6 +230,7 @@ function truwriter_tinymce_settings( $settings ) {
xhr.send(formData);
}';



return $settings;
}
Expand Down Expand Up @@ -297,7 +297,6 @@ function truwriter_upload_action() {
}
echo json_encode( array('id'=> $newupload, 'location' => wp_get_attachment_image_src( $newupload, 'large' )[0], 'caption' => get_attachment_caption_by_id( $newupload ) ) );
die();

}

# -----------------------------------------------------------------
Expand Down Expand Up @@ -465,9 +464,6 @@ function truwriter_is_preview() {
return ( get_query_var( 'ispre', 0 ) == 1);
}

# -----------------------------------------------------------------
# login stuff
# -----------------------------------------------------------------

# -----------------------------------------------------------------
# login stuff - things to set up special user, prevent access to WP
Expand Down
12 changes: 6 additions & 6 deletions includes/tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function truwriter_word_count( $content ) {

function truwriter_preview_notice() {
return ('<div class="notify"><span class="symbol icon-info"></span>
This is a preview of your entry that shows how it will look when published. <a href="#" onclick="self.close();return false;">Close this window/tab</a> when done to return to the writing form. Make any changes and click "Revise Draft" again or if it is ready, click "Publish Now".
This is a preview of your entry that shows how it will look when published. <a href="#" onclick="self.close();return false;">Close this window/tab</a> when done to return to the writing form. Make any changes and click "Update and Save Draft" again or if it is ready, click "Publish Now".
</div>');
}

Expand Down Expand Up @@ -155,11 +155,6 @@ function twitternameify( $str ) {
# Email
# -----------------------------------------------------------------

function set_html_content_type() {
// from http://codex.wordpress.org/Function_Reference/wp_mail
return 'text/html';
}

function truwriter_allowed_email_domain( $email ) {
// checks if an email address is within a list of allowed domains

Expand All @@ -178,6 +173,11 @@ function truwriter_allowed_email_domain( $email ) {
return false;
}

function set_html_content_type() {
// from http://codex.wordpress.org/Function_Reference/wp_mail
return 'text/html';
}


# -----------------------------------------------------------------
# API
Expand Down
135 changes: 61 additions & 74 deletions page-write.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
if ( truwriter_option('show_email') ) {

// check first for valid email address, blank is ok
if ( is_email( $wEmail ) OR empty($wEmail) ) {
if ( is_email( $wEmail ) OR empty( $wEmail ) ) {

// if email is good then check if we are limiting to domains
if ( !empty(truwriter_option('email_domains')) AND !truwriter_allowed_email_domain( $wEmail ) ) {
Expand All @@ -110,13 +110,14 @@

} else {
// bad email, sam.
$errors[] = '<strong>Invalid Email Address</strong> - the email address entered <code>' . $wEmail . '</code> is not a valid address. To skip entering an email address, make sure the field is empty. Pleae check and try again. ';
$errors[] = '<strong>Invalid Email Address</strong> - the email address entered <code>' . $wEmail . '</code> is not valid. Pleae check and try again. To skip entering an email address, make sure the field is empty. ';
}
}

if ( count($errors) > 0 ) {
// form errors, build feedback string to display the errors
$feedback_msg = 'Sorry, but there are a few errors in your entry. Please correct and try again.<ul>';

// Hah, each one is an oops, get it?
foreach ($errors as $oops) {
$feedback_msg .= '<li>' . $oops . '</li>';
Expand All @@ -131,47 +132,82 @@

} else { // good enough, let's set up a post!

// set notifications and display status
// make a copy of the category array so we can append the default category ID
$copy_cats = $wCats;

// set notifications, display status, email messages
if ( isset( $_POST['wPublish'] ) ) {
// set to status defined as option

// set status (will be either 'publish' or 'pending') for post based on theme settings
$post_status = truwriter_option('pub_status');
$is_published = true;

if ( truwriter_option('pub_status') == 'pending' ) {
// moderated
$wStatus = 'Submitted for Review';
$formclass = 'writedraft';
$box_style = '<div class="notify notify-green"><span class="symbol icon-tick"></span> ';

// prep message to writer
$feedback_msg = 'Your writing <strong>"' . $wTitle . '"</strong> is now in the queue for publishing and will appear on <strong>' . get_bloginfo() . '</strong> as soon as it has been reviewed. ';

if ( $wEmail != '' ) {
$feedback_msg .= 'We will notify you by email at <strong>' . $wEmail . '</strong> when it has been published.';
}

$feedback_msg .= ' Now you can <a href="' . site_url() . '">return to ' . get_bloginfo() . '</a>.';

// set up admin email
$subject = 'Review newly submitted writing at ' . get_bloginfo();

$message = '<strong>"' . $wTitle . '"</strong> written by <strong>' . $wAuthor . '</strong> has been submitted to ' . get_bloginfo() . ' for editorial review. You can <a href="'. site_url() . '/?p=' . $post_id . '&preview=true' . '">preview it now</a>.<br /><br /> To publish simply <a href="' . admin_url( 'edit.php?post_status=pending&post_type=post') . '">find it in the submitted works</a> and change it\'s status from <strong>Draft</strong> to <strong>Publish</strong>';

} else {
// publish right away
$wStatus = 'Published';
$box_style = '<div class="notify notify-blue"><span class="symbol icon-tick"></span> ';

// prep message to writer
$feedback_msg = 'Your writing <strong>"' . $wTitle . '"</strong> has been published to <strong>' . get_bloginfo(). '</strong>. You can now exit the writing tool to <a href="'. get_permalink( $post_id ) . '" >view it now</a> or <a href="' . site_url() . '">return to ' . get_bloginfo() . '</a>.';

// set up admin email
$subject = 'Recently published writing at ' . get_bloginfo();

$message = '<strong>"' . $wTitle . '"</strong> written by <strong>' . $wAuthor . '</strong> has been published to ' . get_bloginfo() . '. You can <a href="'. site_url() . '/?p=' . $post_id . '&preview=true' . '">view it now</a>, review / edit if needed, or just enjoy the feeling of being published on your site.';

// if writer provided email address, send instructions to use link to edit if not done before
if ( $wEmail != '' and !$linkEmailed ) truwriter_mail_edit_link( $post_id, truwriter_option('pub_status') );

}

// append notes to admin email message
if ( $wNotes ) $message .= '<br /><br />There are some extra notes from the author:<blockquote>' . $wNotes . '</blockquote>';

$wStatus .= ' (version #' . $revcount . ' last saved ' . get_the_date( '', $post_id) . ' ' . get_the_time( '', $post_id) . ')';

} else {
// stay as draft
// updated form, stay as draft
$formclass = 'writedraft';
$post_status = 'draft';
$wStatus = 'In Draft (revision #' . $revcount . ' last saved ' . get_the_date( '', $post_id) . ' ' . get_the_time( '', $post_id) . ')';
$box_style = '<div class="notify notify-green"><span class="symbol icon-tick"></span> ';
//add the in progress category
$copy_cats[] = get_cat_ID( 'In Progress' );
}

// the default category for in progress
$def_category_id = get_cat_ID( 'In Progress' );


// setup the basic post info
$w_information = array(
'post_title' => $wTitle,
'post_content' => $wText,
'post_status' => $post_status,
'post_category' => array( $def_category_id )
'post_status' => $post_status
);

// updates for display
$wStatus = 'In Draft (revision #' . $revcount . ' last saved ' . get_the_time( '', $post_id) . ')';
$formclass = 'writedraft';


// is this a first draft?
if ( $post_id == 0 ) {


// set the categories
$w_information['post_category'] = $copy_cats;

// insert as a new post
$post_id = wp_insert_post( $w_information );

Expand All @@ -180,7 +216,7 @@

// store the email as post meta data
add_post_meta($post_id, 'wEmail', $wEmail);

// add the tags
wp_set_post_tags( $post_id, $wTags);

Expand Down Expand Up @@ -216,76 +252,27 @@

$feedback_msg = 'We have saved this first version of your writing. You can <a href="'. site_url() . '/?p=' . $post_id . '&preview=true&ispre=1' . '" target="_blank">preview it now</a> (opens in a new window), or make edits and save again. ';


// if user provided email address, send instructions to use link to edit
if ( $wEmail != '' ) {
truwriter_mail_edit_link( $post_id, 'draft' );
$linkEmailed = true;
$feedback_msg .= ' Since you provided an email address, a message has been sent to <strong>' . $wEmail . '</strong> with a special link that can be used at any time later to edit and publish your writing. ';
}


} else { // the post exists, let's update

// make a copy of the category array so we can append the default category ID
$copy_cats = $wCats;

// check if we have a publish button click

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

// roger, we have ignition
$is_published = true;

// for status message links
$returnlink = site_url();
$postlink = get_permalink( $post_id );


// set the published category
$copy_cats[] = $published_cat_id;

// revise status to pending (new ones)
$w_information['post_status'] = truwriter_option('pub_status');

if ( truwriter_option('pub_status') == 'pending' ) {
// theme options for saving as reviewed

$feedback_msg = 'Your writing <strong>"' . $wTitle . '"</strong> is now in the queue for publishing and will appear on <strong>' . get_bloginfo() . '</strong> as soon as it has been reviewed. ';

if ( $wEmail != '' ) {
$feedback_msg .= 'We will notify you by email at <strong>' . $wEmail . '</strong> when it has been published.';
}

$feedback_msg .= ' Now please <a href="' . $returnlink . '">clear the writing tool and return to ' . get_bloginfo() . '</a>.';

// set up admin email
$subject = 'Review newly submitted writing at ' . get_bloginfo();

$message = '<strong>"' . $wTitle . '"</strong> written by <strong>' . $wAuthor . '</strong> has been submitted to ' . get_bloginfo() . ' for editorial review. You can <a href="'. site_url() . '/?p=' . $post_id . '&preview=true' . '">preview it now</a>.<br /><br /> To publish simply <a href="' . admin_url( 'edit.php?post_status=pending&post_type=post') . '">find it in the submitted works</a> and change it\'s status from <strong>Draft</strong> to <strong>Publish</strong>';

} else {
// theme options for saving as published

$feedback_msg = 'Your writing <strong>"' . $wTitle . '"</strong> has been published to <strong>' . get_bloginfo(). '</strong>. You can now exit the writing tool to <a href="'. $postlink . '" >view it now</a> or <a href="' . $returnlink . '">return to ' . get_bloginfo() . '</a>.';

// set up admin email
$subject = 'Recently published writing at ' . get_bloginfo();

$message = '<strong>"' . $wTitle . '"</strong> written by <strong>' . $wAuthor . '</strong> has been published to ' . get_bloginfo() . '. You can <a href="'. site_url() . '/?p=' . $post_id . '&preview=true' . '">view it now</a>, review / edit if needed, or just enjoy the feeling of being published on your site.';

// if user provided email address, send instructions to use link to edit if not done before
if ( $wEmail != '' and !$linkEmailed ) truwriter_mail_edit_link( $post_id, truwriter_option('pub_status') );

} // is_status pending

$copy_cats[] = $published_cat_id;

// Let's do some EMAIL!

// who gets mail? They do.
$to_recipients = explode( "," , truwriter_option( 'notify' ) );

if ( $wNotes ) $message .= '<br /><br />There are some extra notes from the author:<blockquote>' . $wNotes . '</blockquote>';


// turn on HTML mail
add_filter( 'wp_mail_content_type', 'set_html_content_type' );

Expand All @@ -301,17 +288,17 @@
// if user provided email address, send instructions to use link to edit if not done before
if ( isset( $wEmail ) and !$linkEmailed ) truwriter_mail_edit_link( $post_id, 'draft' );

// attach the default category ID
$copy_cats[] = $def_category_id ;

$feedback_msg = 'Your edits have been updated and are still saved as a draft mode. You can <a href="'. site_url() . '/?p=' . $post_id . 'preview=true&ispre=1' . '" target="_blank">preview it now</a> (opens in a new window), or make edits, review again, or if you are ready, submit it for publishing. ';

if ( $wEmail != '' ) $feedback_msg .= ' Since you provided an email address, you should have a message that provides instructions on how to return and make edits in a later session.';

} // isset( $_POST['wPublish']
} // isset( $_POST['wPublish'] )

// add the id to our array of post information so we can issue an update
$w_information['ID'] = $post_id;

// set the categories
$w_information['post_category'] = $copy_cats;

// update the post
Expand Down Expand Up @@ -741,7 +728,7 @@
if ( $is_re_edit ) {
$save_btn_txt = "Update and Publish";
} else {
$save_btn_txt = "Publish Now";
$save_btn_txt = ( truwriter_option('pub_status') == 'publish') ? "Publish Now" : "Submit for Review";
}
?>
<input type="submit" class="pretty-button pretty-button-update" value="Update and Save Draft" id="wSubDraft" name="wSubDraft" > Save changes as draft and continue writing.<br /><br />
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Theme Name: TRU Writer
Theme URI: https://github.com/cogdog/truwriter
Description: TRU Writer (Child of Radcliffe) is a SPLOT (http://splot.ca/) for rich media writing on the web suitable for essays, magazines, conference session proposals, and more. It creates a place for people to publish in a site without them needing a WordPress account or providing identifying information.
Version: 2.7
Version: 2.71
Template: radcliffe
Author: CogDog
Author URI: https://cog.dog
Expand Down

0 comments on commit 9ac109f

Please sign in to comment.