Support

Account

Home Forums ACF PRO merge codes -performance

Solved

merge codes -performance

  • hi guys. im back to acf after sometime with toolset and the start of oxygen builder.

    i would like to know in performance wise anything i can improve below code?

    add_filter('acf/format_value/name=price', 'fix_number', 20, 3);
    function fix_number($value, $post_id, $field) {
      $value = number_format($value);
      return $value;
    	}
    
    add_filter('acf/format_value/name=square_footage', 'fix_number', 20, 3);
    function fix_number($value, $post_id, $field) {
      $value = number_format($value);
      return $value;
    	}

    Perhaps merging both ?
    which is better? merging both or leave it as it is ?
    TIA !

  • aware of the same function name. second should be function fix_number2 .

  • Performance should make little difference with 1 function of 2, but you’re doing the same thing, just use the same filter for both fields. Make the code simpler by removing duplicate function.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘merge codes -performance’ is closed to new replies.