• Resolved dmikam

    (@dmikam)


    I have made some changes in your plugin code so now it supports:
    * WordPress 3.0 version,
    * Attachments files download with cURL and no with copy, because in some servers in is does not work.
    * PHP 5.1 support – because error_get_last function does not exist before PHP 5.2

    I think you can include these changes into the code of plugin.

    replace this code:
    copy($old_filename, $new_filename)
    BY
    download($old_filename, $new_filename)
    AND
    Insert this functions in any part of your plugin:

    if (!function_exists('error_get_last')) {
    	function error_get_last(){
    		$__error_get_last_retval__ = array(
    			'type'        => 'simulated',
    			'message'       => 'simulated',
    			'file'        => 'simulated',
    			'line'        => 'simulated'
    		);
    		return $__error_get_last_retval__;
    	}
    
    }
    
    function download($url,$path){
    	$fp = fopen($path, 'w');
    
    	$ch = curl_init($url);
    	curl_setopt($ch, CURLOPT_FILE, $fp);
    
    	$return = curl_exec($ch);
    
    	curl_close($ch);
    	fclose($fp);
    	return $return;
    }
    
    if (!function_exists('set_post_thumbnail')){
    	function set_post_thumbnail( $post, $thumbnail_id ) {
    		$post = get_post( $post );
    		$thumbnail_id = absint( $thumbnail_id );
    		if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
    			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' );
    			if ( ! empty( $thumbnail_html ) ) {
    				return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
    			}
    		}
    		return false;
    	}
    }

    https://www.ads-software.com/extend/plugins/fg-joomla-to-wordpress/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Kerfred

    (@kerfred)

    Thank you very much.
    I have included your changes in version 1.8.0.

    Thread Starter dmikam

    (@dmikam)

    I glad that I can help !

    Plugin Author Kerfred

    (@kerfred)

    For information, in version 1.8.2, I have used the WordPress HTTP API instead of the curl call to improve the media files download.

    Thread Starter dmikam

    (@dmikam)

    I think this is even better ! I have never used it but I need to read something about.
    Also in error_get_last function I put “simlated” just to put something – if you want it to work propertly – you will need to simulate this function like this: https://www.php.net/manual/es/function.error-get-last.php#103539
    This example does not worked for me and I have had no time to search solution so I desided to put some random text.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Some improvements’ is closed to new replies.