revert 8cad3c2d3d
revert Merge pull request 'feat(widgets): add phase 4 validation and accessibility' (#6) from worktree/widgets-phase-4 into main Reviewed-on: https://gitea.rutua.cn/kate522/wordpress-theme-aksrt/pulls/6
This commit is contained in:
1 parent
e1723a8f08
commit
463ef36ed3
23 files changed
+53
-8078
No files matched your search
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AKSRT\WidgetSystem;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/** Pure visibility rules shared by rendering and contract tests. */
|
||||
final class WidgetVisibility {
|
||||
public static function should_render(array $instance, ?int $current_id = null, ?bool $singular = null): bool {
|
||||
$type = (string) ($instance['show_id_type'] ?? '');
|
||||
$ids = RendererHelpers::ids((string) ($instance['show_ids'] ?? ''));
|
||||
if ($type === '' || !$ids) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($singular === null) {
|
||||
$singular = function_exists('is_singular') && is_singular();
|
||||
}
|
||||
if ($current_id === null) {
|
||||
$current_id = $singular && function_exists('get_queried_object_id') ? (int) get_queried_object_id() : 0;
|
||||
}
|
||||
$matched = $singular && in_array($current_id, $ids, true);
|
||||
return $type === 'show' ? $matched : !$matched;
|
||||
}
|
||||
|
||||
public static function device_class(array $instance): string {
|
||||
$type = (string) ($instance['show_type'] ?? 'all');
|
||||
if ($type === 'only_pc') {
|
||||
return 'aksrt-widget--only-pc';
|
||||
}
|
||||
return $type === 'only_sm' ? 'aksrt-widget--only-mobile' : '';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user