/** * Print settings, adds JavaScripts and stylesheets necessary for providing * a data view. * * @since 1.2.0 * @param string $name of the data view * @param string $source URL for data * @param array $headers for the table */ public function print_data_view_settings($name, $source, $headers, $filters, $empty, $order) { // Add JS settings $data_views = array(); $data_views[$name] = array('source' => $source, 'headers' => $headers, 'filters' => $filters, 'order' => $order, 'l10n' => array('loading' => __('Loading data.', $this->plugin_slug), 'ajaxFailed' => __('Failed to load data.', $this->plugin_slug), 'noData' => __("There's no data available that matches your criteria.", $this->plugin_slug), 'currentPage' => __('Page $current of $total', $this->plugin_slug), 'nextPage' => __('Next page', $this->plugin_slug), 'previousPage' => __('Previous page', $this->plugin_slug), 'search' => __('Search', $this->plugin_slug), 'empty' => $empty)); $plugin = H5P_Plugin::get_instance(); $settings = array('dataViews' => $data_views); $plugin->print_settings($settings); // Add JS H5P_Plugin_Admin::add_script('jquery', 'h5p-php-library/js/jquery.js'); H5P_Plugin_Admin::add_script('utils', 'h5p-php-library/js/h5p-utils.js'); H5P_Plugin_Admin::add_script('data-view', 'h5p-php-library/js/h5p-data-view.js'); H5P_Plugin_Admin::add_script('data-views', 'admin/scripts/h5p-data-views.js'); H5P_Plugin_Admin::add_style('admin', 'h5p-php-library/styles/h5p-admin.css'); }
/** * Add generic admin interface assets. * * @since 1.1.0 */ private function add_admin_assets() { foreach (H5PCore::$adminScripts as $script) { H5P_Plugin_Admin::add_script('admin-' . $script, 'h5p-php-library/' . $script); } H5P_Plugin_Admin::add_style('h5p', 'h5p-php-library/styles/h5p.css'); H5P_Plugin_Admin::add_style('admin', 'h5p-php-library/styles/h5p-admin.css'); }
/** * 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(); // Make sure the h5p classes are loaded $plugin->get_h5p_instance('core'); $this->get_h5peditor_instance(); // Add JavaScript settings $settings = $plugin->get_settings(); $cache_buster = '?ver=' . H5P_Plugin::VERSION; // Use jQuery and styles from core. $assets = array('css' => $settings['core']['styles'], 'js' => $settings['core']['scripts']); // Use relative URL to support both http and https. $upload_dir = plugins_url('h5p/h5p-editor-php-library'); $url = '/' . preg_replace('/^[^:]+:\\/\\/[^\\/]+\\//', '', $upload_dir) . '/'; // Add editor styles foreach (H5peditor::$styles as $style) { $assets['css'][] = $url . $style . $cache_buster; } // Add editor JavaScript foreach (H5peditor::$scripts as $script) { // We do not want the creator of the iframe inside the iframe if ($script !== 'scripts/h5peditor-editor.js') { $assets['js'][] = $url . $script . $cache_buster; } } // Add JavaScript with library framework integration (editor part) 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'); // Add translation $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); // Add JavaScript settings $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(), 'assets' => $assets, 'deleteMessage' => __('Are you sure you wish to delete this content?', $this->plugin_slug)); if ($id !== NULL) { $settings['editor']['nodeVersionId'] = $id; } $plugin->print_settings($settings); }