WordPress.org

Ready to get started?Download WordPress

Forums

Attachments
[resolved] Legacy Attachments Undetected (17 posts)

  1. Candymac
    Member
    Posted 1 year ago #

    I'm attempting to upgrade from version 1 (which I was using on a custom post type). I didn't see the migration script you referred to on the settings page. I took a peek at the plugin and discovered it was hidden as the plugin did not detect any legacy content (I forced it to display and ran it anyhow - without success). I know the content is there, when I downgrade the plugin it shows up again.

    As suggested, I also tried creating a new instance called 'attachments' (with the correct CPT specified), but it just shows up on the edit page without any content in it.

    Any Thoughts? I love this plugin and want to upgrade!

    http://wordpress.org/extend/plugins/attachments/

  2. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Would you be able to send a database dump to me by uploading it to something like Dropbox and sending the link via http://mondaybynoon.com/contact?

  3. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Hi there, would you mind passing along the parameters you're using to register your CPT? It looks like it's private or otherwise not getting flagged with my legacy data check hence the lack of notification to migrate any data. If you're able to make it public, run the migration, and then set it back that should resolve the issue for you but I'd also like to make the migration script take this use case into account if possible so if you can let me know what the parameters are that should help with that.

  4. Candymac
    Member
    Posted 1 year ago #

    Jonathan, Thanks for looking at this, below is the info you requested, though appears the CPT was already pubic.

    function create_sf_projects_post_type() {
      register_post_type( 'sf_projects',
        array(
          'labels' => array(
            'name' => _x('Projects', 'post type general name'),
            'singular_name' => _x('Project', 'post type singular name'),
            'add_new' => _x('Add New', 'project'),
            'add_new_item' => __('Add New Project'),
            'edit_item' => __('Edit Project'),
            'new_item' => __('New Project'),
            'view_item' => __('View Project'),
            'search_items' => __('Search Projects'),
            'not_found' =>  __('No projects found'),
            'not_found_in_trash' => __('No projects found in Trash'),
            'parent_item_colon' => '',
            'menu_name' => 'Projects'
        ),
          'menu_position' => 4,
          'public' => true,
          'rewrite' => array('slug'=>'projects'),
          'hierarchical' => false,
          'query_var' => true,
          'supports' => array( 'title', 'thumbnail','editor','page-attributes','revisions'),
        )
      );
    }
  5. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Can I ask which action you hooked into to fire create_sf_projects_post_type()?

  6. Candymac
    Member
    Posted 1 year ago #

    Sure... It was init:

    add_action( 'init', 'create_sf_projects_post_type' );

  7. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Hi there, I've figured out what has triggered the issue, but it does leave a question I've got. To complete the migration process you'll need to follow these steps:

    1. Add define( 'ATTACHMENTS_LEGACY', true ); to your wp-config.php
    2. View Settings - Attachments in your WordPress admin
    3. Make sure your Projects CPT is checked (http://d.pr/i/Hucc) and save your settings
    4. Remove define( 'ATTACHMENTS_LEGACY', true ); from your wp-config.php
    5. View Settings - Attachments in your WordPress admin
    6. You'll now be able to migrate the legacy data (http://d.pr/i/eYqo)

    To outline what's happening: the legacy data check only checks which post types the old version of Attachments was set to work with. For some reason your CPT wasn't enabled, so switching to the legacy version, enabling it, and then disabling the legacy version will trigger the change necessary for the legacy data check to return true.

  8. Candymac
    Member
    Posted 1 year ago #

    Jonathan,

    Thanks, that did do the trick... I appreciate you sticking with me and figuring this out... Not sure how that happened - wonder if I unintentionally unchecked the CPT.

    Anyway thanks again... Love the plugin - they should build it right into WP.

  9. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Thrilled to hear it's working out for you! Yeah I'm curious as to why the setting wasn't enabled as well, but you've now left the legacy version in the dust and can enjoy version 3! You're very welcome for the assistance, glad to help. If you've got a spare few minutes a Review would be much appreciated!

  10. katart17
    Member
    Posted 1 year ago #

    Jonathan, I've tried all these steps and still the Attachments instance only has the Attach button and none of the Legacy Attachments.

    Attempts to fix:

    1. Turn On Legacy option; Clicked CPT setting; Turn OFF Legacy but no option to migrate again (I already migrated data once)
    2. Recreate Default 'attachments' instance within the functions.php file and add my CPT to the 'post_types' array.

    Any ideas why I don't see the images?

  11. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    Please ensure that you are using the appropriate instance name in your theme template file. If you used the default field values when migrating the data, your instance name is attachments while the sample code in the docs likely uses my_attachments.

  12. katart17
    Member
    Posted 1 year ago #

    I think I did everything right.

    Here is my call within my Template file:
    $attachments = new Attachments( 'attachments' );

    Here is my use of the "Default" instance within the functions.php:

    // Attachments Plugin
    	function attachments( $attachments ) {
    		$args = array(
    	 		'label' => 'Attachments',
    			'post_type' => array( 'post', 'page', 'projects' ),
    			'filetype' => null,
    			'note' => 'Attach files here!',
    			'button_text' => __( 'Attach Files', 'attachments' ),
    			'modal_text' => __( 'Attach', 'attachments' ),
    
    			'fields' => array(
    				array(
    					'name'  => 'title',
    					'type'  => 'text',
    					'label' => __( 'Title', 'attachments' ),
    					),
    		  		array(
    					'name'  => 'caption',                        // unique field name
    					'type'  => 'textarea',                       // registered field type
    					'label' => __( 'Caption', 'attachments' ),   // label to display
    		  			),
    		  		array(
    					'name'  => 'copyright',                      // unique field name
    					'type'  => 'text',                           // registered field type
    					'label' => __( 'Copyright', 'attachments' ), // label to display
    		  			),
    			),
    
    	  	);
    		$attachments->register( 'attachments', $args ); // unique instance name
    	}
    
    	add_action( 'attachments_register', 'attachments' );

    Notice where I added the "projects" CPT. Does this look correct?

  13. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    I'd love to have a look firsthand at your site if possible, and if you were able to send a database dump that'd be really helpful too.

  14. katart17
    Member
    Posted 1 year ago #

    Jonathan, thanks for your help. Here is a link to a page template: http://www.marczarefdesign.com/clients/aspca/

    All the links under Portfolio Highlights use the same template.

    I created a DB Dump. How should I send that to you?

  15. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    If you can send me a Dropbox/Droplr/CloudApp/other link via http://mondaybynoon.com/contact/ that'd be best.

  16. katart17
    Member
    Posted 1 year ago #

    Thanks. Just sent a link.

  17. Fee
    Member
    Posted 1 year ago #

    Hey Jonathan,
    I've the same issue and I experienced that in my case the migration tool was hidden because in my multisite setup the plugin was network activated. I took a look into your code, it's caused in class.attachments.legacy.php line 48

    if( isset( $plugins['attachments/index.php'] ) )
         return;

    Is there a reason for this or should it maybe be if( !isset( ... ?
    (I did this little hack and so the migration worked for me even when network activated)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic