. */ require dirname( __FILE__ ) . '/scb/load.php'; function _p2p_init() { load_plugin_textdomain( 'posts-to-posts', '', dirname( plugin_basename( __FILE__ ) ) . '/lang' ); require_once dirname( __FILE__ ) . '/storage.php'; require_once dirname( __FILE__ ) . '/api.php'; require_once dirname( __FILE__ ) . '/ui/ui.php'; require_once dirname( __FILE__ ) . '/ui/boxes.php'; P2P_Connections::init( __FILE__ ); P2P_Query::init(); P2P_Connection_Types::init(); P2P_Migrate::init(); } scb_init( '_p2p_init' ); class P2P_Migrate { function init() { add_action( 'admin_notices', array( __CLASS__, 'migrate' ) ); } function migrate() { if ( !isset( $_GET['migrate_p2p'] ) || !current_user_can( 'administrator' ) ) return; $tax = 'p2p'; register_taxonomy( $tax, 'post', array( 'public' => false ) ); $count = 0; foreach ( get_terms( $tax ) as $term ) { $post_b = (int) substr( $term->slug, 1 ); $post_a = get_objects_in_term( $term->term_id, $tax ); p2p_connect( $post_a, $post_b ); wp_delete_term( $term->term_id, $tax ); $count += count( $post_a ); } printf( "
Migrated %d connections.