highcharts / highcharts-editor

https://www.highcharts.com/products/highcharts-editor
Other
250 stars 96 forks source link

WordPress plugin shows error in page editor "undefined index: extended_valid_elements" #134

Closed ualr-djspillers closed 6 years ago

ualr-djspillers commented 7 years ago

Full error: Notice: Undefined index: extended_valid_elements in /data/htdocs/oir-datahub.test.ualr.edu/dashboard/wp-content/plugins/highcharts-editor/highcharts-editor.php on line 23

In the $settings array that is part of the tiny_mce_before_init filter, there doesn't seem to be an 'extended_valid_elements' key already there, so appending fails.

The WordPress codex provides some example code that does a check to see if an array item is already there before modifying it. Perhaps something like this:

function highcharts_allow_stuff($initArray) {
    if ( ! empty( $initArray['extended_valid_elements'] ) ) {
        $initArray['extended_valid_elements'] .= ',';
    } else {
        $initArray['extended_valid_elements'] = '';
    }

    $initArray['extended_valid_elements'] .= 'div[id|style|class],a[*],altGlyph[*],altGlyphDef[*],altGlyphItem[*],animate[*],animateColor[*],animateMotion[*],animateTransform[*],circle[*],clipPath[*],color-profile[*],cursor[*],defs[*],desc[*],ellipse[*],feBlend[*],feColorMatrix[*],feComponentTransfer[*],feComposite[*],feConvolveMatrix[*],feDiffuseLighting[*],feDisplacementMap[*],feDistantLight[*],feFlood[*],feFuncA[*],feFuncB[*],feFuncG[*],feFuncR[*],feGaussianBlur[*],feImage[*],feMerge[*],feMergeNode[*],feMorphology[*],feOffset[*],fePointLight[*],feSpecularLighting[*],feSpotLight[*],feTile[*],feTurbulence[*],filter[*],font[*],font-face[*],font-face-format[*],font-face-name[*],font-face-src[*],font-face-uri[*],foreignObject[*],g[*],glyph[*],glyphRef[*],hkern[*],image[*],line[*],linearGradient[*],marker[*],mask[*],metadata[*],missing-glyph[*],mpath[*],path[*],pattern[*],polygon[*],polyline[*],radialGradient[*],rect[*],script[*],set[*],stop[*],style[*],svg[*],switch[*],symbol[*],text[*],textPath[*],title[*],tref[*],tspan[*],use[*],view[*],vkern[*]';

    return $initArray;
}

WordPress version: 4.7.4 PHP version: 7.0.10 Plugin version: 0.2 (0.1.3 beta?)