Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some debug problems (blog page, style.php) #838

Closed
infokurs opened this issue May 13, 2017 · 0 comments
Closed

Some debug problems (blog page, style.php) #838

infokurs opened this issue May 13, 2017 · 0 comments
Milestone

Comments

@infokurs
Copy link

Corresponds also to reported debug notice https://wordpress.org/support/topic/debug-0-9-49/

  1. PHP Notice: Trying to get property of non-object in /var/www/public/defiant-bat/wp-content/plugins/accelerated-mobile-pages/accelerated-moblie-pages.php on line 39

Source:
// Frontpage and Blog page check from reading settings. function ampforwp_name_blog_page() { $page_for_posts = get_option( 'page_for_posts' ); $post = get_post($page_for_posts); $slug = $post->post_name; return $slug; } function ampforwp_custom_post_page() { $front_page_type = get_option( 'show_on_front' ); return $front_page_type; }
and
// For Homepage with Pagination if ( ampforwp_custom_post_page() && ampforwp_name_blog_page() ) { add_rewrite_rule( ampforwp_name_blog_page(). '/amp/page/([0-9]{1,})/?$', 'index.php?amp&paged=$matches[1]', 'top' ); }

Is a small logic problem.
Blog page is optional and is used only in one case - Reading Settings, Front page displays >> A static page (select below) + selected Posts page.
reference: https://developer.wordpress.org/reference/functions/is_home/#usage

Else ...page_for_posts return 0, well get_post() not return valid post object ...and push notice on trying read slug.

Try something like:
// Blog page check from reading settings. function ampforwp_name_blog_page() { $page_for_posts = get_option( 'page_for_posts' ); if( ampforwp_custom_post_page() == 'page' && $page_for_posts != 0 ) { $post = get_post($page_for_posts); $slug = $post->post_name; return $slug; } return false; } function ampforwp_custom_post_page() { $front_page_type = get_option( 'show_on_front' ); return $front_page_type; }
and
// For Blog page with Pagination if ( ampforwp_name_blog_page() ) { add_rewrite_rule( ampforwp_name_blog_page(). '/amp/page/([0-9]{1,})/?$', 'index.php?amp&paged=$matches[1]', 'top' ); }

  1. [12-May-2017 19:40:45 UTC] PHP Notice: Undefined variable: post_id in /var/www/public/defiant-bat/wp-content/plugins/accelerated-mobile-pages/templates/design-manager/design-2/style.php on line 10

style.php in all designs contain: $get_customizer = new AMP_Post_Template( $post_id );
...and $post_id is from ???

@infokurs infokurs changed the title Some debug problems (blog page, style.php Some debug problems (blog page, style.php) May 13, 2017
infokurs added a commit to infokurs/accelerated-mobile-pages that referenced this issue May 13, 2017
@ahmedkaludi ahmedkaludi modified the milestone: 0.9.51 May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants