Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions assets/src/css/admin-style.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
@forward "../../../vendor/pluginever/framework-plugin/src/assets/css/layout";
@forward "../../../vendor/pluginever/framework-plugin/src/assets/css/card";
@forward "../../../vendor/pluginever/framework-plugin/src/assets/css/form";
// Card style.
.b8-card {
&.promo-panel {
background: #2563eb;

// Card component.
.wcsn-card {
.b8-card__header {
color: #fff;
background: #1048c4;
}

.b8-card__body {
color: #fff;
}

.button {
width: 100%;
display: block;
margin-top: 20px;
color: #1048c4;
font-weight: 700;
text-align: center;
text-transform: uppercase;
}
}
&__body {
ol li, ul li {
margin-bottom: .5em;
line-height: 1.7;
}
}
}

.wcsn-card { // TODO: remove it when the card replaced with the (b8).
margin-top: 20px;
box-sizing: border-box;

Expand Down Expand Up @@ -90,9 +117,6 @@
}
}

// Fix misc styles
// Fixing some styles that are not working properly.

// Margin bottom for tabs otherwise they are too close to the content.
.wcsn-nav-tabs {
margin-bottom: 20px !important;
Expand Down
13 changes: 9 additions & 4 deletions assets/src/js/admin-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@
.on('submit', '.wcsn-api-form', function (e) {
e.preventDefault();
const $form = $(this);
const request = ($form.find(':input[name="request"]').val() || $form.data('request') || '').toString().trim();
if (!request) {
$form.find('.wcsn-api-response').text('Missing request type (validate/activate/deactivate).');
return;
}
$.ajax({
url: wc_serial_numbers_vars.apiurl,
method: 'POST',
url: wc_serial_numbers_vars.apiurl + encodeURIComponent(request),
method: 'GET',
data: $form.serialize(),
dataType: 'json',
beforeSend() {
Expand All @@ -55,10 +60,10 @@
success(response) {
$form.find('.wcsn-api-response').text(JSON.stringify(response, null, 2));
},
error: function (response) {
error(response) {
$form.find('.wcsn-api-response').text(JSON.stringify(response, null, 2));
},
always() {
complete() {
$form.removeClass('loading');
}
});
Expand Down
27 changes: 12 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,29 @@
"repositories": [
{
"type": "vcs",
"url": "git@github.com:pluginever/framework-plugin.git"
"url": "git@github.com:byteever/plugin.git"
},
{
"type": "vcs",
"url": "git@github.com:pluginever/framework-settings.git"
},
{
"type": "vcs",
"url": "git@github.com:pluginever/framework-model.git"
"url": "git@github.com:byteever/models.git"
}
],
"require": {
"php": ">=7.4",
"pluginever/framework-plugin": "dev-trunk",
"pluginever/framework-model": "dev-trunk",
"pluginever/framework-settings": "dev-trunk"
"byteever/plugin": "dev-trunk",
"byteever/models": "dev-trunk"
},
"require-dev": {
"byteever/byteever-sniffs": "^1.1.3"
},
"autoload": {
"psr-4": {
"WooCommerceSerialNumbers\\": ["includes/","src/"]
}
},
"files": [
"src/functions.php",
"src/Deprecated/Functions.php"
]
},
"config": {
"platform": {
Expand All @@ -48,8 +47,7 @@
"strauss": [
"test -f /tmp/strauss.phar || curl -o /tmp/strauss.phar -L https://github.com/BrianHenryIE/strauss/releases/download/0.24.1/strauss.phar",
"@php /tmp/strauss.phar",
"@composer dump-autoload --no-scripts",
"find ./vendor/pluginever -type f -name '*.php' -exec perl -i -pe \"s/'framework-text-domain'/'wc-serial-numbers'/g\" {} +"
"@composer dump-autoload --no-scripts"
]
},
"extra": {
Expand All @@ -58,9 +56,8 @@
"namespace_prefix": "WooCommerceSerialNumbers\\",
"classmap_prefix": "WooCommerceSerialNumbers__",
"packages": [
"pluginever/framework-plugin",
"pluginever/framework-settings",
"pluginever/framework-model"
"byteever/plugin",
"byteever/models"
]
}
}
Expand Down
10 changes: 5 additions & 5 deletions includes/Admin/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function add_order_action( $actions ) {
public function handle_order_action( $order ) {
// Must have manage woocommerce user capability role to access this endpoint.
if ( ! current_user_can( 'manage_woocommerce' ) ) { // phpcs:ignore WordPress.WP.Capabilities.Unknown
WCSN()->add_notice( __( 'You do not have permission to perform this action.', 'wc-serial-numbers' ), 'error' );
WCSN()->flash->error( __( 'You do not have permission to perform this action.', 'wc-serial-numbers' ) );
exit;
}

Expand All @@ -76,11 +76,11 @@ public function handle_order_action( $order ) {
if ( 'wcsn_add_keys' === $action ) {
wcsn_order_update_keys( $order_id );
// add a notice.
WCSN()->add_notice( __( 'Serial keys added successfully to the order.', 'wc-serial-numbers' ) );
WCSN()->flash->success( __( 'Serial keys added successfully to the order.', 'wc-serial-numbers' ) );
} elseif ( 'wcsn_remove_keys' === $action ) {
wcsn_order_remove_keys( $order_id );
// add a notice.
WCSN()->add_notice( __( 'Serial keys removed successfully from the order.', 'wc-serial-numbers' ) );
WCSN()->flash->success( __( 'Serial keys removed successfully from the order.', 'wc-serial-numbers' ) );
}
}

Expand Down Expand Up @@ -205,7 +205,7 @@ public function add_order_bulk_action( $actions ) {
public function handle_order_bulk_action( $redirect_to, $action, $order_ids ) {
// Must have manage woocommerce user capability role to access this endpoint.
if ( ! current_user_can( 'manage_woocommerce' ) ) { // phpcs:ignore WordPress.WP.Capabilities.Unknown
WCSN()->add_notice( __( 'You do not have permission to perform this action.', 'wc-serial-numbers' ), 'error' );
WCSN()->flash->error( __( 'You do not have permission to perform this action.', 'wc-serial-numbers' ) );
return $redirect_to;
}

Expand All @@ -221,7 +221,7 @@ public function handle_order_bulk_action( $redirect_to, $action, $order_ids ) {
}
}
// Translators: %d: number of orders.
WCSN()->add_notice( sprintf( __( '%d orders updated successfully.', 'wc-serial-numbers' ), count( $order_ids ) ) );
WCSN()->flash->success( sprintf( __( '%d orders updated successfully.', 'wc-serial-numbers' ), count( $order_ids ) ) );
$redirect_to = add_query_arg( 'bulk_action', $action, $redirect_to );
}

Expand Down
6 changes: 3 additions & 3 deletions includes/Admin/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static function product_write_panel() {
)
);

if ( ! WCSN()->is_premium_active() ) {
if ( WCSN()->plugin_active( 'wc-serial-numbers-pro' ) ) {
echo wp_kses_post(
sprintf(
'<p class="wc-serial-numbers-upgrade-box">%s <a href="%s" target="_blank" class="button">%s</a></p>',
Expand All @@ -205,7 +205,7 @@ public static function product_write_panel() {
* @since 1.2.0
*/
public static function variable_product_content() {
if ( ! WCSN()->is_premium_active() ) {
if ( WCSN()->plugin_active( 'wc-serial-numbers-pro' ) ) {
echo wp_kses_post(
sprintf(
'<p class="wc-serial-numbers-upgrade-box">%s <a href="%s" target="_blank" class="button">%s</a></p>',
Expand All @@ -228,7 +228,7 @@ public static function product_save_data() {

// Must have manage woocommerce user capability role to save this data.
if ( ! current_user_can( 'manage_woocommerce' ) ) { // phpcs:ignore WordPress.WP.Capabilities.Unknown
WCSN()->add_notice( __( 'You do not have permission to save this data.', 'wc-serial-numbers' ), 'error' );
WCSN()->flash->error( __( 'You do not have permission to save this data.', 'wc-serial-numbers' ) );
return;
}

Expand Down
8 changes: 4 additions & 4 deletions includes/Admin/Requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function handle_edit_key() {

// Must have manage woocommerce user capability role to access this endpoint.
if ( ! current_user_can( 'manage_woocommerce' ) ) { // phpcs:ignore WordPress.WP.Capabilities.Unknown
WCSN()->add_notice( __( 'You do not have permission to perform this action.', 'wc-serial-numbers' ), 'error' );
WCSN()->flash->error( __( 'You do not have permission to perform this action.', 'wc-serial-numbers' ) );
wp_safe_redirect( wp_get_referer() );
exit;
}
Expand Down Expand Up @@ -70,7 +70,7 @@ public static function handle_edit_key() {

$key = Key::insert( $data );
if ( is_wp_error( $key ) ) {
WCSN()->add_notice( $key->get_error_message(), 'error' );
WCSN()->flash->error( $key->get_error_message() );
// Redirect to referrer.
wp_safe_redirect( wp_get_referer() );
exit();
Expand All @@ -82,9 +82,9 @@ public static function handle_edit_key() {
update_post_meta( $product_id, '_is_serial_number', 'yes' );
update_post_meta( $product_id, '_serial_key_source', 'custom_source' );

WCSN()->add_notice( __( 'Key added successfully.', 'wc-serial-numbers' ) );
WCSN()->flash->success( __( 'Key added successfully.', 'wc-serial-numbers' ) );
} else {
WCSN()->add_notice( __( 'Key updated successfully.', 'wc-serial-numbers' ) );
WCSN()->flash->success( __( 'Key updated successfully.', 'wc-serial-numbers' ) );
}

$redirect_to = admin_url( 'admin.php?page=wc-serial-numbers&edit=' . $key->get_id() );
Expand Down
Loading
Loading