Fix function hooks in wcff-builder.php
-
Hi,
we’ve noticed that inside
function built_field_wrapper
, there are 2 calls to has_action()/do_filter() function instead of has_filter()/apply_filters().
Could you please change this code snippet inside /includes/wcff-builder.php:... /* CHeck for the custom wrapper action registered */ if (has_action('wccpf_before_field_rendering') && has_action('wccpf_after_field_rendering')) { $before = do_filter('wccpf_before_field_rendering', $_meta); $after = do_filter('wccpf_after_field_rendering', $_meta); $html = $before . $_html . $after; } else { /* Special property for URL field alone */ ...
with:
... /* CHeck for the custom wrapper action registered */ if (has_filter('wccpf_before_field_rendering') && has_filter('wccpf_after_field_rendering')) { $before = apply_filters('wccpf_before_field_rendering', '', $_meta); $after = apply_filters('wccpf_after_field_rendering', '', $_meta); $html = $before . $_html . $after; } else { /* Special property for URL field alone */ ...
The do_filter() function is not defined in WP and causes a Execution error, moreover it would be nicer to change the logic to the following one:
if ($_meta["type"] != "url") { $_html .= '<span class="wccpf-validation-message">' . (isset($_meta["message"]) ? $_meta["message"] : "") . '</span>'; } /* Special property for URL field alone */ $show_label = isset($_meta["show_label"]) ? $_meta["show_label"] : "yes"; /* Default field wrapper */ $wrapper_class = (isset($_meta["field_class"]) && !empty($_meta["field_class"])) ? $_meta["field_class"] : $_meta["name"]; /* Is init field show or hide */ $onload_field = (isset($_meta["initial_show"]) && $_meta["initial_show"] == "no" ) ? "display: none;" : ""; $html_before = '<table style="'.$onload_field.'" class="wccpf_fields_table ' . apply_filters('wccpf_fields_container_class', '') . ' '. $wrapper_class.'-wrapper">'; $html_before .= '<tbody>'; $html_before .= '<tr>'; if ($_meta["type"] != "url" || $show_label == "yes") { $html .= '<td class="wccpf_label"><label for="' . esc_attr($_meta["name"] . $_index) . '">' . esc_html($_meta["label"]) . '' . ((isset($_meta["required"]) && $_meta["required"] == "yes") ? ' <span>*</span>' : '') . '</label></td>'; } $html_before .= '<td class="wccpf_value">'; $html_before = apply_filters('wccpf_before_field_rendering', $html_before, $_meta, $_index); $html_after = '</td>'; $html_after .= '</tr>'; $html_after .= '</tbody>'; $html_after .= '</table>'; $html_after = apply_filters('wccpf_after_field_rendering', $html_after, $_meta, $_index); $html = $html_before . $_html . $html_after;
This allows not to replicate the template when applying the filters.
Please let us know,
Thank you- This topic was modified 6 years, 5 months ago by .
- This topic was modified 6 years, 5 months ago by .
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Fix function hooks in wcff-builder.php’ is closed to new replies.