55 | -------------------------------------------------------------------------------- /includes/Traits/Find_Readme.php: -------------------------------------------------------------------------------- 1 | add_result_error_for_file( 51 | $result, 52 | __( 'Do not use Localhost/127.0.0.1 in your code.', 'plugin-check' ), 53 | 'localhost_code_detected', 54 | $file 55 | ); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /phpmd.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | */assets/* 47 | */node_modules/* 48 | */tests/* 49 | */vendor/* 50 | 51 | -------------------------------------------------------------------------------- /cli.php: -------------------------------------------------------------------------------- 1 | posts = $posts; 37 | } 38 | 39 | /** 40 | * Creates the demo posts in the database to be us 41 | * 42 | * @since n.e.x.t 43 | * 44 | * @return callable Cleanup function to revert changes made by theme and plugin preparation classes. 45 | * 46 | * @throws Exception Thrown when preparation fails. 47 | */ 48 | public function prepare() { 49 | $post_ids = array(); 50 | 51 | foreach ( $this->posts as $postarr ) { 52 | $post_id = wp_insert_post( $postarr, true ); 53 | 54 | if ( is_wp_error( $post_id ) ) { 55 | throw new Exception( $post_id->get_error_message() ); 56 | } 57 | 58 | $post_ids[] = $post_id; 59 | } 60 | 61 | // Return the cleanup function. 62 | return function () use ( $post_ids ) { 63 | foreach ( $post_ids as $post_id ) { 64 | wp_delete_post( $post_id, true ); 65 | } 66 | }; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /includes/Checker/Checks/No_Unfiltered_Uploads_Check.php: -------------------------------------------------------------------------------- 1 | add_result_error_for_file( 51 | $result, 52 | __( 'ALLOW_UNFILTERED_UPLOADS is not permitted.', 'plugin-check' ), 53 | 'allow_unfiltered_uploads_detected', 54 | $file 55 | ); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /drop-ins/object-cache.copy.php: -------------------------------------------------------------------------------- 1 | getConstants(); 35 | 36 | /** 37 | * List of categories. 38 | * 39 | * @var string[] $categories 40 | */ 41 | $categories = array_values( 42 | array_filter( 43 | $constants, 44 | static function ( $key ) { 45 | return strpos( $key, 'CATEGORY_' ) === 0; 46 | }, 47 | ARRAY_FILTER_USE_KEY 48 | ) 49 | ); 50 | } 51 | 52 | return $categories; 53 | } 54 | 55 | /** 56 | * Returns an array of checks. 57 | * 58 | * @since n.e.x.t 59 | * 60 | * @param Check_Collection $collection Check collection. 61 | * @param array $categories An array of categories to filter by. 62 | * @return Check_Collection Filtered check collection. 63 | */ 64 | public static function filter_checks_by_categories( Check_Collection $collection, array $categories ): Check_Collection { 65 | return $collection->filter( 66 | static function ( $check ) use ( $categories ) { 67 | // Return true if at least one of the check categories is among the filter categories. 68 | return (bool) array_intersect( $check->get_categories(), $categories ); 69 | } 70 | ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /test-content/themes/wp-empty-theme/inc/template-functions.php: -------------------------------------------------------------------------------- 1 | '; 27 | } 28 | } 29 | add_action( 'wp_head', 'wp_empty_theme_pingback_header' ); 30 | 31 | /** 32 | * Creates continue reading text. 33 | */ 34 | function wp_empty_theme_continue_reading_text() { 35 | $continue_reading = sprintf( 36 | /* translators: %s: Name of current post. */ 37 | esc_html__( 'Continue reading %s', 'wp-empty-theme' ), 38 | the_title( '', '', false ) 39 | ); 40 | 41 | return $continue_reading; 42 | } 43 | 44 | /** 45 | * Creates the continue reading link for excerpt. 46 | */ 47 | function wp_empty_theme_continue_reading_link_excerpt() { 48 | if ( ! is_admin() ) { 49 | return '… ' . wp_empty_theme_continue_reading_text() . ''; 50 | } 51 | } 52 | add_filter( 'excerpt_more', 'wp_empty_theme_continue_reading_link_excerpt' ); 53 | 54 | /** 55 | * Creates the continue reading link. 56 | */ 57 | function wp_empty_theme_continue_reading_link() { 58 | if ( ! is_admin() ) { 59 | return ''; 60 | } 61 | } 62 | add_filter( 'the_content_more_link', 'wp_empty_theme_continue_reading_link' ); 63 | -------------------------------------------------------------------------------- /includes/Checker/Checks.php: -------------------------------------------------------------------------------- 1 | run_check_with_result( $check, $result ); 46 | } 47 | ); 48 | 49 | return $result; 50 | } 51 | 52 | /** 53 | * Runs a given check with the given result object to amend. 54 | * 55 | * @since n.e.x.t 56 | * 57 | * @param Check $check The check to run. 58 | * @param Check_Result $result The result object to amend. 59 | * 60 | * @throws Exception Thrown when check fails with critical error. 61 | */ 62 | private function run_check_with_result( Check $check, Check_Result $result ) { 63 | // If $check implements Preparation interface, ensure the preparation and clean up is run. 64 | if ( $check instanceof Preparation ) { 65 | $cleanup = $check->prepare(); 66 | 67 | try { 68 | $check->run( $result ); 69 | } catch ( Exception $e ) { 70 | // Run clean up in case of any exception thrown from check. 71 | $cleanup(); 72 | throw $e; 73 | } 74 | 75 | $cleanup(); 76 | return; 77 | } 78 | 79 | // Otherwise, just run the check. 80 | $check->run( $result ); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /test-content/themes/wp-empty-theme/comments.php: -------------------------------------------------------------------------------- 1 | 14 | 15 |
16 | 19 |

20 | 31 |

32 | 33 |
    34 | 60, 38 | 'style' => 'ol', 39 | 'short_ping' => true, 40 | ) 41 | ); 42 | ?> 43 |
44 | 45 | esc_html__( 'Page', 'wp-empty-theme' ) . ' ', 49 | 'mid_size' => 0, 50 | 'prev_text' => sprintf( 51 | '%s', 52 | esc_html__( 'Older comments', 'wp-empty-theme' ) 53 | ), 54 | 'next_text' => sprintf( 55 | '%s', 56 | esc_html__( 'Newer comments', 'wp-empty-theme' ) 57 | ), 58 | ) 59 | ); 60 | 61 | if ( ! comments_open() ) { 62 | ?> 63 |

64 | null, 71 | 'title_reply' => esc_html__( 'Leave a comment', 'wp-empty-theme' ), 72 | 'title_reply_before' => '

', 73 | 'title_reply_after' => '

', 74 | ) 75 | ); 76 | ?> 77 |
78 | -------------------------------------------------------------------------------- /templates/admin-page.php: -------------------------------------------------------------------------------- 1 | 9 | 10 |
11 | 12 |

13 | 14 |
15 | 16 | 17 | 18 |
19 |

20 | 23 |

24 | 25 | 33 | 34 | 35 | 36 |

37 | 40 | 41 | 43 | 44 | 53 | 54 | 55 |
45 |
46 | 47 | 51 |
52 |
56 | 57 |
58 | 59 | 60 | 61 |

62 | 63 | 64 |
65 | 66 |
67 | 68 |
69 | -------------------------------------------------------------------------------- /test-content/themes/wp-empty-theme/inc/back-compat.php: -------------------------------------------------------------------------------- 1 |

'; 30 | printf( 31 | /* translators: %s: WordPress Version. */ 32 | esc_html__( 'This theme requires WordPress 5.3 or newer. You are running version %s. Please upgrade.', 'wp-empty-theme' ), 33 | esc_html( $GLOBALS['wp_version'] ) 34 | ); 35 | echo '