WordPress.org

Forums

MimeTypes Link Icons
[resolved] Bug+fix] some undefined variable errors and more (7 posts)

  1. jrf
    Member
    Plugin Contributor

    Posted 2 years ago #

    Hiya,

    Love the plugin!

    I was getting some undefined variable notices as I run WP in debug in the test environment. Thought I'd help you by solving them and while I was at it, noticed some code which could do with a little efficiency cleaning.

    Please find the below fixes as a compliment to your plugin.

    File: mime_type_link_images.php

    Line 32:

    $mtli_available_mime_types = array('ai','asf','bib','csv','deb','doc','docx','djvu','dmg','dwg','dwf','flac','gif','gz','indd','iso','jpg','log','m4v','midi','mkv','mov','mp3','mp4','mpeg','mpg','odp','ods','odt','oga','ogg','ogv','pdf','png','ppt','pptx','psd','ra','ram','rm','rpm','rv','skp','spx','tar','tex','tgz','txt','vob','wmv','xls','xlsx','xml','xpi','zip');

    Replace with:

    $mtli_available_mime_types = array('ai','asf','bib','csv','deb','doc','docx','djvu','dmg','dwg','dwf','flac','gif','gz','indd','iso','jpg','log','m4v','midi','mkv','mov','mp3','mp4','mpeg','mpg','odp','ods','odt','oga','ogg','ogv','pdf','png','ppt','pptx','psd','ra','ram','rm','rpm','rv','skp','spx','tar','tex','tgz','txt','vob','wmv','xls','xlsx','xml','xpi','zip');
    $mtli_default_true = array('pdf');

    Line 66 - 120:

    $mtli_default_options['enable_ai']     	    = false;
        $mtli_default_options['enable_asf']     	    = false;
        $mtli_default_options['enable_bib']     	    = false;
    <..snip..>
        $mtli_default_options['enable_xml']     	    = false;
        $mtli_default_options['enable_xpi']     	    = false;
        $mtli_default_options['enable_zip']     	    = false;

    Replace with:

    global $mtli_available_mime_types, $mtli_default_true;
        foreach( $mtli_available_mime_types as $type ) {
    		$mtli_default_options['enable_' . $type]	= ( in_array( $type, $mtli_default_true ) === false ? false : true );
    	}

    Line 181 - 239:

    $mtli_options['show_file_size']	= ($_POST['show_file_size']=="true"	? true : false);
    		$mtli_options['enable_ai']		= ($_POST['enable_ai']=="true"		? true : false);
    		$mtli_options['enable_asf'] 	= ($_POST['enable_asf']=="true"		? true : false);
    <..snip..>
    		$mtli_options['enable_zip']		= ($_POST['enable_zip']=="true"		? true : false);
    		$mtli_options['enable_async']	= ($_POST['enable_async']=="true"	? true : false);
    		$mtli_options['enable_hidden_class']	= ($_POST['enable_hidden_class']=="true" 	? true : false);
    		$mtli_options['hidden_classname']		= $_POST['hidden_classname'];

    Replace with:

    $mtli_options['show_file_size']	= ( isset( $_POST['show_file_size'] ) && $_POST['show_file_size']=="true"	? true : false);
    
    		global $mtli_available_mime_types, $mtli_default_true;
    		foreach( $mtli_available_mime_types as $type ) {
    			if( isset( $_POST['enable_' . $type] ) ) {
    				$mtli_options['enable_' . $type]	= ($_POST['enable_' . $type]=="true"		? true : false);
    			}
    			// Not set, get default ? or should this revert back to the already saved version if there is one first ?
    			else {
    				$mtli_options['enable_' . $type]	= ( in_array( $type, $mtli_default_true ) === false ? false : true );
    			}
    		}
    
    		$mtli_options['enable_async']	= ( isset($_POST['enable_async']) && $_POST['enable_async']=="true"	? true : false);
    		$mtli_options['enable_hidden_class']	= ( isset($_POST['enable_hidden_class']) && $_POST['enable_hidden_class']=="true" 	? true : false);
    		if( isset($_POST['hidden_classname']) && !empty($_POST['hidden_classname']) ) {
    			$mtli_options['hidden_classname']		=  $_POST['hidden_classname'];
    		}

    Line 524-525:

    global $fileSizeStyles;
    	if($fileSizeStyles){

    Replace with:

    global $fileSizeStyles;
    	$mtli_css = '';
    	if($fileSizeStyles){

    Hope this helps! Keep up the good work ;-)

    Smile,
    Juliette

    http://wordpress.org/extend/plugins/mimetypes-link-icons/

  2. eagerterrier
    Member
    Plugin Author

    Posted 2 years ago #

    @jrf - thanks for this.

    I'll go through it this week and make amends...

  3. jrf
    Member
    Plugin Contributor

    Posted 2 years ago #

    Hiya @eagerterrier, I just upgraded to the latest version and noticed the bugs I reported and supplied the fixes for haven't been fixed yet. Could you please have another look ?

    Thanks, Juliette

  4. eagerterrier
    Member
    Plugin Author

    Posted 2 years ago #

    ok, ok @jrf - I've been buuuuuusy

    But happy to help, so please find 2.2.2 with your suggested changes.

    MI2 3/5 and clueless 5/5? Five out of five?

  5. jrf
    Member
    Plugin Contributor

    Posted 2 years ago #

    Hiya! Thanks for that. Unfortunately I noticed that my bug fix instruction may not have been clear enough and some new bugs have been introduced in v2.2.2.

    I've fixed it and got a .zip file for version 2.2.2.1 here with your name on it. Please let me know where to email it so we can ensure that people won't get into trouble with the newly introduced errors. ;-)

    Hope this helps & will mail you as soon as I know where to send it.

    P.S.: could you explain what you mean by 'MI2 3/5 and clueless 5/5? Five out of five? ' ? I don't seem to get it.

  6. eagerterrier
    Member
    Plugin Author

    Posted 2 years ago #

    all done

    The reference was from epinions. I was looking to credit you and find a URL, so I googled jrf and juliette and came up with this:-

    http://www.epinions.com/user-jrf

    probably not you, then...

  7. jrf
    Member
    Plugin Contributor

    Posted 2 years ago #

    Thanks for your quick response. Glad the file reached you ok.

    And true, that sure isn't me. You can google me from the info in my email footer if you want to know more about me ;-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • MimeTypes Link Icons
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic