settings = $settings; $this->requests = $requests; $this->events = $events; $this->security = $security; } public function init() { ( new Track_Admin( $this->settings ) )->init(); // The panel on the order screen is what writes the parcel number, so it // is registered whether or not the customer page is switched on: an // operator recording parcels before the page goes live is the normal // order of things, not an edge case. if ( is_admin() ) { ( new Track_Order_Box( $this->settings ) )->init(); } $timeline = new Track_Timeline( $this->settings, $this->requests ); $rest = new Track_Rest( $this->settings, $this->events, $this->security, $timeline ); // The cache headers guard the whole namespace, including the returns // portal's own lookup, so they are attached whether or not this module is // switched on. A privacy control must not depend on an unrelated flag. add_filter( 'rest_post_dispatch', array( $rest, 'no_store' ), 10, 3 ); // The shortcode is registered unconditionally and returns an empty string // while the module is off. Registering it behind the flag would print the // literal [careback_tracking] on a live page the moment somebody switched the // module off — which is exactly when nobody is watching the page. ( new Track_Frontend( $this->settings, $this->security ) )->init(); if ( empty( $this->settings->get( 'track_enabled' ) ) ) { return; } $rest->init(); } }