Skip to content

Commit c4ca6f6

Browse files
committed
fix: WordPress.org review compliance - remove load_plugin_textdomain, fix sanitization warnings, fix release pipeline ZIP, remove dead frontend assets
1 parent ec2e703 commit c4ca6f6

4 files changed

Lines changed: 39 additions & 48 deletions

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ jobs:
3737
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
3838

3939
- name: Create Release
40-
uses: softprops/action-gh-release@v1
40+
uses: softprops/action-gh-release@v2
4141
with:
42-
files: dist/openfields-*.zip
42+
files: dist/codeideal-open-fields-*.zip
4343
draft: false
4444
prerelease: false
4545
body: |
46-
# OpenFields v${{ steps.get_version.outputs.version }}
46+
# Codeideal Open Fields v${{ steps.get_version.outputs.version }}
4747
4848
## Installation
4949
50-
1. Download `openfields-${{ steps.get_version.outputs.version }}.zip` below
50+
1. Download `codeideal-open-fields-${{ steps.get_version.outputs.version }}.zip` below
5151
2. Go to WordPress Admin → **Plugins** → **Add New**
5252
3. Click **Upload Plugin** and select the ZIP file
5353
4. Click **Install Now** and then **Activate Plugin**
@@ -58,7 +58,7 @@ jobs:
5858
5959
---
6060
61-
**OpenFields** - The free, open-source alternative to ACF for WordPress
61+
**Codeideal Open Fields** - The free, open-source custom fields plugin for WordPress
6262
6363
[Documentation](https://openfields.codeideal.com/docs) | [GitHub](https://github.com/novincode/openfields)
6464
env:

plugin/includes/admin/class-cof-meta-box.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ public function save_post( $post_id, $post, $update ) {
511511
// Standard field save.
512512
$field_name = $field->name;
513513
$meta_key = self::META_PREFIX . $field_name;
514-
// phpcs:ignore WordPress.Security.NonceVerification.Missing
514+
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized via $this->sanitize_value() below.
515515
$raw_value = isset( $_POST[ $meta_key ] ) ? wp_unslash( $_POST[ $meta_key ] ) : '';
516516

517517

@@ -585,7 +585,7 @@ private function save_repeater_field( $post_id, $field, $sub_fields_map, $base_n
585585
if ( $sub_field->type === 'repeater' ) {
586586
$this->save_repeater_field( $post_id, $sub_field, $sub_fields_map, $full_name );
587587
} else {
588-
// phpcs:ignore WordPress.Security.NonceVerification.Missing
588+
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized via $this->sanitize_value() below.
589589
$raw_value = isset( $_POST[ $full_name ] ) ? wp_unslash( $_POST[ $full_name ] ) : '';
590590
$sanitized = $this->sanitize_value( $raw_value, $sub_field->type );
591591
update_post_meta( $post_id, $full_name, $sanitized );
@@ -637,7 +637,7 @@ private function save_group_field( $post_id, $field, $sub_fields_map, $base_name
637637
$this->save_group_field( $post_id, $sub_field, $sub_fields_map, $full_name );
638638
} else {
639639
// Standard sub-field save.
640-
// phpcs:ignore WordPress.Security.NonceVerification.Missing
640+
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized via $this->sanitize_value() below.
641641
$raw_value = isset( $_POST[ $full_name ] ) ? wp_unslash( $_POST[ $full_name ] ) : '';
642642
$sanitized = $this->sanitize_value( $raw_value, $sub_field->type );
643643
update_post_meta( $post_id, $full_name, $sanitized );
@@ -1077,7 +1077,7 @@ public function save_taxonomy_fields( $term_id, $tt_id ) {
10771077

10781078
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified above.
10791079
if ( isset( $_POST[ $meta_key ] ) ) {
1080-
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified above.
1080+
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Nonce verified above; sanitized via $this->sanitize_value().
10811081
$value = $this->sanitize_value( wp_unslash( $_POST[ $meta_key ] ), $field->type );
10821082
update_term_meta( $term_id, $meta_key, $value );
10831083
} else {
@@ -1131,7 +1131,7 @@ private function save_repeater_field_for_term( $term_id, $field, $sub_fields_map
11311131
if ( $sub_field->type === 'repeater' ) {
11321132
$this->save_repeater_field_for_term( $term_id, $sub_field, $sub_fields_map, $full_name );
11331133
} else {
1134-
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified in save_taxonomy_fields.
1134+
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Nonce verified in save_taxonomy_fields; sanitized via $this->sanitize_value().
11351135
$raw_value = isset( $_POST[ $full_name ] ) ? wp_unslash( $_POST[ $full_name ] ) : '';
11361136
$sanitized = $this->sanitize_value( $raw_value, $sub_field->type );
11371137
update_term_meta( $term_id, $full_name, $sanitized );
@@ -1165,7 +1165,7 @@ private function save_group_field_for_term( $term_id, $field, $sub_fields_map, $
11651165
} elseif ( $sub_field->type === 'group' ) {
11661166
$this->save_group_field_for_term( $term_id, $sub_field, $sub_fields_map, $full_name );
11671167
} else {
1168-
// phpcs:ignore WordPress.Security.NonceVerification.Missing
1168+
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Nonce verified in save_taxonomy_fields; sanitized via $this->sanitize_value().
11691169
$raw_value = isset( $_POST[ $full_name ] ) ? wp_unslash( $_POST[ $full_name ] ) : '';
11701170
$sanitized = $this->sanitize_value( $raw_value, $sub_field->type );
11711171
update_term_meta( $term_id, $full_name, $sanitized );
@@ -1433,7 +1433,7 @@ public function save_user_fields( $user_id ) {
14331433

14341434
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified above.
14351435
if ( isset( $_POST[ $meta_key ] ) ) {
1436-
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified above.
1436+
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Nonce verified above; sanitized via $this->sanitize_value().
14371437
$value = $this->sanitize_value( wp_unslash( $_POST[ $meta_key ] ), $field->type );
14381438
update_user_meta( $user_id, $meta_key, $value );
14391439
} else {
@@ -1487,7 +1487,7 @@ private function save_repeater_field_for_user( $user_id, $field, $sub_fields_map
14871487
if ( $sub_field->type === 'repeater' ) {
14881488
$this->save_repeater_field_for_user( $user_id, $sub_field, $sub_fields_map, $full_name );
14891489
} else {
1490-
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified in save_user_fields.
1490+
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Nonce verified in save_user_fields; sanitized via $this->sanitize_value().
14911491
$raw_value = isset( $_POST[ $full_name ] ) ? wp_unslash( $_POST[ $full_name ] ) : '';
14921492
$sanitized = $this->sanitize_value( $raw_value, $sub_field->type );
14931493
update_user_meta( $user_id, $full_name, $sanitized );
@@ -1521,7 +1521,7 @@ private function save_group_field_for_user( $user_id, $field, $sub_fields_map, $
15211521
} elseif ( $sub_field->type === 'group' ) {
15221522
$this->save_group_field_for_user( $user_id, $sub_field, $sub_fields_map, $full_name );
15231523
} else {
1524-
// phpcs:ignore WordPress.Security.NonceVerification.Missing
1524+
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Nonce verified in save_user_fields; sanitized via $this->sanitize_value().
15251525
$raw_value = isset( $_POST[ $full_name ] ) ? wp_unslash( $_POST[ $full_name ] ) : '';
15261526
$sanitized = $this->sanitize_value( $raw_value, $sub_field->type );
15271527
update_user_meta( $user_id, $full_name, $sanitized );

plugin/includes/class-cof-assets.php

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,20 @@ public function admin_scripts( $hook ) {
102102
* @since 1.0.0
103103
*/
104104
public function frontend_scripts() {
105-
// Only load if needed.
105+
// Only load if needed — currently no frontend assets are required.
106106
if ( ! $this->should_load_frontend_assets() ) {
107107
return;
108108
}
109109

110-
wp_enqueue_script(
111-
'cof-frontend',
112-
COF_PLUGIN_URL . 'assets/public/js/frontend.js',
113-
array(),
114-
COF_VERSION,
115-
true
116-
);
117-
118-
wp_enqueue_style(
119-
'cof-frontend',
120-
COF_PLUGIN_URL . 'assets/public/css/frontend.css',
121-
array(),
122-
COF_VERSION
123-
);
110+
/**
111+
* Fires when frontend assets should be loaded.
112+
*
113+
* Developers can use the 'cof/load_frontend_assets' filter to
114+
* trigger this, then enqueue their own styles/scripts here.
115+
*
116+
* @since 1.0.0
117+
*/
118+
do_action( 'cof/frontend_enqueue_scripts' );
124119
}
125120

126121
/**
@@ -169,18 +164,21 @@ public function meta_box_scripts( $hook ) {
169164
COF_VERSION
170165
);
171166

172-
// Localize script data.
173-
wp_localize_script(
174-
'cof-fields',
175-
'cofMetaBox',
176-
array(
177-
'i18n' => array(
178-
'selectImage' => __( 'Select Image', 'codeideal-open-fields' ),
179-
'useImage' => __( 'Use this image', 'codeideal-open-fields' ),
180-
'selectFile' => __( 'Select File', 'codeideal-open-fields' ),
181-
'useFile' => __( 'Use this file', 'codeideal-open-fields' ),
182-
),
183-
)
167+
// Localize meta box data for field renderers.
168+
wp_add_inline_script(
169+
'wp-color-picker',
170+
sprintf(
171+
'var cofMetaBox = %s;',
172+
wp_json_encode( array(
173+
'i18n' => array(
174+
'selectImage' => __( 'Select Image', 'codeideal-open-fields' ),
175+
'useImage' => __( 'Use this image', 'codeideal-open-fields' ),
176+
'selectFile' => __( 'Select File', 'codeideal-open-fields' ),
177+
'useFile' => __( 'Use this file', 'codeideal-open-fields' ),
178+
),
179+
) )
180+
),
181+
'before'
184182
);
185183
}
186184

plugin/includes/class-cof.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ private function init_hooks() {
102102
* @since 1.0.0
103103
*/
104104
public function init() {
105-
// Load plugin text domain for translations.
106-
load_plugin_textdomain(
107-
'codeideal-open-fields',
108-
false,
109-
dirname( COF_PLUGIN_BASENAME ) . '/languages'
110-
);
111-
112105
// Initialize components.
113106
COF_Assets::instance();
114107
COF_Field_Registry::instance();

0 commit comments

Comments
 (0)