Skip to content

Commit

Permalink
Turn create into a create/draft/none option selection (#213)
Browse files Browse the repository at this point in the history
* Turn create into a create/draft/none option selection

* Fix escaping
  • Loading branch information
dshanske committed Sep 10, 2021
1 parent 82ca0a4 commit 7800126
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
47 changes: 47 additions & 0 deletions includes/class-indieauth-authorization-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,53 @@ public static function scopes( $scope = 'all' ) {
*/
public static function scope_list( $scopes ) {
if ( ! empty( $scopes ) ) {
$create = array_search( 'create', $scopes, true );
if ( false !== $create ) {
unset( $scopes[ $create ] );
$draft = array_search( 'draft', $scopes, true );
if ( false !== $draft ) {
unset( $scopes[ $draft ] );
}
$scopes = array_values( $scopes );
echo '<div class="create_scope">';
echo wp_kses(
sprintf( '<li><input type="radio" name="scope[]" value="create"><strong>create</strong> - %1$s</li>', esc_html( self::scopes( 'create' ) ) ),
array(
'li' => array(),
'strong' => array(),
'input' => array(
'type' => array(),
'name' => array(),
'value' => array(),
),
)
);
echo wp_kses(
sprintf( '<li><input type="radio" name="scope[]" value="draft"><strong>draft</strong> - %1$s</li>', esc_html( self::scopes( 'draft' ) ) ),
array(
'li' => array(),
'strong' => array(),
'input' => array(
'type' => array(),
'name' => array(),
'value' => array(),
),
)
);
echo wp_kses(
sprintf( '<li><input type="radio" name="scope[]" value=""><strong>none</strong> - %1$s</li>', __( 'Token will have no privileges to create posts', 'indieauth' ) ),
array(
'li' => array(),
'strong' => array(),
'input' => array(
'type' => array(),
'name' => array(),
'value' => array(),
),
)
);
echo '</div>';
}
foreach ( $scopes as $s ) {
echo wp_kses(
sprintf( '<li><input type="checkbox" name="scope[]" value="%1$s" %2$s /><strong>%1$s</strong> - %3$s</li>', $s, checked( true, true, false ), esc_html( self::scopes( $s ) ) ),
Expand Down
4 changes: 4 additions & 0 deletions templates/indieauth-auth-footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
list-style: none;
}

.create_scope {
margin-bottom: 3em;
}

.expiration {
margin-top: 1em;
}
Expand Down

0 comments on commit 7800126

Please sign in to comment.