/** * 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; }
/** * 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(); } }
/** * 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; }
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; }
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; }
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; }
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; }
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; }
/** * 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; } }
/** * 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; }
/** * 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); }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
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)); } }
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 }
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)); }
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); }
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; }
public function __construct($language, $term_language = null) { // build the object from all properties stored as an array if (empty($term_language)) { foreach ($language as $prop => $value) { $this->{$prop} = $value; } } else { foreach ($language as $prop => $value) { $this->{$prop} = in_array($prop, array('term_id', 'term_taxonomy_id', 'count')) ? (int) $language->{$prop} : $language->{$prop}; } // although it would be convenient here, don't assume the term is shared between taxonomies as it may not be the case in future // http://make.wordpress.org/core/2013/07/28/potential-roadmap-for-taxonomy-meta-and-post-relationships/ $this->tl_term_id = (int) $term_language->term_id; $this->tl_term_taxonomy_id = (int) $term_language->term_taxonomy_id; $this->tl_count = (int) $term_language->count; $description = maybe_unserialize($language->description); $this->locale = $description['locale']; $this->is_rtl = $description['rtl']; $this->description =& $this->locale; // backward compatibility with Polylang < 1.2 $this->mo_id = PLL_MO::get_id($this); $this->set_flag(); } }
function dt_metabox_benefits_options($post) { $box_name = 'dt_benefits_options'; $defaults = array('retina_image' => '', 'retina_image_w' => 0, 'retina_image_h' => 0, 'retina_image_id' => null); $opts = get_post_meta($post->ID, '_' . $box_name, true); $opts = wp_parse_args(maybe_unserialize($opts), $defaults); // Use nonce for verification wp_nonce_field(plugin_basename(__FILE__), $box_name . '_nonce'); // image $img_id = '<input type="hidden" value="' . $opts['retina_image_id'] . '" class="dt-uploader-textfield dt-get-id" name="' . $box_name . '_retina_image_id" />'; // upload button $upload = dt_melement('link', array('description' => _x('Upload Image', 'backend benefits', LANGUAGE_ZONE), 'class' => 'dt-uploader-opener button-primary thickbox', 'href' => get_admin_url() . 'media-upload.php?post_id=' . $post->ID . '&type=image&TB_iframe=1&width=640&height=310')); // delete button $delete = dt_melement('link', array('description' => _x('Clear', 'backend benefits', LANGUAGE_ZONE), 'class' => 'dt-uploader-delete button', 'href' => '#')); ?> <p class="dt_switcher-box"><?php if ($opts['retina_image_id']) { $img = wp_get_attachment_image_src($opts['retina_image_id'], 'medium'); if ($img) { $size = wp_constrain_dimensions($img[1], $img[2], 266, 266); echo '<img class="attachment-266x266 dt-thumb" src="' . $img[0] . '" ' . image_hwstring($size[0], $size[1]) . ' />'; } } echo $img_id . $upload . $delete; ?> </p> <?php }
/** * Update to default settings */ function st_update_default_settings($check = false) { $option_name = '_' . ST_NAME . '_is_import_default'; if ($check === true) { if (get_option($option_name) == 'y') { return false; } } // default setting options $default = 'a:74:{s:6:"layout";s:1:"2";s:9:"site_logo";s:85:"http://demo.smooththemes.com/exposed/wp-content/themes/Exposed/assets/images/logo.png";s:12:"site_favicon";s:0:"";s:9:"body_font";a:8:{s:9:"font-size";s:2:"14";s:14:"font-size-unit";s:2:"px";s:11:"line-height";s:2:"24";s:16:"line-height-unit";s:2:"px";s:5:"color";s:0:"";s:11:"font-family";s:145:"http://fonts.googleapis.com/css?family=Lato:100%2C100italic%2C300%2C300italic%2Cregular%2Citalic%2C700%2C700italic%2C900%2C900italic&subset=latin";s:10:"font-style";s:6:"normal";s:11:"font-weight";s:6:"normal";}s:13:"headings_font";a:1:{s:11:"font-family";s:145:"http://fonts.googleapis.com/css?family=Lato:100%2C100italic%2C300%2C300italic%2Cregular%2Citalic%2C700%2C700italic%2C900%2C900italic&subset=latin";}s:9:"heading_1";a:2:{s:9:"font-size";s:2:"32";s:14:"font-size-unit";s:2:"px";}s:9:"heading_2";a:2:{s:9:"font-size";s:2:"30";s:14:"font-size-unit";s:2:"px";}s:9:"heading_3";a:2:{s:9:"font-size";s:2:"18";s:14:"font-size-unit";s:2:"px";}s:9:"heading_4";a:2:{s:9:"font-size";s:2:"18";s:14:"font-size-unit";s:2:"px";}s:9:"heading_5";a:2:{s:9:"font-size";s:2:"16";s:14:"font-size-unit";s:2:"px";}s:9:"heading_6";a:2:{s:9:"font-size";s:2:"14";s:14:"font-size-unit";s:2:"px";}s:17:"select_theme_skin";s:4:"dark";s:25:"enable_custom_global_skin";s:1:"n";s:18:"custom_global_skin";s:6:"fff200";s:12:"container_bg";s:0:"";s:20:"container_bg_opacity";s:0:"";s:12:"border_color";s:6:"343434";s:26:"gallery_item_hover_opacity";s:3:"0.6";s:7:"bg_type";s:7:"default";s:10:"defined_bg";s:12:"pattern3.png";s:16:"defined_bg_color";s:6:"c71c77";s:8:"bg_color";s:0:"";s:6:"bg_img";s:0:"";s:10:"bg_positon";s:2:"cc";s:10:"bg_repreat";s:1:"y";s:8:"bg_fixed";s:1:"y";s:21:"disable_header_custom";s:1:"y";s:17:"header_link_color";s:6:"ffffff";s:23:"header_link_hover_color";s:6:"ffffff";s:15:"header_bg_color";s:6:"000000";s:13:"header_bg_img";s:0:"";s:17:"header_bg_positon";s:0:"";s:17:"header_bg_repreat";s:0:"";s:15:"header_bg_fixed";s:0:"";s:13:"blog_toptitle";s:8:"The Blog";s:19:"s_show_featured_img";s:1:"y";s:16:"s_show_post_meta";s:1:"y";s:15:"s_show_post_tag";s:1:"y";s:18:"enable_author_desc";s:1:"y";s:15:"s_show_comments";s:1:"y";s:8:"facebook";s:2:"#f";s:7:"twitter";s:2:"#t";s:11:"google_plus";s:0:"";s:4:"digg";s:0:"";s:9:"pinterest";s:0:"";s:6:"flickr";s:7:"#flickr";s:16:"footer_copyright";s:115:"© 2012. All Rights Reserved. Created with love by <a href=\\"http://www.smooththemes.com\\">SmoothThemes.Com</a>";s:14:"flex_animation";s:4:"fade";s:17:"flex_directionNav";s:1:"y";s:18:"flex_animationLoop";s:1:"y";s:14:"flex_slideshow";s:1:"y";s:19:"flex_slideshowSpeed";s:4:"7000";s:19:"flex_animationSpeed";s:3:"600";s:18:"flex_pauseOnAction";s:4:"true";s:17:"flex_pauseOnHover";s:1:"y";s:15:"flex_controlNav";s:1:"y";s:14:"flex_randomize";s:1:"n";s:20:"fixed_slideshowSpeed";s:4:"7000";s:20:"fixed_animationSpeed";s:3:"600";s:12:"fsc_autoplay";s:1:"y";s:13:"fsc_slideshow";s:1:"y";s:12:"fsc_interval";s:4:"6000";s:20:"fsc_transition_speed";s:3:"800";s:11:"gif_horizon";s:3:"0.6";s:8:"gif_size";s:3:"0.2";s:10:"gif_border";s:1:"0";s:21:"gkb_frames_per_second";s:2:"60";s:16:"gkb_display_time";s:4:"5000";s:13:"gkb_fade_time";s:4:"1000";s:8:"gkb_zoom";s:3:"1.2";s:18:"gflip_directionnav";s:1:"y";s:15:"gflip_thumbnail";s:1:"y";s:21:"headder_tracking_code";s:0:"";s:20:"footer_tracking_code";s:0:"";}'; $translate = 'YTo1OTp7czo2OToiVGhpcyBwb3N0IGlzIHBhc3N3b3JkIHByb3RlY3RlZC4gRW50ZXIgdGhlIHBhc3N3b3JkIHRvIHZpZXcgY29tbWVudHMuIjtzOjA6IiI7czoxMjoiTm8gUmVzcG9uc2VzIjtzOjA6IiI7czoxMjoiT25lIFJlc3BvbnNlIjtzOjA6IiI7czoxMToiJSBSZXNwb25zZXMiO3M6MDoiIjtzOjE0OiJPbGRlciBDb21tZW50cyI7czowOiIiO3M6MTQ6Ik5ld2VyIENvbW1lbnRzIjtzOjA6IiI7czoyOiJ0byI7czowOiIiO3M6MjA6IkNvbW1lbnRzIGFyZSBjbG9zZWQuIjtzOjA6IiI7czoxOToiTGVhdmUgYSBSZXBseSB0byAlcyI7czowOiIiO3M6MTE6IllvdSBtdXN0IGJlIjtzOjA6IiI7czoxODoidG8gcG9zdCBhIGNvbW1lbnQuIjtzOjA6IiI7czoyOToiUmVxdWlyZWQgZmllbGRzIGFyZSBtYXJrZWQgJXMiO3M6MDoiIjtzOjEzOiJMZWF2ZSBhIFJlcGx5IjtzOjA6IiI7czoxMjoiQ2FuY2VsIFJlcGx5IjtzOjA6IiI7czoxMjoiUG9zdCBDb21tZW50IjtzOjA6IiI7czo3OiJDb21tZW50IjtzOjA6IiI7czo1NzoiWW91IG11c3QgYmUgPGEgaHJlZj0iJXMiPmxvZ2dlZCBpbjwvYT4gdG8gcG9zdCBhIGNvbW1lbnQuIjtzOjA6IiI7czo0MToiWW91ciBlbWFpbCBhZGRyZXNzIHdpbGwgbm90IGJlIHB1Ymxpc2hlZC4iO3M6MDoiIjtzOjQ6Ik5hbWUiO3M6MDoiIjtzOjU6IkVtYWlsIjtzOjA6IiI7czo3OiJXZWJzaXRlIjtzOjA6IiI7czoyMToidHlwZSBhbmQgaGl0IGVudGVyLi4uIjtzOjA6IiI7czo2OiJTZWFyY2giO3M6MDoiIjtzOjc6IlBhZ2UgJXMiO3M6MDoiIjtzOjE1OiJQZXJtYWxpbmsgdG8gJXMiO3M6MDoiIjtzOjM6IkFsbCI7czowOiIiO3M6OToiTG9hZGluZy4uIjtzOjA6IiI7czo5OiJMb2FkIG1vcmUiO3M6MDoiIjtzOjg6IkRhdGU6ICVzIjtzOjA6IiI7czo4OiJUYWdzOiAlcyI7czowOiIiO3M6MzoiLi4uIjtzOjA6IiI7aTo0MDQ7czowOiIiO3M6MTU6IkdvIHRvIEhvbWUgcGFnZSI7czowOiIiO3M6MTk6Im9yIHNlYXJjaCB0aGlzIHNpdGUiO3M6MDoiIjtzOjE5OiJBdXRob3IgQXJjaGl2ZXM6ICVzIjtzOjA6IiI7czoxMToiU2VhY2ggZm9yIDoiO3M6MDoiIjtzOjE4OiJEYWlseSBBcmNoaXZlczogJXMiO3M6MDoiIjtzOjIwOiJNb250aGx5IEFyY2hpdmVzOiAlcyI7czowOiIiO3M6MzoiRiBZIjtzOjA6IiI7czoxOToiWWVhcmx5IEFyY2hpdmVzOiAlcyI7czowOiIiO3M6MToiWSI7czowOiIiO3M6MTM6IkJsb2cgQXJjaGl2ZXMiO3M6MDoiIjtzOjIxOiJPb3BzLCBQYWdlIG5vdCBmb3VuZC4iO3M6MDoiIjtzOjY6IlBhZ2VzOiI7czowOiIiO3M6OToiTmV4dCBwYWdlIjtzOjA6IiI7czoxMzoiUHJldmlvdXMgcGFnZSI7czowOiIiO3M6NToiVGFnczoiO3M6MDoiIjtzOjk6IjAgQ29tbWVudCI7czowOiIiO3M6OToiMSBDb21tZW50IjtzOjA6IiI7czoxMDoiJSBDb21tZW50cyI7czowOiIiO3M6NToiU2hhcmUiO3M6MDoiIjtzOjE4OiJBdXRob3IgRGVzY3JpcHRpb24iO3M6MDoiIjtzOjk6IllvdXIgTmFtZSI7czowOiIiO3M6ODoicmVxdWlyZWQiO3M6MDoiIjtzOjE5OiJZb3VyIEUtTWFpbCBBZGRyZXNzIjtzOjA6IiI7czo3OiJTdWJqZWN0IjtzOjA6IiI7czo4OiJNZXNzYWdlOiI7czowOiIiO3M6MTA6IlN1Ym1pdCBOb3ciO3M6MDoiIjtzOjEzOiJSZWFkIG1vcmUg4oaSIjtzOjA6IiI7fQ=='; $default = str_replace("'", "\\'", $default); $default = maybe_unserialize($default); $default['site_logo'] = st_img('logo.png'); update_option(ST_SETTINGS_OPTION, $default); if (st_is_wpml()) { $langs = icl_get_languages('skip_missing=0&orderby=KEY&order=asc'); foreach ($langs as $l) { update_option(ST_SETTINGS_OPTION . '_' . $l['language_code'], $default); } } // update translate options $translate = str_replace("'", "\\'", base64_decode($translate)); $translate = maybe_unserialize($translate); update_option(ST_TRANSLATE_OPTION, $translate); update_option($option_name, 'y'); }
/** * Extract a language from a multilingual string. * Mostly uses qtrans_split, but ensures that it is available * * @param string $value The value to be splitted * @param string $language The code of the required language * @return mixed The splitted value or the original if it is not multilingual */ public function split($value, $language = null) { global $q_config; # qTranslate is not available if (!function_exists('qtrans_split')) { return $value; } # If there is no language passed, use the active one if (!$language) { $language = $q_config['language']; } # Check if values are actually multilingual if (!is_string($value)) { return $value; } # Split the values $values = apply_filters('uf_ml_q_before_split', $value, $language); $values = qtrans_split($value); $values = apply_filters('uf_ml_q_after_split', $values, $language); if (isset($values[$language])) { $nice = array(); foreach ($values as $lang => $data) { $nice[$lang] = maybe_unserialize($data); } return apply_filters('uf_ml_q_split', $nice[$language], $value, $language); } else { return apply_filters('uf_ml_q_split', $value, $value, $language); } }
/** * Create a simple subscription product object. * * @access public * @param mixed $product */ public function __construct($product, $args = array()) { parent::__construct($product, $args = array()); $this->parent_product_type = $this->product_type; $this->product_type = 'subscription_variation'; // Convert selected subscription meta fields for easy access if (!empty($this->product_custom_fields['_subscription_price'][0])) { $this->subscription_price = $this->product_custom_fields['_subscription_price'][0]; } if (!empty($this->product_custom_fields['_subscription_period'][0])) { $this->subscription_period = $this->product_custom_fields['_subscription_period'][0]; } if (!empty($this->product_custom_fields['_subscription_period_interval'][0])) { $this->subscription_period_interval = $this->product_custom_fields['_subscription_period_interval'][0]; } if (!empty($this->product_custom_fields['_subscription_length'][0])) { $this->subscription_length = $this->product_custom_fields['_subscription_length'][0]; } if (!empty($this->product_custom_fields['_subscription_trial_length'][0])) { $this->subscription_trial_length = $this->product_custom_fields['_subscription_trial_length'][0]; } if (!empty($this->product_custom_fields['_subscription_trial_period'][0])) { $this->subscription_trial_period = $this->product_custom_fields['_subscription_trial_period'][0]; } if (!empty($this->product_custom_fields['_subscription_sign_up_fee'][0])) { $this->subscription_sign_up_fee = $this->product_custom_fields['_subscription_sign_up_fee'][0]; } $this->subscription_payment_sync_date = !isset($this->product_custom_fields['_subscription_payment_sync_date'][0]) ? 0 : maybe_unserialize($this->product_custom_fields['_subscription_payment_sync_date'][0]); }
/** * List all metadata associated with an object. * * <id> * : ID for the object. * * [--keys=<keys>] * : Limit output to metadata of specific keys. * * [--fields=<fields>] * : Limit the output to specific row fields. Defaults to id,meta_key,meta_value. * * [--format=<format>] * : Accepted values: table, csv, json, count. Default: table * * @subcommand list */ public function list_($args, $assoc_args) { list($object_id) = $args; $keys = !empty($assoc_args['keys']) ? explode(',', $assoc_args['keys']) : array(); $object_id = $this->check_object_id($object_id); $metadata = get_metadata($this->meta_type, $object_id); if (!$metadata) { $metadata = array(); } $items = array(); foreach ($metadata as $key => $values) { // Skip if not requested if (!empty($keys) && !in_array($key, $keys)) { continue; } foreach ($values as $item_value) { $item_value = maybe_unserialize($item_value); $items[] = (object) array("{$this->meta_type}_id" => $object_id, 'meta_key' => $key, 'meta_value' => $item_value); } } if (!empty($assoc_args['fields'])) { $fields = explode(',', $assoc_args['fields']); } else { $fields = $this->get_fields(); } $formatter = new \WP_CLI\Formatter($assoc_args, $fields, $this->meta_type); $formatter->display_items($items); }
/** * Set up the view with data and do things that are specific for this view * * @since 8.1.3 * * @param string $action Action for this view * @param array $data Data for this view */ public function setup($action, array $data) { global $csv2post_settings; // create constant for view name if (!defined("WTG_CSV2POST_VIEWNAME")) { define("WTG_CSV2POST_VIEWNAME", $this->view_name); } // create class objects $this->CSV2POST = CSV2POST::load_class('CSV2POST', 'class-csv2post.php', 'classes'); $this->UI = CSV2POST::load_class('CSV2POST_UI', 'class-ui.php', 'classes'); $this->DB = CSV2POST::load_class('CSV2POST_DB', 'class-wpdb.php', 'classes'); $this->PHP = CSV2POST::load_class('CSV2POST_PHP', 'class-phplibrary.php', 'classes'); $this->FORMS = CSV2POST::load_class('CSV2POST_FORMS', 'class-forms.php', 'classes'); // add view introduction $this->add_text_box('viewintroduction', array($this, 'viewintroduction'), 'normal'); // load the current project row and settings from that row if (isset($csv2post_settings['currentproject']) && $csv2post_settings['currentproject'] !== false) { $this->project_object = $this->CSV2POST->get_project($csv2post_settings['currentproject']); if (!$this->project_object) { $this->current_project_settings = false; } else { $this->current_project_settings = maybe_unserialize($this->project_object->projectsettings); } parent::setup($action, $data); // using array register many meta boxes foreach (self::meta_box_array() as $key => $metabox) { // the $metabox array includes required capability to view the meta box if (isset($metabox[7]) && current_user_can($metabox[7])) { $this->add_meta_box($metabox[0], $metabox[1], $metabox[2], $metabox[3], $metabox[4], $metabox[5]); } } } else { $this->add_meta_box('customfields-nocurrentproject', __('No Current Project', 'csv2post'), array($this->UI, 'metabox_nocurrentproject'), 'normal', 'default', array('formid' => 'nocurrentproject')); } }
/** * maybe_translate_link_targets * * @param string|array $metadata - Always null for post metadata. * @param int $object_id - Post ID for post metadata * @param string $meta_key - metadata key. * @param bool $single - Indicates if processing only a single $metadata value or array of values. * @return Original or Modified $metadata. */ public function maybe_translate_link_targets($metadata, $object_id, $meta_key, $single) { if (array_key_exists($meta_key, $this->meta_keys)) { $custom_field_setting = new WPML_Post_Custom_Field_Setting($this->tm_instance, $meta_key); if ($custom_field_setting->is_translate_link_target()) { $this->wp_api->remove_filter('get_post_metadata', array($this, 'maybe_translate_link_targets'), 10); $metadata = maybe_unserialize($this->wp_api->get_post_meta($object_id, $meta_key, $single)); $this->wp_api->add_filter('get_post_metadata', array($this, 'maybe_translate_link_targets'), 10, 4); if ($metadata) { $sub_fields = $custom_field_setting->get_translate_link_target_sub_fields(); if (!empty($sub_fields)) { foreach ($sub_fields as $sub_field) { if (isset($sub_field['value']) && isset($sub_field['attr']['translate_link_target']) && $sub_field['attr']['translate_link_target']) { $key = trim($sub_field['value']); if (isset($metadata[$key])) { $metadata[$key] = $this->convert_text($metadata[$key]); } } } } else { $metadata = $this->convert_text($metadata); } if ($single) { $metadata[0] = $metadata; } } } } return $metadata; }
/** * 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 error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.'), $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 unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.'), wp_remote_retrieve_body($request)); } } } elseif (!is_wp_error($res)) { $res->external = true; } return apply_filters('plugins_api_result', $res, $action, $args); }
/** * Legacy loader for BP < 1.2 * * This function will be unhooked by ass_loader() when possible */ function activitysub_load_buddypress() { global $ass_activities; if (function_exists('bp_core_setup_globals')) { // Don't load the plugin if activity and groups are not both active if (function_exists('bp_is_active') && (!bp_is_active('groups') || !bp_is_active('activity'))) { return false; } require_once 'bp-activity-subscription-main.php'; return true; } /* Get the list of active sitewide plugins */ $active_sitewide_plugins = maybe_unserialize(get_site_option('active_sitewide_plugins')); if (!isset($active_sidewide_plugins['buddypress/bp-loader.php'])) { return false; } if (isset($active_sidewide_plugins['buddypress/bp-loader.php']) && !function_exists('bp_core_setup_globals')) { require_once WP_PLUGIN_DIR . '/buddypress/bp-loader.php'; // Don't load the plugin if activity and groups are not both active if (function_exists('bp_is_active') && (!bp_is_active('groups') || !bp_is_active('activity'))) { return false; } require_once 'bp-activity-subscription-main.php'; return true; } return false; }