diff --git a/class/main.class.php b/class/main.class.php index f1d49e7..d152a63 100644 --- a/class/main.class.php +++ b/class/main.class.php @@ -21,7 +21,6 @@ class CWV3 { add_filter( 'manage_page_posts_columns', array( $this, 'post_cols' ) ); add_filter( 'manage_post_posts_columns', array( $this, 'post_cols' ) ); - //add_action('quick_edit_custom_box', array(&$this, 'display_qe'), 10, 2); // Post column info @@ -38,17 +37,15 @@ class CWV3 { $img = get_option( 'cwv3_bg_image', '' ); $color = get_option( 'cwv3_bg_color' ); ?> json_decode( stripslashes( $_COOKIE['cwv3_pages'] ) ), - 'posts' => json_decode( stripslashes( $_COOKIE['cwv3_posts'] ) ), - 'categories' => json_decode( stripslashes( $_COOKIE['cwv3_cats'] ) ) + // check isset before access (edit by @jgraup) + 'pages' => !isset($_COOKIE['cwv3_pages']) ? '' : json_decode( stripslashes( $_COOKIE['cwv3_pages'] ) ), + 'posts' => !isset($_COOKIE['cwv3_posts']) ? '' : json_decode( stripslashes( $_COOKIE['cwv3_posts'] ) ), + 'categories' => !isset($_COOKIE['cwv3_cats']) ? '' : json_decode( stripslashes( $_COOKIE['cwv3_cats'] ) ) ); - if ( !empty( $sw ) == 'enabled' ) { + // ensure we're using valid objects (edit by @jgraup) + foreach ($cData as $key => $value) { + if(is_scalar($value)){ + $cData[$key] = new stdClass; + } + } + + if ( !empty( $sw ) == 'enabled' ) { $cData['pages']->sitewide = $action; return setcookie( 'cwv3_pages', json_encode( $cData['pages'] ), ( $time['multiplier'] * $time['time'] )+time(), COOKIEPATH, COOKIE_DOMAIN, false ); } @@ -217,12 +226,13 @@ class CWV3 { //Don't want to hender the feed, just in case. return true; } - $cData = array( - 'pages' => json_decode( stripslashes( @$_COOKIE['cwv3_pages'] ), true ), - 'posts' => json_decode( stripslashes( @$_COOKIE['cwv3_posts'] ), true ), - 'categories' => json_decode( stripslashes( @$_COOKIE['cwv3_cats'] ), true ) - ); + $cData = array( + // check isset before access (edit by @jgraup) + 'pages' => !isset($_COOKIE['cwv3_pages']) ? '' : json_decode( stripslashes( @$_COOKIE['cwv3_pages'] ), true ), + 'posts' => !isset($_COOKIE['cwv3_posts']) ? '' : json_decode( stripslashes( @$_COOKIE['cwv3_posts'] ), true ), + 'categories' => !isset($_COOKIE['cwv3_cats']) ? '' : json_decode( stripslashes( @$_COOKIE['cwv3_cats'] ), true ) + ); $sw = get_option( 'cwv3_sitewide' ); $hm = get_option( 'cwv3_homepage' ); @@ -290,7 +300,7 @@ class CWV3 {
-
+
@@ -302,8 +312,6 @@ class CWV3 { $curval = get_post_meta( $post->ID, 'cwv3_auth', true ); $sw = get_option( 'cwv3_sitewide' ); $disabled = $sw[0] == 'enabled' ? 'disabled="disabled"' : ''; - - ?> value="yes" />
@@ -350,4 +358,4 @@ class CWV3 { } new CWV3; -?> +?> \ No newline at end of file