After Template – action hook
-
So for the before_template and after_template actions
the before_template and after_template hooks both call 3 variables – $field,$layout,$is_preview
but somewhere after the before_template action is called and before the after_template action is called, the values of $field and $layout gets modified so its not the same structure.
Im not sure if it something that I did wrong…
I had to add $og_field and $og_layout and set them at the top of the function and then use them in the after_template filter callouts
/* * ACFE: Flexible Render Layout Template * Find & include the Flexible Content Layouts PHP files */ function acfe_flexible_render_layout_template($layout, $field){ //GET ORIGIONAL VALUES OF THE FIELD AND LAYOUT VARIABLES $og_field = $field; $og_layout = $layout; // Global global $is_preview, $col; $col = false; // Vars $name = $field['_name']; $key = $field['key']; $l_name = $layout['name']; // File $file = acf_maybe_get($layout, 'acfe_flexible_render_template'); // Filters $file = apply_filters("acfe/flexible/render/template", $file, $field, $layout, $is_preview); $file = apply_filters("acfe/flexible/render/template/name={$name}", $file, $field, $layout, $is_preview); $file = apply_filters("acfe/flexible/render/template/key={$key}", $file, $field, $layout, $is_preview); $file = apply_filters("acfe/flexible/render/template/layout={$l_name}", $file, $field, $layout, $is_preview); $file = apply_filters("acfe/flexible/render/template/name={$name}&layout={$l_name}", $file, $field, $layout, $is_preview); $file = apply_filters("acfe/flexible/render/template/key={$key}&layout={$l_name}", $file, $field, $layout, $is_preview); // Deprecated $file = apply_filters_deprecated("acfe/flexible/layout/render/template/layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/layout={$l_name}"); $file = apply_filters_deprecated("acfe/flexible/layout/render/template/name={$name}&layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/name={$name}&layout={$l_name}"); $file = apply_filters_deprecated("acfe/flexible/layout/render/template/key={$key}&layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/key={$key}&layout={$l_name}"); // Before Template do_action("acfe/flexible/render/before_template", $field, $layout, $is_preview); do_action("acfe/flexible/render/before_template/name={$name}", $field, $layout, $is_preview); do_action("acfe/flexible/render/before_template/key={$key}", $field, $layout, $is_preview); do_action("acfe/flexible/render/before_template/layout={$l_name}", $field, $layout, $is_preview); do_action("acfe/flexible/render/before_template/name={$name}&layout={$l_name}", $field, $layout, $is_preview); do_action("acfe/flexible/render/before_template/key={$key}&layout={$l_name}", $field, $layout, $is_preview); // Deprecated do_action_deprecated("acfe/flexible/layout/render/before_template/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/layout={$l_name}"); do_action_deprecated("acfe/flexible/layout/render/before_template/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/name={$name}&layout={$l_name}"); do_action_deprecated("acfe/flexible/layout/render/before_template/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/key={$key}&layout={$l_name}"); // Check file if(!empty($file)){ $file_found = acfe_locate_file_path($file); if(!empty($file_found)){ // Front-end if(!$is_preview){ // Include include($file_found); // Preview }else{ $path = pathinfo($file); $extension = $path['extension']; $file_preview = substr($file,0, -strlen($extension)-1); $file_preview .= '-preview.' . $extension; $file_preview = acfe_locate_file_path($file_preview); // Include if(!empty($file_preview)){ include($file_preview); }else{ include($file_found); } } } } // After Template //USE OG VALUES OF LAYOUT AND FIELD VARIABLES do_action("acfe/flexible/render/after_template", $og_field, $og_layout, $is_preview); do_action("acfe/flexible/render/after_template/name={$name}", $field, $layout, $is_preview); do_action("acfe/flexible/render/after_template/key={$key}", $field, $layout, $is_preview); do_action("acfe/flexible/render/after_template/layout={$l_name}", $field, $layout, $is_preview); do_action("acfe/flexible/render/after_template/name={$name}&layout={$l_name}", $field, $layout, $is_preview); do_action("acfe/flexible/render/after_template/key={$key}&layout={$l_name}", $field, $layout, $is_preview); // Deprecated do_action_deprecated("acfe/flexible/layout/render/after_template/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/layout={$l_name}"); do_action_deprecated("acfe/flexible/layout/render/after_template/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/name={$name}&layout={$l_name}"); do_action_deprecated("acfe/flexible/layout/render/after_template/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/key={$key}&layout={$l_name}"); }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘After Template – action hook’ is closed to new replies.