public/wordpress/wp-content/plugins/h5p/admin/class-h5p-content-admin.php
/**
   * Add assets and JavaScript settings for the editor.
   *
   * @since 1.1.0
   * @param int $id optional content identifier
   */
Add assets and JavaScript settings for the editor.
@since 1.1.0
@param int $id optional content identifier
Add assets and JavaScript settings for the editor . @since 1 . 1 . 0 @param int $id optional content identifier
public function add_editor_assets($id = NULL) {
    $plugin = H5P_Plugin::get_instance();
    $plugin->add_core_assets();
    $plugin->get_h5p_instance('core');
    $this->get_h5peditor_instance();
    $settings = $plugin->get_settings();
    $cache_buster = '?ver=' . H5P_Plugin::VERSION;
    $assets = array(
      'css' => $settings['core']['styles'],
      'js' => $settings['core']['scripts']
    );
    $upload_dir = plugins_url('h5p/h5p-editor-php-library');
    $url = '/' . preg_replace('/^[^:]+:\/\/[^\/]+\//', '', $upload_dir) . '/';
    foreach (H5peditor::$styles as $style) {
      $assets['css'][] = $url . $style . $cache_buster;
    }
    foreach (H5peditor::$scripts as $script) {
      if ($script !== 'scripts/h5peditor-editor.js') {
        $assets['js'][] = $url . $script . $cache_buster;
      }
    }
    H5P_Plugin_Admin::add_script('editor-editor', 'h5p-editor-php-library/scripts/h5peditor-editor.js');
    H5P_Plugin_Admin::add_script('editor', 'admin/scripts/h5p-editor.js');
    $language = $plugin->get_language();
    $language_script = 'h5p-editor-php-library/language/' . $language . '.js';
    if (!file_exists(plugin_dir_path(__FILE__) . '../' . $language_script)) {
      $language_script = 'h5p-editor-php-library/language/en.js';
    }
    H5P_Plugin_Admin::add_script('language', $language_script);
    $content_validator = $plugin->get_h5p_instance('contentvalidator');
    $settings['editor'] = array(
      'filesPath' => $plugin->get_h5p_url() . '/editor',
      'fileIcon' => array(
        'path' => plugins_url('h5p/h5p-editor-php-library/images/binary-file.png'),
        'width' => 50,
        'height' => 50,
      ),
      'ajaxPath' => admin_url('admin-ajax.php?token=' . wp_create_nonce('h5p_editor_ajax') . '&action=h5p_'),
      'libraryUrl' => plugin_dir_url('h5p/h5p-editor-php-library/h5peditor.class.php'),
      'copyrightSemantics' => $content_validator->getCopyrightSemantics(),
      'metadataSemantics' => $content_validator->getMetadataSemantics(),
      'assets' => $assets,
      'deleteMessage' => __('Are you sure you wish to delete this content?', $this->plugin_slug),
      'apiVersion' => H5PCore::$coreApi,
      'language' => $language
    );
    if ($id !== NULL) {
      $settings['editor']['nodeVersionId'] = $id;
    }
    $plugin->print_settings($settings);
  }
public function add_editor_assets ( $ id = NULL ) { $ plugin = H5P_Plugin :: get_instance ( ) ; $ plugin -> add_core_assets ( ) ; $ plugin -> get_h5p_instance ( 'core' ) ; $ this -> get_h5peditor_instance ( ) ; $ settings = $ plugin -> get_settings ( ) ; $ cache_buster = '?ver=' . H5P_Plugin :: VERSION ; $ assets = array ( 'css' => $ settings [ 'core' ] [ 'styles' ] , 'js' => $ settings [ 'core' ] [ 'scripts' ] ) ; $ upload_dir = plugins_url ( 'h5p/h5p-editor-php-library' ) ; $ url = '/' . preg_replace ( '/^[^:]+:\/\/[^\/]+\//' , '' , $ upload_dir ) . '/' ; foreach ( H5peditor :: $ styles as $ style ) { $ assets [ 'css' ] [ ] = $ url . $ style . $ cache_buster ; } foreach ( H5peditor :: $ scripts as $ script ) { if ( $ script !== 'scripts/h5peditor-editor.js' ) { $ assets [ 'js' ] [ ] = $ url . $ script . $ cache_buster ; } } H5P_Plugin_Admin :: add_script ( 'editor-editor' , 'h5p-editor-php-library/scripts/h5peditor-editor.js' ) ; H5P_Plugin_Admin :: add_script ( 'editor' , 'admin/scripts/h5p-editor.js' ) ; $ language = $ plugin -> get_language ( ) ; $ language_script = 'h5p-editor-php-library/language/' . $ language . '.js' ; if ( ! file_exists ( plugin_dir_path ( __FILE__ ) . '../' . $ language_script ) ) { $ language_script = 'h5p-editor-php-library/language/en.js' ; } H5P_Plugin_Admin :: add_script ( 'language' , $ language_script ) ; $ content_validator = $ plugin -> get_h5p_instance ( 'contentvalidator' ) ; $ settings [ 'editor' ] = array ( 'filesPath' => $ plugin -> get_h5p_url ( ) . '/editor' , 'fileIcon' => array ( 'path' => plugins_url ( 'h5p/h5p-editor-php-library/images/binary-file.png' ) , 'width' => 50 , 'height' => 50 , ) , 'ajaxPath' => admin_url ( 'admin-ajax.php?token=' . wp_create_nonce ( 'h5p_editor_ajax' ) . '&action=h5p_' ) , 'libraryUrl' => plugin_dir_url ( 'h5p/h5p-editor-php-library/h5peditor.class.php' ) , 'copyrightSemantics' => $ content_validator -> getCopyrightSemantics ( ) , 'metadataSemantics' => $ content_validator -> getMetadataSemantics ( ) , 'assets' => $ assets , 'deleteMessage' => __ ( 'Are you sure you wish to delete this content?' , $ this -> plugin_slug ) , 'apiVersion' => H5PCore :: $ coreApi , 'language' => $ language ) ; if ( $ id !== NULL ) { $ settings [ 'editor' ] [ 'nodeVersionId' ] = $ id ; } $ plugin -> print_settings ( $ settings ) ; }
Add assets and JavaScript settings for the editor.
Add assets and JavaScript settings for the editor .
// Make sure the h5p classes are loaded // Add JavaScript settings // Use jQuery and styles from core. // Use relative URL to support both http and https. // Add editor styles // Add editor JavaScript // We do not want the creator of the iframe inside the iframe // Add JavaScript with library framework integration (editor part) // Add translation // Add JavaScript settings