Advertisement:

Author Topic: After Install Theme, Run some Code  (Read 512 times)

pggco

  • Newbie
  • *
  • Posts: 10
After Install Theme, Run some Code
« on: May 04, 2015, 04:35:29 pm »
hi,

i want when installed a theme, Run some code (like plugin -> osc_register_plugin(osc_plugin_path(__FILE__), 'example_install') )

how can i do this ? :-\

frosticek

  • Hero Member
  • *****
  • Posts: 3948
Re: After Install Theme, Run some Code
« Reply #1 on: May 04, 2015, 05:31:25 pm »
@pggco
In your function.php you should place something like:

Code: [Select]
// install update options
if( !function_exists('hm_theme_install') ) {
  function hm_theme_install() {
    .. my code ..
  }
}

if(!function_exists('check_install_hm_theme')) {
  function check_install_hm_theme() {
    $current_version = osc_get_preference('version', 'tatiana_theme');
    //check if current version is installed or need an update<
    if( !$current_version ) {
      hm_theme_install();
    }
  }
}

check_install_hm_theme();