Friday, 31 January 2014

Uploading Image ffiles Default wordpress upload


     <?php
    require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');

?>
<input type="file" name="file-upload" id="file-upload" /><select name="post_id" required="true">
 
/*************************************************************************/       
        if ( ! function_exists( 'wp_handle_upload' ) ) require_once( ABSPATH . 'wp-admin/default/file.php' );
$uploadedfile = $_FILES['file'];
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
if ( $movefile ) {
    echo '<div id="msg">'.'File is valid, and was successfully uploaded'.'</div>';
    var_dump( $movefile);
   
} else {
    echo '<div id="msg">'.'Possible file upload attack!'.'</div>';
}
/********************************************************************/

Saturday, 25 January 2014

Add text box dynamicaly in javascript

Custom html and javascript cde 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$('document').ready(function() {
    //alert('ffdfd');
$("#txt1").keydown(function(e) {
    var order = e.which;
    //alert(order);
    if ( e.which === 13 ) {
        // Disable line break
        textChange(order);
        e.preventDefault();

        // Do things

    }
});
});
    function textChange(event1){
        var event=event1;
    // Get the number of the caller's id
    var i=0;
   
    alert(i);
   
    $("#me").append("<input type='text' id='txt1'/>");
    }
</script>
<from id="me" name="me" >
    <input type="text" id="txt1"/><input type="submit" value="submit">
</form>

code for wordpress
<script type="text/javascript">
    $(document).ready(function($)
    {
   
$("#logo").keydown(function(e) {
    var order = e.which;
    //alert(order);
    //textChange(order);
    if ( e.which === 13 ) {
        // Disable line break
        textChange(order);
        e.preventDefault();

        // Do things

    }
});
 function textChange(event1){
    var i;
    i=i+1;
    //$("#insertnew").html("<input type='text' id='"+i+"'value='know my value'/>");
   
   
    $("#insertnew").append("<br><input type='text' id='ss"+i+++"'value='know my value'/>");
    i++;

}
   
    });
</script>

Thursday, 23 January 2014

ADD WIDGET AREA TO TEMPLATE In Admin panel

PLEASE BACK UP YOUR WORDPRESS THEME BEFORE EDITING ANY PHP FILES, just incase…
below is a chunk of code that tells WordPress that you want to register a new widget area for your website. It needs to be pasted into yourfunctions.php file. You can find this by logging into your WordPress dashboard, then clicking on Appearance, then click Editor, then select functions.php. If you do not have any of these options in your theme it is most likely that your theme developer / web designer has blocked your from accessing them, so please contact them with further questions.

if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'Extra Widgets',
'id' => 'extra-widgets',
'description' => 'The extra widgets for your website.',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
}
Now WordPress will add a new Widget area called Extra Widgets. This is because as you can see in the code above, I gave it the ‘name’ Extra Widgets. If I had called the ‘name’ value ‘Header Widget’ for example, then I would have a widget area called Header Widget, in my WordPress widget control panel. Wow thats a lot of widgets in a sentence!
IMPORTANT NOTE!
This code can be copied and pasted into your functions.php as many times as you want, to make as many widget areas as you like. Be sure to change the ‘name’, ‘id’and ‘description’ for each widget area.

Step 2 – Call up the widget in your theme template php files


Enter this code into your theme files (e.g. page.php, single.php, header.php, footer.php)

<ul><?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Extra Widgets')) :

endif; ?></ul>

Wednesday, 15 January 2014

Creating Content Tabs with Pure CSS

As CSS3 has started gaining more popularity and more browsers are starting to support it, many common interactions that you would expect from a website that were created using JavaScript are now being replaced by pure CSS solutions. Today I’ll show you how to create an animated content tab using only CSS.

First off, in order to replicate the functionality of JavaScript, we need to find a way to let the CSS know that the user has clicked the button. With JavaScript, we can simply add a class name on click but since we are not going to use JavaScript, we need to hack our way through this. What I did is I used a hidden radio button which is linked to a label tag through rel attribute. The label will act as a button and when you click the label, the label will trigger a “checked” attribute of that linked radio button. Now we can target our styles with a :checked selector.
From the HTML markup, you can see that I have the radio button, the label and the container at the same level. There’s a reason for this. With the help of an awesome CSS sibling combinator (~) we can have one selector triggering another same-level selector without even having it nested together. This allows us to have any radio button with a check triggering any container to appear so that it replicates the behavior of a normal content tab created with JavaScript.
In the demo, I have also included a CSS animation library created by Dan Eden to add some animation effects when the tab content appears.