function siw_update_community_day_options() { //haal cd-datums op for ($x = 1; $x <= 9; $x++) { $community_days[] = get_option("siw_community_day_{$x}"); } asort($community_days); $hide_form_days_before_cd = siw_get_hide_form_days_before_cd(); $limit_date = date("Y-m-d", strtotime(date("Y-m-d") . "+" . $hide_form_days_before_cd . " days")); foreach ($community_days as $community_day => $community_day_date) { if ($community_day_date >= $limit_date) { $future_community_days[]['label'] = siw_get_date_in_text($community_day_date, false); } } //zoek cd-formuliervraag $field_id = siw_get_vfb_field_id('community_day_datums'); global $wpdb; if (!isset($wpdb->vfbp_fields)) { $wpdb->vfbp_fields = $wpdb->prefix . 'vfbp_fields'; } $query = "SELECT {$wpdb->vfbp_fields}.data\n\t\t\t\tFROM {$wpdb->vfbp_fields}\n\t\t\t\tWHERE {$wpdb->vfbp_fields}.id = %d"; $data = $wpdb->get_var($wpdb->prepare($query, $field_id)); $data = maybe_unserialize($data); //update formuliervraag $data['options'] = $future_community_days; $query = "update {$wpdb->vfbp_fields} set {$wpdb->vfbp_fields}.data = %s where {$wpdb->vfbp_fields}.id = %d;"; $wpdb->query($wpdb->prepare($query, maybe_serialize($data), $field_id)); }
public function __construct() { /* * Check for transient. If none, then execute Query */ if (false === ($widgetopts_tabs = get_transient('widgetopts_tabs_transient'))) { $widgetopts_tabs = array('visibility' => get_option('widgetopts_tabmodule-visibility'), 'devices' => get_option('widgetopts_tabmodule-devices'), 'alignment' => get_option('widgetopts_tabmodule-alignment'), 'hide_title' => get_option('widgetopts_tabmodule-hide_title'), 'classes' => get_option('widgetopts_tabmodule-classes'), 'logic' => get_option('widgetopts_tabmodule-logic')); $widgetopts_tabs = maybe_serialize($widgetopts_tabs); // Put the results in a transient. Expire after 4 weeks. set_transient('widgetopts_tabs_transient', $widgetopts_tabs, 4 * WEEK_IN_SECONDS); } $this->widgetopts_tabs = unserialize($widgetopts_tabs); $this->settings = unserialize(get_option('widgetopts_tabmodule-settings')); if ('activate' == $this->widgetopts_tabs['visibility']) { add_action('extended_widget_opts_tabs', array(&$this, 'tab_visibility')); add_action('extended_widget_opts_tabcontent', array(&$this, 'content_visibility')); } if ('activate' == $this->widgetopts_tabs['devices']) { add_action('extended_widget_opts_tabs', array(&$this, 'tab_devices')); add_action('extended_widget_opts_tabcontent', array(&$this, 'content_devices')); } if ('activate' == $this->widgetopts_tabs['alignment']) { add_action('extended_widget_opts_tabs', array(&$this, 'tab_alignment')); add_action('extended_widget_opts_tabcontent', array(&$this, 'content_alignment')); } if ('activate' == $this->widgetopts_tabs['classes'] || 'activate' == $this->widgetopts_tabs['hide_title']) { add_action('extended_widget_opts_tabs', array(&$this, 'tab_class')); add_action('extended_widget_opts_tabcontent', array(&$this, 'content_class')); } add_action('extended_widget_opts_tabs', array(&$this, 'tab_gopro')); add_action('extended_widget_opts_tabcontent', array(&$this, 'gopro_alignment')); }
/** * * @return string of html to display the field */ function display() { $input = $this->_input; $raw_value = maybe_serialize($input->raw_value()); if ($input instanceof EE_Text_Area_Input) { $rows = $input->get_rows(); $cols = $input->get_cols(); } else { $rows = 4; $cols = 20; } $html = '<textarea'; $html .= ' id="' . $input->html_id() . '"'; $html .= ' name="' . $input->html_name() . '"'; $html .= ' class="' . $input->html_class() . '"'; $html .= ' style="' . $input->html_style() . '"'; $html .= $input->other_html_attributes(); $html .= ' rows= "' . $rows . '" cols="' . $cols . '">'; $html .= $raw_value; $html .= '</textarea>'; foreach ($this->_input->get_validation_strategies() as $validation_strategy) { if ($validation_strategy instanceof EE_Simple_HTML_Validation_Strategy || $validation_strategy instanceof EE_Full_HTML_Validation_Strategy) { $html .= sprintf(__('%1$s(allowed tags: %2$s)%3$s', 'event_espresso'), '<p class="ee-question-desc">', $validation_strategy->get_list_of_allowed_tags(), '</p>'); } } return $html; }
/** * Deletes meta data from the database * * @internal */ function wpsc_delete_meta($object_id = 0, $meta_key, $meta_value, $type, $global = false) { global $wpdb; if (!is_numeric($object_id) || empty($object_id) && !$global) { return false; } $cache_object_id = $object_id = (int) $object_id; $object_type = $type; $meta_key = wpsc_sanitize_meta_key($meta_key); $meta_tuple = compact('object_type', 'object_id', 'meta_key', 'meta_value', 'type'); $meta_tuple = apply_filters('wpsc_delete_meta', $meta_tuple); extract($meta_tuple, EXTR_OVERWRITE); $meta_value = maybe_serialize($meta_value); if (empty($meta_value)) { $meta_sql = $wpdb->prepare("SELECT `meta_id` FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $object_type, $object_id, $meta_key); } else { $meta_sql = $wpdb->prepare("SELECT `meta_id` FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s AND `meta_value` = %s", $object_type, $object_id, $meta_key, $meta_value); } if (!($meta_id = $wpdb->get_var($meta_sql))) { return false; } $wpdb->query($wpdb->prepare("DELETE FROM `" . WPSC_TABLE_META . "` WHERE `meta_id` = %d", $meta_id)); wp_cache_delete($cache_object_id, $object_type); return true; }
function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $delete_all = false) { if (!$meta_type || !$meta_key || !$delete_all && !(int) $object_id) { return false; } if (!($table = _get_meta_table($meta_type))) { return false; } global $wpdb; $type_column = esc_sql($meta_type . '_id'); $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; // expected_slashed ($meta_key) $meta_key = stripslashes($meta_key); $meta_value = maybe_serialize(stripslashes_deep($meta_value)); $query = $wpdb->prepare("SELECT {$id_column} FROM {$table} WHERE meta_key = %s", $meta_key); if (!$delete_all) { $query .= $wpdb->prepare(" AND {$type_column} = %d", $object_id); } if ($meta_value) { $query .= $wpdb->prepare(" AND meta_value = %s", $meta_value); } $meta_ids = $wpdb->get_col($query); if (!count($meta_ids)) { return false; } $query = "DELETE FROM {$table} WHERE {$id_column} IN( " . implode(',', $meta_ids) . " )"; $count = $wpdb->query($query); if (!$count) { return false; } wp_cache_delete($object_id, $meta_type . '_meta'); do_action("deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $meta_value); return true; }
/** * Get tags from current post views * * @return boolean */ public static function get_tags_from_current_posts() { if (is_array(self::$posts) && count(self::$posts) > 0) { // Generate SQL from post id $postlist = implode("', '", self::$posts); // Generate key cache $key = md5(maybe_serialize($postlist)); $results = array(); // Get cache if exist $cache = wp_cache_get('generate_keywords', 'simpletags'); if ($cache === false) { foreach (self::$posts as $object_id) { // Get terms $terms = get_object_term_cache($object_id, 'post_tag'); if (false === $terms) { $terms = wp_get_object_terms($object_id, 'post_tag'); } if ($terms != false) { $results = array_merge($results, $terms); } } $cache[$key] = $results; wp_cache_set('generate_keywords', $cache, 'simpletags'); } else { if (isset($cache[$key])) { return $cache[$key]; } } return $results; } return array(); }
function pmxi_wp_ajax_auto_detect_sf() { if (!check_ajax_referer('wp_all_import_secure', 'security', false)) { exit(json_encode(array('result' => array(), 'msg' => __('Security check', 'wp_all_import_plugin')))); } if (!current_user_can(PMXI_Plugin::$capabilities)) { exit(json_encode(array('result' => array(), 'msg' => __('Security check', 'wp_all_import_plugin')))); } $input = new PMXI_Input(); $fieldName = $input->post('name', ''); $post_type = $input->post('post_type', 'post'); global $wpdb; $result = array(); if ($fieldName) { if ($post_type == 'import_users') { $values = $wpdb->get_results("\n\t\t\t\tSELECT DISTINCT usermeta.meta_value\n\t\t\t\tFROM " . $wpdb->usermeta . " as usermeta\n\t\t\t\tWHERE usermeta.meta_key='" . $fieldName . "'\n\t\t\t", ARRAY_A); } else { $values = $wpdb->get_results("\n\t\t\t\tSELECT DISTINCT postmeta.meta_value\n\t\t\t\tFROM " . $wpdb->postmeta . " as postmeta\n\t\t\t\tWHERE postmeta.meta_key='" . $fieldName . "'\n\t\t\t", ARRAY_A); } if (!empty($values)) { foreach ($values as $key => $value) { if (!empty($value['meta_value']) and is_serialized($value['meta_value'])) { $v = unserialize($value['meta_value']); if (!empty($v) and is_array($v)) { foreach ($v as $skey => $svalue) { $result[] = array('key' => $skey, 'val' => maybe_serialize($svalue)); } break; } } } } } exit(json_encode(array('result' => $result))); }
function pmxi_wp_ajax_auto_detect_sf() { $input = new PMXI_Input(); $fieldName = $input->post('name', ''); $post_type = $input->post('post_type', 'post'); global $wpdb; $result = array(); if ($fieldName) { if ($post_type == 'import_users') { $values = $wpdb->get_results("\n\t\t\t\tSELECT DISTINCT usermeta.meta_value\n\t\t\t\tFROM " . $wpdb->usermeta . " as usermeta\n\t\t\t\tWHERE usermeta.meta_key='" . $fieldName . "'\n\t\t\t", ARRAY_A); } else { $values = $wpdb->get_results("\n\t\t\t\tSELECT DISTINCT postmeta.meta_value\n\t\t\t\tFROM " . $wpdb->postmeta . " as postmeta\n\t\t\t\tWHERE postmeta.meta_key='" . $fieldName . "'\n\t\t\t", ARRAY_A); } if (!empty($values)) { foreach ($values as $key => $value) { if (!empty($value['meta_value']) and is_serialized($value['meta_value'])) { $v = unserialize($value['meta_value']); if (!empty($v) and is_array($v)) { foreach ($v as $skey => $svalue) { $result[] = array('key' => $skey, 'val' => maybe_serialize($svalue)); } break; } } } } } exit(json_encode(array('result' => $result))); }
function my_action_callback() { global $wpdb; // this is how you get access to the database if ($_POST) { extract($_POST); parse_str($whatever, $output); extract($output); if ($action == 'update_setting') { $output = array_map('stripslashes_deep', $output); $theme_setting = $output; $theme_setting = maybe_serialize($theme_setting); update_option("_sportstheme_setting", $theme_setting, 'no'); /* if ($output['_footer_credit_link']=='yes') { add_option("_display_footer_links","yes"); } else { delete_option("_display_footer_links"); }*/ echo 'Setting has been saved'; } else { echo 'Something went wrong please try again.'; } } die; }
function update_meta($id = false, $key = false, $value = false, $duplicate = false) { if ($id === false) { return false; } if ($key === false) { return false; } if ($value === false) { return false; } $value = maybe_serialize($value); if ($duplicate === true) { $media_meta = $this->model->insert(array('media_id' => $id, 'meta_key' => $key, 'meta_value' => $value)); } else { if ($this->get_single_meta($id, $key)) { $meta = array('meta_value' => $value); $where = array('media_id' => $id, 'meta_key' => $key); $media_meta = $this->model->update($meta, $where); } else { $media_meta = $this->model->insert(array('media_id' => $id, 'meta_key' => $key, 'meta_value' => $value)); } } return $media_meta; }
/** * Adds a single registration entry. This is a motley function. * * @param string The status of the registration record. **/ function thatcamp_registrations_add_registration($status = 'pending') { global $wpdb; $table = $wpdb->prefix . "thatcamp_registrations"; $_POST = stripslashes_deep($_POST); // The user_id is set to the posted user ID, or null. $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : null; $applicant_info = array(); $applicant_fields = wp_list_pluck(thatcamp_registrations_fields(), 'id'); foreach ($applicant_fields as $field) { $applicant_info[$field] = isset($_POST[$field]) ? $_POST[$field] : null; } $date = isset($_POST['date']) ? $_POST['date'] : null; $applicationText = isset($_POST['application_text']) ? $_POST['application_text'] : null; // Lets serialize the applicant_info before putting it in the database. $applicant_info = maybe_serialize($applicant_info); $applicant_email = isset($_POST['user_email']) ? $_POST['user_email'] : null; // Check for an existing registration $user_exists = false; if (!is_null($user_id) && thatcamp_registrations_get_registration_by_user_id($user_id) || thatcamp_registrations_get_registration_by_applicant_email($applicant_email)) { $user_exists = true; } if ($user_exists) { return 'You have already submitted your registration.'; } else { $reg_id = $wpdb->insert($table, array('applicant_info' => $applicant_info, 'applicant_email' => $applicant_email, 'application_text' => $applicationText, 'status' => $status, 'date' => $date, 'user_id' => $user_id)); thatcamp_registrations_send_applicant_email($applicant_email); thatcamp_registrations_send_admin_notification($wpdb->insert_id); } }
private function generate_transient_key($params) { $params = array_merge($params, array('walker' => get_class($this->walker))); $transient_key_params = apply_filters('awpcp-categories-list-transient-key-params', $params); $transient_key = 'awpcp-categories-list-cache-' . hash('crc32b', maybe_serialize($transient_key_params)); return $transient_key; }
/** * * @see Ai1ec_Write_Data_To_Cache::write_data() * */ public function write_data($key, $value) { $result = $this->model_option->set($this->_key($key), maybe_serialize($value)); if (false === $result) { throw new Ai1ec_Cache_Write_Exception('An error occured while saving data to \'' . $key . '\''); } }
/** * Set a session variable * * @param string $key * @param mixed $value */ public function set($key, $value) { if ($value !== $this->get($key)) { $this->_data[sanitize_key($key)] = maybe_serialize($value); $this->_dirty = true; } }
function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '') { if (!$meta_type || !$meta_key) { return false; } if (!($table = _get_meta_table($meta_type))) { return false; } global $wpdb; $column = esc_sql($meta_type . '_id'); // expected_slashed ($meta_key) $meta_key = stripslashes($meta_key); $meta_value = maybe_serialize(stripslashes_deep($meta_value)); $query = $wpdb->prepare("DELETE FROM {$table} WHERE meta_key = %s", $meta_key); if ($meta_value) { $query .= $wpdb->prepare("AND meta_value = %s", $meta_value); } $count = $wpdb->query($query); if (!$count) { return false; } wp_cache_delete($object_id, $meta_type . '_meta'); do_action("deleted_{$meta_type}_meta", $object_id, $meta_key, $meta_value); return true; }
function update($args = array()) { if (count($args) == 0) { return false; } $name = OP_SN . '_' . $args[0]; $val = array_pop($args); $cur = $this->get($args); $update_val = false; if (count($args) > 1) { $option = array_shift($args); $options = $this->get($option); $options = $options ? $options : array(); for ($i = 0, $al = count($args); $i < $al; $i++) { $is_array = $i >= $al - 1; if (!isset($tmp)) { $tmp =& $options; } if (!isset($tmp[$args[$i]])) { $tmp[$args[$i]] = $is_array ? array() : false; } $tmp =& $tmp[$args[$i]]; } $tmp = $val; $this->_options[$name] = $options; $update_val = $options; } else { $this->_options[$name] = $val; $update_val = $val; } if (isset($update_val)) { update_option($name, maybe_serialize($update_val)); } }
function AutoResponderMailChimp($that, $ar, $wpm_id, $email, $unsub = false) { $listID = $ar['mcID'][$wpm_id]; // get the list ID of the Membership Level $mcAPI = $ar['mcapi']; // get the MailChimp API $WishlistAPIQueueInstance = new WishlistAPIQueue(); $WLM_AUTORESPONDER_MAILCHIMP_INIT = new WLM_AUTORESPONDER_MAILCHIMP_INIT(); if ($listID) { //$listID should not be empty list($fName, $lName) = explode(" ", $that->ARSender['name'], 2); //split the name into First and Last Name $emailAddress = $that->ARSender['email']; $data = false; if ($unsub) { // if the Unsubscribe $mcOnRemCan = isset($ar['mcOnRemCan'][$wpm_id]) ? $ar['mcOnRemCan'][$wpm_id] : ""; if ($mcOnRemCan == "unsub") { //$res = $this->mcListUnsubscribe($mcAPI, $listID, $emailAddress, true); $data = array("apikey" => $mcAPI, "action" => "unsubscribe", "listID" => $listID, "email" => $emailAddress, "delete_member" => true); } elseif ($mcOnRemCan == "move" || $mcOnRemCan == "add") { $gp = $ar['mcRCGp'][$wpm_id]; $gping = $ar['mcRCGping'][$wpm_id]; $groupings = array(); if ($gp != "" && $gping != "") { $groupings = array(array('name' => $gp, 'groups' => $gping)); } $replace_interests = $mcOnRemCan == "move" ? true : false; #add name or else this will still fail $merge_vars = array('FNAME' => $fName, 'LNAME' => $lName, 'NAME' => "{$fName} {$lName}", 'GROUPINGS' => $groupings); // populate the merger vars for MailChimp //$res = $this->mcListSubscribe($mcAPI, $listID, $emailAddress, $merge_vars, true, true, $replace_interests); $data = array("apikey" => $mcAPI, "action" => "subscribe", "listID" => $listID, "email" => $emailAddress, "mergevars" => $merge_vars, "optin" => true, "update_existing" => true, "replace_interests" => $replace_interests); } } else { //else Subscribe $gp = $ar['mcGp'][$wpm_id]; $gping = $ar['mcGping'][$wpm_id]; $groupings = array(); if ($gp != "") { $groupings = array(array('name' => $gp, 'groups' => $gping)); } $optin = $ar['optin']; // get the MailChimp API $optin = $optin == 1 ? false : true; #add name or else this will still fail $merge_vars = array('FNAME' => $fName, 'LNAME' => $lName, 'NAME' => "{$fName} {$lName}", 'GROUPINGS' => $groupings); // populate the merger vars for MailChimp //$res = $this->mcListSubscribe($mcAPI, $listID, $emailAddress, $merge_vars, $optin, true, false); $data = array("apikey" => $mcAPI, "action" => "subscribe", "listID" => $listID, "email" => $emailAddress, "mergevars" => $merge_vars, "optin" => $optin, "update_existing" => 1, "replace_interests" => false); } if ($data) { $qname = "mailchimp_" . time(); $data = maybe_serialize($data); $WishlistAPIQueueInstance->add_queue($qname, $data, "For Queueing"); $WLM_AUTORESPONDER_MAILCHIMP_INIT->mcProcessQueue(); } } }
/** * save custom standings * * @param int $team_id * @return void */ function saveStandings($team_id) { global $wpdb, $leaguemanager; $team = $wpdb->get_results("SELECT `custom` FROM {$wpdb->leaguemanager_teams} WHERE `id` = {$team_id}"); $custom = maybe_unserialize($team->custom); $custom = $this->getStandingsData($team_id, $custom); $wpdb->query($wpdb->prepare("UPDATE {$wpdb->leaguemanager_teams} SET `custom` = '%s' WHERE `id` = '%d'", maybe_serialize($custom), $team_id)); }
/** * Create a cookie. */ function king_setcookie($name, $value = array(), $time = null) { $time = $time != null ? $time : time() + 60 * 60 * 24 * 30; $value = maybe_serialize(stripslashes_deep($value)); $expiration = apply_filters('king_wishlist_cookie_expiration_time', $time); // Default 30 days return setcookie($name, $value, $expiration, '/'); }
/** * * @see Ai1ec_Write_Data_To_Cache::write_data() * */ public function write_data($key, $value) { $result = $this->db_adapter->write_data_to_config($this->_key($key), maybe_serialize($value)); if (false === $result) { $this->inject_logger()->warn('Failed to save \'' . $key . '\''); throw new Ai1ec_Cache_Write_Exception('An error occured while saving data to \'' . $key . '\''); } }
/** * Extend register($widget_class) with ability to pass parameters into widgets * * @param string $widget_class Class of the new Widget * @param array|null $params parameters to pass through to the widget */ function register($widget_class, $params = null) { $key = $widget_class; if (!empty($params)) { $key .= md5(maybe_serialize($params)); } $this->widgets[$key] = new $widget_class($params); }
/** * * @param $post_id * @param $data */ function save_page_options($post_id, $data) { $data = maybe_serialize($data); $data = base64_encode($data); update_post_meta($post_id, self::PAGE_OPTIONS_NAME, $data); $cache_key = $post_id . '_' . self::PAGE_OPTIONS_NAME; do_action('st_save_page_options', $post_id, $data, self::PAGE_OPTIONS_NAME); wp_cache_delete($cache_key); }
/** * Create a schedule record * * @since 1.0.0 * * @param $order_id int the order id * @param $list * * @return void * @author Alberto Ruggiero */ public function schedule_mail($order_id, $list = '') { if ($this->check_exists_schedule($order_id) == 0) { global $wpdb; $order = wc_get_order($order_id); $scheduled_date = date('Y-m-d', strtotime(current_time('mysql') . ' + ' . get_option('ywrr_mail_schedule_day') . ' days')); $wpdb->insert($wpdb->prefix . 'ywrr_email_schedule', array('order_id' => $order_id, 'mail_status' => 'pending', 'scheduled_date' => $scheduled_date, 'order_date' => $order->modified_date, 'request_items' => maybe_serialize($list)), array('%d', '%s', '%s', '%s', '%s')); } }
public function SetOptionValue($name, $value) { $this->GetNamedOption($name); $this->option_name = $name; // Serialize if $value is array or object $value = maybe_serialize($value); $this->option_value = $value; $this->Save(); }
/** * Set the value of a meta item (creates or updates meta item). * @param string $name Meta name. * @param mixed $value Meta value. */ public function SetMetaValue($name, $value) { //get meta adapter $model = new WSAL_Models_Meta(); $model->occurrence_id = $this->getId(); $model->name = $name; $model->value = maybe_serialize($value); $model->SaveMeta(); }
public static function save_post($post_id, $post) { if ($parent_id = wp_is_post_revision($post_id) && !wp_is_post_autosave($post_id)) { $meta = piklist('post_custom', $parent_id); foreach ($meta as $key => $value) { add_metadata('post', $post_id, $key, maybe_serialize($value)); } } }
/** * Format event data into something human-readable * * @param $events * * @return array */ private function format_events($events) { $formatted_events = array(); foreach ($events as $event) { $event_data = \Automattic\WP\Cron_Control\Events::instance()->get_event($event['timestamp'], $event['action'], $event['instance']); $formatted_events[] = array('timestamp' => $event_data['timestamp'], 'action' => $event_data['action'], 'instance' => $event_data['instance'], 'scheduled_for' => date(TIME_FORMAT, $event_data['timestamp']), 'internal_event' => \Automattic\WP\Cron_Control\is_internal_event($event_data['action']) ? __('true', 'automattic-cron-control') : '', 'schedule_name' => false === $event_data['schedule'] ? __('n/a', 'automattic-cron-control') : $event_data['schedule'], 'event_args' => maybe_serialize($event_data['args'])); } return $formatted_events; }
public static function get_changed_keys($old_value, $new_value, $deep = false) { if (!is_array($old_value) && !is_array($new_value)) { return array(); } if (!is_array($old_value)) { return array_keys($new_value); } if (!is_array($new_value)) { return array_keys($old_value); } $diff = array_udiff_assoc($old_value, $new_value, function ($value1, $value2) { return maybe_serialize($value1) !== maybe_serialize($value2); }); $result = array_keys($diff); // find unexisting keys in old or new value $common_keys = array_keys(array_intersect_key($old_value, $new_value)); $unique_keys_old = array_values(array_diff(array_keys($old_value), $common_keys)); $unique_keys_new = array_values(array_diff(array_keys($new_value), $common_keys)); $result = array_merge($result, $unique_keys_old, $unique_keys_new); // remove numeric indexes $result = array_filter($result, function ($value) { // check if is not valid number (is_int, is_numeric and ctype_digit are not enough) return (string) (int) $value !== (string) $value; }); $result = array_values(array_unique($result)); if (false === $deep) { return $result; // Return an numerical based array with changed TOP PARENT keys only } $result = array_fill_keys($result, null); foreach ($result as $key => $val) { if (in_array($key, $unique_keys_old)) { $result[$key] = false; // Removed } elseif (in_array($key, $unique_keys_new)) { $result[$key] = true; // Added } elseif ($deep) { // Changed, find what changed, only if we're allowed to explore a new level if (is_array($old_value[$key]) && is_array($new_value[$key])) { $inner = array(); $parent = $key; $deep--; $changed = self::get_changed_keys($old_value[$key], $new_value[$key], $deep); foreach ($changed as $child => $change) { $inner[$parent . '::' . $child] = $change; } $result[$key] = 0; // Changed parent which has a changed children $result = array_merge($result, $inner); } } } return $result; }
public function cache($member_id) { $myData = array(); $myData = $this->getMydata($member_id); $myData = $this->oldcacheProess($myData); //不合法数据删除(例如:数据库中已存在,但是卡片标识数组不存在的值) $data = array('myData' => maybe_serialize($myData)); $this->membersql->update('member', $data, array('member_id' => $member_id)); return $myData; }
/** * Return the full array of settings * * @access private */ private function get_custom_login_settings() { $settings = array(); include trailingslashit(CUSTOM_LOGIN_DIR) . 'includes/default-settings.php'; foreach ($sections as $section) { $settings[$section['id']] = get_option($section['id']); } return base64_encode(maybe_serialize($settings)); # var_dump( $settings ); exit; }