/** * custom callback for validate fields * @example https://github.com/leemason/NHP-Theme-Options-Framework/blob/master/nhp-options.php * @param $field * @param $value * @param $existing_value */ public function validate_header_fields_cb($field, $value, $existing_value) { //$field['msg'] = 'your custom error message'; if ($field == 'admin_logo' && $value) { HW__Site::set_logo($value, false); } if ($field == 'site_banner' && $value) { HW__Site::set_banner($value, false); } //bloginfo if ($field == 'site_name' && $value) { $site_info['name'] = $value; } if ($field == 'slogan' && $value) { $site_info['description'] = $value; } if (!empty($site_info)) { HW__Site::update_site_info($site_info, false); } return $value; }
/** * setup site metadata * @param $command */ public function setup_site_meta($command, $args) { #$this->command_log('setup site meta');return; //get current template context $theme_config = $this->get_option('theme_config'); //parse config file for current theme #site meta if ($theme_config->item('site')) { $site = $theme_config->item('site'); HW_NHP_Main_Settings::update_data(array('last_tab' => '1')); //fix current tab //update site info (name & description, phone...) HW__Site::update_site_info($site); //update logo if (!empty($site['logo'])) { //get relative path from current theme directory if (!HW_URL::valid_url($site['logo'])) { $site['logo'] = get_stylesheet_directory_uri() . '/' . $site['logo']; } HW__Site::set_logo($site['logo']); } //set banner if exists if (!empty($site['banner'])) { //get relative path from current theme directory if (!HW_URL::valid_url($site['banner'])) { $site['banner'] = get_stylesheet_directory_uri() . '/' . $site['banner']; } HW__Site::set_banner($site['banner']); } //update user info $user = _hw_global('admin')->load_api('HW_WP_User'); $user->update_user(array('user_email' => $site['email'], 'user_url' => 'http://hoangweb.com', 'description' => $site['footer_text'])); } if ($theme_config->item('configuration')) { } $this->command_log('setup site meta'); }