View file upload/src/addons/MMO/Hide/BbCode/HideTags.php

File size: 1.25Kb
<?php

namespace MMO\Hide\BbCode;

/**
 * Class HideTags
 * @package MMO\Hide\BbCode
 */
class HideTags
{
    /**
     * @return array
     */
    public static function getHideTags()
    {
        $tags = [
            'hide',
            'posts',
            'likes',
            'days',
            'trophies',
            'club',
            'groups',
            'thanks',
            'reacts',
            'reply',
            'replythanks',
            'replyandthanks',
            'users',
            'usersid',
            'usersexc',
            'usersidexc',
        ];

        \XF::fire('mh_hide_add_tag_codes', [&$tags]);

        return $tags;
    }

    /**
     * @param $string
     * @param string $replacetext
     * @return string|string[]
     */
    public static function stripHideTags($string, $replacetext = '')
    {
        return \preg_replace('#\[(' . implode ('|', self::getHideTags()) . ')(=[^\]]*)?\](.*)\[/\1\]#siU', $replacetext, $string);
    }

    /**
     * @param $string
     * @return false|int
     */
    public static function findHideTags($string)
    {
        return \preg_match('#\[(' . implode ('|', self::getHideTags()) . ')(=[^\]]*)?\](.*)\[/\1\]#siU', $string);
    }
}