Skip to content

Commit

Permalink
v1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
coax committed Aug 9, 2024
1 parent 928291f commit afcbcb0
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 18 deletions.
114 changes: 103 additions & 11 deletions solo-for-woocommerce/lib/solo-woocommerce-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Solo for WooCommerce
* Plugin URI: https://solo.com.hr/api-dokumentacija/dodaci
* Description: Narudžba u tvojoj WooCommerce trgovini će automatski kreirati račun ili ponudu u servisu Solo.
* Version: 1.3
* Version: 1.4
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Solo
Expand Down Expand Up @@ -36,13 +36,16 @@
$url = $decoded_json[0]['assets'][0]['browser_download_url'];
}
// Create temporary transients (instead session)
set_transient('solo_tag', $tag, 60*60*12);
set_transient('solo_url', $url, 60*60*12);
set_transient('solo_tag', $tag, 60*60*24);
set_transient('solo_url', $url, 60*60*24);
}

if ($installed<>$tag) {
$version1 = ltrim($installed, 'v');
$version2 = ltrim($tag, 'v');

if (version_compare($version1, $version2, '<')) {
?>
<div class="notice notice-warning is-dismissible"><p><?php echo __('Dostupna je nova verzija dodatka', 'solo-for-woocommerce'); ?>: <a href="https://github.com/coax/solo-for-woocommerce/releases" target="_blank">Solo for WooCommerce <?php echo $tag; ?></a></p><p><a href="<?php echo $url; ?>" class="button-secondary"><?php echo __('Preuzmi novu verziju', 'solo-for-woocommerce'); ?></a></p></div>
<div class="notice notice-info notice-alt"><p><?php echo __('Dostupna je nova verzija dodatka', 'solo-for-woocommerce'); ?>: <a href="https://github.com/coax/solo-for-woocommerce/releases" target="_blank">Solo for WooCommerce <?php echo $tag; ?></a></p><p><a href="<?php echo $url; ?>" class="button button-small button-primary"><?php echo __('Preuzmi novu verziju', 'solo-for-woocommerce'); ?></a></p></div>
<?php
}
}
Expand Down Expand Up @@ -89,6 +92,9 @@
switch($tab):
default:
?>
<input type="hidden" name="solo_woocommerce_postavke[prikazi_porez]" value="<?php echo $prikazi_porez ?>">
<input type="hidden" name="solo_woocommerce_postavke[tip_racuna]" value="<?php echo $tip_racuna ?>">
<input type="hidden" name="solo_woocommerce_postavke[posalji]" value="<?php echo $posalji ?>">
<table class="form-table">
<tbody>
<tr>
Expand Down Expand Up @@ -281,7 +287,8 @@
}
}
?>
<br><div class="notice notice-info inline">
<br>
<div class="notice notice-info inline">
<p><?php echo __('Akcija <b>"primiš narudžbu (bez uplate)"</b> se izvršava čim kupac napravi narudžbu neovisno o tipu plaćanja. Takve narudžbe će imati status <span class="status processing">Processing / U obradi</span> ili <span class="status on-hold">On hold / Na čekanju</span> u WooCommerce popisu narudžbi.', 'solo-for-woocommerce'); ?></p>
<p><?php echo __('Akcija <b>"kupac uplati"</b> se izvršava kada narudžbu obilježiš kao <span class="status completed">Completed / Završeno</span> u WooCommerce popisu narudžbi ili kada naplata karticom bude uspješna (trebalo bi automatski promijeniti status).', 'solo-for-woocommerce'); ?></p>
</div>
Expand All @@ -296,10 +303,18 @@
break;

case 'email':

// Cron check
if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
?>
<br>
<div class="notice notice-error inline"><p><?php echo __('Za automatsko slanje računa ili ponude na e-mail, potrebno je izbrisati <code>define(\'DISABLE_WP_CRON\', true);</code> iz <i>wp-config.php</i> datoteke.', 'solo-for-woocommerce'); ?></p></div>
<?php
} else {
?>
<p><?php echo __('Za automatsko slanje mailova trebaš imati namještene SMTP postavke, bilo ručno ili putem jednog od besplatnih WordPress dodataka za slanje (npr. <a href="https://wordpress.org/plugins/smtp-mailer/" target="_blank">SMTP Mailer</a>).', 'solo-for-woocommerce'); ?></p>
<input type="hidden" name="solo_woocommerce_postavke[prikazi_porez]" value="<?php echo $prikazi_porez ?>">
<input type="hidden" name="solo_woocommerce_postavke[tip_racuna]" value="<?php echo $tip_racuna ?>">
<br><div class="notice notice-info inline"><p><?php echo __('Za automatsko slanje mailova trebaš imati namještene SMTP postavke, bilo ručno ili putem jednog od besplatnih WordPress dodataka za slanje (npr. <a href="https://wordpress.org/plugins/wp-mail-smtp/" target="_blank">WP Mail SMTP</a>).', 'solo-for-woocommerce'); ?></p></div>
<table class="form-table">
<tbody>
<tr>
Expand All @@ -319,14 +334,16 @@
<tr>
<th><label for="poruka"><?php echo __('Sadržaj poruke', 'solo-for-woocommerce'); ?><sup class="tooltip" title="<?php echo __('Upiši sadržaj e-mail poruke koju će kupac dobiti.<br>HTML formatiranje nije podržano.', 'solo-for-woocommerce'); ?>"></sup></label></th>
<td>
<textarea name="solo_woocommerce_postavke[poruka]" id="poruka" rows="12" class="large-text"><?php echo $poruka; ?></textarea>
<textarea name="solo_woocommerce_postavke[poruka]" id="poruka" rows="8" class="large-text"><?php echo $poruka; ?></textarea>
<p class="description">*<?php echo __('PDF kopija dokumenta će automatski biti u privitku', 'solo-for-woocommerce'); ?></p>
</td>
</tr>
</tbody>
</table>
<?php submit_button(__('Spremi promjene', 'solo-for-woocommerce')); ?>
<?php
}

break;

case 'tecaj':
Expand Down Expand Up @@ -354,7 +371,7 @@
if (array_filter($results)) {
?>
<p><?php echo __('Prikazane su sve narudžbe koje je WooCommerce poslao u servis Solo. Imaj na umu da WooCommerce šalje samo narudžbe za koje je u <a href="?page=solo-woocommerce&tab=akcije">"Načini plaćanja i akcije"</a> omogućeno kreiranje dokumenta.', 'solo-for-woocommerce'); ?></p>
<table class="widefat striped" id="arhiva">
<table class="widefat fixed striped" id="arhiva">
<colgroup>
<col style="width:9%;">
<col style="width:29%;">
Expand All @@ -365,7 +382,7 @@
</colgroup>
<thead>
<tr>
<th data-sort="int"><?php echo __('Broj narudžbe', 'solo-for-woocommerce'); ?></th>
<th data-sort="int"><?php echo __('Narudžba', 'solo-for-woocommerce'); ?></th>
<th data-sort="string"><?php echo __('API zahtjev', 'solo-for-woocommerce'); ?></th>
<th data-sort="string"><?php echo __('API odgovor', 'solo-for-woocommerce'); ?></th>
<th data-sort="string"><?php echo __('Datum zahtjeva', 'solo-for-woocommerce'); ?></th>
Expand Down Expand Up @@ -448,8 +465,83 @@ function timeago($datetime) {

case 'podrska':
?>
<br><div class="notice notice-info inline"><p><?php echo __('Tehnička podrška za ovaj dodatak nalazi se na <a href="https://github.com/coax/solo-for-woocommerce#podrška" target="_blank">GitHub stranicama</a>.', 'solo-for-woocommerce'); ?></p><p><?php echo __('Imaš instaliranu verziju', 'solo-for-woocommerce'); ?> <?php echo SOLO_VERSION; ?>.</p></div>
<p><?php echo __('Tehnička podrška za ovaj dodatak nalazi se na <a href="https://github.com/coax/solo-for-woocommerce#podrška" target="_blank">GitHub stranicama</a>.', 'solo-for-woocommerce'); ?></p>
<p><?php echo __('Imaš instaliranu verziju', 'solo-for-woocommerce'); ?> <b><?php echo SOLO_VERSION; ?></b></p>
<?php
// Path to wp-config.php
$wp_config_file = ABSPATH . 'wp-config.php';

// Read wp-config.php file contents
$config_contents = file_get_contents($wp_config_file);

// Check if both WP_DEBUG and WP_DEBUG_LOG are enabled
$is_wp_debug_enabled = strpos($config_contents, "define( 'WP_DEBUG', true );") !== false;
$is_wp_debug_log_enabled = strpos($config_contents, "define( 'WP_DEBUG_LOG', true );") !== false;

// Path to debug.log
$log_file = WP_CONTENT_DIR . '/debug.log';

// Logging disabled
if (!$is_wp_debug_enabled || !$is_wp_debug_log_enabled) {
?>
<div class="notice notice-info inline">
<p><?php echo __('Ako imaš problema s dodatkom, omogući <i>debugiranje</i> u WordPressu za dobivanje informacija o tome gdje i kako dolazi do greške. U <i>wp-config.php</i> datoteku dodaj ove linije:<br><code>define(\'WP_DEBUG\', true);</code><br><code>define(\'WP_DEBUG_LOG\', true);</code><br><code>define(\'WP_DEBUG_DISPLAY\', false);</code>', 'solo-for-woocommerce'); ?></p>
</div>
<?php
} else {
if (file_exists($log_file)) {
$filtered_lines = array();

// Parse log
$file_handle = fopen($log_file, 'r');
if ($file_handle) {
while (($line = fgets($file_handle)) !== false) {
// Check if line starts with a date and time (format: [YYYY-MM-DD HH:MM:SS])
if (preg_match('/^\[\d{2}-\w{3}-\d{4}(?: \d{2}:\d{2}:\d{2})?/', $line, $matches)) {
if (strpos($line, $this->plugin_name) !== false) {
$filtered_lines[] = $line;
}
}
}
fclose($file_handle);
}

// Display filtered lines
if (!empty($filtered_lines)) {
?>
<p><?php echo __('Greške iz <a href="' . esc_url(content_url('debug.log')) . '" target="_blank">debug.log</a> datoteke:', 'solo-for-woocommerce'); ?></p>
<?php
// Sort descending
rsort($filtered_lines);

// Limit 50 logs
$filtered_lines = array_slice($filtered_lines, 0, 50);

foreach ($filtered_lines as $filtered_line) {
// Extract date and time
preg_match('/\[(.*?)\]/', $filtered_line, $matches);
$date_time = isset($matches[1]) ? $matches[1] : '&ndash;';

// Convert to Y-m-d H:i:s format
try {
$date = new DateTime($date_time);
// Get WordPress timezone
$local_timezone = new DateTimeZone(wp_timezone_string());
$date->setTimezone($local_timezone);
$formatted_date_time = $date->format('Y-m-d H:i:s');
} catch (Exception $e) {
$formatted_date_time = '&ndash;';
}

// Extract error message (everything after date and time)
$error_message = trim(str_replace($matches[0], '', $filtered_line));

echo '<code>[' . esc_html($formatted_date_time) . '] ' . esc_html($error_message) . '</code><br>' . PHP_EOL;
}
}
}
}

break;
endswitch;
?>
Expand Down
6 changes: 4 additions & 2 deletions solo-for-woocommerce/lib/solo-woocommerce.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.form-table th label {position:relative; display:block;}
div.solo-logo {display:inline-block; vertical-align:-50%; margin-right:10px; width:52px; height:52px; background:url(solo-for-woocommerce.png); background-size:cover; border-radius:3px;}
sup.tooltip {/*position:relative; display:inline-block; margin-left:6px;*/ position:absolute; right:0; top:25%; width:13px; height:13px; line-height:12px; vertical-align:0; cursor:help;}
sup.tooltip {position:absolute; right:0; top:25%; width:13px; height:13px; line-height:12px; vertical-align:0; cursor:help;}
sup.tooltip:after {content:'?'; position:absolute; top:0; left:0; width:100%; height:100%; color:#fff; background:#666; border-radius:50%; font-weight:600; text-align:center; font-size:10px;}
.jBox-container {padding:12px; font-size:12px; background:#000; color:#fff; border-radius:4px; max-width:340px; line-height:1.2;}
.spinner {float:none;}
#arhiva tbody tr.shrink p {position:relative; height:75px; overflow:hidden; cursor:pointer;}
table#arhiva thead th {overflow:hidden; text-overflow:ellipsis;}
table#arhiva tbody tr.shrink p {position:relative; height:75px; overflow:hidden; cursor:pointer;}
.fancySearchRow input[type=search] {padding:0 8px;}
span.status {padding:3px 6px; border-radius:4px;}
span.status.processing {background:#c6e1c6; color:#5b841b;}
span.status.on-hold {background:#f8dda7; color:#94660c;}
Expand Down
Loading

0 comments on commit afcbcb0

Please sign in to comment.