'
));
}
add_action( 'widgets_init', 'ketchupthemes_widgets_init' );
// Register Custom Navigation Walker
require_once('wp_bootstrap_navwalker.php');
/**Add a simple metabox***/
/***
*
*
*/
function ketchupthemes_pricefield_add_custom_box() {
$screens = array( 'post');
foreach ( $screens as $screen ) {
add_meta_box(
'pricefield_id',
__( 'Price Fields', 'chineserestaurant' ),
'ketchupthemes_pricefield_inner_custom_box',
$screen
);
}
}
add_action( 'add_meta_boxes', 'ketchupthemes_pricefield_add_custom_box' );
/**Print the box content**/
function ketchupthemes_pricefield_inner_custom_box( $post ) {
// Add an nonce field so we can check for it later.
wp_nonce_field( 'ketchupthemes_pricefield_inner_custom_box', 'ketchupthemes_pricefield_inner_custom_box_nonce' );
/*
* Use get_post_meta() to retrieve an existing value
* from the database and use the value for the form.
*/
$value = get_post_meta( $post->ID, 'ketchupthemes_price', true );
echo ' ';
echo '';
}
function ketchupthemes_pricefield_save_postdata( $post_id ) {
/*
* We need to verify this came from the our screen and with proper authorization,
* because save_post can be triggered at other times.
*/
// Check if our nonce is set.
if ( ! isset( $_POST['ketchupthemes_pricefield_inner_custom_box_nonce'] ) )
return $post_id;
$nonce = $_POST['ketchupthemes_pricefield_inner_custom_box_nonce'];
// Verify that the nonce is valid.
if ( ! wp_verify_nonce( $nonce, 'ketchupthemes_pricefield_inner_custom_box' ) )
return $post_id;
// If this is an autosave, our form has not been submitted, so we don't want to do anything.
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return $post_id;
// Check the user's permissions.
if ( 'page' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_id ) )
return $post_id;
} else {
if ( ! current_user_can( 'edit_post', $post_id ) )
return $post_id;
}
/* OK, its safe for us to save the data now. */
// Sanitize user input.
$mydata = sanitize_text_field( $_POST['pricefield_new_field'] );
// Update the meta field in the database.
update_post_meta( $post_id, 'ketchupthemes_price', $mydata );
}
add_action( 'save_post', 'ketchupthemes_pricefield_save_postdata' );
/***OPTIONS PAGE***/
/**
*
*/
function ketchupthemes_admin_scripts() {
$url = get_template_directory_uri().'/';
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_enqueue_script('my-upload', $url.'js/upload_image_favicon.js', array('jquery','media-upload','thickbox'));
}
function ketchupthemes_admin_styles() {
wp_enqueue_style('thickbox');
$url = get_template_directory_uri().'/';
wp_enqueue_style('upgradeStyle',$url.'/css/ketchup-upg-style.css','','all');
}
if (isset($_GET['page']) && $_GET['page'] == 'settings') {
add_action('admin_enqueue_scripts', 'ketchupthemes_admin_scripts');
add_action('admin_enqueue_scripts', 'ketchupthemes_admin_styles');
}
//register settings
function ketchupthemes_theme_settings_init(){
register_setting( 'chinese_theme_settings', 'chinese_theme_settings','settings_sanitize_and_validate' );
}
function settings_sanitize_and_validate($input){
/*Validation*/
if(!isset($input['fav_upload'])){ $input['fav_upload'] = '';}
if(!isset($input['badge_text'])){ $input['badge_text'] = '';}
if(!isset($input['badge_url'])){ $input['badge_url']='';}
$favUrl = $input['fav_upload'];
$badgeUrl = $input['badge_url'];
if (filter_var($favUrl, FILTER_VALIDATE_URL)) {
$input['fav_upload'] = $favUrl;
}
else {
$input['fav_upload'] = '';
}
if (filter_var($badgeUrl, FILTER_VALIDATE_URL)) {
$input['badge_url'] = $badgeUrl;
}
else {
$input['badge_url'] = '';
}
return $input;
}
//add settings page to menu
function add_settings_page() {
add_theme_page(__('Theme Settings','chineserestaurant'),__('Theme Settings','chineserestaurant'),'edit_theme_options', 'settings', 'ketchupthemes_theme_settings_page');
}
//add actions
add_action( 'admin_init', 'ketchupthemes_theme_settings_init' );
add_action( 'admin_menu', 'add_settings_page' );
//start settings page
function ketchupthemes_theme_settings_page() {
if ( ! isset( $_REQUEST['updated'] ) )
$_REQUEST['updated'] = false;
?>
The premium version of the theme includes advanced options that allow the creation of a professional and very functional website:
- Allows to activate a slideshow in homepage to display the posts included in it.
- Allows to upload your own custom logo
- Allows to integrate the website with Google Analytics to follow the statistics of website.
- Allows to activate social profiles such as facebook, twitter, google+ etc.
The premium version of our theme is GPL v2 or later compatible.