idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
14,900 | protected function addRemoteResource ( ResourceSettings $ settings ) : bool { $ settings -> repositoryKey = $ this -> getRemoteResourceRepositoryKey ( $ settings ) ; if ( $ this -> resources -> has ( $ settings -> repositoryKey ) ) { ++ $ settings -> order ; return $ this -> addRemoteResource ( $ settings ) ; } if ( $ ... | Add remote resource |
14,901 | protected function addLocalResource ( ResourceSettings $ settings ) : bool { $ settings -> repositoryKey = $ this -> getLocalResourceRepositoryKey ( $ settings ) ; if ( $ this -> resources -> has ( $ settings -> repositoryKey ) ) { ++ $ settings -> order ; return $ this -> addLocalResource ( $ settings ) ; } $ this -> ... | Add local resource |
14,902 | protected function searchForMinifiedResource ( ResourceSettings $ settings , string $ min = 'min' ) : string { if ( strpos ( $ settings -> filename , ".{$min}." ) !== false ) { return $ settings -> filename ; } $ pathinfo = pathinfo ( $ settings -> resourcePath ) ; $ minResource = "{$pathinfo['filename']}.{$min}.{$path... | Search for minified version of resource |
14,903 | protected function exists ( string $ resource , Theme $ theme = null ) : bool { return is_file ( $ this -> getResourcePath ( $ resource , $ theme ) ) ; } | Check if resource exists |
14,904 | public function getResourcePath ( string $ resource , Theme $ theme = null ) : string { return $ this -> createPath ( $ this -> getBasePath ( $ theme ) , $ resource ) ; } | Get path to a resource |
14,905 | protected function getBasePath ( Theme $ theme = null ) : string { $ theme = $ theme ?? $ this -> getTheme ( ) ; if ( isset ( $ this -> fullPaths [ $ theme -> getKey ( ) ] ) ) { return $ this -> fullPaths [ $ theme -> getKey ( ) ] ; } return $ this -> fullPaths [ $ theme -> getKey ( ) ] = $ this -> createPath ( $ theme... | Get full base path |
14,906 | public function getThemeResourceUrl ( string $ resource , Theme $ theme = null ) : string { return $ this -> createPath ( $ this -> getThemeBaseUrl ( $ theme ) , $ resource ) ; } | Get URL to web resource |
14,907 | protected function getThemeBaseUrl ( ? Theme $ theme = null ) : string { $ theme = $ theme ?? $ this -> getTheme ( ) ; if ( isset ( $ this -> webPaths [ $ theme -> getKey ( ) ] ) ) { return $ this -> webPaths [ $ theme -> getKey ( ) ] ; } return $ this -> webPaths [ $ theme -> getKey ( ) ] = $ this -> url -> make ( new... | Get web path for resource group |
14,908 | protected function parseOutputUrl ( $ url , $ file ) : string { if ( is_string ( $ url ) ) { $ url = rtrim ( $ url , '/' ) . '/' . ltrim ( $ file , '/' ) ; return $ this -> url -> url ( $ url ) ; } if ( is_array ( $ url ) ) { $ url = new UrlSettings ( $ url ) ; } if ( ! ( $ url instanceof UrlSettings ) ) { throw new In... | Get the url for output |
14,909 | protected function missing ( string $ resource , Theme $ theme = null ) { $ path = $ this -> getBasePath ( ) ; $ message = "{$resource} not found in {$path}" ; if ( ! $ this -> themeIsDefault ( $ theme ) ) { $ default = $ this -> getBasePath ( $ this -> getDefaultTheme ( ) ) ; $ message .= " or {$default}" ; } $ this -... | Log missing resource |
14,910 | protected function getThemeToUse ( ResourceSettings $ settings ) : Theme { if ( $ settings -> theme instanceof Theme ) { return $ settings -> theme ; } return $ settings -> themeName !== null ? $ this -> getTheme ( $ settings -> themeName ) : $ this -> getDefaultTheme ( ) ; } | Get theme to use |
14,911 | protected function mergeResourceArrays ( ... $ arrays ) : ? array { $ merged = [ ] ; foreach ( $ arrays as $ array ) { if ( ! is_array ( $ array ) ) { continue ; } foreach ( $ array as $ resource ) { $ this -> mergeWithOrder ( $ resource , $ merged ) ; } } return ! empty ( $ merged ) ? $ merged : null ; } | Merge arrays to one |
14,912 | protected function mergeWithOrder ( $ settings , & $ merge ) { if ( isset ( $ merge [ $ settings -> order ] ) ) { $ this -> mergeWithOrder ( ++ $ settings -> order , $ merge ) ; } return $ merge [ $ settings -> order ] = $ settings ; } | Merge resources to one array preserving order |
14,913 | protected function crc ( string $ value , bool $ cache = false ) : string { $ hash = hash ( 'crc32' , $ value ) ; if ( $ cache && ! isset ( $ this -> crcCache [ $ hash ] ) ) { $ this -> crcCache [ $ hash ] = $ value ; } return $ hash ; } | CRC a string |
14,914 | protected function getCrcValue ( string $ crc ) : ? string { return isset ( $ this -> crcCache [ $ crc ] ) ? $ this -> crcCache [ $ crc ] : null ; } | Get CRC string value |
14,915 | public function boot ( ) { if ( Config :: get ( 'theme.defer_scripts' ) ) { $ this -> add_filter ( 'script_loader_tag' , 'defer_scripts' , 10 , 2 ) ; } if ( Config :: get ( 'theme.remove_asset_versions' ) ) { $ this -> add_filter ( 'style_loader_src' , 'remove_versions_from_assets' , 15 ) ; $ this -> add_filter ( 'scri... | Adds optional filters if required . |
14,916 | public function enqueue_scripts ( ) { $ jquery_version = Config :: get ( 'theme.use_jquery_cdn' ) ; if ( Config :: get ( 'theme.disable_jquery' ) !== true && $ jquery_version !== false && \ version_compare ( $ jquery_version , '0.0.1' , '>=' ) === true ) { $ defer_exclude_list = Config :: get ( 'theme.defer_scripts_ski... | Optionally replace the default WordPress jQuery with a Google CDN version and enqueue the child theme assets . |
14,917 | public function defer_scripts ( $ tag , $ handle ) { $ excludes = Config :: get ( 'theme.defer_scripts_skip' ) ; if ( empty ( $ excludes ) ) { $ exclude_list = [ ] ; } else { $ exclude_list = $ excludes ; } if ( ! \ is_array ( $ exclude_list ) ) { $ exclude_list = [ ] ; } if ( \ in_array ( $ handle , $ exclude_list ) )... | If enabled adds defer attribute to js scripts . |
14,918 | public static function preRender ( ) { $ crypt_class = new Crypt ( ) ; $ token = urldecode ( $ crypt_class -> tokenCreate ( \ User :: id ( ) , 'general' ) ) ; \ Layout :: jsData ( [ 'token' => $ token , 'controller_full' => \ Application :: get ( [ 'mvc' , 'full' ] ) , 'host' => \ Request :: host ( ) , 'ws_host' => \ R... | Pre render processing |
14,919 | public function count ( ) { if ( $ this -> count === null ) { $ groupPart = $ this -> select -> getPart ( Select :: GROUP ) ; $ select = empty ( $ groupPart ) ? $ this -> prepareSelect ( clone $ this -> select ) : $ this -> prepareSubquerySelect ( clone $ this -> select ) ; $ this -> count = ( int ) $ select -> query (... | Get the number of the all items |
14,920 | protected function prepareSelect ( Select $ select ) { $ select -> reset ( Select :: COLUMNS ) -> reset ( Select :: LIMIT_OFFSET ) -> reset ( Select :: LIMIT_COUNT ) -> reset ( Select :: ORDER ) -> columns ( [ self :: COUNT_COLUMN => 'count(*)' ] ) ; return $ select ; } | Prepare the simple count select |
14,921 | protected function prepareSubquerySelect ( Select $ select ) { $ select -> reset ( Select :: LIMIT_OFFSET ) -> reset ( Select :: LIMIT_COUNT ) -> reset ( Select :: ORDER ) ; $ countSelect = $ select -> getAdapter ( ) -> select ( ) -> from ( $ select ) -> reset ( Select :: COLUMNS ) -> columns ( [ self :: COUNT_COLUMN =... | Prepare the subquery based count select |
14,922 | public function sort ( ) { $ deps = $ this -> all ( ) ; $ sorted = $ this -> sortDeps ( $ deps ) ; return $ this -> dependency -> getSorted ( $ sorted ) ; } | Determines all dependencies for the data set and sorts it so least dependant are first . |
14,923 | public function all ( ) { foreach ( $ this -> dependency as $ keyOrItem ) { $ this -> get ( $ keyOrItem ) ; } return $ this -> resolved -> immutable ( ) ; } | Returns all of the dependencies for the data set as a map . |
14,924 | public function get ( $ keyOrItem ) { $ id = $ this -> dependency -> getId ( $ keyOrItem ) ; if ( $ this -> resolved -> has ( $ id ) ) { return $ this -> resolved [ $ id ] ; } $ deps = new MutableBag ( ) ; $ thisDeps = $ this -> dependency -> getDependencies ( $ keyOrItem ) ; foreach ( $ thisDeps as $ dep ) { try { $ t... | Return all of the dependencies for the given key or item . |
14,925 | private function sortDeps ( Bag $ toSort ) { $ sorted = [ ] ; $ toSort = $ toSort -> mutable ( ) ; while ( count ( $ toSort ) > 0 ) { foreach ( $ toSort as $ name => $ dependencies ) { if ( ! array_diff ( $ dependencies -> toArray ( ) , $ sorted ) ) { $ sorted [ ] = $ name ; unset ( $ toSort [ $ name ] ) ; } } } return... | Sorts the mapping of dependencies and returns an ordered list . |
14,926 | public function findOneById ( $ appUserId , $ id ) { $ url = sprintf ( 'users/%s/payments/%s' , $ appUserId , $ id ) ; return $ this -> getOne ( $ url , $ this -> entityClassName ) ; } | Find payment by id |
14,927 | public function create ( $ appUserId , Payment $ Payment ) { $ url = sprintf ( 'users/%s/payments' , $ appUserId ) ; return $ this -> createObject ( $ url , $ Payment ) ; } | Create new payment |
14,928 | public function createMultiple ( $ appUserId , array $ Payments ) { $ url = sprintf ( 'users/%s/payments' , $ appUserId ) ; return $ this -> createObjects ( $ url , $ Payments , $ this -> entityClassName ) ; } | Create multiple payments |
14,929 | private function setAppToken ( $ app_token ) { if ( ! preg_match ( self :: APP_TOKEN_VALIDATION_REGEX , $ app_token ) ) { throw new MonetivoException ( 'App token format is invalid' ) ; } $ this -> app_token = $ app_token ; $ this -> setEnvironment ( $ app_token ) ; } | Sets application token and environment |
14,930 | private function getCustomerIP ( ) { $ ip = null ; if ( array_key_exists ( 'X-Forwarded-For' , $ _SERVER ) ) { $ ip = $ _SERVER [ 'X-Forwarded-For' ] ; } elseif ( array_key_exists ( 'HTTP_X_FORWARDED_FOR' , $ _SERVER ) ) { $ ip = $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } elseif ( array_key_exists ( 'REMOTE_ADDR' , $ _SE... | Returns customer IP address |
14,931 | public function setLanguage ( $ language ) { if ( ! is_string ( $ language ) || strlen ( $ language ) !== 2 ) { throw new MonetivoException ( 'Language format is invalid' ) ; } $ language = strtolower ( $ language ) ; $ this -> language = in_array ( $ language , self :: $ supported_langs ) ? $ language : 'en' ; } | Sets desired language ; Defaults to en |
14,932 | public function setTimezone ( $ timezone ) { try { $ test = new \ DateTimeZone ( $ timezone ) ; $ this -> timezone = $ timezone ; } catch ( \ Exception $ e ) { throw new MonetivoException ( 'Invalid timezone' ) ; } } | Sets desired timezone |
14,933 | public function initClient ( $ custom_params = [ ] , $ custom_handler = null ) { $ config = [ 'base_uri' => $ this -> getBaseAPIEndpoint ( ) , 'headers' => [ 'Accept' => 'application/json' , 'User-Agent' => self :: USER_AGENT . ' ' . self :: CLIENT_VERSION , self :: APP_TOKEN_HEADER => $ this -> app_token , self :: LAN... | Initialize API client with custom params and custom handler both empty by default |
14,934 | public function auth ( $ login , $ password ) { $ response = $ this -> call ( 'post' , 'auth/login' , [ 'form_params' => [ 'login' => $ login , 'password' => $ password ] ] ) ; if ( ! isset ( $ response [ 'token' ] ) ) { if ( isset ( $ response [ 'errors' ] ) || isset ( $ response [ 'code' ] ) ) { $ error_message = iss... | Authenticates user After successful authentication authorization token is set automatically . Further calls are no longer required . |
14,935 | private function autoRenewAuthToken ( ApiResponse $ response , $ header = 'X-Auth-Token' ) { $ headers = $ response -> getHeaders ( ) ; if ( ! empty ( $ headers [ $ header ] ) ) { $ this -> setAuthToken ( $ headers [ $ header ] ) ; } } | Sets freshly generated token if previous token expired The new token comes from server s response - server automatically checks if the date of current token is approaching expiration |
14,936 | public function getIterator ( ) { $ fileIterator = new FileIterator ( $ this -> getFile ( ) , $ this -> delimiter , $ this -> partsNames ) ; if ( $ this -> delimiter === null ) { return $ fileIterator ; } return $ this -> createIterator ( $ fileIterator ) ; } | Get data as iterator |
14,937 | protected function getFile ( ) { if ( $ this -> file === null ) { $ path = $ this -> getFilePath ( ) ; if ( ! is_file ( $ path ) ) { throw new NoPath ( 'Unable to locate the file: ' . $ path ) ; } $ file = fopen ( $ path , 'r' ) ; if ( $ file === false ) { throw new NoPath ( 'Unable to open the file: ' . $ path ) ; } }... | Get an opened file |
14,938 | public function setFilePath ( $ path ) { $ path = realpath ( $ path ) ; if ( $ path === false ) { throw new NoPath ( 'Invalid path: ' . $ path ) ; } $ this -> path = $ path ; return $ this ; } | Set a path to a file |
14,939 | public function getFilePath ( ) { if ( $ this -> path === null ) { throw new NoPath ( 'Path to a file was not been specified' ) ; } if ( $ this -> path [ 0 ] === DIRECTORY_SEPARATOR ) { return $ this -> path ; } return $ this -> getIntrospectiveData ( ) -> dirname . DIRECTORY_SEPARATOR . $ this -> path ; } | Get a path to a file |
14,940 | public static function encrypt ( $ message , $ key , $ encode = false ) { list ( $ encKey , $ authKey ) = self :: splitKeys ( $ key ) ; $ ciphertext = parent :: encrypt ( $ message , $ encKey ) ; $ mac = hash_hmac ( self :: HASH_ALGO , $ ciphertext , $ authKey , true ) ; if ( $ encode ) { return base64_encode ( $ mac .... | Encrypts then MACs a message |
14,941 | protected static function splitKeys ( $ masterKey ) { return [ hash_hmac ( self :: HASH_ALGO , 'ENCRYPTION' , $ masterKey , true ) , hash_hmac ( self :: HASH_ALGO , 'AUTHENTICATION' , $ masterKey , true ) ] ; } | Splits a key into two separate keys ; one for encryption and the other for authenticaiton |
14,942 | protected static function hashEquals ( $ a , $ b ) { if ( function_exists ( 'hash_equals' ) ) { return hash_equals ( $ a , $ b ) ; } $ nonce = openssl_random_pseudo_bytes ( 32 ) ; return hash_hmac ( self :: HASH_ALGO , $ a , $ nonce ) === hash_hmac ( self :: HASH_ALGO , $ b , $ nonce ) ; } | Compare two strings without leaking timing information |
14,943 | protected function iteratorToArray ( Traversable $ config , $ delimiter ) { $ rows = [ ] ; foreach ( $ config as $ key => $ value ) { if ( $ value instanceof Traversable ) { foreach ( $ this -> iteratorToArray ( $ value , $ delimiter ) as $ subkey => $ subvalue ) { $ rows [ $ key . $ delimiter . $ subkey ] = $ subvalue... | Assemble an one - dimension array from an recursive traversable config |
14,944 | public function runQueued ( InputInterface $ input , OutputInterface $ output ) { $ edgarCrons = $ this -> listQueued ( ) ; $ crons = $ this -> getCrons ( ) ; $ cronAlias = [ ] ; foreach ( $ crons as $ cron ) { $ cronAlias [ $ cron -> getAlias ( ) ] = $ cron ; } if ( $ edgarCrons ) { foreach ( $ edgarCrons as $ edgarCr... | List cron commands identified as queued . |
14,945 | public function listCronsStatus ( ) : array { $ edgarCrons = $ this -> repository -> listCrons ( ) ; $ crons = $ this -> getCrons ( ) ; $ cronAlias = [ ] ; foreach ( $ crons as $ cron ) { $ cronAlias [ $ cron -> getAlias ( ) ] = $ cron ; } if ( $ edgarCrons ) { foreach ( $ edgarCrons as $ edgarCron ) { if ( isset ( $ c... | Return cron list and status . |
14,946 | public function indexAction ( Request $ request , PaginatorInterface $ paginator ) : Response { $ repo = $ this -> em -> getRepository ( Production :: class ) ; $ query = $ repo -> findAllOpenQuery ( ) ; $ productions = $ paginator -> paginate ( $ query , $ request -> query -> getInt ( 'page' , 1 ) ) ; return new Respo... | Shows a list of productions . |
14,947 | public function createAction ( Request $ request , TokenStorageInterface $ token ) : Response { $ user = $ token -> getToken ( ) -> getUser ( ) ; $ production = new Production ( ) ; $ production -> setAuthor ( $ user -> getUsername ( ) ) ; $ production -> setActive ( true ) ; $ form = $ this -> form -> create ( Product... | Create a new production . |
14,948 | public function updateAction ( int $ id , Request $ request ) : Response { $ production_repo = $ this -> em -> getRepository ( Production :: class ) ; if ( null === $ production = $ production_repo -> findOneBy ( [ 'id' => $ id ] ) ) { throw new NotFoundHttpException ( ) ; } $ form = $ this -> form -> create ( Producti... | Update an existing production . |
14,949 | public function deleteAction ( int $ id , Request $ request ) : Response { $ production_repo = $ this -> em -> getRepository ( Production :: class ) ; if ( null === $ production = $ production_repo -> findOneBy ( [ 'id' => $ id ] ) ) { throw new NotFoundHttpException ( ) ; } $ form = $ this -> form -> createBuilder ( )... | Delete a production from the system . |
14,950 | public static function deleteDirectory ( $ dir ) { if ( is_dir ( $ dir ) ) $ dirHandle = opendir ( $ dir ) ; if ( ! $ dirHandle ) return false ; while ( $ file = readdir ( $ dirHandle ) ) { if ( $ file != "." && $ file != ".." ) { if ( ! is_dir ( $ dir . "/" . $ file ) ) unlink ( $ dir . "/" . $ file ) ; else self :: d... | Delete a directory |
14,951 | public static function removeExtension ( $ fileName ) { $ ext = strrchr ( $ fileName , '.' ) ; if ( $ ext !== false ) { $ fileName = substr ( $ fileName , 0 , - strlen ( $ ext ) ) ; } return $ fileName ; } | strips out the file extenstion |
14,952 | public static function getDirectorySize ( $ dir ) { if ( is_dir ( $ dir ) ) { $ totalSize = 0 ; $ iterator = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ dir ) ) ; foreach ( $ iterator as $ file ) { $ totalSize += $ file -> getSize ( ) ; } return $ totalSize ; } return false ; } | Get total size of files in directory and subdirectories |
14,953 | public function saveProfileFields ( $ user_id ) { $ fields = $ this -> fields ; if ( empty ( $ fields ) ) { return ; } if ( ! current_user_can ( 'edit_user' , $ user_id ) ) { return false ; } foreach ( $ fields as $ field ) { if ( ! $ field ) { continue ; } $ ctn = ( array ) $ field -> getModel ( ) -> getContents ( ) ;... | Hook to save user custom fields . |
14,954 | public function showProfileFields ( $ user ) { $ fields = $ this -> fields ; $ title = $ this -> title ; if ( empty ( $ fields ) ) { return ; } $ vars = [ 't_user_title' => ! empty ( $ title ) ? $ title : Translate :: t ( 'user.title' ) , ] ; foreach ( $ fields as $ field ) { if ( ! $ field ) { continue ; } $ vars [ 'f... | Hook to display user custom fields . |
14,955 | public function getValue ( ) { if ( ! $ this -> isSet ( ) and isset ( $ this -> default ) ) { $ this -> setValue ( $ this -> default , true ) ; } return $ this -> value ; } | Get the option value |
14,956 | public static function removeUnsafeChars ( $ str ) { static $ blacklist = '/[!\"?():\']/' ; static $ whitelist = '/[^a-zA-Z0-9-_.]/' ; $ validStr = preg_replace ( array ( $ blacklist , $ whitelist ) , array ( '' , '-' ) , $ str ) ; return $ validStr ; } | Remove unwanted characters from a string . Characters in blacklist will be removed . Remaining characters not in blacklist or whitelist will be replaced with hyphen . |
14,957 | public static function ellipsizeRight ( $ string , $ max , $ ellipses = '...' ) { $ string = trim ( $ string ) ; if ( strlen ( $ string ) <= $ max ) { return $ string ; } $ string = substr ( $ string , 0 , $ max ) ; $ chop = strrpos ( $ string , ' ' ) ; if ( $ chop !== false ) $ string = substr ( $ string , 0 , $ chop ... | Adds a ellipses to the right of a string and trims down the size |
14,958 | public static function ellipsizeMiddle ( $ string , $ max , $ ellipses = '...' ) { $ string = trim ( $ string ) ; $ firstPiece = '' ; $ lastPiece = '' ; if ( strlen ( $ string ) <= $ max ) { return $ string ; } $ hasSpace = strpos ( $ string , ' ' ) ; if ( $ hasSpace === false ) { $ firstPiece = substr ( $ string , 0 ,... | Adds a ellipses to the middle of string and trims down the size |
14,959 | public function init ( ) { $ pages = $ this -> getModel ( ) -> getPages ( ) ; if ( empty ( $ pages ) ) { return ; } global $ admin_page_hooks ; reset ( $ pages ) ; $ identifier = Helpers :: urlize ( key ( $ pages ) ) ; $ this -> getModel ( ) -> setIdentifier ( $ identifier ) ; if ( ! isset ( $ admin_page_hooks [ $ iden... | Build AdminPageModel and initialize admin pages . |
14,960 | public function initAssets ( ) { $ currentPage = Request :: get ( 'page' ) ; $ currentSection = Request :: get ( 'section' ) ; $ identifier = $ this -> getModel ( ) -> getIdentifier ( ) ; $ page_id = str_replace ( $ identifier . '-' , '' , $ currentPage ) ; if ( ! $ this -> getModel ( ) -> hasPage ( $ page_id ) ) { ret... | Initialize assets in admin pages . |
14,961 | public function addRootPage ( ) { $ identifier = $ this -> getModel ( ) -> getIdentifier ( ) ; if ( ! $ this -> getModel ( ) -> hasPage ( $ identifier ) ) { throw new AdminPageException ( sprintf ( Translate :: t ( 'adminpage.errors.page_is_empty' ) , $ identifier ) ) ; } $ defaults = [ 'slug' => $ identifier , 'title'... | Add root admin page . |
14,962 | public function addRootAdminBar ( ) { $ identifier = $ this -> getModel ( ) -> getIdentifier ( ) ; $ options = $ this -> getModel ( ) -> getPages ( $ identifier ) ; add_action ( 'admin_bar_menu' , function ( ) use ( $ identifier , $ options ) { global $ wp_admin_bar ; $ wp_admin_bar -> add_node ( [ 'parent' => '' , 'id... | Add root admin bar page . |
14,963 | public function addChild ( $ slug , $ options ) { $ identifier = $ this -> getModel ( ) -> getIdentifier ( ) ; if ( empty ( $ slug ) ) { throw new AdminPageException ( Translate :: t ( 'adminpage.errors.slug_is_not_defined' ) ) ; } $ defaults = [ 'slug' => $ slug , 'title' => Translate :: t ( 'adminpage.child.defaults.... | Add child admin page . |
14,964 | public function addChildAdminBar ( $ slug , $ options ) { $ identifier = $ this -> getModel ( ) -> getIdentifier ( ) ; add_action ( 'admin_bar_menu' , function ( ) use ( $ identifier , $ slug , $ options ) { global $ wp_admin_bar ; if ( $ slug === $ identifier ) { return ; } $ pageid = $ identifier . '-' . $ slug ; $ w... | Add child admin bar page . |
14,965 | public function callback ( ) { $ identifier = $ this -> getModel ( ) -> getIdentifier ( ) ; $ currentPage = Request :: get ( 'page' ) ; $ currentSection = Request :: get ( 'section' ) ; $ page_id = str_replace ( $ identifier . '-' , '' , $ currentPage ) ; if ( ! $ this -> getModel ( ) -> hasPage ( $ page_id ) ) { retur... | Hook callback . |
14,966 | protected function _convert_pre ( & $ text ) { while ( preg_match ( '/<pre[^>]*>(.*)<\/pre>/ismU' , $ text , $ matches ) ) { $ this -> pre_content = $ matches [ 1 ] ; $ this -> pre_content = preg_replace_callback ( $ this -> callback_search , array ( $ this , '_preg_callback' ) , $ this -> pre_content ) ; $ this -> pre... | Helper function for PRE body conversion . |
14,967 | private function _strtoupper ( $ str ) { $ str = html_entity_decode ( $ str , ENT_COMPAT ) ; if ( function_exists ( 'mb_strtoupper' ) ) { $ str = mb_strtoupper ( $ str , 'UTF-8' ) ; } else { $ str = strtoupper ( $ str ) ; } $ str = htmlspecialchars ( $ str , ENT_COMPAT ) ; return $ str ; } | Strtoupper multibyte wrapper function with HTML entities handling . Forces mb_strtoupper - call to UTF - 8 . |
14,968 | private function initRichModelUtils ( ) : void { $ this -> richClassReflection = $ this -> richClassReflection ?? new \ ReflectionClass ( $ this ) ; if ( $ this -> richAccessMapExists === null ) { $ this -> richAccessMapExists = false ; if ( $ this -> richClassReflection -> hasProperty ( RichModelInterface :: RICH_MAP_... | Initialize rich model tools . |
14,969 | public function __isset ( $ name ) { try { return \ property_exists ( $ this , $ this -> getRichFieldName ( $ name ) ) ; } catch ( RichModelFieldException $ e ) { return false ; } } | Returns true if field exists in model . |
14,970 | public function & __get ( $ name ) { if ( ! isset ( $ this -> arguments [ $ name ] ) ) return null ; return $ this -> arguments [ $ name ] ; } | Override default getter so we can get stored references . |
14,971 | public function getUrl ( $ page , $ absolute = false , $ routePrm = null ) { $ prm = ! is_null ( $ routePrm ) ? $ routePrm : $ this -> routePrm ; $ prm [ 'page' ] = $ page ; return $ this -> service -> generateUrl ( $ this -> route , $ prm , $ absolute ) ; } | Get the URL for a page number . |
14,972 | public function getPreviousUrl ( $ absolute = false ) { return $ this -> hasPrevious ( ) ? $ this -> getUrl ( $ this -> getPrevious ( ) , $ absolute ) : null ; } | Get the preivous page url null if not . |
14,973 | public function getNextUrl ( $ absolute = false ) { return $ this -> hasNext ( ) ? $ this -> getUrl ( $ this -> getNext ( ) , $ absolute ) : null ; } | Get the next page url null if not . |
14,974 | public function getPagesIndex ( $ nb = 11 , $ absolute = false ) { $ space = ( $ nb - 1 ) / 2 ; $ start = $ this -> getCurPage ( ) - $ space ; $ end = $ this -> getCurPage ( ) + $ space ; if ( $ start < 1 && $ end > $ this -> getNbPages ( ) ) { $ start = 1 ; $ end = $ this -> getNbPages ( ) ; } elseif ( $ start < 1 ) {... | Get Pages index URLs . |
14,975 | protected function calcNbPages ( ) { if ( ! is_null ( $ this -> nbPerPage ) && ! is_null ( $ this -> nbResults ) ) { $ this -> nbPages = ceil ( $ this -> nbResults / $ this -> nbPerPage ) ; } } | Calculates the number of pages . |
14,976 | public function write ( ) { $ stats = array ( 'hits' => $ this -> hits , 'misses' => $ this -> misses ) ; file_put_contents ( $ this -> getFilename ( ) , serialize ( $ stats ) ) ; } | Write statistics to cache directory |
14,977 | private function initialize ( ) { $ stats = unserialize ( file_get_contents ( $ this -> getFilename ( ) ) ) ; $ this -> hits = isset ( $ stats [ 'hits' ] ) ? $ stats [ 'hits' ] : 0 ; $ this -> misses = isset ( $ stats [ 'misses' ] ) ? $ stats [ 'misses' ] : 0 ; } | Initialize statistics from an existing file |
14,978 | public function create ( string $ content , $ url , array $ attributes = [ ] ) : string { return $ this -> make ( new HrefSettings ( [ 'content' => $ content , 'url' => $ url , 'attributes' => $ attributes , ] ) ) ; } | HTML href output |
14,979 | protected function createOutput ( Settings $ settings ) : string { return sprintf ( '<a href="%s"%s>%s</a>' , $ this -> parseUrl ( $ settings -> url ) , $ this -> parseHrefAttributes ( $ settings -> attributes ) , $ settings -> content ) ; } | Create and return string output |
14,980 | protected function parseHrefAttributes ( ? array $ attributes ) : ? string { if ( empty ( $ attributes ) ) { return null ; } if ( isset ( $ attributes [ 'target' ] ) && $ attributes [ 'target' ] === '_blank' ) { if ( ! isset ( $ attributes [ 'rel' ] ) ) { $ attributes [ 'rel' ] = 'noreferrer noopener' ; } } $ extra = [... | Create attributes string for href |
14,981 | protected function onProfilerInit ( ProfilerInterface $ profiler ) { if ( $ profiler instanceof ProfilerExtendedInterface ) { $ name = get_class ( $ this -> getBackend ( ) ) ; $ pos = strrpos ( $ name , '\\' ) ; $ profiler -> setName ( $ pos === false ? $ name : substr ( $ name , $ pos + 1 ) ) ; $ profiler -> setIcon (... | On profiler init |
14,982 | public function scheduleWork ( ) { if ( is_null ( $ this -> scheduler ) ) { return ; } $ this -> scheduler -> reconnect ( ) ; foreach ( $ this -> scheduler -> getJobsFor ( new \ DateTime ( ) ) as $ job ) { $ this -> pipeline -> enqueue ( $ job ) ; } } | Check the schedule for work to enqueue and push it into the pipeline if needed |
14,983 | public function delegateWork ( ) { foreach ( $ this -> employees as $ employee ) { if ( $ employee -> isFree ( ) ) { if ( $ job = $ this -> getWork ( $ employee ) ) { $ employee -> work ( $ job ) ; $ this -> pipeline -> reconnect ( ) ; } } } } | Cycle through all available employees and allocate work when it is available . |
14,984 | public function getWork ( Employee $ employee ) { $ job = $ this -> pipeline -> dequeue ( $ employee -> getOptions ( ) ) ; if ( is_null ( $ job ) ) { usleep ( 10000 ) ; } return $ job ; } | Obtain a job from the pipeline for the given Employee . |
14,985 | public function waitOnEmployees ( ) { foreach ( $ this -> employees as $ employee ) { if ( $ employee -> isBusy ( ) ) { $ employee -> getWorkState ( true ) ; } } } | Wait for all busy employees to finish . |
14,986 | public function updateProgress ( ) { foreach ( $ this -> employees as $ employee ) { if ( $ employee -> isBusy ( ) ) { continue ; } if ( $ employee -> isFree ( ) ) { continue ; } $ job = $ employee -> getJob ( ) ; switch ( $ employee -> getWorkState ( ) ) { case Employee :: COMPLETE : if ( method_exists ( $ job , 'befo... | Get a progress update from all employees . |
14,987 | public function reverseTransform ( $ value ) { $ collection = new ArrayCollection ( ) ; if ( '' === $ value || null === $ value ) { return $ collection ; } if ( ! is_string ( $ value ) ) { throw new UnexpectedTypeException ( $ value , 'string' ) ; } if ( $ this -> onlyKeysInReverse ) { $ ids = \ explode ( $ this -> sep... | Transforms JSON to Collection entities |
14,988 | public function create ( \ Closure $ closure ) { ob_start ( ) ; echo '/*GENERATED AT ' . date ( 'Y-m-d H:i:s' ) . '*/' ; $ closure ( ) ; $ content = ob_get_clean ( ) ; $ content = trim ( preg_replace ( '/<\/?' . $ this -> getTypeTag ( ) . '(.|\s)*?>/' , '' , $ content ) ) ; $ dirs = explode ( DIRECTORY_SEPARATOR , $ th... | Create an asset with the given closure to be buffered . |
14,989 | protected function debug ( $ msg ) { if ( true === $ this -> option ( 'debug' ) ) { $ this -> debug [ ] = $ msg ; } elseif ( $ this -> lookup_class === $ this -> option ( 'debug' ) ) { $ this -> debug [ ] = $ msg ; } return $ this ; } | Stores Debug Message . |
14,990 | public function is_valid_lookup ( ) { if ( strpos ( strtolower ( $ this -> lookup_class ) , strtolower ( $ this -> namespace ) ) !== false ) { if ( false !== $ this -> option ( 'exclude' ) ) { foreach ( $ this -> option ( 'exclude' ) as $ namespace ) { if ( strpos ( strtolower ( $ this -> lookup_class ) , strtolower ( ... | Validates If Its A Proper Lookup Namespace . |
14,991 | protected function get_folders ( $ path ) { if ( isset ( $ this -> subfolders [ $ path ] ) ) { return $ this -> subfolders [ $ path ] ; } $ this -> subfolders [ $ path ] = $ this -> search_folders ( $ path ) ; return $ this -> subfolders [ $ path ] ; } | Saves & Returns Core Folders . |
14,992 | protected function search_folders ( $ path ) { $ return = array ( ) ; $ base_folders = array_filter ( glob ( $ this -> trailingslashit ( $ path ) . '*' ) , 'is_dir' ) ; if ( is_array ( $ base_folders ) && ! empty ( $ base_folders ) ) { foreach ( $ base_folders as $ folder ) { $ _sub = $ this -> search_folders ( $ this ... | Search folders & subfolders inside a given folder and returns it . |
14,993 | protected function get_file_name ( $ class ) { if ( $ class ) { $ file = explode ( '\\' , $ class ) ; $ file = strtolower ( end ( $ file ) ) ; $ file__ = str_replace ( '_' , '-' , $ file ) ; $ files = array ( $ file . '.php' , $ file__ . '.php' , 'class-' . $ file__ . '.php' , 'class_' . $ file__ . '.php' , ) ; return ... | Creates File Names From Class Name . |
14,994 | public function remove ( $ classs ) { if ( isset ( $ this -> mapping [ $ classs ] ) ) { unset ( $ this -> mapping [ $ classs ] ) ; } return $ this ; } | Removes Custom mapping To a Class in mapping Array . |
14,995 | public function has ( string $ key = null ) : bool { if ( $ key === null ) { return false ; } return $ this -> offsetExists ( $ key ) ; } | Check for existence . |
14,996 | public function offsetUnset ( $ offset ) { $ keys = explode ( $ this -> keySeparator , $ offset ) ; $ keyCount = count ( $ keys ) ; $ array = & $ this -> values ; while ( $ keyCount > 1 ) { $ key = array_shift ( $ keys ) ; if ( isset ( $ array [ $ key ] ) && is_array ( $ array [ $ key ] ) ) { $ array = & $ array [ $ ke... | Offset to unset . |
14,997 | public function setPercent ( $ percent ) { NumericValidator :: validate ( $ percent , "Percent" ) ; $ percent = Formatter :: formatToPrice ( $ percent ) ; $ this -> percent = $ percent ; return $ this ; } | The rate of the specified tax . Valid range is from 0 . 001 to 99 . 999 . |
14,998 | public static function ping ( string $ host , int $ port , int $ timeout = 5 ) : bool { if ( $ fp = @ fsockopen ( $ host , $ port , $ errCode , $ errStr , $ timeout ) ) { fclose ( $ fp ) ; return true ; } return false ; } | Ping a host |
14,999 | public static function parseCidr ( string $ cidr ) : array { $ pos = strpos ( $ cidr , "/" ) ; if ( $ pos === false ) { throw new \ UnexpectedValueException ( "invalid CIDR; missing expected '/' delimeter" ) ; } elseif ( $ pos === 0 ) { throw new \ UnexpectedValueException ( "invalid CIDR; missing expected ip" ) ; } $ ... | Parse a CIDR address range into the ip and network mask portions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.