Skip to content

Commit

Permalink
Merge pull request #9 from LinkNacional/dev
Browse files Browse the repository at this point in the history
1.0.0 Tweaks for WordPress production launch
  • Loading branch information
emanuellopess authored Jun 1, 2022
2 parents c8c8e29 + 8ff1517 commit 662af9a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
34 changes: 20 additions & 14 deletions admin/class-wc-invoice-payment-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,19 @@ protected function bulk_actions($which = '') {
foreach ($value as $name => $title) {
$class = ('edit' === $name) ? ' class="hide-if-no-js"' : '';

echo "\t\t" . '<option value="' . esc_attr($name) . '"' . $class . '>' . $title . "</option>\n";
echo "\t\t" . '<option value="' . esc_attr($name) . '"' . esc_attr($class) . '>' . esc_html($title) . "</option>\n";
}
echo "\t" . "</optgroup>\n";
} else {
$class = ('edit' === $key) ? ' class="hide-if-no-js"' : '';

echo "\t" . '<option value="' . esc_attr($key) . '"' . $class . '>' . $value . "</option>\n";
echo "\t" . '<option value="' . esc_attr($key) . '"' . esc_attr($class) . '>' . esc_html($value) . "</option>\n";
}
}

echo "</select>\n";

submit_button(__('Apply'), 'action', '', false, ['id' => "doaction$two"]);
submit_button(__('Apply'), 'action', '', false, ['id' => 'doaction' . esc_attr($two)]);
echo "\n";
}

Expand Down Expand Up @@ -636,7 +636,7 @@ protected function view_switcher($current_mode) {
printf(
"<a href='%s' class='%s' id='view-switch-$mode'$aria_current><span class='screen-reader-text'>%s</span></a>\n",
esc_url(remove_query_arg('attachment-filter', add_query_arg('mode', $mode))),
implode(' ', $classes),
esc_attr(implode(' ', $classes)),
$title
);
} ?>
Expand Down Expand Up @@ -1128,8 +1128,8 @@ public function print_column_headers($with_id = true) {

if (!empty($columns['cb'])) {
static $cb_counter = 1;
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __('Select All') . '</label>'
. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . esc_attr($cb_counter) . '">' . __('Select All') . '</label>'
. '<input id="cb-select-all-' . esc_attr($cb_counter) . '" type="checkbox" />';
$cb_counter++;
}

Expand Down Expand Up @@ -1172,18 +1172,19 @@ public function print_column_headers($with_id = true) {
$column_display_name = sprintf(
'<a href="%s"><span>%s</span><span class="sorting-indicator"></span></a>',
esc_url(add_query_arg(compact('orderby', 'order'), $current_url)),
$column_display_name
esc_attr($column_display_name)
);
}

$tag = ('cb' === $column_key) ? 'td' : 'th';
$scope = ('th' === $tag) ? 'scope="col"' : '';
$id = $with_id ? "id='$column_key'" : '';
$id = $with_id ? "id='" . esc_attr($column_key) . "'" : '';

if (!empty($class)) {
$class = "class='" . implode(' ', $class) . "'";
$class = "class='" . esc_attr(implode(' ', $class)) . "'";
}

// All attributes are previously escaped
echo "<$tag $scope $id $class>$column_display_name</$tag>";
}
}
Expand All @@ -1199,7 +1200,7 @@ public function display() {
$this->display_tablenav('top');

$this->screen->render_screen_reader_content('heading_list'); ?>
<table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>">
<table class="wp-list-table <?php esc_attr_e(implode(' ', $this->get_table_classes())); ?>">
<thead>
<tr>
<?php $this->print_column_headers(); ?>
Expand All @@ -1209,7 +1210,7 @@ public function display() {
<tbody id="the-list"
<?php
if ($singular) {
echo " data-wp-lists='list:$singular'";
echo " data-wp-lists='list:" . esc_attr($singular) . "'";
} ?>
>
<?php $this->display_rows_or_placeholder(); ?>
Expand Down Expand Up @@ -1460,11 +1461,16 @@ public function handle_row_actions($item, $column_name, $primary) {
if ($primary !== $column_name) {
return '';
}
$invoiceId = $item['lkn_wcip_id'];

$editUrl = home_url('wp-admin/admin.php?page=edit-invoice&invoice=' . $item['lkn_wcip_id']);
$order = wc_get_order($invoiceId);

$editUrl = home_url('wp-admin/admin.php?page=edit-invoice&invoice=' . $invoiceId);
$paymentUrl = $order->get_checkout_payment_url();

$action = [];
$action['edit'] = '<a href="' . $editUrl . '">' . __('Edit') . '</a>';
$action['payment'] = '<a href="' . $paymentUrl . '" target="_blank">' . __('Payment link', 'wc-invoice-payment') . '</a>';
// $action['delete'] = '<a href="">' . __('Delete') . '</a>';

return $this->row_actions($action);
Expand Down Expand Up @@ -1551,7 +1557,7 @@ public function column_default($item, $column_name) {
* @return string
*/
public function column_cb($items) {
$top_checkbox = '<input type="checkbox" name="invoices[]" class="lkn-wcip-selected" value="' . $items['lkn_wcip_id'] . '" />';
$top_checkbox = '<input type="checkbox" name="invoices[]" class="lkn-wcip-selected" value="' . esc_attr($items['lkn_wcip_id']) . '" />';

return $top_checkbox;
}
Expand Down Expand Up @@ -1593,7 +1599,7 @@ public function proccess_bulk_action() {
}
update_option('lkn_wcip_invoices', $invoices);

wp_redirect($_SERVER['HTTP_REFERER']);
wp_redirect(sanitize_url($_SERVER['HTTP_REFERER']));
}
}
}
Binary file modified languages/wc-invoice-payment-pt_BR.mo
Binary file not shown.
5 changes: 4 additions & 1 deletion languages/wc-invoice-payment-pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@ msgid "Install WooCommerce"
msgstr "Instalar WooCommerce"

msgid "Invoice payment link"
msgstr "Link de pagamento da fatura"
msgstr "Link de pagamento da fatura"

msgid "Payment link"
msgstr "Link de pagamento"
3 changes: 3 additions & 0 deletions languages/wc-invoice-payment.pot
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@ msgid "Install WooCommerce"
msgstr ""

msgid "Invoice payment link"
msgstr ""

msgid "Payment link"
msgstr ""

0 comments on commit 662af9a

Please sign in to comment.