Skip to content

Commit

Permalink
Fix small errors on app page (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk authored Feb 28, 2025
1 parent b185821 commit fc029df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions includes/class-mastodon-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function process_admin() {
$tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : 'welcome';
if ( isset( $_POST['app'] ) ) {
$app = Mastodon_App::get_by_client_id( sanitize_text_field( wp_unslash( $_POST['app'] ) ) );
if ( $app ) {
if ( $app && ! is_wp_error( $app ) ) {
return $this->process_admin_app_page( $app );
}
$tab = 'registered-apps';
Expand All @@ -182,7 +182,7 @@ public function admin_page() {
$tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'welcome';
if ( isset( $_GET['app'] ) ) {
$app = Mastodon_App::get_by_client_id( sanitize_text_field( wp_unslash( $_GET['app'] ) ) );
if ( $app ) {
if ( $app && ! is_wp_error( $app ) ) {
return $this->admin_app_page( $app );
}
$tab = 'registered-apps';
Expand Down
6 changes: 3 additions & 3 deletions templates/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,22 +295,22 @@ function updatePostFormatDropdown( el ) {
const options = postFormatSelect.querySelectorAll( 'option' );

for ( const option of options ) {
if ( option.value === '' ) {
option.textContent = option.textContent.replace( /\(.*\)/, '(' + postFormats[0].nextSibling.textContent.trim() + ')' );
}
if ( option.value === el.value ) {
option.disabled = ! el.checked;
if ( ! el.checked && postFormatSelect.value === el.value ) {
postFormatSelect.value = '';
}
}
}
const selectedPostFormat = postFormats.length ? postFormats[0] : document.querySelector( '.post-formats input[type="checkbox"]' );
options[0].textContent = options[0].textContent.replace( /\(.*\)/, '(' + selectedPostFormat.nextSibling.textContent.trim() + ')' );
}

if ( event.target.matches( '.post-formats input[type="checkbox"]' ) ) {
return updatePostFormatDropdown( event.target );
}
if ( event.target.id === 'toggle_all_post_formats' ) {
event.preventDefault();
document.querySelectorAll( '.post-formats input[type="checkbox"]' ).forEach( function ( element ) {
element.checked = ! element.checked;
updatePostFormatDropdown( element );
Expand Down

0 comments on commit fc029df

Please sign in to comment.