Plugin Directory

Changeset 3140303


Ignore:
Timestamp:
08/23/2024 10:38:26 AM (18 months ago)
Author:
pmpr
Message:

update codebase

Location:
pmpr-ir
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pmpr-ir/tags/1.3.5/src/Pmpr/Plugin/Pmpr/Component/Common.php

    r3078042 r3140303  
    3535    public function addActions()
    3636    {
    37         $this->addAction('admin_init', [$this, 'addRequiredComponentsJobs']);
     37        $this->addAction('admin_init', [$this, 'installRequiredComponents']);
    3838
    3939        parent::addActions();
     
    5454    }
    5555
    56     public function addRequiredComponentsJobs()
     56    public function installRequiredComponents()
    5757    {
     58        $isDebug = (bool)$this->getHelper()->getServer()->getRequest('pr-dev', false);
     59
     60        $HTMLHelper = $this->getHelper()->getHTML();
    5861        if ($this->isRequirementsSatisfied()) {
    5962
    6063            $componentHelper = $this->getHelper()->getComponent();
    6164            if (!$componentHelper->isRequiredInstalled()) {
     65
    6266                $components = $componentHelper->getRequired();
     67
    6368                foreach ($components as $component) {
    6469
    65                     $this->getManager()->install($component);
     70                    $result = $this->getManager()->install($component);
     71                    if (!$result || is_wp_error($result)) {
     72
     73                        $reason = '';
     74                        if (is_wp_error($result)) {
     75                            $reason = $result->get_error_message();
     76                        }
     77                        if ($isDebug) {
     78
     79                            $HTMLHelper->renderNotice(sprintf('can not install %s: %s', $component, $reason));
     80                        }
     81                    } else if ($isDebug) {
     82
     83                        $HTMLHelper->renderNotice(sprintf('%s installed', $component));
     84                    }
    6685                }
     86            } else if ($isDebug) {
     87
     88                $HTMLHelper->renderNotice('common components already installed');
    6789            }
     90        } else if ($isDebug) {
     91
     92            $HTMLHelper->renderNotice('can not install common components: requirements not satisfied');
    6893        }
    6994    }
  • pmpr-ir/trunk/src/Pmpr/Plugin/Pmpr/Component/Common.php

    r3078042 r3140303  
    3535    public function addActions()
    3636    {
    37         $this->addAction('admin_init', [$this, 'addRequiredComponentsJobs']);
     37        $this->addAction('admin_init', [$this, 'installRequiredComponents']);
    3838
    3939        parent::addActions();
     
    5454    }
    5555
    56     public function addRequiredComponentsJobs()
     56    public function installRequiredComponents()
    5757    {
     58        $isDebug = (bool)$this->getHelper()->getServer()->getRequest('pr-dev', false);
     59
     60        $HTMLHelper = $this->getHelper()->getHTML();
    5861        if ($this->isRequirementsSatisfied()) {
    5962
    6063            $componentHelper = $this->getHelper()->getComponent();
    6164            if (!$componentHelper->isRequiredInstalled()) {
     65
    6266                $components = $componentHelper->getRequired();
     67
    6368                foreach ($components as $component) {
    6469
    65                     $this->getManager()->install($component);
     70                    $result = $this->getManager()->install($component);
     71                    if (!$result || is_wp_error($result)) {
     72
     73                        $reason = '';
     74                        if (is_wp_error($result)) {
     75                            $reason = $result->get_error_message();
     76                        }
     77                        if ($isDebug) {
     78
     79                            $HTMLHelper->renderNotice(sprintf('can not install %s: %s', $component, $reason));
     80                        }
     81                    } else if ($isDebug) {
     82
     83                        $HTMLHelper->renderNotice(sprintf('%s installed', $component));
     84                    }
    6685                }
     86            } else if ($isDebug) {
     87
     88                $HTMLHelper->renderNotice('common components already installed');
    6789            }
     90        } else if ($isDebug) {
     91
     92            $HTMLHelper->renderNotice('can not install common components: requirements not satisfied');
    6893        }
    6994    }
Note: See TracChangeset for help on using the changeset viewer.