_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q22600 | Module.include_sections_and_panels | train | public function include_sections_and_panels() {
// Sections.
$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... | php | {
"resource": ""
} |
q22601 | Module.enqueue_scrips | train | 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__ | php | {
"resource": ""
} |
q22602 | Dimensions.sanitize | train | public static function sanitize( $value ) {
// Sanitize each sub-value separately.
| php | {
"resource": ""
} |
q22603 | Color.filter_setting_args | train | public function filter_setting_args( $args, $wp_customize ) {
if ( $args['settings'] !== $args['settings'] ) {
return $args;
}
// Set the sanitize-callback if none is defined.
if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
$args['sanitize_callback'] = [ __CLASS__, 'saniti... | php | {
"resource": ""
} |
q22604 | Color.filter_control_args | train | public function filter_control_args( $args, $wp_customize ) {
if ( $args['settings'] !== $args['settings'] ) {
return $args;
}
$args = parent::filter_control_args( $args, $wp_customize );
// Set the control-type.
$args['type'] = 'kirki-color';
// Make sure choices is an array.
if ( ! isset( $args['c... | php | {
"resource": ""
} |
q22605 | Module.init | train | public function init() {
global $wp_customize;
if ( ! $wp_customize ) {
return;
}
// Allow disabling the custom loader using the kirki_config filter.
$config = apply_filters( 'kirki_config', [] );
if ( isset( $config['disable_loader'] ) && true === $config['disable_loader'] ) {
return;
| php | {
"resource": ""
} |
q22606 | Control.get_control_class_name | train | final private function get_control_class_name( $args ) {
// Set a default class name.
$class_name = 'WP_Customize_Control';
// Get the classname from the array of control classnames.
| php | {
"resource": ""
} |
q22607 | Control.add_control | train | final protected function add_control( $args ) {
// Get the name of the class we're going to use.
$class_name = $this->get_control_class_name( $args );
// Add the | php | {
"resource": ""
} |
q22608 | Image.set_button_labels | train | 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_... | php | {
"resource": ""
} |
q22609 | Util.is_plugin | train | public static function is_plugin() {
$is_plugin = false;
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
}
// Get all plugins.
$plugins = get_plugins();
$_plugin = '';
foreach ( $plugins as $... | php | {
"resource": ""
} |
q22610 | Util.get_variables | train | public static function get_variables() {
$variables = [];
// Loop through all fields.
foreach ( Kirki::$fields as $field ) {
// Check if we have variables for this field.
if ( isset( $field['variables'] ) && $field['variables'] && ! empty( $field['variables'] ) ) {
// Loop through the array of varia... | php | {
"resource": ""
} |
q22611 | Util.http_request | train | public function http_request( $request = [], $url = '' ) {
// Early exit if installed as a plugin or not a request to wordpress.org,
// or finally if we don't have everything we need.
if (
self::is_plugin() ||
false === strpos( $url, 'wordpress.org' ) || (
! isset( $request['body'] ) ||
! isset( $r... | php | {
"resource": ""
} |
q22612 | Module.enqueue_styles | train | public function enqueue_styles() {
$args = [
'action' => apply_filters( 'kirki_styles_action_handle', 'kirki-styles' ),
];
if ( is_admin() && ! is_customize_preview() ) {
$args['editor'] = '1';
}
// Enqueue the dynamic stylesheet.
wp_enqueue_style(
'kirki-styles',
add_query_arg( $args, site_ur... | php | {
"resource": ""
} |
q22613 | Module.print_styles | train | public function print_styles() {
// Go through all configs.
$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( "kir... | php | {
"resource": ""
} |
q22614 | Module.loop_controls | train | public static function loop_controls( $config_id ) {
// Get an instance of the Generator class.
// This will make sure google fonts and backup fonts are loaded.
Generator::get_instance();
$fields = array_merge( Kirki::$fields, self::get_fields_by_config( $config_id ) );
$css = [];
// Early exit if no ... | php | {
"resource": ""
} |
q22615 | Field.filter_setting_args | train | public function filter_setting_args( $args, $wp_customize ) {
$args['type'] = 'theme_mod';
if ( isset( $args['option_type'] ) ) {
$args['type'] = $args['option_type'];
if ( isset( $args['option_name'] ) && ! empty( $args['option_name'] ) ) {
if ( isset( $args['settings'] ) | php | {
"resource": ""
} |
q22616 | Field.add_setting | train | public function add_setting( $wp_customize ) {
/**
* Allow filtering the arguments.
*
* @since 0.1
* @param array $this->args The arguments.
* @param WP_Customize_Manager $wp_customize The customizer instance.
* @return array | php | {
"resource": ""
} |
q22617 | Field.add_control | train | public function add_control( $wp_customize ) {
$control_class = $this->control_class;
// If no class-name is defined, early exit.
if ( ! $control_class ) {
return;
}
/**
* Allow filtering the arguments.
*
* @since 0.1
* @param array | php | {
"resource": ""
} |
q22618 | GoogleFonts.get_google_fonts_by_args | train | public function get_google_fonts_by_args( $args = [] ) {
$cache_name = 'kirki_googlefonts_' . md5( wp_json_encode( $args ) );
$cache = get_site_transient( $cache_name );
if ( $cache ) {
return $cache;
}
$args['sort'] = isset( $args['sort'] ) ? $args['sort'] : 'alpha';
$fonts = $this->get_a... | php | {
"resource": ""
} |
q22619 | Helper.get_remote_url_contents | train | public static function get_remote_url_contents( $url, $args = [] ) {
$response = wp_remote_get( $url, $args );
if ( is_wp_error( $response ) ) {
return [];
}
| php | {
"resource": ""
} |
q22620 | Helper.get_root_path | train | public static function get_root_path() {
// Get the upload directory for this site.
$upload_dir = wp_upload_dir();
$path = untrailingslashit( wp_normalize_path( $upload_dir['basedir'] ) ) . '/webfonts';
// If the folder doesn't exist, create it.
| php | {
"resource": ""
} |
q22621 | Helper.get_filename_from_url | train | private static function get_filename_from_url( $url ) {
$url_parts = explode( '/', $url );
| php | {
"resource": ""
} |
q22622 | Helper.download_font_file | train | public static function download_font_file( $url ) {
// Gives us access to the download_url() and wp_handle_sideload() functions.
require_once ABSPATH . 'wp-admin/includes/file.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
$timeout_seconds = 5;
// Download file to temp dir.
$temp_file = ... | php | {
"resource": ""
} |
q22623 | Helper.get_root_url | train | public static function get_root_url() {
// Get the upload directory for this site.
$upload_dir = wp_upload_dir();
// The URL.
$url = trailingslashit( $upload_dir['baseurl'] );
// Take care of domain mapping.
// When using domain mapping we have to make sure that the URL to the file
// does not include ... | php | {
"resource": ""
} |
q22624 | Module.init | train | public function init() {
$this->set_configs();
$this->set_enabled();
$this->set_modules_css();
$this->set_google_fonts(); | php | {
"resource": ""
} |
q22625 | Module.enqueue | train | public function enqueue( $settings ) {
$styles = $this->get_styles();
if ( ! empty( $styles ) | php | {
"resource": ""
} |
q22626 | Module.get_styles | train | public function get_styles() {
$styles = null;
foreach ( $this->configs as $config_id => $args ) {
if ( true === $this->is_disabled( $args ) ) {
continue;
}
$modules_css = $this->modules_css;
$styles = $modules_css::loop_controls( $config_id ); // phpcs:ignore PHPCompatibility.Syntax.NewDyn... | php | {
"resource": ""
} |
q22627 | Module.is_disabled | train | private function is_disabled( $args = [] ) {
if ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) {
return true;
}
if ( ! empty( $args ) ) {
| php | {
"resource": ""
} |
q22628 | Module.enqueue_fontawesome | train | public function enqueue_fontawesome() {
foreach ( $this->configs as $config_id => $args ) {
if ( $this->is_disabled( $args ) ) {
continue;
}
$modules_css = $this->modules_css;
if ( $modules_css::get_enqueue_fa() && apply_filters( 'kirki_load_fontawesome', true ) ) { | php | {
"resource": ""
} |
q22629 | Init.add_to_customizer | train | public function add_to_customizer() {
$this->fields_from_filters();
add_action( 'customize_register', [ $this, 'register_control_types' ] );
add_action( 'customize_register', [ $this, 'add_panels' ], | php | {
"resource": ""
} |
q22630 | Init.register_control_types | train | public function register_control_types() {
global $wp_customize;
$section_types = apply_filters( 'kirki_section_types', [] );
foreach ( $section_types as $section_type ) {
$wp_customize->register_section_type( $section_type );
}
$this->control_types = $this->default_control_types();
if ( ! class_exists... | php | {
"resource": ""
} |
q22631 | Init.add_panels | train | public function add_panels() {
if ( ! empty( Kirki::$panels ) ) {
foreach ( Kirki::$panels as $panel_args ) {
// Extra checks for nested panels.
if ( isset( $panel_args['panel'] ) ) {
if ( isset( Kirki::$panels[ $panel_args['panel'] | php | {
"resource": ""
} |
q22632 | Init.add_sections | train | public function add_sections() {
if ( ! empty( Kirki::$sections ) ) {
foreach ( Kirki::$sections as $section_args ) {
// Extra checks for nested sections.
if ( isset( $section_args['section'] ) ) {
if ( isset( Kirki::$sections[ $section_args['section'] ] ) ) {
// Set the type to nested.
$s... | php | {
"resource": ""
} |
q22633 | Init.fields_from_filters | train | private function fields_from_filters() {
$fields = apply_filters( 'kirki_controls', [] );
$fields = apply_filters( 'kirki_fields', $fields );
if ( ! empty( $fields ) ) {
foreach | php | {
"resource": ""
} |
q22634 | Select.sanitize | train | public function sanitize( $value ) {
if ( is_array( $value ) ) {
foreach ( $value as $key => $subvalue ) {
if ( '' !== $subvalue || isset( $this->choices[''] | php | {
"resource": ""
} |
q22635 | Background.sanitize | train | public static function sanitize( $value ) {
if ( ! is_array( $value ) ) {
return [];
}
$sanitized_value = [
'background-color' => '',
'background-image' => '',
'background-repeat' => '',
'background-position' => '',
'background-size' => '',
'background-attachment' => '',... | php | {
"resource": ""
} |
q22636 | Sanitize_Values.dropdown_pages | train | public static function dropdown_pages( $page_id, $setting ) {
// Ensure $input is an absolute integer.
$page_id = absint( $page_id );
// If $page_id is an ID of a published page, return it; otherwise, return | php | {
"resource": ""
} |
q22637 | Sanitize_Values.css_dimension | train | public static function css_dimension( $value ) {
// Trim it.
$value = trim( $value );
// If the value is round, then return 50%.
if ( 'round' === $value ) {
$value = '50%';
}
// If the value is empty, return empty.
if ( '' === $value ) {
return '';
}
// If auto, inherit or initial, return th... | php | {
"resource": ""
} |
q22638 | Module.add_tooltip | train | public function add_tooltip( $field_id, $tooltip ) {
$this->tooltips_content[ $field_id | php | {
"resource": ""
} |
q22639 | Module.register_partials | train | public function register_partials( $wp_customize ) {
// Abort if selective refresh is not available.
if ( ! isset( $wp_customize->selective_refresh ) ) {
return;
}
// Get an array of all fields.
$fields = Kirki::$fields;
// Start parsing the fields.
foreach ( $fields as $field ) {
if ( isset( $fi... | php | {
"resource": ""
} |
q22640 | Repeater.sanitize_repeater_setting | train | public function sanitize_repeater_setting( $value ) {
if ( ! is_array( $value ) ) {
$value = json_decode( urldecode( $value ) );
}
if ( empty( $value ) || ! is_array( $value ) ) {
$value = [];
}
// Make sure that every row is an array, not an object.
foreach ( $value as $key => $val ) {
$value[ $k... | php | {
"resource": ""
} |
q22641 | Module.init | train | protected function init() {
foreach ( array_keys( Kirki::$config ) as $config_id ) {
if ( 'async' === $this->get_method() ) {
new | php | {
"resource": ""
} |
q22642 | Values.get_value | train | public static function get_value( $config_id = '', $field_id = '' ) {
// Make sure value is defined.
$value = '';
// This allows us to skip the $config_id argument.
// If we skip adding a $config_id, use the 'global' configuration.
if ( ( '' === $field_id ) && '' !== $config_id ) {
$field_id = $config_i... | php | {
"resource": ""
} |
q22643 | Values.get_sanitized_field_value | train | public static function get_sanitized_field_value( $field ) {
$value = $field['default'];
if ( isset( $field['option_type'] ) && 'theme_mod' === $field['option_type'] ) {
$value = get_theme_mod( $field['settings'], $field['default'] );
} elseif ( isset( $field['option_type'] ) && 'option' === $field['option_typ... | php | {
"resource": ""
} |
q22644 | Module.field_add_control_args | train | public function field_add_control_args( $args ) {
if ( isset( $args['active_callback'] ) ) {
if ( is_array( $args['active_callback'] ) ) {
if ( ! is_callable( $args['active_callback'] ) ) {
// Bugfix for https://github.com/aristath/kirki/issues/1961.
foreach ( $args['active_callback'] as $key => $v... | php | {
"resource": ""
} |
q22645 | Module.postmessage | train | public function postmessage() {
wp_enqueue_script( 'kirki_auto_css_vars', URL::get_from_path( __DIR__ . '/script.js' ), [ 'jquery', 'customize-preview' ], KIRKI_VERSION, true );
$fields = array_merge( Kirki::$fields, $this->fields ); | php | {
"resource": ""
} |
q22646 | Settings.add_settings | train | final private function add_settings( $args = [] ) {
// Get the classname we'll be using to create our setting(s).
$classname = false;
if ( isset( $args['option_type'] ) && array_key_exists( $args['option_type'], $this->setting_types ) ) {
$classname = $this->setting_types[ $args['option_type'] ];
}
if ( !... | php | {
"resource": ""
} |
q22647 | Settings.add_setting | train | final private function add_setting( $classname, $setting, $default, $type, $capability, $transport, $sanitize_callback ) {
$this->wp_customize->add_setting(
new $classname(
$this->wp_customize,
$setting,
[
'default' => $default,
| php | {
"resource": ""
} |
q22648 | Module.customize_controls_enqueue_scripts | train | public function customize_controls_enqueue_scripts() {
$sections = Kirki::$sections;
$panels = Kirki::$panels;
// Parse sections and find ones with icons.
foreach ( $sections as $section ) {
if ( isset( $section['icon'] ) ) {
$this->add_icon( $section['id'], $section['icon'], 'section' );
}
}
... | php | {
"resource": ""
} |
q22649 | Helper.array_replace_recursive | train | public static function array_replace_recursive( $array, $array1 ) {
if ( function_exists( 'array_replace_recursive' ) ) {
return array_replace_recursive( $array, $array1 );
}
/**
* Handle the arguments, merge one by one.
*
* In PHP 7 func_get_args() changed the way it behaves but this doesn't mean an... | php | {
"resource": ""
} |
q22650 | Helper.recurse | train | public static function recurse( $array, $array1 ) {
foreach ( $array1 as $key => $value ) {
// Create new key in $array, if it is empty or not an array.
if ( ! isset( $array[ $key ] ) || ( isset( $array[ $key ] ) && ! is_array( $array[ $key ] ) ) ) {
$array[ $key ] = [];
}
// | php | {
"resource": ""
} |
q22651 | Helper.init_filesystem | train | public static function init_filesystem() {
$credentials = [];
if ( ! defined( 'FS_METHOD' ) ) {
define( 'FS_METHOD', 'direct' );
}
$method = defined( 'FS_METHOD' ) ? FS_METHOD : false;
if ( 'ftpext' === $method ) {
// If defined, set it to that, Else, set to NULL.
$credentials['hostname'] = define... | php | {
"resource": ""
} |
q22652 | Helper.get_image_id | train | public static function get_image_id( $url ) {
global $wpdb;
if ( empty( $url ) ) {
return 0;
}
$attachment = wp_cache_get( 'kirki_image_id_' . md5( $url ), null );
if ( false === $attachment ) {
$attachment = | php | {
"resource": ""
} |
q22653 | Helper.get_image_from_url | train | public static function get_image_from_url( $url ) {
$image_id = self::get_image_id( $url );
$image = wp_get_attachment_image_src( $image_id, 'full' );
return [
'url' | php | {
"resource": ""
} |
q22654 | Helper.get_posts | train | public static function get_posts( $args ) {
if ( is_string( $args ) ) {
$args = add_query_arg(
[
'suppress_filters' => false,
]
);
} elseif ( is_array( $args ) && ! isset( $args['suppress_filters'] ) ) {
| php | {
"resource": ""
} |
q22655 | Helper.get_taxonomies | train | public static function get_taxonomies() {
$items = [];
// Get the taxonomies.
$taxonomies = get_taxonomies(
[
'public' => true,
]
);
// Build the array.
foreach ( $taxonomies as $taxonomy ) {
$id = $taxonomy; | php | {
"resource": ""
} |
q22656 | Helper.get_post_types | train | public static function get_post_types() {
$items = [];
// Get the post types.
$post_types = get_post_types(
[
'public' => true,
],
'objects'
);
// Build | php | {
"resource": ""
} |
q22657 | Helper.get_terms | train | public static function get_terms( $taxonomies ) {
$items = [];
// Get the post types.
$terms = get_terms( | php | {
"resource": ""
} |
q22658 | Helper.compare_values | train | public static function compare_values( $value1, $value2, $operator ) {
if ( '===' === $operator ) {
return $value1 === $value2;
}
if ( '!==' === $operator ) {
return $value1 !== $value2;
}
if ( ( '!=' === $operator || 'not equal' === $operator ) ) {
return $value1 != $value2; // phpcs:ignore WordPres... | php | {
"resource": ""
} |
q22659 | Panel.add_panel | train | public function add_panel( $args ) {
global $wp_customize;
if ( ! isset( $args['type'] ) || ! array_key_exists( $args['type'], $this->panel_types ) | php | {
"resource": ""
} |
q22660 | Google.process_fonts | train | public function process_fonts() {
// Early exit if font-family is empty.
if ( empty( $this->fonts ) ) {
return;
}
foreach ( $this->fonts as $font => $variants ) {
// Determine if this is indeed a google font or not.
// If it's not, then just remove it from the array.
if ( ! array_key_exists( $fon... | php | {
"resource": ""
} |
q22661 | Fonts.get_all_fonts | train | public static function get_all_fonts() {
$standard_fonts = self::get_standard_fonts();
$google_fonts | php | {
"resource": ""
} |
q22662 | Fonts.get_all_variants | train | public static function get_all_variants() {
return [
'100' => esc_html__( 'Ultra-Light 100', 'kirki' ),
'100light' => esc_html__( 'Ultra-Light 100', 'kirki' ),
'100italic' => esc_html__( 'Ultra-Light 100 Italic', 'kirki' ),
'200' => esc_html__( 'Light 200', 'kirki' ),
'200italic' => esc_ht... | php | {
"resource": ""
} |
q22663 | Fonts.is_google_font | train | public static function is_google_font( $fontname ) {
if ( is_string( $fontname ) ) {
$fonts = self::get_google_fonts(); | php | {
"resource": ""
} |
q22664 | Fonts.get_font_choices | train | public static function get_font_choices() {
$fonts = self::get_all_fonts();
| php | {
"resource": ""
} |
q22665 | Config.get_instance | train | public static function get_instance( $id = 'global', $args = [] ) {
if ( empty( $id ) ) {
$id = 'global';
}
$id_md5 = md5( $id );
if ( ! isset( self::$instances[ $id_md5 ] ) ) {
| php | {
"resource": ""
} |
q22666 | Config.get_config_ids | train | public static function get_config_ids() {
$configs = [];
foreach ( self::$instances as $instance ) {
$configs[] | php | {
"resource": ""
} |
q22667 | Editor.set_type | train | protected function set_type() {
global $wp_version;
if ( version_compare( $wp_version, '4.8' ) >= 0 ) {
$this->type = 'kirki-editor';
return;
}
// Fallback for older WordPress versions.
$this->type = 'kirki-generic';
| php | {
"resource": ""
} |
q22668 | Sortable.sanitize | train | public function sanitize( $value = [] ) {
if ( is_string( $value ) || is_numeric( $value ) ) {
return [
sanitize_text_field( $value ),
];
}
$sanitized_value = [];
foreach ( $value as $sub_value ) | php | {
"resource": ""
} |
q22669 | My_Theme_Kirki.get_option | train | public static function get_option( $config_id = '', $field_id = '' ) {
// if Kirki exists, use it.
if ( class_exists( 'Kirki' ) ) {
return Kirki::get_option( $config_id, $field_id );
}
// Kirki does not exist, continue with our custom implementation.
// Get the default value of the field.
$default = ''... | php | {
"resource": ""
} |
q22670 | My_Theme_Kirki.add_field | train | public static function add_field( $config_id, $args ) {
// if Kirki exists, use it.
if ( class_exists( 'Kirki' ) ) {
Kirki::add_field( $config_id, $args );
return;
}
// Kirki was not located, so we'll need to add our fields here.
// Check that the "settings" & "type" arguments have been defined.
if ... | php | {
"resource": ""
} |
q22671 | My_Theme_Kirki.enqueue_styles | train | public function enqueue_styles() {
// If Kirki exists there's no need to proceed any further.
if ( class_exists( 'Kirki' ) ) {
return;
}
// Get our inline styles.
$styles = $this->get_styles();
// If we have some styles to add, add them now.
if ( ! empty( $styles ) ) {
// Enqueue the theme's sty... | php | {
"resource": ""
} |
q22672 | My_Theme_Kirki.enqueue_fonts | train | public function enqueue_fonts() {
// Check if we need to exit early.
if ( empty( self::$fields ) || ! is_array( self::$fields ) ) {
return;
}
foreach ( self::$fields as $field ) {
// Process typography fields.
if ( isset( $field['type'] ) && 'typography' === $field['type'] ) {
// Check if we've... | php | {
"resource": ""
} |
q22673 | Typography.add_main_field | train | private function add_main_field( $config_id, $args ) {
/**
* Add a hidden field, the label & description.
*/
Kirki::add_field(
$config_id,
wp_parse_args(
[
'type' => 'kirki-generic',
'sanitize_callback' => isset( $args['sanitize_callback'] | php | {
"resource": ""
} |
q22674 | Typography.sanitize | train | public static function sanitize( $value ) {
if ( ! is_array( $value ) ) {
return [];
}
foreach ( $value as $key => $val ) {
switch ( $key ) {
case 'font-family':
$value['font-family'] = sanitize_text_field( $val );
break;
case 'font-weight':
if ( isset( $value['variant'] ) ) {
... | php | {
"resource": ""
} |
q22675 | Typography.enqueue_scripts | train | public function enqueue_scripts() {
wp_enqueue_style( 'kirki-control-typography-style', URL::get_from_path( dirname( __DIR__ ) . '/assets/styles/style.css' ), [], '1.0' );
wp_enqueue_script( 'kirki-typography', URL::get_from_path( dirname( __DIR__ ) . '/assets/scripts/script.js' ), [], '1.0', true );
wp_localize... | php | {
"resource": ""
} |
q22676 | Field.set_field | train | protected function set_field() {
$properties = get_class_vars( __CLASS__ );
// Some things must run before the others.
$this->set_option_type();
$this->set_settings();
// Sanitize the properties, skipping the ones that have already run above.
foreach ( $properties as $property => $value ) {
if ( in_ar... | php | {
"resource": ""
} |
q22677 | Field.set_option_type | train | protected function set_option_type() {
// Take care of common typos.
if ( 'options' === $this->option_type ) {
$this->option_type = 'option';
}
// Take care of common typos.
if ( 'theme_mods' === $this->option_type ) {
/* translators: %1$s represents the field ID where the error occurs. | php | {
"resource": ""
} |
q22678 | Field.set_partial_refresh | train | protected function set_partial_refresh() {
if ( ! is_array( $this->partial_refresh ) ) {
$this->partial_refresh = [];
}
foreach ( $this->partial_refresh as $id => $args ) {
if ( ! is_array( $args ) || ! isset( $args['selector'] ) || ! isset( $args['render_callback'] ) || ! is_callable( $args['render_callbac... | php | {
"resource": ""
} |
q22679 | Field.set_settings | train | protected function set_settings() {
// If settings is not an array, temporarily convert it to an array.
// This is just to allow us to process everything the same way and avoid code duplication.
// if settings is not an array then it will not be set as an array in the end.
if ( ! is_array( $this->settings ) ) ... | php | {
"resource": ""
} |
q22680 | Content.copyUntilUnless | train | public function copyUntilUnless(string $string, string $unless)
{
$lastPos = $this->pos;
$this->fastForward(1);
$foundString = $this->copyUntil($string, true, true);
$position = strcspn($foundString, $unless);
if ($position == strlen($foundString)) {
| php | {
"resource": ""
} |
q22681 | Content.copyByToken | train | public function copyByToken(string $token, bool $char = false, bool $escape = false)
{
$string = $this->$token; | php | {
"resource": ""
} |
q22682 | Content.skip | train | public function skip(string $string, bool $copy = false)
{
$len = strspn($this->content, $string, $this->pos);
// make it chainable if they don't want a copy
$return = $this;
if ($copy) {
| php | {
"resource": ""
} |
q22683 | InnerNode.propagateEncoding | train | public function propagateEncoding(Encode $encode): void
{
$this->encode = $encode;
$this->tag->setEncoding($encode);
| php | {
"resource": ""
} |
q22684 | InnerNode.insertBefore | train | public function insertBefore(AbstractNode $child, | php | {
"resource": ""
} |
q22685 | InnerNode.insertAfter | train | public function insertAfter(AbstractNode $child, int $id): bool
{
if (!isset($this->children[$id])) {
return false;
}
if ($this->children[$id]['next']) {
| php | {
"resource": ""
} |
q22686 | InnerNode.removeChild | train | public function removeChild(int $id): InnerNode
{
if ( ! isset($this->children[$id])) {
return $this;
}
// handle moving next and previous assignments.
$next = $this->children[$id]['next'];
$prev = $this->children[$id]['prev'];
| php | {
"resource": ""
} |
q22687 | InnerNode.hasNextChild | train | public function hasNextChild(int $id)
{
$child= $this->getChild($id);
| php | {
"resource": ""
} |
q22688 | InnerNode.isDescendant | train | public function isDescendant(int $id): bool
{
if ($this->isChild($id)) {
return true;
}
foreach ($this->children as $childId => $child) {
/** @var InnerNode $node */
$node = $child['node'];
if ($node instanceof InnerNode && | php | {
"resource": ""
} |
q22689 | Tag.setStyleAttributeValue | train | public function setStyleAttributeValue($attr_key, $attr_value): void
{
$style_array = $this->getStyleAttributeArray();
$style_array[$attr_key] = $attr_value;
$style_string = '';
foreach ($style_array as $key => $value) {
| php | {
"resource": ""
} |
q22690 | Tag.getStyleAttributeArray | train | public function getStyleAttributeArray(): array
{
$value = $this->getAttribute('style')['value'];
if ($value === null) {
return [];
}
$value = explode(';', substr(trim($value), 0, -1));
$result = [];
| php | {
"resource": ""
} |
q22691 | Tag.setAttributes | train | public function setAttributes(array $attr)
{
foreach ($attr as | php | {
"resource": ""
} |
q22692 | Tag.getAttributes | train | public function getAttributes()
{
$return = [];
foreach ($this->attr as $attr => $info) {
$return[$attr] | php | {
"resource": ""
} |
q22693 | Tag.makeOpeningTag | train | public function makeOpeningTag()
{
$return = '<'.$this->name;
// add the attributes
foreach ($this->attr as $key => $info) {
$info = $this->getAttribute($key);
$val = $info['value'];
if (is_null($val)) {
$return .= ' '.$key;
}... | php | {
"resource": ""
} |
q22694 | TextNode.text | train | public function text(): string
{
// convert charset
if ( ! is_null($this->encode)) {
if ( ! is_null($this->convertedText)) {
// we already know the converted value
return $this->convertedText;
}
| php | {
"resource": ""
} |
q22695 | TextNode.setText | train | public function setText(string $text): void
{
$this->text = $text;
if ( ! is_null($this->encode)) {
$text = $this->encode->convert($text);
| php | {
"resource": ""
} |
q22696 | Dom.addNoSlashTag | train | public function addNoSlashTag($tag): Dom
{
if ( ! is_array($tag)) {
$tag = | php | {
"resource": ""
} |
q22697 | Dom.removeNoSlashTag | train | public function removeNoSlashTag($tag): Dom
{
if ( ! is_array($tag)) {
| php | {
"resource": ""
} |
q22698 | Dom.parse | train | protected function parse(): void
{
// add the root node
$this->root = new HtmlNode('root');
$activeNode = $this->root;
while ( ! is_null($activeNode)) {
$str = $this->content->copyUntil('<');
if ($str == '') {
$info = $this->parseTag();
... | php | {
"resource": ""
} |
q22699 | Dom.detectCharset | train | protected function detectCharset(): bool
{
// set the default
$encode = new Encode;
$encode->from($this->defaultCharset);
$encode->to($this->defaultCharset);
if ( ! is_null($this->options->enforceEncoding)) {
// they want to enforce the given encoding
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.