Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Front End Publishing for WordPress

4,296 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Front End Publishing for WordPress

  1. 1. Front End Publishing for A practical guide to enabling Front End Publishing on WordPress websites
  2. 2. What We'll Cover <ul><li>Reasons for allowing Front End Publishing
  3. 3. Use Cases for FEP
  4. 4. Turnkey methods for FEP with examples </li></ul><ul><li>Tools for writing FEP enabled plug-ins
  5. 5. FEP Security Considerations
  6. 6. Questions </li></ul>
  7. 7. <ul>Reasons to allow FEP </ul><ul><li>Increase amount of content
  8. 8. Users spend more time on your site
  9. 9. Authors will return to see published content
  10. 10. Increases social sharing
  11. 11. */wp-admin/ can scare users away and decrease sexyness of your application </li></ul>
  12. 12. <ul>Use Cases for FEP </ul><ul><li>Blog Sites that want to increase guest blog posting and simplify submission process
  13. 13. Niche content platforms or applications that rely on user generated content such as: </li><ul><li>Widget Directory
  14. 14. Company Document Repository
  15. 15. Photo Sharing </li></ul><li>IE6 users </li></ul>
  16. 16. <ul>Methods for FEP w/ examples </ul><ul><li>Existing WordPress tools that enable Front End Publishing include: </li><ul><li>P2 Theme
  17. 17. TDO Mini Forms </li><ul><li>Only Supports Post and Pages
  18. 18. Is highly configurable with logic and moderation
  19. 19. No Autosave, revisions or wysiwyg :( </li></ul><li>Gravity Forms </li><ul><li>More advanced fields and conditional logic
  20. 20. Requires additional plug-in or coding to support Custom Post Types and Custom Taxonomies </li></ul></ul></ul>
  21. 21. TDO Mini Forms Simple
  22. 22. TDO Mini Forms Chaotic
  23. 23. Gravity Forms Simple
  24. 24. Add Video, the */wp-admin/ way
  25. 25. Gravity Forms Custom Post Type
  26. 26. <ul>Writing FEP enabled plug-ins </ul><ul><li>Rely on wp_insert_post(); to create posts.
  27. 27. Use wp_set_post_terms(); to add (and update) taxonomy terms.
  28. 28. Use add_post_meta(); to add meta values.
  29. 29. Add Image or attachment with wp_insert_attachment(); </li></ul>
  30. 30. Front End Form Example (1/2) <form id=&quot;new_post&quot; name=&quot;new_post&quot; method=&quot;post&quot; action=&quot;&quot;> <label for=&quot;title&quot;>Title</label><input type=&quot;text&quot; id=&quot;title&quot; value=&quot;&quot; tabindex=&quot;1&quot; size=&quot;20&quot; name=&quot;title&quot; /> <label for=&quot;description&quot;>Description</label><textarea id=&quot;description&quot; tabindex=&quot;3&quot; name=&quot;description&quot; cols=&quot;50&quot; rows=&quot;6&quot;></textarea> <?php wp_dropdown_categories( 'show_option_none= Category&tab_index=4&taxonomy=category' ); ?>
  31. 31. Front End Form Example (2/2) <label for=&quot;post_tags&quot;>Tags</label><input type=&quot;text&quot; value=&quot;&quot; tabindex=&quot;5&quot; size=&quot;16&quot; name=&quot;post_tags&quot; id=&quot;post_tags&quot; /> <input type=&quot;submit&quot; value=&quot;Publish&quot; tabindex=&quot;6&quot; id=&quot;submit&quot; name=&quot;submit&quot; /> <input type=&quot;hidden&quot; name=&quot;post_type&quot; id=&quot;post_type&quot; value=&quot;post&quot; /> <input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;post&quot; /> <?php wp_nonce_field( 'new-post' ); ?></form>
  32. 32. Processing $_POST (1/2) <?php if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] )) { if (isset ($_POST['title'])) {$title = $_POST['title'];} if (isset ($_POST['description'])) {$description = $_POST['description'];} $tags = $_POST['post_tags'];
  33. 33. Processing $_POST (2/2) $post = array('post_title' => $title,'post_content' => $description,'post_category' => $_POST['cat'], 'tags_input' => $tags,'post_status' => 'publish','post_type' => $_POST['post_type'] ); wp_insert_post($post); wp_redirect( home_url() );} do_action('wp_insert_post', 'wp_insert_post'); ?>
  34. 34. Updating posts FEP style <ul><li>Update existing posts with wp_update_post();
  35. 35. Update meta values with update_post_meta(); </li></ul>
  36. 36. <ul>FEP Security Considerations </ul><ul><li>SPAM SPAM SPAM!
  37. 37. Fuc*ing bad words!
  38. 38. Easy to hack if user input is unchecked. </li><ul><li>Use esc_attr and esc_url
  39. 39. Filter post content before saving with wp_kses
  40. 40. Be sure to use nonces to verify intent
  41. 41. See Codex Data_Validation </li></ul></ul>
  42. 42. Resources <ul><li>http://wordpress.org/extend/plugins/tdo-mini-forms/
  43. 43. http://www.gravityforms.com/
  44. 44. http://wordpress.org/extend/plugins/gravity-forms-custom-post-types/
  45. 45. http://codex.wordpress.org/Function_Reference/wp_insert_post
  46. 46. http://codex.wordpress.org/Function_Reference/wp_kses
  47. 47. http://codex.wordpress.org/Data_Validation
  48. 48. http://wpshout.com/wordpress-submit-posts-from-frontend/ </li></ul>
  49. 49. Question?
  50. 50. Wrap! <ul><li>Russell Fair
  51. 51. r @ q21.co
  52. 52. Slides @ slideshare . com / rfair / front-end-publishing-for-wordpress </li></ul>

×