Skip to content

Commit 0f31e4d

Browse files
authored
Bug Fixes
1 parent b5cb619 commit 0f31e4d

11 files changed

Lines changed: 50 additions & 38 deletions

.github/ISSUE_TEMPLATE/compatibility-test-failure.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ This issue has been automatically created because the WooCommerce Free Gift Bulk
3636
4. **Plugin Check**: Run WordPress Plugin Check locally against this environment
3737
5. **Update Code**: Make necessary updates to ensure compatibility across supported versions
3838

39-
#### Testing Commands:
39+
#### Testing Commands
40+
4041
```bash
4142
# Test with specific versions using Docker
4243
docker run --rm -v $(pwd):/app wordpress:{{ env.WP_VERSION }}-php{{ env.PHP_VERSION }}-apache

.github/ISSUE_TEMPLATE/phpcs-failure.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ This issue has been automatically created because the WooCommerce Free Gift Bulk
4646
4. **Manual Fix**: Address security and logic issues manually
4747
5. **Validate**: Re-run PHPCS to confirm all issues are resolved
4848

49-
#### Local Testing Commands:
49+
#### Local Testing Commands
50+
5051
```bash
5152
# Install dependencies
5253
composer install

.github/ISSUE_TEMPLATE/phpmd-failure.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ This project uses a WordPress-specific PHPMD configuration (`phpmd.xml`) that su
5858
5. **Improve Naming**: Use consistent and descriptive naming
5959
6. **Validate**: Re-run PHPMD to confirm improvements
6060

61-
#### Local Testing Commands:
61+
#### Local Testing Commands
62+
6263
```bash
6364
# Install dependencies
6465
composer install
@@ -76,7 +77,8 @@ composer install
7677
./vendor/bin/phpmd free-gift-bulk-coupon-generator.php text codesize --minimumpriority 1
7778
```
7879

79-
#### Example Fixes:
80+
#### Example Fixes
81+
8082
```php
8183
// Before: High complexity
8284
function complex_function($a, $b, $c, $d, $e) {

.github/ISSUE_TEMPLATE/phpstan-failure.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ assignees: []
1313
**Date:** {{ date | date('YYYY-MM-DD') }}
1414

1515
### Description
16+
1617
The PHPStan for WordPress static analysis check has failed during the automated testing process.
1718

1819
### What happened?
20+
1921
PHPStan for WordPress detected potential code issues during static analysis. This could indicate:
2022

2123
- Type safety issues specific to WordPress APIs

.github/ISSUE_TEMPLATE/plugin-check-failure.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ The WordPress Plugin Check action has identified issues with the WooCommerce Fre
2020

2121
This issue has been automatically created because the WordPress Plugin Check found issues with the plugin that should be addressed. The check performed the following specific tests:
2222

23-
#### Categories:
23+
#### Categories
2424

2525
- **Accessibility**: Checks for accessibility compliance issues
2626
- **General**: General WordPress coding standards and best practices
2727
- **Performance**: Tests that identify performance bottlenecks
2828
- **Plugin Repo**: Requirements for WordPress.org plugin repository
2929
- **Security**: Security-focused checks to identify vulnerabilities
3030

31-
#### Specific Checks:
31+
#### Specific Checks
3232

3333
- **i18n_usage**: Proper internationalization usage
3434
- **code_obfuscation**: Detecting potentially obfuscated code
@@ -47,7 +47,7 @@ This issue has been automatically created because the WordPress Plugin Check fou
4747
- **plugin_updater**: Checking plugin update mechanisms
4848
- **trademarks**: Checking for potential trademark violations
4949

50-
#### Recommended Actions:
50+
#### Recommended Actions
5151

5252
1. Review the workflow logs for specific error messages and warnings
5353
2. Address each identified issue in the plugin code

.github/ISSUE_TEMPLATE/wp-dependencies-failure.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ assignees: []
1313
**Date:** {{ date | date('YYYY-MM-DD') }}
1414

1515
### Description
16+
1617
The WordPress dependencies monitoring check has failed during the automated testing process.
1718

1819
### What happened?
20+
1921
The WordPress dependencies monitoring action detected issues with dependencies. This could indicate:
2022

2123
- Outdated WordPress core dependencies

.github/workflows/wp-compatibility-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,8 @@ jobs:
798798
class Test_Free_Gift_Bulk_Coupon_Generator extends WP_UnitTestCase {
799799
public function test_plugin_loaded() {
800800
// Test the helper function exists and returns true
801-
$this->assertTrue(function_exists('free_gift_coupons_bulk_coupons_is_loaded'), 'Plugin helper function should exist');
802-
$this->assertTrue(free_gift_coupons_bulk_coupons_is_loaded(), 'Plugin class should be loaded');
801+
$this->assertTrue(function_exists('fgcbg_is_loaded'), 'Plugin helper function should exist');
802+
$this->assertTrue(fgcbg_is_loaded(), 'Plugin class should be loaded');
803803
}
804804
805805
public function test_plugin_class_exists() {

GEMINI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ languages/
4545
### Plugin Initialization
4646

4747
```php
48-
function free_gift_coupons_bulk_coupons_init() {
48+
function fgcbg_init() {
4949
FGCBG_Plugin::get_instance();
5050
}
51-
add_action( 'plugins_loaded', 'free_gift_coupons_bulk_coupons_init' );
51+
add_action( 'plugins_loaded', 'fgcbg_init' );
5252
```
5353

5454
## WordPress Coding Standards

assets/js/admin.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@
4444
} ).text( text );
4545
}
4646

47+
/**
48+
* Insert a notice element before the form and scroll it into view.
49+
*
50+
* @param {jQuery} $el - The notice element to insert.
51+
*/
52+
function insertNoticeBeforeForm( $el ) {
53+
$el.insertBefore( $( '.scg-form' ) );
54+
55+
const offset = $el.offset();
56+
if ( offset?.top ) {
57+
$( 'html, body' ).animate( { scrollTop: Math.max( 0, offset.top - 50 ) }, 300 );
58+
}
59+
}
60+
4761
/**
4862
* Send a single batch AJAX request and return the jQuery promise.
4963
*
@@ -335,12 +349,7 @@
335349

336350
const $el = createElement( 'div', { class: 'notice notice-error scg-error-message' } );
337351
$el.append( createElement( 'p' ).text( message ) );
338-
$el.insertBefore( $( '.scg-form' ) );
339-
340-
const offset = $el.offset();
341-
if ( offset?.top ) {
342-
$( 'html, body' ).animate( { scrollTop: Math.max( 0, offset.top - 50 ) }, 300 );
343-
}
352+
insertNoticeBeforeForm( $el );
344353

345354
setTimeout( () => $el.fadeOut( 400, () => $el.remove() ), 5000 );
346355
},
@@ -355,12 +364,7 @@
355364

356365
const $el = createElement( 'div', { class: 'notice notice-success is-dismissible' } );
357366
$el.append( createElement( 'p' ).text( message ) );
358-
$( '.scg-form' ).before( $el );
359-
360-
const offset = $el.offset();
361-
if ( offset?.top ) {
362-
$( 'html, body' ).animate( { scrollTop: Math.max( 0, offset.top - 50 ) }, 300 );
363-
}
367+
insertNoticeBeforeForm( $el );
364368
},
365369
};
366370

free-gift-bulk-coupon-generator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* @since 1.0.0
4343
* @return bool
4444
*/
45-
function free_gift_coupons_bulk_coupons_is_loaded() {
45+
function fgcbg_is_loaded() {
4646
return class_exists( 'FGCBG_Plugin' );
4747
}
4848

@@ -52,8 +52,8 @@ function free_gift_coupons_bulk_coupons_is_loaded() {
5252
* @since 1.0.0
5353
* @return void
5454
*/
55-
function free_gift_coupons_bulk_coupons_init() {
55+
function fgcbg_init() {
5656
FGCBG_Plugin::get_instance();
5757
}
5858

59-
add_action( 'plugins_loaded', 'free_gift_coupons_bulk_coupons_init' );
59+
add_action( 'plugins_loaded', 'fgcbg_init' );

0 commit comments

Comments
 (0)