Tag Info

New answers tagged

0

something like this : https://codex.wordpress.org/Function_Reference/add_role then if ( current_user_can('new_role') && !current_user_can('upload_files') ) add_action('admin_init', 'allow_new_role_uploads'); function allow_new_role_uploads() { $new_role = get_role('new_role'); $new_role->add_cap('upload_files'); }


0

In the wp-config.php file (wordpress's root folder) you have to enable the debug. You have to set wp_debug to true. Change define('WP_DEBUG', false); to define('WP_DEBUG', true); Save the file and refresh the browser (I suggest you to use ctrl+f5). You'll see all the errors.


0

This likely isn't exactly an issue caused by WordPress, but due to server configurations and/or settings. 500 errors are pretty generic and can have a variety of origins, so it is hard to give the one directive that will solve it. By the way, the returning of JSON and HTML seems to be common when this happens, not sure where and it gets mixed up, might be ...


2

For the media library you can use the pre_get_posts hook targeting upload.php by means of $pagenow, a global variable, or even better, because globals are the devils child, by means of get_current_screen(). I'm assuming you want to target the media modal tab too - because targeting only one, but not the other, doesn't make much sense after all -, you can do ...


1

Here's a shorter way to do it (PHP 5.4+): add_filter( 'media_send_to_editor', function( $html, $send_id, $attachment ) { $class = wp_check_filetype( $attachment['url'] )['ext']; return str_ireplace( '<a href', sprintf( '<a class="%s" href',$class ? $class : 'unknown' ), $html ); }, 10, 3 ); where we get the attachment's info from the third input ...


2

So thanks to @amritanshu and @wycks github's code, here is the solution for those in need to add a class with the media type to the attachment url before it gets inserted in the editor : if ( ! function_exists( 'epc_add_class_pdf' ) ) : function epc_add_class_pdf( $html, $id ) { $attachment = get_post( $id ); $mime_type = ...


1

This is not the answer but just the hint. media_send_to_editor should be the hook that should help you. Not sure how but came across this while searching for my problem I would have commented but still 4 points short, so unable to comment All the best


0

For compressing the uploaded image I wrote a simple code snippet that immediately overwrites a newly uploaded file with an image whose quality can be specified: function wt_handle_upload_callback( $data ) { $image_quality = 30; // Change this according to your needs $file_path = $data['file']; $image = false; switch ( $data['type'] ) { ...


1

You can try adding the input file field once and using then using jQuery to add more fields when clicking add more. Here are the steps Register your setting using register_setting function Create Menu using add_menu_page. This also requires a calback function Add the thickbox and media-upload script using wp_enqueue_script and wp_enqueue_style Use the ...


3

One way to do it (which is probably evil) is to select the control by adding a block of javascript using the tr field of $form_fields: function set_image_data( $form_fields, $post ) { $form_fields['text_color'] = array( 'label' => 'Text Color', 'input' => 'text', 'value' => get_post_meta( $post->ID, '_text_color', ...


1

I can only take a guess at this. Is the image you want to change a background image (using CSS)? - if you goto the page, use your web inspector tool. You should then be able to see where image url is coming from.



Top 50 recent answers are included