supports_post_type( get_post_type( $wp_post ) ) ) { $this->wp_post = $wp_post; } else { //TODO Error, this should not happen. } } /** * Get the supported WP post_types that the transformer can use as an input. * * By default all post types are supported. * * @since version_number_transformer_management_placeholder * @return string[] An array containing all the supported post types. */ public function get_supported_post_types() { return \get_post_types( array( 'public' => true ), 'names' ); } /** * Get the name of the plugin that registered the transformer. * * @see Forked from the WordPress elementor plugin. * * @since version_number_transformer_management_placeholder * @return string Plugin name */ private function get_plugin_name_from_transformer_instance( $transformer ) { $class_reflection = new \ReflectionClass( $transformer ); $plugin_basename = plugin_basename( $class_reflection->getFileName() ); $plugin_directory = strtok( $plugin_basename, '/' ); $plugins_data = get_plugins( '/' . $plugin_directory ); $plugin_data = array_shift( $plugins_data ); return $plugin_data['Name'] ?? esc_html__( 'Unknown', 'activitypub' ); } /** * Return whether the transformer supports a post type. * * @since version_number_transformer_management_placeholder * * @return string post_type Post type name. */ final public function supports_post_type( $post_type ) { return in_array( $post_type, $this->get_supported_post_types() ); } /** * Get the name used for registering the transformer with the ActivityPub plugin. * * @since version_number_transformer_management_placeholder * * @return string name */ abstract public function get_name(); /** * Get the display name for the ActivityPub transformer. * * @since version_number_transformer_management_placeholder * * @return string display name */ abstract public function get_label(); }