OwlCyberSecurity - MANAGER
Edit File: Widget.php
<?php /** * Copyright (с) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2022 All Rights Reserved * * Licensed under CLOUD LINUX LICENSE AGREEMENT * https://www.cloudlinux.com/legal/ */ namespace CloudLinux\SmartAdvice\App\Views; use CloudLinux\SmartAdvice\App\Advice\Manager; use CloudLinux\SmartAdvice\App\View; /** * Admin ui */ class Widget extends View { /** * Advice manager. * * @var Manager */ private $manager; /** * Constructor. * * @param Manager $manager advice. */ public function __construct( Manager $manager ) { $this->manager = $manager; if ( ! empty( $this->manager->advices() ) ) { add_action( 'wp_dashboard_setup', array( $this, 'add' ) ); } } /** * Add a new dashboard widget. * * @return void */ public function add() { if ( current_user_can( 'manage_options' ) ) { wp_add_dashboard_widget( 'cl_smart_advice_widget', 'SmartAdvice', array( $this, 'view' ), null, null, 'normal', 'high' ); } } /** * Output the contents of the dashboard widget. */ public function view() { $advices = $this->manager->advices(); $compatible = $this->manager->compatible(); $this->render( 'widget', array( 'advices' => $advices, 'compatible' => $compatible, ) ); } }