Skip to content

Commit

Permalink
Merged in thePaulCEO/domain-mapping/develop (pull request #6)
Browse files Browse the repository at this point in the history
Fixes for multiple tickets

Approved-by: sheparddw <daniel.shepard@incsub.com>
  • Loading branch information
Paul Kevin authored and sheparddw committed Apr 13, 2017
2 parents d7d3630 + 13cbb30 commit 09bed79
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 17 deletions.
5 changes: 3 additions & 2 deletions classes/Domainmap/Module/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ public function render_mapped_domain_column( $column, $blog_id ) {
if ( is_null( $this->_mapped_domains ) ) {
$this->_mapped_domains = array();
$suffix = $current_site->path != '/' ? $current_site->path : '';
$results = $this->_wpdb->get_results( "SELECT blog_id, domain FROM " . DOMAINMAP_TABLE_MAP );
$results = $this->_wpdb->get_results( "SELECT blog_id, domain, scheme FROM " . DOMAINMAP_TABLE_MAP );
foreach ( $results as $result ) {
if ( !isset( $this->_mapped_domains[$result->blog_id] ) ) {
$this->_mapped_domains[$result->blog_id] = array();
}
$this->_mapped_domains[$result->blog_id][] = sprintf( '<a href="http://%1$s%2$s">%1$s%2$s</a>', Domainmap_Punycode::decode( $result->domain ), $suffix );
$scheme = ($result->scheme == 1) ? 'https' : 'http';
$this->_mapped_domains[$result->blog_id][] = sprintf( '<a href="%3$s://%1$s%2$s">%1$s%2$s</a>', Domainmap_Punycode::decode( $result->domain ), $suffix, $scheme );
}
}

Expand Down
8 changes: 5 additions & 3 deletions classes/Domainmap/Module/Ajax/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ public function unmap_domain() {
$show_form = false;
$domain = strtolower( trim( filter_input( INPUT_GET, 'domain' ) ) );
$success = false;
if ( self::utils()->is_domain( $domain ) ) {
//We need to be able to also delete domains that have been saved wrongly.
//Sometimes somethings can go wrong
//if ( self::utils()->is_domain( $domain ) ) {
$success = $this->delete_mapped_domain( $domain );

// check if we need to show form
Expand All @@ -272,7 +274,7 @@ public function unmap_domain() {
* @param int $blog_id
*/
do_action( 'domainmapping_deleted_domain', $domain, $blog_id);
}
//}

if( $success ){
wp_send_json_success( array( 'show_form' => $show_form ) );
Expand Down Expand Up @@ -412,7 +414,7 @@ function toggle_scheme(){

$current_scheme = (int) $this->_wpdb->get_var( $this->_wpdb->prepare( "SELECT `scheme` FROM " . DOMAINMAP_TABLE_MAP . " WHERE `domain` = %s", $domain ) );
if( !is_null( $current_scheme ) ){
$new_schema = ( $current_scheme + 1 ) % 3;
$new_schema = ( $current_scheme + 1 ) % 3;
$result = $this->_wpdb->update( DOMAINMAP_TABLE_MAP, array(
"scheme" => $new_schema ,
), array(
Expand Down
5 changes: 2 additions & 3 deletions classes/Domainmap/Module/Ajax/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,17 @@ public function check_domain() {
$is_valid = $this->_validate_domain_name( $domain );
if ( $is_valid ) {
$reseller = $this->_plugin->get_reseller();

$price = false;
$available = $reseller->check_domain( $tld, $sld );
if ( $available ) {
$price = '$' . number_format( floatval( $reseller->get_tld_price( $tld ) ), 2 );
$price = '$' . number_format( floatval( $reseller->get_tld_price( $tld) ), 2 );
}

set_site_transient( $this->_get_transient_name( 'checkdomain' ), array(
'domain' => $domain,
'price' => $price,
'sld' => $sld,
'tld' => $tld,
'tld' => $tld
), HOUR_IN_SECONDS );

wp_send_json_success( array(
Expand Down
10 changes: 6 additions & 4 deletions classes/Domainmap/Module/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -856,10 +856,12 @@ function on_delete_blog( $blog_id, $drop){
* @return string
*/
function post_preview_link_from_original_domain_to_mapped_domain($url, $post = null){
$url_fragments = parse_url( $url );
$hostinfo = $url_fragments['scheme'] . "://" . $url_fragments['host'];
if( $hostinfo !== $this->_http->hostInfo ){
return esc_url_raw( add_query_arg(array("dm" => self::BYPASS ), set_url_scheme($this->unswap_mapped_url( $url ), is_ssl() ) ) );
if($url){
$url_fragments = parse_url( $url );
$hostinfo = $url_fragments['scheme'] . "://" . $url_fragments['host'];
if( $hostinfo !== $this->_http->hostInfo ){
return esc_url_raw( add_query_arg(array("dm" => self::BYPASS ), set_url_scheme($this->unswap_mapped_url( $url ), is_ssl() ) ) );
}
}

return $url;
Expand Down
1 change: 1 addition & 0 deletions classes/Domainmap/Render/Site/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Domainmap_Render_Site_Purchase extends Domainmap_Render_Site {
*/
protected function _render_tab() {
$tlds = $this->reseller->get_tld_list();

$predefined_sld = trim( filter_input( INPUT_GET, 'sld' ) );
$predefined_tld = trim( filter_input( INPUT_GET, 'tld' ) );
if ( !in_array( $predefined_tld, $tlds ) ) {
Expand Down
27 changes: 22 additions & 5 deletions classes/Domainmap/Reseller/Enom.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,12 @@ protected function _check_domain( $tld, $sld ) {
* @return float The price for the TLD.
*/
protected function _get_tld_price( $tld, $period ) {

$xml = $this->_exec_command( self::COMMAND_RETAIL_PRICE, array(
'tld' => $tld,
'ProductType' => 10,
) );
'Years' => $period
));

$this->_log_enom_request( self::REQUEST_GET_RETAIL_PRICE, $xml );

Expand Down Expand Up @@ -834,6 +836,9 @@ public function complete_paypal_checkout() {
return false;
}

$firstname = $details['FIRSTNAME'];
$lastname = $details['LASTNAME'];

// complete checkout
$response = $this->_call_paypal_api( 'DoExpressCheckoutPayment', array(
'PAYERID' => $details['PAYERID'],
Expand All @@ -855,13 +860,25 @@ public function complete_paypal_checkout() {
$sld = trim( filter_input( INPUT_GET, 'sld' ) );
$tld = trim( filter_input( INPUT_GET, 'tld' ) );

$response = $this->_exec_command( self::COMMAND_PURCHASE, array(

$enom_request = array(
'sld' => $sld,
'tld' => $tld,
'UseDNS' => 'default',
'UseCreditCard' => 'no',
'EndUserIP' => $_SERVER['REMOTE_ADDR'],
) );
'EndUserIP' => $_SERVER['REMOTE_ADDR']
);

//Check if domain is a UK tld
preg_match("`(?<=\.)\w+$`", strtolower($tld), $tld_array);
//If its UK, we need to add the required parameters
if (in_array('uk', $tld_array)){
$enom_request['Registered_For'] = $firstname.' '.$lastname;
$enom_request['UK_Legal_Type'] = $firstname.' '.$lastname;
$enom_request['UK_Reg_Opt_Out'] = 'no';
}

$response = $this->_exec_command( self::COMMAND_PURCHASE, $enom_request);

$this->_log_enom_request( self::REQUEST_PURCHASE_DOMAIN, $response );

Expand Down Expand Up @@ -975,7 +992,7 @@ public function regiser_account() {
/**
* Returns currenct currency code
*
* @sicne 4.3.1
* @since 4.3.1
* @return string
*/
public function get_currency(){
Expand Down
17 changes: 17 additions & 0 deletions css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,23 @@ table.domains .domainmapping-mapped{
box-sizing: border-box;
}

.domainmapping-form select.domainmapping-select-period {
float: left;
background-color: white;
-moz-border-radius: 0;
-webkit-border-radius: 0;
border-radius: 0;
height: 27px;
padding: 4px 0;
margin: 0;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
border: 0;
-moz-box-sizing: border-box;
box-sizing: border-box;
}

.domainmapping-controls-wrapper {
border-top: 1px solid #dfdfdf;
border-bottom: 1px solid #dfdfdf;
Expand Down
2 changes: 2 additions & 0 deletions js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@
$('#reseller-' + $(this).val()).show();
});



$('#domainmapping-check-domain-form').submit(function() {
var $self = $(this),
domain = $.trim($self.find('.domainmapping-input-domain').val()),
Expand Down

0 comments on commit 09bed79

Please sign in to comment.