本文整理匯總了PHP中is_serialized函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_serialized函數的具體用法?PHP is_serialized怎麽用?PHP is_serialized使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_serialized函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: genesis_update_check
/**
* Pings http://api.genesistheme.com/ asking if a new version of this theme is
* available.
*
* If not, it returns false.
*
* If so, the external server passes serialized data back to this function,
* which gets unserialized and returned for use.
*
* @since 1.1.0
*
* @uses genesis_get_option()
* @uses PARENT_THEME_VERSION Genesis version string
*
* @global string $wp_version WordPress version string
* @return mixed Unserialized data, or false on failure
*/
function genesis_update_check()
{
global $wp_version;
/** If updates are disabled */
if (!genesis_get_option('update') || !current_theme_supports('genesis-auto-updates')) {
return false;
}
/** Get time of last update check */
$genesis_update = get_transient('genesis-update');
/** If it has expired, do an update check */
if (!$genesis_update) {
$url = 'http://api.genesistheme.com/update-themes/';
$options = apply_filters('genesis_update_remote_post_options', array('body' => array('genesis_version' => PARENT_THEME_VERSION, 'wp_version' => $wp_version, 'php_version' => phpversion(), 'uri' => home_url(), 'user-agent' => "WordPress/{$wp_version};")));
$response = wp_remote_post($url, $options);
$genesis_update = wp_remote_retrieve_body($response);
/** If an error occurred, return FALSE, store for 1 hour */
if ('error' == $genesis_update || is_wp_error($genesis_update) || !is_serialized($genesis_update)) {
set_transient('genesis-update', array('new_version' => PARENT_THEME_VERSION), 60 * 60);
return false;
}
/** Else, unserialize */
$genesis_update = maybe_unserialize($genesis_update);
/** And store in transient for 24 hours */
set_transient('genesis-update', $genesis_update, 60 * 60 * 24);
}
/** If we're already using the latest version, return false */
if (version_compare(PARENT_THEME_VERSION, $genesis_update['new_version'], '>=')) {
return false;
}
return $genesis_update;
}
示例2: payment_post_meta
public function payment_post_meta($payment_id)
{
ini_set('xdebug.var_display_max_depth', 5);
ini_set('xdebug.var_display_max_children', 256);
ini_set('xdebug.var_display_max_data', 1024);
?>
<div id="edd-payment-meta" class="postbox">
<h3 class="hndle"><?php
_e('Payment Postmeta Items', 'edd-dev-tools');
?>
</h3>
<div class="inside">
<div style="overlfow:auto">
<?php
$post_meta = get_metadata('post', $payment_id);
?>
<pre style="overflow: auto;word-wrap: break-word;">
<?php
foreach ($post_meta as $key => $value) {
if (is_serialized($value[0])) {
echo $key . '=> ';
var_dump(unserialize($value[0]));
} else {
echo $key . ' => ' . $value[0] . "\n";
}
}
?>
</pre>
</div>
</div>
</div>
<?php
}
示例3: cjtheme_fetch_shortcode_options
function cjtheme_fetch_shortcode_options()
{
global $wpdb, $shortcode_tags;
$select_shortcodes = null;
$shortcode_options = cjtheme_do_shortcode('[' . $_POST['shortcode'] . ' return="options"]');
$shortcode_options = is_serialized($shortcode_options) ? unserialize($shortcode_options) : $shortcode_options;
$shortcode_defaults = cjtheme_do_shortcode('[' . $_POST['shortcode'] . ' return="defaults"]');
$shortcode_defaults = is_serialized($shortcode_defaults) ? unserialize($shortcode_defaults) : $shortcode_defaults;
$form_fields[] = array('type' => 'heading', 'id' => 'shortcode-settings-heading', 'label' => '', 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => __('Shortcode Settings', 'cjtheme'), 'options' => '');
if (!is_null($shortcode_options['description'])) {
$form_fields[] = array('type' => 'info-full', 'id' => 'shortcode_info', 'label' => '', 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => $shortcode_options['description'], 'options' => '');
}
if ($shortcode_options['stype'] == 'closed' && isset($shortcode_options['default_content']) && $shortcode_options['default_content'] != '') {
$form_fields[] = array('type' => 'textarea', 'id' => 'shortcode_content', 'label' => __('Content', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => $shortcode_options['default_content'], 'options' => '');
}
foreach ($shortcode_options as $key => $options) {
if (is_array($options)) {
$form_fields[] = array('type' => $options[1], 'id' => $key, 'label' => $options[0], 'info' => $options[3], 'suffix' => '', 'prefix' => '', 'default' => isset($shortcode_defaults[$key]) ? $shortcode_defaults[$key] : '', 'options' => is_array($options[2]) ? $options[2] : '');
}
}
$form_fields[] = array('type' => 'submit', 'id' => 'cj-insert-shortcode', 'label' => __('Insert Shortcode', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => '', 'options' => '');
echo '<div class="cj-table">';
echo '<form action="" method="post" id="cj-shortcode-settings-form" data-shortcode-stype="' . $shortcode_options['stype'] . '" data-shortcode-name="' . $_POST['shortcode'] . '">';
echo cjtheme_admin_form_raw($form_fields, 'no-search-box', true);
echo '</form>';
echo '</div>';
die;
}
示例4: ns_recursive_search_replace
/**
* Recursively search and replace
* @param mixed $data - **by reference** - string or array which should have find/replace applied
* @param array $search array with text values to find
* @param array $replace array with text values to replace $search values with
* @param array $regex_search array with regular expressions to look for
* @param array $regex_replace array with text value to replace $regex_search values with
* @return int number of replacements made
*/
function ns_recursive_search_replace(&$data, $search, $replace, $regex_search = array(), $regex_replace = array(), $case_sensitive = false)
{
$is_serialized = is_serialized($data);
$string_replacements_made = $regex_replacements_made = 0;
// unserialize if need be
if ($is_serialized) {
$data = unserialize($data);
}
// run through replacements for strings, arrays - other types are unsupported to vaoid
if (is_array($data)) {
foreach ($data as $key => $value) {
ns_recursive_search_replace($data[$key], $search, $replace, $regex_search, $regex_replace, $case_sensitive);
}
} elseif (is_string($data)) {
// simple string replacment - most of the time this is all that is needed
$replace_func = $case_sensitive ? 'str_replace' : 'str_ireplace';
$data = $replace_func($search, $replace, $data, $string_replacements_made);
// advanced regex replacement - this will be skipped most of the time
if (!empty($regex_search) && !empty($regex_replace)) {
$data = preg_replace($regex_search, $regex_replace, $data, -1, $regex_replacements_made);
}
}
// reserialize if need be
if ($is_serialized) {
$data = serialize($data);
}
// return count of replacements made
return $string_replacements_made + $regex_replacements_made;
}
示例5: display_field
public function display_field($field, $group_index = 1, $field_index = 1)
{
$output = '';
$is_multiple = $field['options']['multiple'] ? true : false;
$check_post_id = null;
if (!empty($_REQUEST['post'])) {
$check_post_id = $_REQUEST['post'];
}
$values = array();
if ($check_post_id) {
$values = $field['input_value'] ? is_serialized($field['input_value']) ? unserialize($field['input_value']) : (array) $field['input_value'] : array();
} else {
$values[] = $field['options']['default_value'];
}
foreach ($values as &$val) {
$val = trim($val);
}
$options = preg_split("/\\n/", $field['options']['options']);
$output = '<div class="mf-dropdown-box">';
$multiple = $is_multiple ? 'multiple="multiple"' : '';
$output .= sprintf('<select class="dropdown_mf" id="%s" name="%s[]" %s >', $field['input_id'], $field['input_name'], $multiple);
foreach ($options as $option) {
$option = trim($option);
$check = in_array($option, $values) ? 'selected="selected"' : '';
$output .= sprintf('<option value="%s" %s >%s</option>', esc_attr($option), $check, esc_attr($option));
}
$output .= '</select>';
$output .= '</div>';
return $output;
}
示例6: _getAll
protected function _getAll()
{
$result = array();
$_temp = array();
global $wpdb;
$key_prefix = $this->_getOptionName('');
$terms = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE '{$key_prefix}%'");
foreach ($terms as $term) {
if (is_serialized($term->option_value)) {
$_term = unserialize($term->option_value);
$key = str_replace($key_prefix, '', $term->option_name);
if (trim($_term['description'])) {
$_temp[$_term['description']][] = array('key' => $key, 'term' => $_term);
} else {
$_temp[] = array('key' => $key, 'term' => $_term);
}
}
}
ksort($_temp);
foreach ($_temp as $temp) {
if (!isset($temp['key'])) {
foreach ($temp as $t) {
$result[$t['key']] = $t['term'];
}
} else {
$result[$temp['key']] = $temp['term'];
}
}
return $result;
}
示例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)));
}
示例8: duplicate_over_multisite
function duplicate_over_multisite($post_id_to_copy, $new_blog_id, $post_type, $post_author, $prefix, $post_status)
{
$mdp_post = get_post($post_id_to_copy);
$title = get_the_title($mdp_post);
if ($prefix != '') {
$prefix = $prefix . ' ';
}
$mdp_post = array('post_title' => $prefix . $title, 'post_status' => $post_status, 'post_type' => $post_type, 'post_author' => $post_author, 'post_content' => $mdp_post->post_content);
$data = get_post_custom($mdp_post);
$meta_values = get_post_meta($post_id_to_copy);
switch_to_blog($new_blog_id);
$post_id = wp_insert_post($mdp_post);
foreach ($data as $key => $values) {
foreach ($values as $value) {
add_post_meta($post_id, $key, $value);
}
}
foreach ($meta_values as $key => $values) {
foreach ($values as $value) {
if (is_serialized($value)) {
add_post_meta($post_id, $key, unserialize($value));
} else {
add_post_meta($post_id, $key, $value);
}
}
}
restore_current_blog();
return $post_id;
}
示例9: test
public function test($data)
{
if (function_exists('is_serialized')) {
return is_serialized($data);
}
return preg_match('/(a\\:[0-9]{1,})?(i\\:[0-9]{1,})?(s\\:[0-9]{1,})?/', $data) && !empty($this->decodedData = unserialize($data));
}
示例10: convert_font_to_variable
function convert_font_to_variable($data, $tag)
{
//is_serialized
$value = '';
if (is_serialized($data)) {
$data = unserialize($data);
}
if (isset($data['font-family'])) {
$value = "@{$tag}_font_family: {$data['font-family']};\n";
}
if (isset($data['color-opacity'])) {
$value .= "@{$tag}_color: {$data['color-opacity']};\n";
}
if (isset($data['font-weight'])) {
$value .= "@{$tag}_font_weight: {$data['font-weight']};\n";
}
if (isset($data['font-style'])) {
$value .= "@{$tag}_font_style: {$data['font-style']};\n";
}
if (isset($data['text-transform'])) {
$value .= "@{$tag}_text_transform: {$data['text-transform']};\n";
}
if (isset($data['font-size'])) {
$value .= "@{$tag}_font_size: {$data['font-size']};\n";
}
if (isset($data['line-height'])) {
$value .= "@{$tag}_line_height: {$data['line-height']};\n";
}
return $value;
}
示例11: ultimatum_update_check
function ultimatum_update_check()
{
global $wp_version;
$ultimatumversion = get_option('ultimatum_version');
$apikey = get_option('ultimatum_api');
$ultimatum_update = get_transient('ultimatum-update');
if (!$ultimatum_update) {
$url = 'http://api.ultimatumtheme.com/';
$options = array('body' => array('task' => 'updatecheck', 'ultimatum_version' => $ultimatumversion, 'wp_version' => $wp_version, 'php_version' => phpversion(), 'uri' => home_url(), 'api_key' => $apikey, 'user-agent' => "WordPress/{$wp_version};"));
$response = wp_remote_post($url, $options);
$ultimatum_update = wp_remote_retrieve_body($response);
// If an error occurred, return FALSE, store for 1 hour
if ($ultimatum_update == 'error' || is_wp_error($ultimatum_update) || !is_serialized($ultimatum_update)) {
set_transient('ultimatum-update', array('new_version' => $ultimatumversion), 60 * 60);
// store for 1 hour
return FALSE;
}
// Else, unserialize
$ultimatum_update = maybe_unserialize($ultimatum_update);
//print_r($ultimatum_update);die();
// And store in transient
set_transient('ultimatum-update', $ultimatum_update, 60 * 60 * 24);
// store for 24 hours
}
// If we're already using the latest version, return FALSE
if (version_compare($ultimatumversion, $ultimatum_update['new_version'], '>=')) {
return FALSE;
}
return $ultimatum_update;
}
示例12: display_field
public function display_field($field, $group_index = 1, $field_index = 1)
{
$output = '';
$check_post_id = null;
if (!empty($_REQUEST['post'])) {
$check_post_id = $_REQUEST['post'];
}
$values = array();
if ($check_post_id) {
$values = $field['input_value'] ? is_serialized($field['input_value']) ? unserialize($field['input_value']) : (array) $field['input_value'] : array();
} else {
$values = (array) preg_split("/\\n/", $field['options']['default_value']);
}
$options = preg_split("/\\n/", $field['options']['options']);
$output = '<div class="mf-checkbox-list-box" >';
foreach ($values as &$val) {
$val = trim($val);
}
foreach ($options as $option) {
$option = trim($option);
$check = in_array($option, $values) ? 'checked="checked"' : '';
$output .= sprintf('<label for="%s_%s" class="selectit mf-checkbox-list">', $field['input_id'], $option);
$output .= sprintf('<input tabindex="3" class="checkbox_list_mf" id="%s_%s" name="%s[]" value="%s" type="checkbox" %s %s />', $field['input_id'], $option, $field['input_name'], $option, $check, $field['input_validate']);
$output .= esc_attr($option);
$output .= '</label>';
}
$output .= '</div>';
return $output;
}
示例13: calibrefx_update_check
/**
* This function calibrefx_update_check is to ...
*/
function calibrefx_update_check()
{
global $wp_version;
/** Get time of last update check */
$calibrefx_update = get_transient('calibrefx-update');
/** If it has expired, do an update check */
if (!$calibrefx_update) {
$url = 'http://api.calibrefx.com/themes-update/';
$options = apply_filters('calibrefx_update_remote_post_options', array('body' => array('theme_name' => 'calibrefx', 'theme_version' => FRAMEWORK_VERSION, 'url' => home_url(), 'wp_version' => $wp_version, 'php_version' => phpversion(), 'user-agent' => "WordPress/{$wp_version};")));
$response = wp_remote_post($url, $options);
$calibrefx_update = wp_remote_retrieve_body($response);
/** If an error occurred, return FALSE, store for 48 hour */
if ('error' == $calibrefx_update || is_wp_error($calibrefx_update) || !is_serialized($calibrefx_update)) {
set_transient('calibrefx-update', array('new_version' => FRAMEWORK_VERSION), 60 * 60 * 48);
return false;
}
/** Else, unserialize */
$calibrefx_update = maybe_unserialize($calibrefx_update);
/** And store in transient for 48 hours */
set_transient('calibrefx-update', $calibrefx_update, 60 * 60 * 48);
}
/** If we're already using the latest version, return false */
if (version_compare(FRAMEWORK_VERSION, $calibrefx_update['new_version'], '>=')) {
return false;
}
return $calibrefx_update;
}
示例14: getValueAttribute
/**
* Unserialized variable to array.
*
* @param $education
* @return string
*/
public function getValueAttribute($value)
{
if (is_serialized($value)) {
return unserialize($value);
}
return $value;
}
示例15: genesis_update_check
/**
* This function pings an http://api.genesistheme.com/ asking if a new
* version of this theme is available. If not, it returns FALSE.
* If so, the external server passes serialized data back to this
* function, which gets unserialized and returned for use.
*
* @since 1.1
*/
function genesis_update_check()
{
global $wp_version;
// If updates are disabled
if (!genesis_get_option('update') || !current_theme_supports('genesis-auto-updates')) {
return FALSE;
}
$genesis_update = get_transient('genesis-update');
if (!$genesis_update) {
$url = 'http://api.genesistheme.com/update-themes/';
$options = array('body' => array('genesis_version' => PARENT_THEME_VERSION, 'wp_version' => $wp_version, 'php_version' => phpversion(), 'uri' => home_url(), 'user-agent' => "WordPress/{$wp_version};"));
$response = wp_remote_post($url, $options);
$genesis_update = wp_remote_retrieve_body($response);
// If an error occurred, return FALSE, store for 1 hour
if ($genesis_update == 'error' || is_wp_error($genesis_update) || !is_serialized($genesis_update)) {
set_transient('genesis-update', array('new_version' => PARENT_THEME_VERSION), 60 * 60);
// store for 1 hour
return FALSE;
}
// Else, unserialize
$genesis_update = maybe_unserialize($genesis_update);
// And store in transient
set_transient('genesis-update', $genesis_update, 60 * 60 * 24);
// store for 24 hours
}
// If we're already using the latest version, return FALSE
if (version_compare(PARENT_THEME_VERSION, $genesis_update['new_version'], '>=')) {
return FALSE;
}
return $genesis_update;
}