This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin Name: ACF 7.1 v2 iframe compatibility | |
| * Description: Restores ACF v2 in-canvas block edit mode inside WordPress 7.1's always-iframed post editor. Loads ACF field JS in the iframe and binds jQuery widgets there instead of the parent admin document. ACF block version 2 only. | |
| * Version: 0.9.0 | |
| * Author: Liam Gladdy | |
| * Requires at least: 7.1 | |
| * Requires Plugins: advanced-custom-fields-pro | |
| * | |
| * Why an iframe-local ACF runtime (not global document monkey-patching or rewriting acf-pro-blocks.js): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin Name: ACF Blocks v3 Disable Preview | |
| * Plugin URI: https://liamg.dev | |
| * Description: Disables the preview/iframe rendering for ACF Blocks v3 that have mode support disabled and edit mode set. | |
| * Version: 1.0.0 | |
| * Author: Liam Gladdy | |
| * Author URI: https://liamg.dev | |
| * License: GPL v2 or later | |
| * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'acf/will_remove_unsafe_html', 'acf_enable_detailed_escape_logging_to_php_error_log', 10, 4 ); | |
| add_action( 'acf/removed_unsafe_html', 'acf_enable_detailed_escape_logging_to_php_error_log', 10, 4 ); | |
| function acf_enable_detailed_escape_logging_to_php_error_log( $function, $selector, $field_object, $post_id ) { | |
| if ( $function === 'the_sub_field' ) { | |
| $field = get_sub_field_object( $selector, true ); | |
| $value = ( is_array( $field ) && isset( $field['value'] ) ) ? $field['value'] : false; | |
| } else { | |
| $value = get_field( $selector, $post_id ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'acf/will_remove_unsafe_html', 'print_backtrace_for_unsafe_html_removal', 10, 4 ); | |
| add_action( 'acf/removed_unsafe_html', 'print_backtrace_for_unsafe_html_removal', 10, 4 ); | |
| function print_backtrace_for_unsafe_html_removal( $function, $selector, $field_object, $post_id ) { | |
| echo '<h4 style="color:red">Detected Potentially Unsafe HTML Modification</h4>'; | |
| echo '<pre>'; | |
| debug_print_backtrace(); | |
| echo '</pre>'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "automatic-wide-width", | |
| "title": "Automatically Align Wide", | |
| "description": "A demo block.json for a forced align-wide block", | |
| "apiVersion": 2, | |
| "acf": { | |
| "mode": "edit", | |
| "renderTemplate": "render.php" | |
| }, | |
| "supports": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| acf.addFilter('acf_blocks_parse_node_attr', function( currentValue, nodeAttr ){ | |
| if (nodeAttr.name.startsWith('v-')) { | |
| return { name: nodeAttr.name, value: nodeAttr.value }; | |
| } | |
| return currentValue; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'acf/json/load_paths', 'set_custom_json_load_paths' ); | |
| function set_custom_json_load_paths( $paths ) { | |
| $paths[] = get_stylesheet_directory() . '/acf-json/post-types'; | |
| $paths[] = get_stylesheet_directory() . '/acf-json/field-groups'; | |
| $paths[] = get_stylesheet_directory() . '/acf-json/taxonomies'; | |
| $paths[] = get_stylesheet_directory() . '/acf-json/option-pages'; | |
| return $paths; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'render_block_core/shortcode', 'test_acf_shortcode_render', 10, 3); | |
| function test_acf_shortcode_render( $content, $parsed_block, $block ) { | |
| $content = preg_replace_callback( '/\[acf\s.*?\]/', 'acf_inject_query_loop_post_ID', $content ); | |
| return $content; | |
| } | |
| function acf_inject_query_loop_post_ID( $match ) { | |
| return str_replace( '[acf', '[acf post_id="' . get_the_ID() . '"', $match[0] ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //block.json | |
| { | |
| "name": "simple-test-block", | |
| "title": "Simple Test Block", | |
| "description": "Simple Test Block", | |
| "category": "theme", | |
| "icon": "admin-comments", | |
| "acf": { | |
| "mode": "preview", | |
| "renderTemplate": "render.php" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| acf.addFilter('color_picker_args', function (args) { | |
| const settings = wp.data.select( "core/editor" ).getEditorSettings(); | |
| let colors = settings.colors.map(x => x.color); | |
| args.palettes = colors; | |
| return args; | |
| }); |
NewerOlder