當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Options::tarski_options_defaults方法代碼示例

本文整理匯總了PHP中Options::tarski_options_defaults方法的典型用法代碼示例。如果您正苦於以下問題:PHP Options::tarski_options_defaults方法的具體用法?PHP Options::tarski_options_defaults怎麽用?PHP Options::tarski_options_defaults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Options的用法示例。


在下文中一共展示了Options::tarski_options_defaults方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: flush_tarski_options

/**
 * flush_tarski_options() - Flushes Tarski's options for use by the theme.
 * 
 * Creates a new Options object, and gets the current options. If
 * no options have been set in the database, it will return the
 * defaults. Additionally, if the 'deleted' property has been set
 * then the function will check to see if it was set more than two
 * hours ago--if it was, the tarski_options database row will be
 * dropped. If the 'deleted' property has been set, then the defaults
 * will be returned regardless of whether other options are set.
 * @since 1.4
 * @global object $tarski_options
 * @return object $tarski_options
 */
function flush_tarski_options()
{
    global $tarski_options;
    $tarski_options = new Options();
    $tarski_options->tarski_options_get();
    if (!get_option('tarski_options') || isset($tarski_options->deleted)) {
        $tarski_options->tarski_options_defaults();
    }
}
開發者ID:nihad,項目名稱:tarski,代碼行數:23,代碼來源:options.php

示例2: tarski_upgrade

/**
 * function tarski_upgrade() - Upgrades Tarski's options where appropriate.
 * 
 * Tarski preferences sometimes change between versions, and need to
 * be updated. This function does not determine whether an update is
 * needed, it merely perfoms it. It's also self-contained, so it
 * won't update the global $tarski_options object either.
 * @since 2.1
 * @uses tarski_upgrade_special()
 * @uses tarski_upgrade_widgets()
 */
function tarski_upgrade()
{
    // Get existing options
    $options = new Options();
    $options->tarski_options_get();
    // Get our defaults, so we can merge them in
    $defaults = new Options();
    $defaults->tarski_options_defaults();
    // Update the options version so we don't run this code more than once
    $options->installed = theme_version('current');
    // Handle special cases first
    tarski_upgrade_special($options, $defaults);
    // Upgrade old display options to use widgets instead
    tarski_upgrade_widgets($options, $defaults);
    // Conform our options to the expected values, types, and defaults
    foreach ($options as $name => $value) {
        if (!isset($defaults->{$name})) {
            // Get rid of options which no longer exist
            unset($options->{$name});
        } elseif (!isset($options->{$name})) {
            // Use the default if we don't have this option
            $options->{$name} = $defaults->{$name};
        } elseif (is_array($options->{$name}) && !is_array($defaults->{$name})) {
            // If our option is an array and the default is not, implode using " " as a separator
            $options->{$name} = implode(" ", $options->{$name});
        } elseif (!is_array($options->{$name}) && is_array($defaults->{$name})) {
            // If our option is a scalar and the default is an array, wrap our option in an array
            $options->{$name} = array($options->{$name});
        }
    }
    // Save our upgraded options
    update_option('tarski_options', $options);
}
開發者ID:nihad,項目名稱:tarski,代碼行數:44,代碼來源:admin_helper.php


注:本文中的Options::tarski_options_defaults方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。