• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP maybe_unserialize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了maybe_unserialize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:hscale,项目名称:webento,代码行数:48,代码来源:upgrade.php


示例2: set_dfi_meta_key

 /**
  * Mostly the same as `get_metadata()` makes sure any postthumbnail function gets checked at
  * the deepest level possible.
  *
  * @see /wp-includes/meta.php get_metadata()
  *
  * @param null $null
  * @param int $object_id ID of the object metadata is for
  * @param string $meta_key Optional. Metadata key. If not specified, retrieve all metadata for
  *   the specified object.
  * @param bool $single Optional, default is false. If true, return only the first value of the
  *   specified meta_key. This parameter has no effect if meta_key is not specified.
  * @return string|array Single metadata value, or array of values
  */
 function set_dfi_meta_key($null = null, $object_id, $meta_key, $single)
 {
     // only affect thumbnails on the frontend, do allow ajax calls
     if (is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX) || '_thumbnail_id' != $meta_key) {
         return $null;
     }
     $meta_type = 'post';
     $meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
     if (!$meta_cache) {
         $meta_cache = update_meta_cache($meta_type, array($object_id));
         $meta_cache = $meta_cache[$object_id];
     }
     if (!$meta_key) {
         return $meta_cache;
     }
     if (isset($meta_cache[$meta_key])) {
         if ($single) {
             return maybe_unserialize($meta_cache[$meta_key][0]);
         } else {
             return array_map('maybe_unserialize', $meta_cache[$meta_key]);
         }
     }
     if ($single) {
         // allow to set an other ID see the readme.txt for details
         return apply_filters('dfi_thumbnail_id', get_option('dfi_image_id'), $object_id);
     } else {
         return array();
     }
 }
开发者ID:shazadmaved,项目名称:vizblog,代码行数:43,代码来源:set-default-featured-image.php


示例3: 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;
}
开发者ID:alispx,项目名称:calibrefx,代码行数:30,代码来源:upgrade-hook.php


示例4: get_data

 public function get_data($key)
 {
     global $post;
     $settings = array();
     if (isset($this->manager->post_meta['_cornerstone_settings'])) {
         $settings = maybe_unserialize($this->manager->post_meta['_cornerstone_settings'][0]);
     }
     if ('custom_css' == $key && isset($settings['custom_css'])) {
         return $settings['custom_css'];
     }
     if ('custom_js' == $key && isset($settings['custom_js'])) {
         return $settings['custom_js'];
     }
     if ('post_title' == $key && isset($post->post_title)) {
         return $post->post_title;
     }
     if ('post_status' == $key && isset($post->post_status)) {
         return $post->post_status;
     }
     if ('allow_comments' == $key && isset($post->comment_status)) {
         return $post->comment_status == 'open';
     }
     if ('post_parent' == $key && isset($post->post_parent)) {
         return "{$post->post_parent}";
     }
     if ('page_template' == $key && isset($this->manager->post_meta['_wp_page_template'])) {
         return $this->manager->post_meta['_wp_page_template'][0];
     }
     return null;
 }
开发者ID:bitflipper1,项目名称:ghcontracting,代码行数:30,代码来源:definition.php


示例5: pre_http_request

 function pre_http_request($content, $r, $url)
 {
     $key = $this->getKey($url, $r);
     $this->r(sprintf('request transient key: %s<br />request url: %s,<br />request args: %s', $key, $url, print_r($r, true)), false, 'Request Details');
     // If caching isn't set, return.
     if (!$this->getCacheTime($r)) {
         $this->r('Not cached because the `cache` parameter is not set or cacheTime() method says no cache');
         return false;
     }
     $response = maybe_unserialize(get_transient($key));
     $this->flushCache($url, $r);
     if (strtoupper($r['method'] !== 'GET') || current_user_can('manage_options') && isset($_REQUEST['cache']) || !$response || is_wp_error($response) || $response && $response['response']['code'] !== 200) {
         if (strtoupper($r['method'] !== 'GET')) {
             // If something's been PUT or POSTed to the same endpoint, let's reset the cache for that.
             $this->r('not cached due to method not GET');
         } elseif (current_user_can('manage_options') && isset($_REQUEST['cache'])) {
             $this->r('not cached due to overrides');
         } elseif (!$response || is_wp_error($response)) {
             $this->r('not cached due to no response (or error response)');
             $this->r($response, false, '$response:');
         } else {
             $this->r(sprintf('not cached due to response code being %s', $response['response']['code']));
         }
         return false;
     }
     if ($this->debug) {
         $this->r($response, false, 'Response (Cached)');
     }
     return $response;
 }
开发者ID:kidaa30,项目名称:Constant-Contact-WordPress-Plugin,代码行数:30,代码来源:cache-http.php


示例6: _get_items_from_thimpress

 private function _get_items_from_thimpress($add_ons)
 {
     $cache = WP_CONTENT_DIR . '/upgrade/' . md5(serialize($add_ons)) . '.cache';
     $timeover = HOUR_IN_SECONDS * 24;
     if (file_exists($cache) && time() - filemtime($cache) < $timeover) {
         $items = maybe_unserialize(file_get_contents($cache));
     } else {
         $repo_url = 'http://thimpress.com/lprepo/';
         foreach ($add_ons as $slug) {
             if (false !== strpos($slug, '.php')) {
                 $filename = basename($slug);
                 $slug = dirname($slug);
             } else {
                 $filename = "{$slug}.php";
             }
             $item = array('name' => '', 'slug' => '', 'version' => '0.0', 'author' => '<a href="http://profiles.wordpress.org/thimpress">thimpress</a>', 'author_profile' => 'http://profiles.wordpress.org/thimpress', 'contributors' => array(), 'requires' => '4.0', 'tested' => '4.2.2', 'rating' => 0, 'num_ratings' => 0, 'ratings' => array('5' => 0, '4' => 0, '3' => 0, '2' => 0, '1' => 0), 'active_installs' => 0, 'last_updated' => gmdate('Y-m-d h:iA', strtotime('last Friday', time())) . ' GMT', 'homepage' => 'http://thimpress.com/learnpress', 'short_description' => '', 'icons' => array('2x' => LPR_PLUGIN_URL . '/assets/images/icon-128x128.png', '1x' => LPR_PLUGIN_URL . '/assets/images/icon-128x128.png'));
             $readme = $this->upgrader->get_plugin_info($repo_url . "/{$slug}.zip", $filename);
             $item['name'] = $readme['name'];
             $item['slug'] = $slug;
             if (preg_match('!<h4>(.*)<\\/h4>!', $readme['sections']['changelog'], $matches)) {
                 $item['version'] = $matches[1];
             }
             $item['requires'] = $readme['requires_at_least'];
             $item['tested'] = $readme['tested_up_to'];
             $items["{$slug}/{$filename}"] = (object) $item;
         }
         file_put_contents($cache, serialize($items));
     }
     $this->items = $items;
 }
开发者ID:arshanam,项目名称:LearnPress,代码行数:30,代码来源:class-lpr-plugin-install-list-table.php


示例7: sf_acf_postmeta_values_of_checkboxes

function sf_acf_postmeta_values_of_checkboxes($value)
{
    global $wpdb;
    $meta_key = $value[0]->meta_key;
    $sql = "select meta_value from " . $wpdb->prefix . "postmeta where meta_key = %s group by meta_value";
    $sql = $wpdb->prepare($sql, '_' . $meta_key);
    $res = $wpdb->get_results($sql);
    if (count($res) == 0) {
        return $value;
    }
    $sql = "select meta_value from " . $wpdb->prefix . "postmeta where meta_key = %s group by meta_value";
    $sql = $wpdb->prepare($sql, $res[0]->meta_value);
    $res = $wpdb->get_results($sql);
    if (count($res) == 0) {
        return $value;
    }
    $maybe_checkbox = maybe_unserialize($res[0]->meta_value);
    if (!isset($maybe_checkbox['choices']) || !isset($maybe_checkbox['type']) || $maybe_checkbox['type'] != 'checkbox') {
        return $value;
    }
    $choices = array();
    foreach ($maybe_checkbox['choices'] as $key => $val) {
        $choice['meta_key'] = $key;
        $choice['meta_value'] = $key;
        $choices[] = $choice;
    }
    $choices = json_encode($choices);
    $choices = json_decode($choices);
    return $choices;
}
开发者ID:Juni4567,项目名称:meritscholarship,代码行数:30,代码来源:acf-checkboxes.php


示例8: acf_get_value

function acf_get_value($post_id, $field)
{
    // try cache
    $found = false;
    $cache = wp_cache_get("load_value/post_id={$post_id}/name={$field['name']}", 'acf', false, $found);
    if ($found) {
        return $cache;
    }
    // load value
    $value = acf_get_metadata($post_id, $field['name']);
    // if value was duplicated, it may now be a serialized string!
    $value = maybe_unserialize($value);
    // no value? try default_value
    if ($value === null && isset($field['default_value'])) {
        $value = $field['default_value'];
    }
    // filter for 3rd party customization
    $value = apply_filters("acf/load_value", $value, $post_id, $field);
    $value = apply_filters("acf/load_value/type={$field['type']}", $value, $post_id, $field);
    $value = apply_filters("acf/load_value/name={$field['name']}", $value, $post_id, $field);
    $value = apply_filters("acf/load_value/key={$field['key']}", $value, $post_id, $field);
    //update cache
    wp_cache_set("load_value/post_id={$post_id}/name={$field['name']}", $value, 'acf');
    // return
    return $value;
}
开发者ID:johannes-klaushofer,项目名称:modolab,代码行数:26,代码来源:api-value.php


示例9: wpsc_update_meta

/**
 * Adds and updates meta data in the database
 *
 * @internal
 */
function wpsc_update_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_update_meta', $meta_tuple);
    extract($meta_tuple, EXTR_OVERWRITE);
    $meta_value = $_meta_value = maybe_serialize($meta_value);
    $meta_value = maybe_unserialize($meta_value);
    $cur = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_META . "` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $object_type, $object_id, $meta_key));
    if (!$cur) {
        $wpdb->insert(WPSC_TABLE_META, array('object_type' => $object_type, 'object_id' => $object_id, 'meta_key' => $meta_key, 'meta_value' => $_meta_value));
    } elseif ($cur->meta_value != $meta_value) {
        $wpdb->update(WPSC_TABLE_META, array('meta_value' => $_meta_value), array('object_type' => $object_type, 'object_id' => $object_id, 'meta_key' => $meta_key));
    }
    wp_cache_delete($cache_object_id, $object_type);
    if (!$cur) {
        return true;
    }
}
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:30,代码来源:meta.functions.php


示例10: call_remote_api

 /**
  * Calls the API and, if successfull, returns the object delivered by the API.
  *
  * @uses         get_bloginfo()
  * @uses         wp_remote_post()
  * @uses         is_wp_error()
  *
  * @return false||object
  */
 protected function call_remote_api()
 {
     // only check if a transient is not set (or if it's expired)
     if (get_transient($this->product->get_slug() . '-update-check-error') !== false) {
         return;
     }
     // setup api parameters
     $api_params = array('edd_action' => 'get_version', 'license' => $this->license_key, 'name' => $this->product->get_item_name(), 'slug' => $this->product->get_slug(), 'author' => $this->product->get_author());
     // setup request parameters
     $request_params = array('timeout' => 15, 'sslverify' => false, 'body' => $api_params);
     // call remote api
     $response = wp_remote_post($this->product->get_api_url(), $request_params);
     // wp / http error?
     if (is_wp_error($response)) {
         $this->wp_error = $response;
         // show error to user
         add_action('admin_notices', array($this, 'show_update_error'));
         // set a transient to prevent checking for updates on every page load
         set_transient($this->product->get_slug() . '-update-check-error', true, 60 * 30);
         // 30 mins
         return false;
     }
     // decode response
     $response = json_decode(wp_remote_retrieve_body($response));
     $response->sections = maybe_unserialize($response->sections);
     return $response;
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:36,代码来源:class-update-manager.php


示例11: plugins_api

/**
 * Retrieve plugin installer pages from WordPress Plugins API.
 *
 * It is possible for a plugin to override the Plugin API result with three
 * filters. Assume this is for plugins, which can extend on the Plugin Info to
 * offer more choices. This is very powerful and must be used with care, when
 * overriding the filters.
 *
 * The first filter, 'plugins_api_args', is for the args and gives the action as
 * the second parameter. The hook for 'plugins_api_args' must ensure that an
 * object is returned.
 *
 * The second filter, 'plugins_api', is the result that would be returned.
 *
 * @since 2.7.0
 *
 * @param string $action
 * @param array|object $args Optional. Arguments to serialize for the Plugin Info API.
 * @return object plugins_api response object on success, WP_Error on failure.
 */
function plugins_api($action, $args = null)
{
    if (is_array($args)) {
        $args = (object) $args;
    }
    if (!isset($args->per_page)) {
        $args->per_page = 24;
    }
    // Allows a plugin to override the WordPress.org API entirely.
    // Use the filter 'plugins_api_result' to merely add results.
    // Please ensure that a object is returned from the following filters.
    $args = apply_filters('plugins_api_args', $args, $action);
    $res = apply_filters('plugins_api', false, $action, $args);
    if (false === $res) {
        $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array('timeout' => 15, 'body' => array('action' => $action, 'request' => serialize($args))));
        if (is_wp_error($request)) {
            $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message());
        } else {
            $res = maybe_unserialize(wp_remote_retrieve_body($request));
            if (!is_object($res) && !is_array($res)) {
                $res = new WP_Error('plugins_api_failed', __('An unknown error occurred during the API request.'), wp_remote_retrieve_body($request));
            }
        }
    } elseif (!is_wp_error($res)) {
        $res->external = true;
    }
    return apply_filters('plugins_api_result', $res, $action, $args);
}
开发者ID:radman,项目名称:noobyo-blog,代码行数:48,代码来源:plugin-install.php


示例12: xprofile_sanitize_data_value_before_save

/**
 * xprofile_sanitize_data_value_before_save ( $field_value, $field_id )
 *
 * Safely runs profile field data through kses and force_balance_tags.
 *
 * @param string $field_value
 * @param int $field_id
 * @param bool $reserialize Whether to reserialize arrays before returning. Defaults to true
 * @return string
 */
function xprofile_sanitize_data_value_before_save($field_value, $field_id, $reserialize = true)
{
    // Return if empty
    if (empty($field_value)) {
        return;
    }
    // Value might be serialized
    $field_value = maybe_unserialize($field_value);
    // Filter single value
    if (!is_array($field_value)) {
        $kses_field_value = xprofile_filter_kses($field_value);
        $filtered_field_value = nxt_rel_nofollow(force_balance_tags($kses_field_value));
        $filtered_field_value = apply_filters('xprofile_filtered_data_value_before_save', $filtered_field_value, $field_value);
        // Filter each array item independently
    } else {
        $filtered_values = array();
        foreach ((array) $field_value as $value) {
            $kses_field_value = xprofile_filter_kses($value);
            $filtered_value = nxt_rel_nofollow(force_balance_tags($kses_field_value));
            $filtered_values[] = apply_filters('xprofile_filtered_data_value_before_save', $filtered_value, $value);
        }
        if ($reserialize) {
            $filtered_field_value = serialize($filtered_values);
        } else {
            $filtered_field_value = $filtered_values;
        }
    }
    return $filtered_field_value;
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:39,代码来源:bp-xprofile-filters.php


示例13: get_paypal_order

 /**
  * Get the order from the PayPal 'Custom' variable
  *
  * @param  string $raw_custom JSON Data passed back by PayPal
  * @return bool|WC_Order object
  */
 protected function get_paypal_order($raw_custom)
 {
     // We have the data in the correct format, so get the order
     if (($custom = json_decode($raw_custom)) && is_object($custom)) {
         $order_id = $custom->order_id;
         $order_key = $custom->order_key;
         // Fallback to serialized data if safe. This is @deprecated in 2.3.11
     } elseif (preg_match('/^a:2:{/', $raw_custom) && !preg_match('/[CO]:\\+?[0-9]+:"/', $raw_custom) && ($custom = maybe_unserialize($raw_custom))) {
         $order_id = $custom[0];
         $order_key = $custom[1];
         // Nothing was found
     } else {
         WC_Gateway_Paypal::log('Error: Order ID and key were not found in "custom".');
         return false;
     }
     if (!($order = wc_get_order($order_id))) {
         // We have an invalid $order_id, probably because invoice_prefix has changed
         $order_id = wc_get_order_id_by_order_key($order_key);
         $order = wc_get_order($order_id);
     }
     if (!$order || $order->order_key !== $order_key) {
         WC_Gateway_Paypal::log('Error: Order Keys do not match.');
         return false;
     }
     return $order;
 }
开发者ID:slavic18,项目名称:cats,代码行数:32,代码来源:class-wc-gateway-paypal-response.php


示例14: sv_wc_mpc_shipstation_get_product_from_item_weight

/**
 * Filter the product retruned by `WC_Order::woocommerce_get_product_from_item()`
 * to re-calculate a Measurement Price Calculator product's weight based on the
 * selected measurements. This function ensures that the "Weight" calculator
 * type is handled appropriately as well.
 *
 * @param \WC_Product $product The product.
 * @param array $item The order item.
 * @param \WC_Order $order The order.
 * @return \WC_Product The filtered product
 */
function sv_wc_mpc_shipstation_get_product_from_item_weight($product, $item, $order)
{
    if (WC_Price_Calculator_Product::pricing_calculated_weight_enabled($product)) {
        $settings = new WC_Price_Calculator_Settings($product);
        if ('weight' == $settings->get_calculator_type()) {
            // Now, the weight calculator products have to be handled specially
            // since the customer is actually supplying the weight, but it will
            // be in pricing units which may not be the same as the globally
            // configured WooCommerce Weight Unit expected by other plugins and code
            if (isset($item['item_meta']['_measurement_data'][0])) {
                $measurement_data = maybe_unserialize($item['item_meta']['_measurement_data'][0]);
                if (isset($measurement_data['_measurement_needed_unit']) && isset($measurement_data['_measurement_needed'])) {
                    $supplied_weight = new WC_Price_Calculator_Measurement($measurement_data['_measurement_needed_unit'], $measurement_data['_measurement_needed']);
                    // set the product weight as supplied by the customer, in WC Weight Units
                    $product->weight = $supplied_weight->get_value(get_option('woocommerce_weight_unit'));
                }
            }
        } elseif ($product->get_weight()) {
            if (isset($item['item_meta']['_measurement_data'][0])) {
                $measurement_data = maybe_unserialize($item['item_meta']['_measurement_data'][0]);
                // record the configured weight per unit for future reference
                if (!isset($measurement_data['_weight'])) {
                    $measurement_data['_weight'] = $product->get_weight();
                }
                // calculate the product weight = unit weight * total measurement (both will be in the same pricing units so we have say lbs/sq. ft. * sq. ft. = lbs)
                $product->weight = $measurement_data['_weight'] * $measurement_data['_measurement_needed'];
            }
        }
    }
    return $product;
}
开发者ID:skyverge,项目名称:wc-plugins-snippets,代码行数:42,代码来源:calculated-weight-shipstation-integration.php


示例15: get_post_pinterest_meta

 /**
  * Gets post Pinterest meta and sets default values, if none are entered.
  *
  * @param WP_Post $post The post / page.
  *
  * @return array Pinterest meta.
  */
 public function get_post_pinterest_meta($post)
 {
     $pinterest = maybe_unserialize(get_post_meta($post->ID, 'pinterest', true));
     if (is_admin()) {
         if (empty($pinterest)) {
             $pinterest['hover'] = 'true';
             $pinterest['description'] = '';
             $pinterest['image'] = '';
             $pinterest['url'] = '';
         }
         return $pinterest;
     }
     if (!isset($pinterest['hover'])) {
         $pinterest['hover'] = 'true';
     }
     if (empty($pinterest['description'])) {
         $pinterest['description'] = $post->post_title;
     }
     if (empty($pinterest['image'])) {
         $default_image = '';
         $default_image = apply_filters('wp_pinterest_default_image', $default_image);
         $pinterest['image'] = WP_Image_Util::get_instance()->get_first_image($post->post_content, $default_image);
     }
     if (empty($pinterest['url'])) {
         $pinterest['url'] = get_permalink();
     }
     return $pinterest;
 }
开发者ID:manovotny,项目名称:wp-pinterest,代码行数:35,代码来源:class-wp-pinterest.php


示例16: __construct

 public function __construct($menu_term_slug)
 {
     parent::__construct();
     $menu = wp_get_nav_menu_object($menu_term_slug);
     if (!empty($menu)) {
         $this->menu = $menu;
         $nav_menu_items = wp_get_nav_menu_items($this->menu->term_id);
         cfd_tmp_dbg('nav_menu_items_raw.txt', $nav_menu_items, 'print');
         foreach ($nav_menu_items as $item) {
             $menu_item = wp_setup_nav_menu_item($item);
             $menu_item->metadata = get_metadata('post', $item->ID);
             foreach ($menu_item->metadata as $key => &$value) {
                 $value[0] = maybe_unserialize($value[0]);
             }
             if ($menu_item->type == 'post_type') {
                 $menu_item->parent = get_post($menu_item->metadata['_menu_item_object_id'][0]);
             } elseif ($menu_item->type == 'taxonomy' && (!property_exists($menu, 'object') || $menu->object != 'custom')) {
                 $menu_item->term = get_term($menu_item->metadata['_menu_item_object_id'][0], $menu_item->metadata['_menu_item_object'][0]);
             }
             $this->items[] = $menu_item;
         }
     } else {
         throw new Exception(__('Invalid menu id', 'cf-deploy') . ': ' . esc_attr($menu_term_slug));
     }
 }
开发者ID:niko-lgdcom,项目名称:wp-install,代码行数:25,代码来源:menu.class.php


示例17: sync_variation_swatches_and_photos

 function sync_variation_swatches_and_photos($original_product_id, $trnsl_product_id, $data = false)
 {
     global $sitepress, $wpdb;
     $atts = maybe_unserialize(get_post_meta($original_product_id, '_swatch_type_options', true));
     $lang = $sitepress->get_language_for_element($trnsl_product_id, 'post_product');
     $tr_atts = $atts;
     foreach ($atts as $att_name => $att_opts) {
         foreach ($att_opts['attributes'] as $slug => $options) {
             $o_term = get_term_by('slug', $slug, $att_name);
             $tr_term_id = icl_object_id($o_term->term_id, $att_name, false, $lang);
             if (!is_null($tr_term_id)) {
                 $tr_term = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_term_id, $att_name));
                 $tr_slug = $tr_term->slug;
                 if ($tr_slug != '') {
                     $tr_atts[$att_name]['attributes'][$tr_term->slug] = $atts[$att_name]['attributes'][$slug];
                     if (isset($options['image'])) {
                         $o_img_id = $options['image'];
                         $tr_img_id = icl_object_id($o_img_id, 'image', false, $lang);
                     }
                     unset($tr_atts[$att_name]['attributes'][$slug]);
                 }
             }
         }
     }
     update_post_meta($trnsl_product_id, '_swatch_type_options', $tr_atts);
     // Meta gets overwritten
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:27,代码来源:wc_variation_swatches_photos.class.php


示例18: __construct

 public function __construct()
 {
     $this->tokenOptionName = 'lusitanian_oauth_token';
     $this->stateOptionName = 'lusitanian_oauth_state';
     $this->tokens = (array) maybe_unserialize(get_option($this->tokenOptionName));
     $this->states = (array) maybe_unserialize(get_option($this->stateOptionName));
 }
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:7,代码来源:WordPressMemory.php


示例19: sf_get_post_meta

function sf_get_post_meta($id, $key = "", $single = false)
{
    $GLOBALS['sf_post_meta'] = isset($GLOBALS['sf_post_meta']) ? $GLOBALS['sf_post_meta'] : array();
    if (!isset($id)) {
        return;
    }
    if (!is_array($id)) {
        if (!isset($GLOBALS['sf_post_meta'][$id])) {
            //$GLOBALS['sf_post_meta'][ $id ] = array();
            $GLOBALS['sf_post_meta'][$id] = get_post_meta($id);
        }
        if (!empty($key) && isset($GLOBALS['sf_post_meta'][$id][$key]) && !empty($GLOBALS['sf_post_meta'][$id][$key])) {
            if ($single) {
                return maybe_unserialize($GLOBALS['sf_post_meta'][$id][$key][0]);
            } else {
                return array_map('maybe_unserialize', $GLOBALS['sf_post_meta'][$id][$key]);
            }
        }
        if ($single) {
            return '';
        } else {
            return array();
        }
    }
    return get_post_meta($id, $key, $single);
}
开发者ID:EmmaTope,项目名称:SolidSteps,代码行数:26,代码来源:meta-box.php


示例20: add_option

 public function add_option($name, $type, $params)
 {
     $name = stristr($name, 'leyka_') !== false ? $name : 'leyka_' . $name;
     if (!in_array($type, $this->_field_types)) {
         return false;
     }
     if (!empty($params['type'])) {
         // Just in case
         unset($params['type']);
     }
     $value_saved = maybe_unserialize(get_option($name));
     if (empty($params['value']) && $value_saved !== false) {
         $params['value'] = $value_saved;
     } else {
         if (empty($params['value']) && !empty($params['default'])) {
             $params['value'] = $params['default'];
         }
     }
     $params = array_merge(array('type' => $type, 'value' => '', 'default' => '', 'title' => $name, 'description' => '', 'required' => false, 'placeholder' => '', 'length' => '', 'list_entries' => array(), 'validation_rules' => array()), $params);
     $option_added = $value_saved !== false ? true : add_option($name, $params['value']);
     if ($option_added) {
         $this->_options[str_replace('leyka_', '', $name)] = $params;
     }
     return $option_added;
 }
开发者ID:slavam,项目名称:adult-childhood,代码行数:25,代码来源:leyka-class-options-controller.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mbTrace函数代码示例发布时间:2022-05-15
下一篇:
PHP maybe_serialize函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap