diff --git a/includes/jw_player.filter.inc b/includes/jw_player.filter.inc
deleted file mode 100644
index 8b70ec2..0000000
--- a/includes/jw_player.filter.inc
+++ /dev/null
@@ -1,123 +0,0 @@
- t('JW Player Filter'),
- 'description' => t('Substitutes [jwplayer] shortcode markup with an embedded media file.'),
- 'process callback' => 'jw_player_jw_player_shortcode_process',
- 'tips callback' => 'jw_player_jw_player_shortcode_tips',
- 'weight' => 0,
- );
- return $filters;
-}
-
-/**
- * Helper function to provide on screen tips for using the filter.
- */
-function jw_player_jw_player_shortcode_tips($filter, $format, $long = FALSE) {
- return t('You may insert media with [jwplayer] shortcode markup. Available parameters include: file (required), image, preset (machine name), image_style (machine name), width, height. Example: [jwplayer|file=http://site.com/video.mp4|preset=my_preset_settings]');
-}
-
-/**
- * Callback function to perform the content processing.
- */
-function jw_player_jw_player_shortcode_process($text, $filter, $format, $langcode, $cache, $cache_id) {
- // Detect JW Player shortcode in the context.
- $regex = '/(\[(\
|\s)*jwplayer(\
|\s)*(\|([a-zA-Z0-9_.\s]+=[-a-zA-Z0-9+.,\(\){}:&@#\/\?<>\"%=~_\'\"\s]+))*(\
|\s)*\])/';
- preg_match_all($regex, $text, $matches);
- $shortcodes = $matches[0];
- if (!empty($shortcodes)) {
- foreach ($shortcodes as $shortcode) {
- $element = _jw_player_filter_prepare_player($shortcode);
- if (!$element) {
- continue;
- }
-
- // Get the markup for this player.
- $new_markup = drupal_render($element);
-
- // Replace the original shortcode with the markup.
- $text = str_replace($shortcode, $new_markup, $text);
- }
- }
- return $text;
-}
-
-/**
- * Prepares a Render Array for theme_jw_player_player().
- *
- * It is similar to jw_player_field_formatter_view()
- * with modifications for inline shortcodes.
- *
- * @param string $shortcode
- * A shortcode string.
- *
- * @return array $element
- * A renderable array element.
- *
- * @see jw_player_field_formatter_view()
- */
-function _jw_player_filter_prepare_player($shortcode) {
- $shortcode = str_replace('
', '', $shortcode);
- $shortcode = preg_replace('/\[(\s)*jwplayer(\s)*(\||\])/', '', $shortcode);
- $shortcode = str_replace(']', '', $shortcode);
- $args = preg_split('/\|/', $shortcode);
- // Validate and add parameters.
- $item = array();
- foreach ($args as $fvar) {
- $key_val = preg_split('/=/', $fvar, 2);
- // Build element as long as keys are not empty.
- if (!empty($key_val[0])) {
- $key_val[0] = trim($key_val[0]);
- // Strip out damaging auto link filter.
- $key_val[1] = trim(preg_replace('/<(.)*>/U', '', $key_val[1]));
- switch ($key_val[0]) {
- case 'file':
- case 'image':
- case 'preset':
- case 'image_style':
- $item[$key_val[0]] = $key_val[1];
- break;
- default:
- $item['option'][$key_val[0]] = $key_val[1];
- break;
- }
- }
- }
- // Only render if a file exists.
- $element = array();
- if (isset($item['file'])) {
- $element = array(
- '#type' => 'jw_player',
- '#player_type' => 'player',
- '#theme' => 'jw_player_player',
- '#preset' => isset($item['preset']) ? $item['preset'] : '',
- '#image_style' => isset($item['image_style']) ? $item['image_style'] : '',
- '#files' => array(
- array(
- 'file' => $item['file'],
- 'image' => isset($item['image']) ? $item['image'] : '',
- ),
- ),
- );
- if (isset($item['option'])) {
- foreach ($item['option'] as $key => $value) {
- $element['#options'][$key] = $value;
- }
- }
-
- // Build #html_id based on url, player type, and preset.
- $items[0]['url'] = $item['file'];
- $settings = array(
- 'player_type' => $element['#player_type'],
- 'jwplayer_preset' => $element['#preset'],
- );
- $element['#html_id'] = jw_player_build_player_id($items, $settings);
- }
-
- return $element;
-}
diff --git a/jw_player.module b/jw_player.module
index 7fdda9e..71cf237 100644
--- a/jw_player.module
+++ b/jw_player.module
@@ -7,8 +7,6 @@
define('JW_PLAYER_DEFAULT_PLAYLIST_SIZE', 200);
define('JW_PLAYER_DEFAULT_PLAYLIST_POSITION', 'right');
-module_load_include('inc', 'jw_player', 'includes/jw_player.filter');
-
/**
* Implements hook_menu().
*/
@@ -959,6 +957,137 @@ function jw_player_supports($file) {
}
/**
+ * Implements hook_filter_info().
+ */
+function jw_player_filter_info() {
+ $filters = array();
+ $filters['jw_player_shortcode'] = array(
+ 'title' => t('JW Player Filter'),
+ 'description' => t('Substitutes [jwplayer] shortcode markup with an embedded media file.'),
+ 'process callback' => 'jw_player_jw_player_shortcode_process',
+ 'tips callback' => 'jw_player_jw_player_shortcode_tips',
+ 'weight' => 0,
+ );
+ return $filters;
+}
+
+/**
+ * Helper function to provide on screen tips for using the filter.
+ *
+ * @return string
+ * String to be displayed within input filter tips.
+ */
+function jw_player_jw_player_shortcode_tips($filter, $format, $long = FALSE) {
+ return t('You may insert media with [jwplayer] shortcode markup. Available parameters include: file (required), image, preset (machine name), image_style (machine name), width, height. Example: [jwplayer|file=http://site.com/video.mp4|preset=my_preset_settings]');
+}
+
+/**
+ * Callback function to perform the content processing.
+ *
+ * @param string $text
+ * Text to be processed by input filter.
+ *
+ * @return string
+ * Modified text where shortcodes have been replaced by rendered elements.
+ */
+function jw_player_jw_player_shortcode_process($text, $filter, $format, $langcode, $cache, $cache_id) {
+ // Detect JW Player shortcode in the context.
+ $regex = '/(\[(\
|\s)*jwplayer(\
|\s)*(\|([a-zA-Z0-9_.\s]+=[-a-zA-Z0-9+.,\(\){}:&@#\/\?<>\"%=~_\'\"\s]+))*(\
|\s)*\])/';
+ preg_match_all($regex, $text, $matches);
+ $shortcodes = $matches[0];
+ if (!empty($shortcodes)) {
+ foreach ($shortcodes as $shortcode) {
+ $element = _jw_player_filter_prepare_player($shortcode);
+ if (!$element) {
+ continue;
+ }
+
+ // Get the markup for this player.
+ $new_markup = render($element);
+
+ // Replace the original shortcode with the markup.
+ $text = str_replace($shortcode, $new_markup, $text);
+ }
+ }
+ return $text;
+}
+
+/**
+ * Prepares a render array for theme_jw_player_player().
+ *
+ * It is similar to jw_player_field_formatter_view()
+ * with modifications for inline shortcodes.
+ *
+ * @param string $shortcode
+ * A shortcode string.
+ *
+ * @return array $element
+ * A renderable array element.
+ *
+ * @see jw_player_field_formatter_view()
+ */
+function _jw_player_filter_prepare_player($shortcode) {
+ $shortcode = str_replace('
', '', $shortcode);
+ $shortcode = preg_replace('/\[(\s)*jwplayer(\s)*(\||\])/', '', $shortcode);
+ $shortcode = str_replace(']', '', $shortcode);
+ $args = preg_split('/\|/', $shortcode);
+ // Validate and add parameters.
+ $item = array();
+ foreach ($args as $fvar) {
+ $key_val = preg_split('/=/', $fvar, 2);
+ // Build element as long as keys are not empty.
+ if (!empty($key_val[0])) {
+ $key_val[0] = trim($key_val[0]);
+ // Strip out damaging auto link filter.
+ $key_val[1] = trim(preg_replace('/<(.)*>/U', '', $key_val[1]));
+ switch ($key_val[0]) {
+ case 'file':
+ case 'image':
+ case 'preset':
+ case 'image_style':
+ $item[$key_val[0]] = $key_val[1];
+ break;
+ default:
+ $item['option'][$key_val[0]] = $key_val[1];
+ break;
+ }
+ }
+ }
+ // Only render if a file exists.
+ $element = array();
+ if (isset($item['file'])) {
+ $element = array(
+ '#type' => 'jw_player',
+ '#player_type' => 'player',
+ '#theme' => 'jw_player_player',
+ '#preset' => isset($item['preset']) ? $item['preset'] : '',
+ '#image_style' => isset($item['image_style']) ? $item['image_style'] : '',
+ '#files' => array(
+ array(
+ 'file' => $item['file'],
+ 'image' => isset($item['image']) ? $item['image'] : '',
+ ),
+ ),
+ );
+ if (isset($item['option'])) {
+ foreach ($item['option'] as $key => $value) {
+ $element['#options'][$key] = $value;
+ }
+ }
+
+ // Build #html_id based on url, player type, and preset.
+ $items[0]['url'] = $item['file'];
+ $settings = array(
+ 'player_type' => $element['#player_type'],
+ 'jwplayer_preset' => $element['#preset'],
+ );
+ $element['#html_id'] = jw_player_build_player_id($items, $settings);
+ }
+
+ return $element;
+}
+
+/**
* Checks whether a legacy version is configured.
*
* @return bool