Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Display price packages as a select list
- function gd_build_payment_select_list() {
- global $post, $package_id;
- $listing_type = !empty( $_REQUEST['listing_type'] ) ? sanitize_text_field( $_REQUEST['listing_type'] ) : '';
- $listing_type = empty( $listing_type ) && !empty( $post->post_type ) ? $post->post_type : $listing_type;
- if ( isset( $_REQUEST['package_id'] ) ) {
- $package_id = $_REQUEST['package_id'];
- } else if ( !empty( $post->package_id ) ) {
- $listing_type = $post->post_type;
- $package_id = $post->package_id;
- } else {
- $default_package = geodir_get_default_package( $listing_type );
- $package_id = !empty( $default_package->pid ) ? $default_package->pid : '';
- }
- $package_info = geodir_get_package_info( $package_id );
- $package_list_info = geodir_package_list_info( $listing_type );
- if ( is_page() && isset( $post->post_content ) && has_shortcode( $post->post_content, 'gd_add_listing' ) ) {
- $page_id = $post->ID;
- } else {
- $page_id = geodir_add_listing_page_id();
- }
- $postlink = geodir_getlink( get_permalink( $page_id ), array( 'listing_type' => $listing_type ), false );
- if ( !empty( $_REQUEST['pid'] ) ) {
- $postlink = geodir_getlink( $postlink, array( 'pid' => $_REQUEST['pid'] ), false );
- }
- if ( isset( $_REQUEST['package_id'] ) || ( !isset( $_REQUEST['pid'] ) || $_REQUEST['pid'] == '' ) ) {
- $package_content = '<h5 id="geodir_fieldset_packages" class="geodir-fieldset-row" gd-fieldset="packages">' . SELECT_PACKAGE_TEXT . '</h5>';
- $package_content .= '<div class="geodir_price_package_row geodir_form_row geodir_custom_fields clearfix">';
- $package_content .= '<label>' . __( 'Package', 'geodir_payments' ) . '</label>';
- $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">';
- foreach ( $package_list_info as $pkg ) {
- $alive_days = !empty( $pkg->days ) ? $pkg->days : 'unlimited';
- $pkg_desc = str_replace( 'number of publish days are', __( 'number of publish days are', 'geodir_payments' ), $pkg->title_desc );
- $package_content .= '<div id="geodir_price_package_' . $pkg->pid . '" class="geodir_package">';
- $package_content .= '<option value="' . $pkg->pid . '" ' . selected( (int)$package_id == (int)$pkg->pid, true, false ) . '>' . strip_tags( __( stripslashes_deep( $pkg_desc ), 'geodirectory') ) . '</option>';
- }
- $package_content .= '</select></div>';
- echo $package_content;
- }
- }
- function gd_plugins_loaded() {
- remove_action( 'geodir_before_detail_fields' , 'geodir_build_payment_list', 1 );
- add_action( 'geodir_before_detail_fields' , 'gd_build_payment_select_list', 1 );
- }
- add_action( 'plugins_loaded', 'gd_plugins_loaded' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement