WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Some improvements

[Resolved] Some improvements

  • 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/

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