コード例 #1
0
function register_nav_menus($locations = array())
{
    $_asc_registered_nav_menus = $locations;
    $reg_nav_menu['nav_menu_register'] = $locations;
    $skin = modApiFunc('Look_Feel', 'getCurrentSkin');
    $reg_nav_menu['theme'] = $skin;
    $option_name = "theme_mods_" . $skin;
    $result = asc_get_option($option_name, $default = 'true');
    if ($result) {
        asc_update_option($option_name, $reg_nav_menu);
    } else {
        asc_add_option($option_name, $reg_nav_menu);
    }
}
コード例 #2
0
/**
 * Update the value of an option that was already added.
 *
 * You do not need to serialize values. If the value needs to be serialized, then
 * it will be serialized before it is inserted into the database. Remember,
 * resources can not be serialized or added as an option.
 *
 * If the option does not exist, then the option will be added with the option
 * value, but you will not be able to set whether it is autoloaded.
 *
 * @since 4.7.5
 * @package Avactis
 * @subpackage Option
 *
 *
 * @param string $option Option name.
 * @param mixed $newvalue Option value.
 */
function asc_update_option($option, $newvalue)
{
    global $application;
    $option = trim($option);
    if (empty($option)) {
        return false;
    }
    $result = asc_get_option($option);
    $old_value = $result;
    $NewserializeVal = serialize($newvalue);
    if ($result) {
        $tables = Configuration::getTables();
        $tr = $tables['options']['columns'];
        $query = new DB_Update('options');
        $query->addUpdateValue($tr['option_value'], $NewserializeVal);
        $query->WhereValue($tr["option_name"], DB_EQ, $option);
        $application->db->PrepareSQL($query);
        $application->db->DB_Exec();
        /**
         * Fires after the value of a specific option has been successfully updated.
         *
         * @param mixed $old_value The old option value.
         * @param mixed $value     The new option value.
         */
        do_action("asc_update_option_{$option}", $old_value, $newvalue);
        /**
         * Fires after the value of an option has been successfully updated.
         *
         * @param string $option    Name of the updated option.
         * @param mixed  $old_value The old option value.
         * @param mixed  $value     The new option value.
         */
        do_action('asc_updated_option', $option, $old_value, $newvalue);
        return true;
    } else {
        asc_add_option($option, $newvalue);
    }
}