Pages

Monday, February 25, 2013

How to get all the children of a specific nav menu item?


$menu_items = wp_get_nav_menu_items('MenuName');
echo '<ul>';
foreach($menu_items as $key => $val){
if($menu_items[$key]->menu_item_parent == 0){
echo '<li>';
echo $menu_items[$key]->title;
$submenuitem = get_nav_menu_item_children($menu_items[$key]->ID, $menu_items);
if(!empty($submenuitem)){
echo '<ul>';
foreach($submenuitem as $skey => $sval){
echo '<li id="post-'.$submenuitem[$skey]->object_id.'">';
echo $submenuitem[$skey]->title;
echo '</li>';
}
echo '</ul>';
}
echo '</li>';
}
}
echo '</ul>';

Monday, February 18, 2013

IE Array indexOf() - resolved

    /* this will work in all browsers(no jQuery needed) */
    if (!Array.indexOf) {
    Array.prototype.indexOf = function (obj, start) {
    for (var i = (start || 0); i < this.length; i++) {
    if (this[i] == obj) {
    return i;
    }
    }
    return -1;
    }
    }
   
    //call
    var i = haystack_array.indexOf("needle")
   
   
    /* or you can use jquery instead */
   
    //call
    var i = jQuery.inArray("needle", haystack_array)

Tuesday, February 12, 2013

jQuery Cycle Effects for Previous and Next


<script> 
$(window).load(function(){
 
 $('#slider').cycle({ 
  fx: 'scrollBothWays',
  next: '#next_slide',
  prev: '#prev_slide',
  speed: 1000,
  timeout: 8000,
  slideshow: true,
  easing : 'easeOutCubic'
 });   
});    
</script> 

<script>
$.fn.cycle.transitions.scrollBothWays = function($cont, $slides, opts) {
 $cont.css('overflow','hidden');
 opts.before.push($.fn.cycle.commonReset);
 opts.fxFn = function(curr, next, opts, cb, fwd) {
  var w = $cont.width();
  opts.cssFirst = { left: 0 };
  opts.animIn   = { left: 0 };
  
  if(fwd){
   opts.cssBefore= { left: w, top: 0 };
   opts.animOut  = { left: 0-w };
  }else{
   opts.cssBefore= { left: -w, top: 0 };
   opts.animOut  = { left: w };
  };
  
  var $l = $(curr), $n = $(next);
  var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut, animOut = opts.animOut, animIn = opts.animIn;
  $n.css(opts.cssBefore);
  var fn = function() {$n.show();$n.animate(animIn, speedIn, easeIn, cb);};
  $l.animate(animOut, speedOut, easeOut, function() {
   if (opts.cssAfter) $l.css(opts.cssAfter);
   if (!opts.sync) fn();
  });
  if (opts.sync) fn();
 };
};
</script>

Tuesday, February 5, 2013

Permission Modes

Example Permission Modes

ModeStr PermsExplanation
0477-r--rwxrwxowner has read only (4), other and group has rwx (7)
0677-rw-rwxrwxowner has rw only(6), other and group has rwx (7)
0444-r--r--r--all have read only (4)
0666-rw-rw-rw-all have rw only (6)
0400-r--------owner has read only(4), group and others have no permission(0)
0600-rw-------owner has rw only, group and others have no permission
0470-r--rwx---owner has read only, group has rwx, others have no permission
0407-r-----rwxowner has read only, other has rwx, group has no permission
0670-rw-rwx---owner has rw only, group has rwx, others have no permission
0607-rw----rwxowner has rw only, group has no permission and others have rwx
See full list 0000 to 0777.

Sunday, February 3, 2013

Image Upload with multiple resolution


           
                $additional_image_name = rand(0,5000).$_FILES['additional_image']['name'];
                $additional_image_name_path = "images/".$additional_image_name;
                copy($_FILES['additional_image']['tmp_name'],$additional_image_name_path);
              
                $file = $additional_image_name_path;
                $img_dbname = $additional_image_name;
               

                require_once(simpleImage.php');
           
                $image = new SimpleImage();

                $dimensions = zen_get_dimension_new($file,'800','800');
                $image->load($file);
                $image->resize($dimensions['width'],$dimensions['height']);
                $image->save($file);

                $dimensions = zen_get_dimension_new($file,'400','400');
                $image->resize($dimensions['width'],$dimensions['height']);
                $filename_medium = 'medium/' . $img_dbname;
                $image->save($filename_medium);

                $dimensions = zen_get_dimension_new($file,'100','100');
                $image->resize($dimensions['width'],$dimensions['height']);
                $filename_medium = 'icons/' . $img_dbname;
                $image->save($filename_medium);

And you can download image file from "http://www.thewebsdevelopment.com/test/simpleImage.zip"