Notice: Trying to get property of non-object in C:\Users\xxxxxx\Desktop\xxxxxx\wordpress\wp-content\plugins\ps-auto-sitemap\ps_auto_sitemap.php on line 61
wordpressのプラグインで上記のエラーがでるようになってしまいました
以下がエラーコードが記述されている部分ですが、どのように記述し直すとエラーが解決しますでしょうか?
58行目から150行目までコード記述しておきますのでよろしくお願いします
function ps_auto_sitemap_init() {
$this->option = get_option( 'ps_sitemap' );
if ( ! $this->option ) {
$this->set_default_options();
$this->option = get_option( 'ps_sitemap' );
}
}
function replace_sitemap_content( $content ) { global $post; if ( $this->option['post_id'] && $post->ID == $this->option['post_id'] ) { if ( isset( $_GET['category'] ) && $category = get_category( (int)$_GET['category'] ) ) { $sitemap_content = $this->make_category_sitemap( $category ); } else { $cache_dir = $this->check_cache_dir(); if ( $cache_dir && file_exists( $cache_dir . '/site_map_cache.html' ) && $this->option['use_cache'] ) { $sitemap_content = file_get_contents( $cache_dir . '/site_map_cache.html' ); } else { $sitemap_content = $this->create_sitemap_content(); } } $content = preg_replace( '/(<p><!-- SITEMAP CONTENT REPLACE POINT --><\/p>|<!-- SITEMAP CONTENT REPLACE POINT -->)/', $sitemap_content, $content, 1 ); } return $content; } function create_sitemap_content() { if ( $this->option['post_tree'] == '1' ) { $category_tree = $this->make_category_tree( $this->option['ex_cat_ids'] ); $post_list = $this->make_post_list( $this->option['ex_post_ids'], $category_tree, $this->option['disp_level'], 1, false ); } else { $post_list = ''; } $page_on_front = get_option( 'page_on_front' ); $ex_pages = $this->option['ex_post_ids']; if ( get_option( 'show_on_front') == 'page' && $page_on_front ) { if ( $ex_pages ) { $ex_pages .= ',' . $page_on_front; } else { $ex_pages = $page_on_front; } } $sitemap_content = "<ul id=\"sitemap_list\" class=\"sitemap_disp_level_" . $this->option['disp_level'] . "\">\n"; if ($this->option['home_list'] ) { $sitemap_content .= '<li class="home-item"><a href="' . get_bloginfo( 'url' ) . '" title="' . get_bloginfo( 'name' ) . '">' . esc_html( get_bloginfo( 'name' ) ) . "</a></li>\n"; } if ( $this->option['disp_first'] == 'post' ) { $sitemap_content .= $post_list; if ( $this->option['page_tree'] == '1' ) { $sitemap_content .= wp_list_pages( 'title_li=&echo=0&exclude=' . $ex_pages . '&depth=' . $this->option['disp_level'] ); } } else { if ( $this->option['page_tree'] == '1' ) { $sitemap_content .= wp_list_pages( 'title_li=&echo=0&exclude=' . $ex_pages . '&depth=' . $this->option['disp_level'] ); } $sitemap_content .= $post_list; } $sitemap_content .= "</ul>\n"; if ( ( $cache_dir = $this->check_cache_dir() ) && $this->option['use_cache'] ) { $this->check_htaccess( $cache_dir ); $handle = @fopen( $cache_dir . '/site_map_cache.html', 'w' ); if ( $handle ) { fwrite( $handle, $sitemap_content ); fclose( $handle ); } } return $sitemap_content; }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。