Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 937b36b27f | |||
| 76902390e4 | |||
| e1f7db91f8 | |||
| 05c9a70e01 | |||
| af8a9447b0 | |||
| b0eb1d9526 | |||
| c6b0919eb3 | |||
| 4f87ca1475 | |||
| 271b7fef7f | |||
| 32f17f6e9d | |||
| a7c71933a8 | |||
| a3f69b4118 | |||
| 84ebfcadf2 | |||
| 5152784a20 | |||
| d066342413 | |||
| eaf31ba27e | |||
| 0d6ff33a68 | |||
| d925911261 | |||
| c06b2e25ba | |||
| 4424799bb0 |
@@ -0,0 +1,12 @@
|
||||
:root {
|
||||
--site-title-color: #f7f7fa;
|
||||
--primary-color: #f7f7fa;
|
||||
--secondary-color: #f7f7fa;
|
||||
--light-color: #1e1f29;
|
||||
--grey-color: #f7f7fa;
|
||||
--dark-color: #f7f7fa;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #1e1f29;
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/* =========================
|
||||
Local Fonts
|
||||
========================= */
|
||||
|
||||
/* OSWALD */
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
src: url('../fonts/oswald-400.woff2') format('woff2');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
src: url('../fonts/oswald-500.woff2') format('woff2');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
src: url('../fonts/oswald-700.woff2') format('woff2');
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
|
||||
/* ROBOTO */
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
src: url('../fonts/roboto-400.woff2') format('woff2');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
src: url('../fonts/roboto-500.woff2') format('woff2');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
src: url('../fonts/roboto-700.woff2') format('woff2');
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
|
||||
/* =========================
|
||||
Typography System
|
||||
========================= */
|
||||
|
||||
:root {
|
||||
--primary-font: 'Oswald', var(--zeitfresser-heading-fallback);
|
||||
--secondary-font: 'Roboto', var(--zeitfresser-body-fallback);
|
||||
|
||||
--site-identity-font-size: 40px;
|
||||
|
||||
--font-weight: 400;
|
||||
--line-height: 1.6;
|
||||
}
|
||||
|
||||
|
||||
/* =========================
|
||||
Base Typography
|
||||
========================= */
|
||||
|
||||
body {
|
||||
font-family: var(--secondary-font);
|
||||
font-weight: var(--font-weight);
|
||||
line-height: var(--line-height);
|
||||
}
|
||||
|
||||
|
||||
/* =========================
|
||||
Headlines
|
||||
========================= */
|
||||
|
||||
h1, h2, h3, h4, h5, h6,
|
||||
.entry-title {
|
||||
font-family: var(--primary-font);
|
||||
font-weight: 500;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
|
||||
/* =========================
|
||||
Site Title
|
||||
========================= */
|
||||
|
||||
.site-title,
|
||||
.site-title a {
|
||||
font-family: var(--primary-font);
|
||||
font-size: var(--site-identity-font-size);
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
|
||||
/* =========================
|
||||
Content Typography
|
||||
========================= */
|
||||
|
||||
.site-description,
|
||||
.entry-content,
|
||||
.post-content,
|
||||
.inner-article-content {
|
||||
font-family: var(--secondary-font);
|
||||
}
|
||||
|
||||
html {
|
||||
font-synthesis: none;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+395
-113
@@ -17,11 +17,68 @@ if ( ! defined( 'DAISY_BLOG_VERSION' ) ) {
|
||||
define( 'DAISY_BLOG_VERSION', ZEITFRESSER_VERSION );
|
||||
}
|
||||
|
||||
if ( ! defined( 'ZEITFRESSER_IMAGE_OPTIMIZATION_VERSION' ) ) {
|
||||
define( 'ZEITFRESSER_IMAGE_OPTIMIZATION_VERSION', '1.0' );
|
||||
}
|
||||
|
||||
require get_template_directory() . '/inc/zeitfresser-helpers.php';
|
||||
require get_template_directory() . '/inc/legacy-aliases.php';
|
||||
require get_template_directory() . '/inc/performance-tools.php';
|
||||
require get_template_directory() . '/inc/zeitfresser-toc.php';
|
||||
|
||||
/**
|
||||
* Upload Handler
|
||||
*/
|
||||
add_filter('wp_handle_upload', 'zeitfresser_capture_original_upload', 10, 2);
|
||||
|
||||
/**
|
||||
* Capture original upload path safely
|
||||
*/
|
||||
function zeitfresser_capture_original_upload( $upload, $context ) {
|
||||
|
||||
if ( empty( $upload['file'] ) ) {
|
||||
return $upload;
|
||||
}
|
||||
|
||||
// Store temporarily (request-scoped)
|
||||
$GLOBALS['zeitfresser_last_uploaded_file'] = $upload['file'];
|
||||
|
||||
return $upload;
|
||||
}
|
||||
add_filter( 'wp_handle_upload', 'zeitfresser_capture_original_upload', 10, 2 );
|
||||
|
||||
/**
|
||||
* Persist original file path to attachment meta
|
||||
*/
|
||||
function zeitfresser_store_original_file( $attachment_id ) {
|
||||
|
||||
if ( ! wp_attachment_is_image( $attachment_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( empty( $GLOBALS['zeitfresser_last_uploaded_file'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$file = $GLOBALS['zeitfresser_last_uploaded_file'];
|
||||
|
||||
// Safety: ensure file still exists
|
||||
if ( ! file_exists( $file ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent overwrite if already set
|
||||
if ( get_post_meta( $attachment_id, '_zeitfresser_original_file', true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_post_meta(
|
||||
$attachment_id,
|
||||
'_zeitfresser_original_file',
|
||||
$file
|
||||
);
|
||||
}
|
||||
add_action( 'add_attachment', 'zeitfresser_store_original_file' );
|
||||
|
||||
/**
|
||||
* Theme setup.
|
||||
*
|
||||
@@ -45,16 +102,6 @@ function zeitfresser_setup() {
|
||||
'script',
|
||||
)
|
||||
);
|
||||
add_theme_support(
|
||||
'custom-background',
|
||||
apply_filters(
|
||||
'zeitfresser_custom_background_args',
|
||||
array(
|
||||
'default-image' => '',
|
||||
'default-color' => zeitfresser_get_default_background_color(),
|
||||
)
|
||||
)
|
||||
);
|
||||
add_theme_support( 'customize-selective-refresh-widgets' );
|
||||
add_theme_support(
|
||||
'custom-logo',
|
||||
@@ -79,6 +126,19 @@ function zeitfresser_setup() {
|
||||
}
|
||||
add_action( 'after_setup_theme', 'zeitfresser_setup' );
|
||||
|
||||
/**
|
||||
* Register optimized image sizes
|
||||
*/
|
||||
function zeitfresser_custom_image_sizes() {
|
||||
|
||||
// Content images (main article)
|
||||
add_image_size( 'zeitfresser-content', 720, 0, false );
|
||||
|
||||
// Archive / card layout
|
||||
add_image_size( 'zeitfresser-card', 480, 0, false );
|
||||
}
|
||||
add_action( 'after_setup_theme', 'zeitfresser_custom_image_sizes' );
|
||||
|
||||
/**
|
||||
* Set the content width in pixels.
|
||||
*
|
||||
@@ -151,7 +211,6 @@ function zeitfresser_scripts() {
|
||||
array(),
|
||||
zeitfresser_asset_version( '/style.css' )
|
||||
);
|
||||
wp_style_add_data( 'zeitfresser', 'rtl', 'replace' );
|
||||
|
||||
wp_enqueue_script(
|
||||
'zeitfresser-navigation',
|
||||
@@ -183,7 +242,47 @@ function zeitfresser_scripts() {
|
||||
wp_enqueue_script( 'comment-reply' );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_scripts' );
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_scripts', 10 );
|
||||
|
||||
|
||||
/**
|
||||
* Load RTL stylesheet from /css folder
|
||||
*/
|
||||
function zeitfresser_rtl_styles() {
|
||||
if ( is_rtl() ) {
|
||||
wp_enqueue_style(
|
||||
'zeitfresser-rtl',
|
||||
get_template_directory_uri() . '/css/style-rtl.css',
|
||||
array('zeitfresser'),
|
||||
filemtime(get_template_directory() . '/css/style-rtl.css')
|
||||
);
|
||||
}
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_rtl_styles', 11 );
|
||||
|
||||
function zeitfresser_enqueue_static_colors() {
|
||||
wp_enqueue_style(
|
||||
'zeitfresser-colors',
|
||||
get_template_directory_uri() . '/css/colors.css',
|
||||
array('zeitfresser'),
|
||||
file_exists(get_template_directory() . '/css/colors.css')
|
||||
? filemtime(get_template_directory() . '/css/colors.css')
|
||||
: ZEITFRESSER_VERSION
|
||||
);
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_enqueue_static_colors', 20 );
|
||||
|
||||
function zeitfresser_enqueue_static_fonts() {
|
||||
wp_enqueue_style(
|
||||
'zeitfresser-fonts',
|
||||
get_template_directory_uri() . '/css/fonts.css',
|
||||
array(),
|
||||
file_exists(get_template_directory() . '/css/fonts.css')
|
||||
? filemtime(get_template_directory() . '/css/fonts.css')
|
||||
: ZEITFRESSER_VERSION
|
||||
);
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_enqueue_static_fonts', 15 );
|
||||
|
||||
/**
|
||||
* Theme package marker kept for compatibility with the original premium controls.
|
||||
@@ -194,7 +293,6 @@ function zeitfresser_free_pro() {
|
||||
return 'pro';
|
||||
}
|
||||
|
||||
require get_template_directory() . '/inc/custom-header.php';
|
||||
require get_template_directory() . '/inc/template-tags.php';
|
||||
require get_template_directory() . '/inc/template-functions.php';
|
||||
require get_template_directory() . '/inc/customizer.php';
|
||||
@@ -204,22 +302,8 @@ if ( defined( 'JETPACK__VERSION' ) ) {
|
||||
}
|
||||
|
||||
require get_template_directory() . '/inc/blocks/blocks.php';
|
||||
require get_template_directory() . '/inc/graphthemes-widgets/graphthemes-widgets.php';
|
||||
require get_template_directory() . '/inc/pagination.php';
|
||||
|
||||
|
||||
/**
|
||||
* Remove duplicate local Google font generation to avoid unnecessary footer CSS.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function zeitfresser_disable_duplicate_local_fonts() {
|
||||
remove_action( 'wp_loaded', 'zeitfresser_google_font_local' );
|
||||
}
|
||||
add_action( 'after_setup_theme', 'zeitfresser_disable_duplicate_local_fonts', 20 );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add safe front-end performance optimizations.
|
||||
*
|
||||
@@ -254,6 +338,35 @@ function zeitfresser_cleanup_wp_head() {
|
||||
}
|
||||
add_action( 'init', 'zeitfresser_cleanup_wp_head' );
|
||||
|
||||
/**
|
||||
* Preload critical local fonts only
|
||||
*/
|
||||
function zeitfresser_preload_fonts() {
|
||||
?>
|
||||
<!-- Critical Fonts Only -->
|
||||
<link rel="preload" href="<?php echo get_template_directory_uri(); ?>/fonts/oswald-400.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="preload" href="<?php echo get_template_directory_uri(); ?>/fonts/oswald-700.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="preload" href="<?php echo get_template_directory_uri(); ?>/fonts/roboto-400.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<?php
|
||||
}
|
||||
add_action('wp_head', 'zeitfresser_preload_fonts', 1);
|
||||
|
||||
/**
|
||||
* Optimize font loading with preconnect
|
||||
*/
|
||||
add_filter( 'wp_resource_hints', function( $urls, $relation_type ) {
|
||||
|
||||
if ( 'preconnect' === $relation_type ) {
|
||||
$urls[] = [
|
||||
'href' => get_template_directory_uri(),
|
||||
'crossorigin' => 'anonymous',
|
||||
];
|
||||
}
|
||||
|
||||
return $urls;
|
||||
|
||||
}, 10, 2 );
|
||||
|
||||
/**
|
||||
* Remove front-end dashicons for visitors.
|
||||
*
|
||||
@@ -266,58 +379,6 @@ function zeitfresser_maybe_dequeue_dashicons() {
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_maybe_dequeue_dashicons', 100 );
|
||||
|
||||
/**
|
||||
* Add resource hints for externally loaded fonts only when needed.
|
||||
*
|
||||
* @param array $urls URLs to print for resource hints.
|
||||
* @param string $relation_type Hint relation type.
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_resource_hints( $urls, $relation_type ) {
|
||||
$uses_external_fonts = false;
|
||||
|
||||
if ( function_exists( 'zeitfresser_fonts_url' ) ) {
|
||||
$uses_external_fonts = ! empty( zeitfresser_fonts_url( zeitfresser_used_google_fonts() ) ) && empty( zeitfresser_get_local_webfonts_css() );
|
||||
}
|
||||
|
||||
if ( $uses_external_fonts && 'preconnect' === $relation_type ) {
|
||||
$urls[] = 'https://fonts.googleapis.com';
|
||||
$urls[] = array(
|
||||
'href' => 'https://fonts.gstatic.com',
|
||||
'crossorigin' => 'anonymous',
|
||||
);
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
add_filter( 'wp_resource_hints', 'zeitfresser_resource_hints', 10, 2 );
|
||||
|
||||
/**
|
||||
* Preload locally hosted webfont files once they are available.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function zeitfresser_preload_local_webfonts() {
|
||||
if ( is_admin() || ! function_exists( 'zeitfresser_get_local_webfonts_css' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$urls = zeitfresser_get_local_webfont_urls( zeitfresser_get_local_webfonts_css() );
|
||||
|
||||
if ( empty( $urls ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$urls = array_slice( $urls, 0, 4 );
|
||||
|
||||
foreach ( $urls as $url ) {
|
||||
$type = ( '.woff2' === substr( $url, -6 ) ) ? 'font/woff2' : 'font/woff';
|
||||
printf( "<link rel='preload' href='%s' as='font' type='%s' crossorigin>
|
||||
", esc_url( $url ), esc_attr( $type ) );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_head', 'zeitfresser_preload_local_webfonts', 2 );
|
||||
|
||||
/**
|
||||
* Improve image decoding defaults without changing visual output.
|
||||
*
|
||||
@@ -340,13 +401,18 @@ function zeitfresser_optimize_image_attributes( $attr, $attachment, $size ) {
|
||||
add_filter( 'wp_get_attachment_image_attributes', 'zeitfresser_optimize_image_attributes', 10, 3 );
|
||||
|
||||
/**
|
||||
* Lower the threshold for WordPress scaled originals.
|
||||
* Lower the threshold for WordPress scaled originals when auto optimization is enabled.
|
||||
*
|
||||
* This prevents very large uploads from shipping oversized source images.
|
||||
* When automatic optimization is disabled, original uploads should remain untouched.
|
||||
*
|
||||
* @return int
|
||||
* @return int|false
|
||||
*/
|
||||
function zeitfresser_big_image_size_threshold() {
|
||||
|
||||
if ( ! get_theme_mod( 'ztfr_auto_optimize', true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1800;
|
||||
}
|
||||
add_filter( 'big_image_size_threshold', 'zeitfresser_big_image_size_threshold' );
|
||||
@@ -358,28 +424,185 @@ add_filter( 'big_image_size_threshold', 'zeitfresser_big_image_size_threshold' )
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_filter_intermediate_image_sizes( $sizes ) {
|
||||
unset( $sizes['1536x1536'], $sizes['2048x2048'] );
|
||||
|
||||
// Remove oversized defaults
|
||||
unset(
|
||||
$sizes['1536x1536'],
|
||||
$sizes['2048x2048']
|
||||
);
|
||||
|
||||
return $sizes;
|
||||
}
|
||||
add_filter( 'intermediate_image_sizes_advanced', 'zeitfresser_filter_intermediate_image_sizes' );
|
||||
|
||||
/**
|
||||
* Convert generated JPEG and PNG sub-sizes to WebP when supported by the server.
|
||||
* Convert generated JPEG and PNG files to AVIF/WebP when enabled.
|
||||
*
|
||||
* Auto optimization can be disabled for uploads via Customizer.
|
||||
* Manual optimization may still force conversion through a request-scoped flag.
|
||||
*
|
||||
* @param array $formats Output format map.
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_image_output_format( $formats ) {
|
||||
if ( function_exists( 'wp_image_editor_supports' ) && wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
|
||||
$formats['image/jpeg'] = 'image/webp';
|
||||
$formats['image/png'] = 'image/webp';
|
||||
|
||||
$auto_enabled = get_theme_mod( 'ztfr_auto_optimize', true );
|
||||
$force_enabled = ! empty( $GLOBALS['zeitfresser_force_image_optimization'] );
|
||||
|
||||
if ( ! $auto_enabled && ! $force_enabled ) {
|
||||
return $formats;
|
||||
}
|
||||
|
||||
if ( function_exists( 'wp_image_editor_supports' ) ) {
|
||||
|
||||
// Prefer AVIF if supported.
|
||||
if ( wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) {
|
||||
$formats['image/jpeg'] = 'image/avif';
|
||||
$formats['image/png'] = 'image/avif';
|
||||
|
||||
// Fallback to WebP.
|
||||
} elseif ( wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
|
||||
$formats['image/jpeg'] = 'image/webp';
|
||||
$formats['image/png'] = 'image/webp';
|
||||
}
|
||||
}
|
||||
|
||||
return $formats;
|
||||
}
|
||||
add_filter( 'image_editor_output_format', 'zeitfresser_image_output_format' );
|
||||
|
||||
/**
|
||||
* Mark images as optimized only when optimization is actually active.
|
||||
*
|
||||
* @param array $metadata Attachment metadata.
|
||||
* @param int $attachment_id Attachment ID.
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_mark_new_images_optimized( $metadata, $attachment_id ) {
|
||||
|
||||
if ( ! wp_attachment_is_image( $attachment_id ) ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
$auto_enabled = get_theme_mod( 'ztfr_auto_optimize', true );
|
||||
$force_enabled = ! empty( $GLOBALS['zeitfresser_force_image_optimization'] );
|
||||
|
||||
if ( ! $auto_enabled && ! $force_enabled ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
update_post_meta(
|
||||
$attachment_id,
|
||||
'_zeitfresser_media_optimized_version',
|
||||
ZEITFRESSER_IMAGE_OPTIMIZATION_VERSION
|
||||
);
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
add_filter( 'wp_generate_attachment_metadata', 'zeitfresser_mark_new_images_optimized', 20, 2 );
|
||||
|
||||
/**
|
||||
* Auto Optimize Hook
|
||||
*/
|
||||
add_filter(
|
||||
'wp_generate_attachment_metadata',
|
||||
'zeitfresser_auto_optimize_on_upload',
|
||||
15,
|
||||
2
|
||||
);
|
||||
|
||||
function zeitfresser_auto_optimize_on_upload( $metadata, $attachment_id ) {
|
||||
|
||||
// 🔒 only images
|
||||
if ( ! wp_attachment_is_image( $attachment_id ) ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
// 🔒 feature toggle
|
||||
if ( ! get_theme_mod( 'ztfr_auto_optimize', true ) ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
$file = get_attached_file( $attachment_id );
|
||||
|
||||
if ( ! $file || ! file_exists( $file ) ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
// 🔥 DO NOT overwrite upload-captured original
|
||||
if ( ! get_post_meta( $attachment_id, '_zeitfresser_original_file', true ) ) {
|
||||
|
||||
// fallback only
|
||||
update_post_meta( $attachment_id, '_zeitfresser_original_file', $file );
|
||||
}
|
||||
|
||||
// mark as optimized
|
||||
update_post_meta(
|
||||
$attachment_id,
|
||||
'_zeitfresser_media_optimized_version',
|
||||
ZEITFRESSER_IMAGE_OPTIMIZATION_VERSION
|
||||
);
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto Delete Hook
|
||||
*/
|
||||
add_filter(
|
||||
'wp_generate_attachment_metadata',
|
||||
'zeitfresser_auto_delete_original_after_upload',
|
||||
30,
|
||||
2
|
||||
);
|
||||
|
||||
function zeitfresser_auto_delete_original_after_upload( $metadata, $attachment_id ) {
|
||||
|
||||
if ( ! wp_attachment_is_image( $attachment_id ) ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
if ( ! get_theme_mod( 'ztfr_auto_optimize', true ) ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
if ( ! get_theme_mod( 'ztfr_auto_delete', false ) ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
$original = get_post_meta(
|
||||
$attachment_id,
|
||||
'_zeitfresser_original_file',
|
||||
true
|
||||
);
|
||||
|
||||
if ( ! $original ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
$ext = strtolower( pathinfo( $original, PATHINFO_EXTENSION ) );
|
||||
|
||||
if ( in_array( $ext, [ 'webp', 'avif' ], true ) ) {
|
||||
update_post_meta( $attachment_id, '_zeitfresser_original_deleted', 1 );
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
// If nothing remains, mark as completed.
|
||||
if ( ! zeitfresser_original_family_exists( $attachment_id, $original ) ) {
|
||||
update_post_meta( $attachment_id, '_zeitfresser_original_deleted', 1 );
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
zeitfresser_delete_original_family_files( $attachment_id, $original );
|
||||
|
||||
// Only mark as deleted when all original-format files are gone.
|
||||
if ( ! zeitfresser_original_family_exists( $attachment_id, $original ) ) {
|
||||
update_post_meta( $attachment_id, '_zeitfresser_original_deleted', 1 );
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep generated image quality balanced for file size and visual fidelity.
|
||||
*
|
||||
@@ -388,11 +611,18 @@ add_filter( 'image_editor_output_format', 'zeitfresser_image_output_format' );
|
||||
* @return int
|
||||
*/
|
||||
function zeitfresser_image_quality( $quality, $mime_type = 'image/jpeg' ) {
|
||||
if ( 'image/png' === $mime_type ) {
|
||||
return $quality;
|
||||
}
|
||||
|
||||
return 82;
|
||||
switch ( $mime_type ) {
|
||||
case 'image/avif':
|
||||
return 50;
|
||||
|
||||
case 'image/webp':
|
||||
return 75;
|
||||
|
||||
case 'image/jpeg':
|
||||
default:
|
||||
return 82;
|
||||
}
|
||||
}
|
||||
add_filter( 'wp_editor_set_quality', 'zeitfresser_image_quality', 10, 2 );
|
||||
|
||||
@@ -422,7 +652,7 @@ function zeitfresser_improve_attachment_dimensions( $attr, $attachment, $size )
|
||||
if ( empty( $attr['fetchpriority'] ) && ! is_admin() && ! is_feed() ) {
|
||||
static $did_set_high_priority = false;
|
||||
|
||||
if ( ! $did_set_high_priority && ( is_home() || is_front_page() || is_archive() || is_search() || is_singular() ) ) {
|
||||
if ( ! $did_set_high_priority && is_singular() ) {
|
||||
$attr['fetchpriority'] = 'high';
|
||||
$did_set_high_priority = true;
|
||||
}
|
||||
@@ -432,6 +662,62 @@ function zeitfresser_improve_attachment_dimensions( $attr, $attachment, $size )
|
||||
}
|
||||
add_filter( 'wp_get_attachment_image_attributes', 'zeitfresser_improve_attachment_dimensions', 11, 3 );
|
||||
|
||||
/**
|
||||
* Improve responsive image sizes attribute.
|
||||
*
|
||||
* @param string $sizes Existing sizes attribute.
|
||||
* @param array $size Requested image size.
|
||||
* @return string
|
||||
*/
|
||||
function zeitfresser_responsive_image_sizes( $sizes, $size ) {
|
||||
|
||||
// Single post content
|
||||
if ( is_singular() ) {
|
||||
return '(max-width: 768px) 100vw, (max-width: 1200px) 720px, 720px';
|
||||
}
|
||||
|
||||
// Archive / blog overview
|
||||
if ( is_home() || is_front_page() || is_archive() || is_search() ) {
|
||||
return '(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 400px';
|
||||
}
|
||||
|
||||
return $sizes;
|
||||
}
|
||||
add_filter( 'wp_calculate_image_sizes', 'zeitfresser_responsive_image_sizes', 10, 2 );
|
||||
|
||||
/**
|
||||
* Determine the most likely LCP image URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function zeitfresser_get_lcp_image_url() {
|
||||
|
||||
// Single posts/pages → featured image
|
||||
if ( is_singular() ) {
|
||||
$post_id = get_queried_object_id();
|
||||
|
||||
if ( $post_id && has_post_thumbnail( $post_id ) ) {
|
||||
return get_the_post_thumbnail_url( $post_id, 'large' );
|
||||
}
|
||||
}
|
||||
|
||||
// Archives / homepage → first post with thumbnail
|
||||
if ( is_home() || is_front_page() || is_archive() || is_search() ) {
|
||||
|
||||
global $wp_query;
|
||||
|
||||
if ( ! empty( $wp_query->posts ) ) {
|
||||
|
||||
foreach ( $wp_query->posts as $post ) {
|
||||
if ( has_post_thumbnail( $post->ID ) ) {
|
||||
return get_the_post_thumbnail_url( $post->ID, 'medium_large' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Preload the most likely LCP image for archive and singular views.
|
||||
@@ -440,39 +726,35 @@ add_filter( 'wp_get_attachment_image_attributes', 'zeitfresser_improve_attachmen
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_preload_resources( $resources ) {
|
||||
|
||||
if ( is_admin() || is_feed() || is_embed() ) {
|
||||
return $resources;
|
||||
}
|
||||
|
||||
$image_url = '';
|
||||
$image_type = '';
|
||||
|
||||
if ( is_singular() ) {
|
||||
$object_id = get_queried_object_id();
|
||||
|
||||
if ( $object_id && has_post_thumbnail( $object_id ) ) {
|
||||
$image_url = get_the_post_thumbnail_url( $object_id, 'large' );
|
||||
}
|
||||
} elseif ( is_home() || is_front_page() || is_archive() || is_search() ) {
|
||||
global $wp_query;
|
||||
|
||||
if ( isset( $wp_query->posts[0]->ID ) && has_post_thumbnail( $wp_query->posts[0]->ID ) ) {
|
||||
$image_url = get_the_post_thumbnail_url( $wp_query->posts[0]->ID, 'thumbnail' );
|
||||
}
|
||||
}
|
||||
// 🔥 NEW: use smart detection
|
||||
$image_url = zeitfresser_get_lcp_image_url();
|
||||
|
||||
if ( empty( $image_url ) ) {
|
||||
return $resources;
|
||||
}
|
||||
|
||||
$extension = strtolower( pathinfo( wp_parse_url( $image_url, PHP_URL_PATH ), PATHINFO_EXTENSION ) );
|
||||
// Robust extension detection
|
||||
$extension = strtolower(
|
||||
pathinfo(
|
||||
wp_parse_url( $image_url, PHP_URL_PATH ),
|
||||
PATHINFO_EXTENSION
|
||||
)
|
||||
);
|
||||
|
||||
if ( 'jpg' === $extension || 'jpeg' === $extension ) {
|
||||
$image_type = 'image/jpeg';
|
||||
} elseif ( 'png' === $extension ) {
|
||||
// MIME fallback
|
||||
$image_type = 'image/jpeg';
|
||||
|
||||
if ( 'png' === $extension ) {
|
||||
$image_type = 'image/png';
|
||||
} elseif ( 'webp' === $extension ) {
|
||||
$image_type = 'image/webp';
|
||||
} elseif ( 'avif' === $extension ) {
|
||||
$image_type = 'image/avif';
|
||||
}
|
||||
|
||||
$resources[] = array_filter(
|
||||
|
||||
@@ -15,9 +15,6 @@ require dirname( __FILE__ ) . '/includes/sanitize.php';
|
||||
require dirname( __FILE__ ) . '/includes/register-controls.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/site-identity/site-identity.php';
|
||||
require dirname( __FILE__ ) . '/colors/colors.php';
|
||||
require dirname( __FILE__ ) . '/font-family/font-family.php';
|
||||
require dirname( __FILE__ ) . '/font-customization/font-customization.php';
|
||||
require dirname( __FILE__ ) . '/general/general.php';
|
||||
require dirname( __FILE__ ) . '/post-detail/post-detail.php';
|
||||
require dirname( __FILE__ ) . '/footer-copyright/footer-copyright.php';
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_sticky_menu_background_color' );
|
||||
function zeitfresser_sticky_menu_background_color() {
|
||||
|
||||
$bg_color = get_theme_mod( 'background_color', get_theme_support( 'custom-background', 'default-color' ) );
|
||||
|
||||
$dynamic_css = "body,.site-header{background:#$bg_color;}";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_dark_color' );
|
||||
|
||||
function zeitfresser_dark_color( $wp_customize ) {
|
||||
$wp_customize->add_setting( 'dark_color', array(
|
||||
'default' => zeitfresser_get_default_dark_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'dark_color', array(
|
||||
'label' => esc_html__( 'Misc Colors', 'zeitfresser' ),
|
||||
'section' => 'colors',
|
||||
'settings' => 'dark_color',
|
||||
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_dark_color_enqueue_scripts' );
|
||||
function zeitfresser_dark_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-dark-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-dark/customizer-color-dark.js', array('jquery'), '', true );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('dark_color',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--dark-color', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_grey_color' );
|
||||
|
||||
function zeitfresser_grey_color( $wp_customize ) {
|
||||
$wp_customize->add_setting( 'grey_color', array(
|
||||
'default' => zeitfresser_get_default_grey_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'grey_color', array(
|
||||
'label' => esc_html__( 'Soft Text Color', 'zeitfresser' ),
|
||||
'section' => 'colors',
|
||||
'settings' => 'grey_color',
|
||||
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_grey_color_enqueue_scripts' );
|
||||
function zeitfresser_grey_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-grey-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-grey/customizer-color-grey.js', array('jquery'), '', true );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('grey_color',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--grey-color', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_light_color' );
|
||||
|
||||
function zeitfresser_light_color( $wp_customize ) {
|
||||
$wp_customize->add_setting( 'light_color', array(
|
||||
'default' => zeitfresser_get_default_light_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'light_color', array(
|
||||
'label' => esc_html__( 'Header Color', 'zeitfresser' ),
|
||||
'section' => 'colors',
|
||||
'settings' => 'light_color',
|
||||
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_light_color_enqueue_scripts' );
|
||||
function zeitfresser_light_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-light-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-light/customizer-color-light.js', array('jquery'), '', true );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('light_color',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--light-color', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_primary_color' );
|
||||
function zeitfresser_primary_color( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'primary_color', array(
|
||||
'default' => zeitfresser_get_default_primary_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_color', array(
|
||||
'label' => esc_html__( 'Menu / Title / Button Color', 'zeitfresser' ),
|
||||
'section' => 'colors',
|
||||
'settings' => 'primary_color',
|
||||
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_primary_color_enqueue_scripts' );
|
||||
function zeitfresser_primary_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-primary-color-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-primary/customizer-color-primary.js', array('jquery'), '', true );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('primary_color',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--primary-color', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_secondary_color' );
|
||||
|
||||
function zeitfresser_secondary_color( $wp_customize ) {
|
||||
$wp_customize->add_setting( 'secondary_color', array(
|
||||
'default' => zeitfresser_get_default_secondary_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'secondary_color', array(
|
||||
'label' => esc_html__( 'Highlight Color', 'zeitfresser' ),
|
||||
'section' => 'colors',
|
||||
'settings' => 'secondary_color',
|
||||
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_secondary_color_enqueue_scripts' );
|
||||
function zeitfresser_secondary_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-secondary-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-secondary/customizer-color-secondary.js', array('jquery'), '', true );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('secondary_color',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--secondary-color', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_site_title_color' );
|
||||
function zeitfresser_site_title_color( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'site_title_color_option', array(
|
||||
'default' => zeitfresser_get_default_site_title_color(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_hex_color',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'site_title_color_option', array(
|
||||
'label' => esc_html__( 'Site Identity Color', 'zeitfresser' ),
|
||||
'section' => 'title_tagline',
|
||||
'settings' => 'site_title_color_option',
|
||||
) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_site_title_color_enqueue_scripts' );
|
||||
function zeitfresser_site_title_color_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-site-title-color-customizer', get_template_directory_uri() . '/inc/blocks/colors/color-site-title/customizer-color-site-title.js', array(), '', true );
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize( 'site_title_color_option', function( value ) {
|
||||
value.bind( function( to ) {
|
||||
$( '.site-title a' ).css( 'color', to );
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
add_action( 'after_setup_theme', function () {
|
||||
add_theme_support( 'custom-header', array( 'header-text' => false ) );
|
||||
} );
|
||||
|
||||
add_action('customize_register', 'zeitfresser_color_section');
|
||||
function zeitfresser_color_section($wp_customize)
|
||||
{
|
||||
$wp_customize->get_section('colors')->title = esc_html__( "Color Options", 'zeitfresser' );
|
||||
$wp_customize->get_section('colors')->priority = 21;
|
||||
}
|
||||
|
||||
/* Add Default Colors for Customizer Settings */
|
||||
require dirname( __FILE__ ) . '/default-colors.php';
|
||||
|
||||
if( db_fs()->is__premium_only() ) {
|
||||
|
||||
require dirname( __FILE__ ) . '/color-site-title/color-site-title.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/color-primary/color-primary.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/color-secondary/color-secondary.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/color-light/color-light.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/color-grey/color-grey.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/color-dark/color-dark.php';
|
||||
}
|
||||
|
||||
require dirname( __FILE__ ) . '/color-background/color-background.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/dynamic-colors.php';
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
/* Default Site Title Color */
|
||||
function zeitfresser_get_default_site_title_color() {
|
||||
return "#f7f7fa";
|
||||
}
|
||||
|
||||
/* Default Primary Color */
|
||||
function zeitfresser_get_default_primary_color() {
|
||||
return "#f7f7fa";
|
||||
}
|
||||
|
||||
/* Default Secondary Color */
|
||||
function zeitfresser_get_default_secondary_color() {
|
||||
return "#f7f7fa";
|
||||
}
|
||||
|
||||
/* Default Light Color */
|
||||
function zeitfresser_get_default_light_color() {
|
||||
return "#1e1f29";
|
||||
}
|
||||
|
||||
/* Default Grey Color */
|
||||
function zeitfresser_get_default_grey_color() {
|
||||
return "#f7f7fa";
|
||||
}
|
||||
|
||||
/* Default Dark Color */
|
||||
function zeitfresser_get_default_dark_color() {
|
||||
return "#f7f7fa";
|
||||
}
|
||||
|
||||
/* Default Background Color */
|
||||
function zeitfresser_get_default_background_color() {
|
||||
return "1e1f29";
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_site_title_color_dynamic_css' );
|
||||
function zeitfresser_site_title_color_dynamic_css() {
|
||||
|
||||
$site_title_color = esc_attr( get_theme_mod( 'site_title_color_option', zeitfresser_get_default_site_title_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --site-title-color: $site_title_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_secondary_color_dynamic_css' );
|
||||
function zeitfresser_secondary_color_dynamic_css() {
|
||||
|
||||
$secondary_color = esc_attr( get_theme_mod( 'secondary_color', zeitfresser_get_default_secondary_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --secondary-color: $secondary_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_primary_color_dynamic_css' );
|
||||
function zeitfresser_primary_color_dynamic_css() {
|
||||
|
||||
$primary_color = esc_attr( get_theme_mod( 'primary_color', zeitfresser_get_default_primary_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --primary-color: $primary_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_light_color_dynamic_css' );
|
||||
function zeitfresser_light_color_dynamic_css() {
|
||||
|
||||
$light_color = esc_attr( get_theme_mod( 'light_color', zeitfresser_get_default_light_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --light-color: $light_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_grey_color_dynamic_css' );
|
||||
function zeitfresser_grey_color_dynamic_css() {
|
||||
|
||||
$grey_color = esc_attr( get_theme_mod( 'grey_color', zeitfresser_get_default_grey_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --grey-color: $grey_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_dark_color_dynamic_css' );
|
||||
function zeitfresser_dark_color_dynamic_css() {
|
||||
|
||||
$dark_color = esc_attr( get_theme_mod( 'dark_color', zeitfresser_get_default_dark_color() ) );
|
||||
|
||||
$dynamic_css = ":root { --dark-color: $dark_color; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
/* Default Font Size */
|
||||
function zeitfresser_get_default_font_size() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
function zeitfresser_get_default_logo_size() {
|
||||
return 60;
|
||||
}
|
||||
|
||||
|
||||
function zeitfresser_get_default_site_identity_font_size() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
|
||||
function zeitfresser_get_default_font_weight() {
|
||||
return "400";
|
||||
}
|
||||
|
||||
function zeitfresser_get_default_line_height() {
|
||||
return "1.6";
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_register_font_customization_section' );
|
||||
function zeitfresser_register_font_customization_section( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_section( 'daisy_blog_font_customization_section', array(
|
||||
'title' => esc_html__( 'Font Options', 'zeitfresser' ),
|
||||
'priority' => 20
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Add Default Font Customization for Customizer Settings */
|
||||
require dirname( __FILE__ ) . '/default-font-customization.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/logo-size/logo-size.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/site-identity-font-size/site-identity-font-size.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/font-size/font-size.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/font-weight/font-weight.php';
|
||||
|
||||
require dirname( __FILE__ ) . '/line-height/line-height.php';
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('font_size',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
$( 'body,html' ).css( 'font-size', to+'px' );
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_font_size' );
|
||||
function zeitfresser_font_size( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'font_size', array(
|
||||
'default' => zeitfresser_get_default_font_size(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'font_size', array(
|
||||
'type' => 'number',
|
||||
'settings' => 'font_size',
|
||||
'label' => esc_html__( 'Body Font Size', 'zeitfresser' ),
|
||||
'section' => 'daisy_blog_font_customization_section',
|
||||
'input_attrs' => array(
|
||||
'min' => 1,
|
||||
'max' => 30
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_font_size_enqueue_scripts' );
|
||||
function zeitfresser_font_size_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-font-size-customizer', get_template_directory_uri() . '/inc/blocks/font-customization/font-size/customizer-font-size.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_font_size_dynamic_css' );
|
||||
function zeitfresser_font_size_dynamic_css() {
|
||||
|
||||
$font_size = esc_attr( get_theme_mod( 'font_size', zeitfresser_get_default_font_size() ) );
|
||||
$font_size .= 'px';
|
||||
|
||||
$dynamic_css = "html,body{font-size:{$font_size};}";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('font_weight',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--font-weight', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_font_weight' );
|
||||
function zeitfresser_font_weight( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'font_weight', array(
|
||||
'default' => zeitfresser_get_default_font_weight(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'font_weight', array(
|
||||
'type' => 'number',
|
||||
'settings' => 'font_weight',
|
||||
'label' => esc_html__( 'Body Font Weight', 'zeitfresser' ),
|
||||
'section' => 'daisy_blog_font_customization_section',
|
||||
'input_attrs' => array(
|
||||
'min' => 100,
|
||||
'max' => 900,
|
||||
'step' => 100
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_font_weight_enqueue_scripts' );
|
||||
function zeitfresser_font_weight_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-font-weight-customizer', get_template_directory_uri() . '/inc/blocks/font-customization/font-weight/customizer-font-weight.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_font_weight_dynamic_css' );
|
||||
function zeitfresser_font_weight_dynamic_css() {
|
||||
|
||||
$font_weight = esc_attr( get_theme_mod( 'font_weight', zeitfresser_get_default_font_weight() ) );
|
||||
|
||||
$dynamic_css = ":root { --font-weight: $font_weight; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('line_height',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--line-height', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_line_height' );
|
||||
function zeitfresser_line_height( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'line_height', array(
|
||||
'default' => zeitfresser_get_default_line_height(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'zeitfresser_sanitize_float'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'line_height', array(
|
||||
'type' => 'number',
|
||||
'settings' => 'line_height',
|
||||
'label' => esc_html__( 'Line Height', 'zeitfresser' ),
|
||||
'section' => 'daisy_blog_font_customization_section',
|
||||
'input_attrs' => array(
|
||||
'min' => 1,
|
||||
'max' => 5,
|
||||
'step' => 0.1
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_line_height_enqueue_scripts' );
|
||||
function zeitfresser_line_height_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-line-height-customizer', get_template_directory_uri() . '/inc/blocks/font-customization/line-height/customizer-line-height.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_line_height_dynamic_css' );
|
||||
function zeitfresser_line_height_dynamic_css() {
|
||||
|
||||
$line_height = esc_attr( get_theme_mod( 'line_height', zeitfresser_get_default_line_height() ) );
|
||||
|
||||
$dynamic_css = ":root { --line-height: $line_height; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('logo_size',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--logo-size', to+'px');
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_logo_size' );
|
||||
function zeitfresser_logo_size( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'logo_size', array(
|
||||
'default' => zeitfresser_get_default_logo_size(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'logo_size', array(
|
||||
'type' => 'number',
|
||||
'settings' => 'logo_size',
|
||||
'priority' => 8,
|
||||
'label' => esc_html__( 'Logo Size', 'zeitfresser' ),
|
||||
'section' => 'title_tagline',
|
||||
'input_attrs' => array(
|
||||
'min' => 10,
|
||||
'max' => 100
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_logo_size_enqueue_scripts' );
|
||||
function zeitfresser_logo_size_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-logo-size-customizer', get_template_directory_uri() . '/inc/blocks/font-customization/logo-size/customizer-logo-size.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_logo_size_dynamic_css' );
|
||||
function zeitfresser_logo_size_dynamic_css() {
|
||||
|
||||
$logo_size = esc_attr( get_theme_mod( 'logo_size', zeitfresser_get_default_logo_size() ) );
|
||||
$logo_size .= 'px';
|
||||
|
||||
$dynamic_css = ":root { --logo-size: $logo_size; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('site_identity_font_size',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
document.body.style.setProperty('--site-identity-font-size', to+'px');
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_site_identity_font_size' );
|
||||
function zeitfresser_site_identity_font_size( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'site_identity_font_size', array(
|
||||
'default' => zeitfresser_get_default_site_identity_font_size(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'site_identity_font_size', array(
|
||||
'type' => 'number',
|
||||
'settings' => 'site_identity_font_size',
|
||||
'label' => esc_html__( 'Site Identity Size', 'zeitfresser' ),
|
||||
'section' => 'title_tagline',
|
||||
'input_attrs' => array(
|
||||
'min' => 10,
|
||||
'max' => 40
|
||||
)
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_site_identity_font_size_enqueue_scripts' );
|
||||
function zeitfresser_site_identity_font_size_enqueue_scripts() {
|
||||
wp_enqueue_script( 'graphthemes-site-identity-font-size-customizer', get_template_directory_uri() . '/inc/blocks/font-customization/site-identity-font-size/customizer-site-identity-font-size.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_site_identity_font_size_dynamic_css' );
|
||||
function zeitfresser_site_identity_font_size_dynamic_css() {
|
||||
|
||||
$site_identity_font_size = esc_attr( get_theme_mod( 'site_identity_font_size', zeitfresser_get_default_site_identity_font_size() ) );
|
||||
$site_identity_font_size .= 'px';
|
||||
|
||||
$dynamic_css = ":root { --site-identity-font-size: $site_identity_font_size; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
/* Default Font Family */
|
||||
function zeitfresser_get_default_site_identity_font_family() {
|
||||
return esc_html__( "Oswald", 'zeitfresser' );
|
||||
}
|
||||
|
||||
function zeitfresser_get_default_main_font_family() {
|
||||
return esc_html__( "Oswald", 'zeitfresser' );
|
||||
}
|
||||
|
||||
function zeitfresser_get_default_secondary_font_family() {
|
||||
return esc_html__( "Roboto", 'zeitfresser' );
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
/* Add Google Fonts */
|
||||
require dirname( __FILE__ ) . '/google-fonts.php';
|
||||
|
||||
/* Add Default Font Family for Customizer Settings */
|
||||
require dirname( __FILE__ ) . '/default-font-family.php';
|
||||
|
||||
include_once wp_normalize_path( dirname( __FILE__ ) . '/inc/helper-functions.php' );
|
||||
include_once wp_normalize_path( dirname( __FILE__ ) . '/inc/class-webfonts-local.php' );
|
||||
include_once wp_normalize_path( dirname( __FILE__ ) . '/inc/class-fonts-google-local.php' );
|
||||
|
||||
|
||||
|
||||
require dirname( __FILE__ ) . '/site-identity/site-identity-font-family.php';
|
||||
require dirname( __FILE__ ) . '/main/main-font-family.php';
|
||||
require dirname( __FILE__ ) . '/secondary/secondary-font-family.php';
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_google_fonts_scripts', 5 );
|
||||
function zeitfresser_google_fonts_scripts() {
|
||||
$local_css = zeitfresser_get_local_webfonts_css();
|
||||
|
||||
wp_register_style( 'zeitfresser-webfonts', false, array(), ZEITFRESSER_VERSION );
|
||||
wp_enqueue_style( 'zeitfresser-webfonts' );
|
||||
|
||||
if ( ! empty( $local_css ) ) {
|
||||
wp_add_inline_style( 'zeitfresser-webfonts', $local_css );
|
||||
return;
|
||||
}
|
||||
|
||||
$args = zeitfresser_used_google_fonts();
|
||||
$fonts_url = zeitfresser_fonts_url( $args );
|
||||
|
||||
if ( empty( $fonts_url ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'google-fonts', $fonts_url, array(), null );
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,457 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Handles downloading a font from the google-fonts API locally.
|
||||
* Solves privacy concerns with Google's CDN
|
||||
* and their sometimes less-than-transparent policies.
|
||||
*
|
||||
* @package zeitfresser
|
||||
*/
|
||||
|
||||
// Do not allow directly accessing this file.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit( 'Direct script access denied.' );
|
||||
}
|
||||
|
||||
final class Daisy_Blog_Google_Local {
|
||||
|
||||
/**
|
||||
* The name of the font-family
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $family;
|
||||
|
||||
/**
|
||||
* The system path where font-files are stored.
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $folder_path;
|
||||
|
||||
/**
|
||||
* The URL where files for this font can be found.
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $folder_url;
|
||||
|
||||
/**
|
||||
* An array of instances for this object.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private static $instances = array();
|
||||
|
||||
/**
|
||||
* Create an instance of this object for a specific font-family.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $family The font-family name.
|
||||
* @return Daisy_Blog_Google_Local
|
||||
*/
|
||||
public static function init( $family ) {
|
||||
$key = sanitize_key( $family );
|
||||
if ( ! isset( self::$instances[ $key ] ) ) {
|
||||
self::$instances[ $key ] = new self( $family );
|
||||
}
|
||||
return self::$instances[ $key ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @access private
|
||||
* @param string $family The font-family name.
|
||||
*/
|
||||
private function __construct( $family ) {
|
||||
$this->family = $family;
|
||||
$key = sanitize_key( $this->family );
|
||||
$this->folder_path = $this->get_root_path() . "/$key";
|
||||
$this->folder_url = $this->get_root_url() . "/$key";
|
||||
$this->files = $this->get_font_family();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the @font-face CSS.
|
||||
*
|
||||
* @access public
|
||||
* @param array $variants The variants we want to get.
|
||||
* @return string
|
||||
*/
|
||||
public function get_css( $variants = array() ) {
|
||||
if ( ! $this->files ) {
|
||||
return;
|
||||
}
|
||||
$key = md5( wp_json_encode( $this->files ) );
|
||||
$cached = get_transient( $key );
|
||||
if ( $cached ) {
|
||||
return $cached;
|
||||
}
|
||||
$css = '';
|
||||
|
||||
// If $variants is empty then use all variants available.
|
||||
if ( empty( $variants ) ) {
|
||||
$variants = array_keys( $this->files );
|
||||
}
|
||||
|
||||
// Download files.
|
||||
$this->download_font_family( $variants );
|
||||
|
||||
// Create the @font-face CSS.
|
||||
foreach ( $variants as $variant ) {
|
||||
$css .= $this->get_variant_fontface_css( $variant );
|
||||
}
|
||||
set_transient( $key, $css, WEEK_IN_SECONDS );
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download font-family files.
|
||||
*
|
||||
* @access public
|
||||
* @param array $variants An array of variants to download. Leave empty to download all.
|
||||
* @return void
|
||||
*/
|
||||
public function download_font_family( $variants = array() ) {
|
||||
if ( empty( $variants ) ) {
|
||||
$variants = array_keys( $this->files );
|
||||
}
|
||||
foreach ( $this->files as $variant => $file ) {
|
||||
if ( in_array( $variant, $variants ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
|
||||
$this->download_font_file( $file );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads a font-file and saves it locally.
|
||||
*
|
||||
* @access private
|
||||
* @param string $url The URL of the file we want to get.
|
||||
* @return bool
|
||||
*/
|
||||
private function download_font_file( $url ) {
|
||||
$path = $this->folder_path . '/' . $this->get_filename_from_url( $url );
|
||||
|
||||
// If the folder doesn't exist, create it.
|
||||
if ( ! file_exists( $this->folder_path ) ) {
|
||||
wp_mkdir_p( $this->folder_path );
|
||||
}
|
||||
// If the file exists no reason to do anything.
|
||||
if ( file_exists( $path ) ) {
|
||||
return true;
|
||||
}else{
|
||||
$contents = $this->get_remote_url_contents( $url );
|
||||
// Write file.
|
||||
$filesystem = $this->get_filesystem();
|
||||
return $filesystem->put_contents( $path, $contents, FS_CHMOD_FILE );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remote URL contents.
|
||||
*
|
||||
* @access private
|
||||
* @param string $url The URL we want to get.
|
||||
* @return string The contents of the remote URL.
|
||||
*/
|
||||
public function get_remote_url_contents( $url ) {
|
||||
$response = wp_remote_get( $url );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return array();
|
||||
}
|
||||
$html = wp_remote_retrieve_body( $response );
|
||||
if ( is_wp_error( $html ) ) {
|
||||
return;
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the filename by breaking-down the URL parts.
|
||||
*
|
||||
* @access private
|
||||
* @param string $url The URL.
|
||||
* @return string The filename.
|
||||
*/
|
||||
private function get_filename_from_url( $url ) {
|
||||
$url_parts = explode( '/', $url );
|
||||
$parts_count = count( $url_parts );
|
||||
if ( 1 < $parts_count ) {
|
||||
return $url_parts[ count( $url_parts ) - 1 ];
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the @font-face CSS for a specific variant.
|
||||
*
|
||||
* @access public
|
||||
* @param string $variant The variant.
|
||||
* @return string
|
||||
*/
|
||||
public function get_variant_fontface_css( $variant ) {
|
||||
$font_face = "@font-face{font-family:'{$this->family}';";
|
||||
|
||||
// Get the font-style.
|
||||
$font_style = ( false !== strpos( $variant, 'italic' ) ) ? 'italic' : 'normal';
|
||||
$font_face .= "font-style:{$font_style};";
|
||||
|
||||
// Get the font-weight.
|
||||
$font_weight = '400';
|
||||
$font_weight = str_replace( 'italic', '', $variant );
|
||||
$font_weight = ( ! $font_weight || 'regular' === $font_weight ) ? '400' : $font_weight;
|
||||
$font_face .= "font-weight:{$font_weight};";
|
||||
|
||||
// Get the font-names.
|
||||
$font_name_0 = $this->get_local_font_name( $variant, false );
|
||||
$font_name_1 = $this->get_local_font_name( $variant, true );
|
||||
$font_face .= "src:local('{$font_name_0}'),";
|
||||
if ( $font_name_0 !== $font_name_1 ) {
|
||||
$font_face .= "local('{$font_name_1}'),";
|
||||
}
|
||||
|
||||
// Get the font-url.
|
||||
$font_url = $this->get_variant_local_url( $variant );
|
||||
$paths = $this->get_font_files_paths();
|
||||
if ( ! file_exists( $paths[ $variant ] ) ) {
|
||||
$font_url = $this->files[ $variant ];
|
||||
}
|
||||
|
||||
// Get the font-format.
|
||||
$font_format = ( strpos( $font_url, '.woff2' ) ) ? 'woff2' : 'truetype';
|
||||
$font_format = ( strpos( $font_url, '.woff' ) && ! strpos( $font_url, '.woff2' ) ) ? 'woff' : $font_format;
|
||||
$font_face .= "url({$font_url}) format('{$font_format}');}";
|
||||
|
||||
return $font_face;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the font-family.
|
||||
* This is used by @font-face in case the user already has the font downloaded locally.
|
||||
*
|
||||
* @access public
|
||||
* @param string $variant The variant.
|
||||
* @param bool $compact Whether we want the compact formatting or not.
|
||||
* @return string
|
||||
*/
|
||||
public function get_local_font_name( $variant, $compact = false ) {
|
||||
$variant_names = array(
|
||||
'100' => 'Thin',
|
||||
'100i' => 'Thin Italic',
|
||||
'100italic' => 'Thin Italic',
|
||||
'200' => 'Extra-Light',
|
||||
'200i' => 'Extra-Light Italic',
|
||||
'200italic' => 'Extra-Light Italic',
|
||||
'300' => 'Light',
|
||||
'300i' => 'Light Italic',
|
||||
'300italic' => 'Light Italic',
|
||||
'400' => 'Regular',
|
||||
'regular' => 'Regular',
|
||||
'400i' => 'Regular Italic',
|
||||
'italic' => 'Italic',
|
||||
'400italic' => 'Regular Italic',
|
||||
'500' => 'Medium',
|
||||
'500i' => 'Medium Italic',
|
||||
'500italic' => 'Medium Italic',
|
||||
'600' => 'Semi-Bold',
|
||||
'600i' => 'Semi-Bold Italic',
|
||||
'600italic' => 'Semi-Bold Italic',
|
||||
'700' => 'Bold',
|
||||
'700i' => 'Bold Italic',
|
||||
'700italic' => 'Bold Italic',
|
||||
'800' => 'Extra-Bold',
|
||||
'800i' => 'Extra-Bold Italic',
|
||||
'800italic' => 'Extra-Bold Italic',
|
||||
'900' => 'Black',
|
||||
'900i' => 'Black Italic',
|
||||
'900italic' => 'Black Italic',
|
||||
);
|
||||
|
||||
$variant = (string) $variant;
|
||||
if ( $compact ) {
|
||||
if ( isset( $variant_names[ $variant ] ) ) {
|
||||
return str_replace( array( ' ', '-' ), '', $this->family ) . '-' . str_replace( array( ' ', '-' ), '', $variant_names[ $variant ] );
|
||||
}
|
||||
return str_replace( array( ' ', '-' ), '', $this->family );
|
||||
}
|
||||
|
||||
if ( isset( $variant_names[ $variant ] ) ) {
|
||||
return $this->family . ' ' . $variant_names[ $variant ];
|
||||
}
|
||||
return $this->family;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local URL for a variant.
|
||||
*
|
||||
* @access public
|
||||
* @param string $variant The variant.
|
||||
* @return string The URL.
|
||||
*/
|
||||
public function get_variant_local_url( $variant ) {
|
||||
$local_urls = $this->get_font_files_urls_local();
|
||||
|
||||
if ( empty( $local_urls ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Return the specific variant if we can find it.
|
||||
if ( isset( $local_urls[ $variant ] ) ) {
|
||||
return $local_urls[ $variant ];
|
||||
}
|
||||
|
||||
// Return regular if the one we want could not be found.
|
||||
if ( isset( $local_urls['regular'] ) ) {
|
||||
return $local_urls['regular'];
|
||||
}
|
||||
|
||||
// Return the first available if all else failed.
|
||||
$vals = array_values( $local_urls );
|
||||
return $vals[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of local file URLs.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_font_files_urls_local() {
|
||||
$urls = array();
|
||||
$files = $this->get_font_files();
|
||||
foreach ( $files as $key => $file ) {
|
||||
$urls[ $key ] = $this->folder_url . '/' . $file;
|
||||
}
|
||||
return $urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of local file paths.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_font_files_paths() {
|
||||
$paths = array();
|
||||
$files = $this->get_font_files();
|
||||
foreach ( $files as $key => $file ) {
|
||||
$paths[ $key ] = $this->folder_path . '/' . $file;
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of font-files.
|
||||
* Only contains the filenames.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_font_files() {
|
||||
$files = array();
|
||||
foreach ( $this->files as $key => $url ) {
|
||||
$files[ $key ] = $this->get_filename_from_url( $url );
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the root fonts folder path.
|
||||
* Other paths are built based on this.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function get_root_path() {
|
||||
|
||||
// Get the upload directory for this site.
|
||||
$upload_dir = wp_upload_dir();
|
||||
$path = untrailingslashit( wp_normalize_path( $upload_dir['basedir'] ) ) . '/webfonts';
|
||||
|
||||
// If the folder doesn't exist, create it.
|
||||
if ( ! file_exists( $path ) ) {
|
||||
wp_mkdir_p( $path );
|
||||
}
|
||||
|
||||
// Return the path.
|
||||
return apply_filters( 'daisy_blog_googlefonts_root_path', $path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the root folder url.
|
||||
* Other urls are built based on this.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function get_root_url() {
|
||||
|
||||
// Get the upload directory for this site.
|
||||
$upload_dir = wp_upload_dir();
|
||||
|
||||
// The URL.
|
||||
$url = trailingslashit( $upload_dir['baseurl'] );
|
||||
|
||||
// Take care of domain mapping.
|
||||
// When using domain mapping we have to make sure that the URL to the file
|
||||
// does not include the original domain but instead the mapped domain.
|
||||
if ( defined( 'DOMAIN_MAPPING' ) && DOMAIN_MAPPING ) {
|
||||
if ( function_exists( 'domain_mapping_siteurl' ) && function_exists( 'get_original_url' ) ) {
|
||||
$mapped_domain = domain_mapping_siteurl( false );
|
||||
$original_domain = get_original_url( 'siteurl' );
|
||||
$url = str_replace( $original_domain, $mapped_domain, $url );
|
||||
}
|
||||
}
|
||||
$url = str_replace( array( 'https://', 'http://' ), '//', $url );
|
||||
return apply_filters( 'daisy_blog_googlefonts_root_url', untrailingslashit( esc_url_raw( $url ) ) . '/webfonts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a font-family from the array of google-fonts.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_font_family() {
|
||||
// Get the fonts array.
|
||||
$fonts = $this->get_fonts();
|
||||
if ( isset( $fonts[ $this->family ] ) ) {
|
||||
return $fonts[ $this->family ];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the font defined in the google-fonts API.
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function get_fonts() {
|
||||
zeitfresser_get_google_fonts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the WP_Filesystem object.
|
||||
*
|
||||
* @access protected
|
||||
* @return object
|
||||
*/
|
||||
protected function get_filesystem(){
|
||||
// The WordPress filesystem.
|
||||
global $wp_filesystem;
|
||||
|
||||
if ( empty( $wp_filesystem ) ) {
|
||||
require_once wp_normalize_path( ABSPATH . '/wp-admin/includes/file.php' );
|
||||
WP_Filesystem();
|
||||
}
|
||||
return $wp_filesystem;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Handles adding to the footer the @font-face CSS for locally-hosted google-fonts.
|
||||
* Solves privacy concerns with Google's CDN and their sometimes less-than-transparent policies.
|
||||
*
|
||||
* @package zeitfresser
|
||||
*/
|
||||
|
||||
/**
|
||||
* Manages the way Google Fonts are enqueued.
|
||||
*/
|
||||
final class Daisy_Blog_Webfonts_Local{
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
*/
|
||||
protected $googlefonts;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function __construct( $googlefonts ) {
|
||||
$this->googlefonts = $googlefonts;
|
||||
|
||||
add_action( 'wp_footer', array( $this, 'add_styles' ) );
|
||||
add_action( 'admin_footer', array( $this, 'add_styles' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Webfont Loader for Google Fonts.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function add_styles() {
|
||||
|
||||
$hosted_fonts = $this->googlefonts;
|
||||
|
||||
// Early exit if we don't need to add any fonts.
|
||||
if ( empty( $hosted_fonts ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure we only do this once per font-family.
|
||||
$hosted_fonts = array_unique( $hosted_fonts );
|
||||
|
||||
// Start CSS.
|
||||
$css = '';
|
||||
foreach( $hosted_fonts as $family ){
|
||||
// Add the @font-face CSS for this font-family.
|
||||
$css .= Daisy_Blog_Google_Local::init( $family )->get_css();
|
||||
}
|
||||
|
||||
// If we've got CSS, add to the footer.
|
||||
if ( $css ) {
|
||||
echo '<style id="daisy-blog-local-webfonts">' . $css . '</style>'; // WPCS: XSS ok.
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,334 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Function to check if it's a google font
|
||||
*/
|
||||
function zeitfresser_is_google_font( $font ){
|
||||
$return = false;
|
||||
$websafe_fonts = zeitfresser_get_websafe_font();
|
||||
if( $font ){
|
||||
if( array_key_exists( $font, $websafe_fonts ) ){
|
||||
//Web Safe Font
|
||||
$return = false;
|
||||
}else{
|
||||
//Google Font
|
||||
$return = true;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( ! function_exists( 'zeitfresser_get_websafe_font' ) ) {
|
||||
|
||||
/**
|
||||
* Function listing WebSafe Fonts and its attributes
|
||||
*/
|
||||
function zeitfresser_get_websafe_font(){
|
||||
$standard_fonts = array(
|
||||
'georgia-serif' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => 'Georgia, serif',
|
||||
),
|
||||
'palatino-serif' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Palatino Linotype", "Book Antiqua", Palatino, serif',
|
||||
),
|
||||
'times-serif' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Times New Roman", Times, serif',
|
||||
),
|
||||
'arial-helvetica' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => 'Arial, Helvetica, sans-serif',
|
||||
),
|
||||
'arial-gadget' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Arial Black", Gadget, sans-serif',
|
||||
),
|
||||
'comic-cursive' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Comic Sans MS", cursive, sans-serif',
|
||||
),
|
||||
'impact-charcoal' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => 'Impact, Charcoal, sans-serif',
|
||||
),
|
||||
'lucida' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Lucida Sans Unicode", "Lucida Grande", sans-serif',
|
||||
),
|
||||
'tahoma-geneva' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => 'Tahoma, Geneva, sans-serif',
|
||||
),
|
||||
'trebuchet-helvetica' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Trebuchet MS", Helvetica, sans-serif',
|
||||
),
|
||||
'verdana-geneva' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => 'Verdana, Geneva, sans-serif',
|
||||
),
|
||||
'courier' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Courier New", Courier, monospace',
|
||||
),
|
||||
'lucida-monaco' => array(
|
||||
'variants' => array( 'regular', 'italic', '700', '700italic' ),
|
||||
'fonts' => '"Lucida Console", Monaco, monospace',
|
||||
)
|
||||
);
|
||||
|
||||
return apply_filters( 'daisy_blog_standard_fonts', $standard_fonts );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function zeitfresser_used_google_fonts() {
|
||||
$main_font_family = zeitfresser_get_mod( 'main_font_family', zeitfresser_get_default_main_font_family() );
|
||||
$secondary_font_family = zeitfresser_get_mod( 'secondary_font_family', zeitfresser_get_default_secondary_font_family() );
|
||||
$site_identity_font_family = esc_attr( zeitfresser_get_mod( 'site_identity_font_family', zeitfresser_get_default_site_identity_font_family() ) );
|
||||
|
||||
$args['main_font_family'] = $main_font_family;
|
||||
$args['secondary_font_family'] = $secondary_font_family;
|
||||
$args['site_identity_font_family'] = $site_identity_font_family;
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
||||
|
||||
add_action( 'wp_loaded', 'zeitfresser_google_font_local' );
|
||||
if( ! function_exists( 'zeitfresser_google_font_local' ) ) {
|
||||
/**
|
||||
* Function that load Google Fonts used in our theme from customer locally.
|
||||
* Solves privacy concerns with Google's CDN and their sometimes less-than-transparent policies.
|
||||
*/
|
||||
function zeitfresser_google_font_local() {
|
||||
|
||||
$args = array();
|
||||
$fonts = zeitfresser_used_google_fonts();
|
||||
|
||||
foreach( $fonts as $font ) {
|
||||
|
||||
$is_google_font = zeitfresser_is_google_font( $font );
|
||||
|
||||
if( $is_google_font ) {
|
||||
array_push( $args, $font );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new Daisy_Blog_Webfonts_Local( $args );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ( ! function_exists( 'zeitfresser_font_weight_variants' ) ) {
|
||||
/**
|
||||
* Return the font variants used by the theme as an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_font_weight_variants() {
|
||||
$weights = explode( ';', zeitfresser_font_weight_query() );
|
||||
$weights = array_map( 'trim', $weights );
|
||||
$weights = array_filter( $weights );
|
||||
|
||||
if ( ! in_array( '400', $weights, true ) ) {
|
||||
$weights[] = '400';
|
||||
}
|
||||
|
||||
$weights = array_values( array_unique( $weights ) );
|
||||
sort( $weights );
|
||||
|
||||
return $weights;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'zeitfresser_get_local_webfonts_css' ) ) {
|
||||
/**
|
||||
* Build local @font-face CSS for currently selected Google fonts.
|
||||
*
|
||||
* Falls back to remote font file URLs per variant if a local file is not
|
||||
* available yet, so typography does not break during warmup.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function zeitfresser_get_local_webfonts_css() {
|
||||
$fonts = array_values( array_unique( array_filter( zeitfresser_used_google_fonts() ) ) );
|
||||
$variants = zeitfresser_font_weight_variants();
|
||||
$css = '';
|
||||
|
||||
foreach ( $fonts as $font ) {
|
||||
if ( ! zeitfresser_is_google_font( $font ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$css .= Daisy_Blog_Google_Local::init( $font )->get_css( $variants );
|
||||
}
|
||||
|
||||
return $css;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'zeitfresser_get_local_webfont_urls' ) ) {
|
||||
/**
|
||||
* Extract local font asset URLs from a generated @font-face stylesheet.
|
||||
*
|
||||
* @param string $css Local webfont CSS.
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_get_local_webfont_urls( $css ) {
|
||||
if ( empty( $css ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
preg_match_all( '#url\(([^)]+)\)#', $css, $matches );
|
||||
|
||||
if ( empty( $matches[1] ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$urls = array();
|
||||
|
||||
foreach ( $matches[1] as $url ) {
|
||||
$url = trim( $url, "\"'" );
|
||||
|
||||
if ( false !== strpos( $url, content_url() ) ) {
|
||||
$urls[] = esc_url_raw( $url );
|
||||
}
|
||||
}
|
||||
|
||||
return array_values( array_unique( array_filter( $urls ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( ! function_exists( 'zeitfresser_font_weight_query' ) ) {
|
||||
/**
|
||||
* Return the compact weight list used by the Zeitfresser theme.
|
||||
*/
|
||||
function zeitfresser_font_weight_query() {
|
||||
$weights = array( '400', '500', '700' );
|
||||
$body_weight = (string) zeitfresser_get_mod( 'font_weight', zeitfresser_get_default_font_weight() );
|
||||
|
||||
if ( preg_match( '/^\d{3}$/', $body_weight ) ) {
|
||||
$weights[] = $body_weight;
|
||||
}
|
||||
|
||||
$weights = array_values( array_unique( array_filter( $weights ) ) );
|
||||
sort( $weights );
|
||||
|
||||
return implode( ';', $weights );
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists( 'zeitfresser_fonts_url' ) ) {
|
||||
/**
|
||||
* Returns a Google Fonts CSS2 URL for the selected theme fonts.
|
||||
*/
|
||||
function zeitfresser_fonts_url( $fonts = array() ) {
|
||||
$font_families = array();
|
||||
$weights = zeitfresser_font_weight_query();
|
||||
|
||||
foreach ( $fonts as $font ) {
|
||||
if ( ! zeitfresser_is_google_font( $font ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$family_name = trim( (string) $font );
|
||||
|
||||
if ( '' === $family_name ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$font_families[] = 'family=' . str_replace( ' ', '+', $family_name ) . ':wght@' . $weights;
|
||||
}
|
||||
|
||||
$font_families = array_values( array_unique( $font_families ) );
|
||||
|
||||
if ( empty( $font_families ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return esc_url( 'https://fonts.googleapis.com/css2?' . implode( '&', $font_families ) . '&display=swap' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( ! function_exists( 'zeitfresser_check_varient' ) ) {
|
||||
/**
|
||||
* Checks for matched varients in google fonts for typography fields
|
||||
*/
|
||||
function zeitfresser_check_varient( $font_family = 'serif', $font_variants = 'regular', $body = false ){
|
||||
$variant = '';
|
||||
$var = array();
|
||||
$google_fonts = zeitfresser_get_google_fonts(); //Google Fonts
|
||||
$websafe_fonts = zeitfresser_get_websafe_font(); //Standard Web Safe Fonts
|
||||
|
||||
if( array_key_exists( $font_family, $google_fonts ) ){
|
||||
$variants = $google_fonts[ $font_family ][ 'variants' ];
|
||||
if( in_array( $font_variants, $variants ) ){
|
||||
if( $body ){ //LOAD ALL VARIANTS FOR BODY FONT
|
||||
foreach( $variants as $v ){
|
||||
$var[] = $v;
|
||||
}
|
||||
$variant = implode( ',', $var );
|
||||
}else{
|
||||
$variant = $font_variants;
|
||||
}
|
||||
}else{
|
||||
$variant = 'regular';
|
||||
}
|
||||
}else{ //Standard Web Safe Fonts
|
||||
if( array_key_exists( $font_family, $websafe_fonts ) ){
|
||||
$variants = $websafe_fonts[ $font_family ][ 'variants' ];
|
||||
if( in_array( $font_variants, $variants ) ){
|
||||
if( $body ){ //LOAD ALL VARIANTS FOR BODY FONT
|
||||
foreach( $variants as $v ){
|
||||
$var[] = $v;
|
||||
}
|
||||
$variant = implode( ',', $var );
|
||||
}else{
|
||||
$variant = $font_variants;
|
||||
}
|
||||
}else{
|
||||
$variant = 'regular';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $variant;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( ! function_exists( 'zeitfresser_get_google_fonts' ) ) {
|
||||
/**
|
||||
* Get Google Fonts
|
||||
*/
|
||||
function zeitfresser_get_google_fonts(){
|
||||
$webfonts_json = @file_get_contents( get_template_directory_uri() . '/inc/blocks/font-family/inc/google-webfonts.json', true );
|
||||
$fonts = json_decode( $webfonts_json, true );
|
||||
|
||||
$google_fonts = array();
|
||||
|
||||
if ( is_array( $fonts ) ) {
|
||||
foreach ( $fonts['items'] as $font ) {
|
||||
$google_fonts[ $font['family'] ] = array(
|
||||
'variants' => $font['variants'],
|
||||
);
|
||||
}
|
||||
}
|
||||
return $google_fonts;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('main_font_family',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
$("head").append("<link href='https://fonts.googleapis.com/css?family=" + to + ":200,300,400,500,600,700,800,900|' rel='stylesheet' type='text/css'>");
|
||||
document.body.style.setProperty('--primary-font', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_main_font_family' );
|
||||
function zeitfresser_main_font_family( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'main_font_family', array(
|
||||
'default' => zeitfresser_get_default_main_font_family(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'zeitfresser_sanitize_google_fonts'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'main_font_family', array(
|
||||
'settings' => 'main_font_family',
|
||||
'label' => esc_html__( 'Primary Font', 'zeitfresser' ),
|
||||
'section' => 'daisy_blog_font_customization_section',
|
||||
'type' => 'select',
|
||||
'choices' => zeitfresser_google_fonts( zeitfresser_free_pro() ),
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_main_font_family_enqueue_scripts' );
|
||||
function zeitfresser_main_font_family_enqueue_scripts() {
|
||||
|
||||
$main_font_family = esc_attr( get_theme_mod( 'main_font_family', zeitfresser_get_default_main_font_family() ) );
|
||||
|
||||
wp_enqueue_script( 'graphthemes-main-font-family-customizer', get_template_directory_uri() . '/inc/blocks/font-family/main/customizer-main-font-family.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_main_font_family_dynamic_css' );
|
||||
function zeitfresser_main_font_family_dynamic_css() {
|
||||
|
||||
$main_font_family = esc_attr( get_theme_mod( 'main_font_family', zeitfresser_get_default_main_font_family() ) );
|
||||
|
||||
$dynamic_css = ":root { --primary-font: $main_font_family; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('secondary_font_family',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
$("head").append("<link href='https://fonts.googleapis.com/css?family=" + to + ":200,300,400,500,600,700,800,900|' rel='stylesheet' type='text/css'>");
|
||||
document.body.style.setProperty('--secondary-font', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_secondary_font_family' );
|
||||
function zeitfresser_secondary_font_family( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'secondary_font_family', array(
|
||||
'default' => zeitfresser_get_default_secondary_font_family(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'zeitfresser_sanitize_google_fonts'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'secondary_font_family', array(
|
||||
'settings' => 'secondary_font_family',
|
||||
'label' => esc_html__( 'Secondary Font', 'zeitfresser' ),
|
||||
'section' => 'daisy_blog_font_customization_section',
|
||||
'type' => 'select',
|
||||
'choices' => zeitfresser_google_fonts( zeitfresser_free_pro() ),
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_secondary_font_family_enqueue_scripts' );
|
||||
function zeitfresser_secondary_font_family_enqueue_scripts() {
|
||||
|
||||
$secondary_font_family = esc_attr( get_theme_mod( 'secondary_font_family', zeitfresser_get_default_secondary_font_family() ) );
|
||||
|
||||
|
||||
wp_enqueue_script( 'graphthemes-secondary-font-family-customizer', get_template_directory_uri() . '/inc/blocks/font-family/secondary/customizer-secondary-font-family.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_secondary_font_family_dynamic_css' );
|
||||
function zeitfresser_secondary_font_family_dynamic_css() {
|
||||
|
||||
$secondary_font_family = esc_attr( get_theme_mod( 'secondary_font_family', zeitfresser_get_default_secondary_font_family() ) );
|
||||
|
||||
|
||||
$dynamic_css = ":root { --secondary-font: $secondary_font_family; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
jQuery( function( $ ) {
|
||||
|
||||
wp.customize('site_identity_font_family',function ( value ) {
|
||||
value.bind(function ( to ) {
|
||||
$("head").append("<link rel='stylesheet' href='https://fonts.googleapis.com/css?family="+to+":200,300,400,500,600,700,800,900|' rel='stylesheet' type='text/css'>");
|
||||
document.body.style.setProperty('--site-identity-font-family', to);
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
} );
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
add_action( 'customize_register', 'zeitfresser_site_identity_font_family' );
|
||||
function zeitfresser_site_identity_font_family( $wp_customize ) {
|
||||
|
||||
$wp_customize->add_setting( 'site_identity_font_family', array(
|
||||
'default' => zeitfresser_get_default_site_identity_font_family(),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'zeitfresser_sanitize_google_fonts'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'site_identity_font_family', array(
|
||||
'settings' => 'site_identity_font_family',
|
||||
'label' => esc_html__( 'Site Title/Tagline Font', 'zeitfresser' ),
|
||||
'section' => 'title_tagline',
|
||||
'type' => 'select',
|
||||
'choices' => zeitfresser_google_fonts( zeitfresser_free_pro() ),
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
add_action( 'customize_preview_init', 'zeitfresser_site_identity_font_family_enqueue_scripts' );
|
||||
function zeitfresser_site_identity_font_family_enqueue_scripts() {
|
||||
|
||||
$site_identity_font_family = esc_attr( get_theme_mod( 'site_identity_font_family', zeitfresser_get_default_site_identity_font_family() ) );
|
||||
|
||||
|
||||
wp_enqueue_script( 'graphthemes-site-identity-font-family-customizer', get_template_directory_uri() . '/inc/blocks/font-family/site-identity/customizer-site-identity-font-family.js', array('jquery'), '', true );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'zeitfresser_site_identity_font_family_dynamic_css' );
|
||||
function zeitfresser_site_identity_font_family_dynamic_css() {
|
||||
|
||||
$site_identity_font_family = esc_attr( get_theme_mod( 'site_identity_font_family', zeitfresser_get_default_site_identity_font_family() ) );
|
||||
|
||||
$dynamic_css = ":root { --site-identity-font-family: $site_identity_font_family; }";
|
||||
|
||||
wp_add_inline_style( 'zeitfresser', $dynamic_css );
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Sample implementation of the Custom Header feature
|
||||
*
|
||||
* You can add an optional custom header image to header.php like so ...
|
||||
*
|
||||
<?php the_header_image_tag(); ?>
|
||||
*
|
||||
* @link https://developer.wordpress.org/themes/functionality/custom-headers/
|
||||
*
|
||||
* @package zeitfresser
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set up the WordPress core custom header feature.
|
||||
*
|
||||
* @uses zeitfresser_header_style()
|
||||
*/
|
||||
function zeitfresser_custom_header_setup() {
|
||||
add_theme_support(
|
||||
'custom-header',
|
||||
apply_filters(
|
||||
'daisy_blog_custom_header_args',
|
||||
array(
|
||||
'default-image' => '',
|
||||
'default-text-color' => '444444',
|
||||
'width' => 1000,
|
||||
'height' => 250,
|
||||
'flex-height' => true,
|
||||
'wp-head-callback' => 'zeitfresser_header_style',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'after_setup_theme', 'zeitfresser_custom_header_setup' );
|
||||
|
||||
if ( ! function_exists( 'zeitfresser_header_style' ) ) :
|
||||
/**
|
||||
* Styles the header image and text displayed on the blog.
|
||||
*
|
||||
* @see zeitfresser_custom_header_setup().
|
||||
*/
|
||||
function zeitfresser_header_style() {
|
||||
$header_text_color = get_header_textcolor();
|
||||
|
||||
/*
|
||||
* If no custom options for text are set, let's bail.
|
||||
* get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ).
|
||||
*/
|
||||
if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we get this far, we have custom styles. Let's do this.
|
||||
?>
|
||||
<style type="text/css">
|
||||
<?php
|
||||
// Has the text been hidden?
|
||||
if ( ! display_header_text() ) :
|
||||
?>
|
||||
.site-title,
|
||||
.site-description {
|
||||
position: absolute;
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
}
|
||||
<?php
|
||||
// If the user has set a custom color for the text use that.
|
||||
else :
|
||||
?>
|
||||
.site-title a,
|
||||
.site-description {
|
||||
color: #<?php echo esc_attr( $header_text_color ); ?>;
|
||||
}
|
||||
<?php endif; ?>
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
+179
-2
@@ -9,8 +9,10 @@
|
||||
* Add postMessage support for site title and description for the Theme Customizer.
|
||||
*
|
||||
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
||||
* @return void
|
||||
*/
|
||||
function zeitfresser_customize_register( $wp_customize ) {
|
||||
|
||||
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
|
||||
@@ -23,6 +25,7 @@ function zeitfresser_customize_register( $wp_customize ) {
|
||||
'render_callback' => 'zeitfresser_customize_partial_blogname',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'blogdescription',
|
||||
array(
|
||||
@@ -31,6 +34,59 @@ function zeitfresser_customize_register( $wp_customize ) {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performance Tools section
|
||||
*/
|
||||
$wp_customize->add_section(
|
||||
'ztfr_performance_tools',
|
||||
array(
|
||||
'title' => 'Performance Tools Settings',
|
||||
'priority' => 160,
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Auto optimize uploaded images.
|
||||
*/
|
||||
$wp_customize->add_setting(
|
||||
'ztfr_auto_optimize',
|
||||
array(
|
||||
'default' => true,
|
||||
'sanitize_callback' => 'wp_validate_boolean',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'ztfr_auto_optimize',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'ztfr_performance_tools',
|
||||
'label' => 'Auto Optimize Pictures on Upload',
|
||||
'description' => 'Automatically converts uploaded images to modern formats (AVIF/WebP) for improved performance.',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Auto delete originals after successful optimization.
|
||||
*/
|
||||
$wp_customize->add_setting(
|
||||
'ztfr_auto_delete',
|
||||
array(
|
||||
'default' => false,
|
||||
'sanitize_callback' => 'wp_validate_boolean',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'ztfr_auto_delete',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'ztfr_performance_tools',
|
||||
'label' => 'Auto Delete Original Pictures on Upload',
|
||||
'description' => 'Automatically deletes original images after optimization. ⚠️ This action cannot be undone.',
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'customize_register', 'zeitfresser_customize_register' );
|
||||
|
||||
@@ -53,9 +109,130 @@ function zeitfresser_customize_partial_blogdescription() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
* Bind JS handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function zeitfresser_customize_preview_js() {
|
||||
wp_enqueue_script( 'zeitfresser-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), ZEITFRESSER_VERSION, true );
|
||||
wp_enqueue_script(
|
||||
'zeitfresser-customizer',
|
||||
get_template_directory_uri() . '/js/customizer.js',
|
||||
array( 'customize-preview' ),
|
||||
ZEITFRESSER_VERSION,
|
||||
true
|
||||
);
|
||||
}
|
||||
add_action( 'customize_preview_init', 'zeitfresser_customize_preview_js' );
|
||||
|
||||
/**
|
||||
* Add dependency logic and status box for Performance Tools settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function zeitfresser_customize_controls_dependency_js() {
|
||||
?>
|
||||
<script>
|
||||
(function() {
|
||||
function getOptimizeInput() {
|
||||
return document.querySelector('#customize-control-ztfr_auto_optimize input[type="checkbox"]');
|
||||
}
|
||||
|
||||
function getDeleteInput() {
|
||||
return document.querySelector('#customize-control-ztfr_auto_delete input[type="checkbox"]');
|
||||
}
|
||||
|
||||
function getDeleteControl() {
|
||||
return document.getElementById('customize-control-ztfr_auto_delete');
|
||||
}
|
||||
|
||||
function ensureStatusBox() {
|
||||
let box = document.getElementById('ztfr-auto-status-box');
|
||||
|
||||
if (box) {
|
||||
return box;
|
||||
}
|
||||
|
||||
const optimizeControl = document.getElementById('customize-control-ztfr_auto_optimize');
|
||||
|
||||
if (!optimizeControl || !optimizeControl.parentNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
box = document.createElement('li');
|
||||
box.id = 'ztfr-auto-status-box';
|
||||
box.className = 'customize-control';
|
||||
box.innerHTML =
|
||||
'<span style="display:block;font-weight:600;margin-bottom:6px;">Current Mode</span>' +
|
||||
'<span id="ztfr-auto-status-text">Checking...</span>';
|
||||
|
||||
optimizeControl.parentNode.insertBefore(box, optimizeControl);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
function updateState() {
|
||||
const optimizeInput = getOptimizeInput();
|
||||
const deleteInput = getDeleteInput();
|
||||
const deleteControl = getDeleteControl();
|
||||
const statusBox = ensureStatusBox();
|
||||
const statusText = document.getElementById('ztfr-auto-status-text');
|
||||
|
||||
if (!optimizeInput || !deleteInput || !deleteControl || !statusBox || !statusText) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!optimizeInput.checked) {
|
||||
deleteInput.checked = false;
|
||||
deleteInput.disabled = true;
|
||||
deleteControl.style.opacity = '0.5';
|
||||
statusText.textContent = '⚪ Manual Mode (no automation)';
|
||||
} else {
|
||||
deleteInput.disabled = false;
|
||||
deleteControl.style.opacity = '1';
|
||||
|
||||
if (deleteInput.checked) {
|
||||
statusText.textContent = '🟢 Full Auto Mode (optimize + delete)';
|
||||
} else {
|
||||
statusText.textContent = '🟡 Auto Optimize enabled (originals kept)';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
updateState();
|
||||
|
||||
document.addEventListener('change', function(event) {
|
||||
const target = event.target;
|
||||
|
||||
if (
|
||||
target &&
|
||||
(
|
||||
target.matches('#customize-control-ztfr_auto_optimize input[type="checkbox"]') ||
|
||||
target.matches('#customize-control-ztfr_auto_delete input[type="checkbox"]')
|
||||
)
|
||||
) {
|
||||
updateState();
|
||||
}
|
||||
});
|
||||
|
||||
let tries = 0;
|
||||
const interval = setInterval(function() {
|
||||
updateState();
|
||||
tries++;
|
||||
|
||||
if (tries > 20) {
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action( 'customize_controls_enqueue_scripts', 'zeitfresser_customize_controls_dependency_js' );
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
if( ! defined( 'DAISY_BLOG_WIDGET_PATH' ) ) {
|
||||
define( 'DAISY_BLOG_WIDGET_PATH', dirname( __FILE__ ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Author Profile Widget.
|
||||
*/
|
||||
require_once DAISY_BLOG_WIDGET_PATH . '/includes/class-graphthemes-widget-functions.php';
|
||||
|
||||
require_once DAISY_BLOG_WIDGET_PATH . '/includes/widgets/widget-author-profile.php';
|
||||
|
||||
require_once DAISY_BLOG_WIDGET_PATH . '/includes/widgets/widget-recent-posts.php';
|
||||
|
||||
require_once DAISY_BLOG_WIDGET_PATH . '/includes/widgets/widget-popular-posts.php';
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Graphthemes_Widget_Functions {
|
||||
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
|
||||
}
|
||||
|
||||
public function enqueue_admin_scripts() {
|
||||
wp_enqueue_media();
|
||||
wp_enqueue_script( 'graphthemes-widgets-admin-scripts', get_template_directory_uri() . '/inc/graphthemes-widgets/includes/js/graphthemes-widgets-admin.js', array( 'jquery' ), ZEITFRESSER_VERSION , true );
|
||||
}
|
||||
|
||||
public function zeitfresser_widget_get_attachment_id( $url ) {
|
||||
$attachment_id = 0;
|
||||
$dir = wp_upload_dir();
|
||||
if ( false !== strpos( $url, $dir['baseurl'] . '/' ) ) { // Is URL in uploads directory?
|
||||
$file = basename( $url );
|
||||
$query_args = array(
|
||||
'post_type' => 'attachment',
|
||||
'post_status' => 'inherit',
|
||||
'fields' => 'ids',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'value' => $file,
|
||||
'compare' => 'LIKE',
|
||||
'key' => '_wp_attachment_metadata',
|
||||
),
|
||||
)
|
||||
);
|
||||
$query = new WP_Query( $query_args );
|
||||
if ( $query->have_posts() ) {
|
||||
foreach ( $query->posts as $post_id ) {
|
||||
$meta = wp_get_attachment_metadata( $post_id );
|
||||
$original_file = basename( $meta['file'] );
|
||||
$cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' );
|
||||
if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) {
|
||||
$attachment_id = $post_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $attachment_id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$obj = new Graphthemes_Widget_Functions;
|
||||
@@ -1,36 +0,0 @@
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
$(document).on("click", ".upload_image_button", function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $button = $(this);
|
||||
|
||||
|
||||
// Create the media frame.
|
||||
var file_frame = wp.media.frames.file_frame = wp.media({
|
||||
title: 'Select or upload image',
|
||||
library: { // remove these to show all
|
||||
type: 'image' // specific mime
|
||||
},
|
||||
button: {
|
||||
text: 'Select'
|
||||
},
|
||||
multiple: false // Set to true to allow multiple files to be selected
|
||||
});
|
||||
|
||||
// When an image is selected, run a callback.
|
||||
file_frame.on('select', function () {
|
||||
// We set multiple to false so only get one image from the uploader
|
||||
|
||||
var attachment = file_frame.state().get('selection').first().toJSON();
|
||||
$button.siblings('input').val(attachment.url).trigger('change');
|
||||
|
||||
|
||||
});
|
||||
|
||||
// Finally, open the modal
|
||||
file_frame.open();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,285 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Author Profile
|
||||
*/
|
||||
|
||||
// register Author Profile Widget
|
||||
function zeitfresser_register_author_profile_widget() {
|
||||
register_widget( 'Graphthemes_Author_Profile' );
|
||||
}
|
||||
add_action( 'widgets_init', 'zeitfresser_register_author_profile_widget' );
|
||||
|
||||
if( ! class_exists( 'Graphthemes_Author_Profile' ) ) :
|
||||
/**
|
||||
* Adds Graphthemes_Author_Profile widget.
|
||||
*/
|
||||
class Graphthemes_Author_Profile extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Register widget with WordPress.
|
||||
*/
|
||||
function __construct() {
|
||||
parent::__construct(
|
||||
'daisy_blog_widget_author_profile', // Base ID
|
||||
__( 'Graphthemes: Author Profile', 'zeitfresser' ), // Name
|
||||
array( 'description' => __( 'An Author Profile Widget', 'zeitfresser' ), ) // Args
|
||||
);
|
||||
}
|
||||
|
||||
public function widget( $args, $instance ) {
|
||||
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
|
||||
$name = ! empty( $instance['name'] ) ? $instance['name'] : '';
|
||||
$email = ! empty( $instance['email'] ) ? $instance['email'] : '';
|
||||
$content = ! empty( $instance['content'] ) ? $instance['content'] : '';
|
||||
$image = ! empty( $instance['image'] ) ? $instance['image'] : '';
|
||||
$author_image = ! empty( $instance['author-image'] ) ? $instance['author-image'] : '';
|
||||
$label = ! empty( $instance['label'] ) ? $instance['label'] : '';
|
||||
$link = ! empty( $instance['link'] ) ? $instance['link'] : '';
|
||||
$target = ! empty( $instance['target'] ) ? $instance['target'] : '';
|
||||
$attachment_id = $image;
|
||||
$social_facebook = ! empty( $instance['social-facebook'] ) ? $instance['social-facebook'] : '';
|
||||
$social_linkedin = ! empty( $instance['social-linkedin'] ) ? $instance['social-linkedin'] : '';
|
||||
$social_twitter = ! empty( $instance['social-twitter'] ) ? $instance['social-twitter'] : '';
|
||||
$social_instagram = ! empty( $instance['social-instagram'] ) ? $instance['social-instagram'] : '';
|
||||
|
||||
if ( !filter_var( $image, FILTER_VALIDATE_URL ) === false ) {
|
||||
$attachment_id = $obj->zeitfresser_widget_get_attachment_id( $image );
|
||||
}
|
||||
|
||||
$option = ! empty( $instance['author-image-option'] ) ? $instance['author-image-option'] : 'gravatar';
|
||||
|
||||
if( $attachment_id ){
|
||||
$author_bio_img_size = apply_filters('author_bio_img_size','thumbnail');
|
||||
}
|
||||
|
||||
|
||||
echo $args['before_widget'];
|
||||
ob_start();
|
||||
|
||||
if( $title ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', $title, $instance, $this->id_base ) . $args['after_title'];
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="graphthemes-widget-author-bio-holder">
|
||||
<div class="image-holder">
|
||||
<?php
|
||||
if( $option == 'gravatar' ){
|
||||
echo get_avatar( $email, 300 );
|
||||
}
|
||||
elseif( $option == 'photo' && $author_image ) { ?>
|
||||
<img src="<?php echo esc_url( $author_image ); ?>">
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="text-holder">
|
||||
<H5 class="title-holder"><?php echo esc_html( $name ); ?></H5>
|
||||
<div class="author-bio-content">
|
||||
<?php echo wpautop( wp_kses_post( $content ) ); ?>
|
||||
</div>
|
||||
|
||||
<?php if( $link && $label ){ ?>
|
||||
<a <?php if( isset( $instance['target'] ) && $instance['target']=='1' ){ echo "target=_blank"; } ?> href="<?php echo esc_url( $link ); ?>" class="btn-readmore"><?php echo esc_html( $label );?></a>
|
||||
<?php } ?>
|
||||
|
||||
<div class="author-bio-socicons social-share">
|
||||
<ul class="list-group list-group-horizontal list-inline">
|
||||
<?php if( isset( $instance['social-facebook'] ) && $instance['social-facebook'] ){ ?>
|
||||
|
||||
<li class="social-share-list list-group-item facebook-svg">
|
||||
<a target="_blank" href="<?php echo esc_url( $instance['social-facebook'] );?>">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M279.14 288l14.22-92.66h-88.91v-60.13c0-25.35 12.42-50.06 52.24-50.06h40.42V6.26S260.43 0 225.36 0c-73.22 0-121.08 44.38-121.08 124.72v70.62H22.89V288h81.39v224h100.17V288z"/></svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if( isset( $instance['social-linkedin'] ) && $instance['social-linkedin'] ){ ?>
|
||||
|
||||
|
||||
<li class="social-share-list list-group-item linkedin-svg">
|
||||
<a target="_blank" href="<?php echo esc_url( $instance['social-linkedin'] );?>">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M100.28 448H7.4V148.9h92.88zM53.79 108.1C24.09 108.1 0 83.5 0 53.8a53.79 53.79 0 0 1 107.58 0c0 29.7-24.1 54.3-53.79 54.3zM447.9 448h-92.68V302.4c0-34.7-.7-79.2-48.29-79.2-48.29 0-55.69 37.7-55.69 76.7V448h-92.78V148.9h89.08v40.8h1.3c12.4-23.5 42.69-48.3 87.88-48.3 94 0 111.28 61.9 111.28 142.3V448z"/></svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php if( isset( $instance['social-twitter'] ) && $instance['social-twitter'] ){ ?>
|
||||
|
||||
|
||||
<li class="social-share-list list-group-item twitter-svg">
|
||||
<a target="_blank" href="<?php echo esc_url( $instance['social-twitter'] );?>">
|
||||
<svg version="1.1" viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M492,109.5c-17.4,7.7-36,12.9-55.6,15.3c20-12,35.4-31,42.6-53.6c-18.7,11.1-39.4,19.2-61.5,23.5 C399.8,75.8,374.6,64,346.8,64c-53.5,0-96.8,43.4-96.8,96.9c0,7.6,0.8,15,2.5,22.1C172,179,100.6,140.4,52.9,81.7 c-8.3,14.3-13.1,31-13.1,48.7c0,33.6,17.1,63.3,43.1,80.7C67,210.7,52,206.3,39,199c0,0.4,0,0.8,0,1.2c0,47,33.4,86.1,77.7,95 c-8.1,2.2-16.7,3.4-25.5,3.4c-6.2,0-12.3-0.6-18.2-1.8c12.3,38.5,48.1,66.5,90.5,67.3c-33.1,26-74.9,41.5-120.3,41.5 c-7.8,0-15.5-0.5-23.1-1.4C62.9,432,113.8,448,168.4,448C346.6,448,444,300.3,444,172.2c0-4.2-0.1-8.4-0.3-12.5 C462.6,146,479,128.9,492,109.5z"/></svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php if( isset( $instance['social-instagram'] ) && $instance['social-instagram'] ){ ?>
|
||||
|
||||
|
||||
<li class="social-share-list list-group-item instagram-svg">
|
||||
<a target="_blank" href="<?php echo esc_url( $instance['social-instagram'] );?>">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-instagram" viewBox="0 0 16 16"> <path d="M8 0C5.829 0 5.556.01 4.703.048 3.85.088 3.269.222 2.76.42a3.917 3.917 0 0 0-1.417.923A3.927 3.927 0 0 0 .42 2.76C.222 3.268.087 3.85.048 4.7.01 5.555 0 5.827 0 8.001c0 2.172.01 2.444.048 3.297.04.852.174 1.433.372 1.942.205.526.478.972.923 1.417.444.445.89.719 1.416.923.51.198 1.09.333 1.942.372C5.555 15.99 5.827 16 8 16s2.444-.01 3.298-.048c.851-.04 1.434-.174 1.943-.372a3.916 3.916 0 0 0 1.416-.923c.445-.445.718-.891.923-1.417.197-.509.332-1.09.372-1.942C15.99 10.445 16 10.173 16 8s-.01-2.445-.048-3.299c-.04-.851-.175-1.433-.372-1.941a3.926 3.926 0 0 0-.923-1.417A3.911 3.911 0 0 0 13.24.42c-.51-.198-1.092-.333-1.943-.372C10.443.01 10.172 0 7.998 0h.003zm-.717 1.442h.718c2.136 0 2.389.007 3.232.046.78.035 1.204.166 1.486.275.373.145.64.319.92.599.28.28.453.546.598.92.11.281.24.705.275 1.485.039.843.047 1.096.047 3.231s-.008 2.389-.047 3.232c-.035.78-.166 1.203-.275 1.485a2.47 2.47 0 0 1-.599.919c-.28.28-.546.453-.92.598-.28.11-.704.24-1.485.276-.843.038-1.096.047-3.232.047s-2.39-.009-3.233-.047c-.78-.036-1.203-.166-1.485-.276a2.478 2.478 0 0 1-.92-.598 2.48 2.48 0 0 1-.6-.92c-.109-.281-.24-.705-.275-1.485-.038-.843-.046-1.096-.046-3.233 0-2.136.008-2.388.046-3.231.036-.78.166-1.204.276-1.486.145-.373.319-.64.599-.92.28-.28.546-.453.92-.598.282-.11.705-.24 1.485-.276.738-.034 1.024-.044 2.515-.045v.002zm4.988 1.328a.96.96 0 1 0 0 1.92.96.96 0 0 0 0-1.92zm-4.27 1.122a4.109 4.109 0 1 0 0 8.217 4.109 4.109 0 0 0 0-8.217zm0 1.441a2.667 2.667 0 1 1 0 5.334 2.667 2.667 0 0 1 0-5.334z"/> </svg>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$html = ob_get_clean();
|
||||
echo apply_filters( 'daisy_blog_widget_author_profile_widget_filter', $html, $args, $instance );
|
||||
echo $args['after_widget'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function form( $instance ) {
|
||||
$obj = new Graphthemes_Widget_Functions();
|
||||
|
||||
$email = get_option('admin_email');
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
|
||||
$name = ! empty( $instance['name'] ) ? $instance['name'] : '';
|
||||
$email = ! empty( $instance['email'] ) ? $instance['email'] : sanitize_email( $email );
|
||||
$content = ! empty( $instance['content'] ) ? $instance['content'] : '';
|
||||
$image = ! empty( $instance['image'] ) ? $instance['image'] : '';
|
||||
$author_image = ! empty( $instance['author-image'] ) ? $instance['author-image'] : '';
|
||||
$label = ! empty( $instance['label'] ) ? $instance['label'] : '';
|
||||
$link = ! empty( $instance['link'] ) ? $instance['link'] : '';
|
||||
$target = ! empty( $instance['target'] ) ? $instance['target'] : 0;
|
||||
$socicon = ! empty( $instance['socicon'] ) ? $instance['socicon'] : '';
|
||||
$option = ! empty( $instance['author-image-option'] ) ? $instance['author-image-option'] : 'gravatar';
|
||||
$social_facebook = ! empty( $instance['social-facebook'] ) ? $instance['social-facebook'] : '';
|
||||
$social_linkedin = ! empty( $instance['social-linkedin'] ) ? $instance['social-linkedin'] : '';
|
||||
$social_twitter = ! empty( $instance['social-twitter'] ) ? $instance['social-twitter'] : '';
|
||||
$social_instagram = ! empty( $instance['social-instagram'] ) ? $instance['social-instagram'] : '';
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>"><?php esc_html_e( 'Author Name', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'name' ) ); ?>" type="text" value="<?php echo esc_attr( $name ); ?>" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><?php esc_html_e('Display photo from:','zeitfresser'); ?></label>
|
||||
|
||||
<input class="author-image" type="radio" name="<?php echo esc_attr( $this->get_field_name( 'author-image-option' ) );?>" id="<?php echo esc_attr( $this->get_field_id( 'author-image-option' . '-gravatar' ) );?>" value="gravatar" <?php if( $option == 'gravatar' ) echo 'checked'; ?> />
|
||||
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'author-image-option' . '-gravatar' ) );?>" class="radio-btn-wrap"><?php esc_html_e('Gravatar', 'zeitfresser');?></label>
|
||||
|
||||
<input class="author-image" type="radio" name="<?php echo esc_attr( $this->get_field_name( 'author-image-option' ) );?>" id="<?php echo esc_attr( $this->get_field_id( 'author-image-option' . '-photo' ) );?>" value="photo" <?php if( $option == 'photo' ) echo 'checked'; ?> />
|
||||
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'author-image-option' . '-photo' ) );?>" class="radio-btn-wrap"><?php esc_html_e('Uploaded Photo','zeitfresser');?></label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input class="widefat author_image_url" id="<?php echo $this->get_field_id( 'author-image' ); ?>" name="<?php echo $this->get_field_name( 'author-image' ); ?>" type="text" value="<?php echo esc_url( $author_image ); ?>" />
|
||||
<button class="upload_image_button button button-primary"><?php esc_html_e( "Select Image", 'zeitfresser' ); ?></button>
|
||||
</p>
|
||||
|
||||
<p class="author-email">
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'email' ) ); ?>"><?php esc_html_e( 'Author Email', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'email' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'email' ) ); ?>" type="text" value="<?php echo esc_attr( $email ); ?>" />
|
||||
</p>
|
||||
<div class="widget-side-note" class="example-text"><?php $grav_link = '<a href=' . esc_url( get_avatar_url( $email ) ) . ' target="_blank">' . esc_html__( "Gravatar", 'zeitfresser' ) . '</a>'; echo sprintf( __( 'You can show your %1$s image instead of manually uploading your photo. Just add your gravatar registered email address here.','zeitfresser'), $grav_link );?></div>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'content' ) ); ?>"><?php esc_html_e( 'Description', 'zeitfresser' ); ?></label>
|
||||
<textarea name="<?php echo esc_attr( $this->get_field_name( 'content' ) ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'content' ) ); ?>"><?php echo wp_kses_post( $content ); ?></textarea>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'label' ) ); ?>"><?php esc_html_e( 'Button Label', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'label' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'label' ) ); ?>" type="text" value="<?php echo esc_attr( $label ); ?>" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>"><?php esc_html_e( 'Button Link', 'zeitfresser' ); ?></label>
|
||||
<input id="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'link' ) ); ?>" type="text" value="<?php echo esc_url( $link ); ?>" />
|
||||
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>" <?php $j='0'; if( isset( $instance['target'] ) ){ $j='1'; } ?> value="1" <?php checked( $j, true ); ?> name="<?php echo esc_attr( $this->get_field_name( 'target' ) ); ?>" type="checkbox" />
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>"><?php esc_html_e( 'Open in New Tab', 'zeitfresser' ); ?></label>
|
||||
</p>
|
||||
|
||||
|
||||
<div class="widget-social-profile">
|
||||
<label><h3><?php esc_html_e( "Social Profile", 'zeitfresser' ); ?></h3></label>
|
||||
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'social-facebook' ) ); ?>"><?php esc_html_e( 'Facebook Profile', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'social-facebook' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'social-facebook' ) ); ?>" type="text" value="<?php echo esc_attr( $social_facebook ); ?>" />
|
||||
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'social-linkedin' ) ); ?>"><?php esc_html_e( 'LinkedIn Profile', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'social-linkedin' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'social-linkedin' ) ); ?>" type="text" value="<?php echo esc_attr( $social_linkedin ); ?>" />
|
||||
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'social-twitter' ) ); ?>"><?php esc_html_e( 'Twitter Profile', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'social-twitter' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'social-twitter' ) ); ?>" type="text" value="<?php echo esc_attr( $social_twitter ); ?>" />
|
||||
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'social-instagram' ) ); ?>"><?php esc_html_e( 'Instagram Profile', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'social-instagram' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'social-instagram' ) ); ?>" type="text" value="<?php echo esc_attr( $social_instagram ); ?>" />
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize widget form values as they are saved.
|
||||
*
|
||||
* @see WP_Widget::update()
|
||||
*
|
||||
* @param array $new_instance Values just sent to be saved.
|
||||
* @param array $old_instance Previously saved values from database.
|
||||
*
|
||||
* @return array Updated safe values to be saved.
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
|
||||
$instance = array();
|
||||
$email = get_option('admin_email');
|
||||
|
||||
$instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : "";
|
||||
$instance['name'] = ! empty( $new_instance['name'] ) ? sanitize_text_field( $new_instance['name'] ) : "" ;
|
||||
$instance['email'] = ! empty( $new_instance['email'] ) ? sanitize_email( $new_instance['email'] ) : $email;
|
||||
$instance['content'] = ! empty( $new_instance['content'] ) ? wp_kses_post( $new_instance['content'] ) : '';
|
||||
$instance['image'] = ! empty( $new_instance['image'] ) ? esc_url( $new_instance['image'] ) : '';
|
||||
$instance['author-image'] = ! empty( $new_instance['author-image'] ) ? esc_url( $new_instance['author-image'] ) : '';
|
||||
$instance['label'] = ! empty( $new_instance['label'] ) ? wp_kses_post( $new_instance['label'] ) : '';
|
||||
$instance['link'] = ! empty( $new_instance['link'] ) ? esc_url( $new_instance['link'] ) : '';
|
||||
$instance['target'] = ! empty( $new_instance['target'] ) ? absint( $new_instance['target'] ) : 0;
|
||||
$instance['socicon'] = ! empty( $new_instance['socicon'] ) ? wp_kses_post( $new_instance['socicon'] ) : '';
|
||||
$instance['author-image-option'] = ! empty( $new_instance['author-image-option'] ) ? wp_kses_post( $new_instance['author-image-option'] ) : '';
|
||||
$instance['social-facebook'] = ! empty( $new_instance['social-facebook'] ) ? esc_url( $new_instance['social-facebook'] ) : '';
|
||||
$instance['social-linkedin'] = ! empty( $new_instance['social-linkedin'] ) ? esc_url( $new_instance['social-linkedin'] ) : '';
|
||||
$instance['social-twitter'] = ! empty( $new_instance['social-twitter'] ) ? esc_url( $new_instance['social-twitter'] ) : '';
|
||||
$instance['social-instagram'] = ! empty( $new_instance['social-instagram'] ) ? wp_kses_post( $new_instance['social-instagram'] ) : '';
|
||||
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
@@ -1,281 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Widget Popular Post
|
||||
*
|
||||
* @package Graphthemes_Widget
|
||||
*/
|
||||
|
||||
// register Graphthemes_Widget_Popular_Post widget
|
||||
function zeitfresser_register_popular_post_widget() {
|
||||
register_widget( 'Graphthemes_Widget_Popular_Post' );
|
||||
}
|
||||
add_action( 'widgets_init', 'zeitfresser_register_popular_post_widget' );
|
||||
|
||||
if( ! class_exists( 'Graphthemes_Widget_Popular_Post' ) ) :
|
||||
/**
|
||||
* Adds Graphthemes_Widget_Popular_Post widget.
|
||||
*/
|
||||
class Graphthemes_Widget_Popular_Post extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Register widget with WordPress.
|
||||
*/
|
||||
function __construct(){
|
||||
if( ! is_customize_preview() ) add_action('wp', array( $this, 'zeitfresser_set_views' ) );
|
||||
|
||||
parent::__construct(
|
||||
'daisy_blog_widget_popular_post', // Base ID
|
||||
esc_html__( 'Graphthemes: Popular Post', 'zeitfresser' ), // Name
|
||||
array( 'description' => esc_html__( 'A Popular Post Widget', 'zeitfresser' ), ) // Args
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add the post view count
|
||||
*/
|
||||
function zeitfresser_set_views( $post_id ) {
|
||||
if ( in_the_loop() ) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
else {
|
||||
global $wp_query;
|
||||
$post_id = $wp_query->get_queried_object_id();
|
||||
}
|
||||
if( is_singular( 'post' ) )
|
||||
{
|
||||
$count_key = '_daisy_blog_view_count';
|
||||
$count = get_post_meta( $post_id, $count_key, true );
|
||||
if( $count == '' ){
|
||||
$count = 0;
|
||||
delete_post_meta( $post_id, $count_key );
|
||||
add_post_meta( $post_id, $count_key, '1' );
|
||||
}else{
|
||||
$count++;
|
||||
update_post_meta( $post_id, $count_key, $count );
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Function to get the post view count
|
||||
*/
|
||||
function zeitfresser_get_views( $post_id ){
|
||||
$count_key = '_daisy_blog_view_count';
|
||||
$count = get_post_meta( $post_id, $count_key, true );
|
||||
if( $count == '' ){
|
||||
return __( "0 View", 'zeitfresser' );
|
||||
}elseif($count<=1){
|
||||
return $count. __(' View', 'zeitfresser' );
|
||||
}else{
|
||||
return $count. __(' Views', 'zeitfresser' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Front-end display of widget.
|
||||
*
|
||||
* @see WP_Widget::widget()
|
||||
*
|
||||
* @param array $args Widget arguments.
|
||||
* @param array $instance Saved values from database.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Popular Posts', 'zeitfresser' );
|
||||
$num_post = ! empty( $instance['num_post'] ) ? $instance['num_post'] : 3 ;
|
||||
$show_thumbnail = ! empty( $instance['show_thumbnail'] ) ? $instance['show_thumbnail'] : '';
|
||||
$show_date = ! empty( $instance['show_postdate'] ) ? $instance['show_postdate'] : '';
|
||||
$based_on = ! empty( $instance['based_on'] ) ? $instance['based_on'] : 'views';
|
||||
$comment_num = ! empty( $instance['comment_num'] ) ? $instance['comment_num'] : '';
|
||||
$view_count = ! empty( $instance['view_count'] ) ? $instance['view_count'] : '';
|
||||
$style = ! empty( $instance['style'] ) ? $instance['style'] : 'style-one';
|
||||
|
||||
$cat = get_theme_mod( 'exclude_categories' );
|
||||
if( $cat ) $cat = array_diff( array_unique( $cat ), array('') );
|
||||
|
||||
$arg = array(
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => $num_post,
|
||||
'ignore_sticky_posts' => true,
|
||||
'no_found_rows' => true,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
'category__not_in' => $cat
|
||||
);
|
||||
|
||||
if( $based_on == 'views' ){
|
||||
$arg['orderby'] = 'meta_value_num';
|
||||
$arg['meta_key'] = '_daisy_blog_view_count';
|
||||
}elseif( $based_on == 'comments' ){
|
||||
$arg['orderby'] = 'comment_count';
|
||||
}
|
||||
|
||||
$obj = new Graphthemes_Widget_Functions;
|
||||
|
||||
$daisy_blog_widget_popular_post_size = apply_filters('daisy_blog_widget_popular_post_size', 'thumbnail');
|
||||
$arg['no_found_rows'] = true;
|
||||
$arg['update_post_meta_cache'] = false;
|
||||
$arg['update_post_term_cache'] = false;
|
||||
$qry = new WP_Query( $arg );
|
||||
|
||||
if( $qry->have_posts() ){
|
||||
|
||||
echo $args['before_widget'];
|
||||
ob_start();
|
||||
|
||||
if( $title ) echo $args['before_title'] . apply_filters( 'widget_title', $title, $instance, $this->id_base ) . $args['after_title'];
|
||||
|
||||
$target = 'target="_self"';
|
||||
if( isset($instance['target']) && $instance['target']!='' )
|
||||
{
|
||||
$target = 'target="_blank"';
|
||||
}
|
||||
?>
|
||||
<ul>
|
||||
<?php
|
||||
while( $qry->have_posts() ){
|
||||
$qry->the_post();
|
||||
?>
|
||||
<li>
|
||||
<?php
|
||||
if( $show_thumbnail ){ ?>
|
||||
<a <?php echo $target;?> href="<?php the_permalink();?>" class="post-thumbnail">
|
||||
<?php
|
||||
if( has_post_thumbnail() && $show_thumbnail ){
|
||||
the_post_thumbnail( $daisy_blog_widget_popular_post_size, array( 'itemprop' => 'image' ) );
|
||||
}
|
||||
?>
|
||||
</a>
|
||||
<?php }
|
||||
?>
|
||||
<div class="entry-header">
|
||||
<h6 class="entry-title"><a <?php echo $target;?> href="<?php the_permalink(); ?>"><?php the_title();?></a></h6>
|
||||
|
||||
<?php if( $show_date ){ ?>
|
||||
<div class="entry-meta info">
|
||||
<?php
|
||||
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
|
||||
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
||||
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
|
||||
}
|
||||
|
||||
$time_string = sprintf(
|
||||
$time_string,
|
||||
esc_attr( get_the_date( DATE_W3C ) ),
|
||||
esc_html( get_the_date() ),
|
||||
esc_attr( get_the_modified_date( DATE_W3C ) ),
|
||||
esc_html( get_the_modified_date() )
|
||||
);
|
||||
?>
|
||||
<?php echo $time_string; ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if( $based_on == 'views' && $view_count ){ ?>
|
||||
<span class="view-count"><?php echo esc_html( $this->zeitfresser_get_views( get_the_ID() ) );?></span>
|
||||
<?php }
|
||||
elseif( $based_on == 'comments' && $comment_num ){ ?>
|
||||
<span class="comment-count"><i class="fa fa-comment" aria-hidden="true"></i><?php echo absint( get_comments_number() ); ?></span>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
wp_reset_postdata();
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
$html = ob_get_clean();
|
||||
echo apply_filters( 'daisy_blog_widget_popular_post_widget_filter', $html, $args, $instance );
|
||||
echo $args['after_widget'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Back-end widget form.
|
||||
*
|
||||
* @see WP_Widget::form()
|
||||
*
|
||||
* @param array $instance Previously saved values from database.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Popular Posts', 'zeitfresser' );
|
||||
$num_post = ! empty( $instance['num_post'] ) ? $instance['num_post'] : 3 ;
|
||||
$show_thumbnail = ! empty( $instance['show_thumbnail'] ) ? $instance['show_thumbnail'] : '';
|
||||
$show_postdate = ! empty( $instance['show_postdate'] ) ? $instance['show_postdate'] : '';
|
||||
$based_on = ! empty( $instance['based_on'] ) ? $instance['based_on'] : 'views';
|
||||
$comment_num = ! empty( $instance['comment_num'] ) ? $instance['comment_num'] : '';
|
||||
$view_count = ! empty( $instance['view_count'] ) ? $instance['view_count'] : '';
|
||||
$style = ! empty( $instance['style'] ) ? $instance['style'] : 'style-one';
|
||||
$target = ! empty( $instance['target'] ) ? $instance['target'] : '';
|
||||
?>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'num_post' ) ); ?>"><?php esc_html_e( 'Number of Posts', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'num_post' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'num_post' ) ); ?>" type="number" step="1" min="1" value="<?php echo esc_attr( $num_post ); ?>" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'based_on' ) ); ?>"><?php esc_html_e( 'Popular based on:', 'zeitfresser' ); ?></label>
|
||||
<select id="<?php echo esc_attr( $this->get_field_id( 'based_on' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'based_on' ) ); ?>" class="based-on">
|
||||
<option value="views" <?php selected( $based_on, 'views' ); ?>><?php esc_html_e( 'Post Views', 'zeitfresser' ); ?></option>
|
||||
<option value="comments" <?php selected( $based_on, 'comments' ); ?>><?php esc_html_e( 'Comment Count', 'zeitfresser' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<input id="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_thumbnail' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $show_thumbnail ); ?>/>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>"><?php esc_html_e( 'Show Post Thumbnail', 'zeitfresser' ); ?></label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input id="<?php echo esc_attr( $this->get_field_id( 'show_postdate' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_postdate' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $show_postdate ); ?>/>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'show_postdate' ) ); ?>"><?php esc_html_e( 'Show Post Date', 'zeitfresser' ); ?></label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>">
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'target' ) ); ?>" type="checkbox" value="1" <?php echo checked($target,1);?> /><?php esc_html_e( 'Open in New Tab', 'zeitfresser' ); ?> </label>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize widget form values as they are saved.
|
||||
*
|
||||
* @see WP_Widget::update()
|
||||
*
|
||||
* @param array $new_instance Values just sent to be saved.
|
||||
* @param array $old_instance Previously saved values from database.
|
||||
*
|
||||
* @return array Updated safe values to be saved.
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
|
||||
$instance = array();
|
||||
$instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : __( 'Recent Posts', 'zeitfresser' );
|
||||
$instance['num_post'] = ! empty( $new_instance['num_post'] ) ? absint( $new_instance['num_post'] ) : 3 ;
|
||||
$instance['show_thumbnail'] = ! empty( $new_instance['show_thumbnail'] ) ? absint( $new_instance['show_thumbnail'] ) : '';
|
||||
$instance['show_postdate'] = ! empty( $new_instance['show_postdate'] ) ? absint( $new_instance['show_postdate'] ) : '';
|
||||
$instance['based_on'] = ! empty( $new_instance['based_on'] ) ? esc_attr( $new_instance['based_on'] ) : 'views';
|
||||
$instance['comment_num'] = ! empty( $new_instance['comment_num'] ) ? absint( $new_instance['comment_num'] ) : '';
|
||||
$instance['view_count'] = ! empty( $new_instance['view_count'] ) ? absint( $new_instance['view_count'] ) : '';
|
||||
$instance['style'] = ! empty( $new_instance['style'] ) ? esc_attr( $new_instance['style'] ) : 'style-one';
|
||||
$instance['target'] = ! empty( $new_instance['target'] ) ? esc_attr( $new_instance['target'] ) : '';
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
} // class Graphthemes_Widget_Popular_Post
|
||||
endif;
|
||||
@@ -1,190 +0,0 @@
|
||||
<?php
|
||||
|
||||
// register Daisy_Blog_Recent_Post widget
|
||||
function zeitfresser_register_recent_post_widget() {
|
||||
register_widget( 'Daisy_Blog_Recent_Post' );
|
||||
}
|
||||
add_action( 'widgets_init', 'zeitfresser_register_recent_post_widget' );
|
||||
|
||||
/**
|
||||
* Adds Daisy_Blog_Recent_Post widget.
|
||||
*/
|
||||
class Daisy_Blog_Recent_Post extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Register widget with WordPress.
|
||||
*/
|
||||
function __construct() {
|
||||
parent::__construct(
|
||||
'daisy_blog_widget_recent_post', // Base ID
|
||||
__( 'Graphthemes: Recent Post', 'zeitfresser' ), // Name
|
||||
array( 'description' => __( 'A Recent Post Widget', 'zeitfresser' ), ) // Args
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Front-end display of widget.
|
||||
*
|
||||
* @see WP_Widget::widget()
|
||||
*
|
||||
* @param array $args Widget arguments.
|
||||
* @param array $instance Saved values from database.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Recent Posts', 'zeitfresser' );
|
||||
$num_post = ! empty( $instance['num_post'] ) ? $instance['num_post'] : 3 ;
|
||||
$show_thumb = ! empty( $instance['show_thumbnail'] ) ? $instance['show_thumbnail'] : '';
|
||||
$show_date = ! empty( $instance['show_postdate'] ) ? $instance['show_postdate'] : '';
|
||||
$cats[] = '';
|
||||
$cat = apply_filters( 'daisy_blog_pro_exclude_categories', $cats );
|
||||
$style = ! empty( $instance['style'] ) ? $instance['style'] : 'style-one';
|
||||
|
||||
$target = 'target="_self"';
|
||||
if( isset($instance['target']) && $instance['target']!='' ){
|
||||
$target = 'target="_blank"';
|
||||
}
|
||||
|
||||
$obj = new Graphthemes_Widget_Functions;
|
||||
|
||||
$daisy_blog_recent_post_size = apply_filters('daisy_blog_recent_post_size', 'thumbnail');
|
||||
$qry = new WP_Query( array(
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => $num_post,
|
||||
'ignore_sticky_posts' => true,
|
||||
'no_found_rows' => true,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
'category__not_in' => $cat
|
||||
) );
|
||||
if( $qry->have_posts() ){
|
||||
echo $args['before_widget'];
|
||||
ob_start();
|
||||
if( $title ) echo $args['before_title'] . apply_filters( 'widget_title', $title, $instance, $this->id_base ) . $args['after_title'];
|
||||
?>
|
||||
<ul>
|
||||
<?php
|
||||
while( $qry->have_posts() ){
|
||||
$qry->the_post();
|
||||
?>
|
||||
<li>
|
||||
<?php
|
||||
if( $show_thumb ){ ?>
|
||||
<a <?php echo $target; ?> href="<?php the_permalink();?>" class="post-thumbnail">
|
||||
<?php
|
||||
if( has_post_thumbnail() && $show_thumb ){
|
||||
the_post_thumbnail( $daisy_blog_recent_post_size, array( 'itemprop' => 'image' ) );
|
||||
}
|
||||
?>
|
||||
</a>
|
||||
<?php }
|
||||
?>
|
||||
<div class="entry-header">
|
||||
<h6 class="entry-title"><a <?php echo $target; ?> href="<?php the_permalink(); ?>"><?php the_title();?></a></h6>
|
||||
|
||||
<?php if( $show_date ){ ?>
|
||||
<div class="entry-meta info">
|
||||
<?php
|
||||
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
|
||||
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
||||
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
|
||||
}
|
||||
|
||||
$time_string = sprintf(
|
||||
$time_string,
|
||||
esc_attr( get_the_date( DATE_W3C ) ),
|
||||
esc_html( get_the_date() ),
|
||||
esc_attr( get_the_modified_date( DATE_W3C ) ),
|
||||
esc_html( get_the_modified_date() )
|
||||
);
|
||||
?>
|
||||
<?php echo $time_string; ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
wp_reset_postdata();
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
$html = ob_get_clean();
|
||||
echo apply_filters( 'daisy_blog_recent_post_widget_filter', $html, $args, $instance );
|
||||
echo $args['after_widget'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Back-end widget form.
|
||||
*
|
||||
* @see WP_Widget::form()
|
||||
*
|
||||
* @param array $instance Previously saved values from database.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Recent Posts', 'zeitfresser' );
|
||||
$num_post = ! empty( $instance['num_post'] ) ? $instance['num_post'] : 3 ;
|
||||
$show_thumbnail = ! empty( $instance['show_thumbnail'] ) ? $instance['show_thumbnail'] : '';
|
||||
$show_postdate = ! empty( $instance['show_postdate'] ) ? $instance['show_postdate'] : '';
|
||||
$style = ! empty( $instance['style'] ) ? $instance['style'] : 'style-one';
|
||||
$target = ! empty( $instance['target'] ) ? $instance['target'] : '';
|
||||
?>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'num_post' ) ); ?>"><?php esc_html_e( 'Number of Posts', 'zeitfresser' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'num_post' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'num_post' ) ); ?>" type="number" step="1" min="1" value="<?php echo esc_attr( $num_post ); ?>" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input id="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_thumbnail' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $show_thumbnail ); ?>/>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>"><?php esc_html_e( 'Show Post Thumbnail', 'zeitfresser' ); ?></label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input id="<?php echo esc_attr( $this->get_field_id( 'show_postdate' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_postdate' ) ); ?>" type="checkbox" value="1" <?php checked( '1', $show_postdate ); ?>/>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'show_postdate' ) ); ?>"><?php esc_html_e( 'Show Post Date', 'zeitfresser' ); ?></label>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>">
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'target' ) ); ?>" type="checkbox" value="1" <?php echo checked($target,1);?> /><?php esc_html_e( 'Open in New Tab', 'zeitfresser' ); ?> </label>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize widget form values as they are saved.
|
||||
*
|
||||
* @see WP_Widget::update()
|
||||
*
|
||||
* @param array $new_instance Values just sent to be saved.
|
||||
* @param array $old_instance Previously saved values from database.
|
||||
*
|
||||
* @return array Updated safe values to be saved.
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
|
||||
$instance = array();
|
||||
|
||||
$instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : __( 'Recent Posts', 'zeitfresser' );
|
||||
$instance['num_post'] = ! empty( $new_instance['num_post'] ) ? absint( $new_instance['num_post'] ) : 3 ;
|
||||
$instance['show_thumbnail'] = ! empty( $new_instance['show_thumbnail'] ) ? absint( $new_instance['show_thumbnail'] ) : '';
|
||||
$instance['show_postdate'] = ! empty( $new_instance['show_postdate'] ) ? absint( $new_instance['show_postdate'] ) : '';
|
||||
$instance['style'] = ! empty( $new_instance['style'] ) ? esc_attr( $new_instance['style'] ) : 'style-one';
|
||||
|
||||
$instance['target'] = ! empty( $new_instance['target'] ) ? esc_attr( $new_instance['target'] ) : '';
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Legacy compatibility aliases for old Daisy-prefixed callbacks.
|
||||
*
|
||||
* @package zeitfresser
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
||||
|
||||
if ( ! function_exists( 'daisy_blog_body_classes' ) && function_exists( 'zeitfresser_body_classes' ) ) { function daisy_blog_body_classes(...$args) { return zeitfresser_body_classes(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_check_varient' ) && function_exists( 'zeitfresser_check_varient' ) ) { function daisy_blog_check_varient(...$args) { return zeitfresser_check_varient(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_color_section' ) && function_exists( 'zeitfresser_color_section' ) ) { function daisy_blog_color_section(...$args) { return zeitfresser_color_section(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_container_width' ) && function_exists( 'zeitfresser_container_width' ) ) { function daisy_blog_container_width(...$args) { return zeitfresser_container_width(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_container_width_dynamic_css' ) && function_exists( 'zeitfresser_container_width_dynamic_css' ) ) { function daisy_blog_container_width_dynamic_css(...$args) { return zeitfresser_container_width_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_container_width_enqueue_scripts' ) && function_exists( 'zeitfresser_container_width_enqueue_scripts' ) ) { function daisy_blog_container_width_enqueue_scripts(...$args) { return zeitfresser_container_width_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_content_width' ) && function_exists( 'zeitfresser_content_width' ) ) { function daisy_blog_content_width(...$args) { return zeitfresser_content_width(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_custom_header_setup' ) && function_exists( 'zeitfresser_custom_header_setup' ) ) { function daisy_blog_custom_header_setup(...$args) { return zeitfresser_custom_header_setup(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_customize_partial_blogdescription' ) && function_exists( 'zeitfresser_customize_partial_blogdescription' ) ) { function daisy_blog_customize_partial_blogdescription(...$args) { return zeitfresser_customize_partial_blogdescription(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_customize_partial_blogname' ) && function_exists( 'zeitfresser_customize_partial_blogname' ) ) { function daisy_blog_customize_partial_blogname(...$args) { return zeitfresser_customize_partial_blogname(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_customize_preview_js' ) && function_exists( 'zeitfresser_customize_preview_js' ) ) { function daisy_blog_customize_preview_js(...$args) { return zeitfresser_customize_preview_js(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_customize_register' ) && function_exists( 'zeitfresser_customize_register' ) ) { function daisy_blog_customize_register(...$args) { return zeitfresser_customize_register(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_customize_register_footer_copyright' ) && function_exists( 'zeitfresser_customize_register_footer_copyright' ) ) { function daisy_blog_customize_register_footer_copyright(...$args) { return zeitfresser_customize_register_footer_copyright(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_dark_color' ) && function_exists( 'zeitfresser_dark_color' ) ) { function daisy_blog_dark_color(...$args) { return zeitfresser_dark_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_dark_color_dynamic_css' ) && function_exists( 'zeitfresser_dark_color_dynamic_css' ) ) { function daisy_blog_dark_color_dynamic_css(...$args) { return zeitfresser_dark_color_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_dark_color_enqueue_scripts' ) && function_exists( 'zeitfresser_dark_color_enqueue_scripts' ) ) { function daisy_blog_dark_color_enqueue_scripts(...$args) { return zeitfresser_dark_color_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_entry_footer' ) && function_exists( 'zeitfresser_entry_footer' ) ) { function daisy_blog_entry_footer(...$args) { return zeitfresser_entry_footer(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_font_size' ) && function_exists( 'zeitfresser_font_size' ) ) { function daisy_blog_font_size(...$args) { return zeitfresser_font_size(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_font_size_dynamic_css' ) && function_exists( 'zeitfresser_font_size_dynamic_css' ) ) { function daisy_blog_font_size_dynamic_css(...$args) { return zeitfresser_font_size_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_font_size_enqueue_scripts' ) && function_exists( 'zeitfresser_font_size_enqueue_scripts' ) ) { function daisy_blog_font_size_enqueue_scripts(...$args) { return zeitfresser_font_size_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_font_weight' ) && function_exists( 'zeitfresser_font_weight' ) ) { function daisy_blog_font_weight(...$args) { return zeitfresser_font_weight(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_font_weight_dynamic_css' ) && function_exists( 'zeitfresser_font_weight_dynamic_css' ) ) { function daisy_blog_font_weight_dynamic_css(...$args) { return zeitfresser_font_weight_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_font_weight_enqueue_scripts' ) && function_exists( 'zeitfresser_font_weight_enqueue_scripts' ) ) { function daisy_blog_font_weight_enqueue_scripts(...$args) { return zeitfresser_font_weight_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_fonts_url' ) && function_exists( 'zeitfresser_fonts_url' ) ) { function daisy_blog_fonts_url(...$args) { return zeitfresser_fonts_url(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_free_pro' ) && function_exists( 'zeitfresser_free_pro' ) ) { function daisy_blog_free_pro(...$args) { return zeitfresser_free_pro(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_background_color' ) && function_exists( 'zeitfresser_get_default_background_color' ) ) { function daisy_blog_get_default_background_color(...$args) { return zeitfresser_get_default_background_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_breadcrumbs' ) && function_exists( 'zeitfresser_get_default_breadcrumbs' ) ) { function daisy_blog_get_default_breadcrumbs(...$args) { return zeitfresser_get_default_breadcrumbs(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_container_width' ) && function_exists( 'zeitfresser_get_default_container_width' ) ) { function daisy_blog_get_default_container_width(...$args) { return zeitfresser_get_default_container_width(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_dark_color' ) && function_exists( 'zeitfresser_get_default_dark_color' ) ) { function daisy_blog_get_default_dark_color(...$args) { return zeitfresser_get_default_dark_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_font_size' ) && function_exists( 'zeitfresser_get_default_font_size' ) ) { function daisy_blog_get_default_font_size(...$args) { return zeitfresser_get_default_font_size(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_font_weight' ) && function_exists( 'zeitfresser_get_default_font_weight' ) ) { function daisy_blog_get_default_font_weight(...$args) { return zeitfresser_get_default_font_weight(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_footer_copyright' ) && function_exists( 'zeitfresser_get_default_footer_copyright' ) ) { function daisy_blog_get_default_footer_copyright(...$args) { return zeitfresser_get_default_footer_copyright(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_grey_color' ) && function_exists( 'zeitfresser_get_default_grey_color' ) ) { function daisy_blog_get_default_grey_color(...$args) { return zeitfresser_get_default_grey_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_light_color' ) && function_exists( 'zeitfresser_get_default_light_color' ) ) { function daisy_blog_get_default_light_color(...$args) { return zeitfresser_get_default_light_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_line_height' ) && function_exists( 'zeitfresser_get_default_line_height' ) ) { function daisy_blog_get_default_line_height(...$args) { return zeitfresser_get_default_line_height(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_logo_size' ) && function_exists( 'zeitfresser_get_default_logo_size' ) ) { function daisy_blog_get_default_logo_size(...$args) { return zeitfresser_get_default_logo_size(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_main_font_family' ) && function_exists( 'zeitfresser_get_default_main_font_family' ) ) { function daisy_blog_get_default_main_font_family(...$args) { return zeitfresser_get_default_main_font_family(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_author' ) && function_exists( 'zeitfresser_get_default_post_detail_author' ) ) { function daisy_blog_get_default_post_detail_author(...$args) { return zeitfresser_get_default_post_detail_author(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_author_block' ) && function_exists( 'zeitfresser_get_default_post_detail_author_block' ) ) { function daisy_blog_get_default_post_detail_author_block(...$args) { return zeitfresser_get_default_post_detail_author_block(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_category' ) && function_exists( 'zeitfresser_get_default_post_detail_category' ) ) { function daisy_blog_get_default_post_detail_category(...$args) { return zeitfresser_get_default_post_detail_category(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_comment' ) && function_exists( 'zeitfresser_get_default_post_detail_comment' ) ) { function daisy_blog_get_default_post_detail_comment(...$args) { return zeitfresser_get_default_post_detail_comment(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_date' ) && function_exists( 'zeitfresser_get_default_post_detail_date' ) ) { function daisy_blog_get_default_post_detail_date(...$args) { return zeitfresser_get_default_post_detail_date(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_featured_image' ) && function_exists( 'zeitfresser_get_default_post_detail_featured_image' ) ) { function daisy_blog_get_default_post_detail_featured_image(...$args) { return zeitfresser_get_default_post_detail_featured_image(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_featured_image_size' ) && function_exists( 'zeitfresser_get_default_post_detail_featured_image_size' ) ) { function daisy_blog_get_default_post_detail_featured_image_size(...$args) { return zeitfresser_get_default_post_detail_featured_image_size(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_related_articles' ) && function_exists( 'zeitfresser_get_default_post_detail_related_articles' ) ) { function daisy_blog_get_default_post_detail_related_articles(...$args) { return zeitfresser_get_default_post_detail_related_articles(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_related_articles_title' ) && function_exists( 'zeitfresser_get_default_post_detail_related_articles_title' ) ) { function daisy_blog_get_default_post_detail_related_articles_title(...$args) { return zeitfresser_get_default_post_detail_related_articles_title(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_social_share' ) && function_exists( 'zeitfresser_get_default_post_detail_social_share' ) ) { function daisy_blog_get_default_post_detail_social_share(...$args) { return zeitfresser_get_default_post_detail_social_share(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_social_share_options' ) && function_exists( 'zeitfresser_get_default_post_detail_social_share_options' ) ) { function daisy_blog_get_default_post_detail_social_share_options(...$args) { return zeitfresser_get_default_post_detail_social_share_options(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_detail_tag' ) && function_exists( 'zeitfresser_get_default_post_detail_tag' ) ) { function daisy_blog_get_default_post_detail_tag(...$args) { return zeitfresser_get_default_post_detail_tag(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_author' ) && function_exists( 'zeitfresser_get_default_post_snippet_author' ) ) { function daisy_blog_get_default_post_snippet_author(...$args) { return zeitfresser_get_default_post_snippet_author(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_category' ) && function_exists( 'zeitfresser_get_default_post_snippet_category' ) ) { function daisy_blog_get_default_post_snippet_category(...$args) { return zeitfresser_get_default_post_snippet_category(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_comment' ) && function_exists( 'zeitfresser_get_default_post_snippet_comment' ) ) { function daisy_blog_get_default_post_snippet_comment(...$args) { return zeitfresser_get_default_post_snippet_comment(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_date' ) && function_exists( 'zeitfresser_get_default_post_snippet_date' ) ) { function daisy_blog_get_default_post_snippet_date(...$args) { return zeitfresser_get_default_post_snippet_date(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_excerpt_size' ) && function_exists( 'zeitfresser_get_default_post_snippet_excerpt_size' ) ) { function daisy_blog_get_default_post_snippet_excerpt_size(...$args) { return zeitfresser_get_default_post_snippet_excerpt_size(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_featured_image' ) && function_exists( 'zeitfresser_get_default_post_snippet_featured_image' ) ) { function daisy_blog_get_default_post_snippet_featured_image(...$args) { return zeitfresser_get_default_post_snippet_featured_image(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_featured_image_size' ) && function_exists( 'zeitfresser_get_default_post_snippet_featured_image_size' ) ) { function daisy_blog_get_default_post_snippet_featured_image_size(...$args) { return zeitfresser_get_default_post_snippet_featured_image_size(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_read_more_text' ) && function_exists( 'zeitfresser_get_default_post_snippet_read_more_text' ) ) { function daisy_blog_get_default_post_snippet_read_more_text(...$args) { return zeitfresser_get_default_post_snippet_read_more_text(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_show_hide_read_more' ) && function_exists( 'zeitfresser_get_default_post_snippet_show_hide_read_more' ) ) { function daisy_blog_get_default_post_snippet_show_hide_read_more(...$args) { return zeitfresser_get_default_post_snippet_show_hide_read_more(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_social_share' ) && function_exists( 'zeitfresser_get_default_post_snippet_social_share' ) ) { function daisy_blog_get_default_post_snippet_social_share(...$args) { return zeitfresser_get_default_post_snippet_social_share(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_social_share_options' ) && function_exists( 'zeitfresser_get_default_post_snippet_social_share_options' ) ) { function daisy_blog_get_default_post_snippet_social_share_options(...$args) { return zeitfresser_get_default_post_snippet_social_share_options(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_post_snippet_tag' ) && function_exists( 'zeitfresser_get_default_post_snippet_tag' ) ) { function daisy_blog_get_default_post_snippet_tag(...$args) { return zeitfresser_get_default_post_snippet_tag(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_primary_color' ) && function_exists( 'zeitfresser_get_default_primary_color' ) ) { function daisy_blog_get_default_primary_color(...$args) { return zeitfresser_get_default_primary_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_secondary_color' ) && function_exists( 'zeitfresser_get_default_secondary_color' ) ) { function daisy_blog_get_default_secondary_color(...$args) { return zeitfresser_get_default_secondary_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_secondary_font_family' ) && function_exists( 'zeitfresser_get_default_secondary_font_family' ) ) { function daisy_blog_get_default_secondary_font_family(...$args) { return zeitfresser_get_default_secondary_font_family(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_site_identity_font_family' ) && function_exists( 'zeitfresser_get_default_site_identity_font_family' ) ) { function daisy_blog_get_default_site_identity_font_family(...$args) { return zeitfresser_get_default_site_identity_font_family(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_site_identity_font_size' ) && function_exists( 'zeitfresser_get_default_site_identity_font_size' ) ) { function daisy_blog_get_default_site_identity_font_size(...$args) { return zeitfresser_get_default_site_identity_font_size(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_site_tagline_show_hide' ) && function_exists( 'zeitfresser_get_default_site_tagline_show_hide' ) ) { function daisy_blog_get_default_site_tagline_show_hide(...$args) { return zeitfresser_get_default_site_tagline_show_hide(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_site_title_color' ) && function_exists( 'zeitfresser_get_default_site_title_color' ) ) { function daisy_blog_get_default_site_title_color(...$args) { return zeitfresser_get_default_site_title_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_site_title_show_hide' ) && function_exists( 'zeitfresser_get_default_site_title_show_hide' ) ) { function daisy_blog_get_default_site_title_show_hide(...$args) { return zeitfresser_get_default_site_title_show_hide(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_default_sticky_menu' ) && function_exists( 'zeitfresser_get_default_sticky_menu' ) ) { function daisy_blog_get_default_sticky_menu(...$args) { return zeitfresser_get_default_sticky_menu(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_google_fonts' ) && function_exists( 'zeitfresser_get_google_fonts' ) ) { function daisy_blog_get_google_fonts(...$args) { return zeitfresser_get_google_fonts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_views' ) && function_exists( 'zeitfresser_get_views' ) ) { function daisy_blog_get_views(...$args) { return zeitfresser_get_views(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_get_websafe_font' ) && function_exists( 'zeitfresser_get_websafe_font' ) ) { function daisy_blog_get_websafe_font(...$args) { return zeitfresser_get_websafe_font(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_google_font_local' ) && function_exists( 'zeitfresser_google_font_local' ) ) { function daisy_blog_google_font_local(...$args) { return zeitfresser_google_font_local(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_google_fonts' ) && function_exists( 'zeitfresser_google_fonts' ) ) { function daisy_blog_google_fonts(...$args) { return zeitfresser_google_fonts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_google_fonts_scripts' ) && function_exists( 'zeitfresser_google_fonts_scripts' ) ) { function daisy_blog_google_fonts_scripts(...$args) { return zeitfresser_google_fonts_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_grey_color' ) && function_exists( 'zeitfresser_grey_color' ) ) { function daisy_blog_grey_color(...$args) { return zeitfresser_grey_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_grey_color_dynamic_css' ) && function_exists( 'zeitfresser_grey_color_dynamic_css' ) ) { function daisy_blog_grey_color_dynamic_css(...$args) { return zeitfresser_grey_color_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_grey_color_enqueue_scripts' ) && function_exists( 'zeitfresser_grey_color_enqueue_scripts' ) ) { function daisy_blog_grey_color_enqueue_scripts(...$args) { return zeitfresser_grey_color_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_header_style' ) && function_exists( 'zeitfresser_header_style' ) ) { function daisy_blog_header_style(...$args) { return zeitfresser_header_style(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_infinite_scroll_render' ) && function_exists( 'zeitfresser_infinite_scroll_render' ) ) { function daisy_blog_infinite_scroll_render(...$args) { return zeitfresser_infinite_scroll_render(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_is_google_font' ) && function_exists( 'zeitfresser_is_google_font' ) ) { function daisy_blog_is_google_font(...$args) { return zeitfresser_is_google_font(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_jetpack_setup' ) && function_exists( 'zeitfresser_jetpack_setup' ) ) { function daisy_blog_jetpack_setup(...$args) { return zeitfresser_jetpack_setup(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_light_color' ) && function_exists( 'zeitfresser_light_color' ) ) { function daisy_blog_light_color(...$args) { return zeitfresser_light_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_light_color_dynamic_css' ) && function_exists( 'zeitfresser_light_color_dynamic_css' ) ) { function daisy_blog_light_color_dynamic_css(...$args) { return zeitfresser_light_color_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_light_color_enqueue_scripts' ) && function_exists( 'zeitfresser_light_color_enqueue_scripts' ) ) { function daisy_blog_light_color_enqueue_scripts(...$args) { return zeitfresser_light_color_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_line_height' ) && function_exists( 'zeitfresser_line_height' ) ) { function daisy_blog_line_height(...$args) { return zeitfresser_line_height(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_line_height_dynamic_css' ) && function_exists( 'zeitfresser_line_height_dynamic_css' ) ) { function daisy_blog_line_height_dynamic_css(...$args) { return zeitfresser_line_height_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_line_height_enqueue_scripts' ) && function_exists( 'zeitfresser_line_height_enqueue_scripts' ) ) { function daisy_blog_line_height_enqueue_scripts(...$args) { return zeitfresser_line_height_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_logo_size' ) && function_exists( 'zeitfresser_logo_size' ) ) { function daisy_blog_logo_size(...$args) { return zeitfresser_logo_size(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_logo_size_dynamic_css' ) && function_exists( 'zeitfresser_logo_size_dynamic_css' ) ) { function daisy_blog_logo_size_dynamic_css(...$args) { return zeitfresser_logo_size_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_logo_size_enqueue_scripts' ) && function_exists( 'zeitfresser_logo_size_enqueue_scripts' ) ) { function daisy_blog_logo_size_enqueue_scripts(...$args) { return zeitfresser_logo_size_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_main_font_family' ) && function_exists( 'zeitfresser_main_font_family' ) ) { function daisy_blog_main_font_family(...$args) { return zeitfresser_main_font_family(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_main_font_family_dynamic_css' ) && function_exists( 'zeitfresser_main_font_family_dynamic_css' ) ) { function daisy_blog_main_font_family_dynamic_css(...$args) { return zeitfresser_main_font_family_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_main_font_family_enqueue_scripts' ) && function_exists( 'zeitfresser_main_font_family_enqueue_scripts' ) ) { function daisy_blog_main_font_family_enqueue_scripts(...$args) { return zeitfresser_main_font_family_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_numeric_pagination' ) && function_exists( 'zeitfresser_numeric_pagination' ) ) { function daisy_blog_numeric_pagination(...$args) { return zeitfresser_numeric_pagination(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_pingback_header' ) && function_exists( 'zeitfresser_pingback_header' ) ) { function daisy_blog_pingback_header(...$args) { return zeitfresser_pingback_header(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_post_snippet_excerpt_size' ) && function_exists( 'zeitfresser_post_snippet_excerpt_size' ) ) { function daisy_blog_post_snippet_excerpt_size(...$args) { return zeitfresser_post_snippet_excerpt_size(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_post_thumbnail' ) && function_exists( 'zeitfresser_post_thumbnail' ) ) { function daisy_blog_post_thumbnail(...$args) { return zeitfresser_post_thumbnail(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_posted_by' ) && function_exists( 'zeitfresser_posted_by' ) ) { function daisy_blog_posted_by(...$args) { return zeitfresser_posted_by(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_posted_on' ) && function_exists( 'zeitfresser_posted_on' ) ) { function daisy_blog_posted_on(...$args) { return zeitfresser_posted_on(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_primary_color' ) && function_exists( 'zeitfresser_primary_color' ) ) { function daisy_blog_primary_color(...$args) { return zeitfresser_primary_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_primary_color_dynamic_css' ) && function_exists( 'zeitfresser_primary_color_dynamic_css' ) ) { function daisy_blog_primary_color_dynamic_css(...$args) { return zeitfresser_primary_color_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_primary_color_enqueue_scripts' ) && function_exists( 'zeitfresser_primary_color_enqueue_scripts' ) ) { function daisy_blog_primary_color_enqueue_scripts(...$args) { return zeitfresser_primary_color_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_register_author_profile_widget' ) && function_exists( 'zeitfresser_register_author_profile_widget' ) ) { function daisy_blog_register_author_profile_widget(...$args) { return zeitfresser_register_author_profile_widget(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_register_custom_controls' ) && function_exists( 'zeitfresser_register_custom_controls' ) ) { function daisy_blog_register_custom_controls(...$args) { return zeitfresser_register_custom_controls(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_register_font_customization_section' ) && function_exists( 'zeitfresser_register_font_customization_section' ) ) { function daisy_blog_register_font_customization_section(...$args) { return zeitfresser_register_font_customization_section(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_register_general_customization_section' ) && function_exists( 'zeitfresser_register_general_customization_section' ) ) { function daisy_blog_register_general_customization_section(...$args) { return zeitfresser_register_general_customization_section(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_register_popular_post_widget' ) && function_exists( 'zeitfresser_register_popular_post_widget' ) ) { function daisy_blog_register_popular_post_widget(...$args) { return zeitfresser_register_popular_post_widget(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_register_post_snippet_customization_section' ) && function_exists( 'zeitfresser_register_post_snippet_customization_section' ) ) { function daisy_blog_register_post_snippet_customization_section(...$args) { return zeitfresser_register_post_snippet_customization_section(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_register_recent_post_widget' ) && function_exists( 'zeitfresser_register_recent_post_widget' ) ) { function daisy_blog_register_recent_post_widget(...$args) { return zeitfresser_register_recent_post_widget(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_sanitize_array' ) && function_exists( 'zeitfresser_sanitize_array' ) ) { function daisy_blog_sanitize_array(...$args) { return zeitfresser_sanitize_array(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_sanitize_checkbox' ) && function_exists( 'zeitfresser_sanitize_checkbox' ) ) { function daisy_blog_sanitize_checkbox(...$args) { return zeitfresser_sanitize_checkbox(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_sanitize_float' ) && function_exists( 'zeitfresser_sanitize_float' ) ) { function daisy_blog_sanitize_float(...$args) { return zeitfresser_sanitize_float(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_sanitize_google_fonts' ) && function_exists( 'zeitfresser_sanitize_google_fonts' ) ) { function daisy_blog_sanitize_google_fonts(...$args) { return zeitfresser_sanitize_google_fonts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_sanitize_select' ) && function_exists( 'zeitfresser_sanitize_select' ) ) { function daisy_blog_sanitize_select(...$args) { return zeitfresser_sanitize_select(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_scripts' ) && function_exists( 'zeitfresser_scripts' ) ) { function daisy_blog_scripts(...$args) { return zeitfresser_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_secondary_color' ) && function_exists( 'zeitfresser_secondary_color' ) ) { function daisy_blog_secondary_color(...$args) { return zeitfresser_secondary_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_secondary_color_dynamic_css' ) && function_exists( 'zeitfresser_secondary_color_dynamic_css' ) ) { function daisy_blog_secondary_color_dynamic_css(...$args) { return zeitfresser_secondary_color_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_secondary_color_enqueue_scripts' ) && function_exists( 'zeitfresser_secondary_color_enqueue_scripts' ) ) { function daisy_blog_secondary_color_enqueue_scripts(...$args) { return zeitfresser_secondary_color_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_secondary_font_family' ) && function_exists( 'zeitfresser_secondary_font_family' ) ) { function daisy_blog_secondary_font_family(...$args) { return zeitfresser_secondary_font_family(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_secondary_font_family_dynamic_css' ) && function_exists( 'zeitfresser_secondary_font_family_dynamic_css' ) ) { function daisy_blog_secondary_font_family_dynamic_css(...$args) { return zeitfresser_secondary_font_family_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_secondary_font_family_enqueue_scripts' ) && function_exists( 'zeitfresser_secondary_font_family_enqueue_scripts' ) ) { function daisy_blog_secondary_font_family_enqueue_scripts(...$args) { return zeitfresser_secondary_font_family_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_set_views' ) && function_exists( 'zeitfresser_set_views' ) ) { function daisy_blog_set_views(...$args) { return zeitfresser_set_views(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_setup' ) && function_exists( 'zeitfresser_setup' ) ) { function daisy_blog_setup(...$args) { return zeitfresser_setup(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_show_hide_site_tagline' ) && function_exists( 'zeitfresser_show_hide_site_tagline' ) ) { function daisy_blog_show_hide_site_tagline(...$args) { return zeitfresser_show_hide_site_tagline(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_show_hide_site_title' ) && function_exists( 'zeitfresser_show_hide_site_title' ) ) { function daisy_blog_show_hide_site_title(...$args) { return zeitfresser_show_hide_site_title(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_site_identity_font_family' ) && function_exists( 'zeitfresser_site_identity_font_family' ) ) { function daisy_blog_site_identity_font_family(...$args) { return zeitfresser_site_identity_font_family(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_site_identity_font_family_dynamic_css' ) && function_exists( 'zeitfresser_site_identity_font_family_dynamic_css' ) ) { function daisy_blog_site_identity_font_family_dynamic_css(...$args) { return zeitfresser_site_identity_font_family_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_site_identity_font_family_enqueue_scripts' ) && function_exists( 'zeitfresser_site_identity_font_family_enqueue_scripts' ) ) { function daisy_blog_site_identity_font_family_enqueue_scripts(...$args) { return zeitfresser_site_identity_font_family_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_site_identity_font_size' ) && function_exists( 'zeitfresser_site_identity_font_size' ) ) { function daisy_blog_site_identity_font_size(...$args) { return zeitfresser_site_identity_font_size(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_site_identity_font_size_dynamic_css' ) && function_exists( 'zeitfresser_site_identity_font_size_dynamic_css' ) ) { function daisy_blog_site_identity_font_size_dynamic_css(...$args) { return zeitfresser_site_identity_font_size_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_site_identity_font_size_enqueue_scripts' ) && function_exists( 'zeitfresser_site_identity_font_size_enqueue_scripts' ) ) { function daisy_blog_site_identity_font_size_enqueue_scripts(...$args) { return zeitfresser_site_identity_font_size_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_site_title_color' ) && function_exists( 'zeitfresser_site_title_color' ) ) { function daisy_blog_site_title_color(...$args) { return zeitfresser_site_title_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_site_title_color_dynamic_css' ) && function_exists( 'zeitfresser_site_title_color_dynamic_css' ) ) { function daisy_blog_site_title_color_dynamic_css(...$args) { return zeitfresser_site_title_color_dynamic_css(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_site_title_color_enqueue_scripts' ) && function_exists( 'zeitfresser_site_title_color_enqueue_scripts' ) ) { function daisy_blog_site_title_color_enqueue_scripts(...$args) { return zeitfresser_site_title_color_enqueue_scripts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_social_links' ) && function_exists( 'zeitfresser_social_links' ) ) { function daisy_blog_social_links(...$args) { return zeitfresser_social_links(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_sticky_menu_background_color' ) && function_exists( 'zeitfresser_sticky_menu_background_color' ) ) { function daisy_blog_sticky_menu_background_color(...$args) { return zeitfresser_sticky_menu_background_color(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_used_google_fonts' ) && function_exists( 'zeitfresser_used_google_fonts' ) ) { function daisy_blog_used_google_fonts(...$args) { return zeitfresser_used_google_fonts(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_widget_get_attachment_id' ) && function_exists( 'zeitfresser_widget_get_attachment_id' ) ) { function daisy_blog_widget_get_attachment_id(...$args) { return zeitfresser_widget_get_attachment_id(...$args); } }
|
||||
if ( ! function_exists( 'daisy_blog_widgets_init' ) && function_exists( 'zeitfresser_widgets_init' ) ) { function daisy_blog_widgets_init(...$args) { return zeitfresser_widgets_init(...$args); } }
|
||||
if ( ! function_exists( 'graphthemes_get_social_link_default' ) && function_exists( 'zeitfresser_get_social_link_default' ) ) { function graphthemes_get_social_link_default(...$args) { return zeitfresser_get_social_link_default(...$args); } }
|
||||
if ( ! function_exists( 'graphthemes_get_social_links' ) && function_exists( 'zeitfresser_get_social_links' ) ) { function graphthemes_get_social_links(...$args) { return zeitfresser_get_social_links(...$args); } }
|
||||
+606
-219
@@ -1,272 +1,659 @@
|
||||
<?php
|
||||
/**
|
||||
* Performance tools for existing media and webfonts.
|
||||
* Performance tools for existing media.
|
||||
*
|
||||
* @package zeitfresser
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the performance tools admin page.
|
||||
*
|
||||
* @return void
|
||||
* Register admin page
|
||||
*/
|
||||
function zeitfresser_register_performance_tools_page() {
|
||||
add_theme_page(
|
||||
esc_html__( 'Performance Tools', 'zeitfresser' ),
|
||||
esc_html__( 'Performance Tools', 'zeitfresser' ),
|
||||
'manage_options',
|
||||
'zeitfresser-performance-tools',
|
||||
'zeitfresser_render_performance_tools_page'
|
||||
);
|
||||
add_theme_page(
|
||||
'Performance Tools',
|
||||
'Performance Tools',
|
||||
'manage_options',
|
||||
'zeitfresser-performance-tools',
|
||||
'zeitfresser_render_performance_tools_page'
|
||||
);
|
||||
}
|
||||
add_action( 'admin_menu', 'zeitfresser_register_performance_tools_page' );
|
||||
|
||||
/**
|
||||
* Count attachments still waiting for one-time optimization.
|
||||
*
|
||||
* @return int
|
||||
* Count pending images
|
||||
*/
|
||||
function zeitfresser_get_pending_legacy_images_count() {
|
||||
$query = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'attachment',
|
||||
'post_status' => 'inherit',
|
||||
'post_mime_type' => 'image',
|
||||
'fields' => 'ids',
|
||||
'posts_per_page' => 1,
|
||||
'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
|
||||
array(
|
||||
'key' => '_zeitfresser_media_optimized',
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
),
|
||||
'no_found_rows' => false,
|
||||
'cache_results' => false,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
)
|
||||
);
|
||||
$query = new WP_Query([
|
||||
'post_type' => 'attachment',
|
||||
'post_status' => 'inherit',
|
||||
'post_mime_type' => 'image',
|
||||
'fields' => 'ids',
|
||||
'posts_per_page' => 1,
|
||||
'meta_query' => [
|
||||
'relation' => 'OR',
|
||||
[
|
||||
'key' => '_zeitfresser_media_optimized_version',
|
||||
'compare' => 'NOT EXISTS',
|
||||
],
|
||||
[
|
||||
'key' => '_zeitfresser_media_optimized_version',
|
||||
'value' => ZEITFRESSER_IMAGE_OPTIMIZATION_VERSION,
|
||||
'compare' => '!=',
|
||||
],
|
||||
],
|
||||
'no_found_rows' => false,
|
||||
]);
|
||||
|
||||
return (int) $query->found_posts;
|
||||
return (int) $query->found_posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a batch of legacy images with current thumbnail/webp rules.
|
||||
* Count total images
|
||||
*/
|
||||
function zeitfresser_get_total_images_count() {
|
||||
$query = new WP_Query([
|
||||
'post_type' => 'attachment',
|
||||
'post_status' => 'inherit',
|
||||
'post_mime_type' => 'image',
|
||||
'fields' => 'ids',
|
||||
'posts_per_page' => 1,
|
||||
'no_found_rows' => false,
|
||||
]);
|
||||
|
||||
return (int) $query->found_posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* NEW: Cleanup counters (ONLY ADDITIVE)
|
||||
*/
|
||||
function zeitfresser_get_total_originals_count() {
|
||||
$query = new WP_Query([
|
||||
'post_type'=>'attachment',
|
||||
'post_status'=>'inherit',
|
||||
'post_mime_type'=>'image',
|
||||
'posts_per_page'=>1,
|
||||
'fields'=>'ids',
|
||||
'meta_query'=>[
|
||||
['key'=>'_zeitfresser_original_file','compare'=>'EXISTS']
|
||||
],
|
||||
'no_found_rows'=>false
|
||||
]);
|
||||
return (int) $query->found_posts;
|
||||
}
|
||||
|
||||
function zeitfresser_get_remaining_originals_count() {
|
||||
$query = new WP_Query([
|
||||
'post_type'=>'attachment',
|
||||
'post_status'=>'inherit',
|
||||
'post_mime_type'=>'image',
|
||||
'posts_per_page'=>1,
|
||||
'fields'=>'ids',
|
||||
'meta_query'=>[
|
||||
'relation'=>'AND',
|
||||
['key'=>'_zeitfresser_original_file','compare'=>'EXISTS'],
|
||||
['key'=>'_zeitfresser_original_deleted','compare'=>'NOT EXISTS']
|
||||
],
|
||||
'no_found_rows'=>false
|
||||
]);
|
||||
return (int) $query->found_posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a list of original-format files belonging to one attachment.
|
||||
*
|
||||
* @param int $batch_size Number of images to process.
|
||||
* This includes:
|
||||
* - the original uploaded file
|
||||
* - the original-format main generated file (e.g. scaled JPG)
|
||||
* - original-format sub-size files derived from attachment metadata
|
||||
*
|
||||
* @param int $attachment_id Attachment ID.
|
||||
* @param string $original Absolute path to the original uploaded file.
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_process_legacy_images_batch( $batch_size = 20 ) {
|
||||
$results = array(
|
||||
'processed' => 0,
|
||||
'updated' => 0,
|
||||
'skipped' => 0,
|
||||
'errors' => 0,
|
||||
);
|
||||
function zeitfresser_get_original_family_files( $attachment_id, $original ) {
|
||||
|
||||
$query = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'attachment',
|
||||
'post_status' => 'inherit',
|
||||
'post_mime_type' => 'image',
|
||||
'fields' => 'ids',
|
||||
'posts_per_page' => absint( $batch_size ),
|
||||
'orderby' => 'ID',
|
||||
'order' => 'ASC',
|
||||
'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
|
||||
array(
|
||||
'key' => '_zeitfresser_media_optimized',
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
),
|
||||
'no_found_rows' => true,
|
||||
'cache_results' => false,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
)
|
||||
);
|
||||
$files = [];
|
||||
|
||||
if ( empty( $query->posts ) ) {
|
||||
return $results;
|
||||
}
|
||||
if ( empty( $original ) ) {
|
||||
return $files;
|
||||
}
|
||||
|
||||
foreach ( $query->posts as $attachment_id ) {
|
||||
$results['processed']++;
|
||||
$original_ext = strtolower( pathinfo( $original, PATHINFO_EXTENSION ) );
|
||||
|
||||
$file = get_attached_file( $attachment_id );
|
||||
if ( empty( $original_ext ) ) {
|
||||
return $files;
|
||||
}
|
||||
|
||||
if ( empty( $file ) || ! file_exists( $file ) ) {
|
||||
update_post_meta( $attachment_id, '_zeitfresser_media_optimized', 'missing' );
|
||||
$results['skipped']++;
|
||||
continue;
|
||||
}
|
||||
$files[] = $original;
|
||||
|
||||
$metadata = wp_generate_attachment_metadata( $attachment_id, $file );
|
||||
$metadata = wp_get_attachment_metadata( $attachment_id );
|
||||
$upload_dir = wp_get_upload_dir();
|
||||
|
||||
if ( is_wp_error( $metadata ) || empty( $metadata ) ) {
|
||||
$results['errors']++;
|
||||
continue;
|
||||
}
|
||||
if ( ! empty( $metadata['file'] ) ) {
|
||||
$current_main_absolute = trailingslashit( $upload_dir['basedir'] ) . $metadata['file'];
|
||||
|
||||
wp_update_attachment_metadata( $attachment_id, $metadata );
|
||||
update_post_meta( $attachment_id, '_zeitfresser_media_optimized', current_time( 'mysql' ) );
|
||||
$results['updated']++;
|
||||
}
|
||||
$files[] = preg_replace(
|
||||
'/\.[^.]+$/',
|
||||
'.' . $original_ext,
|
||||
$current_main_absolute
|
||||
);
|
||||
|
||||
return $results;
|
||||
$current_dir = dirname( $current_main_absolute );
|
||||
|
||||
if ( ! empty( $metadata['sizes'] ) && is_array( $metadata['sizes'] ) ) {
|
||||
foreach ( $metadata['sizes'] as $size ) {
|
||||
if ( empty( $size['file'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$files[] = $current_dir . '/' . preg_replace(
|
||||
'/\.[^.]+$/',
|
||||
'.' . $original_ext,
|
||||
$size['file']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$files = array_unique( array_filter( $files ) );
|
||||
|
||||
return array_values( $files );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle admin actions for performance tools.
|
||||
* Check whether any original-format family files still exist.
|
||||
*
|
||||
* @return void
|
||||
* @param int $attachment_id Attachment ID.
|
||||
* @param string $original Absolute path to the original uploaded file.
|
||||
* @return bool
|
||||
*/
|
||||
function zeitfresser_handle_performance_tools_actions() {
|
||||
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
function zeitfresser_original_family_exists( $attachment_id, $original ) {
|
||||
|
||||
if ( empty( $_GET['page'] ) || 'zeitfresser-performance-tools' !== $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
return;
|
||||
}
|
||||
$files = zeitfresser_get_original_family_files( $attachment_id, $original );
|
||||
|
||||
if ( empty( $_GET['zeitfresser_action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
return;
|
||||
}
|
||||
foreach ( $files as $file ) {
|
||||
if ( file_exists( $file ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
check_admin_referer( 'zeitfresser_performance_tools' );
|
||||
|
||||
$action = sanitize_key( wp_unslash( $_GET['zeitfresser_action'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
if ( 'optimize_legacy_images' === $action ) {
|
||||
$results = zeitfresser_process_legacy_images_batch( 25 );
|
||||
$args = array(
|
||||
'page' => 'zeitfresser-performance-tools',
|
||||
'processed' => $results['processed'],
|
||||
'updated' => $results['updated'],
|
||||
'skipped' => $results['skipped'],
|
||||
'errors' => $results['errors'],
|
||||
);
|
||||
|
||||
wp_safe_redirect( add_query_arg( $args, admin_url( 'themes.php' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( 'reset_legacy_images' === $action ) {
|
||||
$query = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'attachment',
|
||||
'post_status' => 'inherit',
|
||||
'post_mime_type' => 'image',
|
||||
'fields' => 'ids',
|
||||
'posts_per_page' => -1,
|
||||
'meta_key' => '_zeitfresser_media_optimized', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
|
||||
'no_found_rows' => true,
|
||||
'cache_results' => false,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $query->posts as $attachment_id ) {
|
||||
delete_post_meta( $attachment_id, '_zeitfresser_media_optimized' );
|
||||
}
|
||||
|
||||
wp_safe_redirect(
|
||||
add_query_arg(
|
||||
array(
|
||||
'page' => 'zeitfresser-performance-tools',
|
||||
'reset' => count( $query->posts ),
|
||||
),
|
||||
admin_url( 'themes.php' )
|
||||
)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
add_action( 'admin_init', 'zeitfresser_handle_performance_tools_actions' );
|
||||
|
||||
/**
|
||||
* Render the performance tools page.
|
||||
* Delete all original-format files belonging to one attachment.
|
||||
*
|
||||
* @return void
|
||||
* @param int $attachment_id Attachment ID.
|
||||
* @param string $original Absolute path to the original uploaded file.
|
||||
* @return int Number of deleted files.
|
||||
*/
|
||||
function zeitfresser_delete_original_family_files( $attachment_id, $original ) {
|
||||
|
||||
$deleted_files = 0;
|
||||
$files = zeitfresser_get_original_family_files( $attachment_id, $original );
|
||||
|
||||
foreach ( $files as $file ) {
|
||||
if ( ! file_exists( $file ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! is_writable( $file ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( unlink( $file ) ) {
|
||||
$deleted_files++;
|
||||
}
|
||||
}
|
||||
|
||||
return $deleted_files;
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE ORIGINALS (manual batch)
|
||||
*/
|
||||
function zeitfresser_delete_originals_batch( $batch_size = 10 ) {
|
||||
|
||||
$deleted = 0;
|
||||
|
||||
$query = new WP_Query([
|
||||
'post_type' => 'attachment',
|
||||
'post_status' => 'inherit',
|
||||
'post_mime_type' => 'image',
|
||||
'fields' => 'ids',
|
||||
'posts_per_page' => $batch_size,
|
||||
'meta_query' => [
|
||||
'relation' => 'AND',
|
||||
[
|
||||
'key' => '_zeitfresser_original_file',
|
||||
'compare' => 'EXISTS',
|
||||
],
|
||||
[
|
||||
'key' => '_zeitfresser_original_deleted',
|
||||
'compare' => 'NOT EXISTS',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
foreach ( $query->posts as $attachment_id ) {
|
||||
|
||||
$original = get_post_meta( $attachment_id, '_zeitfresser_original_file', true );
|
||||
|
||||
if ( ! $original ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$optimized_version = get_post_meta(
|
||||
$attachment_id,
|
||||
'_zeitfresser_media_optimized_version',
|
||||
true
|
||||
);
|
||||
|
||||
if ( ZEITFRESSER_IMAGE_OPTIMIZATION_VERSION !== $optimized_version ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ext = strtolower( pathinfo( $original, PATHINFO_EXTENSION ) );
|
||||
|
||||
if ( in_array( $ext, [ 'webp', 'avif' ], true ) ) {
|
||||
update_post_meta( $attachment_id, '_zeitfresser_original_deleted', 1 );
|
||||
continue;
|
||||
}
|
||||
|
||||
// Nothing left to delete -> mark as done.
|
||||
if ( ! zeitfresser_original_family_exists( $attachment_id, $original ) ) {
|
||||
update_post_meta( $attachment_id, '_zeitfresser_original_deleted', 1 );
|
||||
continue;
|
||||
}
|
||||
|
||||
zeitfresser_delete_original_family_files( $attachment_id, $original );
|
||||
|
||||
// Only mark as deleted when the full original family is gone.
|
||||
if ( ! zeitfresser_original_family_exists( $attachment_id, $original ) ) {
|
||||
$deleted++;
|
||||
update_post_meta( $attachment_id, '_zeitfresser_original_deleted', 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return $deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimizer batch for manual processing.
|
||||
*
|
||||
* Manual optimization must work independently of the auto-optimize upload toggle.
|
||||
*
|
||||
* @param int $batch_size Number of images per batch.
|
||||
* @return array
|
||||
*/
|
||||
function zeitfresser_process_legacy_images_batch( $batch_size = 25 ) {
|
||||
|
||||
$results = [
|
||||
'processed' => 0,
|
||||
'updated' => 0,
|
||||
'skipped' => 0,
|
||||
'errors' => 0,
|
||||
];
|
||||
|
||||
$query = new WP_Query([
|
||||
'post_type' => 'attachment',
|
||||
'post_status' => 'inherit',
|
||||
'post_mime_type' => 'image',
|
||||
'fields' => 'ids',
|
||||
'posts_per_page' => $batch_size,
|
||||
'meta_query' => [
|
||||
'relation' => 'OR',
|
||||
[
|
||||
'key' => '_zeitfresser_media_optimized_version',
|
||||
'compare' => 'NOT EXISTS',
|
||||
],
|
||||
[
|
||||
'key' => '_zeitfresser_media_optimized_version',
|
||||
'value' => ZEITFRESSER_IMAGE_OPTIMIZATION_VERSION,
|
||||
'compare' => '!=',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// Force optimization for manual tool runs, regardless of upload automation setting.
|
||||
$GLOBALS['zeitfresser_force_image_optimization'] = true;
|
||||
|
||||
foreach ( $query->posts as $attachment_id ) {
|
||||
|
||||
$results['processed']++;
|
||||
|
||||
$file = get_attached_file( $attachment_id );
|
||||
|
||||
if ( empty( $file ) || ! file_exists( $file ) ) {
|
||||
update_post_meta( $attachment_id, '_zeitfresser_media_optimized_version', 'missing' );
|
||||
$results['skipped']++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! get_post_meta( $attachment_id, '_zeitfresser_original_file', true ) ) {
|
||||
update_post_meta( $attachment_id, '_zeitfresser_original_file', $file );
|
||||
}
|
||||
|
||||
$metadata = wp_generate_attachment_metadata( $attachment_id, $file );
|
||||
|
||||
if ( is_wp_error( $metadata ) || empty( $metadata ) ) {
|
||||
$results['errors']++;
|
||||
continue;
|
||||
}
|
||||
|
||||
wp_update_attachment_metadata( $attachment_id, $metadata );
|
||||
|
||||
update_post_meta(
|
||||
$attachment_id,
|
||||
'_zeitfresser_media_optimized_version',
|
||||
ZEITFRESSER_IMAGE_OPTIMIZATION_VERSION
|
||||
);
|
||||
|
||||
$results['updated']++;
|
||||
}
|
||||
|
||||
unset( $GLOBALS['zeitfresser_force_image_optimization'] );
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX: Optimizer (extended output only)
|
||||
*/
|
||||
function zeitfresser_ajax_optimize_images() {
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
check_ajax_referer( 'zeitfresser_performance_tools', 'nonce' );
|
||||
|
||||
$results = zeitfresser_process_legacy_images_batch( 25 );
|
||||
|
||||
wp_send_json_success([
|
||||
'processed' => $results['processed'],
|
||||
'updated' => $results['updated'],
|
||||
'pending' => zeitfresser_get_pending_legacy_images_count(),
|
||||
'total' => zeitfresser_get_total_images_count(),
|
||||
]);
|
||||
}
|
||||
add_action( 'wp_ajax_zeitfresser_optimize_images', 'zeitfresser_ajax_optimize_images' );
|
||||
|
||||
/**
|
||||
* AJAX: Delete (extended ONLY)
|
||||
*/
|
||||
function zeitfresser_ajax_delete_originals() {
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
check_ajax_referer( 'zeitfresser_performance_tools', 'nonce' );
|
||||
|
||||
$deleted = zeitfresser_delete_originals_batch( 10 );
|
||||
|
||||
$total = zeitfresser_get_total_originals_count();
|
||||
$remaining = zeitfresser_get_remaining_originals_count();
|
||||
|
||||
wp_send_json_success([
|
||||
'deleted' => $deleted,
|
||||
'total' => $total,
|
||||
'remaining' => $remaining,
|
||||
'deleted_total' => $total - $remaining,
|
||||
]);
|
||||
}
|
||||
add_action( 'wp_ajax_zeitfresser_delete_originals', 'zeitfresser_ajax_delete_originals' );
|
||||
|
||||
/**
|
||||
* Render UI
|
||||
*/
|
||||
function zeitfresser_render_performance_tools_page() {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pending = zeitfresser_get_pending_legacy_images_count();
|
||||
$local = function_exists( 'zeitfresser_get_local_webfonts_css' ) ? zeitfresser_get_local_webfont_urls( zeitfresser_get_local_webfonts_css() ) : array();
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?php esc_html_e( 'Zeitfresser Performance Tools', 'zeitfresser' ); ?></h1>
|
||||
<p><?php esc_html_e( 'Use these tools after major performance updates to warm local fonts and reprocess older uploads with the current image rules.', 'zeitfresser' ); ?></p>
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
<?php if ( isset( $_GET['updated'] ) || isset( $_GET['reset'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>
|
||||
<div class="notice notice-success is-dismissible">
|
||||
<p>
|
||||
<?php
|
||||
if ( isset( $_GET['reset'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
printf(
|
||||
esc_html__( 'Reset complete. %d legacy image markers removed.', 'zeitfresser' ),
|
||||
absint( $_GET['reset'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
esc_html__( 'Batch finished. Processed: %1$d, updated: %2$d, skipped: %3$d, errors: %4$d.', 'zeitfresser' ),
|
||||
absint( $_GET['processed'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
absint( $_GET['updated'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
absint( $_GET['skipped'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
absint( $_GET['errors'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
);
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
$pending = zeitfresser_get_pending_legacy_images_count();
|
||||
$total = zeitfresser_get_total_images_count();
|
||||
$optimized = $total - $pending;
|
||||
$progress = $total > 0 ? round(($optimized / $total) * 100) : 0;
|
||||
|
||||
<div class="card" style="max-width: 880px; padding: 20px;">
|
||||
<h2><?php esc_html_e( 'Legacy Image Optimization', 'zeitfresser' ); ?></h2>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
esc_html__( '%d image attachments have not been reprocessed with the current size, quality and WebP rules yet.', 'zeitfresser' ),
|
||||
(int) $pending
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<p><?php esc_html_e( 'Run the batch button repeatedly until the counter reaches zero. This keeps each request small and safe on shared hosting.', 'zeitfresser' ); ?></p>
|
||||
<p>
|
||||
<a class="button button-primary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'page' => 'zeitfresser-performance-tools', 'zeitfresser_action' => 'optimize_legacy_images' ), admin_url( 'themes.php' ) ), 'zeitfresser_performance_tools' ) ); ?>">
|
||||
<?php esc_html_e( 'Process Next 25 Images', 'zeitfresser' ); ?>
|
||||
</a>
|
||||
<a class="button" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'page' => 'zeitfresser-performance-tools', 'zeitfresser_action' => 'reset_legacy_images' ), admin_url( 'themes.php' ) ), 'zeitfresser_performance_tools' ) ); ?>">
|
||||
<?php esc_html_e( 'Reset Progress', 'zeitfresser' ); ?>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
// 🔥 NEW: Cleanup counters
|
||||
$cleanup_total = zeitfresser_get_total_originals_count();
|
||||
$cleanup_remaining = zeitfresser_get_remaining_originals_count();
|
||||
$cleanup_deleted = $cleanup_total - $cleanup_remaining;
|
||||
$cleanup_progress = $cleanup_total > 0 ? round(($cleanup_deleted / $cleanup_total) * 100) : 0;
|
||||
?>
|
||||
|
||||
<div class="card" style="max-width: 880px; padding: 20px; margin-top: 20px;">
|
||||
<h2><?php esc_html_e( 'Local Font Warmup', 'zeitfresser' ); ?></h2>
|
||||
<p><?php esc_html_e( 'Zeitfresser now prefers locally cached Google font files for the currently selected font families. When the cache is available, the theme preloads the local files and no longer needs the external stylesheet request.', 'zeitfresser' ); ?></p>
|
||||
<p>
|
||||
<?php
|
||||
if ( empty( $local ) ) {
|
||||
esc_html_e( 'Local font files are not cached yet. Visit the front-end once after saving your font settings to warm the cache.', 'zeitfresser' );
|
||||
} else {
|
||||
printf(
|
||||
esc_html__( 'Local font files ready: %d preloadable assets detected.', 'zeitfresser' ),
|
||||
count( $local )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
<div class="wrap">
|
||||
<h1>Zeitfresser Performance Tools</h1>
|
||||
|
||||
<div class="notice notice-info" style="max-width:800px;margin-top:20px;">
|
||||
<p>
|
||||
<strong>How this tool works</strong><br><br>
|
||||
|
||||
This tool helps you optimize your existing media library for better performance.<br><br>
|
||||
|
||||
• Images are converted to modern formats (AVIF/WebP) for smaller file sizes.<br>
|
||||
• The original file path is safely stored before optimization.<br>
|
||||
• Once optimized, original images can be deleted to save disk space.<br><br>
|
||||
|
||||
<strong>Automation:</strong><br>
|
||||
• You can enable automatic optimization on upload in the Customizer under <em>Performance Tools Settings</em>.<br>
|
||||
• Optionally, original images can also be deleted automatically after successful optimization.<br><br>
|
||||
|
||||
<strong>Safety:</strong><br>
|
||||
• Images are only processed once per version.<br>
|
||||
• Original files are only deleted when safe.<br>
|
||||
• The tool can be run multiple times without side effects.<br><br>
|
||||
|
||||
<em><strong>Tip:</strong> You can either automate the process via the Customizer or use this tool manually for full control.</em>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- OPTIMIZATION -->
|
||||
<div class="card" style="max-width:800px;padding:24px;margin-bottom:20px;">
|
||||
|
||||
<h2 style="margin-top:0;">🚀 Image Optimization</h2>
|
||||
|
||||
<div style="margin-bottom:20px;">
|
||||
<p><strong>Total Images:</strong> <span id="total"><?php echo $total; ?></span></p>
|
||||
<p><strong>Optimized:</strong> <span id="optimized"><?php echo $optimized; ?></span></p>
|
||||
<p><strong>Pending:</strong> <span id="remaining"><?php echo $pending; ?></span></p>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom:20px;">
|
||||
<div style="background:#e0e0e0;border-radius:6px;height:12px;">
|
||||
<div id="progress-bar" style="width:<?php echo $progress; ?>%;background:#4caf50;height:100%;"></div>
|
||||
</div>
|
||||
<p><strong>Progress:</strong> <span id="progress"><?php echo $progress; ?></span>%</p>
|
||||
</div>
|
||||
|
||||
<button id="start-btn" class="button button-primary">🚀 Optimize Images</button>
|
||||
</div>
|
||||
|
||||
<!-- CLEANUP -->
|
||||
<div class="card" style="max-width:800px;padding:24px;">
|
||||
|
||||
<h2>🧹 Original Cleanup</h2>
|
||||
|
||||
<div style="margin-bottom:20px;">
|
||||
<p><strong>Total Originals:</strong> <span id="cleanup-total"><?php echo $cleanup_total; ?></span></p>
|
||||
<p><strong>Deleted:</strong> <span id="cleanup-deleted"><?php echo $cleanup_deleted; ?></span></p>
|
||||
<p><strong>Remaining:</strong> <span id="cleanup-remaining"><?php echo $cleanup_remaining; ?></span></p>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom:20px;">
|
||||
<div style="background:#e0e0e0;border-radius:6px;height:12px;">
|
||||
<div id="cleanup-bar" style="width:<?php echo $cleanup_progress; ?>%;background:<?php echo $cleanup_progress === 100 ? '#4caf50' : '#ff9800'; ?>;height:100%;"></div>
|
||||
</div>
|
||||
<p><strong>Cleanup Progress:</strong> <span id="cleanup-progress"><?php echo $cleanup_progress; ?></span>%</p>
|
||||
</div>
|
||||
|
||||
<button id="delete-btn" class="button">🧹 Delete Originals</button>
|
||||
</div>
|
||||
|
||||
<!-- STATUS -->
|
||||
<div style="padding:12px;background:#f6f7f7;border-radius:6px;">
|
||||
<p id="status-opt">🚀 Optimizer: Idle</p>
|
||||
<p id="status-clean">🧹 Cleanup: Idle</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
#progress-bar,
|
||||
#cleanup-bar {
|
||||
transition: width 0.35s ease, background 0.3s ease;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
let running = false;
|
||||
let deleting = false;
|
||||
|
||||
(function initCleanupBar() {
|
||||
const bar = document.getElementById('cleanup-bar');
|
||||
const progress = parseInt(document.getElementById('cleanup-progress').innerText, 10);
|
||||
|
||||
if (!bar || isNaN(progress)) return;
|
||||
|
||||
if (progress >= 100) {
|
||||
bar.style.background = '#4caf50';
|
||||
} else if (progress > 0) {
|
||||
bar.style.background = '#ff9800';
|
||||
}
|
||||
})();
|
||||
|
||||
document.getElementById('start-btn').onclick = () => {
|
||||
running = true;
|
||||
|
||||
document.getElementById('start-btn').disabled = true;
|
||||
document.getElementById('delete-btn').disabled = true;
|
||||
|
||||
document.getElementById('start-btn').innerText = '⏳ Running...';
|
||||
document.getElementById('status-opt').innerText = '🚀 Optimizing images...';
|
||||
|
||||
processBatch();
|
||||
};
|
||||
|
||||
document.getElementById('delete-btn').onclick = () => {
|
||||
deleting = true;
|
||||
|
||||
document.getElementById('start-btn').disabled = true;
|
||||
document.getElementById('delete-btn').disabled = true;
|
||||
|
||||
document.getElementById('delete-btn').innerText = '⏳ Running...';
|
||||
document.getElementById('status-clean').innerText = '🧹 Cleaning originals...';
|
||||
|
||||
deleteBatch();
|
||||
};
|
||||
|
||||
function deleteBatch() {
|
||||
if (!deleting) return;
|
||||
|
||||
fetch(ajaxurl, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||
body: new URLSearchParams({
|
||||
action: 'zeitfresser_delete_originals',
|
||||
nonce: '<?php echo wp_create_nonce('zeitfresser_performance_tools'); ?>'
|
||||
})
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
|
||||
let total = data.data.total;
|
||||
let remaining = data.data.remaining;
|
||||
let deleted = data.data.deleted_total;
|
||||
let batch = data.data.deleted;
|
||||
|
||||
let progress = total > 0 ? Math.round((deleted / total) * 100) : 0;
|
||||
|
||||
// Update Cleanup UI
|
||||
document.getElementById('cleanup-total').innerText = total;
|
||||
document.getElementById('cleanup-deleted').innerText = deleted;
|
||||
document.getElementById('cleanup-remaining').innerText = remaining;
|
||||
document.getElementById('cleanup-progress').innerText = progress;
|
||||
|
||||
let bar = document.getElementById('cleanup-bar');
|
||||
|
||||
bar.style.width = progress + '%';
|
||||
|
||||
if (progress >= 100) {
|
||||
bar.style.background = '#4caf50';
|
||||
} else if (progress > 0) {
|
||||
bar.style.background = '#ff9800';
|
||||
}
|
||||
|
||||
document.getElementById('status-clean').innerText = '🧹 Deleted: ' + batch;
|
||||
|
||||
if (remaining > 0) {
|
||||
setTimeout(deleteBatch, 400);
|
||||
} else {
|
||||
deleting = false;
|
||||
|
||||
document.getElementById('start-btn').disabled = false;
|
||||
document.getElementById('delete-btn').disabled = false;
|
||||
|
||||
document.getElementById('delete-btn').innerText = '🧹 Delete Originals';
|
||||
|
||||
document.getElementById('status-clean').innerText = '✔ Cleanup complete';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function processBatch() {
|
||||
if (!running) return;
|
||||
|
||||
fetch(ajaxurl, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||
body: new URLSearchParams({
|
||||
action: 'zeitfresser_optimize_images',
|
||||
nonce: '<?php echo wp_create_nonce('zeitfresser_performance_tools'); ?>'
|
||||
})
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
|
||||
let pending = data.data.pending;
|
||||
let total = data.data.total;
|
||||
let optimized = total - pending;
|
||||
let progress = total > 0 ? Math.round((optimized / total) * 100) : 0;
|
||||
|
||||
// Live update optimization counters
|
||||
document.getElementById('total').innerText = total;
|
||||
document.getElementById('optimized').innerText = optimized;
|
||||
document.getElementById('remaining').innerText = pending;
|
||||
|
||||
// Live update progress UI
|
||||
document.getElementById('progress').innerText = progress;
|
||||
document.getElementById('progress-bar').style.width = progress + '%';
|
||||
|
||||
document.getElementById('status-opt').innerText =
|
||||
'🚀 Processed: ' + data.data.processed +
|
||||
' | Updated: ' + data.data.updated;
|
||||
|
||||
if (pending > 0) {
|
||||
setTimeout(processBatch, 400);
|
||||
} else {
|
||||
running = false;
|
||||
|
||||
document.getElementById('start-btn').disabled = false;
|
||||
document.getElementById('delete-btn').disabled = false;
|
||||
|
||||
document.getElementById('start-btn').innerText = '🚀 Optimize Images';
|
||||
|
||||
document.getElementById('status-opt').innerText = '✔ Optimization complete';
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
var headingOffset = 88;
|
||||
var ticking = false;
|
||||
|
||||
var tocBottomOffset = null;
|
||||
|
||||
function isDesktop() {
|
||||
return desktopQuery.matches;
|
||||
}
|
||||
@@ -34,6 +36,26 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
});
|
||||
}
|
||||
|
||||
function getArticleElement() {
|
||||
return document.querySelector(
|
||||
'.single-post .post-content article, ' +
|
||||
'.single-post .post-content, ' +
|
||||
'article.post, article, ' +
|
||||
'.entry-content'
|
||||
);
|
||||
}
|
||||
|
||||
function getTocBottomOffset() {
|
||||
if (tocBottomOffset !== null) return tocBottomOffset;
|
||||
|
||||
var value = getComputedStyle(document.documentElement)
|
||||
.getPropertyValue('--toc-bottom-offset')
|
||||
.trim();
|
||||
|
||||
tocBottomOffset = parseInt(value, 10) || 12;
|
||||
return tocBottomOffset;
|
||||
}
|
||||
|
||||
function syncPosition() {
|
||||
if (!isDesktop()) {
|
||||
document.documentElement.style.setProperty('--zeitfresser-toc-top', stickyTop + 'px');
|
||||
@@ -84,23 +106,32 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
return;
|
||||
}
|
||||
|
||||
var footer = document.querySelector('footer.site-footer, footer, #colophon');
|
||||
if (!footer) return;
|
||||
var article = getArticleElement();
|
||||
|
||||
var footerRect = footer.getBoundingClientRect();
|
||||
var tocRect = toc.getBoundingClientRect();
|
||||
|
||||
var offset = 40;
|
||||
var triggerOffset = Math.min(200, window.innerHeight * 0.2);
|
||||
|
||||
var overlap = tocRect.bottom - (footerRect.top - triggerOffset);
|
||||
|
||||
if (overlap > -offset) {
|
||||
var strength = 0.85;
|
||||
var correction = Math.max(0, (overlap + offset) * strength);
|
||||
toc.style.transform = 'translateY(-' + correction + 'px)';
|
||||
} else {
|
||||
if (!article) {
|
||||
toc.style.transform = '';
|
||||
return;
|
||||
}
|
||||
|
||||
toc.style.transform = '';
|
||||
|
||||
var scrollTop = window.scrollY || window.pageYOffset;
|
||||
|
||||
var articleRect = article.getBoundingClientRect();
|
||||
var articleBottom = articleRect.top + scrollTop + articleRect.height;
|
||||
|
||||
var tocRect = toc.getBoundingClientRect();
|
||||
var tocTop = tocRect.top + scrollTop;
|
||||
var tocHeight = tocRect.height;
|
||||
var tocBottom = tocTop + tocHeight;
|
||||
|
||||
var offset = getTocBottomOffset();
|
||||
|
||||
var maxBottom = articleBottom - offset;
|
||||
var overflow = Math.ceil(tocBottom - maxBottom);
|
||||
|
||||
if (overflow > 0) {
|
||||
toc.style.transform = 'translateY(-' + overflow + 'px)';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,10 +151,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
function updateProgress() {
|
||||
if (!progressBar) return;
|
||||
|
||||
var article = document.querySelector(
|
||||
'.single-post .post-content article, ' +
|
||||
'.single-post .post-content, article.post, article'
|
||||
);
|
||||
var article = getArticleElement();
|
||||
|
||||
if (!article) {
|
||||
progressBar.style.width = '0%';
|
||||
@@ -139,7 +167,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
function updateActiveHeading() {
|
||||
var headings = getHeadings();
|
||||
|
||||
if (!headings.length) return;
|
||||
|
||||
var currentId = headings[0].target.id;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# This file is distributed under the GNU General Public License v2 or later.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Daisy Blog 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: https://wordpress.org/support/theme/daisy-blog\n"
|
||||
"Project-Id-Version: Zeitfresser Theme"
|
||||
"Report-Msgid-Bugs-To: https://github.com/Domoel/Zeitfresser-Wordpress-Theme"
|
||||
"POT-Creation-Date: 2023-04-10 14:33:31+00:00\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
@@ -847,7 +847,7 @@ msgid "Daisy Blog"
|
||||
msgstr ""
|
||||
|
||||
#. Theme URI of the plugin/theme
|
||||
msgid "https://graphthemes.com/daisy-blog"
|
||||
msgid "https://github.com/Domoel/Zeitfresser-Wordpress-Theme"
|
||||
msgstr ""
|
||||
|
||||
#. Description of the plugin/theme
|
||||
@@ -9,7 +9,7 @@ Zeitfresser Wordpress Theme
|
||||
</h1>
|
||||
|
||||
<h4 align="center">
|
||||
A performance-optimized, minimalist dark blog theme for WordPress, inspired by the popular Dracula aesthetic.
|
||||
A performance-optimized, minimalist dark blog theme for WordPress, built for fast and distraction-free technical writing.
|
||||
</h4>
|
||||
|
||||
<h6 align="center">
|
||||
@@ -28,91 +28,123 @@ A performance-optimized, minimalist dark blog theme for WordPress, inspired by t
|
||||
<br>
|
||||
<img width="1800" height="1271" alt="preview" src="https://github.com/user-attachments/assets/aefff842-8189-48ae-965c-77799667b2a9" />
|
||||
|
||||
|
||||
## ✨ Overview
|
||||
|
||||
Zeitfresser is a custom-built WordPress theme designed with a clear focus: **fast, readable, and distraction-free technical blogging**.
|
||||
Zeitfresser is a custom-built WordPress theme designed with a clear focus:
|
||||
**fast, readable, and distraction-free technical blogging**.
|
||||
|
||||
Originally based on the popular [Daisy Blog](https://wordpress.org/themes/daisy-blog/) Theme. However with this version the theme has evolved into a fully independent, heavily optimized codebase. Every part of the system has been reworked with performance, clarity, and maintainability in mind. The result is not just a styled theme, but a streamlined platform for long-form content.
|
||||
Originally based on the popular [Daisy Blog](https://wordpress.org/themes/daisy-blog/) theme, Zeitfresser has evolved into a fully independent and heavily optimized codebase. Over time, every layer of the theme has been reworked with performance, clarity, and maintainability in mind.
|
||||
|
||||
The design follows a minimalist dark aesthetic inspired by Dracula, while placing strong emphasis on typography, structure, and reading flow.
|
||||
The visual identity follows a minimalist dark aesthetic inspired by Dracula, where typography, spacing, and structure take priority over decoration. The result is a calm, highly readable environment tailored for long-form technical content.
|
||||
|
||||
## 🚀 Performance & Architecture
|
||||
|
||||
Performance is not treated as an afterthought, but as a core design principle. The theme removes unnecessary WordPress overhead and delivers a lean frontend experience with minimal dependencies.
|
||||
Performance is not an afterthought in Zeitfresser — it is the foundation of the entire system.
|
||||
|
||||
Assets are loaded selectively, scripts are deferred where possible, and no heavy libraries are used. The entire frontend runs on lightweight, purpose-built logic, avoiding common bottlenecks such as render-blocking JavaScript or bloated CSS.
|
||||
Instead of relying on heavy abstractions or third-party dependencies, the theme focuses on a lean architecture with minimal JavaScript, carefully structured CSS, and predictable rendering behavior. Assets are only loaded when needed, avoiding unnecessary overhead and reducing the risk of render-blocking resources.
|
||||
|
||||
Images are handled intelligently: large uploads are automatically scaled down, unused sizes are removed, and modern formats like WebP are supported when available. Combined with lazy loading and async decoding, this ensures efficient delivery without sacrificing visual quality.
|
||||
The DOM structure remains intentionally simple, which helps ensure consistent rendering across browsers and improves maintainability over time.
|
||||
|
||||
## 🧠 Core Web Vitals
|
||||
## 🖼️ Image Optimization System (v1.7)
|
||||
|
||||
Zeitfresser is designed to perform well under real-world conditions.
|
||||
With version **1.7**, Zeitfresser introduces a fully integrated **image optimization pipeline**.
|
||||
|
||||
Layout shifts are avoided by design, the DOM structure is kept clean and predictable, and the Largest Contentful Paint is optimized through prioritization of key elements. The result is a stable and responsive experience that holds up even for long, content-heavy articles.
|
||||
Uploaded images can now be automatically converted to modern formats such as **AVIF** or **WebP**, depending on server capabilities. This significantly reduces file sizes while preserving visual quality, leading to faster page loads and improved Core Web Vitals.
|
||||
|
||||
The system is designed to be both flexible and safe:
|
||||
|
||||
- Optimization can run automatically on upload or manually via the dashboard
|
||||
- Original file paths are preserved before any transformation
|
||||
- Cleanup of original files is optional and only performed when safe
|
||||
- All operations are versioned and idempotent
|
||||
|
||||
A dedicated **Performance Tools dashboard** allows you to process existing media libraries in batches, monitor progress in real time, and optionally remove original files after successful optimization.
|
||||
|
||||
For full control, automation can be configured via the WordPress Customizer. You can choose between manual processing, automatic optimization, or a fully automated workflow that includes cleanup of original images.
|
||||
|
||||
## 🔤 Local Fonts & Typography System
|
||||
|
||||
Zeitfresser uses a fully self-hosted typography system built around Oswald and Roboto.
|
||||
|
||||
All fonts are served locally using optimized `.woff2` files, eliminating external requests and improving privacy and performance. Critical font assets are preloaded to ensure fast rendering, and the entire system is built using CSS variables for consistency and maintainability.
|
||||
|
||||
The result is a predictable and visually stable typography layer across all environments.
|
||||
|
||||
## 🎨 CSS-Based Color System
|
||||
|
||||
The theme relies entirely on a static, CSS variable-driven color system.
|
||||
|
||||
Instead of dynamically generated styles or PHP-driven color logic, all values are defined using native CSS custom properties. This approach simplifies the styling layer, improves performance, and ensures consistent rendering without runtime overhead.
|
||||
|
||||
## ⚡ Core Web Vitals
|
||||
|
||||
Zeitfresser is optimized for real-world performance.
|
||||
|
||||
Layouts are stable and free of unexpected shifts, ensuring a solid CLS score. Critical assets are loaded early, and render-blocking resources are minimized. Even long-form articles with complex structures remain responsive and fast.
|
||||
|
||||
## 📑 Floating Table of Contents
|
||||
|
||||
One of the core features of the theme is its editorial-style floating Table of Contents.
|
||||
A key editorial feature of the theme is the floating Table of Contents.
|
||||
|
||||
The TOC is automatically generated from the article structure and positioned outside the main content area, allowing readers to navigate long articles without breaking reading flow. It follows the scroll position, highlights the current section, and includes a subtle progress indicator.
|
||||
|
||||
Special care has been taken to ensure that this feature enhances usability without adding visual noise or performance overhead.
|
||||
It is generated automatically from headings and positioned outside the main content flow, allowing readers to navigate long articles without distraction. The active section is highlighted, and a subtle progress indicator provides orientation within the document.
|
||||
|
||||
## ⚙️ Customization
|
||||
|
||||
The theme integrates directly into the WordPress Customizer, allowing essential behavior to be configured without introducing unnecessary complexity.
|
||||
Zeitfresser integrates cleanly with the WordPress Customizer, offering a small but focused set of options.
|
||||
|
||||
Within the General Options, the Table of Contents can be enabled or disabled globally. Additionally, a threshold can be defined that determines how many headings must be present before the TOC appears. This prevents unnecessary UI elements on shorter posts while keeping the feature effective for longer content.
|
||||
Instead of overwhelming users with configuration, the theme provides only what is necessary to adapt behavior without introducing complexity. This includes layout-related options and performance settings such as the image optimization pipeline.
|
||||
|
||||
## 🎨 Design Philosophy
|
||||
|
||||
Zeitfresser follows a simple but strict philosophy: **clarity over decoration**.
|
||||
The guiding principle behind Zeitfresser is simple:
|
||||
**clarity over decoration**.
|
||||
|
||||
The visual design is intentionally minimal, using a dark color scheme with subtle purple accents to guide attention. Instead of relying on visual noise, the theme uses spacing, typography, and structure to create hierarchy.
|
||||
|
||||
This results in a reading experience that feels focused and calm, even for very long and complex articles.
|
||||
Every design decision is made to support readability and structure. Colors are used sparingly, spacing is intentional, and typography defines hierarchy. The goal is not to impress visually, but to support sustained reading without fatigue.
|
||||
|
||||
## 🧹 Code Quality
|
||||
|
||||
The theme has been systematically cleaned and refactored.
|
||||
The codebase has been systematically refactored to remove legacy patterns and reduce complexity.
|
||||
|
||||
Legacy components and unused features have been removed, CSS conflicts reduced, and functionality centralized where appropriate. The codebase is modular, predictable, and designed for long-term maintainability.
|
||||
|
||||
No unnecessary dependencies are introduced, and the theme avoids patterns that typically lead to technical debt in WordPress environments.
|
||||
The theme avoids unnecessary abstractions and focuses on a modular, predictable structure. This makes it easier to maintain, extend, and reason about over time, without accumulating technical debt.
|
||||
|
||||
## 📱 Responsiveness
|
||||
|
||||
The layout adapts cleanly across devices.
|
||||
Zeitfresser adapts naturally across devices.
|
||||
|
||||
While the full editorial experience is optimized for larger screens, essential functionality remains accessible on smaller devices. Features such as the Table of Contents are intelligently disabled when they no longer provide value, ensuring that the mobile experience remains clean and usable.
|
||||
On desktop, it provides a full editorial experience with structured navigation. On mobile, the layout simplifies while preserving readability and access to core features. Components such as the Table of Contents adjust dynamically based on context.
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
To install the theme:
|
||||
|
||||
1. Download or clone the repository
|
||||
2. Upload it to your WordPress installation: /wp-content/themes/
|
||||
3. Activate it via: Appearance → Themes
|
||||
2. Upload it to your WordPress installation: `/wp-content/themes/`
|
||||
3. Activate it via: **Appearance → Themes**
|
||||
|
||||
## ⚡ Recommended Setup
|
||||
|
||||
For best results, it is recommended to run the theme in a modern environment with caching enabled.
|
||||
While the theme performs well out of the box, it benefits from a modern setup.
|
||||
|
||||
A CDN can further improve delivery performance, especially for global audiences. If migrating from another theme, existing images should be optimized to fully benefit from the built-in image handling.
|
||||
Using caching, a CDN, and optimized hosting will further improve performance, especially for larger sites with extensive media libraries.
|
||||
|
||||
## 🛠 Development & Support
|
||||
|
||||
Zeitfresser is actively developed and designed to evolve.
|
||||
|
||||
If you need to get support or want to participate in the active development of this software, you can <a href="https://ztfr.eu/matrix">join our Zeitfresser Matrix Community</a> or the <a href="https://look.ztfr.eu/#/#support:ztfr.eu">Development & Support Channel</a> on Matrix.
|
||||
If you want to get support or participate in development, you can join the
|
||||
<a href="https://ztfr.eu/matrix">Zeitfresser Matrix Community</a> or the
|
||||
<a href="https://look.ztfr.eu/#/#support:ztfr.eu">Development & Support Channel</a>.
|
||||
|
||||
## 📄 License
|
||||
|
||||
GPL v2 or later. Originally based on the [Daisy Blog](https://wordpress.org/themes/daisy-blog/) Theme, now heavily modified and optimized into an independent theme.
|
||||
GPL v2 or later.
|
||||
|
||||
Originally based on the [Daisy Blog](https://wordpress.org/themes/daisy-blog/) theme, now heavily modified into an independent codebase.
|
||||
|
||||
## 💬 Final Note
|
||||
|
||||
Zeitfresser is built for people who care about performance, readability, and clean engineering.
|
||||
Zeitfresser is built for developers and writers who care about:
|
||||
|
||||
performance, readability, and clean engineering.
|
||||
|
||||
It avoids unnecessary complexity and focuses on doing a few things exceptionally well:
|
||||
**presenting content clearly, loading fast, and staying maintainable.**
|
||||
**presenting content clearly, loading fast, and remaining maintainable over time.**
|
||||
|
||||
@@ -23,7 +23,10 @@
|
||||
<?php if ( $show_hide_image && has_post_thumbnail() ) : ?>
|
||||
<?php $thumbnail_size = get_theme_mod( 'post_snippet_featured_image_size', zeitfresser_get_default_post_snippet_featured_image_size() ); ?>
|
||||
<a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark" class="featured-image">
|
||||
<?php the_post_thumbnail( $thumbnail_size ); ?>
|
||||
<?php
|
||||
$size = ! empty( $thumbnail_size ) ? $thumbnail_size : 'zeitfresser-card';
|
||||
the_post_thumbnail( $size );
|
||||
?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<div class="summary">
|
||||
|
||||
Reference in New Issue
Block a user