Support » Plugins and Hacks » how to add php inside title code for admin bar menu.. please help..

  • How would you add a custom div and php inside title to display the custom menu?

    for example, right now I have:

    if ( $jrjm[jraba_jobroller_job_count] == 1 ) { $wp_admin_bar->add_menu( array('parent' => 'jobroller_job_links','id' => 'jobroller_job_count','title' => __('Job Count', 'jraba'), 'href' =>get_home_url( $blog->userblog_id, '/?s=&radius=1&location=' ) )); }

    But I want to actualy show the count..

    so what I was trying to do is:

    if ( $jrjm[jraba_jobroller_job_count] == 1 ) { $wp_admin_bar->add_menu( array('parent' => 'jobroller_job_links','id' => 'jobroller_job_count','title' => __('<?php $count_pages = wp_count_posts('job_listing'); echo $count_pages->publish; ?> Jobs', 'jraba'), 'href' =>get_home_url( $blog->userblog_id, '/?s=&radius=1&location=' ) )); }

    But it would give me an error: Parse error: syntax error, unexpected T_STRING in E:\wamp\www\wordpress\wp-content\plugins\jraba\menus\jraba-jobroller.php on line 285

    Looking on line 285 it is the code I added

    'title' => __('<?php $count_pages = wp_count_posts('job_listing'); echo $count_pages->publish; ?> Jobs', 'jraba'),

    So how can I make this:
    <?php $count_pages = wp_count_posts('job_listing'); echo $count_pages->publish; ?> Jobs

    work inside this title code

    work inside 'title' => __(' ');

Viewing 3 replies - 1 through 3 (of 3 total)
  • I found an article here that shows you can add search forms..

    http://wpquestions.com/question/show/id/3558

    $form  = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
    $form .= '<input class="adminbar-input" name="s" id="adminbar-search" tabindex="10" type="text" value="" maxlength="150" />';
    $form .= '<input type="submit" class="adminbar-button" value="' . __('Search') . '"/>';
    $form .= '</form>';

    I’ve tested this method, and it works.. but if I add php to the form, it gives the error.. how can I make php work.. any help on this will be greatly appreciated..

    can anyone help me on this? really need help on this..

    Okay so I figured it out..

    function add_jobroller_jobs_bar_menu() { $jrjm = get_option( 'add_jobroller_jobs_bar_menu' ); global $wp_admin_bar;
    if ( !is_super_admin() || !is_admin_bar_showing() ) return; 
    
    $number_pages = wp_count_posts('job_listing'); $number_jobs = $number_pages->publish; echo $number_jobs;
    $jraba_count_job_listings = ' ' . $number_jobs . ' Jobs';

    and then..

    if ( $jrjm[jraba_jobroller_job_count] == 1 ) {
    $wp_admin_bar->add_menu( array(
    'parent' => 'jobroller_job_links',
    'id' => 'jobroller_job_count',
    'title' => $jraba_count_job_listings,
    'href' => get_home_url( $blog->userblog_id, '/?s=&radius=1&location=' ),
    'meta' => array( 'title' => __( 'Jobs Total', 'jraba' ),'class' => 'jraba_count_job_listings','tabindex' => -1, ) ) ); }

    but one problem remains, for some reason the number of jobs/posts is not only showing up in the

  • container of the menu item but also on the wp-admin header, between <div id="wpcontent"> 22 <div id="wpadminbar" class="" role="navigation"> it shows up as 22, but there’s only 2 jobs, so it’s showing it twice.. does any one here have an idea why it does that?..
  • When I remove $number_pages = wp_count_posts('job_listing'); $number_jobs = $number_pages->publish; echo $number_jobs; it goes away, so what can be done to fix this?.. any response would be great full.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to add php inside title code for admin bar menu.. please help..’ is closed to new replies.