├── .editorconfig ├── .github └── workflows │ ├── cs-lint.yml │ └── integrations.yml ├── .gitignore ├── .phpcs.xml.dist ├── bin └── install-wp-tests.sh ├── class-post-meta-inspector.php ├── composer.json ├── languages └── post-meta-inspector.pot ├── phpunit.xml.dist ├── post-meta-inspector.php ├── readme.txt ├── screenshot-1.jpg └── tests └── bootstrap.php /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs. 2 | # It is based on https://core.trac.wordpress.org/browser/trunk/.editorconfig. 3 | # See https://editorconfig.org for more information about the standard. 4 | 5 | # WordPress Coding Standards 6 | # https://make.wordpress.org/core/handbook/coding-standards/ 7 | 8 | root = true 9 | 10 | [*] 11 | charset = utf-8 12 | end_of_line = lf 13 | insert_final_newline = true 14 | trim_trailing_whitespace = true 15 | indent_style = tab 16 | 17 | [*.yml] 18 | indent_style = space 19 | indent_size = 2 20 | 21 | [*.md] 22 | trim_trailing_whitespace = false 23 | 24 | [*.txt] 25 | end_of_line = crlf 26 | -------------------------------------------------------------------------------- /.github/workflows/cs-lint.yml: -------------------------------------------------------------------------------- 1 | name: CS & Lint 2 | 3 | on: 4 | # Run on all pushes and on all pull requests. 5 | # Prevent the "push" build from running when there are only irrelevant changes. 6 | push: 7 | paths-ignore: 8 | - "**.md" 9 | pull_request: 10 | # Allow manually triggering the workflow. 11 | workflow_dispatch: 12 | 13 | jobs: 14 | checkcs: 15 | name: "Basic CS and QA checks" 16 | runs-on: ubuntu-latest 17 | 18 | env: 19 | XMLLINT_INDENT: " " 20 | 21 | steps: 22 | - name: Setup PHP 23 | uses: shivammathur/setup-php@v2 24 | with: 25 | php-version: "7.4" 26 | coverage: none 27 | tools: cs2pr 28 | 29 | # Show PHP lint violations inline in the file diff. 30 | # @link https://github.com/marketplace/actions/xmllint-problem-matcher 31 | - name: Register PHP lint violations to appear as file diff comments 32 | uses: korelstar/phplint-problem-matcher@v1 33 | 34 | # Show XML violations inline in the file diff. 35 | # @link https://github.com/marketplace/actions/xmllint-problem-matcher 36 | - name: Register XML violations to appear as file diff comments 37 | uses: korelstar/xmllint-problem-matcher@v1 38 | 39 | - name: Checkout code 40 | uses: actions/checkout@v2 41 | 42 | # Validate the composer.json file. 43 | # @link https://getcomposer.org/doc/03-cli.md#validate 44 | - name: Validate Composer installation 45 | run: composer validate --no-check-all 46 | 47 | # Install dependencies and handle caching in one go. 48 | # @link https://github.com/marketplace/actions/install-composer-dependencies 49 | - name: Install Composer dependencies 50 | uses: ramsey/composer-install@v1 51 | 52 | # Lint PHP. 53 | - name: Lint PHP against parse errors 54 | run: composer lint-ci | cs2pr 55 | 56 | # Needed as runs-on: system doesn't have xml-lint by default. 57 | # @link https://github.com/marketplace/actions/xml-lint 58 | - name: Lint phpunit.xml.dist 59 | uses: ChristophWurst/xmllint-action@v1 60 | with: 61 | xml-file: ./phpunit.xml.dist 62 | xml-schema-file: ./vendor/phpunit/phpunit/phpunit.xsd 63 | 64 | # Check the code-style consistency of the PHP files. 65 | # - name: Check PHP code style 66 | # continue-on-error: true 67 | # run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml 68 | 69 | # - name: Show PHPCS results in PR 70 | # run: cs2pr ./phpcs-report.xml 71 | -------------------------------------------------------------------------------- /.github/workflows/integrations.yml: -------------------------------------------------------------------------------- 1 | name: Run PHPUnit 2 | 3 | on: 4 | # Run on all pushes and on all pull requests. 5 | # Prevent the "push" build from running when there are only irrelevant changes. 6 | push: 7 | paths-ignore: 8 | - "**.md" 9 | pull_request: 10 | # Allow manually triggering the workflow. 11 | workflow_dispatch: 12 | 13 | jobs: 14 | test: 15 | name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }} 16 | # Ubuntu-20.x includes MySQL 8.0, which causes `caching_sha2_password` issues with PHP < 7.4 17 | # https://www.php.net/manual/en/mysqli.requirements.php 18 | # TODO: change to ubuntu-latest when we no longer support PHP < 7.4 19 | runs-on: ubuntu-18.04 20 | 21 | env: 22 | WP_VERSION: ${{ matrix.wordpress }} 23 | 24 | strategy: 25 | matrix: 26 | wordpress: ["5.5", "5.6", "5.7"] 27 | php: ["5.6", "7.0", "7.1", "7.2", "7.3", "7.4"] 28 | include: 29 | - php: "8.0" 30 | # Ignore platform requirements, so that PHPUnit 7.5 can be installed on PHP 8.0 (and above). 31 | composer-options: "--ignore-platform-reqs" 32 | extensions: pcov 33 | ini-values: pcov.directory=., "pcov.exclude=\"~(vendor|tests)~\"" 34 | coverage: pcov 35 | exclude: 36 | - php: "8.0" 37 | wordpress: "5.5" 38 | fail-fast: false 39 | 40 | steps: 41 | - name: Checkout code 42 | uses: actions/checkout@v2 43 | 44 | - name: Setup PHP ${{ matrix.php }} 45 | uses: shivammathur/setup-php@v2 46 | with: 47 | php-version: ${{ matrix.php }} 48 | extensions: ${{ matrix.extensions }} 49 | ini-values: ${{ matrix.ini-values }} 50 | coverage: ${{ matrix.coverage }} 51 | 52 | - name: Setup problem matchers for PHP 53 | run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" 54 | 55 | # Setup PCOV since we're using PHPUnit < 8 which has it integrated. Requires PHP 7.1. 56 | # Ignore platform reqs to make it install on PHP 8. 57 | # https://github.com/krakjoe/pcov-clobber 58 | - name: Setup PCOV 59 | if: ${{ matrix.php == 8.0 }} 60 | run: | 61 | composer require pcov/clobber --ignore-platform-reqs 62 | vendor/bin/pcov clobber 63 | 64 | - name: Setup Problem Matchers for PHPUnit 65 | run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" 66 | 67 | - name: Install Composer dependencies 68 | uses: ramsey/composer-install@v1 69 | with: 70 | composer-options: "${{ matrix.composer-options }}" 71 | 72 | - name: Start MySQL Service 73 | run: sudo systemctl start mysql.service 74 | 75 | - name: Prepare environment for integration tests 76 | run: composer prepare-ci 77 | 78 | - name: Run integration tests (single site) 79 | if: ${{ matrix.php != 8.0 }} 80 | run: composer test 81 | - name: Run integration tests (single site with code coverage) 82 | if: ${{ matrix.php == 8.0 }} 83 | run: composer coverage-ci 84 | - name: Run integration tests (multisite) 85 | run: composer test-ms 86 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | /vendor 3 | -------------------------------------------------------------------------------- /.phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | Custom ruleset for post-meta-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 | -------------------------------------------------------------------------------- /bin/install-wp-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ $# -lt 3 ]; then 4 | echo "usage: $0 [db-host] [wp-version] [skip-database-creation]" 5 | exit 1 6 | fi 7 | 8 | DB_NAME=$1 9 | DB_USER=$2 10 | DB_PASS=$3 11 | DB_HOST=${4-localhost} 12 | WP_VERSION=${5-latest} 13 | SKIP_DB_CREATE=${6-false} 14 | 15 | TMPDIR=${TMPDIR-/tmp} 16 | TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//") 17 | WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib} 18 | WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress} 19 | 20 | download() { 21 | if [ `which curl` ]; then 22 | curl -s "$1" > "$2"; 23 | elif [ `which wget` ]; then 24 | wget -nv -O "$2" "$1" 25 | fi 26 | } 27 | 28 | if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then 29 | WP_BRANCH=${WP_VERSION%\-*} 30 | WP_TESTS_TAG="branches/$WP_BRANCH" 31 | 32 | elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then 33 | WP_TESTS_TAG="branches/$WP_VERSION" 34 | elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then 35 | if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then 36 | # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x 37 | WP_TESTS_TAG="tags/${WP_VERSION%??}" 38 | else 39 | WP_TESTS_TAG="tags/$WP_VERSION" 40 | fi 41 | elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then 42 | WP_TESTS_TAG="trunk" 43 | else 44 | # http serves a single offer, whereas https serves multiple. we only want one 45 | download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json 46 | grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json 47 | LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') 48 | if [[ -z "$LATEST_VERSION" ]]; then 49 | echo "Latest WordPress version could not be found" 50 | exit 1 51 | fi 52 | WP_TESTS_TAG="tags/$LATEST_VERSION" 53 | fi 54 | set -ex 55 | 56 | install_wp() { 57 | 58 | if [ -d $WP_CORE_DIR ]; then 59 | return; 60 | fi 61 | 62 | mkdir -p $WP_CORE_DIR 63 | 64 | if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then 65 | mkdir -p $TMPDIR/wordpress-trunk 66 | rm -rf $TMPDIR/wordpress-trunk/* 67 | svn export --quiet https://core.svn.wordpress.org/trunk $TMPDIR/wordpress-trunk/wordpress 68 | mv $TMPDIR/wordpress-trunk/wordpress/* $WP_CORE_DIR 69 | else 70 | if [ $WP_VERSION == 'latest' ]; then 71 | local ARCHIVE_NAME='latest' 72 | elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then 73 | # https serves multiple offers, whereas http serves single. 74 | download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json 75 | if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then 76 | # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x 77 | LATEST_VERSION=${WP_VERSION%??} 78 | else 79 | # otherwise, scan the releases and get the most up to date minor version of the major release 80 | local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'` 81 | LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1) 82 | fi 83 | if [[ -z "$LATEST_VERSION" ]]; then 84 | local ARCHIVE_NAME="wordpress-$WP_VERSION" 85 | else 86 | local ARCHIVE_NAME="wordpress-$LATEST_VERSION" 87 | fi 88 | else 89 | local ARCHIVE_NAME="wordpress-$WP_VERSION" 90 | fi 91 | download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz 92 | tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR 93 | fi 94 | 95 | download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php 96 | } 97 | 98 | install_test_suite() { 99 | # portable in-place argument for both GNU sed and Mac OSX sed 100 | if [[ $(uname -s) == 'Darwin' ]]; then 101 | local ioption='-i.bak' 102 | else 103 | local ioption='-i' 104 | fi 105 | 106 | # set up testing suite if it doesn't yet exist 107 | if [ ! -d $WP_TESTS_DIR ]; then 108 | # set up testing suite 109 | mkdir -p $WP_TESTS_DIR 110 | rm -rf $WP_TESTS_DIR/{includes,data} 111 | svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes 112 | svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data 113 | fi 114 | 115 | if [ ! -f wp-tests-config.php ]; then 116 | download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php 117 | # remove all forward slashes in the end 118 | WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") 119 | sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php 120 | sed $ioption "s:__DIR__ . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php 121 | sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php 122 | sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php 123 | sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php 124 | sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php 125 | fi 126 | 127 | } 128 | 129 | recreate_db() { 130 | shopt -s nocasematch 131 | if [[ $1 =~ ^(y|yes)$ ]] 132 | then 133 | mysqladmin drop $DB_NAME -f --user="$DB_USER" --password="$DB_PASS"$EXTRA 134 | create_db 135 | echo "Recreated the database ($DB_NAME)." 136 | else 137 | echo "Leaving the existing database ($DB_NAME) in place." 138 | fi 139 | shopt -u nocasematch 140 | } 141 | 142 | create_db() { 143 | mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA 144 | } 145 | 146 | install_db() { 147 | 148 | if [ ${SKIP_DB_CREATE} = "true" ]; then 149 | return 0 150 | fi 151 | 152 | # parse DB_HOST for port or socket references 153 | local PARTS=(${DB_HOST//\:/ }) 154 | local DB_HOSTNAME=${PARTS[0]}; 155 | local DB_SOCK_OR_PORT=${PARTS[1]}; 156 | local EXTRA="" 157 | 158 | if ! [ -z $DB_HOSTNAME ] ; then 159 | if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then 160 | EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" 161 | elif ! [ -z $DB_SOCK_OR_PORT ] ; then 162 | EXTRA=" --socket=$DB_SOCK_OR_PORT" 163 | elif ! [ -z $DB_HOSTNAME ] ; then 164 | EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" 165 | fi 166 | fi 167 | 168 | # create database 169 | if [ $(mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA --execute='show databases;' | grep ^$DB_NAME$) ] 170 | then 171 | echo "Reinstalling will delete the existing test database ($DB_NAME)" 172 | read -p 'Are you sure you want to proceed? [y/N]: ' DELETE_EXISTING_DB 173 | recreate_db $DELETE_EXISTING_DB 174 | else 175 | create_db 176 | fi 177 | } 178 | 179 | install_wp 180 | install_test_suite 181 | install_db 182 | 183 | -------------------------------------------------------------------------------- /class-post-meta-inspector.php: -------------------------------------------------------------------------------- 1 | view_cap = apply_filters( 'pmi_view_cap', 'manage_options' ); 70 | 71 | if ( empty( $post_type ) || ! current_user_can( $this->view_cap ) || ! apply_filters( 'pmi_show_post_type', '__return_true', $post_type ) ) { 72 | return; 73 | } 74 | 75 | add_meta_box( 'post-meta-inspector', __( 'Post Meta Inspector', 'post-meta-inspector' ), array( self::$instance, 'post_meta_inspector' ), get_post_type() ); 76 | } 77 | 78 | /** 79 | * Output the post meta in metabox. 80 | * 81 | * @return void 82 | */ 83 | public function post_meta_inspector() { 84 | $toggle_length = apply_filters( 'pmi_toggle_long_value_length', 0 ); 85 | $toggle_length = max( intval( $toggle_length ), 0 ); 86 | $toggle_el = '' . esc_html__( 'Click to show…', 'post-meta-inspector' ) . ''; 87 | ?> 88 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | $values ) : 117 | if ( apply_filters( 'pmi_ignore_post_meta_key', false, $key ) ) { 118 | continue; 119 | } 120 | ?> 121 | 122 | $toggle_length; 125 | ?> 126 | 127 | 128 | 129 | 134 | 140 | > 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 157 | =5.6", 15 | "composer/installers": "~1.0" 16 | }, 17 | "require-dev": { 18 | "automattic/vipwpcs": "^2.2", 19 | "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7", 20 | "php-parallel-lint/php-parallel-lint": "^1.0", 21 | "phpcompatibility/phpcompatibility-wp": "^2.1", 22 | "phpunit/phpunit": "^4 || ^5 || ^6 || ^7", 23 | "squizlabs/php_codesniffer": "^3.5", 24 | "wp-coding-standards/wpcs": "^2.3.0", 25 | "yoast/phpunit-polyfills": "^0.2.0" 26 | }, 27 | "scripts": { 28 | "cbf": [ 29 | "@php ./vendor/bin/phpcbf" 30 | ], 31 | "coverage": [ 32 | "@php ./vendor/bin/phpunit --coverage-html ./build/coverage-html" 33 | ], 34 | "coverage-ci": [ 35 | "@php ./vendor/bin/phpunit" 36 | ], 37 | "cs": [ 38 | "@php ./vendor/bin/phpcs" 39 | ], 40 | "lint": [ 41 | "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git" 42 | ], 43 | "lint-ci": [ 44 | "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --checkstyle" 45 | ], 46 | "prepare-ci": [ 47 | "bash bin/install-wp-tests.sh wordpress_test root root localhost" 48 | ], 49 | "test": [ 50 | "@php ./vendor/bin/phpunit --testsuite WP_Tests" 51 | ], 52 | "test-ms": [ 53 | "@putenv WP_MULTISITE=1", 54 | "@composer test" 55 | ] 56 | }, 57 | "support": { 58 | "issues": "https://github.com/Automattic/post-meta-inspector/issues", 59 | "source": "https://github.com/Automattic/post-meta-inspector" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /languages/post-meta-inspector.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012 Post Meta Inspector 2 | # This file is distributed under the same license as the Post Meta Inspector package. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: Post Meta Inspector 0.0\n" 6 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/post-meta-inspector\n" 7 | "POT-Creation-Date: 2012-10-05 18:12:33+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2012-MO-DA HO:MI+ZONE\n" 12 | "Last-Translator: FULL NAME \n" 13 | "Language-Team: LANGUAGE \n" 14 | 15 | #. #-#-#-#-# plugin.pot (Post Meta Inspector 0.0) #-#-#-#-# 16 | #. Plugin Name of the plugin/theme 17 | #: post-meta-inspector.php:30 18 | msgid "Post Meta Inspector" 19 | msgstr "" 20 | 21 | #: post-meta-inspector.php:49 22 | msgid "Key" 23 | msgstr "" 24 | 25 | #: post-meta-inspector.php:50 26 | msgid "Value" 27 | msgstr "" 28 | 29 | #. Plugin URI of the plugin/theme 30 | msgid "http://wordpress.org/extend/plugins/post-meta-inspector/" 31 | msgstr "" 32 | 33 | #. Description of the plugin/theme 34 | msgid "" 35 | "Peer inside your post meta. Admins can view post meta for any post from a " 36 | "simple meta box." 37 | msgstr "" 38 | 39 | #. Author of the plugin/theme 40 | msgid "Daniel Bachhuber, Automattic" 41 | msgstr "" 42 | 43 | #. Author URI of the plugin/theme 44 | msgid "http://automattic.com/" 45 | msgstr "" 46 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | ./tests/ 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /post-meta-inspector.php: -------------------------------------------------------------------------------- 1 |
140 | > 141 | 142 |