Skip to content

Commit

Permalink
chore: modify acf data rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyrisbee committed Jan 5, 2024
1 parent 76f6dad commit 55fa467
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/triggers/class-acf-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,28 @@ public function run(): array {
$posts = get_posts(
array(
'numberposts' => -1,
'post_type' => array( 'acf-field-group', 'acf-field' ),
'post_type' => array( 'acf-field' ),
)
);

$posts = array_filter(
$posts,
function ( $post ) {
return ! empty( $post->post_title ) && ! empty( $post->post_excerpt );
$length = strlen( $post->post_excerpt );

if ( $length < 3 || $length > 32 ) {
return false;
}

if ( empty( $post->post_title ) || empty( $post->post_excerpt ) ) {
return false;
}

if ( preg_match( '/^[a-z_][a-z0-9_]*$/', $post->post_excerpt ) === 0 ) {
return false;
}

return true;
}
);

Expand Down Expand Up @@ -105,10 +119,8 @@ function ( $post ) {
'acf_type' => $post->post_type,
// Field label.
'label' => $post->post_title,
// Field name.
'description' => $post->post_excerpt,
// Acf unique name.
'name' => $post->post_name,
// Acf field name.
'name' => $post->post_excerpt,
// The detailed settings, including types, validation, etc.
'attributes' => array(
// Group location rules setting.
Expand Down

0 comments on commit 55fa467

Please sign in to comment.