├── .wordpress-org ├── screenshot-1.png ├── screenshot-2.png ├── screenshot-3.png ├── screenshot-4.png ├── banner-1544x500.png └── banner-772x250.png ├── .github ├── CODEOWNERS ├── workflows │ ├── deploy.yml │ └── integration.yml └── dependabot.yml ├── .gitignore ├── .distignore ├── tests ├── Unit │ ├── TestCase.php │ └── Core │ │ └── RewriteRulesTest.php ├── Integration │ ├── TestCase.php │ └── PluginTest.php └── bootstrap.php ├── .wp-env.json ├── .editorconfig ├── phpunit.xml.dist ├── assets ├── js │ └── admin.js └── css │ └── admin.css ├── rector.php ├── rewrite-rules-inspector.php ├── src ├── Core │ ├── RuleFlush.php │ ├── FileExport.php │ ├── Permastructs.php │ ├── RewriteRules.php │ └── UrlTester.php ├── Admin │ ├── AdminPage.php │ ├── ContextualHelp.php │ ├── RewriteRulesTable.php │ └── ViewRenderer.php └── Plugin.php ├── composer.json ├── views └── permastructs-table.php ├── .phpcs.xml.dist ├── CHANGELOG.md ├── README.md ├── languages └── rewrite-rules-inspector.pot └── LICENSE /.wordpress-org/screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Automattic/Rewrite-Rules-Inspector/HEAD/.wordpress-org/screenshot-1.png -------------------------------------------------------------------------------- /.wordpress-org/screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Automattic/Rewrite-Rules-Inspector/HEAD/.wordpress-org/screenshot-2.png -------------------------------------------------------------------------------- /.wordpress-org/screenshot-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Automattic/Rewrite-Rules-Inspector/HEAD/.wordpress-org/screenshot-3.png -------------------------------------------------------------------------------- /.wordpress-org/screenshot-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Automattic/Rewrite-Rules-Inspector/HEAD/.wordpress-org/screenshot-4.png -------------------------------------------------------------------------------- /.wordpress-org/banner-1544x500.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Automattic/Rewrite-Rules-Inspector/HEAD/.wordpress-org/banner-1544x500.png -------------------------------------------------------------------------------- /.wordpress-org/banner-772x250.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Automattic/Rewrite-Rules-Inspector/HEAD/.wordpress-org/banner-772x250.png -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # The following teams will get auto-tagged for a review. 2 | # See https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners 3 | * @Automattic/vip-plugins 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules/ 3 | /vendor/ 4 | 5 | # Composer 6 | /composer.lock 7 | 8 | # Tests 9 | /.phpunit.cache/ 10 | 11 | # Local config overrides 12 | /.phpcs.xml 13 | /phpcs.xml 14 | /phpunit.xml 15 | /.wp-env.override.json 16 | -------------------------------------------------------------------------------- /.distignore: -------------------------------------------------------------------------------- 1 | # Directories 2 | /.git/ 3 | /.github/ 4 | /bin/ 5 | /node_modules/ 6 | /tests/ 7 | /vendor/ 8 | 9 | # Files 10 | .distignore 11 | .editorconfig 12 | .gitattributes 13 | .gitignore 14 | .phpcs.xml.dist 15 | .wp-env.json 16 | .wp-env.override.json 17 | CHANGELOG.md 18 | composer.json 19 | composer.lock 20 | package.json 21 | package-lock.json 22 | phpunit.xml.dist 23 | -------------------------------------------------------------------------------- /tests/Unit/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue( class_exists( \Automattic\RewriteRulesInspector\Core\RewriteRules::class ) ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to WordPress.org 2 | on: 3 | release: 4 | types: [released] 5 | # Allow manual triggering of the workflow. 6 | workflow_dispatch: 7 | 8 | permissions: {} 9 | 10 | jobs: 11 | release: 12 | name: New release to WordPress.org 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 19 | with: 20 | persist-credentials: false 21 | 22 | - name: Install SVN (Subversion) 23 | run: | 24 | sudo apt-get update 25 | sudo apt-get install subversion 26 | 27 | - name: Push to WordPress.org 28 | uses: 10up/action-wordpress-plugin-deploy@54bd289b8525fd23a5c365ec369185f2966529c2 # 2.3.0 29 | env: 30 | SLUG: rewrite-rules-inspector 31 | SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} 32 | SVN_USERNAME: ${{ secrets.SVN_USERNAME }} 33 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./tests/Unit 16 | 17 | 18 | ./tests/Integration 19 | 20 | 21 | 22 | 23 | ./src 24 | ./rewrite-rules-inspector.php 25 | 26 | 27 | ./vendor 28 | ./tests 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /assets/js/admin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Rewrite Rules Inspector Admin JavaScript 3 | * 4 | * @package automattic\rewrite-rules-inspector 5 | * @since 1.5.0 6 | */ 7 | 8 | (function($) { 9 | 'use strict'; 10 | 11 | /** 12 | * Initialize admin functionality when document is ready. 13 | */ 14 | $(document).ready(function() { 15 | initAccessibilityEnhancements(); 16 | }); 17 | 18 | 19 | /** 20 | * Initialize accessibility enhancements. 21 | */ 22 | function initAccessibilityEnhancements() { 23 | // Add ARIA live region for dynamic content updates. 24 | if (!$('#rri-live-region').length) { 25 | $('body').append('
'); 26 | } 27 | } 28 | 29 | /** 30 | * Utility function to check if element is in viewport. 31 | */ 32 | function isInViewport(element) { 33 | const rect = element.getBoundingClientRect(); 34 | return ( 35 | rect.top >= 0 && 36 | rect.left >= 0 && 37 | rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && 38 | rect.right <= (window.innerWidth || document.documentElement.clientWidth) 39 | ); 40 | } 41 | 42 | })(jQuery); 43 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Configuration for Dependabot version updates 2 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 3 | 4 | version: 2 5 | updates: 6 | - package-ecosystem: "github-actions" 7 | directory: "/" 8 | schedule: 9 | interval: "weekly" 10 | day: "monday" 11 | groups: 12 | actions: 13 | patterns: ["*"] 14 | labels: 15 | - "dependencies" 16 | commit-message: 17 | prefix: "Actions" 18 | include: "scope" 19 | open-pull-requests-limit: 5 20 | 21 | - package-ecosystem: "composer" 22 | directory: "/" 23 | schedule: 24 | interval: "weekly" 25 | day: "tuesday" 26 | groups: 27 | dev-dependencies: 28 | patterns: 29 | - "automattic/*" 30 | - "dealerdirect/*" 31 | - "php-parallel-lint/*" 32 | - "phpcompatibility/*" 33 | - "phpunit/*" 34 | - "squizlabs/*" 35 | - "yoast/*" 36 | labels: 37 | - "dependencies" 38 | commit-message: 39 | prefix: "Composer" 40 | include: "scope" 41 | open-pull-requests-limit: 5 42 | versioning-strategy: increase-if-necessary 43 | -------------------------------------------------------------------------------- /tests/Integration/PluginTest.php: -------------------------------------------------------------------------------- 1 | assertTrue( defined( 'REWRITE_RULES_INSPECTOR_VERSION' ) ); 20 | } 21 | 22 | /** 23 | * Test that the plugin file path constant is defined. 24 | */ 25 | public function test_plugin_file_path_constant_defined(): void { 26 | $this->assertTrue( defined( 'REWRITE_RULES_INSPECTOR_FILE_PATH' ) ); 27 | } 28 | 29 | /** 30 | * Test that the global plugin instance exists. 31 | */ 32 | public function test_global_plugin_instance_exists(): void { 33 | global $rewrite_rules_inspector; 34 | $this->assertInstanceOf( \Automattic\RewriteRulesInspector\Plugin::class, $rewrite_rules_inspector ); 35 | } 36 | 37 | /** 38 | * Test that the admin menu is registered. 39 | */ 40 | public function test_admin_menu_registered(): void { 41 | $this->assertGreaterThan( 0, has_action( 'admin_menu' ) ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /rector.php: -------------------------------------------------------------------------------- 1 | withPaths( 20 | array( 21 | __DIR__ . '/src', 22 | __DIR__ . '/rewrite-rules-inspector.php', 23 | ) 24 | ) 25 | ->withSkip( 26 | array( 27 | LongArrayToShortArrayRector::class, 28 | ) 29 | ) 30 | ->withPhpSets( php74: true ) 31 | // Changes from later PHP Sets that are backwards compatible: 32 | ->withRules( 33 | array( 34 | // 8.0 35 | ConsistentImplodeRector::class, 36 | OptionalParametersAfterRequiredRector::class, 37 | RemoveParentCallWithoutParentRector::class, 38 | // Backfilled from PHP 8.0 into WP 5.9, so these can be used. 39 | StrContainsRector::class, 40 | StrEndsWithRector::class, 41 | StrStartsWithRector::class, 42 | 43 | // 8.1 44 | NullToStrictStringFuncCallArgRector::class, 45 | 46 | // 8.2 47 | VariableInStringInterpolationFixerRector::class, 48 | 49 | // 8.3 50 | AddOverrideAttributeToOverriddenMethodsRector::class, 51 | 52 | // 8.4 53 | ExplicitNullableParamTypeRector::class, 54 | ) 55 | ) 56 | ->withPreparedSets( deadCode: true, codeQuality: true, instanceOf: true, codingStyle: true ) 57 | ->withTypeCoverageLevel( 1 ) 58 | ; 59 | -------------------------------------------------------------------------------- /rewrite-rules-inspector.php: -------------------------------------------------------------------------------- 1 | run(); 55 | } 56 | ); 57 | -------------------------------------------------------------------------------- /.github/workflows/integration.yml: -------------------------------------------------------------------------------- 1 | name: Run PHPUnit 2 | 3 | on: 4 | push: 5 | branches: 6 | - develop 7 | - trunk 8 | paths: 9 | - '.github/workflows/integration.yml' 10 | - '**.php' 11 | - 'phpunit.xml.dist' 12 | - 'composer.json' 13 | pull_request: 14 | paths: 15 | - '.github/workflows/integration.yml' 16 | - '**.php' 17 | - 'phpunit.xml.dist' 18 | - 'composer.json' 19 | workflow_dispatch: 20 | 21 | permissions: 22 | contents: read 23 | 24 | # Cancels all previous workflow runs for the same branch that have not yet completed. 25 | concurrency: 26 | group: ${{ github.workflow }}-${{ github.ref }} 27 | cancel-in-progress: true 28 | 29 | jobs: 30 | test: 31 | name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }} 32 | runs-on: ubuntu-latest 33 | 34 | env: 35 | WP_ENV_CORE: WordPress/WordPress#${{ matrix.wordpress }} 36 | 37 | strategy: 38 | matrix: 39 | include: 40 | # Check lowest supported WP version, with the lowest supported PHP. 41 | - wordpress: '6.4' 42 | php: '7.4' 43 | # Check latest WP with the latest PHP. 44 | - wordpress: 'master' 45 | php: 'latest' 46 | fail-fast: false 47 | 48 | steps: 49 | - name: Checkout code 50 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 51 | with: 52 | persist-credentials: false 53 | 54 | - name: Install wordpress environment 55 | run: npm install -g @wordpress/env 56 | 57 | - name: Setup PHP ${{ matrix.php }} 58 | uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0 59 | with: 60 | php-version: ${{ matrix.php }} 61 | tools: composer 62 | 63 | - name: Install Composer dependencies 64 | uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # 3.1.1 65 | 66 | - name: Setup problem matchers for PHP 67 | run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" 68 | 69 | - name: Setup problem matchers for PHPUnit 70 | run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" 71 | 72 | - name: Setup wp-env 73 | run: wp-env start 74 | 75 | - name: Run integration tests (single site) 76 | run: composer test:integration 77 | 78 | - name: Run integration tests (multisite) 79 | run: composer test:integration-ms 80 | -------------------------------------------------------------------------------- /src/Core/RuleFlush.php: -------------------------------------------------------------------------------- 1 | flushing_enabled = $flushing_enabled; 38 | $this->view_cap = $view_cap; 39 | } 40 | 41 | /** 42 | * Allow a user to flush rewrite rules for their site. 43 | * 44 | * @since 1.5.0 45 | * @param string $redirect_url URL to redirect to after flushing. 46 | */ 47 | public function flush_rules( string $redirect_url ): void { 48 | // Check nonce and permissions. 49 | check_admin_referer( 'flush-rules' ); 50 | if ( ! $this->flushing_enabled || ! current_user_can( $this->view_cap ) ) { 51 | wp_die( esc_html__( 'You do not have permissions to perform this action.', 'rewrite-rules-inspector' ) ); 52 | } 53 | 54 | $this->perform_flush(); 55 | $this->redirect_after_flush( $redirect_url ); 56 | } 57 | 58 | /** 59 | * Perform the actual flush operation. 60 | * 61 | * @since 1.5.0 62 | */ 63 | private function perform_flush(): void { 64 | wp_cache_delete( 'rewrite_rules', 'options' ); 65 | // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules 66 | flush_rewrite_rules( false ); 67 | do_action( 'rri_flush_rules' ); 68 | } 69 | 70 | /** 71 | * Redirect after successful flush. 72 | * 73 | * @since 1.5.0 74 | * @param string $redirect_url Base URL to redirect to. 75 | */ 76 | private function redirect_after_flush( string $redirect_url ): void { 77 | $args = [ 78 | 'message' => 'flush-success', 79 | ]; 80 | wp_safe_redirect( add_query_arg( $args, $redirect_url ) ); 81 | exit; 82 | } 83 | 84 | /** 85 | * Check if flushing is enabled. 86 | * 87 | * @since 1.5.0 88 | * @return bool True if flushing is enabled. 89 | */ 90 | public function is_flushing_enabled(): bool { 91 | return $this->flushing_enabled; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/Core/FileExport.php: -------------------------------------------------------------------------------- 1 | view_cap = $view_cap; 30 | } 31 | 32 | /** 33 | * Process a user's request to download a set of the rewrite rules. 34 | * 35 | * Prompts a download of the current set of rules as a text file by 36 | * setting the header. Respects current filter rules. 37 | * 38 | * @since 1.5.0 39 | * @param array $rewrite_rules Array of rewrite rules to export. 40 | */ 41 | public function download_rules( array $rewrite_rules ): void { 42 | // Check nonce and permissions. 43 | check_admin_referer( 'download-rules' ); 44 | if ( ! current_user_can( $this->view_cap ) ) { 45 | wp_die( esc_html__( 'You do not have permissions to perform this action.', 'rewrite-rules-inspector' ) ); 46 | } 47 | 48 | // Get the rewrite rules and prompt the user to download them. 49 | // File is saved as YYYYMMDD.themename.rewriterules.txt. 50 | $theme_name = sanitize_key( get_option( 'stylesheet' ) ); 51 | $filename = gmdate( 'Ymd' ) . '.' . $theme_name . '.rewriterules.txt'; 52 | 53 | $this->set_download_headers( $filename ); 54 | $this->output_rules_content( $rewrite_rules ); 55 | } 56 | 57 | /** 58 | * Set HTTP headers for file download. 59 | * 60 | * @since 1.5.0 61 | * @param string $filename The filename for the download. 62 | */ 63 | private function set_download_headers( string $filename ): void { 64 | header( 'Content-Type: text/plain' ); 65 | header( 'Content-Disposition: attachment; filename="' . $filename . '"' ); 66 | } 67 | 68 | /** 69 | * Output the rules content for download. 70 | * 71 | * @since 1.5.0 72 | * @param array $rewrite_rules Array of rewrite rules to export. 73 | */ 74 | private function output_rules_content( array $rewrite_rules ): void { 75 | $rules_to_export = []; 76 | foreach ( $rewrite_rules as $rule => $data ) { 77 | $rules_to_export[ $rule ] = $data['rewrite']; 78 | } 79 | 80 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped,WordPress.PHP.DevelopmentFunctions.error_log_var_export 81 | echo var_export( $rules_to_export, true ); 82 | exit; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "automattic/rewrite-rules-inspector", 3 | "description": "WordPress plugin to inspect your rewrite rules.", 4 | "license": "GPL-2.0-or-later", 5 | "type": "wordpress-plugin", 6 | "authors": [ 7 | { 8 | "name": "Automattic", 9 | "homepage": "https://automattic.com/" 10 | } 11 | ], 12 | "homepage": "https://wordpress.org/plugins/rewrite-rules-inspector/", 13 | "support": { 14 | "issues": "https://github.com/Automattic/Rewrite-Rules-Inspector/issues", 15 | "source": "https://github.com/Automattic/Rewrite-Rules-Inspector" 16 | }, 17 | "require": { 18 | "php": ">=7.4", 19 | "composer/installers": "^1.0 || ^2.0" 20 | }, 21 | "require-dev": { 22 | "automattic/vipwpcs": "^3.0", 23 | "php-parallel-lint/php-parallel-lint": "^1.0", 24 | "phpcompatibility/phpcompatibility-wp": "^2.1", 25 | "phpunit/phpunit": "^9", 26 | "rector/rector": "^2.2", 27 | "yoast/wp-test-utils": "^1.2" 28 | }, 29 | "autoload-dev": { 30 | "psr-4": { 31 | "Automattic\\RewriteRulesInspector\\Tests\\": "tests/" 32 | } 33 | }, 34 | "config": { 35 | "allow-plugins": { 36 | "composer/installers": true, 37 | "dealerdirect/phpcodesniffer-composer-installer": true 38 | }, 39 | "sort-packages": true 40 | }, 41 | "scripts": { 42 | "coverage": "@php ./vendor/bin/phpunit --coverage-html ./build/coverage-html", 43 | "coverage-ci": "@php ./vendor/bin/phpunit", 44 | "cs": "@php ./vendor/bin/phpcs -q", 45 | "cs-fix": "@php ./vendor/bin/phpcbf -q", 46 | "i18n": "@php wp i18n make-pot . ./languages/rewrite-rules-inspector.pot", 47 | "lint": "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git", 48 | "lint-ci": "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --checkstyle", 49 | "test:unit": "@php ./vendor/bin/phpunit --testsuite Unit", 50 | "test:integration": "wp-env run tests-cli --env-cwd=wp-content/plugins/Rewrite-Rules-Inspector ./vendor/bin/phpunit --testsuite WP_Tests", 51 | "test:integration-ms": "wp-env run tests-cli --env-cwd=wp-content/plugins/Rewrite-Rules-Inspector /bin/bash -c 'WP_MULTISITE=1 ./vendor/bin/phpunit --testsuite WP_Tests'" 52 | }, 53 | "scripts-descriptions": { 54 | "coverage": "Run tests with code coverage reporting", 55 | "coverage-ci": "Run tests with code coverage reporting and send results to stdout", 56 | "cs": "Run PHP Code Sniffer", 57 | "cs-fix": "Run PHP Code Sniffer and fix violations", 58 | "i18n": "Generate a POT file for translation", 59 | "lint": "Run PHP linting", 60 | "lint-ci": "Run PHP linting and send results to stdout", 61 | "test:unit": "Run unit tests", 62 | "test:integration": "Run integration tests", 63 | "test:integration-ms": "Run integration tests in multisite mode" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /views/permastructs-table.php: -------------------------------------------------------------------------------- 1 | 16 | 17 |

18 | 19 |

20 | 21 |

22 | 26 |

27 | 28 |
29 | 30 | 31 | 32 | 35 | 38 | 41 | 42 | 43 | 44 | 45 | 46 | 49 | 52 | 55 | 56 | 57 | 58 | 59 | 60 | 63 | 66 | 69 | 70 | 71 |
33 | 34 | 36 | 37 | 39 | 40 |
47 | 48 | 50 | 51 | 53 | 54 |
61 | 62 | 64 | 65 | 67 | 68 |
72 |
73 | -------------------------------------------------------------------------------- /.phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | Custom ruleset for rewrite-rules-inspector plugin. 4 | 5 | 6 | 7 | 8 | 9 | . 10 | 12 | /vendor/ 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/Admin/AdminPage.php: -------------------------------------------------------------------------------- 1 | parent_slug = $parent_slug; 64 | $this->page_slug = $page_slug; 65 | $this->view_cap = $view_cap; 66 | $this->callback = $callback; 67 | $this->help_service = $help_service; 68 | } 69 | 70 | /** 71 | * Register the admin page. 72 | * 73 | * @since 1.5.0 74 | */ 75 | public function register(): void { 76 | add_action( 'admin_menu', [ $this, 'add_submenu_page' ] ); 77 | } 78 | 79 | /** 80 | * Add our sub-menu page to the admin navigation. 81 | * 82 | * @since 1.5.0 83 | */ 84 | public function add_submenu_page(): void { 85 | $hook = add_submenu_page( 86 | $this->parent_slug, 87 | __( 'Rewrite Rules Inspector', 'rewrite-rules-inspector' ), 88 | __( 'Rewrite Rules', 'rewrite-rules-inspector' ), 89 | $this->view_cap, 90 | $this->page_slug, 91 | $this->callback 92 | ); 93 | 94 | // Add screen help. 95 | add_action( 'load-' . $hook, [ $this, 'add_screen_help' ] ); 96 | } 97 | 98 | /** 99 | * Add screen help tabs to explain rewrite rules and permastructs. 100 | * 101 | * @since 1.5.0 102 | */ 103 | public function add_screen_help(): void { 104 | $this->help_service->add_help_content(); 105 | } 106 | 107 | /** 108 | * Get the page slug. 109 | * 110 | * @since 1.5.0 111 | * @return string The page slug. 112 | */ 113 | public function get_page_slug(): string { 114 | return $this->page_slug; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | get_core_permastructs( $wp_rewrite ) ); 28 | 29 | // Extra permastructs including tags, categories, etc. 30 | $permastructs = array_merge( $permastructs, $this->get_extra_permastructs( $wp_rewrite ) ); 31 | 32 | // Filter out empty structures. 33 | $permastructs = array_filter( 34 | $permastructs, 35 | function ( $permastruct ) { 36 | return ! empty( $permastruct['structure'] ); 37 | } 38 | ); 39 | 40 | // Allow filtering of permastructs. 41 | $permastructs = apply_filters( 'rri_permastructs', $permastructs ); 42 | 43 | return $permastructs; 44 | } 45 | 46 | /** 47 | * Get core WordPress permastructs. 48 | * 49 | * @since 1.5.0 50 | * @param \WP_Rewrite $wp_rewrite WordPress rewrite object. 51 | * @return array Array of core permastructs. 52 | */ 53 | private function get_core_permastructs( \WP_Rewrite $wp_rewrite ): array { 54 | return [ 55 | 'post' => [ 56 | 'name' => __( 'Post Permalink', 'rewrite-rules-inspector' ), 57 | 'structure' => $wp_rewrite->permalink_structure, 58 | 'description' => __( 'The permalink structure for posts', 'rewrite-rules-inspector' ), 59 | ], 60 | 'date' => [ 61 | 'name' => __( 'Date Archive', 'rewrite-rules-inspector' ), 62 | 'structure' => $wp_rewrite->get_date_permastruct(), 63 | 'description' => __( 'The permalink structure for date archives', 'rewrite-rules-inspector' ), 64 | ], 65 | 'search' => [ 66 | 'name' => __( 'Search Results', 'rewrite-rules-inspector' ), 67 | 'structure' => $wp_rewrite->get_search_permastruct(), 68 | 'description' => __( 'The permalink structure for search results', 'rewrite-rules-inspector' ), 69 | ], 70 | 'author' => [ 71 | 'name' => __( 'Author Archive', 'rewrite-rules-inspector' ), 72 | 'structure' => $wp_rewrite->get_author_permastruct(), 73 | 'description' => __( 'The permalink structure for author archives', 'rewrite-rules-inspector' ), 74 | ], 75 | 'comments' => [ 76 | 'name' => __( 'Comments', 'rewrite-rules-inspector' ), 77 | 'structure' => $wp_rewrite->root . $wp_rewrite->comments_base, 78 | 'description' => __( 'The permalink structure for comments', 'rewrite-rules-inspector' ), 79 | ], 80 | 'root' => [ 81 | 'name' => __( 'Root', 'rewrite-rules-inspector' ), 82 | 'structure' => $wp_rewrite->root . '/', 83 | 'description' => __( 'The root permalink structure', 'rewrite-rules-inspector' ), 84 | ], 85 | ]; 86 | } 87 | 88 | /** 89 | * Get extra permastructs (tags, categories, custom, etc.). 90 | * 91 | * @since 1.5.0 92 | * @param \WP_Rewrite $wp_rewrite WordPress rewrite object. 93 | * @return array Array of extra permastructs. 94 | */ 95 | private function get_extra_permastructs( \WP_Rewrite $wp_rewrite ): array { 96 | $permastructs = []; 97 | 98 | foreach ( $wp_rewrite->extra_permastructs as $permastructname => $permastruct ) { 99 | $structure = $this->extract_permastruct_structure( $permastruct ); 100 | 101 | // Generate human-readable names and descriptions. 102 | $name = ucwords( str_replace( [ '_', '-' ], ' ', $permastructname ) ); 103 | /* translators: %s: permastruct name */ 104 | $description = sprintf( __( 'The permalink structure for %s', 'rewrite-rules-inspector' ), strtolower( $name ) ); 105 | 106 | // Apply special cases for common permastructs. 107 | $special_case = $this->get_special_case_permastruct( $permastructname ); 108 | if ( $special_case ) { 109 | $name = $special_case['name']; 110 | $description = $special_case['description']; 111 | } 112 | 113 | $permastructs[ $permastructname ] = [ 114 | 'name' => $name, 115 | 'structure' => $structure, 116 | 'description' => $description, 117 | ]; 118 | } 119 | 120 | return $permastructs; 121 | } 122 | 123 | /** 124 | * Extract structure from permastruct data. 125 | * 126 | * @since 1.5.0 127 | * @param mixed $permastruct Permastruct data. 128 | * @return string The permastruct structure. 129 | */ 130 | private function extract_permastruct_structure( $permastruct ): string { 131 | $structure = ''; 132 | if ( is_array( $permastruct ) ) { 133 | // Pre 3.4 compat. 134 | if ( count( $permastruct ) === 2 ) { 135 | $structure = $permastruct[0]; 136 | } else { 137 | $structure = $permastruct['struct'] ?? ''; 138 | } 139 | } else { 140 | $structure = $permastruct; 141 | } 142 | 143 | return $structure; 144 | } 145 | 146 | /** 147 | * Get special case permastruct information. 148 | * 149 | * @since 1.5.0 150 | * @param string $permastructname The permastruct name. 151 | * @return array|null Special case data or null. 152 | */ 153 | private function get_special_case_permastruct( string $permastructname ): ?array { 154 | $special_cases = [ 155 | 'category' => [ 156 | 'name' => __( 'Category Archive', 'rewrite-rules-inspector' ), 157 | 'description' => __( 'The permalink structure for category archives', 'rewrite-rules-inspector' ), 158 | ], 159 | 'post_tag' => [ 160 | 'name' => __( 'Tag Archive', 'rewrite-rules-inspector' ), 161 | 'description' => __( 'The permalink structure for tag archives', 'rewrite-rules-inspector' ), 162 | ], 163 | 'post_format' => [ 164 | 'name' => __( 'Post Format Archive', 'rewrite-rules-inspector' ), 165 | 'description' => __( 'The permalink structure for post format archives', 'rewrite-rules-inspector' ), 166 | ], 167 | 'test_custom' => [ 168 | 'name' => __( 'Test Custom (Demo)', 'rewrite-rules-inspector' ), 169 | 'description' => __( 'A custom permastruct added for testing the permastructs display feature', 'rewrite-rules-inspector' ), 170 | ], 171 | 'demo_archive' => [ 172 | 'name' => __( 'Demo Archive (Test)', 'rewrite-rules-inspector' ), 173 | 'description' => __( 'A demo archive permastruct with date-based structure for testing', 'rewrite-rules-inspector' ), 174 | ], 175 | ]; 176 | 177 | return $special_cases[ $permastructname ] ?? null; 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /src/Admin/ContextualHelp.php: -------------------------------------------------------------------------------- 1 | add_help_tab( 25 | [ 26 | 'id' => 'overview', 27 | 'title' => __( 'Overview', 'rewrite-rules-inspector' ), 28 | 'content' => '

' . __( 'The Rewrite Rules Inspector helps you understand and debug your WordPress site\'s URL structure. It shows you all the rewrite rules and permastructs that WordPress uses to handle URLs.', 'rewrite-rules-inspector' ) . '

', 29 | ] 30 | ); 31 | 32 | // Rewrite Rules tab. 33 | $screen->add_help_tab( 34 | [ 35 | 'id' => 'rewrite-rules', 36 | 'title' => __( 'Rewrite Rules', 'rewrite-rules-inspector' ), 37 | 'content' => '

' . __( 'Rewrite Rules are the actual URL patterns that WordPress uses to match incoming requests and determine what content to display.', 'rewrite-rules-inspector' ) . '

' . 38 | '

' . __( 'Each rule consists of:', 'rewrite-rules-inspector' ) . '

' . 39 | '' . 44 | '

' . __( 'When someone visits a URL, WordPress checks these rules in order until it finds a match, then executes the corresponding rewrite to determine what content to show.', 'rewrite-rules-inspector' ) . '

', 45 | ] 46 | ); 47 | 48 | // Permastructs tab. 49 | $screen->add_help_tab( 50 | [ 51 | 'id' => 'permastructs', 52 | 'title' => __( 'Permastructs', 'rewrite-rules-inspector' ), 53 | 'content' => '

' . __( 'Permastructs are the URL structure templates that define how different types of content should be accessed via URLs.', 'rewrite-rules-inspector' ) . '

' . 54 | '

' . __( 'For example:', 'rewrite-rules-inspector' ) . '

' . 55 | '' . 63 | '

' . __( 'WordPress uses these permastructs to generate the actual rewrite rules. The permastructs are like blueprints, while the rewrite rules are the specific patterns that get created from those blueprints.', 'rewrite-rules-inspector' ) . '

' . 64 | '

' . __( 'You can customize permastructs through WordPress settings (Settings → Permalinks) or by using WordPress functions like add_permastruct() in your theme or plugin.', 'rewrite-rules-inspector' ) . '

', 65 | ] 66 | ); 67 | 68 | // Troubleshooting tab. 69 | $screen->add_help_tab( 70 | [ 71 | 'id' => 'troubleshooting', 72 | 'title' => __( 'Troubleshooting', 'rewrite-rules-inspector' ), 73 | 'content' => '

' . __( 'Common Issues:', 'rewrite-rules-inspector' ) . '

' . 74 | '' . 80 | '

' . __( 'Tips:', 'rewrite-rules-inspector' ) . '

' . 81 | '', 86 | ] 87 | ); 88 | } 89 | 90 | /** 91 | * Set the help sidebar content. 92 | * 93 | * @since 1.5.0 94 | */ 95 | public function set_help_sidebar(): void { 96 | $screen = get_current_screen(); 97 | 98 | $screen->set_help_sidebar( 99 | '

' . __( 'For more information:', 'rewrite-rules-inspector' ) . '

' . 100 | '

' . __( 'WordPress Permalinks Documentation', 'rewrite-rules-inspector' ) . '

' . 101 | '

' . __( 'WordPress Rewrite API', 'rewrite-rules-inspector' ) . '

' . 102 | '

' . __( 'Plugin on GitHub', 'rewrite-rules-inspector' ) . '

' 103 | ); 104 | } 105 | 106 | /** 107 | * Add all help content to the current screen. 108 | * 109 | * @since 1.5.0 110 | */ 111 | public function add_help_content(): void { 112 | $this->add_help_tabs(); 113 | $this->set_help_sidebar(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/Core/RewriteRules.php: -------------------------------------------------------------------------------- 1 | generate_rules_by_source( $wp_rewrite ); 39 | 40 | // Apply the filters used in core just in case. 41 | foreach ( $rewrite_rules_by_source as $source => $rules ) { 42 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- core hook. 43 | $rewrite_rules_by_source[ $source ] = apply_filters( $source . '_rewrite_rules', $rules ); 44 | if ( 'post_tag' === $source ) { 45 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- core hook. 46 | $rewrite_rules_by_source[ $source ] = apply_filters( 'tag_rewrite_rules', $rules ); 47 | } 48 | } 49 | 50 | // Match rules with their sources. 51 | foreach ( $rewrite_rules as $rule => $rewrite ) { 52 | $rewrite_rules_array[ $rule ]['rewrite'] = $rewrite; 53 | foreach ( $rewrite_rules_by_source as $source => $rules ) { 54 | if ( array_key_exists( $rule, $rules ) ) { 55 | $rewrite_rules_array[ $rule ]['source'] = $source; 56 | } 57 | } 58 | 59 | if ( ! isset( $rewrite_rules_array[ $rule ]['source'] ) ) { 60 | $rewrite_rules_array[ $rule ]['source'] = apply_filters( 'rewrite_rules_inspector_source', 'other', $rule, $rewrite ); 61 | } 62 | } 63 | 64 | // Find any rewrite rules that should've been generated but weren't. 65 | $maybe_missing = $wp_rewrite->rewrite_rules(); 66 | $rewrite_rules_array = array_reverse( $rewrite_rules_array, true ); 67 | foreach ( $maybe_missing as $rule => $rewrite ) { 68 | if ( ! array_key_exists( $rule, $rewrite_rules_array ) ) { 69 | $rewrite_rules_array[ $rule ] = [ 70 | 'rewrite' => $rewrite, 71 | 'source' => 'missing', 72 | ]; 73 | } 74 | } 75 | 76 | // Prepend rules so it's obvious. 77 | $rewrite_rules_array = array_reverse( $rewrite_rules_array, true ); 78 | 79 | // Allow static sources of rewrite rules to override, etc. 80 | $rewrite_rules_array = apply_filters( 'rri_rewrite_rules', $rewrite_rules_array ); 81 | 82 | // Set the sources used in our filtering. 83 | $sources = [ 'all' ]; 84 | foreach ( $rewrite_rules_array as $rule => $data ) { 85 | $sources[] = $data['source']; 86 | } 87 | 88 | $this->sources = array_unique( $sources ); 89 | 90 | // Apply filtering based on search and source. 91 | $rewrite_rules_array = $this->apply_filters( $rewrite_rules_array ); 92 | 93 | return $rewrite_rules_array; 94 | } 95 | 96 | /** 97 | * Generate rewrite rules by source. 98 | * 99 | * @since 1.5.0 100 | * @param \WP_Rewrite $wp_rewrite WordPress rewrite object. 101 | * @return array Array of rules organized by source. 102 | */ 103 | private function generate_rules_by_source( \WP_Rewrite $wp_rewrite ): array { 104 | $rewrite_rules_by_source = []; 105 | 106 | // Core permastructs. 107 | $rewrite_rules_by_source['post'] = $wp_rewrite->generate_rewrite_rules( $wp_rewrite->permalink_structure, EP_PERMALINK ); 108 | $rewrite_rules_by_source['date'] = $wp_rewrite->generate_rewrite_rules( $wp_rewrite->get_date_permastruct(), EP_DATE ); 109 | $rewrite_rules_by_source['root'] = $wp_rewrite->generate_rewrite_rules( $wp_rewrite->root . '/', EP_ROOT ); 110 | $rewrite_rules_by_source['comments'] = $wp_rewrite->generate_rewrite_rules( $wp_rewrite->root . $wp_rewrite->comments_base, EP_COMMENTS, true, true, true, false ); 111 | $rewrite_rules_by_source['search'] = $wp_rewrite->generate_rewrite_rules( $wp_rewrite->get_search_permastruct(), EP_SEARCH ); 112 | $rewrite_rules_by_source['author'] = $wp_rewrite->generate_rewrite_rules( $wp_rewrite->get_author_permastruct(), EP_AUTHORS ); 113 | $rewrite_rules_by_source['page'] = $wp_rewrite->page_rewrite_rules(); 114 | 115 | // Extra permastructs including tags, categories, etc. 116 | foreach ( $wp_rewrite->extra_permastructs as $permastructname => $permastruct ) { 117 | if ( is_array( $permastruct ) ) { 118 | // Pre 3.4 compat. 119 | if ( count( $permastruct ) === 2 ) { 120 | $rewrite_rules_by_source[ $permastructname ] = $wp_rewrite->generate_rewrite_rules( $permastruct[0], $permastruct[1] ); 121 | } else { 122 | $rewrite_rules_by_source[ $permastructname ] = $wp_rewrite->generate_rewrite_rules( $permastruct['struct'], $permastruct['ep_mask'], $permastruct['paged'], $permastruct['feed'], $permastruct['forcomments'], $permastruct['walk_dirs'], $permastruct['endpoints'] ); 123 | } 124 | } else { 125 | $rewrite_rules_by_source[ $permastructname ] = $wp_rewrite->generate_rewrite_rules( $permastruct, EP_NONE ); 126 | } 127 | } 128 | 129 | return $rewrite_rules_by_source; 130 | } 131 | 132 | /** 133 | * Apply search and source filters to rules. 134 | * 135 | * @since 1.5.0 136 | * @param array $rewrite_rules_array Array of rewrite rules. 137 | * @return array Filtered array of rewrite rules. 138 | */ 139 | private function apply_filters( array $rewrite_rules_array ): array { 140 | $match_path = $this->get_search_path(); 141 | 142 | $should_filter_by_source = ! empty( $_GET['source'] ) && 'all' !== $_GET['source'] && in_array( $_GET['source'], $this->sources, true ); 143 | 144 | // Filter based on match or source if necessary. 145 | foreach ( $rewrite_rules_array as $rule => $data ) { 146 | // If we're searching rules based on URL and there's no match, don't return it. 147 | if ( $match_path !== '' && $match_path !== '0' && ! preg_match( sprintf( '#^%s#', $rule ), $match_path ) ) { 148 | unset( $rewrite_rules_array[ $rule ] ); 149 | } elseif ( $should_filter_by_source && $data['source'] !== $_GET['source'] ) { 150 | unset( $rewrite_rules_array[ $rule ] ); 151 | } 152 | } 153 | 154 | return $rewrite_rules_array; 155 | } 156 | 157 | /** 158 | * Get the search path from URL parameter. 159 | * 160 | * @since 1.5.0 161 | * @return string The search path. 162 | */ 163 | private function get_search_path(): string { 164 | $match_path = ''; 165 | 166 | if ( ! empty( $_GET['s'] ) ) { 167 | $input = sanitize_text_field( $_GET['s'] ); 168 | 169 | // If the input doesn't start with http:// or https://, treat it as a path. 170 | if ( ! preg_match( '/^https?:\/\//', $input ) ) { 171 | $match_path = $input; 172 | } else { 173 | $match_path = wp_parse_url( esc_url( $input ), PHP_URL_PATH ); 174 | } 175 | 176 | // Ensure we have a string value. 177 | if ( null === $match_path ) { 178 | $match_path = ''; 179 | } 180 | 181 | $wordpress_subdir_for_site = wp_parse_url( home_url(), PHP_URL_PATH ); 182 | if ( ! empty( $wordpress_subdir_for_site ) ) { 183 | $match_path = str_replace( $wordpress_subdir_for_site, '', $match_path ); 184 | } 185 | 186 | $match_path = ltrim( $match_path, '/' ); 187 | } 188 | 189 | return $match_path; 190 | } 191 | 192 | /** 193 | * Get available sources for filtering. 194 | * 195 | * @since 1.5.0 196 | * @return array Array of available sources. 197 | */ 198 | public function get_sources(): array { 199 | return $this->sources; 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /src/Plugin.php: -------------------------------------------------------------------------------- 1 | initialize_services(); 116 | } 117 | 118 | /** 119 | * Initialize all services. 120 | * 121 | * @since 1.5.0 122 | */ 123 | private function initialize_services(): void { 124 | $this->rewrite_rules_service = new RewriteRules(); 125 | $this->permastruct_service = new Permastructs(); 126 | $this->file_export_service = new FileExport( $this->view_cap ); 127 | $this->rule_flush_service = new RuleFlush( $this->flushing_enabled, $this->view_cap ); 128 | $this->url_tester_service = new UrlTester(); 129 | $this->view_renderer = new ViewRenderer( plugin_dir_path( __DIR__ ) ); 130 | $this->help_service = new ContextualHelp(); 131 | $this->admin_page = new AdminPage( $this->parent_slug, $this->page_slug, $this->view_cap, [ $this, 'view_rules' ], $this->help_service ); 132 | } 133 | 134 | /** 135 | * Run the integration. 136 | * 137 | * @since 1.3.0 138 | */ 139 | public function run(): void { 140 | // This plugin only runs in the admin, but we need it initialized on init. 141 | add_action( 'init', [ $this, 'action_init' ] ); 142 | 143 | // Register and enqueue admin styles. 144 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_styles' ] ); 145 | 146 | } 147 | 148 | /** 149 | * Initialize the plugin. 150 | * 151 | * @since 1.0.0 152 | */ 153 | public function action_init(): void { 154 | if ( ! is_admin() ) { 155 | return; 156 | } 157 | 158 | // Allow the view to be placed elsewhere than tools.php. 159 | $this->parent_slug = apply_filters( 'rri_parent_slug', $this->parent_slug ); 160 | 161 | // Whether or not users can flush the rewrite rules from this tool. 162 | $this->flushing_enabled = apply_filters( 'rri_flushing_enabled', $this->flushing_enabled ); 163 | 164 | // Re-initialize services with updated settings. 165 | $this->initialize_services(); 166 | 167 | // Register admin page. 168 | $this->admin_page->register(); 169 | 170 | // User actions available for the rewrite rules page. 171 | if ( isset( $_GET['page'], $_GET['action'] ) && $_GET['page'] === $this->page_slug && 'download-rules' === $_GET['action'] ) { 172 | add_action( 'admin_init', [ $this, 'download_rules' ] ); 173 | } elseif ( isset( $_GET['page'], $_GET['action'] ) && $_GET['page'] === $this->page_slug && 'flush-rules' === $_GET['action'] ) { 174 | add_action( 'admin_init', [ $this, 'flush_rules' ] ); 175 | } 176 | } 177 | 178 | /** 179 | * Enqueue admin styles and scripts for the rewrite rules inspector page. 180 | * 181 | * @since 1.5.0 182 | * @param string $hook_suffix The current admin page hook suffix. 183 | */ 184 | public function enqueue_admin_styles( string $hook_suffix ): void { 185 | // Only enqueue on our admin page. 186 | if ( 'tools_page_' . $this->page_slug !== $hook_suffix ) { 187 | return; 188 | } 189 | 190 | $css_url = plugin_dir_url( __DIR__ ) . 'assets/css/admin.css'; 191 | $js_url = plugin_dir_url( __DIR__ ) . 'assets/js/admin.js'; 192 | $version = REWRITE_RULES_INSPECTOR_VERSION; 193 | 194 | // Enqueue styles. 195 | wp_enqueue_style( 196 | 'rewrite-rules-inspector-admin', 197 | $css_url, 198 | [], 199 | $version 200 | ); 201 | 202 | // Enqueue scripts. 203 | wp_enqueue_script( 204 | 'rewrite-rules-inspector-admin', 205 | $js_url, 206 | [ 'jquery' ], 207 | $version, 208 | true 209 | ); 210 | } 211 | 212 | /** 213 | * View the rewrite rules for the site. 214 | * 215 | * @since 1.0.0 216 | */ 217 | public function view_rules(): void { 218 | $rules = $this->rewrite_rules_service->get_rules(); 219 | $sources = $this->rewrite_rules_service->get_sources(); 220 | $permastructs = $this->permastruct_service->get_permastructs(); 221 | 222 | $wp_list_table = new RewriteRulesTable( $rules, $sources, $this->flushing_enabled ); 223 | $wp_list_table->prepare_items(); 224 | 225 | // Test URL if one is provided. 226 | $url_test_results = null; 227 | if ( ! empty( $_GET['s'] ) ) { 228 | $url = sanitize_text_field( $_GET['s'] ); 229 | // Use the same filtered rules for URL testing to ensure consistency. 230 | $url_test_results = $this->url_tester_service->test_url_with_rules( $url, $rules ); 231 | } 232 | $flush_success = ( isset( $_GET['message'] ) && 'flush-success' === $_GET['message'] ); 233 | 234 | $this->view_renderer->render_rules_view( $rules, $permastructs, $wp_list_table, $url_test_results, $flush_success ); 235 | } 236 | 237 | /** 238 | * Process a user's request to download a set of the rewrite rules. 239 | * 240 | * @since 1.0.0 241 | */ 242 | public function download_rules(): void { 243 | $rules = $this->rewrite_rules_service->get_rules(); 244 | $this->file_export_service->download_rules( $rules ); 245 | } 246 | 247 | /** 248 | * Allow a user to flush rewrite rules for their site. 249 | * 250 | * @since 1.0.0 251 | */ 252 | public function flush_rules(): void { 253 | global $plugin_page; 254 | $redirect_url = menu_page_url( $plugin_page, false ); 255 | $this->rule_flush_service->flush_rules( $redirect_url ); 256 | } 257 | 258 | 259 | /** 260 | * Get the URL tester service. 261 | * 262 | * @since 1.5.0 263 | * @return UrlTester The URL tester service. 264 | */ 265 | public function get_url_tester(): UrlTester { 266 | return $this->url_tester_service; 267 | } 268 | } 269 | -------------------------------------------------------------------------------- /src/Admin/RewriteRulesTable.php: -------------------------------------------------------------------------------- 1 | items = $rules; 45 | $this->sources = $sources; 46 | $this->flushing_enabled = $flushing_enabled; 47 | 48 | parent::__construct( 49 | [ 50 | 'plural' => 'Rewrite Rules', 51 | ] 52 | ); 53 | } 54 | 55 | /** 56 | * Load all of the matching rewrite rules into our list table. 57 | * 58 | * @since 1.0.0 59 | */ 60 | public function prepare_items() { 61 | $columns = $this->get_columns(); 62 | $hidden = []; 63 | $sortable = []; 64 | $this->_column_headers = [ $columns, $hidden, $sortable ]; 65 | } 66 | 67 | /** 68 | * What to print when no items were found. 69 | * 70 | * @since 1.0.0 71 | */ 72 | public function no_items() { 73 | esc_html_e( 'No rewrite rules were found.', 'rewrite-rules-inspector' ); 74 | } 75 | 76 | /** 77 | * Display the list of views available on this table. 78 | * 79 | * @since 1.0.0 80 | */ 81 | public function get_views(): array { 82 | return []; 83 | } 84 | 85 | /** 86 | * Display the search box. 87 | * 88 | * @since 1.0.0 89 | * @param string $text The 'submit' button label. 90 | * @param string $input_id ID attribute value for the search input field. 91 | */ 92 | public function search_box( $text, $input_id ) { 93 | // This is intentionally empty since we have a custom search box. 94 | } 95 | 96 | /** 97 | * Display the pagination. 98 | * 99 | * @since 1.0.0 100 | * @param string $which The location of the pagination: 'top' or 'bottom'. 101 | */ 102 | protected function pagination( $which ) { 103 | // This is intentionally empty since we don't paginate. 104 | } 105 | 106 | /** 107 | * Display a view switcher. 108 | * 109 | * @since 1.0.0 110 | * @param string $current_mode The current view mode. 111 | */ 112 | protected function view_switcher( $current_mode ) { 113 | // This is intentionally empty since we don't have view modes. 114 | } 115 | 116 | /** 117 | * Display the bulk actions dropdown. 118 | * 119 | * @since 1.0.0 120 | * @param string $which The location of the bulk actions: 'top' or 'bottom'. 121 | */ 122 | protected function bulk_actions( $which = '' ) { 123 | // This is intentionally empty since we don't have bulk actions. 124 | } 125 | 126 | /** 127 | * Display the list table. 128 | * 129 | * @since 1.0.0 130 | */ 131 | public function display() { 132 | $this->display_tablenav( 'top' ); 133 | 134 | // Only show the table if there are items to display 135 | if ( $this->has_items() ) { 136 | ?> 137 | 138 | 139 | 140 | print_column_headers(); ?> 141 | 142 | 143 | 144 | > 145 | display_rows_or_placeholder(); ?> 146 | 147 | 148 | 149 | 150 | print_column_headers( false ); ?> 151 | 152 | 153 |
154 | display_tablenav( 'bottom' ); 158 | } 159 | 160 | /** 161 | * Display the table navigation. 162 | * 163 | * @since 1.0.0 164 | * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. 165 | */ 166 | protected function display_tablenav( $which ) { 167 | if ( 'top' !== $which ) { 168 | return; 169 | } 170 | 171 | global $plugin_page; 172 | $search = empty( $_GET['s'] ) ? '' : sanitize_text_field( $_GET['s'] ); 173 | ?> 174 |
175 |
176 | items ); 179 | $has_url_filter = ! empty( $_GET['s'] ); 180 | $has_source_filter = isset( $_GET['source'] ) && 'all' !== $_GET['source']; 181 | 182 | if ( $has_url_filter || $has_source_filter ) { 183 | $count_text = sprintf( 184 | /* translators: %d: Number of rules */ 185 | _n( '%d rule for this selection', '%d rules for this selection', $count, 'rewrite-rules-inspector' ), 186 | $count 187 | ); 188 | } else { 189 | $count_text = sprintf( 190 | /* translators: %d: Number of rules */ 191 | _n( '%d rule total', '%d rules total', $count, 'rewrite-rules-inspector' ), 192 | $count 193 | ); 194 | } 195 | ?> 196 | 197 | 198 | flushing_enabled ) : 201 | ?> 202 | 'flush-rules', 206 | '_wpnonce' => wp_create_nonce( 'flush-rules' ), 207 | ]; 208 | 209 | $args['source'] = 'all'; 210 | if ( isset( $_GET['source'] ) && in_array( $_GET['source'], $this->sources, true ) ) { 211 | $args['source'] = sanitize_key( $_GET['source'] ); 212 | } 213 | 214 | $args['s'] = empty( $_GET['s'] ) ? '' : sanitize_text_field( $_GET['s'] ); 215 | 216 | $flush_url = add_query_arg( $args, menu_page_url( $plugin_page, false ) ); 217 | ?> 218 | 219 | 'download-rules', 225 | '_wpnonce' => wp_create_nonce( 'download-rules' ), 226 | ]; 227 | 228 | $args['source'] = 'all'; 229 | if ( isset( $_GET['source'] ) && in_array( $_GET['source'], $this->sources, true ) ) { 230 | $args['source'] = sanitize_key( $_GET['source'] ); 231 | } 232 | 233 | $args['s'] = empty( $_GET['s'] ) ? '' : sanitize_text_field( $_GET['s'] ); 234 | 235 | $download_url = add_query_arg( $args, menu_page_url( $plugin_page, false ) ); 236 | ?> 237 | 238 |
239 |
240 |
241 | 242 | 243 | 244 | 245 | 259 | 260 | 261 | 262 | 263 |
264 |
265 |
266 | 'Title' 272 | * 273 | * @since 1.0.0 274 | * @return array 275 | */ 276 | public function get_columns(): array { 277 | return [ 278 | 'priority' => __( 'Priority', 'rewrite-rules-inspector' ), 279 | 'rule' => __( 'Rule', 'rewrite-rules-inspector' ), 280 | 'rewrite' => __( 'Rewrite', 'rewrite-rules-inspector' ), 281 | 'source' => __( 'Source', 'rewrite-rules-inspector' ), 282 | ]; 283 | } 284 | 285 | /** 286 | * Display the rows. 287 | * 288 | * @since 1.0.0 289 | */ 290 | public function display_rows() { 291 | $priority = 1; 292 | foreach ( $this->items as $rule => $data ) { 293 | $this->single_row( [ $rule, $data, $priority ] ); 294 | $priority++; 295 | } 296 | } 297 | 298 | /** 299 | * Display a single row. 300 | * 301 | * @since 1.0.0 302 | * @param array $item The current row's data. 303 | */ 304 | public function single_row( $item ) { 305 | [ $rule, $data, $priority ] = $item; 306 | ?> 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | ' . esc_html__( 'missing', 'rewrite-rules-inspector' ) . ''; 321 | } else { 322 | echo esc_html( $data['source'] ); 323 | } 324 | ?> 325 | 326 | 327 | $data ) { 46 | $rewrite = is_array( $data ) ? $data['rewrite'] : $data; 47 | 48 | if ( preg_match( sprintf( '#^%s#', $rule ), $path, $rule_matches ) ) { 49 | $match_info = [ 50 | 'rule' => $rule, 51 | 'rewrite' => $rewrite, 52 | 'matches' => $rule_matches, 53 | 'query_vars' => $this->extract_query_vars( $rewrite, $rule_matches ), 54 | 'source' => is_array( $data ) ? ( $data['source'] ?? 'other' ) : 'other', 55 | ]; 56 | 57 | $matches[] = $match_info; 58 | 59 | // The first match is the one WordPress would use. 60 | if ( null === $first_match ) { 61 | $first_match = $match_info; 62 | } 63 | } 64 | } 65 | 66 | // Determine if this would result in a 404. 67 | $is_404 = empty( $matches ); 68 | 69 | // Get the final query that WordPress would execute. 70 | $final_query = null; 71 | if ( $first_match ) { 72 | $final_query = $this->build_final_query( $first_match['rewrite'], $first_match['matches'] ); 73 | } 74 | 75 | return [ 76 | 'url' => $url, 77 | 'path' => $path, 78 | 'is_404' => $is_404, 79 | 'matches' => $matches, 80 | 'first_match' => $first_match, 81 | 'final_query' => $final_query, 82 | 'total_rules_tested' => count( $rules ), 83 | ]; 84 | } 85 | 86 | /** 87 | * Test a URL against all rewrite rules and return detailed match information. 88 | * 89 | * @since 1.5.0 90 | * @param string $url The URL to test. 91 | * @return array Detailed test results. 92 | */ 93 | public function test_url( string $url ): array { 94 | global $wp_rewrite; 95 | 96 | // Parse the URL to get the path component. 97 | $parsed_url = wp_parse_url( $url ); 98 | $path = $parsed_url['path'] ?? '/'; 99 | 100 | // If wp_parse_url returns null for path, treat the input as a path. 101 | if ( null === $parsed_url['path'] && ! preg_match( '/^https?:\/\//', $url ) ) { 102 | $path = $url; 103 | } 104 | 105 | // Remove WordPress subdirectory if the site is in a subdirectory. 106 | $home_path = wp_parse_url( home_url(), PHP_URL_PATH ); 107 | if ( ! empty( $home_path ) ) { 108 | $path = str_replace( $home_path, '', $path ); 109 | } 110 | 111 | $path = ltrim( $path, '/' ); 112 | 113 | // Get all rewrite rules using the same method as RewriteRules service. 114 | $rewrite_rules = get_option( 'rewrite_rules' ); 115 | if ( ! $rewrite_rules ) { 116 | $rewrite_rules = []; 117 | } 118 | 119 | // Also check for missing rules that should be generated. 120 | $maybe_missing = $wp_rewrite->rewrite_rules(); 121 | foreach ( $maybe_missing as $rule => $rewrite ) { 122 | if ( ! array_key_exists( $rule, $rewrite_rules ) ) { 123 | $rewrite_rules[ $rule ] = $rewrite; 124 | } 125 | } 126 | 127 | // Test against each rule and collect matches. 128 | $matches = []; 129 | $first_match = null; 130 | 131 | foreach ( $rewrite_rules as $rule => $rewrite ) { 132 | if ( preg_match( sprintf( '#^%s#', $rule ), $path, $rule_matches ) ) { 133 | $match_info = [ 134 | 'rule' => $rule, 135 | 'rewrite' => $rewrite, 136 | 'matches' => $rule_matches, 137 | 'query_vars' => $this->extract_query_vars( $rewrite, $rule_matches ), 138 | 'source' => $this->get_rule_source( $rule, $rewrite ), 139 | ]; 140 | 141 | $matches[] = $match_info; 142 | 143 | // The first match is the one WordPress would use. 144 | if ( null === $first_match ) { 145 | $first_match = $match_info; 146 | } 147 | } 148 | } 149 | 150 | // Determine if this would result in a 404. 151 | $is_404 = empty( $matches ); 152 | 153 | // Get the final query that WordPress would execute. 154 | $final_query = null; 155 | if ( $first_match ) { 156 | $final_query = $this->build_final_query( $first_match['rewrite'], $first_match['matches'] ); 157 | } 158 | 159 | return [ 160 | 'url' => $url, 161 | 'path' => $path, 162 | 'is_404' => $is_404, 163 | 'matches' => $matches, 164 | 'first_match' => $first_match, 165 | 'final_query' => $final_query, 166 | 'total_rules_tested' => count( $rewrite_rules ), 167 | ]; 168 | } 169 | 170 | /** 171 | * Extract query variables from a rewrite rule. 172 | * 173 | * @since 1.5.0 174 | * @param string $rewrite The rewrite rule. 175 | * @param array $matches The regex matches. 176 | * @return array Extracted query variables. 177 | */ 178 | private function extract_query_vars( string $rewrite, array $matches ): array { 179 | $query_vars = []; 180 | 181 | // Parse the rewrite rule to find query variable assignments. 182 | if ( preg_match_all( '/([^=&]+)=([^&]+)/', $rewrite, $var_matches, PREG_SET_ORDER ) ) { 183 | foreach ( $var_matches as $var_match ) { 184 | $key = $var_match[1]; 185 | $value = $var_match[2]; 186 | 187 | // Replace $matches[n] with actual values. 188 | $value = preg_replace_callback( 189 | '/\$matches\[(\d+)\]/', 190 | function ( $m ) use ( $matches ) { 191 | $index = (int) $m[1]; 192 | return isset( $matches[ $index ] ) && $matches[ $index ] !== '' ? $matches[ $index ] : ''; 193 | }, 194 | $value 195 | ); 196 | 197 | $query_vars[ $key ] = $value; 198 | } 199 | } 200 | 201 | return $query_vars; 202 | } 203 | 204 | /** 205 | * Get the source of a rewrite rule. 206 | * 207 | * @since 1.5.0 208 | * @param string $rule The rewrite rule pattern. 209 | * @param string $rewrite The rewrite rule target. 210 | * @return string The rule source. 211 | */ 212 | private function get_rule_source( string $rule, string $rewrite ): string { 213 | // This is a simplified version - in a full implementation, 214 | // you'd want to use the same logic as RewriteRules::generate_rules_by_source() 215 | // to determine the actual source. 216 | 217 | // Common patterns to identify sources. 218 | if ( strpos( $rewrite, 'category_name' ) !== false ) { 219 | return 'category'; 220 | } 221 | if ( strpos( $rewrite, 'tag=' ) !== false ) { 222 | return 'post_tag'; 223 | } 224 | if ( strpos( $rewrite, 'p=' ) !== false ) { 225 | return 'post'; 226 | } 227 | if ( strpos( $rewrite, 'page_id' ) !== false ) { 228 | return 'page'; 229 | } 230 | if ( strpos( $rewrite, 'author_name' ) !== false ) { 231 | return 'author'; 232 | } 233 | if ( strpos( $rewrite, 'year=' ) !== false ) { 234 | return 'date'; 235 | } 236 | 237 | return 'other'; 238 | } 239 | 240 | /** 241 | * Build the final query string that WordPress would execute. 242 | * 243 | * @since 1.5.0 244 | * @param string $rewrite The rewrite rule. 245 | * @param array $matches The regex matches. 246 | * @return string The final query string. 247 | */ 248 | private function build_final_query( string $rewrite, array $matches ): string { 249 | // Replace $matches[n] with actual values. 250 | $query = preg_replace_callback( 251 | '/\$matches\[(\d+)\]/', 252 | function ( $m ) use ( $matches ) { 253 | $index = (int) $m[1]; 254 | return isset( $matches[ $index ] ) && $matches[ $index ] !== '' ? $matches[ $index ] : ''; 255 | }, 256 | $rewrite 257 | ); 258 | 259 | return $query; 260 | } 261 | 262 | /** 263 | * Get a human-readable explanation of the test results. 264 | * 265 | * @since 1.5.0 266 | * @param array $results The test results from test_url(). 267 | * @return string Human-readable explanation. 268 | */ 269 | public function explain_results( array $results ): string { 270 | if ( $results['is_404'] ) { 271 | return sprintf( 272 | /* translators: %1$s: URL, %2$d: Number of rules tested */ 273 | __( 'The URL "%1$s" does not match any of the %2$d rewrite rules and would result in a 404 error.', 'rewrite-rules-inspector' ), 274 | $results['url'], 275 | $results['total_rules_tested'] 276 | ); 277 | } 278 | 279 | $match_count = count( $results['matches'] ); 280 | $first_match = $results['first_match']; 281 | 282 | if ( $match_count === 1 ) { 283 | return sprintf( 284 | /* translators: %1$s: URL, %2$s: Rule pattern */ 285 | __( 'The URL "%1$s" matches exactly one rewrite rule: %2$s', 'rewrite-rules-inspector' ), 286 | $results['url'], 287 | $first_match['rule'] 288 | ); 289 | } 290 | 291 | return sprintf( 292 | /* translators: %1$s: URL, %2$d: Number of matches, %3$s: First matching rule */ 293 | __( 'The URL "%1$s" matches %2$d rewrite rules. The first match (which WordPress will use) is: %3$s', 'rewrite-rules-inspector' ), 294 | $results['url'], 295 | $match_count, 296 | $first_match['rule'] 297 | ); 298 | } 299 | 300 | /** 301 | * Format test results for CLI output. 302 | * 303 | * @since 1.5.0 304 | * @param array $results The test results from test_url(). 305 | * @param bool $verbose Whether to include verbose output. 306 | * @return string Formatted CLI output. 307 | */ 308 | public function format_for_cli( array $results, bool $verbose = false ): string { 309 | $output = []; 310 | 311 | $output[] = sprintf( 'Testing URL: %s', $results['url'] ); 312 | $output[] = sprintf( 'Path tested: %s', $results['path'] ); 313 | $output[] = ''; 314 | 315 | if ( $results['is_404'] ) { 316 | $output[] = '❌ Result: 404 (No matching rules found)'; 317 | $output[] = sprintf( 'Tested against %d rewrite rules', $results['total_rules_tested'] ); 318 | } else { 319 | $output[] = '✅ Result: Found matching rule(s)'; 320 | $output[] = sprintf( 'Total matches: %d', count( $results['matches'] ) ); 321 | $output[] = ''; 322 | 323 | $first_match = $results['first_match']; 324 | $output[] = 'First match (WordPress will use this):'; 325 | $output[] = sprintf( ' Rule: %s', $first_match['rule'] ); 326 | $output[] = sprintf( ' Rewrite: %s', $first_match['rewrite'] ); 327 | $output[] = sprintf( ' Source: %s', $first_match['source'] ); 328 | 329 | if ( $verbose && ! empty( $first_match['query_vars'] ) ) { 330 | $output[] = ' Query variables:'; 331 | foreach ( $first_match['query_vars'] as $key => $value ) { 332 | $output[] = sprintf( ' %s = %s', $key, $value ); 333 | } 334 | } 335 | 336 | if ( $verbose && count( $results['matches'] ) > 1 ) { 337 | $output[] = ''; 338 | $output[] = 'All matching rules:'; 339 | foreach ( $results['matches'] as $index => $match ) { 340 | $output[] = sprintf( ' %d. %s (source: %s)', $index + 1, $match['rule'], $match['source'] ); 341 | } 342 | } 343 | } 344 | 345 | return implode( "\n", $output ); 346 | } 347 | } 348 | -------------------------------------------------------------------------------- /src/Admin/ViewRenderer.php: -------------------------------------------------------------------------------- 1 | plugin_dir_path = $plugin_dir_path; 30 | } 31 | 32 | /** 33 | * Render the main rules view. 34 | * 35 | * @since 1.5.0 36 | * @param array $rules Array of rewrite rules. 37 | * @param array $permastructs Array of permastructs. 38 | * @param object $wp_list_table WordPress list table object. 39 | * @param array $url_test_results Optional URL test results. 40 | */ 41 | public function render_rules_view( array $rules, array $permastructs, $wp_list_table, ?array $url_test_results = null, bool $flush_success = false ): void { 42 | // Bump view stats or do something else on page load. 43 | do_action( 'rri_view_rewrite_rules', $rules ); 44 | 45 | // Determine current tab. 46 | $has_permastructs = ! empty( $permastructs ); 47 | $default_tab = 'rules'; 48 | $current_tab = isset( $_GET['tab'] ) ? sanitize_key( (string) $_GET['tab'] ) : $default_tab; 49 | if ( ! $has_permastructs && 'permastructs' === $current_tab ) { 50 | $current_tab = $default_tab; 51 | } 52 | 53 | ?> 54 |
55 |

56 | 57 | 80 | 81 | 82 |
83 |

84 | 85 | render_flush_success_message(); ?> 86 | 87 | render_rules_messages( $rules ); ?> 88 | 89 | render_url_test_results( $url_test_results ); ?> 90 | 91 | display(); ?> 92 |
93 | 94 |
95 |

96 | render_permastructs_table( $permastructs ); ?> 97 |
98 | 99 |
100 |

' . wp_kses_post( $error_message ) . '

'; 124 | } 125 | } elseif ( $missing_count > 0 ) { 126 | /* translators: %d: Count of missing rewrite rules */ 127 | $error_message = apply_filters( 'rri_message_missing_rules', sprintf( _n( '%d rewrite rule may be missing, try flushing.', '%d rewrite rules may be missing, try flushing.', $missing_count, 'rewrite-rules-inspector' ), $missing_count ) ); 128 | echo '

' . wp_kses_post( $error_message ) . '

'; 129 | } 130 | } 131 | 132 | 133 | /** 134 | * Render the permastructs table. 135 | * 136 | * @since 1.5.0 137 | * @param array $permastructs Array of permastructs. 138 | */ 139 | private function render_permastructs_table( array $permastructs ): void { 140 | $template_path = $this->plugin_dir_path . 'views/permastructs-table.php'; 141 | if ( file_exists( $template_path ) ) { 142 | include $template_path; 143 | } 144 | } 145 | 146 | /** 147 | * Render URL test results. 148 | * 149 | * @since 1.5.0 150 | * @param array $results URL test results. 151 | */ 152 | private function render_url_test_results( array $results ): void { 153 | ?> 154 |
155 |

156 | 157 |
158 |

159 |

160 | 161 | 166 |
167 |

168 |
169 | 0 && ! $is_special_url ) : ?> 176 |
177 |

178 |

185 |
186 | 0 && $is_special_url ) : ?> 187 |
188 |

189 |

196 |
197 | 198 | 199 | 200 | 201 | 202 |
203 |

204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 246 | 247 | 248 |
221 | ' . esc_html( $query_string ) . ''; 232 | } else { 233 | // Array format - show key-value pairs, removing index.php? prefix from keys 234 | foreach ( $query_vars as $key => $value ) : 235 | // Remove index.php? prefix from key if present 236 | $clean_key = $key; 237 | if ( strpos( $key, 'index.php?' ) === 0 ) { 238 | $clean_key = substr( $key, 10 ); 239 | } 240 | ?> 241 | =
242 | 245 |
249 |
250 | 251 | 252 | 1 ) : ?> 253 |
254 |

255 |

262 |
263 | 264 | 265 |
266 |
267 |

' . esc_html__( 'Rewrite rules flushed.', 'rewrite-rules-inspector' ) . '

'; 277 | } 278 | } 279 | -------------------------------------------------------------------------------- /assets/css/admin.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Rewrite Rules Inspector Admin Styles 3 | * 4 | * @package automattic\rewrite-rules-inspector 5 | * @since 1.5.0 6 | */ 7 | 8 | /* ========================================================================== 9 | CSS Custom Properties (Variables) 10 | ========================================================================== */ 11 | 12 | :root { 13 | --rri-primary-color: #0073aa; 14 | --rri-border-color: #c3c4c7; 15 | --rri-background-light: #f6f7f7; 16 | --rri-text-color: #1d2327; 17 | --rri-border-radius: 4px; 18 | --rri-spacing-xs: 4px; 19 | --rri-spacing-sm: 8px; 20 | --rri-spacing-md: 16px; 21 | --rri-spacing-xl: 32px; 22 | } 23 | 24 | /* ========================================================================== 25 | Layout and Structure 26 | ========================================================================== */ 27 | 28 | .rri-admin-page { 29 | max-width: 100%; 30 | } 31 | 32 | .rri-section { 33 | margin-bottom: var(--rri-spacing-xl); 34 | } 35 | 36 | /* ========================================================================== 37 | Tabs 38 | ========================================================================== */ 39 | /* WordPress provides base styles for .nav-tab-wrapper and .nav-tab */ 40 | .nav-tab-wrapper { 41 | margin-bottom: 12px; 42 | } 43 | 44 | /* ========================================================================== 45 | Rewrite Rules Table Styles 46 | ========================================================================== */ 47 | 48 | #the-list tr.type-sunrise, 49 | #the-list tr.type-custom { 50 | background-color: #eec7f0; 51 | transition: background-color 0.2s ease; 52 | } 53 | 54 | #the-list tr.type-sunrise:hover, 55 | #the-list tr.type-custom:hover { 56 | background-color: #e6b8e8; 57 | } 58 | 59 | #the-list tr.type-sunrise td, 60 | #the-list tr.type-custom td { 61 | border-top-color: #f4e6f5; 62 | border-bottom-color: #efbbf2; 63 | } 64 | 65 | #the-list tr.source-missing { 66 | background-color: #f7a8a9; 67 | transition: background-color 0.2s ease; 68 | } 69 | 70 | #the-list tr.source-missing:hover { 71 | background-color: #f48a8c; 72 | } 73 | 74 | #the-list tr.type-missing td { 75 | border-top-color: #fecfd0; 76 | border-bottom-color: #f99b9d; 77 | } 78 | 79 | /* ========================================================================== 80 | Permastructs Section Styles 81 | ========================================================================== */ 82 | 83 | #permastructs-section { 84 | margin-top: var(--rri-spacing-xl); 85 | } 86 | 87 | .permastructs-table-wrapper { 88 | overflow-x: auto; 89 | margin-top: var(--rri-spacing-md); 90 | } 91 | 92 | .permastructs-table { 93 | margin-top: 0; 94 | } 95 | 96 | .permastruct-structure { 97 | font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; 98 | background: var(--rri-background-light); 99 | padding: var(--rri-spacing-xs) var(--rri-spacing-sm); 100 | border-radius: var(--rri-border-radius); 101 | font-size: 13px; 102 | border: 1px solid var(--rri-border-color); 103 | display: inline-block; 104 | max-width: 100%; 105 | word-break: break-all; 106 | transition: all 0.2s ease; 107 | } 108 | 109 | .permastruct-structure:hover { 110 | background: #e8e9ea; 111 | border-color: var(--rri-primary-color); 112 | } 113 | 114 | /* ========================================================================== 115 | List Table Navigation Styles 116 | ========================================================================== */ 117 | 118 | .custom-tablenav-top { 119 | padding: var(--rri-spacing-sm) 0; 120 | } 121 | 122 | .custom-tablenav-top .tablenav-actions { 123 | float: right; 124 | display: flex; 125 | align-items: center; 126 | gap: var(--rri-spacing-sm); 127 | } 128 | 129 | .rri-rules-count { 130 | color: #666; 131 | font-size: 13px; 132 | margin-right: var(--rri-spacing-sm); 133 | } 134 | 135 | /* Priority column should be narrow */ 136 | .column-priority { 137 | width: 60px; 138 | text-align: center; 139 | } 140 | 141 | .custom-tablenav-top form { 142 | display: inline-block; 143 | margin-right: var(--rri-spacing-md); 144 | vertical-align: middle; 145 | } 146 | 147 | .custom-tablenav-top form > * { 148 | margin-right: var(--rri-spacing-xs); 149 | } 150 | 151 | .custom-tablenav-top form > *:last-child { 152 | margin-right: 0; 153 | } 154 | 155 | .custom-tablenav-top label { 156 | font-weight: 600; 157 | color: var(--rri-text-color); 158 | vertical-align: middle; 159 | } 160 | 161 | .custom-tablenav-top input[type="text"], 162 | .custom-tablenav-top select, 163 | .custom-tablenav-top .button { 164 | height: 28px; 165 | padding: 0 8px; 166 | border: 1px solid var(--rri-border-color); 167 | border-radius: var(--rri-border-radius); 168 | font-size: 13px; 169 | line-height: 26px; 170 | vertical-align: middle; 171 | box-sizing: border-box; 172 | } 173 | 174 | .custom-tablenav-top select { 175 | min-width: 120px; 176 | } 177 | 178 | .custom-tablenav-top input[type="text"]:focus, 179 | .custom-tablenav-top select:focus { 180 | border-color: var(--rri-primary-color); 181 | outline: none; 182 | box-shadow: 0 0 0 1px var(--rri-primary-color); 183 | } 184 | 185 | .custom-tablenav-top .button { 186 | display: inline-block; 187 | text-decoration: none; 188 | text-align: center; 189 | cursor: pointer; 190 | background: #f6f7f7; 191 | color: var(--rri-text-color); 192 | } 193 | 194 | .custom-tablenav-top .button:hover { 195 | background: #f0f0f1; 196 | border-color: #8c8f94; 197 | } 198 | 199 | .custom-tablenav-top .button-primary { 200 | background: var(--rri-primary-color); 201 | color: #fff; 202 | border-color: var(--rri-primary-color); 203 | } 204 | 205 | .custom-tablenav-top .button-primary:hover { 206 | background: #005a87; 207 | border-color: #005a87; 208 | } 209 | 210 | /* ========================================================================== 211 | Responsive Design 212 | ========================================================================== */ 213 | 214 | @media (max-width: 782px) { 215 | .custom-tablenav-top .tablenav-actions { 216 | float: none; 217 | display: block; 218 | margin-top: var(--rri-spacing-sm); 219 | } 220 | 221 | .custom-tablenav-top form { 222 | display: block; 223 | margin-right: 0; 224 | margin-bottom: var(--rri-spacing-sm); 225 | } 226 | 227 | .custom-tablenav-top form > * { 228 | margin-right: var(--rri-spacing-xs); 229 | margin-bottom: var(--rri-spacing-xs); 230 | } 231 | 232 | .permastructs-table-wrapper { 233 | font-size: 14px; 234 | } 235 | 236 | .permastruct-structure { 237 | font-size: 12px; 238 | padding: 2px 4px; 239 | } 240 | 241 | } 242 | 243 | @media (max-width: 600px) { 244 | .custom-tablenav-top input[type="text"] { 245 | width: 100%; 246 | } 247 | } 248 | 249 | /* ========================================================================== 250 | Accessibility Improvements 251 | ========================================================================== */ 252 | 253 | /* Focus indicators */ 254 | .rri-admin-page *:focus { 255 | outline: 2px solid var(--rri-primary-color); 256 | outline-offset: 2px; 257 | } 258 | 259 | /* High contrast mode support */ 260 | @media (prefers-contrast: high) { 261 | :root { 262 | --rri-border-color: #000; 263 | --rri-background-light: #fff; 264 | --rri-text-muted: #000; 265 | } 266 | } 267 | 268 | /* Reduced motion support */ 269 | @media (prefers-reduced-motion: reduce) { 270 | * { 271 | transition: none !important; 272 | animation: none !important; 273 | } 274 | } 275 | 276 | /* ========================================================================== 277 | JavaScript Enhancement Styles 278 | ========================================================================== */ 279 | 280 | /* Highlight effect for smooth scrolling targets */ 281 | .rri-highlight { 282 | animation: rri-highlight 2s ease-in-out; 283 | } 284 | 285 | @keyframes rri-highlight { 286 | 0% { background-color: transparent; } 287 | 50% { background-color: rgba(0, 115, 170, 0.1); } 288 | 100% { background-color: transparent; } 289 | } 290 | 291 | /* Active state for jump links */ 292 | .jump-link.rri-active { 293 | color: var(--rri-primary-color); 294 | text-decoration: none; 295 | } 296 | 297 | /* Screen reader text utility */ 298 | .screen-reader-text { 299 | border: 0; 300 | clip: rect(1px, 1px, 1px, 1px); 301 | clip-path: inset(50%); 302 | height: 1px; 303 | margin: -1px; 304 | overflow: hidden; 305 | padding: 0; 306 | position: absolute !important; 307 | width: 1px; 308 | word-wrap: normal !important; 309 | } 310 | 311 | /* ========================================================================== 312 | Print Styles 313 | ========================================================================== */ 314 | 315 | @media print { 316 | .jump-link, 317 | .custom-tablenav-top { 318 | display: none; 319 | } 320 | 321 | .permastruct-structure { 322 | background: transparent; 323 | border: 1px solid #000; 324 | } 325 | 326 | .rri-highlight { 327 | animation: none; 328 | background: transparent !important; 329 | } 330 | } 331 | 332 | /* URL Test Results Styling */ 333 | .rri-url-test-results { 334 | margin: 20px 0; 335 | padding: 20px; 336 | background: #f9f9f9; 337 | border: 1px solid #ddd; 338 | border-radius: 4px; 339 | } 340 | 341 | /* Notices kept inside the tab content to avoid core relocation */ 342 | .rri-notice { 343 | /* Match core .notice spacing */ 344 | margin: 5px 0 15px; 345 | padding: 12px; 346 | background: #fff; 347 | border-left: 4px solid #72aee6; /* info color default */ 348 | box-shadow: 0 1px 1px rgba(0,0,0,.04); 349 | color: #1d2327; 350 | } 351 | 352 | .rri-notice p { 353 | margin: .5em 0; 354 | } 355 | 356 | .rri-notice-success { 357 | border-left-color: #46b450; /* core success */ 358 | } 359 | 360 | .rri-notice-error { 361 | border-left-color: #dc3232; /* core error */ 362 | } 363 | 364 | .rri-url-test-results h3 { 365 | margin-top: 0; 366 | color: #23282d; 367 | } 368 | 369 | .rri-test-summary p { 370 | margin: 8px 0; 371 | } 372 | 373 | .rri-test-summary code { 374 | background: #fff; 375 | padding: 2px 6px; 376 | border: 1px solid #ddd; 377 | border-radius: 3px; 378 | font-family: Consolas, Monaco, monospace; 379 | } 380 | 381 | .rri-first-match { 382 | margin: 20px 0; 383 | } 384 | 385 | .rri-first-match h4 { 386 | margin-bottom: 10px; 387 | color: #23282d; 388 | } 389 | 390 | .rri-first-match table { 391 | margin: 0; 392 | } 393 | 394 | .rri-first-match th { 395 | width: 150px; 396 | text-align: left; 397 | vertical-align: top; 398 | padding: 8px 12px; 399 | background: #f1f1f1; 400 | border-bottom: 1px solid #ddd; 401 | } 402 | 403 | .rri-first-match td { 404 | padding: 8px 12px; 405 | border-bottom: 1px solid #ddd; 406 | } 407 | 408 | .rri-first-match code { 409 | background: #fff; 410 | padding: 2px 6px; 411 | border: 1px solid #ddd; 412 | border-radius: 3px; 413 | font-family: Consolas, Monaco, monospace; 414 | display: inline-block; 415 | margin: 2px 0; 416 | } 417 | 418 | .rri-all-matches { 419 | margin: 20px 0; 420 | } 421 | 422 | .rri-all-matches h4 { 423 | margin-bottom: 10px; 424 | color: #23282d; 425 | } 426 | 427 | .rri-all-matches ol { 428 | margin: 0; 429 | padding-left: 20px; 430 | } 431 | 432 | .rri-all-matches li { 433 | margin: 8px 0; 434 | } 435 | 436 | .rri-all-matches code { 437 | background: #fff; 438 | padding: 2px 6px; 439 | border: 1px solid #ddd; 440 | border-radius: 3px; 441 | font-family: Consolas, Monaco, monospace; 442 | } 443 | 444 | .rri-match-source { 445 | color: #666; 446 | font-style: italic; 447 | margin-left: 8px; 448 | } 449 | 450 | /* Filter form improvements */ 451 | .rri-filter-row { 452 | display: flex; 453 | align-items: center; 454 | gap: 10px; 455 | flex-wrap: wrap; 456 | } 457 | 458 | .rri-filter-row label { 459 | font-weight: 600; 460 | margin-right: 5px; 461 | } 462 | 463 | .rri-filter-row input[type="text"] { 464 | min-width: 300px; 465 | } 466 | 467 | .rri-filter-row select { 468 | min-width: 120px; 469 | } 470 | -------------------------------------------------------------------------------- /languages/rewrite-rules-inspector.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 Automattic, Daniel Bachhuber 2 | # This file is distributed under the GPL-2.0-or-later. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: Rewrite Rules Inspector 1.5.1\n" 6 | "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/rewrite-rules-inspector\n" 7 | "Last-Translator: FULL NAME \n" 8 | "Language-Team: LANGUAGE \n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "POT-Creation-Date: 2025-10-14T16:00:17+00:00\n" 13 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 | "X-Generator: WP-CLI 2.12.0\n" 15 | "X-Domain: rewrite-rules-inspector\n" 16 | 17 | #. Plugin Name of the plugin 18 | #: rewrite-rules-inspector.php 19 | #: src/Admin/AdminPage.php:87 20 | msgid "Rewrite Rules Inspector" 21 | msgstr "" 22 | 23 | #. Plugin URI of the plugin 24 | #: rewrite-rules-inspector.php 25 | msgid "https://wordpress.org/plugins/rewrite-rules-inspector/" 26 | msgstr "" 27 | 28 | #. Description of the plugin 29 | #: rewrite-rules-inspector.php 30 | msgid "Simple WordPress admin tool for inspecting your rewrite rules." 31 | msgstr "" 32 | 33 | #. Author of the plugin 34 | #: rewrite-rules-inspector.php 35 | msgid "Automattic, Daniel Bachhuber" 36 | msgstr "" 37 | 38 | #. Author URI of the plugin 39 | #: rewrite-rules-inspector.php 40 | msgid "https://automattic.com/" 41 | msgstr "" 42 | 43 | #: src/Admin/AdminPage.php:88 44 | #: src/Admin/ContextualHelp.php:36 45 | #: src/Admin/ViewRenderer.php:65 46 | #: src/Admin/ViewRenderer.php:83 47 | msgid "Rewrite Rules" 48 | msgstr "" 49 | 50 | #: src/Admin/ContextualHelp.php:27 51 | msgid "Overview" 52 | msgstr "" 53 | 54 | #: src/Admin/ContextualHelp.php:28 55 | msgid "The Rewrite Rules Inspector helps you understand and debug your WordPress site's URL structure. It shows you all the rewrite rules and permastructs that WordPress uses to handle URLs." 56 | msgstr "" 57 | 58 | #: src/Admin/ContextualHelp.php:37 59 | msgid "Rewrite Rules are the actual URL patterns that WordPress uses to match incoming requests and determine what content to display." 60 | msgstr "" 61 | 62 | #: src/Admin/ContextualHelp.php:38 63 | msgid "Each rule consists of:" 64 | msgstr "" 65 | 66 | #: src/Admin/ContextualHelp.php:40 67 | msgid "Rule: A regular expression pattern that matches URLs (e.g., ^category/([^/]+)/?$)" 68 | msgstr "" 69 | 70 | #: src/Admin/ContextualHelp.php:41 71 | msgid "Rewrite: The internal WordPress query that gets executed (e.g., index.php?category_name=$matches[1])" 72 | msgstr "" 73 | 74 | #: src/Admin/ContextualHelp.php:42 75 | msgid "Source: Where the rule comes from (e.g., category, post, custom permastruct)" 76 | msgstr "" 77 | 78 | #: src/Admin/ContextualHelp.php:44 79 | msgid "When someone visits a URL, WordPress checks these rules in order until it finds a match, then executes the corresponding rewrite to determine what content to show." 80 | msgstr "" 81 | 82 | #: src/Admin/ContextualHelp.php:52 83 | #: src/Admin/ViewRenderer.php:75 84 | #: src/Admin/ViewRenderer.php:95 85 | #: views/permastructs-table.php:18 86 | msgid "Permastructs" 87 | msgstr "" 88 | 89 | #: src/Admin/ContextualHelp.php:53 90 | msgid "Permastructs are the URL structure templates that define how different types of content should be accessed via URLs." 91 | msgstr "" 92 | 93 | #: src/Admin/ContextualHelp.php:54 94 | msgid "For example:" 95 | msgstr "" 96 | 97 | #. translators: %year%, %monthnum%, %day%, %postname% are permalink structure tags. Keep them as-is in the URL example. 98 | #: src/Admin/ContextualHelp.php:57 99 | #, php-format 100 | msgid "Post Permalink: /%year%/%monthnum%/%day%/%postname%/ - defines how individual posts are accessed" 101 | msgstr "" 102 | 103 | #. translators: %category% is a permalink structure tag. Keep it as-is in the URL example. 104 | #: src/Admin/ContextualHelp.php:59 105 | #, php-format 106 | msgid "Category Archive: /category/%category% - defines how category pages are accessed" 107 | msgstr "" 108 | 109 | #. translators: %post_tag% is a permalink structure tag. Keep it as-is in the URL example. 110 | #: src/Admin/ContextualHelp.php:61 111 | msgid "Tag Archive: /tag/%post_tag% - defines how tag pages are accessed" 112 | msgstr "" 113 | 114 | #: src/Admin/ContextualHelp.php:63 115 | msgid "WordPress uses these permastructs to generate the actual rewrite rules. The permastructs are like blueprints, while the rewrite rules are the specific patterns that get created from those blueprints." 116 | msgstr "" 117 | 118 | #: src/Admin/ContextualHelp.php:64 119 | msgid "You can customize permastructs through WordPress settings (Settings → Permalinks) or by using WordPress functions like add_permastruct() in your theme or plugin." 120 | msgstr "" 121 | 122 | #: src/Admin/ContextualHelp.php:72 123 | msgid "Troubleshooting" 124 | msgstr "" 125 | 126 | #: src/Admin/ContextualHelp.php:73 127 | msgid "Common Issues:" 128 | msgstr "" 129 | 130 | #: src/Admin/ContextualHelp.php:75 131 | msgid "Missing Rules: If you see rules marked as \"missing\", try clicking the \"Flush Rules\" button to regenerate them." 132 | msgstr "" 133 | 134 | #: src/Admin/ContextualHelp.php:76 135 | msgid "404 Errors: Check if the URL pattern exists in the rewrite rules. Use the \"Match URL\" filter to test specific URLs." 136 | msgstr "" 137 | 138 | #: src/Admin/ContextualHelp.php:77 139 | msgid "Custom URLs Not Working: Verify that your custom permastruct is properly registered and that rewrite rules have been flushed." 140 | msgstr "" 141 | 142 | #: src/Admin/ContextualHelp.php:78 143 | msgid "Plugin Conflicts: Some plugins may modify rewrite rules. Check the \"Source\" column to see which rules come from which sources." 144 | msgstr "" 145 | 146 | #: src/Admin/ContextualHelp.php:80 147 | msgid "Tips:" 148 | msgstr "" 149 | 150 | #: src/Admin/ContextualHelp.php:82 151 | msgid "Use the \"Rule Source\" filter to focus on specific types of rules." 152 | msgstr "" 153 | 154 | #: src/Admin/ContextualHelp.php:83 155 | msgid "Download the rules as a text file for offline analysis." 156 | msgstr "" 157 | 158 | #: src/Admin/ContextualHelp.php:84 159 | msgid "Check the permastructs section to understand the URL structure templates." 160 | msgstr "" 161 | 162 | #: src/Admin/ContextualHelp.php:99 163 | msgid "For more information:" 164 | msgstr "" 165 | 166 | #: src/Admin/ContextualHelp.php:100 167 | msgid "WordPress Permalinks Documentation" 168 | msgstr "" 169 | 170 | #: src/Admin/ContextualHelp.php:101 171 | msgid "WordPress Rewrite API" 172 | msgstr "" 173 | 174 | #: src/Admin/ContextualHelp.php:102 175 | msgid "Plugin on GitHub" 176 | msgstr "" 177 | 178 | #: src/Admin/RewriteRulesTable.php:73 179 | msgid "No rewrite rules were found." 180 | msgstr "" 181 | 182 | #. translators: %d: Number of rules 183 | #: src/Admin/RewriteRulesTable.php:185 184 | #, php-format 185 | msgid "%d rule for this selection" 186 | msgid_plural "%d rules for this selection" 187 | msgstr[0] "" 188 | msgstr[1] "" 189 | 190 | #. translators: %d: Number of rules 191 | #: src/Admin/RewriteRulesTable.php:191 192 | #, php-format 193 | msgid "%d rule total" 194 | msgid_plural "%d rules total" 195 | msgstr[0] "" 196 | msgstr[1] "" 197 | 198 | #: src/Admin/RewriteRulesTable.php:218 199 | msgid "Flush Rules" 200 | msgstr "" 201 | 202 | #: src/Admin/RewriteRulesTable.php:237 203 | msgid "Download" 204 | msgstr "" 205 | 206 | #: src/Admin/RewriteRulesTable.php:241 207 | msgid "Test URL:" 208 | msgstr "" 209 | 210 | #: src/Admin/RewriteRulesTable.php:242 211 | msgid "Enter URL (e.g., /my-page/ or https://example.com/my-page/)" 212 | msgstr "" 213 | 214 | #: src/Admin/RewriteRulesTable.php:244 215 | msgid "Rule Source:" 216 | msgstr "" 217 | 218 | #: src/Admin/RewriteRulesTable.php:259 219 | msgid "Test URL" 220 | msgstr "" 221 | 222 | #: src/Admin/RewriteRulesTable.php:261 223 | msgid "Reset" 224 | msgstr "" 225 | 226 | #: src/Admin/RewriteRulesTable.php:278 227 | msgid "Priority" 228 | msgstr "" 229 | 230 | #: src/Admin/RewriteRulesTable.php:279 231 | msgid "Rule" 232 | msgstr "" 233 | 234 | #: src/Admin/RewriteRulesTable.php:280 235 | msgid "Rewrite" 236 | msgstr "" 237 | 238 | #: src/Admin/RewriteRulesTable.php:281 239 | #: src/Admin/ViewRenderer.php:214 240 | msgid "Source" 241 | msgstr "" 242 | 243 | #: src/Admin/RewriteRulesTable.php:320 244 | msgid "missing" 245 | msgstr "" 246 | 247 | #: src/Admin/ViewRenderer.php:57 248 | msgid "Rewrite Rules Inspector sections" 249 | msgstr "" 250 | 251 | #: src/Admin/ViewRenderer.php:122 252 | msgid "No rewrite rules yet, try flushing." 253 | msgstr "" 254 | 255 | #. translators: %d: Count of missing rewrite rules 256 | #: src/Admin/ViewRenderer.php:127 257 | #, php-format 258 | msgid "%d rewrite rule may be missing, try flushing." 259 | msgid_plural "%d rewrite rules may be missing, try flushing." 260 | msgstr[0] "" 261 | msgstr[1] "" 262 | 263 | #: src/Admin/ViewRenderer.php:155 264 | msgid "URL Test Results" 265 | msgstr "" 266 | 267 | #: src/Admin/ViewRenderer.php:158 268 | msgid "URL Tested:" 269 | msgstr "" 270 | 271 | #: src/Admin/ViewRenderer.php:159 272 | msgid "Path Tested:" 273 | msgstr "" 274 | 275 | #: src/Admin/ViewRenderer.php:167 276 | msgid "No rewrite rules match the selected rule source." 277 | msgstr "" 278 | 279 | #: src/Admin/ViewRenderer.php:177 280 | msgid "Result: 404 Error" 281 | msgstr "" 282 | 283 | #. translators: %d: Number of rules tested 284 | #: src/Admin/ViewRenderer.php:181 285 | #, php-format 286 | msgid "This URL does not match any of the %d rewrite rules and would result in a 404 error." 287 | msgstr "" 288 | 289 | #: src/Admin/ViewRenderer.php:188 290 | msgid "Result: No matching rules" 291 | msgstr "" 292 | 293 | #. translators: %d: Number of rules tested 294 | #: src/Admin/ViewRenderer.php:192 295 | #, php-format 296 | msgid "This URL does not match any of the %d rewrite rules, but it may be handled by WordPress core routing." 297 | msgstr "" 298 | 299 | #: src/Admin/ViewRenderer.php:203 300 | msgid "First Match (WordPress will use this):" 301 | msgstr "" 302 | 303 | #: src/Admin/ViewRenderer.php:206 304 | msgid "Rule Pattern" 305 | msgstr "" 306 | 307 | #: src/Admin/ViewRenderer.php:210 308 | msgid "Rewrite Target" 309 | msgstr "" 310 | 311 | #: src/Admin/ViewRenderer.php:219 312 | msgid "Query Variables" 313 | msgstr "" 314 | 315 | #: src/Admin/ViewRenderer.php:254 316 | msgid "Additional Matching Rules:" 317 | msgstr "" 318 | 319 | #. translators: %d: Number of additional matches 320 | #: src/Admin/ViewRenderer.php:258 321 | #, php-format 322 | msgid "See the table below for all %d matching rules in priority order." 323 | msgstr "" 324 | 325 | #: src/Admin/ViewRenderer.php:276 326 | msgid "Rewrite rules flushed." 327 | msgstr "" 328 | 329 | #: src/Core/FileExport.php:45 330 | #: src/Core/RuleFlush.php:51 331 | msgid "You do not have permissions to perform this action." 332 | msgstr "" 333 | 334 | #: src/Core/Permastructs.php:56 335 | msgid "Post Permalink" 336 | msgstr "" 337 | 338 | #: src/Core/Permastructs.php:58 339 | msgid "The permalink structure for posts" 340 | msgstr "" 341 | 342 | #: src/Core/Permastructs.php:61 343 | msgid "Date Archive" 344 | msgstr "" 345 | 346 | #: src/Core/Permastructs.php:63 347 | msgid "The permalink structure for date archives" 348 | msgstr "" 349 | 350 | #: src/Core/Permastructs.php:66 351 | msgid "Search Results" 352 | msgstr "" 353 | 354 | #: src/Core/Permastructs.php:68 355 | msgid "The permalink structure for search results" 356 | msgstr "" 357 | 358 | #: src/Core/Permastructs.php:71 359 | msgid "Author Archive" 360 | msgstr "" 361 | 362 | #: src/Core/Permastructs.php:73 363 | msgid "The permalink structure for author archives" 364 | msgstr "" 365 | 366 | #: src/Core/Permastructs.php:76 367 | msgid "Comments" 368 | msgstr "" 369 | 370 | #: src/Core/Permastructs.php:78 371 | msgid "The permalink structure for comments" 372 | msgstr "" 373 | 374 | #: src/Core/Permastructs.php:81 375 | msgid "Root" 376 | msgstr "" 377 | 378 | #: src/Core/Permastructs.php:83 379 | msgid "The root permalink structure" 380 | msgstr "" 381 | 382 | #. translators: %s: permastruct name 383 | #: src/Core/Permastructs.php:104 384 | #, php-format 385 | msgid "The permalink structure for %s" 386 | msgstr "" 387 | 388 | #: src/Core/Permastructs.php:156 389 | msgid "Category Archive" 390 | msgstr "" 391 | 392 | #: src/Core/Permastructs.php:157 393 | msgid "The permalink structure for category archives" 394 | msgstr "" 395 | 396 | #: src/Core/Permastructs.php:160 397 | msgid "Tag Archive" 398 | msgstr "" 399 | 400 | #: src/Core/Permastructs.php:161 401 | msgid "The permalink structure for tag archives" 402 | msgstr "" 403 | 404 | #: src/Core/Permastructs.php:164 405 | msgid "Post Format Archive" 406 | msgstr "" 407 | 408 | #: src/Core/Permastructs.php:165 409 | msgid "The permalink structure for post format archives" 410 | msgstr "" 411 | 412 | #: src/Core/Permastructs.php:168 413 | msgid "Test Custom (Demo)" 414 | msgstr "" 415 | 416 | #: src/Core/Permastructs.php:169 417 | msgid "A custom permastruct added for testing the permastructs display feature" 418 | msgstr "" 419 | 420 | #: src/Core/Permastructs.php:172 421 | msgid "Demo Archive (Test)" 422 | msgstr "" 423 | 424 | #: src/Core/Permastructs.php:173 425 | msgid "A demo archive permastruct with date-based structure for testing" 426 | msgstr "" 427 | 428 | #. translators: %1$s: URL, %2$d: Number of rules tested 429 | #: src/Core/UrlTester.php:273 430 | #, php-format 431 | msgid "The URL \"%1$s\" does not match any of the %2$d rewrite rules and would result in a 404 error." 432 | msgstr "" 433 | 434 | #. translators: %1$s: URL, %2$s: Rule pattern 435 | #: src/Core/UrlTester.php:285 436 | #, php-format 437 | msgid "The URL \"%1$s\" matches exactly one rewrite rule: %2$s" 438 | msgstr "" 439 | 440 | #. translators: %1$s: URL, %2$d: Number of matches, %3$s: First matching rule 441 | #: src/Core/UrlTester.php:293 442 | #, php-format 443 | msgid "The URL \"%1$s\" matches %2$d rewrite rules. The first match (which WordPress will use) is: %3$s" 444 | msgstr "" 445 | 446 | #. translators: %d: Count of permastructs 447 | #: views/permastructs-table.php:24 448 | #, php-format 449 | msgid "A listing of all %d permastructs that WordPress is aware of." 450 | msgstr "" 451 | 452 | #: views/permastructs-table.php:29 453 | msgid "WordPress Permastructs" 454 | msgstr "" 455 | 456 | #: views/permastructs-table.php:33 457 | #: views/permastructs-table.php:61 458 | msgid "Name" 459 | msgstr "" 460 | 461 | #: views/permastructs-table.php:36 462 | #: views/permastructs-table.php:64 463 | msgid "Structure" 464 | msgstr "" 465 | 466 | #: views/permastructs-table.php:39 467 | #: views/permastructs-table.php:67 468 | msgid "Description" 469 | msgstr "" 470 | 471 | #: views/permastructs-table.php:50 472 | msgid "Permastruct structure" 473 | msgstr "" 474 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------