Title: Programatically create controls?
Last modified: July 29, 2017

---

# Programatically create controls?

 *  [imads](https://wordpress.org/support/users/imads/)
 * (@imads)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/programatically-create-controls/)
 * Hi,
 * Your plugin is amazing! I want to use it with my theme to create demo controls
   when the theme is activated. I can create the controls but I’m not sure how exactly
   I can attach the properties to these controls.
 * So basically I’m doing:
 *     ```
       $egf_post_handle = EGF_Posttype::get_instance();
       $post_id = $egf_post_handle->update_font_control($ctrl_name, $ctrl_name, $ctrl_selectors, '', false);
       ```
   
 * What I see until now is:
 * – Controls are custom post types
    – These custom post types contents are json
   econded options with main key being the control-id.
 * So to programatically add the options for my custom controls should I just create
   a raw json array with the control-Id obtained after creation of the egf_control
   and then add that as post content?
 *     ```
       $ctrl_id = get_post_meta($post_id, 'control-id');
       // create json econded settings and  set the custom post content to my json ecoded settings
       // eg: 
       {
           "tt_font_theme_options[$ctrl_id]": {
               "value": {
                   "text_transform": "lowercase",
                   "font_id": "abhaya_libre",
                   ...
                   // update post content with above contents
       ```
   
 * Or is there some helper function that I can use to set a specific value like 
   the text-transform for my control?
 * I’m asking because I’ve tried to edit the post content with phpmyadmi, changed
   a setting like “text_transform” from “lowercase” to “uppercase” and I’m not seeing
   it getting updated in the customizer.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [imads](https://wordpress.org/support/users/imads/)
 * (@imads)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/programatically-create-controls/#post-9365472)
 * Any suggestion is highly appreciated…
 * Thanks!
 *  Thread Starter [imads](https://wordpress.org/support/users/imads/)
 * (@imads)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/programatically-create-controls/#post-9392522)
 * Any luck on finding some help here?
 *  [Marc_J](https://wordpress.org/support/users/marc_j/)
 * (@marc_j)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/programatically-create-controls/#post-9404261)
 * Hi,
 * I’m currently doing the following within a theme: Adding a post of type “tt_font_control”
   and the needed post meta “control_id”, “control_selectors”, “control_description”
   and “force_styles” whether the plugin is installed or not, so these controls 
   are present and can be used after installing the plugin.
 * Since the control IDs currently are generated randomly by the plugin between 
   1 and 100, I simply start with 101.
 * Best,
    Marc

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Programatically create controls?’ is closed to new replies.

 * ![](https://ps.w.org/easy-google-fonts/assets/icon-256x256.png?rev=2562365)
 * [Easy Google Fonts](https://wordpress.org/plugins/easy-google-fonts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/easy-google-fonts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/easy-google-fonts/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-google-fonts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-google-fonts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-google-fonts/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Marc_J](https://wordpress.org/support/users/marc_j/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/programatically-create-controls/#post-9404261)
 * Status: not resolved