Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. // Display price packages as a select list
  2. function gd_build_payment_select_list() {
  3. global $post, $package_id;
  4.  
  5. $listing_type = !empty( $_REQUEST['listing_type'] ) ? sanitize_text_field( $_REQUEST['listing_type'] ) : '';
  6. $listing_type = empty( $listing_type ) && !empty( $post->post_type ) ? $post->post_type : $listing_type;
  7.  
  8. if ( isset( $_REQUEST['package_id'] ) ) {
  9. $package_id = $_REQUEST['package_id'];
  10. } else if ( !empty( $post->package_id ) ) {
  11. $listing_type = $post->post_type;
  12. $package_id = $post->package_id;
  13. } else {
  14. $default_package = geodir_get_default_package( $listing_type );
  15. $package_id = !empty( $default_package->pid ) ? $default_package->pid : '';
  16. }
  17.  
  18. $package_info = geodir_get_package_info( $package_id );
  19.  
  20. $package_list_info = geodir_package_list_info( $listing_type );
  21.  
  22. if ( is_page() && isset( $post->post_content ) && has_shortcode( $post->post_content, 'gd_add_listing' ) ) {
  23. $page_id = $post->ID;
  24. } else {
  25. $page_id = geodir_add_listing_page_id();
  26. }
  27.  
  28. $postlink = geodir_getlink( get_permalink( $page_id ), array( 'listing_type' => $listing_type ), false );
  29.  
  30. if ( !empty( $_REQUEST['pid'] ) ) {
  31. $postlink = geodir_getlink( $postlink, array( 'pid' => $_REQUEST['pid'] ), false );
  32. }
  33.  
  34. if ( isset( $_REQUEST['package_id'] ) || ( !isset( $_REQUEST['pid'] ) || $_REQUEST['pid'] == '' ) ) {
  35. $package_content = '<h5 id="geodir_fieldset_packages" class="geodir-fieldset-row" gd-fieldset="packages">' . SELECT_PACKAGE_TEXT . '</h5>';
  36. $package_content .= '<div class="geodir_price_package_row geodir_form_row geodir_custom_fields clearfix">';
  37. $package_content .= '<label>' . __( 'Package', 'geodir_payments' ) . '</label>';
  38. $package_content .= '<select name="package_id" id="package_id" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . esc_attr__( 'Select Package', 'geodirectory' ) . '" option-ajaxchosen="false" onchange="window.location.href=\''. esc_url( $postlink ) . '&package_id=\' + this.value">';
  39.  
  40. foreach ( $package_list_info as $pkg ) {
  41. $alive_days = !empty( $pkg->days ) ? $pkg->days : 'unlimited';
  42. $pkg_desc = str_replace( 'number of publish days are', __( 'number of publish days are', 'geodir_payments' ), $pkg->title_desc );
  43.  
  44. $package_content .= '<div id="geodir_price_package_' . $pkg->pid . '" class="geodir_package">';
  45.  
  46. $package_content .= '<option value="' . $pkg->pid . '" ' . selected( (int)$package_id == (int)$pkg->pid, true, false ) . '>' . strip_tags( __( stripslashes_deep( $pkg_desc ), 'geodirectory') ) . '</option>';
  47. }
  48.  
  49. $package_content .= '</select></div>';
  50.  
  51. echo $package_content;
  52. }
  53. }
  54.  
  55. function gd_plugins_loaded() {
  56. remove_action( 'geodir_before_detail_fields' , 'geodir_build_payment_list', 1 );
  57. add_action( 'geodir_before_detail_fields' , 'gd_build_payment_select_list', 1 );
  58. }
  59. add_action( 'plugins_loaded', 'gd_plugins_loaded' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement