# buttonizer-multifunctional-button/3.6.0/app/Legacy/Frontend/Group/Group.php

Buttonizer – Floating Menus, Sticky Buttons, &amp; Popup Builder, version 3.6.0. 137 lines.

- Page: https://pluginprobe.com/plugins/buttonizer-multifunctional-button/3.6.0/code/app/Legacy/Frontend/Group/Group.php
- Raw: https://pluginprobe.com/plugins/buttonizer-multifunctional-button/3.6.0/raw/app/Legacy/Frontend/Group/Group.php
- Modified: 2026-08-05T17:29:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/buttonizer-multifunctional-button/3.6.0/code/app/Legacy/Frontend/Group/Group.php#L10-L20`.

```php
<?php

/*
 * SOFTWARE LICENSE INFORMATION
 *
 * Copyright (c) 2017 Buttonizer, all rights reserved.
 *
 * This file is part of Buttonizer
 *
 * For detailed information regarding to the licensing of
 * this software, please review the license.txt or visit:
 * https://buttonizer.pro/license/
 */
namespace Buttonizer\Legacy\Frontend\Group;

use Buttonizer\Legacy\Frontend\Group\Button\Button;
use Buttonizer\Legacy\Frontend\Buttonizer;
use Buttonizer\Core\Utils\Settings;
class Group {
    private $buttons = [];

    private $data;

    private $noLimit;

    private $totalButtons = 0;

    private $countMobile = 0;

    private $countDesktop = 0;

    /**
     * Buttons constructor.
     * @param $data
     */
    public function __construct( $data ) {
        $this->data = $data;
        $this->noLimit = Settings::getSetting( "no_limit" );
    }

    /**
     * Return option data
     *
     * @param $key
     * @param $default null
     * @return string
     */
    private function getOption( $key, $default = '' ) {
        return ( isset( $this->data[$key] ) ? $this->data[$key] : $default );
    }

    /**
     * Return option data as boolean
     *
     * @param $key
     * @param $default false
     * @return boolean
     */
    public function getBoolean( $key, $default = false ) {
        return ( isset( $this->data[$key] ) ? filter_var( $this->data[$key], FILTER_VALIDATE_BOOLEAN, [
            'options' => [
                'default' => false,
            ],
        ] ) === true : $default );
    }

    public function getId() {
        return $this->getOption( "id", null );
    }

    /**
     * Add button
     *
     * @param Button $button
     */
    public function add( Button $button ) {
        $this->totalButtons++;
        // Show button (on page OR only when opened
        if ( $button->showButton() ) {
            if ( !$this->noLimit ) {
                if ( ($button->getBoolean( 'show_desktop' ) || $button->getBoolean( 'show_mobile' )) && ($this->countDesktop >= 7 || $this->countMobile >= 7) ) {
                    // Is desktop, but no place on desktop? Force hide on desktop
                    if ( $button->getBoolean( 'show_desktop' ) && $this->countDesktop >= 7 && $this->countMobile < 7 && $button->getBoolean( 'show_mobile' ) ) {
                        $button->setOption( "show_desktop", false );
                    } else {
                        if ( $button->getBoolean( 'show_mobile' ) && $this->countMobile >= 7 && $this->countDesktop < 7 && $button->getBoolean( 'show_desktop' ) ) {
                            $button->setOption( "show_mobile", false );
                        } else {
                            return;
                        }
                    }
                }
            }
            // Add mobile
            if ( $button->getBoolean( 'show_mobile' ) ) {
                $this->countMobile++;
            }
            // Add desktop
            if ( $button->getBoolean( 'show_desktop' ) ) {
                $this->countDesktop++;
            }
            $this->buttons[] = $button->generate();
        }
    }

    /**
     * Show group?
     *
     * @return bool
     */
    public function show() {
        // Hide on all devices
        if ( !$this->getBoolean( 'show_desktop' ) && !$this->getBoolean( 'show_mobile' ) && !$this->getBoolean( 'single_button_mode' ) ) {
            Buttonizer::addEvent( [
                "id"          => $this->getOption( 'id', null ),
                "name"        => $this->getOption( 'name', "Unnamed" ),
                "button_type" => "group",
                "message"     => __( 'The group is hidden on all devices', 'buttonizer-multifunctional-button' ),
                "type"        => "all_devices_hidden",
            ] );
            return;
        }
        return ( count( $this->buttons ) > 0 ? true : false );
    }

    /**
     * Output
     */
    public function fix() {
        return [
            "data"    => $this->data,
            "buttons" => $this->buttons,
        ];
    }

}

```
