add_script_data() public method

Adds the given data to the given script, and handles it in case the script has been enqueued already.
Since: 3.0.0
public add_script_data ( Inpsyde\MultilingualPress\Asset\Script | string $script, string $object_name, array $data ) : Inpsyde\MultilingualPress\Asset\Script | null
$script Inpsyde\MultilingualPress\Asset\Script | string Script object or handle.
$object_name string The name of the JavaScript variable holding the data.
$data array The data to be made available for the script.
return Inpsyde\MultilingualPress\Asset\Script | null Script object if it exists, null if not.
 /**
  * @param string $hook
  *
  * @return void
  */
 public function load_script($hook)
 {
     if ('nav-menus.php' !== $hook) {
         return;
     }
     $this->asset_manager->add_script_data('multilingualpress-admin', 'mlpNavMenusSettings', ['action' => $this->handle, 'metaBoxId' => $this->handle, 'nonce' => (string) $this->nonce, 'nonceName' => $this->nonce->action()]);
 }
 /**
  * Makes the relationship control settings available for JavaScript.
  *
  * @return void
  */
 private function localize_script()
 {
     if (self::$is_script_localized) {
         return;
     }
     $this->asset_manager->add_script_data('multilingualpress-admin', 'mlpRelationshipControlSettings', ['actionConnectExisting' => RelationshipController::ACTION_CONNECT_EXISTING, 'actionConnectNew' => RelationshipController::ACTION_CONNECT_NEW, 'actionDisconnect' => RelationshipController::ACTION_DISCONNECT, 'l10n' => ['noPostSelected' => __('Please select a post.', 'multilingual-press'), 'unsavedRelationships' => __('You have unsaved changes in your post relationships. The changes you made will be lost if you navigate away from this page.', 'multilingual-press')]]);
     /**
      * Filters the minimum number of characters required to fire the live search.
      *
      * @param int $threshold Minimum number of characters required to fire the live search.
      */
     $threshold = (int) apply_filters('multilingualpress.relationship_control_search_threshold', 3);
     $this->asset_manager->add_script_data('multilingualpress-admin', 'mlpLiveSearchSettings', ['action' => SearchController::ACTION, 'argName' => Search::ARG_NAME, 'threshold' => max(1, $threshold)]);
     self::$is_script_localized = true;
 }