*/ public function relationships( Graph $graph ): array { $nodes = array(); foreach ( $graph->jsonSerialize()['nodes'] as $node ) { $nodes[ $node['id'] ] = true; } $rules = array(); $hotel = $this->onePresent( $nodes, array( 'plugin:motopress-hotel-booking/motopress-hotel-booking.php', 'plugin:motopress-hotel-booking-lite/motopress-hotel-booking.php', ) ); if ( $hotel !== null ) { foreach ( array( 'plugin:mphb-mailchimp/mphb-mailchimp.php', 'plugin:mphb-checkout-fields/mphb-checkout-fields.php', 'plugin:mphb-multi-currency/mphb-multi-currency.php', 'plugin:mphb-notifier/mphb-notifier.php', 'plugin:mphb-payment-request/mphb-payment-request.php', 'plugin:mphb-invoices/mphb-invoices.php', 'plugin:mphb-reviews/mphb-reviews.php', 'plugin:mphb-styles/mphb-styles.php', 'plugin:mphb-elementor/mphb-elementor.php', 'plugin:mphb-woocommerce/mphb-woocommerce.php', 'plugin:mphb-woocommerce-payments/mphb-woocommerce-payments.php', ) as $extension ) { if ( isset( $nodes[ $extension ] ) ) { $rules[] = $this->rule( $extension, $hotel, 'extends' ); } } foreach ( array( 'plugin:mphb-woocommerce/mphb-woocommerce.php', 'plugin:mphb-woocommerce-payments/mphb-woocommerce-payments.php' ) as $bridge ) { if ( isset( $nodes[ $bridge ], $nodes['plugin:woocommerce/woocommerce.php'] ) ) { $rules[] = $this->rule( $bridge, 'plugin:woocommerce/woocommerce.php', 'integrates_with' ); } } if ( isset( $nodes['plugin:mphb-elementor/mphb-elementor.php'], $nodes['plugin:elementor/elementor.php'] ) ) { $rules[] = $this->rule( 'plugin:mphb-elementor/mphb-elementor.php', 'plugin:elementor/elementor.php', 'integrates_with' ); } } $themeRules = array( 'theme:salient' => array( 'plugin:salient-core/salient-core.php', 'plugin:salient-portfolio/salient-portfolio.php', 'plugin:salient-widgets/salient-widgets.php', 'plugin:salient-shortcodes/salient-shortcodes.php', 'plugin:salient-home-slider/salient-home-slider.php', 'plugin:salient-wpbakery/salient-wpbakery.php', ), 'theme:hoteller' => array( 'plugin:hoteller-elementor/hoteller-elementor.php', 'plugin:hoteller-custom-post-type/hoteller-custom-post-type.php', ), ); foreach ( $themeRules as $theme => $plugins ) { if ( ! isset( $nodes[ $theme ] ) ) { continue; } foreach ( $plugins as $plugin ) { if ( isset( $nodes[ $plugin ] ) ) { $rules[] = $this->rule( $plugin, $theme, 'extends' ); } } } return $rules; } private function onePresent( array $nodes, array $candidates ): ?string { $found = array_values( array_filter( $candidates, static function ( $id ) use ( $nodes ) { return isset( $nodes[ $id ] ); } ) ); return count( $found ) === 1 ? $found[0] : null; } private function rule( string $source, string $target, string $relationship ): array { return compact( 'source', 'target', 'relationship' ) + array( 'evidence' => 'known_ecosystem_mapping' ); } }