Skip to content

Instantly share code, notes, and snippets.

@lgedeon
Created November 19, 2021 07:31
Show Gist options
  • Save lgedeon/c83fc6a91f954e9bff7b90f6528b103a to your computer and use it in GitHub Desktop.
Save lgedeon/c83fc6a91f954e9bff7b90f6528b103a to your computer and use it in GitHub Desktop.
Wrapper that ended up being a huge fail.
public function add_notice_and_transparency( $widget_area ) {
$limit = $this->widget_area_limits()[$widget_area] ?? null;
$style = ".ione-module-widget-limit-$limit div:nth-child(n+" . ($limit + 2) . "){opacity:50%}";
if ( $limit ) {
printf(
'<p class="description">This widget area (sidebar) will only display the first %d widgets.</p><section class="ione-module-widget-limit-%d"><style>%s</style>',
absint( $limit ),
absint( $limit ),
$style
);
}
}
public function close_transparency_wrapper( $widget_area ) {
$limit = $this->widget_area_limits()[$widget_area] ?? null;
if ( $limit ) {
echo '</section>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment