function mediaLibrarySave($post, $attachment) { $option = array(); $enable = false; if (PBData::get('media_library_url_field_enable')) { $enable = true; if (isset($attachment['media_library_url'])) { $option['media_library_url'] = $attachment['media_library_url']; } } if (PBData::get('media_library_video_url_field_enable')) { $enable = true; if (isset($attachment['media_library_video_url'])) { $option['media_library_video_url'] = $attachment['media_library_video_url']; } } if ($enable) { PBMeta::update($post['ID'], $option); } return $post; }
function updateNavigationMenuItemField($menu_id, $menu_item_db_id, $args) { $key = array('menu_item_icon', 'menu_item_mega_menu_enable', 'menu_item_mega_menu_layout'); foreach ($key as $index) { if (array_key_exists($index, $_REQUEST)) { if (isset($_REQUEST[$index][$menu_item_db_id])) { $value = $_REQUEST[$index][$menu_item_db_id]; $meta = PBMeta::get($menu_item_db_id); $meta[$index] = $value; PBMeta::update($menu_item_db_id, $meta); } } } }
function updateNavigationMenuItemField($menu_id, $menu_item_db_id, $args) { $default = array('menu_item_icon' => null, 'menu_item_mega_menu_enable' => 0, 'menu_item_mega_menu_layout' => '100'); foreach ($default as $index => $value) { if (!array_key_exists($index, $_REQUEST)) { $_REQUEST[$index] = array(); } if (!isset($_REQUEST[$index][$menu_item_db_id])) { $_REQUEST[$index][$menu_item_db_id] = $value; } $value = $_REQUEST[$index][$menu_item_db_id]; $meta = PBMeta::get($menu_item_db_id); $meta[$index] = $value; PBMeta::update($menu_item_db_id, $meta); } }
function adminSaveMetaBox($postId) { if ($_POST) { if (PBHelper::checkSavePost($postId, PLUGIN_PAGE_BUILDER_CONTEXT . '_team_noncename', 'adminSaveMetaBox') === false) { return false; } $option = PBHelper::getPOSTOption('team'); $Validation = new PBValidation(); /***/ PBHelper::removeUIndex($option, 'team_skill_name', 'team_skill_level', 'team_skill_order'); $skill = array('team_skill_name' => $option['team_skill_name'], 'team_skill_level' => $option['team_skill_level'], 'team_skill_order' => $option['team_skill_order']); unset($option['team_skill_name'], $option['team_skill_level'], $option['team_skill_order']); foreach ($skill['team_skill_name'] as $index => $value) { if ($Validation->isEmpty($value)) { continue; } if (!array_key_exists($index, $skill['team_skill_level'])) { continue; } if (!$Validation->isNumber($skill['team_skill_level'][$index], 1, 100)) { continue; } $option['team_skill'][] = array('team_skill_name' => $value, 'team_skill_level' => $skill['team_skill_level'][$index], 'team_skill_order' => array_key_exists($index, $skill['team_skill_order']) ? $skill['team_skill_order'][$index] : 0); } /***/ PBHelper::removeUIndex($option, 'team_social_name', 'team_social_url', 'team_social_order'); $social = array('team_social_name' => $option['team_social_name'], 'team_social_url' => $option['team_social_url'], 'team_social_order' => $option['team_social_order']); unset($option['team_social_name'], $option['team_social_url'], $option['team_social_order']); foreach ($social['team_social_name'] as $index => $value) { if (!array_key_exists($value, $this->social)) { continue; } if (!array_key_exists($index, $social['team_social_url'])) { continue; } if (!$Validation->isURL($social['team_social_url'][$index])) { continue; } $option['team_social'][] = array('team_social_name' => $value, 'team_social_url' => $social['team_social_url'][$index], 'team_social_order' => array_key_exists($index, $social['team_social_order']) ? $social['team_social_order'][$index] : 0); } PBMeta::update($postId, $option); } }
function mediaLibrarySave($post, $attachment) { $option = array(); if (isset($attachment['media_library_url'])) { $option['media_library_url'] = $attachment['media_library_url']; } if (isset($attachment['media_library_video_url'])) { $option['media_library_video_url'] = $attachment['media_library_video_url']; } PBMeta::update($post['ID'], $option); return $post; }