Skip to content

Commit

Permalink
[#148] Adding ACF custom feild
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-schmidt-viget committed Nov 8, 2024
1 parent 3aeb353 commit 6e7f815
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"key": "group_672e7d812d248",
"title": "Dialog Block",
"fields": [
{
"key": "field_672e7d81d71ee",
"label": "Button Text",
"name": "button_text",
"aria-label": "",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "Open",
"maxlength": "",
"allow_in_bindings": 0,
"placeholder": "",
"prepend": "",
"append": "",
"show_in_graphql": 1,
"graphql_description": "",
"graphql_field_name": "buttonText",
"graphql_non_null": 0
}
],
"location": [
[
{
"param": "block",
"operator": "==",
"value": "acf\/dialog"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": "",
"show_in_rest": 0,
"show_in_graphql": 1,
"graphql_field_name": "dialogBlock",
"map_graphql_types_from_location_rules": 0,
"graphql_types": "",
"modified": 1731100092
}
6 changes: 3 additions & 3 deletions wp-content/themes/wp-starter/blocks/dialog/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* @package WPStarter
*/

$cbx_id = uniqid();

$cbx_id = uniqid();
$button_text = get_field( 'button_text' );
?>
<?php if ( is_admin() ) : ?>
<input type="checkbox" id="<?php echo esc_attr( $cbx_id ); ?>" class="acfbt-dialog-checkbox">
Expand Down Expand Up @@ -68,6 +68,6 @@ class="btn-default"
@click="$refs.dialogRef.showModal(), openDialog = true"
<?php endif; ?>
>
<?php esc_html_e( 'Open', 'wp-site-starter' ); ?>
<?php esc_html_e( $button_text ? $button_text : 'Open', 'wp-site-starter' ); ?>
</button>
</div>
3 changes: 2 additions & 1 deletion wp-content/themes/wp-starter/blocks/dialog/render.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#}

{% set cbx_id = 'dialog-' ~ random() %}
{% set button_text = block.data['button_text'] %}

{% if function('is_admin') == true %}
<input type="checkbox" id="{{ cbx_id }}" class="acfbt-dialog-checkbox">
Expand Down Expand Up @@ -62,6 +63,6 @@
@click="$refs.dialogRef.showModal(), openDialog = true"
{% endif %}
>
Open
{{ button_text ? button_text : 'Open' }}
</button>
</div>

0 comments on commit 6e7f815

Please sign in to comment.