Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter cyrille

    (@cyrille)

    SOLVED
    Finally, the plugin creation is the better way to maintain the update WP

    So, I write thaht and seems work fine

    <?php
    /**
    * Plugin Name: Custom mime types
    * Plugin URI: https://crust.ovh
    * Description: Block upload Mime Types
    * Version: 1.0
    * Author: crust
    * Author URI: http://crust.ovh
    **/
    function custom_mime_types( $mimes ){
      // Forbiden ALL
         unset( $mimes );
      // OK 4 gif, png, jpg and mp3 only
         $mimes['jpg|jpeg|jpe'] = 'image/jpeg';
         $mimes['gif' ] = 'image/gif';
         $mimes['png'] = 'image/png'; 
         $mimes['mp3|m4a|m4b'] = 'audio/mpeg';
    // List mime types available here
    // https://codex.wordpress.org/Function_Reference/get_allowed_mime_types
     return $mimes;
    }
    add_filter('upload_mimes', 'custom_mime_types', 1, 1);
    ?>
    • This reply was modified 6 years, 11 months ago by cyrille.
    • This reply was modified 6 years, 11 months ago by cyrille.
    • This reply was modified 6 years, 11 months ago by cyrille.
    Thread Starter cyrille

    (@cyrille)

    OK thx for your answer
    I’ll patch the function.php file so.

    In order to automatized the update, I’ll write a diff script to update this file when an WP update appears

    A diff based on would works fine

    cat version.php | grep 'wp_version ='
    $wp_version = '5.2.2';

    For the function to add, I found that on the web

    function custom_mime_types( $mimes ){
            // Authorzied SVG
            $mimes['svg'] = 'image/svg+xml'; 
    
            // Forbid PDF
            unset( $mimes['pdf'] );
            return $mimes;
    }
    add_filter('upload_mimes', 'custom_mime_types', 1, 1);

    Is not better to forbiden all mimes types before and only authorized after
    Do you think, It’s good ?

    function custom_mime_types( $mimes ){
          
      // Forbiden ALL
      unset( $mimes );
           
    
      // OK 4 svg, jpg and mp3 only
            $mimes['svg'] =   'image/svg+xml'; 
            $mimes['jpg'] =  'image/jpeg, image/pjpeg
            $mimes['jpeg'] = 'image/jpeg, image/pjpeg
            $mimes['png'] =  'image/png
            $mimes['mp3] =  'audio/mpeg3, audio/x-mpeg-3, video/mpeg, video/x-mpeg ';
     return $mimes;
    }
    add_filter('upload_mimes', 'custom_mime_types', 1, 1);

    Do you think is correct ?

    • This reply was modified 6 years, 11 months ago by cyrille.
    • This reply was modified 6 years, 11 months ago by cyrille.
    Thread Starter cyrille

    (@cyrille)

    OK this works well:

    <?php $args = array('name'=>'top_sidebar',
            	'before_widget' => '<li style="list-style-type: none; list-style-image: none>"',
            	'after_widget' => '</li>',
    		'before_title' => '<span><strong>',
    		 'after_title' => '</strong></span><br />'
    		 );
    		?>
    
    		<table class="optiontable" width="80%">
    		<tr class="alternate">
    			<th>Categories widget</th>
    			<th>Pages widget</th>
    		</tr>
    		<tr>
    			<td style="vertical-align:top;margin-top:0;" width="25%"><?php widget_wp_dtree_get_categories($args);?></td>
    			<td style="vertical-align:top;margin-top:0;" width="25%"><?php widget_wp_dtree_get_pages($args);?></td>
    		</tr>	
    
    		<tr class="alternate">
    			<th>Links widget</th>
    			<th>Archive widget</th>
    		</tr>
    		<tr>
    			<td style="vertical-align:top;margin-top:0;" width="25%"><?php widget_wp_dtree_get_links($args);?></td>
    			<td style="vertical-align:top;margin-top:0;" width="25%"><?php widget_wp_dtree_get_archives($args);?></td>
       	</tr>
    		</table>

    RESOLVED

Viewing 3 replies - 1 through 3 (of 3 total)