idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
57,500 | public function defineTask ( $ taskName , $ baseTask , $ options ) { $ this -> tasks [ 'defined' ] [ $ taskName ] = [ 'task' => $ baseTask , 'options' => $ options ] ; return $ this ; } | Define a new task based on an existing task by setting options |
57,501 | public function beforeStage ( $ stage , $ tasks , Application $ application = null ) { $ this -> addTaskToStage ( $ tasks , $ stage , $ application , 'before' ) ; return $ this ; } | Add tasks that shall be executed before the given stage |
57,502 | public function afterStage ( $ stage , $ tasks , Application $ application = null ) { $ this -> addTaskToStage ( $ tasks , $ stage , $ application , 'after' ) ; return $ this ; } | Add tasks that shall be executed after the given stage |
57,503 | public function setTaskOptions ( $ taskName , $ options ) { $ baseTask = $ taskName ; if ( isset ( $ this -> tasks [ 'defined' ] [ $ taskName ] ) && is_array ( $ this -> tasks [ 'defined' ] [ $ taskName ] ) ) { $ definedTask = $ this -> tasks [ 'defined' ] [ $ taskName ] ; $ baseTask = $ definedTask [ 'task' ] ; if ( i... | Override options for given task |
57,504 | protected function executeStage ( $ stage , Node $ node , Application $ application , Deployment $ deployment ) { foreach ( [ 'before' , 'tasks' , 'after' ] as $ stageStep ) { foreach ( [ '_' , $ application -> getName ( ) ] as $ applicationName ) { $ label = $ applicationName === '_' ? 'for all' : 'for application ' .... | Execute a stage for a node and application |
57,505 | public function rollback ( Node $ node , Application $ application , Deployment $ deployment , array $ options = [ ] ) { $ unLockDeployment = new UnlockDeploymentTask ( ) ; $ unLockDeployment -> setShellCommandService ( new ShellCommandService ( ) ) ; $ unLockDeployment -> execute ( $ node , $ application , $ deploymen... | Removes lock file on failed deployment |
57,506 | public function rollback ( ) { foreach ( array_reverse ( $ this -> taskHistory ) as $ historicTask ) { $ historicTask [ 'deployment' ] -> getLogger ( ) -> info ( 'Rolling back ' . get_class ( $ historicTask [ 'task' ] ) ) ; if ( ! $ historicTask [ 'deployment' ] -> isDryRun ( ) ) { $ historicTask [ 'task' ] -> rollback... | Rollback all tasks stored in the task history in reverse order |
57,507 | protected function overrideOptions ( $ taskName , Deployment $ deployment , Node $ node , Application $ application , array $ taskOptions ) { $ globalOptions = array_merge ( $ deployment -> getOptions ( ) , $ node -> getOptions ( ) , $ application -> getOptions ( ) ) ; $ globalTaskOptions = [ ] ; foreach ( $ globalOpti... | Override options for a task |
57,508 | protected function createTaskInstance ( $ taskName ) { $ taskClassName = $ this -> mapTaskNameToTaskClass ( $ taskName ) ; $ task = new $ taskClassName ( ) ; if ( $ task instanceof ShellCommandServiceAwareInterface ) { $ task -> setShellCommandService ( new ShellCommandService ( ) ) ; } return $ task ; } | Create a task instance from the given task name |
57,509 | public function run ( Deployment $ deployment ) { parent :: run ( $ deployment ) ; $ applications = $ deployment -> getApplications ( ) ; if ( count ( $ applications ) === 0 ) { throw InvalidConfigurationException :: createNoApplicationConfigured ( ) ; } $ nodes = $ deployment -> getNodes ( ) ; if ( count ( $ nodes ) =... | Sequentially execute the stages for each node so first all nodes will go through the initialize stage and then the next stage will be executed until the final stage is reached and the workflow is finished . |
57,510 | public function getCommandPackageKey ( $ command = '' ) { if ( $ this -> getVersion ( ) < '4.0' ) { return $ this -> isNeosCommand ( $ command ) ? 'typo3.neos' : 'typo3.flow' ; } return $ this -> isNeosCommand ( $ command ) ? 'neos.neos' : 'neos.flow' ; } | Get the package key to prefix the command |
57,511 | public function simulate ( Node $ node , Application $ application , Deployment $ deployment , array $ options = [ ] ) { $ options = $ this -> configureOptions ( $ options ) ; $ this -> shell -> executeOrSimulate ( $ options [ 'varnishadm' ] . ' -S ' . $ options [ 'secretFile' ] . ' -T 127.0.0.1:6082 status' , $ node ,... | Simulate this task |
57,512 | protected function determineWorkingDirectoryAndTargetNode ( Node $ node , Application $ application , Deployment $ deployment , array $ options = [ ] ) { if ( ! isset ( $ this -> workingDirectory , $ this -> targetNode ) ) { if ( isset ( $ options [ 'useApplicationWorkspace' ] ) && $ options [ 'useApplicationWorkspace'... | Determines the path to the working directory and the target node by given options |
57,513 | protected function packageExists ( $ packageKey , Node $ node , CMS $ application , Deployment $ deployment , array $ options = [ ] ) { $ webDirectory = isset ( $ options [ 'webDirectory' ] ) ? trim ( $ options [ 'webDirectory' ] , '\\/' ) : '' ; return $ this -> directoryExists ( $ webDirectory . '/typo3conf/ext/' . $... | Checks if a package exists in the packages directory |
57,514 | protected function directoryExists ( $ directory , Node $ node , CMS $ application , Deployment $ deployment , array $ options = [ ] ) { $ this -> determineWorkingDirectoryAndTargetNode ( $ node , $ application , $ deployment , $ options ) ; $ directory = Files :: concatenatePaths ( [ $ this -> workingDirectory , $ dir... | Checks if a given directory exists . |
57,515 | protected function fileExists ( $ pathAndFileName , Node $ node , CMS $ application , Deployment $ deployment , array $ options = [ ] ) { $ this -> determineWorkingDirectoryAndTargetNode ( $ node , $ application , $ deployment , $ options ) ; $ pathAndFileName = $ this -> workingDirectory . '/' . $ pathAndFileName ; re... | Checks if a given file exists . |
57,516 | protected function registerTasksForUpdateMethod ( Workflow $ workflow , $ updateMethod ) { switch ( $ updateMethod ) { case 'composer' : $ workflow -> addTask ( InstallTask :: class , 'update' , $ this ) ; break ; default : parent :: registerTasksForUpdateMethod ( $ workflow , $ updateMethod ) ; break ; } } | Add support for updateMethod composer |
57,517 | public function buildCommand ( $ targetPath , $ command , array $ arguments = [ ] ) { return 'cd ' . $ targetPath . ' && FLOW_CONTEXT=' . $ this -> getContext ( ) . ' ./' . $ this -> getFlowScriptName ( ) . ' ' . $ this -> getCommandPackageKey ( $ command ) . ':' . $ command . ' ' . implode ( ' ' , array_map ( 'escapes... | Returns a executable flow command including the context |
57,518 | protected function composerManifestExists ( $ path , Node $ node , Deployment $ deployment ) { if ( $ deployment -> isDryRun ( ) ) { return false ; } $ composerJsonPath = Files :: concatenatePaths ( [ $ path , 'composer.json' ] ) ; $ composerJsonExists = $ this -> shell -> executeOrSimulate ( 'test -f ' . escapeshellar... | Checks if a composer manifest exists in the directory at the given path . |
57,519 | protected function processOptions ( array $ options , Deployment $ deployment ) { foreach ( [ 'tagName' , 'description' ] as $ optionName ) { $ options [ $ optionName ] = str_replace ( [ '{releaseIdentifier}' , '{deploymentName}' ] , [ $ deployment -> getReleaseIdentifier ( ) , $ deployment -> getName ( ) ] , $ options... | Replace placeholders in option values and set default values |
57,520 | public function encode ( string $ data ) : string { $ data = str_split ( $ data ) ; $ data = array_map ( "ord" , $ data ) ; $ leadingZeroes = 0 ; while ( ! empty ( $ data ) && 0 === $ data [ 0 ] ) { $ leadingZeroes ++ ; array_shift ( $ data ) ; } $ converted = $ this -> baseConvert ( $ data , 256 , 62 ) ; if ( 0 < $ le... | Encode given data to a base62 string |
57,521 | public function decode ( string $ data ) : string { $ this -> validateInput ( $ data ) ; $ data = str_split ( $ data ) ; $ data = array_map ( function ( $ character ) { return strpos ( $ this -> options [ "characters" ] , $ character ) ; } , $ data ) ; $ leadingZeroes = 0 ; while ( ! empty ( $ data ) && 0 === $ data [ ... | Decode given a base62 string back to data |
57,522 | public function encodeInteger ( int $ data ) : string { $ data = [ $ data ] ; $ converted = $ this -> baseConvert ( $ data , 256 , 62 ) ; return implode ( "" , array_map ( function ( $ index ) { return $ this -> options [ "characters" ] [ $ index ] ; } , $ converted ) ) ; } | Encode given integer to a base62 string |
57,523 | public function decodeInteger ( string $ data ) : int { $ this -> validateInput ( $ data ) ; $ data = str_split ( $ data ) ; $ data = array_map ( function ( $ character ) { return strpos ( $ this -> options [ "characters" ] , $ character ) ; } , $ data ) ; $ converted = $ this -> baseConvert ( $ data , 62 , 10 ) ; retu... | Decode given base62 string back to an integer |
57,524 | public function register ( ) { $ this -> app -> bind ( ViewContract :: class , View :: class ) ; $ this -> app -> alias ( ViewContract :: class , 'view' ) ; } | Binds the implementation of the view contract to the container . |
57,525 | protected function hierarchy ( ) { foreach ( $ this -> slugs as $ slug ) { $ templates [ ] = "{$this->name}/{$slug}.php" ; } if ( ! in_array ( 'default' , $ this -> slugs ) ) { $ templates [ ] = "{$this->name}/default.php" ; } $ templates [ ] = "{$this->name}.php" ; return apply_filters ( "hybrid/view/{$this->name}/hie... | Uses the array of template slugs to build a hierarchy of potential templates that can be used . |
57,526 | public function template ( ) { if ( is_null ( $ this -> template ) ) { $ this -> template = $ this -> locate ( ) ; } return $ this -> template ; } | Returns the located template . |
57,527 | public function display ( ) { $ this -> templatePartCompat ( ) ; if ( $ this -> template ( ) ) { $ this -> maybeShiftAttachment ( ) ; $ data = $ this -> data ; if ( $ this -> data instanceof Collection ) { extract ( $ this -> data -> all ( ) ) ; } include ( $ this -> template ( ) ) ; } } | Sets up data to be passed to the template and renders it . |
57,528 | protected function templatePartCompat ( ) { $ slug = $ this -> slugs ? reset ( $ this -> slugs ) : null ; if ( in_array ( $ this -> name , [ 'header' , 'footer' , 'sidebar' ] ) ) { do_action ( "get_{$this->name}" , $ slug ) ; } else { do_action ( "get_template_part_{$this->name}" , $ this -> name , $ slug ) ; } } | Fires the core WP action hooks for template parts . |
57,529 | protected function maybeShiftAttachment ( ) { if ( ! in_the_loop ( ) || 'attachment' !== get_post_type ( ) ) { return ; } if ( in_array ( $ this -> name , [ 'entry' , 'post' , 'entry/archive' , 'entry/single' ] ) ) { remove_filter ( 'the_content' , 'prepend_attachment' ) ; } elseif ( 'embed' === $ this -> name ) { remo... | Removes core WP s prepend_attachment filter whenever a theme is building custom attachment templates . We ll assume that the theme author will handle the appropriate output in the template itself . |
57,530 | public function render ( ) { $ html = '' ; foreach ( $ this -> all ( ) as $ name => $ value ) { $ esc_value = '' ; if ( $ value !== false && 'href' === $ name ) { $ esc_value = esc_url ( $ value ) ; } elseif ( $ value !== false ) { $ esc_value = esc_attr ( $ value ) ; } $ html .= false !== $ value ? sprintf ( ' %s="%s"... | Returns an escaped string of attributes for use in HTML . |
57,531 | public function get ( $ name ) { $ attr = $ this -> all ( ) ; return isset ( $ attr [ $ name ] ) ? $ attr [ $ name ] : '' ; } | Returns a single unescaped attribute s value . |
57,532 | public function all ( ) { if ( $ this -> attr ) { return $ this -> attr ; } $ defaults = [ ] ; if ( isset ( $ this -> input [ 'class' ] ) ) { $ defaults [ 'class' ] = $ this -> input [ 'class' ] ; unset ( $ this -> input [ 'class' ] ) ; } else { $ defaults [ 'class' ] = $ this -> context ? "{$this->name} {$this->name}-... | Filters and returns the array of attributes . |
57,533 | protected function comment ( $ attr ) { $ class = isset ( $ attr [ 'class' ] ) ? $ attr [ 'class' ] : '' ; $ attr [ 'id' ] = 'comment-' . get_comment_ID ( ) ; $ attr [ 'class' ] = join ( ' ' , get_comment_class ( $ class ) ) ; return $ attr ; } | Comment wrapper attributes . |
57,534 | public static function current ( ) { $ title = '' ; if ( is_front_page ( ) ) { $ title = static :: frontPage ( ) ; } elseif ( is_home ( ) || is_singular ( ) ) { $ title = static :: post ( ) ; } elseif ( is_archive ( ) ) { $ title = static :: archive ( ) ; } elseif ( is_search ( ) ) { $ title = static :: search ( ) ; } ... | Retrieve the current page title . |
57,535 | public static function archive ( ) { $ title = '' ; if ( is_category ( ) || is_tag ( ) || is_tax ( ) ) { $ title = static :: term ( ) ; } elseif ( is_post_type_archive ( ) ) { $ title = static :: postTypeArchive ( ) ; } elseif ( is_author ( ) ) { $ title = static :: author ( ) ; } elseif ( get_query_var ( 'minute' ) &&... | Retrieve the general archive title . |
57,536 | protected function locate ( ) { add_filter ( 'embed_maybe_make_link' , '__return_false' ) ; if ( 'attachment' === get_post_type ( $ this -> post_id ) ) { $ this -> media = $ this -> locateSelfMedia ( ) ; } if ( ! $ this -> media && $ this -> shortcodes ) { $ this -> media = $ this -> locateShortcodeMedia ( ) ; } if ( !... | Tries several methods to find media related to the post . Returns the found media . |
57,537 | protected function locateSelfMedia ( ) { $ url = esc_url ( wp_get_attachment_url ( $ this -> post_id ) ) ; $ mime = get_post_mime_type ( $ this -> post_id ) ; list ( $ type , $ subtype ) = false !== strpos ( $ mime , '/' ) ? explode ( '/' , $ mime ) : [ $ mime , '' ] ; return in_array ( $ type , [ 'audio' , 'video' ] )... | If the post type itself is an attachment call the shortcode wrapper function for handling the media . |
57,538 | protected function locateShortcodeMedia ( ) { preg_match_all ( '/' . get_shortcode_regex ( ) . '/s' , $ this -> content , $ matches , PREG_SET_ORDER ) ; if ( empty ( $ matches ) ) { return '' ; } $ shortcodes = is_array ( $ this -> shortcodes ) ? $ this -> shortcodes : [ ] ; $ property = "{$this->type}_shortcodes" ; if... | Searches for shortcodes in the post content and sets the generated shortcode output if one is found . |
57,539 | protected function locateAutoembedMedia ( ) { preg_match_all ( '|^\s*(https?://[^\s"]+)\s*$|im' , $ this -> content , $ matches , PREG_SET_ORDER ) ; if ( empty ( $ matches ) || ! is_array ( $ matches ) ) { return '' ; } foreach ( $ matches as $ value ) { $ embed = $ GLOBALS [ 'wp_embed' ] -> autoembed ( $ value [ 0 ] )... | Uses WordPress autoembed feature to automatically to handle media that s just input as a URL . |
57,540 | protected function doShortcode ( $ tag , $ shortcode ) { if ( 'embed' === $ tag ) { return $ GLOBALS [ 'wp_embed' ] -> run_shortcode ( $ shortcode ) ; } elseif ( 'video' === $ tag ) { return do_shortcode ( $ this -> filterDimensions ( $ shortcode ) ) ; } return do_shortcode ( $ shortcode ) ; } | Helper function for running a shortcode . |
57,541 | public function split ( $ content ) { if ( get_the_ID ( ) === ( int ) $ this -> post_id ) { $ content = str_replace ( $ this -> original_media , '' , $ content ) ; $ content = wp_kses_post ( $ content ) ; } return $ content ; } | Removes the found media from the content . The purpose of this is so that themes can retrieve the media from the content and display it elsewhere on the page based on its design . |
57,542 | protected function filterDimensions ( $ html ) { $ media_atts = [ ] ; $ _html = strip_tags ( $ html , '<object><embed><iframe><video>' ) ; $ atts = wp_kses_hair ( $ _html , [ 'http' , 'https' ] ) ; foreach ( $ atts as $ att ) { $ media_atts [ $ att [ 'name' ] ] = $ att [ 'value' ] ; } if ( empty ( $ media_atts ) || ! i... | Method for filtering the media s width and height attributes so that the theme can handle the dimensions how it sees fit . |
57,543 | public function register ( ) { $ this -> app -> bind ( Attributes :: class , Attr :: class ) ; $ this -> app -> alias ( Attributes :: class , 'attr' ) ; } | Binds the implementation of the attributes contract to the container . |
57,544 | protected function postsArgs ( ) { global $ wp_query , $ wp_rewrite ; $ pagenum_link = html_entity_decode ( get_pagenum_link ( ) ) ; $ this -> url_parts = explode ( '?' , $ pagenum_link ) ; $ total = isset ( $ wp_query -> max_num_pages ) ? $ wp_query -> max_num_pages : 1 ; $ current = get_query_var ( 'paged' ) ? intval... | Returns custom arguments for normal posts pagination . |
57,545 | protected function postArgs ( ) { global $ page , $ numpages , $ more , $ wp_rewrite ; $ this -> url_parts = explode ( '?' , html_entity_decode ( get_permalink ( ) ) ) ; $ base = trailingslashit ( $ this -> url_parts [ 0 ] ) . '%_%' ; $ format = $ wp_rewrite -> using_index_permalinks ( ) && ! strpos ( $ base , 'index.p... | Returns custom arguments for singular post pagination . |
57,546 | protected function commentsArgs ( ) { global $ wp_rewrite ; $ base = add_query_arg ( 'cpage' , '%#%' ) ; $ this -> url_parts = explode ( '?' , html_entity_decode ( get_pagenum_link ( ) ) ) ; if ( $ wp_rewrite -> using_permalinks ( ) ) { $ base = user_trailingslashit ( trailingslashit ( get_permalink ( ) ) . $ wp_rewrit... | Returns custom arguments for comments pagination . |
57,547 | public function render ( ) { $ title = $ list = $ template = '' ; if ( $ this -> items ) { if ( $ this -> args [ 'title_text' ] ) { $ title = sprintf ( '<%1$s class="%2$s">%3$s</%1$s>' , tag_escape ( $ this -> args [ 'title_tag' ] ) , esc_attr ( $ this -> args [ 'title_class' ] ) , esc_html ( $ this -> args [ 'title_te... | Returns the pagination output . |
57,548 | private function formatItem ( $ item ) { $ is_link = isset ( $ item [ 'url' ] ) ; $ attr = [ ] ; $ esc_attr = '' ; $ attr [ 'class' ] = sprintf ( $ this -> args [ 'anchor_class' ] , $ is_link ? 'link' : $ item [ 'type' ] ) ; if ( $ is_link ) { $ attr [ 'href' ] = $ item [ 'url' ] ; } if ( 'current' === $ item [ 'type' ... | Format an item s HTML output . |
57,549 | protected function prevItem ( ) { if ( $ this -> args [ 'prev_next' ] && $ this -> current && 1 < $ this -> current ) { $ this -> items [ ] = [ 'type' => 'prev' , 'url' => $ this -> buildUrl ( 2 == $ this -> current ? '' : $ this -> args [ 'format' ] , $ this -> current - 1 ) , 'content' => $ this -> args [ 'prev_text'... | Builds the previous item . |
57,550 | protected function nextItem ( ) { if ( $ this -> args [ 'prev_next' ] && $ this -> current && $ this -> current < $ this -> total ) { $ this -> items [ ] = [ 'type' => 'next' , 'url' => $ this -> buildUrl ( $ this -> args [ 'format' ] , $ this -> current + 1 ) , 'content' => $ this -> args [ 'next_text' ] ] ; } } | Builds the next item . |
57,551 | protected function pageItem ( $ n ) { if ( $ n === $ this -> current ) { $ this -> items [ ] = [ 'type' => 'current' , 'content' => $ this -> args [ 'before_page_number' ] . number_format_i18n ( $ n ) . $ this -> args [ 'after_page_number' ] ] ; $ this -> dots = true ; } else { if ( $ this -> args [ 'show_all' ] || ( $... | Builds the numeric page link current item and dots item . |
57,552 | protected function buildUrl ( $ format , $ number ) { $ link = str_replace ( '%_%' , $ format , $ this -> args [ 'base' ] ) ; $ link = str_replace ( '%#%' , $ number , $ link ) ; if ( $ this -> args [ 'add_args' ] ) { $ link = add_query_arg ( $ this -> args [ 'add_args' ] , $ link ) ; } $ link .= $ this -> args [ 'add_... | Builds and formats a page link URL . |
57,553 | protected function registerDefaultBindings ( ) { $ this -> instance ( 'app' , $ this ) ; $ this -> instance ( 'path' , untrailingslashit ( HYBRID_DIR ) ) ; $ this -> instance ( 'version' , static :: VERSION ) ; } | Registers the default bindings we need to run the framework . |
57,554 | protected function registerDefaultProviders ( ) { array_map ( function ( $ provider ) { $ this -> provider ( $ provider ) ; } , [ AttrServiceProvider :: class , LanguageServiceProvider :: class , MetaServiceProvider :: class , TemplatesServiceProvider :: class , HierarchyServiceProvider :: class , ViewServiceProvider :... | Adds the default service providers for the framework . |
57,555 | public function provider ( $ provider ) { if ( is_string ( $ provider ) ) { $ provider = $ this -> resolveProvider ( $ provider ) ; } $ this -> providers [ ] = $ provider ; } | Adds a service provider . |
57,556 | protected function registerProxies ( ) { Proxy :: setContainer ( $ this ) ; foreach ( $ this -> proxies as $ class => $ alias ) { class_alias ( $ class , $ alias ) ; } } | Registers the static proxy classes . |
57,557 | public function boot ( ) { add_action ( 'after_setup_theme' , [ $ this , 'loadLocaleFunctions' ] , ~ PHP_INT_MAX ) ; add_action ( 'after_setup_theme' , [ $ this , 'loadTextdomain' ] , 95 ) ; add_filter ( 'override_load_textdomain' , [ $ this , 'overrideLoadTextdomain' ] , 5 , 3 ) ; add_filter ( 'load_textdomain_mofile'... | Adds the class actions and filters . |
57,558 | public function overrideLoadTextdomain ( $ override , $ domain , $ mofile ) { global $ l10n ; if ( 'hybrid-core' === $ domain ) { $ theme_textdomain = $ this -> parentTextdomain ( ) ; if ( $ theme_textdomain && isset ( $ l10n [ $ theme_textdomain ] ) ) { $ l10n [ $ domain ] = $ l10n [ $ theme_textdomain ] ; } $ overrid... | Overrides the load textdomain functionality when hybrid - core is the domain in use . The purpose of this is to allow theme translations to handle the framework s strings . What this function does is sets the hybrid - core domain s translations to the theme s . That way we re not loading multiple of the same MO files . |
57,559 | public function loadTextdomainMofile ( $ mofile , $ domain ) { if ( $ domain == $ this -> parentTextdomain ( ) || $ domain == $ this -> childTextdomain ( ) ) { $ locale = is_admin ( ) ? get_user_locale ( ) : get_locale ( ) ; $ child_mofile = $ this -> childPath ( "{$domain}-{$locale}.mo" ) ; $ theme_mofile = $ this -> ... | Filters the load_textdomain_mofile filter hook so that we can prepend the theme textdomain to the mofile filename . This also allows child themes to house a copy of the parent theme translations so that it doesn t get overwritten when a parent theme is updated . |
57,560 | public function register ( ) { $ this -> app -> singleton ( TemplateHierarchy :: class , Hierarchy :: class ) ; $ this -> app -> alias ( TemplateHierarchy :: class , 'template/hierarchy' ) ; } | Registration callback that adds a single instance of the template hierarchy to the container . |
57,561 | public function bind ( $ abstract , $ concrete = null , $ shared = false ) { unset ( $ this -> instances [ $ abstract ] ) ; if ( is_null ( $ concrete ) ) { $ concrete = $ abstract ; } $ this -> bindings [ $ abstract ] = compact ( 'concrete' , 'shared' ) ; $ this -> extensions [ $ abstract ] = [ ] ; } | Add a binding . The abstract should be a key abstract class name or interface name . The concrete should be the concrete implementation of the abstract . If no concrete is given its assumed the abstract handles the concrete implementation . |
57,562 | public function resolve ( $ abstract , array $ parameters = [ ] ) { $ abstract = $ this -> getAbstract ( $ abstract ) ; if ( isset ( $ this -> instances [ $ abstract ] ) ) { return $ this -> instances [ $ abstract ] ; } $ concrete = $ this -> getConcrete ( $ abstract ) ; if ( ! $ this -> isBuildable ( $ concrete ) ) { ... | Resolve and return the binding . |
57,563 | protected function getConcrete ( $ abstract ) { $ concrete = false ; $ abstract = $ this -> getAbstract ( $ abstract ) ; if ( $ this -> has ( $ abstract ) ) { $ concrete = $ this -> bindings [ $ abstract ] [ 'concrete' ] ; } return $ concrete ? : $ abstract ; } | Gets the concrete of an abstract . |
57,564 | protected function build ( $ concrete , array $ parameters = [ ] ) { if ( $ concrete instanceof Closure ) { return $ concrete ( $ this , $ parameters ) ; } $ reflect = new ReflectionClass ( $ concrete ) ; $ constructor = $ reflect -> getConstructor ( ) ; if ( ! $ constructor ) { return new $ concrete ( ) ; } return $ r... | Builds the concrete implementation . If a closure we ll simply return the closure and pass the included parameters . Otherwise we ll resolve the dependencies for the class and return a new object . |
57,565 | protected function resolveDependencies ( array $ dependencies , array $ parameters ) { $ args = [ ] ; foreach ( $ dependencies as $ dependency ) { if ( isset ( $ parameters [ $ dependency -> getName ( ) ] ) ) { $ args [ ] = $ parameters [ $ dependency -> getName ( ) ] ; } elseif ( ! is_null ( $ dependency -> getClass (... | Resolves the dependencies for a method s parameters . |
57,566 | public function register ( ) { $ this -> app -> singleton ( LanguageContract :: class , Language :: class ) ; $ this -> app -> alias ( LanguageContract :: class , 'language' ) ; } | Registration callback that adds a single instance of the language system to the container . |
57,567 | public function boot ( ) { add_filter ( 'frontpage_template_hierarchy' , [ $ this , 'frontPage' ] , 5 ) ; add_filter ( 'single_template_hierarchy' , [ $ this , 'single' ] , 5 ) ; add_filter ( 'page_template_hierarchy' , [ $ this , 'single' ] , 5 ) ; add_filter ( 'attachment_template_hierarchy' , [ $ this , 'single' ] ,... | Sets up template hierarchy filters . |
57,568 | public function frontPage ( $ templates ) { $ templates = [ ] ; if ( ! is_home ( ) ) { $ custom = get_page_template_slug ( get_queried_object_id ( ) ) ; if ( $ custom ) { $ templates [ ] = $ custom ; } $ templates [ ] = 'front-page.php' ; } return $ templates ; } | Fix for the front page template handling in WordPress core . Its handling is not logical because it forces devs to account for both a page on the front page and posts on the front page . Theme devs must handle both scenarios if they ve created a front - page . php template . This filter overwrites that and disables the... |
57,569 | public function taxonomy ( $ template ) { $ templates = [ ] ; $ term = get_queried_object ( ) ; $ slug = urldecode ( $ term -> slug ) ; if ( 'post_format' === $ term -> taxonomy ) { $ slug = str_replace ( 'post-format-' , '' , $ slug ) ; } $ templates [ ] = "taxonomy-{$term->taxonomy}-{$slug}.php" ; $ templates [ ] = "... | Overrides WP s default template for taxonomy - based archives . This allows better organization of taxonomy template files by making categories and post tags work the same way as other taxonomies . |
57,570 | public function get ( $ key ) { if ( 'filesize' === $ key ) { $ key = 'file_size' ; } $ method = str_replace ( '_' , '' , lcfirst ( ucwords ( $ key , '_' ) ) ) ; $ value = method_exists ( $ this , $ method ) ? $ this -> $ method ( ) : esc_html ( $ this -> raw ( $ key ) ) ; return apply_filters ( "hybrid/media/meta/{$ke... | Returns the escaped and formatted media meta . |
57,571 | protected function raw ( $ key ) { $ value = '' ; if ( isset ( $ this -> meta [ $ key ] ) ) { $ value = $ this -> meta [ $ key ] ; } elseif ( isset ( $ this -> meta [ 'image_meta' ] ) && isset ( $ this -> meta [ 'image_meta' ] [ $ key ] ) ) { $ value = $ this -> meta [ 'image_meta' ] [ $ key ] ; } elseif ( isset ( $ th... | Returns raw data from the media meta . |
57,572 | protected function aperture ( ) { $ aperture = $ this -> raw ( 'aperture' ) ; if ( $ aperture ) { $ aperture = sprintf ( '<sup>f</sup>⁄<sub>%s</sub>' , absint ( $ aperture ) ) ; } return $ aperture ; } | Returns the camera aperture for an image . |
57,573 | protected function createdTimestamp ( ) { $ timestamp = $ this -> raw ( 'created_timestamp' ) ; if ( $ timestamp ) { $ timestamp = date_i18n ( get_option ( 'date_format' ) , strip_tags ( $ timestamp ) ) ; } return $ timestamp ; } | Returns the created timestamp for an image . |
57,574 | protected function fileName ( ) { $ filename = basename ( get_attached_file ( $ this -> post -> ID ) ) ; if ( $ filename ) { $ filename = sprintf ( '<a href="%s">%s</a>' , esc_url ( wp_get_attachment_url ( $ this -> post -> ID ) ) , $ filename ) ; } return $ filename ; } | Returns the media file name linked to the original media file . |
57,575 | protected function fileSize ( ) { $ filesize = isset ( $ this -> meta [ 'filesize' ] ) ? $ this -> meta [ 'filesize' ] : '' ; if ( ! $ filesize ) { $ file = get_attached_file ( $ this -> post -> ID ) ; if ( file_exists ( $ file ) ) { $ filesize = filesize ( $ file ) ; } } if ( $ filesize ) { $ filesize = size_format ( ... | Returns the media file size . |
57,576 | protected function fileType ( ) { $ type = '' ; if ( preg_match ( '/^.*?\.(\w+)$/' , get_attached_file ( $ this -> post -> ID ) , $ matches ) ) { $ type = $ matches [ 1 ] ; } return $ type ? esc_html ( strtoupper ( $ type ) ) : '' ; } | Returns the media file type . |
57,577 | protected function focalLength ( ) { $ focal_length = $ this -> raw ( 'focal_length' ) ; if ( $ focal_length ) { $ focal_length = sprintf ( __ ( '%s mm' , 'hybrid-core' ) , absint ( $ focal_length ) ) ; } return $ focal_length ; } | Returns the camera focal length for an image . |
57,578 | protected function lyrics ( ) { $ lyrics = '' ; if ( isset ( $ this -> meta [ 'unsynchronised_lyric' ] ) ) { $ lyrics = $ this -> meta [ 'unsynchronised_lyric' ] ; } elseif ( isset ( $ this -> meta [ 'unsychronised_lyric' ] ) ) { $ lyrics = $ this -> meta [ 'unsychronised_lyric' ] ; } if ( $ lyrics ) { $ lyrics = strip... | Returns the lyrics for an audio file . |
57,579 | protected function mimeType ( ) { $ mime_type = get_post_mime_type ( $ this -> post ) ; if ( ! $ mime_type ) { $ mime_type = $ this -> raw ( 'mime_type' ) ; } return $ mime_type ? esc_html ( $ mime_type ) : '' ; } | Returns the media file mime type . |
57,580 | protected function shutterSpeed ( ) { $ shutter = $ this -> raw ( 'shutter_speed' ) ; if ( $ shutter ) { $ shutter = $ speed = floatval ( strip_tags ( $ shutter ) ) ; if ( ( 1 / $ speed ) > 1 ) { $ shutter = sprintf ( '<sup>%s</sup>⁄' , number_format_i18n ( 1 ) ) ; if ( number_format ( ( 1 / $ speed ) , 1 ) == nu... | Returns the camera shutter speed for an image . |
57,581 | public function postTemplates ( $ templates , $ theme , $ post , $ post_type ) { foreach ( $ this -> templates -> all ( ) as $ template ) { if ( $ template -> forPostType ( $ post_type ) ) { $ templates [ $ template -> filename ( ) ] = esc_html ( $ template -> label ( ) ) ; } } return $ templates ; } | Filter used on theme_templates to add custom templates to the template drop - down . |
57,582 | private function prepareAttributeUnconditional ( PHPTAL_Php_CodeWriter $ codewriter , $ qname , $ code ) { $ attkey = $ this -> getVarName ( $ qname , $ codewriter ) ; if ( $ this -> _echoType == PHPTAL_Php_Attribute :: ECHO_STRUCTURE ) { $ value = $ codewriter -> stringifyCode ( $ code ) ; } else { $ value = $ codewri... | attribute will be output regardless of its evaluated value . NULL behaves just like . |
57,583 | private function prepareAttributeConditional ( PHPTAL_Php_CodeWriter $ codewriter , $ qname , $ code ) { $ attkey = $ this -> getVarName ( $ qname , $ codewriter ) ; $ codewriter -> doIf ( "null !== ($attkey = ($code))" ) ; if ( $ this -> _echoType !== PHPTAL_Php_Attribute :: ECHO_STRUCTURE ) $ codewriter -> doSetVar (... | If evaluated value of attribute is NULL it will not be output at all . |
57,584 | public function hasAttribute ( $ qname ) { foreach ( $ this -> attribute_nodes as $ attr ) if ( $ attr -> getQualifiedName ( ) == $ qname ) return true ; return false ; } | Returns true if the element contains specified PHPTAL attribute . |
57,585 | public function getOrCreateAttributeNode ( $ qname ) { if ( $ attr = $ this -> getAttributeNode ( $ qname ) ) return $ attr ; $ attr = new PHPTAL_Dom_Attr ( $ qname , "" , null , 'UTF-8' ) ; $ this -> attribute_nodes [ ] = $ attr ; return $ attr ; } | If possible use getAttributeNodeNS and setAttributeNS . |
57,586 | public function setAttributeNS ( $ namespace_uri , $ qname , $ value ) { $ localname = preg_replace ( '/^[^:]*:/' , '' , $ qname ) ; if ( ! ( $ n = $ this -> getAttributeNodeNS ( $ namespace_uri , $ localname ) ) ) { $ this -> attribute_nodes [ ] = $ n = new PHPTAL_Dom_Attr ( $ qname , $ namespace_uri , null , 'UTF-8' ... | Set attribute value . Creates new attribute if it doesn t exist yet . |
57,587 | public function generateSurroundHead ( PHPTAL_Php_CodeWriter $ codewriter ) { foreach ( $ this -> surroundAttributes as $ att ) { $ att -> before ( $ codewriter ) ; } } | ~~~~~ Generation methods may be called by some PHPTAL attributes ~~~~~ |
57,588 | private function generateAttributes ( PHPTAL_Php_CodeWriter $ codewriter ) { $ html5mode = ( $ codewriter -> getOutputMode ( ) === PHPTAL :: HTML5 ) ; foreach ( $ this -> getAttributeNodes ( ) as $ attr ) { if ( $ html5mode && $ attr -> isNamespaceDeclaration ( ) ) { continue ; } switch ( $ attr -> getReplacedState ( )... | ~~~~~ Private members ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
57,589 | private function setTemplateSource ( ) { $ this -> srcFile = $ this -> file ; $ this -> srcLine = $ this -> line ; list ( $ file , $ line ) = $ this -> findFileAndLine ( ) ; if ( NULL === $ file ) { return false ; } $ this -> srcFile = $ file ; $ this -> srcLine = $ line ; $ lines = @ file ( $ file ) ; if ( ! $ lines )... | sets srcLine and srcFile to template path and source line by checking error backtrace and scanning PHP code file |
57,590 | public function doDoctype ( $ called_from_macro = false ) { if ( $ this -> _doctype ) { $ code = '$ctx->setDocType(' . $ this -> str ( $ this -> _doctype ) . ',' . ( $ called_from_macro ? 'true' : 'false' ) . ')' ; $ this -> pushCode ( $ code ) ; } } | Generate code for setting DOCTYPE |
57,591 | public function doXmlDeclaration ( $ called_from_macro = false ) { if ( $ this -> _xmldeclaration && $ this -> getOutputMode ( ) !== PHPTAL :: HTML5 ) { $ code = '$ctx->setXmlDeclaration(' . $ this -> str ( $ this -> _xmldeclaration ) . ',' . ( $ called_from_macro ? 'true' : 'false' ) . ')' ; $ this -> pushCode ( $ cod... | Generate XML declaration |
57,592 | public function setTemplate ( $ path ) { $ this -> _prepared = false ; $ this -> _functionName = null ; $ this -> _codeFile = null ; $ this -> _path = $ path ; $ this -> _source = null ; $ this -> _context -> _docType = null ; $ this -> _context -> _xmlDeclaration = null ; return $ this ; } | Set template from file path . |
57,593 | public function setSource ( $ src , $ path = null ) { $ this -> _prepared = false ; $ this -> _functionName = null ; $ this -> _codeFile = null ; $ this -> _source = new PHPTAL_StringSource ( $ src , $ path ) ; $ this -> _path = $ this -> _source -> getRealPath ( ) ; $ this -> _context -> _docType = null ; $ this -> _c... | Set template from source . |
57,594 | public function setTemplateRepository ( $ rep ) { if ( is_array ( $ rep ) ) { $ this -> _repositories = $ rep ; } else { $ this -> _repositories [ ] = $ rep ; } return $ this ; } | Specify where to look for templates . |
57,595 | public function setEncoding ( $ enc ) { $ enc = strtoupper ( $ enc ) ; if ( $ enc != $ this -> _encoding ) { $ this -> _encoding = $ enc ; if ( $ this -> _translator ) $ this -> _translator -> setEncoding ( $ enc ) ; $ this -> resetPrepared ( ) ; } return $ this ; } | Set input and ouput encoding . Encoding is case - insensitive . |
57,596 | public function setTranslator ( PHPTAL_TranslationService $ t ) { $ this -> _translator = $ t ; $ t -> setEncoding ( $ this -> getEncoding ( ) ) ; return $ this ; } | Set I18N translator . |
57,597 | final public function addPreFilter ( $ filter ) { $ this -> resetPrepared ( ) ; if ( ! $ filter instanceof PHPTAL_PreFilter ) { throw new PHPTAL_ConfigurationException ( "addPreFilter expects PHPTAL_PreFilter object" ) ; } $ this -> prefilters [ ] = $ filter ; return $ this ; } | Add new prefilter to filter chain . Prefilters are called only once template is compiled . |
57,598 | private function getPreFiltersCacheId ( ) { $ cacheid = '' ; foreach ( $ this -> getPreFilters ( ) as $ key => $ prefilter ) { if ( $ prefilter instanceof PHPTAL_PreFilter ) { $ cacheid .= $ key . $ prefilter -> getCacheId ( ) ; } elseif ( $ prefilter instanceof PHPTAL_Filter ) { $ cacheid .= $ key . get_class ( $ pref... | Returns string that is unique for every different configuration of prefilters . Result of prefilters may be cached until this string changes . |
57,599 | public function execute ( ) { try { if ( ! $ this -> _prepared ) { $ this -> prepare ( ) ; } $ this -> _context -> echoDeclarations ( false ) ; $ templateFunction = $ this -> getFunctionName ( ) ; try { ob_start ( ) ; $ templateFunction ( $ this , $ this -> _context ) ; $ res = ob_get_clean ( ) ; } catch ( Exception $ ... | Execute the template code and return generated markup . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.