-
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.
-
Get IDs of WordPress Menu Items
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; }
-
List Tweets with WordPress
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.phpor whichever file like so:<? echo "<h1>Tweets</h1>" . yourplugin_twitter_feed('123456789'); ?>
-
Drop and Drag multiple lists (Mootools)
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)) ? "" : ', '; }
- ← Previous Page
- Page: 1 | 2
- Next Page →