WordPress.org

Ready to get started?Download WordPress

Forums

FG Joomla to WordPress
[resolved] Some improvements (5 posts)

  1. elCHAVALdelaWEB
    Member
    Posted 1 year ago #

    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;
    	}
    }

    http://wordpress.org/extend/plugins/fg-joomla-to-wordpress/

  2. Kerfred
    Member
    Plugin Author

    Posted 1 year ago #

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

  3. elCHAVALdelaWEB
    Member
    Posted 1 year ago #

    I glad that I can help !

  4. Kerfred
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  5. elCHAVALdelaWEB
    Member
    Posted 1 year ago #

    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: http://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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic