Add settings to en/disable user types (for .org users)

This commit is contained in:
Matthias Pfefferle 2023-07-20 14:21:32 +02:00
parent c288fbe021
commit 44a81742aa
4 changed files with 72 additions and 10 deletions

View file

@ -148,7 +148,7 @@ class Admin {
array( array(
'type' => 'boolean', 'type' => 'boolean',
'description' => \__( 'Add hashtags in the content as native tags and replace the #tag with the tag-link', 'activitypub' ), 'description' => \__( 'Add hashtags in the content as native tags and replace the #tag with the tag-link', 'activitypub' ),
'default' => 0, 'default' => '0',
) )
); );
\register_setting( \register_setting(
@ -182,6 +182,24 @@ class Admin {
}, },
) )
); );
\register_setting(
'activitypub',
'activitypub_enable_users',
array(
'type' => 'boolean',
'description' => \__( 'Every Author on this Blog (with the publish_posts capability) gets his own ActivityPub enabled Profile.', 'activitypub' ),
'default' => '1',
)
);
\register_setting(
'activitypub',
'activitypub_enable_blog_user',
array(
'type' => 'boolean',
'description' => \__( 'Your Blog becomes an ActivityPub compatible Profile.', 'activitypub' ),
'default' => '0',
)
);
} }
public static function add_settings_help_tab() { public static function add_settings_help_tab() {

View file

@ -347,7 +347,10 @@ function is_user_type_disabled( $type ) {
break; break;
} }
// @todo check user settings if ( '1' !== \get_option( 'activitypub_enable_blog_user', '0' ) ) {
$return = true;
break;
}
$return = false; $return = false;
break; break;
@ -364,7 +367,10 @@ function is_user_type_disabled( $type ) {
break; break;
} }
// @todo check user settings if ( '1' !== \get_option( 'activitypub_enable_users', '1' ) ) {
$return = true;
break;
}
$return = false; $return = false;
break; break;

View file

@ -33,7 +33,7 @@
<?php if ( ! \Activitypub\is_user_disabled( \Activitypub\Collection\Users::BLOG_USER_ID ) ) : ?> <?php if ( ! \Activitypub\is_user_disabled( \Activitypub\Collection\Users::BLOG_USER_ID ) ) : ?>
<h3><?php \esc_html_e( 'Blog-User', 'activitypub' ); ?></h3> <h3 class="dashicons-before dashicons-admin-users"><?php \esc_html_e( 'Blog-User', 'activitypub' ); ?></h3>
<p><?php \esc_html_e( 'All settings for the Blog-User (Catch-All Account)', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'All settings for the Blog-User (Catch-All Account)', 'activitypub' ); ?></p>
@ -58,9 +58,47 @@
<?php \do_settings_fields( 'activitypub', 'blog-user' ); ?> <?php \do_settings_fields( 'activitypub', 'blog-user' ); ?>
<hr />
<?php endif; ?> <?php endif; ?>
<h3><?php \esc_html_e( 'Activities', 'activitypub' ); ?></h3> <h3 class="dashicons-before dashicons-groups"><?php \esc_html_e( 'Users', 'activitypub' ); ?></h3>
<p><?php \esc_html_e( 'All user related settings.', 'activitypub' ); ?></p>
<table class="form-table">
<tbody>
<tr>
<th scope="row">
<?php \esc_html_e( 'Enable/disable Users by Type', 'activitypub' ); ?>
</th>
<td>
<p>
<label>
<input type="checkbox" name="activitypub_enable_users" id="activitypub_enable_users" value="1" <?php echo \checked( '1', \get_option( 'activitypub_enable_users', '1' ) ); ?> />
<?php \esc_html_e( 'Enable Authors', 'activitypub' ); ?>
</label>
</p>
<p class="description">
<?php echo \wp_kses( \__( 'Every Author on this Blog (with the <code>publish_posts</code> capability) gets his own ActivityPub enabled Profile.', 'activitypub' ), array( 'code' => array() ) ); ?>
</p>
<p>
<label>
<input type="checkbox" name="activitypub_enable_blog_user" id="activitypub_enable_blog_user" value="1" <?php echo \checked( '1', \get_option( 'activitypub_enable_blog_user', '0' ) ); ?> />
<?php \esc_html_e( 'Enable Blog-User', 'activitypub' ); ?>
</label>
</p>
<p class="description">
<?php \esc_html_e( 'Your Blog becomes an ActivityPub compatible Profile.', 'activitypub' ); ?>
</p>
</td>
</tr>
</tbody>
</table>
<?php \do_settings_fields( 'activitypub', 'user' ); ?>
<h3 class="dashicons-before dashicons-format-chat"><?php \esc_html_e( 'Activities', 'activitypub' ); ?></h3>
<p><?php \esc_html_e( 'All activity related settings.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'All activity related settings.', 'activitypub' ); ?></p>
@ -222,7 +260,7 @@
<?php \do_settings_fields( 'activitypub', 'activity' ); ?> <?php \do_settings_fields( 'activitypub', 'activity' ); ?>
<h3><?php \esc_html_e( 'Server', 'activitypub' ); ?></h3> <h3 class="dashicons-before dashicons-database"><?php \esc_html_e( 'Server', 'activitypub' ); ?></h3>
<p><?php \esc_html_e( 'Server related settings.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'Server related settings.', 'activitypub' ); ?></p>

View file

@ -17,7 +17,7 @@
<?php if ( ! \Activitypub\is_user_disabled( \Activitypub\Collection\Users::BLOG_USER_ID ) ) : ?> <?php if ( ! \Activitypub\is_user_disabled( \Activitypub\Collection\Users::BLOG_USER_ID ) ) : ?>
<h3><?php \esc_html_e( 'Blog Account', 'activitypub' ); ?></h3> <h3 class="dashicons-before dashicons-admin-users"><?php \esc_html_e( 'Blog Account', 'activitypub' ); ?></h3>
<p> <p>
<?php <?php
$blog_user = new \Activitypub\Model\Blog_User(); $blog_user = new \Activitypub\Model\Blog_User();
@ -41,7 +41,7 @@
<?php if ( ! \Activitypub\is_user_disabled( get_current_user_id() ) ) : ?> <?php if ( ! \Activitypub\is_user_disabled( get_current_user_id() ) ) : ?>
<h3><?php \esc_html_e( 'Personal Account', 'activitypub' ); ?></h3> <h3 class="dashicons-before dashicons-groups"><?php \esc_html_e( 'Personal Account', 'activitypub' ); ?></h3>
<p> <p>
<?php <?php
$user = \Activitypub\Collection\Users::get_by_id( wp_get_current_user()->ID ); $user = \Activitypub\Collection\Users::get_by_id( wp_get_current_user()->ID );
@ -63,7 +63,7 @@
<?php endif; ?> <?php endif; ?>
<h3><?php \esc_html_e( 'Troubleshooting', 'activitypub' ); ?></h3> <h3 class="dashicons-before dashicons-admin-tools"><?php \esc_html_e( 'Troubleshooting', 'activitypub' ); ?></h3>
<p> <p>
<?php <?php
echo wp_kses( echo wp_kses(
@ -82,7 +82,7 @@
<?php if ( ACTIVITYPUB_SHOW_PLUGIN_RECOMMENDATIONS ) : ?> <?php if ( ACTIVITYPUB_SHOW_PLUGIN_RECOMMENDATIONS ) : ?>
<hr /> <hr />
<h3><?php \esc_html_e( 'Recommended Plugins', 'activitypub' ); ?></h3> <h3 class="dashicons-before dashicons-admin-plugins"><?php \esc_html_e( 'Recommended Plugins', 'activitypub' ); ?></h3>
<p><?php \esc_html_e( 'ActivityPub works as is and there is no need for you to install additional plugins, nevertheless there are some plugins that extends the functionality of ActivityPub.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'ActivityPub works as is and there is no need for you to install additional plugins, nevertheless there are some plugins that extends the functionality of ActivityPub.', 'activitypub' ); ?></p>