<commit_before><?php

/**
 * Singular
 *
 * @package GrottoPress\Jentil\Setups\Views
 * @since 0.1.0
 *
 * @author GrottoPress <<EMAIL>>
 * @author <NAME>
 */

declare (strict_types = 1);

namespace GrottoPress\Jentil\Setups\Views;

use GrottoPress\WordPress\SUV\Setups\AbstractSetup;

/**
 * Singular
 *
 * @since 0.1.0
 */
final class Singular extends AbstractSetup
{
   /**
     * Run setup
     *
     * @since 0.1.0
     * @access public
     */
    public function run()
    {
        \add_filter('body_class', [$this, 'addBodyClasses']);
        // \add_action(
        //     'jentil_before_before_title',
        //     [$this, 'renderParentLink']
        // );
        \add_action('jentil_before_content', [$this, 'renderAttachment']);
        \add_filter(
            'jentil_singular_after_title',
            [$this, 'byline'],
            10,
            3
        );
        \add_action('jentil_after_title', [$this, 'renderByline']);
    }

    /**
     * Add <body> classes
     *
     * @since 0.1.0
     * @access public
     *
     * @filter body_class
     */
    public function addBodyClasses(array $classes): array
    {
        if (!$this->app->utilities->page->is('singular')) {
            return $classes;
        }

        global $post;

        if ($parent = $post->post_parent) {
            $classes[] = \sanitize_title("child-{$post->post_type}");

            for ($i = 1; $parent; ++$i) {
                $object = \get_post($parent);

                $classes[] = \sanitize_title(
                    "{$post->post_type}-parent-{$i}-{$object->ID}"
                );

                $parent = $object->post_parent;
            }
        }

        if ($page_template = \get_page_template_slug($post->ID)) {
            $classes[] = \sanitize_title($page_template);
        }

        if (\post_type_supports($post->post_type, 'comments')) {
            $classes[] = \get_option('show_avatars')
                ? 'show-avatars' : 'hide-avatars';
            $classes[] = \get_option('thread_comments')
                ? 'threaded-comments' : 'unthreaded-comments';
            $classes[] = \comments_open($post->ID)
                ? 'comments-open' : 'comments-closed';
        }

        return $classes;
    }

    /**
     * Post parent link
     *
     * @since 0.1.0
     * @access public
     *
     * @action jentil_before_before_title
     */
    public function renderParentLink()
    {
        if (!$this->app->utilities->page->is('singular')) {
            return;
        }

        global $post;

        if (!$post->post_parent) {
            return;
        }

        echo '<h4 class="parent entry-title">
            <a href="'.\get_permalink($post->post_parent).'">
                <span class="meta-nav">&laquo;</span> '.
                \get_the_title($post->post_parent)
           .'</a>
        </h4>';
    }

    /**
     * Attachment
     *
     * @since 0.1.0
     * @access public
     *
     * @action jentil_before_content
     */
    public function renderAttachment()
    {
        if (!$this->app->utilities->page->is('attachment')) {
            return;
        }

        \remove_filter('the_content', 'prepend_attachment');

        global $post;

        if (\wp_attachment_is_image($post->ID)) {
            $this->app->utilities->loader->loadPartial(
                'attachment',
                'image'
            );
        } elseif (\wp_attachment_is('audio', $post->ID)) {
            $this->app->utilities->loader->loadPartial(
                'attachment',
                'audio'
            );
        } elseif (\wp_attachment_is('video', $post->ID)) {
            $this->app->utilities->loader->loadPartial(
                'attachment',
                'video'
            );
        } else {
            $this->app->utilities->loader->loadPartial('attachment');
        }
    }

    /**
     * Byline
     *
     * Used for single posts when using the `index.php` template.
     *
     * @since 0.1.0
     * @access public
     *
     * @filter jentil_singular_after_title
     *
     * @return string
     */
    public function byline(
        string $output,
        int $id,
        string $separator
    ): string {
        if (!$this->app->utilities->page->is('singular', 'post')) {
            return $output;
        }

        return $this->_byline($id).'<div class="self-clear"></div>';
    }

    /**
     * Render byline
     *
     * Replicates the functionality above for when
     * using the singular.php template
     *
     * @since 0.1.0
     * @access public
     *
     * @action jentil_after_title
     */
    public function renderByline()
    {
        if (!$this->app->utilities->page->is('singular', 'post')) {
            return;
        }

        global $post;

        echo '<aside class="entry-meta after-title self-clear">';
        echo $this->_byline($post->ID);
        echo '</aside>';
    }

    /**
     * Single post after title
     *
     * @param int $id Post ID.
     *
     * @since 0.1.0
     * @access public
     *
     * @return string
     */
    private function _byline(int $id): string
    {
        $jentil_post = $this->app->utilities->post($id);

        $output = '';

        if (($avatar = $jentil_post->info([
            'types' => ['avatar__40']
        ])->list())) {
            $output .= $avatar;
        }<commit_msg>Replace check for singular post with 'single'<commit_after><?php

/**
 * Singular
 *
 * @package GrottoPress\Jentil\Setups\Views
 * @since 0.1.0
 *
 * @author GrottoPress <<EMAIL>>
 * @author <NAME>
 */

declare (strict_types = 1);

namespace GrottoPress\Jentil\Setups\Views;

use GrottoPress\WordPress\SUV\Setups\AbstractSetup;

/**
 * Singular
 *
 * @since 0.1.0
 */
final class Singular extends AbstractSetup
{
   /**
     * Run setup
     *
     * @since 0.1.0
     * @access public
     */
    public function run()
    {
        \add_filter('body_class', [$this, 'addBodyClasses']);
        // \add_action(
        //     'jentil_before_before_title',
        //     [$this, 'renderParentLink']
        // );
        \add_action('jentil_before_content', [$this, 'renderAttachment']);
        \add_filter(
            'jentil_singular_after_title',
            [$this, 'byline'],
            10,
            3
        );
        \add_action('jentil_after_title', [$this, 'renderByline']);
    }

    /**
     * Add <body> classes
     *
     * @since 0.1.0
     * @access public
     *
     * @filter body_class
     */
    public function addBodyClasses(array $classes): array
    {
        if (!$this->app->utilities->page->is('singular')) {
            return $classes;
        }

        global $post;

        if ($parent = $post->post_parent) {
            $classes[] = \sanitize_title("child-{$post->post_type}");

            for ($i = 1; $parent; ++$i) {
                $object = \get_post($parent);

                $classes[] = \sanitize_title(
                    "{$post->post_type}-parent-{$i}-{$object->ID}"
                );

                $parent = $object->post_parent;
            }
        }

        if ($page_template = \get_page_template_slug($post->ID)) {
            $classes[] = \sanitize_title($page_template);
        }

        if (\post_type_supports($post->post_type, 'comments')) {
            $classes[] = \get_option('show_avatars')
                ? 'show-avatars' : 'hide-avatars';
            $classes[] = \get_option('thread_comments')
                ? 'threaded-comments' : 'unthreaded-comments';
            $classes[] = \comments_open($post->ID)
                ? 'comments-open' : 'comments-closed';
        }

        return $classes;
    }

    /**
     * Post parent link
     *
     * @since 0.1.0
     * @access public
     *
     * @action jentil_before_before_title
     */
    public function renderParentLink()
    {
        if (!$this->app->utilities->page->is('singular')) {
            return;
        }

        global $post;

        if (!$post->post_parent) {
            return;
        }

        echo '<h4 class="parent entry-title">
            <a href="'.\get_permalink($post->post_parent).'">
                <span class="meta-nav">&laquo;</span> '.
                \get_the_title($post->post_parent)
           .'</a>
        </h4>';
    }

    /**
     * Attachment
     *
     * @since 0.1.0
     * @access public
     *
     * @action jentil_before_content
     */
    public function renderAttachment()
    {
        if (!$this->app->utilities->page->is('attachment')) {
            return;
        }

        \remove_filter('the_content', 'prepend_attachment');

        global $post;

        if (\wp_attachment_is_image($post->ID)) {
            $this->app->utilities->loader->loadPartial(
                'attachment',
                'image'
            );
        } elseif (\wp_attachment_is('audio', $post->ID)) {
            $this->app->utilities->loader->loadPartial(
                'attachment',
                'audio'
            );
        } elseif (\wp_attachment_is('video', $post->ID)) {
            $this->app->utilities->loader->loadPartial(
                'attachment',
                'video'
            );
        } else {
            $this->app->utilities->loader->loadPartial('attachment');
        }
    }

    /**
     * Byline
     *
     * Used for single posts when using the `index.php` template.
     *
     * @since 0.1.0
     * @access public
     *
     * @filter jentil_singular_after_title
     *
     * @return string
     */
    public function byline(
        string $output,
        int $id,
        string $separator
    ): string {
        if (!$this->app->utilities->page->is('single')) {
            return $output;
        }

        return $this->_byline($id).'<div class="self-clear"></div>';
    }

    /**
     * Render byline
     *
     * Replicates the functionality above for when
     * using the singular.php template
     *
     * @since 0.1.0
     * @access public
     *
     * @action jentil_after_title
     */
    public function renderByline()
    {
        if (!$this->app->utilities->page->is('single')) {
            return;
        }

        global $post;

        echo '<aside class="entry-meta after-title self-clear">';
        echo $this->_byline($post->ID);
        echo '</aside>';
    }

    /**
     * Single post after title
     *
     * @param int $id Post ID.
     *
     * @since 0.1.0
     * @access public
     *
     * @return string
     */
    private function _byline(int $id): string
    {
        $jentil_post = $this->app->utilities->post($id);

        $output = '';

        if (($avatar = $jentil_post->info([
            'types' => ['avatar__40']
        ])->list())) {
            $output .= $avatar;
        }
{'fraction_non_alphanumeric': 0.156377835626627, 'fraction_numerical': 0.00669393826701376, 'mean_word_length': 1.620462850182704, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 149, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3002033', 'n_tokens_mistral': 3397, 'n_tokens_neox': 3279, 'n_words': 570}