403Webshell
Server IP : 172.67.147.195  /  Your IP : 216.73.216.142
Web Server : Apache/2
System : Linux hosting8537.lvs 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : mienphi ( 1014)
PHP Version : 8.2.14
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/mienphi/public_html/wp-content/plugins/learnpress/assets/src/js/utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/mienphi/public_html/wp-content/plugins/learnpress/assets/src/js/utils/hook.js
const Hook = {
	hooks: { action: {}, filter: {} },
	addAction( action, callable, priority, tag ) {
		this.addHook( 'action', action, callable, priority, tag );
		return this;
	},
	addFilter( action, callable, priority, tag ) {
		this.addHook( 'filter', action, callable, priority, tag );
		return this;
	},
	doAction( action ) {
		return this.doHook( 'action', action, arguments );
	},
	applyFilters( action ) {
		return this.doHook( 'filter', action, arguments );
	},
	removeAction( action, tag ) {
		this.removeHook( 'action', action, tag );
		return this;
	},
	removeFilter( action, priority, tag ) {
		this.removeHook( 'filter', action, priority, tag );
		return this;
	},
	addHook( hookType, action, callable, priority, tag ) {
		if ( undefined === this.hooks[ hookType ][ action ] ) {
			this.hooks[ hookType ][ action ] = [];
		}
		const hooks = this.hooks[ hookType ][ action ];
		if ( undefined === tag ) {
			tag = action + '_' + hooks.length;
		}
		this.hooks[ hookType ][ action ].push( { tag, callable, priority } );
		return this;
	},
	doHook( hookType, action, args ) {
		args = Array.prototype.slice.call( args, 1 );

		if ( undefined !== this.hooks[ hookType ][ action ] ) {
			let hooks = this.hooks[ hookType ][ action ],
				hook;

			hooks.sort( function( a, b ) {
				return a.priority - b.priority;
			} );

			for ( let i = 0; i < hooks.length; i++ ) {
				hook = hooks[ i ].callable;
				if ( typeof hook !== 'function' ) {
					hook = window[ hook ];
				}

				if ( 'action' === hookType ) {
					args[ i ] = hook.apply( null, args );
				} else {
					args[ 0 ] = hook.apply( null, args );
				}
			}
		}

		if ( 'filter' === hookType ) {
			return args[ 0 ];
		}
		return args;
	},
	removeHook( hookType, action, priority, tag ) {
		if ( undefined !== this.hooks[ hookType ][ action ] ) {
			const hooks = this.hooks[ hookType ][ action ];
			for ( let i = hooks.length - 1; i >= 0; i-- ) {
				if ( ( undefined === tag || tag === hooks[ i ].tag ) && ( undefined === priority || priority === hooks[ i ].priority ) ) {
					hooks.splice( i, 1 );
				}
			}
		}
		return this;
	},
};

export default Hook;

Youez - 2016 - github.com/yon3zu
LinuXploit