Skip to content

Commit

Permalink
Merge pull request #19 from hxii/patch-1
Browse files Browse the repository at this point in the history
1.1.8 prep
  • Loading branch information
DanGlz authored Oct 11, 2018
2 parents 06df9cd + b02a1bb commit d2879c3
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 121 deletions.
15 changes: 14 additions & 1 deletion woocommerce-yotpo/assets/css/bottom-line.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,17 @@ li.product a img.yoStar, .woocommerce-page ul.products li.product a img.yoStar {
}
.yotpo {
margin-bottom:.5rem;
}
}

.QABottomLine, .bottomLine {
display: inline-block;
}

.bottomLine + .QABottomLine {
margin-left: 0.5em;
margin-bottom: 0.615em;
}

.yotpo-icon-double-bubble, .yotpo-stars {
margin: 0 5px 0 0 !important;
}
3 changes: 2 additions & 1 deletion woocommerce-yotpo/assets/js/headerScript.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 34 additions & 20 deletions woocommerce-yotpo/templates/wc-yotpo-settings.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

define("LOG_FILE", plugin_dir_path( __FILE__ ).'../yotpo_debug.log');
function wc_display_yotpo_admin_page() {

if (function_exists('current_user_can') && !current_user_can('manage_options')) {
die(__(''));
}
Expand All @@ -23,6 +22,11 @@ function wc_display_yotpo_admin_page() {
} elseif (isset($_POST['yotpo_past_orders'])) {
wc_yotpo_send_past_orders();
wc_display_yotpo_settings();
} elseif (isset($_POST['yotdbg-clear'])) {
check_admin_referer('yotdbg-clear');
$filename = LOG_FILE;
file_put_contents($filename, "");
wc_display_yotpo_settings();
} else {
$yotpo_settings = get_option('yotpo_settings', wc_yotpo_get_degault_settings());
if (empty($yotpo_settings['app_key']) && empty($yotpo_settings['secret'])) {
Expand All @@ -40,14 +44,12 @@ function wc_display_yotpo_admin_page() {
}
}
}

function wc_display_yotpo_settings($success_type = false) {
$yotpo_settings = get_option('yotpo_settings', wc_yotpo_get_degault_settings());
$app_key = $yotpo_settings['app_key'];
$secret = $yotpo_settings['secret'];
$language_code = $yotpo_settings['language_code'];
$widget_tab_name = $yotpo_settings['widget_tab_name'];

if (empty($yotpo_settings['app_key'])) {
if ($success_type == 'b2c') {
wc_yotpo_display_message('We have sent you a confirmation email. Please check and click on the link to get your app key and secret token to fill out below.', true);
Expand All @@ -66,15 +68,20 @@ function wc_display_yotpo_settings($success_type = false) {
<th scope='row'><p class='description'>To get your api key and secret token <a href='https://www.yotpo.com/?login=true' target='_blank'>log in here</a> and go to your account settings.</p></th>
</tr>" : '';
$submit_past_orders_button = $yotpo_settings['show_submit_past_orders'] ? "<input type='submit' name='yotpo_past_orders' value='Submit past orders' class='button-secondary past-orders-btn' " . disabled(true, empty($app_key) || empty($secret), false) . ">" : '';

$settings_html = "<div class='wrap'>"
. screen_icon() .
"<h2>Yotpo Settings</h2>
if (isset($yotpo_settings['debug_mode']) && $yotpo_settings['debug_mode']) {
$settings_dump = json_encode($yotpo_settings);
if (file_exists(LOG_FILE)) { $debug_log = file_get_contents(LOG_FILE); } else { $debug_log = false; };
}
$settings_html = "<div class='wrap'><h2>Yotpo Settings</h2>
<h4>To customize the look and feel of the widget, and to edit your Mail After Purchase settings, just head to the " . $dashboard_link . "</h4>
<form method='post' id='yotpo_settings_form'>
<table class='form-table'>" .
wp_nonce_field('yotpo_settings_form') .
"<fieldset>
<tr id='yotpodbg' valign='top' style='background: #e09999; display: none;'><th scope='row'>Enable debug mode</th>
<td><input type='checkbox' name='debug_mode' value='1' " . checked(1, $yotpo_settings['debug_mode'], false) . " /></td>
<td><p class='description'>Enabling debug mode will output all plugin actions into <i>yotpo_debug.log</i>, output the log here and show all the settings.</p></td>
</tr>
<tr valign='top'>
<th scope='row'><div>If you would like to choose a set language, please type the 2-letter language code here. You can find the supported langauge codes <a class='y-href' href='http://support.yotpo.com/entries/21861473-Languages-Customization-' target='_blank'>here.</a></div></th>
<td><div><input type='text' class='yotpo_language_code_text' name='yotpo_widget_language_code' maxlength='5' value='$language_code'/></div></td>
Expand Down Expand Up @@ -112,15 +119,17 @@ function wc_display_yotpo_settings($success_type = false) {
<tr valign='top'>
<th scope='row'><div>Secret token:</div></th>
<td><div class='y-input'><input id='secret' type='text' name='yotpo_oauth_token' value='$secret' $read_only '/></div></td>
</tr>
<tr valign='top'>
<th scope='row'><p class='description'>Yotpo's Bottom Line shows the star rating of the product and the number of reviews for the product. <a href='http://support.yotpo.com/entries/24467793-What-is-the-Yotpo-Bottomline-' target='_blank'>learn more.</a></p></th>
</tr>
<tr valign='top'>
<th scope='row'><div>Enable bottom line in product page:</div></th>
<td><input type='checkbox' name='yotpo_bottom_line_enabled_product' value='1' " . checked(1, $yotpo_settings['bottom_line_enabled_product'], false) . " /></td>
</tr>
<tr valign='top'>
<th scope='row'><div>Enable Q&A bottom line in product page:</div></th>
<td><input type='checkbox' name='yotpo_qna_enabled_product' value='1' " . checked(1, $yotpo_settings['qna_enabled_product'], false) . " />
</td>
</tr>
<tr valign='top'>
<th scope='row'><div>Enable bottom line in category page:</div></th>
<td><input type='checkbox' name='yotpo_bottom_line_enabled_category' value='1' " . checked(1, $yotpo_settings['bottom_line_enabled_category'], false) . " />
</td>
Expand Down Expand Up @@ -155,9 +164,17 @@ function wc_display_yotpo_settings($success_type = false) {
</form>
</div>";
echo $settings_html;
if (isset($yotpo_settings['debug_mode']) && $yotpo_settings['debug_mode']) {
echo '<h3>Settings</h3><pre>'.$settings_dump.'</pre>';
if ($debug_log === FALSE) {
echo '<h3>Yotpo Debug</h3>
<textarea cols=170 rows=15>Problem opening yotpo_debug.log and/or file is empty</textarea>';
} else {
echo '<h3>Yotpo Debug</h3><textarea cols=170 rows=15>'.$debug_log.'</textarea>
<form method="post" id="yotdbg-clear">' .wp_nonce_field('yotdbg-clear') .'<input type="submit" value="Clear" class="button-primary" name="yotdbg-clear" id="yotdbg-clear-submit"/></form>';
}
}
}


function wc_proccess_yotpo_settings() {
$current_settings = get_option('yotpo_settings', wc_yotpo_get_degault_settings());
$new_settings = array('app_key' => $_POST['yotpo_app_key'],
Expand All @@ -166,11 +183,13 @@ function wc_proccess_yotpo_settings() {
'language_code' => $_POST['yotpo_widget_language_code'],
'widget_tab_name' => $_POST['yotpo_widget_tab_name'],
'bottom_line_enabled_product' => isset($_POST['yotpo_bottom_line_enabled_product']) ? true : false,
'qna_enabled_product' => isset($_POST['yotpo_qna_enabled_product']) ? true : false,
'bottom_line_enabled_category' => isset($_POST['yotpo_bottom_line_enabled_category']) ? true : false,
'yotpo_order_status' => $_POST['yotpo_order_status'],
'yotpo_language_as_site' => isset($_POST['yotpo_language_as_site']) ? true : false,
'disable_native_review_system' => isset($_POST['disable_native_review_system']) ? true : false,
'show_submit_past_orders' => $current_settings['show_submit_past_orders']);
'show_submit_past_orders' => $current_settings['show_submit_past_orders'],
'debug_mode' => isset($_POST['debug_mode']) ? true : false);
update_option('yotpo_settings', $new_settings);
if ($current_settings['disable_native_review_system'] != $new_settings['disable_native_review_system']) {
if ($new_settings['disable_native_review_system'] == false) {
Expand All @@ -180,13 +199,10 @@ function wc_proccess_yotpo_settings() {
}
}
}

function wc_display_yotpo_register() {
$email = isset($_POST['yotpo_user_email']) ? $_POST['yotpo_user_email'] : '';
$user_name = isset($_POST['yotpo_user_name']) ? $_POST['yotpo_user_name'] : '';
$register_html = "<div class='wrap'>"
. screen_icon() .
"<h2>Yotpo Registration</h2>
$register_html = "<div class='wrap'><h2>Yotpo Registration</h2>
<form method='post'>
<table class='form-table'>"
. wp_nonce_field('yotpo_registration_form') .
Expand Down Expand Up @@ -222,7 +238,6 @@ function wc_display_yotpo_register() {
</div>";
echo $register_html;
}

function wc_proccess_yotpo_register() {
$errors = array();
if ($_POST['yotpo_user_email'] === '') {
Expand Down Expand Up @@ -299,7 +314,6 @@ function wc_proccess_yotpo_register() {
}
return false;
}

function wc_yotpo_display_message($messages = array(), $is_error = false) {
$class = $is_error ? 'error' : 'updated fade';
if (is_array($messages)) {
Expand Down
Loading

0 comments on commit d2879c3

Please sign in to comment.