` markup. */ function openstation_content_graph_icon_svg() { return ''; } /** * Whether the current user should see Content Graph. * * Mirrors the my-wordpress gate, anyone who can edit posts can view * the link map of the content they author and maintain. * * @return bool */ function openstation_content_graph_user_can_use() { $can = current_user_can( 'edit_posts' ); /** * Filter whether the current user can see the Content Graph * desktop icon and window. * * @param bool $can Default: edit_posts capability. */ return (bool) apply_filters( 'openstation_content_graph_user_can_use', $can ); } /** * Build the descriptor list of post types eligible for the graph. * Defaults to every public post type (so CPTs participate by * default), matching the user-facing filter bar that ships ON for all * of them. * * @return array[] Each entry: `array( 'slug', 'label', 'icon', 'taxonomies' )`. */ function openstation_content_graph_post_types() { $types = get_post_types( array( 'public' => true ), 'objects' ); $result = array(); foreach ( $types as $type ) { // `attachment` is public but participates in the graph as media // (rendered in the side panel) rather than as a node — skip it // on the node-type axis to avoid every image becoming a node. if ( 'attachment' === $type->name ) { continue; } $result[] = array( 'slug' => (string) $type->name, 'label' => (string) $type->labels->name, 'icon' => (string) ( ! empty( $type->menu_icon ) ? $type->menu_icon : 'dashicons-admin-post' ), 'taxonomies' => array( 'category' => is_object_in_taxonomy( $type->name, 'category' ), 'post_tag' => is_object_in_taxonomy( $type->name, 'post_tag' ), ), ); } /** * Filter the list of post types shown in the Content Graph filter * bar. Each entry declares `slug`, `label`, `icon`, and optionally * `taxonomies` (`array( 'category' => bool, 'post_tag' => bool )`); * entries missing `taxonomies` get it derived from * `is_object_in_taxonomy()` after filtering. Removing * an entry hides it from the filter bar AND excludes it from the * graph entirely. * * @param array[] $result Default: every public post type except attachment. */ $filtered = apply_filters( 'openstation_content_graph_post_types', $result ); $filtered = is_array( $filtered ) ? array_values( $filtered ) : $result; foreach ( $filtered as $i => $entry ) { $slug = isset( $entry['slug'] ) ? (string) $entry['slug'] : ''; $filtered[ $i ]['taxonomies'] = array( 'category' => isset( $entry['taxonomies'] ) ? ! empty( $entry['taxonomies']['category'] ) : is_object_in_taxonomy( $slug, 'category' ), 'post_tag' => isset( $entry['taxonomies'] ) ? ! empty( $entry['taxonomies']['post_tag'] ) : is_object_in_taxonomy( $slug, 'post_tag' ), ); } return $filtered; } /** * Render the Content Graph window's static template body. The bundle * mounts its UI into `[data-os-content-graph-root]`. */ function openstation_content_graph_render_template() { ob_start(); ?>