Changeset 3104569
- Timestamp:
- 06/19/2024 12:42:58 PM (8 weeks ago)
- Location:
- enable-mastodon-apps/trunk
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
enable-mastodon-apps/trunk/README.md
r3101492 r3104569 7 7 - Requires PHP: 7.4 8 8 - License: [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html) 9 - Stable tag: 0.9. 39 - Stable tag: 0.9. 10 10 11 11 Allow accessing your WordPress with Mastodon clients. Just enter your own blog URL as your instance. … … 98 98 ## Changelog 99 99 100 101 102 103 100 104 ### 0.9.3 101 105 - Bring back the upgrade code. … … 131 135 132 136 137 138 133 139 [#150]: https://github.com/akirk/enable-mastodon-apps/pull/150 134 140 [#148]: https://github.com/akirk/enable-mastodon-apps/pull/148 -
enable-mastodon-apps/trunk/admin.css
r3097861 r3104569 226 226 border-color: #b32d2e; 227 227 color: #b32d2e; 228 228 229 } 229 230 … … 278 279 margin: 0 auto; 279 280 } 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 -
enable-mastodon-apps/trunk/admin.js
r3097861 r3104569 38 38 } ); 39 39 40 $(document).on( 'click', '.enable-mastodon-apps-settings button[ name=delete-app]', function( event, response ) {40 $(document).on( 'click', '.enable-mastodon-apps-settings button[]', function( event, response ) { 41 41 if ( ! confirm( this.dataset.confirm ) ) { 42 42 event.preventDefault(); … … 44 44 } 45 45 } ); 46 47 $(document).on( 'click', '.enable-mastodon-apps-settings button[name=clear-app-logs]', function( event, response ) {48 if ( ! confirm( this.dataset.confirm ) ) {49 event.preventDefault();50 return false;51 }52 } );53 54 46 } ); -
enable-mastodon-apps/trunk/enable-mastodon-apps.php
r3101492 r3104569 4 4 * Plugin author: Alex Kirk 5 5 * Plugin URI: https://github.com/akirk/enable-mastodon-apps 6 * Version: 0.9. 36 * Version: 0.9. 7 7 * 8 8 * Description: Allow accessing your WordPress with Mastodon clients. Just enter your own blog URL as your instance. … … 19 19 defined( 'ABSPATH' ) || exit; 20 20 define( 'ENABLE_MASTODON_APPS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 21 define( 'ENABLE_MASTODON_APPS_VERSION', '0.9. 3' );21 define( 'ENABLE_MASTODON_APPS_VERSION', '0.9.' ); 22 22 23 23 require __DIR__ . '/vendor/bshaffer/oauth2-server-php/src/OAuth2/Autoloader.php'; -
enable-mastodon-apps/trunk/includes/class-mastodon-admin.php
r3101492 r3104569 57 57 58 58 $tab = $_GET['tab'] ?? 'welcome'; 59 60 61 62 63 64 65 59 66 switch ( $tab ) { 60 67 case 'settings': … … 73 80 $this->enable_debug = get_option( 'mastodon_api_enable_debug' ); 74 81 $tab = $_GET['tab'] ?? 'welcome'; 82 83 84 85 86 87 88 75 89 switch ( $tab ) { 76 90 case 'welcome': … … 448 462 } 449 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 450 587 public static function upgrade_plugin( $override_old_version = false ) { 451 588 $old_version = get_option( 'ema_plugin_version' ); -
enable-mastodon-apps/trunk/includes/class-mastodon-app.php
r3097861 r3104569 55 55 } 56 56 57 public function set_client_secret( $client_secret ) {58 return update_term_meta( $this->term->term_id, 'client_secret', $client_secret );59 }60 61 57 public function get_redirect_uris() { 62 58 return get_term_meta( $this->term->term_id, 'redirect_uris', true ); … … 95 91 return $query_args['post_formats']; 96 92 } 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 97 129 98 130 public function set_post_formats( $post_formats ) { -
enable-mastodon-apps/trunk/includes/class-mastodon-oauth.php
r3101476 r3104569 37 37 public function __construct() { 38 38 $config = array( 39 'issuer' => home_url( '/' ), 40 'enforce_state' => false, 41 'access_lifetime' => YEAR_IN_SECONDS * 2, 39 'issuer' => home_url( '/' ), 40 'enforce_state' => false, 41 'require_exact_redirect_uri' => false, 42 'access_lifetime' => YEAR_IN_SECONDS * 2, 42 43 ); 43 44 -
enable-mastodon-apps/trunk/includes/handler/class-handler.php
r3097861 r3104569 22 22 $limit = 20; 23 23 } 24 24 $app = Mastodon_App::get_current_app(); 25 $post_types = array( 'post' ); 26 if ( $app ) { 27 $post_types = $app->get_view_post_types(); 28 } 25 29 $args['posts_per_page'] = $limit; 26 $args['post_type'] = array ( 'post', Mastodon_API::CPT);30 $args['post_type'] = array ); 27 31 $args['suppress_filters'] = false; 28 32 $args['post_status'] = array( 'publish', 'private' ); -
enable-mastodon-apps/trunk/templates/admin-header.php
r3097861 r3104569 77 77 <?php 78 78 } 79 79 80 ?> 80 81 <div class="enable-mastodon-apps-settings-header"> … … 109 110 </div> 110 111 <hr class="wp-header-end"> 112 113 114 115 116 117 -
enable-mastodon-apps/trunk/templates/registered-apps.php
r3097861 r3104569 13 13 14 14 $rest_nonce = wp_create_nonce( 'wp_rest' ); 15 16 function post_format_select( $name, $selected = array() ) {17 ?>18 <select name="<?php echo esc_attr( $name ); ?>[]" id="<?php echo esc_attr( $name ); ?>" size="10" multiple class="appformats">19 <?php20 foreach ( get_post_format_slugs() as $format ) {21 ?>22 <option value="<?php echo esc_attr( $format ); ?>" <?php selected( in_array( $format, $selected, true ) ); ?>><?php echo esc_html( $format ); ?></option>23 <?php24 }25 ?>26 </select>27 <?php28 }29 15 30 16 ?> … … 52 38 <th><?php esc_html_e( 'Last Used', 'enable-mastodon-apps' ); ?></th> 53 39 <th><?php esc_html_e( 'Created', 'enable-mastodon-apps' ); ?></th> 54 <th><?php esc_html_e( 'Actions', 'enable-mastodon-apps' ); ?></th>55 40 </thead> 56 41 <tbody> … … 59 44 foreach ( $args['apps'] as $app ) { 60 45 $alternate = ! $alternate; 61 $confirm = esc_html(62 sprintf(63 // translators: %s is the app name.64 __( 'Are you sure you want to delete %s?', 'enable-mastodon-apps' ),65 $app->get_client_name()66 )67 );68 46 69 47 ?> 70 48 <tr id='app-<?php echo esc_attr( $app->get_client_id() ); ?>' class="<?php echo $alternate ? 'alternate' : ''; ?>"> 71 49 <td title='<?php echo esc_attr( $app->get_client_id() ); ?>'> 50 72 51 <?php 73 if ( $app->get_website() ) {74 ?>75 <a href="<?php echo esc_url( $app->get_website() ); ?>"><?php echo esc_html( $app->get_client_name() ); ?></a>76 <?php77 } else {78 echo esc_html( $app->get_client_name() );79 }80 52 81 53 if ( $app->is_outdated() && Mastodon_App::DEBUG_CLIENT_ID !== $app->get_client_id() ) { … … 87 59 <td><?php echo esc_html( $app->get_scopes() ); ?></td> 88 60 <td class="debug-hide"> 89 <details> 90 <summary><?php echo esc_html( implode( ', ', $app->get_post_formats() ) ); ?></summary> 91 <?php post_format_select( 'app_post_formats[' . $app->get_client_id() . ']', $app->get_post_formats() ); ?> 92 </details> 61 <?php 62 foreach ( get_post_format_strings() as $format => $label ) { 63 if ( in_array( $format, $app->get_post_formats() ) ) { 64 echo esc_html( $label ) . '<br>'; 65 } 66 } 67 ?> 93 68 </td> 94 69 <?php td_timestamp( $app->get_last_used() ); ?> 95 70 <?php td_timestamp( $app->get_creation_date() ); ?> 96 <td>97 <button name="save-app" value="<?php echo esc_attr( $app->get_client_id() ); ?>" class="button save-app button-secondary"><?php esc_html_e( 'Save' ); /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ ?></button>98 <button name="delete-app" data-confirm="<?php echo esc_attr( $confirm ); ?>" value="<?php echo esc_attr( $app->get_client_id() ); ?>" class="button button-destructive"><?php esc_html_e( 'Delete' ); /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ ?></button>99 </td>100 71 </tr> 101 72 <?php 102 if ( $args['enable_debug'] ) {103 $last_requests = $app->get_last_requests();104 if ( $last_requests ) {105 $confirm = esc_html(106 sprintf(107 // translators: %s is the app name.108 __( 'Are you sure you want to delete all logs for %s?', 'enable-mastodon-apps' ),109 $app->get_client_name()110 )111 );112 ?>113 <tr id='applog-<?php echo esc_attr( $app->get_client_id() ); ?>' class="<?php echo $alternate ? 'alternate' : ''; ?>">114 <td colspan="6">115 <details class="tt"><summary>116 <?php117 echo esc_html(118 sprintf(119 // translators: %ds is the number of requests.120 _n( '%d logged request', '%d logged requests', count( $last_requests ), 'enable-mastodon-apps' ),121 count( $last_requests )122 )123 );124 ?>125 </summary>126 <?php127 foreach ( $last_requests as $request ) {128 output_request_log( $request, $rest_nonce );129 }130 ?>131 </details>132 </td>133 <td>134 <button name="clear-app-logs" data-confirm="<?php echo esc_attr( $confirm ); ?>" value="<?php echo esc_attr( $app->get_client_id() ); ?>" class="button button-destructive"><?php esc_html_e( 'Clear logs', 'enable-mastodon-apps' ); ?></button>135 </td>136 </tr>137 <?php138 }139 }140 73 } 141 74 ?> … … 143 76 </table> 144 77 145 <?php if ( $args['enable_debug'] ) : ?> 78 <?php if ( $args['enable_debug'] ) : ?> 79 <?php if ( ! empty( $args['codes'] ) ) : ?> 146 80 <h2><?php esc_html_e( 'Authorization Codes', 'enable-mastodon-apps' ); ?></h2> 147 81 … … 163 97 <th><?php esc_html_e( 'Expires', 'enable-mastodon-apps' ); ?></th> 164 98 <th><?php esc_html_e( 'Scope', 'enable-mastodon-apps' ); ?></th> 165 <th><?php esc_html_e( 'Actions', 'enable-mastodon-apps' ); ?></th>166 99 </thead> 167 100 <tbody> … … 190 123 <?php td_timestamp( $data['expires'] ); ?> 191 124 <td><?php echo esc_html( $data['scope'] ); ?></td> 192 <td><button name="delete-code" value="<?php echo esc_attr( $code ); ?>" class="button button-destructive"><?php esc_html_e( 'Delete' ); /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ ?></button></td>193 125 </tr> 194 126 <?php … … 197 129 </tbody> 198 130 </table> 131 199 132 200 <h2><?php esc_html_e( 'Access Tokens', 'enable-mastodon-apps' ); ?></h2> 201 <span class="count"> 202 <?php 203 echo esc_html( 204 sprintf( 205 // translators: %d is the number of tokens. 206 _n( '%d token', '%d tokens', count( $args['tokens'] ), 'enable-mastodon-apps' ), 207 count( $args['tokens'] ) 208 ) 209 ); 210 ?> 211 </span> 212 <table class="widefat striped"> 213 <thead> 214 <th><?php esc_html_e( 'App', 'enable-mastodon-apps' ); ?></th> 215 <th><?php esc_html_e( 'User', 'enable-mastodon-apps' ); ?></th> 216 <th><?php esc_html_e( 'Last Used', 'enable-mastodon-apps' ); ?></th> 217 <th><?php esc_html_e( 'Expires', 'enable-mastodon-apps' ); ?></th> 218 <th><?php esc_html_e( 'Scope', 'enable-mastodon-apps' ); ?></th> 219 <th><?php esc_html_e( 'Actions', 'enable-mastodon-apps' ); ?></th> 220 </thead> 221 <tbody> 222 <?php 223 foreach ( $args['tokens'] as $token => $data ) { 224 $user = 'app-level'; 225 if ( $data['user_id'] ) { 226 $userdata = get_user_by( 'ID', $data['user_id'] ); 227 if ( $userdata ) { 228 if ( is_wp_error( $userdata ) ) { 229 $user = $userdata->get_error_message(); 230 } else { 231 $user = $userdata->user_login; 232 } 233 } else { 234 $user = 'error'; 235 } 236 } 237 ?> 238 <tr id="token-<?php echo esc_attr( $token ); ?>"> 239 <td title="<?php echo esc_attr( $token ); ?>"> 240 <?php 241 if ( isset( $args['apps'][ $data['client_id'] ] ) ) { 242 ?> 243 <a href="#app-<?php echo esc_attr( $data['client_id'] ); ?>"><?php echo esc_html( $args['apps'][ $data['client_id'] ]->get_client_name() ); ?></a> 244 <?php 245 } else { 246 echo esc_html( 247 sprintf( 248 // Translators: %s is the app ID. 249 __( 'Unknown App: %s', 'enable-mastodon-apps' ), 250 $data['client_id'] 251 ) 252 ); 253 echo ' <span class="pill pill-outdated" title="' . esc_html__( 'Associated with an app that no longer exists.', 'enable-mastodon-apps' ) . '">' . esc_html__( 'Outdated', 'enable-mastodon-apps' ) . '</span>'; 254 } 255 ?> 256 </td> 257 <td><?php echo esc_html( $user ); ?></td> 258 <?php td_timestamp( $data['last_used'] ); ?> 259 <?php td_timestamp( $data['expires'], true ); ?> 260 <td><?php echo esc_html( $data['scope'] ); ?></td> 261 <td><button name="delete-token" value="<?php echo esc_attr( $token ); ?>" class="button button-destructive"><?php esc_html_e( 'Delete' ); /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ ?></button></td> 262 </tr> 263 <?php 264 } 265 ?> 266 </tbody> 267 </table> 268 269 <?php if ( ! empty( $args['codes'] ) || ! empty( $args['tokens'] ) || ! empty( $args['apps'] ) ) : ?> 270 <h2><?php esc_html_e( 'Cleanup', 'enable-mastodon-apps' ); ?></h2> 271 <button name="delete-outdated" class="button"><?php esc_html_e( 'Delete outdated apps and tokens', 'enable-mastodon-apps' ); ?></button> 272 <button name="delete-never-used" class="button"><?php esc_html_e( 'Delete never used apps and tokens', 'enable-mastodon-apps' ); ?></button> 273 <button name="delete-apps-without-tokens" class="button"><?php esc_html_e( 'Delete apps without tokens', 'enable-mastodon-apps' ); ?></button> 274 <button name="clear-all-app-logs" class="button button-destructive"><?php esc_html_e( 'Clear all logs', 'enable-mastodon-apps' ); ?></button> 133 <?php if ( ! empty( $args['codes'] ) || ! empty( $args['tokens'] ) || ! empty( $args['apps'] ) ) : ?> 134 <h2><?php esc_html_e( 'Cleanup', 'enable-mastodon-apps' ); ?></h2> 135 <button name="delete-outdated" class="button"><?php esc_html_e( 'Delete outdated apps and tokens', 'enable-mastodon-apps' ); ?></button> 136 <button name="delete-never-used" class="button"><?php esc_html_e( 'Delete never used apps and tokens', 'enable-mastodon-apps' ); ?></button> 137 <button name="delete-apps-without-tokens" class="button"><?php esc_html_e( 'Delete apps without tokens', 'enable-mastodon-apps' ); ?></button> 138 <button name="clear-all-app-logs" class="button button-destructive"><?php esc_html_e( 'Clear all logs', 'enable-mastodon-apps' ); ?></button> 275 139 <?php endif; ?> 276 140 <?php endif; ?> 277 </form>141 </form> 278 142 </div> -
enable-mastodon-apps/trunk/templates/welcome.php
r3101476 r3104569 47 47 </p> 48 48 <p> 49 <?php esc_html_e( 'Since the task of this plugin to achieve Mastodon API compatibility is complex, it is possible that you encounter issues.', 'enable-mastodon-apps' ); ?> 49 <span><?php esc_html_e( 'Since the task of this plugin to achieve Mastodon API compatibility is complex, it is possible that you encounter issues.', 'enable-mastodon-apps' ); ?></span> 50 <span> 50 51 <?php 51 52 echo wp_kses( … … 63 64 ); 64 65 ?> 66 65 67 </p> 66 68 </div>
Note: See TracChangeset
for help on using the changeset viewer.