Adding WP user name and user last name to the database

Home Forums Quform WordPress Adding WP user name and user last name to the database

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #3886
    cagrioner
    Participant

    How can i enter logged in user’s name and last name to the entries database (I mean not the login or display name)?

    Also how can i set these as default values in the text fields? I’ve read the article on dynamic fields but it seemed too complicated

    #3899
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #3903
    cagrioner
    Participant

    Hi,
    When i enter the code you provided to functions.php the site gives a server error. I tried it before and after setting the dynamic values.

    Is there a syntax error that I cant see?
    Here is my functions.php look like (I first insertes the code at the bottom and then right after enqeue scripts and styles as seen below, line 200). My page works all right when I remove your code.

    <?php

    #--------------------------------------------------------------------
    #
    # GENERAL SETUP
    #
    #--------------------------------------------------------------------

    // TO DO INCLUDES ----------------------------------------------------//

    require_once(TEMPLATEPATH . '/lib/shortcodes.php');
    require_once(TEMPLATEPATH . '/lib/post-type-work.php');

    // SHORTCUT CONSTANTS ----------------------------------------------------//

    define('CSSPATH', get_template_directory_uri() . "/css/");
    define('JSPATH', get_template_directory_uri() . "/js/");
    define('IMGPATH', get_template_directory_uri() . "/img/");
    define('ADMIN_URI', get_stylesheet_directory_uri() . '/admin/');

    // theme data
    $theme_data = get_theme_data(TEMPLATEPATH.'/style.css');
    define('THEME_NAME', $theme_data['Name']);
    define('THEME_AUTHOR', $theme_data['Author']);
    define('THEME_HOMEPAGE', $theme_data['URI']);
    define('THEME_VERSION', trim($theme_data['Version']));

    // POST FORMATS ------------------------------------------------------------//
    /* Disable the Admin Bar. */
    add_filter( 'show_admin_bar', '__return_false' );
    add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'video' ) );

    // Video
    function parseVideo($path){
    $parsedUrl = parse_url($path);

    if($parsedUrl['host'] == 'youtube.com' || $parsedUrl['host'] == 'www.youtube.com'){
    // for youtube
    $embed = $parsedUrl['query'];
    parse_str($embed, $out);
    $embedUrl = $out['v'];
    echo "http://www.youtube.com/embed/$embedUrl";
    }

    if($parsedUrl['host'] == 'vimeo.com' || $parsedUrl['host'] == 'www.vimeo.com'){
    // for vimeo
    $embed = $parsedUrl['path'];
    echo "http://player.vimeo.com/video$embed";
    }
    }

    // LOCALIZATION ------------------------------------------------------------//

    function init_localization(){
    load_theme_textdomain('nova',TEMPLATEPATH . '/languages');
    }
    add_action('after_setup_theme', 'init_localization');

    /*
    // smart quotes remover ----------------------------------------------------//

    remove_filter('the_content', 'wptexturize');
    remove_filter('the_title', 'wptexturize');
    remove_filter('the_excerpt', 'wptexturize');
    remove_filter('comment_text', 'wptexturize');
    */

    // sidebars ----------------------------------------------------------//

    if ( function_exists('register_sidebar') ){

    register_sidebar(array(
    'name' => 'sidebar',
    'before_widget' => '<li>',
    'after_widget' => '</li>',
    'before_title' => '<h6>',
    'after_title' => '</h6>'
    ));

    register_sidebar(array(
    'name' => 'Footer',
    'before_widget' => '<li class="col">',
    'after_widget' => '</li>',
    'before_title' => '<h6>',
    'after_title' => '</h6>',

    ));

    }

    // ADD FRONTEND JS SCRIPTS ----------------------------------------------------//

    function load_js_scripts() {
    if ( !is_admin() ) {
    // General JS
    wp_enqueue_script( 'jquery' );
    wp_enqueue_script( 'custom', JSPATH . "custom.js" );
    wp_enqueue_script( 'rotate', JSPATH . "jQueryRotate.2.2.js" );
    wp_enqueue_script( 'boxSlider', JSPATH . "jquery.bxslider.js" );
    wp_enqueue_script( 'easing', JSPATH . "easing.js" );
    wp_enqueue_script( 'isotope', JSPATH . "jquery.isotope.min.js" );
    // wp_enqueue_script( 'jqueryui', JSPATH . "jquery-ui-1.8.13.custom.min.js" );

    // General CSS
    wp_enqueue_style('general-styles', CSSPATH . 'style.css');
    wp_enqueue_style('cagri-styles', CSSPATH . 'cagri-style.css');
    // wp_enqueue_style('boxslider-styles', CSSPATH . 'jquery.bxslider.css');

    wp_enqueue_style('social-icons', CSSPATH . 'social-icons.css');

    // Scrollto JS
    wp_enqueue_script('scrollTo', JSPATH . 'jquery.scrollTo-1.4.2-min.js');

    // Cycle all JS
    wp_enqueue_script('cycleAll', JSPATH . 'jquery.cycle.all.js', array('jquery'), '2', true);

    // superfish JS
    wp_enqueue_script('hoverIntent', JSPATH . 'superfish-1.4.8/js/hoverIntent.js');
    wp_enqueue_script('superfish', JSPATH . 'superfish-1.4.8/js/superfish.js');
    wp_enqueue_script('supersubs', JSPATH . 'superfish-1.4.8/js/supersubs.js');
    // superfish CSS
    wp_enqueue_style('superfish', CSSPATH . 'superfish.css');

    // Poshytip JS
    /* wp_enqueue_script('poshytip', JSPATH . 'poshytip-1.0/src/jquery.poshytip.min.js');
    // Poshytip CSS
    wp_enqueue_style('poshytip-twitter', JSPATH . 'poshytip-1.0/src/tip-twitter/tip-twitter.css');
    wp_enqueue_style('poshytip-yellow', JSPATH . 'poshytip-1.0/src/tip-yellowsimple/tip-yellowsimple.css');*/

    // Prettyphoto JS
    wp_enqueue_script('prettyPhoto', JSPATH . 'prettyPhoto/js/jquery.prettyPhoto.js');
    // Prettyphoto CSS
    wp_enqueue_style('prettyPhoto', JSPATH . 'prettyPhoto/css/prettyPhoto.css');

    // Google fonts
    wp_enqueue_style('googleFonts', 'http://fonts.googleapis.com/css?family=' . ansimuzFontFamily());

    // Tweet JS
    wp_enqueue_script('tweet', JSPATH . 'tweet/jquery.tweet.js');

    /* // Tabs JS
    wp_enqueue_script('tabs', JSPATH . 'tabs.js');
    // Tabs CSS
    wp_enqueue_style('tabs', CSSPATH . 'tabs.css');*/

    // Nivo JS
    wp_enqueue_script('nivo', JSPATH . 'nivo-slider/jquery.nivo.slider.js');
    // Nivo CSS
    wp_enqueue_style('nivoCss', CSSPATH . 'nivo-slider.css');

    // Slides
    wp_enqueue_script('slidesJS', JSPATH . 'slides.min.jquery.js');
    /*
    // Fancy JS
    wp_enqueue_script('fancyBox', JSPATH . 'jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack.js');
    // Fancy CSS
    wp_enqueue_style('fancyBoxCss', JSPATH . 'jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.css');*/

    }
    }
    add_action('init', 'load_js_scripts');

    // ADD ADMIN JS SCRIPTS ----------------------------------------------------//

    function load_custom_wp_admin_scripts(){

    // scripts
    wp_enqueue_script('jquery-ui-encore');
    wp_enqueue_script('jquery-ui-sortable');
    wp_enqueue_script('jquery-appendo', ADMIN_URI . '/js/jquery.appendo.js', false, '1.0', false);
    wp_enqueue_script('slider-manager', ADMIN_URI . '/js/custom-admin.js', false, '1.0', false);

    // Mini colors
    wp_enqueue_script('miniColors', ADMIN_URI . '/js/jquery.miniColors-0.1/jquery.miniColors.min.js', false, '1.0', false);
    wp_enqueue_style('miniColors', ADMIN_URI . '/js/jquery.miniColors-0.1/jquery.miniColors.css', false, '1.0', 'all');

    // styles
    wp_enqueue_style('slider-manager', ADMIN_URI . '/css/admin-styles.css', false, '1.0', 'all');
    }
    add_action('admin_enqueue_scripts', 'load_custom_wp_admin_scripts');

    #--------------------------------------------------------------------
    #
    # QUFORM
    #
    #--------------------------------------------------------------------

    function mytheme_get_first_name($value)
    {
    if (is_user_logged_in()) {
    global $current_user;
    get_currentuserinfo();
    $value = $current_user-&gt;user_firstname;
    }

    return $value;
    }
    add_filter('iphorm_element_value_fname', 'mytheme_get_first_name');

    function mytheme_get_last_name($value)
    {
    if (is_user_logged_in()) {
    global $current_user;
    get_currentuserinfo();
    $value = $current_user-&gt;user_lastname;
    }

    return $value;
    }
    add_filter('iphorm_element_value_lname', 'mytheme_get_last_name');

    // Enable support for thumbnails -----------------------------//

    add_theme_support('post-thumbnails');
    if( function_exists('add_theme_support') ){
    add_theme_support('post-thumbnails');
    add_image_size( 'ansimuz-front-page', 282, 9999, false );
    add_image_size( 'ansimuz-post-feature', 596, 9999, false );
    add_image_size( 'ansimuz-post-work', 438, 9999, false );
    add_image_size( 'cagri-thumbs', 70, 70, false );
    }

    add_filter('post_thumbnail_html', 'thumbnail_html', 10, 3);
    function thumbnail_html($html, $post_id, $post_image_id){
    $link = get_permalink($post_id);
    $title = esc_attr(get_post_field('post_title', $post_id));
    $html = '<a href="'.$link.'" title="'.$title.'">'.$html.'</a>';
    return $html;
    }

    // Enable Nav Menu -----------------------------//

    if ( function_exists( 'add_theme_support' ) )
    add_theme_support ('nav-menus');

    function register_ansimuz_menu() {
    register_nav_menus (array(
    'main' => __('Main Navigation', 'main' )
    ));
    }
    add_action('init', 'register_ansimuz_menu' );

    // adds nav menu if exists if not add regular menu
    function ansimuz_menu(){

    wp_nav_menu( array(
    'menu' => 'main_menu',
    'menu_id' => 'nav',
    'menu_class' => 'sf-menu',
    'theme_location' => 'main',
    'fallback_cb' => 'regular_ansimuz_menu',
    'walker' => new description_walker()
    ));
    }

    function regular_ansimuz_menu(){
    ?>
    <ul id="nav" class="sf-menu">
    <?php wp_list_pages('title_li=&sort_column=menu_order, post_title&show_home=1'); ?>
    </ul>
    <?php
    }

    #--------------------------------------------------------------------
    #
    # CUSTOM FUNCTIONS
    #
    #--------------------------------------------------------------------

    // Returns logo path ----------------------------------------------------//

    function ansimuz_logo(){
    $src = (get_option('ansimuz_logo') != '') ? get_option('ansimuz_logo') : get_template_directory_uri() . '/img/logo.png';
    echo '<a href="'.get_bloginfo('url').'"><img id="logo" src="'.$src.'" alt="'.get_bloginfo('name').'" /></a>';
    }

    // Searchform ----------------------------------------------------//

    function ansimuz_searchform(){
    // filter visibility
    if( get_option('ansimuz_search_display') == ''):

    // get the last search...
    $last_search = esc_attr( apply_filters( 'the_search_query' , get_search_query() ) );
    if($last_search != ""){
    $search_string = $last_search;
    }else{
    $search_string = __("Search...", 'nova');
    }

    // Search box string
    $search_box = '
    <div class="top-search">
    <form method="get" id="searchform" action="'.home_url().'">
    <div>
    <input type="text" value="'.$search_string.'" name="s" id="s" onfocus="defaultInput(this,\''.$search_string.'\')" onblur="clearInput(this,\''.$search_string.'\')" />
    <input type="submit" id="searchsubmit" value=" " />
    </div>
    </form>
    </div>
    ';

    echo $search_box;
    endif;
    }

    // Social bar display -----------------------------------------------//

    function ansimuz_social_bar(){
    if( get_option('ansimuz_social_bar_display') == ''){
    ?>
    <ul class="social <?php echo get_option('ansimuz_social_icon_style') ?>">
    <?php
    $social_links = get_option('social_links');
    if($social_links != "" ):
    foreach($social_links as $k => $link):
    $social_caption = ( $link['caption'] == "") ? "" : "title='".$link['caption']."'";
    $use_poshytip = ($link['caption'] == "") ? "" : " poshytip ";
    ?>

    <li><a href="<?php echo $link['link'] ?>" class="<?php echo $link['class'] . $use_poshytip ?>" <?php echo $social_caption ?>></a></li>

    <?php endforeach; ?>
    <?php endif; ?>
    </ul>
    <?php
    }
    }

    // nivo-slider ----------------------------------------------------//

    function ansimuz_slider(){
    $slides = get_option('slides');
    if(get_option('ansimuz_slider_display') == '' && $slides != ""){
    ?>
    <div id="slider-block">
    <div id="slider-holder">
    <div id="slider">
    <?php foreach($slides as $k => $slide): ?>
    <a href="<?php echo $slide['link'] ?>">
    <img src="<?php echo $slide['src'] ?>" alt="" title="<?php echo $slide['caption'] ?>" /></a>
    <?php endforeach; ?>
    </div>
    </div>
    </div>
    <?php
    }//if
    }

    // Custom styles ----------------------------------------------------//

    function ansimuz_custom_styles(){
    if(get_option("ansimuz_bg_default") != 'checked'):
    ?>
    <style type="text/css" >
    body {
    <?php
    // set background
    $bg_path = ansimuz_get_default_bg();
    $bg_predefined = get_option('ansimuz_bg_predefined');
    $bg_color = get_option('ansimuz_bg_color');
    $bg_repeat = get_option('ansimuz_bg_repeat');
    if( $bg_path != ''){
    echo " background-image: url(".$bg_path.");";
    echo "background-position: top left;";
    }
    if( $bg_predefined != ''){
    echo " background-image: url(".$bg_predefined.");";
    echo "background-position: top left;";
    }
    if( $bg_color != ''){
    echo "background-color: ".$bg_color.";";
    }
    if( $bg_repeat != ''){
    echo "background-repeat: ".$bg_repeat.";";
    }
    if( $font_color != ''){
    echo "color: #".$font_color.";";
    }
    ?>
    }

    </style>
    <?php
    endif;
    }

    // Returns the set background ----------------------------------------------------//

    function ansimuz_get_default_bg(){
    return (get_option('ansimuz_bg_path')=='') ? get_bloginfo('template_directory') . "/img/bg/patterns/noise.png": get_option('ansimuz_bg_path') ;
    }

    // Ads by ansimuz ----------------------------------------------------//

    function ansimuz_ads(){
    ?>
    <a href="http://luiszuno.com"><img src="<?php echo get_template_directory_uri() ?>/admin/img/get-free-files.png" alt="Get free files" style="float:right;" /></a>

    <a href="http://themeforest.net/user/Ansimuz/portfolio?ref=ansimuz"><img src="<?php echo get_template_directory_uri() ?>/admin/img/buy-premium-files.png" alt="Buy premium files" style="float:right; margin-right: 5px;" /></a>

    <div style="clear:both;"></div>
    <?php
    }

    // Set js vars ----------------------------------------------------//

    function ansimuz_set_js_vars(){
    // get php variables for js

    //
    if(get_option('ansimuz_tweet') == ''){
    $twitter_user = 'ansimuz';
    }else{
    $twitter_user = get_option('ansimuz_tweet');
    }
    //
    if(get_option('ansimuz_tweet_number') == ''){
    $twitter_number = '3';
    }else{
    $twitter_number = get_option('ansimuz_tweet_number');
    }
    //
    echo "<script type='text/javascript'>\n" ;
    // twitter
    echo "twitter_user = '".$twitter_user."';\n";
    echo "twitter_number = '".$twitter_number."';\n";
    echo "</script>";
    }

    // Front front tabs ----------------------------------------------------//

    function ansimuz_front_tabs(){
    $front_tabs = get_option('front_tabs');
    if($front_tabs != ""): ?>

    <!-- tabs-->
    <ul class="tabs">
    <?php foreach($front_tabs as $k => $v): ?>
    <li><a href="#"><span><?php echo $v['ansimuz_front_tab_label'] ?></span></a></li>
    <?php endforeach ?>
    </ul>
    <!-- ENDS tabs -->

    <!-- panes -->
    <div class="panes">
    <?php foreach($front_tabs as $k => $v): ?>
    <div>

    <?php if($v['ansimuz_front_tab_type'] == 'text'): ?>
    <?php echo '<div class="plain-text">' . $v['ansimuz_front_tab_text'] .'</div>' ?>
    <?php else: ?>
    <ul class="blocks-thumbs thumbs-rollover"><?php ansimuz_tabs_items($v) ?></ul>
    <?php endif; ?>
    </div>
    <?php endforeach; ?>
    </div>
    <!-- ENDS panes -->

    <?php endif;
    }

    // Front tabs elements ----------------------------------------------------//

    function ansimuz_tabs_items($v){

    // get config
    $type = $v['ansimuz_front_tab_type'];
    $nPosts = $v['ansimuz_front_tab_number'];
    $includePosts = $v['ansimuz_front_tab_include'];
    $nPosts = ($nPosts == '') ? 3 : $nPosts;

    // set category if it is not a page
    if($type != 'page'){
    $categorySlug = $v['ansimuz_front_tab_category'];
    }

    $args = array(
    'post_type' => $type,
    'numberposts' => $nPosts,
    'include' => $includePosts,
    'category_name' => $categorySlug
    );
    $myposts = get_posts($args);

    global $post;
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>

    <li>
    <div class="thumb"><?php the_post_thumbnail("ansimuz-front-page"); ?></div>

    <div class="the-excerpt">
    <div class="header"><?php the_title() ?></div>
    <?php the_excerpt() ?>
    <a href="<?php the_permalink() ?>" class="link-button"><span><?php _e('Read more','nova') ?> →</span></a>
    </div>
    </li>

    <?php endforeach; ?>

    <?php
    }

    // Seo functions -------------------------------------------------//

    function ansimuz_seo(){
    // title
    echo '<title>';
    if(get_option('ansimuz_SEO') == '' ):
    echo wp_title('', false) . ' | ' . get_bloginfo('name');
    else:
    ansimuz_seo_title();
    endif;
    echo '</title>';

    // metas
    if(get_option('ansimuz_SEO') != '' ) ansimuz_seo_metas();
    }

    function ansimuz_seo_title(){
    $out = '';
    $out = get_option('ansimuz_SEO_page_title');

    // replace tags
    $out = str_replace('%blog_title%', get_bloginfo('name'), $out);
    $out = str_replace('%blog_description%', get_bloginfo('description'), $out);
    $out = str_replace('%page_title%', wp_title('', false), $out);

    echo $out;

    }

    function ansimuz_seo_metas(){

    // only home page flag
    $only_home = (get_option('ansimuz_SEO_only_home') == 'checked' ) ? true : false;

    // If there are keywords...
    if(get_option('ansimuz_SEO_meta_keywords') != '' ):
    // show for all pages
    if(!$only_home):
    ?>
    <meta name="keywords" content="<?php echo get_option('ansimuz_SEO_meta_keywords') ?>">
    <?php
    else:
    // show only on home page
    if(is_front_page()):
    ?>
    <meta name="keywords" content="<?php echo get_option('ansimuz_SEO_meta_keywords') ?>">
    <?php
    endif;
    endif;
    endif;

    // If there are description...
    if(get_option('ansimuz_SEO_meta_description') != '' ):
    ?>
    <meta name="description" content="<?php echo get_option('ansimuz_SEO_meta_description') ?>">
    <?php
    endif;
    }

    // Pagination ----------------------------------------------//

    function ansimuz_pagination($pages = '', $range = 2){

    // Fake post nav to avid warning
    $foo = '';
    if($foo) posts_nav_link();

    $showitems = ($range * 2)+1;

    global $paged;
    if(empty($paged)) $paged = 1;

    if($pages == ''){
    global $wp_query;
    $pages = $wp_query->max_num_pages;
    if(!$pages){
    $pages = 1;
    }
    }

    if(1 != $pages){
    echo "<ul class='pager'>";
    // First page
    if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<li class='first-page'><a href='".get_pagenum_link(1)."'>&laquo;</a></li>";
    // Prev page
    if($paged > 1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link($paged - 1)."'>&lsaquo;</a></li>";

    // page links
    for ($i=1; $i <= $pages; $i++){
    if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )){
    echo ($paged == $i)? "<li class='active'><a href='#'>".$i."</a></li>":"<li><a href='".get_pagenum_link($i)."' >".$i."</a></li>";
    }
    }

    // Next page
    if ($paged < $pages && $showitems < $pages) echo "<li><a href='".get_pagenum_link($paged + 1)."'>&rsaquo;</a></li>";

    // Last page
    if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<li class='last-page'><a href='".get_pagenum_link($pages)."'>&raquo;</a></li>";
    echo "</ul>";
    }

    echo '<br class="clear"></br>';
    }

    #--------------------------------------------------------------------
    #
    # CATEGORIES NAV
    #
    #--------------------------------------------------------------------

    // Categories list ------------------------------------------//

    function categoriesNav($title, $taxonomy){
    ?>
    <ul class="filter">
    <li><span><?php echo $title ?> </span> </li>
    <?php
    $args = array(
    'taxonomy' => $taxonomy
    );
    $categories = get_categories( $args );
    foreach($categories as $cat){
    $sel = ($cat->slug == getCurrentTaxSlug() ) ? 'class="active"' : '';
    echo '<li '.$sel.' ><a href="'.get_term_link($cat->slug, $taxonomy).'">'.$cat->name.'</a></li>';
    } ?>
    </ul>
    <?php
    }

    // get Current taxonomy slug ------------------------------------------//

    function getCurrentTaxSlug(){
    global $wp_query;
    $cat_obj = $wp_query->get_queried_object();
    return $cat_obj->slug;
    }

    // get Current taxonomy name ------------------------------------------//

    function getCurrentTaxName(){
    global $wp_query;
    $cat_obj = $wp_query->get_queried_object();
    return $cat_obj->name;
    }

    #--------------------------------------------------------------------
    #
    # FONT FAMILY
    #
    #--------------------------------------------------------------------

    $defaultFontFamily = 'Ubuntu';

    // Print CSS google fonts ----------------------------------------------------//

    function ansimuz_set_googleFonts(){
    $font = (get_option('ansimuz_fontfamily') == '') ? $defaultFontFamily : ansimuzFontFamilyName();
    ?>
    <style type="text/css" >
    h1,h2,h3,h4,h5,h6,
    #page-title .title,
    #headline>span.main,
    #comments-block .n-comments-text{ font-family: <?php echo $font ?>, arial, serif;}
    </style>
    <?php
    }

    // Returns the font family name -------------------------------------------------//

    function ansimuzFontFamily(){
    return (get_option('ansimuz_fontfamily') == '') ? $defaultFontFamily : get_option('ansimuz_fontfamily');
    }

    // Returns the font family name without the + chars ------------------------------------------//

    function ansimuzFontFamilyName(){
    return str_replace('+', ' ', get_option('ansimuz_fontfamily'));
    }

    // gets the background

    function ansimuz_bg(){
    global $post;

    // If theres an specific bg for this page
    $bg_cf = get_post_meta($post->ID, 'bg', true);
    if( $bg_cf ){
    $bg = $bg_cf;
    }else{
    if(get_option('ansimuz_resize_bg') == "") $bg = ansimuz_get_default_bg();
    }
    ?>
    <img src="<?php echo $bg ?>" id="bg" alt="">
    <div id="no-bg-click"></div>
    <?php
    }

    #--------------------------------------------------------------------
    #
    # OPTIONS PANEL
    #
    #--------------------------------------------------------------------

    function themeoptions_admin_menu(){
    // menu
    add_menu_page('nova', __('Nova Settings','nova'), 'read', 'ansimuz-menu', 'load_edit_page', get_template_directory_uri() .'/admin/img/bag32.png');
    add_submenu_page( 'ansimuz-menu', __('General settings','nova'), __('General settings','nova'), 'read', 'ansimuz-menu', 'load_edit_page');
    add_submenu_page( 'ansimuz-menu', __('Appearance','nova'), __('Appearance','nova'), 'read', 'appearance', 'load_edit_page');
    add_submenu_page( 'ansimuz-menu', __('Front page','nova'), __('Front page','nova'), 'read', 'front', 'load_edit_page');
    add_submenu_page( 'ansimuz-menu', __('SEO','nova'), __('SEO','nova'), 'read', 'seo', 'load_edit_page');
    add_submenu_page( 'ansimuz-menu', __('Slider','nova'), __('Slider','nova'), 'read', 'slider', 'load_edit_page');
    add_submenu_page( 'ansimuz-menu', __('Social networks','nova'), __('Social networks','nova'), 'read', 'social', 'load_edit_page');
    add_submenu_page( 'ansimuz-menu', __('Contact','nova'), __('Contact','nova'), 'read', 'contact', 'load_edit_page');
    }

    // Load the corresponding editing page
    function load_edit_page(){
    //default page
    if($_GET['page'] == 'ansimuz-menu'){
    include_once('admin/general.php');
    }else{
    include_once('admin/'.$_GET['page'].'.php');
    }
    }

    // init menu
    add_action('admin_menu', 'themeoptions_admin_menu');

    #--------------------------------------------------------------------
    #
    # EXTENDING CLASSES
    #
    #--------------------------------------------------------------------

    // Adds the description to the menu

    class description_walker extends Walker_Nav_Menu
    {
    function start_el(&$output, $item, $depth, $args)
    {
    global $wp_query;
    $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';

    $class_names = $value = '';

    $classes = empty( $item->classes ) ? array() : (array) $item->classes;

    $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
    $class_names = ' class="'. esc_attr( $class_names ) . '"';

    $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';

    $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
    $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
    $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
    $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';

    $prepend = '';
    $append = '';
    $description = ! empty( $item->description ) ? '<span class="subheader">'.esc_attr( $item->description ).'</span>' : '';

    if($depth != 0)
    {
    $description = $append = $prepend = "";
    }

    $item_output = $args->before;
    $item_output .= '<a'. $attributes .'>';
    $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
    $item_output .= $description.$args->link_after;
    $item_output .= '</a>';
    $item_output .= $args->after;

    $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
    }
    }

    #3904
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #15032
    smart367
    Participant

    I realize this post is right at 2 yrs old but THANKS!!! This saved me so much time, it was exactly what I was looking to do. Using dynamic values from an existing table is making my project a breeze.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy