• Resolved awj07

    (@awj07)


    How do I unlink certain pages from their mobile versions after the mobile version has been created?

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

    (@giuse)

    HI @awj07
    if you trash the mobile version it will be unlinked from the related desktop page.
    If you need to do it only for testing, don’t empty the trash. When you restore the trashed mobile page from the trash, it will be linked again to the desktop page, but only if at the same time you didn’t create a new mobile version for the same desktop page.

    Thread Starter awj07

    (@awj07)

    Unfortunately, I already trashed the page permanently. Is it possible to remove the functionality of your plugin for certain pages altogether?

    Plugin Author Jose Mortellaro

    (@giuse)

    Hi @awj07

    I will add this feature, this can be useful also for other users. Thank you very much for the idea.
    if you feel confident adding some PHP code, you can open the file wp-content/plugins/specific-content-for-mobile/admin/scfm-admin.php and add this code:

    
    add_filter( 'bulk_actions-edit-post','eos_scfm_unlink_mobile_versions_bulk_item' );
    add_filter( 'bulk_actions-edit-page','eos_scfm_unlink_mobile_versions_bulk_item' );
    //Add bulk action item in the bulk actions dropdown list to unlink mobile versions.
    function eos_scfm_unlink_mobile_versions_bulk_item( $bulk_actions ){
    	$bulk_actions['scfm-unlink-mobile-version'] = __( 'Unlink mobile version','eos-scfm' );
    	return $bulk_actions;
    }
    
    add_filter( 'handle_bulk_actions-edit-post','eos_scfm_unlink_mobile_versions',10,3 ); 
    add_filter( 'handle_bulk_actions-edit-page','eos_scfm_unlink_mobile_versions',10,3 ); 
    //Handler to execute the bulk action to unlink the mobile versions
    function eos_scfm_unlink_mobile_versions( $redirect_url,$action,$ids ){
    	if( $action === 'scfm-unlink-mobile-version') {
    		foreach( $ids as $id ){
    			$mobile_id = eos_scfm_related_mobile_id( $id );
    			$desktop_id = eos_scfm_related_desktop_id( $id );
    			if( $mobile_id > 0 ){
    				delete_post_meta( $mobile_id,'eos_scfm_desktop_post_id' );
    				delete_post_meta( $id,'eos_scfm_mobile_post_id' );
    			}
    			if( $desktop_id > 0 ){
    				delete_post_meta( $desktop_id,'eos_scfm_mobile_post_id' );
    				delete_post_meta( $id,'eos_scfm_desktop_post_id' );
    			}
    		}
    		$redirect_url = add_query_arg( 'scfm-unlink-mobile-version', count( $ids ),$redirect_url );
    	}
    	return $redirect_url;
    }
    
    add_action('admin_notices','eos_scfm_admin_notices' );
    //Notice after unlinking the mobile versions
    function eos_scfm_admin_notices(){
    	if( !empty( $_REQUEST['scfm-unlink-mobile-version'] ) ){
    		?>
    		<div id="message" class="updated notice is-dismissable">
    			<p><?php printf( esc_html__( 'Unlinked %s pages.','eos-scfm'),$_REQUEST['scfm-unlink-mobile-version'] ); ?></p>
    		</div>
    		<?php
    	}
    }

    Then you will see a bulk action to unlink the mobile versions in the bulk actions dropdown list.
    Pages from the main admin menu => Bulk actions dropdown list => Select “Unlink mobile version” => Apply

    If it’s not urgent and you can wait, you will find this new feature in the next plugin version.
    If your site is not live, you can also test the beta version that already includes this feature.

    So, you can:
    – add yourself the proposed code
    – wait for the new official version
    – test the beta version

    In case you prefer to test the beta version, let me know and I will provide it to you.

    Plugin Author Jose Mortellaro

    (@giuse)

    Hi @awj07, I will close this thread for inactivity.

    For your information, the new version 0.1.4 gives you now the possibility to unlink the mobile versions from their related desktop version.
    You will find the bulk action “Unlink mobile version” in the pages and posts list in the backend.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Unlinking pages’ is closed to new replies.