403Webshell
Server IP : 66.29.153.156  /  Your IP : 216.73.216.151
Web Server : LiteSpeed
System : Linux premium322.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User : lastyfjz ( 1521)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/lastyfjz/dermalaserclinic.co.uk/wp-content/plugins/boxzilla/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/lastyfjz/dermalaserclinic.co.uk/wp-content/plugins/boxzilla/src//class-box.php
<?php

namespace Boxzilla;

use WP_Post;

class Box
{
    /**
     * @var int
     */
    public $ID;

    /**
     * @var array
     */
    public $options = [];

    /**
     * @var string
     */
    public $title = '';

    /**
     * @var string
     */
    protected $content = '';

    /**
     * @var bool
     */
    public $enabled = false;

    /**
     * @var WP_Post
     */
    private $post;

    /**
     * @param WP_Post|int $post
     */
    public function __construct($post)
    {

        // fetch post if it hasn't been fetched yet
        if (! $post instanceof WP_Post) {
            $post = get_post($post);
        }

        // store ref to post
        $this->post = $post;

        // store ID in property for quick access
        $this->ID = $post->ID;

        // store title in property
        $this->title = $post->post_title;

        // store content in property
        $this->content = $post->post_content;

        // is this box enabled?
        $this->enabled = $post->post_status === 'publish';

        // load and store options in property
        $this->options = $this->load_options();
    }

    /**
     * Get the options for this box.
     **
     * @return array Array of box options
     */
    protected function load_options()
    {
        $defaults = [
            'css'                   => [
                'background_color' => '',
                'color'            => '',
                'width'            => '',
                'border_color'     => '',
                'border_width'     => '',
                'border_style'     => '',
                'position'         => 'bottom-right',
            ],
            'rules'                 => [
                0 => [
                    'condition' => '',
                    'value'     => '',
                ],
            ],
            'rules_comparision'     => 'any',
            'cookie'                => [
                'triggered' => 0,
                'dismissed' => 0,
            ],
            'trigger'               => 'percentage',
            'trigger_percentage'    => 65,
            'trigger_element'       => '',
            'trigger_time_on_site'  => 0,
            'trigger_time_on_page'  => 0,
            'animation'             => 'fade',
            'auto_hide'             => 0,
            'screen_size_condition' => [
                'condition' => 'larger',
                'value'     => 0,
            ],
            'closable'              => 1,
            'show_close_icon'       => 1,
        ];
        $box      = $this;

        $options = get_post_meta($this->ID, 'boxzilla_options', true);
        $options = is_array($options) ? $options : [];

        // merge options with default options
        $options = array_replace_recursive($defaults, $options);

        // allow others to filter the final array of options
        /**
         * Filter the options for a given box
         *
         * @param array $options
         * @param Box $box
         */
        $options = apply_filters('boxzilla_box_options', $options, $box);

        return $options;
    }

    /**
     * @return bool
     */
    public function is_enabled()
    {
        return $this->enabled;
    }

    /**
     * Get the options for this box
     *
     * @return array
     */
    public function get_options()
    {
        return $this->options;
    }

    /**
     * Get the close / hide icon for this box
     *
     * @return string
     */
    public function get_close_icon()
    {
        if (! $this->options['show_close_icon']) {
            return '';
        }

        $box  = $this;
        $html = '&times;';

        /**
         * Filters the HTML for the close icon.
         *
         * @param string $html
         * @param Box $box
         */
        $close_icon = (string) apply_filters('boxzilla_box_close_icon', $html, $box);

        return $close_icon;
    }

    /**
     * Get the content of this box
     *
     * @return string
     */
    public function get_content()
    {
        $content = $this->content;
        $box     = $this;

        // replace boxzilla specific shortcodes
        $close_link = "<a href=\"javascript:Boxzilla.dismiss({$this->ID});\">";

        $replacements = [
            '[boxzilla_close]'  => $close_link, // accept underscore and dash here for consistency with other shortcode
            '[boxzilla-close]'  => $close_link,
            '[/boxzilla_close]' => '</a>',
            '[/boxzilla-close]' => '</a>',
        ];

        $content = str_replace(array_keys($replacements), array_values($replacements), $content);

        /**
         * Filters the HTML for the box content
         *
         * @param string $content
         * @param Box $box
         */
        $content = apply_filters('boxzilla_box_content', $content, $box);
        return $content;
    }

    /**
     * Get options object for JS script.
     *
     * @return array
     */
    public function get_client_options()
    {
        $box = $this;

        $trigger = false;
        if ($box->options['trigger']) {
            $trigger = [
                'method' => $this->options['trigger'],
            ];

            if (isset($this->options[ 'trigger_' . $this->options['trigger'] ])) {
                $trigger['value'] = $this->options[ 'trigger_' . $this->options['trigger'] ];
            }
        }

        // build screenWidthCondition object (or null)
        $screen_width_condition = null;
        if ($box->options['screen_size_condition']['value'] > 0) {
            $screen_width_condition = [
                'condition' => $box->options['screen_size_condition']['condition'],
                'value'     => intval($box->options['screen_size_condition']['value']),
            ];
        }

        $post = $this->post;
        $client_options = [
            'id'                   => $box->ID,
            'icon'                 => $box->get_close_icon(),
            'content'              => '', // we grab this later from an HTML element
            'css'                  => array_filter($box->options['css']),
            'trigger'              => $trigger,
            'animation'            => $box->options['animation'],
            'cookie'               => [
                'triggered' => absint($box->options['cookie']['triggered']),
                'dismissed' => absint($box->options['cookie']['dismissed']),
            ],
            'rehide'               => (bool) $box->options['auto_hide'],
            'position'             => $box->options['css']['position'],
            'screenWidthCondition' => $screen_width_condition,
            'closable'             => ! ! $box->options['closable'],
            'post'                 => [
                'id'    => $post->ID,
                'title' => $post->post_title,
                'slug'  => $post->post_name,
            ],
        ];

        /**
         * Filter the final options for the JS Boxzilla client.
         *
         * @param array $client_options
         * @param Box $box
         */
        $client_options = apply_filters('boxzilla_box_client_options', $client_options, $box);

        return $client_options;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit