Title: PHP code snippets Critical Error
Last modified: March 12, 2023

---

# PHP code snippets Critical Error

 *  Resolved [jaredpooley](https://wordpress.org/support/users/jaredpooley/)
 * (@jaredpooley)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/php-code-snippets-critical-error/)
 * I use a PHP code snippet to display a download link for the ACF plugin, however
   when I activate this plugin i get a critical error. The backend page shows the
   following message:
 * “INSERT PHP CODE SNIPPET caused a fatal error and has been deactivated in the
   FDP backend pages.”
 * The error specifically reads:
 *     ```wp-block-code
       Uncaught Error: Call to undefined function get_field() in wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(99) : eval()'d code:2 Stack trace: #0 wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(99): eval() #1 wp-includes/shortcodes.php(355): xyz_ips_display_content(Array, '', 'xyz-ips') #2 [internal function]: do_shortcode_tag(Array) #3 wp-includes/shortcodes.php(227): preg_replace_callback('/\\[(\\[?)(xyz\\-i...', 'do_shortcode_ta...', '[xyz-ips snippe...') #4 wp-content/plugins/elementor-pro/modules/dynamic-tags/tags/shortcode.php(54): do_shortcode('[xyz-ips snippe...') #5 wp-content/plugins/elementor/core/dynamic-tags/tag.php(35): ElementorPro\Modules\DynamicTags\Tags\Shortcode->render() #6 /home/otterbhouse/staging
       ```
   
 * Just if it is any interest, the snippet in question is the following:
 *     ```wp-block-code
       <?php
       $file = get_field('menu_file', 402);
       if( $file ): ?>
           <?php echo $file['url']; ?>
       <?php endif; ?>
       ```
   
 * I have had to deactivate the plugin so the functionality on my site still works.
   Is there anyway to stop it checking for errors/ even leave this page alone completely
   as I can assure I have absolutely no errors when I don’t have this plugin deactivated.

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

 *  Plugin Author [Jose Mortellaro](https://wordpress.org/support/users/giuse/)
 * (@giuse)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/php-code-snippets-critical-error/#post-16552044)
 * Hi [@jaredpooley](https://wordpress.org/support/users/jaredpooley/)
 * the function get_field is defined in the ACF plugin.
   Where you call that function
   the ACF plugin must not be deactivated, in another case that function doesn’t
   exist, and you call something that doesn’t exist, hence you have a fatal error.
 * When you use a function that doesn’t always exist you should first check if that
   function exist. Your code should be something like this:
 *     ```wp-block-code
       <?php 
       $file = function_exists( 'get_field' ) ? get_field('menu_file', 402) : false; 
       if( $file ) echo $file['url'];
       ?>
       ```
   
 * The code above will not generate fatal errors where ACF is not active, however,
   it will not print the file URL when ACF is not active.
 * I suggest you modify your code, but most of all, be sure ACF is always active
   where you call that code.
 * The issue. is probably not caused by a bug but by the fact that you asked FDP
   to disable ACF also where you need it.
 * I hope it helps.
 * Best regards
 * Jose
    -  This reply was modified 3 years, 3 months ago by [Jose Mortellaro](https://wordpress.org/support/users/giuse/).
    -  This reply was modified 3 years, 3 months ago by [Jose Mortellaro](https://wordpress.org/support/users/giuse/).
    -  This reply was modified 3 years, 3 months ago by [Jose Mortellaro](https://wordpress.org/support/users/giuse/).
 *  Thread Starter [jaredpooley](https://wordpress.org/support/users/jaredpooley/)
 * (@jaredpooley)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/php-code-snippets-critical-error/#post-16552180)
 * Legend!
 * That makes so much sense and is working just fine now I have enabled ACF to be
   active on that page.
 * Thank You!
    -  This reply was modified 3 years, 3 months ago by [jaredpooley](https://wordpress.org/support/users/jaredpooley/).

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

The topic ‘PHP code snippets Critical Error’ is closed to new replies.

 * ![](https://ps.w.org/freesoul-deactivate-plugins/assets/icon-256x256.png?rev=
   2847508)
 * [Freesoul Deactivate Plugins - Disable plugins on individual WordPress pages](https://wordpress.org/plugins/freesoul-deactivate-plugins/)
 * [Support Threads](https://wordpress.org/support/plugin/freesoul-deactivate-plugins/)
 * [Active Topics](https://wordpress.org/support/plugin/freesoul-deactivate-plugins/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/freesoul-deactivate-plugins/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/freesoul-deactivate-plugins/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [jaredpooley](https://wordpress.org/support/users/jaredpooley/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/php-code-snippets-critical-error/#post-16552180)
 * Status: resolved