Skip to content

Commit

Permalink
CDPT-2264 Fix font assets, and debug logging typo. (#788)
Browse files Browse the repository at this point in the history
* Move moji-clarity font to fonts.styl so it's not included in style.css with incorrect relative path.

* Fix/improve debug logging.

* Update amazon-s3-and-cloudfront-assets.php
  • Loading branch information
EarthlingDavey authored Nov 20, 2024
1 parent dbc738d commit 85022da
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
24 changes: 12 additions & 12 deletions public/app/themes/clarity/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@
*/

// Log on document_serve
/*add_action('document_serve', function ($file, $post_id, $attach_id) {
error_log('CDPT_Debug: document_serve: ' . $file . ' ' . $post_id . ' ' . $attach_id);
}, 10, 3);
add_action('serve_document', function ( $post_id, $file ) {
error_log('CDPT_Debug: document_serve: ' . $post_id . ' ' . $file);
}, 10, 2);

// Log on document_serve_done
add_action('document_serve_done', function ($file, $attach_id ) {
Expand All @@ -143,39 +143,39 @@
// Log on document edit
add_action('document_edit', function () {
error_log('CDPT_Debug: document_edit');
}, 10);
});

// Log on document saved
add_action('document_saved', function ($doc_id, $attach_id) {
error_log('CDPT_Debug: document_saved: ' . $doc_id . ' ' . $attach_id);
}, 10, 2);*/
}, 10, 2);

// Log on attachment upload
add_action('add_attachment', function ($attach_id) {
error_log('CDPT_Debug: add_attachment: ' . $attach_id);
}, 10, 1);
});

// Log on edit post
add_action('edit_post', function ($post_id) {
error_log('CDPT_Debug: edit_post: ' . $post_id);
}, 10, 1);
});

// Log on post save
add_action('save_post', function ($post_id) {
error_log('CDPT_Debug: save_post: ' . $post_id);
}, 10, 1);
});

// Log on S3 upload - as3cf_post_upload_attachment
add_action('as3cf_post_upload_attachment', function ($source_id, $item) {
error_log('CDPT_Debug: as3cf_post_upload_attachment: ' . $source_id);
}, 10, 3);
}, 10, 2);

// Log on as3cf_pre_upload_object
add_action('as3cf_pre_upload_object', function ($args) {
add_action('as3cf_pre_upload_object', function ($args, $file) {
error_log('CDPT_Debug: as3cf_pre_upload_object');
}, 10, 1);
}, 10, 2);

// Log on as3cf_post_upload_item
add_action('as3cf_post_upload_item', function ($item) {
error_log('CDPT_Debug: as3cf_post_upload_item');
}, 10, 1);
});
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public function rewriteSrc(string $src, string $handle): string
}

// Fonts cannot be served via the CDN, because browsers do not send cookies for `@font-face` requests.
// Exclude the core-css and style handles from being rewritten, because they use `@font-face`.
if (in_array($handle, ['core-css', 'style'])) {
// Exclude the core-css handle from being rewritten, because it uses `@font-face`.
if (in_array($handle, ['core-css'])) {
return $src;
}

Expand Down
6 changes: 4 additions & 2 deletions public/app/themes/clarity/inc/post-types/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ function mojintranet_sort_events($vars)
// Delete `event_get_events_...` transients from the database, these are created in EventsHelper.
function mojintranet_clear_events_cache() {

error_log('Clearing event cache.');

error_log('CDPT_Debug: Clearing event cache.');
global $wpdb;
$wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_event_get_events_%')" );

Expand All @@ -138,4 +138,6 @@ function mojintranet_clear_events_cache() {
// As there is no function to clear cache by 'keys that start with', we have to flush the whole cache.
wp_cache_flush();
}

error_log('CDPT_Debug: Cleared event cache.');
}
11 changes: 11 additions & 0 deletions public/app/themes/clarity/src/globals/css/fonts.styl
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@
src: url("../fonts/nta_bold.woff") format("woff");
font-weight: bold;
}

@font-face {
font-family: 'moji-clarity';
src: url('../fonts/moji-clarity.eot?vklv4a');
src: url('../fonts/moji-clarity.eot?vklv4a#iefix') format('embedded-opentype'),
url('../fonts/moji-clarity.ttf?vklv4a') format('truetype'),
url('../fonts/moji-clarity.woff?vklv4a') format('woff'),
url('../fonts/moji-clarity.svg?vklv4a#moji-clarity') format('svg');
font-weight: normal;
font-style: normal;
}
11 changes: 0 additions & 11 deletions public/app/themes/clarity/src/globals/css/icons.styl
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
@font-face {
font-family: 'moji-clarity';
src: url('../fonts/moji-clarity.eot?vklv4a');
src: url('../fonts/moji-clarity.eot?vklv4a#iefix') format('embedded-opentype'),
url('../fonts/moji-clarity.ttf?vklv4a') format('truetype'),
url('../fonts/moji-clarity.woff?vklv4a') format('woff'),
url('../fonts/moji-clarity.svg?vklv4a#moji-clarity') format('svg');
font-weight: normal;
font-style: normal;
}

.u-icon {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'moji-clarity' !important;
Expand Down

0 comments on commit 85022da

Please sign in to comment.