idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
9,100 | private function findClasspathAndClass ( $ class ) { if ( false !== $ pos = strrpos ( $ class , '\\' ) ) { $ classpath = str_replace ( '\\' , DIRECTORY_SEPARATOR , substr ( $ class , 0 , $ pos ) ) . DIRECTORY_SEPARATOR ; $ classname = substr ( $ class , $ pos + 1 ) ; return array ( $ classpath , $ classname ) ; } $ cla... | Finds classpath and classname from class . |
9,101 | private function resolveArgument ( $ value ) { if ( is_string ( $ value ) && 0 === mb_strpos ( $ value , '@' ) ) { return $ this -> container -> get ( mb_substr ( $ value , 1 ) ) ; } return $ value ; } | Attempts to resolve singular argument from container . |
9,102 | private function replaceStyle ( $ match ) { if ( ! $ this -> isDecorated ( ) ) { return $ match [ 2 ] ; } if ( $ this -> hasStyle ( $ match [ 1 ] ) ) { $ style = $ this -> getStyle ( $ match [ 1 ] ) ; } else { return $ match [ 0 ] ; } return $ style -> apply ( $ match [ 2 ] ) ; } | Replaces style of the output . |
9,103 | public function printSnippets ( SnippetPrinter $ printer , array $ snippets ) { $ printableSnippets = array ( ) ; foreach ( $ snippets as $ snippet ) { foreach ( $ snippet -> getTargets ( ) as $ target ) { $ targetSnippets = array ( ) ; if ( isset ( $ printableSnippets [ $ target ] ) ) { $ targetSnippets = $ printableS... | Prints snippets using provided printer . |
9,104 | public function printUndefinedSteps ( SnippetPrinter $ printer , array $ undefinedSteps ) { $ printableSteps = array ( ) ; foreach ( $ undefinedSteps as $ undefinedStep ) { $ suiteName = $ undefinedStep -> getEnvironment ( ) -> getSuite ( ) -> getName ( ) ; $ step = $ undefinedStep -> getStep ( ) ; if ( ! isset ( $ pri... | Prints undefined steps using provided printer . |
9,105 | private function appendSnippet ( AggregateSnippet $ snippet ) { foreach ( $ this -> appenders as $ appender ) { if ( ! $ appender -> supportsSnippet ( $ snippet ) ) { continue ; } $ appender -> appendSnippet ( $ snippet ) ; } } | Appends snippet to appropriate targets . |
9,106 | private function applySimpleTransformations ( array $ transformations , DefinitionCall $ definitionCall , $ index , $ value ) { usort ( $ transformations , function ( SimpleArgumentTransformation $ t1 , SimpleArgumentTransformation $ t2 ) { if ( $ t1 -> getPriority ( ) == $ t2 -> getPriority ( ) ) { return 0 ; } return... | Apply simple argument transformations in priority order . |
9,107 | private function transform ( DefinitionCall $ definitionCall , Transformation $ transformation , $ index , $ value ) { if ( is_object ( $ value ) && ! $ value instanceof ArgumentInterface ) { return $ value ; } if ( $ transformation instanceof SimpleArgumentTransformation && $ transformation -> supportsDefinitionAndArg... | Transforms argument value using registered transformers . |
9,108 | private function splitSimpleAndNormalTransformations ( array $ transformations ) { return array_reduce ( $ transformations , function ( $ acc , $ t ) { return array ( $ t instanceof SimpleArgumentTransformation ? array_merge ( $ acc [ 0 ] , array ( $ t ) ) : $ acc [ 0 ] , ! $ t instanceof SimpleArgumentTransformation ?... | Splits transformations into simple and normal ones . |
9,109 | protected function loadRootNodeListener ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Output\Node\EventListener\AST\StepListener' , array ( new Reference ( 'output.node.printer.progress.step' ) ) ) ; $ container -> setDefinition ( self :: ROOT_LISTENER_ID , $ definition ) ; } | Loads progress formatter node event listener . |
9,110 | protected function loadCorePrinters ( ContainerBuilder $ container ) { $ definition = new Definition ( 'Behat\Behat\Output\Node\Printer\CounterPrinter' , array ( new Reference ( self :: RESULT_TO_STRING_CONVERTER_ID ) , new Reference ( TranslatorExtension :: TRANSLATOR_ID ) , ) ) ; $ container -> setDefinition ( 'outpu... | Loads feature scenario and step printers . |
9,111 | public function call ( $ closure , array $ parameters = [ ] , $ buffer = false ) { if ( $ buffer ) { \ ob_start ( ) ; } $ rslt = \ call_user_func_array ( $ closure , $ parameters ) ; if ( $ buffer ) { return \ ob_get_clean ( ) ; } return $ rslt ; } | Call the given Closure with buffering support . |
9,112 | public function start ( ) { $ command = $ this -> buildCommand ( ) ; $ process = Process :: fromStringCommand ( $ command ) ; $ this -> setProcess ( $ process ) ; $ this -> getProcess ( ) -> start ( function ( $ type , $ content ) : void { $ this -> wholeOutput [ ] = $ content ; } ) ; if ( $ this -> preventOverlapping ... | Start the event execution . |
9,113 | public function cron ( string $ expression ) : self { $ parts = \ preg_split ( '/\s/' , $ expression , - 1 , PREG_SPLIT_NO_EMPTY ) ; if ( \ count ( $ parts ) > 5 ) { throw new TaskException ( "Expression '{$expression}' has more than five parts and this is not allowed." ) ; } $ this -> expression = $ expression ; retur... | The Cron expression representing the event s frequency . |
9,114 | public function on ( $ date ) { $ parsedDate = \ date_parse ( $ date ) ; $ segments = \ array_intersect_key ( $ parsedDate , $ this -> fieldsPosition ) ; if ( $ parsedDate [ 'year' ] ) { $ this -> skip ( static function ( ) use ( $ parsedDate ) { return ( int ) \ date ( 'Y' ) !== $ parsedDate [ 'year' ] ; } ) ; } forea... | Schedule the event to run on a certain date . |
9,115 | public function weeklyOn ( $ day , $ time = '0:0' ) : self { $ this -> dailyAt ( $ time ) ; return $ this -> spliceIntoPosition ( 5 , ( string ) $ day ) ; } | Schedule the event to run weekly on a given day and time . |
9,116 | public function days ( $ days ) : self { $ days = \ is_array ( $ days ) ? $ days : \ func_get_args ( ) ; return $ this -> spliceIntoPosition ( 5 , \ implode ( ',' , $ days ) ) ; } | Set the days of the week the command should run on . |
9,117 | public function minute ( $ value ) : self { $ value = \ is_array ( $ value ) ? $ value : \ func_get_args ( ) ; return $ this -> spliceIntoPosition ( 1 , \ implode ( ',' , $ value ) ) ; } | Set minute for the cron job . |
9,118 | public function every ( $ unit = null , $ value = null ) : self { if ( null === $ unit || ! isset ( $ this -> fieldsPosition [ $ unit ] ) ) { return $ this ; } $ value = ( 1 === ( int ) $ value ) ? '*' : '*/' . $ value ; return $ this -> spliceIntoPosition ( $ this -> fieldsPosition [ $ unit ] , $ value ) -> applyMask ... | Another way to the frequency of the cron job . |
9,119 | public function refreshLock ( ) : void { if ( ! $ this -> preventOverlapping ) { return ; } $ lock = $ this -> createLockObject ( ) ; $ remainingLifetime = $ lock -> getRemainingLifetime ( ) ; if ( null === $ remainingLifetime ) { return ; } $ lockRefreshNeeded = $ remainingLifetime < 15 ; if ( $ lockRefreshNeeded ) { ... | If this event is prevented from overlapping this method should be called regularly to refresh the lock . |
9,120 | protected function createLockObject ( ) { $ this -> checkLockFactory ( ) ; if ( null === $ this -> lock && null !== $ this -> lockFactory ) { $ ttl = 30 ; $ this -> lock = $ this -> lockFactory -> createLock ( $ this -> lockKey ( ) , $ ttl ) ; } return $ this -> lock ; } | Get the symfony lock object for the task . |
9,121 | protected function serializeClosure ( Closure $ closure ) { $ closure = ( new Serializer ( ) ) -> serialize ( $ closure ) ; $ serializedClosure = \ http_build_query ( [ $ closure ] ) ; $ crunzRoot = CRUNZ_BIN ; return PHP_BINARY . " {$crunzRoot} closure:run {$serializedClosure}" ; } | Convert closure to an executable command . |
9,122 | protected function applyMask ( $ unit ) { $ cron = \ explode ( ' ' , $ this -> expression ) ; $ mask = [ '0' , '0' , '1' , '1' , '*' , '*' ] ; $ fpos = $ this -> fieldsPosition [ $ unit ] - 1 ; \ array_splice ( $ cron , 0 , $ fpos , \ array_slice ( $ mask , 0 , $ fpos ) ) ; return $ this -> cron ( \ implode ( ' ' , $ c... | Mask a cron expression . |
9,123 | protected function save ( ) { $ filename = Path :: create ( [ $ this -> outputPath ( ) , $ this -> outputFile ( ) ] ) ; return ( bool ) \ file_put_contents ( $ filename -> toString ( ) , $ this -> stub ) ; } | Save the generate task skeleton into a file . |
9,124 | protected function outputPath ( ) { $ source = $ this -> config -> getSourcePath ( ) ; $ destination = $ this -> ask ( 'Where do you want to save the file? (Press enter for the current directory)' ) ; $ outputPath = null !== $ destination ? $ destination : $ source ; if ( ! \ file_exists ( $ outputPath ) ) { \ mkdir ( ... | Return the output path . |
9,125 | protected function getStub ( ) { $ projectRootDirectory = $ this -> filesystem -> projectRootDirectory ( ) ; $ path = Path :: fromStrings ( $ projectRootDirectory , 'src' , 'Stubs' , \ ucfirst ( $ this -> type ( ) . 'Task.php' ) ) ; return $ this -> filesystem -> readContent ( $ path -> toString ( ) ) ; } | Get the task stub . |
9,126 | protected function replaceFrequency ( ) { $ this -> stub = \ str_replace ( 'DummyFrequency' , \ rtrim ( $ this -> options [ 'frequency' ] , '()' ) , $ this -> stub ) ; return $ this ; } | Replace frequency . |
9,127 | protected function replaceConstraint ( ) { $ this -> stub = \ str_replace ( 'DummyConstraint' , \ rtrim ( $ this -> options [ 'constraint' ] , '()' ) , $ this -> stub ) ; return $ this ; } | Replace constraint . |
9,128 | public function run ( $ command , array $ parameters = [ ] ) { if ( \ is_string ( $ command ) && \ count ( $ parameters ) ) { $ command .= ' ' . $ this -> compileParameters ( $ parameters ) ; } $ this -> events [ ] = $ event = new Event ( $ this -> id ( ) , $ command ) ; return $ event ; } | Add a new event to the schedule object . |
9,129 | public function events ( array $ events = null ) { if ( null !== $ events ) { return $ this -> events = $ events ; } return $ this -> events ; } | Get or set the events of the schedule object . |
9,130 | protected function id ( ) { while ( true ) { $ id = \ uniqid ( 'crunz' , true ) ; if ( ! \ array_key_exists ( $ id , $ this -> events ) ) { return $ id ; } } } | Generate a unique task id . |
9,131 | public static function validateInput ( $ caller , $ input ) { if ( null !== $ input ) { if ( \ is_resource ( $ input ) ) { return $ input ; } if ( \ is_string ( $ input ) ) { return $ input ; } if ( \ is_scalar ( $ input ) ) { return ( string ) $ input ; } if ( $ input instanceof Process ) { return $ input -> getIterat... | Validates and normalizes a Process input . |
9,132 | public function addStream ( $ path , $ level , $ bubble = true ) { $ handler = new StreamHandler ( $ path , $ this -> parseLevel ( $ level ) , $ bubble ) ; $ handler -> setFormatter ( $ this -> getDefaultFormatter ( ) ) ; $ this -> logger -> pushHandler ( $ handler ) ; return $ this ; } | Create a neaw stream handler . |
9,133 | protected function getDefaultFormatter ( ) { $ allowLinebreaks = $ this -> configuration -> get ( 'log_allow_line_breaks' ) ; return new LineFormatter ( null , null , $ allowLinebreaks , false ) ; } | Get a default Monolog formatter instance . |
9,134 | public function handle ( OutputInterface $ output , array $ schedules = [ ] ) : void { $ this -> schedules = $ schedules ; $ this -> output = $ output ; foreach ( $ this -> schedules as $ schedule ) { $ this -> consoleLogger -> debug ( "Invoke Schedule's ping before" ) ; $ this -> pingBefore ( $ schedule ) ; $ this -> ... | Handle an array of Schedule objects . |
9,135 | protected function start ( Event $ event ) : void { if ( ! $ event -> nullOutput ( ) ) { if ( ! $ event -> shouldAppendOutput ) { $ f = @ \ fopen ( $ event -> output , 'r+' ) ; if ( false !== $ f ) { \ ftruncate ( $ f , 0 ) ; \ fclose ( $ f ) ; } } $ event -> logger = $ this -> loggerFactory -> create ( [ 'info' => $ e... | Run an event process . |
9,136 | protected function manageStartedEvents ( ) : void { while ( $ this -> schedules ) { foreach ( $ this -> schedules as $ scheduleKey => $ schedule ) { $ events = $ schedule -> events ( ) ; $ refreshLocks = ( \ mt_rand ( 1 , 100 ) <= 10 ) ; foreach ( $ events as $ eventKey => $ event ) { if ( $ refreshLocks ) { $ event ->... | Manage the running processes . |
9,137 | protected function invoke ( array $ callbacks = [ ] , array $ parameters = [ ] ) { $ output = '' ; foreach ( $ callbacks as $ callback ) { $ output .= $ this -> invoker -> call ( $ callback , $ parameters , true ) ; } return $ output ; } | Invoke an array of callables . |
9,138 | protected function formatEventError ( Event $ event ) { return $ event -> description . '(' . $ event -> getCommandForDisplay ( ) . ') ' . PHP_EOL . $ event -> wholeOutput ( ) . PHP_EOL ; } | Format the event error message . |
9,139 | private function getMailer ( ) : \ Swift_Mailer { if ( $ this -> mailer ) { return $ this -> mailer ; } switch ( $ this -> config ( 'mailer.transport' ) ) { case 'smtp' : $ transport = $ this -> getSmtpTransport ( ) ; break ; case 'mail' : throw new MailerException ( "'mail' transport is no longer supported, please use... | Return the proper mailer . |
9,140 | private function getSmtpTransport ( ) : \ Swift_SmtpTransport { $ object = new \ Swift_SmtpTransport ( $ this -> config ( 'smtp.host' ) , $ this -> config ( 'smtp.port' ) , $ this -> config ( 'smtp.encryption' ) ) ; return $ object -> setUsername ( $ this -> config ( 'smtp.username' ) ) -> setPassword ( $ this -> confi... | Get the SMTP transport . |
9,141 | private function getMessage ( string $ subject , string $ message ) : \ Swift_Message { $ messageObject = new \ Swift_Message ( $ subject , $ message ) ; $ messageObject -> setFrom ( [ $ this -> config ( 'mailer.sender_email' ) => $ this -> config ( 'mailer.sender_name' ) ] ) -> setTo ( $ this -> config ( 'mailer.recip... | Prepare a swift message object . |
9,142 | public function get ( string $ key , $ default = null ) { if ( null === $ this -> config ) { $ this -> config = $ this -> configurationParser -> parseConfig ( ) ; } if ( \ array_key_exists ( $ key , $ this -> config ) ) { return $ this -> config [ $ key ] ; } $ parts = \ explode ( '.' , $ key ) ; $ value = $ this -> co... | Return a parameter based on a key . |
9,143 | public function outer_sections_css ( ) { echo '<style>' ; $ css = '' ; if ( ! empty ( Kirki :: $ sections ) ) { foreach ( Kirki :: $ sections as $ section_args ) { if ( isset ( $ section_args [ 'id' ] ) && isset ( $ section_args [ 'type' ] ) && 'outer' === $ section_args [ 'type' ] || 'kirki-outer' === $ section_args [... | Generate CSS for the outer sections . These are by default hidden we need to expose them . |
9,144 | protected function get_root_value ( $ default = null ) { $ id_base = $ this -> id_data [ 'base' ] ; $ user_meta = get_user_meta ( get_current_user_id ( ) ) ; $ single_meta = get_user_meta ( get_current_user_id ( ) , $ id_base , true ) ; if ( isset ( $ user_meta [ $ id_base ] ) ) { return $ single_meta ; } return $ defa... | Get the root value for a setting especially for multidimensional ones . |
9,145 | protected function set_root_value ( $ value ) { $ id_base = $ this -> id_data [ 'base' ] ; delete_user_meta ( get_current_user_id ( ) , $ id_base ) ; return update_user_meta ( get_current_user_id ( ) , $ id_base , $ value ) ; } | Set the root value for a setting especially for multidimensional ones . |
9,146 | public function field_add_setting_args ( $ args ) { if ( ! isset ( $ args [ 'transport' ] ) ) { return $ args ; } if ( 'postMessage' === $ args [ 'transport' ] && isset ( $ args [ 'js_vars' ] ) && ! empty ( $ args [ 'js_vars' ] ) ) { $ this -> fields [ ] = $ args ; return $ args ; } if ( 'auto' === $ args [ 'transport'... | Filter setting args before adding the setting to the customizer . |
9,147 | public function postmessage ( ) { wp_enqueue_script ( 'kirki_auto_postmessage' , URL :: get_from_path ( __DIR__ . '/assets/scripts/script.js' ) , [ 'jquery' , 'customize-preview' ] , KIRKI_VERSION , true ) ; $ fields = array_merge ( Kirki :: $ fields , $ this -> fields ) ; $ data = [ ] ; foreach ( $ fields as $ field )... | Enqueues the postMessage script and adds variables to it using the wp_localize_script function . The rest is handled via JS . |
9,148 | protected function apply_sanitize_callback ( $ output , $ value ) { if ( isset ( $ output [ 'sanitize_callback' ] ) && null !== $ output [ 'sanitize_callback' ] ) { if ( ! is_callable ( $ output [ 'sanitize_callback' ] ) ) { return $ value ; } return call_user_func ( $ output [ 'sanitize_callback' ] , $ this -> value )... | If we have a sanitize_callback defined apply it to the value . |
9,149 | protected function parse_output ( ) { foreach ( $ this -> output as $ output ) { $ skip = false ; $ value = $ this -> apply_sanitize_callback ( $ output , $ this -> value ) ; if ( '' === $ this -> value ) { $ skip = true ; } if ( isset ( $ output [ 'exclude' ] ) && is_array ( $ output [ 'exclude' ] ) ) { foreach ( $ ou... | Parses the output arguments . Calls the process_output method for each of them . |
9,150 | protected function process_output ( $ output , $ value ) { if ( ! isset ( $ output [ 'element' ] ) || ! isset ( $ output [ 'property' ] ) ) { return ; } $ output [ 'media_query' ] = ( isset ( $ output [ 'media_query' ] ) ) ? $ output [ 'media_query' ] : 'global' ; $ output [ 'prefix' ] = ( isset ( $ output [ 'prefix' ]... | Parses an output and creates the styles array for it . |
9,151 | protected function process_property_value ( $ property , $ value ) { $ properties = apply_filters ( 'kirki_output_property_classnames' , [ 'font-family' => '\Kirki\Modules\CSS\Property\Font_Family' , 'background-image' => '\Kirki\Modules\CSS\Property\Background_Image' , 'background-position' => '\Kirki\Modules\CSS\Prop... | Some CSS properties are unique . We need to tweak the value to make everything works as expected . |
9,152 | protected function process_value ( $ value , $ output ) { if ( isset ( $ output [ 'property' ] ) ) { return $ this -> process_property_value ( $ output [ 'property' ] , $ value ) ; } return $ value ; } | Returns the value . |
9,153 | public static function get_instance ( $ path ) { $ path = \ wp_normalize_path ( $ path ) ; if ( ! isset ( self :: $ instances [ $ path ] ) ) { self :: $ instances [ $ path ] = new self ( $ path ) ; } return self :: $ instances [ $ path ] ; } | Gets an instance based on the path . |
9,154 | public function get_url ( ) { $ this -> url = \ str_replace ( ABSPATH , \ trailingslashit ( \ site_url ( ) ) , $ this -> path ) ; if ( false !== \ strpos ( $ this -> path , self :: $ content_path ) ) { $ this -> url = \ str_replace ( self :: $ content_path , self :: $ content_url , $ this -> path ) ; } if ( $ this -> i... | Get the file URL . |
9,155 | public static function sanitize ( $ value ) { if ( class_exists ( '\Kirki\Field\Color' ) ) { return \ Kirki \ Field \ Color :: sanitize ( $ value ) ; } return esc_attr ( $ value ) ; } | Sanitization callback . |
9,156 | public static function add_module ( $ module ) { if ( ! in_array ( $ module , self :: $ modules , true ) ) { self :: $ modules [ ] = $ module ; } } | Add a module . |
9,157 | public static function remove_module ( $ module ) { $ key = array_search ( $ module , self :: $ modules , true ) ; if ( false !== $ key ) { unset ( self :: $ modules [ $ key ] ) ; } } | Remove a module . |
9,158 | protected function set_preset ( ) { $ this -> preset = $ this -> choices ; foreach ( $ this -> choices as $ key => $ args ) { $ this -> choices [ $ key ] = $ args [ 'label' ] ; } } | Set the preset . |
9,159 | protected function row_label ( $ args ) { if ( isset ( $ args [ 'row_label' ] ) && is_array ( $ args [ 'row_label' ] ) && ! empty ( $ args [ 'row_label' ] ) ) { if ( isset ( $ args [ 'row_label' ] [ 'type' ] ) && ( 'text' === $ args [ 'row_label' ] [ 'type' ] || 'field' === $ args [ 'row_label' ] [ 'type' ] ) ) { $ thi... | Validate row - labels . |
9,160 | public static function css ( $ field ) { self :: $ settings = $ field [ 'settings' ] ; self :: $ callback = isset ( $ field [ 'sanitize_callback' ] ) ? $ field [ 'sanitize_callback' ] : '' ; self :: $ field_type = $ field [ 'type' ] ; self :: $ field_type = ( isset ( $ field [ 'choices' ] ) && isset ( $ field [ 'choice... | Get the CSS for a field . |
9,161 | public static function styles_parse ( $ css = [ ] ) { $ css = apply_filters ( 'kirki_styles_array' , $ css ) ; $ final_css = '' ; if ( ! is_array ( $ css ) || empty ( $ css ) ) { return '' ; } foreach ( $ css as $ media_query => $ styles ) { $ final_css .= ( 'global' !== $ media_query ) ? $ media_query . '{' : '' ; for... | Gets the array of generated styles and creates the minimized inline CSS . |
9,162 | public static function add_prefixes ( $ css ) { if ( is_array ( $ css ) ) { foreach ( $ css as $ media_query => $ elements ) { foreach ( $ elements as $ element => $ style_array ) { foreach ( $ style_array as $ property => $ value ) { if ( is_string ( $ property ) && in_array ( $ property , [ 'border-radius' , 'box-sha... | Add prefixes if necessary . |
9,163 | protected function set_choices ( ) { if ( ! is_array ( $ this -> choices ) ) { $ this -> choices = [ ] ; } $ this -> choices = wp_parse_args ( $ this -> choices , [ 'on' => esc_html__ ( 'On' , 'kirki' ) , 'off' => esc_html__ ( 'Off' , 'kirki' ) , 'round' => false , ] ) ; } | Sets the control choices . |
9,164 | public static function add_panel ( $ id = '' , $ args = [ ] ) { $ args [ 'id' ] = $ id ; if ( ! isset ( $ args [ 'description' ] ) ) { $ args [ 'description' ] = '' ; } if ( ! isset ( $ args [ 'priority' ] ) ) { $ args [ 'priority' ] = 10 ; } if ( ! isset ( $ args [ 'type' ] ) ) { $ args [ 'type' ] = 'default' ; } if (... | Create a new panel . |
9,165 | public static function remove_panel ( $ id = '' ) { if ( ! in_array ( $ id , self :: $ panels_to_remove , true ) ) { self :: $ panels_to_remove [ ] = $ id ; } } | Remove a panel . |
9,166 | public static function remove_section ( $ id = '' ) { if ( ! in_array ( $ id , self :: $ sections_to_remove , true ) ) { self :: $ sections_to_remove [ ] = $ id ; } } | Remove a section . |
9,167 | public static function add_field ( $ config_id , $ args = [ ] ) { if ( doing_action ( 'customize_register' ) ) { _doing_it_wrong ( __METHOD__ , esc_html__ ( 'Kirki fields should not be added on customize_register. Please add them directly, or on init.' , 'kirki' ) , '3.0.10' ) ; } if ( ! isset ( $ args [ 'type' ] ) ) {... | Create a new field . |
9,168 | public static function remove_control ( $ id ) { if ( ! in_array ( $ id , self :: $ controls_to_remove , true ) ) { self :: $ controls_to_remove [ ] = $ id ; } } | Remove a control . |
9,169 | public static function get_config_param ( $ id , $ param ) { if ( ! isset ( self :: $ config [ $ id ] ) || ! isset ( self :: $ config [ $ id ] [ $ param ] ) ) { return '' ; } return self :: $ config [ $ id ] [ $ param ] ; } | Gets a parameter for a config - id . |
9,170 | public static function sanitize ( $ value ) { if ( ! is_array ( $ value ) ) { return [ ] ; } foreach ( $ value as $ key => $ val ) { $ value [ $ key ] = Color :: sanitize ( $ val ) ; } return $ value ; } | The method that will be used as a sanitize_callback . |
9,171 | public function add_section ( $ args ) { global $ wp_customize ; $ section_classname = 'WP_Customize_Section' ; if ( isset ( $ args [ 'type' ] ) && array_key_exists ( $ args [ 'type' ] , $ this -> section_types ) ) { $ section_classname = $ this -> section_types [ $ args [ 'type' ] ] ; } if ( isset ( $ args [ 'type' ] ... | Adds the section using the WordPress Customizer API . |
9,172 | public function resource_hints ( $ urls , $ relation_type ) { $ fonts_to_load = $ this -> googlefonts -> fonts ; if ( ! empty ( $ fonts_to_load ) && 'preconnect' === $ relation_type ) { $ urls [ ] = [ 'href' => 'https://fonts.gstatic.com' , 'crossorigin' , ] ; } return $ urls ; } | Add preconnect for Google Fonts . |
9,173 | public function the_css ( ) { foreach ( $ this -> fonts_to_load as $ font ) { $ family = str_replace ( ' ' , '+' , trim ( $ font [ 'family' ] ) ) ; $ weights = join ( ',' , $ font [ 'weights' ] ) ; $ url = "https://fonts.googleapis.com/css?family={$family}:{$weights}&subset=cyrillic,cyrillic-ext,devanagari,greek,greek-... | Webfont Loader script for Google Fonts . |
9,174 | private function use_local_files ( $ css ) { preg_match_all ( '/https\:.*?\.woff/' , $ css , $ matches ) ; $ matches = array_shift ( $ matches ) ; foreach ( $ matches as $ match ) { if ( 0 === strpos ( $ match , 'https://fonts.gstatic.com' ) ) { $ new_url = Helper :: download_font_file ( $ match ) ; if ( $ new_url ) { ... | Downloads font - files locally and uses the local files instead of the ones from Google s servers . This addresses any and all GDPR concerns as well as firewalls that exist in some parts of the world . |
9,175 | public function load_textdomain ( ) { if ( null !== $ this -> get_path ( ) ) { load_textdomain ( $ this -> textdomain , $ this -> get_path ( ) ) ; } load_plugin_textdomain ( $ this -> textdomain , false , dirname ( KIRKI_PLUGIN_FILE ) . '/languages' ) ; } | Load the plugin textdomain |
9,176 | protected function get_path ( ) { $ path_found = false ; $ found_path = null ; foreach ( $ this -> get_paths ( ) as $ path ) { if ( $ path_found ) { continue ; } $ path = wp_normalize_path ( $ path ) ; if ( file_exists ( $ path ) ) { $ path_found = true ; $ found_path = $ path ; } } return $ found_path ; } | Gets the path to a translation file . |
9,177 | protected function get_paths ( ) { return [ WP_LANG_DIR . '/' . $ this -> textdomain . '-' . get_locale ( ) . '.mo' , dirname ( KIRKI_PLUGIN_FILE ) . '/languages/' . $ this -> textdomain . '-' . get_locale ( ) . '.mo' , ] ; } | Returns an array of paths where translation files may be located . |
9,178 | public function override_load_textdomain ( $ override , $ domain , $ mofile ) { global $ l10n ; if ( isset ( $ l10n [ $ this -> get_theme_textdomain ( ) ] ) ) { $ l10n [ 'kirki' ] = $ l10n [ $ this -> get_theme_textdomain ( ) ] ; } if ( 'kirki' === $ domain ) { return true ; } return $ override ; } | Allows overriding the kirki textdomain from a theme . |
9,179 | private function get_theme_textdomain ( ) { if ( '' === $ this -> theme_textdomain ) { $ theme = wp_get_theme ( ) ; $ this -> theme_textdomain = $ theme -> get ( 'TextDomain' ) ; if ( ! $ this -> theme_textdomain ) { $ this -> theme_textdomain = get_template ( ) ; } } return $ this -> theme_textdomain ; } | Get the theme s textdomain . |
9,180 | public static function sanitize_hex ( $ color = '#FFFFFF' , $ hash = true ) { if ( ! $ hash ) { return ltrim ( self :: sanitize_color ( $ color , 'hex' ) , '#' ) ; } return self :: sanitize_color ( $ color , 'hex' ) ; } | A proxy for the sanitize_color method . |
9,181 | public static function sanitize_color ( $ color = '' , $ mode = 'auto' ) { if ( is_string ( $ color ) && 'transparent' == trim ( $ color ) ) { return 'transparent' ; } $ obj = ariColor :: newColor ( $ color ) ; if ( 'auto' == $ mode ) { $ mode = $ obj -> mode ; } return $ obj -> toCSS ( $ mode ) ; } | Sanitize colors . Determine if the current value is a hex or an rgba color and call the appropriate method . |
9,182 | public static function get_rgb ( $ color , $ implode = false ) { $ obj = ariColor :: newColor ( $ color ) ; if ( $ implode ) { return $ obj -> toCSS ( 'rgb' ) ; } return array ( $ obj -> red , $ obj -> green , $ obj -> blue ) ; } | Gets the rgb value of a color . |
9,183 | public static function color_difference ( $ color_1 = '#ffffff' , $ color_2 = '#000000' ) { $ color_1 = self :: sanitize_hex ( $ color_1 , false ) ; $ color_2 = self :: sanitize_hex ( $ color_2 , false ) ; $ color_1_rgb = self :: get_rgb ( $ color_1 ) ; $ color_2_rgb = self :: get_rgb ( $ color_2 ) ; $ r_diff = max ( $... | This is a very simple algorithm that works by summing up the differences between the three color components red green and blue . A value higher than 500 is recommended for good readability . |
9,184 | public static function brightness_difference ( $ color_1 = '#ffffff' , $ color_2 = '#000000' ) { $ color_1 = self :: sanitize_hex ( $ color_1 , false ) ; $ color_2 = self :: sanitize_hex ( $ color_2 , false ) ; $ color_1_rgb = self :: get_rgb ( $ color_1 ) ; $ color_2_rgb = self :: get_rgb ( $ color_2 ) ; $ br_1 = ( 29... | This function tries to compare the brightness of the colors . A return value of more than 125 is recommended . Combining it with the color_difference function above might make sense . |
9,185 | public static function lumosity_difference ( $ color_1 = '#ffffff' , $ color_2 = '#000000' ) { $ color_1 = self :: sanitize_hex ( $ color_1 , false ) ; $ color_2 = self :: sanitize_hex ( $ color_2 , false ) ; $ color_1_rgb = self :: get_rgb ( $ color_1 ) ; $ color_2_rgb = self :: get_rgb ( $ color_2 ) ; $ l1 = 0.2126 *... | Uses the luminosity to calculate the difference between the given colors . The returned value should be bigger than 5 for best readability . |
9,186 | public function include_sections_and_panels ( ) { $ folder_path = dirname ( __FILE__ ) . '/sections/' ; $ section_types = apply_filters ( 'kirki_section_types' , [ ] ) ; foreach ( $ section_types as $ id => $ class ) { if ( ! class_exists ( $ class ) ) { $ path = wp_normalize_path ( $ folder_path . 'class-kirki-section... | Include the custom - section classes . |
9,187 | public function enqueue_scrips ( ) { wp_enqueue_style ( 'kirki-custom-sections' , URL :: get_from_path ( __DIR__ . '/assets/styles/sections.css' ) , [ ] , KIRKI_VERSION ) ; wp_enqueue_script ( 'kirki-custom-sections' , URL :: get_from_path ( __DIR__ . '/assets/scripts/sections.js' ) , [ 'jquery' , 'customize-base' , 'c... | Enqueues any necessary scripts and styles . |
9,188 | public static function sanitize ( $ value ) { foreach ( $ value as $ key => $ sub_value ) { $ value [ $ key ] = sanitize_text_field ( $ sub_value ) ; } return $ value ; } | Sanitizes the value . |
9,189 | public function filter_setting_args ( $ args , $ wp_customize ) { if ( $ args [ 'settings' ] !== $ args [ 'settings' ] ) { return $ args ; } if ( ! isset ( $ args [ 'sanitize_callback' ] ) || ! $ args [ 'sanitize_callback' ] ) { $ args [ 'sanitize_callback' ] = [ __CLASS__ , 'sanitize' ] ; if ( isset ( $ args [ 'mode' ... | Filter arguments before creating the setting . |
9,190 | public function filter_control_args ( $ args , $ wp_customize ) { if ( $ args [ 'settings' ] !== $ args [ 'settings' ] ) { return $ args ; } $ args = parent :: filter_control_args ( $ args , $ wp_customize ) ; $ args [ 'type' ] = 'kirki-color' ; if ( ! isset ( $ args [ 'choices' ] ) || ! \ is_array ( $ args [ 'choices'... | Filter arguments before creating the control . |
9,191 | public function init ( ) { global $ wp_customize ; if ( ! $ wp_customize ) { return ; } $ config = apply_filters ( 'kirki_config' , [ ] ) ; if ( isset ( $ config [ 'disable_loader' ] ) && true === $ config [ 'disable_loader' ] ) { return ; } add_action ( 'wp_footer' , [ $ this , 'add_loader_to_footer' ] ) ; add_action ... | Runs on init . |
9,192 | final private function get_control_class_name ( $ args ) { $ class_name = 'WP_Customize_Control' ; if ( array_key_exists ( $ args [ 'type' ] , self :: $ control_types ) ) { $ class_name = self :: $ control_types [ $ args [ 'type' ] ] ; } return $ class_name ; } | Get the class name of the class needed to create tis control . |
9,193 | final protected function add_control ( $ args ) { $ class_name = $ this -> get_control_class_name ( $ args ) ; $ this -> wp_customize -> add_control ( new $ class_name ( $ this -> wp_customize , $ args [ 'settings' ] , $ args ) ) ; } | Adds the control . |
9,194 | protected function set_button_labels ( ) { $ this -> button_labels = wp_parse_args ( $ this -> button_labels , [ 'select' => esc_html__ ( 'Select image' , 'kirki' ) , 'change' => esc_html__ ( 'Change image' , 'kirki' ) , 'default' => esc_html__ ( 'Default' , 'kirki' ) , 'remove' => esc_html__ ( 'Remove' , 'kirki' ) , '... | Sets the button labels . |
9,195 | public static function is_plugin ( ) { $ is_plugin = false ; if ( ! function_exists ( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php' ; } $ plugins = get_plugins ( ) ; $ _plugin = '' ; foreach ( $ plugins as $ plugin => $ args ) { if ( ! $ is_plugin && isset ( $ args [ 'Name' ] ) && ( 'Kirki' ... | Determine if Kirki is installed as a plugin . |
9,196 | public static function get_variables ( ) { $ variables = [ ] ; foreach ( Kirki :: $ fields as $ field ) { if ( isset ( $ field [ 'variables' ] ) && $ field [ 'variables' ] && ! empty ( $ field [ 'variables' ] ) ) { foreach ( $ field [ 'variables' ] as $ field_variable ) { if ( isset ( $ field_variable [ 'name' ] ) ) { ... | Build the variables . |
9,197 | public function http_request ( $ request = [ ] , $ url = '' ) { if ( self :: is_plugin ( ) || false === strpos ( $ url , 'wordpress.org' ) || ( ! isset ( $ request [ 'body' ] ) || ! isset ( $ request [ 'body' ] [ 'plugins' ] ) || ! isset ( $ request [ 'body' ] [ 'translations' ] ) || ! isset ( $ request [ 'body' ] [ 'l... | HTTP Request injection . |
9,198 | public function enqueue_styles ( ) { $ args = [ 'action' => apply_filters ( 'kirki_styles_action_handle' , 'kirki-styles' ) , ] ; if ( is_admin ( ) && ! is_customize_preview ( ) ) { $ args [ 'editor' ] = '1' ; } wp_enqueue_style ( 'kirki-styles' , add_query_arg ( $ args , site_url ( ) ) , [ ] , KIRKI_VERSION ) ; if ( s... | Enqueue the styles . |
9,199 | public function print_styles ( ) { $ configs = Kirki :: $ config ; foreach ( $ configs as $ config_id => $ args ) { if ( isset ( $ args [ 'disable_output' ] ) && true === $ args [ 'disable_output' ] ) { continue ; } $ styles = self :: loop_controls ( $ config_id ) ; $ styles = apply_filters ( "kirki_{$config_id}_dynami... | Prints the styles . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.