mahfuz118

Directorist - Social Import

Sep 12th, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <?php
  2.  
  3. // atbdp_import_listing on tools.php
  4.  
  5. foreach ($metas as $index => $value) {
  6.                     $meta_value = $post[$value] ? $post[$value] : '';
  7.                     $meta_value = $this->maybe_unserialize_csv_string($meta_value);
  8.  
  9.                     // if ($index == 'social_facebook' && !empty($meta_value)) {
  10.                     //     $social = array(
  11.                     //         array(
  12.                     //             'id' => 'facebook',
  13.                     //             'url' => $meta_value
  14.                     //         )
  15.                     //     );
  16.                     //     $index = 'social';
  17.                     //     $meta_value = $social;
  18.                     // }
  19.  
  20.                     if ($index == 'social') continue;
  21.  
  22.                     if (strpos($index, 'social_') !== false) {
  23.                         $social_key = substr($index, strpos($index, "social_") + 7);
  24.                         $social_info = get_post_meta($post_id, '_social', true) ? get_post_meta($post_id, '_social', true) : array();
  25.                         array_push(
  26.                             $social_info,
  27.                             array(
  28.                                 'id' => $social_key,
  29.                                 'url' => $meta_value
  30.                             )
  31.                         );
  32.                         $index = 'social';
  33.                         $meta_value = $social_info;
  34.                     }
  35.  
  36.                     if ($meta_value) {
  37.                         update_post_meta($post_id, '_' . $index, $meta_value);
  38.                     }
  39.                 }
Advertisement
Add Comment
Please, Sign In to add comment