• Portfolio
    • Posters & Logos
    • Websites
    • Galleries
    • Blog
    • About
  •  
  • View All
  • |
  • Design
  • Featured
  • HTML & CSS
  • Misc
  • PHP
  • Uncategorized
  • Wordpress
  • PHP : acronym : Hypertext Preprocessor : a popular general-purpose server side scripting language which can be embedded into HTML to create a wide variety of mini-applications, but can also be used to build large-scale complex applications.
  •  Saturday August 27th, 2011
    Posted in PHP & Wordpress
    Share: Twitter · Facebook
    No comments

  • Get IDs of WordPress Menu Items

    Saturday August 27th, 2011
    Posted in PHP & Wordpress
    Share: Twitter · Facebook
    No comments

    WordPress 3 introduced Custom Menu’s, which is a great feature, but when calling a menu with wp_nav_menu() it builds the menu with the ID’s relative to the menu itself, and not the actual object ID’s the menu items represent.

    I needed to get the ID’s of a menu list, here’s how I did it:

    function get_ids_of_nav_menu($nav_slug) {                              
     
        // lets get all wordpress menus
        $terms   = get_terms('nav_menu');
     
        // cycle through terms (custom menus) and find $nav_slug
        $term_id = '';
        foreach ($terms as $aterm) {
           if ($aterm->;slug == $nav_slug || $aterm->name == $nav_slug)
                $term_id = $aterm->term_id;    
        }
     
        // get all objects in found menu
        $items        = get_objects_in_term( $term_id , 'nav_menu' );
     
        // get the custom navigations ID's of pages
        $menuids      = array();
        foreach ($items as $uselss => $menu_id) {
           $realitem                       = get_post($menu_id);
           $object_id                      = get_post_meta( $realitem->ID, '_menu_item_object_id', true );
           // get the specified menu order, use as key for sorting after
           $menuids[$realitem->menu_order] = array('menu_id' => $menu_id, 'object_id' => $object_id );
        }
     
        // order by the the custom menu as seen in appearance > menus
        ksort($menuids);
     
        // rebuid & the array
        $return = array();
        foreach ($menuids as $order => $ids) {
           $return[$ids['menu_id']] = $ids['object_id'];
        }
        return $return;
    }
  •  Sunday May 22nd, 2011
    Posted in PHP & Wordpress
    Share: Twitter · Facebook
    No comments

  • List Tweets with WordPress

    Sunday May 22nd, 2011
    Posted in PHP & Wordpress
    Share: Twitter · Facebook
    No comments

    The provided widgets that social networking sites like Twitter make offer for external web sites, are not my favourite – I understand the logic behind them; trying to make something consistent, universal, visually flexible, recognizable, ect.. but some sites integration of the social networking tools, are just horrible -

    I believe every site should have a social networking feeds.. it shows you’re an active user and it keep your followers interested – but I also believe it has to look good.

    I use Twitter for my networking (because it has relatively no ads), so I’ve written this script to pull tweets from a users RSS feed, then format the tweets any way I want. It’s on my site as well as hey-you.ca in the footers.

    (If you can’t find your twitter ID in the source code of your twitter page, get it from this site)

    The function can be called from your footer.php or whichever file like so:

    <?
    echo "<h1>Tweets</h1>" .
          yourplugin_twitter_feed('123456789');
    ?>

    ..continue reading

    Tags: how to rss twitter, rss twitter, timeline, tweet timeline, Tweets, Twitter feed, twitter wordpress
  •  Wednesday March 23rd, 2011
    Posted in PHP & Wordpress
    Share: Twitter · Facebook
    No comments

  • Drop and Drag multiple lists (Mootools)

    Wednesday March 23rd, 2011
    Posted in PHP & Wordpress
    Share: Twitter · Facebook
    No comments

    I’m using a cut down version of David Walsh’s drop and drag tutorial for my WordPress Plugin to reorder lists of posts within categories. I needed the snippet to work on multiple lists (not drag-able between lists, but multiple implementations of the drop-and-drag) so I edited the script a little and got this:

        // dynamic num of lists
        $numoflists = 2; //from database
        $order = array();
     
        //array of ID's in order for saving/processing
        if (isset($_POST)) {
            $postorder_ids = @explode(',',$_POST['sort_order']);
           //do something with $postorder_ids
        }
     
        //build the dynamic javascript
        $list_vars    = '';
        $sort_order = '';
        $get_ids      = '';
        $make_sort  = '';
        for($i = 0; $i != $numoflists; $i++) {
            $list_vars .= "
            var list{$i} = document.id('sortable-list-{$i}');\n\n";
            $sort_order .= "
            list{$i}.getElements('li').each(function(li) {
                sortOrder.push(li.retrieve('id'));
            });\n\n";
            $get_ids .= "
            list{$i}.getElements('li').each(function(li) {
                li.store('id',li.get('title')).set('title','');
            });\n\n";
            $make_sort .= "#sortable-list-{$i} ";
            $make_sort .= ($i == ($numoflists-1)) ? "" : ', ';
        }

    ..continue reading

    Tags: david walsh, drag and drop, mootools, php, wordpress
  • ← Previous Page 
  • Page:   1  |  2                
  •  Next Page →
 
  • David Sword
    David Sword
    Digital Artist & Developer
    davida @daavid_ sword.cacom
    Always having the same reoccurring thought at gym... "damnit, forgot to wear deodorant"
    3 hours ago.

    Follow @david_sword

  • Contact Me


  • Online Print Store
    • limited edition
    • hand signed
    • seq. numbered
    • qlty paper+ink
    • never reprints
    • Paypal/Interac
    Visit Store! →

    Coming soon.

  • Instagram
    • Good eatin

© Copyright 2006 - 2012 David Sword. All Rights Reserved   ∞   Credit & Resources   ∞   Links   ∞   Proudly powered by Wordpress & heyyou   ∞   Mobile Site