Welcome to our new Help Center. We’re still adding articles, and if you can’t find an answer yet, we’re happy to help.Contact Us

What’s changed for developers in LayerSlider 9

LayerSlider 9 needs newer PHP and WordPress, loads projects far down a page later, and drops the Transition Builder and a few settings. Old hooks and commands remain, and a few are new.

On this page

    JavaScript

    LayerSlider 9 loads the projects closest to the viewport first, so a project far below the first screen loads after the page has loaded. Code that runs at the window’s load event can find such a project not loaded yet. To have such a project load with the page, give it the highest load priority.

    Every command and every event of the old documentation still exists in LayerSlider 9.

    PHP and hooks

    LayerSlider 9 needs newer versions of PHP and WordPress than LayerSlider 8 did. On a server with older versions of PHP or WordPress, LayerSlider loads nothing, so none of its functions, classes, or hooks exist. Check your server against the versions that LayerSlider 9 needs, and guard your calls with function_exists( 'layerslider' ) or class_exists( 'LS_Sliders' ).

    In LayerSlider 9, a group can hold another group. With the groups option of find() set to true, a group’s items can include a group, which has its own items and whose data is NULL. If your code reads data from each entry of items, test flag_group first. The keys are listed under what find() returns.

    In LayerSlider 9, the HTML that the layerslider_slider_markup filter receives can start with <link> tags for the project’s web fonts, before the rest of the project’s HTML. If your filter expects the string to begin with the project’s element, find the element in the string by the id that the filter receives as its third argument.

    Every action and filter of the old documentation still exists in LayerSlider 9.

    The Transition Builder and removed settings

    The Transition Builder is gone, and with it the custom slide transitions that it made. LayerSlider 9 doesn’t load layerslider.custom.transitions.js and doesn’t read layerSliderCustomTransitions, so you can remove code that writes the file or defines the variable. A slide that used a custom transition plays a built-in transition instead. If the slide also selects a built-in transition, it plays that one.

    LayerSlider 9 has no markup caching, and the sandbox of its copy of GSAP can’t be turned off. So use_cache and gsap_sandboxing have no effect in a call of LS_Config::forceSettings(), and neither does use_custom_jquery, which had no effect before LayerSlider 9 either. Such a call causes no error and changes nothing on the page. Remove these keys from the call, or the whole call if it holds nothing else.

    Themes that bundle LayerSlider

    We no longer sell the In-Stock license, and a license of any plan takes its place. To bundle LayerSlider in a theme, you need one license for each theme that bundles it.

    layerslider_set_as_theme() and layerslider_hide_promotions() do what they did before LayerSlider 9. On a site without a registered license, layerslider_set_as_theme() changes the closing line of the license box, which reads “Got LayerSlider with a theme? Learn more” in LayerSlider 9. layerslider_hide_promotions() changes nothing, and you can remove its call.

    Skins, including those a theme adds with LS_Sources::addSkins(), apply only to projects on the legacy navigation. A new project isn’t on the legacy navigation, so it loads no skin, and Project Settings › Appearance doesn’t show the Skin list for it.

    New in LayerSlider 9

    LayerSlider 9 adds these for your code to use:

    • muteMedia mutes the project’s media layers, and it’s listed with the other commands.
    • mediaPlayStateDidChange fires each time a video layer starts or stops playing, and mediaMuteStateDidChange fires when the project’s sound is muted or unmuted. They’re listed with the other events.
    • ls_can_access_library decides whether the current user can use the project picker, the Choose Project window, and it’s described with the other filters. Without code, the Project Library Access list in Plugin Settings › Permissions does the same.

    Code from the old documentation

    Code copied from the examples of the old documentation can fail in these ways, none of them new in LayerSlider 9.

    If your code selects a project by its element id

    Code that selects a project by an element id such as #layerslider_12 finds nothing. The element id ends in a random part, new for each copy of the project on every page load. The random part lets a page show the same project more than once. Select the project by the start of its element id instead, as [id^="layerslider_12_"], or by its slug.

    If your code uses $ instead of jQuery

    Code that uses $ as the old examples do stops with an error on the pages of a WordPress site with a default theme, because $ isn’t defined there. Write jQuery instead.

    If your code calls a project before it has loaded

    A command sent before the project has loaded can be lost without a message, and a getter called that early fails. A call made in a script right after the project, in a jQuery ready handler, or in a sliderWillLoad handler comes before the project has loaded. Make such calls in a sliderDidLoad handler instead.

    If your event handler doesn’t run

    An event handler doesn’t run if it’s bound on a parent element of the project or delegated from the document. A handler whose event name has a namespace of your own doesn’t run either. Bind the handler on the project itself instead, with the event’s plain name.