当前位置: 首页>>代码示例>>PHP>>正文


PHP maybe_serialize函数代码示例

本文整理汇总了PHP中maybe_serialize函数的典型用法代码示例。如果您正苦于以下问题:PHP maybe_serialize函数的具体用法?PHP maybe_serialize怎么用?PHP maybe_serialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了maybe_serialize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: siw_update_community_day_options

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));
}
开发者ID:siwvolunteers,项目名称:siw,代码行数:28,代码来源:siw-vfb.php

示例2: __construct

 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'));
 }
开发者ID:phpbits,项目名称:widget-options,代码行数:32,代码来源:functions.option.tabs.php

示例3: display

 /**
  *
  * @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;
 }
开发者ID:aaronfrey,项目名称:PepperLillie-GSP,代码行数:31,代码来源:EE_Text_Area_Display_Strategy.strategy.php

示例4: wpsc_delete_meta

/**
 * 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;
}
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:30,代码来源:meta.functions.php

示例5: delete_metadata

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;
}
开发者ID:gigikiri,项目名称:bcnAutoWallpaperSite,代码行数:34,代码来源:meta.php

示例6: get_tags_from_current_posts

 /**
  * 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();
 }
开发者ID:EasterAndJay,项目名称:tamichelew.com,代码行数:37,代码来源:class.client.autolinks.php

示例7: pmxi_wp_ajax_auto_detect_sf

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)));
}
开发者ID:estrategasdigitales,项目名称:rufiatta,代码行数:35,代码来源:wp_ajax_auto_detect_sf.php

示例8: pmxi_wp_ajax_auto_detect_sf

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)));
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:29,代码来源:wp_ajax_auto_detect_sf.php

示例9: my_action_callback

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;
}
开发者ID:kleitz,项目名称:ProSports,代码行数:25,代码来源:sm-theme-setting.php

示例10: update_meta

 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;
 }
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:25,代码来源:RTMediaMeta.php

示例11: thatcamp_registrations_add_registration

/**
 * 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);
    }
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:35,代码来源:thatcamp-registrations-functions.php

示例12: generate_transient_key

 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;
 }
开发者ID:sabdev1,项目名称:ljcdevsab,代码行数:7,代码来源:class-categories-renderer.php

示例13: write_data

 /**
  *
  * @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 . '\'');
     }
 }
开发者ID:sedici,项目名称:wpmu-istec,代码行数:12,代码来源:db.php

示例14: set

 /**
  * 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;
     }
 }
开发者ID:CannedHead,项目名称:feelingsurf,代码行数:13,代码来源:abstract-wc-session.php

示例15: delete_metadata

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;
}
开发者ID:bluedanbob,项目名称:wordpress,代码行数:25,代码来源:meta.php


注:本文中的maybe_serialize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。