Giter Site home page Giter Site logo

code-examples's People

Contributors

cais avatar chipbennett avatar emiluzelac avatar ernilambar avatar leanne63 avatar wpmisc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code-examples's Issues

PHP notice in select sanitization

I am using function theme_slug_sanitize_select for sanitizing select control. But PHP notice is returned as below.
Notice: Trying to get property of non-object on ....

I checked setting->id and it is returning correct value. I guess PHP notice is due to $setting->manager. What may be problem here?

Setting defaults

Hello,

from what I have read so far, the appropriate way to call a customizer setting is by declaring its default value, for example:

get_theme_mod('my_setting', 'default_value');

When you have to call the setting in many different places, though, it might be problematic if you decide to change your default value. What I was thinking of doing was a function where I would set the customizer default values only once. For example, something like that:

if( ! function_exists('my_default') ) :
function my_default( $key = '' ) {
    $def = array(
        'setting1' => 'default_value',
        'setting2' => 'default_value'
    );
    if( isset($def[$key]) ) {
        return $def[$key];
    }
}
endif;

Then, in the customizer settings, instead of setting the default like this:

'default'  => 'my_default_value',

I would do it like this:

'default'  => my_default('setting1'),

and I would call the value in the templates like that:

get_theme_mod('my_setting', my_default('setting1'));

That way I would only need to declare my defaults in one place. Would this approach comply with WordPress' good practices or is there any other, preferred way for dealing with the issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.