Title: PHP Warning
Last modified: May 11, 2023

---

# PHP Warning

 *  Resolved [kendawes](https://wordpress.org/support/users/kendawes/)
 * (@kendawes)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/php-warning-426/)
 * I’m getting the following warning in the WP debug.log on my client’s site.
 * PHP Warning: Undefined array key “sort” in /home/path/wp-content/plugins/custom-
   post-type-ui/inc/tools-sections/tools-taxonomies.php on line 172
 * The site is currently running PHP 8.0.28. Everything else is all current.
 * Any fix in sight?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [3 years, 1 month ago](https://wordpress.org/support/topic/php-warning-426/#post-16733071)
 * Hi,
 * Not something that should be taking the site down by any means, so you should
   be good on that front.
 * As a potential quick win, can you edit the taxonomy without actually changing
   any settings, just edit and save. I’m wondering if that will help remove it from
   the debug log. Hopefully you don’t have TOO many taxonomies registered where 
   it’d take a long time.
 *  [Earthman Media](https://wordpress.org/support/users/earthman100/)
 * (@earthman100)
 * [3 years ago](https://wordpress.org/support/topic/php-warning-426/#post-16749738)
 * Hello [@tw2113](https://wordpress.org/support/users/tw2113/) – love your plugin,
   been using it for years, thanks for all your efforts to keep it active!
 * This issue, however, is affecting my client’s sites’ functionality. The warning
   message is being output into the PHP code in the “Tools” section.
 * It takes the site down when I use the CPTUI export and try to import that into
   our test or production site, which is a regular and necessary part of development,
   or when I use the code below this message to auto-export the PHP
 * It appears that your code is not parsing the input form properly. I have set 
   the ‘sort’ option to true in the edit form, but after saving, the warning shows
   up, and the issue still persists when trying to export to PHP code.
 * See screenshots at links below:
 * _Form settings:_
   [https://drive.google.com/file/d/1rBvCrM0VzsJW1KXY4OlcoZt-rHvkeF4J/view?usp=sharing](https://drive.google.com/file/d/1rBvCrM0VzsJW1KXY4OlcoZt-rHvkeF4J/view?usp=sharing)
 * _Warning in Output Code:_
   [https://drive.google.com/file/d/1rCi7nbwszmHxbOW1aXwxCog3ShnzHyle/view?usp=sharing](https://drive.google.com/file/d/1rCi7nbwszmHxbOW1aXwxCog3ShnzHyle/view?usp=sharing)
 * Here is a hack that fixes the problem, but then the Form Settings for ‘sort’ (
   see screenshot above) are still not being saved, nor retrieved:
   [https://drive.google.com/file/d/1rFqoF1F5PCOXpIl-SMkz2XhDDqcnVIz0/view?usp=sharing](https://drive.google.com/file/d/1rFqoF1F5PCOXpIl-SMkz2XhDDqcnVIz0/view?usp=sharing)
 * _Code used to output CPT’s to php file:_ (just for ref – it happens when manually
   exporting too)
 *     ```wp-block-code
       <?php
       /**
        * Class and Functions to Sync CPTUI cpt's and tax's to/from a file
        * Version: 1.0.0
        * @package CPTUI_SYNC
        */
   
        // load cpt and taxonomy config.
       define( 'CPTUI_SYNC_PATH', WP_CONTENT_DIR . '/themes/sps-base-theme/cptui' );
       if ( file_exists( CPTUI_SYNC_PATH . '/custom-post-types.php' ) ) {
       	require_once CPTUI_SYNC_PATH . '/custom-post-types.php';
       }
       if ( file_exists( CPTUI_SYNC_PATH . '/custom-taxonomies.php' ) ) {
       	require_once CPTUI_SYNC_PATH . '/custom-taxonomies.php';
       }
   
   
       /**
        * Export custom CPT's on save
        * using the 'custom-post-types-ui' plugin.
        *
        * @return void
        */
       function cptui_sync_export_cpts_json() {
       	if ( function_exists( 'cptui_get_post_type_data' ) ) {
       		$post_type_export_data = cptui_get_post_type_data();
       		$content               = json_encode( $post_type_export_data, JSON_PRETTY_PRINT );
       		$save_path             = CPTUI_SYNC_PATH;
       		try {
       			$result = file_put_contents( $save_path . '/custom-post-types.json', $content );
       		} catch ( Exception $e ) {
       			// do nothing.
       		}
       	}
       }
       add_action( 'cptui_after_update_post_type', 'cptui_sync_export_cpts_json' );
   
       /**
        * Export custom taxonomies on save
        * using the 'custom-post-types-ui' plugin.
        *
        * @return void
        */
       function cptui_sync_export_taxs_json() {
       	if ( function_exists( 'cptui_get_taxonomy_data' ) ) {
       		$taxonomy_export_data = cptui_get_taxonomy_data();
       		$content              = json_encode( $taxonomy_export_data, JSON_PRETTY_PRINT );
       		$save_path            = CPTUI_SYNC_PATH;
       		try {
       			$result = file_put_contents( $save_path . '/custom-taxonomies.json', $content );
       		} catch ( Exception $e ) {
       			// do nothing.
       		}
       	}
       }
       add_action( 'cptui_after_update_taxonomy', 'cptui_sync_export_taxs_json' );
   
   
       /**
        * Export custom CPT's on save
        * using the 'custom-post-types-ui' plugin.
        *
        * @return void
        */
       function cptui_sync_export_cpts_code() {
       	if ( function_exists( 'cptui_get_post_type_code' ) ) {
       		$cptui_post_types = cptui_get_post_type_data();
       		ob_start();
       		cptui_get_post_type_code( $cptui_post_types );
       		// Return the contents of the output buffer.
       		$post_type_export_data = ob_get_contents();
       		// Clean (erase) the output buffer and turn off output buffering.
       		ob_end_clean();
       		$save_path = CPTUI_SYNC_PATH;
       		try {
       			$result = file_put_contents( $save_path . '/custom-post-types.php', "<?php\n" . $post_type_export_data );
       		} catch ( Exception $e ) {
       			// do nothing.
       		}
       	}
       }
       add_action( 'cptui_after_update_post_type', 'cptui_sync_export_cpts_code' );
   
       /**
        * Export custom taxonomies on save
        * using the 'custom-post-types-ui' plugin.
        *
        * @return void
        */
       function cptui_sync_export_taxs_code() {
       	if ( function_exists( 'cptui_get_taxonomy_code' ) ) {
       		$cptui_taxonomies = cptui_get_taxonomy_data();
       		ob_start();
       		cptui_get_taxonomy_code( $cptui_taxonomies );
       		// Return the contents of the output buffer.
       		$taxonomy_export_data = ob_get_contents();
       		// Clean (erase) the output buffer and turn off output buffering.
       		ob_end_clean();
       		$save_path = CPTUI_SYNC_PATH;
       		try {
       			$result = file_put_contents( $save_path . '/custom-taxonomies.php', "<?php\n" . $taxonomy_export_data );
       		} catch ( Exception $e ) {
       			// do nothing.
       		}
       	}
       }
       add_action( 'cptui_after_update_taxonomy', 'cptui_sync_export_taxs_code' );
       ```
   
 * Hope this helps, eager to hear from you!
 * Terrance
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [3 years ago](https://wordpress.org/support/topic/php-warning-426/#post-16749826)
 * [@earthman100](https://wordpress.org/support/users/earthman100/) Can you try 
   out this copy of the plugin which has what would essentially be the fix I push
   out to address this PHP warning?
 * [https://www.dropbox.com/s/66m1kwo86p294n2/custom-post-type-ui-sort-fix.zip?dl=0](https://www.dropbox.com/s/66m1kwo86p294n2/custom-post-type-ui-sort-fix.zip?dl=0)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP Warning’ is closed to new replies.

 * ![](https://ps.w.org/custom-post-type-ui/assets/icon-256x256.png?rev=2744389)
 * [Custom Post Type UI](https://wordpress.org/plugins/custom-post-type-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-post-type-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-post-type-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-post-type-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-post-type-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-post-type-ui/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/php-warning-426/#post-16749826)
 * Status: resolved