<commit_before><?php

namespace FS\Components\Event\Listener;

use FS\Injection\I;
use FS\Components\AbstractComponent;
use FS\Context\ApplicationListenerInterface;
use FS\Components\Event\NativeHookInterface;
use FS\Context\ConfigurableApplicationContextInterface as Context;
use FS\Context\ApplicationEventInterface as Event;
use FS\Components\Event\ApplicationEvent;

class GetSectionsShipping extends AbstractComponent implements ApplicationListenerInterface, NativeHookInterface
{
    public function getSupportedEvent()
    {
        return ApplicationEvent::GET_SECTIONS_SHIPPING;
    }

    public function onApplicationEvent(Event $event, Context $context)
    {
        $sections = $event->getInput('sections');
        unset($sections['flagship_shipping_method']);

        return $sections;
    }

    public function publishNativeHook(Context $context)
    {
        \add_filter('woocommerce_get_sections_shipping', function ($sections) use ($context) {
            $event = new ApplicationEvent(ApplicationEvent::GET_SECTIONS_SHIPPING);
            $event->setInputs(array(
                'sections' => $sections,
            ));

            return $context->publishEvent($event);
        }, 10, 1);
    }

    public function getNativeHookType()
    {
        return self::TYPE_FILTER;
    }
}
<commit_msg>For removing the FlagShip section in the shipping settings tab, avoid hardcoding the FlagShip shipping method id.<commit_after><?php

namespace FS\Components\Event\Listener;

use FS\Components\AbstractComponent;
use FS\Context\ApplicationListenerInterface;
use FS\Components\Event\NativeHookInterface;
use FS\Context\ConfigurableApplicationContextInterface as Context;
use FS\Context\ApplicationEventInterface as Event;
use FS\Components\Event\ApplicationEvent;

class GetSectionsShipping extends AbstractComponent implements ApplicationListenerInterface, NativeHookInterface
{
    public function getSupportedEvent()
    {
        return ApplicationEvent::GET_SECTIONS_SHIPPING;
    }

    public function onApplicationEvent(Event $event, Context $context)
    {
        //Since on woocommerce3.0.x, settings are for each shipping zone, the global settings for FlagShip method will not be displayed.
        $sections = $event->getInput('sections');
        unset($sections[$context->setting('FLAGSHIP_SHIPPING_PLUGIN_ID')]);

        return $sections;
    }

    public function publishNativeHook(Context $context)
    {
        \add_filter('woocommerce_get_sections_shipping', function ($sections) use ($context) {
            $event = new ApplicationEvent(ApplicationEvent::GET_SECTIONS_SHIPPING);
            $event->setInputs(array(
                'sections' => $sections,
            ));

            return $context->publishEvent($event);
        }, 10, 1);
    }

    public function getNativeHookType()
    {
        return self::TYPE_FILTER;
    }
}

{'fraction_non_alphanumeric': 0.09116117850953206, 'fraction_numerical': 0.0027729636048526864, 'mean_word_length': 3.707993474714519, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6956112', 'n_tokens_mistral': 771, 'n_tokens_neox': 736, 'n_words': 169}