/includes/woo-upload-listing-form.php

https://github.com/greentv/beta.green.tv · PHP · 211 lines · 96 code · 87 blank · 28 comment · 37 complexity · 5ff5f1996391a1aac8d31450bc916ae9 MD5 · raw file

  1. <?php
  2. // If necessary, force the user to login.
  3. global $woo_options, $current_user;
  4. // Determine whether or not the user can upload a listing (do they need to be registered? If so, are they logged in? Can anyone upload a listing without registering?)
  5. $can_upload_listing = false;
  6. if ( $woo_options['woo_upload_user_logged_in'] == 'true' ) {
  7. get_currentuserinfo();
  8. if ( is_user_logged_in() ) {
  9. $can_upload_listing = true;
  10. } // End IF Statement ( is_user_logged_in() )
  11. } else {
  12. $can_upload_listing = true;
  13. } // End IF Statement ( $woo_options['woo_upload_user_logged_in'] )
  14. // Once we have determined whether or not to display the form, display either the upload form or a login/register option.
  15. if ( $can_upload_listing ) {
  16. // Load the form processing file,
  17. // allowing users to override the form in their child theme.
  18. $templates = array( 'includes/upload-listing/process.php' );
  19. $form = locate_template( $templates, false );
  20. if ( $form == '' ) {} else { require_once( $form ); } // End IF Statement
  21. ?>
  22. <form name="woothemes_upload_video" method="post" action="">
  23. <?php
  24. // Once in, display a form using dynamic data from the database.
  25. $post_type = 'woo_video';
  26. if ( $post_type ) {
  27. // $post_type = strtolower( strip_tags( trim( $_POST['woo_post_type'] ) ) );
  28. // If errors are present, display them for the user.
  29. if ( count( $errors ) ) {
  30. $_html = '';
  31. $_html .= '<p class="woo-sc-box alert">' . "\n";
  32. foreach ( $errors as $e ) {
  33. $_html .= $e . '<br />' . "\n";
  34. } // End FOREACH Loop
  35. $_html .= '</p>' . "\n";
  36. echo $_html;
  37. } // End IF Statement
  38. $button_text = __( 'Post Your Video' , 'woothemes' );
  39. $action = 'upload';
  40. // $post_type = $_POST['woo_post_type'];
  41. // Display the remaining form.
  42. if ( $_is_processed ) {
  43. $message = sprintf( __( 'Your %s has been submitted for review.', 'woothemes' ), 'video' );
  44. $message = apply_filters( 'woo_listings_thankyou_message', $message );
  45. $message = '<p class="woo-sc-box tick">' . $message . '</p>' . "\n";
  46. echo $message;
  47. } else {
  48. // Load the "Title and content" form,
  49. // allowing users to override the form in their child theme.
  50. $templates = array( 'includes/upload-listing/form-field-defaults.php' );
  51. $form = locate_template( $templates, false );
  52. if ( $form == '' ) {} else { require_once( $form ); } // End IF Statement
  53. // Load the "Select custom taxonomies" form,
  54. // allowing users to override the form in their child theme.
  55. $templates = array( 'includes/upload-listing/form-field-custom-taxonomies.php' );
  56. $form = locate_template( $templates, false );
  57. if ( $form == '' ) {} else { require_once( $form ); } // End IF Statement
  58. // Load the "Input custom fields" form,
  59. // allowing users to override the form in their child theme.
  60. $templates = array( 'includes/upload-listing/form-field-custom-fields.php' );
  61. $form = locate_template( $templates, false );
  62. if ( $form == '' ) {} else { require_once( $form ); } // End IF Statement
  63. // Load the "Upload a featured image" form,
  64. // allowing users to override the form in their child theme.
  65. // Make sure the user is logged in before allowing them to upload images.
  66. if ( is_user_logged_in() && current_user_can( 'upload_files' ) ) {
  67. $templates = array( 'includes/upload-listing/form-field-featured-image.php' );
  68. $form = locate_template( $templates, false );
  69. if ( $form == '' ) {} else { require_once( $form ); } // End IF Statement
  70. } // End IF Statement
  71. } // End IF Statement
  72. } else {
  73. $button_text = __( 'Create Entry' , 'woothemes' );
  74. $action = 'select_post_type';
  75. // No post type has been selected yet. Let the user choose one.
  76. // Load the "Select a post type" form,
  77. // allowing users to override the form in their child theme.
  78. $templates = array( 'includes/upload-listing/form-field-post-type.php' );
  79. $form = locate_template( $templates, false );
  80. if ( $form == '' ) {} else { require_once( $form ); } // End IF Statement
  81. } // End IF Statement
  82. if ( $_is_processed ) {} else {
  83. ?>
  84. <fieldset class="submit-buttons">
  85. <input type="hidden" name="woo-action" value="<?php echo $action; ?>" />
  86. <?php
  87. // $post_id_val = $_POST['woo_post_id'];
  88. $post_id_val = '';
  89. // If no post ID has yet been set, create an auto-draft.
  90. if ( $post_id_val == '' ) {
  91. // Get the file that holds get_default_post_to_edit().
  92. require_once( 'wp-admin/includes/post.php' );
  93. $post_obj = get_default_post_to_edit( $post_type, true );
  94. $post_id_val = $post_obj->ID;
  95. } // End IF Statement
  96. ?>
  97. <input type="hidden" name="woo_post_type" value="<?php echo $post_type; ?>" />
  98. <input type="hidden" name="woo_post_id" value="<?php echo $post_id_val; ?>" />
  99. <input type="submit" name="woo-submit" class="submit button button-primary" id="submit-button" value="<?php echo $button_text; ?>" />
  100. </fieldset>
  101. <?php // End the main form. Don't remove this, or the sky will fall on your head. ?>
  102. <?php
  103. } // End IF Statement ( $_is_processed )
  104. ?></form><?php
  105. } else {
  106. // Display a login/register form.
  107. echo '<div id="woo-listings-login">' . "\n";
  108. echo '<p class="woo-sc-box info">' . __( 'Please login to post a video', 'woothemes' ) . '</p>';
  109. wp_login_form();
  110. echo '</div>' . "\n";
  111. // Only show the "register" link if the user has enabled registrations in their installation.
  112. if ( get_option('users_can_register') ) {
  113. $_register_link = '';
  114. $_site_root_url = site_url();
  115. if ( function_exists( 'network_home_url' ) ) {
  116. $_site_root_url = network_home_url();
  117. } // End IF Statement
  118. $_site_root_url = trailingslashit( $_site_root_url );
  119. $_register_link .= '<p class="woo-sc-box note">' . __( 'Not a member yet? ', 'woothemes' ) . '<a href="' . $_site_root_url . 'wp-login.php?action=register&is_woothemes_register=yes&TB_iframe=true" class="thickbox">' . __( 'Click here to register.', 'woothemes' ) . '</a></p>';
  120. echo $_register_link;
  121. // wp_register( '<span class="woo-listings-register">', '</span>' );
  122. } // End IF Statement
  123. } // End IF Statement ( $can_upload_listing )
  124. ?>