Skip to content

Commit

Permalink
Merge pull request #404 from codepress/release/4.7.6
Browse files Browse the repository at this point in the history
Release 4.7.6
  • Loading branch information
DGStefan authored Jun 7, 2024
2 parents 911464c + 6b27653 commit 67dddc0
Show file tree
Hide file tree
Showing 56 changed files with 6,259 additions and 1,163 deletions.
2 changes: 1 addition & 1 deletion assets/js/table.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions classes/Admin/Colors/ColorRepository.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

declare(strict_types=1);

namespace AC\Admin\Colors;

use AC\Admin\Colors\Storage\OptionFactory;
use AC\Admin\Colors\Type\Color;
use AC\Storage\Option;

final class ColorRepository implements ColorReader
{
Expand Down Expand Up @@ -38,9 +38,7 @@ public function find_all(): ColorCollection
if (null === $this->colors) {
$this->colors = new ColorCollection();

$data = $this->storage->get([
Option::OPTION_DEFAULT => [],
]);
$data = $this->storage->get() ?: [];

foreach ($data as $name => $color) {
$this->colors->add(new Color($color, $name));
Expand Down
6 changes: 4 additions & 2 deletions classes/Admin/Page/Addons.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ public function render(): string
<?php
foreach ($group['integrations'] as $addon) {
$actions = $this->render_actions($addon);
/* @var AC\Integration $addon */
/**
* @var AC\Integration $addon
*/

$view = new AC\View([
'logo' => Container::get_location()->with_suffix($addon->get_logo())->get_url(),
'title' => $addon->get_title(),
'slug' => $addon->get_slug(),
'description' => $addon->get_description(),
'link' => $addon->get_link(),
'link' => (string)$addon->get_url(),
'actions' => $actions ? $actions->render() : null,
]);

Expand Down
17 changes: 13 additions & 4 deletions classes/Admin/PageFactory/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,34 @@ class Settings implements PageFactoryInterface

private $is_acp_active;

private $edit_button;

public function __construct(
Location\Absolute $location,
MenuFactoryInterface $menu_factory,
bool $is_acp_active
bool $is_acp_active,
AC\Settings\General\EditButton $edit_button
) {
$this->location = $location;
$this->menu_factory = $menu_factory;
$this->is_acp_active = $is_acp_active;
$this->edit_button = $edit_button;
}

public function create()
public function create(): Page\Settings
{
$page = new Page\Settings(
new AC\Admin\View\Menu($this->menu_factory->create('settings')),
$this->location
);

$page->add_section(new Section\General([new Section\Partial\ShowEditButton()]))
->add_section(new Section\Restore(), 40);
$page
->add_section(
new Section\General([
new Section\Partial\ShowEditButton($this->edit_button),
])
)
->add_section(new Section\Restore(), 40);

if ( ! $this->is_acp_active) {
$page->add_section(new Section\ProCta(), 50);
Expand Down
2 changes: 1 addition & 1 deletion classes/Admin/Section/AddonStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AddonStatus extends View
public function __construct(Integration $integration)
{
parent::__construct([
'url' => $integration->get_link(),
'url' => (string)$integration->get_url(),
'class' => '-pink',
]);

Expand Down
12 changes: 8 additions & 4 deletions classes/Admin/Section/Partial/ShowEditButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

use AC\Form\Element\Toggle;
use AC\Renderable;
use AC\Settings\Option\EditButton;
use AC\Settings\General\EditButton;
use AC\View;

class ShowEditButton implements Renderable
{

private $option;

public function __construct()
public function __construct(EditButton $option)
{
$this->option = new EditButton();
$this->option = $option;
}

private function get_label(): string
Expand All @@ -27,7 +27,11 @@ private function get_label(): string

public function render(): string
{
$toggle = new Toggle($this->option->get_name(), $this->get_label(), $this->option->is_enabled());
$toggle = new Toggle(
$this->option->get_name(),
$this->get_label(),
$this->option->is_enabled()
);
$toggle->set_value('1');
$toggle->set_attribute('data-ajax-setting', $this->option->get_name());

Expand Down
166 changes: 87 additions & 79 deletions classes/Asset/Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,84 +4,92 @@

use AC\Asset\Script\Inline\Position;

class Script extends Enqueueable {

protected $in_footer;

public function __construct(
string $handle,
Location $location = null,
array $dependencies = [],
bool $in_footer = false
) {
parent::__construct( $handle, $location, $dependencies );

$this->in_footer = $in_footer;
}

protected function is_registered(): bool {
return wp_script_is( $this->get_handle(), 'registered' );
}

public function is_in_footer(): bool {
return $this->in_footer;
}

public function register(): void {
if ( ! $this->location instanceof Location ) {
return;
}

wp_register_script(
$this->get_handle(),
$this->location->get_url(),
$this->dependencies,
$this->get_version(),
$this->is_in_footer()
);
}

public function enqueue(): void {
if ( wp_script_is( $this->get_handle() ) ) {
return;
}

if ( ! $this->is_registered() ) {
$this->register();
}

wp_enqueue_script( $this->get_handle() );
}

public function localize( string $name, Script\Localize\Translation $translation ): self {
if ( ! $this->is_registered() ) {
$this->register();
}

wp_localize_script( $this->handle, $name, $translation->get_translation() );

return $this;
}

public function add_inline( string $data, Position $position = null ): self {
if ( null === $position ) {
$position = Position::after();
}

if ( ! $this->is_registered() ) {
$this->register();
}

wp_add_inline_script( $this->handle, $data, (string) $position );

return $this;
}

public function add_inline_variable( string $name, $data ): self {
return $this->add_inline(
sprintf( 'var %s = %s;', $name, json_encode( $data ) ),
Position::before()
);
}
class Script extends Enqueueable
{

protected $in_footer;

public function __construct(
string $handle,
Location $location = null,
array $dependencies = [],
bool $in_footer = false
) {
parent::__construct($handle, $location, $dependencies);

$this->in_footer = $in_footer;
}

protected function is_registered(): bool
{
return wp_script_is($this->get_handle(), 'registered');
}

public function is_in_footer(): bool
{
return $this->in_footer;
}

public function register(): void
{
if ( ! $this->location instanceof Location) {
return;
}

wp_register_script(
$this->get_handle(),
$this->location->get_url(),
$this->dependencies,
$this->get_version(),
$this->is_in_footer()
);
}

public function enqueue(): void
{
if (wp_script_is($this->get_handle())) {
return;
}

if ( ! $this->is_registered()) {
$this->register();
}

wp_enqueue_script($this->get_handle());
}

public function localize(string $name, Script\Localize\Translation $translation): self
{
if ( ! $this->is_registered()) {
$this->register();
}

wp_localize_script($this->handle, $name, $translation->get_translation());

return $this;
}

public function add_inline(string $data, Position $position = null): self
{
if (null === $position) {
$position = Position::after();
}

if ( ! $this->is_registered()) {
$this->register();
}

wp_add_inline_script($this->handle, $data, (string)$position);

return $this;
}

public function add_inline_variable(string $name, $data): self
{
return $this->add_inline(
sprintf('var %s = %s;', $name, json_encode($data)),
Position::before()
);
}

}
2 changes: 1 addition & 1 deletion classes/Check/AddonAvailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function display(Screen $screen): void

$link = sprintf(
'<a href="%s">%s</a>',
'https://www.admincolumns.com',
$this->integration->get_url(),
__('Get Admin Columns Pro', 'codepress-admin-columns')
);
$message = sprintf('%s %s', $support_text, $link);
Expand Down
Loading

0 comments on commit 67dddc0

Please sign in to comment.