Exemplo n.º 1
0
/**
 * Retrieve and return an option from the database.
 *
 * @since 0.1.0
 */
function accesspress_get_option($key, $setting = null)
{
    /**
     * Get setting. The default is set here, once, so it doesn't have to be
     * repeated in the function arguments for accesspress_option() too.
     */
    $setting = $setting ? $setting : MEMBER_ACCESS_SETTINGS_FIELD;
    return premise_get_option($key, $setting);
}
 /**
  * get value of a field by context
  *
  * Context applies to where the field is saved. By default fields are assumed to be saved
  * in the options table. But if adding fields to a custom post type, get_option() would not work anymore
  * so we pass the context 'post'. That's how Premise knows to get the value from get_post_meta() instead of get_option()
  *
  * @since 1.2 
  * 
  * @return mixed value found
  */
 protected function get_value_by_context($name)
 {
     $context = $this->args['context'];
     switch ($context) {
         case 'post':
             $value = premise_get_option($name, 'post');
             break;
         default:
             return get_option($this->args['name']);
             break;
     }
 }
Exemplo n.º 3
0
 /**
  * Helper function that returns a setting value from this form's settings
  * field for use in form fields.
  *
  * @since 0.1.0
  *
  * @param string $key Field key
  * @return string Field value
  */
 protected function get_field_value($key, $subkey = null)
 {
     $setting = premise_get_option($key, $this->settings_field);
     if ($subkey === null) {
         return $setting;
     }
     if (isset($setting[$subkey])) {
         return $setting[$subkey];
     }
     return '';
 }