本文整理汇总了PHP中get_theme_mods函数的典型用法代码示例。如果您正苦于以下问题:PHP get_theme_mods函数的具体用法?PHP get_theme_mods怎么用?PHP get_theme_mods使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_theme_mods函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jim_styles
function jim_styles()
{
wp_enqueue_style('custom_style', get_template_directory_uri() . '/css/global.css');
$mods = get_theme_mods();
// var_dump($mods);
$p_color = get_theme_mod('color_setting');
$styles = '
body { color:' . $p_color . ';}
body p { color: ' . $p_color . ';}
body h1 { color:' . $mods['h1_color'] . ' }
body h2 { color:' . $mods['h2_color'] . ' }
body h3 { color:' . $mods['h3_color'] . ' }
body h4 { color:' . $mods['h4_color'] . ' }
body h5 { color:' . $mods['h5_color'] . ' }
';
wp_add_inline_style('custom_style', $styles);
}
示例2: wpo_init_constants
function wpo_init_constants()
{
$theme_mods = get_theme_mods();
if (!defined('TEMPLATEURI')) {
define('TEMPLATEURI', trailingslashit(get_stylesheet_directory_uri()));
}
if (!defined('HOMEURL')) {
define('HOMEURL', trailingslashit(get_home_url()));
}
if (!defined('THEMECOLOR')) {
if (!empty($theme_mods['wpo_theme_color'])) {
$meta_color = $theme_mods['wpo_theme_color'];
} else {
$meta_color = '#000000';
}
define('THEMECOLOR', $meta_color);
}
if (!defined('HEADERCOLOR')) {
if (!empty($theme_mods['wpo_header_color'])) {
$meta_color = $theme_mods['wpo_header_color'];
} else {
$meta_color = '#000000';
}
define('HEADERCOLOR', $meta_color);
}
}
示例3: customcss
function customcss()
{
$thim_options = get_theme_mods();
$custom_css = '';
if (isset($thim_options['thim_user_bg_pattern']) && $thim_options['thim_user_bg_pattern'] == '1') {
$custom_css .= ' body{background-image: url("' . $thim_options['thim_bg_pattern'] . '"); }';
}
if (isset($thim_options['thim_bg_pattern_upload']) && $thim_options['thim_bg_pattern_upload'] != '') {
$bg_body = wp_get_attachment_image_src($thim_options['thim_bg_pattern_upload'], 'full');
$custom_css .= ' body{background-image: url("' . $bg_body[0] . '"); }
body{
background-repeat: ' . $thim_options['thim_bg_repeat'] . ';
background-position: ' . $thim_options['thim_bg_position'] . ';
background-attachment: ' . $thim_options['thim_bg_attachment'] . ';
background-size: ' . $thim_options['thim_bg_size'] . ';
}
';
}
/* Footer */
// Background
if (isset($thim_options['thim_footer_background_img']) && $thim_options['thim_footer_background_img']) {
$bg_footer = wp_get_attachment_image_src($thim_options['thim_footer_background_img'], 'full');
$custom_css .= 'footer#colophon {background-image: url("' . $bg_footer[0] . '");
}';
}
$custom_css .= $thim_options['thim_custom_css'];
return $custom_css;
}
示例4: set_theme_mods
/**
* Update theme modifications for the current theme.
* Note: Candidate core function.
* http://core.trac.wordpress.org/ticket/20091
*
* @since 3.4.0
*
* @param array $mods Theme modifications.
*/
public function set_theme_mods($mods)
{
$current = get_theme_mods();
$mods = wp_parse_args($mods, $current);
$theme = get_stylesheet();
update_option("theme_mods_{$theme}", $mods);
}
示例5: get_context
/**
* Custom implementation for get_context method.
*/
public function get_context()
{
global $content_width;
if (class_exists('Easy_Digital_Downloads')) {
global $edd_options;
}
$context = Timber::get_context();
$sidebar_primary = Timber::get_widgets('sidebar_primary');
$sidebar_footer = Timber::get_widgets('sidebar_footer');
$context['theme_mods'] = get_theme_mods();
$context['site_options'] = wp_load_alloptions();
$context['teaser_mode'] = apply_filters('maera/teaser/mode', 'excerpt');
$context['thumbnail']['width'] = apply_filters('maera/image/width', 600);
$context['thumbnail']['height'] = apply_filters('maera/image/height', 371);
$context['menu']['primary'] = has_nav_menu('primary_navigation') ? new TimberMenu('primary_navigation') : null;
$context['sidebar']['primary'] = apply_filters('maera/sidebar/primary', $sidebar_primary);
$context['sidebar']['footer'] = apply_filters('maera/sidebar/footer', $sidebar_footer);
$context['pagination'] = Timber::get_pagination();
$context['comment_form'] = TimberHelper::get_comment_form();
$context['comments_args'] = array('style' => 'ul', 'reply_text' => __('Reply', 'maera'), 'short_ping' => true, 'avatar_size' => 60);
$context['site_logo'] = get_option('site_logo', false);
$context['content_width'] = $content_width;
$context['sidebar_template'] = maera_templates_sidebar();
if (class_exists('Easy_Digital_Downloads')) {
$data['edd_options'] = $edd_options;
$data['download_categories'] = Timber::get_terms('download_category');
$data['download_tags'] = Timber::get_terms('download_tag');
$data['default_image'] = new TimberImage(get_template_directory_uri() . '/assets/images/default.png');
}
return apply_filters('maera/timber/context', $context);
}
示例6: export_customizer_options
public function export_customizer_options()
{
$mods = get_theme_mods();
unset($mods['nav_menu_locations']);
$output = base64_encode(serialize($mods));
$this->save_as_txt_file("customizer_options.txt", $output);
}
示例7: add_to_context
function add_to_context($context)
{
$context['foo'] = 'bar';
$context['stuff'] = 'I am a value set in your functions.php file';
$context['notes'] = 'These values are available everytime you call Timber::get_context();';
$context['menu'] = new TimberMenu();
//$context['custom_wp_nav_menu'] = wp_nav_menu( array( 'container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu' ) );
$context['custom_wp_nav_menu'] = wp_nav_menu(array('container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu'));
$context['site'] = $this;
$context['theme_url'] = get_stylesheet_directory_uri();
$context['is_logged_in'] = is_user_logged_in();
$context['theme_mod'] = get_theme_mods();
$context['options'] = wp_load_alloptions();
$context['site_url'] = site_url();
if (is_home() || is_front_page()) {
$context['is_home'] = true;
}
/*
* Footer
*/
$context['footer_tag_line'] = get_option('footer_text');
$context['footer_address'] = get_option('address');
$context['footer_site_url'] = site_url();
$context['footer_inquiry_mail'] = get_option('inquiry_mail');
$context['footer_telephone'] = get_option('telephone');
$context['s_facebook'] = get_option('facebook');
$context['s_twitter'] = get_option('twitter');
$context['s_linkedin'] = get_option('linkedin');
$context['footer_copyright'] = get_option('copyright');
return $context;
}
示例8: get_theme_mod_value
/**
* Get theme mod value.
*
* @param string $value
* @return string
*/
public function get_theme_mod_value($value)
{
$key = substr(current_filter(), 10);
$set_theme_mods = get_theme_mods();
if (isset($set_theme_mods[$key])) {
return $value;
}
$values = $this->get_storefront_default_setting_values();
return isset($values[$key]) ? $values[$key] : $value;
}
示例9: octopus_header_style
/**
* Styles the header image and text displayed on the blog.
*
* @see octopus_custom_header_setup().
*/
function octopus_header_style()
{
$header_text_color = get_header_textcolor();
// If no custom options are set, let's bail.
if (!get_theme_mods()) {
return;
}
// If we get this far, we have custom styles. Let's do this.
?>
<style type="text/css" id="octopus-custom-style">
<?php
/*
* If no custom options for text are set, let's bail.
* get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: HEADER_TEXTCOLOR.
*/
if (!HEADER_TEXTCOLOR === $header_text_color) {
// Has the text been hidden?
if (!display_header_text()) {
?>
.site-title,
.site-description {
position: absolute;
clip: rect(1px, 1px, 1px, 1px);
}
<?php
// If the user has set a custom color for the text use that.
} else {
?>
.site-title a,
.site-description {
color: #<?php
echo esc_attr($header_text_color);
?>
;
}
<?php
}
?>
<?php
}
?>
<?php
octopus_generate_css('#page.container', 'max-width', 'container_max_width', '', '', true);
//Header
octopus_generate_css('.container-fluid .octopus-wrapper', 'max-width', 'wrapped_element_max_width', '', 'px', true);
// Header banner
octopus_generate_css('.octopus-header-banner', 'height', 'header_banner_height', '', 'px', true);
?>
</style>
<?php
}
示例10: thememove_customizer_options_exporter
function thememove_customizer_options_exporter()
{
$blogname = strtolower(str_replace(' ', '-', get_option('blogname')));
$file_name = $blogname . '-thememove-' . date('Ydm') . '.txt';
$options = get_theme_mods();
unset($options['nav_menu_locations']);
ob_clean();
header("Content-type: application/text", true, 200);
header("Content-Disposition: attachment; filename=\"{$file_name}\"");
header("Pragma: no-cache");
header("Expires: 0");
echo base64_encode(serialize($options));
die;
}
示例11: import_skin_from_file
protected function import_skin_from_file($file)
{
$content = $this->get_file_contents($file);
$options = @unserialize(base64_decode($content));
foreach ((array) $options as $key => $val) {
set_theme_mod($key, $val);
}
$mods = get_theme_mods();
foreach ($mods as $mod_key => $mod_valud) {
if ('nav_menu_locations' != $mod_key && !isset($options[$mod_key])) {
remove_theme_mod($mod_key);
}
}
}
示例12: of_get_options
/**
* Get options from the database and process them with the load filter hook.
*
* @author Jonah Dahlquist
* @since 1.4.0
* @return array
*/
function of_get_options($key = null, $data = null)
{
do_action('of_get_options_before', array('key' => $key, 'data' => $data));
if ($key != null) {
// Get one specific value
$data = get_theme_mod($key, $data);
} else {
// Get all values
$data = get_theme_mods();
}
$data = apply_filters('of_options_after_load', $data);
do_action('of_option_setup_before', array('key' => $key, 'data' => $data));
return $data;
}
示例13: customize_save
/**
* Hooks into the customize_save action to save modifications in theme_options/mods
*/
public function customize_save(\WP_Customize_Manager $manager)
{
foreach ($manager->settings() as $key => $setting) {
if ($setting->type == 'theme_mod') {
// We have to call this early to make sure it is saved
$setting->save();
}
}
$mods = get_theme_mods();
if ($mods) {
ksort($mods);
static::writeConfigs("theme_options/mods", array('mods' => $mods));
}
}
示例14: thim_customizer_export_theme_settings
function thim_customizer_export_theme_settings()
{
$blogname = strtolower(str_replace(' ', '-', get_option('blogname')));
$file_name = $blogname . '-thimtheme-' . date('Ydm') . '.json';
$options = get_theme_mods();
unset($options['nav_menu_locations']);
foreach ($options as $key => $value) {
$value = maybe_unserialize($value);
$need_options[$key] = $value;
}
$json_file = json_encode($need_options);
ob_clean();
header('Content-Type: text/json; charset=' . get_option('blog_charset'));
header('Content-Disposition: attachment; filename="' . $file_name . '"');
echo ent2ncr($json_file);
exit;
}
示例15: x_version_migration
function x_version_migration()
{
$prior = get_option('x_version', '1.0.0');
if (version_compare($prior, X_VERSION, '<')) {
//
// If $prior is less than 2.2.0.
//
if (version_compare($prior, '2.2.0', '<')) {
$mods = get_theme_mods();
foreach ($mods as $key => $value) {
update_option($key, $value);
}
}
//
// If $prior is less than 3.1.0.
//
if (version_compare($prior, '3.1.0', '<')) {
$stack = get_option('x_stack');
$design = $stack == 'integrity' ? '_' . get_option('x_integrity_design') : '';
$stack_safe = $stack == 'icon' ? 'integrity' : $stack;
$updated = array('x_layout_site' => get_option('x_' . $stack . '_layout_site'), 'x_layout_site_max_width' => get_option('x_' . $stack . '_sizing_site_max_width'), 'x_layout_site_width' => get_option('x_' . $stack . '_sizing_site_width'), 'x_layout_content' => get_option('x_' . $stack . '_layout_content'), 'x_layout_content_width' => get_option('x_' . $stack_safe . '_sizing_content_width'), 'x_layout_sidebar_width' => get_option('x_icon_sidebar_width'), 'x_design_bg_color' => get_option('x_' . $stack . $design . '_bg_color'), 'x_design_bg_image_pattern' => get_option('x_' . $stack . $design . '_bg_image_pattern'), 'x_design_bg_image_full' => get_option('x_' . $stack . $design . '_bg_image_full'), 'x_design_bg_image_full_fade' => get_option('x_' . $stack . $design . '_bg_image_full_fade'));
foreach ($updated as $key => $value) {
update_option($key, $value);
}
}
//
// If $prior is less than 4.0.0.
//
if (version_compare($prior, '4.0.0', '<')) {
$updated = array('x_pre_v4' => true);
foreach ($updated as $key => $value) {
update_option($key, $value);
}
}
//
// Update stored version number.
//
update_option('x_version', X_VERSION);
//
// Turn on the version migration notice.
//
update_option('x_version_migration_notice', true);
}
}