{"size": 2012, "ext": "js", "max_stars_repo_path": "content/plugins/wp-migrate-db/asset/js/hook.js", "max_stars_repo_name": "sbodrero/Mediis_wordpress_Foundation_deploy_master", "max_stars_repo_stars_event_min_datetime": "2016-06-03T03:24:31.000Z", "max_stars_repo_stars_event_max_datetime": "2016-08-22T21:43:07.000Z", "max_issues_repo_path": "content/plugins/wp-migrate-db/asset/js/hook.js", "max_issues_repo_name": "sbodrero/Mediis_wordpress_Foundation_deploy_master", "max_issues_repo_issues_event_min_datetime": "2016-05-07T02:24:33.000Z", "max_issues_repo_issues_event_max_datetime": "2016-07-21T01:35:17.000Z", "max_forks_repo_path": "content/plugins/wp-migrate-db/asset/js/hook.js", "max_forks_repo_name": "sbodrero/Mediis_wordpress_Foundation_deploy_master", "max_forks_repo_forks_event_min_datetime": "2016-05-21T00:31:34.000Z", "max_forks_repo_forks_event_max_datetime": "2016-07-17T00:57:05.000Z"}
{"max_stars_count": 5, "max_issues_count": 2, "max_forks_count": 3, "avg_line_length": 31.9365079365, "max_line_length": 95, "alphanum_fraction": 0.6167992048}
(function($) {

	$.wpmdb = {
		/**
		 * Implement a WordPress-link Hook System for Javascript
		 * TODO: Change 'tag' to 'args', allow number (priority), string (tag), object (priority+tag)
		 */
		hooks: { action: {}, filter: {} },
		add_action: function( action, callable, tag ) {
			jQuery.wpmdb.add_hook( 'action', action, callable, tag );
		},
		add_filter: function( action, callable, tag ) {
			jQuery.wpmdb.add_hook( 'filter', action, callable, tag );
		},
		do_action: function( action, args ) {
			jQuery.wpmdb.do_hook( 'action', action, null, args );
		},
		apply_filters: function( action, value, args ) {
			return jQuery.wpmdb.do_hook( 'filter', action, value, args );
		},
		remove_action: function( action, tag ) {
			jQuery.wpmdb.remove_hook( 'action', action, tag );
		},
		remove_filter: function( action, tag ) {
			jQuery.wpmdb.remove_hook( 'filter', action, tag );
		},
		add_hook: function( hook_type, action, callable, tag ) {
			if ( undefined == jQuery.wpmdb.hooks[hook_type][action] ) {
				jQuery.wpmdb.hooks[hook_type][action] = [];
			}
			var hooks = jQuery.wpmdb.hooks[hook_type][action];
			if ( undefined == tag ) {
				tag = action + '_' + hooks.length;
			}
			jQuery.wpmdb.hooks[hook_type][action].push( { tag:tag, callable:callable } );
		},
		do_hook: function( hook_type, action, value, args ) {
			if ( undefined != jQuery.wpmdb.hooks[hook_type][action] ) {
				var hooks = jQuery.wpmdb.hooks[hook_type][action];
				for( var i=0; i<hooks.length; i++) {
					if ( 'action'==hook_type ) {
						hooks[i].callable(args);
					} else {
						value = hooks[i].callable(value, args);
					}
				}
			}
			if ( 'filter'==hook_type ) {
				return value;
			}
		},
		remove_hook: function( hook_type, action, tag ) {
			if ( undefined != jQuery.wpmdb.hooks[hook_type][action] ) {
				var hooks = jQuery.wpmdb.hooks[hook_type][action];
				for( var i=hooks.length-1; i>=0; i--) {
					if (undefined==tag||tag==hooks[i].tag)
						hooks.splice(i,1);
					}
			}
		}
	}

})(jQuery);