Remove Admin Bar from WordPress 3.3

Paste the below code in your ‘functions.php’

// Remove Admin Bar From WP 3.3
if (!function_exists('disableAdminBar')) {

	function disableAdminBar(){

  	remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); // for the admin page
    remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // for the front end

    function remove_admin_bar_style_backend() {  // css override for the admin page
      echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
    }

    add_filter('admin_head','remove_admin_bar_style_backend');

    function remove_admin_bar_style_frontend() { // css override for the frontend
      echo '<style type="text/css" media="screen">
      html { margin-top: 0px !important; }
      * html body { margin-top: 0px !important; }
      </style>';
    }

    add_filter('wp_head','remove_admin_bar_style_frontend', 99);

  }

}

// add_filter('admin_head','remove_admin_bar_style_backend'); // Original version
add_action('init','disableAdminBar'); // New version
Advertisements

Convert stdClass object to Array

function objectToArray($d) {
		if (is_object($d)) {
			// Gets the properties of the given object
			// with get_object_vars function
			$d = get_object_vars($d);
		}
 		if (is_array($d)) {
			/*
			* Return array converted to object
			* Using __FUNCTION__ (Magic constant)
			* for recursive call
			*/
			return array_map(__FUNCTION__, $d);
		}
		else {
			// Return array
			return $d;
	}
	}

Call your Array variable with the function.

objectToArray(Array_variable);

Create user using wp_create_user

<?php

$base = dirname(__FILE__);

    require( dirname(dirname(dirname($base))) .'/wp-blog-header.php');
     
    $user_name =$_POST['signup_username'];
    $user_email = $_POST['signup_email'];
     
    $user_id = username_exists( $user_name );
    if ( !$user_id ) {
    $random_password = wp_generate_password( 12, false );
    $user_id = wp_create_user( $user_name, $random_password, $user_email );
    } else {
    $random_password = __('User already exists. Password inherited.');
    }
?>

WordPress Post attachment MIME Types

function get_attachment_icons($echo = false){
	$sAttachmentString = "<div class='documentIconsWrapper'> \n";
	if ( $files = get_children(array(   //do only if there are attachments of these qualifications
	 'post_parent' => get_the_ID(),
	 'post_type' => 'attachment',
	 'numberposts' => -1,
	 'post_mime_type' => 'application/pdf',  //MIME Type condition
	 ))){
	 foreach( $files as $file ){ //setup array for more than one file attachment
		$file_link = wp_get_attachment_url($file->ID);    //get the url for linkage
		$file_name_array=explode("/",$file_link);
		$file_name=array_reverse($file_name_array);  //creates an array out of the url and grabs the filename
		$sAttachmentString .= "<div class='documentIcons'>";
		$sAttachmentString .= "<a href='$file_link'>";
		$sAttachmentString .= "<img src='".get_stylesheet_directory_uri()."/_inc/images/mime/pdf.png'/>";
		$sAttachmentString .= "</a>";
		$sAttachmentString .= "<br>";
		$sAttachmentString .= "<a href='$file_link'>$file_name[0]</a>";
		$sAttachmentString .= "</div>";
		}
	}
	if ( $files = get_children(array(   //do only if there are attachments of these qualifications
	 'post_parent' => get_the_ID(),
	 'post_type' => 'attachment',
	 'numberposts' => -1,
	 'post_mime_type' => 'image',  //MIME Type condition
	 ))){
	echo gallery_shortcode(get_the_ID());
	}
	//Word Documents
	if ( $files = get_children(array(   //do only if there are attachments of these qualifications
	 'post_parent' => get_the_ID(),
	 'post_type' => 'attachment',
	 'numberposts' => -1,
	 'post_mime_type' => 'application/msword',  //MIME Type condition
	 ))){
	 foreach( $files as $file ){ //setup array for more than one file attachment
		$file_link = wp_get_attachment_url($file->ID);    //get the url for linkage
		$file_name_array=explode("/",$file_link);
		$file_name=array_reverse($file_name_array);  //creates an array out of the url and grabs the filename
		$sAttachmentString .= "<div class='documentIcons'>";
		$sAttachmentString .= "<a href='$file_link'>";
		$sAttachmentString .= "<img src='".get_stylesheet_directory_uri()."/_inc/images/mime/word.png'/>";
		$sAttachmentString .= "</a>";
		$sAttachmentString .= "<br>";
		$sAttachmentString .= "<a href='$file_link'>$file_name[0]</a>";
		$sAttachmentString .= "</div>";
		}
	}
	//Powerpoint Documents
	if ( $files = get_children(array(   //do only if there are attachments of these qualifications
	 'post_parent' => get_the_ID(),
	 'post_type' => 'attachment',
	 'numberposts' => -1,
	 'post_mime_type' => 'application/vnd.ms-powerpoint',  //MIME Type condition
	 ))){
	 foreach( $files as $file ){ //setup array for more than one file attachment
		$file_link = wp_get_attachment_url($file->ID);    //get the url for linkage
		$file_name_array=explode("/",$file_link);
		$file_name=array_reverse($file_name_array);  //creates an array out of the url and grabs the filename
		$sAttachmentString .= "<div class='documentIcons'>";
		$sAttachmentString .= "<a href='$file_link'>";
		$sAttachmentString .= "<img src='".get_stylesheet_directory_uri()."/_inc/images/mime/PowerPoint.png'/>";
		$sAttachmentString .= "</a>";
		$sAttachmentString .= "<br>";
		$sAttachmentString .= "<a href='$file_link'>$file_name[0]</a>";
		$sAttachmentString .= "</div>";
		}
	}
	//Excel Documents
	if ( $files = get_children(array(   //do only if there are attachments of these qualifications
	 'post_parent' => get_the_ID(),
	 'post_type' => 'attachment',
	 'numberposts' => -1,
	 'post_mime_type' => 'application/vnd.ms-excel',  //MIME Type condition
	 ))){
	 foreach( $files as $file ){ //setup array for more than one file attachment
		$file_link = wp_get_attachment_url($file->ID);    //get the url for linkage
		$file_name_array=explode("/",$file_link);
		$file_name=array_reverse($file_name_array);  //creates an array out of the url and grabs the filename
		$sAttachmentString .= "<div class='documentIcons'>";
		$sAttachmentString .= "<a href='$file_link'>";
		$sAttachmentString .= "<img src='".get_stylesheet_directory_uri()."/_inc/images/mime/XLS8.png'/>";
		$sAttachmentString .= "</a>";
		$sAttachmentString .= "<br>";
		$sAttachmentString .= "<a href='$file_link'>$file_name[0]</a>";
		$sAttachmentString .= "</div>";
		}
	}
	//Zipped Files
	if ( $files = get_children(array(   //do only if there are attachments of these qualifications
	 'post_parent' => get_the_ID(),
	 'post_type' => 'attachment',
	 'numberposts' => -1,
	 'post_mime_type' => 'application/zip',  //MIME Type condition
	 ))){
	 foreach( $files as $file ){ //setup array for more than one file attachment
		$file_link = wp_get_attachment_url($file->ID);    //get the url for linkage
		$file_name_array=explode("/",$file_link);
		$file_name=array_reverse($file_name_array);  //creates an array out of the url and grabs the filename
		$sAttachmentString .= "<div class='documentIcons'>";
		$sAttachmentString .= "<a href='$file_link'>";
		$sAttachmentString .= "<img src='".get_stylesheet_directory_uri()."/_inc/images/mime/zip.png'/>";
		$sAttachmentString .= "</a>";
		$sAttachmentString .= "<br>";
		$sAttachmentString .= "<a href='$file_link'>$file_name[0]</a>";
		$sAttachmentString .= "</div>";
		}
	}

	//Audio Files
	$mp3s = get_children(array(   //do only if there are attachments of these qualifications
	 'post_parent' => get_the_ID(),
	 'post_type' => 'attachment',
	 'numberposts' => -1,
	 'post_mime_type' => 'audio',  //MIME Type condition
	 ) );

	if (!empty($mp3s)) :
	$sAttachmentString .= "<ul class='audiofiles'>";
		foreach($mp3s as $mp3) :
    		$sAttachmentString .= "<li>";
			if(!empty($mp3->post_title)) : //checking to make sure the post title isn't empty
				$sAttachmentString .= "<h4 class='title'>".$mp3->post_title."</h4>";
			endif;

			if(!empty($mp3->post_content)) : //checking to make sure something exists in post_content (description)
				$sAttachmentString .= "<p class='description'>".$mp3->post_content."</p>";
			endif;

			$sAttachmentString .= "<object width='438' height='24' id='single".$mp3->ID."' name='single".$mp3->ID."'>";
				$sAttachmentString .= "<param name='movie' value='player.swf'>";
				$sAttachmentString .= "<param name='allowfullscreen' value='true'>";
				$sAttachmentString .= "<param name='allowscriptaccess' value='always'>";
				$sAttachmentString .= "<param name='wmode' value='transparent'>";
				$sAttachmentString .= "<param name='flashvars' value='file=".$mp3->guid."'>";
					$sAttachmentString .= "<embed ";
					  $sAttachmentString .= "id='single".$mp3->ID."' ";
					  $sAttachmentString .= "name='single".$mp3->ID."' ";
					  $sAttachmentString .= "src='".get_stylesheet_directory_uri()."/_inc/images/player.swf' ";
					  $sAttachmentString .= "width='438' ";
					  $sAttachmentString .= "height='24' ";
					  $sAttachmentString .= "bgcolor='#ffffff' ";
					  $sAttachmentString .= "allowscriptaccess='always' ";
					  $sAttachmentString .= "allowfullscreen='true' ";
					  $sAttachmentString .= "flashvars='file=".$mp3->guid."' ";

					$sAttachmentString .= "/>";
			$sAttachmentString .= "</object>";
                        $sAttachmentString .= "<a href='".$mp3->guid."'>Download</a>";
			$sAttachmentString .= "</li>";
		endforeach;
	$sAttachmentString .= "</ul>";
	endif;	
	
	//Video Files
	$mpeg3s = get_children(array(   //do only if there are attachments of these qualifications
	 'post_parent' => get_the_ID(),
	 'post_type' => 'attachment',
	 'numberposts' => -1,
	 'post_mime_type' => 'video/mp4',  //MIME Type condition
	 ) );

	if (!empty($mpeg3s)) :
	$sAttachmentString .= "<ul class='videofiles'>";
		foreach($mpeg3s as $mp3) :
    		$sAttachmentString .= "<li>";
			if(!empty($mp3->post_title)) : //checking to make sure the post title isn't empty
				$sAttachmentString .= "<h4 class='title'>".$mp3->post_title."</h4>";
			endif;

			if(!empty($mp3->post_content)) : //checking to make sure something exists in post_content (description)
				$sAttachmentString .= "<p class='description'>".$mp3->post_content."</p>";
			endif;

			$sAttachmentString .= "<object width='700' height='400' id='single".$mp3->ID."' name='single".$mp3->ID."'>";
				$sAttachmentString .= "<param name='movie' value='player.swf'>";
				$sAttachmentString .= "<param name='allowfullscreen' value='true'>";
				$sAttachmentString .= "<param name='allowscriptaccess' value='always'>";
				$sAttachmentString .= "<param name='wmode' value='transparent'>";
				$sAttachmentString .= "<param name='flashvars' value='file=".$mp3->guid."'>";
					$sAttachmentString .= "<embed ";
					  $sAttachmentString .= "id='single".$mp3->ID."' ";
					  $sAttachmentString .= "name='single".$mp3->ID."' ";
					  $sAttachmentString .= "src='".get_stylesheet_directory_uri()."/_inc/images/player.swf' ";
					  $sAttachmentString .= "width='700' ";
					  $sAttachmentString .= "height='400' ";
					  $sAttachmentString .= "bgcolor='#ffffff' ";
					  $sAttachmentString .= "allowscriptaccess='always' ";
					  $sAttachmentString .= "allowfullscreen='true' ";
					  $sAttachmentString .= "flashvars='file=".$mp3->guid."' ";

					$sAttachmentString .= "/>";
			$sAttachmentString .= "</object>";
                        $sAttachmentString .= "<a href='".$mp3->guid."'>Download</a>";
			$sAttachmentString .= "</li>";
		endforeach;
	$sAttachmentString .= "</ul>";
	endif;	
	
$sAttachmentString .= "</div>";
if($echo){
    echo $sAttachmentString;
  }
  return $sAttachmentString;
}
add_shortcode('attachment_icons', 'get_attachment_icons');
get_attachment_icons($echo=true);
<style>
.documentIcons{
float:left;
height:125px;
line-height:30px;
overflow:hidden;
padding:10px;
text-align:center;
width:125px;
}
.documentIcons a{
font-size:10px;
line-height:13px;
}
.documentIcons img{
border:0px solid #606060;
}
.documentIconsWrapper ul.audiofiles, .documentIconsWrapper ul.videofiles{
float:left;
width:100%;
margin:0;
}
.audiofiles li{
list-style:none outside none;
margin:20px 5px;
padding:12px;
width:438px;
float:left;
}
.videofiles li{
list-style:none outside none;
margin:20px 5px;
padding:12px;
width:100%;
float:left;
clear:both;
text-align:center;
}
.videofiles li a {float:left;width:100%;}
</style>

Source : http://tgrayimages.com/automate-file-attachments-on-your-wordpress-posts/