Masalah Crayon Syntax Highlighter di PHP 7.4

Saat coba ditampilkan, halaman post tidak akan menampilkan isi yang sebenarnya. Tetapi hanya menampilkan pesan kesalahan "Call to a member function id() on array".

Masalah ini tampaknya disebabkan adanya ketidaksesuaian dengan versi PHP yang di-upgrade dengan salah satu plugin, yaitu  Crayon Syntax Highlighter. Di server saya masalah terjadi di PHP 7.4, tetapi beberapa laporan menyampaikan bahwa masalah juga terjadi di PHP 7.3. Plugin ini sudah beberapa tahun tidak pernah di-update lagi.


Cara menghindari masalah yang termudah adalah dengan melakukan deaktivasi plugin ini. Cara lainnya adalah dengan melakukan editing seperti pada contoh (saya masih belum mencoba cara ini).

Alternatif pengganti plugin ini salah satunya adalah: SyntaxHighlighter Evolved.


Snippets  [SyntaxHighlighter Settings]:

These are the parameters you can pass to the shortcode and what they do. For the booleans (i.e. on/off), pass true/1 or false/0.

  • lang or language — The language syntax to highlight with. You can alternately just use that as the tag, such as [php]code[/php]Click here for a list of valid tags (under "aliases").
  • autolinks — Toggle automatic URL linking.
  • classname — Add an additional CSS class to the code box.
  • collapse — Toggle collapsing the code box by default, requiring a click to expand it. Good for large code posts.
  • firstline — An interger specifying what number the first line should be (for the line numbering).
  • gutter — Toggle the left-side line numbering.
  • highlight — A comma-separated list of line numbers to highlight. You can also specify a range. Example: 2,5-10,12
  • htmlscript — Toggle highlighting any extra HTML/XML. Good for when you're mixing HTML/XML with another language, such as having PHP inside an HTML web page. The above preview has it enabled for example. This only works with certain languages.
  • light — Toggle light mode which disables the gutter and toolbar all at once.
  • padlinenumbers — Controls line number padding. Valid values are <code>false</code> (no padding), <code>true</code> (automatic padding), or an integer (forced padding).
  • title (v3 only) — Sets some text to show up before the code. Very useful when combined with the collapse parameter.
  • toolbar — Toggle the toolbar (buttons in v2, the about question mark in v3)
  • wraplines (v2 only) — Toggle line wrapping.
  • quickcode — Enable edit mode on double click.

Some example shortcodes:

  • [php]your code here[/php]
  • [css autolinks="false" classname="myclass" collapse="false" firstline="1" gutter="true" highlight="1-3,6,9" htmlscript="false" light="false" padlinenumbers="false" smarttabs="true" tabsize="4" toolbar="true" title="example-filename.php"]your code here[/css]
  • [code lang="js"]your code here[/code]
  • [sourcecode language="plain"]  your code here  [/sourcecode]

  • [code lang="C"]  your code here  [/code]

You'll only receive email when they publish something new.

More from Sunu Pradana
All posts