Changeset 10038
- Timestamp:
- 07/08/2020 10:00:30 PM (5 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-block-plugin-checker.php
r10037 r10038 308 308 'type' => $type, 309 309 'message' => $message, 310 'data' => $data ); 310 'data' => $data, 311 ); 311 312 } 312 313 … … 319 320 */ 320 321 function check_readme_exists() { 321 if ( empty( $this->readme_path ) || !file_exists( $this->readme_path ) ) { 322 $this->record_result( __FUNCTION__, 322 if ( empty( $this->readme_path ) || ! file_exists( $this->readme_path ) ) { 323 $this->record_result( 324 __FUNCTION__, 323 325 'error', 324 326 __( 'Missing readme.txt file.', 'wporg-plugins' ), … … 333 335 function check_license() { 334 336 if ( empty( $this->readme->license ) && empty( $this->headers->License ) ) { 335 $this->record_result( __FUNCTION__, 337 $this->record_result( 338 __FUNCTION__, 336 339 'warning', 337 340 __( 'No plugin license was found.', 'wporg-plugins' ) 338 341 ); 339 } elseif ( !empty( $this->readme->license ) ) { 340 $this->record_result( __FUNCTION__, 342 } elseif ( ! empty( $this->readme->license ) ) { 343 $this->record_result( 344 __FUNCTION__, 341 345 'info', 346 // translators: %s is the license. 342 347 sprintf( __( 'Found a license in readme.txt: %s.', 'wporg-plugins' ), $this->readme->license ), 343 348 $this->readme->license 344 349 ); 345 } elseif ( !empty( $this->headers->License ) ) { 346 $this->record_result( __FUNCTION__, 350 } elseif ( ! empty( $this->headers->License ) ) { 351 $this->record_result( 352 __FUNCTION__, 347 353 'info', 354 // translators: %s is the license. 348 355 sprintf( __( 'Found a license in plugin headers: %s.', 'wporg-plugins' ), $this->headers->License ), 349 356 $this->headers->License … … 357 364 function check_plugin_headers() { 358 365 if ( empty( $this->headers ) ) { 359 $this->record_result( __FUNCTION__, 366 $this->record_result( 367 __FUNCTION__, 360 368 'error', 361 369 __( 'Missing plugin headers. Is this a WordPress plugin?', 'wporg-plugins' ) … … 369 377 function check_block_tag() { 370 378 if ( empty( $this->readme->tags ) || ! in_array( 'block', array_map( 'strtolower', $this->readme->tags ) ) ) { 371 $this->record_result( __FUNCTION__, 379 $this->record_result( 380 __FUNCTION__, 372 381 'warning', 373 __( 'No blocktag found in readme.txt.', 'wporg-plugins' ),382 __( 'No "block" tag found in readme.txt.', 'wporg-plugins' ), 374 383 $this->readme->tags 375 384 ); 376 385 } else { 377 $this->record_result( __FUNCTION__, 386 $this->record_result( 387 __FUNCTION__, 378 388 'info', 379 __( 'Found a blocktag in readme.txt.', 'wporg-plugins' ),389 __( 'Found the "block" tag in readme.txt.', 'wporg-plugins' ), 380 390 $this->readme->tags 381 391 ); … … 416 426 } 417 427 } 418 419 428 } 420 429 … … 424 433 function check_for_blocks() { 425 434 if ( 0 === count( $this->blocks ) ) { 426 $this->record_result( __FUNCTION__, 435 $this->record_result( 436 __FUNCTION__, 427 437 'error', 428 438 __( 'No blocks found in plugin.', 'wporg-plugins' ) 429 439 ); 430 440 } else { 431 $this->record_result( __FUNCTION__, 432 ( count( $this->blocks ) < 5 ? 'info' : 'warning' ), // 5+ blocks suggests it's probably not a block plugin 433 sprintf( _n( 'Found %d block.', 'Found %d blocks.', count( $this->blocks ), 'wporg-plugins' ), count( $this->blocks ) ), 441 $this->record_result( 442 __FUNCTION__, 443 'info', 444 sprintf( 445 // translators: %d number of blocks. 446 _n( 'Found %d block.', 'Found %d blocks.', count( $this->blocks ), 'wporg-plugins' ), 447 count( $this->blocks ) 448 ), 434 449 array_keys( $this->blocks ) 435 450 ); … … 442 457 function check_for_block_json() { 443 458 foreach ( $this->blocks as $block_name => $block_info ) { 444 if ( !empty( $this->block_json_files[ $block_name ] ) ) { 445 $this->record_result( __FUNCTION__, 459 if ( ! empty( $this->block_json_files[ $block_name ] ) ) { 460 $this->record_result( 461 __FUNCTION__, 446 462 'info', 447 sprintf( __( 'block.json file exists for block %s.', 'wporg-plugins' ), $block_name ), 463 // translators: %s is the block name. 464 sprintf( __( 'Found a block.json file for block %s.', 'wporg-plugins' ), '<code>' . $block_name . '</code>' ), 448 465 $this->block_json_files[ $block_name ] 449 466 ); … … 452 469 453 470 if ( empty( $this->block_json_files ) ) { 454 $this->record_result( __FUNCTION__, 471 $this->record_result( 472 __FUNCTION__, 455 473 'warning', 456 474 __( 'No block.json files were found.', 'wporg-plugins' ) … … 466 484 467 485 foreach ( $this->blocks as $block_name => $block_info ) { 468 if ( !empty( $block_scripts[ $block_name ] ) ) { 469 $this->record_result( __FUNCTION__, 486 if ( ! empty( $block_scripts[ $block_name ] ) ) { 487 $this->record_result( 488 __FUNCTION__, 470 489 'info', 471 sprintf( __( 'Scripts found for block %s.', 'wporg-plugins' ), $block_name ), 490 // translators: %s is the block name. 491 sprintf( __( 'Scripts found for block %s.', 'wporg-plugins' ), '<code>' . $block_name . '</code>' ), 472 492 $block_scripts[ $block_name ] 473 493 ); 474 494 } else { 475 $this->record_result( __FUNCTION__, 495 $this->record_result( 496 __FUNCTION__, 476 497 'warning', 477 sprintf( __( 'No scripts found for block %s.', 'wporg-plugins' ), $block_name ), 498 // translators: %s is the block name. 499 sprintf( __( 'No scripts found for block %s.', 'wporg-plugins' ), '<code>' . $block_name . '</code>' ), 478 500 $block_name 479 501 ); … … 489 511 foreach ( $scripts as $script ) { 490 512 if ( file_exists( $this->path_to_plugin . $script ) ) { 491 $this->record_result( __FUNCTION__, 513 $this->record_result( 514 __FUNCTION__, 492 515 'info', 493 sprintf( __( 'Script file exists for block %s.', 'wporg-plugins' ), $block_name ), 516 // translators: %s is the block name. 517 sprintf( __( 'Script file exists for block %s.', 'wporg-plugins' ), '<code>' . $block_name . '</code>' ), 494 518 $script 495 519 ); 496 520 } else { 497 $this->record_result( __FUNCTION__, 521 $this->record_result( 522 __FUNCTION__, 498 523 'warning', 499 sprintf( __( 'Missing script file for block %s.', 'wporg-plugins' ), $block_name ), 524 // translators: %s is the block name. 525 sprintf( __( 'Missing script file for block %s.', 'wporg-plugins' ), '<code>' . $block_name . '</code>' ), 500 526 $script 501 527 ); … … 520 546 521 547 if ( empty( $block_files ) ) { 522 $this->record_result( __FUNCTION__, 548 $this->record_result( 549 __FUNCTION__, 523 550 'error', 524 551 sprintf( __( '<code>registerBlockType()</code> must be called in a JavaScript file.', 'wporg-plugins' ) ) … … 534 561 if ( is_wp_error( $result ) ) { 535 562 if ( $message = $result->get_error_message( 'json_parse_error' ) ) { 536 $this->record_result( __FUNCTION__, 563 $this->record_result( 564 __FUNCTION__, 537 565 'error', 538 sprintf( __( 'Error attempting to parse json in %s: %s', 'wporg-plugins' ), $this->relative_filename( $block_json_file ), $message ), 566 sprintf( 567 // translators: %1$s is the file name, %2$s is the json error message. 568 __( 'Error attempting to parse json in %1$s: %2$s', 'wporg-plugins' ), 569 '<code>' . $this->relative_filename( $block_json_file ) . '</code>', 570 $message 571 ), 539 572 $this->relative_filename( $block_json_file ) 540 573 ); … … 550 583 foreach ( $this->block_json_validation as $block_json_file => $result ) { 551 584 if ( true === $result ) { 552 $this->record_result( __FUNCTION__, 585 $this->record_result( 586 __FUNCTION__, 553 587 'info', 554 sprintf( __( 'JSON file %s is valid.', 'wporg-plugins' ), $this->relative_filename( $block_json_file ) ), 588 // translators: %s is the file name. 589 sprintf( __( 'JSON file %s is valid.', 'wporg-plugins' ), '<code>' . $this->relative_filename( $block_json_file ) . '</code>' ), 555 590 $this->relative_filename( $block_json_file ) 556 591 ); … … 564 599 continue; // Already handled in check_block_json_is_valid_json 565 600 } else { 566 $this->record_result( __FUNCTION__, 601 $this->record_result( 602 __FUNCTION__, 567 603 ( 'error' === $code ? 'warning' : $code ), // TODO: be smarter about mapping these 568 $this->relative_filename( $block_json_file ) . ': ' . $message,604 '<code>' . $this->relative_filename( $block_json_file ) . '</code>: ' . $message, 569 605 array( 570 606 $this->relative_filename( $block_json_file ), 571 $result->get_error_data( $code ) 607 $result->get_error_data( $code ), 572 608 ) 573 609 ); … … 590 626 591 627 if ( 1 === $count ) { 592 $this->record_result( __FUNCTION__, 628 $this->record_result( 629 __FUNCTION__, 593 630 'info', 594 sprintf( __( 'PHP asset file found: %s.', 'wporg-plugins' ), $this->relative_filename( $file ) ), 631 // translators: %s is the name of asset file. 632 sprintf( 633 __( 'PHP asset file found: %s.', 'wporg-plugins' ), 634 '<code>' . $this->relative_filename( $file ) . '</code>' 635 ), 595 636 $this->relative_filename( $file ) 596 637 ); 597 638 } elseif ( $count > 1 ) { 598 $this->record_result( __FUNCTION__, 639 $this->record_result( 640 __FUNCTION__, 599 641 'warning', 642 // translators: %s is the number of asset files. 600 643 sprintf( __( 'Found %s PHP asset files.', 'wporg-plugins' ), $count ), 601 644 array_map( null, array( $this->relative_filename( $file ) ), $this->asset_php_files ) … … 614 657 } 615 658 if ( $total_size > 50 * KB_IN_BYTES ) { 616 $this->record_result( __FUNCTION__, 617 'error', 659 $this->record_result( 660 __FUNCTION__, 661 'error', 662 // translators: %s is the size of PHP code. 618 663 sprintf( __( 'Found %s of PHP code. Please submit PHP plugins to the plugin directory.', 'wporg-plugins' ), size_format( $total_size ) ), 619 664 $total_size 620 665 ); 621 666 } elseif ( $total_size > 10 * KB_IN_BYTES ) { 622 $this->record_result( __FUNCTION__, 667 $this->record_result( 668 __FUNCTION__, 623 669 'warning', 670 // translators: %s is the size of PHP code. 624 671 sprintf( __( 'Found %s of PHP code. This might not be a block plugin.', 'wporg-plugins' ), size_format( $total_size ) ), 625 672 $total_size 626 673 ); 627 674 } else { 628 $this->record_result( __FUNCTION__, 675 $this->record_result( 676 __FUNCTION__, 629 677 'info', 678 // translators: %s is the size of PHP code. 630 679 sprintf( __( 'Found %s of PHP code. Thanks for keeping it minimal!', 'wporg-plugins' ), size_format( $total_size ) ), 631 680 $total_size -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-block-validator.php
r10036 r10038 15 15 16 16 if ( is_user_logged_in() ) : 17 ?> 18 <div class="wrap"> 19 <form method="post" action="."> 20 <p> 21 <label for="plugin_url"><?php _e( 'Plugin repo URL', 'wporg-plugins' ); ?></label> 22 </p> 23 <p> 24 <input type="text" id="plugin_url" name="plugin_url" size="70" placeholder="https://plugins.svn.wordpress.org/" value="<?php echo esc_attr( $plugin_url ); ?>" /> 25 <input type="submit" class="button button-secondary" value="<?php esc_attr_e( 'Validate!', 'wporg-plugins' ); ?>" /> 17 ?> 18 19 <div class="wrap block-validator"> 20 <form method="post" action="." class="block-validator__plugin-form"> 21 <label for="plugin_url"><?php _e( 'Plugin repo URL', 'wporg-plugins' ); ?></label> 22 <div class="block-validator__plugin-input-container"> 23 <input type="text" class="block-validator__plugin-input" id="plugin_url" name="plugin_url" placeholder="https://plugins.svn.wordpress.org/" value="<?php echo esc_attr( $plugin_url ); ?>" /> 24 <input type="submit" class="button button-secondary block-validator__plugin-submit" value="<?php esc_attr_e( 'Validate!', 'wporg-plugins' ); ?>" /> 26 25 <?php wp_nonce_field( 'validate-block-plugin', 'block-nonce' ); ?> 27 </ p>26 </div> 28 27 </form> 29 28 30 29 <?php 31 if ( $_POST && ! empty( $_POST['plugin_url'] ) && wp_verify_nonce( $_POST['block-nonce'], 'validate-block-plugin' ) ) {30 if ( $_POST && ! empty( $_POST['plugin_url'] ) && wp_verify_nonce( $_POST['block-nonce'], 'validate-block-plugin' ) ) { 32 31 self::validate_block( $_POST['plugin_url'] ); 33 } elseif ( $_POST && ! empty( $_POST['block-directory-edit'] ) ) {32 } elseif ( $_POST && ! empty( $_POST['block-directory-edit'] ) ) { 34 33 $post = get_post( intval( $_POST['plugin-id'] ) ); 35 34 if ( $post && wp_verify_nonce( $_POST['block-directory-nonce'], 'block-directory-edit-' . $post->ID ) ) { … … 49 48 ?> 50 49 </div> 51 <?php else : ?>52 <div class="wrap ">50 <?php else : ?> 51 <div class="wrap block-validator"> 53 52 <p><?php _e( 'Please log in to use the validator.', 'wporg-plugins' ); ?></p> 54 53 </div> … … 123 122 $output .= "<div class='notice notice-success notice-alt'>\n"; 124 123 if ( $checker->slug && self::plugin_is_in_block_directory( $checker->slug ) ) { 125 $output .= __( 'No problems were found. This plugin is already in the Block Directory.', 'wporg-plugins' );124 $output .= '<p>' . __( 'No problems were found. This plugin is already in the Block Directory.', 'wporg-plugins' ) . '</p>'; 126 125 } else { 127 $output .= __( 'No problems were found. Your plugin has passed the first step towards being included in the Block Directory.', 'wporg-plugins' );126 $output .= '<p>' . __( 'No problems were found. Your plugin has passed the first step towards being included in the Block Directory.', 'wporg-plugins' ) . '</p>'; 128 127 } 129 128 $output .= "</div>\n"; … … 131 130 $output .= '<h3>' . __( 'Problems were encountered', 'wporg-plugins' ) . '</h3>'; 132 131 $output .= "<div class='notice notice-error notice-alt'>\n"; 133 $output .= __( 'Some problems were found. They need to be addressed before your plugin will work in the Block Directory.', 'wporg-plugins' );132 $output .= '<p>' . __( 'Some problems were found. They need to be addressed before your plugin will work in the Block Directory.', 'wporg-plugins' ) . '</p>'; 134 133 $output .= "</div>\n"; 135 134 }
Note: See TracChangeset
for help on using the changeset viewer.