...
 
Commits (7)
......@@ -3,8 +3,7 @@ version: '3.5'
networks:
default:
external: true
name: proxy
name: bezirksblaetter
volumes:
database:
......
<?php
/**
* Performs a safe (local) redirect, using wp_redirect().
*
* Checks whether the $location is using an allowed host, if it has an absolute
* path. A plugin can therefore set or remove allowed host(s) to or from the
* list.
*
* If the host is not allowed, then the redirect defaults to wp-admin on the siteurl
* instead. This prevents malicious redirects which redirect to another host,
* but only used in a few places.
*
* Note: wp_safe_redirect() does not exit automatically, and should almost always be
* followed by a call to `exit;`:
*
* wp_safe_redirect( $url );
* exit;
*
* Exiting can also be selectively manipulated by using wp_safe_redirect() as a conditional
* in conjunction with the {@see 'wp_redirect'} and {@see 'wp_redirect_location'} filters:
*
* if ( wp_safe_redirect( $url ) ) {
* exit;
* }
*
* @since 2.3.0
* @since 5.1.0 The return value from wp_redirect() is now passed on, and the `$x_redirect_by` parameter was added.
*
* @param string $location The path or URL to redirect to.
* @param int $status Optional. HTTP response status code to use. Default '302' (Moved Temporarily).
* @param string $x_redirect_by Optional. The application doing the redirect. Default 'WordPress'.
* @return bool $redirect False if the redirect was cancelled, true otherwise.
*/
function wp_safe_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) {
// Need to look at the URL the way it will end up in wp_redirect()
$location = wp_sanitize_redirect( $location );
/**
* Filters the redirect fallback URL for when the provided redirect is not safe (local).
*
* @since 4.3.0
*
* @param string $fallback_url The fallback URL to use by default.
* @param int $status The HTTP response status code to use.
*/
$location = wp_validate_redirect( $location, apply_filters( 'wp_safe_redirect_fallback', admin_url(), $status ) );
// See: https://github.com/polylang/polylang/issues/452
if ( $x_redirect_by === 'Polylang Pro' ) {
header( 'Vary: Accept-Language' );
}
return wp_redirect( $location, $status, $x_redirect_by );
}
......@@ -32,27 +32,9 @@ add_filter('manage_media_columns', function (array $posts_columns): array {
}, 10, 1);
if (class_exists('\Cachify')) {
/**
* Alter time to live of captcha data if Cachify plugin is installed.
*
* @return int
*/
add_filter('bezirksblaetter/captcha_ttl', function (): int {
// Read Cachify config
$config = get_option('cachify');
$page_cache_length = intval($config['cache_expires']) * HOUR_IN_SECONDS;
// If pages are cached indefinitely, set TTL to one year,
// otherwise just set TTL to whatever page cache length is.
return ($page_cache_length === 0) ? YEAR_IN_SECONDS : $page_cache_length;
}, 10, 0);
}
// BC Security integration
if (interface_exists(\BlueChip\Security\Modules\Checklist\Hooks::class)) {
/**
* Ignore premium plugins in core integrity check.
*
......@@ -60,24 +42,22 @@ if (interface_exists(\BlueChip\Security\Modules\Checklist\Hooks::class)) {
*
* @return array
*/
add_filter(\BlueChip\Security\Modules\Checklist\Hooks::PLUGINS_TO_CHECK_FOR_INTEGRITY, function (array $plugins): array {
function unsetPremiumPlugins(array $plugins): array
{
// Polylang Pro is not hosted in Plugins Directory.
unset($plugins['polylang-pro/polylang.php']);
return $plugins;
});
}
/**
* Ignore premium plugins in core integrity check.
*/
add_filter(\BlueChip\Security\Modules\Checklist\Hooks::PLUGINS_TO_CHECK_FOR_INTEGRITY, __NAMESPACE__ . '\\unsetPremiumPlugins', 10, 1);
/**
* Ignore premium plugins in removed plugins check.
*
* @param array $plugins
*
* @return array
*/
add_filter(\BlueChip\Security\Modules\Checklist\Hooks::PLUGINS_TO_CHECK_FOR_REMOVAL, function (array $plugins): array {
// Polylang Pro is not hosted in Plugins Directory.
unset($plugins['polylang-pro/polylang.php']);
return $plugins;
});
add_filter(\BlueChip\Security\Modules\Checklist\Hooks::PLUGINS_TO_CHECK_FOR_REMOVAL, __NAMESPACE__ . '\\unsetPremiumPlugins', 10, 1);
}
......
<?php
/**
* Integration with 3rd party plugins
* Integration with particluar 3rd party plugins:
* - Nginx Cache: https://wordpress.org/plugins/nginx-cache/
* - Polylang Pro: https://polylang.pro/
* - Statify: https://wordpress.org/plugins/statify/
*
* @package Bezirksblätter
*/
namespace App\Integration;
if (class_exists('Cachify')) {
/**
* Flush Cachify cache when post category or post tag is edited.
*/
add_action('edit_category', [\Cachify::class, 'flush_total_cache']);
add_action('edit_post_tag', [\Cachify::class, 'flush_total_cache']);
/**
* Flush Cachify cache when media gallery or media tag is edited.
*/
add_action('edit_' . MEDIA_GALLERIES_TAXONOMY, [\Cachify::class, 'flush_total_cache']);
add_action('edit_' . MEDIA_TAGS_TAXONOMY, [\Cachify::class, 'flush_total_cache']);
/**
* Flush Cachify cache when media item is added or edited.
*/
add_action('add_attachment', [\Cachify::class, 'flush_total_cache']);
add_action('edit_attachment', [\Cachify::class, 'flush_total_cache']);
}
if (class_exists('NginxCache')) {
/**
* Flush Nginx cache ...
*/
add_filter('nginx_cache_purge_actions', function (array $actions): array {
// ...when post category or post tag is edited.
$actions[] = 'edit_category';
$actions[] = 'edit_post_tag';
// ...when media gallery or media tag is edited.
$actions[] = 'edit_' . MEDIA_GALLERIES_TAXONOMY;
$actions[] = 'edit_' . MEDIA_TAGS_TAXONOMY;
// ...when media item is added or edited.
$actions[] = 'add_attachment';
$actions[] = 'edit_attachment';
return $actions;
}, 10, 1);
}
/**
* Flush Nginx cache ...
*/
add_filter('nginx_cache_purge_actions', function (array $actions): array {
// ...when post category or post tag is edited.
$actions[] = 'edit_category';
$actions[] = 'edit_post_tag';
// ...when media gallery or media tag is edited.
$actions[] = 'edit_' . MEDIA_GALLERIES_TAXONOMY;
$actions[] = 'edit_' . MEDIA_TAGS_TAXONOMY;
// ...when media item is added or edited.
$actions[] = 'add_attachment';
$actions[] = 'edit_attachment';
return $actions;
}, 10, 1);
/**
......
......@@ -5,7 +5,7 @@
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Bezirksblätter
* @version 20200201
* @version 20200202
*/
// If instead of usual while - we're assuming only single post here.
......@@ -28,7 +28,7 @@ if (have_posts()) {
?>
<div class="image-header vh-100" id="image-header">
<figure itemscope itemtype="http://schema.org/ImageObject">
<?= wp_get_attachment_image($post_id, 'large'); // Output large thumbnail and let the browser decide based on srcset ?>
<?= wp_get_attachment_image($post_id, 'large', false, ['data-skip-lazy' => true]); // Output large thumbnail and let the browser decide based on srcset ?>
<?php if ($image_caption) { ?>
<figcaption itemprop="caption description"><?= esc_html($image_caption); ?></figcaption>
<?php } ?>
......
......@@ -3,7 +3,7 @@
* Single (blog) post template
*
* @package Bezirksblätter
* @version 20170701
* @version 20200202
*/
if (has_post_thumbnail()) {
......@@ -13,7 +13,7 @@ if (has_post_thumbnail()) {
?>
<div class="image-header vmin-75" id="image-header">
<figure>
<?= get_the_post_thumbnail($post, 'large'); // Output large thumbnail and let the browser decide based on srcset ?>
<?= get_the_post_thumbnail($post, 'large', ['data-skip-lazy' => true]); // Output large thumbnail and let the browser decide based on srcset ?>
</figure>
<header>
<h1 class="entry-title"><?= get_the_title(); ?></h1>
......