|
<?php |
|
|
|
add_action('pmxi_update_post_meta', 'update_panels', 10, 3); |
|
|
|
function update_panels($pid, $m_key, $m_value) { |
|
if ( $m_key == 'import_unprocessed') { |
|
|
|
$arr = preg_split('/\n|\r\n?/', $m_value); |
|
update_post_meta($pid, 'test', count($arr)); |
|
for ($i = 0; $i < (count($arr) - 1); $i++) { |
|
$col = explode(',', $arr[$i]); |
|
update_post_meta($pid, 'name_'.$i, $col[0]); |
|
update_post_meta($pid, 'image_'.$i, $col[1]); |
|
} |
|
} |
|
} |
|
|
|
// Alternative Example For Flexible Content |
|
add_action('pmxi_update_post_meta', 'update_panels', 10, 3); |
|
function update_panels($pid, $m_key, $m_value) { |
|
$updatable_actions = []; |
|
|
|
if ( $m_key == 'import_panels') { |
|
$panelarr = []; |
|
|
|
$arr = explode('***LINE***', $m_value); |
|
|
|
update_post_meta($pid, 'test', count($arr)); |
|
|
|
for ($i = 0; $i < (count($arr) - 1); $i++) { |
|
$col = explode('***,***', $arr[$i]); |
|
$panelarr[] = 'field_btm_panel'; |
|
|
|
array_push($updatable_actions, [ 'key' => 'field_btm_content_layout_'.$i.'_field_btm_panel_image', 'value' => $col[0] ]); |
|
array_push($updatable_actions, [ 'key' => '_field_btm_content_layout_'.$i.'_field_btm_panel_image', 'value' => 'field_btm_panel_image' ]); |
|
|
|
array_push($updatable_actions, [ 'key' => 'field_btm_content_layout_'.$i.'_field_btm_panel_content', 'value' => $col[1] ]); |
|
array_push($updatable_actions, [ 'key' => '_field_btm_content_layout_'.$i.'_field_btm_panel_content', 'value' => 'field_btm_panel_content' ]); |
|
} |
|
|
|
array_push($updatable_actions, [ 'key' => 'field_btm_content_layout', 'value' => serialize($panelarr) ]); |
|
array_push($updatable_actions, [ 'key' => '_field_btm_content_layout', 'value' => 'field_btm_content_layout' ]); |
|
|
|
} |
|
|
|
foreach ($updatable_actions as $action) { |
|
update_post_meta($pid, $action['key'], $action['value']); |
|
} |
|
} |