-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from AdTechMedia/dev
Add localization and multiple currencies per countries
- Loading branch information
Showing
12 changed files
with
141 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,13 @@ public function api_to_plugin_options() { | |
$this->update_from_api_option( 'price_currency', $api_result['Config']['defaults']['payment']['currency'] ); | ||
$this->update_from_api_option( 'content_paywall', $pleded_types[ $api_result['Config']['defaults']['payment']['pledgedType'] ] ); | ||
$this->update_from_api_option( 'content_offset_type', $api_result['Config']['defaults']['content']['offsetType'] ); | ||
|
||
$plugin_dir = plugin_dir_path( __FILE__ ); | ||
$file = $plugin_dir . '/js/atm.min.js'; | ||
// @codingStandardsIgnoreStart | ||
@unlink( $file ); | ||
// @codingStandardsIgnoreEnd | ||
|
||
} | ||
} | ||
|
||
|
@@ -261,14 +268,6 @@ public function add_actions_and_filters() { | |
|
||
$property_check = $this->check_prop(); | ||
|
||
if ( ! $key_check ) { | ||
add_action( 'admin_notices', | ||
array( | ||
&$this, | ||
'key_not_exists_error', | ||
) | ||
); | ||
} | ||
if ( ! $property_check ) { | ||
add_action( 'admin_notices', | ||
array( | ||
|
@@ -340,17 +339,6 @@ public function add_actions_and_filters() { | |
); | ||
} | ||
|
||
/** | ||
* Call function update_appearance after activation | ||
*/ | ||
public function one_update_appearance() { | ||
if ( ! empty( $this->get_plugin_option( 'key' ) ) ) { | ||
$this->update_appearance(); | ||
$this->add_plugin_option( 'updated_appearance', 1 ); | ||
} | ||
wp_die(); | ||
} | ||
|
||
/** | ||
* The first init function Adtechmedia_AB | ||
*/ | ||
|
@@ -461,10 +449,6 @@ public function ajax_save_template() { | |
if ( isset( $_POST['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'adtechmedia-nonce' ) ) { | ||
// @codingStandardsIgnoreStart | ||
if ( isset( $_POST['revenueMethod'], $_POST['country'] ) ) { | ||
$plugin_dir = plugin_dir_path( __FILE__ ); | ||
$file = $plugin_dir . '/js/atm.min.js'; | ||
@unlink( $file ); | ||
|
||
$revenue_method = sanitize_text_field( wp_unslash( $_POST['revenueMethod'] ) ); | ||
$this->update_plugin_option( 'revenue_method', $revenue_method ); | ||
|
||
|
@@ -474,20 +458,24 @@ public function ajax_save_template() { | |
$country = sanitize_text_field( wp_unslash( $_POST['country'] ) ); | ||
$this->update_plugin_option( 'country', $country ); | ||
|
||
Adtechmedia_Request::property_update_config_by_array( | ||
$this->get_plugin_option( 'id' ), | ||
$this->get_plugin_option( 'key' ), | ||
[ | ||
'revenueMethod' => $revenue_method, | ||
] | ||
); | ||
$currency = sanitize_text_field( wp_unslash( $_POST['currency'] ) ); | ||
$this->update_plugin_option( 'price_currency', $currency ); | ||
|
||
// Adtechmedia_Request::property_update_config_by_array( | ||
// $this->get_plugin_option( 'id' ), | ||
// $this->get_plugin_option( 'key' ), | ||
// [ | ||
// 'revenueMethod' => $revenue_method, | ||
// ] | ||
// ); | ||
Adtechmedia_Request::property_update( | ||
$this->get_plugin_option( 'id' ), | ||
$this->get_plugin_option( 'support_email' ), | ||
$this->country_full_to_UN( $country ), | ||
$this->get_plugin_option( 'key' ) | ||
); | ||
Adtechmedia_ContentManager::clear_all_content(); | ||
$this->update_prop(); | ||
// Adtechmedia_ContentManager::clear_all_content(); | ||
} else if ( isset( $_POST['contentConfig'] ) ) { | ||
$content_config = json_decode( wp_unslash( $_POST['contentConfig'] ), true ); | ||
foreach ( $content_config as $a_option_key => $a_option_meta ) { | ||
|
@@ -503,7 +491,18 @@ public function ajax_save_template() { | |
// @codingStandardsIgnoreEnd | ||
echo 'ok'; | ||
} | ||
die(); | ||
wp_die(); | ||
} | ||
|
||
/** | ||
* Call function update_appearance after activation | ||
*/ | ||
public function one_update_appearance() { | ||
if ( ! empty( $this->get_plugin_option( 'key' ) ) ) { | ||
$this->update_appearance(); | ||
$this->add_plugin_option( 'updated_appearance', 1 ); | ||
} | ||
wp_die(); | ||
} | ||
|
||
/** | ||
|
@@ -726,6 +725,15 @@ public function content_wrapper( $content ) { | |
$content_id = (string) get_the_ID(); | ||
$author_name = get_the_author(); | ||
$author_avatar = get_avatar_url( get_the_author_meta( 'user_email' ) ); | ||
$country = $this->get_plugin_option( 'country' ); | ||
$locale = null; | ||
switch ( $country ) { | ||
case 'Romania': | ||
$locale = 'ro'; | ||
break; | ||
default: | ||
$locale = 'en'; | ||
} | ||
$script = "<script> | ||
window.ATM_FORCE_NOT_LOCALHOST = true; | ||
window.ATM_PROPERTY_ID = '$property_id'; | ||
|
@@ -734,6 +742,7 @@ public function content_wrapper( $content ) { | |
window.WP_ATM_AUTHOR_NAME = '$author_name'; | ||
window.WP_ATM_AUTHOR_AVATAR = '$author_avatar'; | ||
window.ATM_SERVICE_WORKER = '/sw.min.js'; | ||
window.ATM_LOCALE = '$locale'; | ||
</script>"; | ||
|
||
return "<span id='content-for-atm-modal'> </span><span id='content-for-atm'>$content</span>" . $script; | ||
|
@@ -754,18 +763,4 @@ public function property_id_not_exists_error() { | |
// @codingStandardsIgnoreEnd | ||
} | ||
|
||
/** | ||
* Show error if API key not exists | ||
*/ | ||
public function key_not_exists_error() { | ||
// @codingStandardsIgnoreStart | ||
?> | ||
<div class="error notice"> | ||
<p><?php echo $this->key_error ?: __( 'An error occurred. API key has not been created, please reload the page or contact support service at <a href="mailto:[email protected]">[email protected]</a>.', | ||
'adtechmedia-plugin' | ||
); ?></p> | ||
</div> | ||
<?php | ||
// @codingStandardsIgnoreEnd | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/** | ||
* Plugin Name: AdTechMedia | ||
* Plugin URI: https://wordpress.org/plugins/adtechmedia/ | ||
* Version: 0.10.8 | ||
* Version: 0.12.0 | ||
* Author: AdTechMedia.io | ||
* Description: AdTechMedia is an advertising platform with micropayments capabilities for media content monetization. We help publishers and content providers to generate complimentary revenue streams that are immune to ad blocking software (e.g. native advertising or native micropayments). Our solutions are white labeled, data driven and realtime. To learn more, contact [email protected] or visit www.adtechmedia.io. | ||
* Text Domain: adtechmedia | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.