From 036e9e6024bc3264a1c3a5e1f3d050e27aea5665 Mon Sep 17 00:00:00 2001 From: jdevalk Date: Tue, 1 Dec 2020 23:02:32 +0000 Subject: [PATCH] Tagging version 0.3 git-svn-id: http://plugins.svn.wordpress.org/custom-field-finder/trunk@2429869 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- cff.php | 61 +++++++++++++++++++++++++++--------------------------- readme.txt | 18 ++++++++++------ 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/cff.php b/cff.php index 80aa8ec..6125f8d 100644 --- a/cff.php +++ b/cff.php @@ -1,84 +1,85 @@ name, $this->name, 'manage_options', $this->hook, array( $this, 'plugin_page' ) ); + public function register_page() { + $name = __( 'Custom field finder', 'custom-field-finder' ); + + add_submenu_page( 'tools.php', $name, $name, 'manage_options', $this->hook, [ $this, 'plugin_page' ] ); } /** * Output for the plugin page. */ - function plugin_page() { + public function plugin_page() { + $post_id = filter_input( INPUT_POST, 'post_id', FILTER_SANITIZE_NUMBER_INT ); + echo '
'; - echo '

'; echo '

' . esc_html__( 'Custom field finder', 'custom-field-finder' ) . '

'; echo '

', esc_html__( 'Enter a post, page or custom post type ID below and press find custom fields to see the custom fields attached to that post.', 'custom-field-finder' ), '

'; - echo '
'; - echo ''; - echo '

'; + echo ''; + wp_nonce_field( 'custom-field-finder' ); + echo '

'; echo ''; echo '
'; echo '
'; - if ( isset( $_GET['post_id'] ) ) { + if ( $post_id > 0 && wp_verify_nonce( $_POST['_wpnonce'], 'custom-field-finder' ) ) { echo '

'; - $post = get_post( intval( $_GET['post_id'] ) ); + $post = get_post( $post_id ); if ( is_null( $post ) ) { - echo sprintf( esc_html__( 'Post %d not found.', 'custom-field-finder' ), (int) $_GET['post_id'] ); + echo sprintf( esc_html__( 'Post %d not found.', 'custom-field-finder' ), $post_id ); } else { echo '

', esc_html__( 'Custom fields for post', 'custom-field-finder' ), ' "' . $post->post_title . '"

'; $customs = get_post_custom( $post->ID ); if ( count( $customs ) > 0 ) { ksort( $customs ); echo '

', __( 'Note that custom fields whose key starts with _ will normally be invisible in the custom fields interface.', 'custom-field-finder' ), '

'; - echo ''; - echo ''; - echo ''; + echo ''; + echo '
', esc_html__( 'Key', 'custom-field-finder' ), 'Value(s)
'; + echo ''; echo ''; foreach ( $customs as $key => $val ) { echo ''; - echo ''; @@ -94,4 +95,4 @@ function plugin_page() { } -$yoast_cff = new CustomFieldFinder(); +$yoast_cff = new Yoast_Custom_Field_Finder(); diff --git a/readme.txt b/readme.txt index 93cd1ab..8770c6a 100644 --- a/readme.txt +++ b/readme.txt @@ -1,10 +1,10 @@ -=== Custom Field Finder === -Contributors: joostdevalk +=== Custom field finder === +Contributors: joostdevalk, yoast Donate link: http://yoast.com/donate/ Tags: custom fields Requires at least: 3.0 Tested up to: 5.6 -Stable tag: 0.2 +Stable tag: 0.3 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -15,8 +15,8 @@ Allows you to easily find the custom fields (including hidden custom fields) and Allows you to easily find the custom fields (including hidden custom fields) and their values for a post, page or custom post type post. -Just go to Tools -> Custom Field Finder, enter the post ID of any post and you'll see all the custom fields, including -the ones that start with an underscore ( _ ) that are normally hidden from the custom fields interface. +Just go to Tools - Custom field finder, enter the post ID of any post and you'll see all the custom fields. This includes +the custom fields that start with an underscore ( _ ) that are normally hidden from the custom fields interface. == Installation == @@ -31,7 +31,13 @@ the ones that start with an underscore ( _ ) that are normally hidden from the c == Changelog == -= 0.2 = += 0.3 = + +* Added a plugin header and icon. +* Some basic coding style & cleanliness fixes. +* Fixed a string that was not translateable. + += 0.2 = * Updated screenshots. * Updated tested up to.
', esc_html__( 'Key', 'custom-field-finder' ), '', esc_html__( 'Value(s)', 'custom-field-finder' ), '
' . esc_html( $key ) . ''; + echo '', esc_html( $key ), ''; if ( count( $val ) === 1 ) { $val = maybe_unserialize( $val[0] ); - if ( !is_array( $val ) ) + if ( ! is_array( $val ) ) { echo esc_html( $val ); - else - echo '
' . esc_html( print_r( $val, 1 ) ) . '
'; - } else { + } + else { + echo '
', esc_html( print_r( $val, 1 ) ), '
'; + } + } + else { foreach ( $val as $v ) { - echo esc_html( $v ) . '
'; + echo esc_html( $v ), '
'; } } echo '