Skip to content

Commit 7e3762e

Browse files
authored
Merge pull request #349 from athemes/improvement/rt/project-setup
Project setup improvements
2 parents 6e6cb9b + 1de00c1 commit 7e3762e

File tree

18 files changed

+18697
-29195
lines changed

18 files changed

+18697
-29195
lines changed

.cursor/rules/general.mdc

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: false
5+
---
6+
---
7+
description: WPForms Cursor General Rules
8+
globs:
9+
alwaysApply: true
10+
---
11+
By default use git repository in plugins directory.
12+
13+
# General code style rules:
14+
- Use tabs instead of spaces for indentation at the beginning of the line.
15+
- Comments in the code must be in English and end with a period.
16+
17+
# Core Principles
18+
- Adhere to PHP and WordPress best practices for consistency and readability.
19+
- Emphasize object-oriented programming (OOP) for better modularity.
20+
- Focus on code reusability through iteration and modularization, avoiding duplication.
21+
- Use descriptive and meaningful functions, variables, and file names.
22+
- Follow existing project directory naming conventions.
23+
- Use WordPress hooks (actions and filters) to extend functionality.
24+
- Add explicit, descriptive comments to improve code clarity and maintainability.
25+
26+
# PHP/WordPress Coding Practices
27+
- Utilize features of PHP 7.2+ where applicable.
28+
- Follow WordPress PHP coding standards throughout the codebase.
29+
- Values inside parentheses must have one space between value and each parenthesis. This is also required for brackets and curly braces.
30+
- Leverage core WordPress functions and APIs wherever possible.
31+
- Maintain WordPress theme and plugin directory structure and naming conventions.
32+
- Implement robust error handling:
33+
- Use WordPress's built-in debug logging (WP_DEBUG_LOG).
34+
- Apply try-catch blocks for controlled exception handling.
35+
- Always use WordPress's built-in functions for data validation and sanitization.
36+
- Ensure secure form handling by verifying nonces in submissions.
37+
- For database interactions:
38+
- Use WordPress's $wpdb abstraction layer.
39+
- Apply prepare() statements for all dynamic queries to prevent SQL injection.
40+
- Use the dbDelta() function to manage database schema changes.
41+
42+
# JavaScript
43+
- Use short arrow function syntax.
44+
45+
# Dependencies
46+
- Ensure compatibility with the latest stable version of WordPress.
47+
- Use Composer for dependency management in advanced plugins or themes.
48+
49+
# WordPress Best Practices
50+
- Use WordPress's user roles and capabilities to manage permissions.
51+
- Apply the transients API to cache data and optimize performance.
52+
- Follow best practices for internationalization (i18n) by using WordPress localization functions.
53+
- Apply proper security practices such as nonce verification, input sanitization, and data escaping.
54+
- Manage scripts and styles by using wp_enqueue_script() and wp_enqueue_style().
55+
- Store configuration data securely using WordPress's options API.
56+
57+
# Key Conventions
58+
- Follow WordPress's plugin API to extend functionality in a modular and scalable manner.
59+
- Apply WordPress's built-in functions for data sanitization and validation to secure user inputs.
60+
- For custom queries, use $wpdb or WP_Query for database interactions.
61+
- For AJAX requests, use admin-ajax.php or the WordPress REST API to handle backend requests.
62+
- Always apply WordPress's hook system (actions and filters) for extensible and modular code.
63+
- Implement database operations using transactional functions where needed.

.gitattributes

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
bin export-ignore
2+
tests export-ignore
3+
vendor export-ignore
4+
5+
.editorconfig export-ignore
6+
.gitattributes export-ignore
7+
.gitignore export-ignore
8+
.github export-ignore
9+
.travis.yml export-ignore
10+
.phpunit.result.cache export-ignore
11+
composer.lock export-ignore
12+
LICENSE.md export-ignore
13+
phpcs.xml export-ignore
14+
README.md export-ignore
15+
Explanation.md export-ignore
16+
phpunit.xml.dist export-ignore
17+
phpcs.xml.dist export-ignore
18+
readme.md export-ignore

.github/workflows/code-checks.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
jobs:
1212
# Run php tests.
1313
php-tests:
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-latest
1515
if: "!contains(github.event.head_commit.message, 'ci skip')"
1616
strategy:
1717
matrix:
@@ -31,9 +31,6 @@ jobs:
3131
- name: Validate composer.json
3232
run: composer validate
3333

34-
- name: show files
35-
run: ls -la
36-
3734
- name: Cache Composer dependencies
3835
id: composer-cache
3936
uses: actions/cache@v3
@@ -51,6 +48,9 @@ jobs:
5148
with:
5249
composer-options: -q -n -a --no-progress --prefer-dist
5350

51+
- name: Composer update
52+
run: composer update
53+
5454
# Run composer script to run php syntax checks.
5555
- name: Run Check PHP Syntax
5656
run: composer phpcs:fix

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ node_modules
1111
assets/css
1212
assets/js/**/*.js
1313
!assets/js/src/**/*.js
14+
composer.lock

assets/sass/abstracts/mixins/_mixins.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use "sass:map";
2+
13
// Center block
24
@mixin center-block {
35
display: block;
@@ -7,12 +9,12 @@
79

810
// Column width with margin
911
@mixin column-width($numberColumns: 3) {
10-
width: map-get($columns, $numberColumns) - ( ( $columns__margin * ( $numberColumns - 1 ) ) / $numberColumns );
12+
width: map.get($columns, $numberColumns) - ( calc(($columns--margin * ($numberColumns - 1)) / $numberColumns) );
1113
}
1214

1315
@mixin font-size($sizeValue: 1) {
1416
font-size: ($sizeValue) * 1px;
15-
font-size: ($sizeValue / 16) * 1rem;
17+
font-size: calc($sizeValue / 16) * 1rem;
1618
}
1719

1820
@mixin valign {

assets/sass/plugins/woocommerce/_components.scss

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,12 @@
194194

195195
.quantity-button-style4 {
196196
.quantity {
197+
border-width: 1px;
198+
197199
@media(min-width: 1025px) {
198200
width: 40%;
199201
}
200202

201-
border-width: 1px;
202203
.botiga-quantity-plus,
203204
.botiga-quantity-minus {
204205
font-size: 1.4rem;
@@ -220,10 +221,10 @@
220221

221222
.quantity-button-style5 {
222223
.quantity {
224+
border: none;
223225
@media(min-width: 1025px) {
224226
width: 40%;
225227
}
226-
border: none;
227228
.botiga-quantity-plus,
228229
.botiga-quantity-minus {
229230
font-size: 1.4rem;
@@ -240,10 +241,10 @@
240241

241242
.quantity-button-style6 {
242243
.quantity {
244+
border: none;
243245
@media(min-width: 1025px) {
244246
width: 50%;
245247
}
246-
border: none;
247248
.botiga-quantity-plus,
248249
.botiga-quantity-minus {
249250
font-size: 1.4rem;
@@ -282,10 +283,10 @@
282283

283284
.quantity-button-style7 {
284285
.quantity {
286+
border-width: 1px;
285287
@media(min-width: 1025px) {
286288
width: 22%;
287289
}
288-
border-width: 1px;
289290
.botiga-quantity-plus,
290291
.botiga-quantity-minus {
291292
width: 22px;
@@ -317,11 +318,13 @@
317318

318319
.quantity-button-style8 {
319320
.quantity {
321+
padding: 5px;
322+
border-width: 1px;
323+
320324
@media(min-width: 1025px) {
321325
width: 40%;
322326
}
323-
padding: 5px;
324-
border-width: 1px;
327+
325328
.botiga-quantity-plus,
326329
.botiga-quantity-minus {
327330
font-size: 1.4rem;

0 commit comments

Comments
 (0)