Skip to content

Instantly share code, notes, and snippets.

@amostajo
Created March 20, 2017 18:17
Show Gist options
  • Save amostajo/53aa1c5ffa00063cf65bded85ee9b80f to your computer and use it in GitHub Desktop.
Save amostajo/53aa1c5ffa00063cf65bded85ee9b80f to your computer and use it in GitHub Desktop.
Post Gallery - Default settings by code.
<?php
// The class settings is located at PostGallery\Models\PostGallery
// There are 2 ways of calling and using this class.
// - 1 - Using use statement
use PostGallery\Models\PostGallery;
$settings = PostGallery::find();
// - 2 - Without use statement
$settings = PostGallery\Models\PostGallery::find();
//-----------------------------------------
// Then you can read/write the settings by code
$settings->can_enqueue = 0;
$settings->types = ['custom-post-type','post'];
$settings->metabox_context = 'advanced';
$settings->metabox_priority = 'default';
// Then save the settings by code
$settings->save();
// Settings are cached, so you will need to clear cached settings
// Once cleared, settings will be refreshed
$settings->clear();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment