is_active() ) { return $eligible; } return ! in_array( $post->ID, $this->ids(), true ); } /** * Refreshes the pages that gained or lost their shop role, and the llms files. * * @param mixed $old Previous page ID. * @param mixed $current New page ID. * @return void */ public function on_page_changed( mixed $old, mixed $current ): void { $this->ids = null; $this->pages->queue( array_values( array_filter( array( absint( $old ), absint( $current ) ) ) ) ); OutputCache::purge(); } /** * @return bool True when WooCommerce is active. */ private function is_active(): bool { return defined( 'WC_VERSION' ) || class_exists( 'WooCommerce' ); } /** * Reads the page IDs the way WooCommerce does, so translation plugins that filter them are respected. * * @return int[] IDs of the pages left out. */ private function ids(): array { if ( null !== $this->ids ) { return $this->ids; } $this->ids = array(); foreach ( (array) apply_filters( 'agentwelcome_woocommerce_excluded_pages', self::PAGES ) as $page ) { $id = absint( apply_filters( 'woocommerce_get_' . $page . '_page_id', get_option( 'woocommerce_' . $page . '_page_id' ) ) ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound, WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- WooCommerce's own filter. if ( $id > 0 ) { $this->ids[] = $id; } } return $this->ids; } }