Downloadable Documents

No need to insert the download into the post as @kaiser says, you can automate: $download = get_children( ‘post_type=attachment&post_mime_type=application/pdf&post_parent=”.$post->ID ); if ($download) { foreach ( $download as $attachment_id => $attachment ) { echo “<a href=”‘.wp_get_attachment_url($attachment_id).'” target=”_blank” class=”download”>Download PDF</a>’; } }

Show Post ID in “Find Posts or Pages” box in Media Library?

You cannot do that with pure PHP. The table is created in wp-admin/includes/ajax-actions.php::wp_ajax_find_posts(), and there is no filter. But look at the radio buttons: name=”found_post_id” value=”‘ . esc_attr($post->ID) You can print a script on the action admin_footer-upload.php that extracts the post ID from the values and adds a new column to the table. Here is … Read more

Change URLs for static content

This answer has solved the problem. You need to add this to your functions.php file. /** * Custom media upload URL * @link https://wordpress.stackexchange.com/questions/77960/wordpress-3-5-setting-custom-full-url-path-to-files-in-the-media-library */ add_filter( ‘pre_option_upload_url_path’, ‘upload_url’ ); function upload_url() { return ‘http://static.yourdomain.com/wp-content/uploads’; } There’s no need to add the original snippet to wp-config.php.

Add metabox with media uploader in a custom post type [duplicate]

I am working on something similar. This is for a podcast upload meta-box. Returns the url to the file. Here is what I have so far: //Add Metabox add_action(‘add_meta_boxes’, ‘add_upload_file_metaboxes’); function add_upload_file_metaboxes() { add_meta_box(‘swp_file_upload’, ‘File Upload’, ‘swp_file_upload’, ‘podcasts’, ‘normal’, ‘default’); } function swp_file_upload() { global $post; // Noncename needed to verify where the data originated … Read more

Append button to WordPress Image Details modal

Here’s an alternative technique to manipulating the template. I adapted the solution below from this post. In the approach below, the print_media_templates hook, which is triggered at the bottom of wp-includes/media-template.php, is used to output some JavaScript that removes the default image details underscores template (<script type=”text/html” id=”tmpl-image-details”>) and replaces it with a duplicated version … Read more

Download external images if post is publish

Scheduled posts don’t trigger publish_post, only updating the post itself will do that. Add an action for future_to_publish, see the reference on post status transitions. I don’t believe that you’ll have access to the user-object in that case, so you might want to refactor that. Alternatively, just get the images when the user saves the … Read more

Add new “Insert Into Post” button with another function

There’s a get_image_send_to_editor() function in wp-admin/includes/media.php that runs this: apply_filters( ‘image_send_to_editor’, $html, $id, $caption, $title, $align, $url, $size, $alt );. Try hooking that filter. Edit: Help with the filter call… Your call to hook the callback would look like this: add_filter(‘image_send_to_editor’, array(&$MyClassReference, ‘filter_iste’), 10, 8); The 10 is the priority, you might need to adjust … Read more

Add file name column to media library

Here you go, this code not only lists all filenames in Library but also allows you to sort them by name: // Add the column function filename_column( $cols ) { $cols[“filename”] = “Filename”; return $cols; } // Display filenames function filename_value( $column_name, $id ) { $meta = wp_get_attachment_metadata( $id ); echo substr( strrchr( $meta[‘file’], “https://wordpress.stackexchange.com/” … Read more

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