Title: Undefined variable
Last modified: February 6, 2024

---

# Undefined variable

 *  ResolvedModerator [tobifjellner (Tor-Bjorn “Tobi” Fjellner)](https://wordpress.org/support/users/tobifjellner/)
 * (@tobifjellner)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/undefined-variable-98/)
 * Hi,
 * When troubleshooting a client’s site, I stumbled upon a PHP warning that may 
   be good for you to handle:
 * `PHP Warning: Undefined variable $open_graphite_head in .../public_html/wp-content/
   plugins/open-graphite/_open_graphite.php on line 619`
 * Cheers!

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

 *  [chapmangeo](https://wordpress.org/support/users/chapmangeo/)
 * (@chapmangeo)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/undefined-variable-98/#post-17468873)
 * It’s a path through ‘openghead()’ that doesn’t initialize $open_graphite_head.
 *     ```wp-block-code
       /* Open Graph Ouput into <head> */
       add_action('wp_head', 'openghead', $output_priority);
       function openghead() {
   
         /* Homepage */
         if ( is_home() || is_front_page() ) {
   
           $open_graphite_head = '
       <!--/ Open Graphite Start /-->
       <!--/ Open Graphite End /-->' . "\n\n";
   
         /* Other pages, posts and custom post types */
         } else {
           if (isset($ogoptions['post_types']) && in_array(get_post_type(), $ogoptions['post_types']) || class_exists( 'WooCommerce' )) {
   
             $open_graphite_head = '
       <!--/ Open Graphite /-->
       <!--/ Open Graphite End /-->' . "\n\n";
           }
           /*****  This point allows $open_graphite_head to be unset if:
                     is_home() == false
                     is_front_page() == false
                     class_exists( 'WooCommerce' ) == false
                     isset($ogoptions['post_types']) == false --OR-- in_array(get_post_type(), $ogoptions['post_types']) == false
           *****/
         }
   
         echo $open_graphite_head;
       }
       ```
   
 *  Plugin Author [Rocket Apps](https://wordpress.org/support/users/mikeyott/)
 * (@mikeyott)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/undefined-variable-98/#post-17469458)
 * Apologies for the late response. This is now sorted.

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

The topic ‘Undefined variable’ is closed to new replies.

 * ![](https://ps.w.org/open-graphite/assets/icon-256x256.png?rev=2106847)
 * [Open Graphite](https://wordpress.org/plugins/open-graphite/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/open-graphite/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/open-graphite/)
 * [Active Topics](https://wordpress.org/support/plugin/open-graphite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/open-graphite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/open-graphite/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [Rocket Apps](https://wordpress.org/support/users/mikeyott/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/undefined-variable-98/#post-17469458)
 * Status: resolved