idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
34,900 | public function unbind ( ) { $ this -> _setErrorHandler ( ) ; ldap_unbind ( $ this -> _connection ) ; $ this -> _unsetErrorHandler ( ) ; $ this -> _connection = null ; } | Unbind from LDAP directory |
34,901 | public function get ( $ key = null ) { if ( empty ( $ this -> _identity ) ) { return null ; } if ( $ key === null ) { return $ this -> _identity -> getOriginalData ( ) ; } return Hash :: get ( $ this -> _identity , $ key ) ; } | Gets user data |
34,902 | protected function get ( $ field ) { $ map = $ this -> _config [ 'fieldMap' ] ; if ( isset ( $ map [ $ field ] ) ) { $ field = $ map [ $ field ] ; } if ( isset ( $ this -> data [ $ field ] ) ) { return $ this -> data [ $ field ] ; } return null ; } | Get data from the identity |
34,903 | protected function _create ( $ className , $ alias , $ config ) { $ authenticator = new $ className ( $ this -> _identifiers , $ config ) ; if ( ! ( $ authenticator instanceof AuthenticatorInterface ) ) { throw new RuntimeException ( sprintf ( 'Authenticator class `%s` must implement \Auth\Authentication\AuthenticatorI... | Creates authenticator instance . |
34,904 | public static function build ( $ passwordHasher ) { $ config = [ ] ; if ( is_string ( $ passwordHasher ) ) { $ class = $ passwordHasher ; } else { $ class = $ passwordHasher [ 'className' ] ; $ config = $ passwordHasher ; unset ( $ config [ 'className' ] ) ; } $ className = App :: className ( $ class , 'PasswordHasher'... | Returns password hasher object out of a hasher name or a configuration array |
34,905 | public function getPasswordHasher ( ) { if ( $ this -> _passwordHasher === null ) { $ passwordHasher = $ this -> getConfig ( 'passwordHasher' ) ; if ( $ passwordHasher !== null ) { $ passwordHasher = PasswordHasherFactory :: build ( $ passwordHasher ) ; } else { $ passwordHasher = $ this -> _getPasswordHasher ( ) ; } $... | Return password hasher object . |
34,906 | protected function _checkPassword ( $ identity , $ password ) { $ passwordField = $ this -> getConfig ( 'fields.' . self :: CREDENTIAL_PASSWORD ) ; if ( $ identity === null ) { $ identity = [ $ passwordField => '' ] ; } $ hasher = $ this -> getPasswordHasher ( ) ; $ hashedPassword = $ identity [ $ passwordField ] ; if ... | Find a user record using the username and password provided . Input passwords will be hashed even when a user doesn t exist . This helps mitigate timing attacks that are attempting to find valid usernames . |
34,907 | protected function _buildLoginUrlErrorResult ( $ request ) { $ errors = [ sprintf ( 'Login URL `%s` did not match `%s`.' , ( string ) $ request -> getUri ( ) , implode ( '` or `' , ( array ) $ this -> getConfig ( 'loginUrl' ) ) ) ] ; return new Result ( null , Result :: FAILURE_OTHER , $ errors ) ; } | Prepares the error object for a login URL error |
34,908 | private function genUUID ( ) { return sprintf ( '%04x%04x%04x%03x4%04x%04x%04x%04x' , mt_rand ( 0 , 65535 ) , mt_rand ( 0 , 65535 ) , mt_rand ( 0 , 65535 ) , mt_rand ( 0 , 4095 ) , bindec ( substr_replace ( sprintf ( '%016b' , mt_rand ( 0 , 65535 ) ) , '01' , 6 , 2 ) ) , mt_rand ( 0 , 65535 ) , mt_rand ( 0 , 65535 ) , ... | Generates a UUID string . |
34,909 | private function genUUIDPath ( ) { $ uid = $ this -> genUUID ( ) ; $ result = '/' ; $ segments = 8 ; if ( $ segments > strlen ( $ uid ) / 2 ) { $ segments = strlen ( $ uid ) / 2 ; } for ( $ i = 0 ; $ i < $ segments ; $ i ++ ) { $ result .= substr ( $ uid , $ i * 2 , 2 ) . '/' ; } return $ result ; } | Generates a UUID path |
34,910 | private function getObjectVersion ( $ id = null ) { if ( ! empty ( $ id ) && ! empty ( $ this -> versionedIds [ $ id ] ) ) { return $ this -> versionedIds [ $ id ] ; } $ date_format = 'dHis' ; $ time = current_time ( 'timestamp' ) ; $ object_version = date ( $ date_format , $ time ) . '/' ; $ object_version = apply_fil... | Gets an Offload S3 compatible object version string . |
34,911 | public function incrementTotalTime ( $ batch , $ lastTime ) { update_option ( "ilab_media_tools_{$batch}_last_time" , $ lastTime ) ; update_option ( "ilab_media_tools_{$batch}_total_time" , $ this -> totalTime ( $ batch ) + $ lastTime ) ; } | Increments the total processing time for the batch |
34,912 | public function setErrorMessage ( $ batch , $ error ) { update_option ( "ilab_media_tools_{$batch}_error_id" , $ batch . '-error-' . sanitize_title ( microtime ( true ) ) . '-forever' ) ; update_option ( "ilab_media_tools_{$batch}_error_message" , $ error ) ; } | Sets the current error |
34,913 | public function lastUpdate ( $ batch ) { $ lu = get_option ( "ilab_media_tools_{$batch}_last_update" , 0 ) ; if ( $ lu > 0 ) { $ lu = microtime ( true ) - $ lu ; } return $ lu ; } | Returns the amount of time that has elapsed since the last item was processed . |
34,914 | public function stats ( $ batch ) { $ total = $ this -> totalCount ( $ batch ) ; $ current = $ this -> current ( $ batch ) ; $ totalTime = $ this -> totalTime ( $ batch ) ; $ progress = 0 ; if ( $ total > 0 ) { $ progress = ( $ current / $ total ) * 100 ; } $ postsPerMinute = 0 ; $ eta = 0 ; if ( ( $ totalTime > 0 ) &&... | Returns stats about this batch |
34,915 | public function displayAnyErrors ( $ batch ) { $ error = $ this -> errorMessage ( $ batch ) ; if ( ! empty ( $ error ) ) { NoticeManager :: instance ( ) -> displayAdminNotice ( 'error' , $ error , true , $ this -> errorMessageId ( $ batch ) ) ; } } | Display any error for a batch |
34,916 | public function reset ( $ batch ) { delete_option ( "ilab_media_tools_{$batch}_status" ) ; delete_option ( "ilab_media_tools_{$batch}_current" ) ; delete_option ( "ilab_media_tools_{$batch}_file" ) ; delete_option ( "ilab_media_tools_{$batch}_total" ) ; delete_option ( "ilab_media_tools_{$batch}_last_run" ) ; delete_op... | Removes an stored information about the batch |
34,917 | public function addToBatchAndRun ( $ batch , $ postIDs ) { if ( ! isset ( static :: $ batchClasses [ $ batch ] ) ) { throw new \ Exception ( "Batch '$batch' is not registered." ) ; } $ this -> reset ( $ batch ) ; if ( count ( $ postIDs ) == 0 ) { return ; } $ testResult = $ this -> testConnectivity ( ) ; if ( $ testRes... | Adds posts to a batch and runs it . If another one of this batch type is running it will be cancelled . |
34,918 | public function dispatchBatchesIfNeeded ( ) { foreach ( static :: $ batchClasses as $ batch => $ batchClass ) { if ( $ this -> status ( $ batch ) ) { $ lastRun = $ this -> lastRun ( $ batch ) ; if ( ( time ( ) - $ lastRun ) > 60 ) { $ this -> setLastRun ( $ batch , time ( ) ) ; $ process = new $ batchClass ( ) ; $ proc... | Determines if enough time has elapsed since the last time the batch was forced to run and then runs it if so |
34,919 | public function log ( $ channel , $ level , $ message , $ context = '' ) { if ( ! $ this -> enabled ) { return ; } $ message = ltrim ( $ message ) ; global $ wpdb ; $ query = $ wpdb -> prepare ( "insert into {$this->table} (date, channel, level, message, context) values (%s, %s, %s, %s, %s)" , current_time ( 'mysql' , ... | Logs to the database |
34,920 | protected function insureTable ( ) { global $ wpdb ; $ this -> table = $ wpdb -> prefix . 'ilab_mc_logging' ; $ tableSchema = <<<SQL create table {$this->table} ( id bigint not null auto_increment, date datetime not null, channel varchar(32) not null, level varchar(16) not nu... | Insures the table exists |
34,921 | public function csv ( ) { global $ wpdb ; $ fd = fopen ( 'php://temp/maxmemory:1048576' , 'w' ) ; fputcsv ( $ fd , [ "date" , "channel" , "level" , "message" , "context" ] ) ; $ rows = $ wpdb -> get_results ( "select date, channel, level, message, context from {$this->table} order by id asc" , ARRAY_N ) ; if ( is_array... | Exports the log to CSV |
34,922 | public function dispatch ( ) { $ url = add_query_arg ( $ this -> get_query_args ( ) , $ this -> get_query_url ( ) ) ; $ args = $ this -> get_post_args ( ) ; Logger :: info ( "Background dispatching $url" , $ args ) ; $ rawUrl = esc_url_raw ( $ url ) ; Logger :: info ( "Async call to $rawUrl" , [ 'args' => $ args ] ) ; ... | Dispatch the async request |
34,923 | protected function get_query_args ( ) { if ( property_exists ( $ this , 'query_args' ) ) { return $ this -> query_args ; } return array ( 'action' => $ this -> identifier , 'nonce' => wp_create_nonce ( $ this -> identifier ) , ) ; } | Get query args |
34,924 | protected function get_post_args ( ) { if ( property_exists ( $ this , 'post_args' ) ) { return $ this -> post_args ; } $ timeout = EnvironmentOptions :: Option ( 'ilab-media-s3-batch-timeout' , null , 0.1 ) ; return array ( 'timeout' => $ timeout , 'blocking' => false , 'body' => $ this -> data , 'cookies' => $ _COOKI... | Get post args |
34,925 | private function buildSizedImgixImage ( $ id , $ size ) { $ meta = wp_get_attachment_metadata ( $ id ) ; if ( ! $ meta || empty ( $ meta ) ) { return false ; } if ( ! isset ( $ meta [ 's3' ] ) ) { return [ ] ; } $ imgix = new UrlBuilder ( $ this -> imgixDomains , $ this -> useHTTPS ) ; if ( $ this -> signingKey ) { $ i... | Builds an Imgix URL for a dynamically sized image . |
34,926 | public function buildSrcSetURL ( $ post_id , $ parentSize , $ newSize ) { return $ this -> buildImgixImage ( $ post_id , $ parentSize , null , false , null , $ newSize ) ; } | Builds the URL for a srcSet Image |
34,927 | public function imageGetIntermediateSize ( $ data , $ post_id , $ size ) { $ result = $ this -> buildImgixImage ( $ post_id , $ size ) ; if ( is_array ( $ result ) && ! empty ( $ result ) ) { $ data [ 'url' ] = $ result [ 0 ] ; } return $ data ; } | Filters the image data for intermediate sizes . |
34,928 | private function buildPresetsUI ( $ image_id , $ size ) { $ presets = get_option ( 'ilab-imgix-presets' ) ; if ( ! $ presets ) { $ presets = [ ] ; } $ sizePresets = get_option ( 'ilab-imgix-size-presets' ) ; if ( ! $ sizePresets ) { $ sizePresets = [ ] ; } $ presetsUI = [ ] ; foreach ( $ presets as $ pkey => $ pinfo ) ... | Builds the presets UI |
34,929 | public function saveAdjustments ( ) { $ image_id = esc_html ( $ _POST [ 'image_id' ] ) ; $ size = esc_html ( $ _POST [ 'size' ] ) ; $ params = ( isset ( $ _POST [ 'settings' ] ) ) ? $ _POST [ 'settings' ] : [ ] ; if ( ! current_user_can ( 'edit_post' , $ image_id ) ) { json_response ( [ 'status' => 'error' , 'message' ... | Save The Parameters |
34,930 | public function previewAdjustments ( ) { $ image_id = esc_html ( $ _POST [ 'image_id' ] ) ; $ size = esc_html ( $ _POST [ 'size' ] ) ; if ( ! current_user_can ( 'edit_post' , $ image_id ) ) { json_response ( [ 'status' => 'error' , 'message' => 'You are not strong enough, smart enough or fast enough.' ] ) ; } $ params ... | Preview the adjustment |
34,931 | private function doUpdatePresets ( $ key , $ name , $ settings , $ size , $ makeDefault ) { $ image_id = esc_html ( $ _POST [ 'image_id' ] ) ; $ presets = get_option ( 'ilab-imgix-presets' ) ; if ( ! $ presets ) { $ presets = [ ] ; } $ presets [ $ key ] = [ 'title' => $ name , 'settings' => $ settings ] ; update_option... | Update the presets |
34,932 | public function newPreset ( ) { $ name = esc_html ( $ _POST [ 'name' ] ) ; if ( empty ( $ name ) ) { json_response ( [ 'status' => 'error' , 'error' => 'Seems that you may have forgotten something.' ] ) ; } $ key = sanitize_title ( $ name ) ; $ newKey = $ key ; $ presets = get_option ( 'ilab-imgix-presets' ) ; if ( $ p... | Create a new preset |
34,933 | public function savePreset ( ) { $ key = esc_html ( $ _POST [ 'key' ] ) ; if ( empty ( $ key ) ) { json_response ( [ 'status' => 'error' , 'error' => 'Seems that you may have forgotten something.' ] ) ; } $ presets = get_option ( 'ilab-imgix-presets' ) ; if ( ! isset ( $ presets [ $ key ] ) ) { json_response ( [ 'statu... | Save an existing preset |
34,934 | public function deletePreset ( ) { $ key = esc_html ( $ _POST [ 'key' ] ) ; if ( empty ( $ key ) ) { json_response ( [ 'status' => 'error' , 'error' => 'Seems that you may have forgotten something.' ] ) ; } $ presets = get_option ( 'ilab-imgix-presets' ) ; if ( $ presets ) { unset ( $ presets [ $ key ] ) ; update_optio... | Delete an existing preset |
34,935 | public function uploadUrl ( $ key , $ acl , $ mimeType = null , $ cacheControl = null , $ expires = null ) { try { $ optionsData = [ 'ACL' => $ acl , 'Bucket' => $ this -> bucket , 'ContentType' => $ mimeType , 'Key' => $ key ] ; if ( ! empty ( $ cacheControl ) ) { $ optionsData [ ] = [ 'CacheControl' => $ cacheControl... | region Direct Uploads |
34,936 | protected function logSystemError ( $ type , $ message , $ file , $ line ) { switch ( $ type ) { case E_ERROR : case E_USER_ERROR : case E_RECOVERABLE_ERROR : case E_PARSE : case E_CORE_ERROR : case E_COMPILE_ERROR : $ this -> doLogError ( $ message , [ 'file' => $ file , 'line' => $ line ] ) ; break ; case E_WARNING :... | region Protected Logging Methods |
34,937 | public function setup ( ) { if ( $ this -> enabled ( ) ) { $ this -> hookupUI ( ) ; add_action ( 'admin_enqueue_scripts' , [ $ this , 'enqueueTheGoods' ] ) ; add_action ( 'wp_ajax_ilab_crop_image_page' , [ $ this , 'displayCropUI' ] ) ; add_action ( 'wp_ajax_ilab_perform_crop' , [ $ this , 'performCrop' ] ) ; add_filte... | Setup the plugin |
34,938 | public function enqueueTheGoods ( $ hook ) { add_thickbox ( ) ; if ( $ hook == 'post.php' ) wp_enqueue_media ( ) ; else if ( $ hook == 'upload.php' ) { $ mode = get_user_option ( 'media_library_mode' , get_current_user_id ( ) ) ? get_user_option ( 'media_library_mode' , get_current_user_id ( ) ) : 'grid' ; if ( isset (... | Enqueue the CSS and JS needed to make the magic happen |
34,939 | public static function storageInstance ( ) { if ( self :: $ instance ) { return self :: $ instance ; } if ( ! isset ( self :: $ registry [ self :: driver ( ) ] ) ) { throw new StorageException ( "Invalid driver '" . self :: driver ( ) . "'" ) ; } $ class = self :: $ registry [ self :: driver ( ) ] ; self :: $ instance ... | Gets the currently configured storage interface . |
34,940 | public function setupAdmin ( ) { add_action ( 'admin_enqueue_scripts' , function ( ) { wp_enqueue_script ( 'wp-util' ) ; wp_enqueue_style ( 'ilab-media-upload-css' , ILAB_PUB_CSS_URL . '/ilab-media-upload.min.css' ) ; wp_enqueue_script ( 'ilab-media-upload-js' , ILAB_PUB_JS_URL . '/ilab-media-upload.js' , [ 'jquery' , ... | Setup upload UI |
34,941 | public function setupAdminAjax ( ) { add_action ( 'wp_ajax_ilab_upload_prepare' , function ( ) { $ this -> prepareUpload ( ) ; } ) ; add_action ( 'wp_ajax_ilab_upload_import_cloud_file' , function ( ) { $ this -> importUploadedFile ( ) ; } ) ; add_action ( 'wp_ajax_ilab_upload_attachment_info' , function ( ) { $ postId... | Install Ajax Endpoints |
34,942 | private function importUploadedFile ( ) { if ( ! current_user_can ( 'upload_files' ) ) { json_response ( [ "status" => "error" , "message" => "Current user can't upload." ] ) ; } $ key = $ _POST [ 'key' ] ; if ( empty ( $ key ) ) { json_response ( [ 'status' => 'error' , 'message' => 'Missing key.' ] ) ; } $ info = $ t... | Called after a file has been uploaded and needs to be imported into the system . |
34,943 | private function prepareUpload ( ) { if ( ! current_user_can ( 'upload_files' ) ) { json_response ( [ "status" => "error" , "message" => "Current user can't upload." ] ) ; } if ( ! $ this -> client || ! $ this -> client -> enabled ( ) ) { json_response ( [ "status" => "error" , "message" => "Storage settings are invali... | Called when ready to upload to the storage service |
34,944 | public function process ( $ args , $ assoc_args ) { $ tool = ToolsManager :: instance ( ) -> tools [ 'rekognition' ] ; if ( ! $ tool || ! $ tool -> enabled ( ) ) { Command :: Error ( 'Rekognition tool is not enabled in Media Cloud or the settings are incorrect.' ) ; return ; } global $ wpdb ; $ sql = <<<SQL select ... | Processes the media library with Rekognition |
34,945 | public function deleteAttachment ( $ id ) { if ( ! StorageSettings :: deleteFromStorage ( ) ) { return $ id ; } $ data = wp_get_attachment_metadata ( $ id ) ; if ( isset ( $ data [ 'file' ] ) && ! isset ( $ data [ 's3' ] ) ) { return $ id ; } if ( $ this -> client && $ this -> client -> enabled ( ) ) { if ( ! isset ( $... | Filters for when attachments are deleted |
34,946 | public function forcedImageDownsize ( $ fail , $ id , $ size ) { if ( empty ( $ size ) || empty ( $ id ) || is_array ( $ size ) ) { return $ fail ; } $ meta = wp_get_attachment_metadata ( $ id ) ; if ( empty ( $ meta ) ) { return $ fail ; } if ( ! isset ( $ meta [ 'sizes' ] ) ) { return $ fail ; } if ( ! isset ( $ meta... | Performs the image downsize regardless if Imgix is enabled or not . |
34,947 | private function getOffloadS3URL ( $ post_id , $ info ) { if ( ! is_array ( $ info ) && ( count ( $ info ) < 1 ) ) { return null ; } $ region = $ info [ 0 ] [ 'region' ] ; $ bucket = $ info [ 0 ] [ 'bucket' ] ; $ file = $ info [ 0 ] [ 'key' ] ; return "https://s3-$region.amazonaws.com/$bucket/$file" ; } | For compatibility with Offload S3 . |
34,948 | public function processCrop ( $ size , $ upload_path , $ file , $ sizeMeta ) { $ upload_info = wp_upload_dir ( ) ; $ subdir = trim ( str_replace ( $ upload_info [ 'basedir' ] , '' , $ upload_path ) , '/' ) ; $ upload_path = rtrim ( str_replace ( $ subdir , '' , $ upload_path ) , '/' ) ; if ( $ this -> client && $ this ... | Processes a file after a crop has been performed uploading it to storage if it exists |
34,949 | private function deleteFile ( $ file ) { try { if ( $ this -> client && $ this -> client -> enabled ( ) ) { $ this -> client -> delete ( $ file ) ; } } catch ( StorageException $ ex ) { Logger :: error ( "Error deleting file '$file'." , [ 'exception' => $ ex -> getMessage ( ) , 'Key' => $ file ] ) ; } } | Deletes a file from storage |
34,950 | private function hookMediaList ( ) { if ( ! $ this -> mediaListIntegration ) { return ; } add_action ( 'admin_init' , function ( ) { add_filter ( 'manage_media_columns' , function ( $ cols ) { $ cols [ "cloud" ] = 'Cloud' ; return $ cols ; } ) ; add_action ( 'manage_media_custom_column' , function ( $ column_name , $ i... | Adds a custom column to the media list . |
34,951 | private function doRenderStorageInfoMeta ( $ postId = null , $ readOnly = false ) { global $ post ; if ( empty ( $ postId ) ) { $ postId = $ post -> ID ; } $ meta = wp_get_attachment_metadata ( $ postId ) ; if ( empty ( $ meta ) ) { return ; } if ( ! isset ( $ meta [ 's3' ] ) ) { $ meta = get_post_meta ( $ postId , 'il... | Renders the Cloud Storage metabox |
34,952 | public function regenerateFile ( $ postId ) { @ set_time_limit ( 120 ) ; $ fullsizepath = get_attached_file ( $ postId ) ; if ( ! file_exists ( $ fullsizepath ) ) { if ( function_exists ( '_load_image_to_edit_path' ) ) { $ fullsizepath = _load_image_to_edit_path ( $ postId ) ; } else { Logger :: warning ( "The function... | Regenerates an image s thumbnails and re - uploads them to the storage service . |
34,953 | public function uploadUrlForFile ( $ filename ) { $ prefix = StorageSettings :: prefix ( null ) ; $ parts = explode ( '/' , $ filename ) ; $ bucketFilename = array_pop ( $ parts ) ; if ( $ this -> client && $ this -> client -> enabled ( ) ) { try { return $ this -> client -> uploadUrl ( $ prefix . $ bucketFilename , St... | Gets a pre - signed URL for uploading directly to the storage backend |
34,954 | public function handleImageOptimizer ( $ postId ) { $ this -> processingOptimized = true ; Logger :: info ( 'Handle Image Optimizer: ' . $ postId ) ; add_filter ( 'ilab_ignore_existing_s3_data' , function ( $ shouldIgnore , $ attachmentId ) use ( $ postId ) { if ( $ postId == $ attachmentId ) { return true ; } return $... | region Image Optimizer |
34,955 | protected function getBucketRegion ( ) { if ( ! $ this -> enabled ( ) ) { return false ; } $ config = [ 'version' => 'latest' , 'credentials' => [ 'key' => $ this -> key , 'secret' => $ this -> secret ] ] ; if ( ! empty ( $ this -> endpoint ) ) { $ config [ 'endpoint' ] = $ this -> endpoint ; if ( $ this -> endPointPat... | Attempts to determine the region for the bucket |
34,956 | protected function getS3MultiRegionClient ( ) { if ( ! $ this -> enabled ( ) ) { return null ; } $ config = [ 'version' => 'latest' , 'credentials' => [ 'key' => $ this -> key , 'secret' => $ this -> secret ] ] ; if ( ! empty ( $ this -> endpoint ) ) { $ config [ 'endpoint' ] = $ this -> endpoint ; if ( $ this -> endPo... | Builds and returns an S3MultiRegionClient |
34,957 | protected function getS3Client ( $ region = false , $ errorCollector = null ) { if ( ! $ this -> enabled ( ) ) { return null ; } if ( empty ( $ region ) ) { if ( empty ( $ this -> region ) ) { $ this -> region = $ this -> getBucketRegion ( ) ; if ( empty ( $ this -> region ) ) { if ( $ errorCollector ) { $ errorCollect... | Attempts to build the S3Client . This requires a region be defined or determinable . |
34,958 | protected function getClient ( $ errorCollector = null ) { if ( ! $ this -> enabled ( ) ) { if ( $ errorCollector ) { $ errorCollector -> addError ( "Account ID, account secret and/or the bucket are incorrect or missing." ) ; } return null ; } $ s3 = $ this -> getS3Client ( false , $ errorCollector ) ; if ( ! $ s3 ) { ... | Gets the S3Client |
34,959 | public function enabled ( ) { if ( $ this -> badPluginsInstalled ) { return false ; } $ env = ( $ this -> env_variable ) ? getenv ( $ this -> env_variable ) : false ; $ enabled = get_option ( "ilab-media-tool-enabled-$this->toolName" , $ env ) ; if ( $ enabled && isset ( $ this -> toolInfo [ 'dependencies' ] ) ) { fore... | Determines if this tool is enabled or not |
34,960 | public function registerMenu ( $ top_menu_slug ) { if ( ! isset ( $ this -> toolInfo [ 'settings' ] ) ) return ; if ( $ this -> only_when_enabled && ( ! $ this -> enabled ( ) ) ) { return ; } $ settings = $ this -> toolInfo [ 'settings' ] ; add_submenu_page ( $ top_menu_slug , $ settings [ 'title' ] , $ settings [ 'men... | Register menu pages |
34,961 | protected function registerSettingsSection ( $ slug , $ title , $ description ) { $ this -> settingSections [ $ slug ] = [ 'title' => $ title , 'description' => $ description , 'fields' => [ ] ] ; add_settings_section ( $ slug , $ title , [ $ this , 'renderSettingsSection' ] , $ this -> options_page ) ; } | Registers a settings section |
34,962 | public function renderSettingsSection ( $ section ) { if ( ! isset ( $ this -> settingSections [ $ section [ 'id' ] ] ) ) return ; $ settingSection = $ this -> settingSections [ $ section [ 'id' ] ] ; echo "<a name='{$section['id']}'></a>" ; if ( is_array ( $ settingSection [ 'description' ] ) ) { foreach ( $ settingSe... | Renders a settings section description |
34,963 | public function maybe_handle ( ) { if ( $ this -> is_process_running ( ) ) { wp_die ( ) ; } if ( $ this -> is_queue_empty ( ) ) { wp_die ( ) ; } check_ajax_referer ( $ this -> identifier , 'nonce' ) ; $ this -> handle ( ) ; wp_die ( ) ; } | Maybe process queue |
34,964 | protected function is_queue_empty ( ) { global $ wpdb ; $ table = $ wpdb -> options ; $ column = 'option_name' ; if ( is_multisite ( ) ) { $ table = $ wpdb -> sitemeta ; $ column = 'meta_key' ; } $ key = $ this -> identifier . '_batch_%' ; $ count = $ wpdb -> get_var ( $ wpdb -> prepare ( " SELECT COUNT(*) FROM {$t... | Is queue empty |
34,965 | protected function is_process_running ( ) { $ lockData = get_option ( $ this -> identifier . '_process_lock' , null ) ; if ( ! empty ( $ lockData ) || isset ( $ lockData [ 'expires' ] ) ) { if ( time ( ) <= $ lockData [ 'expires' ] ) { Logger :: info ( 'Lock still active. Expires in: ' . ( $ lockData [ 'expires' ] - t... | Is process running |
34,966 | public function schedule_cron_healthcheck ( $ schedules ) { $ interval = apply_filters ( $ this -> identifier . '_cron_interval' , 5 ) ; if ( property_exists ( $ this , 'cron_interval' ) ) { $ interval = apply_filters ( $ this -> identifier . '_cron_interval' , $ this -> cron_interval_identifier ) ; } $ schedules [ $ t... | Schedule cron healthcheck |
34,967 | public function handle_cron_healthcheck ( ) { if ( $ this -> is_process_running ( ) ) { exit ; } if ( $ this -> is_queue_empty ( ) ) { $ this -> clear_scheduled_event ( ) ; exit ; } $ this -> handle ( ) ; exit ; } | Handle cron healthcheck |
34,968 | protected function clear_scheduled_event ( ) { $ timestamp = wp_next_scheduled ( $ this -> cron_hook_identifier ) ; if ( $ timestamp ) { wp_unschedule_event ( $ timestamp , $ this -> cron_hook_identifier ) ; } } | Clear scheduled event |
34,969 | public function toArray ( ) { return [ 'key' => $ this -> key ( ) , 'url' => $ this -> url ( ) , 'formData' => $ this -> formData ( ) , 'cacheControl' => $ this -> cacheControl ( ) , 'expires' => $ this -> expires ( ) , 'acl' => $ this -> acl ( ) ] ; } | Returns the upload info as an array |
34,970 | public static function Option ( $ optionName = null , $ envVariableName = null , $ default = false ) { if ( empty ( $ optionName ) && empty ( $ envVariableName ) ) { return $ default ; } if ( $ envVariableName == null ) { $ envVariableName = str_replace ( '-' , '_' , strtoupper ( $ optionName ) ) ; } if ( is_array ( $ ... | Fetches an option from WordPress or the environment . |
34,971 | public function import ( $ args , $ assoc_args ) { $ this -> debugMode = ( \ WP_CLI :: get_config ( 'debug' ) == 'mediacloud' ) ; Logger :: instance ( ) ; $ storageTool = ToolsManager :: instance ( ) -> tools [ 'storage' ] ; if ( ! $ storageTool || ! $ storageTool -> enabled ( ) ) { Command :: Error ( 'Storage tool is ... | Imports the media library to the cloud . |
34,972 | public function attachmentTaxonomies ( ) { $ taxonomies = [ 'category' => 'Category' , 'post_tag' => 'Tag' ] ; $ attachTaxes = get_object_taxonomies ( 'attachment' ) ; if ( ! empty ( $ attachTaxes ) ) { foreach ( $ attachTaxes as $ attachTax ) { if ( ! in_array ( $ attachTax , [ 'post_tag' , 'category' ] ) ) { $ taxono... | Returns a list of taxonomies for Attachments used in the Rekognition settings page . |
34,973 | private function processTags ( $ tags , $ tax , $ postID ) { if ( empty ( $ tags ) ) { return ; } $ tagsToAdd = [ ] ; foreach ( $ tags as $ tag ) { $ term = false ; if ( term_exists ( $ tag [ 'tag' ] , $ tax ) ) { $ term = get_term_by ( 'name' , $ tag [ 'tag' ] , $ tax ) ; } else { $ parent = false ; if ( isset ( $ tag... | Process the tags found with Rekognition |
34,974 | public function resize ( $ max_w , $ max_h , $ crop = false ) { return $ this -> imageEditor -> resize ( $ max_w , $ max_h , $ crop ) ; } | Resizes current image . |
34,975 | public function crop ( $ src_x , $ src_y , $ src_w , $ src_h , $ dst_w = null , $ dst_h = null , $ src_abs = false ) { return $ this -> imageEditor -> crop ( $ src_x , $ src_y , $ src_w , $ src_h , $ dst_w , $ dst_h , $ src_abs ) ; } | Crops Image . |
34,976 | public function setup ( ) { if ( $ this -> enabled ( ) ) { BatchManager :: instance ( ) -> displayAnyErrors ( $ this -> batchIdentifier ( ) ) ; if ( $ this -> mediaListIntegration ) { add_action ( 'admin_init' , function ( ) { add_filter ( 'bulk_actions-upload' , function ( $ actions ) { return $ this -> registerBulkAc... | Performs any additional setup |
34,977 | protected function getImportBatch ( $ page , $ forceImages = false ) { $ total = 0 ; $ pages = 1 ; $ shouldRun = false ; $ fromSelection = false ; if ( isset ( $ _POST [ 'selection' ] ) ) { $ postIds = $ _POST [ 'selection' ] ; $ total = count ( $ postIds ) ; $ shouldRun = true ; } else { $ postIds = get_site_transient... | Gets the post data to process for this batch . Data is paged to minimize memory usage . |
34,978 | public function renderBatchTool ( ) { wp_enqueue_style ( 'ilab-media-importer-css' , ILAB_PUB_CSS_URL . '/ilab-media-importer.min.css' ) ; $ data = BatchManager :: instance ( ) -> stats ( $ this -> batchIdentifier ( ) ) ; $ postData = $ this -> getImportBatch ( 1 ) ; $ data [ 'posts' ] = $ postData [ 'posts' ] ; $ data... | Renders the batch tool |
34,979 | public function startAction ( ) { $ posts = $ this -> getImportBatch ( - 1 ) ; if ( $ posts [ 'total' ] > 0 ) { try { $ postIDs = [ ] ; foreach ( $ posts [ 'posts' ] as $ post ) { $ postIDs [ ] = $ post [ 'id' ] ; } BatchManager :: instance ( ) -> addToBatchAndRun ( $ this -> batchIdentifier ( ) , $ postIDs ) ; } catch... | The action that starts a batch in motion |
34,980 | public function progressAction ( ) { $ data = BatchManager :: instance ( ) -> stats ( $ this -> batchIdentifier ( ) ) ; $ data [ 'status' ] = ( $ data [ 'running' ] ) ? 'running' : 'idle' ; $ data [ 'enabled' ] = $ this -> enabled ( ) ; json_response ( $ data ) ; } | Reports progress on a batch |
34,981 | public function nextBatchAction ( ) { $ page = isset ( $ _POST [ 'page' ] ) ? ( int ) $ _POST [ 'page' ] : 1 ; $ postData = $ this -> getImportBatch ( $ page ) ; json_response ( $ postData ) ; } | Fetches the next group of posts to process |
34,982 | public function cancelAction ( ) { BatchManager :: instance ( ) -> setShouldCancel ( $ this -> batchIdentifier ( ) , true ) ; call_user_func ( [ $ this -> batchProcessClassName ( ) , 'cancelAll' ] ) ; json_response ( [ 'status' => 'ok' ] ) ; } | Cancels the batch |
34,983 | public function toolEnabled ( $ toolName ) { if ( isset ( $ this -> tools [ $ toolName ] ) ) return $ this -> tools [ $ toolName ] -> enabled ( ) ; return false ; } | Determines if a tool is enabled or not |
34,984 | public function init_hooks ( ) { add_filter ( 'user_has_cap' , array ( $ this , 'filter_user_has_cap' ) , 10 , 4 ) ; add_filter ( 'map_meta_cap' , array ( $ this , 'filter_map_meta_cap' ) , 10 , 4 ) ; add_filter ( 'user_row_actions' , array ( $ this , 'filter_user_row_actions' ) , 10 , 2 ) ; add_action ( 'plugins_loade... | Sets up all the filters and actions . |
34,985 | public function action_plugins_loaded ( ) { if ( ! defined ( 'USER_SWITCHING_COOKIE' ) ) { define ( 'USER_SWITCHING_COOKIE' , 'wordpress_user_sw_' . COOKIEHASH ) ; } if ( ! defined ( 'USER_SWITCHING_SECURE_COOKIE' ) ) { define ( 'USER_SWITCHING_SECURE_COOKIE' , 'wordpress_user_sw_secure_' . COOKIEHASH ) ; } if ( ! defi... | Defines the names of the cookies used by User Switching . |
34,986 | public function action_personal_options ( WP_User $ user ) { $ link = self :: maybe_switch_url ( $ user ) ; if ( ! $ link ) { return ; } ?> <tr> <th scope="row"> <?php echo esc_html_x ( 'User Switching' , 'User Switching title on user profile screen' , 'user-switching' ) ; ?> </th> <td><a href=" <?php echo esc_url ... | Outputs the Switch To link on the user editing screen if the current user has permission to switch to them . |
34,987 | public static function get_old_user ( ) { $ cookie = user_switching_get_olduser_cookie ( ) ; if ( ! empty ( $ cookie ) ) { $ old_user_id = wp_validate_auth_cookie ( $ cookie , 'logged_in' ) ; if ( $ old_user_id ) { return get_userdata ( $ old_user_id ) ; } } return false ; } | Validates the old user cookie and returns its user data . |
34,988 | public static function authenticate_old_user ( WP_User $ user ) { $ cookie = user_switching_get_auth_cookie ( ) ; if ( ! empty ( $ cookie ) ) { if ( self :: secure_auth_cookie ( ) ) { $ scheme = 'secure_auth' ; } else { $ scheme = 'auth' ; } $ old_user_id = wp_validate_auth_cookie ( end ( $ cookie ) , $ scheme ) ; if (... | Authenticates an old user by verifying the latest entry in the auth cookie . |
34,989 | public function filter_user_row_actions ( array $ actions , WP_User $ user ) { $ link = self :: maybe_switch_url ( $ user ) ; if ( ! $ link ) { return $ actions ; } $ actions [ 'switch_to_user' ] = '<a href="' . esc_url ( $ link ) . '">' . esc_html__ ( 'Switch To' , 'user-switching' ) . '</a>' ; return $ actions ;... | Adds a Switch To link to each list of user actions on the Users screen . |
34,990 | public function action_bp_button ( ) { $ user = null ; if ( bp_is_user ( ) ) { $ user = get_userdata ( bp_displayed_user_id ( ) ) ; } elseif ( bp_is_members_directory ( ) ) { $ user = get_userdata ( bp_get_member_user_id ( ) ) ; } if ( ! $ user ) { return ; } $ link = self :: maybe_switch_url ( $ user ) ; if ( ! $ link... | Adds a Switch To link to each member s profile page and profile listings in BuddyPress . |
34,991 | public function action_bbpress_button ( ) { $ user = get_userdata ( bbp_get_user_id ( ) ) ; if ( ! $ user ) { return ; } $ link = self :: maybe_switch_url ( $ user ) ; if ( ! $ link ) { return ; } $ link = add_query_arg ( array ( 'redirect_to' => urlencode ( bbp_get_user_profile_url ( $ user -> ID ) ) , ) , $ link ) ; ... | Adds a Switch To link to each member s profile page in bbPress . |
34,992 | public static function maybe_switch_url ( WP_User $ user ) { $ old_user = self :: get_old_user ( ) ; if ( $ old_user && ( $ old_user -> ID === $ user -> ID ) ) { return self :: switch_back_url ( $ old_user ) ; } elseif ( current_user_can ( 'switch_to_user' , $ user -> ID ) ) { return self :: switch_to_url ( $ user ) ; ... | Returns the switch to or switch back URL for a given user . |
34,993 | public static function forget_woocommerce_session ( WooCommerce $ wc ) { if ( ! property_exists ( $ wc , 'session' ) ) { return false ; } if ( ! method_exists ( $ wc -> session , 'forget_session' ) ) { return false ; } $ wc -> session -> forget_session ( ) ; } | Instructs WooCommerce to forget the session for the current user without deleting it . |
34,994 | public function filter_user_has_cap ( array $ user_caps , array $ required_caps , array $ args , WP_User $ user ) { if ( 'switch_to_user' === $ args [ 0 ] ) { if ( array_key_exists ( 'switch_users' , $ user_caps ) ) { $ user_caps [ 'switch_to_user' ] = $ user_caps [ 'switch_users' ] ; return $ user_caps ; } $ user_caps... | Filters a user s capabilities so they can be altered at runtime . |
34,995 | public function filter_map_meta_cap ( array $ required_caps , $ cap , $ user_id , array $ args ) { if ( ( 'switch_to_user' === $ cap ) && ( $ args [ 0 ] === $ user_id ) ) { $ required_caps [ ] = 'do_not_allow' ; } return $ required_caps ; } | Filters the required primitive capabilities for the given primitive or meta capability . |
34,996 | public function switch_to_user ( $ user_id ) { $ user_id = $ this -> getUserIdFromLogin ( $ user_id ) ; PHPUnit_Framework_Assert :: assertNotEmpty ( $ user_id ) ; $ this -> visitPath ( sprintf ( 'wp-admin/user-edit.php?user_id=%d' , $ user_id ) ) ; $ this -> getSession ( ) -> getPage ( ) -> clickLink ( "Switch\xc2\xa0T... | Switch to the specified user |
34,997 | public function logged_in_as ( $ user_id ) { $ display_name = $ this -> getUserDataFromUsername ( 'display_name' , $ user_id ) ; PHPUnit_Framework_Assert :: assertNotEmpty ( $ display_name ) ; $ this -> visitPath ( '/' ) ; PHPUnit_Framework_Assert :: assertTrue ( $ this -> getSession ( ) -> getPage ( ) -> hasContent ( ... | Verify that the user is logged in as the specified user |
34,998 | public function getTableName ( $ string , $ prefix = '' , $ prefixRequired = false ) { if ( ! empty ( $ prefix ) && strpos ( $ string , $ prefix ) === 0 ) { $ string = substr ( $ string , strlen ( $ prefix ) ) ; } elseif ( $ prefixRequired ) { $ string = '' ; } return $ string ; } | Formats a class name to a specific value stripping the prefix if specified . |
34,999 | public function getClassName ( $ string ) { if ( is_string ( $ string ) && $ strArray = explode ( '_' , $ string ) ) { $ return = '' ; foreach ( $ strArray as $ k => $ v ) { $ return .= strtoupper ( substr ( $ v , 0 , 1 ) ) . substr ( $ v , 1 ) . '' ; } $ string = $ return ; } return trim ( $ string ) ; } | Gets a class name from a table name by splitting the string by _ and capitalizing each token . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.