idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
51,600 | public function searchMulti ( $ query , array $ parameters = [ ] , array $ headers = [ ] ) { return $ this -> get ( 'search/multi' , array_merge ( $ parameters , [ 'query' => $ query ] , $ headers ) ) ; } | Search the movie tv show and person collections with a single query . |
51,601 | public function postJson ( $ path , $ postBody = null , array $ parameters = [ ] , $ headers = [ ] ) { if ( is_array ( $ postBody ) ) { $ postBody = json_encode ( $ postBody ) ; } return $ this -> post ( $ path , $ postBody , $ parameters , $ headers ) ; } | Send a POST request but json_encode the post body in the request |
51,602 | private function processSearchMultiItem ( array $ item ) { if ( array_key_exists ( 'media_type' , $ item ) ) { switch ( $ item [ 'media_type' ] ) { case 'movie' : return $ this -> getMovieFactory ( ) -> create ( $ item ) ; case 'tv' : return $ this -> getTvFactory ( ) -> create ( $ item ) ; case 'person' : return $ thi... | Process multi search items |
51,603 | public function getGenre ( $ id ) { foreach ( $ this -> data as $ genre ) { if ( $ id === $ genre -> getId ( ) ) { return $ genre ; } } return null ; } | Retrieve a genre from the collection |
51,604 | private function setWithoutFlush ( $ name , $ value , SettingsOwnerInterface $ owner = null ) { $ this -> validateSetting ( $ name , $ owner ) ; $ this -> loadSettings ( $ owner ) ; if ( $ owner === null ) { $ this -> globalSettings [ $ name ] = $ value ; } else { $ this -> ownerSettings [ $ owner -> getSettingIdentifi... | Sets setting value to private array . Used for settings batch saving . |
51,605 | protected function findSettingByName ( $ haystack , $ needle ) { foreach ( $ haystack as $ setting ) { if ( $ setting -> getName ( ) === $ needle ) { return $ setting ; } } } | Find a setting by name form an array of settings . |
51,606 | private function loadSettings ( SettingsOwnerInterface $ owner = null ) { if ( $ this -> globalSettings === null ) { $ this -> globalSettings = $ this -> getSettingsFromRepository ( ) ; } if ( $ owner !== null && ( $ this -> ownerSettings === null || ! array_key_exists ( $ owner -> getSettingIdentifier ( ) , $ this -> ... | Settings lazy loading . |
51,607 | private function getSettingsFromRepository ( SettingsOwnerInterface $ owner = null ) { $ settings = array ( ) ; foreach ( array_keys ( $ this -> settingsConfiguration ) as $ name ) { try { $ this -> validateSetting ( $ name , $ owner ) ; $ settings [ $ name ] = null ; } catch ( WrongScopeException $ e ) { continue ; } ... | Retreives settings from repository . |
51,608 | protected function fetchFromCache ( $ name , SettingsOwnerInterface $ owner = null ) { $ cacheKey = $ this -> getCacheKey ( $ name , $ owner ) ; return $ this -> storage -> getItem ( $ cacheKey ) -> get ( ) ; } | Get from cache . |
51,609 | protected function storeInCache ( $ name , $ value , SettingsOwnerInterface $ owner = null ) { $ item = $ this -> storage -> getItem ( $ this -> getCacheKey ( $ name , $ owner ) ) -> set ( $ value ) -> expiresAfter ( $ this -> cacheLifeTime ) ; return $ this -> storage -> save ( $ item ) ; } | Store in cache . |
51,610 | public static function generate ( Invoice $ invoice , $ template = 'default' ) { $ template = strtolower ( $ template ) ; $ options = new Options ( ) ; $ options -> set ( 'isRemoteEnabled' , true ) ; $ pdf = new Dompdf ( $ options ) ; $ context = stream_context_create ( [ 'ssl' => [ 'verify_peer' => false , 'verify_pee... | Generate the PDF . |
51,611 | public function addItem ( $ name , $ price , $ ammount = 1 , $ id = '-' ) { $ this -> items -> push ( Collection :: make ( [ 'name' => $ name , 'price' => $ price , 'ammount' => $ ammount , 'totalPrice' => number_format ( bcmul ( $ price , $ ammount , $ this -> decimals ) , $ this -> decimals ) , 'id' => $ id , ] ) ) ;... | Adds an item to the invoice . |
51,612 | public function formatCurrency ( ) { $ currencies = json_decode ( file_get_contents ( __DIR__ . '/../Currencies.json' ) ) ; $ currency = $ this -> currency ; return $ currencies -> $ currency ; } | Return the currency object . |
51,613 | private function subTotalPrice ( ) { return $ this -> items -> sum ( function ( $ item ) { return bcmul ( $ item [ 'price' ] , $ item [ 'ammount' ] , $ this -> decimals ) ; } ) ; } | Return the subtotal invoice price . |
51,614 | public function save ( $ name = 'invoice.pdf' ) { $ invoice = $ this -> generate ( ) ; Storage :: put ( $ name , $ invoice -> pdf -> output ( ) ) ; } | Save the generated PDF . |
51,615 | private function getScriptSrc ( $ callbackName = null ) { $ queries = [ ] ; if ( $ this -> hasLang ( ) ) Arr :: set ( $ queries , 'hl' , $ this -> lang ) ; Arr :: set ( $ queries , 'render' , $ this -> getSiteKey ( ) ) ; if ( $ this -> hasCallbackName ( $ callbackName ) ) Arr :: set ( $ queries , 'onload' , $ callbackN... | Get script source link . |
51,616 | public function display ( $ name = null , array $ attributes = [ ] ) { return Div :: make ( ) -> attributes ( array_merge ( static :: prepareNameAttribute ( $ name ) , $ this -> prepareAttributes ( $ attributes ) ) ) ; } | Display Captcha . |
51,617 | public function scriptWithCallback ( array $ captchas , $ callbackName = 'captchaRenderCallback' ) { $ script = $ this -> script ( $ callbackName ) -> toHtml ( ) ; if ( ! empty ( $ script ) && ! empty ( $ captchas ) ) { $ script = implode ( PHP_EOL , [ $ this -> getApiScript ( ) -> toHtml ( ) , '<script>' , "var $callb... | Get script tag with a callback function . |
51,618 | private function prepareAttributes ( array $ attributes ) { $ attributes = array_merge ( [ 'class' => 'g-recaptcha' , 'data-sitekey' => $ this -> siteKey ] , array_filter ( $ attributes ) ) ; self :: checkDataAttribute ( $ attributes , 'data-type' , [ 'image' , 'audio' ] , 'image' ) ; self :: checkDataAttribute ( $ att... | Prepare the attributes . |
51,619 | protected static function prepareNameAttribute ( $ name ) { if ( is_null ( $ name ) ) return [ ] ; if ( $ name === AbstractNoCaptcha :: CAPTCHA_NAME ) { throw new InvalidArgumentException ( 'The captcha name must be different from "' . AbstractNoCaptcha :: CAPTCHA_NAME . '".' ) ; } return array_combine ( [ 'id' , 'name... | Prepare the name and id attributes . |
51,620 | private function registerFormMacros ( $ app ) { foreach ( [ FormBuilder :: class , 'form' ] as $ alias ) { if ( $ app -> bound ( $ alias ) ) { $ app [ $ alias ] -> macro ( 'captcha' , function ( $ name = null ) use ( $ app ) { return $ app [ Contracts \ NoCaptcha :: class ] -> input ( $ name ) ; } ) ; } } } | Register Form Macros . |
51,621 | public function verify ( $ response , $ clientIp = null ) { return $ this -> response = $ this -> sendVerifyRequest ( [ 'secret' => $ this -> secret , 'response' => $ response , 'remoteip' => $ clientIp ] ) ; } | Verify Response . |
51,622 | public function verifyRequest ( ServerRequestInterface $ request ) { $ body = $ request -> getParsedBody ( ) ; $ server = $ request -> getServerParams ( ) ; return $ this -> verify ( $ body [ self :: CAPTCHA_NAME ] ?? '' , $ server [ 'REMOTE_ADDR' ] ?? null ) ; } | Calls the reCAPTCHA siteverify API to verify whether the user passes CAPTCHA test using a PSR - 7 ServerRequest object . |
51,623 | protected function sendVerifyRequest ( array $ query = [ ] ) { $ query = array_filter ( $ query ) ; $ json = $ this -> request -> send ( $ this -> getVerificationUrl ( ) . '?' . http_build_query ( $ query ) ) ; return $ this -> parseResponse ( $ json ) ; } | Send verify request to API and get response . |
51,624 | private static function checkKey ( $ name , & $ value ) { self :: checkIsString ( $ name , $ value ) ; $ value = trim ( $ value ) ; self :: checkIsNotEmpty ( $ name , $ value ) ; } | Check key . |
51,625 | public function send ( $ url , $ curled = true ) { $ this -> setUrl ( $ url ) ; $ result = ( $ this -> isCurlExists ( ) && $ curled === true ) ? $ this -> curl ( ) : file_get_contents ( $ this -> url ) ; return $ this -> checkResult ( $ result ) ? $ result : '{}' ; } | Run the request and get response . |
51,626 | public function seeUserMetaFor ( $ user_id , $ meta_key , $ meta_value = null ) { $ metas = get_user_meta ( $ user_id , $ meta_key ) ; $ message = sprintf ( 'User meta %s does not exist' , $ meta_key ) ; $ this -> assertNotEmpty ( $ metas , $ message ) ; if ( func_num_args ( ) > 2 ) { $ message = sprintf ( 'User meta %... | Checks user meta exists for an user . |
51,627 | public function dontSeeUserMetaFor ( $ user_id , $ meta_key , $ meta_value = null ) { $ metas = get_user_meta ( $ user_id , $ meta_key ) ; if ( func_num_args ( ) > 2 ) { $ message = sprintf ( 'User meta %s contains not expected value' , $ meta_key ) ; $ this -> assertNotContains ( $ meta_value , $ metas , $ message ) ;... | Checks if user meta doesn t exists . |
51,628 | public function seePostMetaFor ( $ post_id , $ meta_key , $ meta_value = null ) { $ metas = get_post_meta ( $ post_id , $ meta_key ) ; $ message = sprintf ( 'Post meta %s does not exist' , $ meta_key ) ; $ this -> assertNotEmpty ( $ metas , $ message ) ; if ( func_num_args ( ) > 2 ) { $ message = sprintf ( 'Post meta %... | Checks a post meta exists for a post . |
51,629 | public function dontSeePostMetaFor ( $ post , $ meta_key , $ meta_value = null ) { $ metas = get_post_meta ( $ post , $ meta_key ) ; if ( func_num_args ( ) > 2 ) { $ message = sprintf ( 'Post meta %s contains not expected value' , $ meta_key ) ; $ this -> assertNotContains ( $ meta_value , $ metas , $ message ) ; } els... | Checks if post meta doesn t exists . |
51,630 | protected function _createObject ( $ args = array ( ) ) { if ( empty ( $ args [ 'post_mime_type' ] ) ) { if ( ! empty ( $ args [ 'file' ] ) && is_readable ( $ args [ 'file' ] ) ) { $ this -> _debug ( 'Reading mime type of the file: ' . $ args [ 'file' ] ) ; $ filetype = wp_check_filetype ( basename ( $ args [ 'file' ] ... | Generates a new attachemnt . |
51,631 | public function stop ( $ args , $ assoc_args ) { $ selenium = $ this -> _get_executable ( ) ; $ pids = trim ( shell_exec ( "pgrep -l -f {$selenium}" ) ) ; $ pids = explode ( PHP_EOL , ( string ) $ pids ) ; if ( ! empty ( $ pids ) && count ( $ pids ) >= 1 ) { foreach ( $ pids as $ pid ) { shell_exec ( "kill -15 {$pid} >... | Stops selenium server . |
51,632 | public function start ( $ args , $ assoc_args ) { $ selenium = $ this -> _get_executable ( ) ; if ( is_executable ( $ selenium ) ) { $ pids = explode ( PHP_EOL , trim ( shell_exec ( "pgrep -f {$selenium}" ) ) ) ; if ( count ( $ pids ) < 2 ) { shell_exec ( "{$selenium} > /dev/null 2>/dev/null &" ) ; \ WP_CLI :: success ... | Starts selenium server . |
51,633 | public function restart ( $ args , $ assoc_args ) { $ this -> stop ( $ args , $ assoc_args ) ; $ this -> start ( $ args , $ assoc_args ) ; } | Restarts selenium server . |
51,634 | public function clickAdminMenu ( $ menu , $ parent = null ) { if ( $ parent ) { $ this -> click ( $ parent , '#adminmenu' ) ; } $ this -> click ( $ menu , '#adminmenu' ) ; } | Clicks admin menu item . Since we are using a WebDriver the first click on a parent element will lead to opening a submenu group . So if we need to click on submenu item we need to do it in two steps . |
51,635 | public function fillTinyMCEField ( $ editor_id , $ value ) { $ script = sprintf ( "tinyMCE.get('%s').setContent('%s')" , esc_js ( $ editor_id ) , esc_js ( $ value ) ) ; $ this -> webDriver -> executeScript ( $ script ) ; } | Fills TinyMCE editor . |
51,636 | public function login ( $ username , $ password ) { $ I = $ this -> _actor ; $ I -> amOnPage ( wp_login_url ( ) ) ; $ I -> fillField ( self :: USERNAME_FIELD , $ username ) ; $ I -> fillField ( self :: PASSWORD_FIELD , $ password ) ; $ I -> click ( self :: LOGIN_BUTTON ) ; $ I -> seeCookie ( LOGGED_IN_COOKIE ) ; return... | Logins as an user . |
51,637 | public function addTermsFactory ( $ factory_name , $ taxonomy ) { if ( ! empty ( $ this -> _factories [ $ factory_name ] ) ) { return false ; } if ( ! taxonomy_exists ( $ taxonomy ) ) { return false ; } $ this -> _factories [ $ factory_name ] = new TermsFactory ( $ taxonomy ) ; return true ; } | Registers new terms factory . |
51,638 | public function cleanup ( ) { foreach ( $ this -> _factories as $ factory ) { if ( $ factory instanceof \ WPCC \ Component \ Factory ) { $ factory -> deleteAll ( ) ; } } } | Cleans up all factories . |
51,639 | protected function _prepareQuery ( $ table , $ columns , $ criteria ) { $ where = '1 = 1' ; $ params = array ( ) ; foreach ( $ criteria as $ column => $ value ) { $ pattern = '%s' ; if ( is_null ( $ value ) ) { $ pattern = '%s AND `%s` IS NULL' ; } elseif ( is_numeric ( $ value ) ) { $ pattern = '%s AND `%s` = %%d' ; $... | Builds query . |
51,640 | public function seeInDatabase ( $ table , $ criteria = array ( ) ) { $ query = $ this -> _prepareQuery ( $ table , 'count(*)' , $ criteria ) ; $ this -> debugSection ( 'Query' , $ query ) ; $ suppress_errors = $ this -> _wpdb -> suppress_errors ( true ) ; $ res = $ this -> _wpdb -> get_var ( $ query ) ; $ this -> _wpdb... | Checks whether or not a record exists in the database . |
51,641 | public function dontSeeInDatabase ( $ table , $ criteria = array ( ) ) { $ query = $ this -> _prepareQuery ( $ table , 'count(*)' , $ criteria ) ; $ this -> debugSection ( 'Query' , $ query ) ; $ suppress_errors = $ this -> _wpdb -> suppress_errors ( true ) ; $ res = $ this -> _wpdb -> get_var ( $ query ) ; $ this -> _... | Checks whether or not a record doesn t exist in the database . |
51,642 | public function grabFromDatabase ( $ table , $ columns , $ criteria = array ( ) ) { $ query = $ this -> _prepareQuery ( $ table , $ columns , $ criteria ) ; $ this -> debugSection ( 'Query' , $ query ) ; $ suppress_errors = $ this -> _wpdb -> suppress_errors ( true ) ; $ results = $ this -> _wpdb -> get_results ( $ que... | Fetches rows from database . |
51,643 | protected function initializeModules ( ) { self :: $ modules = Configuration :: modules ( $ this -> settings ) ; self :: $ actions = Configuration :: actions ( self :: $ modules ) ; foreach ( self :: $ modules as $ module ) { $ module -> _initialize ( ) ; } } | Initializes modules . |
51,644 | protected function _createObject ( $ args ) { $ post_id = wp_insert_post ( $ args , true ) ; if ( $ post_id && ! is_wp_error ( $ post_id ) ) { $ this -> _debug ( 'Generated post ID: ' . $ post_id ) ; } elseif ( is_wp_error ( $ post_id ) ) { $ this -> _debug ( 'Post generation failed with message [%s] %s' , $ post_id ->... | Generates a new post . |
51,645 | protected function _updateObject ( $ post_id , $ fields ) { $ fields [ 'ID' ] = $ post_id ; $ updated = wp_update_post ( $ fields ) ; if ( $ updated && ! is_wp_error ( $ updated ) ) { $ this -> _debug ( 'Updated post ' . $ post_id ) ; } elseif ( is_wp_error ( $ updated ) ) { $ this -> _debug ( 'Update failed for post %... | Updates generated object . |
51,646 | protected function _deleteObject ( $ post_id ) { $ post = get_post ( $ post_id ) ; if ( ! $ post ) { return false ; } $ deleted = wp_delete_post ( $ post_id , true ) ; if ( $ deleted ) { $ this -> _debug ( 'Deleted post with ID: ' . $ post_id ) ; return true ; } $ this -> _debug ( 'Post removal failed for ID: ' . $ pos... | Deletes previously generated post object . |
51,647 | protected function _debug ( $ message , $ args = null ) { $ message = '[Factory] ' . $ message ; if ( func_num_args ( ) == 1 ) { Debug :: debug ( $ message ) ; } else { $ args = array_slice ( func_get_args ( ) , 1 ) ; Debug :: debugf ( $ message , $ args ) ; } } | Displays debug message . |
51,648 | public function create ( $ args = array ( ) , $ definitions = null ) { if ( is_null ( $ definitions ) ) { $ definitions = $ this -> _definitions ; } $ callbacks = array ( ) ; $ generated_args = $ this -> _generateArgs ( $ args , $ definitions , $ callbacks ) ; if ( is_wp_error ( $ generated_args ) ) { return $ generate... | Creates a new object . |
51,649 | public function createAndGet ( $ args = array ( ) , $ definitions = null ) { $ object_id = $ this -> create ( $ args , $ definitions ) ; if ( ! $ object_id || is_wp_error ( $ object_id ) ) { return $ object_id ; } return $ this -> getObjectById ( $ object_id ) ; } | Creates a new object and returns it . |
51,650 | public function createMany ( $ count , $ args = array ( ) , $ definitions = null ) { $ results = array ( ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ results [ ] = $ this -> create ( $ args , $ definitions ) ; } return $ results ; } | Creates many new objects and returns their ids . |
51,651 | public function delete ( $ object ) { if ( ! in_array ( $ object , $ this -> _objects ) ) { return false ; } $ deleted = $ this -> _deleteObject ( $ object ) ; if ( $ deleted && ! is_wp_error ( $ deleted ) ) { $ index = array_search ( $ object , $ this -> _objects ) ; if ( false !== $ index ) { unset ( $ this -> _objec... | Deletes an object generated by this factory instance . |
51,652 | protected function _generateArgs ( $ args , $ definitions , & $ callbacks = array ( ) ) { foreach ( $ definitions as $ field => $ generator ) { if ( isset ( $ args [ $ field ] ) ) { continue ; } if ( is_scalar ( $ generator ) ) { $ args [ $ field ] = $ generator ; } elseif ( $ generator instanceof AfterCreateCallback )... | Generates arguments for a new object . |
51,653 | protected function _applyCallbacks ( $ callbacks , $ created ) { $ updated_fields = array ( ) ; foreach ( $ callbacks as $ field => $ callback ) { $ updated_fields [ $ field ] = $ callback -> call ( $ created ) ; } return $ updated_fields ; } | Applies callbacks and returns updated fields . |
51,654 | protected function _addSlashesDeep ( $ value ) { if ( is_array ( $ value ) ) { $ value = array_map ( array ( $ this , '_addSlashesDeep' ) , $ value ) ; } elseif ( is_object ( $ value ) ) { $ vars = get_object_vars ( $ value ) ; foreach ( $ vars as $ key => $ data ) { $ value -> { $ key } = $ this -> _addSlashesDeep ( $... | Adds slashes recursively to each item of incomming value . |
51,655 | public function filter_arguments ( $ arg ) { $ patterns = array ( 'url=' , 'path=' , 'user=' , 'skip-plugins=?' , 'skip-themes=?' , 'require=' , 'no-color' , 'color' , 'prompt' , 'allow-root' , ) ; foreach ( $ patterns as $ pattern ) { if ( preg_match ( "~^--{$pattern}~i" , $ arg ) ) { return false ; } } return true ; ... | Removes WP_CLI related arguments from input for Codeception commands to escape conflicts . |
51,656 | protected function _createObject ( $ args ) { $ comment_id = wp_insert_comment ( $ this -> _addSlashesDeep ( $ args ) ) ; if ( $ comment_id && ! is_wp_error ( $ comment_id ) ) { $ this -> _debug ( 'Generated comment ID: ' . $ comment_id ) ; } elseif ( is_wp_error ( $ comment_id ) ) { $ this -> _debug ( 'Comment generat... | Generates a new comment . |
51,657 | protected function _updateObject ( $ comment_id , $ fields ) { $ fields [ 'comment_ID' ] = $ comment_id ; $ updated = ( bool ) wp_update_comment ( $ this -> _addSlashesDeep ( $ fields ) ) ; if ( $ updated ) { $ this -> _debug ( 'Updated comment ' . $ comment_id ) ; } else { $ this -> _debug ( 'Update failed for comment... | Updates generated comment . |
51,658 | protected function _deleteObject ( $ comment_id ) { $ comment = get_comment ( $ comment_id ) ; if ( ! $ comment || is_wp_error ( $ comment ) ) { return false ; } $ deleted = wp_delete_comment ( $ comment_id , true ) ; if ( $ deleted ) { $ this -> _debug ( 'Deleted comment with ID: ' . $ comment_id ) ; return true ; } $... | Deletes previously generated comment . |
51,659 | public function createPostComments ( $ post_id , $ count = 1 , $ args = array ( ) , $ definitions = null ) { $ args [ 'comment_post_ID' ] = $ post_id ; return $ this -> createMany ( $ count , $ args , $ definitions ) ; } | Creates comments for a post . |
51,660 | public function updateGuy ( SuiteEvent $ e ) { $ settings = $ e -> getSettings ( ) ; $ guyFile = $ settings [ 'path' ] . $ settings [ 'class_name' ] . '.php' ; $ handle = fopen ( $ guyFile , "r" ) ; if ( $ handle ) { $ line = fgets ( $ handle ) ; if ( preg_match ( '~\[STAMP\] ([a-f0-9]*)~' , $ line , $ matches ) ) { $ ... | Updates test guy class . |
51,661 | protected function buildActorsForConfig ( $ configFile ) { $ config = $ this -> getGlobalConfig ( $ configFile ) ; $ suites = $ this -> getSuites ( $ configFile ) ; $ path = pathinfo ( $ configFile ) ; $ dir = isset ( $ path [ 'dirname' ] ) ? $ path [ 'dirname' ] : getcwd ( ) ; foreach ( $ config [ 'include' ] as $ sub... | Builds actors for suites . |
51,662 | public function registerSubscribers ( ) { $ this -> dispatcher -> addSubscriber ( new \ Codeception \ Subscriber \ ErrorHandler ( ) ) ; $ this -> dispatcher -> addSubscriber ( new \ WPCC \ Subscriber \ Bootstrap ( ) ) ; $ this -> dispatcher -> addSubscriber ( new \ Codeception \ Subscriber \ Module ( ) ) ; $ this -> di... | Registers event listeners . |
51,663 | public function runSuite ( $ settings , $ suite , $ test = null ) { $ suiteManager = new SuiteManager ( $ this -> dispatcher , $ suite , $ settings ) ; $ suiteManager -> initialize ( ) ; $ suiteManager -> loadTests ( $ test ) ; $ suiteManager -> run ( $ this -> runner , $ this -> result , $ this -> options ) ; return $... | Runs suite tests . |
51,664 | protected function _createObject ( $ args ) { require_once ABSPATH . 'wp-admin/includes/upgrade.php' ; $ faker = \ Faker \ Factory :: create ( ) ; $ test_email = defined ( 'WP_TESTS_EMAIL' ) ? WP_TESTS_EMAIL : $ faker -> email ; $ email = isset ( $ args [ 'user' ] ) ? get_userdata ( $ args [ 'user' ] ) -> user_email : ... | Generates a new network . |
51,665 | protected function _deleteObject ( $ network_id ) { global $ wpdb ; $ network_blog = wp_get_sites ( array ( 'network_id' => $ network_id ) ) ; if ( ! empty ( $ network_blog ) ) { $ suppress = $ wpdb -> suppress_errors ( ) ; foreach ( $ network_blog as $ blog ) { wpmu_delete_blog ( $ blog -> blog_id , true ) ; } $ wpdb ... | Deletes previously generated network . |
51,666 | protected function createAcceptanceSuite ( $ actor = 'Acceptance' ) { $ suiteConfig = array ( 'class_name' => $ actor . $ this -> actorSuffix , 'modules' => array ( 'enabled' => array ( 'WebDriver' , 'WordPress' , "{$actor}Helper" , ) , 'config' => array ( 'WebDriver' => array ( 'browser' => 'phantomjs' , ) , ) , ) , )... | Creates acceptance suite . |
51,667 | public function createGlobalConfig ( ) { $ basicConfig = array ( 'actor' => $ this -> actorSuffix , 'paths' => array ( 'tests' => 'tests' , 'log' => $ this -> logDir , 'data' => $ this -> dataDir , 'helpers' => $ this -> helperDir ) , 'settings' => array ( 'bootstrap' => '_bootstrap.php' , 'colors' => strtoupper ( subs... | Creates global config file . |
51,668 | protected function createDirs ( ) { @ mkdir ( 'tests' ) ; @ mkdir ( $ this -> logDir ) ; @ mkdir ( $ this -> dataDir ) ; @ mkdir ( $ this -> helperDir ) ; } | Creates appropriate folders . |
51,669 | protected function _createObject ( $ args ) { $ user_id = wp_insert_user ( $ args ) ; if ( $ user_id && ! is_wp_error ( $ user_id ) ) { $ this -> _debug ( 'Generated user with ID: ' . $ user_id ) ; } elseif ( is_wp_error ( $ user_id ) ) { $ this -> _debug ( 'User generation failed with message [%s] %s' , $ user_id -> g... | Generates a new user . |
51,670 | protected function _updateObject ( $ user_id , $ fields ) { $ fields [ 'ID' ] = $ user_id ; $ updated = wp_update_user ( $ fields ) ; if ( $ updated && ! is_wp_error ( $ updated ) ) { $ this -> _debug ( 'Updated user ' . $ user_id ) ; } elseif ( is_wp_error ( $ updated ) ) { $ this -> _debug ( 'Update failed for user %... | Updates generated user . |
51,671 | protected function _deleteObject ( $ user_id ) { $ user = get_user_by ( 'id' , $ user_id ) ; if ( ! $ user ) { return false ; } $ deleted = is_multisite ( ) ? wpmu_delete_user ( $ user_id ) : wp_delete_user ( $ user_id ) ; if ( $ deleted ) { $ this -> _debug ( 'Deleted user with ID: ' . $ user_id ) ; return true ; } $ ... | Deletes previously generated user . |
51,672 | public function _initialize ( ) { $ this -> wd_host = sprintf ( 'http://%s:%s@hub.browserstack.com/wd/hub' , $ this -> config [ 'username' ] , $ this -> config [ 'access_key' ] ) ; $ this -> capabilities = $ this -> config [ 'capabilities' ] ; $ this -> capabilities [ \ WebDriverCapabilityType :: BROWSER_NAME ] = $ thi... | Initializes webdriver . |
51,673 | protected function initialWindowSize ( ) { if ( isset ( $ this -> config [ 'resolution' ] ) ) { if ( $ this -> config [ 'resolution' ] == 'maximize' ) { $ this -> maximizeWindow ( ) ; } else { $ size = explode ( 'x' , $ this -> config [ 'resolution' ] ) ; if ( count ( $ size ) == 2 ) { $ this -> resizeWindow ( intval (... | Setup initial window size . |
51,674 | public function _setup_smtp_settings ( \ PHPMailer $ phpmailer ) { $ phpmailer -> Host = 'mailtrap.io' ; $ phpmailer -> Port = $ this -> config [ 'port' ] ; $ phpmailer -> Username = $ this -> config [ 'username' ] ; $ phpmailer -> Password = $ this -> config [ 'password' ] ; $ phpmailer -> SMTPAuth = true ; $ phpmaile... | Setups SMPT settings for the mailer object . |
51,675 | protected function _send_request ( $ url , $ args = array ( ) ) { $ url = 'https://mailtrap.io/api/v1/inboxes/' . $ this -> config [ 'inbox_id' ] . $ url ; $ args = wp_parse_args ( $ args , array ( 'method' => 'GET' , 'headers' => array ( ) , ) ) ; $ args [ 'headers' ] = array_merge ( $ args [ 'headers' ] , array ( 'Ap... | Sends request to the Mailtrap . io API . |
51,676 | protected function _send_get_request ( $ url ) { $ response = $ this -> _send_request ( $ url , array ( 'method' => 'GET' ) ) ; $ response_code = wp_remote_retrieve_response_code ( $ response ) ; $ this -> assertEquals ( 200 , $ response_code , 'The Mailtrap.io API resonse code is not equals to 200.' ) ; return $ respo... | Sends GET request to the Mailtrap . io API . |
51,677 | protected function _send_delete_request ( $ url ) { $ response = $ this -> _send_request ( $ url , array ( 'method' => 'DELETE' ) ) ; $ response_code = wp_remote_retrieve_response_code ( $ response ) ; $ this -> assertEquals ( 200 , $ response_code , 'The Mailtrap.io API resonse code is not equals to 200.' ) ; return $... | Sends DELETE request to the Mailtrap . io API . |
51,678 | protected function _send_patch_request ( $ url , $ body ) { $ response = $ this -> _send_request ( $ url , array ( 'method' => 'PATCH' , 'body' => $ body , ) ) ; $ response_code = wp_remote_retrieve_response_code ( $ response ) ; $ this -> assertEquals ( 200 , $ response_code , 'The Mailtrap.io API resonse code is not ... | Sends PATCH request to the Mailtrap . io API . |
51,679 | public function seeNewEmailFor ( $ recipient ) { $ email = $ this -> grabLatestEmailFor ( $ recipient ) ; $ this -> assertEquals ( $ recipient , $ email [ 'to_email' ] , 'The email recipient is wrong.' ) ; $ this -> assertFalse ( $ email [ 'is_read' ] , 'The email is already read.' ) ; } | Checks whether a new email exists for a recipient or not . |
51,680 | public function deleteEmail ( $ email_id = null ) { if ( ! $ email_id ) { $ this -> assertNotEmpty ( $ this -> _current_email , 'The current email is not selected' ) ; $ email_id = $ this -> _current_email [ 'id' ] ; } $ this -> _send_delete_request ( '/messages/' . $ email_id ) ; } | Deletes an email from the inbox . If no email id is provided then email id will be taken from the current email . |
51,681 | public function markEmailRead ( $ email_id = null ) { if ( ! $ email_id ) { $ this -> assertNotEmpty ( $ this -> _current_email , 'The current email is not selected' ) ; $ email_id = $ this -> _current_email [ 'id' ] ; } $ this -> _send_patch_request ( '/messages/' . $ email_id , array ( 'message' => array ( 'is_read' ... | Marks email read . If no email id is provided then email id will be taken from the current email . |
51,682 | protected function _createObject ( $ args ) { global $ wpdb ; $ meta = isset ( $ args [ 'meta' ] ) ? $ args [ 'meta' ] : array ( ) ; $ user_id = isset ( $ args [ 'user_id' ] ) ? $ args [ 'user_id' ] : get_current_user_id ( ) ; $ suppress = $ wpdb -> suppress_errors ( ) ; $ blog = wpmu_create_blog ( $ args [ 'domain' ] ... | Generates a new blog . |
51,683 | protected function _deleteObject ( $ blog_id ) { global $ wpdb ; $ suppress = $ wpdb -> suppress_errors ( ) ; wpmu_delete_blog ( $ blog_id , true ) ; $ wpdb -> suppress_errors ( $ suppress ) ; $ this -> _debug ( 'Deleted blog with ID: ' . $ blog_id ) ; return true ; } | Deletes previously generated blog . |
51,684 | public function run ( $ args , $ assoc_args ) { $ app = new Application ( 'Codeception' , \ Codeception \ Codecept :: VERSION ) ; $ app -> add ( new \ WPCC \ Command \ Run ( 'run' ) ) ; $ app -> run ( new ArgvInput ( ) ) ; } | Runs Codeception tests . |
51,685 | private function _execute_command ( ) { $ app = new Application ( 'Codeception' , \ Codeception \ Codecept :: VERSION ) ; $ app -> add ( new \ WPCC \ Command \ Build ( 'build' ) ) ; $ app -> add ( new \ Codeception \ Command \ Console ( 'console' ) ) ; $ app -> add ( new \ WPCC \ Command \ Bootstrap ( 'bootstrap' ) ) ;... | Executes command . |
51,686 | protected function _createObject ( $ args ) { $ args = array_merge ( array ( 'taxonomy' => $ this -> _taxonomy ) , $ args ) ; $ term_id_pair = wp_insert_term ( $ args [ 'name' ] , $ args [ 'taxonomy' ] , $ args ) ; if ( is_wp_error ( $ term_id_pair ) ) { $ this -> _debug ( 'Term generation failed with message [%s] %s' ... | Generates a new term . |
51,687 | protected function _updateObject ( $ term , $ fields ) { $ fields = array_merge ( array ( 'taxonomy' => $ this -> _taxonomy ) , $ fields ) ; $ taxonomy = is_object ( $ term ) ? $ term -> taxonomy : $ this -> _taxonomy ; $ term_id_pair = wp_update_term ( $ term , $ taxonomy , $ fields ) ; if ( is_wp_error ( $ term_id_pa... | Updates generated term . |
51,688 | protected function _deleteObject ( $ term_id ) { $ term = get_term_by ( 'id' , $ term_id , $ this -> _taxonomy ) ; if ( ! $ term || is_wp_error ( $ term ) ) { return false ; } $ deleted = wp_delete_term ( $ term_id , $ this -> _taxonomy ) ; if ( $ deleted && ! is_wp_error ( $ deleted ) ) { $ this -> _debug ( 'Deleted t... | Deletes previously generated term . |
51,689 | public function addPostTerms ( $ post_id , $ terms , $ taxonomy , $ append = true ) { return wp_set_post_terms ( $ post_id , $ terms , $ taxonomy , $ append ) ; } | Adds terms to a post . |
51,690 | public static function debugf ( $ message , $ args ) { $ args = array_slice ( func_get_args ( ) , 1 ) ; if ( count ( $ args ) == 1 && is_array ( $ args [ 0 ] ) ) { $ args = $ args [ 0 ] ; } array_unshift ( $ args , $ message ) ; $ message = call_user_func_array ( 'sprintf' , $ args ) ; self :: debug ( $ message ) ; } | Prints formatted data to screen . |
51,691 | private function getSimpleCache ( ) { if ( $ cache = $ this -> app -> config -> get ( 'swap.cache' ) ) { $ store = $ this -> app [ 'cache' ] -> store ( $ cache ) -> getStore ( ) ; return new SimpleCacheBridge ( new IlluminateCachePool ( $ store ) ) ; } return null ; } | Gets the simple cache . |
51,692 | private function getHttpClient ( ) { if ( $ httpClient = $ this -> app -> config -> get ( 'swap.http_client' ) ) { return $ this -> app [ $ httpClient ] ; } return null ; } | Gets the http client . |
51,693 | private function getRequestFactory ( ) { if ( $ requestFactory = $ this -> app -> config -> get ( 'swap.request_factory' ) ) { return $ this -> app [ $ requestFactory ] ; } return null ; } | Gets the request factory . |
51,694 | public static function normalizeLat ( float $ lat ) : float { if ( $ lat > 360.0 ) { $ lat = \ fmod ( $ lat , 360.0 ) ; } if ( $ lat < - 360.0 ) { $ lat = \ fmod ( $ lat , - 360.0 ) ; } if ( $ lat > 180.0 ) { $ lat = 180.0 - $ lat ; } if ( $ lat < - 180.0 ) { $ lat = - 180.0 - $ lat ; } if ( $ lat > 90.0 ) { $ lat = 18... | Normalizes a latitude in degrees to the - 90 90 range . |
51,695 | public static function normalizeLng ( float $ lng ) : float { if ( $ lng > 360.0 ) { $ lng = \ fmod ( $ lng , 360.0 ) ; } if ( $ lng < - 360.0 ) { $ lng = \ fmod ( $ lng , - 360.0 ) ; } if ( $ lng > 180.0 ) { $ lng = - 360.0 + $ lng ; } if ( $ lng < - 180.0 ) { $ lng = 360.0 + $ lng ; } if ( $ lng === - 180.0 ) { retur... | Normalizes a longitude in degrees to the - 180 180 range . |
51,696 | public function midpoint ( Position $ from , Position $ to ) : Position { $ lat1 = $ from -> latitude ( ) ; $ lng1 = $ from -> longitude ( ) ; $ lat2 = $ to -> latitude ( ) ; $ lng2 = $ to -> longitude ( ) ; $ lat1 = \ deg2rad ( $ lat1 ) ; $ lat2 = \ deg2rad ( $ lat2 ) ; $ dLon = \ deg2rad ( $ lng2 - $ lng1 ) ; $ Bx = ... | Calculates an intermediate point on the geodesic between the two given points . |
51,697 | public function endpoint ( Position $ start , float $ heading , Distance $ distance ) : Position { $ lat = \ deg2rad ( $ start -> latitude ( ) ) ; $ lng = \ deg2rad ( $ start -> longitude ( ) ) ; $ angularDistance = $ distance -> meters ( ) / Earth :: RADIUS ; $ heading = \ deg2rad ( $ heading ) ; $ lat2 = \ asin ( \ s... | Calculates the destination point along a geodesic given an initial heading and distance from the given start point . |
51,698 | public function getLink ( $ attributesOrText = null ) { $ text = $ this -> getText ( ) ; $ extraAttributes = null ; if ( is_string ( $ attributesOrText ) ) { $ text = $ attributesOrText ; } elseif ( is_array ( $ attributesOrText ) ) { $ extraAttributes = $ attributesOrText ; if ( array_key_exists ( 'text' , $ extraAttr... | Renders a complete link tag . |
51,699 | public function getLinkAttributes ( $ extraAttributes = null ) { $ attributes = $ this -> getRawLinkAttributes ( $ extraAttributes ) ; return Template :: raw ( is_null ( $ attributes ) ? '' : Html :: renderTagAttributes ( $ attributes ) ) ; } | Return the attributes of this link as a rendered html string . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.