public function save_mycomment_data($comment_ID) { if (count($this->post_types_metaboxes) >= 1) { foreach ($this->post_types_metaboxes as $key => $value) { $dbkey = $this->prefix($value[1]['metabox_id']); if ('comment' === $value[0] && isset($_POST[$dbkey . '_update_options']) && $_POST[$dbkey . '_update_options'] === $dbkey . "_update_options") { $BBWPFieldTypes = new BBWPFieldTypes($dbkey); $BBWPFieldTypes->Set('saveType', 'comment'); $BBWPFieldTypes->Set('dataID', $comment_ID); $BBWPFieldTypes->SaveOptions(); } } } }
public function input_handle() { if (isset($_GET['page']) && $_GET['page'] === $this->prefix) { /* metabox input handling */ if (isset($_POST['create_new_metabox']) && $_POST['create_new_metabox'] === $this->prefix('create_new_metabox') && isset($_POST['user_created_metaboxes'])) { $update = false; $update_message = 'Your setting have been updated.'; $existing_values = SerializeStringToArray(get_option($this->prefix('user_created_metaboxes'))); $new_values = array(); if (isset($_POST['metabox_location']) && is_array($_POST['metabox_location']) && count($_POST['metabox_location']) >= 1) { $new_values['metabox_location'] = $_POST['metabox_location']; } if (isset($_POST['metabox_pages'])) { $new_values['metabox_pages'] = $_POST['metabox_pages']; } if (isset($_POST['metabox_context'])) { $new_values['metabox_context'] = $_POST['metabox_context']; } if (isset($_POST['metabox_priority'])) { $new_values['metabox_priority'] = $_POST['metabox_priority']; } $value = BBWPSanitization::Textfield($_POST['user_created_metaboxes']); $key = sanitize_key($_POST['user_created_metaboxes']); if (isset($_POST['update_created_metabox']) && array_key_exists($_POST['update_created_metabox'], $existing_values)) { $key = $_POST['update_created_metabox']; $update = true; $update_message = '<p>Your setting have been updated.</p><p><a href="?page=' . $_GET['page'] . '">← Back to Main Page</a></p>'; } if ($update == false && $key && array_key_exists($key, $existing_values)) { update_option("bbwp_error_message", 'There was some problem. Please try again with different meta box name.'); } elseif ($value && $key) { $new_values['metabox_id'] = $key; $new_values['metabox_title'] = $value; $existing_values[$key] = $new_values; update_option($this->prefix('user_created_metaboxes'), ArrayToSerializeString($existing_values)); $this->set_bbcf_option("selected_metabox", $key); update_option("bbwp_update_message", $update_message); } } if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['metabox_id']) && $_GET['metabox_id']) { $this->DeleteMetaBoxes($_GET['metabox_id'], $this->prefix("user_created_metaboxes")); } if (isset($_POST['sort_fields']) && $_POST['sort_fields'] === $this->prefix('user_created_metaboxes')) { if (isset($_POST['bulk_action']) && $_POST['bulk_action'] === 'delete' && isset($_POST['fields']) && is_array($_POST['fields']) && count($_POST['fields']) >= 1) { $this->DeleteMetaBoxes($_POST['fields'], $this->prefix("user_created_metaboxes")); } elseif (isset($_POST['sort_field']) && is_array($_POST['sort_field']) && count($_POST['sort_field']) >= 1) { BBWPFieldTypes::SortFields($_POST['sort_field'], $this->prefix("user_created_metaboxes")); } } /* meta box inputs end here */ /* create new option page form input start */ if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['page_slug']) && $_GET['page_slug']) { BBWPFieldTypes::DeleteFields($_GET['page_slug'], $this->prefix("user_created_pages")); } if (isset($_POST['sort_fields']) && $_POST['sort_fields'] === $this->prefix('user_created_pages')) { if (isset($_POST['bulk_action']) && $_POST['bulk_action'] === 'delete' && isset($_POST['fields']) && is_array($_POST['fields']) && count($_POST['fields']) >= 1) { BBWPFieldTypes::DeleteFields($_POST['fields'], $this->prefix("user_created_pages")); } elseif (isset($_POST['sort_field']) && is_array($_POST['sort_field']) && count($_POST['sort_field']) >= 1) { BBWPFieldTypes::SortFields($_POST['sort_field'], $this->prefix("user_created_pages")); } } if (isset($_POST['create_new_option_page']) && $_POST['create_new_option_page'] === $this->prefix('create_new_option_page')) { if (isset($_POST['user_created_pages']) && $_POST['user_created_pages'] && isset($_POST['parent_menu']) && $_POST['parent_menu']) { $update = false; $update_message = 'Your setting have been updated.'; $existing_values = SerializeStringToArray(get_option($this->prefix('user_created_pages'))); $value = BBWPSanitization::Textfield($_POST['user_created_pages']); $key = sanitize_key($_POST['user_created_pages']); $parent_menu = sanitize_key($_POST['parent_menu']); if (isset($_POST['update_created_option_page']) && array_key_exists($_POST['update_created_option_page'], $existing_values)) { $key = $_POST['update_created_option_page']; $update = true; $update_message = '<p>Your setting have been updated.</p><p><a href="?page=' . sanitize_key($_GET['page']) . '">← Back to Main Page</a></p>'; } if ($update == false && array_key_exists($key, $existing_values)) { update_option("bbwp_error_message", 'There was some problem. Please try again with different page name.'); } elseif ($value && $parent_menu && $key) { $existing_values[$key] = array('page_slug' => $key, 'page_title' => $value, 'parent_menu' => $parent_menu); update_option($this->prefix('user_created_pages'), ArrayToSerializeString($existing_values)); update_option("bbwp_update_message", $update_message); } } } /* create new option page form input start */ if (isset($_POST[$this->prefix("current_selected_metabox")]) && array_key_exists($_POST[$this->prefix("current_selected_metabox")], SerializeStringToArray(get_option($this->prefix('user_created_metaboxes'))))) { $this->set_bbcf_option("selected_metabox", $_POST[$this->prefix("current_selected_metabox")]); update_option("bbwp_update_message", 'Your setting have been updated.'); } $current_selected_metabox = $this->get_bbcf_option("selected_metabox"); if ($current_selected_metabox) { $BBWPFieldTypes = new BBWPFieldTypes($this->prefix($current_selected_metabox)); if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['meta_key']) && $_GET['meta_key']) { BBWPFieldTypes::DeleteFields($_GET['meta_key'], $this->prefix($current_selected_metabox)); } if (isset($_POST['sort_fields']) && $_POST['sort_fields'] === $this->prefix($current_selected_metabox)) { if (isset($_POST['bulk_action']) && $_POST['bulk_action'] === 'delete' && isset($_POST['fields']) && is_array($_POST['fields']) && count($_POST['fields']) >= 1) { BBWPFieldTypes::DeleteFields($_POST['fields'], $this->prefix($current_selected_metabox)); } elseif (isset($_POST['sort_field']) && is_array($_POST['sort_field']) && count($_POST['sort_field']) >= 1) { BBWPFieldTypes::SortFields($_POST['sort_field'], $this->prefix($current_selected_metabox)); } } $BBWPFieldTypes->UpdateFields(); } } // if isset page end here }