Wednesday, 29 June 2016

Google launches a page "My Activity" that shows all of your web and device activity

Google has launched a page called My Activity, that is aimed at showing users--and allowing them to control--all of their Google related web activity.

The page is a timeline-based collection of activity that includes things like Web searches, sites visited, videos watched and more. The site is, of course, located behind your Google login, and is visible only to the user. It is a vertically scrolling timeline that indicates the entirety of a user’s activity across devices.
Using this resource, users can view a breakup of items accessed, such as Chrome searches, image searches, YouTube videos, Google News and more. Individual items can be deleted from this listing, or entire topics can be as well. You can for example search for ‘cars’, and all activity around this topic will show up. These can then be deleted individually or in total.
Users can also change what aspects are associated with their account, including things like Web and App access, location history, device information, voice and audio activity, YouTube search and watch history. Each of these can be turned off if required.
You can delete specific items or entire topics. You can also change your settings and decide what data gets associated with your account.

Thursday, 23 June 2016

jQuery find next similar class element to currently active class


To find next similar class to currently active class you can use following jquery code.

 
var k = jQuery(".classname").index($(".classname.active"));
jQuery("a.classname:eq("+ (k +1) + ")").click();




NOTE : 
1) "classname" and "active" are both class name
2) :eq = equivalent  used to find similar property

Monday, 20 June 2016

Creating Custom Post Types in WordPress

First on our agenda is creating the post type itself. Ideally you should create a plugin when working with custom post types, but if you don’t know how, or just need a quick test, you can use the functions.php file in your theme.


function my_custom_post_product() {
  $args = array();
  register_post_type( 'product', $args ); 
}
add_action( 'init', 'my_custom_post_product' );
 
 
In its simplest form, it will create a post type which has almost no customization. 
It won’t be public, it won’t show up in the admin, interaction messages will be the
 same as posts (“post saved,” “post updated,” etc.) and so on. To tailor our new post type to our 
needs, I’ll go through some of the more frequently-used options and add them to the previously 
empty $args array. 
 
 
function my_custom_post_product() {
  $labels = array(
    'name'               => _x( 'Products', 'post type general name' ),
    'singular_name'      => _x( 'Product', 'post type singular name' ),
    'add_new'            => _x( 'Add New', 'book' ),
    'add_new_item'       => __( 'Add New Product' ),
    'edit_item'          => __( 'Edit Product' ),
    'new_item'           => __( 'New Product' ),
    'all_items'          => __( 'All Products' ),
    'view_item'          => __( 'View Product' ),
    'search_items'       => __( 'Search Products' ),
    'not_found'          => __( 'No products found' ),
    'not_found_in_trash' => __( 'No products found in the Trash' ), 
    'parent_item_colon'  => '',
    'menu_name'          => 'Products'
  );
  $args = array(
    'labels'        => $labels,
    'description'   => 'Holds our products and product specific data',
    'public'        => true,
    'menu_position' => 5,
    'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
    'has_archive'   => true,
  );
  register_post_type( 'product', $args ); 
}
add_action( 'init', 'my_custom_post_product' );
 
 
 
  • labels :
    The labels option should be an array defining the different labels that a custom post type can have. I have separated this out above just to make the arguments for registering a post type clearer.
  • description :
    A short explanation of our custom post type; what it does and why we’re using it.
  • public :
    This option controls a bunch of things in one go. Setting this to true will set a bunch of other options (all to do with visibility) to true. For example, it is possible to have the custom post type visible but not queryable. More on this later.
  • menu_position :
    Defines the position of the custom post type menu in the back end. Setting it to “5” places it below the “posts” menu; the higher you set it, the lower the menu will be placed.
  • supports :
    This option sets up the default WordPress controls that are available in the edit screen for the custom post type. By default, only the title field and editor are shown. If you want to add support for comments, revisions, post formats and such you will need to specify them here. For a full list take a look at the argument section in the Codex.
  • has_archive :
    If set to true, rewrite rules will be created for you, enabling a post type archive at http://mysite.com/posttype/ (by default)
  • menu_position :
    (optional) The position in the menu order the post type should appear. show_in_menu must be true. Default: null - defaults to below Comments
 5 - below Posts
10 - below Media
15 - below Links
20 - below Pages
25 - below comments
60 - below first separator
65 - below Plugins
70 - below Users
75 - below Tools
80 - below Settings
100 - below second separator
  
 
 




 

Wednesday, 8 June 2016

jQuery delete all table rows except first

When you want to remove all rows except first rows 
 
$(document).ready(function() { 
   $("someTableSelector").find("tr:gt(0)").remove();  
});