Advertisement
verygoodplugins

Untitled

Jan 27th, 2021
1,024
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1.         $crm_names = array();
  2.         $posts     = array();
  3.  
  4.         $crms = get_field( 'crms', 'option' );
  5.  
  6.         foreach ( $crms as $crm ) {
  7.  
  8.             $crm_names[] = $crm['name'];
  9.  
  10.         }
  11.  
  12.         $args = array(
  13.             'nopaging'  => true,
  14.             'post_type' => 'documentation',
  15.             'tax_query' => array(
  16.                 array(
  17.                     'taxonomy' => 'documentation_category',
  18.                     'field'    => 'slug',
  19.                     'terms'    => 'integrations',
  20.                 ),
  21.             ),
  22.         );
  23.  
  24.         $integrations = get_posts( $args );
  25.  
  26.         $did = 0;
  27.  
  28.         foreach ( $crm_names as $crm_name ) {
  29.  
  30.             foreach ( $integrations as $integration ) {
  31.  
  32.                 // Not applicable
  33.                 if ( 'PilotPress' == $integration->post_title ) {
  34.                     continue;
  35.                 }
  36.  
  37.                 $title = 'Connect ' . $integration->post_title . ' to ' . $crm_name;
  38.  
  39.                 if ( ! empty( get_page_by_title( $title, OBJECT, 'connect' ) ) ) {
  40.                     continue;
  41.                 }
  42.  
  43.                 $args = array(
  44.                     'post_title'  => $title,
  45.                     'post_status' => 'publish',
  46.                     'post_type'   => 'connect',
  47.                 );
  48.  
  49.                 $post_id = wp_insert_post( $args );
  50.  
  51.                 update_post_meta( $post_id, 'crm_name', $crm_name );
  52.                 update_post_meta( $post_id, 'plugin_name', $integration->post_title );
  53.                 update_post_meta( $post_id, 'plugin_docs_id', $integration->ID );
  54.  
  55.                 $did++;
  56.  
  57.             }
  58.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement