<commit_before><?php
/*
 * This file is part of WPCore project.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace WPCore;

/**
 * WP shortcode
 *
 * @author <NAME> <<EMAIL>>
 */
class WPshortcode extends WPaction
{
    protected $slug;
    protected $view;

    public function __construct($shortcode, View $view = null)
    {
        $this->slug = $shortcode;
        $this->view = $view;

        parent::__construct('init');
    }

    public function action()
    {
        add_shortcode($this->slug, array($this, 'callback'));
    }

    public function callback()
    {
        if (is_null($this->view)) {
            return '';
        }
        
        return $this->view->getContent();
    }
}<commit_msg>Added shortcode attributes to view data<commit_after><?php
/*
 * This file is part of WPCore project.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace WPCore;

/**
 * WP shortcode
 *
 * @author <NAME> <<EMAIL>>
 */
class WPshortcode extends WPaction
{
    protected $slug;
    protected $view;

    public function __construct($shortcode, View $view = null)
    {
        $this->slug = $shortcode;
        $this->view = $view;

        parent::__construct('init');
    }

    public function action()
    {
        add_shortcode($this->slug, array($this, 'callback'));
    }

    public function callback($atts)
    {
        if (is_null($this->view)) {
            return '';
        }
        
        $this->view->appendData(array('shortcodeAtts' => $atts));
        return $this->view->getContent();
    }
}
{'fraction_non_alphanumeric': 0.14003387916431395, 'fraction_numerical': 0.0, 'mean_word_length': 2.467710371819961, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 30, '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': '2442758', 'n_tokens_mistral': 532, 'n_tokens_neox': 530, 'n_words': 147}