Support » Plugin: AMP » PHP error with stories

  • Resolved colecoboy84


    I had to disable Stories, was getting a php error message: Warning: Cannot use a scalar value as an array in public_html/wp-content/plugins/amp/includes/class-amp-story-post-type.php on line 710. I even deleted and re-installed the AMP plugin, but the issue recurred. Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Weston Ruter


    It appears your site has a wp_kses_allowed_html filter which is returning something other than an array. This is causing the AMP_Story_Post_Type::filter_kses_allowed_html() function in the AMP plugin to issue that warning, since it is expecting an array to be passed in.

    However, I can see in the docs for wp_kses_allowed_html that it actually is supposed to allow either an array of a string. So this would appear to be a defect with the AMP plugin then.

    Plugin Author Weston Ruter


    We’ll fix this in the AMP plugin, but in the mean time you can fix the warning on your site with this patch:

    --- a/includes/class-amp-story-post-type.php
    +++ b/includes/class-amp-story-post-type.php
    @@ -688,6 +688,10 @@ class AMP_Story_Post_Type {
     	 * @return array Allowed tags.
     	public static function filter_kses_allowed_html( $allowed_tags ) {
    +		if ( ! is_array( $allowed_tags ) ) {
    +			return $allowed_tags;
    +		}
     		$story_components = [

    Thank you, Weston! Haven’t really dealt with patches before, so this should be an experience.

    Plugin Author Weston Ruter


    Don’t worry about the patch specifically. You can just add the if statement to the includes/class-amp-story-post-type.php file.

    This change was also merged into the AMP plugin and will be part of the next release:

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.