Skip to content

Commit

Permalink
put better checks in place to fix issue with parse_url not having a p…
Browse files Browse the repository at this point in the history
…roper url to parse
  • Loading branch information
farinspace committed Jan 4, 2012
1 parent ee0c38c commit ebebcd7
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions wp-content/wpalchemy/MetaBox.php
Expand Up @@ -5,7 +5,7 @@
* @copyright Copyright (c) 2009, Dimas Begunoff, http://farinspace.com * @copyright Copyright (c) 2009, Dimas Begunoff, http://farinspace.com
* @license http://en.wikipedia.org/wiki/MIT_License The MIT License * @license http://en.wikipedia.org/wiki/MIT_License The MIT License
* @package WPAlchemy * @package WPAlchemy
* @version 1.4.16 * @version 1.4.17
* @link http://github.com/farinspace/wpalchemy * @link http://github.com/farinspace/wpalchemy
* @link http://farinspace.com * @link http://farinspace.com
*/ */
Expand Down Expand Up @@ -1017,26 +1017,29 @@ function _get_current_post_type()
{ {
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : NULL ; $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : NULL ;


$uri_parts = parse_url($uri); if ( isset( $uri ) )
{
$uri_parts = parse_url($uri);


$file = basename($uri_parts['path']); $file = basename($uri_parts['path']);


if ($uri AND in_array($file, array('post.php', 'post-new.php'))) if ($uri AND in_array($file, array('post.php', 'post-new.php')))
{ {
$post_id = WPAlchemy_MetaBox::_get_post_id(); $post_id = WPAlchemy_MetaBox::_get_post_id();


$post_type = isset($_GET['post_type']) ? $_GET['post_type'] : NULL ; $post_type = isset($_GET['post_type']) ? $_GET['post_type'] : NULL ;


$post_type = $post_id ? get_post_type($post_id) : $post_type ; $post_type = $post_id ? get_post_type($post_id) : $post_type ;


if (isset($post_type)) if (isset($post_type))
{ {
return $post_type; return $post_type;
} }
else else
{ {
// because of the 'post.php' and 'post-new.php' checks above, we can default to 'post' // because of the 'post.php' and 'post-new.php' checks above, we can default to 'post'
return 'post'; return 'post';
}
} }
} }


Expand Down

0 comments on commit ebebcd7

Please sign in to comment.