Skip to content

Commit dd6a035

Browse files
committed
Add setting for avatar store
1 parent c031274 commit dd6a035

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

includes/class-admin.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,16 @@ public static function register_settings() {
417417
'default' => 1,
418418
)
419419
);
420+
register_setting(
421+
'webmention',
422+
'webmention_avatar_store_enable',
423+
array(
424+
'type' => 'int',
425+
'description' => esc_html__( 'Store Avatars Locally', 'webmention' ),
426+
'show_in_rest' => true,
427+
'default' => 1,
428+
)
429+
);
420430
register_setting(
421431
'webmention',
422432
'webmention_separate_comment',

templates/webmention-settings.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
</td>
128128
</tr>
129129
<tr>
130-
<th scope="row"><?php esc_html_e( 'Avatars', 'webmention' ); ?></th>
130+
<th scope="row"><?php esc_html_e( 'Use Avatars', 'webmention' ); ?></th>
131131
<td>
132132
<fieldset>
133133
<label for="webmention_avatars">
@@ -137,6 +137,17 @@
137137
</fieldset>
138138
</td>
139139
</tr>
140+
<tr>
141+
<th scope="row"><?php esc_html_e( 'Store Avatars', 'webmention' ); ?></th>
142+
<td>
143+
<fieldset>
144+
<label for="webmention_avatar_store_enable">
145+
<input type="checkbox" name="webmention_avatar_store_enable" id="webmention_avatar_store_enable" value="1" <?php echo checked( true, get_option( 'webmention_avatar_store_enable', 1 ) ); ?> />
146+
<?php esc_html_e( 'Enable Local Caching of Avatars.', 'webmention' ); ?>
147+
</label>
148+
</fieldset>
149+
</td>
150+
</tr>
140151
<tr>
141152
<th scope="row"><?php esc_html_e( 'Display', 'webmention' ); ?></th>
142153
<td>

webmention.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
defined( 'WEBMENTION_GRAVATAR_CACHE_TIME' ) || define( 'WEBMENTION_GRAVATAR_CACHE_TIME', WEEK_IN_SECONDS );
2525

2626

27-
defined( 'WEBMENTION_LOCAL_AVATAR_STORE' ) || define( 'WEBMENTION_LOCAL_AVATAR_STORE', false );
27+
defined( 'WEBMENTION_LOCAL_AVATAR_STORE' ) || define( 'WEBMENTION_LOCAL_AVATAR_STORE', true );
2828
defined( 'WEBMENTION_AVATAR_QUALITY' ) || define( 'WEBMENTION_AVATAR_QUALITY', null );
2929
defined( 'WEBMENTION_AVATAR_SIZE' ) || define( 'WEBMENTION_AVATAR_SIZE', 256 );
3030

@@ -121,7 +121,7 @@ function init() {
121121
add_action( 'init', array( '\Webmention\Discovery', 'init' ) );
122122

123123
// load local avatar store.
124-
if ( WEBMENTION_LOCAL_AVATAR_STORE ) {
124+
if ( 1 === (int) get_option( 'webmention_disable_media_mentions', 1 ) ) {
125125
require_once __DIR__ . '/includes/class-avatar-store.php';
126126
add_action( 'init', array( '\Webmention\Avatar_Store', 'init' ) );
127127
}

0 commit comments

Comments
 (0)