%s

', get_block_wrapper_attributes( [ 'class' => 'rooster-docs__chapters' ] ), esc_html__( "The manual's chapters print here.", 'ai-eshop-optimizer' ) ) ); } return; } $current = AIEO_Docs::current_term(); $post_id = is_singular() ? (int) get_queried_object_id() : 0; $path = $current ? array_merge( [ (int) $current->term_id ], get_ancestors( (int) $current->term_id, 'category', 'taxonomy' ) ) : []; $id = wp_unique_id( 'rooster-docs-' ); $phone = function_exists( 'rooster_device_class' ) && 'mobile' === rooster_device_class(); $on = static function ( string $directive ) use ( $phone ): string { return $phone ? '' : ' ' . $directive; }; $pages = static function ( WP_Term $term ) use ( $post_id ): string { $out = ''; foreach ( AIEO_Docs::pages( $term ) as $post ) { $is_current = (int) $post->ID === $post_id; $out .= '' . esc_html( (string) get_the_title( $post ) ) . ''; } return $out; }; $items = $pages( $manual ); $templates = ''; $chapter_now = null; foreach ( AIEO_Docs::chapters( $manual ) as $chapter ) { $open = in_array( (int) $chapter->term_id, $path, true ); $link = '' . esc_html( $chapter->name ) . ''; $inner = ''; if ( $open ) { $chapter_now = $chapter; $inner = $pages( $chapter ); foreach ( AIEO_Docs::chapters( $chapter ) as $sub ) { $sub_open = in_array( (int) $sub->term_id, $path, true ); $inner .= '' . esc_html( $sub->name ) . '' . ( $sub_open ? '' : '' ) . ''; } $items .= '
  • ' . $link . '
      ' . $inner . '
  • '; continue; } $inner = $pages( $chapter ); foreach ( AIEO_Docs::chapters( $chapter ) as $sub ) { $inner .= '
  • ' . esc_html( $sub->name ) . '
  • '; } if ( '' === $inner ) { $items .= '
  • ' . $link . '
  • '; continue; } $items .= '
  • ' . $link . '
  • '; $templates .= ''; } $remember = ! empty( $attributes['remember'] ); $manual_p = '

    ' . esc_html( $manual->name ) . '

    '; $filter = ''; if ( ! empty( $attributes['filter'] ) ) { $filter = '

    ' . '

    '; } $tree = ''; if ( '' !== $templates ) { $tree .= ''; } $tree .= ''; if ( $phone ) { $where = $chapter_now ? $chapter_now->name : $manual->name; $wrapper = get_block_wrapper_attributes( [ 'class' => 'rooster-docs__chapters is-compact', 'aria-label' => __( 'Chapters', 'ai-eshop-optimizer' ), 'data-rooster-ui' => 'rooster-one/docs-chapters', 'data-wp-interactive' => 'rooster-docs/chapters', ] ); $bar = ''; $sheet = ''; AIEO_Engine_Blocks::out( sprintf( '', $wrapper, $bar . $sheet ) ); return; } $wrapper = get_block_wrapper_attributes( [ 'class' => 'rooster-docs__chapters', 'aria-label' => __( 'Chapters', 'ai-eshop-optimizer' ), 'data-rooster-ui' => 'rooster-one/docs-chapters', 'data-wp-interactive' => 'rooster-docs/chapters', 'data-wp-context' => wp_json_encode( [ 'manual' => $manual->slug, 'remember' => $remember ] ), 'data-wp-init' => 'callbacks.init', ] ); AIEO_Engine_Blocks::out( sprintf( '', $wrapper, $manual_p . $filter . $tree ) );