idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
48,700
public function onKernelResponse ( FilterResponseEvent $ event ) { $ response = $ event -> getResponse ( ) ; $ request = $ event -> getRequest ( ) ; if ( ! $ event -> isMasterRequest ( ) ) { return ; } if ( $ request -> isXmlHttpRequest ( ) ) { return ; } $ this -> _injectDatatableScript ( $ response , $ request ) ; }
On kernel response event
48,701
protected function _injectDatatableScript ( Response $ response , Request $ request ) { $ content = $ response -> getContent ( ) ; $ pos_body = strripos ( $ content , '</body>' ) ; if ( ! $ pos_body ) { return ; } $ session = $ request -> getSession ( ) ; $ dom = '<script id="alidatatable-scripts" type="text/javascript">' ; $ pos_container = strripos ( $ content , 'alidatatable-scripts' ) ; $ sess_dta = $ session -> get ( 'datatable' , array ( ) ) ; $ dta_script = null ; if ( $ sess_dta ) { array_walk ( $ sess_dta , function ( & $ part , & $ key ) { $ part = trim ( preg_replace ( '/\s\s+/' , ' ' , $ part ) ) ; } ) ; $ dta_script = implode ( "\n" , $ sess_dta ) ; } $ session -> set ( 'datatable' , array ( ) ) ; if ( ! $ pos_container ) { $ dta_container = $ dom ; $ content = substr_replace ( $ content , $ dta_container . '</script>' , $ pos_body , 0 ) ; $ response -> setContent ( $ content ) ; } $ pos_dta = strripos ( $ content , $ dom ) ; $ content = substr_replace ( $ content , $ dta_script , $ pos_dta + strlen ( $ dom ) , 0 ) ; $ response -> setContent ( $ content ) ; }
Injects the datatable scripts into the given HTTP Response .
48,702
public function boot ( ) { $ this -> setFingerprint ( mt_rand ( ) ) ; $ this -> setArguments ( $ this -> getMessages ( ) ) ; $ this -> setSingular ( $ this -> getArgument ( 'title' ) ) ; $ this -> setPlural ( $ this -> getArgument ( 'title' ) ) ; $ this -> manager -> boot ( $ this ) ; }
Bootstrap field instance .
48,703
public function dispatch ( ) { $ this -> manager -> dispatchTemplate ( ) ; if ( $ this -> hasChildren ( ) ) { $ this -> getChildren ( ) -> setParent ( $ this ) -> boostSchemaWithValues ( $ this -> getValue ( ) ) ; if ( $ this -> isTypeOf ( 'repeatable' ) && empty ( $ this -> getValue ( ) ) ) { $ this -> dispatchSchema ( ) ; } } }
Dispach field values .
48,704
public function dispatchSchema ( ) { foreach ( $ this -> children -> getSchema ( ) as $ field ) { if ( is_array ( $ field ) ) { foreach ( $ field as $ key => $ item ) { $ item -> setValue ( $ item -> getArgument ( 'default' ) ) -> dispatch ( ) ; } continue ; } $ field -> setValue ( $ field -> getArgument ( 'default' ) ) -> dispatch ( ) ; } }
Dispach field schema .
48,705
public function jsonSerialize ( ) { $ children = ( $ this -> hasChildren ( ) ) ? $ this -> children : [ ] ; return [ 'slug' => $ this -> getSlug ( ) , 'type' => $ this -> getType ( ) , 'arguments' => $ this -> getArguments ( ) , 'singular' => $ this -> getSingular ( ) , 'plural' => $ this -> getPlural ( ) , 'value' => $ this -> getValue ( ) , 'fingerprint' => $ this -> getFingerprint ( ) , 'children' => $ children , 'validator' => $ this -> manager -> getValidator ( ) , ] ; }
Serialize Field to JSON .
48,706
public function setValue ( $ value ) { if ( null === $ value ) { $ value = $ this -> getArgument ( 'default' ) ; } $ this -> value = ( $ this -> needsSanitization ( ) ) ? $ this -> sanitizeWithCallback ( $ value ) : $ value ; return $ this ; }
Set the value of value .
48,707
public function match ( array $ methods , $ path , $ action ) { $ methods = $ this -> normalizeRequestMethods ( $ methods ) ; return $ this -> addRoute ( $ methods , $ path , $ action ) ; }
Create route that match specifed request method .
48,708
public function addRoute ( $ method , $ path , $ action ) { $ route = ( new Route ( $ this -> conditions , $ this -> container ) ) -> setMethods ( $ method ) -> setPath ( $ path ) -> setAction ( $ action ) -> setRouter ( $ this ) ; return $ this -> routes -> add ( $ route ) ; }
Create route and store it in routes collection .
48,709
public function execute ( WP $ wp , WP_Query $ wp_query ) { if ( $ this -> conditions -> is ( '404' ) ) { return $ this -> prepareResponse ( $ this -> resolveNotFoundRoute ( ) , Response :: HTTP_NOT_FOUND ) ; } foreach ( $ this -> routes -> getGroup ( $ _SERVER [ 'REQUEST_METHOD' ] ) as $ route ) { if ( $ route -> matches ( $ wp -> request , array_filter ( $ wp_query -> query_vars ) ) ) { return $ this -> prepareResponse ( $ route -> run ( ) ) ; } } throw new RoutingException ( "Route not found. Couldn't find any matching route." ) ; }
Execute router match and resolve route .
48,710
public function resolveNotFoundRoute ( ) { try { if ( $ notFoundRoute = $ this -> routes -> get ( '404' ) ) { return $ notFoundRoute -> run ( ) ; } } catch ( RoutingException $ e ) { if ( wp_redirect ( home_url ( ) ) ) { exit ( ) ; } } }
Resolve 404 route or redirect if not exist .
48,711
public function prepareResponse ( $ content , $ status = null ) { $ response = new Response ; $ response -> setContent ( $ content ) ; if ( isset ( $ status ) ) { $ response -> setStatusCode ( $ status ) ; } return $ response -> send ( ) ; }
Prepares router response .
48,712
public function normalizeRequestMethods ( $ methods ) { if ( is_string ( $ methods ) ) { return strtoupper ( $ methods ) ; } foreach ( $ methods as $ key => $ method ) { $ methods [ $ key ] = strtoupper ( $ method ) ; } return $ methods ; }
Normalize request methods to uppercase .
48,713
private function make ( $ slug , $ arguments = [ ] ) { $ asset = $ this -> container -> make ( Asset :: class ) ; $ asset -> setSlug ( $ slug ) -> setArguments ( $ arguments ) ; return $ this -> hang ( $ asset ) ; }
Make asset .
48,714
public function meta ( $ key = null ) { if ( isset ( $ key ) ) { return $ this -> model -> findMeta ( $ this -> id , $ key ) ; } return $ this -> model -> getMeta ( $ this -> id ) ; }
User meta data .
48,715
public function hooks ( ) { $ this -> hook -> action ( 'after_setup_theme' , [ $ this -> menu , 'register' ] ) -> dispatch ( ) ; $ this -> hook -> filter ( 'wp_get_nav_menu_items' , function ( $ items , $ menu , $ args ) { _wp_menu_item_classes_by_context ( $ items ) ; return $ items ; } , [ 'numberOfArguments' => 3 ] ) -> dispatch ( ) ; }
Setup hooks .
48,716
public function register ( ) { $ this -> app -> singleton ( 'profile.factory' , function ( $ app ) { return new ProfileFactory ( $ app ) ; } ) ; $ this -> app -> alias ( 'profile.factory' , ProfileFactory :: class ) ; }
Register profile services .
48,717
public function hooks ( ) { $ this -> hook -> action ( 'init' , [ $ this -> taxonomy , 'register' ] ) -> dispatch ( ) ; $ this -> hook -> action ( "{$this->taxonomy->getModel()->getSlug()}_add_form_fields" , [ $ this -> taxonomy , 'fill' ] ) -> dispatch ( ) ; $ this -> hook -> action ( "{$this->taxonomy->getModel()->getSlug()}_edit_form_fields" , [ $ this -> taxonomy , 'fill' ] ) -> dispatch ( ) ; $ this -> hook -> action ( "created_{$this->taxonomy->getModel()->getSlug()}" , [ $ this -> taxonomy , 'save' ] ) -> dispatch ( ) ; $ this -> hook -> action ( "edited_{$this->taxonomy->getModel()->getSlug()}" , [ $ this -> taxonomy , 'save' ] ) -> dispatch ( ) ; }
Register taxonomy hooks .
48,718
public function columns ( ) { $ this -> hook -> filter ( "manage_edit-{$this->taxonomy->getModel()->getSlug()}_columns" , [ $ this -> taxonomy -> getColumns ( ) , 'setNames' ] ) -> dispatch ( ) ; $ this -> hook -> filter ( "manage_{$this->taxonomy->getModel()->getSlug()}_custom_column" , function ( $ value , $ name , $ id ) { return $ this -> taxonomy -> getColumn ( $ name ) -> render ( $ id ) ; } , [ 'numberOfArguments' => 3 ] ) -> dispatch ( ) ; }
Register taxonomy columns hooks .
48,719
public function posttype ( ) { $ this -> setClassname ( $ this -> getArgument ( 0 ) ) ; $ name = Str :: snake ( $ this -> getClassname ( ) ) ; $ this -> generateClass ( 'Posttypes' , 'posttype.stub' , [ 'classname' => $ this -> getClassname ( ) , 'slug' => $ this -> getOption ( 'slug' , $ name ) , 'rewrite_slug' => $ this -> getOption ( 'slug' , Str :: slug ( $ name ) ) , ] ) ; }
Scafford custom post type .
48,720
public function metabox ( ) { $ this -> setClassname ( $ this -> getArgument ( 0 ) ) ; $ name = Str :: snake ( $ this -> getClassname ( ) ) ; $ this -> generateClass ( 'Metaboxes' , 'metabox.stub' , [ 'classname' => $ this -> getClassname ( ) , 'slug' => $ this -> getOption ( 'slug' , $ name ) , 'belongsto' => $ this -> getOption ( 'belongsto' ) , ] ) ; }
Scafford custom metabox .
48,721
public function command ( $ arguments , $ options ) { $ this -> setClassname ( $ this -> getArgument ( 0 ) ) ; if ( ! $ this -> getOption ( 'signature' ) ) { return $ this -> error ( 'You must specify command signature [--signature=<signature>].' ) ; } if ( ! $ this -> getOption ( 'method' ) ) { return $ this -> error ( 'You must specify the name of command method name [--method=<method>].' ) ; } $ this -> generateClass ( 'Console/Commands' , 'command.stub' , [ 'classname' => $ this -> getClassname ( ) , 'signature' => $ this -> getOption ( 'signature' ) , 'method' => $ this -> getOption ( 'method' ) , ] ) ; }
Scafford custom command .
48,722
protected function generateClass ( $ dir , $ stub , array $ arguments = [ ] ) { $ this -> line ( $ this -> colorize ( 'Crafting:' ) . " Generating [{$this->getClassname()}] class..." ) ; $ base = $ this -> config -> get ( 'app.directory' ) ; $ file = "{$base}/app/{$dir}/{$this->getClassname()}.php" ; if ( $ this -> filesystem -> exists ( $ file ) ) { $ this -> confirm ( "[{$this->getClassname()}] class already exists. Want to overwrite?" ) ; } $ template = $ this -> filesystem -> get ( __DIR__ . "/stubs/{$stub}" ) ; $ this -> filesystem -> put ( $ file , $ this -> stub -> render ( $ template , $ arguments ) ) ; $ this -> success ( "{$this->getClassname()} created successfully." ) ; }
Generate class for singularity .
48,723
public function boot ( $ posttype ) { $ this -> posttype = $ posttype ; $ this -> hook -> action ( 'init' , [ $ this -> posttype , 'register' ] ) -> dispatch ( ) ; }
Bootstrap posttype manager .
48,724
public function columns ( ) { $ this -> hook -> filter ( "manage_edit-{$this->posttype->getModel()->getSlug()}_columns" , [ $ this -> posttype -> getColumns ( ) , 'setNames' ] ) -> dispatch ( ) ; $ this -> hook -> action ( "manage_{$this->posttype->getModel()->getSlug()}_posts_custom_column" , [ $ this -> posttype -> getColumns ( ) , 'manageContent' ] ) -> dispatch ( ) ; }
Register posttype list columns .
48,725
protected function meetsConditions ( ) { if ( isset ( $ this -> visibility ) && $ this -> visibility === 'public' ) { return true ; } return $ this -> auth -> user ( ) -> can ( 'edit_user' ) ; }
Check if we meet conditions for the profile registration .
48,726
public function add ( Route $ route ) { foreach ( $ route -> getMethods ( ) as $ method ) { $ this -> routes [ $ method ] [ $ route -> getPath ( ) ] = $ route ; $ this -> allRoutes [ $ route -> getPath ( ) ] = $ route ; } return $ route ; }
Add route to the collection .
48,727
public function get ( $ path ) { if ( isset ( $ this -> allRoutes [ $ path ] ) ) { return $ this -> allRoutes [ $ path ] ; } throw new RoutingException ( "Route [{$path}] does not exist." ) ; }
Get the route form collection .
48,728
public function getGroup ( $ method ) { if ( isset ( $ this -> routes [ $ method ] ) ) { return $ this -> routes [ $ method ] ; } throw new RoutingException ( "Routes group [{$method}] does not exist." ) ; }
Get the route group form collection .
48,729
public function hooks ( ) { $ this -> hook -> action ( 'admin_init' , [ $ this -> metabox , 'register' ] ) -> dispatch ( ) ; $ this -> hook -> action ( 'save_post' , function ( $ id ) { $ this -> metabox -> getModel ( ) -> setContext ( 'post' ) ; $ this -> metabox -> save ( $ id ) ; } ) -> dispatch ( ) ; $ this -> hook -> action ( 'edit_comment' , function ( $ id ) { $ this -> metabox -> getModel ( ) -> setContext ( 'comment' ) ; $ this -> metabox -> save ( $ id ) ; } ) -> dispatch ( ) ; }
Register metabox hooks .
48,730
public function dispatch ( ) { $ this -> hook -> action ( 'admin_print_footer_scripts' , [ $ this , 'script' ] ) -> dispatch ( ) ; echo $ this -> view -> make ( 'Assely::Metabox.metabox' , [ 'slug' => $ this -> metabox -> getModel ( ) -> getSlug ( ) , 'fingerprint' => $ this -> metabox -> getModel ( ) -> getFingerprint ( ) , ] ) ; }
Dispach metabox .
48,731
public function script ( ) { echo $ this -> view -> make ( 'Assely::script' , [ 'slug' => $ this -> metabox -> getModel ( ) -> getSlug ( ) , 'fingerprint' => $ this -> metabox -> getModel ( ) -> getFingerprint ( ) , 'fields' => json_encode ( $ this -> metabox -> getFields ( ) -> all ( ) ) , ] ) ; }
Render metabox script .
48,732
public function make ( $ slug , array $ arguments = [ ] ) { $ this -> setSlug ( $ slug ) ; $ this -> setArguments ( $ arguments ) ; $ this -> setSingular ( $ this -> getArgument ( 'title' ) ) ; $ this -> setPlural ( $ this -> getArgument ( 'title' ) ) ; $ this -> setFingerprint ( ) ; return $ this ; }
Make model .
48,733
public function save ( $ id , $ values ) { $ this -> nonce -> verify ( $ this -> getSlug ( ) ) ; if ( $ this -> isPreservedAs ( 'single' ) ) { return $ this -> updateMeta ( $ id , [ 'key' => $ this -> getSlug ( ) , 'value' => $ values , ] ) ; } if ( $ this -> isPreservedAs ( 'multiple' ) ) { foreach ( $ values as $ key => $ value ) { $ this -> updateMeta ( $ id , [ 'key' => $ key , 'value' => $ value , ] ) ; } } }
Save model .
48,734
public function resolveMeta ( $ action , $ arguments ) { if ( $ this -> isPreservedAs ( 'single' ) ) { $ arguments [ 1 ] = $ this -> getSlug ( ) ; return $ this -> { "{$action}Meta" } ( $ arguments ) ; } if ( $ this -> isPreservedAs ( 'multiple' ) ) { return $ this -> unserializeCollection ( $ this -> { "{$action}Meta" } ( $ arguments ) ) ; } return $ this -> { "{$action}Meta" } ( $ arguments ) ; }
Resolve meta data .
48,735
public function resolveMetaArguments ( $ arguments ) { if ( $ this -> isPreservedAs ( 'multiple' ) && ! isset ( $ arguments [ 'key' ] ) ) { throw new MetaArgumentsException ( "You need to provide key for processing Taxonomy [{$this->slug}] meta." ) ; } return array_merge ( $ this -> metaDefaults , $ arguments ) ; }
Resolve and verify meta process arguments .
48,736
public function unserializeCollection ( $ collection ) { if ( is_array ( $ collection ) ) { return array_map ( function ( $ value ) { return maybe_unserialize ( reset ( $ value ) ) ; } , $ collection ) ; } return maybe_unserialize ( $ collection ) ; }
Unserialize data collection .
48,737
public function preserveAs ( ) { $ arguments = $ this -> getArguments ( ) ; if ( ! isset ( $ arguments [ 'preserve' ] ) ) { throw new QueryException ( 'You need to specify how this repository should be preserved [single, multiple or default].' ) ; } if ( ! in_array ( $ arguments [ 'preserve' ] , [ 'single' , 'multiple' , 'default' ] ) ) { throw new QueryException ( 'Repository can be preserved only as single, multiple or default.' ) ; } return $ arguments [ 'preserve' ] ; }
How this repository have to preserve values .
48,738
public function plugAdapter ( $ adapter , array $ adaptees , ModelInterface $ model = null ) { return $ this -> plugger -> setModel ( $ model ? : $ this ) -> setAdapter ( $ adapter ) -> plugIn ( $ adaptees ) -> getConnected ( ) ; }
Plug adapters to adaptee .
48,739
public function prefixValues ( array $ arguments , $ prefix ) { $ skip = [ 'id' , 'ID' ] ; return array_map ( function ( $ key ) use ( $ prefix , $ skip ) { if ( in_array ( $ key , $ skip ) ) { return $ key ; } return "{$prefix}{$key}" ; } , $ arguments ) ; }
Prefix and normalize methods arguments .
48,740
public function prefixKeys ( array $ arguments , $ prefix ) { $ normalized = [ ] ; $ skip = [ 'id' , 'ID' ] ; foreach ( $ arguments as $ key => $ value ) { if ( in_array ( $ key , $ skip ) ) { $ normalized [ $ key ] = $ value ; continue ; } $ normalized [ "{$prefix}{$key}" ] = $ value ; } return $ normalized ; }
Prefix arguments keys .
48,741
public function matches ( $ request , $ queries = [ ] ) { $ this -> setQueries ( $ queries ) ; if ( ! $ request && $ this -> isHomePath ( ) ) { return true ; } if ( $ matches = preg_match ( "@^{$this->getPathMock($queries)}$@" , $ request ) ) { if ( $ this -> rulesNotPassed ( ) ) { return false ; } } return ( bool ) $ matches ; }
Checks if route matches request .
48,742
public function getPathMock ( array $ queries ) { $ path = $ this -> getPath ( ) ; foreach ( $ queries as $ query => $ value ) { if ( is_array ( $ value ) ) { $ flatten = $ this -> flattenQueries ( $ value ) ; $ value = reset ( $ flatten ) ; } $ path = preg_replace ( "/\\{({$query})\\}/" , $ value , $ path ) ; } return $ path ; }
Gets path mocked with queries values .
48,743
public function evaluateRules ( ) { foreach ( $ this -> rules as $ rule => $ condition ) { $ this -> rules [ $ rule ] = $ this -> conditions -> is ( $ rule , $ condition ) ; } return $ this -> rules ; }
Evaluates statuses of rules .
48,744
protected function renderSalts ( $ format ) { foreach ( $ this -> saltsVariables as $ name ) { if ( $ this -> getOption ( 'format' ) === 'yaml' ) { $ name = strtolower ( $ name ) ; } $ this -> line ( sprintf ( $ format , $ name , base64_encode ( Str :: randomBytes ( 48 ) ) ) ) ; } }
Render WordPress salts .
48,745
public function active ( ) { $ classes = $ this -> getAdaptee ( ) -> classes ; foreach ( $ classes as $ class ) { if ( strpos ( $ class , 'current' ) !== false ) { return true ; } } return false ; }
Is current menu item active?
48,746
public function columns ( array $ columns ) { $ this -> getColumns ( ) -> setColumns ( $ columns ) ; $ this -> manager -> columns ( ) ; return $ this ; }
Set taxonomy list columns .
48,747
protected function registerTaxonomy ( ) { if ( ! $ this -> isRegistered ( ) ) { $ parameters = array_merge ( [ 'labels' => $ this -> getModel ( ) -> getLabels ( ) , 'rewrite' => [ 'slug' => $ this -> getModel ( ) -> getSlug ( ) ] , ] , $ this -> getModel ( ) -> getArguments ( ) ) ; return register_taxonomy ( $ this -> getModel ( ) -> getSlug ( ) , $ this -> getBelongsTo ( ) , $ parameters ) ; } throw new TaxonomyException ( "Taxonomy [{$this->model->getSlug()}] already exsist." ) ; }
Register taxonomy .
48,748
public function fill ( $ term ) { $ id = ( isset ( $ term -> term_id ) ) ? $ term -> term_id : false ; parent :: prepare ( $ id ) ; }
Fill taxonomy fields .
48,749
public function registerCacheService ( ) { $ this -> app -> singleton ( 'cache' , function ( $ app ) { return new Cache ( $ app [ 'config' ] ) ; } ) ; $ this -> app -> alias ( 'cache' , Cache :: class ) ; }
Register cache service .
48,750
public function verify ( $ slug ) { $ nonce = $ this -> make ( $ slug ) ; return $ nonce -> check ( $ this -> request -> input ( $ nonce -> getSlug ( ) ) ) ; }
Verify nonce value .
48,751
public function registerByAccessibility ( ) { switch ( $ this -> getArgument ( 'accessibility' ) ) { case 'unauthorized' : $ this -> registerAsUnauthorized ( ) ; break ; case 'authorized' : $ this -> registerAsAuthorized ( ) ; break ; default : $ this -> registerAsUnauthorized ( ) ; $ this -> registerAsAuthorized ( ) ; break ; } }
Register Ajax by accessibility argument .
48,752
public function findBy ( $ key , $ id ) { $ adaptees = get_term_by ( $ key , $ id , $ this -> getSlug ( ) ) ; return $ this -> plugger -> setModel ( $ this ) -> setAdapter ( Term :: class ) -> plugIn ( $ adaptees ) -> getConnected ( ) -> first ( ) ; }
Find term by key .
48,753
public function find ( $ id ) { if ( is_numeric ( $ id ) ) { return $ this -> findBy ( 'id' , $ id ) ; } return $ this -> findBy ( 'slug' , $ id ) ; }
Find term .
48,754
public function findOrFail ( $ id ) { $ term = $ this -> find ( $ id ) ; if ( ! $ term -> getAdaptee ( ) ) { throw new QueryException ( "Taxonomy [{$this->slug}] could not find term [{$id}]." ) ; } return $ term ; }
Find term or trow if unssuccesful .
48,755
public function createOrFail ( array $ arguments ) { $ term = $ this -> create ( $ arguments ) ; if ( is_wp_error ( $ term ) ) { throw new QueryException ( "Taxonomy [{$this->slug}] could not create new term." ) ; } return $ term ; }
Create term .
48,756
public function makeAssociativeCollection ( array $ columns ) { $ mapped = [ ] ; foreach ( $ columns as $ column ) { Arr :: set ( $ mapped , $ column -> getSlug ( ) , $ column ) ; } return $ mapped ; }
Map columns .
48,757
public function setNames ( $ names ) { foreach ( $ this -> columns as $ key => $ column ) { Arr :: set ( $ names , $ key , $ column -> getSingular ( ) ) ; } return $ names ; }
Set columns names .
48,758
public function renderContent ( $ name , $ id ) { if ( $ column = $ this -> getColumn ( $ name ) ) { $ column -> render ( $ id ) ; } }
Manage columns content .
48,759
public function prepare ( $ id ) { if ( $ this -> isValidScreen ( ) ) { $ collection = $ this -> getModel ( ) -> getMeta ( $ id ) ; $ this -> setValue ( $ collection -> toArray ( ) ) ; $ this -> getFields ( ) -> boostSchemaWithValues ( $ this -> getValue ( ) ) ; $ this -> manager -> dispatch ( ) ; } }
Prepare singularity values and dispatch to the view .
48,760
public function save ( $ id ) { if ( $ this -> requestNotEmpty ( ) ) { $ this -> getFields ( ) -> setValues ( $ this -> getRequestInput ( ) ) -> propagateSchemaWithValues ( ) ; $ this -> getModel ( ) -> save ( $ id , $ this -> getFields ( ) -> getSanitizedValues ( ) ) ; } }
Save singularity .
48,761
public function getRequestInput ( ) { if ( isset ( $ _REQUEST [ $ this -> getModel ( ) -> getSlug ( ) ] ) ) { return $ _REQUEST [ $ this -> getModel ( ) -> getSlug ( ) ] ; } }
Gets value of field request .
48,762
public function dispatch ( ) { $ this -> setSingular ( $ this -> getArgument ( 'title' ) ) ; $ this -> setPlural ( $ this -> getArgument ( 'title' ) ) ; $ this -> hook -> action ( 'after_setup_theme' , [ $ this , 'register' ] ) -> dispatch ( ) ; $ this -> hook -> filter ( 'image_size_names_choose' , [ $ this , 'registerName' ] ) -> dispatch ( ) ; }
Dispach thumbnail to registration .
48,763
public function register ( ) { return add_image_size ( $ this -> getSlug ( ) , $ this -> getArgument ( 'size' ) [ 0 ] , $ this -> getArgument ( 'size' ) [ 1 ] , $ this -> getArgument ( 'crop' ) ) ; }
Register thumbnail size .
48,764
public function create ( ModelInterface $ model , $ belongsTo ) { $ metabox = $ this -> container -> make ( MetaboxSingularity :: class ) ; $ metabox -> setModel ( $ model ) -> setBelongsTo ( $ belongsTo ) -> boot ( ) ; return $ metabox ; }
Create metabox .
48,765
public function boot ( HookFactory $ hook , Router $ router , WP $ wp , WP_Query $ wp_query ) { $ this -> load ( ) ; $ hook -> filter ( 'template_include' , function ( ) use ( $ router , $ wp , $ wp_query ) { $ router -> setNamespace ( $ this -> getNamespace ( ) ) -> execute ( $ wp , $ wp_query ) ; return false ; } ) -> dispatch ( ) ; }
Boot routes and execute route .
48,766
public function query ( array $ arguments = [ ] ) { $ defaults = array_merge ( $ this -> queryDefaults , [ 'post_type' => $ this -> getSlug ( ) , ] ) ; return $ this -> plugger -> setModel ( $ this ) -> setAdapter ( Post :: class ) -> plugIn ( get_posts ( array_merge ( $ arguments , $ defaults ) ) ) -> getConnected ( ) ; }
Query posttype .
48,767
public function find ( $ id ) { if ( ! is_numeric ( $ id ) && is_string ( $ id ) ) { return $ this -> findBySlug ( $ id ) ; } return $ this -> plugger -> setModel ( $ this ) -> setAdapter ( Post :: class ) -> plugIn ( get_post ( $ id ) ) -> getConnected ( ) -> first ( ) ; }
Find post by id .
48,768
public function findBySlug ( $ slug ) { return $ this -> plugger -> setModel ( $ this ) -> setAdapter ( Post :: class ) -> plugIn ( get_page_by_path ( $ slug , OBJECT , $ this -> getSlug ( ) ) ) -> getConnected ( ) -> first ( ) ; }
Find post by slug .
48,769
public function findOrFail ( $ id ) { $ post = $ this -> find ( $ id ) ; if ( ! $ post -> getAdaptee ( ) ) { throw new QueryException ( "Posttype [{$this->getSlug()}] could not find post with id [{$id}]." ) ; } return $ post ; }
Find post by id or trow if unsuccessful .
48,770
public function paginate ( $ page , $ perPage = null ) { $ this -> queryDefaults [ 'paged' ] = $ page ; $ this -> queryDefaults [ 'posts_per_page' ] = $ perPage ? : get_option ( 'posts_per_page' ) ; return $ this ; }
Paginate query results .
48,771
public function getTerms ( Post $ post , $ taxonomy ) { $ model = App :: make ( TaxonomyModel :: class ) ; return $ model -> make ( $ taxonomy ) -> postTerms ( $ post ) ; }
Gets post terms .
48,772
public function getAllTerms ( Post $ post ) { $ taxonomies = get_object_taxonomies ( $ this -> getSlug ( ) ) ; $ adaptees = wp_get_object_terms ( $ post -> id , $ taxonomies ) ; return $ this -> plugAdapter ( Term :: class , $ adaptees ) ; }
Gets all post terms .
48,773
public function getComments ( array $ arguments ) { $ model = App :: make ( CommentModel :: class ) ; return $ model -> make ( 'comment' ) -> query ( $ arguments ) ; }
Gets post comments .
48,774
public function create ( array $ arguments ) { $ post = $ this -> mockAdapterPost ( $ arguments ) ; return wp_insert_post ( array_merge ( ( array ) $ post -> getAdaptee ( ) , [ 'post_type' => $ this -> getSlug ( ) ] ) ) ; }
Create post .
48,775
public function mockAdapterPost ( array $ parameters ) { $ post = $ this -> plugAdapter ( Post :: class , new \ WP_Post ( new \ StdClass ) ) -> first ( ) ; foreach ( $ parameters as $ key => $ value ) { $ post -> { $ key } = $ value ; } return $ post ; }
Mock post adapter .
48,776
public function columns ( ) { $ this -> hook -> filter ( 'manage_users_columns' , [ $ this -> user -> getColumns ( ) , 'setNames' ] ) -> dispatch ( ) ; $ this -> hook -> action ( 'manage_users_custom_column' , function ( $ value , $ name , $ id ) { ob_start ( ) ; $ column = $ this -> user -> getColumn ( $ name ) ; if ( isset ( $ column ) ) { $ column -> render ( $ id ) ; } return ob_get_clean ( ) ; } , [ 'numberOfArguments' => 3 ] ) -> dispatch ( ) ; }
Register user list columns .
48,777
public function runController ( ) { return ( new ControllerDispatcher ( $ this -> container ) ) -> dispatch ( $ this , $ this -> getController ( ) , $ this -> getControllerMethod ( ) ) ; }
Run controller method action .
48,778
public function getController ( ) { list ( $ controller ) = explode ( '@' , $ this -> getAction ( ) ) ; if ( ! $ this -> controller ) { $ this -> setController ( $ this -> makeController ( $ controller ) ) ; } return $ this -> controller ; }
Gets the Route controller .
48,779
public function makeController ( $ controller ) { $ namespace = $ this -> router -> getNamespace ( ) ; $ classname = "{$namespace}\\{$controller}" ; if ( class_exists ( $ classname ) ) { return $ this -> container -> make ( $ classname ) ; } throw new RoutingException ( "Controller [{$classname}] do not exists." ) ; }
Makes controller instance .
48,780
public function thumbnail ( $ size = null ) { $ size = ( $ size ) ? $ size : $ this -> config -> get ( 'images.size' ) ; if ( $ id = $ this -> thumbnailId ) { return new Image ( $ id , $ size ) ; } }
Get post thumbnail .
48,781
public function register ( ) { $ this -> app -> singleton ( 'taxonomy.factory' , function ( $ app ) { return new TaxonomyFactory ( $ app ) ; } ) ; $ this -> app -> alias ( 'taxonomy.factory' , TaxonomyFactory :: class ) ; }
Register taxonomy services .
48,782
public function findBy ( $ key , $ value ) { return $ this -> plugger -> setModel ( $ this ) -> setAdapter ( User :: class ) -> plugIn ( get_user_by ( $ key , $ value ) ) -> getConnected ( ) -> first ( ) ; }
Find user by keys .
48,783
public function findOrFail ( $ id ) { $ user = $ this -> find ( $ id ) ; if ( ! isset ( $ user -> id ) ) { throw new QueryException ( "User [{$id}] not found." ) ; } return $ user ; }
Find user by id or trow if unsuccessful .
48,784
public function setUp ( $ key , $ arguments = [ ] ) { $ this -> setArguments ( $ arguments ) ; ob_start ( ) ; $ this -> keys [ ] = $ key = ( string ) $ key ; return $ this -> cached = $ this -> cache -> has ( $ key ) ; }
Returns before widget markup .
48,785
public function tearDown ( ) { $ buffer = ob_get_clean ( ) ; $ key = array_pop ( $ this -> keys ) ; if ( ! $ this -> cached ) { $ this -> cache -> put ( $ key , $ buffer , $ this -> getArgument ( 'expire' ) ) ; return $ buffer ; } return $ this -> cache -> get ( $ key ) ; }
Returns after widget markup .
48,786
public function register ( ) { $ this -> app -> singleton ( 'metabox.factory' , function ( $ app ) { return new MetaboxFactory ( $ app ) ; } ) ; $ this -> app -> alias ( 'metabox.factory' , MetaboxFactory :: class ) ; }
Register metabox services .
48,787
public function rejectHiddenMeta ( $ meta ) { return $ meta -> filter ( function ( $ value , $ key ) { if ( substr ( $ key , 0 , 1 ) !== '_' ) { return $ value ; } } ) -> all ( ) ; }
Reject hidden meta .
48,788
private function make ( $ slug , array $ arguments = [ ] ) { $ thumbnail = $ this -> container -> make ( Thumbnail :: class ) ; $ thumbnail -> setSlug ( $ slug ) -> setArguments ( $ arguments ) -> dispatch ( ) ; return $ this -> hang ( $ thumbnail ) ; }
Make thumbnail instance .
48,789
public function register ( ) { return add_meta_box ( $ this -> model -> getSlug ( ) , $ this -> model -> getSingular ( ) , [ $ this , 'fill' ] , $ this -> belongsTo , $ this -> model -> getArgument ( 'location' ) , $ this -> model -> getArgument ( 'priority' ) ) ; }
Register metabox .
48,790
public function fill ( $ object ) { if ( $ this -> screenIsComment ( ) ) { $ this -> model -> setContext ( 'comment' ) ; return parent :: prepare ( $ object -> comment_ID ) ; } return parent :: prepare ( $ object -> ID ) ; }
Fill metabox fields .
48,791
public function register ( ) { $ this -> setFingerprint ( $ this -> generateFingerprint ( ) ) ; return register_nav_menus ( [ $ this -> model -> getSlug ( ) => $ this -> model -> getSingular ( ) ] ) ; }
Register menu .
48,792
public function generateTree ( $ items ) { foreach ( $ items -> reverse ( ) -> all ( ) as $ index => $ item ) { $ parent = $ this -> findParent ( $ items , $ item ) ; if ( isset ( $ parent ) ) { $ parent -> setChild ( $ item ) ; $ items -> forget ( $ index ) ; } } return $ items ; }
Transform flat menu structure into tree .
48,793
public function findParent ( & $ items , $ item ) { return $ items -> filter ( function ( $ element ) use ( $ item ) { return $ item -> parent_id == $ element -> id ; } ) -> first ( ) ; }
Find parent item in menu .
48,794
protected function registerTemplates ( ) { $ this -> hook -> filter ( "theme_{$this->slug}_templates" , function ( $ templates ) { return array_merge ( $ templates , $ this -> templates ( ) ) ; } ) -> dispatch ( ) ; }
Register posttype templates .
48,795
public function plugIn ( $ adaptee ) { if ( is_array ( $ adaptee ) ) { foreach ( $ adaptee as $ item ) { $ this -> plugIn ( $ item ) ; } return $ this ; } $ this -> collection -> push ( $ this -> connectAdapter ( $ adaptee ) ) ; return $ this ; }
Plugin adaptees .
48,796
public function connectAdapter ( $ adaptee ) { $ adapter = new $ this -> adapter ( $ this -> config ) ; return $ adapter -> setAdaptee ( $ adaptee ) -> setModel ( $ this -> model ) ; }
Connect adapter model and adaptee .
48,797
public function register ( ) { $ this -> rule -> resolve ( $ this -> pattern , $ this -> conditions ) -> add ( ) ; if ( ! empty ( $ parameters = $ this -> rule -> getParameters ( ) ) ) { $ this -> tag -> add ( $ parameters ) ; } }
Registers rewrite rule and tags .
48,798
public function search ( ) { $ paths = explode ( '.' , $ this -> getPath ( ) ) ; $ record = array_filter ( $ this -> getSchema ( ) , function ( $ field ) use ( $ paths ) { return $ field -> getSlug ( ) == $ paths [ 0 ] ; } ) ; $ field = reset ( $ record ) ; if ( $ paths [ 0 ] !== end ( $ paths ) ) { return $ field -> getChildren ( ) -> getWithPath ( implode ( '.' , array_slice ( $ paths , 1 ) ) ) ; } if ( $ field ) { return $ field ; } throw new FieldException ( "We couldn't find Field: " . $ this -> getPath ( ) ) ; }
Search field in schema .
48,799
public function registerApplicationConfig ( ) { $ this -> singleton ( ApplicationConfig :: class , function ( ) { return new ApplicationConfig ( $ this -> getConfigFiles ( ) ) ; } ) ; $ this -> alias ( ApplicationConfig :: class , 'config' ) ; }
Load application configured configs .