Changeset 1596655
- Timestamp:
- 02/15/2017 03:43:44 PM (9 years ago)
- Location:
- directory-builder
- Files:
-
- 10 edited
- 20 copied
-
tags/1.3.6 (copied) (copied from directory-builder/trunk)
-
tags/1.3.6/README.txt (copied) (copied from directory-builder/trunk/README.txt) (2 diffs)
-
tags/1.3.6/admin/class-db-functionality-admin.php (copied) (copied from directory-builder/trunk/admin/class-db-functionality-admin.php)
-
tags/1.3.6/admin/css/db-functionality-admin.css (copied) (copied from directory-builder/trunk/admin/css/db-functionality-admin.css)
-
tags/1.3.6/admin/js/db-functionality-admin.js (copied) (copied from directory-builder/trunk/admin/js/db-functionality-admin.js) (1 diff)
-
tags/1.3.6/auth_autoload.php (modified) (3 diffs)
-
tags/1.3.6/directory-builder.php (copied) (copied from directory-builder/trunk/directory-builder.php) (28 diffs)
-
tags/1.3.6/font/config.json (copied) (copied from directory-builder/trunk/font/config.json)
-
tags/1.3.6/font/dboptions.eot (copied) (copied from directory-builder/trunk/font/dboptions.eot)
-
tags/1.3.6/font/dboptions.svg (copied) (copied from directory-builder/trunk/font/dboptions.svg)
-
tags/1.3.6/font/dboptions.ttf (copied) (copied from directory-builder/trunk/font/dboptions.ttf)
-
tags/1.3.6/font/dboptions.woff (copied) (copied from directory-builder/trunk/font/dboptions.woff)
-
tags/1.3.6/font/dboptions.woff2 (copied) (copied from directory-builder/trunk/font/dboptions.woff2)
-
tags/1.3.6/includes/class-db-functionality-activator.php (copied) (copied from directory-builder/trunk/includes/class-db-functionality-activator.php) (1 diff)
-
tags/1.3.6/languages/directory-builder.pot (copied) (copied from directory-builder/trunk/languages/directory-builder.pot)
-
tags/1.3.6/paypal_ipn.php (copied) (copied from directory-builder/trunk/paypal_ipn.php) (1 diff)
-
tags/1.3.6/public/class-db-functionality-public.php (copied) (copied from directory-builder/trunk/public/class-db-functionality-public.php) (1 diff)
-
tags/1.3.6/public/css/db-functionality-public.css (copied) (copied from directory-builder/trunk/public/css/db-functionality-public.css) (1 diff)
-
tags/1.3.6/public/js/db-functionality-public.js (copied) (copied from directory-builder/trunk/public/js/db-functionality-public.js) (5 diffs)
-
tags/1.3.6/template/search-listing-item.php (copied) (copied from directory-builder/trunk/template/search-listing-item.php)
-
tags/1.3.6/template/single-listing-ratings.php (copied) (copied from directory-builder/trunk/template/single-listing-ratings.php)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/admin/js/db-functionality-admin.js (modified) (1 diff)
-
trunk/auth_autoload.php (modified) (3 diffs)
-
trunk/directory-builder.php (modified) (28 diffs)
-
trunk/includes/class-db-functionality-activator.php (modified) (1 diff)
-
trunk/paypal_ipn.php (modified) (1 diff)
-
trunk/public/class-db-functionality-public.php (modified) (1 diff)
-
trunk/public/css/db-functionality-public.css (modified) (1 diff)
-
trunk/public/js/db-functionality-public.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
directory-builder/tags/1.3.6/README.txt
r1595019 r1596655 4 4 Requires at least: 4.5.3 5 5 Tested up to: 4.7.2 6 Stable tag: 1.3. 56 Stable tag: 1.3.6 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 25 25 26 26 == Changelog == 27 28 = 1.3.6 = 29 * Allow to unfavourite listings 30 * Allow to add custom fields to search sorting dropdown 31 * Added subscription option 32 * Fixed default checkbox value issue 27 33 28 34 = 1.3.5 = -
directory-builder/tags/1.3.6/admin/js/db-functionality-admin.js
r1592626 r1596655 278 278 }); 279 279 jQuery('.db-create-listing_run_type').trigger('change'); 280 281 jQuery(document).on('change', '.db-create-payment_type', function() { 282 if ( jQuery(this).val() == 'onetime' ) { 283 jQuery('.db-create-payment_cycle').parent().parent().hide(); 284 jQuery('.db-create-payment_interval').parent().parent().hide(); 285 jQuery('.db-create-listing_run_type').parent().parent().show(); 286 jQuery('.db-create-listing_run_days').parent().parent().show(); 287 } else { 288 jQuery('.db-create-payment_cycle').parent().parent().show(); 289 jQuery('.db-create-payment_interval').parent().parent().show(); 290 jQuery('.db-create-listing_run_type').parent().parent().hide(); 291 jQuery('.db-create-listing_run_days').parent().parent().hide(); 292 } 293 }); 294 jQuery('.db-create-payment_type').trigger('change'); 280 295 281 296 jQuery(document).on('click', '.db-upload-file', function() { -
directory-builder/tags/1.3.6/auth_autoload.php
r1557657 r1596655 4 4 5 5 $main_settings = get_option( 'db_main_settings'); 6 7 $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); 8 $merchantAuthentication->setName($main_settings['authorize_id']); 9 $merchantAuthentication->setTransactionKey($main_settings['authorize_key']); 10 11 $request = new AnetAPI\CreateTransactionRequest(); 12 $request->setMerchantAuthentication($merchantAuthentication); 13 14 $creditCard = new AnetAPI\CreditCardType(); 15 $creditCard->setCardNumber($card_data['x_card_num']); 16 $creditCard->setExpirationDate($card_data['x_year']."-".$card_data['x_month']); 17 $paymentOne = new AnetAPI\PaymentType(); 18 $paymentOne->setCreditCard($creditCard); 19 20 // Create a transaction 21 $transactionRequestType = new AnetAPI\TransactionRequestType(); 22 $transactionRequestType->setTransactionType( "authCaptureTransaction"); 23 $transactionRequestType->setAmount($card_data['db-package-fee']); 24 $transactionRequestType->setPayment($paymentOne); 25 26 $request = new AnetAPI\CreateTransactionRequest(); 27 $request->setMerchantAuthentication($merchantAuthentication); 28 $request->setTransactionRequest( $transactionRequestType); 29 $controller = new AnetController\CreateTransactionController($request); 30 $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); 31 32 if ( $response != null ) { 33 $tresponse = $response->getTransactionResponse(); 34 35 if ( ($tresponse != null) && ($tresponse->getResponseCode()=="1") ) { 6 $card_data = json_decode( stripslashes( $_POST['card_data'] ), true ); 7 8 9 10 $get_order_meta = get_post_meta( $card_data['db-listing-id'], 'db_order_info', true ); 11 if ( isset($get_order_meta['listing_package']) ) { 12 global $wpdb; 13 $package_data = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'directory_packages WHERE ID="'.$get_order_meta['listing_package'].'"'); 14 15 if ( !empty($package_data) ) { 16 $package_settings = json_decode( $package_data['0']->package_settings, true ); 17 18 $payment_type = (isset($package_settings['payment_type'])?$package_settings['payment_type']:'onetime'); 19 $single_payment = db_process_single_payment( $main_settings, $card_data ); 20 } 21 } 22 23 if ( $single_payment != null && $single_payment->getMessages()->getResultCode() == 'Ok' ) { 24 if ( $payment_type == 'onetime' ) { 25 $tresponse = $single_payment->getTransactionResponse(); 26 if ( $tresponse != null && $tresponse->getResponseCode() == "1" ) { 27 $payment_status = true; 28 } else { 29 $payment_status = false; 30 } 31 } else { 32 $payment_status = false; 33 34 $subscription_payment = db_process_subscription( $main_settings, $card_data, $package_settings ); 35 if ( $subscription_payment != null && $subscription_payment->getMessages()->getResultCode() == 'Ok' ) { 36 $payment_status = true; 37 } else { 38 echo '{"save_response": "failed", "message": "'.__('Something went wrong while processing your subscription!', 'directory-builder').'"}'; 39 die(0); 40 } 41 } 42 43 if ( $payment_status ) { // Payment succeeded 36 44 $listing_billing = get_post_meta( $card_data['db-listing-id'], 'db_billing_info', true ); 37 $listing_billing['auth-code'] = $tresponse->getAuthCode(); 38 $listing_billing['trans-id'] = $tresponse->getTransId(); 45 if ( $payment_type == 'onetime' ) { 46 $listing_billing['auth-code'] = $tresponse->getAuthCode(); 47 $listing_billing['trans-id'] = $tresponse->getTransId(); 48 } else { 49 $listing_billing['subscription'] = $subscription_payment->getSubscriptionId(); 50 } 39 51 update_post_meta( $card_data['db-listing-id'], 'db_billing_info', $listing_billing ); 40 52 53 41 54 $payment_status = 'Completed'; 42 43 55 $payment_amount = $card_data['db-package-fee']; 44 56 $listing_id = $card_data['db-listing-id']; … … 61 73 if ( $payment_status == 'Completed' ) { 62 74 $order_info['completed_on'] = time(); 75 76 global $wpdb; 77 $package_data = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'directory_packages WHERE ID="'.$order_info['listing_package'].'"'); 78 if ( !empty($package_data) ) { 79 $package_data = json_decode($package_data['0']->package_settings, true); 80 81 if ( $payment_type != 'onetime' ) { 82 if ( $package_settings['payment_cycle'] == 'days' ) { 83 $start_value = 1; 84 } else if ( $package_settings['payment_cycle'] == 'weeks' ) { 85 $start_value = 7; 86 } else if ( $package_settings['payment_cycle'] == 'months' ) { 87 $start_value = 30; 88 } else if ( $package_settings['payment_cycle'] == 'years' ) { 89 $start_value = 365; 90 } 91 92 $package_data['listing_run_days'] = $start_value*intval($package_settings['payment_interval']); 93 } 94 95 if ( isset($order_info['listing_expires']) && is_numeric($order_info['listing_expires']) ) { 96 if ( $package_data['listing_run_type'] == 'days' ) { 97 $new_expire_date = strtotime('+'.$package_data['listing_run_days'].' days', $order_info['listing_expires']); 98 $order_info['listing_expires'] = $new_expire_date; 99 } 100 } else if ( isset($order_info['listing_expires']) && !is_numeric($order_info['listing_expires']) ) { 101 if ( $package_data['listing_run_type'] == 'days' ) { 102 $new_expire_date = strtotime('+'.$package_data['listing_run_days'].' days', time()); 103 $order_info['listing_expires'] = $new_expire_date; 104 } 105 } 106 } 63 107 } 64 108 … … 80 124 echo '{"save_response": "failed", "message": "'.__('Something went wrong while processing your card!', 'directory-builder').'"}'; 81 125 } 126 127 function db_process_single_payment( $main_settings, $card_data ) { 128 $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); 129 $merchantAuthentication->setName($main_settings['authorize_id']); 130 $merchantAuthentication->setTransactionKey($main_settings['authorize_key']); 131 132 $request = new AnetAPI\CreateTransactionRequest(); 133 $request->setMerchantAuthentication($merchantAuthentication); 134 135 $creditCard = new AnetAPI\CreditCardType(); 136 $creditCard->setCardNumber($card_data['x_card_num']); 137 $creditCard->setExpirationDate($card_data['x_year']."-".$card_data['x_month']); 138 $paymentOne = new AnetAPI\PaymentType(); 139 $paymentOne->setCreditCard($creditCard); 140 141 // Create a transaction 142 $transactionRequestType = new AnetAPI\TransactionRequestType(); 143 $transactionRequestType->setTransactionType( "authCaptureTransaction"); 144 $transactionRequestType->setAmount($card_data['db-package-fee']); 145 $transactionRequestType->setPayment($paymentOne); 146 147 $request = new AnetAPI\CreateTransactionRequest(); 148 $request->setMerchantAuthentication($merchantAuthentication); 149 $request->setTransactionRequest( $transactionRequestType); 150 $controller = new AnetController\CreateTransactionController($request); 151 152 if ( $main_settings['payment_mode'] == 'sandbox' ) { 153 $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); 154 } else { 155 $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION); 156 } 157 158 return $response; 159 } 160 161 function db_process_subscription( $main_settings, $card_data, $package_settings ) { 162 $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); 163 $merchantAuthentication->setName($main_settings['authorize_id']); 164 $merchantAuthentication->setTransactionKey($main_settings['authorize_key']); 165 166 $request = new AnetAPI\CreateTransactionRequest(); 167 $request->setMerchantAuthentication($merchantAuthentication); 168 169 $creditCard = new AnetAPI\CreditCardType(); 170 $creditCard->setCardNumber($card_data['x_card_num']); 171 $creditCard->setExpirationDate($card_data['x_year']."-".$card_data['x_month']); 172 $paymentOne = new AnetAPI\PaymentType(); 173 $paymentOne->setCreditCard($creditCard); 174 175 $subscription_status = false; 176 $subscription = new AnetAPI\ARBSubscriptionType(); 177 $subscription->setName($package_settings['fee_label'].' package subscription'); 178 $interval = new AnetAPI\PaymentScheduleType\IntervalAType(); 179 $interval->setLength($package_settings['payment_interval']); 180 $interval->setUnit($package_settings['payment_cycle']); 181 182 if ( $package_settings['payment_cycle'] == 'days' ) { 183 $start_value = 1; 184 } else if ( $package_settings['payment_cycle'] == 'weeks' ) { 185 $start_value = 7; 186 } else if ( $package_settings['payment_cycle'] == 'months' ) { 187 $start_value = 30; 188 } else if ( $package_settings['payment_cycle'] == 'years' ) { 189 $start_value = 365; 190 } 191 192 $paymentSchedule = new AnetAPI\PaymentScheduleType(); 193 $paymentSchedule->setInterval($interval); 194 $paymentSchedule->setStartDate(new DateTime(date('Y-m-d', strtotime(date('Y-m-d', time()) . '+ '.($start_value*intval($package_settings['payment_interval'])).' days')))); 195 $paymentSchedule->setTotalOccurrences("24"); 196 $paymentSchedule->setTrialOccurrences("0"); 197 $subscription->setPaymentSchedule($paymentSchedule); 198 $subscription->setAmount($card_data['db-package-fee']); 199 $subscription->setTrialAmount("0.00"); 200 201 $creditCard = new AnetAPI\CreditCardType(); 202 $creditCard->setCardNumber($card_data['x_card_num']); 203 $creditCard->setExpirationDate($card_data['x_year']."-".$card_data['x_month']); 204 $payment = new AnetAPI\PaymentType(); 205 $payment->setCreditCard($creditCard); 206 $subscription->setPayment($payment); 207 $order = new AnetAPI\OrderType(); 208 $order->setInvoiceNumber($card_data['db-listing-id'].time()); 209 $order->setDescription($package_settings['fee_label'].' package subscription for your listing!'); 210 $subscription->setOrder($order); 211 212 $billing_data = json_decode( stripslashes( $_POST['field_data'] ), true ); 213 $name_comp = explode(' ', $billing_data['x_full_name']); 214 $billTo = new AnetAPI\NameAndAddressType(); 215 $billTo->setFirstName($name_comp['0']); 216 $first_name = $name_comp['0']; 217 unset($name_comp['0']); 218 $billTo->setLastName((empty($name_comp)?$first_name:implode(' ', $name_comp))); 219 $subscription->setBillTo($billTo); 220 $request = new AnetAPI\ARBCreateSubscriptionRequest(); 221 $request->setmerchantAuthentication($merchantAuthentication); 222 $request->setRefId('ref' . time()); 223 $request->setSubscription($subscription); 224 $controller = new AnetController\ARBCreateSubscriptionController($request); 225 226 if ( $main_settings['payment_mode'] == 'sandbox' ) { 227 $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); 228 } else { 229 $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION); 230 } 231 232 return $response; 233 } -
directory-builder/tags/1.3.6/directory-builder.php
r1595019 r1596655 17 17 * Plugin URI: https://cohhe.com/ 18 18 * Description: Directory builder provides listing functionality for your theme. 19 * Version: 1.3. 519 * Version: 1.3.6 20 20 * Author: Cohhe 21 21 * Author URI: https://cohhe.com/ … … 580 580 </div> 581 581 </div> 582 <?php 583 $sorting_types = array( 'text', 'number', 'textarea', 'checkbox', 'radio', 'select', 'multi-select', 'url', 'date', 'time', 'email' ); 584 if ( in_array($field_type, $sorting_types) ) { ?> 585 <div class="db-field-row focused active clearfix"> 586 <label class="field-label">Show in sorting options?</label> 587 <div class="db-field-input"> 588 <select class="db-create-on-sorting"> 589 <option value="no" <?php echo(isset($field_settings['on_sorting'])&&$field_settings['on_sorting']=='no'?'selected':''); ?>>No</option> 590 <option value="yes" <?php echo(isset($field_settings['on_sorting'])&&$field_settings['on_sorting']=='yes'?'selected':''); ?>>Yes</option> 591 </select> 592 <span class="field-description">Do you want to show this field in sorting options at the search page?</span> 593 </div> 594 </div> 595 <?php } ?> 582 596 <div class="db-field-row focused active clearfix"> 583 597 <label class="field-label">Custom field icon</label> … … 1308 1322 case 'auth-code': $billing_label = __('Card Auth Code', 'directory-builder'); break; 1309 1323 case 'trans-id': $billing_label = __('Transaction ID', 'directory-builder'); break; 1324 case 'subscription': $billing_label = __('Subscription ID', 'directory-builder'); break; 1310 1325 1311 1326 default: break; … … 1442 1457 $output .= ' 1443 1458 <div class="db-field-row'.$field_required.' checkbox-label">'; 1444 $is_checked = ($field_default==$field_settings['checkbox_true']?true:false); 1459 global $post; 1460 if ( has_shortcode( $post->post_content, 'directory_add_listing' ) ) { 1461 $is_checked = ($field_default==$field_settings['checkbox_true']||$field_default=='true'?true:false); 1462 } else { 1463 $is_checked = ($field_default=='true'?true:false); 1464 } 1445 1465 $output .= '<input type="checkbox" id="'.$field_name.'" name="'.$field_name.'" class="'.$custom_class.'" value="true"'.($is_checked?' checked':'').'>'; 1446 1466 if ( $field_title != '' ) { … … 1526 1546 <div class="db-field-row'.$field_required.' custom-select">'; 1527 1547 if ( $field_title != '' ) { 1528 $output .= '<label class="db-field-row-label">'.$field_title.'</label>';1548 // $output .= '<label class="db-field-row-label">'.$field_title.'</label>'; 1529 1549 } 1530 1550 1531 $active_values = (isset($_GET[$field_name])?explode(',', sanitize_text_field($_GET[$field_name])):array( ));1551 $active_values = (isset($_GET[$field_name])?explode(',', sanitize_text_field($_GET[$field_name])):array( $field_default )); 1532 1552 $active_value_shown = $active_value_hidden = ''; 1533 1553 if ( !empty($active_values) ) { … … 1615 1635 $active_value_shown = $active_value_hidden = ''; 1616 1636 if ( !empty($active_values) ) { 1617 $active_value_shown = implode(', ', $active_values);1637 // $active_value_shown = implode(', ', $active_values); 1618 1638 $active_value_hidden = implode(',', $active_values); 1639 1640 $all_select_data = explode( '||', str_replace("\n", '||', $field_settings['select_options']) ); 1641 $all_select_options = array(); 1642 foreach ($all_select_data as $select_value) { 1643 $select_value_exploded = explode(':', $select_value); 1644 $all_select_options[$select_value_exploded['0']] = $select_value_exploded['1']; 1645 } 1646 1647 $active_shown_values = array(); 1648 if ( $active_values['0'] != '' ) { 1649 foreach ($active_values as $active_value) { 1650 $active_shown_values[] = $all_select_options[$active_value]; 1651 } 1652 } 1653 1654 $active_value_shown = implode( ', ', $active_shown_values ); 1619 1655 } 1620 1656 … … 2060 2096 <a href="javascript:void(0)" class="db-find-listings onload">'.__('Search', 'directory-builder').'</a> 2061 2097 </div>'; 2098 $custom_sorting = whitelab_get_listing_custom_fields( '', 'on_sorting' ); 2062 2099 if ( !defined('WHITELAB_CUSTOM_SELECT') ) { 2063 2100 $output .= __('Sort by:', 'directory-builder').' … … 2065 2102 <option value="name">Name</option> 2066 2103 <option value="date">Date</option> 2067 <option value="rating">Rating</option> 2104 <option value="rating">Rating</option>'; 2105 foreach ($custom_sorting as $field_name => $field_data) { 2106 $output .= '<option value="'.$field_name.'">'.$field_data['title'].'</option>'; 2107 } 2108 $output .= ' 2068 2109 </select>'; 2069 2110 } else { … … 2079 2120 <div class="dt-custom-select-item" data-value="name">Name</div> 2080 2121 <div class="dt-custom-select-item" data-value="date">Date</div> 2081 <div class="dt-custom-select-item" data-value="rating">Rating</div> 2122 <div class="dt-custom-select-item" data-value="rating">Rating</div>'; 2123 foreach ($custom_sorting as $field_name => $field_data) { 2124 $output .= '<div class="dt-custom-select-item" data-value="'.$field_name.'">'.$field_data['title'].'</div>'; 2125 } 2126 $output .= ' 2082 2127 </div> 2083 2128 <div class="dt-custom-select-scrollbar-wrapper"> … … 2102 2147 add_shortcode('directory_listings','db_search_shortcode'); 2103 2148 2149 // function db_check_listing_status( $post ) { 2150 // if ( get_post_type( $post['0']->ID ) == 'listings' && get_post_status( $post['0']->ID ) == 'publish' ) { 2151 // $order_data = get_post_meta( $post['0']->ID, 'db_order_info', true ); 2152 2153 // if ( isset($order_data['listing_expires']) && is_numeric($order_data['listing_expires']) && time() > $order_data['listing_expires'] ) { 2154 // wp_update_post( array( 'ID' => $post['0']->ID, 'post_status' => 'draft' ) ); 2155 // } 2156 // } 2157 // } 2158 // add_action( 'posts_results', 'db_check_listing_status', 10, 1 ); 2159 2104 2160 function db_search_for_listings() { 2105 2161 $output = ''; … … 2111 2167 if ( !isset($search_terms['listing_address']) || ( isset($search_terms['listing_address']) && $search_terms['listing_address'] == '' ) ) { 2112 2168 unset($search_terms['listing_search_radius']); 2169 } 2170 2171 if ( strpos($db_full_url, 'amenities=') !== false ) { // Add amenities to the search parameters 2172 $url_parts = parse_url( $_POST['db_full_url'] ); 2173 parse_str($url_parts['query'], $url_query); 2174 $search_terms['amenities'] = $url_query['amenities']; 2113 2175 } 2114 2176 … … 2145 2207 unset($search_terms['listing_search_radius']); 2146 2208 2209 $map_new_center = false; 2147 2210 if ( !empty($search_listings) ) { 2148 2211 $field_list = db_get_active_fields(); 2149 2212 2150 2213 if ( isset($search_terms['listing_address']) && $search_terms['listing_address'] != '' ) { 2151 $search_coordinates = db_get_coordinates( $search_terms['listing_address'] ); 2152 $search_coordinates = explode(',', $search_coordinates); 2214 $search_address_data = db_get_coordinates( $search_terms['listing_address'] ); 2215 2216 $map_new_center = true; 2153 2217 } 2154 2218 … … 2158 2222 $listing_value = array_merge((array)$listing_value, $custom_field_data); 2159 2223 $show_listing = true; 2160 2161 if ( $main_settings['search_radius_status'] == 'yes' && isset($search_terms['listing_address']) && $search_terms['listing_address'] != '' ) { 2162 $db_search_distance = db_calculateDistanceFromLatLong($listing_value['listing_address_lat'], $listing_value['listing_address_lng'], $search_coordinates['0'], $search_coordinates['1'], $main_settings['search_radius_value']); 2163 2164 if ( intval($db_search_distance) > intval($search_distance) ) { 2224 $listing_visible = false; 2225 2226 if ( isset($search_terms['listing_address']) && $search_terms['listing_address'] != '' ) { 2227 if ( $search_address_data['type'] == 'fields' ) { 2228 if ( $search_address_data['field_type'] == 'country' && strpos($listing_value['listing_country'], $search_address_data['value']) !== false ) { 2229 $listing_visible = true; 2230 } else if ( $search_address_data['field_type'] == 'locality' && strpos($listing_value['listing_city'], $search_address_data['value']) !== false ) { 2231 $listing_visible = true; 2232 } else { 2233 $listing_visible = false; 2234 } 2235 } else { 2236 $db_search_distance = db_calculateDistanceFromLatLong($listing_value['listing_address_lat'], $listing_value['listing_address_lng'], $search_address_data['lat'], $search_address_data['lng'], $main_settings['search_radius_value']); 2237 2238 if ( $main_settings['search_radius_status'] != 'yes' ) { 2239 $search_distance = '200'; 2240 } 2241 if ( intval($db_search_distance) > intval($search_distance) ) { 2242 $listing_visible = false; 2243 } else { 2244 $listing_visible = true; 2245 } 2246 } 2247 2248 if ( $listing_visible ) { 2249 $dist_show_listing = true; 2250 } else { 2165 2251 $dist_show_listing = false; 2166 } else {2167 $dist_show_listing = true;2168 }2169 } else if ( isset($search_terms['listing_address']) && $search_terms['listing_address'] != '' ) {2170 $db_search_distance = db_calculateDistanceFromLatLong($listing_value['listing_address_lat'], $listing_value['listing_address_lng'], $search_coordinates['0'], $search_coordinates['1'], $main_settings['search_radius_value']);2171 2172 if ( intval($db_search_distance) > 200 ) {2173 $dist_show_listing = false;2174 } else {2175 $dist_show_listing = true;2176 2252 } 2177 2253 } … … 2216 2292 } 2217 2293 } 2294 } else if ( $search_key == 'amenities' ) { 2295 $amenities_values = (is_array($listing_value[$search_key])?$listing_value[$search_key]:explode(',', $listing_value[$search_key])); 2296 if ( in_array($search_value, $amenities_values) ) { 2297 $show_listing = true; 2298 $matched_settings++; 2299 break; 2300 } else { 2301 $show_listing = false; 2302 } 2218 2303 } else { 2219 2304 if ( strtolower($listing_value[$search_key]) != strtolower($search_value) ) { … … 2269 2354 } 2270 2355 } 2271 2272 echo json_encode(array('listing_html' => $all_listings, 'marker_data' => $all_markers, 'new_url' => $db_new_url)); 2356 2357 $search_data = array('listing_html' => $all_listings, 'marker_data' => $all_markers, 'new_url' => $db_new_url, 'map_changed' => false ); 2358 2359 if ( empty( $all_markers ) && $map_new_center ) { 2360 $search_data['map_lat'] = $search_address_data['lat']; 2361 $search_data['map_lng'] = $search_address_data['lng']; 2362 $search_data['map_changed'] = true; 2363 } 2364 2365 echo json_encode( $search_data ); 2273 2366 2274 2367 die(0); … … 2276 2369 add_action( 'wp_ajax_db_search_listings', 'db_search_for_listings' ); 2277 2370 add_action( 'wp_ajax_nopriv_db_search_listings', 'db_search_for_listings' ); 2371 2372 function db_get_custom_sorting() { 2373 $custom_sorting = whitelab_get_listing_custom_fields( '', 'on_sorting' ); 2374 $sort_ints = array( 'number', 'date', 'time', 'phone' ); 2375 $sorting_arr = array( 'name' => '[data-name]', 'date' => '[data-date] parseInt', 'rating' => '[data-rating] parseInt', 'featured' => '[data-featured] parseInt' ); 2376 2377 if ( !empty($custom_sorting) ) { 2378 foreach ($custom_sorting as $sorting_key => $sorting_value) { 2379 $sorting_arr[$sorting_key] = '[data-'.$sorting_key.']'.(in_array($sorting_value['type'], $sort_ints)?' parseInt':''); 2380 } 2381 } 2382 2383 return json_encode( $sorting_arr ); 2384 } 2385 2386 function db_get_custom_sorting_dir() { 2387 $custom_sorting = whitelab_get_listing_custom_fields( '', 'on_sorting' ); 2388 $sort_ints = array( 'number', 'date', 'time', 'phone' ); 2389 $sorting_dir_arr = array( 'name' => true, 'date' => false, 'rating' => false, 'featured' => true ); 2390 2391 if ( !empty($custom_sorting) ) { 2392 foreach ($custom_sorting as $sorting_key => $sorting_value) { 2393 $sorting_dir_arr[$sorting_key] = (in_array($sorting_value['type'], $sort_ints)?false:true); 2394 } 2395 } 2396 2397 return json_encode( $sorting_dir_arr ); 2398 } 2278 2399 2279 2400 function db_get_coordinates( $address ) { … … 2283 2404 $json = json_decode($response['body'],TRUE); 2284 2405 2285 return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']); 2406 if ( ( $json['results'][0]['types']['0'] == 'country' || $json['results'][0]['types']['0'] == 'locality' ) && $json['results'][0]['types']['1'] == 'political' ) { 2407 return array( 'type' => 'fields', 'field_type' => $json['results'][0]['types']['0'], 'value' => $json['results'][0]['address_components']['0']['long_name'], 'lat' => $json['results'][0]['geometry']['location']['lat'], 'lng' => $json['results'][0]['geometry']['location']['lng'] ); 2408 } else { 2409 return array( 'type' => 'coordinates', 'lat' => $json['results'][0]['geometry']['location']['lat'], 'lng' => $json['results'][0]['geometry']['location']['lng'] ); 2410 } 2286 2411 } 2287 2412 … … 2427 2552 <div class="db-row"> 2428 2553 <div class="db-row-group clearfix"> 2429 <span class="db-row-label col-sm-3"> Listings per page</span>2554 <span class="db-row-label col-sm-3">Per page limit at search</span> 2430 2555 <div class="col-sm-9"> 2431 <input type="number" class="db-settings-per_page" placeholder=" Listings per page" value="<?php echo $main_settings['per_page']; ?>">2556 <input type="number" class="db-settings-per_page" placeholder="Per page limit at search" value="<?php echo $main_settings['per_page']; ?>"> 2432 2557 </div> 2433 2558 </div> … … 2545 2670 foreach ($all_pages as $page_key => $page_value) { 2546 2671 $is_selected = ($main_settings['add_page_id']==$page_value->ID?' selected':''); 2672 echo '<option value="'.$page_value->ID.'"'.$is_selected.'>'.$page_value->post_title.'</option>'; 2673 } 2674 ?> 2675 </select> 2676 </div> 2677 </div> 2678 </div> 2679 <div class="db-row"> 2680 <div class="db-row-group clearfix"> 2681 <span class="db-row-label col-sm-3">Listing author account page</span> 2682 <div class="col-sm-9"> 2683 <select class="db-settings-account_page_id"> 2684 <?php 2685 foreach ($all_pages as $page_key => $page_value) { 2686 $is_selected = ($main_settings['account_page_id']==$page_value->ID?' selected':''); 2547 2687 echo '<option value="'.$page_value->ID.'"'.$is_selected.'>'.$page_value->post_title.'</option>'; 2548 2688 } … … 3183 3323 </div> 3184 3324 <div class="db-field-row active clearfix"> 3185 <label class="field-label">Listing run in days</label> 3325 <label class="field-label">Payment type</label> 3326 <div class="db-field-input"> 3327 <select class="db-create-payment_type"> 3328 <option value="onetime" <?php echo(isset($field_settings['payment_type'])&&$field_settings['payment_type']=='onetime'?'selected':''); ?>>One time payment</option> 3329 <option value="recurring" <?php echo(isset($field_settings['payment_type'])&&$field_settings['payment_type']=='recurring'?'selected':''); ?>>Recurring payment</option> 3330 </select> 3331 </div> 3332 </div> 3333 <div class="db-field-row active clearfix"> 3334 <label class="field-label">Run listing for</label> 3186 3335 <div class="db-field-input"> 3187 3336 <select class="db-create-listing_run_type"> … … 3195 3344 <div class="db-field-input"> 3196 3345 <input type="number" class="db-create-listing_run_days" value="<?php echo(isset($field_settings['listing_run_days'])?$field_settings['listing_run_days']:'20'); ?>"> 3346 </div> 3347 </div> 3348 <div class="db-field-row active clearfix"> 3349 <label class="field-label">Payment cycle</label> 3350 <div class="db-field-input"> 3351 <select class="db-create-payment_cycle"> 3352 <option value="days" <?php echo(isset($field_settings['payment_cycle'])&&$field_settings['payment_cycle']=='days'?'selected':''); ?>>Days</option> 3353 <option value="weeks" <?php echo(isset($field_settings['payment_cycle'])&&$field_settings['payment_cycle']=='weeks'?'selected':''); ?>>Weeks</option> 3354 <option value="months" <?php echo(isset($field_settings['payment_cycle'])&&$field_settings['payment_cycle']=='months'?'selected':''); ?>>Months</option> 3355 <option value="years" <?php echo(isset($field_settings['payment_cycle'])&&$field_settings['payment_cycle']=='years'?'selected':''); ?>>Years</option> 3356 </select> 3357 </div> 3358 </div> 3359 <div class="db-field-row <?php echo(isset($field_settings['payment_interval'])&&$field_settings['payment_interval']!=''?'active':(!isset($field_settings['payment_interval'])?'active':'')); ?> clearfix"> 3360 <label class="field-label">Payment cycle interval</label> 3361 <div class="db-field-input"> 3362 <input type="number" class="db-create-payment_interval" value="<?php echo(isset($field_settings['payment_interval'])?$field_settings['payment_interval']:''); ?>"> 3197 3363 </div> 3198 3364 </div> … … 3472 3638 function db_send_contact_email() { 3473 3639 $output = ''; 3474 $db_author = ( isset($_POST['db_author']) ? sanitize_text_field($_POST['db_author']) : '' );3640 $db_author_email = ( isset($_POST['db_author']) ? sanitize_text_field($_POST['db_author']) : '' ); 3475 3641 $db_message = ( isset($_POST['db_message']) ? sanitize_text_field($_POST['db_message']) : '' ); 3476 $author_email = get_the_author_meta('email', $db_author); 3477 3478 $subject = 'Contacting regarding your listing'; 3479 $message = $db_message; 3480 3481 $maintenance_email = wp_mail( $author_email, $subject, $message ); 3642 $db_name = ( isset($_POST['db_name']) ? sanitize_text_field($_POST['db_name']) : '' ); 3643 $db_email = ( isset($_POST['db_email']) ? sanitize_text_field($_POST['db_email']) : '' ); 3644 3645 $subject = esc_html__( 'Contacting regarding your listing', 'directory-builder' ); 3646 $message = esc_html__( 'Name:', 'directory-builder' ) . ' ' . $db_name . '<br />'; 3647 $message .= esc_html__( 'Email:', 'directory-builder' ) . ' ' . $db_email . '<br />'; 3648 $message .= esc_html__( 'Message:', 'directory-builder' ) . '<br />' . $db_message; 3649 3650 $maintenance_email = wp_mail( $db_author_email, $subject, $message ); 3482 3651 3483 3652 if ( $maintenance_email ) { … … 3678 3847 <input type="hidden" name="db-checkout" value="true"> 3679 3848 <input type="hidden" name="db-listing-id" value="'.get_the_ID().'"> 3680 3681 <input type="hidden" name="cmd" value="_xclick-subscriptions"> 3849 <input type="hidden" name="cmd" value="_xclick"> 3682 3850 <input type="hidden" name="business" value="' . $main_settings['paypal_merchant_id'] . '"> 3683 3851 <input type="hidden" name="item_name" value="'.(isset($package_data['fee_label'])?$package_data['fee_label']:'').'"> … … 3688 3856 <input type="hidden" name="return" value="' . $main_settings['paypal_return_url'] . '"> 3689 3857 <input type="hidden" name="notify_url" value="' . get_the_permalink() . '"> 3690 <input type="hidden" name="custom" value="' . $new_listing_id . '">'; 3858 <input type="hidden" name="custom" value="' . $new_listing_id . '"> 3859 <input type="hidden" name="src" value="1"> 3860 <input type="hidden" name="a3" value="'.(isset($package_data['fee_amount'])?$package_data['fee_amount']:'').'"> 3861 <input type="hidden" name="p3" value="1"> 3862 <input type="hidden" name="t3" value="M">'; 3863 3691 3864 if ( $main_settings['terms_and_conditions_status'] ) { 3692 3865 $output .= ' … … 3878 4051 3879 4052 foreach ($fields_to_save as $field_key => $field_value) { 3880 update_post_meta( esc_attr($_GET['edit-listing']), sanitize_key($field_key), sanitize_text_field($field_value));4053 update_post_meta( esc_attr($_GET['edit-listing']), sanitize_key($field_key), (!is_array($field_value)?sanitize_text_field($field_value):$field_value)); 3881 4054 } 3882 4055 … … 4302 4475 4303 4476 function db_account_shortcode( $atts, $content = null ) { 4304 extract( shortcode_atts( array(4305 // 'id' => '',4306 ), $atts ) );4307 4477 $main_settings = get_option( 'db_main_settings'); 4308 4478 … … 4362 4532 } 4363 4533 4364 if ( ! empty($user_listings) && !isset($_GET['edit-listing']) && !isset($_GET['my-profile']) ) {4365 if ( !isset($_GET['my-favorites']) ) {4534 if ( !isset($_GET['edit-listing']) && !isset($_GET['my-profile']) ) { 4535 if ( !isset($_GET['my-favorites']) && !empty($user_listings) ) { 4366 4536 $output .= db_checkout_html(); 4367 4537 $output .= ' … … 5084 5254 add_action( 'wp_ajax_db_address_autocomplete', 'db_do_address_autocomplete' ); 5085 5255 add_action( 'wp_ajax_nopriv_db_address_autocomplete', 'db_do_address_autocomplete' ); 5256 5257 function db_setup_vc_modules() { 5258 // Extend Visual Composer 5259 if ( defined('WPB_VC_VERSION') ) { 5260 vc_map( array( 5261 "name" => __("Directory builder search", "directory-builder" ), 5262 "base" => "directory_listings", 5263 "class" => "", 5264 "icon" => "icon-wpb-ui-gap-content", 5265 "category" => __( "by Directory builder", "directory-builder" ), 5266 "show_settings_on_create" => false 5267 )); 5268 5269 vc_map( array( 5270 "name" => __("Directory builder add listing", "directory-builder" ), 5271 "base" => "directory_add_listing", 5272 "class" => "", 5273 "icon" => "icon-wpb-ui-gap-content", 5274 "category" => __( "by Directory builder", "directory-builder" ), 5275 "show_settings_on_create" => false 5276 )); 5277 5278 vc_map( array( 5279 "name" => __("Directory builder author dashboard", "directory-builder" ), 5280 "base" => "directory_account", 5281 "class" => "", 5282 "icon" => "icon-wpb-ui-gap-content", 5283 "category" => __( "by Directory builder", "directory-builder" ), 5284 "show_settings_on_create" => false 5285 )); 5286 5287 vc_map( array( 5288 "name" => __("Directory builder login", "directory-builder" ), 5289 "base" => "directory_login", 5290 "class" => "", 5291 "icon" => "icon-wpb-ui-gap-content", 5292 "category" => __( "by Directory builder", "directory-builder" ), 5293 "show_settings_on_create" => false 5294 )); 5295 5296 vc_map( array( 5297 "name" => __("Directory builder register", "directory-builder" ), 5298 "base" => "directory_register", 5299 "class" => "", 5300 "icon" => "icon-wpb-ui-gap-content", 5301 "category" => __( "by Directory builder", "directory-builder" ), 5302 "show_settings_on_create" => false 5303 )); 5304 } 5305 } 5306 add_action('after_setup_theme', 'db_setup_vc_modules'); -
directory-builder/tags/1.3.6/includes/class-db-functionality-activator.php
r1595019 r1596655 452 452 } 453 453 454 $account_page = array( 455 'post_author' => get_current_user_id(), 456 'post_content' => '[directory_account]', 457 'post_title' => 'Directory builder user account', 458 'post_status' => 'publish', 459 'post_type' => 'page' 460 ); 461 462 $account_id = wp_insert_post($account_page); 463 464 if ( $account_id ) { 465 $main_settings = get_option( 'db_main_settings' ); 466 $main_settings['account_page_id'] = $account_id; 467 update_option( 'db_main_settings', $main_settings ); 468 } 469 454 470 $success_page = array( 455 471 'post_author' => get_current_user_id(), -
directory-builder/tags/1.3.6/paypal_ipn.php
r1595019 r1596655 114 114 $package_data = json_decode($package_data['0']->package_settings, true); 115 115 116 if ( $package_data['payment_type'] != 'onetime' ) { 117 if ( $package_settings['payment_cycle'] == 'days' ) { 118 $start_value = 1; 119 } else if ( $package_settings['payment_cycle'] == 'weeks' ) { 120 $start_value = 7; 121 } else if ( $package_settings['payment_cycle'] == 'months' ) { 122 $start_value = 30; 123 } else if ( $package_settings['payment_cycle'] == 'years' ) { 124 $start_value = 365; 125 } 126 127 $package_data['listing_run_days'] = $start_value*intval($package_settings['payment_interval']); 128 } 129 116 130 if ( isset($order_info['listing_expires']) && is_numeric($order_info['listing_expires']) ) { 117 131 if ( $package_data['listing_run_type'] == 'days' ) { -
directory-builder/tags/1.3.6/public/class-db-functionality-public.php
r1571162 r1596655 125 125 'default_location_lat' => $default_location_lat, 126 126 'default_location_lng' => $default_location_lng, 127 'template_url' => get_template_directory_uri() 127 'template_url' => get_template_directory_uri(), 128 'custom_sorting' => db_get_custom_sorting(), 129 'custom_sorting_dir' => db_get_custom_sorting_dir() 128 130 )); 129 131 -
directory-builder/tags/1.3.6/public/css/db-functionality-public.css
r1595019 r1596655 246 246 position: absolute; 247 247 opacity: 0; 248 top: 30px; 248 top: 10px; 249 left: 140px; 249 250 } 250 251 -
directory-builder/tags/1.3.6/public/js/db-functionality-public.js
r1595019 r1596655 266 266 $search_map.setZoom(13); 267 267 } 268 269 268 db_set_isotope(); 270 269 }, 100); 271 270 272 271 } else { 272 if ( parsed_search_data.map_changed ) { 273 setTimeout(function() { 274 $search_map.setCenter(new google.maps.LatLng(parsed_search_data.map_lat, parsed_search_data.map_lng)); 275 $search_map.setZoom(10); 276 }, 100); 277 } 278 273 279 jQuery('.db-main-search-listings').addClass('db-no-listings'); 274 280 jQuery('.db-main-search-listings').append('<div class="db-main-search-item full-listing" style="text-align: center;">No listings found!</div>'); … … 304 310 var scrolled_percentage = jQuery(this).scrollTop()/(jQuery(this)[0].scrollHeight-jQuery(this).innerHeight())*100; 305 311 var extra_scroll = jQuery(this).find('.db-search-scrollbar').height()*(scrolled_percentage/100); 306 // if ( !jQuery(this).hasClass('mh-search-wrapper') ) { 307 var scroll_height = 'calc('+scrolled_percentage+'% - '+extra_scroll+'px + '+jQuery(this).scrollTop()+'px)'; 308 // } else { 309 // var scroll_height = 'calc('+scrolled_percentage+'% - '+extra_scroll+'px)'; 310 // } 312 var scroll_height = 'calc('+scrolled_percentage+'% - '+extra_scroll+'px + '+jQuery(this).scrollTop()+'px)'; 311 313 312 314 jQuery(this).find('.db-search-scrollbar').css('top', scroll_height); … … 321 323 gutter: 30 322 324 }, 323 getSortData: { 324 name: '[data-name]', 325 date: '[data-date] parseInt', 326 rating: '[data-rating] parseInt', 327 featured: '[data-featured] parseInt' 328 }, 325 getSortData: jQuery.parseJSON(db_main.custom_sorting), 329 326 sortBy: [ 'featured', 'name' ], 330 sortAscending: { 331 name: true, 332 date: false, 333 rating: false, 334 featured: true 335 }, 327 sortAscending: jQuery.parseJSON(db_main.custom_sorting_dir), 336 328 transitionDuration: '0.2s', 337 329 hiddenStyle: { … … 349 341 jQuery(document).on('change', '.db-search-sort, #db-search-sort', function() { 350 342 var sort_by_value = jQuery(this).val(); 351 if ( sort_by_value == 'date' || sort_by_value == 'rating' ) { 352 $search_item_container.isotope({ 353 sortBy: [ 'featured', sort_by_value ], 354 }); 355 } else { 356 $search_item_container.isotope({ 357 sortBy: [ 'featured', sort_by_value ], 358 }); 359 } 360 343 $search_item_container.isotope({ 344 sortBy: [ 'featured', sort_by_value ], 345 }); 361 346 }); 362 347 … … 368 353 'action': 'db_send_contact_email', 369 354 'db_author': jQuery(this).attr('data-id'), 370 'db_message': jQuery('.db-contact-message').val() 355 'db_message': jQuery('.db-contact-message').val(), 356 'db_name': jQuery('.db-contact-name').val(), 357 'db_email': jQuery('.db-contact-email').val() 371 358 }, 372 359 success: function(data) { -
directory-builder/trunk/README.txt
r1595019 r1596655 4 4 Requires at least: 4.5.3 5 5 Tested up to: 4.7.2 6 Stable tag: 1.3. 56 Stable tag: 1.3.6 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 25 25 26 26 == Changelog == 27 28 = 1.3.6 = 29 * Allow to unfavourite listings 30 * Allow to add custom fields to search sorting dropdown 31 * Added subscription option 32 * Fixed default checkbox value issue 27 33 28 34 = 1.3.5 = -
directory-builder/trunk/admin/js/db-functionality-admin.js
r1592626 r1596655 278 278 }); 279 279 jQuery('.db-create-listing_run_type').trigger('change'); 280 281 jQuery(document).on('change', '.db-create-payment_type', function() { 282 if ( jQuery(this).val() == 'onetime' ) { 283 jQuery('.db-create-payment_cycle').parent().parent().hide(); 284 jQuery('.db-create-payment_interval').parent().parent().hide(); 285 jQuery('.db-create-listing_run_type').parent().parent().show(); 286 jQuery('.db-create-listing_run_days').parent().parent().show(); 287 } else { 288 jQuery('.db-create-payment_cycle').parent().parent().show(); 289 jQuery('.db-create-payment_interval').parent().parent().show(); 290 jQuery('.db-create-listing_run_type').parent().parent().hide(); 291 jQuery('.db-create-listing_run_days').parent().parent().hide(); 292 } 293 }); 294 jQuery('.db-create-payment_type').trigger('change'); 280 295 281 296 jQuery(document).on('click', '.db-upload-file', function() { -
directory-builder/trunk/auth_autoload.php
r1557657 r1596655 4 4 5 5 $main_settings = get_option( 'db_main_settings'); 6 7 $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); 8 $merchantAuthentication->setName($main_settings['authorize_id']); 9 $merchantAuthentication->setTransactionKey($main_settings['authorize_key']); 10 11 $request = new AnetAPI\CreateTransactionRequest(); 12 $request->setMerchantAuthentication($merchantAuthentication); 13 14 $creditCard = new AnetAPI\CreditCardType(); 15 $creditCard->setCardNumber($card_data['x_card_num']); 16 $creditCard->setExpirationDate($card_data['x_year']."-".$card_data['x_month']); 17 $paymentOne = new AnetAPI\PaymentType(); 18 $paymentOne->setCreditCard($creditCard); 19 20 // Create a transaction 21 $transactionRequestType = new AnetAPI\TransactionRequestType(); 22 $transactionRequestType->setTransactionType( "authCaptureTransaction"); 23 $transactionRequestType->setAmount($card_data['db-package-fee']); 24 $transactionRequestType->setPayment($paymentOne); 25 26 $request = new AnetAPI\CreateTransactionRequest(); 27 $request->setMerchantAuthentication($merchantAuthentication); 28 $request->setTransactionRequest( $transactionRequestType); 29 $controller = new AnetController\CreateTransactionController($request); 30 $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); 31 32 if ( $response != null ) { 33 $tresponse = $response->getTransactionResponse(); 34 35 if ( ($tresponse != null) && ($tresponse->getResponseCode()=="1") ) { 6 $card_data = json_decode( stripslashes( $_POST['card_data'] ), true ); 7 8 9 10 $get_order_meta = get_post_meta( $card_data['db-listing-id'], 'db_order_info', true ); 11 if ( isset($get_order_meta['listing_package']) ) { 12 global $wpdb; 13 $package_data = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'directory_packages WHERE ID="'.$get_order_meta['listing_package'].'"'); 14 15 if ( !empty($package_data) ) { 16 $package_settings = json_decode( $package_data['0']->package_settings, true ); 17 18 $payment_type = (isset($package_settings['payment_type'])?$package_settings['payment_type']:'onetime'); 19 $single_payment = db_process_single_payment( $main_settings, $card_data ); 20 } 21 } 22 23 if ( $single_payment != null && $single_payment->getMessages()->getResultCode() == 'Ok' ) { 24 if ( $payment_type == 'onetime' ) { 25 $tresponse = $single_payment->getTransactionResponse(); 26 if ( $tresponse != null && $tresponse->getResponseCode() == "1" ) { 27 $payment_status = true; 28 } else { 29 $payment_status = false; 30 } 31 } else { 32 $payment_status = false; 33 34 $subscription_payment = db_process_subscription( $main_settings, $card_data, $package_settings ); 35 if ( $subscription_payment != null && $subscription_payment->getMessages()->getResultCode() == 'Ok' ) { 36 $payment_status = true; 37 } else { 38 echo '{"save_response": "failed", "message": "'.__('Something went wrong while processing your subscription!', 'directory-builder').'"}'; 39 die(0); 40 } 41 } 42 43 if ( $payment_status ) { // Payment succeeded 36 44 $listing_billing = get_post_meta( $card_data['db-listing-id'], 'db_billing_info', true ); 37 $listing_billing['auth-code'] = $tresponse->getAuthCode(); 38 $listing_billing['trans-id'] = $tresponse->getTransId(); 45 if ( $payment_type == 'onetime' ) { 46 $listing_billing['auth-code'] = $tresponse->getAuthCode(); 47 $listing_billing['trans-id'] = $tresponse->getTransId(); 48 } else { 49 $listing_billing['subscription'] = $subscription_payment->getSubscriptionId(); 50 } 39 51 update_post_meta( $card_data['db-listing-id'], 'db_billing_info', $listing_billing ); 40 52 53 41 54 $payment_status = 'Completed'; 42 43 55 $payment_amount = $card_data['db-package-fee']; 44 56 $listing_id = $card_data['db-listing-id']; … … 61 73 if ( $payment_status == 'Completed' ) { 62 74 $order_info['completed_on'] = time(); 75 76 global $wpdb; 77 $package_data = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'directory_packages WHERE ID="'.$order_info['listing_package'].'"'); 78 if ( !empty($package_data) ) { 79 $package_data = json_decode($package_data['0']->package_settings, true); 80 81 if ( $payment_type != 'onetime' ) { 82 if ( $package_settings['payment_cycle'] == 'days' ) { 83 $start_value = 1; 84 } else if ( $package_settings['payment_cycle'] == 'weeks' ) { 85 $start_value = 7; 86 } else if ( $package_settings['payment_cycle'] == 'months' ) { 87 $start_value = 30; 88 } else if ( $package_settings['payment_cycle'] == 'years' ) { 89 $start_value = 365; 90 } 91 92 $package_data['listing_run_days'] = $start_value*intval($package_settings['payment_interval']); 93 } 94 95 if ( isset($order_info['listing_expires']) && is_numeric($order_info['listing_expires']) ) { 96 if ( $package_data['listing_run_type'] == 'days' ) { 97 $new_expire_date = strtotime('+'.$package_data['listing_run_days'].' days', $order_info['listing_expires']); 98 $order_info['listing_expires'] = $new_expire_date; 99 } 100 } else if ( isset($order_info['listing_expires']) && !is_numeric($order_info['listing_expires']) ) { 101 if ( $package_data['listing_run_type'] == 'days' ) { 102 $new_expire_date = strtotime('+'.$package_data['listing_run_days'].' days', time()); 103 $order_info['listing_expires'] = $new_expire_date; 104 } 105 } 106 } 63 107 } 64 108 … … 80 124 echo '{"save_response": "failed", "message": "'.__('Something went wrong while processing your card!', 'directory-builder').'"}'; 81 125 } 126 127 function db_process_single_payment( $main_settings, $card_data ) { 128 $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); 129 $merchantAuthentication->setName($main_settings['authorize_id']); 130 $merchantAuthentication->setTransactionKey($main_settings['authorize_key']); 131 132 $request = new AnetAPI\CreateTransactionRequest(); 133 $request->setMerchantAuthentication($merchantAuthentication); 134 135 $creditCard = new AnetAPI\CreditCardType(); 136 $creditCard->setCardNumber($card_data['x_card_num']); 137 $creditCard->setExpirationDate($card_data['x_year']."-".$card_data['x_month']); 138 $paymentOne = new AnetAPI\PaymentType(); 139 $paymentOne->setCreditCard($creditCard); 140 141 // Create a transaction 142 $transactionRequestType = new AnetAPI\TransactionRequestType(); 143 $transactionRequestType->setTransactionType( "authCaptureTransaction"); 144 $transactionRequestType->setAmount($card_data['db-package-fee']); 145 $transactionRequestType->setPayment($paymentOne); 146 147 $request = new AnetAPI\CreateTransactionRequest(); 148 $request->setMerchantAuthentication($merchantAuthentication); 149 $request->setTransactionRequest( $transactionRequestType); 150 $controller = new AnetController\CreateTransactionController($request); 151 152 if ( $main_settings['payment_mode'] == 'sandbox' ) { 153 $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); 154 } else { 155 $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION); 156 } 157 158 return $response; 159 } 160 161 function db_process_subscription( $main_settings, $card_data, $package_settings ) { 162 $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); 163 $merchantAuthentication->setName($main_settings['authorize_id']); 164 $merchantAuthentication->setTransactionKey($main_settings['authorize_key']); 165 166 $request = new AnetAPI\CreateTransactionRequest(); 167 $request->setMerchantAuthentication($merchantAuthentication); 168 169 $creditCard = new AnetAPI\CreditCardType(); 170 $creditCard->setCardNumber($card_data['x_card_num']); 171 $creditCard->setExpirationDate($card_data['x_year']."-".$card_data['x_month']); 172 $paymentOne = new AnetAPI\PaymentType(); 173 $paymentOne->setCreditCard($creditCard); 174 175 $subscription_status = false; 176 $subscription = new AnetAPI\ARBSubscriptionType(); 177 $subscription->setName($package_settings['fee_label'].' package subscription'); 178 $interval = new AnetAPI\PaymentScheduleType\IntervalAType(); 179 $interval->setLength($package_settings['payment_interval']); 180 $interval->setUnit($package_settings['payment_cycle']); 181 182 if ( $package_settings['payment_cycle'] == 'days' ) { 183 $start_value = 1; 184 } else if ( $package_settings['payment_cycle'] == 'weeks' ) { 185 $start_value = 7; 186 } else if ( $package_settings['payment_cycle'] == 'months' ) { 187 $start_value = 30; 188 } else if ( $package_settings['payment_cycle'] == 'years' ) { 189 $start_value = 365; 190 } 191 192 $paymentSchedule = new AnetAPI\PaymentScheduleType(); 193 $paymentSchedule->setInterval($interval); 194 $paymentSchedule->setStartDate(new DateTime(date('Y-m-d', strtotime(date('Y-m-d', time()) . '+ '.($start_value*intval($package_settings['payment_interval'])).' days')))); 195 $paymentSchedule->setTotalOccurrences("24"); 196 $paymentSchedule->setTrialOccurrences("0"); 197 $subscription->setPaymentSchedule($paymentSchedule); 198 $subscription->setAmount($card_data['db-package-fee']); 199 $subscription->setTrialAmount("0.00"); 200 201 $creditCard = new AnetAPI\CreditCardType(); 202 $creditCard->setCardNumber($card_data['x_card_num']); 203 $creditCard->setExpirationDate($card_data['x_year']."-".$card_data['x_month']); 204 $payment = new AnetAPI\PaymentType(); 205 $payment->setCreditCard($creditCard); 206 $subscription->setPayment($payment); 207 $order = new AnetAPI\OrderType(); 208 $order->setInvoiceNumber($card_data['db-listing-id'].time()); 209 $order->setDescription($package_settings['fee_label'].' package subscription for your listing!'); 210 $subscription->setOrder($order); 211 212 $billing_data = json_decode( stripslashes( $_POST['field_data'] ), true ); 213 $name_comp = explode(' ', $billing_data['x_full_name']); 214 $billTo = new AnetAPI\NameAndAddressType(); 215 $billTo->setFirstName($name_comp['0']); 216 $first_name = $name_comp['0']; 217 unset($name_comp['0']); 218 $billTo->setLastName((empty($name_comp)?$first_name:implode(' ', $name_comp))); 219 $subscription->setBillTo($billTo); 220 $request = new AnetAPI\ARBCreateSubscriptionRequest(); 221 $request->setmerchantAuthentication($merchantAuthentication); 222 $request->setRefId('ref' . time()); 223 $request->setSubscription($subscription); 224 $controller = new AnetController\ARBCreateSubscriptionController($request); 225 226 if ( $main_settings['payment_mode'] == 'sandbox' ) { 227 $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); 228 } else { 229 $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION); 230 } 231 232 return $response; 233 } -
directory-builder/trunk/directory-builder.php
r1595019 r1596655 17 17 * Plugin URI: https://cohhe.com/ 18 18 * Description: Directory builder provides listing functionality for your theme. 19 * Version: 1.3. 519 * Version: 1.3.6 20 20 * Author: Cohhe 21 21 * Author URI: https://cohhe.com/ … … 580 580 </div> 581 581 </div> 582 <?php 583 $sorting_types = array( 'text', 'number', 'textarea', 'checkbox', 'radio', 'select', 'multi-select', 'url', 'date', 'time', 'email' ); 584 if ( in_array($field_type, $sorting_types) ) { ?> 585 <div class="db-field-row focused active clearfix"> 586 <label class="field-label">Show in sorting options?</label> 587 <div class="db-field-input"> 588 <select class="db-create-on-sorting"> 589 <option value="no" <?php echo(isset($field_settings['on_sorting'])&&$field_settings['on_sorting']=='no'?'selected':''); ?>>No</option> 590 <option value="yes" <?php echo(isset($field_settings['on_sorting'])&&$field_settings['on_sorting']=='yes'?'selected':''); ?>>Yes</option> 591 </select> 592 <span class="field-description">Do you want to show this field in sorting options at the search page?</span> 593 </div> 594 </div> 595 <?php } ?> 582 596 <div class="db-field-row focused active clearfix"> 583 597 <label class="field-label">Custom field icon</label> … … 1308 1322 case 'auth-code': $billing_label = __('Card Auth Code', 'directory-builder'); break; 1309 1323 case 'trans-id': $billing_label = __('Transaction ID', 'directory-builder'); break; 1324 case 'subscription': $billing_label = __('Subscription ID', 'directory-builder'); break; 1310 1325 1311 1326 default: break; … … 1442 1457 $output .= ' 1443 1458 <div class="db-field-row'.$field_required.' checkbox-label">'; 1444 $is_checked = ($field_default==$field_settings['checkbox_true']?true:false); 1459 global $post; 1460 if ( has_shortcode( $post->post_content, 'directory_add_listing' ) ) { 1461 $is_checked = ($field_default==$field_settings['checkbox_true']||$field_default=='true'?true:false); 1462 } else { 1463 $is_checked = ($field_default=='true'?true:false); 1464 } 1445 1465 $output .= '<input type="checkbox" id="'.$field_name.'" name="'.$field_name.'" class="'.$custom_class.'" value="true"'.($is_checked?' checked':'').'>'; 1446 1466 if ( $field_title != '' ) { … … 1526 1546 <div class="db-field-row'.$field_required.' custom-select">'; 1527 1547 if ( $field_title != '' ) { 1528 $output .= '<label class="db-field-row-label">'.$field_title.'</label>';1548 // $output .= '<label class="db-field-row-label">'.$field_title.'</label>'; 1529 1549 } 1530 1550 1531 $active_values = (isset($_GET[$field_name])?explode(',', sanitize_text_field($_GET[$field_name])):array( ));1551 $active_values = (isset($_GET[$field_name])?explode(',', sanitize_text_field($_GET[$field_name])):array( $field_default )); 1532 1552 $active_value_shown = $active_value_hidden = ''; 1533 1553 if ( !empty($active_values) ) { … … 1615 1635 $active_value_shown = $active_value_hidden = ''; 1616 1636 if ( !empty($active_values) ) { 1617 $active_value_shown = implode(', ', $active_values);1637 // $active_value_shown = implode(', ', $active_values); 1618 1638 $active_value_hidden = implode(',', $active_values); 1639 1640 $all_select_data = explode( '||', str_replace("\n", '||', $field_settings['select_options']) ); 1641 $all_select_options = array(); 1642 foreach ($all_select_data as $select_value) { 1643 $select_value_exploded = explode(':', $select_value); 1644 $all_select_options[$select_value_exploded['0']] = $select_value_exploded['1']; 1645 } 1646 1647 $active_shown_values = array(); 1648 if ( $active_values['0'] != '' ) { 1649 foreach ($active_values as $active_value) { 1650 $active_shown_values[] = $all_select_options[$active_value]; 1651 } 1652 } 1653 1654 $active_value_shown = implode( ', ', $active_shown_values ); 1619 1655 } 1620 1656 … … 2060 2096 <a href="javascript:void(0)" class="db-find-listings onload">'.__('Search', 'directory-builder').'</a> 2061 2097 </div>'; 2098 $custom_sorting = whitelab_get_listing_custom_fields( '', 'on_sorting' ); 2062 2099 if ( !defined('WHITELAB_CUSTOM_SELECT') ) { 2063 2100 $output .= __('Sort by:', 'directory-builder').' … … 2065 2102 <option value="name">Name</option> 2066 2103 <option value="date">Date</option> 2067 <option value="rating">Rating</option> 2104 <option value="rating">Rating</option>'; 2105 foreach ($custom_sorting as $field_name => $field_data) { 2106 $output .= '<option value="'.$field_name.'">'.$field_data['title'].'</option>'; 2107 } 2108 $output .= ' 2068 2109 </select>'; 2069 2110 } else { … … 2079 2120 <div class="dt-custom-select-item" data-value="name">Name</div> 2080 2121 <div class="dt-custom-select-item" data-value="date">Date</div> 2081 <div class="dt-custom-select-item" data-value="rating">Rating</div> 2122 <div class="dt-custom-select-item" data-value="rating">Rating</div>'; 2123 foreach ($custom_sorting as $field_name => $field_data) { 2124 $output .= '<div class="dt-custom-select-item" data-value="'.$field_name.'">'.$field_data['title'].'</div>'; 2125 } 2126 $output .= ' 2082 2127 </div> 2083 2128 <div class="dt-custom-select-scrollbar-wrapper"> … … 2102 2147 add_shortcode('directory_listings','db_search_shortcode'); 2103 2148 2149 // function db_check_listing_status( $post ) { 2150 // if ( get_post_type( $post['0']->ID ) == 'listings' && get_post_status( $post['0']->ID ) == 'publish' ) { 2151 // $order_data = get_post_meta( $post['0']->ID, 'db_order_info', true ); 2152 2153 // if ( isset($order_data['listing_expires']) && is_numeric($order_data['listing_expires']) && time() > $order_data['listing_expires'] ) { 2154 // wp_update_post( array( 'ID' => $post['0']->ID, 'post_status' => 'draft' ) ); 2155 // } 2156 // } 2157 // } 2158 // add_action( 'posts_results', 'db_check_listing_status', 10, 1 ); 2159 2104 2160 function db_search_for_listings() { 2105 2161 $output = ''; … … 2111 2167 if ( !isset($search_terms['listing_address']) || ( isset($search_terms['listing_address']) && $search_terms['listing_address'] == '' ) ) { 2112 2168 unset($search_terms['listing_search_radius']); 2169 } 2170 2171 if ( strpos($db_full_url, 'amenities=') !== false ) { // Add amenities to the search parameters 2172 $url_parts = parse_url( $_POST['db_full_url'] ); 2173 parse_str($url_parts['query'], $url_query); 2174 $search_terms['amenities'] = $url_query['amenities']; 2113 2175 } 2114 2176 … … 2145 2207 unset($search_terms['listing_search_radius']); 2146 2208 2209 $map_new_center = false; 2147 2210 if ( !empty($search_listings) ) { 2148 2211 $field_list = db_get_active_fields(); 2149 2212 2150 2213 if ( isset($search_terms['listing_address']) && $search_terms['listing_address'] != '' ) { 2151 $search_coordinates = db_get_coordinates( $search_terms['listing_address'] ); 2152 $search_coordinates = explode(',', $search_coordinates); 2214 $search_address_data = db_get_coordinates( $search_terms['listing_address'] ); 2215 2216 $map_new_center = true; 2153 2217 } 2154 2218 … … 2158 2222 $listing_value = array_merge((array)$listing_value, $custom_field_data); 2159 2223 $show_listing = true; 2160 2161 if ( $main_settings['search_radius_status'] == 'yes' && isset($search_terms['listing_address']) && $search_terms['listing_address'] != '' ) { 2162 $db_search_distance = db_calculateDistanceFromLatLong($listing_value['listing_address_lat'], $listing_value['listing_address_lng'], $search_coordinates['0'], $search_coordinates['1'], $main_settings['search_radius_value']); 2163 2164 if ( intval($db_search_distance) > intval($search_distance) ) { 2224 $listing_visible = false; 2225 2226 if ( isset($search_terms['listing_address']) && $search_terms['listing_address'] != '' ) { 2227 if ( $search_address_data['type'] == 'fields' ) { 2228 if ( $search_address_data['field_type'] == 'country' && strpos($listing_value['listing_country'], $search_address_data['value']) !== false ) { 2229 $listing_visible = true; 2230 } else if ( $search_address_data['field_type'] == 'locality' && strpos($listing_value['listing_city'], $search_address_data['value']) !== false ) { 2231 $listing_visible = true; 2232 } else { 2233 $listing_visible = false; 2234 } 2235 } else { 2236 $db_search_distance = db_calculateDistanceFromLatLong($listing_value['listing_address_lat'], $listing_value['listing_address_lng'], $search_address_data['lat'], $search_address_data['lng'], $main_settings['search_radius_value']); 2237 2238 if ( $main_settings['search_radius_status'] != 'yes' ) { 2239 $search_distance = '200'; 2240 } 2241 if ( intval($db_search_distance) > intval($search_distance) ) { 2242 $listing_visible = false; 2243 } else { 2244 $listing_visible = true; 2245 } 2246 } 2247 2248 if ( $listing_visible ) { 2249 $dist_show_listing = true; 2250 } else { 2165 2251 $dist_show_listing = false; 2166 } else {2167 $dist_show_listing = true;2168 }2169 } else if ( isset($search_terms['listing_address']) && $search_terms['listing_address'] != '' ) {2170 $db_search_distance = db_calculateDistanceFromLatLong($listing_value['listing_address_lat'], $listing_value['listing_address_lng'], $search_coordinates['0'], $search_coordinates['1'], $main_settings['search_radius_value']);2171 2172 if ( intval($db_search_distance) > 200 ) {2173 $dist_show_listing = false;2174 } else {2175 $dist_show_listing = true;2176 2252 } 2177 2253 } … … 2216 2292 } 2217 2293 } 2294 } else if ( $search_key == 'amenities' ) { 2295 $amenities_values = (is_array($listing_value[$search_key])?$listing_value[$search_key]:explode(',', $listing_value[$search_key])); 2296 if ( in_array($search_value, $amenities_values) ) { 2297 $show_listing = true; 2298 $matched_settings++; 2299 break; 2300 } else { 2301 $show_listing = false; 2302 } 2218 2303 } else { 2219 2304 if ( strtolower($listing_value[$search_key]) != strtolower($search_value) ) { … … 2269 2354 } 2270 2355 } 2271 2272 echo json_encode(array('listing_html' => $all_listings, 'marker_data' => $all_markers, 'new_url' => $db_new_url)); 2356 2357 $search_data = array('listing_html' => $all_listings, 'marker_data' => $all_markers, 'new_url' => $db_new_url, 'map_changed' => false ); 2358 2359 if ( empty( $all_markers ) && $map_new_center ) { 2360 $search_data['map_lat'] = $search_address_data['lat']; 2361 $search_data['map_lng'] = $search_address_data['lng']; 2362 $search_data['map_changed'] = true; 2363 } 2364 2365 echo json_encode( $search_data ); 2273 2366 2274 2367 die(0); … … 2276 2369 add_action( 'wp_ajax_db_search_listings', 'db_search_for_listings' ); 2277 2370 add_action( 'wp_ajax_nopriv_db_search_listings', 'db_search_for_listings' ); 2371 2372 function db_get_custom_sorting() { 2373 $custom_sorting = whitelab_get_listing_custom_fields( '', 'on_sorting' ); 2374 $sort_ints = array( 'number', 'date', 'time', 'phone' ); 2375 $sorting_arr = array( 'name' => '[data-name]', 'date' => '[data-date] parseInt', 'rating' => '[data-rating] parseInt', 'featured' => '[data-featured] parseInt' ); 2376 2377 if ( !empty($custom_sorting) ) { 2378 foreach ($custom_sorting as $sorting_key => $sorting_value) { 2379 $sorting_arr[$sorting_key] = '[data-'.$sorting_key.']'.(in_array($sorting_value['type'], $sort_ints)?' parseInt':''); 2380 } 2381 } 2382 2383 return json_encode( $sorting_arr ); 2384 } 2385 2386 function db_get_custom_sorting_dir() { 2387 $custom_sorting = whitelab_get_listing_custom_fields( '', 'on_sorting' ); 2388 $sort_ints = array( 'number', 'date', 'time', 'phone' ); 2389 $sorting_dir_arr = array( 'name' => true, 'date' => false, 'rating' => false, 'featured' => true ); 2390 2391 if ( !empty($custom_sorting) ) { 2392 foreach ($custom_sorting as $sorting_key => $sorting_value) { 2393 $sorting_dir_arr[$sorting_key] = (in_array($sorting_value['type'], $sort_ints)?false:true); 2394 } 2395 } 2396 2397 return json_encode( $sorting_dir_arr ); 2398 } 2278 2399 2279 2400 function db_get_coordinates( $address ) { … … 2283 2404 $json = json_decode($response['body'],TRUE); 2284 2405 2285 return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']); 2406 if ( ( $json['results'][0]['types']['0'] == 'country' || $json['results'][0]['types']['0'] == 'locality' ) && $json['results'][0]['types']['1'] == 'political' ) { 2407 return array( 'type' => 'fields', 'field_type' => $json['results'][0]['types']['0'], 'value' => $json['results'][0]['address_components']['0']['long_name'], 'lat' => $json['results'][0]['geometry']['location']['lat'], 'lng' => $json['results'][0]['geometry']['location']['lng'] ); 2408 } else { 2409 return array( 'type' => 'coordinates', 'lat' => $json['results'][0]['geometry']['location']['lat'], 'lng' => $json['results'][0]['geometry']['location']['lng'] ); 2410 } 2286 2411 } 2287 2412 … … 2427 2552 <div class="db-row"> 2428 2553 <div class="db-row-group clearfix"> 2429 <span class="db-row-label col-sm-3"> Listings per page</span>2554 <span class="db-row-label col-sm-3">Per page limit at search</span> 2430 2555 <div class="col-sm-9"> 2431 <input type="number" class="db-settings-per_page" placeholder=" Listings per page" value="<?php echo $main_settings['per_page']; ?>">2556 <input type="number" class="db-settings-per_page" placeholder="Per page limit at search" value="<?php echo $main_settings['per_page']; ?>"> 2432 2557 </div> 2433 2558 </div> … … 2545 2670 foreach ($all_pages as $page_key => $page_value) { 2546 2671 $is_selected = ($main_settings['add_page_id']==$page_value->ID?' selected':''); 2672 echo '<option value="'.$page_value->ID.'"'.$is_selected.'>'.$page_value->post_title.'</option>'; 2673 } 2674 ?> 2675 </select> 2676 </div> 2677 </div> 2678 </div> 2679 <div class="db-row"> 2680 <div class="db-row-group clearfix"> 2681 <span class="db-row-label col-sm-3">Listing author account page</span> 2682 <div class="col-sm-9"> 2683 <select class="db-settings-account_page_id"> 2684 <?php 2685 foreach ($all_pages as $page_key => $page_value) { 2686 $is_selected = ($main_settings['account_page_id']==$page_value->ID?' selected':''); 2547 2687 echo '<option value="'.$page_value->ID.'"'.$is_selected.'>'.$page_value->post_title.'</option>'; 2548 2688 } … … 3183 3323 </div> 3184 3324 <div class="db-field-row active clearfix"> 3185 <label class="field-label">Listing run in days</label> 3325 <label class="field-label">Payment type</label> 3326 <div class="db-field-input"> 3327 <select class="db-create-payment_type"> 3328 <option value="onetime" <?php echo(isset($field_settings['payment_type'])&&$field_settings['payment_type']=='onetime'?'selected':''); ?>>One time payment</option> 3329 <option value="recurring" <?php echo(isset($field_settings['payment_type'])&&$field_settings['payment_type']=='recurring'?'selected':''); ?>>Recurring payment</option> 3330 </select> 3331 </div> 3332 </div> 3333 <div class="db-field-row active clearfix"> 3334 <label class="field-label">Run listing for</label> 3186 3335 <div class="db-field-input"> 3187 3336 <select class="db-create-listing_run_type"> … … 3195 3344 <div class="db-field-input"> 3196 3345 <input type="number" class="db-create-listing_run_days" value="<?php echo(isset($field_settings['listing_run_days'])?$field_settings['listing_run_days']:'20'); ?>"> 3346 </div> 3347 </div> 3348 <div class="db-field-row active clearfix"> 3349 <label class="field-label">Payment cycle</label> 3350 <div class="db-field-input"> 3351 <select class="db-create-payment_cycle"> 3352 <option value="days" <?php echo(isset($field_settings['payment_cycle'])&&$field_settings['payment_cycle']=='days'?'selected':''); ?>>Days</option> 3353 <option value="weeks" <?php echo(isset($field_settings['payment_cycle'])&&$field_settings['payment_cycle']=='weeks'?'selected':''); ?>>Weeks</option> 3354 <option value="months" <?php echo(isset($field_settings['payment_cycle'])&&$field_settings['payment_cycle']=='months'?'selected':''); ?>>Months</option> 3355 <option value="years" <?php echo(isset($field_settings['payment_cycle'])&&$field_settings['payment_cycle']=='years'?'selected':''); ?>>Years</option> 3356 </select> 3357 </div> 3358 </div> 3359 <div class="db-field-row <?php echo(isset($field_settings['payment_interval'])&&$field_settings['payment_interval']!=''?'active':(!isset($field_settings['payment_interval'])?'active':'')); ?> clearfix"> 3360 <label class="field-label">Payment cycle interval</label> 3361 <div class="db-field-input"> 3362 <input type="number" class="db-create-payment_interval" value="<?php echo(isset($field_settings['payment_interval'])?$field_settings['payment_interval']:''); ?>"> 3197 3363 </div> 3198 3364 </div> … … 3472 3638 function db_send_contact_email() { 3473 3639 $output = ''; 3474 $db_author = ( isset($_POST['db_author']) ? sanitize_text_field($_POST['db_author']) : '' );3640 $db_author_email = ( isset($_POST['db_author']) ? sanitize_text_field($_POST['db_author']) : '' ); 3475 3641 $db_message = ( isset($_POST['db_message']) ? sanitize_text_field($_POST['db_message']) : '' ); 3476 $author_email = get_the_author_meta('email', $db_author); 3477 3478 $subject = 'Contacting regarding your listing'; 3479 $message = $db_message; 3480 3481 $maintenance_email = wp_mail( $author_email, $subject, $message ); 3642 $db_name = ( isset($_POST['db_name']) ? sanitize_text_field($_POST['db_name']) : '' ); 3643 $db_email = ( isset($_POST['db_email']) ? sanitize_text_field($_POST['db_email']) : '' ); 3644 3645 $subject = esc_html__( 'Contacting regarding your listing', 'directory-builder' ); 3646 $message = esc_html__( 'Name:', 'directory-builder' ) . ' ' . $db_name . '<br />'; 3647 $message .= esc_html__( 'Email:', 'directory-builder' ) . ' ' . $db_email . '<br />'; 3648 $message .= esc_html__( 'Message:', 'directory-builder' ) . '<br />' . $db_message; 3649 3650 $maintenance_email = wp_mail( $db_author_email, $subject, $message ); 3482 3651 3483 3652 if ( $maintenance_email ) { … … 3678 3847 <input type="hidden" name="db-checkout" value="true"> 3679 3848 <input type="hidden" name="db-listing-id" value="'.get_the_ID().'"> 3680 3681 <input type="hidden" name="cmd" value="_xclick-subscriptions"> 3849 <input type="hidden" name="cmd" value="_xclick"> 3682 3850 <input type="hidden" name="business" value="' . $main_settings['paypal_merchant_id'] . '"> 3683 3851 <input type="hidden" name="item_name" value="'.(isset($package_data['fee_label'])?$package_data['fee_label']:'').'"> … … 3688 3856 <input type="hidden" name="return" value="' . $main_settings['paypal_return_url'] . '"> 3689 3857 <input type="hidden" name="notify_url" value="' . get_the_permalink() . '"> 3690 <input type="hidden" name="custom" value="' . $new_listing_id . '">'; 3858 <input type="hidden" name="custom" value="' . $new_listing_id . '"> 3859 <input type="hidden" name="src" value="1"> 3860 <input type="hidden" name="a3" value="'.(isset($package_data['fee_amount'])?$package_data['fee_amount']:'').'"> 3861 <input type="hidden" name="p3" value="1"> 3862 <input type="hidden" name="t3" value="M">'; 3863 3691 3864 if ( $main_settings['terms_and_conditions_status'] ) { 3692 3865 $output .= ' … … 3878 4051 3879 4052 foreach ($fields_to_save as $field_key => $field_value) { 3880 update_post_meta( esc_attr($_GET['edit-listing']), sanitize_key($field_key), sanitize_text_field($field_value));4053 update_post_meta( esc_attr($_GET['edit-listing']), sanitize_key($field_key), (!is_array($field_value)?sanitize_text_field($field_value):$field_value)); 3881 4054 } 3882 4055 … … 4302 4475 4303 4476 function db_account_shortcode( $atts, $content = null ) { 4304 extract( shortcode_atts( array(4305 // 'id' => '',4306 ), $atts ) );4307 4477 $main_settings = get_option( 'db_main_settings'); 4308 4478 … … 4362 4532 } 4363 4533 4364 if ( ! empty($user_listings) && !isset($_GET['edit-listing']) && !isset($_GET['my-profile']) ) {4365 if ( !isset($_GET['my-favorites']) ) {4534 if ( !isset($_GET['edit-listing']) && !isset($_GET['my-profile']) ) { 4535 if ( !isset($_GET['my-favorites']) && !empty($user_listings) ) { 4366 4536 $output .= db_checkout_html(); 4367 4537 $output .= ' … … 5084 5254 add_action( 'wp_ajax_db_address_autocomplete', 'db_do_address_autocomplete' ); 5085 5255 add_action( 'wp_ajax_nopriv_db_address_autocomplete', 'db_do_address_autocomplete' ); 5256 5257 function db_setup_vc_modules() { 5258 // Extend Visual Composer 5259 if ( defined('WPB_VC_VERSION') ) { 5260 vc_map( array( 5261 "name" => __("Directory builder search", "directory-builder" ), 5262 "base" => "directory_listings", 5263 "class" => "", 5264 "icon" => "icon-wpb-ui-gap-content", 5265 "category" => __( "by Directory builder", "directory-builder" ), 5266 "show_settings_on_create" => false 5267 )); 5268 5269 vc_map( array( 5270 "name" => __("Directory builder add listing", "directory-builder" ), 5271 "base" => "directory_add_listing", 5272 "class" => "", 5273 "icon" => "icon-wpb-ui-gap-content", 5274 "category" => __( "by Directory builder", "directory-builder" ), 5275 "show_settings_on_create" => false 5276 )); 5277 5278 vc_map( array( 5279 "name" => __("Directory builder author dashboard", "directory-builder" ), 5280 "base" => "directory_account", 5281 "class" => "", 5282 "icon" => "icon-wpb-ui-gap-content", 5283 "category" => __( "by Directory builder", "directory-builder" ), 5284 "show_settings_on_create" => false 5285 )); 5286 5287 vc_map( array( 5288 "name" => __("Directory builder login", "directory-builder" ), 5289 "base" => "directory_login", 5290 "class" => "", 5291 "icon" => "icon-wpb-ui-gap-content", 5292 "category" => __( "by Directory builder", "directory-builder" ), 5293 "show_settings_on_create" => false 5294 )); 5295 5296 vc_map( array( 5297 "name" => __("Directory builder register", "directory-builder" ), 5298 "base" => "directory_register", 5299 "class" => "", 5300 "icon" => "icon-wpb-ui-gap-content", 5301 "category" => __( "by Directory builder", "directory-builder" ), 5302 "show_settings_on_create" => false 5303 )); 5304 } 5305 } 5306 add_action('after_setup_theme', 'db_setup_vc_modules'); -
directory-builder/trunk/includes/class-db-functionality-activator.php
r1595019 r1596655 452 452 } 453 453 454 $account_page = array( 455 'post_author' => get_current_user_id(), 456 'post_content' => '[directory_account]', 457 'post_title' => 'Directory builder user account', 458 'post_status' => 'publish', 459 'post_type' => 'page' 460 ); 461 462 $account_id = wp_insert_post($account_page); 463 464 if ( $account_id ) { 465 $main_settings = get_option( 'db_main_settings' ); 466 $main_settings['account_page_id'] = $account_id; 467 update_option( 'db_main_settings', $main_settings ); 468 } 469 454 470 $success_page = array( 455 471 'post_author' => get_current_user_id(), -
directory-builder/trunk/paypal_ipn.php
r1595019 r1596655 114 114 $package_data = json_decode($package_data['0']->package_settings, true); 115 115 116 if ( $package_data['payment_type'] != 'onetime' ) { 117 if ( $package_settings['payment_cycle'] == 'days' ) { 118 $start_value = 1; 119 } else if ( $package_settings['payment_cycle'] == 'weeks' ) { 120 $start_value = 7; 121 } else if ( $package_settings['payment_cycle'] == 'months' ) { 122 $start_value = 30; 123 } else if ( $package_settings['payment_cycle'] == 'years' ) { 124 $start_value = 365; 125 } 126 127 $package_data['listing_run_days'] = $start_value*intval($package_settings['payment_interval']); 128 } 129 116 130 if ( isset($order_info['listing_expires']) && is_numeric($order_info['listing_expires']) ) { 117 131 if ( $package_data['listing_run_type'] == 'days' ) { -
directory-builder/trunk/public/class-db-functionality-public.php
r1571162 r1596655 125 125 'default_location_lat' => $default_location_lat, 126 126 'default_location_lng' => $default_location_lng, 127 'template_url' => get_template_directory_uri() 127 'template_url' => get_template_directory_uri(), 128 'custom_sorting' => db_get_custom_sorting(), 129 'custom_sorting_dir' => db_get_custom_sorting_dir() 128 130 )); 129 131 -
directory-builder/trunk/public/css/db-functionality-public.css
r1595019 r1596655 246 246 position: absolute; 247 247 opacity: 0; 248 top: 30px; 248 top: 10px; 249 left: 140px; 249 250 } 250 251 -
directory-builder/trunk/public/js/db-functionality-public.js
r1595019 r1596655 266 266 $search_map.setZoom(13); 267 267 } 268 269 268 db_set_isotope(); 270 269 }, 100); 271 270 272 271 } else { 272 if ( parsed_search_data.map_changed ) { 273 setTimeout(function() { 274 $search_map.setCenter(new google.maps.LatLng(parsed_search_data.map_lat, parsed_search_data.map_lng)); 275 $search_map.setZoom(10); 276 }, 100); 277 } 278 273 279 jQuery('.db-main-search-listings').addClass('db-no-listings'); 274 280 jQuery('.db-main-search-listings').append('<div class="db-main-search-item full-listing" style="text-align: center;">No listings found!</div>'); … … 304 310 var scrolled_percentage = jQuery(this).scrollTop()/(jQuery(this)[0].scrollHeight-jQuery(this).innerHeight())*100; 305 311 var extra_scroll = jQuery(this).find('.db-search-scrollbar').height()*(scrolled_percentage/100); 306 // if ( !jQuery(this).hasClass('mh-search-wrapper') ) { 307 var scroll_height = 'calc('+scrolled_percentage+'% - '+extra_scroll+'px + '+jQuery(this).scrollTop()+'px)'; 308 // } else { 309 // var scroll_height = 'calc('+scrolled_percentage+'% - '+extra_scroll+'px)'; 310 // } 312 var scroll_height = 'calc('+scrolled_percentage+'% - '+extra_scroll+'px + '+jQuery(this).scrollTop()+'px)'; 311 313 312 314 jQuery(this).find('.db-search-scrollbar').css('top', scroll_height); … … 321 323 gutter: 30 322 324 }, 323 getSortData: { 324 name: '[data-name]', 325 date: '[data-date] parseInt', 326 rating: '[data-rating] parseInt', 327 featured: '[data-featured] parseInt' 328 }, 325 getSortData: jQuery.parseJSON(db_main.custom_sorting), 329 326 sortBy: [ 'featured', 'name' ], 330 sortAscending: { 331 name: true, 332 date: false, 333 rating: false, 334 featured: true 335 }, 327 sortAscending: jQuery.parseJSON(db_main.custom_sorting_dir), 336 328 transitionDuration: '0.2s', 337 329 hiddenStyle: { … … 349 341 jQuery(document).on('change', '.db-search-sort, #db-search-sort', function() { 350 342 var sort_by_value = jQuery(this).val(); 351 if ( sort_by_value == 'date' || sort_by_value == 'rating' ) { 352 $search_item_container.isotope({ 353 sortBy: [ 'featured', sort_by_value ], 354 }); 355 } else { 356 $search_item_container.isotope({ 357 sortBy: [ 'featured', sort_by_value ], 358 }); 359 } 360 343 $search_item_container.isotope({ 344 sortBy: [ 'featured', sort_by_value ], 345 }); 361 346 }); 362 347 … … 368 353 'action': 'db_send_contact_email', 369 354 'db_author': jQuery(this).attr('data-id'), 370 'db_message': jQuery('.db-contact-message').val() 355 'db_message': jQuery('.db-contact-message').val(), 356 'db_name': jQuery('.db-contact-name').val(), 357 'db_email': jQuery('.db-contact-email').val() 371 358 }, 372 359 success: function(data) {
Note: See TracChangeset
for help on using the changeset viewer.