What type of template are WP media-modal’s templates?

Here’s an interesting part from http://underscorejs.org/#template If ERB-style delimiters aren’t your cup of tea, you can change Underscore’s template settings to use different symbols to set off interpolated code. Define an interpolate regex to match expressions that should be interpolated verbatim, an escape regex to match expressions that should be inserted after being HTML-escaped, and … Read more

How do I add the data-toggle=”modal” data-target=”#myModal” attribures to a WP Nav bar?

PHP way: Add the following to your functions.php file. Filter nav_menu_link_attributes: add_filter( ‘nav_menu_link_attributes’, ‘my_menu_atts’, 10, 3 ); function my_menu_atts( $atts, $item, $args ) { // Provide the id of the targeted menu item $menu_target = 123; // inspect $item if ($item->ID == $menu_target) { // original post used a comma after ‘modal’ but this caused … Read more

Hook for image edit popup

The answer is there is no damn hook for the edit button. It’s just a bunch of JS contained within wp-includes/js/tinymce/plugins/wpeditimage/plugin.js. I’ve included the barebones of what you need below. Key points: a. Clicking an element with a data-wp-imgselect attribute will open the image edit dialogue. You need to change that to something else if … Read more

Add control in image detail panel

You can use this code function your_slug_edit_media_custom_checkbox( $form_fields, $post ) { $form_fields[‘custom_field’] = array( ‘label’ => ‘Custom Field’, ‘input’ => ‘text’, ‘value’ => get_post_meta( $post->ID, ‘_custom_field’, true ) ); return $form_fields; } function your_slug_save_media_custom_field( $post, $attachment ) { update_post_meta( $post[‘ID’], ‘_custom_field’, $attachment[‘custom_field’] ); return $post; } add_filter( ‘attachment_fields_to_edit’, ‘edit_media_custom_checkbox’, 11, 2 ); add_filter( ‘attachment_fields_to_save’, ‘save_media_custom_checkbox’, … Read more

Refresh wp.media after ajax call

So, I followed your links and this is working for me. This test works the same for my upload callbacks so hopefully it works for you. In the iframe function myTab_save_frame() { global $redir_tab; $redir_tab = ‘mytab’; media_upload_header(); ?> <button>Test Trigger</button> <script> var switchAndReload = function() { // get wp outside iframe var wp = … Read more

Using Underscore Templates in WordPress

Your plugin index file: add_action( ‘print_media_templates’, ‘wpse8170_admin_footer’ ); function wpse8170_admin_footer() { require ‘templates.php’; } Your templates.php: <script id=”tmpl-mytemplate” type=”text/html”> <h1>Hello {{data.name}}!</h1> </script> Your media js file: wp.media.view.MyView = wp.media.View.extend({ template: wp.media.template(‘mytemplate’), render: function() { this.$el.html(this.template({name: ‘world’})); } });

Disable media library tab for non admins in uploader screen

This function will not show media library tab in upload screen function remove_medialibrary_tab($strings) { if ( !current_user_can( ‘administrator’ ) ) { unset($strings[“mediaLibraryTitle”]); return $strings; } else { return $strings; } } add_filter(‘media_view_strings’,’remove_medialibrary_tab’); I found out that switching to media library tab actually call this ajax action query-attachments. So i added another callback function to this … Read more

Is it possible to trigger some JavaScript when Media Popup is opened?

You can use several event handlers. frame.on(‘open’,function() { // Do something }); frame.on(‘close’,function() { // Do something }); frame.on(‘select’,function() { // Do something }); Where frame is a reference to wp.media() frame = wp.media(); frame.on(‘select’,function() { // Do something }); Full example Script en-queued with jQuery and media editor as dependencies. function media_script_enqueue() { wp_enqueue_script( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)