function _p2p_register_missing_post_types($ctype)
{
    foreach (_p2p_extract_post_types($ctype->side) as $ptype) {
        if (!post_type_exists($ptype)) {
            _p2p_generate_post_type($ptype);
        }
    }
}
Beispiel #2
0
 /**
  * Generate connections for a specific connection type.
  *
  * @subcommand generate-connections
  * @synopsis <connection-type> [--items]
  */
 function generate_connections($args, $assoc_args)
 {
     list($connection_type) = $args;
     $ctype = p2p_type($connection_type);
     if (!$ctype) {
         WP_CLI::error("'{$connection_type}' is not a registered connection type.");
     }
     if (isset($assoc_args['items'])) {
         foreach (_p2p_extract_post_types($ctype->side) as $ptype) {
             $assoc_args = array('post_type' => $ptype);
             WP_CLI::launch('wp post generate' . \WP_CLI\Utils\assoc_args_to_str($assoc_args));
         }
     }
     $count = $this->_generate_c($ctype);
     WP_CLI::success("Created {$count} connections.");
 }