Exemplo n.º 1
0
/**
 * 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);
}
    /**
     * Module Settings Fields
     * @param array $module_options 
     * @return string
     */
    function themify_builder_module_settings_field($module_options, $module_name)
    {
        foreach ($module_options as $field) {
            $id = isset($field['id']) ? $field['id'] : '';
            // custom field types used by 3rd party module authors
            if (function_exists("themify_builder_field_{$field['type']}")) {
                call_user_func("themify_builder_field_{$field['type']}", $field, $module_name);
                continue;
            } elseif ($field['type'] == 'group') {
                // simple wrapper for multiple related options
                $classes = isset($field['wrap_with_class']) ? $field['wrap_with_class'] : '';
                echo '<div class="themify_builder_field ' . $id . ' ' . $classes . '">';
                themify_builder_module_settings_field($field['fields'], $module_name);
                echo '</div>';
                continue;
            } else {
                if ($field['type'] == 'tabs') {
                    themify_builder_tabs($field, $module_name);
                    continue;
                }
            }
            if (isset($field['separated']) && $field['separated'] == 'top') {
                ?>
				<hr />
			<?php 
            }
            ?>

			<?php 
            if ($field['type'] != 'builder' && (!isset($field['hide']) || $field['hide'] == false)) {
                ?>
			<div class="themify_builder_field <?php 
                echo $id;
                ?>
 <?php 
                echo isset($field['wrap_with_class']) ? $field['wrap_with_class'] : '';
                ?>
">
			<?php 
            }
            ?>

				<?php 
            if (isset($field['id']) && isset($field['label']) && $field['label'] != false) {
                ?>
					<div class="themify_builder_label"><?php 
                echo $field['label'];
                ?>
</div>
				<?php 
            }
            ?>

			<?php 
            if ($field['type'] == 'multi') {
                echo '<div class="' . $id . ' tf_multi_fields tf_fields_count_' . count($field['fields']) . '">';
                foreach ($field['fields'] as $_field) {
                    themify_builder_module_settings_field(array($_field), $module_name);
                }
                echo '</div>';
            } else {
                if ('wp_editor' == $field['type']) {
                    wp_editor('', $field['id'], array('editor_class' => $field['class'] . ' tfb_lb_wp_editor tfb_lb_option', 'textarea_rows' => 20));
                } elseif ('builder' == $field['type']) {
                    ?>

				<div class="<?php 
                    echo isset($field['wrap_with_class']) ? $field['wrap_with_class'] : '';
                    ?>
">
				<hr />

				<div id="<?php 
                    echo $field['id'];
                    ?>
" class="themify_builder_module_opt_builder_wrap themify_builder_row_js_wrapper tfb_lb_option">
					
					<div class="themify_builder_row clearfix">
					
						<div class="themify_builder_row_top">
							<div class="row_menu">
								<div class="menu_icon">
								</div>
								<ul style="display: none;" class="themify_builder_dropdown">
									<li><a href="#" class="themify_builder_duplicate_row"><?php 
                    _e('Duplicate', 'themify');
                    ?>
</a></li>
									<li><a href="#" class="themify_builder_delete_row"><?php 
                    _e('Delete', 'themify');
                    ?>
</a></li>
								</ul>
							</div>
							<!-- /row_menu -->
							<div class="toggle_row"></div><!-- /toggle_row -->
						</div>
						<!-- /row_top -->
						
						<div class="themify_builder_row_content">

							<?php 
                    foreach ($field['options'] as $option) {
                        ?>
								<div class="themify_builder_field <?php 
                        echo isset($field['wrap_with_class']) ? $field['wrap_with_class'] : '';
                        ?>
">

									<?php 
                        if (isset($option['label']) && $option['label'] != false) {
                            ?>
										<div class="themify_builder_label"><?php 
                            echo $option['label'];
                            ?>
</div><!-- /themify_builder_input_title -->
									<?php 
                        }
                        ?>

									<div class="themify_builder_input"<?php 
                        echo $option['type'] == 'wp_editor' ? ' style="width:100%;"' : '';
                        ?>
>
										<?php 
                        if ($option['type'] == 'text') {
                            ?>

											<?php 
                            if (isset($option['colorpicker']) && $option['colorpicker'] == true) {
                                ?>
												<span class="builderColorSelect"><span></span></span> 
												<input type="text" class="<?php 
                                echo $option['class'];
                                ?>
 colordisplay" <?php 
                                echo themify_builder_get_binding_data($option);
                                ?>
 />
												<input id="<?php 
                                echo $option['id'];
                                ?>
" name="<?php 
                                echo $option['id'];
                                ?>
" value="<?php 
                                if (isset($option['value'])) {
                                    echo $option['value'];
                                }
                                ?>
" class="builderColorSelectInput tfb_lb_option_child" type="hidden"  data-input-id="<?php 
                                echo $option['id'];
                                ?>
" />
											<?php 
                            } else {
                                ?>
												<input name="<?php 
                                echo $option['id'];
                                ?>
" class="<?php 
                                echo $option['class'];
                                ?>
 tfb_lb_option_child <?php 
                                echo $add_class;
                                ?>
" type="text" data-input-id="<?php 
                                echo $option['id'];
                                ?>
" />
												<?php 
                                if (isset($option['iconpicker']) && $option['iconpicker'] == true) {
                                    ?>
													<a class="button button-secondary hide-if-no-js themify_fa_toggle" href="#"><?php 
                                    _e('Insert Icon', 'themify');
                                    ?>
</a>
												<?php 
                                }
                                ?>
												<?php 
                                if (isset($option['after'])) {
                                    echo $option['after'];
                                }
                                ?>
											<?php 
                            }
                            ?>

										<?php 
                        } elseif ('image' == $option['type']) {
                            ?>
											<input data-input-id="<?php 
                            echo $option['id'];
                            ?>
" name="<?php 
                            echo $option['id'];
                            ?>
" placeholder="<?php 
                            if (isset($option['value'])) {
                                echo $option['value'];
                            }
                            ?>
" class="<?php 
                            echo $option['class'];
                            ?>
 themify-builder-uploader-input tfb_lb_option_child" 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 $option['id'];
                                ?>
themify-builder-plupload-upload-ui">
														<input id="<?php 
                                echo $option['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($option['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 an Image', 'themify');
                                ?>
" data-uploader-button-text="<?php 
                                _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 
                        } elseif ('audio' == $option['type']) {
                            ?>
											<input data-input-id="<?php 
                            echo $option['id'];
                            ?>
" name="<?php 
                            echo $option['id'];
                            ?>
" placeholder="<?php 
                            if (isset($option['value'])) {
                                echo $option['value'];
                            }
                            ?>
" class="<?php 
                            echo $option['class'];
                            ?>
 themify-builder-uploader-input tfb_lb_option_child" 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 $option['id'];
                                ?>
themify-builder-plupload-upload-ui" data-extensions="<?php 
                                echo esc_attr(implode(',', wp_get_audio_extensions()));
                                ?>
">
														<input id="<?php 
                                echo $option['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($option['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 an Image', 'themify');
                                ?>
" data-uploader-button-text="<?php 
                                _e('Insert file URL', 'themify');
                                ?>
" data-library-type="audio"><?php 
                                _e('Browse Library', 'themify');
                                ?>
</a>

												<?php 
                            }
                            ?>

											</div>

										<?php 
                        } elseif ($option['type'] == 'textarea') {
                            ?>
											<textarea name="<?php 
                            echo $option['id'];
                            ?>
" class="<?php 
                            echo $option['class'];
                            ?>
 tfb_lb_option_child" <?php 
                            echo isset($option['rows']) ? 'rows="' . $option['rows'] . '"' : '';
                            ?>
 data-input-id="<?php 
                            echo $option['id'];
                            ?>
"></textarea><br />

											<?php 
                            if (isset($option['radio'])) {
                                ?>
												<div data-input-id="<?php 
                                echo $option['radio']['id'];
                                ?>
" class="tfb_lb_option_child tf-radio-choice">
													<?php 
                                echo $option['radio']['label'];
                                ?>
													<?php 
                                foreach ($option['radio']['options'] as $k => $v) {
                                    ?>
														<input id="<?php 
                                    echo $option['radio']['id'] . '_' . $k;
                                    ?>
" type="radio" name="<?php 
                                    echo $option['radio']['id'];
                                    ?>
" class="themify-builder-radio-dnd" value="<?php 
                                    echo $k;
                                    ?>
" />
														<label for="<?php 
                                    echo $option['radio']['id'] . '_' . $k;
                                    ?>
" class="pad-right themify-builder-radio-dnd-label"><?php 
                                    echo $k;
                                    ?>
</label>
													<?php 
                                }
                                ?>
												</div>
											<?php 
                            }
                            // endif radio input
                            ?>

										<?php 
                        } elseif ('wp_editor' == $option['type']) {
                            wp_editor('', $option['id'], array('editor_class' => $option['class'] . ' tfb_lb_wp_editor tfb_lb_option_child', 'textarea_rows' => 20));
                            ?>

										<?php 
                        } elseif ('radio' == $option['type']) {
                            ?>
											<div data-input-id="<?php 
                            echo $option['id'];
                            ?>
" class="tfb_lb_option_child tf-radio-choice">
												<?php 
                            foreach ($option['options'] as $k => $v) {
                                ?>
													<input id="<?php 
                                echo $option['id'] . '_' . $k;
                                ?>
" type="radio" name="<?php 
                                echo $option['id'];
                                ?>
" class="themify-builder-radio-dnd" value="<?php 
                                echo $k;
                                ?>
" />
													<label for="<?php 
                                echo $option['id'] . '_' . $k;
                                ?>
" class="pad-right themify-builder-radio-dnd-label"><?php 
                                echo $k;
                                ?>
</label>
												<?php 
                            }
                            ?>
											</div>
										<?php 
                        }
                        // endif radio input
                        ?>

										<?php 
                        if (isset($option['help'])) {
                            ?>
											<?php 
                            if (isset($option['help']['new_line'])) {
                                ?>
												<br />
											<?php 
                            }
                            ?>
											<small><?php 
                            echo $option['help']['text'];
                            ?>
</small>
										<?php 
                        }
                        ?>

									</div><!-- /themify_builder_input -->

								</div>
								<!-- /themify_builder_field -->

							<?php 
                    }
                    ?>

						</div>
						<!-- /themify_builder_row_content -->

					</div>
					<!-- /builder_row -->

				</div>
				<!-- /themify_builder_module_opt_builder_wrap -->
					
				<p class="add_new"><a href="#"><span class="themify_builder_icon add"></span><?php 
                    _e('Add new row', 'themify');
                    ?>
</a></p>
				</div>
				<!-- /builder wrapper -->
				<?php 
                } else {
                    ?>
				<div class="themify_builder_input<?php 
                    echo isset($field['pushed']) && $field['pushed'] != '' ? ' ' . $field['pushed'] : '';
                    ?>
">
					<?php 
                    if ('text' == $field['type']) {
                        ?>

						<?php 
                        if (isset($field['colorpicker']) && $field['colorpicker'] == true) {
                            ?>
							<span class="builderColorSelect"><span></span></span> 
							<input type="text" class="<?php 
                            echo $field['class'];
                            ?>
 colordisplay" <?php 
                            echo themify_builder_get_binding_data($field);
                            ?>
 />
							<input id="<?php 
                            echo $field['id'];
                            ?>
" name="<?php 
                            echo $field['id'];
                            ?>
" value="<?php 
                            if (isset($field['value'])) {
                                echo $field['value'];
                            }
                            ?>
" class="builderColorSelectInput tfb_lb_option" type="hidden" />
						<?php 
                        } else {
                            ?>
							<input id="<?php 
                            echo $field['id'];
                            ?>
" name="<?php 
                            echo $field['id'];
                            ?>
" value="<?php 
                            if (isset($field['value'])) {
                                echo $field['value'];
                            }
                            ?>
" class="<?php 
                            echo $field['class'] . $add_class;
                            ?>
 tfb_lb_option" type="text" <?php 
                            echo themify_builder_get_binding_data($field);
                            ?>
 />
							<?php 
                            if (isset($field['after'])) {
                                echo $field['after'];
                            }
                            ?>

							<?php 
                            if (isset($field['unit'])) {
                                ?>
								<select id="<?php 
                                echo $field['unit']['id'];
                                ?>
" class="tfb_lb_option" <?php 
                                echo themify_builder_get_binding_data($field);
                                ?>
>
									<?php 
                                foreach ($field['unit']['options'] as $u) {
                                    ?>
									<option value="<?php 
                                    echo $u['value'];
                                    ?>
" <?php 
                                    echo isset($field['unit']['selected']) && $field['unit']['selected'] == $u['value'] ? 'selected="selected"' : '';
                                    ?>
><?php 
                                    echo $u['value'];
                                    ?>
</option>
									<?php 
                                }
                                ?>
								</select>
							<?php 
                            }
                            // unit
                            ?>
						<?php 
                        }
                        ?>

					<?php 
                    } elseif ('icon' == $field['type']) {
                        ?>
					<input id="<?php 
                        echo $field['id'];
                        ?>
" name="<?php 
                        echo $field['id'];
                        ?>
" value="<?php 
                        if (isset($field['value'])) {
                            echo $field['value'];
                        }
                        ?>
" class="themify_field_icon <?php 
                        echo $field['class'];
                        ?>
 tfb_lb_option" type="text" <?php 
                        echo themify_builder_get_binding_data($field);
                        ?>
 />
					<a class="button button-secondary hide-if-no-js themify_fa_toggle" href="#" data-target="#<?php 
                        echo $field['id'];
                        ?>
"><?php 
                        _e('Insert Icon', 'themify');
                        ?>
</a>

					<?php 
                    } elseif ('radio' == $field['type']) {
                        ?>
					<?php 
                        $option_js = isset($field['option_js']) && $field['option_js'] == true ? 'tf-option-checkbox-js' : '';
                        $option_js_wrap = isset($field['option_js']) && $field['option_js'] == true ? 'tf-option-checkbox-enable' : '';
                        ?>
						<div id="<?php 
                        echo $field['id'];
                        ?>
" class="tfb_lb_option tf-radio-input-container <?php 
                        echo $option_js_wrap;
                        ?>
">
							<?php 
                        foreach ($field['options'] as $k => $v) {
                            ?>
							<?php 
                            $default_checked = isset($field['default']) && $field['default'] == $k ? 'checked="checked"' : '';
                            $data_el = isset($field['option_js']) && $field['option_js'] == true ? 'data-selected="tf-group-element-' . $k . '"' : '';
                            ?>
							<input id="<?php 
                            echo $field['id'] . '_' . $k;
                            ?>
" name="<?php 
                            echo $field['id'];
                            ?>
" type="radio" class="<?php 
                            echo $option_js;
                            ?>
" value="<?php 
                            echo $k;
                            ?>
" <?php 
                            echo $default_checked . ' ' . $data_el;
                            ?>
/>
							<label for="<?php 
                            echo $field['id'] . '_' . $k;
                            ?>
" class="pad-right"><?php 
                            echo $v;
                            ?>
</label> 
							
							<?php 
                            if (isset($field['break']) && $field['break'] == true) {
                                ?>
							<br />
							<?php 
                            }
                            ?>

							<?php 
                        }
                        ?>
						</div>

					<?php 
                    } elseif ('layout' == $field['type']) {
                        ?>
					<p id="<?php 
                        echo $field['id'];
                        ?>
" class="layout_icon tfb_lb_option themify-layout-icon">
						<?php 
                        foreach ($field['options'] as $option) {
                            ?>
						<a href="#" id="<?php 
                            echo $option['value'];
                            ?>
" title="<?php 
                            echo $option['label'];
                            ?>
" class="tfl-icon">
							<?php 
                            $image_url = filter_var($option['img'], FILTER_VALIDATE_URL) ? $option['img'] : THEMIFY_BUILDER_URI . '/img/builder/' . $option['img'];
                            ?>
							<img src="<?php 
                            echo $image_url;
                            ?>
" alt="<?php 
                            echo $option['label'];
                            ?>
" />
						</a>
						<?php 
                        }
                        ?>
					</p>

					<?php 
                    } elseif ('image' == $field['type']) {
                        ?>
					<input id="<?php 
                        echo $field['id'];
                        ?>
" name="<?php 
                        echo $field['id'];
                        ?>
" placeholder="<?php 
                        if (isset($field['value'])) {
                            echo $field['value'];
                        }
                        ?>
" class="<?php 
                        echo $field['class'];
                        ?>
 themify-builder-uploader-input tfb_lb_option" type="text" <?php 
                        echo themify_builder_get_binding_data($field);
                        ?>
 /><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 $field['id'];
                            ?>
themify-builder-plupload-upload-ui">
								<input id="<?php 
                            echo $field['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($field['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 an Image', 'themify');
                            ?>
" data-uploader-button-text="<?php 
                            _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 
                    } elseif ('checkbox' == $field['type']) {
                        ?>

						<div id="<?php 
                        echo $field['id'];
                        ?>
" class="tfb_lb_option themify-checkbox">
						<?php 
                        foreach ($field['options'] as $opt) {
                            ?>
							<?php 
                            $checkbox_checked = '';
                            if (isset($field['default']) && is_array($field['default'])) {
                                $checkbox_checked = in_array($opt['name'], $field['default']) ? 'checked="checked"' : '';
                            } elseif (isset($field['default'])) {
                                $checkbox_checked = checked($field['default'], $opt['name'], false);
                            }
                            ?>
							<input id="<?php 
                            echo $field['id'] . '_' . $opt['name'];
                            ?>
" name="<?php 
                            echo $field['id'];
                            ?>
[]" type="checkbox" class="tf-checkbox" value="<?php 
                            echo $opt['name'];
                            ?>
" <?php 
                            echo $checkbox_checked;
                            ?>
 /> 
							<label for="<?php 
                            echo $field['id'] . '_' . $opt['name'];
                            ?>
" class="pad-right"><?php 
                            echo $opt['value'];
                            ?>
</label>
							
							<?php 
                            if (isset($opt['help'])) {
                                ?>
							<small><?php 
                                echo $opt['help'];
                                ?>
</small>
							<?php 
                            }
                            ?>
							
							<?php 
                            if (!isset($field['new_line']) || $field['new_line'] == true) {
                                ?>
							<br />
							<?php 
                            }
                            ?>

						<?php 
                        }
                        ?>
						</div>

					<?php 
                    } elseif ('textarea' == $field['type']) {
                        ?>
					<textarea id="<?php 
                        echo $field['id'];
                        ?>
" name="<?php 
                        echo $field['id'];
                        ?>
" class="<?php 
                        echo $field['class'];
                        ?>
 tfb_lb_option" row="3" type="text" <?php 
                        echo themify_builder_get_binding_data($field);
                        ?>
></textarea>

					<?php 
                    } elseif ('select' == $field['type']) {
                        ?>
					
					<?php 
                        if (!isset($field['hide']) || $field['hide'] == false) {
                            ?>
						<select id="<?php 
                            echo $field['id'];
                            ?>
" name="<?php 
                            echo $field['id'];
                            ?>
" class="tfb_lb_option" <?php 
                            echo themify_builder_get_binding_data($field);
                            ?>
>
							<?php 
                            if (isset($field['empty'])) {
                                ?>
								<option value="<?php 
                                echo $field['empty']['val'];
                                ?>
"><?php 
                                echo $field['empty']['label'];
                                ?>
</option>
							<?php 
                            }
                            ?>
							
							<?php 
                            foreach ($field['options'] as $key => $value) {
                                $selected = isset($field['default']) && $field['default'] == $value ? ' selected="selected"' : '';
                                echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
                            }
                            ?>
						</select>
					<?php 
                        }
                        // isset hide
                        ?>
					
					<?php 
                        if (isset($field['help'])) {
                            ?>
					<br />
					<?php 
                        }
                        // isset help
                        ?>

					<?php 
                    } elseif ('selectbasic' == $field['type']) {
                        ?>
					<select id="<?php 
                        echo $field['id'];
                        ?>
" name="<?php 
                        echo $field['id'];
                        ?>
" class="tfb_lb_option" <?php 
                        echo themify_builder_get_binding_data($field);
                        ?>
>
						<?php 
                        foreach ($field['options'] as $value) {
                            $selected = isset($field['default']) && $field['default'] == $value ? ' selected="selected"' : '';
                            echo '<option value="' . $value . '" ' . $selected . '>' . $value . '</option>';
                        }
                        ?>
					</select>

					<?php 
                    } elseif ('select_menu' == $field['type']) {
                        ?>
					<select id="<?php 
                        echo $field['id'];
                        ?>
" name="<?php 
                        echo $field['id'];
                        ?>
" class="tfb_lb_option select_menu_field" <?php 
                        echo themify_builder_get_binding_data($field);
                        ?>
>
						<option value=""><?php 
                        _e('Select a Menu...', 'themify');
                        ?>
</option>
						<?php 
                        foreach ($field['options'] as $key => $value) {
                            $selected = isset($field['default']) && $field['default'] == $value ? ' selected="selected"' : '';
                            echo '<option value="' . $value->slug . '" ' . $selected . ' data-termid="' . $value->term_id . '">' . $value->name . '</option>';
                        }
                        ?>
					</select>

					<?php 
                    } elseif ('query_category' == $field['type']) {
                        ?>
					<?php 
                        $terms_tax = isset($field['options']['taxonomy']) ? $field['options']['taxonomy'] : 'category';
                        $terms_options = '';
                        $terms_by_tax = get_terms($terms_tax);
                        $terms_list = array();
                        $terms_list['0'] = array('title' => __('All Categories', 'themify'), 'slug' => '0');
                        foreach ($terms_by_tax as $term) {
                            $terms_list[$term->term_id] = array('title' => $term->name, 'slug' => $term->slug);
                        }
                        foreach ($terms_list as $term_id => $term) {
                            $term_selected = '';
                            $terms_options .= sprintf('<option value="%s" data-termid="%s" %s>%s</option>', $term['slug'], $term_id, $term_selected, $term['title']);
                        }
                        ?>
						<select id="<?php 
                        echo $field['id'] . '_dropdown';
                        ?>
" class="query_category_single" <?php 
                        echo themify_builder_get_binding_data($field);
                        ?>
>
							<option></option>
							<?php 
                        echo $terms_options;
                        ?>
						</select>
					 <?php 
                        _e('or', 'themify');
                        ?>
					<input class="small query_category_multiple" type="text" /><br /><small><?php 
                        _e('multiple category IDs (eg. 2,5,8) or slug (eg. news,blog,featured)', 'themify');
                        ?>
</small><br />
					<input type="hidden" id="<?php 
                        echo $field['id'];
                        ?>
" name="<?php 
                        echo $field['id'];
                        ?>
" value="" class="tfb_lb_option themify-option-query-cat" />

					<?php 
                        ///////////////////////////////////////////
                        // Query category single field
                        ///////////////////////////////////////////
                    } elseif ('query_category_single' == $field['type']) {
                        ?>
					<?php 
                        echo preg_replace('/>/', '><option></option>', wp_dropdown_categories(array('taxonomy' => isset($field['options']['taxonomy']) ? $field['options']['taxonomy'] : 'category', 'class' => 'tfb_lb_option', 'show_option_all' => __('All Categories', 'themify'), 'hide_empty' => 0, 'echo' => 0, 'name' => $field['id'], 'selected' => '')), 1);
                        echo '<br />';
                        ?>

					<?php 
                        ///////////////////////////////////////////
                        // Multifield
                        ///////////////////////////////////////////
                    } elseif ('multifield' == $field['type']) {
                        ?>

						<?php 
                        if (isset($field['options']['select'])) {
                            ?>
						<select id="<?php 
                            echo $field['options']['select']['id'];
                            ?>
" class="tfb_lb_option" <?php 
                            echo themify_builder_get_binding_data($field);
                            ?>
>
							<?php 
                            foreach ($field['options']['select']['options'] as $opt => $label) {
                                ?>
							<option value="<?php 
                                echo $opt;
                                ?>
"><?php 
                                echo $label;
                                ?>
</option>
							<?php 
                            }
                            ?>
						</select>
						<?php 
                        }
                        ?>
						
						<?php 
                        if (isset($field['options']['text'])) {
                            ?>
						<input id="<?php 
                            echo $field['options']['text']['id'];
                            ?>
" class="xsmall tfb_lb_option" type="text" <?php 
                            echo themify_builder_get_binding_data($field);
                            ?>
 /> 
							<?php 
                            if (isset($field['options']['text']['help'])) {
                                ?>
							<small><?php 
                                echo $field['options']['text']['help'];
                                ?>
</small>
							<?php 
                            }
                            ?>
						<?php 
                        }
                        ?>

						<?php 
                        if (isset($field['options']['colorpicker'])) {
                            ?>
						<?php 
                            $color_class = isset($field['options']['colorpicker']['class']) ? $field['options']['colorpicker']['class'] : 'xsmall';
                            ?>
							<span class="builderColorSelect"><span></span></span> 
							<input id="<?php 
                            echo $field['options']['colorpicker']['id'];
                            ?>
" class="<?php 
                            echo $color_class;
                            ?>
 tfb_lb_option builderColorSelectInput" type="text" />
						<?php 
                        }
                        ?>

						<?php 
                        ///////////////////////////////////////////
                        // Type Slider option
                        ///////////////////////////////////////////
                    } elseif ('slider' == $field['type']) {
                        ?>

						<?php 
                        foreach ($field['options'] as $fieldsec) {
                            ?>

						<?php 
                            if ($fieldsec['type'] == 'select') {
                                ?>
							<select id="<?php 
                                echo $fieldsec['id'];
                                ?>
" name="<?php 
                                echo $fieldsec['id'];
                                ?>
" class="tfb_lb_option" <?php 
                                echo themify_builder_get_binding_data($field);
                                ?>
>
								<?php 
                                if (isset($fieldsec['empty'])) {
                                    ?>
									<option value="<?php 
                                    echo $fieldsec['empty']['val'];
                                    ?>
"><?php 
                                    echo $fieldsec['empty']['label'];
                                    ?>
</option>
								<?php 
                                }
                                ?>
								
								<?php 
                                foreach ($fieldsec['options'] as $key => $value) {
                                    $selected = isset($fieldsec['default']) && $fieldsec['default'] == $value ? ' selected="selected"' : '';
                                    echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
                                }
                                ?>
							</select>

						<?php 
                            } elseif ($fieldsec['type'] == 'text') {
                                ?>
							<input id="<?php 
                                echo $fieldsec['id'];
                                ?>
" name="<?php 
                                echo $fieldsec['id'];
                                ?>
" placeholder="<?php 
                                if (isset($fieldsec['value'])) {
                                    echo $fieldsec['value'];
                                }
                                ?>
" class="<?php 
                                echo $fieldsec['class'];
                                ?>
 tfb_lb_option" type="text" />
							<?php 
                                echo isset($fieldsec['unit']) ? '<small>' . $fieldsec['unit'] . '</small>' : '';
                                ?>
						<?php 
                            }
                            ?>
						<?php 
                            echo isset($fieldsec['help']) ? $fieldsec['help'] : '';
                            ?>
<br />
						<?php 
                        }
                        ?>
					<?php 
                    }
                    ?>

					<?php 
                    // hook actions
                    do_action('themify_builder_lightbox_fields', $field, $module_name);
                    ?>
					
					<?php 
                    if (isset($field['break']) && $field['break'] == true) {
                        ?>
						<br />
					<?php 
                    }
                    ?>
					
					<?php 
                    if (isset($field['help'])) {
                        ?>
					<small><?php 
                        echo $field['help'];
                        ?>
</small>
					<?php 
                    }
                    ?>
				</div>
				<!-- /themify_builder_input -->
				<?php 
                }
            }
            ?>
			
			<?php 
            if ($field['type'] != 'builder' && (!isset($field['hide']) || $field['hide'] == false)) {
                ?>
			</div>
			<!-- /themify_builder_field -->
			<?php 
            }
            ?>
		
		<?php 
            if (isset($field['separated']) && $field['separated'] == 'bottom') {
                ?>
			<hr />
		<?php 
            }
        }
    }
Exemplo n.º 3
0
/**
 * 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;
}
Exemplo n.º 4
0
/**
 * Adds a featured image (if one exists) next to the audio player.  Also adds a section below the player to
 * display the audio file information (toggled by custom JS).
 *
 * @since  1.0.0
 * @access public
 * @param  string  $html
 * @param  array   $atts
 * @param  object  $audio
 * @param  object  $post_id
 * @return string
 */
function stargazer_audio_shortcode($html, $atts, $audio, $post_id)
{
    // Don't show in the admin.
    if (is_admin()) {
        return $html;
    }
    // If we have an actual attachment to work with, use the ID.
    if (is_object($audio)) {
        $attachment_id = $audio->ID;
    } else {
        $extensions = join('|', wp_get_audio_extensions());
        preg_match('/(src|' . $extensions . ')=[\'"](.+?)[\'"]/i', preg_replace('/(\\?_=[0-9])/i', '', $html), $matches);
        if (!empty($matches)) {
            $attachment_id = stargazer_get_attachment_id_from_url($matches[2]);
        }
    }
    // If an attachment ID was found.
    if (!empty($attachment_id)) {
        // Get the attachment's featured image.
        $image = get_the_image(array('post_id' => $attachment_id, 'image_class' => 'audio-image', 'link_to_post' => is_attachment() ? false : true, 'echo' => false));
        // If there's no attachment featured image, see if there's one for the post.
        if (empty($image) && !empty($post_id)) {
            $image = get_the_image(array('image_class' => 'audio-image', 'link_to_post' => false, 'echo' => false));
        }
        // Add a wrapper for the audio element and image.
        if (!empty($image)) {
            $image = preg_replace(array('/width=[\'"].+?[\'"]/i', '/height=[\'"].+?[\'"]/i'), '', $image);
            $html = '<div class="audio-shortcode-wrap">' . $image . $html . '</div>';
        }
        // If not viewing an attachment page, add the media info section.
        if (!is_attachment()) {
            $html .= '<div class="media-shortcode-extend">';
            $html .= '<div class="media-info audio-info">';
            $html .= '<ul class="media-meta">';
            $pre = '<li><span class="prep">%s</span>';
            $html .= hybrid_get_media_meta('length_formatted', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('Run Time', 'stargazer')), 'after' => '</li>'));
            $html .= hybrid_get_media_meta('artist', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('Artist', 'stargazer')), 'after' => '</li>'));
            $html .= hybrid_get_media_meta('album', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('Album', 'stargazer')), 'after' => '</li>'));
            $html .= hybrid_get_media_meta('track_number', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('Track', 'stargazer')), 'after' => '</li>'));
            $html .= hybrid_get_media_meta('year', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('Year', 'stargazer')), 'after' => '</li>'));
            $html .= hybrid_get_media_meta('gennre', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('Genre', 'stargazer')), 'after' => '</li>'));
            $html .= hybrid_get_media_meta('file_type', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('File Type', 'stargazer')), 'after' => '</li>'));
            $html .= hybrid_get_media_meta('file_name', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('File Name', 'stargazer')), 'after' => '</li>'));
            $html .= hybrid_get_media_meta('mime_type', array('post_id' => $attachment_id, 'before' => sprintf($pre, esc_html__('Mime Type', 'stargazer')), 'after' => '</li>'));
            $html .= '</ul></div>';
            $html .= '<button class="media-info-toggle">' . __('Audio Info', 'stargazer') . '</button>';
            $html .= '</div>';
        }
    }
    return $html;
}
Exemplo n.º 5
0
/**
 * 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' => __('&#8592; 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' => __('&#8592; 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&hellip;'), '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' => __('&#8592; 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' => __('&#8592; 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');
}
Exemplo n.º 6
0
/**
 * 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;
    }
}
Exemplo n.º 7
0
/**
 * Get first instance of audio in post
 * @since ProGo 0.6
 * @return audio SRC
 */
function pgb_get_audio()
{
    global $post, $posts;
    $first_audio = '';
    ob_start();
    ob_end_clean();
    $output = preg_match_all('/<a.+href=[\'"]([^\'"]+(' . implode('|', wp_get_audio_extensions()) . '))[\'"].*>/i', $post->post_content, $matches);
    $first_audio = isset($matches[1][0]) ? $matches[1][0] : false;
    if (!empty($first_audio)) {
        return $first_audio;
    }
    $output = preg_match_all('/\\[audio.+src=[\'"]([^\'"]+(' . implode('|', wp_get_audio_extensions()) . '))[\'"].*\\]/i', $post->post_content, $matches);
    $first_audio = isset($matches[1][0]) ? $matches[1][0] : false;
    if (!empty($first_audio)) {
        return $first_audio;
    }
    return false;
}
Exemplo n.º 8
0
/**
 * Adds a featured image (if one exists) next to the audio player.  Also adds a section below the player to 
 * display the audio file information (toggled by custom JS).
 *
 * @since  1.0.0
 * @access public
 * @param  string  $html
 * @param  array   $atts
 * @param  object  $audio
 * @param  object  $post_id
 * @return string
 */
function stargazer_audio_shortcode($html, $atts, $audio, $post_id)
{
    /* Don't show in the admin. */
    if (is_admin()) {
        return $html;
    }
    /* If we have an actual attachment to work with, use the ID. */
    if (is_object($audio)) {
        $attachment_id = $audio->ID;
    } else {
        $extensions = join('|', wp_get_audio_extensions());
        preg_match('/(src|' . $extensions . ')=[\'"](.+?)[\'"]/i', preg_replace('/(\\?_=[0-9])/i', '', $html), $matches);
        if (!empty($matches)) {
            $attachment_id = hybrid_get_attachment_id_from_url($matches[2]);
        }
    }
    /* If an attachment ID was found. */
    if (!empty($attachment_id)) {
        /* Get the attachment's featured image. */
        $image = get_the_image(array('post_id' => $attachment_id, 'image_class' => 'audio-image', 'link_to_post' => is_attachment() ? false : true, 'echo' => false));
        /* If there's no attachment featured image, see if there's one for the post. */
        if (empty($image) && !empty($post_id)) {
            $image = get_the_image(array('image_class' => 'audio-image', 'link_to_post' => false, 'echo' => false));
        }
        /* Add a wrapper for the audio element and image. */
        if (!empty($image)) {
            $image = preg_replace(array('/width=[\'"].+?[\'"]/i', '/height=[\'"].+?[\'"]/i'), '', $image);
            $html = '<div class="audio-shortcode-wrap">' . $image . $html . '</div>';
        }
        /* If not viewing an attachment page, add the media info section. */
        if (!is_attachment()) {
            $html .= '<div class="media-shortcode-extend">';
            $html .= '<div class="media-info audio-info">';
            $html .= hybrid_media_meta(array('post_id' => $attachment_id, 'echo' => false));
            $html .= '</div>';
            $html .= '<button class="media-info-toggle">' . __('Audio Info', 'stargazer') . '</button>';
            $html .= '</div>';
        }
    }
    return $html;
}
Exemplo n.º 9
0
 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');
     }
 }
 /**
  * @return string[] The extensions supported by this thumber.
  */
 protected function getThumberExtensions()
 {
     return array_merge(wp_get_audio_extensions(), wp_get_video_extensions());
 }
Exemplo n.º 11
0
 /**
  * Get the first valid audio-enclosure-url from an audio doc
  *
  * @since 0.2
  */
 public static function getPlayableUrl($audio_doc)
 {
     $guid = $audio_doc->attributes->guid;
     $enclosure = $audio_doc->links('enclosure')->first();
     if (!$enclosure) {
         pmp_debug("      ** NO ENCLOSURES for audio[{$guid}]");
         return null;
     }
     // supplementary data
     $href = $enclosure->href;
     $type = isset($enclosure->type) ? $enclosure->type : null;
     $uri_parts = parse_url($href);
     $extension = pathinfo($uri_parts['path'], PATHINFO_EXTENSION);
     if (!in_array($uri_parts['scheme'], array('http', 'https'))) {
         pmp_debug("      ** INVALID ENCLOSURE HREF ({$href}) for audio[{$guid}]");
         return null;
     }
     // dereference playlists (m3u)
     if ($type == 'audio/m3u' || $extension == 'm3u') {
         pmp_debug("      ** dereferencing playlist for audio[{$guid}]");
         $response = wp_remote_get($href);
         $lines = explode("\n", $response['body']);
         $href = $lines[0];
         $uri_parts = parse_url($href);
         $extension = pathinfo($uri_parts['path'], PATHINFO_EXTENSION);
         $type = null;
         // we don't know this anymore
     }
     // check for "known" types that start with audio/*
     if ($type && in_array($type, array_values(get_allowed_mime_types()))) {
         if (preg_match('/^audio/', $type)) {
             pmp_debug("      ** known mime type '{$type}' for audio[{$guid}]");
             return $href;
         }
     }
     if (in_array($extension, wp_get_audio_extensions())) {
         pmp_debug("      ** known extension '{$extension}' for audio[{$guid}]");
         return $href;
     }
     // not sure what this is
     pmp_debug("      ** UNABLE TO PLAY enclosure ({$href}) for audio[{$guid}]");
     return null;
 }
Exemplo n.º 12
0
/**
 * @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}&nbsp;&#x1f517;</a>";
                    } else {
                        echo $gmedia->title;
                    }
                    ?>
&nbsp;</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;
}
Exemplo n.º 13
0
    function admin_main($data)
    {
        wp_enqueue_style('thickbox');
        wp_enqueue_script('thickbox');
        wp_enqueue_media();
        wp_enqueue_script('media-upload');
        $supported_audio_extensions = implode(",", wp_get_audio_extensions());
        if (!empty($data)) {
            if (!isset($data->autoplay) or empty($data->autoplay)) {
                $data->autoplay = 'No';
            }
            if (!isset($data->loop) or empty($data->loop)) {
                $data->loop = 'No';
            }
        }
        ?>

		<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="audio_url_holder">
					<label><?php 
        echo sprintf(__('Put a URL or Browse for an audio file. Supported audio extensions ( %s )', 'cp'), $supported_audio_extensions);
        ?>
						<input class="audio_url" type="text" size="36" name="<?php 
        echo $this->name;
        ?>
_audio_url[]" value="<?php 
        echo esc_attr(isset($data->audio_url) ? $data->audio_url : '');
        ?>
"/>
						<input class="audio_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_audio_extensions);
        ?>
</div>
					</label>
				</div>

				<div class="audio_additional_controls">
					<label><?php 
        _e('Play in a loop', 'cp');
        ?>
</label>
					<?php 
        $data_loop = isset($data->loop) ? $data->loop : 'No';
        $data_autoplay = isset($data->autoplay) ? $data->autoplay : 'No';
        ?>
					<input type="radio" name="<?php 
        echo $this->name . '_loop[' . (isset($data->module_order) ? $data->module_order : 999) . ']';
        ?>
" value="Yes" <?php 
        checked($data_loop, 'Yes', true);
        ?>
/> <?php 
        _e('Yes', 'cp');
        ?>
					<br/><br/>
					<input type="radio" name="<?php 
        echo $this->name . '_loop[' . (isset($data->module_order) ? $data->module_order : 999) . ']';
        ?>
" value="No" <?php 
        checked($data_loop, 'No', true);
        ?>
/> <?php 
        _e('No', 'cp');
        ?>
					<br/><br/>

					<label><?php 
        _e('Autoplay', 'cp');
        ?>
</label>
					<input type="radio" name="<?php 
        echo $this->name . '_autoplay[' . (isset($data->module_order) ? $data->module_order : 999) . ']';
        ?>
" value="Yes" <?php 
        checked($data_autoplay, 'Yes', true);
        ?>
/> <?php 
        _e('Yes', 'cp');
        ?>
					<br/><br/>
					<input type="radio" name="<?php 
        echo $this->name . '_autoplay[' . (isset($data->module_order) ? $data->module_order : 999) . ']';
        ?>
" value="No" <?php 
        checked($data_autoplay, 'No', true);
        ?>
/> <?php 
        _e('No', 'cp');
        ?>
					<br/><br/>
				</div>

				<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>

				<?php 
        parent::get_module_delete_link();
        ?>

			</div>

		</div>

	<?php 
    }
Exemplo n.º 14
0
 /**
  * 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;
 }
/**
 * 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' => __('&#8592; 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' => __('&#8592; 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&hellip;'), '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' => __('&#8592; 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' => __('&#8592; 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');
}
function themify_builder_module_settings_field_builder($field)
{
    ?>
	<?php 
    foreach ($field['options'] as $option) {
        ?>
			<?php 
        if (isset($option['separated']) && $option['separated'] == 'top') {
            ?>
				<hr />
			<?php 
        }
        ?>
		<?php 
        if ($option['type'] == 'multi') {
            ?>
				<div class="themify_builder_field <?php 
            echo isset($option['wrap_with_class']) ? esc_attr($option['wrap_with_class']) : '';
            ?>
">

					<?php 
            if (isset($option['label']) && $option['label'] != false) {
                ?>
						<div class="themify_builder_label"><?php 
                echo esc_html($option['label']);
                ?>
</div><!-- /themify_builder_input_title -->
					<?php 
            }
            ?>

					<div class="<?php 
            echo esc_attr($option['id']) . ' tf_multi_fields tf_fields_count_' . esc_attr(count($option['options']));
            ?>
">
						<?php 
            themify_builder_module_settings_field_builder($option);
            ?>
					</div>
				</div>
				<?php 
            continue;
        }
        ?>
		<div class="themify_builder_field <?php 
        echo isset($option['wrap_with_class']) ? esc_attr($option['wrap_with_class']) : '';
        ?>
">

			<?php 
        if (isset($option['label']) && $option['label'] != false) {
            ?>
				<div class="themify_builder_label"><?php 
            echo esc_html($option['label']);
            ?>
</div><!-- /themify_builder_input_title -->
			<?php 
        }
        ?>

			<div class="themify_builder_input"<?php 
        echo 'wp_editor' == $option['type'] ? ' style="width:100%;"' : '';
        ?>
>
				<?php 
        if ($option['type'] == 'text') {
            ?>

					<?php 
            if (isset($option['colorpicker']) && $option['colorpicker'] == true) {
                ?>
						<span class="builderColorSelect"><span></span></span> 
						<input type="text" class="<?php 
                echo esc_attr($option['class']);
                ?>
 colordisplay" <?php 
                echo themify_builder_get_binding_data($option);
                ?>
 />
						<input id="<?php 
                echo esc_attr($option['id']);
                ?>
" name="<?php 
                echo esc_attr($option['id']);
                ?>
" value="<?php 
                if (isset($option['value'])) {
                    echo esc_attr($option['value']);
                }
                ?>
" class="builderColorSelectInput tfb_lb_option_child" type="hidden"  data-input-id="<?php 
                echo esc_attr($option['id']);
                ?>
" />
					<?php 
            } else {
                ?>
						<input name="<?php 
                echo esc_attr($option['id']);
                ?>
" class="<?php 
                echo isset($option['class']) ? esc_attr($option['class']) : '';
                ?>
 tfb_lb_option_child <?php 
                echo isset($add_class) ? esc_attr($add_class) : '';
                ?>
" type="text" data-input-id="<?php 
                echo esc_attr($option['id']);
                ?>
" />
						<?php 
                if (isset($option['iconpicker']) && $option['iconpicker'] == true) {
                    ?>
							<a class="button button-secondary hide-if-no-js themify_fa_toggle" href="#"><?php 
                    _e('Insert Icon', 'themify');
                    ?>
</a>
						<?php 
                }
                ?>
						<?php 
                if (isset($option['after'])) {
                    echo wp_kses_post($option['after']);
                }
                ?>
					<?php 
            }
            ?>

				<?php 
        } elseif ('image' == $option['type']) {
            ?>
					<input data-input-id="<?php 
            echo esc_attr($option['id']);
            ?>
" name="<?php 
            echo esc_attr($option['id']);
            ?>
" placeholder="<?php 
            if (isset($option['value'])) {
                echo esc_attr($option['value']);
            }
            ?>
" class="<?php 
            echo esc_attr($option['class']);
            ?>
 themify-builder-uploader-input tfb_lb_option_child" 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($option['id']);
                ?>
themify-builder-plupload-upload-ui">
								<input id="<?php 
                echo esc_attr($option['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($option['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 
        } elseif ('audio' == $option['type']) {
            ?>
					<input data-input-id="<?php 
            echo esc_attr($option['id']);
            ?>
" name="<?php 
            echo esc_attr($option['id']);
            ?>
" placeholder="<?php 
            if (isset($option['value'])) {
                echo esc_attr($option['value']);
            }
            ?>
" class="<?php 
            echo esc_attr($option['class']);
            ?>
 themify-builder-uploader-input tfb_lb_option_child" 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($option['id']);
                ?>
themify-builder-plupload-upload-ui" data-extensions="<?php 
                echo esc_attr(implode(',', wp_get_audio_extensions()));
                ?>
">
								<input id="<?php 
                echo esc_attr($option['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($option['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');
                ?>
" data-library-type="audio"><?php 
                _e('Browse Library', 'themify');
                ?>
</a>

						<?php 
            }
            ?>

					</div>

				<?php 
        } elseif ($option['type'] == 'textarea') {
            ?>
					<textarea name="<?php 
            echo esc_attr($option['id']);
            ?>
" class="<?php 
            echo esc_attr($option['class']);
            ?>
 tfb_lb_option_child" <?php 
            echo isset($option['rows']) ? 'rows="' . esc_attr($option['rows']) . '"' : '';
            ?>
 data-input-id="<?php 
            echo esc_attr($option['id']);
            ?>
"></textarea><br />

					<?php 
            if (isset($option['radio'])) {
                ?>
						<div data-input-id="<?php 
                echo esc_attr($option['radio']['id']);
                ?>
" class="tfb_lb_option_child tf-radio-choice">
							<?php 
                echo esc_html($option['radio']['label']);
                ?>
							<?php 
                foreach ($option['radio']['options'] as $k => $v) {
                    ?>
								<input id="<?php 
                    echo esc_attr($option['radio']['id'] . '_' . $k);
                    ?>
" type="radio" name="<?php 
                    echo esc_attr($option['radio']['id']);
                    ?>
" class="themify-builder-radio-dnd" value="<?php 
                    echo esc_attr($k);
                    ?>
" />
								<label for="<?php 
                    echo esc_attr($option['radio']['id'] . '_' . $k);
                    ?>
" class="pad-right themify-builder-radio-dnd-label"><?php 
                    echo wp_kses_post($k);
                    ?>
</label>
							<?php 
                }
                ?>
						</div>
					<?php 
            }
            // endif radio input
            ?>

			<?php 
        } elseif ($option['type'] == 'select') {
            ?>
				<select data-input-id="<?php 
            echo esc_attr($option['id']);
            ?>
" name="<?php 
            echo esc_attr($option['id']);
            ?>
" class="tfb_lb_option_child">
					<?php 
            if (isset($option['empty'])) {
                ?>
						<option value="<?php 
                echo esc_attr($option['empty']['val']);
                ?>
"><?php 
                echo esc_html($option['empty']['label']);
                ?>
</option>
					<?php 
            }
            ?>
					
					<?php 
            foreach ($option['options'] as $key => $value) {
                $selected = isset($option['default']) && $option['default'] == $value ? ' selected="selected"' : '';
                echo '<option value="' . esc_attr($key) . '" ' . $selected . '>' . esc_html($value) . '</option>';
            }
            ?>
				</select>

				<?php 
        } elseif ('layout' == $option['type']) {
            ?>
				<p id="<?php 
            echo esc_attr($option['id']);
            ?>
" class="layout_icon tfb_lb_option_child themify-layout-icon">
					<?php 
            foreach ($option['options'] as $option) {
                ?>
					<a href="#" id="<?php 
                echo esc_attr($option['value']);
                ?>
" title="<?php 
                echo esc_attr($option['label']);
                ?>
" class="tfl-icon">
						<?php 
                $image_url = filter_var($option['img'], FILTER_VALIDATE_URL) ? $option['img'] : THEMIFY_BUILDER_URI . '/img/builder/' . $option['img'];
                ?>
						<img src="<?php 
                echo esc_url($image_url);
                ?>
" alt="<?php 
                echo esc_attr($option['label']);
                ?>
" />
					</a>
					<?php 
            }
            ?>
				</p>

				<?php 
        } elseif ('wp_editor' == $option['type']) {
            wp_editor('', $option['id'], array('editor_class' => $option['class'] . ' tfb_lb_wp_editor tfb_lb_option_child', 'textarea_rows' => 20));
            ?>

				<?php 
        } elseif ('checkbox' == $option['type']) {
            ?>
					<?php 
            if (isset($option['before'])) {
                echo wp_kses_post($option['before']);
            }
            ?>

					<div id="<?php 
            echo esc_attr($option['id']);
            ?>
" class="tfb_lb_option themify-checkbox">
					<?php 
            foreach ($option['options'] as $opt) {
                ?>
						<?php 
                $checkbox_checked = '';
                if (isset($option['default']) && is_array($option['default'])) {
                    if (in_array($opt['name'], $option['default'])) {
                        $checkbox_checked = 'checked="checked"';
                    }
                } elseif (isset($option['default'])) {
                    $checkbox_checked = checked($option['default'], $opt['name'], false);
                }
                ?>
						<input id="<?php 
                echo esc_attr($option['id'] . '_' . $opt['name']);
                ?>
" name="<?php 
                echo esc_attr($option['id']);
                ?>
[]" type="checkbox" class="tf-checkbox" value="<?php 
                echo esc_attr($opt['name']);
                ?>
" <?php 
                echo $checkbox_checked;
                ?>
 />
						<label for="<?php 
                echo esc_attr($option['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($option['new_line']) || $option['new_line'] == true) {
                    ?>
						<br />
						<?php 
                }
                ?>

					<?php 
            }
            ?>
					</div>
					<?php 
            if (isset($field['after'])) {
                echo wp_kses_post($field['after']);
            }
            ?>

				<?php 
        } elseif ('radio' == $option['type']) {
            ?>
					<div data-input-id="<?php 
            echo esc_attr($option['id']);
            ?>
" class="tfb_lb_option_child tf-radio-choice">
						<?php 
            foreach ($option['options'] as $k => $v) {
                ?>
							<input id="<?php 
                echo esc_attr($option['id'] . '_' . $k);
                ?>
" type="radio" name="<?php 
                echo esc_attr($option['id']);
                ?>
" class="themify-builder-radio-dnd" value="<?php 
                echo esc_attr($k);
                ?>
" />
							<label for="<?php 
                echo esc_attr($option['id'] . '_' . $k);
                ?>
" class="pad-right themify-builder-radio-dnd-label"><?php 
                echo wp_kses_post($k);
                ?>
</label>
						<?php 
            }
            ?>
					</div>
				<?php 
        }
        // endif radio input
        ?>

				<?php 
        if (isset($option['help'])) {
            ?>
					<?php 
            if (isset($option['help']['new_line'])) {
                ?>
						<br />
					<?php 
            }
            ?>
					<small><?php 
            echo wp_kses_post($option['help']['text']);
            ?>
</small>
				<?php 
        }
        ?>

			</div><!-- /themify_builder_input -->

		</div>
		<!-- /themify_builder_field -->

	<?php 
    }
}
Exemplo n.º 17
0
 /**
  * @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());
 }
Exemplo n.º 18
0
/**
 * 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' => __('&#8592; 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' => __('&#8592; 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');
}
Exemplo n.º 19
0
/**
 * Adds a featured image (if one exists) next to the audio player.  Also adds a section below the player to
 * display the audio file information (toggled by custom JS).
 *
 * @since  1.0.0
 * @access public
 * @param  string  $html
 * @param  array   $atts
 * @param  object  $audio
 * @param  object  $post_id
 * @return string
 */
function stargazer_audio_shortcode($html, $atts, $audio, $post_id)
{
    // Don't show in the admin.
    if (is_admin()) {
        return $html;
    }
    // If we have an actual attachment to work with, use the ID.
    if (is_object($audio)) {
        $attachment_id = $audio->ID;
    } else {
        if ($post_id && hybrid_attachment_is_audio($post_id)) {
            $attachment_id = $post_id;
        } else {
            $extensions = join('|', wp_get_audio_extensions());
            preg_match('/(src|' . $extensions . ')=[\'"](.+?)[\'"]/i', preg_replace('/(\\?_=[0-9])/i', '', $html), $matches);
            if (!empty($matches)) {
                $dir = wp_upload_dir();
                $file = parse_url($matches[2]);
                if (isset($dir['baseurl']) && isset($file['path'])) {
                    $attachment_id = attachment_url_to_postid(trim(str_replace($dir['baseurl'], '', $file['path']), '/'));
                }
            }
        }
    }
    // If an attachment ID was found.
    if (!empty($attachment_id)) {
        // Get the attachment's featured image.
        $image = get_the_image(array('post_id' => $attachment_id, 'image_class' => 'audio-image', 'link_to_post' => is_attachment() ? false : true, 'echo' => false));
        // If there's no attachment featured image, see if there's one for the post.
        if (empty($image) && !empty($post_id)) {
            $image = get_the_image(array('image_class' => 'audio-image', 'link_to_post' => false, 'echo' => false));
        }
        // Add a wrapper for the audio element and image.
        if (!empty($image)) {
            $image = preg_replace(array('/width=[\'"].+?[\'"]/i', '/height=[\'"].+?[\'"]/i'), '', $image);
            $html = '<div class="audio-shortcode-wrap">' . $image . $html . '</div>';
        }
    }
    return $html;
}
Exemplo n.º 20
0
/**
 * 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}} &times; {{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">&ndash;</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 }} &times; {{ 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&hellip;'); ?>" {{ 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&hellip;'); ?>"
					<# } else if ( 'audio' === data.type ) { #>
						placeholder="<?php esc_attr_e('Describe this audio file&hellip;'); ?>"
					<# } else { #>
						placeholder="<?php esc_attr_e('Describe this media file&hellip;'); ?>"
					<# } #> {{ 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 }} &times; {{ data.height }}</div>
					<# } #>

					<# if ( data.can.save && data.sizes ) { #>
						<a class="edit-attachment" href="{{ data.editLink }}&amp;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 ); ?> &ndash; {{ size.width }} &times; {{ 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 ); ?> &ndash; {{ size.width }} &times; {{ 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">&times;</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' );
}
Exemplo n.º 21
0
/**
 * 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}} &times; {{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">&ndash;</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&hellip;');
    ?>
" {{ 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&hellip;');
    ?>
"
					<# } else if ( 'audio' === data.type ) { #>
						placeholder="<?php 
    esc_attr_e('Describe this audio file&hellip;');
    ?>
"
					<# } else { #>
						placeholder="<?php 
    esc_attr_e('Describe this media file&hellip;');
    ?>
"
					<# } #> {{ 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 }} &times; {{ data.height }}</div>
					<# } #>

					<# if ( data.can.save ) { #>
						<a class="edit-attachment" href="{{ data.editLink }}&amp;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);
        ?>
 &ndash; {{ size.width }} &times; {{ 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);
        ?>
 &ndash; {{ size.width }} &times; {{ 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">&times;</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');
}
 /**
  * Extract [audio] shortcodes and `<a href="*.mp3">` tags, from text.
  *
  * @since 2.3.0
  *
  * @see wp_get_audio_extensions() for supported audio 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 $audio
  *     }
  *     @type array $audio Extracted audio. {
  *         Array of extracted media.
  *
  *         @type string $original The entire shortcode.
  *         @type string $source   Media source. Either "html" or "shortcodes".
  *         @type string $url      Link to audio.
  *     }
  * }
  */
 protected function extract_audio($richtext, $plaintext, $extra_args = array())
 {
     $data = array('has' => array('audio' => 0), 'audio' => array());
     $audios = $this->extract_shortcodes($richtext, $plaintext, $extra_args);
     $links = $this->extract_links($richtext, $plaintext, $extra_args);
     $audio_types = wp_get_audio_extensions();
     // [audio]
     $audios = wp_list_filter($audios['shortcodes'], array('type' => 'audio'));
     foreach ($audios as $audio) {
         // Media URL can appear as the first parameter inside the shortcode brackets.
         if (isset($audio['attributes']['src'])) {
             $src_param = 'src';
         } elseif (isset($audio['attributes'][0])) {
             $src_param = 0;
         } else {
             continue;
         }
         $path = untrailingslashit(parse_url($audio['attributes'][$src_param], PHP_URL_PATH));
         foreach ($audio_types as $extension) {
             $extension = '.' . $extension;
             // Check this URL's file extension matches that of an accepted audio format.
             if (!$path || substr($path, -4) !== $extension) {
                 continue;
             }
             $data['audio'][] = array('original' => '[audio src="' . esc_url_raw($audio['attributes'][$src_param]) . '"]', 'source' => 'shortcodes', 'url' => esc_url_raw($audio['attributes'][$src_param]));
         }
     }
     // <a href="*.mp3"> tags
     foreach ($audio_types as $extension) {
         $extension = '.' . $extension;
         foreach ($links['links'] as $link) {
             $path = untrailingslashit(parse_url($link['url'], PHP_URL_PATH));
             // Check this URL's file extension matches that of an accepted audio format.
             if (!$path || substr($path, -4) !== $extension) {
                 continue;
             }
             $data['audio'][] = array('original' => '[audio src="' . esc_url_raw($link['url']) . '"]', 'source' => 'html', 'url' => esc_url_raw($link['url']));
         }
     }
     $data['has']['audio'] = count($data['audio']);
     /**
      * Filters audio extracted from text.
      *
      * @since 2.3.0
      *
      * @param array  $data       Extracted audio. See {@link BP_Media_Extractor::extract_audio()} 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_audio', $data, $richtext, $plaintext, $extra_args);
 }
Exemplo n.º 23
0
 function usp_audio_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);
     $audio_extensions = wp_get_audio_extensions();
     $audio_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'], $audio_extensions)) {
                     if (!empty($fileId)) {
                         if (isset($matches[1]) && $matches[1] == $fileId) {
                             if (!empty($v)) {
                                 $audio_urls[] = $v;
                                 $i++;
                             }
                         }
                     } else {
                         $audio_urls[] = $v;
                         $i++;
                     }
                 }
             }
         }
         if ($i === intval($number)) {
             break;
         }
     }
     return $audio_urls;
 }
Exemplo n.º 24
0
/**
 * 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 Audio shortcode output.
  *
  * This implements the functionality of the Audio Shortcode for displaying
  * WordPress mp3s in a post.
  *
  * @param array  $attr {
  *     Attributes of the audio shortcode.
  *
  *     @type string $src      URL to the source of the audio file. Default empty.
  *     @type string $loop     The 'loop' attribute for the `<audio>` element. Default empty.
  *     @type string $autoplay The 'autoplay' attribute for the `<audio>` element. Default empty.
  *     @type string $preload  The 'preload' attribute for the `<audio>` element. Default empty.
  *     @type string $class    The 'class' attribute for the `<audio>` element. Default 'simple-fb-audio-shortcode'.
  *     @type string $style    The 'style' attribute for the `<audio>` element. Default 'width: 100%'.
  * }
  * @param string $content Shortcode content.
  * @return string|void HTML content to display audio.
  */
 function audio($attr, $content = '')
 {
     $post_id = get_post() ? get_the_ID() : 0;
     /**
      * Filter the default audio shortcode output.
      *
      * If the filtered output isn't empty, it will be used instead of generating the default audio template.
      *
      * @since 3.6.0
      *
      * @param string $html     Empty variable to be replaced with shortcode markup.
      * @param array  $attr     Attributes of the shortcode. @see wp_audio_shortcode()
      * @param string $content  Shortcode content.
      */
     $override = apply_filters('simple_fb_audio_shortcode_override', '', $attr, $content);
     if ('' !== $override) {
         return $override;
     }
     $audio = null;
     $default_types = wp_get_audio_extensions();
     $defaults_atts = array('src' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'none');
     foreach ($default_types as $type) {
         $defaults_atts[$type] = '';
     }
     $atts = shortcode_atts($defaults_atts, $attr, 'audio');
     $primary = false;
     if (!empty($atts['src'])) {
         $type = wp_check_filetype($atts['src'], wp_get_mime_types());
         if (!in_array(strtolower($type['ext']), $default_types)) {
             return sprintf('<a class="simple-fb-embedded-audio" 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) {
         $audios = get_attached_media('audio', $post_id);
         if (empty($audios)) {
             return;
         }
         $audio = reset($audios);
         $atts['src'] = wp_get_attachment_url($audio->ID);
         if (empty($atts['src'])) {
             return;
         }
         array_unshift($default_types, 'src');
     }
     /**
      * Filter the class attribute for the audio shortcode output container.
      *
      * @since 3.6.0
      *
      * @param string $class CSS class or list of space-separated classes.
      */
     $html_atts = array('class' => apply_filters('simple_fb_audio_shortcode_class', 'simple-fb-audio-shortcode'), 'id' => sprintf('audio-%d', $post_id), 'loop' => wp_validate_boolean($atts['loop']), 'autoplay' => wp_validate_boolean($atts['autoplay']), 'preload' => $atts['preload'], 'style' => 'width: 100%; visibility: hidden;');
     // These ones should just be omitted altogether if they are blank
     foreach (array('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('<audio %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];
             }
             $type = wp_check_filetype($atts[$fallback], wp_get_mime_types());
             $url = add_query_arg('_', $atts[$fallback]);
             $html .= sprintf($source, $type['type'], esc_url($url));
         }
     }
     $html .= '</audio>';
     /**
      * Filter the audio shortcode output.
      *
      * @since 3.6.0
      *
      * @param string $html    Audio shortcode HTML output.
      * @param array  $atts    Array of audio shortcode attributes.
      * @param string $audio   Audio file.
      * @param int    $post_id Post ID.
      */
     return apply_filters('simple_fb_audio_shortcode', $html, $atts, $audio, $post_id);
 }