删除插件中的功能

时间:2018-03-14 06:11:43

标签: wordpress woocommerce

remove_action 无效我尝试使用以下代码删除 acf_woocommerce_add_fields_to_order

remove remove_action( 'acf_woocommerce_add_fields_to_order', array( ACF_Woo_API::get_instance(), 'acf_woocommerce_add_fields_to_order' ) );

但是,这并没有起到帮助的作用。

我想从插件中删除的功能如下

 public function acf_woocommerce_add_fields_to_order() {
              $api = ACF_Woo_API::get_instance();
              $group_keys = wp_list_pluck($api->get_field_groups(), $api->acf_id_case_sensitive());
              foreach ($group_keys as $group_key => $key) {
                  $fields = $api->get_field_group_fields($key);
                  foreach ($fields as $field => $value) {
                      $field_label = $value['label'];
                      $raw_meta = base64_decode(get_post_meta(get_the_ID(), $value['key'], true));
                      $meta = unserialize($raw_meta);
                      if (is_array($meta)) {
                          //handle repeater, flexible content
                          if (is_array(reset($meta))) {
                              echo '<table style="border-collapse: collapse; width: 100%">';
                              foreach ($meta as $row) {
                                  echo '<tr>';
                                  foreach ($row as $column) {
                                      echo "<td style='border: 1px solid black;'>$column</td>";
                                  }
                                  echo '</tr>';
                              }
                              echo '</table>';
                          } //handle choice and select
                          else {
                              echo '<p><strong>' . $field_label . ': </strong>' . implode('; ', $meta) . '</p>';
                          }
                      } else {
                          $meta = stripcslashes($meta);
                          echo '<p><strong>' . $field_label . ': </strong>' . $meta . '</p>';
                      }
                  }
              }
          }

正在尝试

remove_action('acf_woocommerce_add_fields_to_order',array(ACF_Woo_API :: get_instance(),'acf_woocommerce_add_fields_to_order'));

但无法做到。 希望了解更多。谢谢!

0 个答案:

没有答案