Click here to Skip to main content
15,883,705 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
QuestionPHP find all occurrences of string in file Pin
MicahC5-Jul-13 6:44
MicahC5-Jul-13 6:44 
AnswerRe: PHP find all occurrences of string in file Pin
Graham Breach5-Jul-13 21:20
Graham Breach5-Jul-13 21:20 
GeneralRe: PHP find all occurrences of string in file Pin
MicahC7-Jul-13 19:52
MicahC7-Jul-13 19:52 
GeneralRe: PHP find all occurrences of string in file Pin
MicahC10-Jul-13 5:56
MicahC10-Jul-13 5:56 
QuestionNot much traffic here is there..... Pin
Erudite_Eric16-Jun-13 23:40
Erudite_Eric16-Jun-13 23:40 
AnswerRe: Not much traffic here is there..... Pin
Ali Al Omairi(Abu AlHassan)7-Jul-13 22:18
professionalAli Al Omairi(Abu AlHassan)7-Jul-13 22:18 
QuestionCounting Menu Items & Determining If First/Last Pin
NickBogi7-Jun-13 13:20
NickBogi7-Jun-13 13:20 
AnswerGot It Working Pin
NickBogi10-Jun-13 8:29
NickBogi10-Jun-13 8:29 
I couldn't figure it out except I knew that there must be some native wordpress functionality I could use with wp_nav_menu so I created this code and it works well to have wordpress count and mark first/last (excluding child items for last) with an added function and filter.

Seems to work well. Here it is for anyone else with a similar problem:

PHP
// set first/last class 
function nb_first_last_menu_class( $objects, $args ) { 
     // set first/last class for submenu 
    $ids        = array(); 
    $parent_ids = array(); 
    $top_ids    = array(); 
    foreach ( $objects as $i => $object ) { 
        // If no parent, store the ID, skip object 
        if ( 0 == $object->menu_item_parent ) { 
            $top_ids[$i] = $object; 
            continue; 
        } 
        // don't set first class for submenu 
        if ( ! in_array( $object->menu_item_parent, $ids ) ) { 
            $objects[$i]->classes[] = ''; 
            $ids[]          = $object->menu_item_parent; 
        } 
         // If we didn't set first class for submenu, skip adding the ID 
        if ( in_array( '', $object->classes ) ) 
            continue; 
         // Store the menu parent IDs in an array 
        $parent_ids[$i] = $object->menu_item_parent; 
    } 
    // Remove dup values and pull out last menu item 
    $sanitized_parent_ids = array_unique( array_reverse( $parent_ids, true ) ); 
    // Loop IDs, set last class to the appropriate objects 
    foreach ( $sanitized_parent_ids as $i => $id ) 
        $objects[$i]->classes[] = 'last'; 
    // set classes for top level menu items 
    $objects[1]->classes[] = 'first';  
    $objects[end( array_keys( $top_ids ) )]->classes[] = 'last'; 
    return $objects; 
} 
add_filter( 'wp_nav_menu_objects', 'nb_first_last_menu_class', 10, 2 );

QuestionUrgent !!! Looking for the best solution Pin
MacAriel15-May-13 8:43
MacAriel15-May-13 8:43 
AnswerRe: Urgent !!! Looking for the best solution Pin
herlon21423-Jul-13 9:59
herlon21423-Jul-13 9:59 
QuestionVideo Gallery for wordpress site. Pin
Neha Pandal12-May-13 10:03
professionalNeha Pandal12-May-13 10:03 
AnswerRe: Video Gallery for wordpress site. Pin
Archie22is30-Jun-13 21:07
Archie22is30-Jun-13 21:07 
Questionhow to store QR Code image in mysql with php Pin
blertaaa2-May-13 22:43
blertaaa2-May-13 22:43 
AnswerRe: how to store QR Code image in mysql with php Pin
Prasad Khandekar21-May-13 4:56
professionalPrasad Khandekar21-May-13 4:56 
AnswerRe: how to store QR Code image in mysql with php Pin
Resalat Haque Prodhan27-Jun-13 2:02
Resalat Haque Prodhan27-Jun-13 2:02 
AnswerRe: how to store QR Code image in mysql with php Pin
Rony Sur2-Jul-13 0:04
professionalRony Sur2-Jul-13 0:04 
QuestionHow to install xampp or Lamp in Ubuntu 8 Pin
Member 992947820-Mar-13 20:55
Member 992947820-Mar-13 20:55 
AnswerRe: How to install xampp or Lamp in Ubuntu 8 Pin
Richard MacCutchan20-Mar-13 22:54
mveRichard MacCutchan20-Mar-13 22:54 
AnswerRe: How to install xampp or Lamp in Ubuntu 8 Pin
Mohibur Rashid30-Apr-13 17:19
professionalMohibur Rashid30-Apr-13 17:19 
GeneralRe: How to install xampp or Lamp in Ubuntu 8 Pin
Rony Sur2-Jul-13 0:09
professionalRony Sur2-Jul-13 0:09 
AnswerRe: How to install xampp or Lamp in Ubuntu 8 Pin
Tushar Guru8-Sep-14 22:17
Tushar Guru8-Sep-14 22:17 
QuestionHow to get data from the other website in php Pin
surendra4u20-Mar-13 1:04
surendra4u20-Mar-13 1:04 
AnswerRe: How to get data from the other website in php Pin
dusty_dex20-Mar-13 3:21
dusty_dex20-Mar-13 3:21 
QuestionIRDA without IR Pin
lukeer25-Feb-13 22:30
lukeer25-Feb-13 22:30 
AnswerRe: IRDA without IR Pin
Richard MacCutchan25-Feb-13 23:52
mveRichard MacCutchan25-Feb-13 23:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.