/** * Sorted video and poster url * * @since 1.0.0 * @return array */ private function sorted_array($array) { $output_array = array('video' => array(), 'poster' => ''); $default_types = wp_get_video_extensions(); $pattern = '/.(' . implode('|', $default_types) . ')/im'; foreach ($array as $url) { foreach ($default_types as $type) { if (strpos($url, $type)) { $output_array['video'][$type] = $url; } } if (!preg_match($pattern, $url)) { $output_array['poster'] = $url; } } return $output_array; }
/** * Return an array of files prepared for output. * * Processes files by file type and generates unique output for each. * * Returns array for each file, with the following keys: * * `file_path` => The file path of the file, with a line break * `html` => The file output HTML formatted * * @since 1.2 * @todo Support `playlist` shortcode for playlist of video/audio * @usedby gravityview_get_files_array() * @param string $value Field value passed by Gravity Forms. String of file URL, or serialized string of file URL array * @param string $gv_class Field class to add to the output HTML * @return array Array of file output, with `file_path` and `html` keys (see comments above) */ static function get_files_array($value, $gv_class) { $gravityview_view = GravityView_View::getInstance(); extract($gravityview_view->getCurrentField()); $output_arr = array(); // Get an array of file paths for the field. $file_paths = rgar($field, 'multipleFiles') ? json_decode($value) : array($value); // Process each file path foreach ($file_paths as $file_path) { // If the site is HTTPS, use HTTPS if (function_exists('set_url_scheme')) { $file_path = set_url_scheme($file_path); } // This is from Gravity Forms's code $file_path = esc_attr(str_replace(" ", "%20", $file_path)); // If the field is set to link to the single entry, link to it. $link = !empty($field_settings['show_as_link']) ? GravityView_API::entry_link($entry, $field) : $file_path; // Get file path information $file_path_info = pathinfo($file_path); $html_format = NULL; $disable_lightbox = false; $disable_wrapped_link = false; // Is this an image? $image = new GravityView_Image(array('src' => $file_path, 'class' => 'gv-image gv-field-id-' . $field_settings['id'], 'alt' => $field_settings['label'], 'width' => gravityview_get_context() === 'single' ? NULL : 250)); $content = $image->html(); // The new default content is the image, if it exists. If not, use the file name as the content. $content = !empty($content) ? $content : $file_path_info['basename']; // If pathinfo() gave us the extension of the file, run the switch statement using that. $extension = empty($file_path_info['extension']) ? NULL : strtolower($file_path_info['extension']); switch (true) { // Audio file case in_array($extension, wp_get_audio_extensions()): $disable_lightbox = true; if (shortcode_exists('audio')) { $disable_wrapped_link = true; /** * Modify the settings passed to the `wp_video_shortcode()` function * * @since 1.2 * @var array */ $audio_settings = apply_filters('gravityview_audio_settings', array('src' => $file_path, 'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings['id'])); /** * Generate the audio shortcode * @link http://codex.wordpress.org/Audio_Shortcode * @link https://developer.wordpress.org/reference/functions/wp_audio_shortcode/ */ $content = wp_audio_shortcode($audio_settings); } break; // Video file // Video file case in_array($extension, wp_get_video_extensions()): $disable_lightbox = true; if (shortcode_exists('video')) { $disable_wrapped_link = true; /** * Modify the settings passed to the `wp_video_shortcode()` function * * @since 1.2 * @var array */ $video_settings = apply_filters('gravityview_video_settings', array('src' => $file_path, 'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings['id'])); /** * Generate the video shortcode * @link http://codex.wordpress.org/Video_Shortcode * @link https://developer.wordpress.org/reference/functions/wp_video_shortcode/ */ $content = wp_video_shortcode($video_settings); } break; // PDF // PDF case $extension === 'pdf': // PDF needs to be displayed in an IFRAME $link = add_query_arg(array('TB_iframe' => 'true'), $link); break; // if not image, do not set the lightbox (@since 1.5.3) // if not image, do not set the lightbox (@since 1.5.3) case !in_array($extension, array('jpg', 'jpeg', 'jpe', 'gif', 'png')): $disable_lightbox = true; break; } // If using Link to File, override the content. // (We do this here so that the $disable_lightbox can be set. Yes, there's a little more processing time, but oh well.) if (!empty($field_settings['link_to_file'])) { // Force the content to be the file name $content = $file_path_info["basename"]; // Restore the wrapped link $disable_wrapped_link = false; } // Whether to use lightbox or not if ($disable_lightbox || empty($gravityview_view->atts['lightbox']) || !empty($field_settings['show_as_link'])) { $link_atts = empty($field_settings['show_as_link']) ? "target='_blank'" : ''; $link_atts = apply_filters('gravityview/fields/fileupload/link_atts', $link_atts, $gravityview_view->getCurrentField()); } else { $link_atts = sprintf("rel='%s-{$entry['id']}' class='thickbox' target='_blank'", $gv_class); } /** * Filter to alter the default behaviour of wrapping images (or image names) with a link to the content object * * @since 1.5.1 * * @param bool $disable_wrapped_link whether to wrap the content with a link to the content object. * @param array $gravityview_view->field_data * * @see GravityView_API:field_value() for info about $gravityview_view->field_data * */ $disable_wrapped_link = apply_filters('gravityview/fields/fileupload/disable_link', $disable_wrapped_link, $gravityview_view->getCurrentField()); // If the HTML output hasn't been overridden by the switch statement above, use the default format if (!empty($content) && empty($disable_wrapped_link)) { /** * Modify the link text (defaults to the file name) * * @since 1.7 * * @param string $content The existing anchor content. Could be `<img>` tag, audio/video embed or the file name * @param array $field GravityView array of the current field being processed */ $content = apply_filters('gravityview/fields/fileupload/link_content', $content, $gravityview_view->getCurrentField()); $content = '<a href="' . esc_url_raw($link) . '" ' . $link_atts . '>' . $content . '</a>'; } $output_arr[] = array('file_path' => $file_path, 'content' => $content); } // End foreach loop /** * Modify the files array * * @since 1.7 * * @param array $output_arr Associative array of files { * @type string $file_path The path to the file as stored in Gravity Forms * @type string $content The generated output for the file * } * @param array $field GravityView array of the current field being processed */ $output_arr = apply_filters('gravityview/fields/fileupload/files_array', $output_arr, $gravityview_view->getCurrentField()); return $output_arr; }
/** * Verifies an attachment is of a given type. * * @since 4.2.0 * * @param string $type Attachment type. Accepts 'image', 'audio', or 'video'. * @param int|WP_Post $post_id Optional. Attachment ID. Default 0. * @return bool True if one of the accepted types, false otherwise. */ function wp_attachment_is($type, $post_id = 0) { if (!($post = get_post($post_id))) { return false; } if (!($file = get_attached_file($post->ID))) { return false; } if (0 === strpos($post->post_mime_type, $type . '/')) { return true; } $check = wp_check_filetype($file); if (empty($check['ext'])) { return false; } $ext = $check['ext']; if ('import' !== $post->post_mime_type) { return $type === $ext; } switch ($type) { case 'image': $image_exts = array('jpg', 'jpeg', 'jpe', 'gif', 'png'); return in_array($ext, $image_exts); case 'audio': return in_array($ext, wp_get_audio_extensions()); case 'video': return in_array($ext, wp_get_video_extensions()); default: return $type === $ext; } }
/** * Populate network settings. * * @since 3.0.0 * * @global wpdb $wpdb * @global object $current_site * @global int $wp_db_version * @global WP_Rewrite $wp_rewrite * * @param int $network_id ID of network to populate. * @return bool|WP_Error True on success, or WP_Error on warning (with the install otherwise successful, * so the error code must be checked) or failure. */ function populate_network($network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false) { global $wpdb, $current_site, $wp_db_version, $wp_rewrite; $errors = new WP_Error(); if ('' == $domain) { $errors->add('empty_domain', __('You must provide a domain name.')); } if ('' == $site_name) { $errors->add('empty_sitename', __('You must provide a name for your network of sites.')); } // Check for network collision. if ($network_id == $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->site} WHERE id = %d", $network_id))) { $errors->add('siteid_exists', __('The network already exists.')); } if (!is_email($email)) { $errors->add('invalid_email', __('You must provide a valid email address.')); } if ($errors->get_error_code()) { return $errors; } // If a user with the provided email does not exist, default to the current user as the new network admin. $site_user = get_user_by('email', $email); if (false === $site_user) { $site_user = wp_get_current_user(); } // Set up site tables. $template = get_option('template'); $stylesheet = get_option('stylesheet'); $allowed_themes = array($stylesheet => true); if ($template != $stylesheet) { $allowed_themes[$template] = true; } if (WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template) { $allowed_themes[WP_DEFAULT_THEME] = true; } // If WP_DEFAULT_THEME doesn't exist, also whitelist the latest core default theme. if (!wp_get_theme(WP_DEFAULT_THEME)->exists()) { if ($core_default = WP_Theme::get_core_default_theme()) { $allowed_themes[$core_default->get_stylesheet()] = true; } } if (1 == $network_id) { $wpdb->insert($wpdb->site, array('domain' => $domain, 'path' => $path)); $network_id = $wpdb->insert_id; } else { $wpdb->insert($wpdb->site, array('domain' => $domain, 'path' => $path, 'id' => $network_id)); } wp_cache_delete('networks_have_paths', 'site-options'); if (!is_multisite()) { $site_admins = array($site_user->user_login); $users = get_users(array('fields' => array('ID', 'user_login'))); if ($users) { foreach ($users as $user) { if (is_super_admin($user->ID) && !in_array($user->user_login, $site_admins)) { $site_admins[] = $user->user_login; } } } } else { $site_admins = get_site_option('site_admins'); } /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */ $welcome_email = __('Howdy USERNAME, Your new SITE_NAME site has been successfully set up at: BLOG_URL You can log in to the administrator account with the following information: Username: USERNAME Password: PASSWORD Log in here: BLOG_URLwp-login.php We hope you enjoy your new site. Thanks! --The Team @ SITE_NAME'); $misc_exts = array('jpg', 'jpeg', 'png', 'gif', 'mov', 'avi', 'mpg', '3gp', '3g2', 'midi', 'mid', 'pdf', 'doc', 'ppt', 'odt', 'pptx', 'docx', 'pps', 'ppsx', 'xls', 'xlsx', 'key'); $audio_exts = wp_get_audio_extensions(); $video_exts = wp_get_video_extensions(); $upload_filetypes = array_unique(array_merge($misc_exts, $audio_exts, $video_exts)); $sitemeta = array('site_name' => $site_name, 'admin_email' => $email, 'admin_user_id' => $site_user->ID, 'registration' => 'none', 'upload_filetypes' => implode(' ', $upload_filetypes), 'blog_upload_space' => 100, 'fileupload_maxk' => 1500, 'site_admins' => $site_admins, 'allowedthemes' => $allowed_themes, 'illegal_names' => array('www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files'), 'wpmu_upgrade_site' => $wp_db_version, 'welcome_email' => $welcome_email, 'first_post' => __('Welcome to %s. This is your first post. Edit or delete it, then start blogging!'), 'siteurl' => get_option('siteurl') . '/', 'add_new_users' => '0', 'upload_space_check_disabled' => is_multisite() ? get_site_option('upload_space_check_disabled') : '1', 'subdomain_install' => intval($subdomain_install), 'global_terms_enabled' => global_terms_enabled() ? '1' : '0', 'ms_files_rewriting' => is_multisite() ? get_site_option('ms_files_rewriting') : '0', 'initial_db_version' => get_option('initial_db_version'), 'active_sitewide_plugins' => array(), 'WPLANG' => get_locale()); if (!$subdomain_install) { $sitemeta['illegal_names'][] = 'blog'; } /** * Filter meta for a network on creation. * * @since 3.7.0 * * @param array $sitemeta Associative array of network meta keys and values to be inserted. * @param int $network_id ID of network to populate. */ $sitemeta = apply_filters('populate_network_meta', $sitemeta, $network_id); $insert = ''; foreach ($sitemeta as $meta_key => $meta_value) { if (is_array($meta_value)) { $meta_value = serialize($meta_value); } if (!empty($insert)) { $insert .= ', '; } $insert .= $wpdb->prepare("( %d, %s, %s)", $network_id, $meta_key, $meta_value); } $wpdb->query("INSERT INTO {$wpdb->sitemeta} ( site_id, meta_key, meta_value ) VALUES " . $insert); /* * When upgrading from single to multisite, assume the current site will * become the main site of the network. When using populate_network() * to create another network in an existing multisite environment, skip * these steps since the main site of the new network has not yet been * created. */ if (!is_multisite()) { $current_site = new stdClass(); $current_site->domain = $domain; $current_site->path = $path; $current_site->site_name = ucfirst($domain); $wpdb->insert($wpdb->blogs, array('site_id' => $network_id, 'blog_id' => 1, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql'))); $current_site->blog_id = $blog_id = $wpdb->insert_id; update_user_meta($site_user->ID, 'source_domain', $domain); update_user_meta($site_user->ID, 'primary_blog', $blog_id); if ($subdomain_install) { $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); } else { $wp_rewrite->set_permalink_structure('/blog/%year%/%monthnum%/%day%/%postname%/'); } flush_rewrite_rules(); if (!$subdomain_install) { return true; } $vhost_ok = false; $errstr = ''; $hostname = substr(md5(time()), 0, 6) . '.' . $domain; // Very random hostname! $page = wp_remote_get('http://' . $hostname, array('timeout' => 5, 'httpversion' => '1.1')); if (is_wp_error($page)) { $errstr = $page->get_error_message(); } elseif (200 == wp_remote_retrieve_response_code($page)) { $vhost_ok = true; } if (!$vhost_ok) { $msg = '<p><strong>' . __('Warning! Wildcard DNS may not be configured correctly!') . '</strong></p>'; $msg .= '<p>' . sprintf(__('The installer attempted to contact a random hostname (%s) on your domain.'), '<code>' . $hostname . '</code>'); if (!empty($errstr)) { /* translators: %s: error message */ $msg .= ' ' . sprintf(__('This resulted in an error message: %s'), '<code>' . $errstr . '</code>'); } $msg .= '</p>'; $msg .= '<p>' . sprintf(__('To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a %s hostname record pointing at your web server in your DNS configuration tool.'), '<code>*</code>') . '</p>'; $msg .= '<p>' . __('You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.') . '</p>'; return new WP_Error('no_wildcard_dns', $msg); } } return true; }
/** * Get allowed types for any attachment * * @since 2.4.0 * * @param string $type The extension types to get. * Default: 'avatar' * @return array The list of allowed extensions for attachments */ function bp_attachments_get_allowed_types($type = 'avatar') { // Defaults to BuddyPress supported image extensions $exts = array('jpeg', 'gif', 'png'); /** * It's not a BuddyPress feature, get the allowed extensions * matching the $type requested */ if ('avatar' !== $type && 'cover_image' !== $type) { // Reset the default exts $exts = array(); switch ($type) { case 'video': $exts = wp_get_video_extensions(); break; case 'audio': $exts = wp_get_video_extensions(); break; default: $allowed_mimes = get_allowed_mime_types(); /** * Search for allowed mimes matching the type * * eg: using 'application/vnd.oasis' as the $type * parameter will get all OpenOffice extensions supported * by WordPress and allowed for the current user. */ if ('' !== $type) { $allowed_mimes = preg_grep('/' . addcslashes($type, '/.+-') . '/', $allowed_mimes); } $allowed_types = array_keys($allowed_mimes); // Loop to explode keys using '|' foreach ($allowed_types as $allowed_type) { $t = explode('|', $allowed_type); $exts = array_merge($exts, (array) $t); } break; } } /** * Filter here to edit the allowed extensions by attachment type. * * @since 2.4.0 * * @param array $exts List of allowed extensions * @param string $type The requested file type */ return apply_filters('bp_attachments_get_allowed_types', $exts, $type); }
/** * Enqueues all scripts, styles, settings, and templates necessary to use * all media JS APIs. * * @since 3.5.0 * * @global int $content_width * @global wpdb $wpdb * @global WP_Locale $wp_locale * * @param array $args { * Arguments for enqueuing media scripts. * * @type int|WP_Post A post object or ID. * } */ function wp_enqueue_media($args = array()) { // Enqueue me just once per page, please. if (did_action('wp_enqueue_media')) { return; } global $content_width, $wpdb, $wp_locale; $defaults = array('post' => null); $args = wp_parse_args($args, $defaults); // We're going to pass the old thickbox media tabs to `media_upload_tabs` // to ensure plugins will work. We will then unset those tabs. $tabs = array('type' => '', 'type_url' => '', 'gallery' => '', 'library' => ''); /** This filter is documented in wp-admin/includes/media.php */ $tabs = apply_filters('media_upload_tabs', $tabs); unset($tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library']); $props = array('link' => get_option('image_default_link_type'), 'align' => get_option('image_default_align'), 'size' => get_option('image_default_size')); $exts = array_merge(wp_get_audio_extensions(), wp_get_video_extensions()); $mimes = get_allowed_mime_types(); $ext_mimes = array(); foreach ($exts as $ext) { foreach ($mimes as $ext_preg => $mime_match) { if (preg_match('#' . $ext . '#i', $ext_preg)) { $ext_mimes[$ext] = $mime_match; break; } } } $has_audio = $wpdb->get_var("\n\t\tSELECT ID\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_type = 'attachment'\n\t\tAND post_mime_type LIKE 'audio%'\n\t\tLIMIT 1\n\t"); $has_video = $wpdb->get_var("\n\t\tSELECT ID\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_type = 'attachment'\n\t\tAND post_mime_type LIKE 'video%'\n\t\tLIMIT 1\n\t"); $months = $wpdb->get_results($wpdb->prepare("\n\t\tSELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_type = %s\n\t\tORDER BY post_date DESC\n\t", 'attachment')); foreach ($months as $month_year) { $month_year->text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($month_year->month), $month_year->year); } $settings = array('tabs' => $tabs, 'tabUrl' => add_query_arg(array('chromeless' => true), admin_url('media-upload.php')), 'mimeTypes' => wp_list_pluck(get_post_mime_types(), 0), 'captions' => !apply_filters('disable_captions', ''), 'nonce' => array('sendToEditor' => wp_create_nonce('media-send-to-editor')), 'post' => array('id' => 0), 'defaultProps' => $props, 'attachmentCounts' => array('audio' => $has_audio ? 1 : 0, 'video' => $has_video ? 1 : 0), 'embedExts' => $exts, 'embedMimes' => $ext_mimes, 'contentWidth' => $content_width, 'months' => $months, 'mediaTrash' => MEDIA_TRASH ? 1 : 0); $post = null; if (isset($args['post'])) { $post = get_post($args['post']); $settings['post'] = array('id' => $post->ID, 'nonce' => wp_create_nonce('update-post_' . $post->ID)); $thumbnail_support = current_theme_supports('post-thumbnails', $post->post_type) && post_type_supports($post->post_type, 'thumbnail'); if (!$thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type) { if (wp_attachment_is('audio', $post)) { $thumbnail_support = post_type_supports('attachment:audio', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:audio'); } elseif (wp_attachment_is('video', $post)) { $thumbnail_support = post_type_supports('attachment:video', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:video'); } } if ($thumbnail_support) { $featured_image_id = get_post_meta($post->ID, '_thumbnail_id', true); $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; } } if ($post) { $post_type_object = get_post_type_object($post->post_type); } else { $post_type_object = get_post_type_object('post'); } $strings = array('url' => __('URL'), 'addMedia' => __('Add Media'), 'search' => __('Search'), 'select' => __('Select'), 'cancel' => __('Cancel'), 'update' => __('Update'), 'replace' => __('Replace'), 'remove' => __('Remove'), 'back' => __('Back'), 'selected' => __('%d selected'), 'dragInfo' => __('Drag and drop to reorder media files.'), 'uploadFilesTitle' => __('Upload Files'), 'uploadImagesTitle' => __('Upload Images'), 'mediaLibraryTitle' => __('Media Library'), 'insertMediaTitle' => __('Insert Media'), 'createNewGallery' => __('Create a new gallery'), 'createNewPlaylist' => __('Create a new playlist'), 'createNewVideoPlaylist' => __('Create a new video playlist'), 'returnToLibrary' => __('← Return to library'), 'allMediaItems' => __('All media items'), 'allDates' => __('All dates'), 'noItemsFound' => __('No items found.'), 'insertIntoPost' => $post_type_object->labels->insert_into_item, 'unattached' => __('Unattached'), 'trash' => _x('Trash', 'noun'), 'uploadedToThisPost' => $post_type_object->labels->uploaded_to_this_item, 'warnDelete' => __("You are about to permanently delete this item.\n 'Cancel' to stop, 'OK' to delete."), 'warnBulkDelete' => __("You are about to permanently delete these items.\n 'Cancel' to stop, 'OK' to delete."), 'warnBulkTrash' => __("You are about to trash these items.\n 'Cancel' to stop, 'OK' to delete."), 'bulkSelect' => __('Bulk Select'), 'cancelSelection' => __('Cancel Selection'), 'trashSelected' => __('Trash Selected'), 'untrashSelected' => __('Untrash Selected'), 'deleteSelected' => __('Delete Selected'), 'deletePermanently' => __('Delete Permanently'), 'apply' => __('Apply'), 'filterByDate' => __('Filter by date'), 'filterByType' => __('Filter by type'), 'searchMediaLabel' => __('Search Media'), 'noMedia' => __('No media attachments found.'), 'attachmentDetails' => __('Attachment Details'), 'insertFromUrlTitle' => __('Insert from URL'), 'setFeaturedImageTitle' => $post_type_object->labels->featured_image, 'setFeaturedImage' => $post_type_object->labels->set_featured_image, 'createGalleryTitle' => __('Create Gallery'), 'editGalleryTitle' => __('Edit Gallery'), 'cancelGalleryTitle' => __('← Cancel Gallery'), 'insertGallery' => __('Insert gallery'), 'updateGallery' => __('Update gallery'), 'addToGallery' => __('Add to gallery'), 'addToGalleryTitle' => __('Add to Gallery'), 'reverseOrder' => __('Reverse order'), 'imageDetailsTitle' => __('Image Details'), 'imageReplaceTitle' => __('Replace Image'), 'imageDetailsCancel' => __('Cancel Edit'), 'editImage' => __('Edit Image'), 'chooseImage' => __('Choose Image'), 'selectAndCrop' => __('Select and Crop'), 'skipCropping' => __('Skip Cropping'), 'cropImage' => __('Crop Image'), 'cropYourImage' => __('Crop your image'), 'cropping' => __('Cropping…'), 'suggestedDimensions' => __('Suggested image dimensions:'), 'cropError' => __('There has been an error cropping your image.'), 'audioDetailsTitle' => __('Audio Details'), 'audioReplaceTitle' => __('Replace Audio'), 'audioAddSourceTitle' => __('Add Audio Source'), 'audioDetailsCancel' => __('Cancel Edit'), 'videoDetailsTitle' => __('Video Details'), 'videoReplaceTitle' => __('Replace Video'), 'videoAddSourceTitle' => __('Add Video Source'), 'videoDetailsCancel' => __('Cancel Edit'), 'videoSelectPosterImageTitle' => __('Select Poster Image'), 'videoAddTrackTitle' => __('Add Subtitles'), 'playlistDragInfo' => __('Drag and drop to reorder tracks.'), 'createPlaylistTitle' => __('Create Audio Playlist'), 'editPlaylistTitle' => __('Edit Audio Playlist'), 'cancelPlaylistTitle' => __('← Cancel Audio Playlist'), 'insertPlaylist' => __('Insert audio playlist'), 'updatePlaylist' => __('Update audio playlist'), 'addToPlaylist' => __('Add to audio playlist'), 'addToPlaylistTitle' => __('Add to Audio Playlist'), 'videoPlaylistDragInfo' => __('Drag and drop to reorder videos.'), 'createVideoPlaylistTitle' => __('Create Video Playlist'), 'editVideoPlaylistTitle' => __('Edit Video Playlist'), 'cancelVideoPlaylistTitle' => __('← Cancel Video Playlist'), 'insertVideoPlaylist' => __('Insert video playlist'), 'updateVideoPlaylist' => __('Update video playlist'), 'addToVideoPlaylist' => __('Add to video playlist'), 'addToVideoPlaylistTitle' => __('Add to Video Playlist')); /** * Filter the media view settings. * * @since 3.5.0 * * @param array $settings List of media view settings. * @param WP_Post $post Post object. */ $settings = apply_filters('media_view_settings', $settings, $post); /** * Filter the media view strings. * * @since 3.5.0 * * @param array $strings List of media view strings. * @param WP_Post $post Post object. */ $strings = apply_filters('media_view_strings', $strings, $post); $strings['settings'] = $settings; // Ensure we enqueue media-editor first, that way media-views is // registered internally before we try to localize it. see #24724. wp_enqueue_script('media-editor'); wp_localize_script('media-views', '_wpMediaViewsL10n', $strings); wp_enqueue_script('media-audiovideo'); wp_enqueue_style('media-views'); if (is_admin()) { wp_enqueue_script('mce-view'); wp_enqueue_script('image-edit'); } wp_enqueue_style('imgareaselect'); wp_plupload_default_settings(); require_once ABSPATH . WPINC . '/media-template.php'; add_action('admin_footer', 'wp_print_media_templates'); add_action('wp_footer', 'wp_print_media_templates'); add_action('customize_controls_print_footer_scripts', 'wp_print_media_templates'); /** * Fires at the conclusion of wp_enqueue_media(). * * @since 3.5.0 */ do_action('wp_enqueue_media'); }
/** * Get first instance of video in post * @since ProGo 0.6 * @return video SRC */ function pgb_get_video() { global $post, $posts; $first_video = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<a.+href=[\'"]([^\'"]+(' . implode('|', wp_get_video_extensions()) . '))[\'"].*>/i', $post->post_content, $matches); $first_video = isset($matches[1][0]) ? $matches[1][0] : false; if (!empty($first_video)) { return $first_video; } $output = preg_match_all('/\\[video.+src=[\'"]([^\'"]+(' . implode('|', wp_get_video_extensions()) . '))[\'"].*\\]/i', $post->post_content, $matches); $first_video = isset($matches[1][0]) ? $matches[1][0] : false; if (!empty($first_video)) { return $first_video; } return false; }
/** * Enqueues all scripts, styles, settings, and templates necessary to use * all media JS APIs. * * @since 3.5.0 */ function wp_enqueue_media($args = array()) { // Enqueue me just once per page, please. if (did_action('wp_enqueue_media')) { return; } $defaults = array('post' => null); $args = wp_parse_args($args, $defaults); // We're going to pass the old thickbox media tabs to `media_upload_tabs` // to ensure plugins will work. We will then unset those tabs. $tabs = array('type' => '', 'type_url' => '', 'gallery' => '', 'library' => ''); $tabs = apply_filters('media_upload_tabs', $tabs); unset($tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library']); $props = array('link' => get_option('image_default_link_type'), 'align' => get_option('image_default_align'), 'size' => get_option('image_default_size')); $settings = array('tabs' => $tabs, 'tabUrl' => add_query_arg(array('chromeless' => true), admin_url('media-upload.php')), 'mimeTypes' => wp_list_pluck(get_post_mime_types(), 0), 'captions' => !apply_filters('disable_captions', ''), 'nonce' => array('sendToEditor' => wp_create_nonce('media-send-to-editor')), 'post' => array('id' => 0), 'defaultProps' => $props, 'embedExts' => array_merge(wp_get_audio_extensions(), wp_get_video_extensions())); $post = null; if (isset($args['post'])) { $post = get_post($args['post']); $settings['post'] = array('id' => $post->ID, 'nonce' => wp_create_nonce('update-post_' . $post->ID)); if (current_theme_supports('post-thumbnails', $post->post_type) && post_type_supports($post->post_type, 'thumbnail')) { $featured_image_id = get_post_meta($post->ID, '_thumbnail_id', true); $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; } } $hier = $post && is_post_type_hierarchical($post->post_type); $strings = array('url' => __('URL'), 'addMedia' => __('Add Media'), 'search' => __('Search'), 'select' => __('Select'), 'cancel' => __('Cancel'), 'selected' => __('%d selected'), 'dragInfo' => __('Drag and drop to reorder images.'), 'uploadFilesTitle' => __('Upload Files'), 'uploadImagesTitle' => __('Upload Images'), 'mediaLibraryTitle' => __('Media Library'), 'insertMediaTitle' => __('Insert Media'), 'createNewGallery' => __('Create a new gallery'), 'returnToLibrary' => __('← Return to library'), 'allMediaItems' => __('All media items'), 'noItemsFound' => __('No items found.'), 'insertIntoPost' => $hier ? __('Insert into page') : __('Insert into post'), 'uploadedToThisPost' => $hier ? __('Uploaded to this page') : __('Uploaded to this post'), 'warnDelete' => __("You are about to permanently delete this item.\n 'Cancel' to stop, 'OK' to delete."), 'insertFromUrlTitle' => __('Insert from URL'), 'setFeaturedImageTitle' => __('Set Featured Image'), 'setFeaturedImage' => __('Set featured image'), 'createGalleryTitle' => __('Create Gallery'), 'editGalleryTitle' => __('Edit Gallery'), 'cancelGalleryTitle' => __('← Cancel Gallery'), 'insertGallery' => __('Insert gallery'), 'updateGallery' => __('Update gallery'), 'addToGallery' => __('Add to gallery'), 'addToGalleryTitle' => __('Add to Gallery'), 'reverseOrder' => __('Reverse order')); $settings = apply_filters('media_view_settings', $settings, $post); $strings = apply_filters('media_view_strings', $strings, $post); $strings['settings'] = $settings; wp_localize_script('media-views', '_wpMediaViewsL10n', $strings); wp_enqueue_script('media-editor'); wp_enqueue_style('media-views'); wp_plupload_default_settings(); require_once ABSPATH . WPINC . '/media-template.php'; add_action('admin_footer', 'wp_print_media_templates'); add_action('wp_footer', 'wp_print_media_templates'); add_action('customize_controls_print_footer_scripts', 'wp_print_media_templates'); do_action('wp_enqueue_media'); }
/** * @return string[] The extensions supported by this thumber. */ protected function getThumberExtensions() { return array_merge(wp_get_audio_extensions(), wp_get_video_extensions()); }
public static function video($attr) { $post_id = get_post() ? get_the_ID() : 0; static $instances = 0; $instances++; $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'width' => 640, 'height' => 360); foreach ($default_types as $type) { $defaults_atts[$type] = ''; } $atts = shortcode_atts($defaults_atts, $attr, 'video'); $yt_pattern = '#^https?://(?:www\\.)?(?:youtube\\.com/watch|youtu\\.be/)#'; $primary = false; if (!empty($atts['src'])) { if (!preg_match($yt_pattern, $atts['src'])) { $type = wp_check_filetype($atts['src'], wp_get_mime_types()); if (!in_array(strtolower($type['ext']), $default_types)) { return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($atts['src']), esc_html($atts['src'])); } } $primary = true; array_unshift($default_types, 'src'); } else { foreach ($default_types as $ext) { if (!empty($atts[$ext])) { $type = wp_check_filetype($atts[$ext], wp_get_mime_types()); if (strtolower($type['ext']) === $ext) { $primary = true; } } } } if (!$primary) { $videos = get_attached_media('video', $post_id); if (empty($videos)) { return; } $video = reset($videos); $atts['src'] = wp_get_attachment_url($video->ID); if (empty($atts['src'])) { return; } array_unshift($default_types, 'src'); } $library = apply_filters('wp_video_shortcode_library', 'mediaelement'); if ('mediaelement' === $library && did_action('init')) { wp_enqueue_style('wp-mediaelement'); wp_enqueue_script('wp-mediaelement'); } $html_atts = array('class' => apply_filters('wp_video_shortcode_class', 'wp-video-shortcode'), 'id' => sprintf('video-%d-%d', $post_id, $instances), 'width' => absint($atts['width']), 'height' => absint($atts['height']), 'poster' => esc_url($atts['poster']), 'loop' => $atts['loop'], 'autoplay' => $atts['autoplay'], 'preload' => $atts['preload']); foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) { if (empty($html_atts[$a])) { unset($html_atts[$a]); } } $attr_strings = array(); foreach ($html_atts as $k => $v) { $attr_strings[] = $k . '="' . esc_attr($v) . '"'; } $html = ''; if ('mediaelement' === $library && 1 === $instances) { $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; } $html .= sprintf('<video %s controls="controls">', join(' ', $attr_strings)); $fileurl = ''; $source = '<source type="%s" src="%s" />'; foreach ($default_types as $fallback) { if (!empty($atts[$fallback])) { if (empty($fileurl)) { $fileurl = $atts[$fallback]; } if ('src' === $fallback && preg_match($yt_pattern, $atts['src'])) { $type = array('type' => 'video/youtube'); } else { $type = wp_check_filetype($atts[$fallback], wp_get_mime_types()); } $url = add_query_arg('_', $instances, $atts[$fallback]); $html .= sprintf($source, $type['type'], esc_url($url)); } } if ('mediaelement' === $library) { $html .= wp_mediaelement_fallback($fileurl); } $html .= '</video>'; $width_rule = $height_rule = ''; if (!empty($atts['width'])) { $width_rule = sprintf('width: %dpx; ', $atts['width']); } if (!empty($atts['height'])) { $height_rule = sprintf('height: %dpx;', $atts['height']); } $output = sprintf('<div style="%s%s" class="wp-video">%s</div>', $width_rule, $height_rule, $html); return $output; }
function admin_header_actions() { global $pagenow; if (is_admin() && !CoursePress_Capabilities::is_campus()) { if (isset($_GET['cp_admin_ref']) && $_GET['cp_admin_ref'] == 'cp_course_creation_page' || isset($_POST['cp_admin_ref']) && $_POST['cp_admin_ref'] == 'cp_course_creation_page') { wp_enqueue_style('admin_coursepress_marketpress_popup', $this->plugin_url . 'css/admin_marketpress_popup.css', array(), $this->version); } } wp_enqueue_style('font_awesome', $this->plugin_url . 'css/font-awesome.css'); wp_enqueue_style('admin_general', $this->plugin_url . 'css/admin_general.css', array(), $this->version); wp_enqueue_style('admin_general_responsive', $this->plugin_url . 'css/admin_general_responsive.css', array(), $this->version); /* wp_enqueue_script( 'jquery-ui-datepicker' ); wp_enqueue_script( 'jquery-ui-accordion' ); wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( 'jquery-ui-resizable' ); wp_enqueue_script( 'jquery-ui-draggable' ); wp_enqueue_script( 'jquery-ui-droppable' ); */ //add_action( 'wp_enqueue_scripts', array( &$this, 'add_jquery_ui' ) ); //wp_enqueue_script( 'jquery' ); //wp_enqueue_script( 'jquery-ui-core' ); //wp_enqueue_script( 'jquery-ui', '//code.jquery.com/ui/1.10.3/jquery-ui.js', array( 'jquery' ), '1.10.3' ); //need to change this to built-in wp_enqueue_script('jquery-ui-spinner'); // CryptoJS.MD5 wp_enqueue_script('cryptojs-md5', $this->plugin_url . 'js/md5.js'); $page = isset($_GET['page']) ? $_GET['page'] : ''; $this->add_jquery_ui(); if ($page == 'course_details' || $page == $this->screen_base . '_settings') { wp_enqueue_style('cp_settings', $this->plugin_url . 'css/settings.css', array(), $this->version); wp_enqueue_style('cp_settings_responsive', $this->plugin_url . 'css/settings_responsive.css', array(), $this->version); wp_enqueue_style('cp_tooltips', $this->plugin_url . 'css/tooltips.css', array(), $this->version); wp_enqueue_script('cp-plugins', $this->plugin_url . 'js/plugins.js', array('jquery'), $this->version); wp_enqueue_script('cp-tooltips', $this->plugin_url . 'js/tooltips.js', array('jquery'), $this->version); wp_enqueue_script('cp-settings', $this->plugin_url . 'js/settings.js', array('jquery', 'jquery-ui', 'jquery-ui-spinner'), $this->version); wp_enqueue_script('cp-chosen-config', $this->plugin_url . 'js/chosen-config.js', array('cp-settings'), $this->version, true); } $page = isset($_GET['page']) ? $_GET['page'] : ''; $included_pages = apply_filters('cp_settings_localize_pages', array('course', 'courses', 'course_details', 'instructors', 'students', 'assessment', 'reports', $this->screen_base . '_settings')); if (in_array($page, $included_pages) || isset($_GET['taxonomy']) && $_GET['taxonomy'] == 'course_category') { $unit_pagination = false; if (isset($_GET['unit_id'])) { $unit_pagination = cp_unit_uses_new_pagination((int) $_GET['unit_id']); } wp_enqueue_script('courses_bulk', $this->plugin_url . 'js/coursepress-admin.js', array('jquery-ui-tabs'), $this->version); //wp_enqueue_script( 'courses_bulk', $this->plugin_url . 'js/coursepress-admin.js', array(), $this->version ); wp_enqueue_script('wplink'); wp_localize_script('courses_bulk', 'coursepress', array('delete_instructor_alert' => __('Please confirm that you want to remove the instructor from this course?', 'cp'), 'delete_pending_instructor_alert' => __('Please confirm that you want to cancel the invite. Instuctor will receive a warning when trying to activate.', 'cp'), 'delete_course_alert' => __('Please confirm that you want to permanently delete the course, its units, unit elements and responses?', 'cp'), 'delete_student_response_alert' => __('Please confirm that you want to permanently delete this student answer / reponse?', 'cp'), 'delete_notification_alert' => __('Please confirm that you want to permanently delete the notification?', 'cp'), 'delete_discussion_alert' => __('Please confirm that you want to permanently delete the discussion?', 'cp'), 'withdraw_student_alert' => __('Please confirm that you want to withdraw student from this course. If you withdraw, you will no longer be able to see student\'s records for this course.', 'cp'), 'delete_unit_alert' => __('Please confirm that you want to permanently delete the unit, its elements and responses?', 'cp'), 'active_student_tab' => isset($_REQUEST['active_student_tab']) ? $_REQUEST['active_student_tab'] : 0, 'delete_module_alert' => __('Please confirm that you want to permanently delete selected element and its responses?', 'cp'), 'delete_unit_page_and_elements_alert' => __('Please confirm that you want to permanently delete this unit page, all its elements and student responses?', 'cp'), 'remove_unit_page_and_elements_alert' => __('Please confirm that you want to remove this unit page and all its elements?', 'cp'), 'remove_module_alert' => __('Please confirm that you want to remove selected element?', 'cp'), 'delete_unit_page_label' => __('Delete unit page and all elements', 'cp'), 'remove_row' => __('Remove', 'cp'), 'empty_class_name' => __('Class name cannot be empty', 'cp'), 'duplicated_class_name' => __('Class name already exists', 'cp'), 'course_taxonomy_screen' => isset($_GET['taxonomy']) && $_GET['taxonomy'] == 'course_category' ? true : false, 'unit_page_num' => isset($_GET['unit_page_num']) && $_GET['unit_page_num'] !== '' ? $_GET['unit_page_num'] : 1, 'allowed_video_extensions' => wp_get_video_extensions(), 'allowed_audio_extensions' => wp_get_audio_extensions(), 'allowed_image_extensions' => cp_wp_get_image_extensions(), 'start_of_week' => get_option('start_of_week', 0), 'unit_pagination' => $unit_pagination ? 1 : 0, 'admin_ajax_url' => cp_admin_ajax_url())); do_action('coursepress_editor_options'); } }
/** * @param $content * * @return mixed|string */ function gmedia_post_type__the_content($content) { global $post, $gmDB, $gmCore; if (isset($post->gmedia_content)) { $post->post_content = $post->gmedia_content; return $post->gmedia_content; } remove_filter('the_content', 'gmedia_post_type__the_content', 200); $output = ''; if ($post->post_type == 'gmedia') { $gmedia_id = get_post_meta($post->ID, '_gmedia_ID', true); $gmedia = $gmDB->get_gmedia($gmedia_id); if ($gmedia) { gmedia_item_more_data($gmedia); ob_start(); if ($gmedia->link) { $gmedia_link = $gmedia->link; $base_url_host = parse_url($gmCore->upload['url'], PHP_URL_HOST); $url_host = parse_url($gmedia->link, PHP_URL_HOST); if ($url_host == $base_url_host || empty($url_host)) { $link_target = ' target="_self"'; } else { $link_target = ' target="_blank"'; } if (isset($gmedia->meta['link_target'][0])) { $link_target = ' target="' . $gmedia->meta['link_target'][0] . '"'; } } else { $gmedia_link = $gmedia->url; $link_target = ''; } if ('image' == $gmedia->type) { ?> <a class="gmedia-item-link" href="<?php echo $gmedia_link; ?> "<?php echo $link_target; ?> ><img class="gmedia-item" style="max-width:100%;" src="<?php echo $gmedia->url; ?> " alt="<?php esc_attr_e($gmedia->title); ?> "/></a> <?php if (is_single()) { /** more info */ $author_name = get_the_author_meta('display_name', $gmedia->author); $author_posts_link = get_author_posts_url($gmedia->author); $avatar_img = get_avatar($gmedia->author, 60); if (preg_match("/src=['\"](.*?)['\"]/i", $avatar_img, $matches)) { $author_avatar = $matches[1]; } ?> <div class="gmsingle_wrapper gmsingle_clearfix"> <div class="gmsingle_photo_header gmsingle_clearfix"> <div class="gmsingle_name_wrap gmsingle_clearfix"> <?php if (!empty($author_avatar)) { ?> <div class="gmsingle_user_avatar"> <a class="gmsingle_user_avatar_link" href="<?php echo urldecode($author_posts_link); ?> "><img src="<?php echo $author_avatar; ?> " alt=""/></a> </div> <?php } ?> <div class="gmsingle_title_author"> <div class="gmsingle_title"><?php if ('image' != $gmedia->type && $gmedia->link) { echo "<a href='{$gmedia_link}'{$link_target}>{$gmedia->title} 🔗</a>"; } else { echo $gmedia->title; } ?> </div> <div class="gmsingle_author_name"> <a class="gmsingle_author_link" href="<?php echo urldecode($author_posts_link); ?> "><?php echo $author_name; ?> </a> </div> </div> </div> </div> <div class="gmsingle_photo_info"> <div class="gmsingle_description_wrap"> <?php echo apply_filters('the_gmedia_content', wpautop($gmedia->description)); if (!empty($gmedia->album)) { $term_name = $gmedia->album[0]->name; $term_post_id = $gmDB->get_metadata('gmedia_term', $gmedia->album[0]->term_id, '_post_ID', true); if (!empty($term_post_id)) { $term_url = get_permalink($term_post_id); } else { $term_url = $gmCore->gmcloudlink($gmedia->album[0]->term_id, 'album'); } ?> <div class="gmsingle_terms"> <span class="gmsingle_term_label"><?php _e('Album'); ?> :</span> <span class="gmsingle_album"><span class="gmsingle_term"><a href="<?php echo $term_url; ?> "><?php echo $term_name; ?> </a></span></span> </div> <?php } if (!empty($gmedia->categories)) { $item_cats = array(); foreach ($gmedia->categories as $term) { $term->slug = $term->name; $term_url = get_term_link($term); //$term_url = $gmCore->gmcloudlink($term->term_id, 'category'); $item_cats[] = "<span class='gmsingle_term'><a href='{$term_url}'>{$term->name}</a></span>"; } ?> <div class="gmsingle_terms"> <span class="gmsingle_term_label"><?php _e('Categories'); ?> :</span> <span class="gmsingle_categories"><?php echo implode(' ', $item_cats); ?> </span> </div> <?php } if (!empty($gmedia->tags)) { $item_tags = array(); foreach ($gmedia->tags as $term) { $term->slug = $term->name; $term_url = get_term_link($term); //$term_url = $gmCore->gmcloudlink($term->term_id, 'tag'); $item_tags[] = "<span class='gmsingle_term'><a href='{$term_url}'>#{$term->name}</a></span>"; } ?> <div class="gmsingle_terms"> <span class="gmsingle_term_label"><?php _e('Tags'); ?> :</span> <span class="gmsingle_tags"><?php echo implode(' ', $item_tags); ?> </span> </div> <?php } ?> </div> <?php if ($gmedia->gps) { $loc = str_replace(' ', '', $gmedia->gps); ?> <div class="gmsingle_location_section"> <div class="gmsingle_details_title"><?php _e('Location'); ?> </div> <div class="gmsingle_location_info"> <a href='https://www.google.com/maps/place/<?php echo $loc; ?> ' target='_blank'><img src='//maps.googleapis.com/maps/api/staticmap?key=AIzaSyBMiF6nlG5O1tE81Q-35_dckOwW4ypMRuk&size=320x240&zoom=10&scale=2&maptype=roadmap&markers=<?php echo $loc; ?> ' alt='' width='320' height='240'/></a> </div> </div> <?php } ?> <div class="gmsingle_details_section"> <div class="gmsingle_details_title"><?php _e('Details', 'grand-media'); ?> </div> <div class="gmsingle_slide_details"> <?php /* ?> <div class='gmsingle_badges'> <div class='gmsingle_badges__column'> <div class='gmsingle_badges__label'><?php _e('Views', 'grand-media'); ?></div> <div class='gmsingle_badges__count'><?php echo $gmedia->meta['views'][0]; ?></div> </div> <div class='gmsingle_badges__column'> <div class='gmsingle_badges__label'><?php _e('Likes', 'grand-media'); ?></div> <div class='gmsingle_badges__count gmsingle_like_count'><?php echo $gmedia->meta['likes'][0]; ?></div> </div> <div class='gmsingle_clearfix'></div> </div> <?php */ $exif = $gmCore->metadata_info($gmedia->ID); $details = array(); if (!empty($exif)) { $details['model'] = empty($exif['model']) ? '' : $exif['model']['value']; $details['lens'] = empty($exif['lens']) ? '' : $exif['lens']['value']; $details['camera_settings'] = array('focallength' => empty($exif['focallength']) ? empty($exif['focallength35']) ? '' : $exif['focallength35']['value'] : $exif['focallength']['value'], 'aperture' => empty($exif['aperture']) ? '' : str_replace('f', 'ƒ', $exif['aperture']['value']), 'exposure' => empty($exif['exposure']) ? '' : $exif['exposure']['value'], 'iso' => empty($exif['iso']) ? '' : 'ISO ' . $exif['iso']['value']); $details['camera_settings'] = array_filter($details['camera_settings']); $details['taken'] = empty($exif['created_timestamp']) ? '' : date_i18n(get_option('date_format'), $exif['created_timestamp']['value']); } $details['uploaded'] = date_i18n(get_option('date_format'), strtotime($gmedia->date)); if (!empty($details['model'])) { ?> <div class='gmsingle_exif'> <div class='gmsingle_label gmsingle_exif_model'><?php echo $details['model']; ?> </div> <?php if (!empty($details['lens'])) { ?> <div class='gmsingle_label_small gmsingle_exif_lens'><?php echo $details['lens']; ?> </div> <?php } $camera_settings = array(); foreach ($details['camera_settings'] as $key => $value) { $camera_settings[] = "<span class='gmsingle_exif_{$key}'>{$value}</span>"; } if (!empty($camera_settings)) { ?> <div class='gmsingle_label_small gmsingle_camera_settings'><?php echo implode('<span class="gmsingle_separator"> / </span>', $camera_settings); ?> </div> <?php } ?> </div> <?php } ?> <div class='gmsingle_meta'> <?php if (!empty($details['taken'])) { ?> <div class='gmsingle_clearfix'> <span class='gmsingle_meta_key'><?php _e('Created', 'grand-media'); ?> </span> <span class='gmsingle_meta_value'><?php echo $details['taken']; ?> </span> </div> <?php } ?> <div class='gmsingle_clearfix'> <span class='gmsingle_meta_key'><?php _e('Uploaded', 'grand-media'); ?> </span> <span class='gmsingle_meta_value'><?php echo $details['uploaded']; ?> </span> </div> </div> </div> </div> </div> </div> <style type="text/css"> .gmsingle_clearfix { display:block; } .gmsingle_clearfix::after { visibility:hidden; display:block; font-size:0; content:' '; clear:both; height:0; } .gmsingle_wrapper { margin:0 auto; } .gmsingle_wrapper * { -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box; } .gmsingle_photo_header { margin-bottom:15px; } .gmsingle_name_wrap { padding:24px 0 2px 80px; height:85px; max-width:100%; overflow:hidden; white-space:nowrap; position:relative; } .gmsingle_name_wrap .gmsingle_user_avatar { position:absolute; top:20px; left:0; } .gmsingle_name_wrap .gmsingle_user_avatar a.gmsingle_user_avatar_link { display:block; text-decoration:none; } .gmsingle_name_wrap .gmsingle_user_avatar img { height:60px; width:auto; overflow:hidden; border-radius:3px; } .gmsingle_name_wrap .gmsingle_title_author { display:inline-block; vertical-align:top; max-width:100%; } .gmsingle_name_wrap .gmsingle_title_author .gmsingle_title { text-rendering:auto; font-weight:100; font-size:24px; width:100%; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; margin:0; padding:1px 0; height:1.1em; line-height:1; box-sizing:content-box; text-transform:none; letter-spacing:0px; text-transform:capitalize; } .gmsingle_name_wrap .gmsingle_title_author > div { font-size:14px; } .gmsingle_name_wrap .gmsingle_title_author .gmsingle_author_name { float:left; } .gmsingle_name_wrap .gmsingle_title_author a { font-size:inherit; } .gmsingle_photo_info { display:flex; flex-wrap:wrap; } .gmsingle_details_title { margin:0; padding:0; text-transform:uppercase; font-size:18px; line-height:1em; font-weight:300; height:1.1em; display:inline-block; overflow:visible; border:none; } .gmsingle_description_wrap { flex:1; overflow:hidden; min-width:220px; max-width:100%; padding-right:7px; margin-bottom:30px; } .gmsingle_description_wrap .gmsingle_terms { overflow:hidden; margin:0; position:relative; font-size:14px; font-weight:300; } .gmsingle_description_wrap .gmsingle_term_label { margin-right:10px; } .gmsingle_description_wrap .gmsingle_term_label:empty { display:none; } .gmsingle_description_wrap .gmsingle_terms .gmsingle_term { display:inline-block; margin:0 12px 1px 0; } .gmsingle_description_wrap .gmsingle_terms .gmsingle_term a { white-space:nowrap; } .gmsingle_details_section { flex:1; width:33%; padding-right:7px; padding-left:7px; min-width:220px; max-width:100%; } .gmsingle_details_section .gmsingle_slide_details { margin:20px 0; } .gmsingle_location_section { flex:1; width:27%; padding-right:7px; padding-left:7px; min-width:220px; max-width:100%; } .gmsingle_location_section .gmsingle_location_info { margin:20px 0; } .gmsingle_location_section .gmsingle_location_info * { display:block; } .gmsingle_location_section .gmsingle_location_info img { width:100%; height:auto; } .gmsingle_badges { border-bottom:1px solid rgba(0, 0, 0, 0.1); padding-bottom:17px; margin-bottom:12px; text-align:left; font-weight:300; } .gmsingle_badges__column { display:inline-block; vertical-align:top; width:40%; min-width:80px; } .gmsingle_badges__column .gmsingle_badges__label { font-size:14px; } .gmsingle_badges__column .gmsingle_badges__count { font-size:20px; line-height:1em; margin-top:1px; } .gmsingle_exif { border-bottom:1px solid rgba(0, 0, 0, 0.1); padding-bottom:12px; margin-bottom:12px; text-align:left; font-size:14px; line-height:1.7em; font-weight:300; } .gmsingle_exif .gmsingle_camera_settings .gmsingle_separator { font-weight:200; padding:0 5px; display:inline-block; } .gmsingle_meta { padding-bottom:12px; margin-bottom:12px; text-align:left; font-size:14px; line-height:1.2em; font-weight:300; } .gmsingle_meta .gmsingle_meta_key { float:left; padding:3px 0; width:40%; min-width:80px; } .gmsingle_meta .gmsingle_meta_value { float:left; white-space:nowrap; padding:3px 0; text-transform:capitalize; } </style> <?php } else { echo apply_filters('the_gmedia_content', wpautop($gmedia->description)); } } elseif ('audio' == $gmedia->type && ($module = $gmCore->get_module_path('wavesurfer')) && $module['name'] === 'wavesurfer') { echo gmedia_shortcode(array('module' => 'wavesurfer', 'library' => $gmedia->ID, 'native' => true)); if (is_single()) { echo apply_filters('the_gmedia_content', wpautop($gmedia->description)); } } else { $ext1 = wp_get_audio_extensions(); $ext2 = wp_get_video_extensions(); $ext = array_merge($ext1, $ext2); if (in_array($gmedia->ext, $ext)) { $embed = do_shortcode("[embed]{$gmedia->url}[/embed]"); echo $embed; } else { $cover_url = $gmCore->gm_get_media_image($gmedia, 'web'); ?> <a class="gmedia-item-link" href="<?php echo $gmedia->url; ?> " download="true"><img class="gmedia-item" style="max-width:100%;" src="<?php echo $cover_url; ?> " alt="<?php esc_attr_e($gmedia->title); ?> "/></a> <?php } } $ob_content = ob_get_contents(); ob_end_clean(); if (is_single()) { $before = '<div class="GmediaGallery_SinglePage">'; $after = '</div>'; } else { $before = '<div class="GmediaGallery_ArchivePage">'; $after = '</div>'; } $output = $before . $ob_content . $after; } } else { if ('get_the_excerpt' != current_filter()) { if (!isset($post->term_id)) { $post->term_id = get_post_meta($post->ID, '_gmedia_term_ID', true); } if ($post->post_type == 'gmedia_gallery') { $output .= do_shortcode("[gmedia id={$post->term_id}]"); } else { $output .= do_shortcode("[gm id={$post->term_id}]"); } } } $output = str_replace(array("\r\n", "\r", "\n"), '', $output); $output = preg_replace('/ {2,}/', ' ', $output); $post->post_content = $output; $post->gmedia_content = $output; return $output; }
<?php $set_status = $course_setup_progress['step-2']; ?> <input type='hidden' name='meta_course_setup_progress[step-2]' class='course_setup_progress' value="<?php echo $set_status; ?> "/> <div class="wide narrow"> <?php global $content_width; wp_enqueue_style('thickbox'); wp_enqueue_script('thickbox'); wp_enqueue_media(); wp_enqueue_script('media-upload'); $supported_video_extensions = implode(", ", wp_get_video_extensions()); if (!empty($data)) { if (!isset($data->player_width) or empty($data->player_width)) { $data->player_width = empty($content_width) ? 640 : $content_width; } } ?> <div class="video_url_holder mp-wrap"> <label for='meta_course_video_url'> <?php _e('Featured Video', 'cp'); ?> <br/> <span><?php _e('This is used on the Course Overview page and will be displayed with the course description.', 'cp');
/** * Module Styling Fields * @param array $styling * @return string */ function themify_builder_styling_field($styling) { switch ($styling['type']) { case 'text': ?> <input id="<?php echo esc_attr($styling['id']); ?> " name="<?php echo esc_attr($styling['id']); ?> " type="text" value="" class="<?php echo esc_attr($styling['class']); ?> tfb_lb_option"> <?php if (isset($styling['description'])) { echo '<small>' . wp_kses_post($styling['description']) . '</small>'; } ?> <?php break; case 'textarea': ?> <textarea id="<?php echo esc_attr($styling['id']); ?> " name="<?php echo esc_attr($styling['id']); ?> " class="<?php echo esc_attr($styling['class']); ?> tfb_lb_option"><?php if (isset($styling['value'])) { echo esc_textarea($styling['value']); } ?> </textarea> <?php if (isset($styling['description'])) { echo '<small>' . wp_kses_post($styling['description']) . '</small>'; } ?> <?php break; case 'separator': echo isset($styling['meta']['html']) && '' != $styling['meta']['html'] ? $styling['meta']['html'] : '<hr class="meta_fields_separator" />'; break; case 'image': ?> <input id="<?php echo esc_attr($styling['id']); ?> " name="<?php echo esc_attr($styling['id']); ?> " placeholder="<?php if (isset($styling['value'])) { echo esc_attr($styling['value']); } ?> " class="<?php echo esc_attr($styling['class']); ?> themify-builder-uploader-input tfb_lb_option" type="text" /><br /> <div class="small"> <?php if (is_multisite() && !is_upload_space_available()) { ?> <?php echo sprintf(__('Sorry, you have filled your %s MB storage quota so uploading has been disabled.', 'themify'), get_space_allowed()); ?> <?php } else { ?> <div class="themify-builder-plupload-upload-uic hide-if-no-js tf-upload-btn" id="<?php echo esc_attr($styling['id']); ?> themify-builder-plupload-upload-ui"> <input id="<?php echo esc_attr($styling['id']); ?> themify-builder-plupload-browse-button" type="button" value="<?php esc_attr_e(__('Upload', 'themify')); ?> " class="builder_button" /> <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($styling['id'] . 'themify-builder-plupload'); ?> "></span> </div> <?php _e('or', 'themify'); ?> <a href="#" class="themify-builder-media-uploader tf-upload-btn" data-uploader-title="<?php esc_attr_e('Upload an Image', 'themify'); ?> " data-uploader-button-text="<?php esc_attr_e('Insert file URL', 'themify'); ?> "><?php _e('Browse Library', 'themify'); ?> </a> <?php } ?> </div> <p class="thumb_preview"> <span class="img-placeholder"></span> <a href="#" class="themify_builder_icon small delete themify-builder-delete-thumb"></a> </p> <?php break; case 'video': ?> <input id="<?php echo esc_attr($styling['id']); ?> " name="<?php echo esc_attr($styling['id']); ?> " placeholder="<?php if (isset($styling['value'])) { echo esc_attr($styling['value']); } ?> " class="<?php echo esc_attr($styling['class']); ?> themify-builder-uploader-input tfb_lb_option" type="text" /><br /> <div class="small"> <?php if (is_multisite() && !is_upload_space_available()) { ?> <?php echo sprintf(__('Sorry, you have filled your %s MB storage quota so uploading has been disabled.', 'themify'), get_space_allowed()); ?> <?php } else { ?> <div class="themify-builder-plupload-upload-uic hide-if-no-js tf-upload-btn" id="<?php echo esc_attr($styling['id']); ?> themify-builder-plupload-upload-ui" data-extensions="<?php echo esc_attr(implode(',', wp_get_video_extensions())); ?> "> <input id="<?php echo esc_attr($styling['id']); ?> themify-builder-plupload-browse-button" type="button" value="<?php esc_attr_e(__('Upload', 'themify')); ?> " class="builder_button" /> <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($styling['id'] . 'themify-builder-plupload'); ?> "></span> </div> <?php _e('or', 'themify'); ?> <a href="#" class="themify-builder-media-uploader tf-upload-btn" data-uploader-title="<?php _e('Upload a Video', 'themify'); ?> " data-uploader-button-text="<?php esc_attr_e('Insert file URL', 'themify'); ?> " data-library-type="video"><?php _e('Browse Library', 'themify'); ?> </a> <?php } ?> </div> <?php if (isset($styling['description'])) { echo '<small>' . wp_kses_post($styling['description']) . '</small>'; } ?> <?php break; case 'select': ?> <select id="<?php echo esc_attr($styling['id']); ?> " name="<?php echo esc_attr($styling['id']); ?> " class="tfb_lb_option <?php echo isset($styling['class']) ? esc_attr($styling['class']) : ''; ?> "> <?php if (isset($styling['default'])) { ?> <option value="<?php echo esc_attr($styling['default']); ?> "><?php echo esc_html($styling['default']); ?> </option> <?php } foreach ($styling['meta'] as $option) { ?> <option value="<?php echo esc_attr($option['value']); ?> "><?php echo esc_html($option['name']); ?> </option> <?php } ?> </select> <?php if (isset($styling['description'])) { echo wp_kses_post($styling['description']); } ?> <?php break; case 'animation_select': ?> <?php $class = isset($styling['class']) ? $styling['class'] : ''; ?> <select id="<?php echo esc_attr($styling['id']); ?> " name="<?php echo esc_attr($styling['id']); ?> " class="tfb_lb_option <?php echo esc_attr($class); ?> "> <option value=""></option> <?php $animation = Themify_Builder_model::get_preset_animation(); foreach ($animation as $group) { ?> <optgroup label="<?php echo esc_attr($group['group_label']); ?> "> <?php foreach ($group['options'] as $opt) { ?> <option value="<?php echo esc_attr($opt['value']); ?> "><?php echo esc_html($opt['name']); ?> </option> <?php } ?> </optgroup> <?php } ?> </select> <?php if (isset($styling['description'])) { echo wp_kses_post($styling['description']); } ?> <?php break; case 'font_select': $fonts = array_merge(themify_get_web_safe_font_list(), themify_get_google_web_fonts_list()); ?> <select id="<?php echo esc_attr($styling['id']); ?> " name="<?php echo esc_attr($styling['id']); ?> " class="tfb_lb_option <?php echo esc_attr($styling['class']); ?> "> <?php if (isset($styling['default'])) { ?> <option value="<?php echo esc_attr($styling['default']); ?> "><?php echo esc_html($styling['default']); ?> </option> <?php } foreach ($fonts as $option) { ?> <option value="<?php echo esc_attr($option['value']); ?> "><?php echo esc_html($option['name']); ?> </option> <?php } ?> </select> <?php if (isset($styling['description'])) { echo wp_kses_post($styling['description']); } ?> <?php break; case 'color': ?> <span class="builderColorSelect"><span></span></span> <input type="text" class="<?php echo esc_attr($styling['class']); ?> colordisplay"/> <input id="<?php echo esc_attr($styling['id']); ?> " name="<?php echo esc_attr($styling['id']); ?> " value="" class="builderColorSelectInput tfb_lb_option" type="hidden" /> <?php break; case 'checkbox': if (isset($styling['before'])) { echo wp_kses_post($styling['before']); } ?> <div id="<?php echo esc_attr($styling['id']); ?> " class="tfb_lb_option themify-checkbox"> <?php foreach ($styling['options'] as $opt) { ?> <?php $checkbox_checked = ''; if (isset($styling['default']) && is_array($styling['default'])) { $checkbox_checked = in_array($opt['name'], $styling['default']) ? 'checked="checked"' : ''; } elseif (isset($styling['default'])) { $checkbox_checked = checked($styling['default'], $opt['name'], false); } ?> <input id="<?php echo esc_attr($styling['id'] . '_' . $opt['name']); ?> " name="<?php echo esc_attr($styling['id']); ?> " type="checkbox" class="tfb_lb_option tf-checkbox" value="<?php echo esc_attr($opt['name']); ?> " <?php echo $checkbox_checked; ?> /> <label for="<?php echo esc_attr($styling['id'] . '_' . $opt['name']); ?> " class="pad-right"><?php echo wp_kses_post($opt['value']); ?> </label> <?php if (isset($opt['help'])) { ?> <small><?php echo wp_kses_post($opt['help']); ?> </small> <?php } ?> <?php if (!isset($styling['new_line']) || $styling['new_line'] == true) { ?> <br /> <?php } ?> <?php } ?> </div> <?php if (isset($styling['after'])) { echo wp_kses_post($styling['after']); } break; case 'radio': $option_js = isset($styling['option_js']) && $styling['option_js'] == true ? 'tf-option-checkbox-js' : ''; $option_js_wrap = isset($styling['option_js']) && $styling['option_js'] == true ? 'tf-option-checkbox-enable' : ''; ?> <div id="<?php echo esc_attr($styling['id']); ?> " class="tfb_lb_option tf-radio-input-container <?php echo esc_attr($option_js_wrap); ?> "> <?php foreach ($styling['meta'] as $option) { $checked = isset($option['selected']) && $option['selected'] == true ? 'checked="checked"' : ''; $data_el = isset($styling['option_js']) && $styling['option_js'] == true ? 'data-selected="tf-group-element-' . $option['value'] . '"' : ''; ?> <input type="radio" id="<?php echo esc_attr($styling['id'] . '_' . $option['value']); ?> " name="<?php echo esc_attr($styling['id']); ?> " value="<?php echo esc_attr($option['value']); ?> " class="tfb_lb_option <?php echo esc_attr($option_js); ?> " <?php echo $checked . ' ' . $data_el; ?> > <label for="<?php echo esc_attr($styling['id'] . '_' . $option['value']); ?> "><?php echo esc_html($option['name']); ?> </label> <?php } ?> <?php if (isset($styling['description'])) { echo '<br/><small>' . wp_kses_post($styling['description']) . '</small>'; } ?> </div> <?php break; } }
/** * Enqueues all scripts, styles, settings, and templates necessary to use * all media JS APIs. * * @since 3.5.0 */ function wp_enqueue_media($args = array()) { // Enqueue me just once per page, please. if (did_action('wp_enqueue_media')) { return; } global $content_width; $defaults = array('post' => null); $args = wp_parse_args($args, $defaults); // We're going to pass the old thickbox media tabs to `media_upload_tabs` // to ensure plugins will work. We will then unset those tabs. $tabs = array('type' => '', 'type_url' => '', 'gallery' => '', 'library' => ''); /** This filter is documented in wp-admin/includes/media.php */ $tabs = apply_filters('media_upload_tabs', $tabs); unset($tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library']); $props = array('link' => get_option('image_default_link_type'), 'align' => get_option('image_default_align'), 'size' => get_option('image_default_size')); $exts = array_merge(wp_get_audio_extensions(), wp_get_video_extensions()); $mimes = get_allowed_mime_types(); $ext_mimes = array(); foreach ($exts as $ext) { foreach ($mimes as $ext_preg => $mime_match) { if (preg_match('#' . $ext . '#i', $ext_preg)) { $ext_mimes[$ext] = $mime_match; break; } } } $audio = $video = 0; $counts = (array) wp_count_attachments(); foreach ($counts as $mime => $total) { if (0 === strpos($mime, 'audio/')) { $audio += (int) $total; } elseif (0 === strpos($mime, 'video/')) { $video += (int) $total; } } $settings = array('tabs' => $tabs, 'tabUrl' => add_query_arg(array('chromeless' => true), admin_url('media-upload.php')), 'mimeTypes' => wp_list_pluck(get_post_mime_types(), 0), 'captions' => !apply_filters('disable_captions', ''), 'nonce' => array('sendToEditor' => wp_create_nonce('media-send-to-editor')), 'post' => array('id' => 0), 'defaultProps' => $props, 'attachmentCounts' => array('audio' => $audio, 'video' => $video), 'embedExts' => $exts, 'embedMimes' => $ext_mimes, 'contentWidth' => $content_width); $post = null; if (isset($args['post'])) { $post = get_post($args['post']); $settings['post'] = array('id' => $post->ID, 'nonce' => wp_create_nonce('update-post_' . $post->ID)); $thumbnail_support = current_theme_supports('post-thumbnails', $post->post_type) && post_type_supports($post->post_type, 'thumbnail'); if (!$thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type) { if (0 === strpos($post->post_mime_type, 'audio/')) { $thumbnail_support = post_type_supports('attachment:audio', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:audio'); } elseif (0 === strpos($post->post_mime_type, 'video/')) { $thumbnail_support = post_type_supports('attachment:video', 'thumbnail') || current_theme_supports('post-thumbnails', 'attachment:video'); } } if ($thumbnail_support) { $featured_image_id = get_post_meta($post->ID, '_thumbnail_id', true); $settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; } } $hier = $post && is_post_type_hierarchical($post->post_type); $strings = array('url' => __('URL'), 'addMedia' => __('Add Media'), 'search' => __('Search'), 'select' => __('Select'), 'cancel' => __('Cancel'), 'update' => __('Update'), 'replace' => __('Replace'), 'remove' => __('Remove'), 'back' => __('Back'), 'selected' => __('%d selected'), 'dragInfo' => __('Drag and drop to reorder images.'), 'uploadFilesTitle' => __('Upload Files'), 'uploadImagesTitle' => __('Upload Images'), 'mediaLibraryTitle' => __('Media Library'), 'insertMediaTitle' => __('Insert Media'), 'createNewGallery' => __('Create a new gallery'), 'createNewPlaylist' => __('Create a new playlist'), 'createNewVideoPlaylist' => __('Create a new video playlist'), 'returnToLibrary' => __('← Return to library'), 'allMediaItems' => __('All media items'), 'noItemsFound' => __('No items found.'), 'insertIntoPost' => $hier ? __('Insert into page') : __('Insert into post'), 'uploadedToThisPost' => $hier ? __('Uploaded to this page') : __('Uploaded to this post'), 'warnDelete' => __("You are about to permanently delete this item.\n 'Cancel' to stop, 'OK' to delete."), 'insertFromUrlTitle' => __('Insert from URL'), 'setFeaturedImageTitle' => __('Set Featured Image'), 'setFeaturedImage' => __('Set featured image'), 'createGalleryTitle' => __('Create Gallery'), 'editGalleryTitle' => __('Edit Gallery'), 'cancelGalleryTitle' => __('← Cancel Gallery'), 'insertGallery' => __('Insert gallery'), 'updateGallery' => __('Update gallery'), 'addToGallery' => __('Add to gallery'), 'addToGalleryTitle' => __('Add to Gallery'), 'reverseOrder' => __('Reverse order'), 'imageDetailsTitle' => __('Image Details'), 'imageReplaceTitle' => __('Replace Image'), 'imageDetailsCancel' => __('Cancel Edit'), 'editImage' => __('Edit Image'), 'chooseImage' => __('Choose Image'), 'selectAndCrop' => __('Select and Crop'), 'skipCropping' => __('Skip Cropping'), 'cropImage' => __('Crop Image'), 'cropYourImage' => __('Crop your image'), 'cropping' => __('Cropping…'), 'suggestedDimensions' => __('Suggested image dimensions:'), 'cropError' => __('There has been an error cropping your image.'), 'audioDetailsTitle' => __('Audio Details'), 'audioReplaceTitle' => __('Replace Audio'), 'audioAddSourceTitle' => __('Add Audio Source'), 'audioDetailsCancel' => __('Cancel Edit'), 'videoDetailsTitle' => __('Video Details'), 'videoReplaceTitle' => __('Replace Video'), 'videoAddSourceTitle' => __('Add Video Source'), 'videoDetailsCancel' => __('Cancel Edit'), 'videoSelectPosterImageTitle' => _('Select Poster Image'), 'videoAddTrackTitle' => __('Add Subtitles'), 'playlistDragInfo' => __('Drag and drop to reorder tracks.'), 'createPlaylistTitle' => __('Create Audio Playlist'), 'editPlaylistTitle' => __('Edit Audio Playlist'), 'cancelPlaylistTitle' => __('← Cancel Audio Playlist'), 'insertPlaylist' => __('Insert audio playlist'), 'updatePlaylist' => __('Update audio playlist'), 'addToPlaylist' => __('Add to audio playlist'), 'addToPlaylistTitle' => __('Add to Audio Playlist'), 'videoPlaylistDragInfo' => __('Drag and drop to reorder videos.'), 'createVideoPlaylistTitle' => __('Create Video Playlist'), 'editVideoPlaylistTitle' => __('Edit Video Playlist'), 'cancelVideoPlaylistTitle' => __('← Cancel Video Playlist'), 'insertVideoPlaylist' => __('Insert video playlist'), 'updateVideoPlaylist' => __('Update video playlist'), 'addToVideoPlaylist' => __('Add to video playlist'), 'addToVideoPlaylistTitle' => __('Add to Video Playlist')); /** * Filter the media view settings. * * @since 3.5.0 * * @param array $settings List of media view settings. * @param WP_Post $post Post object. */ $settings = apply_filters('media_view_settings', $settings, $post); /** * Filter the media view strings. * * @since 3.5.0 * * @param array $strings List of media view strings. * @param WP_Post $post Post object. */ $strings = apply_filters('media_view_strings', $strings, $post); $strings['settings'] = $settings; wp_localize_script('media-views', '_wpMediaViewsL10n', $strings); wp_enqueue_script('media-editor'); wp_enqueue_script('media-audiovideo'); wp_enqueue_style('media-views'); if (is_admin()) { wp_enqueue_script('mce-view'); wp_enqueue_script('image-edit'); } wp_enqueue_style('imgareaselect'); wp_plupload_default_settings(); require_once ABSPATH . WPINC . '/media-template.php'; add_action('admin_footer', 'wp_print_media_templates'); add_action('wp_footer', 'wp_print_media_templates'); add_action('customize_controls_print_footer_scripts', 'wp_print_media_templates'); /** * Fires at the conclusion of wp_enqueue_media(). * * @since 3.5.0 */ do_action('wp_enqueue_media'); }
/** * Featured image for self-hosted videos. Checks the vidoe attachment for sub-attachment images. If * none exist, checks the current post (if in The Loop) for its featured image. If an image is found, * it's used as the "poster" attribute in the [video] shortcode. * * @since 1.0.0 * @access public * @param array $out * @return array */ function stargazer_video_atts($out) { /* Don't show in the admin. */ if (is_admin()) { return $out; } /* Only run if the user didn't set a 'poster' image. */ if (empty($out['poster'])) { /* Check the 'src' attribute for an attachment file. */ if (!empty($out['src'])) { $attachment_id = hybrid_get_attachment_id_from_url($out['src']); } /* If we couldn't get an attachment from the 'src' attribute, check other supported file extensions. */ if (empty($attachment_id)) { $default_types = wp_get_video_extensions(); foreach ($default_types as $type) { if (!empty($out[$type])) { $attachment_id = hybrid_get_attachment_id_from_url($out[$type]); if (!empty($attachment_id)) { break; } } } } /* If there's an attachment ID at this point. */ if (!empty($attachment_id)) { /* Get the attachment's featured image. */ $image = get_the_image(array('post_id' => $attachment_id, 'size' => 'full', 'format' => 'array', 'echo' => false)); } /* If no image has been found and we're in the post loop, see if the current post has a featured image. */ if (empty($image) && get_post()) { $image = get_the_image(array('size' => 'full', 'format' => 'array', 'echo' => false)); } /* Set the 'poster' attribute if we have an image at this point. */ if (!empty($image)) { $out['poster'] = $image['src']; } } return $out; }
/** * The Video shortcode. * Pretty much a copy-paste of the wp_video_shortcode function from wp-includes/media.php */ function video_shortcode($html, $attr, $content, $instances) { global $content_width; $post_id = get_post() ? get_the_ID() : 0; // do not modify video display on the admin side if (is_admin()) { return ''; } static $instances = 0; $instances++; $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'width' => 640, 'height' => 360); foreach ($default_types as $type) { $defaults_atts[$type] = ''; } $atts = shortcode_atts($defaults_atts, $attr, 'video'); if (is_admin()) { // shrink the video so it isn't huge in the admin if ($atts['width'] > $defaults_atts['width']) { $atts['height'] = round($atts['height'] * $defaults_atts['width'] / $atts['width']); $atts['width'] = $defaults_atts['width']; } } else { // if the video is bigger than the theme if (!empty($content_width) && $atts['width'] > $content_width) { $atts['height'] = round($atts['height'] * $content_width / $atts['width']); $atts['width'] = $content_width; } } $yt_pattern = '#^https?://(?:www\\.)?(?:youtube\\.com/watch|youtu\\.be/)#'; // Skrollr : add Dailymotion pattern $dm_pattern = '#^https?://(?:www\\.)?(?:dailymotion\\.com/video/|dai\\.ly/)#'; // End Skrollr $primary = false; if (!empty($atts['src'])) { if (!preg_match($yt_pattern, $atts['src']) && !preg_match($dm_pattern, $atts['src'])) { // Skrollr : add Dailymotion pattern $type = wp_check_filetype($atts['src'], wp_get_mime_types()); if (!in_array(strtolower($type['ext']), $default_types)) { return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($atts['src']), esc_html($atts['src'])); } } $primary = true; array_unshift($default_types, 'src'); } else { foreach ($default_types as $ext) { if (!empty($atts[$ext])) { $type = wp_check_filetype($atts[$ext], wp_get_mime_types()); if (strtolower($type['ext']) === $ext) { $primary = true; } } } } if (!$primary) { $videos = get_attached_media('video', $post_id); if (empty($videos)) { return; } $video = reset($videos); $atts['src'] = wp_get_attachment_url($video->ID); if (empty($atts['src'])) { return; } array_unshift($default_types, 'src'); } /** * Filter the class attribute for the video shortcode output container. * * @since 3.6.0 * * @param string $class CSS class or list of space-separated classes. */ $html_atts = array('class' => apply_filters('wp_video_shortcode_class', 'wp-video-shortcode'), 'id' => sprintf('video-%d-%d', $post_id, $instances), 'width' => '100%', 'height' => '100%', 'poster' => esc_url($atts['poster']), 'loop' => $atts['loop'], 'autoplay' => $atts['autoplay'], 'preload' => $atts['preload']); // These ones should just be omitted altogether if they are blank foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) { if (empty($html_atts[$a])) { unset($html_atts[$a]); } } $attr_strings = array(); foreach ($html_atts as $k => $v) { $attr_strings[] = $k . '="' . esc_attr($v) . '"'; } $html = ''; $html .= sprintf('<video %s controls="controls">', join(' ', $attr_strings)); $fileurl = ''; $source = '<source type="%s" src="%s" />'; foreach ($default_types as $fallback) { if (!empty($atts[$fallback])) { if (empty($fileurl)) { $fileurl = $atts[$fallback]; } if ('src' === $fallback && preg_match($yt_pattern, $atts['src'])) { $type = array('type' => 'video/youtube'); } else { if ('src' === $fallback && preg_match($dm_pattern, $atts['src'])) { // Skrollr : add Dailymotion pattern $type = array('type' => 'video/dailymotion'); } else { $type = wp_check_filetype($atts[$fallback], wp_get_mime_types()); } } // Skrollr : remove '_' in URL query args $url = $atts[$fallback]; $html .= sprintf($source, $type['type'], esc_url($url)); } } if (!empty($content)) { if (false !== strpos($content, "\n")) { $content = str_replace(array("\r\n", "\n", "\t"), '', $content); } $html .= trim($content); } $html .= wp_mediaelement_fallback($fileurl); $html .= '</video>'; // use the post content as a legend global $post; $content = strip_shortcodes(get_the_content()); if (trim($content) != '') { $html .= "<figcaption "; $html .= "data--0p-bottom-top=\"opacity:1\" "; $html .= "data--100p-bottom-top=\"opacity:1\" "; $html .= "data--120p-bottom-top=\"opacity:0\""; $html .= "data-anchor-target=\"#{$post->post_name}\" "; $html .= ">{$content}</figcaption>"; } // Skrollr : remove width and height rules return sprintf('<div class="wp-video">%s</div>', $html); }
function custom_video_shortcode($attr, $content = '') { global $content_width; $post_id = get_post() ? get_the_ID() : 0; static $instances = 0; $instances++; /** * Override the default video shortcode. * * @since 3.7.0 * * @param null Empty variable to be replaced with shortcode markup. * @param array $attr Attributes of the shortcode. * @param string $content Shortcode content. * @param int $instances Unique numeric ID of this video shortcode instance. */ $html = apply_filters('wp_video_shortcode_override', '', $attr, $content, $instances); if ('' !== $html) { return $html; } $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'height' => 1080, 'width' => empty($content_width) ? 1920 : $content_width, 'size' => ''); foreach ($default_types as $type) { $defaults_atts[$type] = ''; } $atts = shortcode_atts($defaults_atts, $attr, 'video'); extract($atts); $w = $width; $h = $height; if (is_admin() && $width > 600) { $w = 1920; } elseif (!is_admin() && $w > $defaults_atts['width']) { $w = $defaults_atts['width']; } if ($w < $width) { $height = round($h * $w / $width); } $width = $w; $primary = false; if (!empty($src)) { $type = wp_check_filetype($src, wp_get_mime_types()); if (!in_array(strtolower($type['ext']), $default_types)) { return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($src), esc_html($src)); } $primary = true; array_unshift($default_types, 'src'); } else { foreach ($default_types as $ext) { if (!empty(${$ext})) { $type = wp_check_filetype(${$ext}, wp_get_mime_types()); if (strtolower($type['ext']) === $ext) { $primary = true; } } } } if (!$primary) { $videos = get_attached_media('video', $post_id); if (empty($videos)) { return; } $video = reset($videos); $src = wp_get_attachment_url($video->ID); if (empty($src)) { return; } array_unshift($default_types, 'src'); } $library = apply_filters('wp_video_shortcode_library', 'mediaelement'); /*if ( 'mediaelement' === $library && did_action( 'init' ) ) { wp_enqueue_style( 'wp-mediaelement' ); wp_enqueue_script( 'wp-mediaelement' ); } /*$atts = array( 'class' => apply_filters( 'wp_video_shortcode_class', 'wp-video-shortcode' ), 'id' => sprintf( 'video-%d-%d', $post_id, $instances ), 'width' => absint( $width ), 'height' => absint( $height ), 'poster' => esc_url( $poster ), 'loop' => $loop, 'autoplay' => $autoplay, 'preload' => $preload, );*/ // These ones should just be omitted altogether if they are blank foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) { if (empty($atts[$a])) { unset($atts[$a]); } } $attr_strings = array(); foreach ($atts as $k => $v) { $attr_strings[] = $k . '="' . esc_attr($v) . '"'; } $html .= '<video id="videoplayer" class="video-js vjs-mnml ' . $size . '" controls="controls" data-setup>'; $fileurl = ''; $source = '<source type="%s" src="%s" />'; foreach ($default_types as $fallback) { if (!empty(${$fallback})) { if (empty($fileurl)) { $fileurl = ${$fallback}; } $type = wp_check_filetype(${$fallback}, wp_get_mime_types()); // m4v sometimes shows up as video/mpeg which collides with mp4 if ('m4v' === $type['ext']) { $type['type'] = 'video/m4v'; } $html .= sprintf($source, $type['type'], esc_url(${$fallback})); } } if ('mediaelement' === $library) { $html .= wp_mediaelement_fallback($fileurl); } $html .= '</video>'; $html = sprintf('<div class="wp-video">%s</div>', $html); return apply_filters('wp_video_shortcode', $html, $atts, $video, $post_id, $library); }
/** * @return array All extensions supported by WP Audio Video Media metadata. */ private static function getAudioVideoExts() { return array_merge(wp_get_audio_extensions(), wp_get_video_extensions()); }
function admin_main($data) { global $content_width; wp_enqueue_style('thickbox'); wp_enqueue_script('thickbox'); wp_enqueue_media(); wp_enqueue_script('media-upload'); $supported_video_extensions = implode(", ", wp_get_video_extensions()); ?> <div class="<?php if (empty($data)) { ?> draggable-<?php } ?> module-holder-<?php echo $this->name; ?> module-holder-title" <?php if (empty($data)) { ?> style="display:none;"<?php } ?> > <h3 class="module-title sidebar-name <?php echo !empty($data->active_module) ? 'is_active_module' : ''; ?> " data-panel="<?php echo !empty($data->panel) ? $data->panel : ''; ?> " data-id="<?php echo !empty($data->ID) ? $data->ID : ''; ?> "> <span class="h3-label"> <span class="h3-label-left"><?php echo isset($data->post_title) && $data->post_title !== '' ? $data->post_title : __('Untitled', 'cp'); ?> </span> <span class="h3-label-right"><?php echo $this->label; ?> </span> <?php parent::get_module_move_link(); ?> </span> </h3> <div class="module-content"> <input type="hidden" name="<?php echo $this->name; ?> _module_page[]" class="module_page" value="<?php echo isset($data->module_page) ? $data->module_page : ''; ?> "/> <input type="hidden" name="<?php echo $this->name; ?> _module_order[]" class="module_order" value="<?php echo isset($data->module_order) ? $data->module_order : 999; ?> "/> <input type="hidden" name="module_type[]" value="<?php echo $this->name; ?> "/> <input type="hidden" name="<?php echo $this->name; ?> _id[]" class="unit_element_id" value="<?php echo esc_attr(isset($data->ID) ? $data->ID : ''); ?> "/> <input type="hidden" class="element_id" value="<?php echo esc_attr(isset($data->ID) ? $data->ID : ''); ?> "/> <label class="bold-label"><?php _e('Element Title', 'cp'); $this->time_estimation($data); ?> </label> <?php echo $this->element_title_description(); ?> <input type="text" class="element_title" name="<?php echo $this->name; ?> _title[]" value="<?php echo esc_attr(isset($data->post_title) ? $data->post_title : ''); ?> "/> <?php echo $this->show_title_on_front_element($data); ?> <div class="editor_in_place" style="display: none;"> <?php $editor_name = $this->name . "_content[]"; $editor_id = esc_attr(isset($data->ID) ? 'editor_' . $data->ID : rand(1, 9999)); $editor_content = htmlspecialchars_decode(isset($data->post_content) ? $data->post_content : ''); $editor = '<textarea id="' . $editor_id . '" name="' . $editor_name . '" class="coursepress-editor">' . $editor_content . '</textarea>'; echo trim($editor); ?> </div> <div class="video_url_holder"> <label><?php _e('Put a URL or Browse for a video file.', 'cp'); ?> <br/> <span class="element_title_description"><?php printf(__('You can enter a Youtube or Vimeo link (oEmbed support is required). Alternatively you can Browse for a file - supported video extensions (%s)', 'cp'), $supported_video_extensions); ?> </span> <input class="video_url" type="text" size="36" name="<?php echo $this->name; ?> _video_url[]" value="<?php echo esc_attr(isset($data->video_url) ? $data->video_url : ''); ?> "/> <input class="attachment_id" type="hidden" size="36" name="<?php echo $this->name; ?> _attachment_id[]" value="<?php echo esc_attr(isset($data->attachment_id) ? $data->attachment_id : '0'); ?> "/> <input class="video_url_button" type="button" value="<?php _e('Browse', 'cp'); ?> "/> <div class="invalid_extension_message"><?php echo sprintf(__('Extension of the file is not valid. Please use one of the following: %s', 'cp'), $supported_video_extensions); ?> </div> </label> </div> <!--<div class="video_additional_controls"> <label><?php // _e('Player Width ( pixels )', 'cp'); ?> </label> <input type="text" name="<?php // echo $this->name; ?> _player_width[]" value="<?php //echo ( isset($data->player_width) ? esc_attr($data->player_width) : esc_attr(empty($content_width) ? 960 : $content_width ) ); ?> " /> </div>--> <?php echo $this->show_media_caption($data); ?> <?php echo $this->hide_related_videos($data); ?> <?php parent::get_module_delete_link(); ?> </div> </div> <?php }
/** * Prints the templates used in the media manager. * * @since 3.5.0 */ function wp_print_media_templates() { global $is_IE; $class = 'media-modal wp-core-ui'; if ($is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false) { $class .= ' ie7'; } ?> <script type="text/html" id="tmpl-media-frame"> <div class="media-frame-menu"></div> <div class="media-frame-title"></div> <div class="media-frame-router"></div> <div class="media-frame-content"></div> <div class="media-frame-toolbar"></div> <div class="media-frame-uploader"></div> </script> <script type="text/html" id="tmpl-media-modal"> <div class="<?php echo $class; ?> "> <a class="media-modal-close" href="#" title="<?php esc_attr_e('Close'); ?> "><span class="media-modal-icon"></span></a> <div class="media-modal-content"></div> </div> <div class="media-modal-backdrop"></div> </script> <script type="text/html" id="tmpl-uploader-window"> <div class="uploader-window-content"> <h3><?php _e('Drop files to upload'); ?> </h3> </div> </script> <script type="text/html" id="tmpl-uploader-editor"> <div class="uploader-editor-content"> <div class="uploader-editor-title"><?php _e('Drop files to upload'); ?> </div> </div> </script> <script type="text/html" id="tmpl-uploader-inline"> <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #> <div class="uploader-inline-content {{ messageClass }}"> <# if ( data.message ) { #> <h3 class="upload-message">{{ data.message }}</h3> <# } #> <?php if (!_device_can_upload()) { ?> <h3 class="upload-instructions"><?php printf(__('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://wordpress.org/mobile/'); ?> </h3> <?php } elseif (is_multisite() && !is_upload_space_available()) { ?> <h3 class="upload-instructions"><?php _e('Upload Limit Exceeded'); ?> </h3> <?php /** This action is documented in wp-admin/includes/media.php */ do_action('upload_ui_over_quota'); ?> <?php } else { ?> <div class="upload-ui"> <h3 class="upload-instructions drop-instructions"><?php _e('Drop files anywhere to upload'); ?> </h3> <a href="#" class="browser button button-hero"><?php _e('Select Files'); ?> </a> </div> <div class="upload-inline-status"></div> <div class="post-upload-ui"> <?php /** This action is documented in wp-admin/includes/media.php */ do_action('pre-upload-ui'); /** This action is documented in wp-admin/includes/media.php */ do_action('pre-plupload-upload-ui'); if (10 === remove_action('post-plupload-upload-ui', 'media_upload_flash_bypass')) { /** This action is documented in wp-admin/includes/media.php */ do_action('post-plupload-upload-ui'); add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); } else { /** This action is documented in wp-admin/includes/media.php */ do_action('post-plupload-upload-ui'); } $upload_size_unit = $max_upload_size = wp_max_upload_size(); $byte_sizes = array('KB', 'MB', 'GB'); for ($u = -1; $upload_size_unit > 1024 && $u < count($byte_sizes) - 1; $u++) { $upload_size_unit /= 1024; } if ($u < 0) { $upload_size_unit = 0; $u = 0; } else { $upload_size_unit = (int) $upload_size_unit; } ?> <p class="max-upload-size"><?php printf(__('Maximum upload file size: %d%s.'), esc_html($upload_size_unit), esc_html($byte_sizes[$u])); ?> </p> <# if ( data.suggestedWidth && data.suggestedHeight ) { #> <p class="suggested-dimensions"> <?php _e('Suggested image dimensions:'); ?> {{data.suggestedWidth}} × {{data.suggestedHeight}} </p> <# } #> <?php /** This action is documented in wp-admin/includes/media.php */ do_action('post-upload-ui'); ?> </div> <?php } ?> </div> </script> <script type="text/html" id="tmpl-uploader-status"> <h3><?php _e('Uploading'); ?> </h3> <a class="upload-dismiss-errors" href="#"><?php _e('Dismiss Errors'); ?> </a> <div class="media-progress-bar"><div></div></div> <div class="upload-details"> <span class="upload-count"> <span class="upload-index"></span> / <span class="upload-total"></span> </span> <span class="upload-detail-separator">–</span> <span class="upload-filename"></span> </div> <div class="upload-errors"></div> </script> <script type="text/html" id="tmpl-uploader-status-error"> <span class="upload-error-label"><?php _e('Error'); ?> </span> <span class="upload-error-filename">{{{ data.filename }}}</span> <span class="upload-error-message">{{ data.message }}</span> </script> <script type="text/html" id="tmpl-attachment"> <div class="attachment-preview type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div></div></div> <# } else if ( 'image' === data.type ) { #> <div class="thumbnail"> <div class="centered"> <img src="{{ data.size.url }}" draggable="false" /> </div> </div> <# } else { #> <img src="{{ data.icon }}" class="icon" draggable="false" /> <div class="filename"> <div>{{ data.filename }}</div> </div> <# } #> <# if ( data.buttons.close ) { #> <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?> "></a> <# } #> <# if ( data.buttons.check ) { #> <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?> "><div class="media-modal-icon"></div></a> <# } #> </div> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; if ( data.describe ) { #> <# if ( 'image' === data.type ) { #> <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption" placeholder="<?php esc_attr_e('Caption this image…'); ?> " {{ maybeReadOnly }} /> <# } else { #> <input type="text" value="{{ data.title }}" class="describe" data-setting="title" <# if ( 'video' === data.type ) { #> placeholder="<?php esc_attr_e('Describe this video…'); ?> " <# } else if ( 'audio' === data.type ) { #> placeholder="<?php esc_attr_e('Describe this audio file…'); ?> " <# } else { #> placeholder="<?php esc_attr_e('Describe this media file…'); ?> " <# } #> {{ maybeReadOnly }} /> <# } #> <# } #> </script> <script type="text/html" id="tmpl-attachment-details"> <h3> <?php _e('Attachment Details'); ?> <span class="settings-save-status"> <span class="spinner"></span> <span class="saved"><?php esc_html_e('Saved.'); ?> </span> </span> </h3> <div class="attachment-info"> <div class="thumbnail"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div></div></div> <# } else if ( 'image' === data.type ) { #> <img src="{{ data.size.url }}" draggable="false" /> <# } else { #> <img src="{{ data.icon }}" class="icon" draggable="false" /> <# } #> </div> <div class="details"> <div class="filename">{{ data.filename }}</div> <div class="uploaded">{{ data.dateFormatted }}</div> <# if ( 'image' === data.type && ! data.uploading ) { #> <# if ( data.width && data.height ) { #> <div class="dimensions">{{ data.width }} × {{ data.height }}</div> <# } #> <# if ( data.can.save ) { #> <a class="edit-attachment" href="{{ data.editLink }}&image-editor" target="_blank"><?php _e('Edit Image'); ?> </a> <a class="refresh-attachment" href="#"><?php _e('Refresh'); ?> </a> <# } #> <# } #> <# if ( data.fileLength ) { #> <div class="file-length"><?php _e('Length:'); ?> {{ data.fileLength }}</div> <# } #> <# if ( ! data.uploading && data.can.remove ) { #> <?php if (MEDIA_TRASH) { ?> <a class="trash-attachment" href="#"><?php _e('Trash'); ?> </a> <?php } else { ?> <a class="delete-attachment" href="#"><?php _e('Delete Permanently'); ?> </a> <?php } ?> <# } #> <div class="compat-meta"> <# if ( data.compat && data.compat.meta ) { #> {{{ data.compat.meta }}} <# } #> </div> </div> </div> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> <label class="setting" data-setting="title"> <span><?php _e('Title'); ?> </span> <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> </label> <label class="setting" data-setting="caption"> <span><?php _e('Caption'); ?> </span> <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea> </label> <# if ( 'image' === data.type ) { #> <label class="setting" data-setting="alt"> <span><?php _e('Alt Text'); ?> </span> <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} /> </label> <# } #> <label class="setting" data-setting="description"> <span><?php _e('Description'); ?> </span> <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea> </label> </script> <script type="text/html" id="tmpl-media-selection"> <div class="selection-info"> <span class="count"></span> <# if ( data.editable ) { #> <a class="edit-selection" href="#"><?php _e('Edit'); ?> </a> <# } #> <# if ( data.clearable ) { #> <a class="clear-selection" href="#"><?php _e('Clear'); ?> </a> <# } #> </div> <div class="selection-view"></div> </script> <script type="text/html" id="tmpl-attachment-display-settings"> <h3><?php _e('Attachment Display Settings'); ?> </h3> <# if ( 'image' === data.type ) { #> <label class="setting"> <span><?php _e('Alignment'); ?> </span> <select class="alignment" data-setting="align" <# if ( data.userSettings ) { #> data-user-setting="align" <# } #>> <option value="left"> <?php esc_attr_e('Left'); ?> </option> <option value="center"> <?php esc_attr_e('Center'); ?> </option> <option value="right"> <?php esc_attr_e('Right'); ?> </option> <option value="none" selected> <?php esc_attr_e('None'); ?> </option> </select> </label> <# } #> <div class="setting"> <label> <# if ( data.model.canEmbed ) { #> <span><?php _e('Embed or Link'); ?> </span> <# } else { #> <span><?php _e('Link To'); ?> </span> <# } #> <select class="link-to" data-setting="link" <# if ( data.userSettings && ! data.model.canEmbed ) { #> data-user-setting="urlbutton" <# } #>> <# if ( data.model.canEmbed ) { #> <option value="embed" selected> <?php esc_attr_e('Embed Media Player'); ?> </option> <option value="file"> <# } else { #> <option value="file" selected> <# } #> <# if ( data.model.canEmbed ) { #> <?php esc_attr_e('Link to Media File'); ?> <# } else { #> <?php esc_attr_e('Media File'); ?> <# } #> </option> <option value="post"> <# if ( data.model.canEmbed ) { #> <?php esc_attr_e('Link to Attachment Page'); ?> <# } else { #> <?php esc_attr_e('Attachment Page'); ?> <# } #> </option> <# if ( 'image' === data.type ) { #> <option value="custom"> <?php esc_attr_e('Custom URL'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> <# } #> </select> </label> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> <# if ( 'undefined' !== typeof data.sizes ) { #> <label class="setting"> <span><?php _e('Size'); ?> </span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #>> <?php /** This filter is documented in wp-admin/includes/media.php */ $sizes = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'))); foreach ($sizes as $value => $name) { ?> <# var size = data.sizes['<?php echo esc_js($value); ?> ']; if ( size ) { #> <option value="<?php echo esc_attr($value); ?> " <?php selected($value, 'full'); ?> > <?php echo esc_html($name); ?> – {{ size.width }} × {{ size.height }} </option> <# } #> <?php } ?> </select> </label> <# } #> </script> <script type="text/html" id="tmpl-gallery-settings"> <h3><?php _e('Gallery Settings'); ?> </h3> <label class="setting"> <span><?php _e('Link To'); ?> </span> <select class="link-to" data-setting="link" <# if ( data.userSettings ) { #> data-user-setting="urlbutton" <# } #>> <option value="post" selected> <?php esc_attr_e('Attachment Page'); ?> </option> <option value="file"> <?php esc_attr_e('Media File'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> </select> </label> <label class="setting"> <span><?php _e('Columns'); ?> </span> <select class="columns" name="columns" data-setting="columns"> <?php for ($i = 1; $i <= 9; $i++) { ?> <option value="<?php echo esc_attr($i); ?> " <?php selected($i, 3); ?> > <?php echo esc_html($i); ?> </option> <?php } ?> </select> </label> <label class="setting"> <span><?php _e('Random Order'); ?> </span> <input type="checkbox" data-setting="_orderbyRandom" /> </label> </script> <script type="text/html" id="tmpl-playlist-settings"> <h3><?php _e('Playlist Settings'); ?> </h3> <# var emptyModel = _.isEmpty( data.model ), isVideo = 'video' === data.controller.get('library').props.get('type'); #> <label class="setting"> <input type="checkbox" data-setting="tracklist" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <# if ( isVideo ) { #> <span><?php _e('Show Video List'); ?> </span> <# } else { #> <span><?php _e('Show Tracklist'); ?> </span> <# } #> </label> <# if ( ! isVideo ) { #> <label class="setting"> <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <span><?php _e('Show Artist Name in Tracklist'); ?> </span> </label> <# } #> <label class="setting"> <input type="checkbox" data-setting="images" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <span><?php _e('Show Images'); ?> </span> </label> </script> <script type="text/html" id="tmpl-embed-link-settings"> <label class="setting"> <span><?php _e('Title'); ?> </span> <input type="text" class="alignment" data-setting="title" /> </label> </script> <script type="text/html" id="tmpl-embed-image-settings"> <div class="thumbnail"> <img src="{{ data.model.url }}" draggable="false" /> </div> <?php /** This filter is documented in wp-admin/includes/media.php */ if (!apply_filters('disable_captions', '')) { ?> <label class="setting caption"> <span><?php _e('Caption'); ?> </span> <textarea data-setting="caption" /> </label> <?php } ?> <label class="setting alt-text"> <span><?php _e('Alt Text'); ?> </span> <input type="text" data-setting="alt" /> </label> <div class="setting align"> <span><?php _e('Align'); ?> </span> <div class="button-group button-large" data-setting="align"> <button class="button" value="left"> <?php esc_attr_e('Left'); ?> </button> <button class="button" value="center"> <?php esc_attr_e('Center'); ?> </button> <button class="button" value="right"> <?php esc_attr_e('Right'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> </div> <div class="setting link-to"> <span><?php _e('Link To'); ?> </span> <div class="button-group button-large" data-setting="link"> <button class="button" value="file"> <?php esc_attr_e('Image URL'); ?> </button> <button class="button" value="custom"> <?php esc_attr_e('Custom URL'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> </script> <script type="text/html" id="tmpl-attachments-css"> <style type="text/css" id="{{ data.id }}-css"> #{{ data.id }} { padding: 0 {{ data.gutter }}px; } #{{ data.id }} .attachment { margin: {{ data.gutter }}px; width: {{ data.edge }}px; } #{{ data.id }} .attachment-preview, #{{ data.id }} .attachment-preview .thumbnail { width: {{ data.edge }}px; height: {{ data.edge }}px; } #{{ data.id }} .portrait .thumbnail img { max-width: {{ data.edge }}px; height: auto; } #{{ data.id }} .landscape .thumbnail img { width: auto; max-height: {{ data.edge }}px; } </style> </script> <script type="text/html" id="tmpl-image-details"> <div class="media-embed"> <div class="embed-media-settings"> <div class="column-image"> <div class="image"> <img src="{{ data.model.url }}" draggable="false" /> <# if ( data.attachment && window.imageEdit ) { #> <div class="actions"> <input type="button" class="edit-attachment button" value="<?php esc_attr_e('Edit Original'); ?> " /> <input type="button" class="replace-attachment button" value="<?php esc_attr_e('Replace'); ?> " /> </div> <# } #> </div> </div> <div class="column-settings"> <?php /** This filter is documented in wp-admin/includes/media.php */ if (!apply_filters('disable_captions', '')) { ?> <label class="setting caption"> <span><?php _e('Caption'); ?> </span> <textarea data-setting="caption">{{ data.model.caption }}</textarea> </label> <?php } ?> <label class="setting alt-text"> <span><?php _e('Alternative Text'); ?> </span> <input type="text" data-setting="alt" value="{{ data.model.alt }}" /> </label> <h3><?php _e('Display Settings'); ?> </h3> <div class="setting align"> <span><?php _e('Align'); ?> </span> <div class="button-group button-large" data-setting="align"> <button class="button" value="left"> <?php esc_attr_e('Left'); ?> </button> <button class="button" value="center"> <?php esc_attr_e('Center'); ?> </button> <button class="button" value="right"> <?php esc_attr_e('Right'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> </div> <# if ( data.attachment ) { #> <# if ( 'undefined' !== typeof data.attachment.sizes ) { #> <label class="setting size"> <span><?php _e('Size'); ?> </span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #>> <?php /** This filter is documented in wp-admin/includes/media.php */ $sizes = apply_filters('image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'))); foreach ($sizes as $value => $name) { ?> <# var size = data.sizes['<?php echo esc_js($value); ?> ']; if ( size ) { #> <option value="<?php echo esc_attr($value); ?> "> <?php echo esc_html($name); ?> – {{ size.width }} × {{ size.height }} </option> <# } #> <?php } ?> <option value="<?php echo esc_attr('custom'); ?> "> <?php _e('Custom Size'); ?> </option> </select> </label> <# } #> <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>"> <label><span><?php _e('Width'); ?> <small>(px)</small></span> <input data-setting="customWidth" type="number" step="1" value="{{ data.model.customWidth }}" /></label><span class="sep">×</span><label><span><?php _e('Height'); ?> <small>(px)</small></span><input data-setting="customHeight" type="number" step="1" value="{{ data.model.customHeight }}" /></label> </div> <# } #> <div class="setting link-to"> <span><?php _e('Link To'); ?> </span> <select data-setting="link"> <# if ( data.attachment ) { #> <option value="file"> <?php esc_attr_e('Media File'); ?> </option> <option value="post"> <?php esc_attr_e('Attachment Page'); ?> </option> <# } else { #> <option value="file"> <?php esc_attr_e('Image URL'); ?> </option> <# } #> <option value="custom"> <?php esc_attr_e('Custom URL'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> </select> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> <div class="advanced-section"> <h3><a class="advanced-toggle" href="#"><?php _e('Advanced Options'); ?> </a></h3> <div class="advanced-settings hidden"> <div class="advanced-image"> <label class="setting title-text"> <span><?php _e('Image Title Attribute'); ?> </span> <input type="text" data-setting="title" value="{{ data.model.title }}" /> </label> <label class="setting extra-classes"> <span><?php _e('Image CSS Class'); ?> </span> <input type="text" data-setting="extraClasses" value="{{ data.model.extraClasses }}" /> </label> </div> <div class="advanced-link"> <div class="setting link-target"> <label><input type="checkbox" data-setting="linkTargetBlank" value="_blank" <# if ( data.model.linkTargetBlank ) { #>checked="checked"<# } #>><?php _e('Open link in a new window/tab'); ?> </label> </div> <label class="setting link-rel"> <span><?php _e('Link Rel'); ?> </span> <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" /> </label> <label class="setting link-class-name"> <span><?php _e('Link CSS Class'); ?> </span> <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" /> </label> </div> </div> </div> </div> </div> </div> </script> <script type="text/html" id="tmpl-image-editor"> <div id="media-head-{{ data.id }}"></div> <div id="image-editor-{{ data.id }}"></div> </script> <script type="text/html" id="tmpl-audio-details"> <# var ext, html5types = { mp3: wp.media.view.settings.embedMimes.mp3, ogg: wp.media.view.settings.embedMimes.ogg }; #> <?php $audio_types = wp_get_audio_extensions(); ?> <div class="media-embed media-embed-details"> <div class="embed-media-settings embed-audio-settings"> <?php wp_underscore_audio_template(); ?> <# if ( ! _.isEmpty( data.model.src ) ) { ext = data.model.src.split('.').pop(); if ( html5types[ ext ] ) { delete html5types[ ext ]; } #> <label class="setting"> <span>SRC</span> <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" /> <a class="remove-setting"><?php _e('Remove'); ?> </a> </label> <# } #> <?php foreach ($audio_types as $type) { ?> <# if ( ! _.isEmpty( data.model.<?php echo $type; ?> ) ) { if ( ! _.isUndefined( html5types.<?php echo $type; ?> ) ) { delete html5types.<?php echo $type; ?> ; } #> <label class="setting"> <span><?php echo strtoupper($type); ?> </span> <input type="text" disabled="disabled" data-setting="<?php echo $type; ?> " value="{{ data.model.<?php echo $type; ?> }}" /> <a class="remove-setting"><?php _e('Remove'); ?> </a> </label> <# } #> <?php } ?> <# if ( ! _.isEmpty( html5types ) ) { #> <div class="setting"> <span><?php _e('Add alternate sources for maximum HTML5 playback:'); ?> </span> <div class="button-large"> <# _.each( html5types, function (mime, type) { #> <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button> <# } ) #> </div> </div> <# } #> <div class="setting preload"> <span><?php _e('Preload'); ?> </span> <div class="button-group button-large" data-setting="preload"> <button class="button" value="auto"><?php _ex('Auto', 'auto preload'); ?> </button> <button class="button" value="metadata"><?php _e('Metadata'); ?> </button> <button class="button active" value="none"><?php _e('None'); ?> </button> </div> </div> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="autoplay" /> <span><?php _e('Autoplay'); ?> </span> </label> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="loop" /> <span><?php _e('Loop'); ?> </span> </label> </div> </div> </script> <script type="text/html" id="tmpl-video-details"> <# var ext, html5types = { mp4: wp.media.view.settings.embedMimes.mp4, ogv: wp.media.view.settings.embedMimes.ogv, webm: wp.media.view.settings.embedMimes.webm }; #> <?php $video_types = wp_get_video_extensions(); ?> <div class="media-embed media-embed-details"> <div class="embed-media-settings embed-video-settings"> <div class="wp-video-holder"> <# var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/); w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width, h = ! data.model.height ? 360 : data.model.height; if ( data.model.width && w !== data.model.width ) { h = Math.ceil( ( h * w ) / data.model.width ); } #> <?php wp_underscore_video_template(); ?> <# if ( ! _.isEmpty( data.model.src ) ) { ext = data.model.src.split('.').pop(); if ( html5types[ ext ] ) { delete html5types[ ext ]; } #> <label class="setting"> <span>SRC</span> <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" /> <a class="remove-setting"><?php _e('Remove'); ?> </a> </label> <# } #> <?php foreach ($video_types as $type) { ?> <# if ( ! _.isEmpty( data.model.<?php echo $type; ?> ) ) { if ( ! _.isUndefined( html5types.<?php echo $type; ?> ) ) { delete html5types.<?php echo $type; ?> ; } #> <label class="setting"> <span><?php echo strtoupper($type); ?> </span> <input type="text" disabled="disabled" data-setting="<?php echo $type; ?> " value="{{ data.model.<?php echo $type; ?> }}" /> <a class="remove-setting"><?php _e('Remove'); ?> </a> </label> <# } #> <?php } ?> </div> <# if ( ! _.isEmpty( html5types ) ) { #> <div class="setting"> <span><?php _e('Add alternate sources for maximum HTML5 playback:'); ?> </span> <div class="button-large"> <# _.each( html5types, function (mime, type) { #> <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button> <# } ) #> </div> </div> <# } #> <# if ( ! _.isEmpty( data.model.poster ) ) { #> <label class="setting"> <span><?php _e('Poster Image'); ?> </span> <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" /> <a class="remove-setting"><?php _e('Remove'); ?> </a> </label> <# } #> <div class="setting preload"> <span><?php _e('Preload'); ?> </span> <div class="button-group button-large" data-setting="preload"> <button class="button" value="auto"><?php _ex('Auto', 'auto preload'); ?> </button> <button class="button" value="metadata"><?php _e('Metadata'); ?> </button> <button class="button active" value="none"><?php _e('None'); ?> </button> </div> </div> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="autoplay" /> <span><?php _e('Autoplay'); ?> </span> </label> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="loop" /> <span><?php _e('Loop'); ?> </span> </label> <label class="setting" data-setting="content"> <span><?php _e('Tracks (subtitles, captions, descriptions, chapters, or metadata)'); ?> </span> <# var content = ''; if ( ! _.isEmpty( data.model.content ) ) { var tracks = jQuery( data.model.content ).filter( 'track' ); _.each( tracks.toArray(), function (track) { content += track.outerHTML; #> <p> <input class="content-track" type="text" value="{{ track.outerHTML }}" /> <a class="remove-setting remove-track"><?php _e('Remove'); ?> </a> </p> <# } ); #> <# } else { #> <em><?php _e('There are no associated subtitles.'); ?> </em> <# } #> <textarea class="hidden content-setting">{{ content }}</textarea> </label> </div> </div> </script> <script type="text/html" id="tmpl-editor-gallery"> <div class="toolbar"> <div class="dashicons dashicons-edit edit"></div><div class="dashicons dashicons-no-alt remove"></div> </div> <# if ( data.attachments ) { #> <div class="gallery gallery-columns-{{ data.columns }}"> <# _.each( data.attachments, function( attachment, index ) { #> <dl class="gallery-item"> <dt class="gallery-icon"> <# if ( attachment.thumbnail ) { #> <img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" /> <# } else { #> <img src="{{ attachment.url }}" /> <# } #> </dt> <dd class="wp-caption-text gallery-caption"> {{ attachment.caption }} </dd> </dl> <# if ( index % data.columns === data.columns - 1 ) { #> <br style="clear: both;"> <# } #> <# } ); #> </div> <# } else { #> <div class="wpview-error"> <div class="dashicons dashicons-format-gallery"></div><p><?php _e('No items found.'); ?> </p> </div> <# } #> </script> <script type="text/html" id="tmpl-editor-audio"> <div class="toolbar"> <div class="dashicons dashicons-edit edit"></div> <div class="dashicons dashicons-no-alt remove"></div> </div> <?php wp_underscore_audio_template(); ?> <div class="wpview-overlay"></div> </script> <script type="text/html" id="tmpl-editor-video"> <div class="toolbar"> <div class="dashicons dashicons-edit edit"></div> <div class="dashicons dashicons-no-alt remove"></div> </div> <?php wp_underscore_video_template(); ?> <div class="wpview-overlay"></div> </script> <?php wp_underscore_playlist_templates(); ?> <script type="text/html" id="tmpl-editor-playlist"> <div class="toolbar"> <div class="dashicons dashicons-edit edit"></div> <div class="dashicons dashicons-no-alt remove"></div> </div> <# if ( data.tracks ) { #> <div class="wp-playlist wp-{{ data.type }}-playlist wp-playlist-{{ data.style }}"> <# if ( 'audio' === data.type ){ #> <div class="wp-playlist-current-item"></div> <# } #> <{{ data.type }} controls="controls" preload="none" <# if ( data.width ) { #> width="{{ data.width }}"<# } #><# if ( data.height ) { #> height="{{ data.height }}"<# } #>></{{ data.type }}> <div class="wp-playlist-next"></div> <div class="wp-playlist-prev"></div> </div> <div class="wpview-overlay"></div> <# } else { #> <div class="wpview-error"> <div class="dashicons dashicons-video-alt3"></div><p><?php _e('No items found.'); ?> </p> </div> <# } #> </script> <script type="text/html" id="tmpl-crop-content"> <img class="crop-image" src="{{ data.url }}"> <div class="upload-errors"></div> </script> <?php /** * Fires when the custom Backbone media templates are printed. * * @since 3.5.0 */ do_action('print_media_templates'); }
/** * Prints the templates used in the media manager. * * @since 3.5.0 * * @global bool $is_IE */ function wp_print_media_templates() { global $is_IE; $class = 'media-modal wp-core-ui'; if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false ) $class .= ' ie7'; ?> <!--[if lte IE 8]> <style> .attachment:focus { outline: #1e8cbe solid; } .selected.attachment { outline: #1e8cbe solid; } </style> <![endif]--> <script type="text/html" id="tmpl-media-frame"> <div class="media-frame-menu"></div> <div class="media-frame-title"></div> <div class="media-frame-router"></div> <div class="media-frame-content"></div> <div class="media-frame-toolbar"></div> <div class="media-frame-uploader"></div> </script> <script type="text/html" id="tmpl-media-modal"> <div class="<?php echo $class; ?>"> <a class="media-modal-close" href="#"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close media panel' ); ?></span></span></a> <div class="media-modal-content"></div> </div> <div class="media-modal-backdrop"></div> </script> <script type="text/html" id="tmpl-uploader-window"> <div class="uploader-window-content"> <h3><?php _e( 'Drop files to upload' ); ?></h3> </div> </script> <script type="text/html" id="tmpl-uploader-editor"> <div class="uploader-editor-content"> <div class="uploader-editor-title"><?php _e( 'Drop files to upload' ); ?></div> </div> </script> <script type="text/html" id="tmpl-uploader-inline"> <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #> <# if ( data.canClose ) { #> <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close uploader' ); ?></span></button> <# } #> <div class="uploader-inline-content {{ messageClass }}"> <# if ( data.message ) { #> <h3 class="upload-message">{{ data.message }}</h3> <# } #> <?php if ( ! _device_can_upload() ) : ?> <h3 class="upload-instructions"><?php printf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://apps.wordpress.org/' ); ?></h3> <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?> <h3 class="upload-instructions"><?php _e( 'Upload Limit Exceeded' ); ?></h3> <?php /** This action is documented in wp-admin/includes/media.php */ do_action( 'upload_ui_over_quota' ); ?> <?php else : ?> <div class="upload-ui"> <h3 class="upload-instructions drop-instructions"><?php _e( 'Drop files anywhere to upload' ); ?></h3> <p class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p> <button type="button" class="browser button button-hero"><?php _e( 'Select Files' ); ?></button> </div> <div class="upload-inline-status"></div> <div class="post-upload-ui"> <?php /** This action is documented in wp-admin/includes/media.php */ do_action( 'pre-upload-ui' ); /** This action is documented in wp-admin/includes/media.php */ do_action( 'pre-plupload-upload-ui' ); if ( 10 === remove_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ) ) { /** This action is documented in wp-admin/includes/media.php */ do_action( 'post-plupload-upload-ui' ); add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ); } else { /** This action is documented in wp-admin/includes/media.php */ do_action( 'post-plupload-upload-ui' ); } $max_upload_size = wp_max_upload_size(); if ( ! $max_upload_size ) { $max_upload_size = 0; } ?> <p class="max-upload-size"><?php printf( __( 'Maximum upload file size: %s.' ), esc_html( size_format( $max_upload_size ) ) ); ?></p> <# if ( data.suggestedWidth && data.suggestedHeight ) { #> <p class="suggested-dimensions"> <?php _e( 'Suggested image dimensions:' ); ?> {{data.suggestedWidth}} × {{data.suggestedHeight}} </p> <# } #> <?php /** This action is documented in wp-admin/includes/media.php */ do_action( 'post-upload-ui' ); ?> </div> <?php endif; ?> </div> </script> <script type="text/html" id="tmpl-media-library-view-switcher"> <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-list"> <span class="screen-reader-text"><?php _e( 'List View' ); ?></span> </a> <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-grid current"> <span class="screen-reader-text"><?php _e( 'Grid View' ); ?></span> </a> </script> <script type="text/html" id="tmpl-uploader-status"> <h3><?php _e( 'Uploading' ); ?></h3> <a class="upload-dismiss-errors" href="#"><?php _e('Dismiss Errors'); ?></a> <div class="media-progress-bar"><div></div></div> <div class="upload-details"> <span class="upload-count"> <span class="upload-index"></span> / <span class="upload-total"></span> </span> <span class="upload-detail-separator">–</span> <span class="upload-filename"></span> </div> <div class="upload-errors"></div> </script> <script type="text/html" id="tmpl-uploader-status-error"> <span class="upload-error-filename">{{{ data.filename }}}</span> <span class="upload-error-message">{{ data.message }}</span> </script> <script type="text/html" id="tmpl-edit-attachment-frame"> <div class="edit-media-header"> <button class="left dashicons <# if ( ! data.hasPrevious ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit previous media item' ); ?></span></button> <button class="right dashicons <# if ( ! data.hasNext ) { #> disabled <# } #>"><span class="screen-reader-text"><?php _e( 'Edit next media item' ); ?></span></button> </div> <div class="media-frame-title"></div> <div class="media-frame-content"></div> </script> <script type="text/html" id="tmpl-attachment-details-two-column"> <div class="attachment-media-view {{ data.orientation }}"> <div class="thumbnail thumbnail-{{ data.type }}"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div></div></div> <# } else if ( 'image' === data.type && data.sizes && data.sizes.large ) { #> <img class="details-image" src="{{ data.sizes.large.url }}" draggable="false" /> <# } else if ( 'image' === data.type && data.sizes && data.sizes.full ) { #> <img class="details-image" src="{{ data.sizes.full.url }}" draggable="false" /> <# } else if ( -1 === jQuery.inArray( data.type, [ 'audio', 'video' ] ) ) { #> <img class="details-image" src="{{ data.icon }}" class="icon" draggable="false" /> <# } #> <# if ( 'audio' === data.type ) { #> <div class="wp-media-wrapper"> <audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none"> <source type="{{ data.mime }}" src="{{ data.url }}"/> </audio> </div> <# } else if ( 'video' === data.type ) { var w_rule = h_rule = ''; if ( data.width ) { w_rule = 'width: ' + data.width + 'px;'; } else if ( wp.media.view.settings.contentWidth ) { w_rule = 'width: ' + wp.media.view.settings.contentWidth + 'px;'; } if ( data.height ) { h_rule = 'height: ' + data.height + 'px;'; } #> <div style="{{ w_rule }}{{ h_rule }}" class="wp-media-wrapper wp-video"> <video controls="controls" class="wp-video-shortcode" preload="metadata" <# if ( data.width ) { #>width="{{ data.width }}"<# } #> <# if ( data.height ) { #>height="{{ data.height }}"<# } #> <# if ( data.image && data.image.src !== data.icon ) { #>poster="{{ data.image.src }}"<# } #>> <source type="{{ data.mime }}" src="{{ data.url }}"/> </video> </div> <# } #> <div class="attachment-actions"> <# if ( 'image' === data.type && ! data.uploading && data.sizes && data.can.save ) { #> <button type="button" class="button edit-attachment"><?php _e( 'Edit Image' ); ?></button> <# } #> </div> </div> </div> <div class="attachment-info"> <span class="settings-save-status"> <span class="spinner"></span> <span class="saved"><?php esc_html_e('Saved.'); ?></span> </span> <div class="details"> <div class="filename"><strong><?php _e( 'File name:' ); ?></strong> {{ data.filename }}</div> <div class="filename"><strong><?php _e( 'File type:' ); ?></strong> {{ data.mime }}</div> <div class="uploaded"><strong><?php _e( 'Uploaded on:' ); ?></strong> {{ data.dateFormatted }}</div> <div class="file-size"><strong><?php _e( 'File size:' ); ?></strong> {{ data.filesizeHumanReadable }}</div> <# if ( 'image' === data.type && ! data.uploading ) { #> <# if ( data.width && data.height ) { #> <div class="dimensions"><strong><?php _e( 'Dimensions:' ); ?></strong> {{ data.width }} × {{ data.height }}</div> <# } #> <# } #> <# if ( data.fileLength ) { #> <div class="file-length"><strong><?php _e( 'Length:' ); ?></strong> {{ data.fileLength }}</div> <# } #> <# if ( 'audio' === data.type && data.meta.bitrate ) { #> <div class="bitrate"> <strong><?php _e( 'Bitrate:' ); ?></strong> {{ Math.round( data.meta.bitrate / 1000 ) }}kb/s <# if ( data.meta.bitrate_mode ) { #> {{ ' ' + data.meta.bitrate_mode.toUpperCase() }} <# } #> </div> <# } #> <div class="compat-meta"> <# if ( data.compat && data.compat.meta ) { #> {{{ data.compat.meta }}} <# } #> </div> </div> <div class="settings"> <label class="setting" data-setting="url"> <span class="name"><?php _e('URL'); ?></span> <input type="text" value="{{ data.url }}" readonly /> </label> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> <?php if ( post_type_supports( 'attachment', 'title' ) ) : ?> <label class="setting" data-setting="title"> <span class="name"><?php _e('Title'); ?></span> <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> </label> <?php endif; ?> <# if ( 'audio' === data.type ) { #> <?php foreach ( array( 'artist' => __( 'Artist' ), 'album' => __( 'Album' ), ) as $key => $label ) : ?> <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>"> <span class="name"><?php echo $label ?></span> <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" /> </label> <?php endforeach; ?> <# } #> <label class="setting" data-setting="caption"> <span class="name"><?php _e( 'Caption' ); ?></span> <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea> </label> <# if ( 'image' === data.type ) { #> <label class="setting" data-setting="alt"> <span class="name"><?php _e( 'Alt Text' ); ?></span> <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} /> </label> <# } #> <label class="setting" data-setting="description"> <span class="name"><?php _e('Description'); ?></span> <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea> </label> <label class="setting"> <span class="name"><?php _e( 'Uploaded By' ); ?></span> <span class="value">{{ data.authorName }}</span> </label> <# if ( data.uploadedToTitle ) { #> <label class="setting"> <span class="name"><?php _e( 'Uploaded To' ); ?></span> <# if ( data.uploadedToLink ) { #> <span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span> <# } else { #> <span class="value">{{ data.uploadedToTitle }}</span> <# } #> </label> <# } #> <div class="attachment-compat"></div> </div> <div class="actions"> <a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a> <# if ( data.can.save ) { #> | <a href="post.php?post={{ data.id }}&action=edit"><?php _e( 'Edit more details' ); ?></a> <# } #> <# if ( ! data.uploading && data.can.remove ) { #> | <?php if ( MEDIA_TRASH ): ?> <# if ( 'trash' === data.status ) { #> <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a> <# } else { #> <a class="trash-attachment" href="#"><?php _ex( 'Trash', 'verb' ); ?></a> <# } #> <?php else: ?> <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a> <?php endif; ?> <# } #> </div> </div> </script> <script type="text/html" id="tmpl-attachment"> <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}"> <div class="thumbnail"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div style="width: {{ data.percent }}%"></div></div> <# } else if ( 'image' === data.type && data.sizes ) { #> <div class="centered"> <img src="{{ data.size.url }}" draggable="false" alt="" /> </div> <# } else { #> <div class="centered"> <# if ( data.image && data.image.src && data.image.src !== data.icon ) { #> <img src="{{ data.image.src }}" class="thumbnail" draggable="false" /> <# } else { #> <img src="{{ data.icon }}" class="icon" draggable="false" /> <# } #> </div> <div class="filename"> <div>{{ data.filename }}</div> </div> <# } #> </div> <# if ( data.buttons.close ) { #> <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a> <# } #> </div> <# if ( data.buttons.check ) { #> <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>" tabindex="-1"><div class="media-modal-icon"></div></a> <# } #> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; if ( data.describe ) { if ( 'image' === data.type ) { #> <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption" placeholder="<?php esc_attr_e('Caption this image…'); ?>" {{ maybeReadOnly }} /> <# } else { #> <input type="text" value="{{ data.title }}" class="describe" data-setting="title" <# if ( 'video' === data.type ) { #> placeholder="<?php esc_attr_e('Describe this video…'); ?>" <# } else if ( 'audio' === data.type ) { #> placeholder="<?php esc_attr_e('Describe this audio file…'); ?>" <# } else { #> placeholder="<?php esc_attr_e('Describe this media file…'); ?>" <# } #> {{ maybeReadOnly }} /> <# } } #> </script> <script type="text/html" id="tmpl-attachment-details"> <h3> <?php _e('Attachment Details'); ?> <span class="settings-save-status"> <span class="spinner"></span> <span class="saved"><?php esc_html_e('Saved.'); ?></span> </span> </h3> <div class="attachment-info"> <div class="thumbnail thumbnail-{{ data.type }}"> <# if ( data.uploading ) { #> <div class="media-progress-bar"><div></div></div> <# } else if ( 'image' === data.type && data.sizes ) { #> <img src="{{ data.size.url }}" draggable="false" /> <# } else { #> <img src="{{ data.icon }}" class="icon" draggable="false" /> <# } #> </div> <div class="details"> <div class="filename">{{ data.filename }}</div> <div class="uploaded">{{ data.dateFormatted }}</div> <div class="file-size">{{ data.filesizeHumanReadable }}</div> <# if ( 'image' === data.type && ! data.uploading ) { #> <# if ( data.width && data.height ) { #> <div class="dimensions">{{ data.width }} × {{ data.height }}</div> <# } #> <# if ( data.can.save && data.sizes ) { #> <a class="edit-attachment" href="{{ data.editLink }}&image-editor" target="_blank"><?php _e( 'Edit Image' ); ?></a> <a class="refresh-attachment" href="#"><?php _e( 'Refresh' ); ?></a> <# } #> <# } #> <# if ( data.fileLength ) { #> <div class="file-length"><?php _e( 'Length:' ); ?> {{ data.fileLength }}</div> <# } #> <# if ( ! data.uploading && data.can.remove ) { #> <?php if ( MEDIA_TRASH ): ?> <# if ( 'trash' === data.status ) { #> <a class="untrash-attachment" href="#"><?php _e( 'Untrash' ); ?></a> <# } else { #> <a class="trash-attachment" href="#"><?php _ex( 'Trash', 'verb' ); ?></a> <# } #> <?php else: ?> <a class="delete-attachment" href="#"><?php _e( 'Delete Permanently' ); ?></a> <?php endif; ?> <# } #> <div class="compat-meta"> <# if ( data.compat && data.compat.meta ) { #> {{{ data.compat.meta }}} <# } #> </div> </div> </div> <label class="setting" data-setting="url"> <span class="name"><?php _e('URL'); ?></span> <input type="text" value="{{ data.url }}" readonly /> </label> <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> <?php if ( post_type_supports( 'attachment', 'title' ) ) : ?> <label class="setting" data-setting="title"> <span class="name"><?php _e('Title'); ?></span> <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> </label> <?php endif; ?> <# if ( 'audio' === data.type ) { #> <?php foreach ( array( 'artist' => __( 'Artist' ), 'album' => __( 'Album' ), ) as $key => $label ) : ?> <label class="setting" data-setting="<?php echo esc_attr( $key ) ?>"> <span class="name"><?php echo $label ?></span> <input type="text" value="{{ data.<?php echo $key ?> || data.meta.<?php echo $key ?> || '' }}" /> </label> <?php endforeach; ?> <# } #> <label class="setting" data-setting="caption"> <span class="name"><?php _e('Caption'); ?></span> <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea> </label> <# if ( 'image' === data.type ) { #> <label class="setting" data-setting="alt"> <span class="name"><?php _e('Alt Text'); ?></span> <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} /> </label> <# } #> <label class="setting" data-setting="description"> <span class="name"><?php _e('Description'); ?></span> <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea> </label> </script> <script type="text/html" id="tmpl-media-selection"> <div class="selection-info"> <span class="count"></span> <# if ( data.editable ) { #> <a class="edit-selection" href="#"><?php _e( 'Edit Selection' ); ?></a> <# } #> <# if ( data.clearable ) { #> <a class="clear-selection" href="#"><?php _e('Clear'); ?></a> <# } #> </div> <div class="selection-view"></div> </script> <script type="text/html" id="tmpl-attachment-display-settings"> <h3><?php _e('Attachment Display Settings'); ?></h3> <# if ( 'image' === data.type ) { #> <label class="setting"> <span><?php _e('Alignment'); ?></span> <select class="alignment" data-setting="align" <# if ( data.userSettings ) { #> data-user-setting="align" <# } #>> <option value="left"> <?php esc_attr_e('Left'); ?> </option> <option value="center"> <?php esc_attr_e('Center'); ?> </option> <option value="right"> <?php esc_attr_e('Right'); ?> </option> <option value="none" selected> <?php esc_attr_e('None'); ?> </option> </select> </label> <# } #> <div class="setting"> <label> <# if ( data.model.canEmbed ) { #> <span><?php _e('Embed or Link'); ?></span> <# } else { #> <span><?php _e('Link To'); ?></span> <# } #> <select class="link-to" data-setting="link" <# if ( data.userSettings && ! data.model.canEmbed ) { #> data-user-setting="urlbutton" <# } #>> <# if ( data.model.canEmbed ) { #> <option value="embed" selected> <?php esc_attr_e('Embed Media Player'); ?> </option> <option value="file"> <# } else { #> <option value="file" selected> <# } #> <# if ( data.model.canEmbed ) { #> <?php esc_attr_e('Link to Media File'); ?> <# } else { #> <?php esc_attr_e('Media File'); ?> <# } #> </option> <option value="post"> <# if ( data.model.canEmbed ) { #> <?php esc_attr_e('Link to Attachment Page'); ?> <# } else { #> <?php esc_attr_e('Attachment Page'); ?> <# } #> </option> <# if ( 'image' === data.type ) { #> <option value="custom"> <?php esc_attr_e('Custom URL'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> <# } #> </select> </label> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> <# if ( 'undefined' !== typeof data.sizes ) { #> <label class="setting"> <span><?php _e('Size'); ?></span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #>> <?php /** This filter is documented in wp-admin/includes/media.php */ $sizes = apply_filters( 'image_size_names_choose', array( 'thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'), ) ); foreach ( $sizes as $value => $name ) : ?> <# var size = data.sizes['<?php echo esc_js( $value ); ?>']; if ( size ) { #> <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, 'full' ); ?>> <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }} </option> <# } #> <?php endforeach; ?> </select> </label> <# } #> </script> <script type="text/html" id="tmpl-gallery-settings"> <h3><?php _e('Gallery Settings'); ?></h3> <label class="setting"> <span><?php _e('Link To'); ?></span> <select class="link-to" data-setting="link" <# if ( data.userSettings ) { #> data-user-setting="urlbutton" <# } #>> <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> <?php esc_attr_e('Attachment Page'); ?> </option> <option value="file" <# if ( 'file' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> <?php esc_attr_e('Media File'); ?> </option> <option value="none" <# if ( 'none' == wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>> <?php esc_attr_e('None'); ?> </option> </select> </label> <label class="setting"> <span><?php _e('Columns'); ?></span> <select class="columns" name="columns" data-setting="columns"> <?php for ( $i = 1; $i <= 9; $i++ ) : ?> <option value="<?php echo esc_attr( $i ); ?>" <# if ( <?php echo $i ?> == wp.media.galleryDefaults.columns ) { #>selected="selected"<# } #>> <?php echo esc_html( $i ); ?> </option> <?php endfor; ?> </select> </label> <label class="setting"> <span><?php _e( 'Random Order' ); ?></span> <input type="checkbox" data-setting="_orderbyRandom" /> </label> <label class="setting size"> <span><?php _e( 'Size' ); ?></span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #> > <?php // This filter is documented in wp-admin/includes/media.php $size_names = apply_filters( 'image_size_names_choose', array( 'thumbnail' => __( 'Thumbnail' ), 'medium' => __( 'Medium' ), 'large' => __( 'Large' ), 'full' => __( 'Full Size' ), ) ); foreach ( $size_names as $size => $label ) : ?> <option value="<?php echo esc_attr( $size ); ?>"> <?php echo esc_html( $label ); ?> </option> <?php endforeach; ?> </select> </label> </script> <script type="text/html" id="tmpl-playlist-settings"> <h3><?php _e( 'Playlist Settings' ); ?></h3> <# var emptyModel = _.isEmpty( data.model ), isVideo = 'video' === data.controller.get('library').props.get('type'); #> <label class="setting"> <input type="checkbox" data-setting="tracklist" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <# if ( isVideo ) { #> <span><?php _e( 'Show Video List' ); ?></span> <# } else { #> <span><?php _e( 'Show Tracklist' ); ?></span> <# } #> </label> <# if ( ! isVideo ) { #> <label class="setting"> <input type="checkbox" data-setting="artists" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <span><?php _e( 'Show Artist Name in Tracklist' ); ?></span> </label> <# } #> <label class="setting"> <input type="checkbox" data-setting="images" <# if ( emptyModel ) { #> checked="checked" <# } #> /> <span><?php _e( 'Show Images' ); ?></span> </label> </script> <script type="text/html" id="tmpl-embed-link-settings"> <label class="setting link-text"> <span><?php _e( 'Link Text' ); ?></span> <input type="text" class="alignment" data-setting="linkText" /> </label> <div class="embed-container" style="display: none;"> <div class="embed-preview"></div> </div> </script> <script type="text/html" id="tmpl-embed-image-settings"> <div class="thumbnail"> <img src="{{ data.model.url }}" draggable="false" /> </div> <?php /** This filter is documented in wp-admin/includes/media.php */ if ( ! apply_filters( 'disable_captions', '' ) ) : ?> <label class="setting caption"> <span><?php _e('Caption'); ?></span> <textarea data-setting="caption" /> </label> <?php endif; ?> <label class="setting alt-text"> <span><?php _e('Alt Text'); ?></span> <input type="text" data-setting="alt" /> </label> <div class="setting align"> <span><?php _e('Align'); ?></span> <div class="button-group button-large" data-setting="align"> <button class="button" value="left"> <?php esc_attr_e('Left'); ?> </button> <button class="button" value="center"> <?php esc_attr_e('Center'); ?> </button> <button class="button" value="right"> <?php esc_attr_e('Right'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> </div> <div class="setting link-to"> <span><?php _e('Link To'); ?></span> <div class="button-group button-large" data-setting="link"> <button class="button" value="file"> <?php esc_attr_e('Image URL'); ?> </button> <button class="button" value="custom"> <?php esc_attr_e('Custom URL'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> </script> <script type="text/html" id="tmpl-image-details"> <div class="media-embed"> <div class="embed-media-settings"> <div class="column-image"> <div class="image"> <img src="{{ data.model.url }}" draggable="false" /> <# if ( data.attachment && window.imageEdit ) { #> <div class="actions"> <input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Original' ); ?>" /> <input type="button" class="replace-attachment button" value="<?php esc_attr_e( 'Replace' ); ?>" /> </div> <# } #> </div> </div> <div class="column-settings"> <?php /** This filter is documented in wp-admin/includes/media.php */ if ( ! apply_filters( 'disable_captions', '' ) ) : ?> <label class="setting caption"> <span><?php _e('Caption'); ?></span> <textarea data-setting="caption">{{ data.model.caption }}</textarea> </label> <?php endif; ?> <label class="setting alt-text"> <span><?php _e('Alternative Text'); ?></span> <input type="text" data-setting="alt" value="{{ data.model.alt }}" /> </label> <h3><?php _e( 'Display Settings' ); ?></h3> <div class="setting align"> <span><?php _e('Align'); ?></span> <div class="button-group button-large" data-setting="align"> <button class="button" value="left"> <?php esc_attr_e('Left'); ?> </button> <button class="button" value="center"> <?php esc_attr_e('Center'); ?> </button> <button class="button" value="right"> <?php esc_attr_e('Right'); ?> </button> <button class="button active" value="none"> <?php esc_attr_e('None'); ?> </button> </div> </div> <# if ( data.attachment ) { #> <# if ( 'undefined' !== typeof data.attachment.sizes ) { #> <label class="setting size"> <span><?php _e('Size'); ?></span> <select class="size" name="size" data-setting="size" <# if ( data.userSettings ) { #> data-user-setting="imgsize" <# } #>> <?php /** This filter is documented in wp-admin/includes/media.php */ $sizes = apply_filters( 'image_size_names_choose', array( 'thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'), ) ); foreach ( $sizes as $value => $name ) : ?> <# var size = data.sizes['<?php echo esc_js( $value ); ?>']; if ( size ) { #> <option value="<?php echo esc_attr( $value ); ?>"> <?php echo esc_html( $name ); ?> – {{ size.width }} × {{ size.height }} </option> <# } #> <?php endforeach; ?> <option value="<?php echo esc_attr( 'custom' ); ?>"> <?php _e( 'Custom Size' ); ?> </option> </select> </label> <# } #> <div class="custom-size<# if ( data.model.size !== 'custom' ) { #> hidden<# } #>"> <label><span><?php _e( 'Width' ); ?> <small>(px)</small></span> <input data-setting="customWidth" type="number" step="1" value="{{ data.model.customWidth }}" /></label><span class="sep">×</span><label><span><?php _e( 'Height' ); ?> <small>(px)</small></span><input data-setting="customHeight" type="number" step="1" value="{{ data.model.customHeight }}" /></label> </div> <# } #> <div class="setting link-to"> <span><?php _e('Link To'); ?></span> <select data-setting="link"> <# if ( data.attachment ) { #> <option value="file"> <?php esc_attr_e('Media File'); ?> </option> <option value="post"> <?php esc_attr_e('Attachment Page'); ?> </option> <# } else { #> <option value="file"> <?php esc_attr_e('Image URL'); ?> </option> <# } #> <option value="custom"> <?php esc_attr_e('Custom URL'); ?> </option> <option value="none"> <?php esc_attr_e('None'); ?> </option> </select> <input type="text" class="link-to-custom" data-setting="linkUrl" /> </div> <div class="advanced-section"> <h3><a class="advanced-toggle" href="#"><?php _e('Advanced Options'); ?></a></h3> <div class="advanced-settings hidden"> <div class="advanced-image"> <label class="setting title-text"> <span><?php _e('Image Title Attribute'); ?></span> <input type="text" data-setting="title" value="{{ data.model.title }}" /> </label> <label class="setting extra-classes"> <span><?php _e('Image CSS Class'); ?></span> <input type="text" data-setting="extraClasses" value="{{ data.model.extraClasses }}" /> </label> </div> <div class="advanced-link"> <div class="setting link-target"> <label><input type="checkbox" data-setting="linkTargetBlank" value="_blank" <# if ( data.model.linkTargetBlank ) { #>checked="checked"<# } #>><?php _e( 'Open link in a new window/tab' ); ?></label> </div> <label class="setting link-rel"> <span><?php _e('Link Rel'); ?></span> <input type="text" data-setting="linkRel" value="{{ data.model.linkClassName }}" /> </label> <label class="setting link-class-name"> <span><?php _e('Link CSS Class'); ?></span> <input type="text" data-setting="linkClassName" value="{{ data.model.linkClassName }}" /> </label> </div> </div> </div> </div> </div> </div> </script> <script type="text/html" id="tmpl-image-editor"> <div id="media-head-{{ data.id }}"></div> <div id="image-editor-{{ data.id }}"></div> </script> <script type="text/html" id="tmpl-audio-details"> <# var ext, html5types = { mp3: wp.media.view.settings.embedMimes.mp3, ogg: wp.media.view.settings.embedMimes.ogg }; #> <?php $audio_types = wp_get_audio_extensions(); ?> <div class="media-embed media-embed-details"> <div class="embed-media-settings embed-audio-settings"> <?php wp_underscore_audio_template() ?> <# if ( ! _.isEmpty( data.model.src ) ) { ext = data.model.src.split('.').pop(); if ( html5types[ ext ] ) { delete html5types[ ext ]; } #> <label class="setting"> <span>SRC</span> <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" /> <a class="remove-setting"><?php _e( 'Remove' ); ?></a> </label> <# } #> <?php foreach ( $audio_types as $type ): ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) { delete html5types.<?php echo $type ?>; } #> <label class="setting"> <span><?php echo strtoupper( $type ) ?></span> <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" /> <a class="remove-setting"><?php _e( 'Remove' ); ?></a> </label> <# } #> <?php endforeach ?> <# if ( ! _.isEmpty( html5types ) ) { #> <div class="setting"> <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ) ?></span> <div class="button-large"> <# _.each( html5types, function (mime, type) { #> <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button> <# } ) #> </div> </div> <# } #> <div class="setting preload"> <span><?php _e( 'Preload' ); ?></span> <div class="button-group button-large" data-setting="preload"> <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button> <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button> <button class="button active" value="none"><?php _e( 'None' ); ?></button> </div> </div> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="autoplay" /> <span><?php _e( 'Autoplay' ); ?></span> </label> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="loop" /> <span><?php _e( 'Loop' ); ?></span> </label> </div> </div> </script> <script type="text/html" id="tmpl-video-details"> <# var ext, html5types = { mp4: wp.media.view.settings.embedMimes.mp4, ogv: wp.media.view.settings.embedMimes.ogv, webm: wp.media.view.settings.embedMimes.webm }; #> <?php $video_types = wp_get_video_extensions(); ?> <div class="media-embed media-embed-details"> <div class="embed-media-settings embed-video-settings"> <div class="wp-video-holder"> <# var w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width, h = ! data.model.height ? 360 : data.model.height; if ( data.model.width && w !== data.model.width ) { h = Math.ceil( ( h * w ) / data.model.width ); } #> <?php wp_underscore_video_template() ?> <# if ( ! _.isEmpty( data.model.src ) ) { ext = data.model.src.split('.').pop(); if ( html5types[ ext ] ) { delete html5types[ ext ]; } #> <label class="setting"> <span>SRC</span> <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" /> <a class="remove-setting"><?php _e( 'Remove' ); ?></a> </label> <# } #> <?php foreach ( $video_types as $type ): ?><# if ( ! _.isEmpty( data.model.<?php echo $type ?> ) ) { if ( ! _.isUndefined( html5types.<?php echo $type ?> ) ) { delete html5types.<?php echo $type ?>; } #> <label class="setting"> <span><?php echo strtoupper( $type ) ?></span> <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" /> <a class="remove-setting"><?php _e( 'Remove' ); ?></a> </label> <# } #> <?php endforeach ?> </div> <# if ( ! _.isEmpty( html5types ) ) { #> <div class="setting"> <span><?php _e( 'Add alternate sources for maximum HTML5 playback:' ); ?></span> <div class="button-large"> <# _.each( html5types, function (mime, type) { #> <button class="button add-media-source" data-mime="{{ mime }}">{{ type }}</button> <# } ) #> </div> </div> <# } #> <# if ( ! _.isEmpty( data.model.poster ) ) { #> <label class="setting"> <span><?php _e( 'Poster Image' ); ?></span> <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" /> <a class="remove-setting"><?php _e( 'Remove' ); ?></a> </label> <# } #> <div class="setting preload"> <span><?php _e( 'Preload' ); ?></span> <div class="button-group button-large" data-setting="preload"> <button class="button" value="auto"><?php _ex( 'Auto', 'auto preload' ); ?></button> <button class="button" value="metadata"><?php _e( 'Metadata' ); ?></button> <button class="button active" value="none"><?php _e( 'None' ); ?></button> </div> </div> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="autoplay" /> <span><?php _e( 'Autoplay' ); ?></span> </label> <label class="setting checkbox-setting"> <input type="checkbox" data-setting="loop" /> <span><?php _e( 'Loop' ); ?></span> </label> <label class="setting" data-setting="content"> <span><?php _e( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ); ?></span> <# var content = ''; if ( ! _.isEmpty( data.model.content ) ) { var tracks = jQuery( data.model.content ).filter( 'track' ); _.each( tracks.toArray(), function (track) { content += track.outerHTML; #> <p> <input class="content-track" type="text" value="{{ track.outerHTML }}" /> <a class="remove-setting remove-track"><?php _e( 'Remove' ); ?></a> </p> <# } ); #> <# } else { #> <em><?php _e( 'There are no associated subtitles.' ); ?></em> <# } #> <textarea class="hidden content-setting">{{ content }}</textarea> </label> </div> </div> </script> <script type="text/html" id="tmpl-editor-gallery"> <# if ( data.attachments.length ) { #> <div class="gallery gallery-columns-{{ data.columns }}"> <# _.each( data.attachments, function( attachment, index ) { #> <dl class="gallery-item"> <dt class="gallery-icon"> <# if ( attachment.thumbnail ) { #> <img src="{{ attachment.thumbnail.url }}" width="{{ attachment.thumbnail.width }}" height="{{ attachment.thumbnail.height }}" /> <# } else { #> <img src="{{ attachment.url }}" /> <# } #> </dt> <# if ( attachment.caption ) { #> <dd class="wp-caption-text gallery-caption"> {{ attachment.caption }} </dd> <# } #> </dl> <# if ( index % data.columns === data.columns - 1 ) { #> <br style="clear: both;"> <# } #> <# } ); #> </div> <# } else { #> <div class="wpview-error"> <div class="dashicons dashicons-format-gallery"></div><p><?php _e( 'No items found.' ); ?></p> </div> <# } #> </script> <script type="text/html" id="tmpl-crop-content"> <img class="crop-image" src="{{ data.url }}"> <div class="upload-errors"></div> </script> <?php /** * Fires when the custom Backbone media templates are printed. * * @since 3.5.0 */ do_action( 'print_media_templates' ); }
function usp_video_url($postId = false, $fileId = false, $number = false) { global $post; if ($postId === false) { $postId = $post->ID; } if ($number === false) { $number = -1; } if ($fileId === false) { $fileId = null; } $post_meta = get_post_custom($postId); $video_extensions = wp_get_video_extensions(); $video_urls = array(); $i = 0; foreach ($post_meta as $key => $value) { if (preg_match("/^usp-file-([0-9]+)\$/i", $key, $matches)) { foreach ($value as $k => $v) { $url = pathinfo($v); if (isset($url['extension']) && in_array($url['extension'], $video_extensions)) { if (!empty($fileId)) { if (isset($matches[1]) && $matches[1] == $fileId) { if (!empty($v)) { $video_urls[] = $v; $i++; } } } else { $video_urls[] = $v; $i++; } } } } if ($i === intval($number)) { break; } } return $video_urls; }
/** * Extract [video] shortcodes from text. * * @since 2.3.0 * * @see wp_get_video_extensions() for supported video formats. * * @param string $richtext Content to parse. * @param string $plaintext Sanitized version of the content. * @param array $extra_args Bespoke data for a particular extractor (optional). * * @return array { * @type array $has Extracted media counts. { * @type int $video * } * @type array $videos Extracted video. { * Array of extracted media. * * @type string $source Media source. Currently only "shortcodes". * @type string $url Link to audio. * } * } */ protected function extract_video($richtext, $plaintext, $extra_args = array()) { $data = array('has' => array('videos' => 0), 'videos' => array()); $videos = $this->extract_shortcodes($richtext, $plaintext, $extra_args); $video_types = wp_get_video_extensions(); // [video] $videos = wp_list_filter($videos['shortcodes'], array('type' => 'video')); foreach ($videos as $video) { // Media URL can appear as the first parameter inside the shortcode brackets. if (isset($video['attributes']['src'])) { $src_param = 'src'; } elseif (isset($video['attributes'][0])) { $src_param = 0; } else { continue; } $path = untrailingslashit(parse_url($video['attributes'][$src_param], PHP_URL_PATH)); foreach ($video_types as $extension) { $extension = '.' . $extension; // Check this URL's file extension matches that of an accepted video format (-5 for webm). if (!$path || substr($path, -4) !== $extension && substr($path, -5) !== $extension) { continue; } $data['videos'][] = array('original' => $video['original'], 'source' => 'shortcodes', 'url' => esc_url_raw($video['attributes'][$src_param])); } } $data['has']['videos'] = count($data['videos']); /** * Filters videos extracted from text. * * @since 2.3.0 * * @param array $data Extracted videos. See {@link BP_Media_Extractor::extract_videos()} for format. * @param string $richtext Content to parse. * @param string $plaintext Copy of $richtext without any markup. * @param array $extra_args Bespoke data for a particular extractor. */ return apply_filters('bp_media_extractor_videos', $data, $richtext, $plaintext, $extra_args); }
/** * Determines if default embed handlers should be loaded. * * Checks to make sure that the embeds library hasn't already been loaded. If * it hasn't, then it will load the embeds library. * * @since 2.9.0 */ function wp_maybe_load_embeds() { if (!apply_filters('load_default_embeds', true)) { return; } wp_embed_register_handler('googlevideo', '#http://video\\.google\\.([A-Za-z.]{2,5})/videoplay\\?docid=([\\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo'); wp_embed_register_handler('audio', '#^https?://.+?\\.(' . join('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999); wp_embed_register_handler('video', '#^https?://.+?\\.(' . join('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999); }
/** * Determines if default embed handlers should be loaded. * * Checks to make sure that the embeds library hasn't already been loaded. If * it hasn't, then it will load the embeds library. * * @since 2.9.0 * * @see wp_embed_register_handler() */ function wp_maybe_load_embeds() { /** * Filter whether to load the default embed handlers. * * Returning a falsey value will prevent loading the default embed handlers. * * @since 2.9.0 * * @param bool $maybe_load_embeds Whether to load the embeds library. Default true. */ if (!apply_filters('load_default_embeds', true)) { return; } wp_embed_register_handler('youtube_embed_url', '#https?://(www.)?youtube\\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube'); wp_embed_register_handler('googlevideo', '#http://video\\.google\\.([A-Za-z.]{2,5})/videoplay\\?docid=([\\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo'); /** * Filter the audio embed handler callback. * * @since 3.6.0 * * @param callable $handler Audio embed handler callback function. */ wp_embed_register_handler('audio', '#^https?://.+?\\.(' . join('|', wp_get_audio_extensions()) . ')$#i', apply_filters('wp_audio_embed_handler', 'wp_embed_handler_audio'), 9999); /** * Filter the video embed handler callback. * * @since 3.6.0 * * @param callable $handler Video embed handler callback function. */ wp_embed_register_handler('video', '#^https?://.+?\\.(' . join('|', wp_get_video_extensions()) . ')$#i', apply_filters('wp_video_embed_handler', 'wp_embed_handler_video'), 9999); }
/** * Builds the Video shortcode output. * * This implements the functionality of the Video Shortcode for displaying * WordPress mp4s in a post. * * * @param array $attr { * Attributes of the shortcode. * * @type string $src URL to the source of the video file. Default empty. * @type int $height Height of the video embed in pixels. Default 360. * @type int $width Width of the video embed in pixels. Default $content_width or 640. * @type string $poster The 'poster' attribute for the `<video>` element. Default empty. * @type string $loop The 'loop' attribute for the `<video>` element. Default empty. * @type string $autoplay The 'autoplay' attribute for the `<video>` element. Default empty. * @type string $preload The 'preload' attribute for the `<video>` element. * Default 'metadata'. * @type string $class The 'class' attribute for the `<video>` element. * Default 'simple-fb-video-shortcode'. * } * @param string $content Shortcode content. * @return string|void HTML content to display video. */ function video($attr, $content = '') { /** * Filter the default video shortcode output. * * If the filtered output isn't empty, it will be used instead of generating * the default video template. * * @since 3.6.0 * * @see wp_video_shortcode() * * @param string $html Empty variable to be replaced with shortcode markup. * @param array $attr Attributes of the video shortcode. * @param string $content Video shortcode content. */ $override = apply_filters('simple_fb_video_shortcode_override', '', $attr, $content); if ('' !== $override) { return $override; } $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'width' => 640, 'height' => 360); foreach ($default_types as $type) { $defaults_atts[$type] = ''; } // Boom, atts. $atts = shortcode_atts($defaults_atts, $attr, 'video'); $primary = false; foreach ($default_types as $ext) { if (!empty($atts[$ext])) { $type = wp_check_filetype($atts[$ext], wp_get_mime_types()); if (strtolower($type['ext']) === $ext) { $primary = true; } } } if (!$primary) { $videos = get_attached_media('video', $post_id); if (empty($videos)) { return; } $video = reset($videos); $atts['src'] = wp_get_attachment_url($video->ID); if (empty($atts['src'])) { return; } array_unshift($default_types, 'src'); } $html_atts = array('class' => apply_filters('wp_video_shortcode_class', 'simple-fb-video-shortcode'), 'id' => sprintf('video-%d', $post_id), 'width' => absint($atts['width']), 'height' => absint($atts['height']), 'poster' => esc_url($atts['poster']), 'loop' => wp_validate_boolean($atts['loop']), 'autoplay' => wp_validate_boolean($atts['autoplay']), 'preload' => $atts['preload']); // These ones should just be omitted altogether if they are blank foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) { if (empty($html_atts[$a])) { unset($html_atts[$a]); } } $attr_strings = array(); foreach ($html_atts as $k => $v) { $attr_strings[] = $k . '="' . esc_attr($v) . '"'; } $html = ''; $html .= sprintf('<video %s controls="controls">', join(' ', $attr_strings)); $fileurl = ''; $source = '<source type="%s" src="%s" />'; foreach ($default_types as $fallback) { if (!empty($atts[$fallback])) { if (empty($fileurl)) { $fileurl = $atts[$fallback]; } if ('src' === $fallback && $is_youtube) { $type = array('type' => 'video/youtube'); } elseif ('src' === $fallback && $is_vimeo) { $type = array('type' => 'video/vimeo'); } else { $type = wp_check_filetype($atts[$fallback], wp_get_mime_types()); } $url = add_query_arg('_', $instance, $atts[$fallback]); $html .= sprintf($source, $type['type'], esc_url($url)); } } if (!empty($content)) { if (false !== strpos($content, "\n")) { $content = str_replace(array("\r\n", "\n", "\t"), '', $content); } $html .= trim($content); } $html .= '</video>'; /** * Filter the output of the video shortcode. * * @since 3.6.0 * * @param string $output Video shortcode HTML output. * @param array $atts Array of video shortcode attributes. * @param string $video Video file. * @param int $post_id Post ID. */ return apply_filters('simple_fb_video_shortcode', $output, $atts, $video, $post_id); }