Corcel\Options::get PHP 메소드

get() 공개 정적인 메소드

Gets option field by its name.
public static get ( string $name ) : string | array
$name string
리턴 string | array
    public static function get($name)
    {
        if ($option = self::where('option_name', $name)->first()) {
            return $option->value;
        }
        return;
    }

Usage Example

예제 #1
0
 /**
  * Test getting some options.
  */
 public function testGetOptions()
 {
     // Get all the options and test some
     $options = Options::getAll();
     $this->assertNotNull($options);
     // String value
     $this->assertArrayHasKey('blogname', $options);
     $this->assertEquals('Wordpress Corcel', $options['blogname']);
     // Array value
     $this->assertArrayHasKey('wp_user_roles', $options);
     $this->assertCount(5, $options['wp_user_roles']);
     $this->assertEquals('Administrator', $options['wp_user_roles']['administrator']['name']);
     // Get single values
     $this->assertEquals('*****@*****.**', Options::get('admin_email'));
     $this->assertEquals(false, Options::get('moderation_keys'));
     $themeRoots = Options::get('_site_transient_theme_roots');
     $this->assertNotNull($themeRoots);
     $this->assertEquals('/themes', $themeRoots['twentyfourteen']);
 }