$key,
'label' => $label,
'svg' => $svg,
];
}
// Parse classes from CSS.
if ( $field['icon_css'] && ! $field['icon_file'] ) {
$icon = trim( $field['icon_base_class'] . ' ' . $icon );
}
// Text file: each icon on a line.
return [
'value' => $icon,
'label' => $icon,
'svg' => '',
];
}
private static function get_svg( array $field, string $value ): string {
$file = trailingslashit( $field['icon_dir'] ) . $value . '.svg';
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
return file_exists( $file ) ? file_get_contents( $file ) : '';
}
private static function get_options( array $field ): array {
$icons = self::get_icons( $field );
$options = [];
foreach ( $icons as $icon ) {
$svg = ! $icon['svg'] && $field['icon_dir'] ? self::get_svg( $field, $icon['value'] ) : $icon['svg'];
$options[] = [
'value' => $icon['value'],
'label' => $svg . $icon['label'],
];
}
return $options;
}
/**
* Normalize field settings.
*
* @param array $field Field settings.
* @return array
*/
public static function normalize( $field ) {
$field = wp_parse_args( $field, [
'placeholder' => __( 'Select an icon', 'meta-box' ),
'icon_css' => '',
'icon_set' => '',
'icon_file' => '',
'icon_dir' => '',
'icon_base_class' => '',
] );
// Ensure absolute paths and URLs.
$field['icon_file'] = self::ensure_absolute_path( $field['icon_file'] );
$field['icon_dir'] = self::ensure_absolute_path( $field['icon_dir'] );
if ( is_string( $field['icon_css'] ) && $field['icon_css'] ) {
$field['icon_css'] = self::ensure_absolute_url( $field['icon_css'] );
}
// Font Awesome Pro.
if ( $field['icon_set'] === 'font-awesome-pro' ) {
} elseif ( $field['icon_file'] || $field['icon_dir'] || $field['icon_css'] ) {
// Custom icon set.
$field['icon_set'] = 'custom';
} else {
// Font Awesome Free.
$field['icon_set'] = 'font-awesome-free';
$field['icon_file'] = RWMB_DIR . 'css/fontawesome/icons.json';
}
$field['options'] = self::get_options( $field );
$field = parent::normalize( $field );
return $field;
}
/**
* Format value for the helper functions.
*
* @param array $field Field parameters.
* @param string|array $value The field meta value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
// SVG from file.
if ( $field['icon_dir'] ) {
return self::get_svg( $field, $value );
}
$icons = self::get_icons( $field );
$key = array_search( $value, array_column( $icons, 'value' ) );
if ( false === $key ) {
return '';
}
// Embed SVG.
if ( $icons[ $key ]['svg'] ) {
return $icons[ $key ]['svg'];
}
// Render with class and use css.
self::enqueue_icon_font_style( $field );
return sprintf( ' ', $value );
}
private static function url_to_path( string $url ): string {
return str_starts_with( $url, home_url( '/' ) ) ? str_replace( home_url( '/' ), trailingslashit( ABSPATH ), $url ) : '';
}
private static function ensure_absolute_path( string $path ): string {
if ( ! $path || file_exists( $path ) ) {
return $path;
}
$root = wp_normalize_path( ABSPATH );
$path = wp_normalize_path( $path );
return str_starts_with( $path, $root ) ? $path : trailingslashit( $root ) . ltrim( $path, '/' );
}
private static function ensure_absolute_url( string $url ): string {
return filter_var( $url, FILTER_VALIDATE_URL ) ? $url : home_url( $url );
}
}
fields/single-image.php 0000644 00000003352 15154570313 0011073 0 ustar 00 '',
'data-single-image' => 1,
] );
$field['attributes']['class'] .= ' rwmb-image_advanced';
$field['multiple'] = false;
return $field;
}
/**
* Get meta values to save.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
*
* @return array|mixed
*/
public static function value( $new, $old, $post_id, $field ) {
return $new;
}
/**
* Get the field value. Return meaningful info of the files.
*
* @param array $field Field parameters.
* @param array $args Not used for this field.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return mixed Full info of uploaded files
*/
public static function get_value( $field, $args = [], $post_id = null ) {
$value = RWMB_Field::get_value( $field, $args, $post_id );
if ( ! is_array( $value ) ) {
return RWMB_Image_Field::file_info( $value, $args, $field );
}
$return = [];
foreach ( $value as $image_id ) {
$return[] = RWMB_Image_Field::file_info( $image_id, $args, $field );
}
return $return;
}
}
fields/video.php 0000644 00000007437 15154570313 0007650 0 ustar 00 wp_get_video_extensions(),
] );
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field['mime_type'] = 'video';
$field = parent::normalize( $field );
return $field;
}
/**
* Get uploaded file information.
*
* @param int $file_id Attachment image ID (post ID). Required.
* @param array $args Array of arguments (for size).
* @param array $field Field settings.
*
* @return array|bool False if file not found. Array of image info on success.
*/
public static function file_info( $file_id, $args = [], $field = [] ) {
if ( ! get_attached_file( $file_id ) ) {
return false;
}
$attachment = get_post( $file_id );
$url = wp_get_attachment_url( $attachment->ID );
$file_type = wp_check_filetype( $url, wp_get_mime_types() );
$data = [
'ID' => $file_id,
'src' => $url,
'type' => $file_type['type'],
'title' => $attachment->post_title,
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
];
$data['meta'] = [];
$meta = wp_get_attachment_metadata( $attachment->ID );
if ( ! empty( $meta ) ) {
foreach ( wp_get_attachment_id3_keys( $attachment ) as $key => $label ) {
if ( ! empty( $meta[ $key ] ) ) {
$data['meta'][ $key ] = $meta[ $key ];
}
}
if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
$data['dimensions'] = [
'width' => $meta['width'],
'height' => $meta['height'],
];
} else {
$data['dimensions'] = [
'width' => 640,
'height' => 360,
];
}
}
$thumb_id = get_post_thumbnail_id( $attachment->ID );
if ( ! empty( $thumb_id ) ) {
list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'full' );
$data['image'] = compact( 'src', 'width', 'height' );
list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'thumbnail' );
$data['thumb'] = compact( 'src', 'width', 'height' );
} else {
$src = wp_mime_type_icon( $attachment->ID );
$width = 48;
$height = 64;
$data['image'] = compact( 'src', 'width', 'height' );
$data['thumb'] = compact( 'src', 'width', 'height' );
}
return $data;
}
/**
* Format value for a clone.
*
* @param array $field Field parameters.
* @param string|array $value The field meta value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_clone_value( $field, $value, $args, $post_id ) {
$ids = implode( ',', wp_list_pluck( $value, 'ID' ) );
// Display single video.
if ( 1 === count( $value ) ) {
$video = reset( $value );
return wp_video_shortcode( [
'src' => $video['src'],
'width' => $video['dimensions']['width'],
'height' => $video['dimensions']['height'],
] );
}
// Display multiple videos in a playlist.
return wp_playlist_shortcode( [
'ids' => $ids,
'type' => 'video',
] );
}
}
fields/map.php 0000644 00000014764 15154570313 0007320 0 ustar 00 $field['api_key'],
'language' => $field['language'],
'libraries' => 'places',
], 'https://maps.google.com/maps/api/js' );
/**
* Allows developers load more libraries via a filter.
* @link https://developers.google.com/maps/documentation/javascript/libraries
*/
$google_maps_url = apply_filters( 'rwmb_google_maps_url', $google_maps_url );
wp_register_script( 'google-maps', esc_url_raw( $google_maps_url ), [], RWMB_VER, true );
wp_enqueue_script( 'rwmb-map', RWMB_JS_URL . 'map.js', [ 'jquery-ui-autocomplete', 'google-maps' ], RWMB_VER, true );
RWMB_Helpers_Field::localize_script_once( 'rwmb-map', 'RWMB_Map', [
'no_results_string' => __( 'No results found', 'meta-box' ),
] );
}
/**
* Get field HTML.
*
* @param mixed $meta Meta value.
* @param array $field Field parameters.
*
* @return string
*/
public static function html( $meta, $field ) {
$address = is_array( $field['address_field'] ) ? implode( ',', $field['address_field'] ) : $field['address_field'];
$html = sprintf(
'',
esc_attr( $address )
);
$attributes = self::get_attributes( $field, $meta );
$attributes['type'] = 'hidden';
$attributes['value'] = $meta;
$html .= sprintf(
'
',
esc_attr( $field['std'] ),
esc_attr( $field['region'] ),
esc_attr( $field['marker_draggable'] ? 'true' : 'false' ),
self::render_attributes( $attributes )
);
$html .= '
';
return $html;
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'std' => '',
'address_field' => '',
'language' => '',
'region' => '',
'marker_draggable' => true,
// Default API key, required by Google Maps since June 2016.
// Users should overwrite this key with their own key.
'api_key' => 'AIzaSyC1mUh87SGFyf133tpZQJa-s96p0tgnraQ',
] );
return $field;
}
/**
* Get the field value.
* The difference between this function and 'meta' function is 'meta' function always returns the escaped value
* of the field saved in the database, while this function returns more meaningful value of the field.
*
* @param array $field Field parameters.
* @param array $args Not used for this field.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return mixed Array(latitude, longitude, zoom)
*/
public static function get_value( $field, $args = [], $post_id = null ) {
$value = parent::get_value( $field, $args, $post_id );
if ( is_array( $value ) ) {
$location = [];
foreach ( $value as $clone ) {
list( $latitude, $longitude, $zoom ) = explode( ',', $clone . ',,' );
$location[] = compact( 'latitude', 'longitude', 'zoom' );
}
return $location;
}
list( $latitude, $longitude, $zoom ) = explode( ',', $value . ',,' );
return compact( 'latitude', 'longitude', 'zoom' );
}
/**
* Format value before render map
* @param mixed $field
* @param mixed $value
* @param mixed $args
* @param mixed $post_id
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ): string {
$args = wp_parse_args( $args, [
'api_key' => $field['api_key'] ?? '',
] );
return self::render_map( $value, $args );
}
/**
* Render a map in the frontend.
*
* @param string $location The "latitude,longitude[,zoom]" location.
* @param array $args Additional arguments for the map.
*
* @return string
*/
public static function render_map( $location, $args = [] ) {
// For compatibility with previous version, or within groups.
if ( is_string( $location ) ) {
list( $latitude, $longitude, $zoom ) = explode( ',', $location . ',,' );
} else {
extract( $location );
}
if ( ! $latitude || ! $longitude ) {
return '';
}
$args = wp_parse_args( $args, [
'latitude' => $latitude,
'longitude' => $longitude,
'width' => '100%',
'height' => '480px',
'marker' => true, // Display marker?
'marker_title' => '', // Marker title, when hover.
'info_window' => '', // Content of info window (when click on marker). HTML allowed.
'js_options' => [],
'zoom' => $zoom,
// Default API key, required by Google Maps since June 2016.
// Users should overwrite this key with their own key.
'api_key' => 'AIzaSyC1mUh87SGFyf133tpZQJa-s96p0tgnraQ',
] );
$google_maps_url = add_query_arg( 'key', $args['api_key'], 'https://maps.google.com/maps/api/js' );
/*
* Allows developers load more libraries via a filter.
* @link https://developers.google.com/maps/documentation/javascript/libraries
*/
$google_maps_url = apply_filters( 'rwmb_google_maps_url', $google_maps_url );
wp_register_script( 'google-maps', esc_url_raw( $google_maps_url ), [], RWMB_VER, true );
wp_enqueue_script( 'rwmb-map-frontend', RWMB_JS_URL . 'map-frontend.js', [ 'google-maps', 'jquery' ], RWMB_VER, true );
/*
* Google Maps options.
* Option name is the same as specified in Google Maps documentation.
* This array will be convert to Javascript Object and pass as map options.
* @link https://developers.google.com/maps/documentation/javascript/reference
*/
$args['js_options'] = wp_parse_args( $args['js_options'], [
// Default to 'zoom' level set in admin, but can be overwritten.
'zoom' => $args['zoom'],
// Map type, see https://developers.google.com/maps/documentation/javascript/reference#MapTypeId.
'mapTypeId' => 'ROADMAP',
// Open Info Window
'openInfoWindow' => false,
] );
$output = sprintf(
'
',
esc_attr( wp_json_encode( $args ) ),
esc_attr( $args['width'] ),
esc_attr( $args['height'] )
);
return $output;
}
}
fields/select.php 0000644 00000004770 15154570313 0010016 0 ustar 00 ',
self::render_attributes( $attributes )
);
if ( ! $field['multiple'] && $field['placeholder'] ) {
$output .= '' . esc_html( $field['placeholder'] ) . ' ';
}
$output .= $walker->walk( $options, $field['flatten'] ? -1 : 0 );
$output .= '';
$output .= self::get_select_all_html( $field );
return $output;
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = $field['multiple'] ? RWMB_Multiple_Values_Field::normalize( $field ) : $field;
$field = wp_parse_args( $field, [
'select_all_none' => false,
] );
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes = wp_parse_args( $attributes, [
'multiple' => $field['multiple'],
] );
return $attributes;
}
/**
* Get html for select all|none for multiple select.
*
* @param array $field Field parameters.
* @return string
*/
public static function get_select_all_html( $field ) {
if ( $field['multiple'] && $field['select_all_none'] ) {
return '';
}
return '';
}
}
fields/background.php 0000644 00000012505 15154570313 0010651 0 ustar 00 'color',
'id' => "{$field['id']}_color",
'field_name' => "{$field['field_name']}[color]",
'alpha_channel' => true,
] );
RWMB_Color_Field::admin_enqueue_scripts( $color );
RWMB_File_Input_Field::admin_enqueue_scripts();
}
/**
* Get field HTML.
*
* @param mixed $meta Meta value.
* @param array $field Field settings.
*
* @return string
*/
public static function html( $meta, $field ) {
$meta = wp_parse_args( $meta, [
'color' => '',
'image' => '',
'repeat' => '',
'attachment' => '',
'position' => '',
'size' => '',
] );
$output = '';
// Color.
$color = RWMB_Color_Field::normalize( [
'type' => 'color',
'id' => "{$field['id']}_color",
'field_name' => "{$field['field_name']}[color]",
'alpha_channel' => true,
] );
$output .= RWMB_Color_Field::html( $meta['color'], $color );
$output .= '
';
$output .= '';
// Image.
$image = RWMB_File_Input_Field::normalize( [
'type' => 'file_input',
'id' => "{$field['id']}_image",
'field_name' => "{$field['field_name']}[image]",
'placeholder' => __( 'Background Image', 'meta-box' ),
] );
$output .= RWMB_File_Input_Field::html( $meta['image'], $image );
$output .= '
';
$output .= '';
// Repeat.
$repeat = RWMB_Select_Field::normalize( [
'type' => 'select',
'id' => "{$field['id']}_repeat",
'field_name' => "{$field['field_name']}[repeat]",
'placeholder' => esc_html__( '-- Repeat --', 'meta-box' ),
'options' => [
'no-repeat' => esc_html__( 'No Repeat', 'meta-box' ),
'repeat' => esc_html__( 'Repeat All', 'meta-box' ),
'repeat-x' => esc_html__( 'Repeat Horizontally', 'meta-box' ),
'repeat-y' => esc_html__( 'Repeat Vertically', 'meta-box' ),
'inherit' => esc_html__( 'Inherit', 'meta-box' ),
],
] );
$output .= RWMB_Select_Field::html( $meta['repeat'], $repeat );
// Position.
$position = RWMB_Select_Field::normalize( [
'type' => 'select',
'id' => "{$field['id']}_position",
'field_name' => "{$field['field_name']}[position]",
'placeholder' => esc_html__( '-- Position --', 'meta-box' ),
'options' => [
'top left' => esc_html__( 'Top Left', 'meta-box' ),
'top center' => esc_html__( 'Top Center', 'meta-box' ),
'top right' => esc_html__( 'Top Right', 'meta-box' ),
'center left' => esc_html__( 'Center Left', 'meta-box' ),
'center center' => esc_html__( 'Center Center', 'meta-box' ),
'center right' => esc_html__( 'Center Right', 'meta-box' ),
'bottom left' => esc_html__( 'Bottom Left', 'meta-box' ),
'bottom center' => esc_html__( 'Bottom Center', 'meta-box' ),
'bottom right' => esc_html__( 'Bottom Right', 'meta-box' ),
],
] );
$output .= RWMB_Select_Field::html( $meta['position'], $position );
// Attachment.
$attachment = RWMB_Select_Field::normalize( [
'type' => 'select',
'id' => "{$field['id']}_attachment",
'field_name' => "{$field['field_name']}[attachment]",
'placeholder' => esc_html__( '-- Attachment --', 'meta-box' ),
'options' => [
'fixed' => esc_html__( 'Fixed', 'meta-box' ),
'scroll' => esc_html__( 'Scroll', 'meta-box' ),
'inherit' => esc_html__( 'Inherit', 'meta-box' ),
],
] );
$output .= RWMB_Select_Field::html( $meta['attachment'], $attachment );
// Size.
$size = RWMB_Select_Field::normalize( [
'type' => 'select',
'id' => "{$field['id']}_size",
'field_name' => "{$field['field_name']}[size]",
'placeholder' => esc_html__( '-- Size --', 'meta-box' ),
'options' => [
'inherit' => esc_html__( 'Inherit', 'meta-box' ),
'cover' => esc_html__( 'Cover', 'meta-box' ),
'contain' => esc_html__( 'Contain', 'meta-box' ),
],
] );
$output .= RWMB_Select_Field::html( $meta['size'], $size );
$output .= '
';
return $output;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param array $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
if ( empty( $value ) ) {
return '';
}
$output = '';
$value = array_filter( $value );
foreach ( $value as $key => $subvalue ) {
$subvalue = 'image' === $key ? 'url(' . esc_url( $subvalue ) . ')' : $subvalue;
$output .= 'background-' . $key . ': ' . $subvalue . ';';
}
return $output;
}
}
fields/button-group.php 0000644 00000003532 15154570313 0011177 0 ustar 00 ',
$field['inline'] ? 'rwmb-inline' : ''
);
$output .= $walker->walk( $options, -1 );
$output .= '';
return $output;
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'inline' => true,
] );
$field = $field['multiple'] ? RWMB_Multiple_Values_Field::normalize( $field ) : $field;
$field = RWMB_Input_Field::normalize( $field );
$field['flatten'] = true;
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = RWMB_Input_Field::get_attributes( $field, $value );
$attributes['id'] = false;
$attributes['type'] = $field['multiple'] ? 'checkbox' : 'radio';
$attributes['value'] = $value;
return $attributes;
}
}
fields/choice.php 0000644 00000003541 15154570313 0007764 0 ustar 00 true,
'options' => [],
] );
// Use callback: function_name format from Meta Box Builder.
if ( isset( $field['_callback'] ) && is_callable( $field['_callback'] ) ) {
$field['options'] = call_user_func( $field['_callback'] );
}
return $field;
}
public static function transform_options( $options ) : array {
$transformed = [];
$options = (array) $options;
foreach ( $options as $value => $label ) {
$option = is_array( $label ) ? $label : [
'label' => (string) $label,
'value' => (string) $value,
];
if ( isset( $option['label'] ) && isset( $option['value'] ) ) {
$transformed[ $option['value'] ] = (object) $option;
}
}
return $transformed;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param string $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
$options = self::transform_options( $field['options'] );
return isset( $options[ $value ] ) ? $options[ $value ]->label : '';
}
}
fields/date.php 0000644 00000001143 15154570313 0007443 0 ustar 00 false,
'js_options' => [],
] );
$field['js_options'] = wp_parse_args( $field['js_options'], [
'defaultColor' => false,
'hide' => true,
'palettes' => true,
] );
$field = parent::normalize( $field );
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes = wp_parse_args( $attributes, [
'data-options' => wp_json_encode( $field['js_options'] ),
] );
$attributes['type'] = 'text';
if ( $field['alpha_channel'] ) {
$attributes['data-alpha-enabled'] = 'true';
$attributes['data-alpha-color-type'] = 'hex';
}
return $attributes;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param string $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
return sprintf( " ", $value );
}
}
fields/custom-html.php 0000644 00000001132 15154570313 0011000 0 ustar 00 ',
$field['collapse'] ? ' rwmb-collapse' : '',
$field['inline'] ? ' rwmb-inline' : ''
);
$output .= $walker->walk( $options, $field['flatten'] ? -1 : 0 );
$output .= '';
return $output;
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = $field['multiple'] ? RWMB_Multiple_Values_Field::normalize( $field ) : $field;
$field = RWMB_Input_Field::normalize( $field );
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'collapse' => true,
'inline' => null,
'select_all_none' => false,
] );
$field['flatten'] = $field['multiple'] ? $field['flatten'] : true;
$field['inline'] = ! $field['multiple'] && ! isset( $field['inline'] ) ? true : $field['inline'];
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = RWMB_Input_Field::get_attributes( $field, $value );
$attributes['id'] = false;
$attributes['type'] = $field['multiple'] ? 'checkbox' : 'radio';
$attributes['value'] = $value;
return $attributes;
}
/**
* Get html for select all|none for multiple checkbox.
*
* @param array $field Field parameters.
* @return string
*/
public static function get_select_all_html( $field ) {
if ( $field['multiple'] && $field['select_all_none'] ) {
return sprintf( '%s
', $field['id'], __( 'Toggle All', 'meta-box' ) );
}
return '';
}
}
fields/slider.php 0000644 00000004441 15154570313 0010014 0 ustar 00
%s%s %s
',
$field['id'],
esc_attr( wp_json_encode( $field['js_options'] ) ),
$field['prefix'],
$meta,
$field['suffix'],
$meta,
self::render_attributes( $attributes )
);
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'prefix' => '',
'suffix' => '',
'std' => '',
'js_options' => [],
] );
$field['js_options'] = wp_parse_args( $field['js_options'], [
'range' => 'min', // range = 'min' will add a dark background to sliding part, better UI.
'value' => $field['std'],
] );
return $field;
}
}
fields/taxonomy-advanced.php 0000644 00000005541 15154570313 0012155 0 ustar 00 $field['taxonomy'],
'include' => $term_ids,
'hide_empty' => false,
], $args );
$info = get_terms( $args );
$info = is_array( $info ) ? $info : [];
return $field['multiple'] ? $info : reset( $info );
}
}
fields/input.php 0000644 00000005714 15154570313 0007675 0 ustar 00 fields.
*/
abstract class RWMB_Input_Field extends RWMB_Field {
public static function admin_enqueue_scripts() {
wp_enqueue_style( 'rwmb-input', RWMB_CSS_URL . 'input.css', [], RWMB_VER );
wp_style_add_data( 'rwmb-input', 'path', RWMB_CSS_DIR . 'input.css' );
}
/**
* Get field HTML.
*
* @param mixed $meta Meta value.
* @param array $field Field parameters.
* @return string
*/
public static function html( $meta, $field ) {
$output = '';
if ( $field['prepend'] || $field['append'] ) {
$output = '';
}
if ( $field['prepend'] ) {
$output .= '' . $field['prepend'] . ' ';
}
$attributes = static::get_attributes( $field, $meta );
$output .= sprintf( ' %s', self::render_attributes( $attributes ), self::datalist( $field ) );
if ( $field['append'] ) {
$output .= '' . $field['append'] . ' ';
}
if ( $field['prepend'] || $field['append'] ) {
$output .= '
';
}
return $output;
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'autocomplete' => false,
'datalist' => false,
'readonly' => false,
'maxlength' => false,
'minlength' => false,
'pattern' => false,
'prepend' => '',
'append' => '',
] );
if ( $field['datalist'] ) {
$field['datalist'] = wp_parse_args( $field['datalist'], [
'id' => $field['id'] . '_list',
'options' => [],
] );
}
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes = wp_parse_args( $attributes, [
'autocomplete' => $field['autocomplete'],
'list' => $field['datalist'] ? $field['datalist']['id'] : false,
'readonly' => $field['readonly'],
'maxlength' => $field['maxlength'],
'minlength' => $field['minlength'],
'pattern' => $field['pattern'],
'value' => $value,
'placeholder' => $field['placeholder'],
'type' => $field['type'],
] );
if ( isset( $field['size'] ) ) {
$attributes['size'] = $field['size'];
}
return $attributes;
}
protected static function datalist( array $field ): string {
if ( empty( $field['datalist'] ) ) {
return '';
}
$datalist = $field['datalist'];
$html = sprintf( '', $datalist['id'] );
foreach ( $datalist['options'] as $option ) {
$html .= sprintf( ' ', $option );
}
$html .= ' ';
return $html;
}
}
fields/image-advanced.php 0000644 00000004265 15154570313 0011363 0 ustar 00 'thumbnail',
] );
$field = parent::normalize( $field );
$field['js_options'] = wp_parse_args( $field['js_options'], [
'imageSize' => $field['image_size'],
] );
return $field;
}
/**
* Get the field value.
*
* @param array $field Field parameters.
* @param array $args Additional arguments.
* @param ?int $post_id Post ID.
* @return mixed
*/
public static function get_value( $field, $args = [], $post_id = null ) {
return RWMB_Image_Field::get_value( $field, $args, $post_id );
}
/**
* Get uploaded file information.
*
* @param int $file Attachment image ID (post ID). Required.
* @param array $args Array of arguments (for size).
* @param array $field Field settings.
*
* @return array|bool False if file not found. Array of image info on success.
*/
public static function file_info( $file, $args = [], $field = [] ) {
return RWMB_Image_Field::file_info( $file, $args, $field );
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param array $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
return RWMB_Image_Field::format_single_value( $field, $value, $args, $post_id );
}
}
fields/select-tree.php 0000644 00000003013 15154570313 0010740 0 ustar 00 walk( $options ) : '';
}
public static function admin_enqueue_scripts() {
parent::admin_enqueue_scripts();
wp_enqueue_style( 'rwmb-select-tree', RWMB_CSS_URL . 'select-tree.css', [ 'rwmb-select' ], RWMB_VER );
wp_style_add_data( 'rwmb-select-tree', 'path', RWMB_CSS_DIR . 'select-tree.css' );
wp_enqueue_script( 'rwmb-select-tree', RWMB_JS_URL . 'select-tree.js', [ 'rwmb-select' ], RWMB_VER, true );
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field['multiple'] = true;
$field['size'] = 0;
$field = parent::normalize( $field );
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes['multiple'] = false;
$attributes['id'] = false;
return $attributes;
}
}
fields/number.php 0000644 00000001616 15154570313 0010023 0 ustar 00 .
*/
class RWMB_Number_Field extends RWMB_Input_Field {
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'step' => 1,
'min' => 0,
'max' => false,
] );
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes = wp_parse_args( $attributes, [
'step' => $field['step'],
'max' => $field['max'],
'min' => $field['min'],
] );
return $attributes;
}
}
fields/media.php 0000644 00000015142 15154570313 0007611 0 ustar 00 apply_filters( 'rwmb_media_add_string', _x( '+ Add Media', 'media', 'meta-box' ) ),
'single' => apply_filters( 'rwmb_media_single_files_string', _x( ' file', 'media', 'meta-box' ) ),
'multiple' => apply_filters( 'rwmb_media_multiple_files_string', _x( ' files', 'media', 'meta-box' ) ),
'remove' => apply_filters( 'rwmb_media_remove_string', _x( 'Remove', 'media', 'meta-box' ) ),
'edit' => apply_filters( 'rwmb_media_edit_string', _x( 'Edit', 'media', 'meta-box' ) ),
'view' => apply_filters( 'rwmb_media_view_string', _x( 'View', 'media', 'meta-box' ) ),
'noTitle' => _x( 'No Title', 'media', 'meta-box' ),
'loadingUrl' => admin_url( 'images/spinner.gif' ),
'extensions' => static::get_mime_extensions(),
'select' => apply_filters( 'rwmb_media_select_string', _x( 'Select Files', 'media', 'meta-box' ) ),
'or' => apply_filters( 'rwmb_media_or_string', _x( 'or', 'media', 'meta-box' ) ),
'uploadInstructions' => apply_filters( 'rwmb_media_upload_instructions_string', _x( 'Drop files here to upload', 'media', 'meta-box' ) ),
] );
}
/**
* Get meta value.
*
* @param int $post_id Post ID.
* @param bool $saved Whether the meta box is saved at least once.
* @param array $field Field parameters.
*
* @return mixed
*/
public static function meta( $post_id, $saved, $field ) {
$meta = parent::meta( $post_id, $saved, $field );
/*
* Update meta cache for all attachments, preparing for getting data for rendering in JS.
* This reduces the number of queries for updating all attachments' meta.
* @see get_attributes()
*/
$ids = (array) $meta;
if ( $field['clone'] ) {
foreach ( $ids as &$value ) {
$value = (array) $value;
}
$ids = call_user_func_array( 'array_merge', $ids );
}
update_meta_cache( 'post', $ids );
return $meta;
}
/**
* Get field HTML.
*
* @param mixed $meta Meta value.
* @param array $field Field parameters.
*
* @return string
*/
public static function html( $meta, $field ) {
$attributes = static::get_attributes( $field, $meta );
$html = sprintf(
' ',
self::render_attributes( $attributes ),
esc_attr( wp_json_encode( $field['js_options'] ) )
);
return $html;
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'std' => [],
'mime_type' => '',
'max_file_uploads' => 0,
'force_delete' => false,
'max_status' => true,
'js_options' => [],
'add_to' => 'end',
] );
$field['js_options'] = wp_parse_args( $field['js_options'], [
'mimeType' => $field['mime_type'],
'maxFiles' => $field['max_file_uploads'],
'forceDelete' => $field['force_delete'],
'maxStatus' => $field['max_status'],
'addTo' => $field['add_to'],
] );
$field['multiple'] = true;
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$value = (array) $value;
$attributes = parent::get_attributes( $field, $value );
$attributes['type'] = 'hidden';
$attributes['name'] = $field['clone'] ? str_replace( '[]', '', $attributes['name'] ) : $attributes['name'];
$attributes['id'] = false;
$attributes['value'] = implode( ',', $value );
$attributes['class'] .= ' rwmb-media';
// Add attachment details.
$attachments = array_values( array_filter( array_map( 'wp_prepare_attachment_for_js', $value ) ) );
$attributes['data-attachments'] = wp_json_encode( $attachments );
if ( empty( $attachments ) ) {
unset( $attributes['value'] );
}
return $attributes;
}
protected static function get_mime_extensions() : array {
$mime_types = wp_get_mime_types();
$extensions = [];
foreach ( $mime_types as $ext => $mime ) {
$ext = explode( '|', $ext );
$extensions[ $mime ] = $ext;
$mime_parts = explode( '/', $mime );
if ( empty( $extensions[ $mime_parts[0] ] ) ) {
$extensions[ $mime_parts[0] ] = [];
}
$extensions[ $mime_parts[0] ] = array_merge( $extensions[ $mime_parts[0] ], $ext );
$extensions[ $mime_parts[0] . '/*' ] = $extensions[ $mime_parts[0] ];
}
return $extensions;
}
/**
* Get meta values to save.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
*
* @return array
*/
public static function value( $new, $old, $post_id, $field ) {
$new = wp_parse_id_list( $new );
if ( empty( $new ) ) {
return [];
}
// Attach the uploaded images to the post if needed.
global $wpdb;
$ids = implode( ',', $new );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent=%d WHERE post_parent=0 AND ID IN ($ids)", $post_id ) );
return $new;
}
/**
* Save meta value.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
*/
public static function save( $new, $old, $post_id, $field ) {
if ( empty( $field['id'] ) || ! $field['save_field'] ) {
return;
}
$storage = $field['storage'];
$storage->delete( $post_id, $field['id'] );
parent::save( $new, [], $post_id, $field );
}
}
fields/range.php 0000644 00000003010 15154570313 0007615 0 ustar 00
%s
%s
',
parent::html( $meta, $field ),
$meta
);
}
public static function admin_enqueue_scripts() {
wp_enqueue_style( 'rwmb-range', RWMB_CSS_URL . 'range.css', [], RWMB_VER );
wp_style_add_data( 'rwmb-range', 'path', RWMB_CSS_DIR . 'range.css' );
wp_enqueue_script( 'rwmb-range', RWMB_JS_URL . 'range.js', [], RWMB_VER, true );
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = wp_parse_args( $field, [
'max' => 10,
] );
$field = parent::normalize( $field );
return $field;
}
/**
* Ensure number in range.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
*
* @return int
*/
public static function value( $new, $old, $post_id, $field ) {
$new = (float) $new;
$min = (float) $field['min'];
$max = (float) $field['max'];
if ( $new < $min ) {
return $min;
}
if ( $new > $max ) {
return $max;
}
return $new;
}
}
fields/textarea.php 0000644 00000003114 15154570313 0010343 0 ustar 00 %s',
self::render_attributes( $attributes ),
esc_textarea( $meta )
);
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'autocomplete' => false,
'cols' => false,
'rows' => 3,
'maxlength' => false,
'minlength' => false,
'wrap' => false,
'readonly' => false,
] );
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes = wp_parse_args( $attributes, [
'autocomplete' => $field['autocomplete'],
'cols' => $field['cols'],
'rows' => $field['rows'],
'maxlength' => $field['maxlength'],
'minlength' => $field['minlength'],
'wrap' => $field['wrap'],
'readonly' => $field['readonly'],
'placeholder' => $field['placeholder'],
] );
return $attributes;
}
}
fields/select-advanced.php 0000644 00000004631 15154570313 0011555 0 ustar 00 is_admin(),
]);
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = wp_parse_args( $field, [
'js_options' => [],
'placeholder' => __( 'Select an item', 'meta-box' ),
] );
$field = parent::normalize( $field );
$field['js_options'] = wp_parse_args( $field['js_options'], [
'allowClear' => true,
'dropdownAutoWidth' => true,
'placeholder' => $field['placeholder'],
'width' => 'style',
] );
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes = wp_parse_args( $attributes, [
'data-options' => wp_json_encode( $field['js_options'] ),
] );
return $attributes;
}
}
fields/image.php 0000644 00000011435 15154570313 0007615 0 ustar 00 .
*/
class RWMB_Image_Field extends RWMB_File_Field {
public static function admin_enqueue_scripts() {
parent::admin_enqueue_scripts();
wp_enqueue_media();
wp_enqueue_style( 'rwmb-image', RWMB_CSS_URL . 'image.css', [], RWMB_VER );
wp_style_add_data( 'rwmb-image', 'path', RWMB_CSS_DIR . 'image.css' );
}
/**
* Get HTML for uploaded file.
*
* @param int $file Attachment (file) ID.
* @param int $index File index.
* @param array $field Field data.
*
* @return string
*/
protected static function file_html( $file, $index, $field ) {
$attributes = self::get_attributes( $field, $file );
$edit_link = get_edit_post_link( $file );
if ( $edit_link ) {
$edit_link = sprintf( ' ', $edit_link );
}
$attachment_image = is_numeric( $file ) ? wp_get_attachment_image( $file, $field['image_size'] ) : ' ';
return sprintf(
'
%s
',
$attachment_image,
$edit_link,
esc_attr( $file ),
esc_attr( $attributes['name'] ),
esc_attr( $index ),
esc_attr( $file )
);
}
/**
* Normalize field settings.
*
* @param array $field Field settings.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [ 'image_size' => 'thumbnail' ] );
$field['attributes'] = wp_parse_args( $field['attributes'], [ 'accept' => 'image/*' ] );
return $field;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param array $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
$output = sprintf( ' ', esc_url( $value['url'] ), esc_attr( $value['alt'] ) );
// Link thumbnail to full size image?
if ( ! empty( $args['link'] ) ) {
$output = sprintf( '%s ', esc_url( $value['full_url'] ), esc_attr( $value['title'] ), $output );
}
return $output;
}
/**
* Get uploaded file information.
*
* @param int $file Attachment image ID (post ID). Required.
* @param array $args Array of arguments (for size).
* @param array $field Field settings.
*
* @return array|bool False if file not found. Array of image info on success.
*/
public static function file_info( $file, $args = [], $field = [] ) {
if ( ! empty( $field['upload_dir'] ) ) {
return self::file_info_custom_dir( $file, $field );
}
$path = get_attached_file( $file );
if ( ! $path ) {
return false;
}
$args = wp_parse_args( $args, [ 'size' => 'thumbnail' ] );
$image = wp_get_attachment_image_src( $file, $args['size'] );
if ( ! $image ) {
return false;
}
$attachment = get_post( $file );
$info = [
'ID' => $file,
'name' => basename( $path ),
'path' => $path,
'url' => $image[0],
'full_url' => wp_get_attachment_url( $file ),
'title' => $attachment->post_title,
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'alt' => get_post_meta( $file, '_wp_attachment_image_alt', true ),
];
if ( function_exists( 'wp_get_attachment_image_srcset' ) ) {
$info['srcset'] = wp_get_attachment_image_srcset( $file, $args['size'] );
}
$info = wp_parse_args( $info, self::get_image_meta_data( $file ) );
// Do not overwrite width and height by returned value of image meta.
$info['width'] = $image[1];
$info['height'] = $image[2];
return $info;
}
/**
* Get image meta data.
*
* @param int $attachment_id Attachment ID.
* @return array
*/
protected static function get_image_meta_data( $attachment_id ) {
$metadata = wp_get_attachment_metadata( $attachment_id );
if ( empty( $metadata['sizes'] ) ) {
return $metadata;
}
$dir_url = dirname( wp_get_attachment_url( $attachment_id ) );
foreach ( $metadata['sizes'] as &$size ) {
$size['url'] = "{$dir_url}/{$size['file']}";
}
return $metadata;
}
}
fields/password.php 0000644 00000004327 15154570313 0010377 0 ustar 00
';
$output .= $button;
return $output;
}
/**
* Store secured password in the database.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
* @return string
*/
public static function value( $new, $old, $post_id, $field ) {
$new = $new !== $old ? wp_hash_password( $new ) : $new;
return $new;
}
}
fields/file-input.php 0000644 00000003671 15154570313 0010612 0 ustar 00 esc_html__( 'Select File', 'meta-box' ),
] );
}
/**
* Get field HTML.
*
* @param mixed $meta Meta value.
* @param array $field Field parameters.
*
* @return string
*/
public static function html( $meta, $field ) {
$attributes = self::get_attributes( $field, $meta );
$meta_array = explode( '.', $meta );
$file_ext = strtolower( end( $meta_array ) );
$extensions = [ 'jpeg', 'jpg', 'png', 'gif' ];
return sprintf(
'
',
in_array( $file_ext, $extensions, true ) ? '' : 'rwmb-file-input-hidden',
$meta,
self::render_attributes( $attributes ),
esc_html__( 'Select', 'meta-box' ),
$meta ? '' : 'hidden',
esc_html__( 'Remove', 'meta-box' )
);
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes['type'] = 'text';
return $attributes;
}
}
fields/osm.php 0000644 00000013244 15154570313 0007331 0 ustar 00 __( 'No results found', 'meta-box' ),
] );
}
/**
* Get field HTML.
*
* @param mixed $meta Meta value.
* @param array $field Field parameters.
*
* @return string
*/
public static function html( $meta, $field ) {
$address = is_array( $field['address_field'] ) ? implode( ',', $field['address_field'] ) : $field['address_field'];
$html = sprintf(
'',
esc_attr( $address )
);
$attributes = self::get_attributes( $field, $meta );
$attributes['type'] = 'hidden';
$attributes['value'] = $meta;
$html .= sprintf(
'
',
esc_attr( $field['std'] ),
esc_attr( $field['region'] ),
esc_attr( $field['language'] ),
esc_attr( $field['marker_draggable'] ? 'true' : 'false' ),
self::render_attributes( $attributes )
);
$html .= '
';
return $html;
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'std' => '',
'address_field' => '',
'language' => '',
'region' => '',
'marker_draggable' => true,
] );
return $field;
}
/**
* Get the field value.
* The difference between this function and 'meta' function is 'meta' function always returns the escaped value
* of the field saved in the database, while this function returns more meaningful value of the field.
*
* @param array $field Field parameters.
* @param array $args Not used for this field.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return mixed Array(latitude, longitude, zoom)
*/
public static function get_value( $field, $args = [], $post_id = null ) {
$value = parent::get_value( $field, $args, $post_id );
if ( is_array( $value ) ) {
$location = [];
foreach ( $value as $clone ) {
list( $latitude, $longitude, $zoom ) = explode( ',', $clone . ',,' );
$location[] = compact( 'latitude', 'longitude', 'zoom' );
}
return $location;
}
list( $latitude, $longitude, $zoom ) = explode( ',', $value . ',,' );
return compact( 'latitude', 'longitude', 'zoom' );
}
/**
* Format value before render map
* @param mixed $field
* @param mixed $value
* @param mixed $args
* @param mixed $post_id
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ): string {
return self::render_map( $value, $args );
}
/**
* Render a map in the frontend.
*
* @param string|array $location The "latitude,longitude[,zoom]" location.
* @param array $args Additional arguments for the map.
*
* @return string
*/
public static function render_map( $location, $args = [] ) {
// For compatibility with previous version, or within groups.
if ( is_string( $location ) ) {
list( $latitude, $longitude, $zoom ) = explode( ',', $location . ',,' );
} else {
extract( $location );
}
if ( ! $latitude || ! $longitude ) {
return '';
}
$args = wp_parse_args( $args, [
'latitude' => $latitude,
'longitude' => $longitude,
'width' => '100%',
'height' => '480px',
'marker' => true, // Display marker?
'marker_title' => '', // Marker title, when hover.
'info_window' => '', // Content of info window (when click on marker). HTML allowed.
'js_options' => [],
'zoom' => $zoom,
] );
self::enqueue_map_assets();
wp_enqueue_script( 'rwmb-osm-frontend', RWMB_JS_URL . 'osm-frontend.js', [ 'jquery', 'leaflet' ], RWMB_VER, true );
wp_enqueue_style( 'rwmb-osm-frontend', RWMB_CSS_URL . 'osm-frontend.css', [], RWMB_VER );
wp_style_add_data( 'rwmb-osm-frontend', 'path', RWMB_CSS_DIR . 'osm-frontend.css' );
/*
* More Open Street Map options
* @link https://leafletjs.com/reference-1.5.0.html#map-option
*/
$args['js_options'] = wp_parse_args( $args['js_options'], [
// Default to 'zoom' level set in admin, but can be overwritten.
'zoom' => $args['zoom'],
] );
$output = sprintf(
'
',
esc_attr( wp_json_encode( $args ) ),
esc_attr( $args['width'] ),
esc_attr( $args['height'] )
);
return $output;
}
private static function enqueue_map_assets() {
wp_enqueue_style( 'leaflet', RWMB_JS_URL . 'leaflet/leaflet.css', [], '1.9.4' );
wp_style_add_data( 'leaflet', 'path', RWMB_JS_URL . 'leaflet/leaflet.css' );
wp_enqueue_script( 'leaflet', RWMB_JS_URL . 'leaflet/leaflet.js', [], '1.9.4', true );
wp_enqueue_style( 'leaflet-gesture-handling', RWMB_JS_URL . 'leaflet/leaflet-gesture-handling.min.css', [ 'leaflet' ], '1.2.2' );
wp_style_add_data( 'leaflet-gesture-handling', 'path', RWMB_JS_URL . 'leaflet/leaflet-gesture-handling.min.css' );
wp_enqueue_script( 'leaflet-gesture-handling', RWMB_JS_URL . 'leaflet/leaflet-gesture-handling.min.js', [ 'leaflet' ], '1.2.2' );
}
}
fields/divider.php 0000644 00000001141 15154570313 0010152 0 ustar 00 ";
}
public static function end_html( array $field ) : string {
return '';
}
}
fields/checkbox-list.php 0000644 00000000724 15154570313 0011271 0 ustar 00 true,
'query_args' => [],
'field_type' => 'select_advanced',
'add_new' => false,
'ajax' => true,
] );
if ( 'select_advanced' !== $field['field_type'] ) {
$field['ajax'] = false;
}
if ( 'checkbox_tree' === $field['field_type'] ) {
$field['field_type'] = 'checkbox_list';
$field['flatten'] = false;
}
if ( 'radio_list' === $field['field_type'] ) {
$field['field_type'] = 'radio';
}
$field = call_user_func( [ self::get_type_class( $field ), 'normalize' ], $field );
return $field;
}
/**
* Set ajax parameters.
*
* @param array $field Field settings.
*/
protected static function set_ajax_params( &$field ) {
if ( ! $field['ajax'] ) {
return;
}
if ( empty( $field['js_options']['ajax'] ) ) {
$field['js_options']['ajax'] = [];
}
$field['js_options']['ajax'] = wp_parse_args(
[
'url' => admin_url( 'admin-ajax.php' ),
],
$field['js_options']['ajax']
);
$field['js_options']['ajax_data'] = [
'field' => [
'id' => $field['id'],
'type' => $field['type'],
'query_args' => $field['query_args'],
],
'_wpnonce' => wp_create_nonce( 'query' ),
];
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = call_user_func( [ self::get_type_class( $field ), 'get_attributes' ], $field, $value );
if ( 'select_advanced' === $field['field_type'] ) {
$attributes['class'] .= ' rwmb-select_advanced';
} elseif ( 'select' === $field['field_type'] ) {
$attributes['class'] .= ' rwmb-select';
}
return $attributes;
}
public static function admin_enqueue_scripts() {
RWMB_Input_List_Field::admin_enqueue_scripts();
RWMB_Select_Field::admin_enqueue_scripts();
RWMB_Select_Tree_Field::admin_enqueue_scripts();
RWMB_Select_Advanced_Field::admin_enqueue_scripts();
// Field is the 1st param.
$field = func_get_arg( 0 );
if ( empty( $field['add_new'] ) ) {
return;
}
wp_enqueue_style( 'rwmb-modal', RWMB_CSS_URL . 'modal.css', [], RWMB_VER );
wp_style_add_data( 'rwmb-modal', 'path', RWMB_CSS_DIR . 'modal.css' );
wp_enqueue_script( 'rwmb-modal', RWMB_JS_URL . 'modal.js', [ 'jquery' ], RWMB_VER, true );
$type = $field['type'] === 'taxonomy_advanced' ? 'taxonomy' : $field['type'];
wp_enqueue_script( "rwmb-$type", RWMB_JS_URL . "$type.js", [ 'jquery', 'rwmb-modal' ], RWMB_VER, true );
}
/**
* Get correct rendering class for the field.
*/
protected static function get_type_class( array $field ) : string {
return RWMB_Helpers_Field::get_class( [ 'type' => $field['field_type'] ] );
}
}
fields/taxonomy.php 0000644 00000022115 15154570313 0010406 0 ustar 00 filter_post( 'field', FILTER_DEFAULT, FILTER_FORCE_ARRAY );
// Required for 'choice_label' filter. See self::filter().
$field['clone'] = false;
$field['_original_id'] = $field['id'];
// Search.
$field['query_args']['name__like'] = $request->filter_post( 'term' );
// Pagination.
$limit = $field['query_args']['number'] ?? 0;
$limit = (int) $limit;
if ( 'query:append' === $request->filter_post( '_type' ) ) {
$page = $request->filter_post( 'page', FILTER_SANITIZE_NUMBER_INT );
$field['query_args']['offset'] = $limit * ( $page - 1 );
}
// Query the database.
$items = self::query( null, $field );
$items = array_values( $items );
$items = apply_filters( 'rwmb_ajax_get_terms', $items, $field, $request );
$data = [ 'items' => $items ];
// More items for pagination.
if ( $limit && count( $items ) === $limit ) {
$data['more'] = true;
}
wp_send_json_success( $data );
}
/**
* Add default value for 'taxonomy' field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
// Backwards compatibility with field args.
if ( isset( $field['options']['args'] ) ) {
$field['query_args'] = $field['options']['args'];
}
if ( isset( $field['options']['taxonomy'] ) ) {
$field['taxonomy'] = $field['options']['taxonomy'];
}
if ( isset( $field['options']['type'] ) ) {
$field['field_type'] = $field['options']['type'];
}
// Set default field args.
$field = wp_parse_args( $field, [
'taxonomy' => 'category',
'query_args' => [],
'remove_default' => false,
] );
// Force taxonomy to be an array.
$field['taxonomy'] = (array) $field['taxonomy'];
/*
* Set default placeholder:
* - If multiple taxonomies: show 'Select a term'.
* - If single taxonomy: show 'Select a %taxonomy_name%'.
*/
$placeholder = __( 'Select a term', 'meta-box' );
$taxonomy_name = self::get_taxonomy_singular_name( $field );
if ( $taxonomy_name ) {
// Translators: %s is the taxonomy singular label.
$placeholder = sprintf( __( 'Select a %s', 'meta-box' ), strtolower( $taxonomy_name ) );
}
$field = wp_parse_args( $field, [
'placeholder' => $placeholder,
] );
$field = parent::normalize( $field );
// Set default query args.
$limit = $field['ajax'] ? 10 : 0;
$field['query_args'] = wp_parse_args( $field['query_args'], [
'taxonomy' => $field['taxonomy'],
'number' => $limit,
] );
parent::set_ajax_params( $field );
// Prevent cloning for taxonomy field, not for child fields (taxonomy_advanced).
if ( 'taxonomy' === $field['type'] ) {
$field['clone'] = false;
}
return $field;
}
public static function query( $meta, array $field ): array {
$args = wp_parse_args( $field['query_args'], [
'hide_empty' => false,
'count' => false,
'update_term_meta_cache' => false,
] );
$meta = wp_parse_id_list( (array) $meta );
// Query only selected items.
if ( ! empty( $field['ajax'] ) && ! empty( $meta ) ) {
$args['include'] = $meta;
$args['number'] = count( $meta );
}
$terms = get_terms( $args );
if ( ! is_array( $terms ) ) {
return [];
}
$options = [];
foreach ( $terms as $term ) {
$label = $term->name ? $term->name : __( '(No title)', 'meta-box' );
$label = self::filter( 'choice_label', $label, $field, $term );
$options[ $term->term_id ] = [
'value' => $term->term_id,
'label' => $label,
'parent' => $term->parent,
];
}
return $options;
}
/**
* Get meta values to save.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
*
* @return array
*/
public static function value( $new, $old, $post_id, $field ) {
$new = (array) $new;
$new[] = self::add_term( $field );
$new = array_filter( wp_parse_id_list( $new ) );
return $new;
}
/**
* Save meta value.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
*/
public static function save( $new, $old, $post_id, $field ) {
if ( empty( $field['id'] ) || ! $field['save_field'] ) {
return;
}
foreach ( $field['taxonomy'] as $taxonomy ) {
wp_set_object_terms( $post_id, $new, $taxonomy );
}
}
/**
* Add new terms if users created some.
*
* @param array $field Field settings.
* @return int|null Term ID if added successfully, null otherwise.
*/
protected static function add_term( $field ) {
$term = rwmb_request()->post( $field['id'] . '_new' );
if ( ! $field['add_new'] || ! $term || 1 !== count( $field['taxonomy'] ) ) {
return null;
}
$taxonomy = reset( $field['taxonomy'] );
$term = wp_insert_term( $term, $taxonomy );
if ( is_wp_error( $term ) ) {
return null;
}
return $term['term_id'] ?? null;
}
/**
* Get raw meta value.
*
* @param int $object_id Object ID.
* @param array $field Field parameters.
* @param array $args Arguments of {@see rwmb_meta()} helper.
*
* @return mixed
*/
public static function raw_meta( $object_id, $field, $args = [] ) {
if ( empty( $field['id'] ) ) {
return '';
}
$meta = wp_get_object_terms( $object_id, $field['taxonomy'], [
'orderby' => 'term_order',
] );
$meta = wp_list_pluck( $meta, 'term_id' );
return $field['multiple'] ? $meta : reset( $meta );
}
/**
* Get the field value.
* Return list of post term objects.
*
* @param array $field Field parameters.
* @param array $args Additional arguments.
* @param ?int $post_id Post ID.
*
* @return array List of post term objects.
*/
public static function get_value( $field, $args = [], $post_id = null ) {
if ( ! $post_id ) {
$post_id = get_the_ID();
}
$value = wp_get_object_terms( $post_id, $field['taxonomy'], [
'orderby' => 'term_order',
] );
// Get single value if necessary.
if ( ! $field['clone'] && ! $field['multiple'] ) {
$value = reset( $value );
}
return $value;
}
/**
* Format a single value for the helper functions.
*
* @param array $field Field parameters.
* @param WP_Term $value The term object.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param ?int $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
if ( empty( $value ) ) {
return '';
}
$link = $args['link'] ?? 'view';
$text = $value->name;
if ( false === $link ) {
return $text;
}
$url = get_term_link( $value );
if ( 'edit' === $link ) {
$url = get_edit_term_link( $value );
}
return sprintf( '%s ', esc_url( $url ), esc_html( $text ) );
}
public static function add_new_form( array $field ): string {
if ( ! current_user_can( 'edit_posts' ) ) {
return '';
}
// Only add new term if field has only one taxonomy.
if ( 1 !== count( $field['taxonomy'] ) ) {
return '';
}
$taxonomy = reset( $field['taxonomy'] );
$taxonomy_object = get_taxonomy( $taxonomy );
if ( false === $taxonomy_object ) {
return '';
}
return sprintf(
'%s ',
admin_url( 'edit-tags.php?taxonomy=' . $taxonomy_object->name ),
esc_html( $taxonomy_object->labels->add_new_item )
);
}
public static function admin_enqueue_scripts() {
$field = func_get_arg( 0 );
parent::admin_enqueue_scripts( $field );
static::remove_default_meta_box( $field );
}
protected static function remove_default_meta_box( array $field ) {
if ( empty( $field['remove_default'] ) || ! function_exists( 'remove_meta_box' ) ) {
return;
}
// Only run in admin.
if ( ! is_admin() ) {
return;
}
// Do nothing if in Ajax or Rest API.
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
return;
}
foreach ( $field['taxonomy'] as $taxonomy ) {
$id = is_taxonomy_hierarchical( $taxonomy ) ? "{$taxonomy}div" : "tagsdiv-{$taxonomy}";
remove_meta_box( $id, null, 'side' );
}
}
protected static function get_taxonomy_singular_name( array $field ): string {
if ( 1 !== count( $field['taxonomy'] ) ) {
return '';
}
$taxonomy = reset( $field['taxonomy'] );
$taxonomy_object = get_taxonomy( $taxonomy );
return false === $taxonomy_object ? '' : $taxonomy_object->labels->singular_name;
}
}
fields/wysiwyg.php 0000644 00000004437 15154570313 0010261 0 ustar 00 ';
echo '';
return ob_get_clean();
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'raw' => false,
'options' => [],
] );
$field['options'] = wp_parse_args( $field['options'], [
'editor_class' => 'rwmb-wysiwyg',
'dfw' => true, // Use default WordPress full screen UI.
] );
// Keep the filter to be compatible with previous versions.
$field['options'] = apply_filters( 'rwmb_wysiwyg_settings', $field['options'] );
return $field;
}
}
fields/autocomplete.php 0000644 00000005676 15154570313 0011246 0 ustar 00 __( 'Delete', 'meta-box' ),
] );
}
/**
* Get field HTML.
*
* @param mixed $meta Meta value.
* @param array $field Field parameters.
* @return string
*/
public static function html( $meta, $field ) {
if ( ! is_array( $meta ) ) {
$meta = [ $meta ];
}
// Filter out empty values in case the array started with empty or 0 values
$meta = array_filter( $meta, function ( $index ) use ( $meta ) {
return $meta[ $index ] !== '';
}, ARRAY_FILTER_USE_KEY );
$field = apply_filters( 'rwmb_autocomplete_field', $field, $meta );
$options = $field['options'];
if ( is_array( $field['options'] ) ) {
$options = [];
foreach ( $field['options'] as $value => $label ) {
$options[] = [
'value' => (string) $value,
'label' => $label,
];
}
$options = wp_json_encode( $options );
}
// Input field that triggers autocomplete.
// This field doesn't store field values, so it doesn't have "name" attribute.
// The value(s) of the field is store in hidden input(s). See below.
$html = sprintf(
'
',
esc_attr( $field['field_name'] ),
esc_attr( $options )
);
$html .= '';
// Each value is displayed with label and 'Delete' option.
// The hidden input has to have ".rwmb-*" class to make clone work.
$tpl = '
';
if ( is_array( $field['options'] ) ) {
foreach ( $field['options'] as $value => $label ) {
if ( ! in_array( $value, $meta ) ) {
continue;
}
$html .= sprintf(
$tpl,
esc_html( $label ),
esc_html__( 'Delete', 'meta-box' ),
esc_attr( $field['field_name'] ),
esc_attr( $value )
);
}
} else {
$meta = array_filter( $meta );
foreach ( $meta as $value ) {
$label = apply_filters( 'rwmb_autocomplete_result_label', $value, $field );
$html .= sprintf(
$tpl,
esc_html( $label ),
esc_html__( 'Delete', 'meta-box' ),
esc_attr( $field['field_name'] ),
esc_attr( $value )
);
}
}
$html .= '
'; // .rwmb-autocomplete-results.
return $html;
}
}
fields/image-select.php 0000644 00000004505 15154570313 0011072 0 ustar 00 $image ) {
$attributes = self::get_attributes( $field, $value );
$html[] = sprintf(
' ',
$image,
self::render_attributes( $attributes ),
checked( in_array( $value, $meta ), true, false )
);
}
return implode( ' ', $html );
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field['options'] = $field['options'] ?? [];
$field['field_name'] .= $field['multiple'] ? '[]' : '';
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes['id'] = false;
$attributes['type'] = $field['multiple'] ? 'checkbox' : 'radio';
$attributes['value'] = $value;
return $attributes;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param string $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
return $value ? sprintf( ' ', esc_url( $field['options'][ $value ] ) ) : '';
}
}
fields/radio.php 0000644 00000000416 15154570313 0007626 0 ustar 00 '', 'oo' => '', '@' => '', "''" => "'".
*
* @var array
*/
protected static $date_formats = [
'd' => 'j',
'dd' => 'd',
'oo' => 'z',
'D' => 'D',
'DD' => 'l',
'm' => 'n',
'mm' => 'm',
'M' => 'M',
'MM' => 'F',
'y' => 'y',
'yy' => 'Y',
'o' => 'z',
];
/**
* Translate time format from jQuery UI time picker to PHP date().
* It's used to store timestamp value of the field.
* Missing: 't' => '', T' => '', 'm' => '', 's' => ''.
*
* @var array
*/
protected static $time_formats = [
'H' => 'G',
'HH' => 'H',
'h' => 'g',
'hh' => 'h',
'mm' => 'i',
'ss' => 's',
'l' => 'u',
'tt' => 'a',
'TT' => 'A',
];
public static function register_assets() {
// jQueryUI base theme: https://github.com/jquery/jquery-ui/tree/1.13.2/themes/base
$url = RWMB_CSS_URL . 'jqueryui';
wp_register_style( 'jquery-ui-core', "$url/core.css", [], '1.13.2' );
wp_style_add_data( 'jquery-ui-core', 'path', RWMB_CSS_DIR . 'jqueryui/core.css' );
wp_register_style( 'jquery-ui-theme', "$url/theme.css", [], '1.13.2' );
wp_style_add_data( 'jquery-ui-theme', 'path', RWMB_CSS_DIR . 'jqueryui/theme.css' );
wp_register_style( 'jquery-ui-datepicker', "$url/datepicker.css", [ 'jquery-ui-core', 'jquery-ui-theme' ], '1.13.2' );
wp_style_add_data( 'jquery-ui-datepicker', 'path', RWMB_CSS_DIR . 'jqueryui/datepicker.css' );
wp_register_style( 'jquery-ui-slider', "$url/slider.css", [ 'jquery-ui-core', 'jquery-ui-theme' ], '1.13.2' );
wp_style_add_data( 'jquery-ui-slider', 'path', RWMB_CSS_DIR . 'jqueryui/slider.css' );
// jQueryUI timepicker addon: https://github.com/trentrichardson/jQuery-Timepicker-Addon
wp_register_style( 'jquery-ui-timepicker', "$url/jquery-ui-timepicker-addon.min.css", [ 'rwmb-date', 'jquery-ui-slider' ], '1.6.3' );
wp_style_add_data( 'jquery-ui-timepicker', 'path', RWMB_CSS_DIR . 'jqueryui/jquery-ui-timepicker-addon.min.css' );
wp_register_style( 'rwmb-date', RWMB_CSS_URL . 'date.css', [ 'jquery-ui-datepicker' ], RWMB_VER );
wp_style_add_data( 'rwmb-date', 'path', RWMB_CSS_DIR . 'date.css' );
// Scripts.
$url = RWMB_JS_URL . 'jqueryui';
wp_register_script( 'jquery-ui-timepicker', "$url/jquery-ui-timepicker-addon.min.js", [ 'jquery-ui-datepicker', 'jquery-ui-slider' ], '1.6.3', true );
wp_register_script( 'jquery-ui-timepicker-slider', "$url/jquery-ui-sliderAccess.js", [ 'jquery-ui-datepicker', 'jquery-ui-slider' ], '0.3', true );
wp_register_script( 'jquery-ui-timepicker-i18n', "$url/jquery-ui-timepicker-addon-i18n.min.js", [ 'jquery-ui-timepicker' ], '1.6.3', true );
wp_register_script( 'rwmb-datetime', RWMB_JS_URL . 'datetime.js', [ 'jquery-ui-datepicker', 'jquery-ui-timepicker-i18n', 'underscore', 'jquery-ui-button', 'jquery-ui-timepicker-slider', 'rwmb' ], RWMB_VER, true );
wp_register_script( 'rwmb-date', RWMB_JS_URL . 'date.js', [ 'jquery-ui-datepicker', 'underscore', 'rwmb' ], RWMB_VER, true );
wp_register_script( 'rwmb-time', RWMB_JS_URL . 'time.js', [ 'jquery-ui-timepicker-i18n', 'jquery-ui-button', 'jquery-ui-timepicker-slider', 'rwmb' ], RWMB_VER, true );
$handles = [ 'datetime', 'time' ];
$locale = str_replace( '_', '-', get_user_locale() );
$locale_short = substr( $locale, 0, 2 );
$data = [
'locale' => $locale,
'localeShort' => $locale_short,
];
foreach ( $handles as $handle ) {
RWMB_Helpers_Field::localize_script_once( "rwmb-$handle", 'RWMB_' . ucfirst( $handle ), $data );
}
}
/**
* Enqueue scripts and styles.
*/
public static function admin_enqueue_scripts() {
self::register_assets();
wp_enqueue_style( 'jquery-ui-timepicker' );
wp_enqueue_script( 'rwmb-datetime' );
}
/**
* Get field HTML.
*
* @param mixed $meta The field meta value.
* @param array $field The field parameters.
*
* @return string
*/
public static function html( $meta, $field ) {
$output = '';
if ( $field['timestamp'] ) {
$name = $field['field_name'];
$field = wp_parse_args( [ 'field_name' => $name . '[formatted]' ], $field );
$timestamp = $meta['timestamp'] ?? 0;
$output .= sprintf(
' ',
esc_attr( $name . '[timestamp]' ),
(int) $timestamp
);
$meta = $meta['formatted'] ?? '';
}
$output .= parent::html( $meta, $field );
if ( $field['inline'] ) {
$output .= '
';
}
return $output;
}
/**
* Calculates the timestamp from the datetime string and returns it if $field['timestamp'] is set or the datetime string if not.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
*
* @return string|int
*/
public static function value( $new, $old, $post_id, $field ) {
if ( $field['timestamp'] ) {
if ( is_array( $new ) ) {
return $new['timestamp'];
}
if ( ! is_numeric( $new ) ) {
return strtotime( $new );
}
return $new;
}
if ( $field['save_format'] ) {
// Fix 'c' and 'r' formats not containing WordPress timezone.
$timezone = in_array( $field['save_format'], [ 'c', 'r' ], true ) ? wp_timezone() : null;
$date = DateTimeImmutable::createFromFormat( $field['php_format'], $new, $timezone );
return $date === false ? $new : $date->format( $field['save_format'] );
}
return $new;
}
/**
* Get meta value.
*
* @param int $post_id The post ID.
* @param bool $saved Whether the meta box is saved at least once.
* @param array $field The field parameters.
*
* @return mixed
*/
public static function meta( $post_id, $saved, $field ) {
$meta = parent::meta( $post_id, $saved, $field );
if ( $field['timestamp'] ) {
return Arr::map( $meta, __CLASS__ . '::from_timestamp', $field );
}
if ( $field['save_format'] && $meta ) {
return Arr::map( $meta, __CLASS__ . '::from_save_format', $field );
}
return $meta;
}
/**
* Format meta value if set 'timestamp'.
*/
public static function from_timestamp( $meta, array $field ): array {
return [
'timestamp' => $meta ?: null,
'formatted' => $meta ? gmdate( $field['php_format'], intval( $meta ) ) : '',
];
}
/**
* Transform meta value from save format to the JS format.
*/
public static function from_save_format( $meta, array $field ): string {
$formats = array_merge(
[
$field['save_format'] => $field['save_format'],
],
[
'c' => DateTimeInterface::ATOM,
'r' => DateTimeInterface::RFC2822,
]
);
$format = $formats[ $field['save_format'] ];
$date = DateTimeImmutable::createFromFormat( $format, $meta );
return false === $date ? (string) $meta : $date->format( $field['php_format'] );
}
/**
* Normalize parameters for field.
*
* @param array $field The field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = wp_parse_args( $field, [
'timestamp' => false,
'inline' => false,
'js_options' => [],
'save_format' => '',
'autocomplete' => 'off',
] );
// Deprecate 'format', but keep it for backward compatible.
// Use 'js_options' instead.
$field['js_options'] = wp_parse_args( $field['js_options'], [
'timeFormat' => 'HH:mm',
'separator' => ' ',
'dateFormat' => $field['format'] ?? 'yy-mm-dd',
'showButtonPanel' => true,
'changeYear' => true,
'yearRange' => '-100:+100',
'changeMonth' => true,
'oneLine' => true,
'stepMinute' => 5,
'controlType' => 'select', // select or slider
'addSliderAccess' => true,
'sliderAccessArgs' => [
'touchonly' => true, // To show sliderAccess only on touch devices
],
] );
if ( $field['inline'] ) {
$field['js_options'] = wp_parse_args( $field['js_options'], [ 'altFieldTimeOnly' => false ] );
}
$field['php_format'] = static::get_php_format( $field['js_options'] );
$field = parent::normalize( $field );
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field The field parameters.
* @param mixed $value The meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes = wp_parse_args( $attributes, [ 'data-options' => wp_json_encode( $field['js_options'] ) ] );
$attributes['type'] = 'text';
return $attributes;
}
/**
* Returns a date() compatible format string from the JavaScript format.
* @link http://www.php.net/manual/en/function.date.php
*/
protected static function get_php_format( array $js_options ): string {
return strtr( $js_options['dateFormat'], self::$date_formats )
. $js_options['separator']
. strtr( $js_options['timeFormat'], self::$time_formats );
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param string $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
if ( $field['timestamp'] ) {
$value = self::from_timestamp( $value, $field );
} else {
$value = [
'timestamp' => strtotime( $value ),
'formatted' => $value,
];
}
return empty( $args['format'] ) ? $value['formatted'] : gmdate( $args['format'], $value['timestamp'] );
}
}
fields/fieldset-text.php 0000644 00000006561 15154570313 0011320 0 ustar 00 %s %s';
if ( ! is_array( $field['options'] ) ) {
return '';
}
foreach ( $field['options'] as $key => $label ) {
$value = $meta[ $key ] ?? '';
$field['attributes']['name'] = $field['field_name'] . "[{$key}]";
$html[] = sprintf( $tpl, $label, parent::html( $value, $field ) );
}
$out = '' . ( $field['desc'] ? '' . $field['desc'] . ' ' : '' ) . implode( ' ', $html ) . ' ';
return $out;
}
protected static function input_description( array $field ) : string {
return '';
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field['multiple'] = false;
$field['attributes']['id'] = false;
$field['attributes']['type'] = 'text';
return $field;
}
/**
* Format value for the helper functions.
*
* @param array $field Field parameters.
* @param string|array $value The field meta value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_value( $field, $value, $args, $post_id ) {
$output = '';
foreach ( $field['options'] as $label ) {
$output .= "$label ";
}
$output .= ' ';
if ( ! $field['clone'] ) {
$output .= self::format_single_value( $field, $value, $args, $post_id );
} else {
foreach ( $value as $subvalue ) {
$output .= self::format_single_value( $field, $subvalue, $args, $post_id );
}
}
$output .= '
';
return $output;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param array $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
$output = '';
foreach ( $value as $subvalue ) {
$output .= "$subvalue ";
}
$output .= ' ';
return $output;
}
/**
* Since we're using an array of text fields, we need to check if all of them are empty.
* Otherwise, there is no way to know if the field is empty or not.
*/
public static function value( $new, $old, $post_id, $field ) {
$all_empty = empty( array_filter( (array) $new ) );
return $all_empty ? [] : $new;
}
}
fields/file-upload.php 0000644 00000001671 15154570313 0010735 0 ustar 00 0,
] );
$field['js_options'] = wp_parse_args( $field['js_options'], [
'maxFileSize' => $field['max_file_size'],
] );
return $field;
}
}
fields/post.php 0000644 00000016272 15154570313 0007524 0 ustar 00 filter_post( 'field', FILTER_DEFAULT, FILTER_FORCE_ARRAY );
// Required for 'choice_label' filter. See self::filter().
$field['clone'] = false;
$field['_original_id'] = $field['id'];
// Search.
$field['query_args']['s'] = $request->filter_post( 'term' );
// Pagination.
if ( 'query:append' === $request->filter_post( '_type' ) ) {
$field['query_args']['paged'] = $request->filter_post( 'page', FILTER_SANITIZE_NUMBER_INT );
}
// Query the database.
$items = self::query( null, $field );
$items = array_values( $items );
$items = apply_filters( 'rwmb_ajax_get_posts', $items, $field, $request );
$data = [ 'items' => $items ];
// More items for pagination.
$limit = (int) $field['query_args']['posts_per_page'];
if ( -1 !== $limit && count( $items ) === $limit ) {
$data['more'] = true;
}
wp_send_json_success( $data );
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = wp_parse_args( $field, [
'post_type' => 'post',
'parent' => false,
'query_args' => [],
] );
$field['post_type'] = (array) $field['post_type'];
/*
* Set default placeholder:
* - If multiple post types: show 'Select a post'.
* - If single post type: show 'Select a %post_type_name%'.
*/
$placeholder = __( 'Select a post', 'meta-box' );
if ( 1 === count( $field['post_type'] ) ) {
$post_type = reset( $field['post_type'] );
$post_type_object = get_post_type_object( $post_type );
if ( ! empty( $post_type_object ) ) {
// Translators: %s is the post singular label.
$placeholder = sprintf( __( 'Select a %s', 'meta-box' ), strtolower( $post_type_object->labels->singular_name ) );
}
}
$field = wp_parse_args( $field, [
'placeholder' => $placeholder,
] );
// Set parent option, which will change field name to `parent_id` to save as post parent.
if ( $field['parent'] ) {
$field['multiple'] = false;
$field['field_name'] = 'parent_id';
}
$field = parent::normalize( $field );
// Set default query args.
$posts_per_page = $field['ajax'] ? 10 : -1;
$field['query_args'] = wp_parse_args( $field['query_args'], [
'post_type' => $field['post_type'],
'post_status' => 'publish',
'posts_per_page' => $posts_per_page,
] );
parent::set_ajax_params( $field );
return $field;
}
public static function query( $meta, array $field ): array {
$args = wp_parse_args( $field['query_args'], [
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'mb_field_id' => $field['id'],
] );
$meta = wp_parse_id_list( (array) $meta );
// Query only selected items.
if ( ! empty( $field['ajax'] ) && ! empty( $meta ) ) {
$args['posts_per_page'] = count( $meta );
$args['post__in'] = $meta;
}
// Get from cache to prevent same queries.
$last_changed = wp_cache_get_last_changed( 'posts' );
$key = md5( serialize( $args ) );
$cache_key = "$key:$last_changed";
$options = wp_cache_get( $cache_key, 'meta-box-post-field' );
if ( false !== $options ) {
return $options;
}
// Only search by title.
add_filter( 'posts_search', [ __CLASS__, 'search_by_title' ], 10, 2 );
$query = new WP_Query( $args );
remove_filter( 'posts_search', [ __CLASS__, 'search_by_title' ] );
$options = [];
foreach ( $query->posts as $post ) {
if ( ! current_user_can( 'read_post', $post ) ) {
continue;
}
$label = $post->post_title ? $post->post_title : __( '(No title)', 'meta-box' );
$label = self::filter( 'choice_label', $label, $field, $post );
$options[ $post->ID ] = [
'value' => $post->ID,
'label' => $label,
'parent' => $post->post_parent,
];
}
// Cache the query.
wp_cache_set( $cache_key, $options, 'meta-box-post-field' );
return $options;
}
/**
* Only search posts by title.
* WordPress searches by either title or content which is confused when users can't find their posts.
*
* @link https://developer.wordpress.org/reference/hooks/posts_search/
*/
public static function search_by_title( $search, $wp_query ) {
global $wpdb;
if ( empty( $search ) ) {
return $search;
}
$q = $wp_query->query_vars;
$n = ! empty( $q['exact'] ) ? '' : '%';
$search = [];
foreach ( (array) $q['search_terms'] as $term ) {
$term = esc_sql( $wpdb->esc_like( $term ) );
$search[] = "($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";
}
if ( empty( $search ) ) {
return $search;
}
$search = ' AND (' . implode( ' AND ', $search ) . ') ';
if ( ! is_user_logged_in() ) {
$search .= " AND ($wpdb->posts.post_password = '') ";
}
return $search;
}
/**
* Get meta value.
* If field is cloneable, value is saved as a single entry in DB.
* Otherwise value is saved as multiple entries (for backward compatibility).
*
* @see "save" method for better understanding
*
* @param int $post_id Post ID.
* @param bool $saved Is the meta box saved.
* @param array $field Field parameters.
*
* @return mixed
*/
public static function meta( $post_id, $saved, $field ) {
return $field['parent'] ? wp_get_post_parent_id( $post_id ) : parent::meta( $post_id, $saved, $field );
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param int $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param ?int $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
if ( empty( $value ) ) {
return '';
}
$link = $args['link'] ?? 'view';
$text = get_the_title( $value );
if ( false === $link ) {
return $text;
}
$url = get_permalink( $value );
if ( 'edit' === $link ) {
$url = get_edit_post_link( $value );
}
return sprintf( '%s ', esc_url( $url ), wp_kses_post( $text ) );
}
public static function add_new_form( array $field ): string {
if ( ! current_user_can( 'edit_posts' ) ) {
return '';
}
if ( 1 !== count( $field['post_type'] ) ) {
return '';
}
$post_type = reset( $field['post_type'] );
if ( ! post_type_exists( $post_type ) ) {
return '';
}
$post_type_object = get_post_type_object( $post_type );
return sprintf(
'%s ',
admin_url( $post_type === 'post' ? 'post-new.php' : 'post-new.php?post_type=' . $post_type ),
esc_html( $post_type_object->labels->add_new_item )
);
}
}
fields/text-list.php 0000644 00000006557 15154570313 0010501 0 ustar 00 %s ';
$attributes = self::get_attributes( $field, $meta );
$attributes['type'] = 'text';
$count = 0;
foreach ( $field['options'] as $placeholder => $label ) {
$attributes['value'] = $meta[ $count ] ?? '';
$attributes['placeholder'] = $placeholder;
$html[] = sprintf(
$input,
$label,
self::render_attributes( $attributes )
);
$count ++;
}
return implode( ' ', $html );
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
if ( ! $field['clone'] ) {
$field['class'] .= ' rwmb-text_list-non-cloneable';
}
return $field;
}
/**
* Set value of meta before saving into database.
* Do not save if all inputs has no value.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
*
* @return mixed
*/
public static function value( $new, $old, $post_id, $field ) {
$filtered = array_filter( $new );
return count( $filtered ) ? $new : [];
}
/**
* Format value for the helper functions.
*
* @param array $field Field parameters.
* @param string|array $value The field meta value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_value( $field, $value, $args, $post_id ) {
$output = '';
foreach ( $field['options'] as $label ) {
$output .= "$label ";
}
$output .= ' ';
if ( ! $field['clone'] ) {
$output .= self::format_single_value( $field, $value, $args, $post_id );
} else {
foreach ( $value as $subvalue ) {
$output .= self::format_single_value( $field, $subvalue, $args, $post_id );
}
}
$output .= '
';
return $output;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param array $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
$output = '';
foreach ( $value as $subvalue ) {
$output .= "$subvalue ";
}
$output .= ' ';
return $output;
}
}
fields/multiple-values.php 0000644 00000002521 15154570313 0011657 0 ustar 00 ',
self::render_attributes( $attributes ),
checked( ! empty( $meta ), 1, false )
);
if ( $field['desc'] ) {
$output = "$output {$field['desc']} ";
}
return $output;
}
protected static function input_description( array $field ) : string {
return '';
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param string $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
return $value ? __( 'Yes', 'meta-box' ) : __( 'No', 'meta-box' );
}
}
fields/button.php 0000644 00000002412 15154570313 0010041 0 ustar 00 %s', self::render_attributes( $attributes ), $field['std'] );
}
/**
* Normalize parameters for field.
*
* @param array $field The field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = wp_parse_args( $field, [
'std' => __( 'Click me', 'meta-box' ),
] );
$field = parent::normalize( $field );
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field The field parameters.
* @param mixed $value The attribute value.
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes = wp_parse_args( $attributes, [
'type' => $field['type'],
] );
$attributes['class'] .= ' button hide-if-no-js';
return $attributes;
}
}
fields/key-value.php 0000644 00000005561 15154570313 0010440 0 ustar 00 ', self::render_attributes( $attributes ) );
// Value.
$val = isset( $meta[1] ) ? $meta[1] : '';
$attributes = self::get_attributes( $field, $val );
$attributes['placeholder'] = $field['placeholder']['value'];
$html .= sprintf( ' ', self::render_attributes( $attributes ) );
return $html;
}
protected static function begin_html( array $field ) : string {
return parent::begin_html( $field ) . parent::input_description( $field );
}
protected static function input_description( array $field ) : string {
return '';
}
/**
* Sanitize field value.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
*
* @return array
*/
public static function value( $new, $old, $post_id, $field ) {
foreach ( $new as &$arr ) {
if ( empty( $arr[0] ) && empty( $arr[1] ) ) {
$arr = false;
}
}
$new = array_filter( $new );
return $new;
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field['clone'] = true;
$field['multiple'] = true;
$field = parent::normalize( $field );
$field['attributes']['type'] = 'text';
$field['placeholder'] = wp_parse_args( (array) $field['placeholder'], [
'key' => __( 'Key', 'meta-box' ),
'value' => __( 'Value', 'meta-box' ),
] );
return $field;
}
/**
* Format value for the helper functions.
*
* @param array $field Field parameters.
* @param string|array $value The field meta value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_clone_value( $field, $value, $args, $post_id ) {
return sprintf( '%s: %s', $value[0], $value[1] );
}
}
fields/file.php 0000644 00000036621 15154570313 0007456 0 ustar 00 .
*/
class RWMB_File_Field extends RWMB_Field {
public static function admin_enqueue_scripts() {
wp_enqueue_style( 'rwmb-file', RWMB_CSS_URL . 'file.css', [], RWMB_VER );
wp_style_add_data( 'rwmb-file', 'path', RWMB_CSS_DIR . 'file.css' );
wp_enqueue_script( 'rwmb-file', RWMB_JS_URL . 'file.js', [ 'jquery-ui-sortable' ], RWMB_VER, true );
RWMB_Helpers_Field::localize_script_once( 'rwmb-file', 'rwmbFile', [
// Translators: %d is the number of files in singular form.
'maxFileUploadsSingle' => __( 'You may only upload maximum %d file', 'meta-box' ),
// Translators: %d is the number of files in plural form.
'maxFileUploadsPlural' => __( 'You may only upload maximum %d files', 'meta-box' ),
] );
}
public static function add_actions() {
add_action( 'post_edit_form_tag', [ __CLASS__, 'post_edit_form_tag' ] );
add_action( 'wp_ajax_rwmb_delete_file', [ __CLASS__, 'ajax_delete_file' ] );
}
public static function post_edit_form_tag() {
echo ' enctype="multipart/form-data"';
}
public static function ajax_delete_file() {
$request = rwmb_request();
$field_id = (string) $request->filter_post( 'field_id' );
$type = str_contains( $request->filter_post( 'field_name' ), '[' ) ? 'child' : 'top';
check_ajax_referer( "rwmb-delete-file_{$field_id}" );
if ( 'child' === $type ) {
$field_group = explode( '[', $request->filter_post( 'field_name' ) );
$field_id = $field_group[0]; // This is top parent field_id.
}
// Make sure the file to delete is in the custom field.
$attachment = $request->post( 'attachment_id' );
$object_id = $request->filter_post( 'object_id' );
$object_type = (string) $request->filter_post( 'object_type' );
$field = rwmb_get_field_settings( $field_id, [ 'object_type' => $object_type ], $object_id );
$field_value = self::raw_meta( $object_id, $field );
if ( ! self::in_array_r( $attachment, $field_value ) ) {
wp_send_json_error( __( 'Error: Invalid file', 'meta-box' ) );
}
// Delete the file.
if ( is_numeric( $attachment ) ) {
$result = wp_delete_attachment( $attachment );
} else {
$path = str_replace( home_url( '/' ), trailingslashit( ABSPATH ), $attachment );
$result = unlink( $path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.unlink_unlink
}
if ( $result ) {
wp_send_json_success();
}
wp_send_json_error( __( 'Error: Cannot delete file', 'meta-box' ) );
}
/**
* Recursively search needle in haystack
*/
protected static function in_array_r( $needle, $haystack, $strict = false ) : bool {
foreach ( $haystack as $item ) {
if ( ( $strict ? $item === $needle : $item == $needle ) || ( is_array( $item ) && self::in_array_r( $needle, $item, $strict ) ) ) {
return true;
}
}
return false;
}
/**
* Get field HTML.
*
* @param mixed $meta Meta value.
* @param array $field Field parameters.
*
* @return string
*/
public static function html( $meta, $field ) {
$meta = array_filter( (array) $meta );
$i18n_more = apply_filters( 'rwmb_file_add_string', _x( '+ Add new file', 'file upload', 'meta-box' ), $field );
$html = self::get_uploaded_files( $meta, $field );
// Show form upload.
$attributes = self::get_attributes( $field, $meta );
$attributes['type'] = 'file';
$attributes['name'] = "{$field['input_name']}[]";
$attributes['class'] = 'rwmb-file-input';
/*
* Use JavaScript to toggle 'required' attribute, because:
* - Field might already have value (uploaded files).
* - Be able to detect when uploading multiple files.
*/
if ( $attributes['required'] ) {
$attributes['data-required'] = 1;
$attributes['required'] = false;
}
// Upload new files.
$html .= sprintf(
'';
$html .= sprintf(
' ',
$field['index_name'],
$field['input_name']
);
return $html;
}
/**
* Get HTML for uploaded files.
*
* @param array $files List of uploaded files.
* @param array $field Field parameters.
* @return string
*/
protected static function get_uploaded_files( $files, $field ) {
$delete_nonce = wp_create_nonce( "rwmb-delete-file_{$field['id']}" );
$output = '';
foreach ( (array) $files as $k => $file ) {
// Ignore deleted files (if users accidentally deleted files or uses `force_delete` without saving post).
if ( get_attached_file( $file ) || $field['upload_dir'] ) {
$output .= static::file_html( $file, $k, $field );
}
}
return sprintf(
'',
$field['id'],
$field['field_name'],
$delete_nonce,
$field['force_delete'] ? 1 : 0,
$field['max_file_uploads'],
$field['mime_type'],
$output
);
}
/**
* Get HTML for uploaded file.
*
* @param int $file Attachment (file) ID.
* @param int $index File index.
* @param array $field Field data.
* @return string
*/
protected static function file_html( $file, $index, $field ) {
$i18n_delete = apply_filters( 'rwmb_file_delete_string', _x( 'Delete', 'file upload', 'meta-box' ) );
$i18n_edit = apply_filters( 'rwmb_file_edit_string', _x( 'Edit', 'file upload', 'meta-box' ) );
$attributes = self::get_attributes( $field, $file );
if ( ! $file ) {
return '';
}
if ( $field['upload_dir'] ) {
$data = self::file_info_custom_dir( $file, $field );
} else {
$data = [
'icon' => wp_get_attachment_image( $file, [ 48, 64 ], true ),
'name' => basename( get_attached_file( $file ) ),
'url' => wp_get_attachment_url( $file ),
'title' => get_the_title( $file ),
'edit_link' => '',
];
$edit_link = get_edit_post_link( $file );
if ( $edit_link ) {
$data['edit_link'] = sprintf( '%s ', $edit_link, $i18n_edit );
}
}
return sprintf(
'
%s
',
$data['icon'],
esc_url( $data['url'] ),
esc_html( $data['title'] ),
esc_html( $data['name'] ),
$data['edit_link'],
esc_attr( $file ),
esc_html( $i18n_delete ),
esc_attr( $attributes['name'] ),
esc_attr( $index ),
esc_attr( $file )
);
}
protected static function file_info_custom_dir( string $file, array $field ) : array {
$path = wp_normalize_path( trailingslashit( $field['upload_dir'] ) . basename( $file ) );
$ext = pathinfo( $path, PATHINFO_EXTENSION );
$icon_url = wp_mime_type_icon( wp_ext2type( $ext ) );
$data = [
'icon' => ' ',
'name' => basename( $path ),
'path' => $path,
'url' => $file,
'title' => preg_replace( '/\.[^.]+$/', '', basename( $path ) ),
'edit_link' => '',
];
return $data;
}
/**
* Get meta values to save.
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $post_id The post ID.
* @param array $field The field parameters.
*
* @return array|mixed
*/
public static function value( $new, $old, $post_id, $field ) {
$input = $field['index'] ?? $field['input_name'];
// @codingStandardsIgnoreLine
if ( empty( $input ) || empty( $_FILES[ $input ] ) ) {
return $new;
}
$new = array_filter( (array) $new );
$count = self::transform( $input );
for ( $i = 0; $i < $count; $i ++ ) {
$attachment = self::handle_upload( "{$input}_{$i}", $post_id, $field );
if ( $attachment && ! is_wp_error( $attachment ) ) {
$new[] = $attachment;
}
}
return $new;
}
/**
* Get meta values to save for cloneable fields.
*
* @param array $new The submitted meta value.
* @param array $old The existing meta value.
* @param int $object_id The object ID.
* @param array $field The field settings.
* @param array $data_source Data source. Either $_POST or custom array. Used in group to get uploaded files.
*
* @return mixed
*/
public static function clone_value( $new, $old, $object_id, $field, $data_source = null ) {
if ( ! $data_source ) {
// @codingStandardsIgnoreLine
$data_source = $_POST;
}
$indexes = $data_source[ "_index_{$field['id']}" ] ?? [];
foreach ( $indexes as $key => $index ) {
$field['index'] = $index;
$old_value = $old[ $key ] ?? [];
$value = $new[ $key ] ?? [];
$value = self::value( $value, $old_value, $object_id, $field );
$new[ $key ] = self::filter( 'sanitize', $value, $field, $old_value, $object_id );
}
return $new;
}
/**
* Handle file upload.
* Consider upload to Media Library or custom folder.
*
* @param string $file_id File ID in $_FILES when uploading.
* @param int $post_id Post ID.
* @param array $field Field settings.
*
* @return \WP_Error|int|string WP_Error if has error, attachment ID if upload in Media Library, URL to file if upload to custom folder.
*/
protected static function handle_upload( $file_id, $post_id, $field ) {
return $field['upload_dir'] ? self::handle_upload_custom_dir( $file_id, $field ) : media_handle_upload( $file_id, $post_id );
}
/**
* Transform $_FILES from $_FILES['field']['key']['index'] to $_FILES['field_index']['key'].
*
* @param string $input_name The field input name.
*
* @return int The number of uploaded files.
*/
protected static function transform( $input_name ): int {
// phpcs:disable
foreach ( $_FILES[ $input_name ] as $key => $list ) {
foreach ( $list as $index => $value ) {
$file_key = sanitize_text_field( "{$input_name}_{$index}" );
if ( ! isset( $_FILES[ $file_key ] ) ) {
$_FILES[ $file_key ] = [];
}
$_FILES[ $file_key ][ $key ] = $value;
}
}
return count( $_FILES[ $input_name ]['name'] );
// phpcs:enable
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'std' => [],
'force_delete' => false,
'max_file_uploads' => 0,
'mime_type' => '',
'upload_dir' => '',
'unique_filename_callback' => null,
] );
$field['multiple'] = true;
$field['input_name'] = "_file_{$field['id']}";
$field['index_name'] = "_index_{$field['id']}";
return $field;
}
/**
* Get the field value. Return meaningful info of the files.
*
* @param array $field Field parameters.
* @param array $args Not used for this field.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return mixed Full info of uploaded files
*/
public static function get_value( $field, $args = [], $post_id = null ) {
$value = parent::get_value( $field, $args, $post_id );
if ( ! $field['clone'] ) {
$value = static::files_info( $field, $value, $args );
} else {
$return = [];
foreach ( $value as $subvalue ) {
$return[] = static::files_info( $field, $subvalue, $args );
}
$value = $return;
}
if ( isset( $args['limit'] ) ) {
$value = array_slice( $value, 0, intval( $args['limit'] ) );
}
return $value;
}
/**
* Get uploaded files information.
*
* @param array $field Field parameters.
* @param array $files Files IDs.
* @param array $args Additional arguments (for image size).
* @return array
*/
public static function files_info( $field, $files, $args ) {
$return = [];
foreach ( (array) $files as $file ) {
$info = static::file_info( $file, $args, $field );
if ( $info ) {
$return[ $file ] = $info;
}
}
return $return;
}
/**
* Get uploaded file information.
*
* @param int $file Attachment file ID (post ID). Required.
* @param array $args Array of arguments (for size).
* @param array $field Field settings.
*
* @return array|bool False if file not found. Array of (id, name, path, url) on success.
*/
public static function file_info( $file, $args = [], $field = [] ) {
if ( ! empty( $field['upload_dir'] ) ) {
return self::file_info_custom_dir( $file, $field );
}
$path = get_attached_file( $file );
if ( ! $path ) {
return false;
}
return wp_parse_args(
[
'ID' => $file,
'name' => basename( $path ),
'path' => $path,
'url' => wp_get_attachment_url( $file ),
'title' => get_the_title( $file ),
],
wp_get_attachment_metadata( $file )
);
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param array $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
return sprintf( '%s ', esc_url( $value['url'] ), esc_html( $value['title'] ) );
}
/**
* Handle upload for files in custom directory.
*
* @param string $file_id File ID in $_FILES when uploading.
* @param array $field Field settings.
*
* @return string URL to uploaded file.
*/
public static function handle_upload_custom_dir( $file_id, $field ) {
// @codingStandardsIgnoreStart
if ( empty( $_FILES[ $file_id ] ) ) {
return;
}
$file = $_FILES[ $file_id ];
// @codingStandardsIgnoreEnd
// Use a closure to filter upload directory. Requires PHP >= 5.3.0.
$filter_upload_dir = function( $uploads ) use ( $field ) {
$uploads['path'] = $field['upload_dir'];
$uploads['url'] = self::convert_path_to_url( $field['upload_dir'] );
$uploads['subdir'] = '';
$uploads['basedir'] = $field['upload_dir'];
return $uploads;
};
// Make sure upload dir is inside WordPress.
$upload_dir = wp_normalize_path( untrailingslashit( $field['upload_dir'] ) );
$root = wp_normalize_path( untrailingslashit( ABSPATH ) );
if ( ! str_starts_with( $upload_dir, $root ) ) {
return;
}
// Let WordPress handle upload to the custom directory.
add_filter( 'upload_dir', $filter_upload_dir );
$overrides = [
'test_form' => false,
'unique_filename_callback' => $field['unique_filename_callback'],
];
$file_info = wp_handle_upload( $file, $overrides );
remove_filter( 'upload_dir', $filter_upload_dir );
return empty( $file_info['url'] ) ? null : $file_info['url'];
}
public static function convert_path_to_url( string $path ) : string {
$path = wp_normalize_path( untrailingslashit( $path ) );
$root = wp_normalize_path( untrailingslashit( ABSPATH ) );
$relative_path = str_replace( $root, '', $path );
return home_url( $relative_path );
}
}
fields/switch.php 0000644 00000004514 15154570313 0010034 0 ustar 00
' . $field['on_label'] . '
' . $field['off_label'] . '
',
self::render_attributes( $attributes ),
checked( ! empty( $meta ), 1, false )
);
return $output;
}
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
$field = parent::normalize( $field );
$field = wp_parse_args( $field, [
'style' => 'rounded',
'on_label' => '',
'off_label' => '',
] );
return $field;
}
/**
* Get the attributes for a field.
*
* @param array $field The field parameters.
* @param mixed $value The attribute value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes['type'] = 'checkbox';
return $attributes;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param string $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
$on = $field['on_label'] ?: __( 'On', 'meta-box' );
$off = $field['off_label'] ?: __( 'Off', 'meta-box' );
return $value ? $on : $off;
}
}
fields/oembed.php 0000644 00000010066 15154570313 0007765 0 ustar 00 __( 'Embed HTML not available.', 'meta-box' ),
] );
$field['attributes'] = wp_parse_args( $field['attributes'], [
'data-not-available' => $field['not_available_string'],
] );
return $field;
}
public static function admin_enqueue_scripts() {
wp_enqueue_style( 'rwmb-oembed', RWMB_CSS_URL . 'oembed.css', [], RWMB_VER );
wp_style_add_data( 'rwmb-oembed', 'path', RWMB_CSS_DIR . 'oembed.css' );
wp_enqueue_script( 'rwmb-oembed', RWMB_JS_URL . 'oembed.js', [ 'jquery', 'underscore', 'rwmb' ], RWMB_VER, true );
wp_localize_script( 'rwmb-oembed', 'rwmbOembed', [
'nonce' => wp_create_nonce( 'oembed_get' ),
] );
}
public static function add_actions() {
add_action( 'wp_ajax_rwmb_get_embed', [ __CLASS__, 'ajax_get_embed' ] );
}
public static function ajax_get_embed() {
check_ajax_referer( 'oembed_get' );
$request = rwmb_request();
$url = (string) $request->filter_post( 'url', FILTER_SANITIZE_URL );
$not_available = (string) $request->post( 'not_available' );
wp_send_json_success( self::get_embed( $url, $not_available ) );
}
/**
* Get embed html from url.
*
* @param string $url URL.
* @param string $not_available Not available string displayed to users.
* @return string
*/
public static function get_embed( $url, $not_available = '' ) {
/**
* Set arguments for getting embedded HTML.
* Without arguments, default width will be taken from global $content_width, which can break UI in the admin.
*
* @link https://github.com/rilwis/meta-box/issues/801
* @see WP_oEmbed::fetch()
* @see WP_Embed::shortcode()
* @see wp_embed_defaults()
*/
$args = [];
if ( is_admin() ) {
$args['width'] = 360;
}
// Try oembed first.
$embed = wp_oembed_get( $url, $args );
// If no oembed provides found, try WordPress auto embed.
if ( ! $embed ) {
global $wp_embed;
$temp = $wp_embed->return_false_on_fail;
$wp_embed->return_false_on_fail = true; // Do not fallback to make a link.
$embed = $wp_embed->shortcode( $args, $url );
$wp_embed->return_false_on_fail = $temp;
}
if ( $not_available ) {
$not_available = '' . wp_kses_post( $not_available ) . '
';
}
$not_available = apply_filters( 'rwmb_oembed_not_available_string', $not_available, $url );
return $embed ? $embed : $not_available;
}
/**
* Get field HTML.
*
* @param mixed $meta Meta value.
* @param array $field Field parameters.
* @return string
*/
public static function html( $meta, $field ) {
return parent::html( $meta, $field ) . sprintf(
'
%s
',
$meta ? self::get_embed( $meta, $field['not_available_string'] ) : ''
);
}
/**
* Get the attributes for a field.
*
* @param array $field Field parameters.
* @param mixed $value Meta value.
*
* @return array
*/
public static function get_attributes( $field, $value = null ) {
$attributes = parent::get_attributes( $field, $value );
$attributes['type'] = 'url';
return $attributes;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param string $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
return self::get_embed( $value, $field['not_available_string'] );
}
}
fields/sidebar.php 0000644 00000002343 15154570313 0010142 0 ustar 00 __( 'Select a sidebar', 'meta-box' ),
] );
$field = parent::normalize( $field );
return $field;
}
public static function query( $meta, array $field ) : array {
global $wp_registered_sidebars;
$options = [];
foreach ( $wp_registered_sidebars as $sidebar ) {
$options[ $sidebar['id'] ] = [
'value' => $sidebar['id'],
'label' => $sidebar['name'],
];
}
return $options;
}
/**
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
*
* @param array $field Field parameters.
* @param string $value The value.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string
*/
public static function format_single_value( $field, $value, $args, $post_id ) {
if ( ! is_active_sidebar( $value ) ) {
return '';
}
ob_start();
dynamic_sidebar( $value );
return ob_get_clean();
}
}
storage-registry.php 0000644 00000000642 15154570313 0010575 0 ustar 00 storages[ $class_name ] ) ) {
$this->storages[ $class_name ] = new $class_name();
}
return $this->storages[ $class_name ];
}
}
wpml.php 0000644 00000006755 15154570313 0006255 0 ustar 00 get( $meta_data['key'], get_post_type( $meta_data['master_post_id'] ) );
if ( false === $field || ! in_array( $field['type'], $this->field_types, true ) ) {
return $value;
}
// Object type needed for WPML filter differs between fields.
$object_type = 'taxonomy_advanced' === $field['type'] ? $field['taxonomy'] : $field['post_type'];
// Translating values, whether are stored as comma separated strings or not.
if ( ! str_contains( $value, ',' ) ) {
$value = apply_filters( 'wpml_object_id', $value, $object_type, true, $target_language );
return $value;
}
// Dealing with IDs stored as comma separated strings.
$translated_values = [];
$values = explode( ',', $value );
foreach ( $values as $v ) {
$translated_values[] = apply_filters( 'wpml_object_id', $v, $object_type, true, $target_language );
}
$value = implode( ',', $translated_values );
return $value;
}
/**
* Modified field depends on its translation status.
* If the post is a translated version of another post and the field is set to:
* - Do not translate: hide the field.
* - Copy: make it disabled so users cannot edit.
* - Translate: do nothing.
*
* @param array $field Field parameters.
*
* @return mixed
*/
public function modify_field( $field ) {
global $wpml_post_translations;
if ( empty( $field['id'] ) ) {
return $field;
}
// Get post ID.
$request = rwmb_request();
$post_id = $request->filter_get( 'post', FILTER_SANITIZE_NUMBER_INT );
if ( ! $post_id ) {
$post_id = $request->filter_post( 'post_ID', FILTER_SANITIZE_NUMBER_INT );
}
// If the post is the original one: do nothing.
if ( ! method_exists( $wpml_post_translations, 'get_source_lang_code' ) || ! $wpml_post_translations->get_source_lang_code( $post_id ) ) {
return $field;
}
// Get setting for the custom field translation.
$custom_fields_translation = apply_filters( 'wpml_sub_setting', false, 'translation-management', 'custom_fields_translation' );
if ( ! isset( $custom_fields_translation[ $field['id'] ] ) ) {
return $field;
}
$setting = intval( $custom_fields_translation[ $field['id'] ] );
if ( 0 === $setting ) { // Do not translate: hide it.
$field['class'] .= ' hidden';
} elseif ( 1 === $setting ) { // Copy: disable editing.
$field['disabled'] = true;
}
return $field;
}
}
field-registry.php 0000644 00000003207 15154570313 0010214 0 ustar 00 data[ $object_type ] ) ) {
$this->data[ $object_type ] = [];
}
if ( empty( $this->data[ $object_type ][ $type ] ) ) {
$this->data[ $object_type ][ $type ] = [];
}
$this->data[ $object_type ][ $type ][ $field['id'] ] = $field;
do_action( 'rwmb_field_registered', $field, $type, $object_type );
}
/**
* Retrieve a field.
*
* @param string $id A meta box instance id.
* @param string $type Post type|Taxonomy|'user'|Setting page which the field belongs to.
* @param string $object_type Object type which the field belongs to.
*
* @return bool|array False or field configuration.
*/
public function get( $id, $type, $object_type = 'post' ) {
return $this->data[ $object_type ][ $type ][ $id ] ?? false;
}
/**
* Retrieve fields by object type.
*
* @param string $object_type Object type which the field belongs to.
*
* @return array List of fields.
*/
public function get_by_object_type( string $object_type = 'post' ) : array {
return $this->data[ $object_type ] ?? [];
}
}
functions.php 0000644 00000022775 15154570313 0007306 0 ustar 00 'post',
'type' => '',
] );
/**
* Filter meta type from object type and object id.
*
* @var string Meta type, default is post type name.
* @var string Object type.
* @var ?string|?int Object id.
*/
$type = apply_filters( 'rwmb_meta_type', $args['type'], $args['object_type'], $object_id );
if ( ! $type ) {
$type = get_post_type( $object_id );
}
return rwmb_get_registry( 'field' )->get( $key, $type, $args['object_type'] );
}
}
if ( ! function_exists( 'rwmb_meta_legacy' ) ) {
/**
* Get post meta.
*
* @param string $key Meta key. Required.
* @param array $args Array of arguments. Optional.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return mixed
*/
function rwmb_meta_legacy( $key, $args = [], $post_id = null ) {
$args = wp_parse_args( $args, [
'type' => 'text',
'multiple' => false,
'clone' => false,
] );
$field = [
'id' => $key,
'type' => $args['type'],
'clone' => $args['clone'],
'multiple' => $args['multiple'],
];
$method = 'get_value';
switch ( $args['type'] ) {
case 'taxonomy':
case 'taxonomy_advanced':
$field['taxonomy'] = $args['taxonomy'];
break;
case 'map':
case 'osm':
case 'oembed':
$method = 'the_value';
break;
}
$field = RWMB_Field::call( 'normalize', $field );
return RWMB_Field::call( $method, $field, $args, $post_id );
}
}
if ( ! function_exists( 'rwmb_get_value' ) ) {
/**
* Get value of custom field.
* This is used to replace old version of rwmb_meta key.
*
* @param string $field_id Field ID. Required.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return mixed false if field doesn't exist. Field value otherwise.
*/
function rwmb_get_value( $field_id, $args = [], $post_id = null ) {
$args = wp_parse_args( $args );
$field = rwmb_get_field_settings( $field_id, $args, $post_id );
// Get field value.
$value = $field ? RWMB_Field::call( 'get_value', $field, $args, $post_id ) : false;
/*
* Allow developers to change the returned value of field.
* For version < 4.8.2, the filter name was 'rwmb_get_field'.
*
* @param mixed $value Field value.
* @param array $field Field parameters.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*/
$value = apply_filters( 'rwmb_get_value', $value, $field, $args, $post_id );
return $value;
}
}
if ( ! function_exists( 'rwmb_the_value' ) ) {
/**
* Display the value of a field
*
* @param string $field_id Field ID. Required.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
* @param bool $echo Display field meta value? Default `true` which works in almost all cases. We use `false` for the [rwmb_meta] shortcode.
*
* @return string
*/
function rwmb_the_value( $field_id, $args = [], $post_id = null, $echo = true ) {
$args = wp_parse_args( $args );
$field = rwmb_get_field_settings( $field_id, $args, $post_id );
if ( ! $field ) {
return '';
}
$output = RWMB_Field::call( 'the_value', $field, $args, $post_id );
/*
* Allow developers to change the returned value of field.
* For version < 4.8.2, the filter name was 'rwmb_get_field'.
*
* @param mixed $value Field HTML output.
* @param array $field Field parameters.
* @param array $args Additional arguments. Rarely used. See specific fields for details.
* @param int|null $post_id Post ID. null for current post. Optional.
*/
$output = apply_filters( 'rwmb_the_value', $output, $field, $args, $post_id );
if ( $echo ) {
echo $output; // phpcs:ignore WordPress.Security.EscapeOutput
}
return $output;
}
}
if ( ! function_exists( 'rwmb_get_object_fields' ) ) {
/**
* Get defined meta fields for object.
*
* @param int|string $type_or_id Object ID or post type / taxonomy (for terms) / user (for users).
* @param string $object_type Object type. Use post, term.
*
* @return array
*/
function rwmb_get_object_fields( $type_or_id, $object_type = 'post' ) {
$meta_boxes = rwmb_get_registry( 'meta_box' )->get_by( [ 'object_type' => $object_type ] );
array_walk( $meta_boxes, 'rwmb_check_meta_box_supports', [ $object_type, $type_or_id ] );
$meta_boxes = array_filter( $meta_boxes );
$fields = [];
foreach ( $meta_boxes as $meta_box ) {
foreach ( $meta_box->fields as $field ) {
$fields[ $field['id'] ] = $field;
}
}
return $fields;
}
}
if ( ! function_exists( 'rwmb_check_meta_box_supports' ) ) {
/**
* Check if a meta box supports an object.
*
* @param object $meta_box Meta Box object.
* @param int $key Not used.
* @param array $object_data Object data (type and ID).
*/
function rwmb_check_meta_box_supports( &$meta_box, $key, $object_data ) {
list( $object_type, $type_or_id ) = $object_data;
$type = null;
$prop = null;
switch ( $object_type ) {
case 'post':
$type = is_numeric( $type_or_id ) ? get_post_type( $type_or_id ) : $type_or_id;
$prop = 'post_types';
break;
case 'term':
$type = $type_or_id;
if ( is_numeric( $type_or_id ) ) {
$term = get_term( $type_or_id );
$type = is_wp_error( $term ) || ! $term ? null : $term->taxonomy;
}
$prop = 'taxonomies';
break;
case 'user':
$type = 'user';
$prop = 'user';
break;
case 'setting':
$type = $type_or_id;
$prop = 'settings_pages';
break;
}
if ( ! $type ) {
$meta_box = false;
return;
}
if ( isset( $meta_box->meta_box[ $prop ] ) && ! in_array( $type, $meta_box->meta_box[ $prop ], true ) ) {
$meta_box = false;
}
}
}
if ( ! function_exists( 'rwmb_get_registry' ) ) {
/**
* Get the registry by type.
* Always return the same instance of the registry.
*
* @param string $type Registry type.
*
* @return object
*/
function rwmb_get_registry( $type ) {
static $data = [];
$class = 'RWMB_' . RWMB_Helpers_String::title_case( $type ) . '_Registry';
if ( ! isset( $data[ $type ] ) ) {
$data[ $type ] = new $class();
}
return $data[ $type ];
}
}
if ( ! function_exists( 'rwmb_get_storage' ) ) {
/**
* Get storage instance.
*
* @param string $object_type Object type. Use post or term.
* @param RW_Meta_Box $meta_box Meta box object. Optional.
* @return RWMB_Storage_Interface
*/
function rwmb_get_storage( $object_type, $meta_box = null ) {
$class = 'RWMB_' . RWMB_Helpers_String::title_case( $object_type ) . '_Storage';
$class = class_exists( $class ) ? $class : 'RWMB_Post_Storage';
$storage = rwmb_get_registry( 'storage' )->get( $class );
return apply_filters( 'rwmb_get_storage', $storage, $object_type, $meta_box );
}
}
if ( ! function_exists( 'rwmb_request' ) ) {
/**
* Get request object.
*
* @return RWMB_Request
*/
function rwmb_request() {
static $request;
if ( ! $request ) {
$request = new RWMB_Request();
}
return $request;
}
}
core.php 0000644 00000004475 15154570313 0006223 0 ustar 00 add_context_hooks();
}
public function plugin_links( array $links ) : array {
$links[] = '' . esc_html__( 'Docs', 'meta-box' ) . ' ';
return $links;
}
public function register_meta_boxes() {
$configs = apply_filters( 'rwmb_meta_boxes', [] );
$registry = rwmb_get_registry( 'meta_box' );
foreach ( $configs as $config ) {
if ( ! is_array( $config ) || empty( $config ) ) {
continue;
}
$meta_box = $registry->make( $config );
$meta_box->register_fields();
}
}
/**
* WordPress will prevent post data saving if a page template has been selected that does not exist.
* This is especially a problem when switching themes, and old page templates are in the post data.
* Unset the page template if the page does not exist to allow the post to save.
*/
public function fix_page_template( WP_Post $post ) {
$template = get_post_meta( $post->ID, '_wp_page_template', true );
$page_templates = wp_get_theme()->get_page_templates();
// If the template doesn't exists, remove the data to allow WordPress to save.
if ( ! isset( $page_templates[ $template ] ) ) {
delete_post_meta( $post->ID, '_wp_page_template' );
}
}
/**
* Get registered meta boxes via a filter.
* @deprecated No longer used. Keep for backward-compatibility with extensions.
*/
public static function get_meta_boxes() : array {
$meta_boxes = rwmb_get_registry( 'meta_box' )->all();
return wp_list_pluck( $meta_boxes, 'meta_box' );
}
public function add_context_hooks() {
$hooks = [
'edit_form_top',
'edit_form_after_title',
'edit_form_after_editor',
'edit_form_before_permalink',
];
foreach ( $hooks as $hook ) {
add_action( $hook, [ $this, 'render_meta_boxes_for_context' ] );
}
}
public function render_meta_boxes_for_context( $post ) {
$hook = current_filter();
$context = 'edit_form_top' === $hook ? 'form_top' : substr( $hook, 10 );
do_meta_boxes( null, $context, $post );
}
}
media-modal.php 0000644 00000006130 15154570313 0007432 0 ustar 00 all();
foreach ( $meta_boxes as $meta_box ) {
if ( $this->is_in_modal( $meta_box->meta_box ) ) {
$this->fields = array_merge( $this->fields, array_values( $meta_box->fields ) );
}
}
}
/**
* Add fields to the attachment edit popup.
*
* @param array $form_fields An array of attachment form fields.
* @param WP_Post $post The WP_Post attachment object.
*
* @return mixed
*/
public function add_fields( $form_fields, $post ) {
if ( empty( $post ) || $this->is_attachment_edit_screen() ) {
return $form_fields;
}
foreach ( $this->fields as $field ) {
$form_field = $field;
$form_field['label'] = $field['name'];
$form_field['input'] = 'html';
// Just ignore the field 'std' because there's no way to check it.
$meta = RWMB_Field::call( $field, 'meta', $post->ID, true );
$form_field['value'] = $meta;
$field['field_name'] = 'attachments[' . $post->ID . '][' . $field['field_name'] . ']';
ob_start();
$field['name'] = ''; // Don't show field label as it's already handled by WordPress.
RWMB_Field::call( 'show', $field, true, $post->ID );
// For MB Custom Table to flush data from the cache to the database.
do_action( 'rwmb_flush_data', $post->ID, $field, [] );
$form_field['html'] = ob_get_clean();
$form_fields[ $field['id'] ] = $form_field;
}
return $form_fields;
}
/**
* Save custom fields.
*
* @param array $post An array of post data.
* @param array $attachment An array of attachment metadata.
*
* @return array
*/
public function save_fields( $post, $attachment ) {
foreach ( $this->fields as $field ) {
$key = $field['id'];
$old = RWMB_Field::call( $field, 'raw_meta', $post['ID'] );
$new = isset( $attachment[ $key ] ) ? $attachment[ $key ] : '';
$new = RWMB_Field::process_value( $new, $post['ID'], $field );
// Call defined method to save meta value, if there's no methods, call common one.
RWMB_Field::call( $field, 'save', $new, $old, $post['ID'] );
// For MB Custom Table to flush data from the cache to the database.
do_action( 'rwmb_flush_data', $post['ID'], $field, [] );
}
return $post;
}
private function is_in_modal( array $meta_box ): bool {
return in_array( 'attachment', $meta_box['post_types'], true ) && ! empty( $meta_box['media_modal'] );
}
private function is_attachment_edit_screen(): bool {
if ( ! function_exists( 'get_current_screen' ) ) {
return false;
}
$screen = get_current_screen();
return $screen && $screen->id === 'attachment';
}
}
autoloader.php 0000644 00000002761 15154570313 0007426 0 ustar 00 dirs[] = [
'dir' => trailingslashit( $dir ),
'prefix' => $prefix,
'suffix' => $suffix,
];
}
public function register() {
spl_autoload_register( [ $this, 'autoload' ] );
}
public function autoload( string $class_name ) {
foreach ( $this->dirs as $dir ) {
if (
( $dir['prefix'] && ! str_starts_with( $class_name, $dir['prefix'] ) )
|| ( $dir['suffix'] && ! str_ends_with( $class_name, $dir['suffix'] ) )
) {
continue;
}
$file = substr( $class_name, strlen( $dir['prefix'] ) );
if ( $dir['suffix'] && strlen( $file ) > strlen( $dir['suffix'] ) ) {
$file = substr( $file, 0, - strlen( $dir['suffix'] ) );
}
if ( function_exists( 'mb_strtolower' ) && function_exists( 'mb_detect_encoding' ) ) {
$file = mb_strtolower( str_replace( '_', '-', $file ), mb_detect_encoding( $file ) ) . '.php';
} else {
$file = strtolower( str_replace( '_', '-', $file ) ) . '.php';
}
$file = $dir['dir'] . $file;
$this->require( $file );
}
}
private function require( string $file ) {
if ( file_exists( $file ) ) {
require_once $file;
}
}
}
validation.php 0000644 00000005133 15154570313 0007415 0 ustar 00 and will be converted into JSON by JS.
*/
public function rules( RW_Meta_Box $meta_box ) {
$settings = $meta_box->meta_box;
if ( empty( $settings['validation'] ) ) {
return;
}
$prefix = $settings['prefix'] ?? ''; // Get field ID prefix from the builder.
$fields = $settings['fields'];
$validation = $settings['validation'];
$ids = wp_list_pluck( $fields, 'id' ); // Don't use array_column() as it doesn't preserve keys.
// Add prefix for validation rules.
foreach ( $validation as &$rules ) {
$rules = array_combine(
array_map( function ( $key ) use ( $fields, $prefix, $ids ) {
$id = $prefix . $key;
$index = array_search( $id, $ids, true );
if ( $index === false ) {
return $id;
}
$field = $fields[ $index ];
if ( in_array( $field['type'], [ 'file', 'image' ], true ) ) {
return $field['clone'] ? $field['index_name'] : $field['input_name'];
}
return $id;
}, array_keys( $rules ) ),
$rules
);
}
echo '';
}
public function enqueue() {
wp_enqueue_script( 'jquery-validation', RWMB_JS_URL . 'validation/jquery.validate.js', [ 'jquery' ], '1.20.0', true );
wp_enqueue_script( 'jquery-validation-additional-methods', RWMB_JS_URL . 'validation/additional-methods.js', [ 'jquery-validation' ], '1.20.0', true );
wp_enqueue_script( 'rwmb-validation', RWMB_JS_URL . 'validation/validation.js', [ 'jquery-validation-additional-methods', 'rwmb' ], RWMB_VER, true );
$locale = determine_locale();
$locale_short = substr( $locale, 0, 2 );
$locale = file_exists( RWMB_DIR . "js/validation/i18n/messages_$locale.js" ) ? $locale : $locale_short;
if ( file_exists( RWMB_DIR . "js/validation/i18n/messages_$locale.js" ) ) {
wp_enqueue_script( 'jquery-validation-i18n', RWMB_JS_URL . "validation/i18n/messages_$locale.js", [ 'jquery-validation-additional-methods' ], '1.20.0', true );
}
RWMB_Helpers_Field::localize_script_once( 'rwmb-validation', 'rwmbValidation', [
'message' => esc_html( apply_filters( 'rwmb_validation_message_string', __( 'Please correct the errors highlighted below and try again.', 'meta-box' ) ) ),
] );
}
}
loader.php 0000644 00000010042 15154570313 0006524 0 ustar 00 constants();
// PSR-4 autoload.
$psr4_autoload = dirname( __DIR__ ) . '/vendor/autoload.php';
if ( file_exists( $psr4_autoload ) ) {
require $psr4_autoload;
}
// Register autoload for classes.
require_once RWMB_INC_DIR . 'autoloader.php';
$autoloader = new RWMB_Autoloader();
$autoloader->add( RWMB_INC_DIR, 'RW_' );
$autoloader->add( RWMB_INC_DIR, 'RWMB_' );
$autoloader->add( RWMB_INC_DIR . 'about', 'RWMB_' );
$autoloader->add( RWMB_INC_DIR . 'fields', 'RWMB_', '_Field' );
$autoloader->add( RWMB_INC_DIR . 'walkers', 'RWMB_Walker_' );
$autoloader->add( RWMB_INC_DIR . 'interfaces', 'RWMB_', '_Interface' );
$autoloader->add( RWMB_INC_DIR . 'storages', 'RWMB_', '_Storage' );
$autoloader->add( RWMB_INC_DIR . 'helpers', 'RWMB_Helpers_' );
$autoloader->add( RWMB_INC_DIR . 'update', 'RWMB_Update_' );
$autoloader->register();
// Plugin core.
$core = new RWMB_Core();
$core->init();
$shortcode = new RWMB_Shortcode();
$shortcode->init();
// Validation module.
new RWMB_Validation();
$sanitizer = new RWMB_Sanitizer();
$sanitizer->init();
$media_modal = new RWMB_Media_Modal();
$media_modal->init();
// WPML Compatibility.
$wpml = new RWMB_WPML();
$wpml->init();
// Update.
$update_option = null;
$update_checker = null;
if ( class_exists( '\MetaBox\Updater\Option' ) ) {
$update_option = new \MetaBox\Updater\Option();
$update_checker = new \MetaBox\Updater\Checker( $update_option );
$update_checker->init();
$update_settings = new \MetaBox\Updater\Settings( $update_checker, $update_option );
$update_settings->init();
$update_notification = new \MetaBox\Updater\Notification( $update_checker, $update_option );
$update_notification->init();
}
// Register categories for page builders.
new \MetaBox\Integrations\Block();
new \MetaBox\Integrations\Bricks;
new \MetaBox\Integrations\Elementor;
new \MetaBox\Integrations\Oxygen();
if ( is_admin() ) {
new \MetaBox\Dashboard\Dashboard( $update_checker, $update_option );
new \MetaBox\FeaturedPlugins();
}
// Public functions.
require_once RWMB_INC_DIR . 'functions.php';
}
}
clone.php 0000644 00000006775 15154570313 0006400 0 ustar 00 $sub_meta ) {
$sub_field = $field;
$sub_field['field_name'] = $field['field_name'] . "[{$index}]";
$attributes_id = $sub_field['attributes']['id'] ?? $sub_field['id'];
if ( $index === 0 && $count > 1 ) {
$sub_field['attributes']['id'] = $attributes_id . "_rwmb_template";
}
if ( $index === 1 ) {
$sub_field['attributes']['id'] = $attributes_id;
}
if ( $index > 1 ) {
if ( isset( $sub_field['address_field'] ) ) {
$sub_field['address_field'] = $field['address_field'] . "_{$index}";
}
$sub_field['id'] = $field['id'] . "_{$index}";
if ( ! empty( $sub_field['attributes']['id'] ) ) {
$sub_field['attributes']['id'] .= "_{$index}";
}
}
if ( in_array( $sub_field['type'], [ 'file', 'image' ], true ) ) {
$sub_field['input_name'] = '_file_' . uniqid();
$sub_field['index_name'] .= "[{$index}]";
} elseif ( $field['multiple'] ) {
$sub_field['field_name'] .= '[]';
}
// Wrap field HTML in a div with class="rwmb-clone" if needed.
$class = "rwmb-clone rwmb-{$field['type']}-clone";
$sort_icon = '';
if ( $field['sort_clone'] ) {
$class .= ' rwmb-sort-clone';
$sort_icon = " ";
}
$class .= $index === 0 ? ' rwmb-clone-template' : '';
$input_html = "" . $sort_icon;
// Call separated methods for displaying each type of field.
$input_html .= RWMB_Field::call( $sub_field, 'html', $sub_meta );
$input_html = RWMB_Field::filter( 'html', $input_html, $sub_field, $sub_meta );
// Remove clone button.
$input_html .= self::remove_clone_button( $sub_field );
$input_html .= '
';
$field_html .= $input_html;
}
return $field_html;
}
/**
* Set value of meta before saving into database
*
* @param mixed $new The submitted meta value.
* @param mixed $old The existing meta value.
* @param int $object_id The object ID.
* @param array $field The field parameters.
*
* @return mixed
*/
public static function value( $new, $old, $object_id, array $field ) {
if ( ! is_array( $new ) ) {
$new = [];
}
if ( in_array( $field['type'], [ 'file', 'image' ], true ) ) {
$new = RWMB_File_Field::clone_value( $new, $old, $object_id, $field );
} else {
foreach ( $new as $key => $value ) {
$old_value = $old[ $key ] ?? null;
$value = RWMB_Field::call( $field, 'value', $value, $old_value, $object_id );
$new[ $key ] = RWMB_Field::filter( 'sanitize', $value, $field, $old_value, $object_id );
}
}
// Remove empty clones.
$new = array_filter( $new, 'RWMB_Helpers_Value::is_valid_for_field' );
// Reset indexes.
$new = array_values( $new );
return $new;
}
public static function add_clone_button( array $field ) : string {
if ( ! $field['clone'] ) {
return '';
}
$text = RWMB_Field::filter( 'add_clone_button_text', $field['add_button'], $field );
return '' . esc_html( $text ) . ' ';
}
public static function remove_clone_button( array $field ) : string {
$text = RWMB_Field::filter( 'remove_clone_button_text', ' ', $field );
return '' . $text . ' ';
}
}
interfaces/storage.php 0000644 00000000500 15154570313 0011043 0 ustar 00 get_callback( $field );
return is_callable( $callback ) ? call_user_func( $callback, $value, $field, $old_value, $object_id ) : $value;
}
/**
* Get sanitize callback for a field.
*
* @param array $field Field settings.
* @return callable
*/
private function get_callback( $field ) {
// User-defined callback.
if ( is_callable( $field['sanitize_callback'] ) ) {
return $field['sanitize_callback'];
}
$callbacks = [
'autocomplete' => [ $this, 'sanitize_choice' ],
'background' => [ $this, 'sanitize_background' ],
'button_group' => [ $this, 'sanitize_choice' ],
'checkbox' => [ $this, 'sanitize_checkbox' ],
'checkbox_list' => [ $this, 'sanitize_choice' ],
'color' => [ $this, 'sanitize_color' ],
'date' => [ $this, 'sanitize_datetime' ],
'datetime' => [ $this, 'sanitize_datetime' ],
'email' => 'sanitize_email',
'fieldset_text' => [ $this, 'sanitize_text' ],
'file' => [ $this, 'sanitize_file' ],
'file_advanced' => [ $this, 'sanitize_object' ],
'file_input' => [ $this, 'sanitize_url' ],
'file_upload' => [ $this, 'sanitize_object' ],
'hidden' => 'sanitize_text_field',
'image' => [ $this, 'sanitize_file' ],
'image_advanced' => [ $this, 'sanitize_object' ],
'image_select' => [ $this, 'sanitize_choice' ],
'image_upload' => [ $this, 'sanitize_object' ],
'key_value' => [ $this, 'sanitize_text' ],
'map' => [ $this, 'sanitize_map' ],
'number' => [ $this, 'sanitize_number' ],
'oembed' => [ $this, 'sanitize_url' ],
'osm' => [ $this, 'sanitize_map' ],
'password' => 'sanitize_text_field',
'post' => [ $this, 'sanitize_object' ],
'radio' => [ $this, 'sanitize_choice' ],
'range' => [ $this, 'sanitize_number' ],
'select' => [ $this, 'sanitize_choice' ],
'select_advanced' => [ $this, 'sanitize_choice' ],
'sidebar' => [ $this, 'sanitize_text' ],
'single_image' => 'absint',
'slider' => [ $this, 'sanitize_slider' ],
'switch' => [ $this, 'sanitize_checkbox' ],
'taxonomy' => [ $this, 'sanitize_object' ],
'taxonomy_advanced' => [ $this, 'sanitize_taxonomy_advanced' ],
'text' => 'sanitize_text_field',
'text_list' => [ $this, 'sanitize_text' ],
'textarea' => 'wp_kses_post',
'time' => 'sanitize_text_field',
'url' => [ $this, 'sanitize_url' ],
'user' => [ $this, 'sanitize_object' ],
'video' => [ $this, 'sanitize_object' ],
'wysiwyg' => 'wp_kses_post',
];
$type = $field['type'];
return $callbacks[ $type ] ?? null;
}
/**
* Set the value of checkbox to 1 or 0 instead of 'checked' and empty string.
* This prevents using default value once the checkbox has been unchecked.
*
* @link https://github.com/rilwis/meta-box/issues/6
* @param string $value Checkbox value.
*/
private function sanitize_checkbox( $value ): int {
return (int) ! empty( $value );
}
/**
* Sanitize numeric value.
*
* @param string $value The number value.
* @return string
*/
private function sanitize_number( $value ) {
return is_numeric( $value ) ? $value : '';
}
private function sanitize_color( string $value ): string {
if ( str_contains( $value, 'hsl' ) ) {
return wp_unslash( $value );
}
if ( ! str_contains( $value, 'rgb' ) ) {
return (string) sanitize_hex_color( $value );
}
// rgba value.
$red = '';
$green = '';
$blue = '';
$alpha = 1;
if ( str_contains( $value, 'rgba' ) ) {
sscanf( $value, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
} else {
sscanf( $value, 'rgb(%d,%d,%d)', $red, $green, $blue );
}
return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
}
/**
* Sanitize value for a choice field.
*
* @param string|array $value The submitted value.
* @param array $field The field settings.
* @return string|array
*/
private function sanitize_choice( $value, $field ) {
$options = RWMB_Choice_Field::transform_options( $field['options'] );
$options = wp_list_pluck( $options, 'value' );
$value = wp_unslash( $value );
return is_array( $value ) ? array_intersect( $value, $options ) : ( in_array( $value, $options ) ? $value : '' );
}
/**
* Sanitize object & media field.
*
* @param int|array $value The submitted value.
* @return int|array
*/
private function sanitize_object( $value ) {
return is_array( $value ) ? array_filter( array_map( 'absint', $value ) ) : ( $value ? absint( $value ) : '' );
}
/**
* Sanitize background field.
*
* @param array $value The submitted value.
* @return array
*/
private function sanitize_background( $value ) {
$value = wp_parse_args( $value, [
'color' => '',
'image' => '',
'repeat' => '',
'attachment' => '',
'position' => '',
'size' => '',
] );
$value['color'] = $this->sanitize_color( $value['color'] );
$value['image'] = esc_url_raw( $value['image'] );
$value['repeat'] = in_array( $value['repeat'], [ 'no-repeat', 'repeat', 'repeat-x', 'repeat-y', 'inherit' ], true ) ? $value['repeat'] : '';
$value['position'] = in_array( $value['position'], [ 'top left', 'top center', 'top right', 'center left', 'center center', 'center right', 'bottom left', 'bottom center', 'bottom right' ], true ) ? $value['position'] : '';
$value['attachment'] = in_array( $value['attachment'], [ 'fixed', 'scroll', 'inherit' ], true ) ? $value['attachment'] : '';
$value['size'] = in_array( $value['size'], [ 'inherit', 'cover', 'contain' ], true ) ? $value['size'] : '';
return $value;
}
/**
* Sanitize text field.
*
* @param string|array $value The submitted value.
* @return string|array
*/
private function sanitize_text( $value ) {
return is_array( $value ) ? array_map( __METHOD__, $value ) : sanitize_text_field( $value );
}
/**
* Sanitize file, image field.
*
* @param array $value The submitted value.
* @param array $field The field settings.
* @return array
*/
private function sanitize_file( $value, $field ) {
return $field['upload_dir'] ? array_map( 'esc_url_raw', $value ) : $this->sanitize_object( $value );
}
/**
* Sanitize slider field.
*
* @param mixed $value The submitted value.
* @param array $field The field settings.
* @return string|int|float
*/
private function sanitize_slider( $value, $field ) {
return true === $field['js_options']['range'] ? sanitize_text_field( $value ) : $this->sanitize_number( $value );
}
/**
* Sanitize datetime field.
*
* @param mixed $value The submitted value.
* @param array $field The field settings.
* @return float|string
*/
private function sanitize_datetime( $value, $field ) {
return $field['timestamp'] ? (float) $value : sanitize_text_field( $value );
}
private function sanitize_map( $value ): string {
$value = sanitize_text_field( $value );
list( $latitude, $longitude, $zoom ) = explode( ',', $value . ',,' );
$latitude = (float) $latitude;
$longitude = (float) $longitude;
$zoom = (int) $zoom;
return "$latitude,$longitude,$zoom";
}
private function sanitize_taxonomy_advanced( $value ): string {
return implode( ',', wp_parse_id_list( $value ) );
}
private function sanitize_url( string $value ): string {
return esc_url_raw( $value );
}
}
bootstrap.php 0000644 00000000406 15154616326 0007303 0 ustar 00 '', 'direction' => 'down' ) );
$currencies = $WOOCS->get_currencies();
$currency_list = array();
foreach ( $currencies as $key => $currency ) {
if ( $WOOCS->current_currency == $key ) {
array_unshift( $currency_list, sprintf(
'%s ',
esc_attr( $currency['name'] ),
esc_html( $currency['name'] )
) );
} else {
$currency_list[] = sprintf(
'%s ',
esc_attr( $currency['name'] ),
esc_html( $currency['name'] )
);
}
}
?>
'%code%')); ?>
1));
} else if (function_exists('icl_get_languages')) {
$languages = icl_get_languages('skip_missing=0');
}
?>
'inc/merlin', // Location / directory where Merlin WP is placed in your theme.
'merlin_url' => 'merlin', // The wp-admin page slug where Merlin WP loads.
'parent_slug' => 'themes.php', // The wp-admin parent page slug for the admin menu item.
'capability' => 'manage_options', // The capability required for this menu to be displayed to the user.
'child_action_btn_url' => 'https://codex.wordpress.org/child_themes', // URL for the 'child-action-link'.
'dev_mode' => true, // Enable development mode for testing.
'license_step' => false, // EDD license activation step.
'license_required' => false, // Require the license activation step.
'license_help_url' => '', // URL for the 'license-tooltip'.
'edd_remote_api_url' => '', // EDD_Theme_Updater_Admin remote_api_url.
'edd_item_name' => '', // EDD_Theme_Updater_Admin item_name.
'edd_theme_slug' => '', // EDD_Theme_Updater_Admin item_slug.
'ready_big_button_url' => home_url( '/' ), // Link for the big button on the ready step.
),
$strings = array(
'admin-menu' => esc_html__( 'Theme Setup', '@@textdomain' ),
/* translators: 1: Title Tag 2: Theme Name 3: Closing Title Tag */
'title%s%s%s%s' => esc_html__( '%1$s%2$s Themes ‹ Theme Setup: %3$s%4$s', '@@textdomain' ),
'return-to-dashboard' => esc_html__( 'Return to the dashboard', '@@textdomain' ),
'ignore' => esc_html__( 'Disable this wizard', '@@textdomain' ),
'btn-skip' => esc_html__( 'Skip', '@@textdomain' ),
'btn-next' => esc_html__( 'Next', '@@textdomain' ),
'btn-start' => esc_html__( 'Start', '@@textdomain' ),
'btn-no' => esc_html__( 'Cancel', '@@textdomain' ),
'btn-plugins-install' => esc_html__( 'Install', '@@textdomain' ),
'btn-child-install' => esc_html__( 'Install', '@@textdomain' ),
'btn-content-install' => esc_html__( 'Install', '@@textdomain' ),
'btn-import' => esc_html__( 'Import', '@@textdomain' ),
'btn-license-activate' => esc_html__( 'Activate', '@@textdomain' ),
'btn-license-skip' => esc_html__( 'Later', '@@textdomain' ),
/* translators: Theme Name */
'license-header%s' => esc_html__( 'Activate %s', '@@textdomain' ),
/* translators: Theme Name */
'license-header-success%s' => esc_html__( '%s is Activated', '@@textdomain' ),
/* translators: Theme Name */
'license%s' => esc_html__( 'Enter your license key to enable remote updates and theme support.', '@@textdomain' ),
'license-label' => esc_html__( 'License key', '@@textdomain' ),
'license-success%s' => esc_html__( 'The theme is already registered, so you can go to the next step!', '@@textdomain' ),
'license-json-success%s' => esc_html__( 'Your theme is activated! Remote updates and theme support are enabled.', '@@textdomain' ),
'license-tooltip' => esc_html__( 'Need help?', '@@textdomain' ),
/* translators: Theme Name */
'welcome-header%s' => esc_html__( 'Welcome to %s', '@@textdomain' ),
'welcome-header-success%s' => esc_html__( 'Hi. Welcome back', '@@textdomain' ),
'welcome%s' => esc_html__( 'This wizard will set up your theme, install plugins, and import content. It should take only a few minutes.', '@@textdomain' ),
'welcome-success%s' => esc_html__( 'You may have already run this theme setup wizard. If you would like to proceed anyway, click on the "Start" button below.', '@@textdomain' ),
'child-header' => esc_html__( 'Install Child Theme', '@@textdomain' ),
'child-header-success' => esc_html__( 'You\'re good to go!', '@@textdomain' ),
'child' => esc_html__( 'Let\'s build & activate a child theme so you may easily make theme changes.', '@@textdomain' ),
'child-success%s' => esc_html__( 'Your child theme has already been installed and is now activated, if it wasn\'t already.', '@@textdomain' ),
'child-action-link' => esc_html__( 'Learn about child themes', '@@textdomain' ),
'child-json-success%s' => esc_html__( 'Awesome. Your child theme has already been installed and is now activated.', '@@textdomain' ),
'child-json-already%s' => esc_html__( 'Awesome. Your child theme has been created and is now activated.', '@@textdomain' ),
'plugins-header' => esc_html__( 'Install Plugins', '@@textdomain' ),
'plugins-header-success' => esc_html__( 'You\'re up to speed!', '@@textdomain' ),
'plugins' => esc_html__( 'Let\'s install some essential WordPress plugins to get your site up to speed.', '@@textdomain' ),
'plugins-success%s' => esc_html__( 'The required WordPress plugins are all installed and up to date. Press "Next" to continue the setup wizard.', '@@textdomain' ),
'plugins-action-link' => esc_html__( 'Advanced', '@@textdomain' ),
'import-header' => esc_html__( 'Import Content', '@@textdomain' ),
'import' => esc_html__( 'Let\'s import content to your website. This could take some minutes. Please wait.', '@@textdomain' ),
'import-demo-link' => sprintf( '%2$s ', 'https://goya.everthemes.com/#home-cards', esc_html__( 'Explore Demos', '@@textdomain' ) ),
'import-action-link' => esc_html__( 'Advanced', '@@textdomain' ),
'ready-header' => esc_html__( 'All done. Have fun!', '@@textdomain' ),
/* translators: Theme Author */
'ready%s' => esc_html__( 'Your theme has been all set up. Enjoy your new theme by %s.', '@@textdomain' ),
'ready-action-link' => esc_html__( 'Extras', '@@textdomain' ),
'ready-big-button' => esc_html__( 'View your website', '@@textdomain' ),
'ready-link-1' => sprintf( '%2$s ', 'https://wordpress.org/support/', esc_html__( 'Explore WordPress', '@@textdomain' ) ),
'ready-link-2' => sprintf( '%2$s ', 'https://themebeans.com/contact/', esc_html__( 'Get Theme Support', '@@textdomain' ) ),
'ready-link-3' => sprintf( '%2$s ', admin_url( 'customize.php' ), esc_html__( 'Start Customizing', '@@textdomain' ) ),
)
);
admin/setup/merlin-filters.php 0000644 00000006273 15154650146 0012460 0 ustar 00 array(),
);
return $widget_areas;
}
add_filter( 'merlin_unset_default_widgets_args', 'goya_merlin_unset_default_widgets_args' );
/**
* Custom content for the generated child theme's functions.php file.
*
* @param string $output Generated content.
* @param string $slug Parent theme slug.
*/
function goya_generate_child_functions_php( $output, $slug ) {
$slug_no_hyphens = strtolower( preg_replace( '#[^a-zA-Z]#', '', $slug ) );
$output = "
wp_version = $GLOBALS['wp_version'];
// Announce that the class is ready, and pass the object (for advanced use).
do_action_ref_array( 'tgmpa_init', array( $this ) );
/*
* Load our text domain and allow for overloading the fall-back file.
*
* {@internal IMPORTANT! If this code changes, review the regex in the custom TGMPA
* generator on the website.}}
*/
add_action( 'init', array( $this, 'load_textdomain' ), 5 );
add_filter( 'load_textdomain_mofile', array( $this, 'overload_textdomain_mofile' ), 10, 2 );
// When the rest of WP has loaded, kick-start the rest of the class.
add_action( 'init', array( $this, 'init' ) );
}
/**
* Magic method to (not) set protected properties from outside of this class.
*
* {@internal hackedihack... There is a serious bug in v2.3.2 - 2.3.6 where the `menu` property
* is being assigned rather than tested in a conditional, effectively rendering it useless.
* This 'hack' prevents this from happening.}}
*
* @see https://github.com/TGMPA/TGM-Plugin-Activation/blob/2.3.6/tgm-plugin-activation/class-tgm-plugin-activation.php#L1593
*
* @since 2.5.2
*
* @param string $name Name of an inaccessible property.
* @param mixed $value Value to assign to the property.
* @return void Silently fail to set the property when this is tried from outside of this class context.
* (Inside this class context, the __set() method if not used as there is direct access.)
*/
public function __set( $name, $value ) {
return;
}
/**
* Magic method to get the value of a protected property outside of this class context.
*
* @since 2.5.2
*
* @param string $name Name of an inaccessible property.
* @return mixed The property value.
*/
public function __get( $name ) {
return $this->{$name};
}
/**
* Initialise the interactions between this class and WordPress.
*
* Hooks in three new methods for the class: admin_menu, notices and styles.
*
* @since 2.0.0
*
* @see TGM_Plugin_Activation::admin_menu()
* @see TGM_Plugin_Activation::notices()
* @see TGM_Plugin_Activation::styles()
*/
public function init() {
/**
* By default TGMPA only loads on the WP back-end and not in an Ajax call. Using this filter
* you can overrule that behaviour.
*
* @since 2.5.0
*
* @param bool $load Whether or not TGMPA should load.
* Defaults to the return of `is_admin() && ! defined( 'DOING_AJAX' )`.
*/
if ( true !== apply_filters( 'tgmpa_load', ( is_admin() && ! defined( 'DOING_AJAX' ) ) ) ) {
return;
}
// Load class strings.
$this->strings = array(
'page_title' => __( 'Install Required Plugins', 'tgmpa' ),
'menu_title' => __( 'Install Plugins', 'tgmpa' ),
/* translators: %s: plugin name. */
'installing' => __( 'Installing Plugin: %s', 'tgmpa' ),
/* translators: %s: plugin name. */
'updating' => __( 'Updating Plugin: %s', 'tgmpa' ),
'oops' => __( 'Something went wrong with the plugin API.', 'tgmpa' ),
'notice_can_install_required' => _n_noop(
/* translators: 1: plugin name(s). */
'This theme requires the following plugin: %1$s.',
'This theme requires the following plugins: %1$s.',
'tgmpa'
),
'notice_can_install_recommended' => _n_noop(
/* translators: 1: plugin name(s). */
'This theme recommends the following plugin: %1$s.',
'This theme recommends the following plugins: %1$s.',
'tgmpa'
),
'notice_ask_to_update' => _n_noop(
/* translators: 1: plugin name(s). */
'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.',
'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.',
'tgmpa'
),
'notice_ask_to_update_maybe' => _n_noop(
/* translators: 1: plugin name(s). */
'There is an update available for: %1$s.',
'There are updates available for the following plugins: %1$s.',
'tgmpa'
),
'notice_can_activate_required' => _n_noop(
/* translators: 1: plugin name(s). */
'The following required plugin is currently inactive: %1$s.',
'The following required plugins are currently inactive: %1$s.',
'tgmpa'
),
'notice_can_activate_recommended' => _n_noop(
/* translators: 1: plugin name(s). */
'The following recommended plugin is currently inactive: %1$s.',
'The following recommended plugins are currently inactive: %1$s.',
'tgmpa'
),
'install_link' => _n_noop(
'Begin installing plugin',
'Begin installing plugins',
'tgmpa'
),
'update_link' => _n_noop(
'Begin updating plugin',
'Begin updating plugins',
'tgmpa'
),
'activate_link' => _n_noop(
'Begin activating plugin',
'Begin activating plugins',
'tgmpa'
),
'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ),
'dashboard' => __( 'Return to the Dashboard', 'tgmpa' ),
'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ),
'activated_successfully' => __( 'The following plugin was activated successfully:', 'tgmpa' ),
/* translators: 1: plugin name. */
'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'tgmpa' ),
/* translators: 1: plugin name. */
'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'tgmpa' ),
/* translators: 1: dashboard link. */
'complete' => __( 'All plugins installed and activated successfully. %1$s', 'tgmpa' ),
'dismiss' => __( 'Dismiss this notice', 'tgmpa' ),
'notice_cannot_install_activate' => __( 'There are one or more required or recommended plugins to install, update or activate.', 'tgmpa' ),
'contact_admin' => __( 'Please contact the administrator of this site for help.', 'tgmpa' ),
);
do_action( 'tgmpa_register' );
/* After this point, the plugins should be registered and the configuration set. */
// Proceed only if we have plugins to handle.
if ( empty( $this->plugins ) || ! is_array( $this->plugins ) ) {
return;
}
// Set up the menu and notices if we still have outstanding actions.
if ( true !== $this->is_tgmpa_complete() ) {
// Sort the plugins.
array_multisort( $this->sort_order, SORT_ASC, $this->plugins );
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'admin_head', array( $this, 'dismiss' ) );
// Prevent the normal links from showing underneath a single install/update page.
add_filter( 'install_plugin_complete_actions', array( $this, 'actions' ) );
add_filter( 'update_plugin_complete_actions', array( $this, 'actions' ) );
if ( $this->has_notices ) {
add_action( 'admin_notices', array( $this, 'notices' ) );
add_action( 'admin_init', array( $this, 'admin_init' ), 1 );
add_action( 'admin_enqueue_scripts', array( $this, 'thickbox' ) );
}
}
// If needed, filter plugin action links.
add_action( 'load-plugins.php', array( $this, 'add_plugin_action_link_filters' ), 1 );
// Make sure things get reset on switch theme.
add_action( 'switch_theme', array( $this, 'flush_plugins_cache' ) );
if ( $this->has_notices ) {
add_action( 'switch_theme', array( $this, 'update_dismiss' ) );
}
// Setup the force activation hook.
if ( true === $this->has_forced_activation ) {
add_action( 'admin_init', array( $this, 'force_activation' ) );
}
// Setup the force deactivation hook.
if ( true === $this->has_forced_deactivation ) {
add_action( 'switch_theme', array( $this, 'force_deactivation' ) );
}
}
/**
* Load translations.
*
* @since 2.6.0
*
* (@internal Uses `load_theme_textdomain()` rather than `load_plugin_textdomain()` to
* get round the different ways of handling the path and deprecated notices being thrown
* and such. For plugins, the actual file name will be corrected by a filter.}}
*
* {@internal IMPORTANT! If this function changes, review the regex in the custom TGMPA
* generator on the website.}}
*/
public function load_textdomain() {
if ( is_textdomain_loaded( 'tgmpa' ) ) {
return;
}
if ( false !== strpos( __FILE__, WP_PLUGIN_DIR ) || false !== strpos( __FILE__, WPMU_PLUGIN_DIR ) ) {
// Plugin, we'll need to adjust the file name.
add_action( 'load_textdomain_mofile', array( $this, 'correct_plugin_mofile' ), 10, 2 );
load_theme_textdomain( 'tgmpa', dirname( __FILE__ ) . '/languages' );
remove_action( 'load_textdomain_mofile', array( $this, 'correct_plugin_mofile' ), 10 );
} else {
load_theme_textdomain( 'tgmpa', dirname( __FILE__ ) . '/languages' );
}
}
/**
* Correct the .mo file name for (must-use) plugins.
*
* Themese use `/path/{locale}.mo` while plugins use `/path/{text-domain}-{locale}.mo`.
*
* {@internal IMPORTANT! If this function changes, review the regex in the custom TGMPA
* generator on the website.}}
*
* @since 2.6.0
*
* @param string $mofile Full path to the target mofile.
* @param string $domain The domain for which a language file is being loaded.
* @return string $mofile
*/
public function correct_plugin_mofile( $mofile, $domain ) {
// Exit early if not our domain (just in case).
if ( 'tgmpa' !== $domain ) {
return $mofile;
}
return preg_replace( '`/([a-z]{2}_[A-Z]{2}.mo)$`', '/tgmpa-$1', $mofile );
}
/**
* Potentially overload the fall-back translation file for the current language.
*
* WP, by default since WP 3.7, will load a local translation first and if none
* can be found, will try and find a translation in the /wp-content/languages/ directory.
* As this library is theme/plugin agnostic, translation files for TGMPA can exist both
* in the WP_LANG_DIR /plugins/ subdirectory as well as in the /themes/ subdirectory.
*
* This method makes sure both directories are checked.
*
* {@internal IMPORTANT! If this function changes, review the regex in the custom TGMPA
* generator on the website.}}
*
* @since 2.6.0
*
* @param string $mofile Full path to the target mofile.
* @param string $domain The domain for which a language file is being loaded.
* @return string $mofile
*/
public function overload_textdomain_mofile( $mofile, $domain ) {
// Exit early if not our domain, not a WP_LANG_DIR load or if the file exists and is readable.
if ( 'tgmpa' !== $domain || false === strpos( $mofile, WP_LANG_DIR ) || @is_readable( $mofile ) ) {
return $mofile;
}
// Current fallback file is not valid, let's try the alternative option.
if ( false !== strpos( $mofile, '/themes/' ) ) {
return str_replace( '/themes/', '/plugins/', $mofile );
} elseif ( false !== strpos( $mofile, '/plugins/' ) ) {
return str_replace( '/plugins/', '/themes/', $mofile );
} else {
return $mofile;
}
}
/**
* Hook in plugin action link filters for the WP native plugins page.
*
* - Prevent activation of plugins which don't meet the minimum version requirements.
* - Prevent deactivation of force-activated plugins.
* - Add update notice if update available.
*
* @since 2.5.0
*/
public function add_plugin_action_link_filters() {
foreach ( $this->plugins as $slug => $plugin ) {
if ( false === $this->can_plugin_activate( $slug ) ) {
add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_activate' ), 20 );
}
if ( true === $plugin['force_activation'] ) {
add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_deactivate' ), 20 );
}
if ( false !== $this->does_plugin_require_update( $slug ) ) {
add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_update' ), 20 );
}
}
}
/**
* Remove the 'Activate' link on the WP native plugins page if the plugin does not meet the
* minimum version requirements.
*
* @since 2.5.0
*
* @param array $actions Action links.
* @return array
*/
public function filter_plugin_action_links_activate( $actions ) {
unset( $actions['activate'] );
return $actions;
}
/**
* Remove the 'Deactivate' link on the WP native plugins page if the plugin has been set to force activate.
*
* @since 2.5.0
*
* @param array $actions Action links.
* @return array
*/
public function filter_plugin_action_links_deactivate( $actions ) {
unset( $actions['deactivate'] );
return $actions;
}
/**
* Add a 'Requires update' link on the WP native plugins page if the plugin does not meet the
* minimum version requirements.
*
* @since 2.5.0
*
* @param array $actions Action links.
* @return array
*/
public function filter_plugin_action_links_update( $actions ) {
$actions['update'] = sprintf(
'%3$s ',
esc_url( $this->get_tgmpa_status_url( 'update' ) ),
esc_attr__( 'This plugin needs to be updated to be compatible with your theme.', 'tgmpa' ),
esc_html__( 'Update Required', 'tgmpa' )
);
return $actions;
}
/**
* Handles calls to show plugin information via links in the notices.
*
* We get the links in the admin notices to point to the TGMPA page, rather
* than the typical plugin-install.php file, so we can prepare everything
* beforehand.
*
* WP does not make it easy to show the plugin information in the thickbox -
* here we have to require a file that includes a function that does the
* main work of displaying it, enqueue some styles, set up some globals and
* finally call that function before exiting.
*
* Down right easy once you know how...
*
* Returns early if not the TGMPA page.
*
* @since 2.1.0
*
* @global string $tab Used as iframe div class names, helps with styling
* @global string $body_id Used as the iframe body ID, helps with styling
*
* @return null Returns early if not the TGMPA page.
*/
public function admin_init() {
if ( ! $this->is_tgmpa_page() ) {
return;
}
if ( isset( $_REQUEST['tab'] ) && 'plugin-information' === $_REQUEST['tab'] ) {
// Needed for install_plugin_information().
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
wp_enqueue_style( 'plugin-install' );
global $tab, $body_id;
$body_id = 'plugin-information';
// @codingStandardsIgnoreStart
$tab = 'plugin-information';
// @codingStandardsIgnoreEnd
install_plugin_information();
exit;
}
}
/**
* Enqueue thickbox scripts/styles for plugin info.
*
* Thickbox is not automatically included on all admin pages, so we must
* manually enqueue it for those pages.
*
* Thickbox is only loaded if the user has not dismissed the admin
* notice or if there are any plugins left to install and activate.
*
* @since 2.1.0
*/
public function thickbox() {
if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) {
add_thickbox();
}
}
/**
* Adds submenu page if there are plugin actions to take.
*
* This method adds the submenu page letting users know that a required
* plugin needs to be installed.
*
* This page disappears once the plugin has been installed and activated.
*
* @since 1.0.0
*
* @see TGM_Plugin_Activation::init()
* @see TGM_Plugin_Activation::install_plugins_page()
*
* @return null Return early if user lacks capability to install a plugin.
*/
public function admin_menu() {
// Make sure privileges are correct to see the page.
if ( ! current_user_can( 'install_plugins' ) ) {
return;
}
$args = apply_filters(
'tgmpa_admin_menu_args',
array(
'parent_slug' => $this->parent_slug, // Parent Menu slug.
'page_title' => $this->strings['page_title'], // Page title.
'menu_title' => $this->strings['menu_title'], // Menu title.
'capability' => $this->capability, // Capability.
'menu_slug' => $this->menu, // Menu slug.
'function' => array( $this, 'install_plugins_page' ), // Callback.
)
);
$this->add_admin_menu( $args );
}
/**
* Add the menu item.
*
* {@internal IMPORTANT! If this function changes, review the regex in the custom TGMPA
* generator on the website.}}
*
* @since 2.5.0
*
* @param array $args Menu item configuration.
*/
protected function add_admin_menu( array $args ) {
$this->page_hook = add_theme_page( $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] );
}
/**
* Echoes plugin installation form.
*
* This method is the callback for the admin_menu method function.
* This displays the admin page and form area where the user can select to install and activate the plugin.
* Aborts early if we're processing a plugin installation action.
*
* @since 1.0.0
*
* @return null Aborts early if we're processing a plugin installation action.
*/
public function install_plugins_page() {
// Store new instance of plugin table in object.
$plugin_table = new TGMPA_List_Table;
// Return early if processing a plugin installation action.
if ( ( ( 'tgmpa-bulk-install' === $plugin_table->current_action() || 'tgmpa-bulk-update' === $plugin_table->current_action() ) && $plugin_table->process_bulk_actions() ) || $this->do_plugin_install() ) {
return;
}
// Force refresh of available plugin information so we'll know about manual updates/deletes.
wp_clean_plugins_cache( false );
?>
prepare_items(); ?>
message ) && is_string( $this->message ) ) {
echo wp_kses_post( $this->message );
}
?>
views(); ?>
sanitize_key( urldecode( $_GET['plugin'] ) );
if ( ! isset( $this->plugins[ $slug ] ) ) {
return false;
}
// Was an install or upgrade action link clicked?
if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) {
$install_type = 'install';
if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) {
$install_type = 'update';
}
check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' );
// Pass necessary information via URL if WP_Filesystem is needed.
$url = wp_nonce_url(
add_query_arg(
array(
'plugin' => urlencode( $slug ),
'tgmpa-' . $install_type => $install_type . '-plugin',
),
$this->get_tgmpa_url()
),
'tgmpa-' . $install_type,
'tgmpa-nonce'
);
$method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, array() ) ) ) {
return true;
}
if ( ! WP_Filesystem( $creds ) ) {
request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, array() ); // Setup WP_Filesystem.
return true;
}
/* If we arrive here, we have the filesystem. */
// Prep variables for Plugin_Installer_Skin class.
$extra = array();
$extra['slug'] = $slug; // Needed for potentially renaming of directory name.
$source = $this->get_download_url( $slug );
$api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null;
$api = ( false !== $api ) ? $api : null;
$url = add_query_arg(
array(
'action' => $install_type . '-plugin',
'plugin' => urlencode( $slug ),
),
'update.php'
);
if ( ! class_exists( 'Plugin_Upgrader', false ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
}
$title = ( 'update' === $install_type ) ? $this->strings['updating'] : $this->strings['installing'];
$skin_args = array(
'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload',
'title' => sprintf( $title, $this->plugins[ $slug ]['name'] ),
'url' => esc_url_raw( $url ),
'nonce' => $install_type . '-plugin_' . $slug,
'plugin' => '',
'api' => $api,
'extra' => $extra,
);
unset( $title );
if ( 'update' === $install_type ) {
$skin_args['plugin'] = $this->plugins[ $slug ]['file_path'];
$skin = new Plugin_Upgrader_Skin( $skin_args );
} else {
$skin = new Plugin_Installer_Skin( $skin_args );
}
// Create a new instance of Plugin_Upgrader.
$upgrader = new Plugin_Upgrader( $skin );
// Perform the action and install the plugin from the $source urldecode().
add_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 );
if ( 'update' === $install_type ) {
// Inject our info into the update transient.
$to_inject = array( $slug => $this->plugins[ $slug ] );
$to_inject[ $slug ]['source'] = $source;
$this->inject_update_info( $to_inject );
$upgrader->upgrade( $this->plugins[ $slug ]['file_path'] );
} else {
$upgrader->install( $source );
}
remove_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1 );
// Make sure we have the correct file path now the plugin is installed/updated.
$this->populate_file_path( $slug );
// Only activate plugins if the config option is set to true and the plugin isn't
// already active (upgrade).
if ( $this->is_automatic && ! $this->is_plugin_active( $slug ) ) {
$plugin_activate = $upgrader->plugin_info(); // Grab the plugin info from the Plugin_Upgrader method.
if ( false === $this->activate_single_plugin( $plugin_activate, $slug, true ) ) {
return true; // Finish execution of the function early as we encountered an error.
}
}
$this->show_tgmpa_version();
// Display message based on if all plugins are now active or not.
if ( $this->is_tgmpa_complete() ) {
echo '', sprintf( esc_html( $this->strings['complete'] ), '' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . ' ' ), '
';
echo '';
} else {
echo '', esc_html( $this->strings['return'] ), '
';
}
return true;
} elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) {
// Activate action link was clicked.
check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' );
if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) {
return true; // Finish execution of the function early as we encountered an error.
}
}
return false;
}
/**
* Inject information into the 'update_plugins' site transient as WP checks that before running an update.
*
* @since 2.5.0
*
* @param array $plugins The plugin information for the plugins which are to be updated.
*/
public function inject_update_info( $plugins ) {
$repo_updates = get_site_transient( 'update_plugins' );
if ( ! is_object( $repo_updates ) ) {
$repo_updates = new stdClass;
}
foreach ( $plugins as $slug => $plugin ) {
$file_path = $plugin['file_path'];
if ( empty( $repo_updates->response[ $file_path ] ) ) {
$repo_updates->response[ $file_path ] = new stdClass;
}
// We only really need to set package, but let's do all we can in case WP changes something.
$repo_updates->response[ $file_path ]->slug = $slug;
$repo_updates->response[ $file_path ]->plugin = $file_path;
$repo_updates->response[ $file_path ]->new_version = $plugin['version'];
$repo_updates->response[ $file_path ]->package = $plugin['source'];
if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) {
$repo_updates->response[ $file_path ]->url = $plugin['external_url'];
}
}
set_site_transient( 'update_plugins', $repo_updates );
}
/**
* Adjust the plugin directory name if necessary.
*
* The final destination directory of a plugin is based on the subdirectory name found in the
* (un)zipped source. In some cases - most notably GitHub repository plugin downloads -, this
* subdirectory name is not the same as the expected slug and the plugin will not be recognized
* as installed. This is fixed by adjusting the temporary unzipped source subdirectory name to
* the expected plugin slug.
*
* @since 2.5.0
*
* @param string $source Path to upgrade/zip-file-name.tmp/subdirectory/.
* @param string $remote_source Path to upgrade/zip-file-name.tmp.
* @param \WP_Upgrader $upgrader Instance of the upgrader which installs the plugin.
* @return string $source
*/
public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) {
if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) {
return $source;
}
// Check for single file plugins.
$source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) );
if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) {
return $source;
}
// Multi-file plugin, let's see if the directory is correctly named.
$desired_slug = '';
// Figure out what the slug is supposed to be.
if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) {
$desired_slug = $upgrader->skin->options['extra']['slug'];
} else {
// Bulk installer contains less info, so fall back on the info registered here.
foreach ( $this->plugins as $slug => $plugin ) {
if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) {
$desired_slug = $slug;
break;
}
}
unset( $slug, $plugin );
}
if ( ! empty( $desired_slug ) ) {
$subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) );
if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) {
$from_path = untrailingslashit( $source );
$to_path = trailingslashit( $remote_source ) . $desired_slug;
if ( true === $GLOBALS['wp_filesystem']->move( $from_path, $to_path ) ) {
return trailingslashit( $to_path );
} else {
return new WP_Error( 'rename_failed', esc_html__( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
}
} elseif ( empty( $subdir_name ) ) {
return new WP_Error( 'packaged_wrong', esc_html__( 'The remote plugin package consists of more than one file, but the files are not packaged in a folder.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
}
}
return $source;
}
/**
* Activate a single plugin and send feedback about the result to the screen.
*
* @since 2.5.0
*
* @param string $file_path Path within wp-plugins/ to main plugin file.
* @param string $slug Plugin slug.
* @param bool $automatic Whether this is an automatic activation after an install. Defaults to false.
* This determines the styling of the output messages.
* @return bool False if an error was encountered, true otherwise.
*/
protected function activate_single_plugin( $file_path, $slug, $automatic = false ) {
if ( $this->can_plugin_activate( $slug ) ) {
$activate = activate_plugin( $file_path );
if ( is_wp_error( $activate ) ) {
echo '', wp_kses_post( $activate->get_error_message() ), '
',
'', esc_html( $this->strings['return'] ), '
';
return false; // End it here if there is an error with activation.
} else {
if ( ! $automatic ) {
// Make sure message doesn't display again if bulk activation is performed
// immediately after a single activation.
if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
echo '', esc_html( $this->strings['activated_successfully'] ), ' ', esc_html( $this->plugins[ $slug ]['name'] ), '.
';
}
} else {
// Simpler message layout for use on the plugin install page.
echo '', esc_html( $this->strings['plugin_activated'] ), '
';
}
}
} elseif ( $this->is_plugin_active( $slug ) ) {
// No simpler message format provided as this message should never be encountered
// on the plugin install page.
echo '',
sprintf(
esc_html( $this->strings['plugin_already_active'] ),
'' . esc_html( $this->plugins[ $slug ]['name'] ) . ' '
),
'
';
} elseif ( $this->does_plugin_require_update( $slug ) ) {
if ( ! $automatic ) {
// Make sure message doesn't display again if bulk activation is performed
// immediately after a single activation.
if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
echo '',
sprintf(
esc_html( $this->strings['plugin_needs_higher_version'] ),
'' . esc_html( $this->plugins[ $slug ]['name'] ) . ' '
),
'
';
}
} else {
// Simpler message layout for use on the plugin install page.
echo '', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '
';
}
}
return true;
}
/**
* Echoes required plugin notice.
*
* Outputs a message telling users that a specific plugin is required for
* their theme. If appropriate, it includes a link to the form page where
* users can install and activate the plugin.
*
* Returns early if we're on the Install page.
*
* @since 1.0.0
*
* @global object $current_screen
*
* @return null Returns early if we're on the Install page.
*/
public function notices() {
// Remove nag on the install page / Return early if the nag message has been dismissed or user < author.
if ( ( $this->is_tgmpa_page() || $this->is_core_update_page() ) || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) || ! current_user_can( apply_filters( 'tgmpa_show_admin_notice_capability', 'publish_posts' ) ) ) {
return;
}
// Store for the plugin slugs by message type.
$message = array();
// Initialize counters used to determine plurality of action link texts.
$install_link_count = 0;
$update_link_count = 0;
$activate_link_count = 0;
$total_required_action_count = 0;
foreach ( $this->plugins as $slug => $plugin ) {
if ( $this->is_plugin_active( $slug ) && false === $this->does_plugin_have_update( $slug ) ) {
continue;
}
if ( ! $this->is_plugin_installed( $slug ) ) {
if ( current_user_can( 'install_plugins' ) ) {
$install_link_count++;
if ( true === $plugin['required'] ) {
$message['notice_can_install_required'][] = $slug;
} else {
$message['notice_can_install_recommended'][] = $slug;
}
}
if ( true === $plugin['required'] ) {
$total_required_action_count++;
}
} else {
if ( ! $this->is_plugin_active( $slug ) && $this->can_plugin_activate( $slug ) ) {
if ( current_user_can( 'activate_plugins' ) ) {
$activate_link_count++;
if ( true === $plugin['required'] ) {
$message['notice_can_activate_required'][] = $slug;
} else {
$message['notice_can_activate_recommended'][] = $slug;
}
}
if ( true === $plugin['required'] ) {
$total_required_action_count++;
}
}
if ( $this->does_plugin_require_update( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) {
if ( current_user_can( 'update_plugins' ) ) {
$update_link_count++;
if ( $this->does_plugin_require_update( $slug ) ) {
$message['notice_ask_to_update'][] = $slug;
} elseif ( false !== $this->does_plugin_have_update( $slug ) ) {
$message['notice_ask_to_update_maybe'][] = $slug;
}
}
if ( true === $plugin['required'] ) {
$total_required_action_count++;
}
}
}
}
unset( $slug, $plugin );
// If we have notices to display, we move forward.
if ( ! empty( $message ) || $total_required_action_count > 0 ) {
krsort( $message ); // Sort messages.
$rendered = '';
// As add_settings_error() wraps the final message in a and as the final message can't be
// filtered, using
's in our html would render invalid html output.
$line_template = '%s ' . "\n";
if ( ! current_user_can( 'activate_plugins' ) && ! current_user_can( 'install_plugins' ) && ! current_user_can( 'update_plugins' ) ) {
$rendered = esc_html( $this->strings['notice_cannot_install_activate'] ) . ' ' . esc_html( $this->strings['contact_admin'] );
$rendered .= $this->create_user_action_links_for_notice( 0, 0, 0, $line_template );
} else {
// If dismissable is false and a message is set, output it now.
if ( ! $this->dismissable && ! empty( $this->dismiss_msg ) ) {
$rendered .= sprintf( $line_template, wp_kses_post( $this->dismiss_msg ) );
}
// Render the individual message lines for the notice.
foreach ( $message as $type => $plugin_group ) {
$linked_plugins = array();
// Get the external info link for a plugin if one is available.
foreach ( $plugin_group as $plugin_slug ) {
$linked_plugins[] = $this->get_info_link( $plugin_slug );
}
unset( $plugin_slug );
$count = count( $plugin_group );
$linked_plugins = array_map( array( 'TGMPA_Utils', 'wrap_in_em' ), $linked_plugins );
$last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability.
$imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin );
$rendered .= sprintf(
$line_template,
sprintf(
translate_nooped_plural( $this->strings[ $type ], $count, 'tgmpa' ),
$imploded,
$count
)
);
}
unset( $type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded );
$rendered .= $this->create_user_action_links_for_notice( $install_link_count, $update_link_count, $activate_link_count, $line_template );
}
// Register the nag messages and prepare them to be processed.
add_settings_error( 'tgmpa', 'tgmpa', $rendered, $this->get_admin_notice_class() );
}
// Admin options pages already output settings_errors, so this is to avoid duplication.
if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) {
$this->display_settings_errors();
}
}
/**
* Generate the user action links for the admin notice.
*
* @since 2.6.0
*
* @param int $install_count Number of plugins to install.
* @param int $update_count Number of plugins to update.
* @param int $activate_count Number of plugins to activate.
* @param int $line_template Template for the HTML tag to output a line.
* @return string Action links.
*/
protected function create_user_action_links_for_notice( $install_count, $update_count, $activate_count, $line_template ) {
// Setup action links.
$action_links = array(
'install' => '',
'update' => '',
'activate' => '',
'dismiss' => $this->dismissable ? '' . esc_html( $this->strings['dismiss'] ) . ' ' : '',
);
$link_template = '%1$s ';
if ( current_user_can( 'install_plugins' ) ) {
if ( $install_count > 0 ) {
$action_links['install'] = sprintf(
$link_template,
translate_nooped_plural( $this->strings['install_link'], $install_count, 'tgmpa' ),
esc_url( $this->get_tgmpa_status_url( 'install' ) )
);
}
if ( $update_count > 0 ) {
$action_links['update'] = sprintf(
$link_template,
translate_nooped_plural( $this->strings['update_link'], $update_count, 'tgmpa' ),
esc_url( $this->get_tgmpa_status_url( 'update' ) )
);
}
}
if ( current_user_can( 'activate_plugins' ) && $activate_count > 0 ) {
$action_links['activate'] = sprintf(
$link_template,
translate_nooped_plural( $this->strings['activate_link'], $activate_count, 'tgmpa' ),
esc_url( $this->get_tgmpa_status_url( 'activate' ) )
);
}
$action_links = apply_filters( 'tgmpa_notice_action_links', $action_links );
$action_links = array_filter( (array) $action_links ); // Remove any empty array items.
if ( ! empty( $action_links ) ) {
$action_links = sprintf( $line_template, implode( ' | ', $action_links ) );
return apply_filters( 'tgmpa_notice_rendered_action_links', $action_links );
} else {
return '';
}
}
/**
* Get admin notice class.
*
* Work around all the changes to the various admin notice classes between WP 4.4 and 3.7
* (lowest supported version by TGMPA).
*
* @since 2.6.0
*
* @return string
*/
protected function get_admin_notice_class() {
if ( ! empty( $this->strings['nag_type'] ) ) {
return sanitize_html_class( strtolower( $this->strings['nag_type'] ) );
} else {
if ( version_compare( $this->wp_version, '4.2', '>=' ) ) {
return 'notice-warning';
} elseif ( version_compare( $this->wp_version, '4.1', '>=' ) ) {
return 'notice';
} else {
return 'updated';
}
}
}
/**
* Display settings errors and remove those which have been displayed to avoid duplicate messages showing
*
* @since 2.5.0
*/
protected function display_settings_errors() {
global $wp_settings_errors;
settings_errors( 'tgmpa' );
foreach ( (array) $wp_settings_errors as $key => $details ) {
if ( 'tgmpa' === $details['setting'] ) {
unset( $wp_settings_errors[ $key ] );
break;
}
}
}
/**
* Register dismissal of admin notices.
*
* Acts on the dismiss link in the admin nag messages.
* If clicked, the admin notice disappears and will no longer be visible to this user.
*
* @since 2.1.0
*/
public function dismiss() {
if ( isset( $_GET['tgmpa-dismiss'] ) && check_admin_referer( 'tgmpa-dismiss-' . get_current_user_id() ) ) {
update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 );
}
}
/**
* Add individual plugin to our collection of plugins.
*
* If the required keys are not set or the plugin has already
* been registered, the plugin is not added.
*
* @since 2.0.0
*
* @param array|null $plugin Array of plugin arguments or null if invalid argument.
* @return null Return early if incorrect argument.
*/
public function register( $plugin ) {
if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) {
return;
}
if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) {
return;
}
$defaults = array(
'name' => '', // String
'slug' => '', // String
'source' => 'repo', // String
'required' => false, // Boolean
'version' => '', // String
'force_activation' => false, // Boolean
'force_deactivation' => false, // Boolean
'external_url' => '', // String
'is_callable' => '', // String|Array.
);
// Prepare the received data.
$plugin = wp_parse_args( $plugin, $defaults );
// Standardize the received slug.
$plugin['slug'] = $this->sanitize_key( $plugin['slug'] );
// Forgive users for using string versions of booleans or floats for version number.
$plugin['version'] = (string) $plugin['version'];
$plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source'];
$plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] );
$plugin['force_activation'] = TGMPA_Utils::validate_bool( $plugin['force_activation'] );
$plugin['force_deactivation'] = TGMPA_Utils::validate_bool( $plugin['force_deactivation'] );
// Enrich the received data.
$plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] );
$plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] );
// Set the class properties.
$this->plugins[ $plugin['slug'] ] = $plugin;
$this->sort_order[ $plugin['slug'] ] = $plugin['name'];
// Should we add the force activation hook ?
if ( true === $plugin['force_activation'] ) {
$this->has_forced_activation = true;
}
// Should we add the force deactivation hook ?
if ( true === $plugin['force_deactivation'] ) {
$this->has_forced_deactivation = true;
}
}
/**
* Determine what type of source the plugin comes from.
*
* @since 2.5.0
*
* @param string $source The source of the plugin as provided, either empty (= WP repo), a file path
* (= bundled) or an external URL.
* @return string 'repo', 'external', or 'bundled'
*/
protected function get_plugin_source_type( $source ) {
if ( 'repo' === $source || preg_match( self::WP_REPO_REGEX, $source ) ) {
return 'repo';
} elseif ( preg_match( self::IS_URL_REGEX, $source ) ) {
return 'external';
} else {
return 'bundled';
}
}
/**
* Sanitizes a string key.
*
* Near duplicate of WP Core `sanitize_key()`. The difference is that uppercase characters *are*
* allowed, so as not to break upgrade paths from non-standard bundled plugins using uppercase
* characters in the plugin directory path/slug. Silly them.
*
* @see https://developer.wordpress.org/reference/hooks/sanitize_key/
*
* @since 2.5.0
*
* @param string $key String key.
* @return string Sanitized key
*/
public function sanitize_key( $key ) {
$raw_key = $key;
$key = preg_replace( '`[^A-Za-z0-9_-]`', '', $key );
/**
* Filter a sanitized key string.
*
* @since 2.5.0
*
* @param string $key Sanitized key.
* @param string $raw_key The key prior to sanitization.
*/
return apply_filters( 'tgmpa_sanitize_key', $key, $raw_key );
}
/**
* Amend default configuration settings.
*
* @since 2.0.0
*
* @param array $config Array of config options to pass as class properties.
*/
public function config( $config ) {
$keys = array(
'id',
'default_path',
'has_notices',
'dismissable',
'dismiss_msg',
'menu',
'parent_slug',
'capability',
'is_automatic',
'message',
'strings',
);
foreach ( $keys as $key ) {
if ( isset( $config[ $key ] ) ) {
if ( is_array( $config[ $key ] ) ) {
$this->$key = array_merge( $this->$key, $config[ $key ] );
} else {
$this->$key = $config[ $key ];
}
}
}
}
/**
* Amend action link after plugin installation.
*
* @since 2.0.0
*
* @param array $install_actions Existing array of actions.
* @return false|array Amended array of actions.
*/
public function actions( $install_actions ) {
// Remove action links on the TGMPA install page.
if ( $this->is_tgmpa_page() ) {
return false;
}
return $install_actions;
}
/**
* Flushes the plugins cache on theme switch to prevent stale entries
* from remaining in the plugin table.
*
* @since 2.4.0
*
* @param bool $clear_update_cache Optional. Whether to clear the Plugin updates cache.
* Parameter added in v2.5.0.
*/
public function flush_plugins_cache( $clear_update_cache = true ) {
wp_clean_plugins_cache( $clear_update_cache );
}
/**
* Set file_path key for each installed plugin.
*
* @since 2.1.0
*
* @param string $plugin_slug Optional. If set, only (re-)populates the file path for that specific plugin.
* Parameter added in v2.5.0.
*/
public function populate_file_path( $plugin_slug = '' ) {
if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) {
$this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug );
} else {
// Add file_path key for all plugins.
foreach ( $this->plugins as $slug => $values ) {
$this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug );
}
}
}
/**
* Helper function to extract the file path of the plugin file from the
* plugin slug, if the plugin is installed.
*
* @since 2.0.0
*
* @param string $slug Plugin slug (typically folder name) as provided by the developer.
* @return string Either file path for plugin if installed, or just the plugin slug.
*/
protected function _get_plugin_basename_from_slug( $slug ) {
$keys = array_keys( $this->get_plugins() );
foreach ( $keys as $key ) {
if ( preg_match( '|^' . $slug . '/|', $key ) ) {
return $key;
}
}
return $slug;
}
/**
* Retrieve plugin data, given the plugin name.
*
* Loops through the registered plugins looking for $name. If it finds it,
* it returns the $data from that plugin. Otherwise, returns false.
*
* @since 2.1.0
*
* @param string $name Name of the plugin, as it was registered.
* @param string $data Optional. Array key of plugin data to return. Default is slug.
* @return string|boolean Plugin slug if found, false otherwise.
*/
public function _get_plugin_data_from_name( $name, $data = 'slug' ) {
foreach ( $this->plugins as $values ) {
if ( $name === $values['name'] && isset( $values[ $data ] ) ) {
return $values[ $data ];
}
}
return false;
}
/**
* Retrieve the download URL for a package.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return string Plugin download URL or path to local file or empty string if undetermined.
*/
public function get_download_url( $slug ) {
$dl_source = '';
switch ( $this->plugins[ $slug ]['source_type'] ) {
case 'repo':
return $this->get_wp_repo_download_url( $slug );
case 'external':
return $this->plugins[ $slug ]['source'];
case 'bundled':
return $this->default_path . $this->plugins[ $slug ]['source'];
}
return $dl_source; // Should never happen.
}
/**
* Retrieve the download URL for a WP repo package.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return string Plugin download URL.
*/
protected function get_wp_repo_download_url( $slug ) {
$source = '';
$api = $this->get_plugins_api( $slug );
if ( false !== $api && isset( $api->download_link ) ) {
$source = $api->download_link;
}
return $source;
}
/**
* Try to grab information from WordPress API.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return object Plugins_api response object on success, WP_Error on failure.
*/
protected function get_plugins_api( $slug ) {
static $api = array(); // Cache received responses.
if ( ! isset( $api[ $slug ] ) ) {
if ( ! function_exists( 'plugins_api' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
}
$response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) );
$api[ $slug ] = false;
if ( is_wp_error( $response ) ) {
wp_die( esc_html( $this->strings['oops'] ) );
} else {
$api[ $slug ] = $response;
}
}
return $api[ $slug ];
}
/**
* Retrieve a link to a plugin information page.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return string Fully formed html link to a plugin information page if available
* or the plugin name if not.
*/
public function get_info_link( $slug ) {
if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) {
$link = sprintf(
'%2$s ',
esc_url( $this->plugins[ $slug ]['external_url'] ),
esc_html( $this->plugins[ $slug ]['name'] )
);
} elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) {
$url = add_query_arg(
array(
'tab' => 'plugin-information',
'plugin' => urlencode( $slug ),
'TB_iframe' => 'true',
'width' => '640',
'height' => '500',
),
self_admin_url( 'plugin-install.php' )
);
$link = sprintf(
'%2$s ',
esc_url( $url ),
esc_html( $this->plugins[ $slug ]['name'] )
);
} else {
$link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink.
}
return $link;
}
/**
* Determine if we're on the TGMPA Install page.
*
* @since 2.1.0
*
* @return boolean True when on the TGMPA page, false otherwise.
*/
protected function is_tgmpa_page() {
return isset( $_GET['page'] ) && $this->menu === $_GET['page'];
}
/**
* Determine if we're on a WP Core installation/upgrade page.
*
* @since 2.6.0
*
* @return boolean True when on a WP Core installation/upgrade page, false otherwise.
*/
protected function is_core_update_page() {
// Current screen is not always available, most notably on the customizer screen.
if ( ! function_exists( 'get_current_screen' ) ) {
return false;
}
$screen = get_current_screen();
if ( 'update-core' === $screen->base ) {
// Core update screen.
return true;
} elseif ( 'plugins' === $screen->base && ! empty( $_POST['action'] ) ) { // WPCS: CSRF ok.
// Plugins bulk update screen.
return true;
} elseif ( 'update' === $screen->base && ! empty( $_POST['action'] ) ) { // WPCS: CSRF ok.
// Individual updates (ajax call).
return true;
}
return false;
}
/**
* Retrieve the URL to the TGMPA Install page.
*
* I.e. depending on the config settings passed something along the lines of:
* http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins
*
* @since 2.5.0
*
* @return string Properly encoded URL (not escaped).
*/
public function get_tgmpa_url() {
static $url;
if ( ! isset( $url ) ) {
$parent = $this->parent_slug;
if ( false === strpos( $parent, '.php' ) ) {
$parent = 'admin.php';
}
$url = add_query_arg(
array(
'page' => urlencode( $this->menu ),
),
self_admin_url( $parent )
);
}
return $url;
}
/**
* Retrieve the URL to the TGMPA Install page for a specific plugin status (view).
*
* I.e. depending on the config settings passed something along the lines of:
* http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins&plugin_status=install
*
* @since 2.5.0
*
* @param string $status Plugin status - either 'install', 'update' or 'activate'.
* @return string Properly encoded URL (not escaped).
*/
public function get_tgmpa_status_url( $status ) {
return add_query_arg(
array(
'plugin_status' => urlencode( $status ),
),
$this->get_tgmpa_url()
);
}
/**
* Determine whether there are open actions for plugins registered with TGMPA.
*
* @since 2.5.0
*
* @return bool True if complete, i.e. no outstanding actions. False otherwise.
*/
public function is_tgmpa_complete() {
$complete = true;
foreach ( $this->plugins as $slug => $plugin ) {
if ( ! $this->is_plugin_active( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) {
$complete = false;
break;
}
}
return $complete;
}
/**
* Check if a plugin is installed. Does not take must-use plugins into account.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return bool True if installed, false otherwise.
*/
public function is_plugin_installed( $slug ) {
$installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached).
return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) );
}
/**
* Check if a plugin is active.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return bool True if active, false otherwise.
*/
public function is_plugin_active( $slug ) {
return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) );
}
/**
* Check if a plugin can be updated, i.e. if we have information on the minimum WP version required
* available, check whether the current install meets them.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return bool True if OK to update, false otherwise.
*/
public function can_plugin_update( $slug ) {
// We currently can't get reliable info on non-WP-repo plugins - issue #380.
if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
return true;
}
$api = $this->get_plugins_api( $slug );
if ( false !== $api && isset( $api->requires ) ) {
return version_compare( $this->wp_version, $api->requires, '>=' );
}
// No usable info received from the plugins API, presume we can update.
return true;
}
/**
* Check to see if the plugin is 'updatetable', i.e. installed, with an update available
* and no WP version requirements blocking it.
*
* @since 2.6.0
*
* @param string $slug Plugin slug.
* @return bool True if OK to proceed with update, false otherwise.
*/
public function is_plugin_updatetable( $slug ) {
if ( ! $this->is_plugin_installed( $slug ) ) {
return false;
} else {
return ( false !== $this->does_plugin_have_update( $slug ) && $this->can_plugin_update( $slug ) );
}
}
/**
* Check if a plugin can be activated, i.e. is not currently active and meets the minimum
* plugin version requirements set in TGMPA (if any).
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return bool True if OK to activate, false otherwise.
*/
public function can_plugin_activate( $slug ) {
return ( ! $this->is_plugin_active( $slug ) && ! $this->does_plugin_require_update( $slug ) );
}
/**
* Retrieve the version number of an installed plugin.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return string Version number as string or an empty string if the plugin is not installed
* or version unknown (plugins which don't comply with the plugin header standard).
*/
public function get_installed_version( $slug ) {
$installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached).
if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) {
return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'];
}
return '';
}
/**
* Check whether a plugin complies with the minimum version requirements.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return bool True when a plugin needs to be updated, otherwise false.
*/
public function does_plugin_require_update( $slug ) {
$installed_version = $this->get_installed_version( $slug );
$minimum_version = $this->plugins[ $slug ]['version'];
return version_compare( $minimum_version, $installed_version, '>' );
}
/**
* Check whether there is an update available for a plugin.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return false|string Version number string of the available update or false if no update available.
*/
public function does_plugin_have_update( $slug ) {
// Presume bundled and external plugins will point to a package which meets the minimum required version.
if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
if ( $this->does_plugin_require_update( $slug ) ) {
return $this->plugins[ $slug ]['version'];
}
return false;
}
$repo_updates = get_site_transient( 'update_plugins' );
if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) {
return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version;
}
return false;
}
/**
* Retrieve potential upgrade notice for a plugin.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return string The upgrade notice or an empty string if no message was available or provided.
*/
public function get_upgrade_notice( $slug ) {
// We currently can't get reliable info on non-WP-repo plugins - issue #380.
if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
return '';
}
$repo_updates = get_site_transient( 'update_plugins' );
if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) {
return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice;
}
return '';
}
/**
* Wrapper around the core WP get_plugins function, making sure it's actually available.
*
* @since 2.5.0
*
* @param string $plugin_folder Optional. Relative path to single plugin folder.
* @return array Array of installed plugins with plugin information.
*/
public function get_plugins( $plugin_folder = '' ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
return get_plugins( $plugin_folder );
}
/**
* Delete dismissable nag option when theme is switched.
*
* This ensures that the user(s) is/are again reminded via nag of required
* and/or recommended plugins if they re-activate the theme.
*
* @since 2.1.1
*/
public function update_dismiss() {
delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true );
}
/**
* Forces plugin activation if the parameter 'force_activation' is
* set to true.
*
* This allows theme authors to specify certain plugins that must be
* active at all times while using the current theme.
*
* Please take special care when using this parameter as it has the
* potential to be harmful if not used correctly. Setting this parameter
* to true will not allow the specified plugin to be deactivated unless
* the user switches themes.
*
* @since 2.2.0
*/
public function force_activation() {
foreach ( $this->plugins as $slug => $plugin ) {
if ( true === $plugin['force_activation'] ) {
if ( ! $this->is_plugin_installed( $slug ) ) {
// Oops, plugin isn't there so iterate to next condition.
continue;
} elseif ( $this->can_plugin_activate( $slug ) ) {
// There we go, activate the plugin.
activate_plugin( $plugin['file_path'] );
}
}
}
}
/**
* Forces plugin deactivation if the parameter 'force_deactivation'
* is set to true and adds the plugin to the 'recently active' plugins list.
*
* This allows theme authors to specify certain plugins that must be
* deactivated upon switching from the current theme to another.
*
* Please take special care when using this parameter as it has the
* potential to be harmful if not used correctly.
*
* @since 2.2.0
*/
public function force_deactivation() {
$deactivated = array();
foreach ( $this->plugins as $slug => $plugin ) {
/*
* Only proceed forward if the parameter is set to true and plugin is active
* as a 'normal' (not must-use) plugin.
*/
if ( true === $plugin['force_deactivation'] && is_plugin_active( $plugin['file_path'] ) ) {
deactivate_plugins( $plugin['file_path'] );
$deactivated[ $plugin['file_path'] ] = time();
}
}
if ( ! empty( $deactivated ) ) {
update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
}
}
/**
* Echo the current TGMPA version number to the page.
*
* @since 2.5.0
*/
public function show_tgmpa_version() {
echo '
',
esc_html(
sprintf(
/* translators: %s: version number */
__( 'TGMPA v%s', 'tgmpa' ),
self::TGMPA_VERSION
)
),
'
';
}
/**
* Returns the singleton instance of the class.
*
* @since 2.4.0
*
* @return \TGM_Plugin_Activation The TGM_Plugin_Activation object.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
self::$instance = new self();
}
return self::$instance;
}
}
if ( ! function_exists( 'load_tgm_plugin_activation' ) ) {
/**
* Ensure only one instance of the class is ever invoked.
*
* @since 2.5.0
*/
function load_tgm_plugin_activation() {
$GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance();
}
}
if ( did_action( 'plugins_loaded' ) ) {
load_tgm_plugin_activation();
} else {
add_action( 'plugins_loaded', 'load_tgm_plugin_activation' );
}
}
if ( ! function_exists( 'tgmpa' ) ) {
/**
* Helper function to register a collection of required plugins.
*
* @since 2.0.0
* @api
*
* @param array $plugins An array of plugin arrays.
* @param array $config Optional. An array of configuration values.
*/
function tgmpa( $plugins, $config = array() ) {
$instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
foreach ( $plugins as $plugin ) {
call_user_func( array( $instance, 'register' ), $plugin );
}
if ( ! empty( $config ) && is_array( $config ) ) {
// Send out notices for deprecated arguments passed.
if ( isset( $config['notices'] ) ) {
_deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' );
if ( ! isset( $config['has_notices'] ) ) {
$config['has_notices'] = $config['notices'];
}
}
if ( isset( $config['parent_menu_slug'] ) ) {
_deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_menu_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' );
}
if ( isset( $config['parent_url_slug'] ) ) {
_deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_url_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' );
}
call_user_func( array( $instance, 'config' ), $config );
}
}
}
/**
* WP_List_Table isn't always available. If it isn't available,
* we load it here.
*
* @since 2.2.0
*/
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
if ( ! class_exists( 'TGMPA_List_Table' ) ) {
/**
* List table class for handling plugins.
*
* Extends the WP_List_Table class to provide a future-compatible
* way of listing out all required/recommended plugins.
*
* Gives users an interface similar to the Plugin Administration
* area with similar (albeit stripped down) capabilities.
*
* This class also allows for the bulk install of plugins.
*
* @since 2.2.0
*
* @package TGM-Plugin-Activation
* @author Thomas Griffin
* @author Gary Jones
*/
class TGMPA_List_Table extends WP_List_Table {
/**
* TGMPA instance.
*
* @since 2.5.0
*
* @var object
*/
protected $tgmpa;
/**
* The currently chosen view.
*
* @since 2.5.0
*
* @var string One of: 'all', 'install', 'update', 'activate'
*/
public $view_context = 'all';
/**
* The plugin counts for the various views.
*
* @since 2.5.0
*
* @var array
*/
protected $view_totals = array(
'all' => 0,
'install' => 0,
'update' => 0,
'activate' => 0,
);
/**
* References parent constructor and sets defaults for class.
*
* @since 2.2.0
*/
public function __construct() {
$this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
parent::__construct(
array(
'singular' => 'plugin',
'plural' => 'plugins',
'ajax' => false,
)
);
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) {
$this->view_context = sanitize_key( $_REQUEST['plugin_status'] );
}
add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) );
}
/**
* Get a list of CSS classes for the tag.
*
* Overruled to prevent the 'plural' argument from being added.
*
* @since 2.5.0
*
* @return array CSS classnames.
*/
public function get_table_classes() {
return array( 'widefat', 'fixed' );
}
/**
* Gathers and renames all of our plugin information to be used by WP_List_Table to create our table.
*
* @since 2.2.0
*
* @return array $table_data Information for use in table.
*/
protected function _gather_plugin_data() {
// Load thickbox for plugin links.
$this->tgmpa->admin_init();
$this->tgmpa->thickbox();
// Categorize the plugins which have open actions.
$plugins = $this->categorize_plugins_to_views();
// Set the counts for the view links.
$this->set_view_totals( $plugins );
// Prep variables for use and grab list of all installed plugins.
$table_data = array();
$i = 0;
// Redirect to the 'all' view if no plugins were found for the selected view context.
if ( empty( $plugins[ $this->view_context ] ) ) {
$this->view_context = 'all';
}
foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) {
$table_data[ $i ]['sanitized_plugin'] = $plugin['name'];
$table_data[ $i ]['slug'] = $slug;
$table_data[ $i ]['plugin'] = '' . $this->tgmpa->get_info_link( $slug ) . ' ';
$table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] );
$table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] );
$table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug );
$table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug );
$table_data[ $i ]['minimum_version'] = $plugin['version'];
$table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug );
// Prep the upgrade notice info.
$upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug );
if ( ! empty( $upgrade_notice ) ) {
$table_data[ $i ]['upgrade_notice'] = $upgrade_notice;
add_action( "tgmpa_after_plugin_row_{$slug}", array( $this, 'wp_plugin_update_row' ), 10, 2 );
}
$table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin );
$i++;
}
return $table_data;
}
/**
* Categorize the plugins which have open actions into views for the TGMPA page.
*
* @since 2.5.0
*/
protected function categorize_plugins_to_views() {
$plugins = array(
'all' => array(), // Meaning: all plugins which still have open actions.
'install' => array(),
'update' => array(),
'activate' => array(),
);
foreach ( $this->tgmpa->plugins as $slug => $plugin ) {
if ( $this->tgmpa->is_plugin_active( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) {
// No need to display plugins if they are installed, up-to-date and active.
continue;
} else {
$plugins['all'][ $slug ] = $plugin;
if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) {
$plugins['install'][ $slug ] = $plugin;
} else {
if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
$plugins['update'][ $slug ] = $plugin;
}
if ( $this->tgmpa->can_plugin_activate( $slug ) ) {
$plugins['activate'][ $slug ] = $plugin;
}
}
}
}
return $plugins;
}
/**
* Set the counts for the view links.
*
* @since 2.5.0
*
* @param array $plugins Plugins order by view.
*/
protected function set_view_totals( $plugins ) {
foreach ( $plugins as $type => $list ) {
$this->view_totals[ $type ] = count( $list );
}
}
/**
* Get the plugin required/recommended text string.
*
* @since 2.5.0
*
* @param string $required Plugin required setting.
* @return string
*/
protected function get_plugin_advise_type_text( $required ) {
if ( true === $required ) {
return __( 'Required', 'tgmpa' );
}
return __( 'Recommended', 'tgmpa' );
}
/**
* Get the plugin source type text string.
*
* @since 2.5.0
*
* @param string $type Plugin type.
* @return string
*/
protected function get_plugin_source_type_text( $type ) {
$string = '';
switch ( $type ) {
case 'repo':
$string = __( 'WordPress Repository', 'tgmpa' );
break;
case 'external':
$string = __( 'External Source', 'tgmpa' );
break;
case 'bundled':
$string = __( 'Pre-Packaged', 'tgmpa' );
break;
}
return $string;
}
/**
* Determine the plugin status message.
*
* @since 2.5.0
*
* @param string $slug Plugin slug.
* @return string
*/
protected function get_plugin_status_text( $slug ) {
if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) {
return __( 'Not Installed', 'tgmpa' );
}
if ( ! $this->tgmpa->is_plugin_active( $slug ) ) {
$install_status = __( 'Installed But Not Activated', 'tgmpa' );
} else {
$install_status = __( 'Active', 'tgmpa' );
}
$update_status = '';
if ( $this->tgmpa->does_plugin_require_update( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) {
$update_status = __( 'Required Update not Available', 'tgmpa' );
} elseif ( $this->tgmpa->does_plugin_require_update( $slug ) ) {
$update_status = __( 'Requires Update', 'tgmpa' );
} elseif ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
$update_status = __( 'Update recommended', 'tgmpa' );
}
if ( '' === $update_status ) {
return $install_status;
}
return sprintf(
/* translators: 1: install status, 2: update status */
_x( '%1$s, %2$s', 'Install/Update Status', 'tgmpa' ),
$install_status,
$update_status
);
}
/**
* Sort plugins by Required/Recommended type and by alphabetical plugin name within each type.
*
* @since 2.5.0
*
* @param array $items Prepared table items.
* @return array Sorted table items.
*/
public function sort_table_items( $items ) {
$type = array();
$name = array();
foreach ( $items as $i => $plugin ) {
$type[ $i ] = $plugin['type']; // Required / recommended.
$name[ $i ] = $plugin['sanitized_plugin'];
}
array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items );
return $items;
}
/**
* Get an associative array ( id => link ) of the views available on this table.
*
* @since 2.5.0
*
* @return array
*/
public function get_views() {
$status_links = array();
foreach ( $this->view_totals as $type => $count ) {
if ( $count < 1 ) {
continue;
}
switch ( $type ) {
case 'all':
/* translators: 1: number of plugins. */
$text = _nx( 'All (%s) ', 'All (%s) ', $count, 'plugins', 'tgmpa' );
break;
case 'install':
/* translators: 1: number of plugins. */
$text = _n( 'To Install (%s) ', 'To Install (%s) ', $count, 'tgmpa' );
break;
case 'update':
/* translators: 1: number of plugins. */
$text = _n( 'Update Available (%s) ', 'Update Available (%s) ', $count, 'tgmpa' );
break;
case 'activate':
/* translators: 1: number of plugins. */
$text = _n( 'To Activate (%s) ', 'To Activate (%s) ', $count, 'tgmpa' );
break;
default:
$text = '';
break;
}
if ( ! empty( $text ) ) {
$status_links[ $type ] = sprintf(
'%s ',
esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ),
( $type === $this->view_context ) ? ' class="current"' : '',
sprintf( $text, number_format_i18n( $count ) )
);
}
}
return $status_links;
}
/**
* Create default columns to display important plugin information
* like type, action and status.
*
* @since 2.2.0
*
* @param array $item Array of item data.
* @param string $column_name The name of the column.
* @return string
*/
public function column_default( $item, $column_name ) {
return $item[ $column_name ];
}
/**
* Required for bulk installing.
*
* Adds a checkbox for each plugin.
*
* @since 2.2.0
*
* @param array $item Array of item data.
* @return string The input checkbox with all necessary info.
*/
public function column_cb( $item ) {
return sprintf(
' ',
esc_attr( $this->_args['singular'] ),
esc_attr( $item['slug'] ),
esc_attr( $item['sanitized_plugin'] )
);
}
/**
* Create default title column along with the action links.
*
* @since 2.2.0
*
* @param array $item Array of item data.
* @return string The plugin name and action links.
*/
public function column_plugin( $item ) {
return sprintf(
'%1$s %2$s',
$item['plugin'],
$this->row_actions( $this->get_row_actions( $item ), true )
);
}
/**
* Create version information column.
*
* @since 2.5.0
*
* @param array $item Array of item data.
* @return string HTML-formatted version information.
*/
public function column_version( $item ) {
$output = array();
if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) {
$installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' );
$color = '';
if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) {
$color = ' color: #ff0000; font-weight: bold;';
}
$output[] = sprintf(
'%2$s ' . __( 'Installed version:', 'tgmpa' ) . '
',
$color,
$installed
);
}
if ( ! empty( $item['minimum_version'] ) ) {
$output[] = sprintf(
'%1$s ' . __( 'Minimum required version:', 'tgmpa' ) . '
',
$item['minimum_version']
);
}
if ( ! empty( $item['available_version'] ) ) {
$color = '';
if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) {
$color = ' color: #71C671; font-weight: bold;';
}
$output[] = sprintf(
'%2$s ' . __( 'Available version:', 'tgmpa' ) . '
',
$color,
$item['available_version']
);
}
if ( empty( $output ) ) {
return ' '; // Let's not break the table layout.
} else {
return implode( "\n", $output );
}
}
/**
* Sets default message within the plugins table if no plugins
* are left for interaction.
*
* Hides the menu item to prevent the user from clicking and
* getting a permissions error.
*
* @since 2.2.0
*/
public function no_items() {
echo esc_html__( 'No plugins to install, update or activate.', 'tgmpa' ) . ' ' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . ' ';
echo '';
}
/**
* Output all the column information within the table.
*
* @since 2.2.0
*
* @return array $columns The column names.
*/
public function get_columns() {
$columns = array(
'cb' => ' ',
'plugin' => __( 'Plugin', 'tgmpa' ),
'source' => __( 'Source', 'tgmpa' ),
'type' => __( 'Type', 'tgmpa' ),
);
if ( 'all' === $this->view_context || 'update' === $this->view_context ) {
$columns['version'] = __( 'Version', 'tgmpa' );
$columns['status'] = __( 'Status', 'tgmpa' );
}
return apply_filters( 'tgmpa_table_columns', $columns );
}
/**
* Get name of default primary column
*
* @since 2.5.0 / WP 4.3+ compatibility
* @access protected
*
* @return string
*/
protected function get_default_primary_column_name() {
return 'plugin';
}
/**
* Get the name of the primary column.
*
* @since 2.5.0 / WP 4.3+ compatibility
* @access protected
*
* @return string The name of the primary column.
*/
protected function get_primary_column_name() {
if ( method_exists( 'WP_List_Table', 'get_primary_column_name' ) ) {
return parent::get_primary_column_name();
} else {
return $this->get_default_primary_column_name();
}
}
/**
* Get the actions which are relevant for a specific plugin row.
*
* @since 2.5.0
*
* @param array $item Array of item data.
* @return array Array with relevant action links.
*/
protected function get_row_actions( $item ) {
$actions = array();
$action_links = array();
// Display the 'Install' action link if the plugin is not yet available.
if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) {
/* translators: %2$s: plugin name in screen reader markup */
$actions['install'] = __( 'Install %2$s', 'tgmpa' );
} else {
// Display the 'Update' action link if an update is available and WP complies with plugin minimum.
if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) {
/* translators: %2$s: plugin name in screen reader markup */
$actions['update'] = __( 'Update %2$s', 'tgmpa' );
}
// Display the 'Activate' action link, but only if the plugin meets the minimum version.
if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) {
/* translators: %2$s: plugin name in screen reader markup */
$actions['activate'] = __( 'Activate %2$s', 'tgmpa' );
}
}
// Create the actual links.
foreach ( $actions as $action => $text ) {
$nonce_url = wp_nonce_url(
add_query_arg(
array(
'plugin' => urlencode( $item['slug'] ),
'tgmpa-' . $action => $action . '-plugin',
),
$this->tgmpa->get_tgmpa_url()
),
'tgmpa-' . $action,
'tgmpa-nonce'
);
$action_links[ $action ] = sprintf(
'' . esc_html( $text ) . ' ', // $text contains the second placeholder.
esc_url( $nonce_url ),
'' . esc_html( $item['sanitized_plugin'] ) . ' '
);
}
$prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : '';
return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context );
}
/**
* Generates content for a single row of the table.
*
* @since 2.5.0
*
* @param object $item The current item.
*/
public function single_row( $item ) {
parent::single_row( $item );
/**
* Fires after each specific row in the TGMPA Plugins list table.
*
* The dynamic portion of the hook name, `$item['slug']`, refers to the slug
* for the plugin.
*
* @since 2.5.0
*/
do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context );
}
/**
* Show the upgrade notice below a plugin row if there is one.
*
* @since 2.5.0
*
* @see /wp-admin/includes/update.php
*
* @param string $slug Plugin slug.
* @param array $item The information available in this table row.
* @return null Return early if upgrade notice is empty.
*/
public function wp_plugin_update_row( $slug, $item ) {
if ( empty( $item['upgrade_notice'] ) ) {
return;
}
echo '
',
esc_html__( 'Upgrade message from the plugin author:', 'tgmpa' ),
' ', wp_kses_data( $item['upgrade_notice'] ), '
';
}
/**
* Extra controls to be displayed between bulk actions and pagination.
*
* @since 2.5.0
*
* @param string $which 'top' or 'bottom' table navigation.
*/
public function extra_tablenav( $which ) {
if ( 'bottom' === $which ) {
$this->tgmpa->show_tgmpa_version();
}
}
/**
* Defines the bulk actions for handling registered plugins.
*
* @since 2.2.0
*
* @return array $actions The bulk actions for the plugin install table.
*/
public function get_bulk_actions() {
$actions = array();
if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) {
if ( current_user_can( 'install_plugins' ) ) {
$actions['tgmpa-bulk-install'] = __( 'Install', 'tgmpa' );
}
}
if ( 'install' !== $this->view_context ) {
if ( current_user_can( 'update_plugins' ) ) {
$actions['tgmpa-bulk-update'] = __( 'Update', 'tgmpa' );
}
if ( current_user_can( 'activate_plugins' ) ) {
$actions['tgmpa-bulk-activate'] = __( 'Activate', 'tgmpa' );
}
}
return $actions;
}
/**
* Processes bulk installation and activation actions.
*
* The bulk installation process looks for the $_POST information and passes that
* through if a user has to use WP_Filesystem to enter their credentials.
*
* @since 2.2.0
*/
public function process_bulk_actions() {
// Bulk installation process.
if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) {
check_admin_referer( 'bulk-' . $this->_args['plural'] );
$install_type = 'install';
if ( 'tgmpa-bulk-update' === $this->current_action() ) {
$install_type = 'update';
}
$plugins_to_install = array();
// Did user actually select any plugins to install/update ?
if ( empty( $_POST['plugin'] ) ) {
if ( 'install' === $install_type ) {
$message = __( 'No plugins were selected to be installed. No action taken.', 'tgmpa' );
} else {
$message = __( 'No plugins were selected to be updated. No action taken.', 'tgmpa' );
}
echo '', esc_html( $message ), '
';
return false;
}
if ( is_array( $_POST['plugin'] ) ) {
$plugins_to_install = (array) $_POST['plugin'];
} elseif ( is_string( $_POST['plugin'] ) ) {
// Received via Filesystem page - un-flatten array (WP bug #19643).
$plugins_to_install = explode( ',', $_POST['plugin'] );
}
// Sanitize the received input.
$plugins_to_install = array_map( 'urldecode', $plugins_to_install );
$plugins_to_install = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins_to_install );
// Validate the received input.
foreach ( $plugins_to_install as $key => $slug ) {
// Check if the plugin was registered with TGMPA and remove if not.
if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) {
unset( $plugins_to_install[ $key ] );
continue;
}
// For install: make sure this is a plugin we *can* install and not one already installed.
if ( 'install' === $install_type && true === $this->tgmpa->is_plugin_installed( $slug ) ) {
unset( $plugins_to_install[ $key ] );
}
// For updates: make sure this is a plugin we *can* update (update available and WP version ok).
if ( 'update' === $install_type && false === $this->tgmpa->is_plugin_updatetable( $slug ) ) {
unset( $plugins_to_install[ $key ] );
}
}
// No need to proceed further if we have no plugins to handle.
if ( empty( $plugins_to_install ) ) {
if ( 'install' === $install_type ) {
$message = __( 'No plugins are available to be installed at this time.', 'tgmpa' );
} else {
$message = __( 'No plugins are available to be updated at this time.', 'tgmpa' );
}
echo '', esc_html( $message ), '
';
return false;
}
// Pass all necessary information if WP_Filesystem is needed.
$url = wp_nonce_url(
$this->tgmpa->get_tgmpa_url(),
'bulk-' . $this->_args['plural']
);
// Give validated data back to $_POST which is the only place the filesystem looks for extra fields.
$_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643.
$method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
$fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem.
if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, $fields ) ) ) {
return true; // Stop the normal page form from displaying, credential request form will be shown.
}
// Now we have some credentials, setup WP_Filesystem.
if ( ! WP_Filesystem( $creds ) ) {
// Our credentials were no good, ask the user for them again.
request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, $fields );
return true;
}
/* If we arrive here, we have the filesystem */
// Store all information in arrays since we are processing a bulk installation.
$names = array();
$sources = array(); // Needed for installs.
$file_paths = array(); // Needed for upgrades.
$to_inject = array(); // Information to inject into the update_plugins transient.
// Prepare the data for validated plugins for the install/upgrade.
foreach ( $plugins_to_install as $slug ) {
$name = $this->tgmpa->plugins[ $slug ]['name'];
$source = $this->tgmpa->get_download_url( $slug );
if ( ! empty( $name ) && ! empty( $source ) ) {
$names[] = $name;
switch ( $install_type ) {
case 'install':
$sources[] = $source;
break;
case 'update':
$file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path'];
$to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ];
$to_inject[ $slug ]['source'] = $source;
break;
}
}
}
unset( $slug, $name, $source );
// Create a new instance of TGMPA_Bulk_Installer.
$installer = new TGMPA_Bulk_Installer(
new TGMPA_Bulk_Installer_Skin(
array(
'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ),
'nonce' => 'bulk-' . $this->_args['plural'],
'names' => $names,
'install_type' => $install_type,
)
)
);
// Wrap the install process with the appropriate HTML.
echo '',
'
', esc_html( get_admin_page_title() ), '
';
// Process the bulk installation submissions.
add_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 );
if ( 'tgmpa-bulk-update' === $this->current_action() ) {
// Inject our info into the update transient.
$this->tgmpa->inject_update_info( $to_inject );
$installer->bulk_upgrade( $file_paths );
} else {
$installer->bulk_install( $sources );
}
remove_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1 );
echo '
';
return true;
}
// Bulk activation process.
if ( 'tgmpa-bulk-activate' === $this->current_action() ) {
check_admin_referer( 'bulk-' . $this->_args['plural'] );
// Did user actually select any plugins to activate ?
if ( empty( $_POST['plugin'] ) ) {
echo '', esc_html__( 'No plugins were selected to be activated. No action taken.', 'tgmpa' ), '
';
return false;
}
// Grab plugin data from $_POST.
$plugins = array();
if ( isset( $_POST['plugin'] ) ) {
$plugins = array_map( 'urldecode', (array) $_POST['plugin'] );
$plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins );
}
$plugins_to_activate = array();
$plugin_names = array();
// Grab the file paths for the selected & inactive plugins from the registration array.
foreach ( $plugins as $slug ) {
if ( $this->tgmpa->can_plugin_activate( $slug ) ) {
$plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path'];
$plugin_names[] = $this->tgmpa->plugins[ $slug ]['name'];
}
}
unset( $slug );
// Return early if there are no plugins to activate.
if ( empty( $plugins_to_activate ) ) {
echo '', esc_html__( 'No plugins are available to be activated at this time.', 'tgmpa' ), '
';
return false;
}
// Now we are good to go - let's start activating plugins.
$activate = activate_plugins( $plugins_to_activate );
if ( is_wp_error( $activate ) ) {
echo '', wp_kses_post( $activate->get_error_message() ), '
';
} else {
$count = count( $plugin_names ); // Count so we can use _n function.
$plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names );
$last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability.
$imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin );
printf( // WPCS: xss ok.
'',
esc_html( _n( 'The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'tgmpa' ) ),
$imploded
);
// Update recently activated plugins option.
$recent = (array) get_option( 'recently_activated' );
foreach ( $plugins_to_activate as $plugin => $time ) {
if ( isset( $recent[ $plugin ] ) ) {
unset( $recent[ $plugin ] );
}
}
update_option( 'recently_activated', $recent );
}
unset( $_POST ); // Reset the $_POST variable in case user wants to perform one action after another.
return true;
}
return false;
}
/**
* Prepares all of our information to be outputted into a usable table.
*
* @since 2.2.0
*/
public function prepare_items() {
$columns = $this->get_columns(); // Get all necessary column information.
$hidden = array(); // No columns to hide, but we must set as an array.
$sortable = array(); // No reason to make sortable columns.
$primary = $this->get_primary_column_name(); // Column which has the row actions.
$this->_column_headers = array( $columns, $hidden, $sortable, $primary ); // Get all necessary column headers.
// Process our bulk activations here.
if ( 'tgmpa-bulk-activate' === $this->current_action() ) {
$this->process_bulk_actions();
}
// Store all of our plugin data into $items array so WP_List_Table can use it.
$this->items = apply_filters( 'tgmpa_table_data_items', $this->_gather_plugin_data() );
}
/* *********** DEPRECATED METHODS *********** */
/**
* Retrieve plugin data, given the plugin name.
*
* @since 2.2.0
* @deprecated 2.5.0 use {@see TGM_Plugin_Activation::_get_plugin_data_from_name()} instead.
* @see TGM_Plugin_Activation::_get_plugin_data_from_name()
*
* @param string $name Name of the plugin, as it was registered.
* @param string $data Optional. Array key of plugin data to return. Default is slug.
* @return string|boolean Plugin slug if found, false otherwise.
*/
protected function _get_plugin_data_from_name( $name, $data = 'slug' ) {
_deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'TGM_Plugin_Activation::_get_plugin_data_from_name()' );
return $this->tgmpa->_get_plugin_data_from_name( $name, $data );
}
}
}
if ( ! class_exists( 'TGM_Bulk_Installer' ) ) {
/**
* Hack: Prevent TGMPA v2.4.1- bulk installer class from being loaded if 2.4.1- is loaded after 2.5+.
*
* @since 2.5.2
*
* {@internal The TGMPA_Bulk_Installer class was originally called TGM_Bulk_Installer.
* For more information, see that class.}}
*/
class TGM_Bulk_Installer {
}
}
if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) {
/**
* Hack: Prevent TGMPA v2.4.1- bulk installer skin class from being loaded if 2.4.1- is loaded after 2.5+.
*
* @since 2.5.2
*
* {@internal The TGMPA_Bulk_Installer_Skin class was originally called TGM_Bulk_Installer_Skin.
* For more information, see that class.}}
*/
class TGM_Bulk_Installer_Skin {
}
}
/**
* The WP_Upgrader file isn't always available. If it isn't available,
* we load it here.
*
* We check to make sure no action or activation keys are set so that WordPress
* does not try to re-include the class when processing upgrades or installs outside
* of the class.
*
* @since 2.2.0
*/
add_action( 'admin_init', 'tgmpa_load_bulk_installer' );
if ( ! function_exists( 'tgmpa_load_bulk_installer' ) ) {
/**
* Load bulk installer
*/
function tgmpa_load_bulk_installer() {
// Silently fail if 2.5+ is loaded *after* an older version.
if ( ! isset( $GLOBALS['tgmpa'] ) ) {
return;
}
// Get TGMPA class instance.
$tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) {
if ( ! class_exists( 'Plugin_Upgrader', false ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
}
if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) {
/**
* Installer class to handle bulk plugin installations.
*
* Extends WP_Upgrader and customizes to suit the installation of multiple
* plugins.
*
* @since 2.2.0
*
* {@internal Since 2.5.0 the class is an extension of Plugin_Upgrader rather than WP_Upgrader.}}
* {@internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer to TGMPA_Bulk_Installer.
* This was done to prevent backward compatibility issues with v2.3.6.}}
*
* @package TGM-Plugin-Activation
* @author Thomas Griffin
* @author Gary Jones
*/
class TGMPA_Bulk_Installer extends Plugin_Upgrader {
/**
* Holds result of bulk plugin installation.
*
* @since 2.2.0
*
* @var string
*/
public $result;
/**
* Flag to check if bulk installation is occurring or not.
*
* @since 2.2.0
*
* @var boolean
*/
public $bulk = false;
/**
* TGMPA instance
*
* @since 2.5.0
*
* @var object
*/
protected $tgmpa;
/**
* Whether or not the destination directory needs to be cleared ( = on update).
*
* @since 2.5.0
*
* @var bool
*/
protected $clear_destination = false;
/**
* References parent constructor and sets defaults for class.
*
* @since 2.2.0
*
* @param \Bulk_Upgrader_Skin|null $skin Installer skin.
*/
public function __construct( $skin = null ) {
// Get TGMPA class instance.
$this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
parent::__construct( $skin );
if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) {
$this->clear_destination = true;
}
if ( $this->tgmpa->is_automatic ) {
$this->activate_strings();
}
add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) );
}
/**
* Sets the correct activation strings for the installer skin to use.
*
* @since 2.2.0
*/
public function activate_strings() {
$this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' );
$this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' );
}
/**
* Performs the actual installation of each plugin.
*
* @since 2.2.0
*
* @see WP_Upgrader::run()
*
* @param array $options The installation config options.
* @return null|array Return early if error, array of installation data on success.
*/
public function run( $options ) {
$result = parent::run( $options );
// Reset the strings in case we changed one during automatic activation.
if ( $this->tgmpa->is_automatic ) {
if ( 'update' === $this->skin->options['install_type'] ) {
$this->upgrade_strings();
} else {
$this->install_strings();
}
}
return $result;
}
/**
* Processes the bulk installation of plugins.
*
* @since 2.2.0
*
* {@internal This is basically a near identical copy of the WP Core
* Plugin_Upgrader::bulk_upgrade() method, with minor adjustments to deal with
* new installs instead of upgrades.
* For ease of future synchronizations, the adjustments are clearly commented, but no other
* comments are added. Code style has been made to comply.}}
*
* @see Plugin_Upgrader::bulk_upgrade()
* @see https://core.trac.wordpress.org/browser/tags/4.2.1/src/wp-admin/includes/class-wp-upgrader.php#L838
* (@internal Last synced: Dec 31st 2015 against https://core.trac.wordpress.org/browser/trunk?rev=36134}}
*
* @param array $plugins The plugin sources needed for installation.
* @param array $args Arbitrary passed extra arguments.
* @return array|false Install confirmation messages on success, false on failure.
*/
public function bulk_install( $plugins, $args = array() ) {
// [TGMPA + ] Hook auto-activation in.
add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
$defaults = array(
'clear_update_cache' => true,
);
$parsed_args = wp_parse_args( $args, $defaults );
$this->init();
$this->bulk = true;
$this->install_strings(); // [TGMPA + ] adjusted.
/* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */
/* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */
$this->skin->header();
// Connect to the Filesystem first.
$res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
if ( ! $res ) {
$this->skin->footer();
return false;
}
$this->skin->bulk_header();
/*
* Only start maintenance mode if:
* - running Multisite and there are one or more plugins specified, OR
* - a plugin with an update available is currently active.
* @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible.
*/
$maintenance = ( is_multisite() && ! empty( $plugins ) );
/*
[TGMPA - ]
foreach ( $plugins as $plugin )
$maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) );
*/
if ( $maintenance ) {
$this->maintenance_mode( true );
}
$results = array();
$this->update_count = count( $plugins );
$this->update_current = 0;
foreach ( $plugins as $plugin ) {
$this->update_current++;
/*
[TGMPA - ]
$this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true);
if ( !isset( $current->response[ $plugin ] ) ) {
$this->skin->set_result('up_to_date');
$this->skin->before();
$this->skin->feedback('up_to_date');
$this->skin->after();
$results[$plugin] = true;
continue;
}
// Get the URL to the zip file.
$r = $current->response[ $plugin ];
$this->skin->plugin_active = is_plugin_active($plugin);
*/
$result = $this->run(
array(
'package' => $plugin, // [TGMPA + ] adjusted.
'destination' => WP_PLUGIN_DIR,
'clear_destination' => false, // [TGMPA + ] adjusted.
'clear_working' => true,
'is_multi' => true,
'hook_extra' => array(
'plugin' => $plugin,
),
)
);
$results[ $plugin ] = $this->result;
// Prevent credentials auth screen from displaying multiple times.
if ( false === $result ) {
break;
}
} //end foreach $plugins
$this->maintenance_mode( false );
/**
* Fires when the bulk upgrader process is complete.
*
* @since WP 3.6.0 / TGMPA 2.5.0
*
* @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might
* be a Theme_Upgrader or Core_Upgrade instance.
* @param array $data {
* Array of bulk item update data.
*
* @type string $action Type of action. Default 'update'.
* @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'.
* @type bool $bulk Whether the update process is a bulk update. Default true.
* @type array $packages Array of plugin, theme, or core packages to update.
* }
*/
do_action( 'upgrader_process_complete', $this, array(
'action' => 'install', // [TGMPA + ] adjusted.
'type' => 'plugin',
'bulk' => true,
'plugins' => $plugins,
) );
$this->skin->bulk_footer();
$this->skin->footer();
// Cleanup our hooks, in case something else does a upgrade on this connection.
/* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */
// [TGMPA + ] Remove our auto-activation hook.
remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
// Force refresh of plugin update information.
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
return $results;
}
/**
* Handle a bulk upgrade request.
*
* @since 2.5.0
*
* @see Plugin_Upgrader::bulk_upgrade()
*
* @param array $plugins The local WP file_path's of the plugins which should be upgraded.
* @param array $args Arbitrary passed extra arguments.
* @return string|bool Install confirmation messages on success, false on failure.
*/
public function bulk_upgrade( $plugins, $args = array() ) {
add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
$result = parent::bulk_upgrade( $plugins, $args );
remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
return $result;
}
/**
* Abuse a filter to auto-activate plugins after installation.
*
* Hooked into the 'upgrader_post_install' filter hook.
*
* @since 2.5.0
*
* @param bool $bool The value we need to give back (true).
* @return bool
*/
public function auto_activate( $bool ) {
// Only process the activation of installed plugins if the automatic flag is set to true.
if ( $this->tgmpa->is_automatic ) {
// Flush plugins cache so the headers of the newly installed plugins will be read correctly.
wp_clean_plugins_cache();
// Get the installed plugin file.
$plugin_info = $this->plugin_info();
// Don't try to activate on upgrade of active plugin as WP will do this already.
if ( ! is_plugin_active( $plugin_info ) ) {
$activate = activate_plugin( $plugin_info );
// Adjust the success string based on the activation result.
$this->strings['process_success'] = $this->strings['process_success'] . " \n";
if ( is_wp_error( $activate ) ) {
$this->skin->error( $activate );
$this->strings['process_success'] .= $this->strings['activation_failed'];
} else {
$this->strings['process_success'] .= $this->strings['activation_success'];
}
}
}
return $bool;
}
}
}
if ( ! class_exists( 'TGMPA_Bulk_Installer_Skin' ) ) {
/**
* Installer skin to set strings for the bulk plugin installations..
*
* Extends Bulk_Upgrader_Skin and customizes to suit the installation of multiple
* plugins.
*
* @since 2.2.0
*
* {@internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer_Skin to
* TGMPA_Bulk_Installer_Skin.
* This was done to prevent backward compatibility issues with v2.3.6.}}
*
* @see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-upgrader-skins.php
*
* @package TGM-Plugin-Activation
* @author Thomas Griffin
* @author Gary Jones
*/
class TGMPA_Bulk_Installer_Skin extends Bulk_Upgrader_Skin {
/**
* Holds plugin info for each individual plugin installation.
*
* @since 2.2.0
*
* @var array
*/
public $plugin_info = array();
/**
* Holds names of plugins that are undergoing bulk installations.
*
* @since 2.2.0
*
* @var array
*/
public $plugin_names = array();
/**
* Integer to use for iteration through each plugin installation.
*
* @since 2.2.0
*
* @var integer
*/
public $i = 0;
/**
* TGMPA instance
*
* @since 2.5.0
*
* @var object
*/
protected $tgmpa;
/**
* Constructor. Parses default args with new ones and extracts them for use.
*
* @since 2.2.0
*
* @param array $args Arguments to pass for use within the class.
*/
public function __construct( $args = array() ) {
// Get TGMPA class instance.
$this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
// Parse default and new args.
$defaults = array(
'url' => '',
'nonce' => '',
'names' => array(),
'install_type' => 'install',
);
$args = wp_parse_args( $args, $defaults );
// Set plugin names to $this->plugin_names property.
$this->plugin_names = $args['names'];
// Extract the new args.
parent::__construct( $args );
}
/**
* Sets install skin strings for each individual plugin.
*
* Checks to see if the automatic activation flag is set and uses the
* the proper strings accordingly.
*
* @since 2.2.0
*/
public function add_strings() {
if ( 'update' === $this->options['install_type'] ) {
parent::add_strings();
/* translators: 1: plugin name, 2: action number 3: total number of actions. */
$this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
} else {
/* translators: 1: plugin name, 2: error message. */
$this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: %2$s .', 'tgmpa' );
/* translators: 1: plugin name. */
$this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' );
if ( $this->tgmpa->is_automatic ) {
// Automatic activation strings.
$this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' );
/* translators: 1: plugin name. */
$this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' );
$this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' );
/* translators: 1: plugin name, 2: action number 3: total number of actions. */
$this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
} else {
// Default installation strings.
$this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' );
/* translators: 1: plugin name. */
$this->upgrader->strings['skin_update_successful'] = esc_html__( '%1$s installed successfully.', 'tgmpa' );
$this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' );
/* translators: 1: plugin name, 2: action number 3: total number of actions. */
$this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
}
}
}
/**
* Outputs the header strings and necessary JS before each plugin installation.
*
* @since 2.2.0
*
* @param string $title Unused in this implementation.
*/
public function before( $title = '' ) {
if ( empty( $title ) ) {
$title = esc_html( $this->plugin_names[ $this->i ] );
}
parent::before( $title );
}
/**
* Outputs the footer strings and necessary JS after each plugin installation.
*
* Checks for any errors and outputs them if they exist, else output
* success strings.
*
* @since 2.2.0
*
* @param string $title Unused in this implementation.
*/
public function after( $title = '' ) {
if ( empty( $title ) ) {
$title = esc_html( $this->plugin_names[ $this->i ] );
}
parent::after( $title );
$this->i++;
}
/**
* Outputs links after bulk plugin installation is complete.
*
* @since 2.2.0
*/
public function bulk_footer() {
// Serve up the string to say installations (and possibly activations) are complete.
parent::bulk_footer();
// Flush plugins cache so we can make sure that the installed plugins list is always up to date.
wp_clean_plugins_cache();
$this->tgmpa->show_tgmpa_version();
// Display message based on if all plugins are now active or not.
$update_actions = array();
if ( $this->tgmpa->is_tgmpa_complete() ) {
// All plugins are active, so we display the complete string and hide the menu to protect users.
echo '';
$update_actions['dashboard'] = sprintf(
esc_html( $this->tgmpa->strings['complete'] ),
'' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . ' '
);
} else {
$update_actions['tgmpa_page'] = '' . esc_html( $this->tgmpa->strings['return'] ) . ' ';
}
/**
* Filter the list of action links available following bulk plugin installs/updates.
*
* @since 2.5.0
*
* @param array $update_actions Array of plugin action links.
* @param array $plugin_info Array of information for the last-handled plugin.
*/
$update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
if ( ! empty( $update_actions ) ) {
$this->feedback( implode( ' | ', (array) $update_actions ) );
}
}
/* *********** DEPRECATED METHODS *********** */
/**
* Flush header output buffer.
*
* @since 2.2.0
* @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead
* @see Bulk_Upgrader_Skin::flush_output()
*/
public function before_flush_output() {
_deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' );
$this->flush_output();
}
/**
* Flush footer output buffer and iterate $this->i to make sure the
* installation strings reference the correct plugin.
*
* @since 2.2.0
* @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead
* @see Bulk_Upgrader_Skin::flush_output()
*/
public function after_flush_output() {
_deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' );
$this->flush_output();
$this->i++;
}
}
}
}
}
}
if ( ! class_exists( 'TGMPA_Utils' ) ) {
/**
* Generic utilities for TGMPA.
*
* All methods are static, poor-dev name-spacing class wrapper.
*
* Class was called TGM_Utils in 2.5.0 but renamed TGMPA_Utils in 2.5.1 as this was conflicting with Soliloquy.
*
* @since 2.5.0
*
* @package TGM-Plugin-Activation
* @author Juliette Reinders Folmer
*/
class TGMPA_Utils {
/**
* Whether the PHP filter extension is enabled.
*
* @see http://php.net/book.filter
*
* @since 2.5.0
*
* @static
*
* @var bool $has_filters True is the extension is enabled.
*/
public static $has_filters;
/**
* Wrap an arbitrary string in tags. Meant to be used in combination with array_map().
*
* @since 2.5.0
*
* @static
*
* @param string $string Text to be wrapped.
* @return string
*/
public static function wrap_in_em( $string ) {
return '' . wp_kses_post( $string ) . ' ';
}
/**
* Wrap an arbitrary string in tags. Meant to be used in combination with array_map().
*
* @since 2.5.0
*
* @static
*
* @param string $string Text to be wrapped.
* @return string
*/
public static function wrap_in_strong( $string ) {
return '' . wp_kses_post( $string ) . ' ';
}
/**
* Helper function: Validate a value as boolean
*
* @since 2.5.0
*
* @static
*
* @param mixed $value Arbitrary value.
* @return bool
*/
public static function validate_bool( $value ) {
if ( ! isset( self::$has_filters ) ) {
self::$has_filters = extension_loaded( 'filter' );
}
if ( self::$has_filters ) {
return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
} else {
return self::emulate_filter_bool( $value );
}
}
/**
* Helper function: Cast a value to bool
*
* @since 2.5.0
*
* @static
*
* @param mixed $value Value to cast.
* @return bool
*/
protected static function emulate_filter_bool( $value ) {
// @codingStandardsIgnoreStart
static $true = array(
'1',
'true', 'True', 'TRUE',
'y', 'Y',
'yes', 'Yes', 'YES',
'on', 'On', 'ON',
);
static $false = array(
'0',
'false', 'False', 'FALSE',
'n', 'N',
'no', 'No', 'NO',
'off', 'Off', 'OFF',
);
// @codingStandardsIgnoreEnd
if ( is_bool( $value ) ) {
return $value;
} elseif ( is_int( $value ) && ( 0 === $value || 1 === $value ) ) {
return (bool) $value;
} elseif ( ( is_float( $value ) && ! is_nan( $value ) ) && ( (float) 0 === $value || (float) 1 === $value ) ) {
return (bool) $value;
} elseif ( is_string( $value ) ) {
$value = trim( $value );
if ( in_array( $value, $true, true ) ) {
return true;
} elseif ( in_array( $value, $false, true ) ) {
return false;
} else {
return false;
}
}
return false;
}
} // End of class TGMPA_Utils
} // End of class_exists wrapper
admin/plugins/plugins.php 0000644 00000011506 15154650146 0011521 0 ustar 00 esc_html__('Goya Core', 'goya'),
'slug' => 'goya-core',
'source' => 'https://goya.b-cdn.net/assets/plugins/v25-dkk3dkfsx/goya-core.zip',
'required' => true,
'version' => '1.0.7',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => ''
),
array(
'name' => esc_html__('Envato Market (theme updates)', 'goya'),
'slug' => 'envato-market',
'source' => 'https://envato.github.io/wp-envato-market/dist/envato-market.zip',
'required' => false,
'version' => '2.0.7',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => ''
),
array(
'name' => esc_html__('WPBakery Visual Composer', 'goya'),
'slug' => 'js_composer',
'source' => 'https://goya.b-cdn.net/assets/plugins/v25-dkk3dkfsx/js_composer.zip',
'required' => false,
'version' => '6.10.0',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => ''
),
array(
'name' => esc_html__('WC Ajax Product Filters', 'goya'),
'slug' => 'wc-ajax-product-filter',
'source' => 'https://goya.b-cdn.net/assets/plugins/v25-dkk3dkfsx/wc-ajax-product-filter.zip',
'required' => false,
'version' => '4.1.0',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => ''
),
array(
'name' => esc_html__('Slider Revolution', 'goya'),
'slug' => 'revslider',
'source' => 'https://goya.b-cdn.net/assets/plugins/v25-dkk3dkfsx/revslider.zip',
'required' => false,
'version' => '6.6.8',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => ''
),
// Include plugins from the WordPress Plugin Repository
array(
'name' => esc_html__('Kirki Toolkit', 'goya'),
'slug' => 'kirki',
'required' => true,
'force_activation' => false,
'force_deactivation' => false,
),
array(
'name' => esc_html__('Meta Box ', 'goya'),
'slug' => 'meta-box',
'required' => false,
'force_activation' => false,
'force_deactivation' => false,
),
array(
'name' => esc_html__('WooCommerce', 'goya'),
'slug' => 'woocommerce',
'required' => false,
'force_activation' => false,
'force_deactivation' => false,
),
array(
'name' => esc_html__('YITH WooCommerce Wishlist', 'goya'),
'slug' => 'yith-woocommerce-wishlist',
'required' => false,
'force_activation' => false,
'force_deactivation' => false,
),
array(
'name' => esc_html__('WooCommerce Variation Swatches', 'goya'),
'slug' => 'woo-variation-swatches',
'required' => false,
'force_activation' => false,
'force_deactivation' => false,
),
array(
'name' => esc_html__('Ninja Forms', 'goya'),
'slug' => 'ninja-forms',
'required' => false,
'force_activation' => false,
'force_deactivation' => false,
),
array(
'name' => esc_html__('Mailchimp for WordPress', 'goya'),
'slug' => 'mailchimp-for-wp',
'required' => false,
'force_activation' => false,
'force_deactivation' => false,
),
);
$config = array(
'id' => 'et-framework',
'default_path' => '', // Default absolute path to pre-packaged plugins
'parent_slug' => 'themes.php',
'menu' => 'install-required-plugins', // Menu slug
'has_notices' => true, // Show admin notices or not
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => true, // Automatically activate plugins after installation or not.
'message' => 'Install the following required or recommended plugins to get complete functionality from your new theme.
', // Message to output right before the plugins table.
'strings' => array(
'return' => esc_html__( 'Return to Theme Plugins', 'goya' )
)
);
tgmpa($plugins, $config);
}
add_action('tgmpa_register', 'goya_register_required_plugins'); admin/imports/import.php 0000644 00000017053 15154650146 0011371 0 ustar 00 'basic-v1',
'name' => esc_html__('Basic (faster)', 'goya'),
'url' => 'demo-basic/',
'home' => 'Home - Classic',
'content' => 'basic-v1',
'revslider' => 'basic-v1'
),
array(
'id' => 'decor-v1',
'name' => esc_html__('Decoration', 'goya'),
'url' => 'demo-decor/',
'home' => 'Home - Classic',
'content' => 'decor-v1',
'revslider' => 'decor-v3'
),
array(
'id' => 'fashion-v1',
'name' => esc_html__('Fashion', 'goya'),
'url' => 'demo-fashion/',
'home' => 'Home - Classic',
'content' => 'fashion-v1',
'revslider' => 'fashion-v2'
),
);
function goya_ocdi_import_files() {
global $goya_demo_list;
$url = 'https://goya.everthemes.com/';
$path = 'https://goya.b-cdn.net/assets/demo/content/';
foreach ($goya_demo_list as $params) {
$import[] = array(
'import_file_name' => $params['name'],
'import_file_url' => $path . $params['content'] . '/content-'. $params['content'] .'.xml',
'import_widget_file_url' => $path . $params['content'] . '/widgets-'. $params['content'] .'.wie',
'import_customizer_file_url' => $path . $params['content'] . '/customizer-'. $params['content'] .'.dat',
'import_rev_slider_file_url' => $path . $params['content'] . '/revslider-'. $params['revslider'] .'.zip',
'import_preview_image_url' => $path . $params['id'] . '/preview-'. $params['id'] .'.jpg',
'preview_url' => $url . $params['url'],
);
}
return $import;
}
add_filter( 'pt-ocdi/import_files', 'goya_ocdi_import_files' );
if( extension_loaded('imagick') || class_exists('Imagick') ){
// disable thumbnail regeneration
add_filter( 'pt-ocdi/regenerate_thumbnails_in_content_import', '__return_false' );
add_filter( 'merlin_regenerate_thumbnails_in_content_import', '__return_false' );
}
function goya_ocdi_after_import( $selected_import ) {
global $goya_demo_list;
// Assign menus to their locations.
$navigation = get_term_by('name', 'Main', 'nav_menu');
$topbar = get_term_by('name', 'Top Bar', 'nav_menu');
$footer = get_term_by('name', 'Footer', 'nav_menu');
$secondary = get_term_by('name', 'Secondary', 'nav_menu');
set_theme_mod( 'nav_menu_locations' , array(
'primary-menu' => $navigation->term_id,
'topbar-menu' => $topbar->term_id,
'secondary-menu' => $secondary->term_id,
'fullscreen-menu' => $navigation->term_id,
'mobile-menu' => $navigation->term_id,
'footer-menu' => $footer->term_id )
);
// Assign front, blog and WooCommerce pages.
$home = get_page_by_path('home');
$blog = get_page_by_path('blog');
// Override home and blog pages according to demo ID
$home = get_page_by_title($goya_demo_list[$selected_import]['home']);
if ($selected_import == 2) {
$blog = get_page_by_path('journal');
}
// Delete duplicates
$pages2 = array('cart','checkout','my-account','wishlist');
foreach ($pages2 as $p2) {
$p = get_page_by_path($p2 . '-2');
if ($p) {
wp_delete_post( $p->ID, true);
}
}
// Get Shop page
$shop2 = get_page_by_path('shop-2');
if ($shop2) {
$shop1 = get_page_by_path('shop');
wp_delete_post( $shop1->ID, true);
wp_update_post([
'post_name' => 'shop',
'ID' => $shop2->ID,
]);
}
$shop = get_page_by_path('shop');
$cart = get_page_by_path('cart');
$checkout = get_page_by_path('checkout');
$wishlist = get_page_by_path('wishlist');
$myaccount = get_page_by_path('my-account');
update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $home->ID );
update_option( 'page_for_posts', $blog->ID );
update_option( 'woocommerce_myaccount_page_id', $myaccount->ID );
update_option( 'woocommerce_shop_page_id', $shop->ID );
update_option( 'woocommerce_cart_page_id', $cart->ID );
update_option( 'woocommerce_checkout_page_id', $checkout->ID );
update_option( 'general-show_notice', '');
// Yith Wishlist
if ( class_exists( 'YITH_WCWL_Frontend' ) ) {
remove_action( 'wp_head', array( YITH_WCWL_Frontend(), 'add_button' ) );
update_option( 'yith_wcwl_show_on_loop', 'yes');
update_option( 'yith_wcwl_button_position', 'shortcode');
update_option( 'yith_wcwl_loop_position', 'shortcode');
update_option( 'add_to_wishlist-position', 'shortcode');
update_option( 'add_to_wishlist_catalog-position', 'shortcode');
update_option( 'yith_wcwl_rounded_corners', 0);
update_option( 'yith_wcwl_price_show', 'yes');
update_option( 'yith_wcwl_add_to_cart_show', 'yes');
update_option( 'yith_wcwl_show_remove', 'yes');
update_option( 'yith_wcwl_repeat_remove_button', 'yes');
update_option( 'yith_wcwl_wishlist_page_id', $wishlist->ID );
}
// WC Ajax Product Filters
$wcapf = get_option('wcapf_settings');
$wcapf['shop_loop_container'] = '.wcapf-before-products';
$wcapf['not_found_container'] = '.wcapf-before-products';
$wcapf['pagination_container'] = '.woocommerce-pagination';
$wcapf['overlay_bg_color'] = '#fff';
$wcapf['sorting_control'] = '1';
$wcapf['scroll_to_top'] = '1';
$wcapf['scroll_to_top_offset'] = '150';
$wcapf['custom_scripts'] = '';
$wcapf['disable_transients'] = '';
update_option('wcapf_settings', $wcapf);
// Ninja Forms
$ninjaf = get_option('ninja_forms');
$ninjaf['opinionated_styles'] = '';
update_option('ninja_forms', $ninjaf);
// ARG Multistep Checkout
$argmc = get_option('arg-mc-options');
$argmc['tabs_layout'] = 'tabs-progress-bar';
update_option('arg-mc-options', $argmc);
// We no longer need to install pages for WooCommerce
delete_option( '_wc_needs_pages' );
delete_transient( '_wc_activation_redirect' );
// Flush rules after install
flush_rewrite_rules();
global $wpdb;
// Change attribute types
$table_name = $wpdb->prefix . 'woocommerce_attribute_taxonomies';
$wpdb->query( "UPDATE `$table_name` SET `attribute_type` = 'color' WHERE `attribute_name` = 'color'" );
$wpdb->query( "UPDATE `$table_name` SET `attribute_type` = 'image' WHERE `attribute_name` = 'pattern'" );
$wpdb->query( "UPDATE `$table_name` SET `attribute_type` = 'button' WHERE `attribute_name` = 'size'" );
}
add_action( 'pt-ocdi/after_import', 'goya_ocdi_after_import' );
/* Disable Branding */
add_filter( 'pt-ocdi/disable_pt_branding', '__return_true' );
/* Intro text */
function goya_ocdi_plugin_intro_text( $default_text ) {
ob_start(); ?>
true,
), $config );
}
add_filter( 'kirki_config', 'goya_kirki_config_style' );
$sep = 0;
// Animations array
$goya_animations_list = array(
'' => esc_html__('None', 'goya'),
'animation right-to-left' => esc_html__('Right to Left', 'goya'),
'animation left-to-right' => esc_html__('Left to Right', 'goya'),
'animation right-to-left-3d' => esc_html__('Right to Left - 3D', 'goya'),
'animation left-to-right-3d' => esc_html__('Left to Right - 3D', 'goya'),
'animation bottom-to-top' => esc_html__('Bottom to Top', 'goya'),
'animation top-to-bottom' => esc_html__('Top to Bottom', 'goya'),
'animation bottom-to-top-3d' => esc_html__('Bottom to Top - 3D', 'goya'),
'animation top-to-bottom-3d' => esc_html__('Top to Bottom - 3D', 'goya'),
'animation scale' => esc_html__('Scale', 'goya'),
'animation fade' => esc_html__('Fade', 'goya'),
);
// Replace bundled Jost with Google version
$main_font = get_theme_mod( 'main_font', array() );
$main_font_family = isset($main_font['font-family']) ? $main_font['font-family'] : '';
$second_font = get_theme_mod( 'second_font', array() );
$second_font_family = isset($second_font['font-family']) ? $second_font['font-family'] : '';
if ($main_font_family == 'Jost, sans-serif') {
set_theme_mod( 'main_font' , array(
'font-family' => 'Jost',
)
);
}
if ($second_font_family == 'Jost, sans-serif') {
set_theme_mod( 'second_font' , array(
'font-family' => 'Jost',
)
);
}
// Migrate campaign to new version
/*$old_campaign = get_theme_mod( 'campaign_bar_content', '' );
if (!empty($old_campaign)) {
set_theme_mod( 'campaign_bar_items' , array(
array(
'campaign_text' => strip_tags($old_campaign),
)
)
);
}*/
// Google fonts lists
function goya_main_font_choices() {
return apply_filters( 'goya_main_font_choices', array(
'fonts' => array(
'google' => array( 'popularity', 700 ),
),
) );
}
function goya_second_font_choices() {
return apply_filters( 'goya_second_font_choices', array(
'fonts' => array(
'google' => array( 'popularity', 700 ),
),
) );
}
function goya_social_media_icons() {
return apply_filters( 'goya_social_media_icons', array(
'' => esc_html__( '', 'goya' ),
'facebook' => esc_html__( 'Facebook', 'goya' ),
'twitter' => esc_html__( 'Twitter', 'goya' ),
'instagram' => esc_html__( 'Instagram', 'goya' ),
'googleplus' => esc_html__( 'Google+', 'goya' ),
'pinterest' => esc_html__( 'Pinterest', 'goya' ),
'linkedin' => esc_html__( 'LinkedIn', 'goya' ),
'rss' => esc_html__( 'RSS', 'goya' ),
'email' => esc_html__( 'Email', 'goya' ),
'tumblr' => esc_html__( 'Tumblr', 'goya' ),
'youtube' => esc_html__( 'Youtube', 'goya' ),
'vimeo' => esc_html__( 'Vimeo', 'goya' ),
'behance' => esc_html__( 'Behance', 'goya' ),
'dribbble' => esc_html__( 'Dribbble', 'goya' ),
'flickr' => esc_html__( 'Flickr', 'goya' ),
'github' => esc_html__( 'GitHub', 'goya' ),
'skype' => esc_html__( 'Skype', 'goya' ),
'whatsapp' => esc_html__( 'WhatsApp', 'goya' ),
'telegram' => esc_html__( 'Telegram', 'goya' ),
'snapchat' => esc_html__( 'Snapchat', 'goya' ),
'wechat' => esc_html__( 'WeChat', 'goya' ),
'weibo' => esc_html__( 'Weibo', 'goya' ),
'foursquare' => esc_html__( 'Foursquare', 'goya' ),
'soundcloud' => esc_html__( 'Soundcloud', 'goya' ),
'vk' => esc_html__( 'VK', 'goya' ),
'tiktok' => esc_html__( 'TikTok', 'goya' ),
'phone' => esc_html__( 'Phone', 'goya' ),
'map-marker' => esc_html__( 'Map Pin', 'goya' ),
'spotify' => esc_html__( 'Spotify', 'goya' ),
) );
}
function goya_topbar_elements_list() {
return apply_filters( 'goya_topbar_elements_list', array(
'menu' => esc_html__( 'Menu Top Bar', 'goya' ),
'currency' => esc_html__( 'Currency Selector', 'goya' ),
'language' => esc_html__( 'Language Selector', 'goya' ),
'social' => esc_html__( 'Social Icons', 'goya' ),
'text' => esc_html__( 'Text 1', 'goya' ),
'text2' => esc_html__( 'Text 2', 'goya' ),
'text3' => esc_html__( 'Text 3', 'goya' ),
'search' => esc_html__( 'Search Icon', 'goya' ),
'search-box' => esc_html__( 'Search Box', 'goya' ),
'cart' => esc_html__( 'Cart Icon', 'goya' ),
'hamburger' => esc_html__( 'Hamburger Icon', 'goya' ),
'wishlist' => esc_html__( 'Wishlist Icon', 'goya' ),
'account' => esc_html__( 'Account Link', 'goya' ),
) );
}
function goya_header_elements_list() {
return apply_filters( 'goya_header_elements_list', array(
'logo' => esc_html__( 'Logo', 'goya' ),
'account' => esc_html__( 'Account Link', 'goya' ),
'cart' => esc_html__( 'Cart Icon', 'goya' ),
'currency' => esc_html__( 'Currency Selector', 'goya' ),
'hamburger' => esc_html__( 'Hamburger Icon', 'goya' ),
'language' => esc_html__( 'Language Selector', 'goya' ),
'menu-primary' => esc_html__( 'Menu Primary', 'goya' ),
'menu-secondary' => esc_html__( 'Menu Secondary', 'goya' ),
'search' => esc_html__( 'Search Icon', 'goya' ),
'search-box' => esc_html__( 'Search Box', 'goya' ),
'social' => esc_html__( 'Social Icons', 'goya' ),
'text' => esc_html__( 'Text 1', 'goya' ),
'text2' => esc_html__( 'Text 2', 'goya' ),
'text3' => esc_html__( 'Text 3', 'goya' ),
'wishlist' => esc_html__( 'Wishlist Icon', 'goya' ),
) );
}
function goya_footer_elements_list() {
return apply_filters( 'goya_footer_elements_list', array(
'copyright' => esc_html__( 'Copyright', 'goya' ),
'currency' => esc_html__( 'Currency Selector', 'goya' ),
'currency_language' => esc_html__( 'Currency & Language Selector', 'goya' ),
'language' => esc_html__( 'Language Selector', 'goya' ),
'menu' => esc_html__( 'Menu Footer', 'goya' ),
'social' => esc_html__( 'Social Icons', 'goya' ),
'text' => esc_html__( 'Text 1', 'goya' ),
'text2' => esc_html__( 'Text 2', 'goya' ),
) );
}
function goya_mobile_header_elements_list() {
return apply_filters( 'goya_mobile_header_elements_list', array(
'cart' => esc_html__( 'Cart', 'goya' ),
'account' => esc_html__( 'Account', 'goya' ),
'search' => esc_html__( 'Search', 'goya' ),
'wishlist' => esc_html__( 'Wishlist', 'goya' ),
'currency' => esc_html__( 'Currency Selector', 'goya' ),
'language' => esc_html__( 'Language Selector', 'goya' ),
'text' => esc_html__( 'Text 1', 'goya' ),
) );
}
function goya_vertical_bar_elements_list() {
return apply_filters( 'goya_vertical_bar_elements_list', array(
'cart' => esc_html__( 'Cart', 'goya' ),
'account' => esc_html__( 'Account', 'goya' ),
'search' => esc_html__( 'Search', 'goya' ),
'wishlist' => esc_html__( 'Wishlist', 'goya' ),
) );
}
function goya_mobile_menu_elements_list() {
return apply_filters( 'goya_mobile_menu_elements_list', array(
'cart' => esc_html__( 'Cart', 'goya' ),
'account' => esc_html__( 'Account', 'goya' ),
'currency' => esc_html__( 'Currency Selector', 'goya' ),
'language' => esc_html__( 'Language Selector', 'goya' ),
'social' => esc_html__( 'Social Icons', 'goya' ),
'wishlist' => esc_html__( 'Wishlist', 'goya' ),
'text' => esc_html__( 'Text 1', 'goya' ),
'text2' => esc_html__( 'Text 2', 'goya' ),
'text3' => esc_html__( 'Text 3', 'goya' ),
'divider1' => '––––––',
'divider2' => '––––––',
'divider3' => '––––––',
'divider4' => '––––––',
) );
}
add_action( 'customize_register','goya_customizer' );
function goya_customizer( $wp_customize ) {
// Add Panels
$wp_customize->add_panel( 'panel_general', array(
'title' => esc_html__( 'General', 'goya' ),
'priority' => 5,
'capability' => 'edit_theme_options',
) );
$wp_customize->add_panel( 'panel_style', array(
'title' => esc_html__( 'Theme Styles', 'goya' ),
'priority' => 5,
'capability' => 'edit_theme_options',
) );
$wp_customize->add_panel( 'panel_header', array(
'title' => esc_html__( 'Header', 'goya' ),
'priority' => 5,
'capability' => 'edit_theme_options',
) );
$wp_customize->add_panel( 'panel_footer', array(
'title' => esc_html__( 'Footer', 'goya' ),
'priority' => 5,
'capability' => 'edit_theme_options',
) );
$wp_customize->add_panel( 'panel_shop', array(
'title' => esc_html__( 'Shop', 'goya' ),
'priority' => 5,
'capability' => 'edit_theme_options',
) );
$wp_customize->add_panel( 'panel_product', array(
'title' => esc_html__( 'Single Product', 'goya' ),
'priority' => 5,
'capability' => 'edit_theme_options',
) );
$wp_customize->add_panel( 'panel_blog', array(
'title' => esc_html__( 'Blog', 'goya' ),
'priority' => 5,
'capability' => 'edit_theme_options',
) );
$wp_customize->add_panel( 'panel_portfolio', array(
'title' => esc_html__( 'Portfolio', 'goya' ),
'priority' => 5,
'capability' => 'edit_theme_options',
) );
}
if ( class_exists( 'Kirki' ) ) {
/* Configs */
Kirki::add_config( 'goya_config', array(
'gutenberg_support' => true,
'capability' => 'edit_theme_options',
'option_type' => 'theme_mod',
) );
/* Sections */
Kirki::add_section( 'general_settings', array(
'title' => esc_html__('General Settings', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_general',
) );
Kirki::add_section( 'social_media', array(
'title' => esc_html__( 'Social Media', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_general',
) );
Kirki::add_section( 'popup', array(
'title' => esc_html__( 'Popup', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_general',
) );
Kirki::add_section( 'apis', array(
'title' => esc_html__( 'Keys & APIs', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_general',
) );
Kirki::add_section( 'language_selector', array(
'title' => esc_html__( 'Language Selector', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_general',
) );
Kirki::add_section( 'header_layout', array(
'title' => esc_html__('Header Layout', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'header_logo', array(
'title' => esc_html__( 'Logo', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'header_logo_size', array(
'title' => esc_html__('Header/Logo Size', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'header_elements', array(
'title' => esc_html__( 'Header Icons', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'top_bar', array(
'title' => esc_html__( 'Top Bar', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'campaign', array(
'title' => esc_html__( 'Campaign Bar', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'header_main_menu', array(
'title' => esc_html__('Main Menu Options', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'header_offcanvas_desktop', array(
'title' => esc_html__('Off-canvas Desktop', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'header_vertical_bar', array(
'title' => esc_html__('Vertical Icons Bar', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'header_mobile', array(
'title' => esc_html__( 'Mobile Header', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'header_menu_mobile', array(
'title' => esc_html__('Mobile Menu', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_header',
) );
Kirki::add_section( 'footer_setting', array(
'title' => esc_html__( 'Footer Main', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_footer',
) );
Kirki::add_section( 'footer_extra', array(
'title' => esc_html__( 'Footer Extra', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_footer',
) );
Kirki::add_section( 'footer_bottom', array(
'title' => esc_html__( 'Footer Bottom', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_footer',
) );
Kirki::add_section( 'footer_colors', array(
'title' => esc_html__( 'Footer Colors', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_footer',
) );
Kirki::add_section( 'footer_mobile', array(
'title' => esc_html__( 'Mobile', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_footer',
) );
Kirki::add_section( 'blog_list', array(
'title' => esc_html__( 'Blog Main', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_blog',
) );
Kirki::add_section( 'blog_categories', array(
'title' => esc_html__( 'Categories Menu', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_blog',
) );
Kirki::add_section( 'blog_single', array(
'title' => esc_html__( 'Single Post', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_blog',
) );
Kirki::add_section( 'blog_related', array(
'title' => esc_html__( 'Related Posts', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_blog',
) );
Kirki::add_section( 'shop_general', array(
'title' => esc_html__( 'Shop General', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_shop',
) );
Kirki::add_section( 'shop_header', array(
'title' => esc_html__( 'Shop Header', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_shop',
) );
Kirki::add_section( 'shop_listing', array(
'title' => esc_html__( 'Products Catalog', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_shop',
) );
Kirki::add_section( 'shop_filters', array(
'title' => esc_html__( 'Sidebar Filters', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_shop',
) );
Kirki::add_section( 'shop_variations', array(
'title' => esc_html__( 'Variations/Swatches', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_shop',
) );
Kirki::add_section( 'minicart_panel', array(
'title' => esc_html__( 'Mini Cart', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_shop',
) );
Kirki::add_section( 'shop_quickview', array(
'title' => esc_html__( 'Quick View', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_shop',
) );
Kirki::add_section( 'checkout', array(
'title' => esc_html__( 'Cart / Checkout', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_shop',
) );
Kirki::add_section( 'shop_progress_bar', array(
'title' => esc_html__( 'Progress Bar', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_shop',
) );
Kirki::add_section( 'shop_mobile', array(
'title' => esc_html__( 'Mobile', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_shop',
) );
Kirki::add_section( 'product_layout', array(
'title' => esc_html__( 'Product Layout', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_product',
) );
Kirki::add_section( 'product_gallery', array(
'title' => esc_html__( 'Product Gallery', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_product',
) );
Kirki::add_section( 'product_elements', array(
'title' => esc_html__( 'Product Page Elements', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_product',
) );
Kirki::add_section( 'product_size', array(
'title' => esc_html__( 'Size Guide', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_product',
) );
Kirki::add_section( 'product_related', array(
'title' => esc_html__( 'Related Products', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_product',
) );
Kirki::add_section( 'product_mobile', array(
'title' => esc_html__( 'Mobile', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_product',
) );
Kirki::add_section( 'portfolio_main', array(
'title' => esc_html__( 'Portfolio Main', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_portfolio',
) );
Kirki::add_section( 'portfolio_single', array(
'title' => esc_html__( 'Single Portfolio', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_portfolio',
) );
Kirki::add_section( 'styling', array(
'title' => esc_html__( 'Global Colors', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_style',
) );
Kirki::add_section( 'header_styles', array(
'title' => esc_html__('Header Colors', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_style',
) );
Kirki::add_section( 'shop_styles', array(
'title' => esc_html__( 'Shop Colors', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_style',
) );
Kirki::add_section( 'form_styles', array(
'title' => esc_html__( 'Form styles', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_style',
) );
Kirki::add_section( 'fonts', array(
'title' => esc_html__( 'Typography', 'goya' ),
'priority' => 10,
'capability' => 'edit_theme_options',
'panel' => 'panel_style',
) );
// **************************************
// Fields
// **************************************
/**
* GENERAL SETTINGS
*/
Kirki::add_field( 'goya_config', array(
'type' => 'radio-image',
'settings' => 'site_global_layout',
'label' => esc_html__( 'Global Site Layout', 'goya' ),
'description' => esc_html__( '1.Regular, 2. Framed', 'goya' ),
'transport' => 'postMessage',
'section' => 'general_settings',
'default' => 'regular',
'priority' => 10,
'choices' => array(
'regular' => get_template_directory_uri() . '/assets/img/admin/options/layout-normal.png',
'framed' => get_template_directory_uri() . '/assets/img/admin/options/layout-framed.png',
),
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'et-site-layout-regular',
'value' => 'regular',
),
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'et-site-layout-framed',
'value' => 'framed',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'general_settings',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'page_transition',
'label' => esc_html__( 'Page preload Transition', 'goya' ),
'description' => sprintf( '%s ',
esc_html__( '* Warning: It may affect your Google Page Speed score if your server is not fast enough', 'goya' )
),
'section' => 'general_settings',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'page_transition_style',
'label' => esc_html__( 'Transition loader icon', 'goya' ),
'section' => 'general_settings',
'default' => 'dot3-loader',
'priority' => 10,
'choices' =>
array(
'dot3-loader' => esc_attr__('Dots', 'goya'),
'line-loader' => esc_attr__('Line', 'goya'),
'custom-loader' => esc_attr__('Custom', 'goya'),
),
'required' => array(
array(
'setting' => 'page_transition',
'operator' => '==',
'value' => true
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'image',
'settings' => 'page_transition_icon',
'label' => esc_html__( 'Use custom Page Load icon', 'goya' ),
'section' => 'general_settings',
'priority' => 10,
'default' => '',
'required' => array(
array(
'setting' => 'page_transition',
'operator' => '==',
'value' => true
),
array(
'setting' => 'page_transition_style',
'operator' => '==',
'value' => 'custom-loader'
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'general_settings',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'lazy_load',
'label' => esc_html__( 'Use lazy load', 'goya' ),
'description' => esc_html__( 'Load images only when visible to improve loading time. DISABLE if you are using a Lazyload plugin', 'goya' ),
'section' => 'general_settings',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'lazy_load_skip',
'label' => esc_html__( 'Skip lazy load', 'goya' ),
'description' => esc_html__( 'For products catalog you can skip the first images from lazy loading. Choose the number of products to skip.', 'goya' ),
'section' => 'general_settings',
'default' => 6,
'priority' => 10,
'choices' => array(
'min' => 0,
'max' => 10,
'step' => 1
),
'required' => array(
array(
'setting' => 'lazy_load',
'operator' => '==',
'value' => true
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'general_settings',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'login_two_columns',
'label' => esc_html__( 'Login/Register form in two columns', 'goya' ),
'description' => esc_html__( 'For desktop size and only on the regular login/register page', 'goya' ),
'section' => 'general_settings',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'general_settings',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'wp_gallery_popup',
'label' => esc_html__( 'WordPress Gallery - Lightbox', 'goya' ),
'description' => esc_html__( 'Open WordPress Gallery Images in Lightbox', 'goya' ),
'section' => 'general_settings',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'general_settings',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'js_composer_standalone',
'label' => esc_html__( 'Standalone WP Bakery', 'goya' ),
'description' => esc_html__( 'If you have your own WP Bakery Page Builder license, enable this option and add your license in the plugin settings', 'goya' ),
'section' => 'general_settings',
'default' => false,
'priority' => 10,
));
/**
* POPUP
*/
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'popup_modal',
'label' => esc_html__( 'Enable Popup', 'goya' ),
'section' => 'popup',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'popup',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'popup_layout',
'label' => esc_html__( 'Popup layout', 'goya' ),
'transport' => 'postMessage',
'section' => 'popup',
'default' => '2-col',
'priority' => 10,
'choices' => array(
'1-col' => esc_attr__('1 column', 'goya'),
'2-col' => esc_attr__('2 columns', 'goya')
),
'js_vars' => array(
array(
'element' => '#goya-popup',
'function' => 'toggleClass',
'class' => 'popup-layout-1-col',
'value' => '1-col',
),
array(
'element' => '#goya-popup',
'function' => 'toggleClass',
'class' => 'popup-layout-2-col',
'value' => '2-col',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'popup_color_style',
'label' => esc_html__( 'Color Scheme', 'goya' ),
'description' => esc_html__( 'The image will be used as background.', 'goya' ),
'transport' => 'postMessage',
'section' => 'popup',
'default' => '',
'priority' => 10,
'choices' => array(
'' => esc_attr__('Light', 'goya'),
'dark' => esc_attr__('Dark', 'goya')
),
'js_vars' => array(
array(
'element' => '#goya-popup',
'function' => 'toggleClass',
'class' => 'dark',
'value' => 'dark',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'popup',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'image',
'settings' => 'popup_image',
'label' => esc_html__( 'Popup Image', 'goya' ),
'section' => 'popup',
'priority' => 10,
'default' => '',
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'popup_content',
'label' => esc_html__( 'Popup Content', 'goya' ),
'description' => esc_html__( 'You can use shortcodes like Mailchimp sign up shortcode.', 'goya' ),
'transport' => 'postMessage',
'section' => 'popup',
'priority' => 10,
'default' => '',
'partial_refresh' => array(
'popup_content' => array(
'selector' => '#goya-popup .content-wrapper',
'render_callback' => function() {
echo do_shortcode( get_theme_mod( 'popup_content','' ) );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'popup',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'select',
'settings' => 'popup_frequency',
'label' => esc_html__( 'Frequency', 'goya' ),
'description' => esc_html__( 'Do NOT show the popup to the same visitor again until:', 'goya' ),
'section' => 'popup',
'priority' => 10,
'choices' => array(
'0' => esc_attr__( '0 - For Testing', 'goya' ),
'1' => esc_attr__( '1 Day', 'goya' ),
'2' => esc_attr__( '2 Days', 'goya' ),
'3' => esc_attr__( '3 Days', 'goya' ),
'7' => esc_attr__( '1 Week', 'goya' ),
'14' => esc_attr__( '2 Weeks', 'goya' ),
'21' => esc_attr__( '3 Weeks', 'goya' ),
'30' => esc_attr__( '1 Month', 'goya' ),
),
'default' => '1',
));
Kirki::add_field( 'goya_config', array(
'type' => 'number',
'settings' => 'popup_delay',
'label' => esc_html__( 'Delay', 'goya' ),
'description' => esc_html__( 'Seconds until the popup is displayed after page load.', 'goya' ),
'section' => 'popup',
'default' => 3,
'priority' => 10,
'choices' => array(
'min' => 0,
'step' => 1,
),
));
/**
* APIs
*/
Kirki::add_field( 'goya_config', array(
'type' => 'text',
'settings' => 'google_api_key',
'label' => esc_html__( 'Google API key', 'goya' ),
'description' => sprintf( __( 'Enter your %sGoogle Maps API key%s.', 'goya' ), '', ' ' ),
'section' => 'apis',
'default' => '',
'priority' => 10,
));
/**
* Language Selector
*/
if ( function_exists('pll_the_languages') || function_exists('icl_get_languages')) {
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'language_selector',
'default' => '' .
esc_html__( 'For WPML/Polylang', 'goya' ) . ' ' .
esc_html__( 'Add the selector manually in the customizer in Header > Layout and other positions.', 'goya' ) .
'
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'ls_default_layout',
'label' => esc_html__( 'Default Layout', 'goya' ),
'section' => 'language_selector',
'default' => 'dropdown',
'priority' => 10,
'choices' => array(
'dropdown' => esc_attr__('Drop-down', 'goya'),
'inline' => esc_attr__('Inline', 'goya')
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'multicheck',
'settings' => 'ls_default',
'label' => esc_html__( 'General Display', 'goya' ),
'description' => esc_html__( 'The default layout for language selector', 'goya' ),
'section' => 'language_selector',
'default' => array('name'),
'priority' => 10,
'multiple' => 1,
'choices' => array(
'flag' => esc_attr__('Flag', 'goya'),
'code' => esc_attr__('Code', 'goya'),
'name' => esc_attr__('Name', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'language_selector',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'multicheck',
'settings' => 'ls_mobile_header',
'label' => esc_html__( 'Mobile header/top bar', 'goya' ),
'description' => esc_html__( 'For mobiles in dropdown mode only.', 'goya' ),
'section' => 'language_selector',
'default' => array('code'),
'priority' => 10,
'multiple' => 1,
'choices' => array(
'flag' => esc_attr__('Flag', 'goya'),
'code' => esc_attr__('Code', 'goya'),
'name' => esc_attr__('Name', 'goya'),
),
));
}
/**
* HEADER
*/
/* Header Styles */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'header_sticky',
'label' => esc_html__( 'Sticky Header', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_layout',
'default' => true,
'priority' => 10,
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'header-sticky',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'header_sticky_sections',
'label' => esc_html__( 'Section to display on sticky header', 'goya' ),
'description' => esc_html__( 'For desktop size only', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_layout',
'default' => 'top',
'priority' => 10,
'choices' => array(
'both' => esc_html__( 'Both', 'goya' ),
'top' => esc_html__( 'Top', 'goya' ),
'bottom' => esc_html__( 'Bottom', 'goya' ),
),
'required' => array(
array(
'setting' => 'header_sticky',
'operator' => '==',
'value' => true,
),
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
array(
'setting' => 'header_show_bottom',
'operator' => '==',
'value' => true,
),
),
'js_vars' => array(
array(
'element' => '.site-header',
'function' => 'toggleClass',
'class' => 'sticky-display-top',
'value' => 'top',
),
array(
'element' => '.site-header',
'function' => 'toggleClass',
'class' => 'sticky-display-bottom',
'value' => 'bottom',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_layout',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'header_full_width',
'label' => esc_html__( 'Header Full Width', 'goya' ),
'description' => esc_html__('This also applies to the "Top Bar" if visible.', 'goya'),
'transport' => 'postMessage',
'section' => 'header_layout',
'default' => false,
'priority' => 10,
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'header-full-width',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_layout',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'header_layout',
'label' => esc_html__( 'Header Layout', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_layout',
'default' => 'prebuild',
'priority' => 10,
'choices' => array(
'prebuild' => esc_html__( 'Preset', 'goya' ),
'custom' => esc_html__( 'Custom', 'goya' ),
),
'partial_refresh' => array(
'header_layout' => array(
'selector' => '#header',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/header', 'default' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'select',
'settings' => 'header_version',
'label' => esc_html__( 'Header version', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_layout',
'default' => 'v6',
'priority' => 11,
'choices' => array(
'v1' => esc_html__( 'Header V1', 'goya' ),
'v2' => esc_html__( 'Header V2', 'goya' ),
'v3' => esc_html__( 'Header V3', 'goya' ),
'v4' => esc_html__( 'Header V4', 'goya' ),
'v5' => esc_html__( 'Header V5', 'goya' ),
'v6' => esc_html__( 'Header V6', 'goya' ),
'v7' => esc_html__( 'Header V7', 'goya' ),
'v8' => esc_html__( 'Header V8', 'goya' ),
'v9' => esc_html__( 'Header V9', 'goya' ),
),
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'prebuild',
),
),
'partial_refresh' => array(
'header_version' => array(
'selector' => '#header',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/header', 'default' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_layout',
'default' => '' . esc_html__( 'Header Top', 'goya' ) . ' ' . esc_html__( 'Custom elements for top section of the header', 'goya' ) . '
',
'priority' => 12,
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'header_main_left',
'label' => esc_html__( 'Top - Left Section', 'goya' ),
'section' => 'header_layout',
'transport' => 'postMessage',
'default' => array(),
'priority' => 13,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_header_elements_list(),
),
),
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
),
'partial_refresh' => array(
'header_main_left' => array(
'selector' => '#header',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/header', 'default' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'header_main_center',
'label' => esc_html__( 'Top - Center Section', 'goya' ),
'section' => 'header_layout',
'transport' => 'postMessage',
'default' => array(),
'priority' => 14,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_header_elements_list(),
),
),
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
),
'partial_refresh' => array(
'header_main_center' => array(
'selector' => '#header',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/header', 'default' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'header_main_right',
'label' => esc_html__( 'Top - Right Section', 'goya' ),
'section' => 'header_layout',
'transport' => 'postMessage',
'default' => array(),
'priority' => 15,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_header_elements_list(),
),
),
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
),
'partial_refresh' => array(
'header_main_right' => array(
'selector' => '#header',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/header', 'default' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_layout',
'default' => '' .
esc_html__( 'Header Bottom', 'goya' ) . ' ' .
esc_html__( 'Custom elements for bottom section of the header', 'goya' ) .
'
',
'priority' => 16,
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'header_show_bottom',
'label' => esc_html__( 'Show bottom section', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_layout',
'default' => true,
'priority' => 17,
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_layout',
'default' => '
',
'priority' => 18,
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
array(
'setting' => 'header_show_bottom',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'header_bottom_left',
'label' => esc_html__( 'Bottom - Left Section', 'goya' ),
'section' => 'header_layout',
'transport' => 'postMessage',
'default' => array(),
'priority' => 19,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_header_elements_list(),
),
),
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
array(
'setting' => 'header_show_bottom',
'operator' => '==',
'value' => true,
),
),
'partial_refresh' => array(
'header_bottom_left' => array(
'selector' => '#header',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/header', 'default' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'header_bottom_center',
'label' => esc_html__( 'Bottom - Center Section', 'goya' ),
'section' => 'header_layout',
'transport' => 'postMessage',
'default' => array(),
'priority' => 20,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_header_elements_list(),
),
),
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
array(
'setting' => 'header_show_bottom',
'operator' => '==',
'value' => true,
),
),
'partial_refresh' => array(
'header_bottom_center' => array(
'selector' => '#header',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/header', 'default' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'header_bottom_right',
'label' => esc_html__( 'Bottom - Right Section', 'goya' ),
'section' => 'header_layout',
'transport' => 'postMessage',
'default' => array(),
'priority' => 21,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_header_elements_list(),
),
),
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
array(
'setting' => 'header_show_bottom',
'operator' => '==',
'value' => true,
),
),
'partial_refresh' => array(
'header_bottom_right' => array(
'selector' => '#header',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/header', 'default' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_layout',
'default' => '' .
esc_html__( 'Text Fields', 'goya' ) . ' ' .
esc_html__( 'To be used with the customizer above: Text 1, Text 2, Text 3', 'goya' ) .
'
',
'priority' => 22,
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'header_custom_text',
'label' => esc_html__( 'Text 1', 'goya' ),
'section' => 'header_layout',
'priority' => 22,
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
),
'default' => '',
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'header_custom_text2',
'label' => esc_html__( 'Text 2', 'goya' ),
'section' => 'header_layout',
'priority' => 22,
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
),
'default' => '',
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'header_custom_text3',
'label' => esc_html__( 'Text 3', 'goya' ),
'section' => 'header_layout',
'priority' => 22,
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
),
'default' => '',
));
/* Header Icons */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_elements',
'default' => '
' . esc_html__( 'Account', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'main_header_login_popup',
'label' => esc_html__( 'Login/Register Lightbox', 'goya' ),
'section' => 'header_elements',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'main_header_login_icon',
'label' => esc_html__( 'Display mode', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_elements',
'default' => 'text',
'priority' => 10,
'choices' => array(
'icon' => esc_attr__('Icon', 'goya'),
'text' => esc_attr__('Text', 'goya'),
),
'js_vars' => array(
array(
'element' => '.et-menu-account-btn',
'function' => 'toggleClass',
'class' => 'account-icon',
'value' => 'icon',
),
array(
'element' => '.et-menu-account-btn',
'function' => 'toggleClass',
'class' => 'account-text',
'value' => 'text',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_elements',
'default' => '
' . esc_html__( 'Wishlist', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'ajax_wishlist_counter',
'label' => esc_html__( 'Ajax update Wishlist counter', 'goya' ),
'description' => esc_html__( 'Update the counter on cached pages - it creates a new Ajax request.', 'goya' ),
'section' => 'header_elements',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'wishlist_account_dashboard',
'label' => esc_html__( 'Wishlist in My Account dashboard', 'goya' ),
'description' => sprintf( '%s %s',
esc_html__( 'Re-save "Settings > Permalinks" after any change', 'goya' ),
esc_html__( 'The header icon will point to the new tab. DON\'T delete the Wishlist page! It\'s still required.', 'goya' )
),
'section' => 'header_elements',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_elements',
'default' => '
' . esc_html__( 'Search', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'ajax_search',
'label' => esc_html__( 'Use Ajax Product Search', 'goya' ),
'description' => esc_html__( 'Only if WooCommerce is installed', 'goya' ),
'section' => 'header_elements',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_elements',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'search_categories',
'label' => esc_html__( 'Narrow by Category', 'goya' ),
'section' => 'header_elements',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_elements',
'default' => '' .
esc_html__( 'Mini Cart', 'goya' ) . ' ' .
esc_html__( 'Moved to Shop > Minicart in customizer.', 'goya' ) .
'
',
'priority' => 10,
));
/* Header Logo */
Kirki::add_field( 'goya_config', array(
'type' => 'image',
'settings' => 'site_logo',
'label' => esc_html__( 'Logo - General', 'goya' ),
'description' => sprintf( '%s %s ',
esc_html__( '* Leave empty ', 'goya' ),
esc_html__( 'Site Identity > Logo', 'goya' )
),
'transport' => 'auto',
'section' => 'header_logo',
'priority' => 10,
'default' => get_template_directory_uri() . '/assets/img/logo-light.png',
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_logo',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'image',
'settings' => 'site_logo_dark',
'label' => esc_html__( 'Logo - Dark', 'goya' ),
'description' => esc_html__( 'Logo for dark background transparent header', 'goya' ),
'transport' => 'auto',
'section' => 'header_logo',
'priority' => 10,
'default' => get_template_directory_uri() . '/assets/img/logo-dark.png',
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_logo',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'select',
'settings' => 'site_logo_alt_use',
'label' => esc_html__( 'Alternative Logo', 'goya' ),
'description' => esc_html__( 'This will override the Logo - Dark in some cases', 'goya' ),
'transport' => 'auto',
'section' => 'header_logo',
'priority' => 10,
'choices' => array(
'' => esc_html__( 'Disable', 'goya' ),
'alt-logo-sticky' => esc_html__( 'Show in Sticky Header + Mobiles', 'goya' ),
'alt-logo-tablet' => esc_html__( 'Show in Tablets + Mobiles', 'goya' ),
'alt-logo-mobile' => esc_html__( 'Show in Mobiles only', 'goya' ),
),
'default' => '',
));
Kirki::add_field( 'goya_config', array(
'type' => 'image',
'settings' => 'site_logo_alt',
'label' => esc_html__( 'Alternative Logo Upload', 'goya' ),
'section' => 'header_logo',
'priority' => 10,
'default' => '',
'required' => array(
array(
'setting' => 'site_logo_alt_use',
'operator' => '!=',
'value' => ''
)
),
));
/* Header/Logo Size */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_logo_size',
'default' => '
' . esc_html__( 'Header Height', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'header_height',
'label' => esc_html__( 'Header Height (px)', 'goya' ),
'description' => esc_html__( 'This is the full header height (including bottom section if enabled)', 'goya' ),
'transport' => 'auto',
'section' => 'header_logo_size',
'default' => 90,
'priority' => 10,
'choices' => array(
'min' => 50,
'max' => 250,
'step' => 1
),
'output' => array(
array(
'element' => '.header,.header-spacer,.product-header-spacer',
'property' => 'height',
'units' => 'px',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'header_height_bottom',
'label' => esc_html__( 'Header Bottom (px)', 'goya' ),
'description' => esc_html__( 'The height of the bottom section only', 'goya' ),
'transport' => 'auto',
'section' => 'header_logo_size',
'default' => 40,
'priority' => 10,
'choices' => array(
'min' => 30,
'max' => 150,
'step' => 1
),
'required' => array(
array(
'setting' => 'header_layout',
'operator' => '==',
'value' => 'custom',
),
array(
'setting' => 'header_show_bottom',
'operator' => '==',
'value' => true,
),
),
'output' => array(
array(
'element' => '.header .header-bottom',
'property' => 'height',
'units' => 'px',
),
array(
'element' => '.header .header-bottom',
'property' => 'max-height',
'units' => 'px',
),
array(
'element' => '.header .header-bottom',
'property' => 'min-height',
'units' => 'px',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'header_height_sticky',
'label' => esc_html__( 'Sticky Header (px)', 'goya' ),
'transport' => 'auto',
'section' => 'header_logo_size',
'default' => 70,
'priority' => 10,
'choices' => array(
'min' => 50,
'max' => 250,
'step' => 1
),
'required' => array(
array(
'setting' => 'header_sticky',
'operator' => '==',
'value' => true,
),
),
'output' => array(
array(
'element' => '.header_on_scroll:not(.megamenu-active) .header',
'property' => 'height',
'units' => 'px',
'media_query' => '@media only screen and (min-width: 992px)'
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'header_height_mobile',
'label' => esc_html__( 'Mobile Header (px)', 'goya' ),
'transport' => 'auto',
'section' => 'header_logo_size',
'default' => 60,
'priority' => 10,
'choices' => array(
'min' => 40,
'max' => 120,
'step' => 1
),
'output' => array(
array(
'element' => array('.header', '.header_on_scroll .header', '.sticky-product-bar', '.header-spacer', '.product-header-spacer'),
'property' => 'height',
'units' => 'px',
'media_query' => '@media only screen and (max-width: 991px)',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_logo_size',
'default' => '
' . esc_html__( 'Logo Height', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'logo_height',
'label' => esc_html__( 'Logo Height (px)', 'goya' ),
'description' => esc_html__( 'Maximum Logo Height', 'goya' ),
'transport' => 'auto',
'section' => 'header_logo_size',
'default' => 24,
'priority' => 10,
'choices' => array(
'min' => 15,
'max' => 200,
'step' => 1
),
'output' => array(
array(
'element' => array('.header .logolink img'),
'property' => 'max-height',
'units' => 'px',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'logo_height_sticky',
'label' => esc_html__( 'Logo Height - Sticky Header (px)', 'goya' ),
'description' => esc_html__( 'Maximum Logo Height in sticky header (when scrolling down)', 'goya' ),
'transport' => 'auto',
'section' => 'header_logo_size',
'default' => 24,
'priority' => 10,
'choices' => array(
'min' => 15,
'max' => 200,
'step' => 1
),
'output' => array(
array(
'element' => array('.header_on_scroll:not(.megamenu-active) .header .logolink img, .header_on_scroll.megamenu-active .header .alt-logo-sticky img'),
'property' => 'max-height',
'units' => 'px',
'media_query' => '@media only screen and (min-width: 992px)',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'logo_height_mobile',
'label' => esc_html__( 'Logo Height - Mobile (px)', 'goya' ),
'description' => esc_html__( 'Maximum Logo Height for Mobiles', 'goya' ),
'transport' => 'auto',
'section' => 'header_logo_size',
'default' => 24,
'priority' => 10,
'choices' => array(
'min' => 15,
'max' => 100,
'step' => 1
),
'output' => array(
array(
'element' => array('.header .logolink img'),
'property' => 'max-height',
'units' => 'px',
'media_query' => '@media only screen and (max-width: 991px)',
),
),
));
/* Top Bar */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'top_bar',
'label' => esc_html__( 'Show Top Bar', 'goya' ),
'section' => 'top_bar',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'top_bar',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'multicheck',
'settings' => 'top_bar_mobiles',
'label' => esc_html__( 'Mobile visibility', 'goya' ),
'description' => esc_html__( 'Select the sections to display on mobiles', 'goya' ),
'section' => 'top_bar',
'default' => array(),
'priority' => 10,
'multiple' => 1,
'choices' => array(
'left' => esc_attr__('Left', 'goya'),
'center' => esc_attr__('Center', 'goya'),
'right' => esc_attr__('Right', 'goya'),
),
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true
)
),*/
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'top_bar',
'default' => '
' . esc_html__( 'Elements', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'top_bar_left',
'label' => esc_html__( 'Left Section', 'goya' ),
'section' => 'top_bar',
'transport' => 'postMessage',
'default' => array( array( 'item' => 'social' ) ),
'priority' => 11,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_topbar_elements_list(),
),
),
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true
)
),*/
'partial_refresh' => array(
'top_bar_left' => array(
'selector' => '.top-bar',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header-parts/top-bar' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'top_bar_center',
'label' => esc_html__( 'Center Section', 'goya' ),
'section' => 'top_bar',
'transport' => 'postMessage',
'default' => array(),
'priority' => 12,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_topbar_elements_list(),
),
),
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true
)
),*/
'partial_refresh' => array(
'top_bar_center' => array(
'selector' => '.top-bar',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header-parts/top-bar' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'top_bar_right',
'label' => esc_html__( 'Right Section', 'goya' ),
'section' => 'top_bar',
'transport' => 'postMessage',
'default' => array(),
'priority' => 13,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_topbar_elements_list(),
),
),
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true
)
),*/
'partial_refresh' => array(
'top_bar_right' => array(
'selector' => '.top-bar',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header-parts/top-bar' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'top_bar',
'default' => '' .
esc_html__( 'Text Fields', 'goya' ) . ' ' .
esc_html__( 'To be used with the customizer above', 'goya' ) .
'
',
'priority' => 14,
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true
)
),*/
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'top_bar_text',
'label' => esc_html__( 'Custom Text 1', 'goya' ),
'section' => 'top_bar',
'priority' => 14,
'default' => '',
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true
)
),*/
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'top_bar_text2',
'label' => esc_html__( 'Custom Text 2', 'goya' ),
'section' => 'top_bar',
'priority' => 14,
'default' => '',
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true
)
),*/
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'top_bar_text3',
'label' => esc_html__( 'Custom Text 3', 'goya' ),
'section' => 'top_bar',
'priority' => 14,
'default' => '',
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true
)
),*/
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'top_bar',
'default' => '
' . esc_html__( 'Styles', 'goya' ) . ' ',
'priority' => 14,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'top_bar_height',
'label' => esc_html__( 'Height (px)', 'goya' ),
'transport' => 'auto',
'section' => 'top_bar',
'default' => 40,
'priority' => 14,
'choices' => array(
'min' => 30,
'max' => 60,
'step' => 1
),
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true
)
),*/
'output' => array(
array(
'element' => array('.top-bar .search-field, .top-bar .search-button-group select'),
'property' => 'height',
'units' => 'px',
),
array(
'element' => array('.top-bar'),
'property' => 'min-height',
'units' => 'px',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'top_bar',
'default' => '
',
'priority' => 14,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'top_bar_font_color',
'label' => esc_html__( 'Top Bar Text Color', 'goya' ),
'transport' => 'auto',
'section' => 'top_bar',
'default' => '#eeeeee',
'priority' => 14,
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true,
),
),*/
'output' => array(
array(
'element' => array('.top-bar, .top-bar a, .top-bar button, .top-bar .selected'),
'property' => 'color',
),
array(
'element' => array('.search-button-group .search-clear:before, .search-button-group .search-clear:after'),
'property' => 'background-color',
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'top_bar_background_color',
'label' => esc_html__( 'Top Bar Background Color', 'goya' ),
'transport' => 'auto',
'section' => 'top_bar',
'default' => '#282828',
'priority' => 14,
/*'required' => array(
array(
'setting' => 'top_bar',
'operator' => '==',
'value' => true,
),
),*/
'output' => array(
array(
'element' => array('.top-bar'),
'property' => 'background-color',
),
),
));
/* Campaign */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'campaign_bar',
'label' => esc_html__( 'Show Campaign Bar', 'goya' ),
'section' => 'campaign',
'default' => false,
'priority' => 10,
));
if (get_theme_mod('campaign_bar_content', '') != '') {
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'campaign',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'textarea',
'settings' => 'campaign_bar_content',
'label' => esc_html__( 'Old Content', 'goya' ),
'description' => sprintf( '%s %s
%s
',
esc_html__( '* Warning: This field is deprecated and it will be removed. Leave this field empty and use the new options under', 'goya' ),
esc_html__( 'Campaign Content', 'goya' ),
esc_html__( 'For multilanguage sites translate the strings again.', 'goya' )
),
'section' => 'campaign',
'default' => '',
'priority' => 10,
/*'required' => array(
array(
'setting' => 'campaign_bar',
'operator' => '==',
'value' => true
)
),*/
));
}
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'campaign',
'default' => '
' . esc_html__( 'Contents', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'campaign_bar_items',
'label' => esc_html__( 'Campaign Content', 'goya' ),
'section' => 'campaign',
'transport' => 'postMessage',
'default' => array(),
'priority' => 11,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Campaign', 'goya' ),
),
'fields' => array(
'campaign_text' => array(
'type' => 'textarea',
'label' => esc_html__( 'Text', 'goya' ),
'default' => ''
),
'campaign_link' => array(
'type' => 'text',
'label' => esc_html__( 'URL', 'goya' ),
'default' => ''
),
'campaign_button' => array(
'type' => 'text',
'label' => esc_html__( 'Button Text', 'goya' ),
'description' => esc_html__( 'Only used if Link Mode is Button', 'goya' ),
'default' => ''
),
),
/*'required' => array(
array(
'setting' => 'campaign_bar',
'operator' => '==',
'value' => true
)
),*/
'partial_refresh' => array(
'campaign_items' => array(
'selector' => '.et-global-campaign',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header-parts/campaigns' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'campaign',
'default' => '
' . esc_html__( 'Layout', 'goya' ) . ' ',
'priority' => 12,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'campaign_layout',
'label' => esc_html__( 'Layout', 'goya' ),
'section' => 'campaign',
'default' => 'slider',
'priority' => 12,
'choices' => array(
'inline' => esc_attr__('Inline', 'goya'),
'slider' => esc_attr__('Slider', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'campaign',
'default' => '
',
'priority' => 12,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'campaign_slider_transition',
'label' => esc_html__( 'Slider Transition', 'goya' ),
'section' => 'campaign',
'default' => 'slide',
'priority' => 12,
'choices' => array(
'slide' => esc_attr__('Slide', 'goya'),
'fade' => esc_attr__('Fade', 'goya'),
),
/*'required' => array(
array(
'setting' => 'campaign_layout',
'operator' => '==',
'value' => 'slider',
),
),*/
));
Kirki::add_field( 'goya_config', array(
'type' => 'text',
'settings' => 'campaign_autoplay_speed',
'label' => esc_html__( 'Autoplay Speed', 'goya' ),
'description' => __( 'Enter autoplay interval in milliseconds (1 second = 1000 milliseconds).', 'goya' ),
'section' => 'campaign',
'default' => 2500,
'priority' => 12,
/*'required' => array(
array(
'setting' => 'campaign_layout',
'operator' => '==',
'value' => 'slider',
),
),*/
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'campaign',
'default' => '
',
'priority' => 12,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'campaign_links_mode',
'label' => esc_html__( 'Link Mode', 'goya' ),
'description' => esc_html__( 'Full Text: click anywhere on the text, the button is not visible', 'goya' ),
'section' => 'campaign',
'default' => 'button',
'priority' => 12,
'choices' => array(
'button' => esc_attr__('Button', 'goya'),
'cover' => esc_attr__('Full Text', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'campaign',
'default' => '
',
'priority' => 12,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'campaign_bar_dismissible',
'label' => esc_html__( 'Show close button', 'goya' ),
'description' => esc_html__( 'Campaign area is reactivated after 24hr.', 'goya' ),
'transport' => 'postMessage',
'section' => 'campaign',
'default' => true,
'priority' => 12,
/*'required' => array(
array(
'setting' => 'campaign_bar',
'operator' => '==',
'value' => true,
),
),*/
'js_vars' => array(
array(
'element' => '.et-global-campaign .remove',
'function' => 'toggleClass',
'class' => 'dismissible',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'campaign',
'default' => '
',
'priority' => 12,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'campaign_bar_height',
'label' => esc_html__( 'Min Height (px)', 'goya' ),
'transport' => 'auto',
'section' => 'campaign',
'default' => 40,
'priority' => 12,
'choices' => array(
'min' => 30,
'max' => 60,
'step' => 1
),
/*'required' => array(
array(
'setting' => 'campaign_bar',
'operator' => '==',
'value' => true
)
),*/
'output' => array(
array(
'element' => array('.et-global-campaign'),
'property' => 'min-height',
'units' => 'px',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'campaign',
'default' => '
' . esc_html__( 'Colors', 'goya' ) . ' ',
'priority' => 12,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'campaign_bar_font_color',
'label' => esc_html__( 'Campaign - Text Color', 'goya' ),
'transport' => 'auto',
'section' => 'campaign',
'default' => '#ffffff',
'priority' => 12,
/*'required' => array(
array(
'setting' => 'campaign_bar',
'operator' => '==',
'value' => true,
),
),*/
'output' => array(
array(
'element' => array('.et-global-campaign'),
'property' => 'color',
),
array(
'element' => array('.et-global-campaign .et-close:before, .et-global-campaign .et-close:after, .no-touch .et-global-campaign .et-close:hover:before, .no-touch .et-global-campaign .et-close:hover:after'),
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'campaign_bar_background_color',
'label' => esc_html__( 'Campaign - Background Color', 'goya' ),
'transport' => 'auto',
'section' => 'campaign',
'default' => '#e97a7e',
'priority' => 12,
/*'required' => array(
array(
'setting' => 'campaign_bar',
'operator' => '==',
'value' => true,
),
),*/
'output' => array(
array(
'element' => array('.et-global-campaign'),
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'campaign_button_text_color',
'label' => esc_html__( 'Button Color', 'goya' ),
'transport' => 'auto',
'section' => 'campaign',
'default' => '#ffffff',
'priority' => 12,
'required' => array(
/*array(
'setting' => 'campaign_bar',
'operator' => '==',
'value' => true,
),*/
array(
'setting' => 'campaign_links_mode',
'operator' => '==',
'value' => 'button',
)
),
'output' => array(
array(
'element' => array('.campaign-inner .link-button'),
'property' => 'color',
),
),
));
/* Header Styles */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'vertical_bar',
'label' => esc_html__( 'Show Vertical Bar', 'goya' ),
'description' => esc_html__( 'Vertical icons bar in Toggle/Mobile menu panel', 'goya' ),
'section' => 'header_vertical_bar',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'sortable',
'settings' => 'vertical_bar_icons',
'label' => esc_html__( 'Vertical Bar Icons', 'goya' ),
'section' => 'header_vertical_bar',
'transport' => 'postMessage',
'default' => array( 'account', 'wishlist' ),
'choices' => goya_vertical_bar_elements_list(),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_vertical_bar',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'vertical_bar_mode',
'label' => esc_html__( 'Color scheme', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_vertical_bar',
'default' => 'light',
'priority' => 10,
'choices' => array(
'light' => esc_attr__('Light', 'goya'),
'dark' => esc_attr__('Dark', 'goya'),
),
'js_vars' => array(
array(
'element' => '.side-panel .mobile-bar',
'function' => 'toggleClass',
'class' => 'dark',
'value' => 'dark',
),
array(
'element' => '.side-panel .mobile-bar',
'function' => 'toggleClass',
'class' => 'light',
'value' => 'light',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'vertical_bar_background',
'label' => esc_html__( 'Bar background', 'goya' ),
'transport' => 'auto',
'section' => 'header_vertical_bar',
'default' => '#f8f8f8',
'priority' => 10,
'output' => array(
array(
'element' => array('.side-panel .mobile-bar','.side-panel .mobile-bar.dark'),
'property' => 'background-color',
),
),
));
/* Main Menu Settings */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'megamenu_fullwidth',
'label' => esc_html__( 'Full width Mega Menu', 'goya' ),
'description' => esc_html__( 'Megamenu fills the entire page width', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_main_menu',
'default' => true,
'priority' => 10,
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'megamenu-fullwidth',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_main_menu',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'megamenu_column_animation',
'label' => esc_html__( 'Animate Megamenu Columns', 'goya' ),
'description' => esc_html__( 'Add delayed animation to megamenu dropdown columns', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_main_menu',
'default' => false,
'priority' => 10,
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'megamenu-column-animation',
'value' => true,
),
),
));
/* Off Canvas Desktop Menu */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'menu_fullscreen_override',
'label' => esc_html__( 'Override with mobile?', 'goya' ),
'description' => esc_html__( 'Show mobile panel on desktops too', 'goya' ),
'section' => 'header_offcanvas_desktop',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_offcanvas_desktop',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'menu_fullscreen_override',
'operator' => '!=',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'menu_fullscreen_mode',
'label' => esc_html__( 'Panel color scheme', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_offcanvas_desktop',
'default' => 'light',
'priority' => 10,
'choices' => array(
'light' => esc_attr__('Light', 'goya'),
'dark' => esc_attr__('Dark', 'goya'),
),
'required' => array(
array(
'setting' => 'menu_fullscreen_override',
'operator' => '!=',
'value' => true,
),
),
'js_vars' => array(
array(
'element' => '#fullscreen-menu',
'function' => 'toggleClass',
'class' => 'dark',
'value' => 'dark',
),
array(
'element' => '#fullscreen-menu',
'function' => 'toggleClass',
'class' => 'light',
'value' => 'light',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'menu_fullscreen_background_color',
'label' => esc_html__( 'Panel Background', 'goya' ),
'transport' => 'auto',
'section' => 'header_offcanvas_desktop',
'default' => '#ffffff',
'priority' => 10,
'required' => array(
array(
'setting' => 'menu_fullscreen_override',
'operator' => '!=',
'value' => true,
),
),
'output' => array(
array(
'element' => array('.side-fullscreen-menu','.side-fullscreen-menu.dark'),
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_offcanvas_desktop',
'default' => '
' . esc_html__( 'Additional Elements', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'menu_fullscreen_widget',
'label' => esc_html__( 'Widget Area', 'goya' ),
'section' => 'header_offcanvas_desktop',
'default' => true,
'priority' => 10,
'required' => array(
array(
'setting' => 'menu_fullscreen_override',
'operator' => '!=',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'menu_fullscreen_account',
'label' => esc_html__( 'Account links', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_offcanvas_desktop',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'menu_fullscreen_override',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'menu_fullscreen_currency',
'label' => esc_html__( 'Currency Selector', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_offcanvas_desktop',
'default' => true,
'priority' => 10,
'partial_refresh' => array(
'menu_fullscreen_currency' => array(
'selector' => '#fullscreen-menu',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/fullscreen-menu' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'menu_fullscreen_language',
'label' => esc_html__( 'Language Selector', 'goya' ),
'section' => 'header_offcanvas_desktop',
'default' => true,
'priority' => 10,
'partial_refresh' => array(
'menu_fullscreen_language' => array(
'selector' => '#fullscreen-menu',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/fullscreen-menu' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'menu_fullscreen_social',
'label' => esc_html__( 'Social Icons', 'goya' ),
'section' => 'header_offcanvas_desktop',
'default' => true,
'priority' => 10,
'partial_refresh' => array(
'menu_fullscreen_social' => array(
'selector' => '#fullscreen-menu',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header/fullscreen-menu' );
},
),
),
));
/* Mobile Menu */
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'mobile_menu_type',
'label' => esc_html__( 'Mobile Sub-menus', 'goya' ),
'description' => esc_html__( 'How to reveal sub-menus on mobiles', 'goya' ),
'section' => 'header_menu_mobile',
'default' => 'sliding',
'priority' => 10,
'choices' => array(
'sliding' => esc_attr__('Sliding', 'goya'),
'vertical' => esc_attr__('Collapsible (vertical)', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_menu_mobile',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'menu_mobile_mode',
'label' => esc_html__( 'Panel color scheme', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_menu_mobile',
'default' => 'light',
'priority' => 10,
'choices' => array(
'light' => esc_attr__('Light', 'goya'),
'dark' => esc_attr__('Dark', 'goya'),
),
'js_vars' => array(
array(
'element' => '#mobile-menu',
'function' => 'toggleClass',
'class' => 'dark',
'value' => 'dark',
),
array(
'element' => '#mobile-menu',
'function' => 'toggleClass',
'class' => 'light',
'value' => 'light',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'menu_mobile_text_color',
'label' => esc_html__( 'Links Color', 'goya' ),
'transport' => 'auto',
'section' => 'header_menu_mobile',
'default' => '#282828',
'priority' => 10,
'output' => array(
array(
'element' => array('.side-mobile-menu li, .side-mobile-menu li a, .side-mobile-menu .bottom-extras, .side-mobile-menu .bottom-extras a, .side-mobile-menu .selected'),
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'menu_mobile_background_color',
'label' => esc_html__( 'Panel Background', 'goya' ),
'transport' => 'auto',
'section' => 'header_menu_mobile',
'default' => '#ffffff',
'priority' => 10,
'output' => array(
array(
'element' => array('.side-menu.side-mobile-menu','.side-menu.side-mobile-menu.dark'),
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_menu_mobile',
'default' => '' .
esc_html__( 'Elements to show', 'goya' ) . ' ' .
esc_html__( 'Items to show on mobile menu', 'goya' ) .
'
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'menu_mobile_search',
'label' => esc_html__( 'Search Box', 'goya' ),
'description' => esc_html__( 'Show search box on top of mobile menu', 'goya' ),
'section' => 'header_menu_mobile',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'sortable',
'settings' => 'menu_mobile_items',
'label' => esc_html__( 'Extra Options', 'goya' ),
'description' => esc_html__( 'Additional elements below menu', 'goya' ),
'section' => 'header_menu_mobile',
'transport' => 'postMessage',
'default' => array('account', 'divider1', 'currency', 'language', 'divider2', 'social'),
'choices' => goya_mobile_menu_elements_list(),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_menu_mobile',
'default' => '' .
esc_html__( 'Text Fields', 'goya' ) . ' ' .
esc_html__( 'To be used with the customizer above', 'goya' ) .
'
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'menu_mobile_custom_text',
'label' => esc_html__( 'Custom Text 1', 'goya' ),
'section' => 'header_menu_mobile',
'priority' => 10,
'default' => '',
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'menu_mobile_custom_text2',
'label' => esc_html__( 'Custom Text 2', 'goya' ),
'section' => 'header_menu_mobile',
'priority' => 10,
'default' => '',
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'menu_mobile_custom_text3',
'label' => esc_html__( 'Custom Text 3', 'goya' ),
'section' => 'header_menu_mobile',
'priority' => 10,
'default' => '',
));
/* Mobile Options */
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'mobile_logo_position',
'label' => esc_html__( 'Logo Position', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_mobile',
'default' => 'center',
'priority' => 10,
'choices' => array(
'center' => esc_attr__( 'Center', 'goya' ),
'left' => esc_attr__( 'Left', 'goya' ),
),
'js_vars' => array(
array(
'element' => '.header .header-mobile',
'function' => 'toggleClass',
'class' => 'logo-center',
'value' => 'center',
),
array(
'element' => '.header .header-mobile',
'function' => 'toggleClass',
'class' => 'logo-left',
'value' => 'left',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_mobile',
'default' => '
',
'priority' => 11,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'header_transparent_mobiles',
'label' => esc_html__( 'Keep transparent header', 'goya' ),
'description' => esc_html__( 'This option only works if you enable transparent header on other customizer sections (shop, blog) or directly on the product or page.', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_mobile',
'default' => true,
'priority' => 12,
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'header-transparent-mobiles',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_mobile',
'default' => '
',
'priority' => 13,
));
Kirki::add_field( 'goya_config', array( // Repeater
'type' => 'repeater',
'settings' => 'mobile_header_icons',
'label' => esc_html__( 'Header Icons', 'goya' ),
'description' => esc_html__( 'Control icons on the right side of mobile header', 'goya' ),
'section' => 'header_mobile',
'transport' => 'postMessage',
'default' => array( array( 'item' => 'cart' ) ),
'priority' => 14,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_mobile_header_elements_list(),
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_mobile',
'default' => '
',
'priority' => 15,
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'header_mobile_custom_text',
'label' => esc_html__( 'Custom Text', 'goya' ),
'section' => 'header_mobile',
'priority' => 16,
'default' => '',
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_mobile',
'default' => '
',
'priority' => 17,
));
Kirki::add_field( 'goya_config', array(
'type' => 'text',
'settings' => 'mobile_header_breakpoint',
'label' => esc_html__( 'Responsive breakpoint', 'goya' ),
'description' => esc_html__( 'Screen width in px at which the mobile header becomes visible. Applied to Top Bar too. Min: 575, Max: 1360, Default: 991px', 'goya' ),
'section' => 'header_mobile',
'default' => 991,
'priority' => 18,
));
/**
* FOOTER
*/
/* Footer */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'back_to_top_button',
'label' => esc_html__( 'Back To Top Button', 'goya' ),
'section' => 'footer_setting',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'footer_setting',
'default' => '
' . esc_html__( 'Footer Widgets', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'footer_widgets_columns',
'label' => esc_html__( 'Widgets Columns', 'goya' ),
'description' => esc_html__( 'Number of columns for Footer Widgets', 'goya' ),
'section' => 'footer_setting',
'default' => 3,
'priority' => 10,
'choices' =>
array
(
'min' => 1,
'max' => 4,
'step' => 1
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'select',
'settings' => 'footer_widgets_column_width',
'label' => esc_html__( 'Columns Width', 'goya' ),
'section' => 'footer_setting',
'default' => 'equal',
'priority' => 10,
'choices' => array(
'equal' => esc_html__( 'Equal width columns', 'goya' ),
'last' => esc_html__( 'Last column wide', 'goya' ),
'first' => esc_html__( 'First column wide', 'goya' ),
),
'required' => array(
array(
'setting' => 'footer_widgets_columns',
'operator' => '>',
'value' => 1,
),
),
));
/* Footer Extra */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'footer_middle',
'label' => esc_html__( 'Enable Footer Extra', 'goya' ),
'description' => esc_html__( 'Full width section with custom content', 'goya' ),
'section' => 'footer_extra',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'footer_extra',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'footer_middle_position',
'label' => esc_html__( 'Position', 'goya' ),
'section' => 'footer_extra',
'default' => 'after',
'priority' => 10,
'choices' => array(
'before' => esc_attr__('Before Widgets', 'goya'),
'after' => esc_attr__('After Widgets', 'goya'),
),
'required' => array(
array(
'setting' => 'footer_middle',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'footer_extra',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'footer_middle_content',
'label' => esc_html__( 'Content', 'goya' ),
'description' => esc_html__( 'You can use shortcodes like Mailchimp sign up shortcode.', 'goya' ),
'transport' => 'postMessage',
'section' => 'footer_extra',
'priority' => 10,
'default' => '',
'required' => array(
array(
'setting' => 'footer_middle',
'operator' => '==',
'value' => true,
),
),
'partial_refresh' => array(
'footer_middle_content' => array(
'selector' => '.footer-middle > div > div > .col-12',
'render_callback' => function() {
echo do_shortcode( get_theme_mod( 'footer_middle_content','' ) );
},
),
),
));
/* Footer Bottom */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'footer_bar_full_width',
'label' => esc_html__( 'Full-width Footer Bar', 'goya' ),
'transport' => 'postMessage',
'section' => 'footer_bottom',
'default' => true,
'priority' => 10,
'js_vars' => array(
array(
'element' => '.footer-bar',
'function' => 'toggleClass',
'class' => 'footer-full',
'value' => true,
),
array(
'element' => '.footer-bar',
'function' => 'toggleClass',
'class' => 'footer-normal',
'value' => false,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'footer_bottom',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'footer_bar_border',
'label' => esc_html__( 'Footer Bar Top Border', 'goya' ),
'transport' => 'postMessage',
'section' => 'footer_bottom',
'default' => false,
'priority' => 11,
'js_vars' => array(
array(
'element' => '.footer-bar',
'function' => 'toggleClass',
'class' => 'footer-bar-border-1',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'footer_bottom',
'default' => '
' . esc_html__( 'Columns', 'goya' ) . ' ',
'priority' => 12,
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'footer_main_left',
'label' => esc_html__( 'Left Section', 'goya' ),
'section' => 'footer_bottom',
'transport' => 'postMessage',
'default' => array( array( 'item' => 'copyright' ) ),
'priority' => 13,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_footer_elements_list(),
),
),
'partial_refresh' => array(
'footer_main_left' => array(
'selector' => '.footer-main',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/footer/footer', 'bar' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'footer_main_center',
'label' => esc_html__( 'Center Section', 'goya' ),
'section' => 'footer_bottom',
'transport' => 'postMessage',
'default' => array(),
'priority' => 14,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_footer_elements_list(),
),
),
'partial_refresh' => array(
'footer_main_center' => array(
'selector' => '.footer-main',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/footer/footer', 'bar' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'footer_main_right',
'label' => esc_html__( 'Right Section', 'goya' ),
'section' => 'footer_bottom',
'transport' => 'postMessage',
'default' => array(),
'priority' => 15,
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'item',
),
'fields' => array(
'item' => array(
'type' => 'select',
'choices' => goya_footer_elements_list(),
),
),
'partial_refresh' => array(
'footer_main_right' => array(
'selector' => '.footer-main',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/footer/footer', 'bar' );
},
),
),
));
/* Footer Text */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'footer_bottom',
'default' => '
' . esc_html__( 'Text Fields', 'goya' ) . ' ',
'priority' => 16,
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'footer_bar_copyright',
'label' => esc_html__( 'Copyright', 'goya' ),
'description' => sprintf( '%s [current_year]',
esc_html__( 'To automatically update the year use the shortcode ', 'goya' )
),
'section' => 'footer_bottom',
'priority' => 17,
'default' => '',
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'footer_bar_custom_text',
'label' => esc_html__( 'Custom Text 1', 'goya' ),
'section' => 'footer_bottom',
'priority' => 18,
'default' => '',
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'footer_bar_custom_text2',
'label' => esc_html__( 'Custom Text 2', 'goya' ),
'section' => 'footer_bottom',
'priority' => 19,
'default' => '',
));
/* Footer Widgets Styles */
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'footer_widgets_mode',
'label' => esc_html__( 'Footer Color Scheme', 'goya' ),
'description' => esc_html__( 'These styles are inherited to footer middle and bottom bar', 'goya' ),
'transport' => 'postMessage',
'section' => 'footer_colors',
'transport' => 'postMessage',
'default' => 'light',
'priority' => 10,
'choices' => array(
'light' => esc_attr__('Light', 'goya'),
'dark' => esc_attr__('Dark', 'goya'),
),
'js_vars' => array(
array(
'element' => '.site-footer',
'function' => 'toggleClass',
'class' => 'dark',
'value' => 'dark',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'footer_widgets_background',
'label' => esc_html__( 'Footer Background', 'goya' ),
'transport' => 'auto',
'section' => 'footer_colors',
'default' => '#ffffff',
'priority' => 10,
'output' => array(
array(
'element' => array('.site-footer','.site-footer.dark'),
'property' => 'background-color',
),
),
));
/* Footer Bar Styles */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'footer_colors',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'footer_bar_custom',
'label' => esc_html__( 'Footer Bar Colors', 'goya' ),
'description' => esc_html__( 'Custom colors for the bottom bar', 'goya' ),
'section' => 'footer_colors',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'footer_bar_mode',
'label' => esc_html__( 'Footer Bar Scheme', 'goya' ),
'transport' => 'postMessage',
'section' => 'footer_colors',
'default' => 'light',
'priority' => 10,
'choices' => array(
'light' => esc_attr__('Light', 'goya'),
'dark' => esc_attr__('Dark', 'goya'),
),
'required' => array(
array(
'setting' => 'footer_bar_custom',
'operator' => '==',
'value' => true,
),
),
'js_vars' => array(
array(
'element' => '.footer-bar',
'function' => 'toggleClass',
'class' => 'dark',
'value' => 'dark',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'footer_bar_background',
'label' => esc_html__( 'Footer bar background', 'goya' ),
'transport' => 'auto',
'section' => 'footer_colors',
'default' => '#ffffff',
'priority' => 10,
'required' => array(
array(
'setting' => 'footer_bar_custom',
'operator' => '==',
'value' => true,
),
),
'output' => array(
array(
'element' => array('.site-footer .footer-bar.custom-color-1','.site-footer .footer-bar.custom-color-1.dark'),
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'footer_bar_social_icons_color',
'label' => esc_html__( 'Footer Bar Social Icons', 'goya' ),
'transport' => 'auto',
'section' => 'footer_colors',
'default' => '#000000',
'priority' => 10,
'required' => array(
array(
'setting' => 'footer_bar_custom',
'operator' => '==',
'value' => true,
),
),
'output' => array(
array(
'element' => array('.footer-bar.custom-color-1 .social-icons a'),
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'footer_toggle_widgets',
'label' => esc_html__( 'Collapse Widgets on Mobiles', 'goya' ),
'section' => 'footer_mobile',
'default' => false,
'priority' => 10,
));
/**
* BLOG
*/
/* Blog Main */
Kirki::add_field( 'goya_config', array(
'type' => 'radio-image',
'settings' => 'blog_style',
'label' => esc_html__( 'Blog Layout', 'goya' ),
'section' => 'blog_list',
'default' => 'classic',
'priority' => 10,
'choices' => array(
'classic' => get_template_directory_uri() . '/assets/img/admin/options/blog-classic.png',
'masonry' => get_template_directory_uri() . '/assets/img/admin/options/blog-masonry.png',
'grid' => get_template_directory_uri() . '/assets/img/admin/options/blog-grid.png',
'cards' => get_template_directory_uri() . '/assets/img/admin/options/blog-cards.png',
'list' => get_template_directory_uri() . '/assets/img/admin/options/blog-list.png',
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'blog_style',
'operator' => 'contains',
'value' => array('masonry', 'grid'),
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'blog_grid_columns',
'label' => esc_html__( 'Columns in masonry/grid layout', 'goya' ),
'section' => 'blog_list',
'default' => 3,
'priority' => 10,
'choices' => array (
'min' => 2,
'max' => 4,
'step' => 1
),
'required' => array(
array(
'setting' => 'blog_style',
'operator' => 'contains',
'value' => array('masonry', 'grid'),
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'blog_style',
'operator' => '==',
'value' => 'classic',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'blog_title_overlay',
'label' => esc_html__( 'Title Overlay', 'goya' ),
'description' => esc_html__( 'Only in Classic style', 'goya' ),
'section' => 'blog_list',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'blog_style',
'operator' => '==',
'value' => 'classic',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'select',
'settings' => 'blog_list_animation',
'label' => esc_html__( 'Load animation', 'goya' ),
'label' => esc_html__( 'Animation to load the posts', 'goya' ),
'section' => 'blog_list',
'default' => 'animation bottom-to-top',
'priority' => 10,
'choices' => $goya_animations_list,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
' . esc_html__( 'Hero Title', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'blog_hero_title',
'label' => esc_html__( 'Post Hero Title', 'goya' ),
'description' => esc_html__( 'For main blog, archives and single posts', 'goya' ),
'section' => 'blog_list',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'blog_hero_title',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'blog_transparent_header',
'label' => esc_html__( 'Transparent header', 'goya' ),
'description' => esc_html__( 'For blog archives if hero title is active', 'goya' ),
'section' => 'blog_list',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'blog_hero_title',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'blog_hero_title',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'blog_menu_color',
'label' => esc_html__( 'Header/Description color mode', 'goya' ),
'section' => 'blog_list',
'default' => 'dark-title',
'priority' => 10,
'choices' => array(
'dark-title' => esc_attr__('Dark Text', 'goya'),
'light-title' => esc_attr__('Light Text', 'goya'),
),
'required' => array(
array(
'setting' => 'blog_hero_title',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'blog_hero_title_bg',
'label' => esc_html__( 'Default Header Background Color', 'goya' ),
'description' => esc_html__( 'You can choose header color scheme on each post', 'goya' ),
'section' => 'blog_list',
'default' => '#f8f8f8',
'priority' => 10,
'required' => array(
array(
'setting' => 'blog_hero_title',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'blog_hero_title',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'image',
'settings' => 'blog_header_bg_image',
'label' => esc_html__( 'Blog home image Background', 'goya' ),
'description' => esc_html__( 'This image is only for the Main Blog page', 'goya' ),
'section' => 'blog_list',
'priority' => 10,
'default' => '',
'required' => array(
array(
'setting' => 'blog_hero_title',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'blog_sidebar',
'label' => esc_html__( 'Blog Sidebar', 'goya' ),
'section' => 'blog_list',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'blog_sidebar_position',
'label' => esc_html__( 'Blog Sidebar Position', 'goya' ),
'section' => 'blog_list',
'default' => 'right',
'priority' => 10,
'choices' => array(
'right' => esc_html__('Right', 'goya'),
'left' => esc_html__('Left', 'goya')
),
'required' => array(
array(
'setting' => 'blog_sidebar',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
' . esc_html__( 'Blog List Elements', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'blog_category',
'label' => esc_html__( 'Show Post Category', 'goya' ),
'section' => 'blog_list',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'blog_author',
'label' => esc_html__( 'Show Author', 'goya' ),
'section' => 'blog_list',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'blog_date',
'label' => esc_html__( 'Show Date', 'goya' ),
'section' => 'blog_list',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_list',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'blog_pagination_style',
'label' => esc_html__( 'Blog Pagination', 'goya' ),
'section' => 'blog_list',
'default' => 'button',
'priority' => 10,
'choices' => array(
'regular' => esc_attr__('Regular', 'goya'),
'button' => esc_attr__('Load More', 'goya'),
'scroll' => esc_attr__('Infinite', 'goya'),
),
));
/* Blog Categories */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'blog_categories',
'label' => esc_html__( 'Blog Category Menu', 'goya' ),
'section' => 'blog_categories',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_categories',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'blog_categories_hide_empty',
'label' => esc_html__( 'Hide Empty Categories', 'goya' ),
'section' => 'blog_categories',
'default' => true,
'priority' => 10,
'required' => array(
array(
'setting' => 'blog_categories',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_categories',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'blog_categories_orderby',
'label' => esc_html__( 'Category Menu Order', 'goya' ),
'section' => 'blog_categories',
'default' => 'name',
'priority' => 10,
'choices' => array(
'id' => esc_attr__('ID', 'goya'),
'name' => esc_attr__('Name', 'goya'),
'slug' => esc_attr__('Slug', 'goya'),
'count' => esc_attr__('Count', 'goya'),
'term_group' => esc_attr__('Term Group', 'goya'),
),
'required' => array(
array(
'setting' => 'blog_categories',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_categories',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'blog_categories_order',
'label' => esc_html__( 'Order Direction', 'goya' ),
'section' => 'blog_categories',
'default' => 'asc',
'priority' => 10,
'choices' => array(
'asc' => esc_attr__('Ascending', 'goya'),
'desc' => esc_attr__('Descending', 'goya'),
),
'required' => array(
array(
'setting' => 'blog_categories',
'operator' => '==',
'value' => true,
),
),
));
/* Blog Single */
Kirki::add_field( 'goya_config', array(
'type' => 'radio-image',
'settings' => 'post_featured_image',
'label' => esc_html__( 'Featured Media Position', 'goya' ),
'description' => esc_html__( 'Display featured image, gallery or video if present: 1.Header Background, 2.Below title, 3.No Featured', 'goya' ),
'section' => 'blog_single',
'default' => 'below',
'priority' => 10,
'choices' => array(
'parallax' => get_template_directory_uri() . '/assets/img/admin/options/post-parallax.png',
'below' => get_template_directory_uri() . '/assets/img/admin/options/post-below.png',
'regular' => get_template_directory_uri() . '/assets/img/admin/options/post-regular.png',
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_single',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'post_featured_image',
'operator' => '==',
'value' => 'parallax',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'post_transparent_header',
'label' => esc_html__( 'Post Transparent Header', 'goya' ),
'description' => esc_html__( 'Used with Background Featured Media', 'goya' ),
'section' => 'blog_single',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'post_featured_image',
'operator' => '==',
'value' => 'parallax',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_single',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'post_sidebar',
'label' => esc_html__( 'Single Post Sidebar', 'goya' ),
'section' => 'blog_single',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'post_sidebar_position',
'label' => esc_html__( 'Single Post Sidebar Position', 'goya' ),
'section' => 'blog_single',
'default' => 'right',
'priority' => 10,
'choices' => array(
'right' => esc_html__('Right', 'goya'),
'left' => esc_html__('Left', 'goya')
),
'required' => array(
array(
'setting' => 'post_sidebar',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_single',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'post_author',
'label' => esc_html__( 'Author Details', 'goya' ),
'description' => esc_html__( 'Displays author information at the bottom, only if author description exists', 'goya' ),
'section' => 'blog_single',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_single',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'post_meta_bar',
'label' => esc_html__( 'Post Categories/Tags', 'goya' ),
'section' => 'blog_single',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_single',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'post_navigation',
'label' => esc_html__( 'Previous/Next Posts Links', 'goya' ),
'section' => 'blog_single',
'priority' => 10,
'choices' => array(
'' => esc_attr__( 'Disable', 'goya' ),
'simple' => esc_attr__( 'Simple', 'goya' ),
'image' => esc_attr__( 'Background Image', 'goya' ),
),
'required' => array(
array(
'setting' => 'single_post_related',
'operator' => '==',
'value' => true,
),
),
'default' => 'simple',
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_single',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'post_footer',
'label' => esc_html__( 'Show Footer on Single Posts', 'goya' ),
'section' => 'blog_single',
'default' => true,
'priority' => 10,
));
/* Blog Related */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'single_post_related',
'label' => esc_html__( 'Related Posts', 'goya' ),
'section' => 'blog_related',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_related',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'single_post_related_per_page',
'label' => esc_html__( 'Number of Related Posts', 'goya' ),
'section' => 'blog_related',
'default' => 3,
'priority' => 10,
'choices' => array (
'min' => 2,
'max' => 6,
'step' => 1
),
'required' => array(
array(
'setting' => 'single_post_related',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'blog_related',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'single_post_related_columns',
'label' => esc_html__( 'Related Posts Columns', 'goya' ),
'section' => 'blog_related',
'default' => 3,
'priority' => 10,
'choices' => array (
'min' => 2,
'max' => 4,
'step' => 1
),
'required' => array(
array(
'setting' => 'single_post_related',
'operator' => '==',
'value' => true,
),
),
));
/**
* PORTFOLIO
*/
if ( ! apply_filters('goya_disable_portfolio', false) == true ) {
/* Portfolio Home */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'portfolio_post_type',
'label' => esc_html__( 'Enable Portfolio', 'goya' ),
'description' => esc_html__( 'Activate portfolio post type', 'goya' ),
'section' => 'portfolio_main',
'default' => 'true',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'portfolio_main',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'portfolio_main_page',
'label' => esc_html__( 'Portfolio Main Page', 'goya' ),
'description' => esc_html__('*With the "shortcode" you can insert the Portfolio anywhere using the Page Builder.', 'goya'),
'section' => 'portfolio_main',
'default' => 'automatic',
'priority' => 10,
'choices' => array(
'automatic' => esc_attr__('Automatic', 'goya'),
'custom' => esc_attr__('Static Page', 'goya'),
'shortcode' => esc_attr__('Use Shortcode*', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'dropdown-pages',
'settings' => 'portfolio_page_custom',
'label' => esc_html__( 'Portfolio Page', 'goya' ),
'description' => esc_html__( 'Select your portfolio page. Best if the slug is the same as the permalink.', 'goya' ),
'section' => 'portfolio_main',
'priority' => 10,
'default' => '',
'required' => array(
array(
'setting' => 'portfolio_main_page',
'operator' => '==',
'value' => 'custom',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'portfolio_main',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'text',
'settings' => 'portfolio_permalink',
'label' => esc_html__( 'Permalink', 'goya' ),
'description' => sprintf( '%s %s ',
esc_html__( 'Slug used for the portfolio permalinks. Default is "portfolio".', 'goya' ),
esc_html__( 'Re-save "Settings > Permalinks" page after changing.', 'goya' )
),
'section' => 'portfolio_main',
'default' => 'portfolio',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'portfolio_main',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-image',
'settings' => 'portfolio_layout_main',
'label' => esc_html__( 'Portfolio Layout', 'goya' ),
'section' => 'portfolio_main',
'priority' => 10,
'choices' => array(
'masonry' => esc_attr__( 'Masonry', 'goya' ),
'grid' => esc_attr__( 'Grid', 'goya' ),
'list' => esc_attr__( 'List', 'goya' ),
),
'choices' => array(
'masonry' => get_template_directory_uri() . '/assets/img/admin/options/portfolio-masonry.png',
'grid' => get_template_directory_uri() . '/assets/img/admin/options/portfolio-grid.png',
'list' => get_template_directory_uri() . '/assets/img/admin/options/portfolio-list.png',
),
'default' => 'masonry',
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'portfolio_columns',
'label' => esc_html__( 'Number of columns', 'goya' ),
'section' => 'portfolio_main',
'priority' => 10,
'choices' => array(
'6' => esc_attr( '6 Columns', 'goya' ),
'4' => esc_attr( '4 Columns', 'goya' ),
'3' => esc_attr( '3 Columns', 'goya' ),
'2' => esc_attr( '2 Columns', 'goya' ),
),
'default' => '4',
'required' => array(
array(
'setting' => 'portfolio_layout_main',
'operator' => '==',
'value' => 'grid',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'portfolio_item_margin',
'label' => esc_html__( 'Margins between items', 'goya' ),
'section' => 'portfolio_main',
'priority' => 10,
'choices' => array(
'regular-padding' => esc_attr( 'Regular', 'goya' ),
'no-padding' => esc_attr( 'No Margins', 'goya' ),
),
'default' => 'regular-padding',
'required' => array(
array(
'setting' => 'portfolio_layout_main',
'operator' => '!=',
'value' => 'list',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'portfolio_list_alternate',
'label' => esc_html__( 'Alternate Columns', 'goya' ),
'description' => esc_html__( 'Alternate image/text columns in List view', 'goya' ),
'section' => 'portfolio_main',
'default' => 'true',
'priority' => 10,
'required' => array(
array(
'setting' => 'portfolio_layout_main',
'operator' => '==',
'value' => 'list',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'portfolio_main',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'portfolio_item_style',
'label' => esc_html__( 'Item Style', 'goya' ),
'description' => esc_html__( 'The style for posts in the main portfolio page', 'goya' ),
'section' => 'portfolio_main',
'priority' => 10,
'choices' => array(
'regular' => esc_attr__( 'Regular', 'goya' ),
'overlay' => esc_attr__( 'Overlay', 'goya' ),
'hover-card' => esc_attr__( 'Hover Card', 'goya' ),
),
'default' => 'regular',
'required' => array(
array(
'setting' => 'portfolio_layout_main',
'operator' => '!=',
'value' => 'list',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'select',
'settings' => 'portfolio_animation',
'label' => esc_html__( 'Item animation', 'goya' ),
'section' => 'portfolio_main',
'default' => 'animation bottom-to-top',
'priority' => 10,
'choices' => $goya_animations_list,
'required' => array(
array(
'setting' => 'portfolio_layout_main',
'operator' => '!=',
'value' => 'list',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'portfolio_main',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'portfolio_categories_nav',
'label' => esc_html__( 'Categories Navigation', 'goya' ),
'description' => esc_html__( 'List of portfolio categories on top', 'goya' ),
'section' => 'portfolio_main',
'default' => 'true',
'priority' => 10,
));
/* Single Portfolio */
Kirki::add_field( 'goya_config', array(
'type' => 'radio-image',
'settings' => 'portfolio_title_style',
'label' => esc_html__( 'Single Item Style', 'goya' ),
'description' => esc_html__( '1. Regular, 2. Featured Image Background, 3. Hero Title', 'goya' ),
'section' => 'portfolio_single',
'priority' => 10,
'choices' => array(
'regular' => get_template_directory_uri() . '/assets/img/admin/options/portfolio-single-regular.png',
'parallax' => get_template_directory_uri() . '/assets/img/admin/options/portfolio-single-parallax.png',
'hero' => get_template_directory_uri() . '/assets/img/admin/options/portfolio-single-hero.png',
),
'default' => 'parallax',
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'portfolio_single',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'portfolio_header_style',
'label' => esc_html__( 'Header Color mode', 'goya' ),
'section' => 'portfolio_single',
'default' => 'dark-title',
'priority' => 10,
'choices' => array(
'dark-title' => esc_attr__('Dark Text', 'goya'),
'light-title' => esc_attr__('Light Text', 'goya'),
),
'required' => array(
array(
'setting' => 'portfolio_title_style',
'operator' => '!=',
'value' => 'regular',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'portfolio_single',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'portfolio_transparent_header',
'label' => esc_html__( 'Single Portfolio Transparent Header', 'goya' ),
'description' => esc_html__( 'Used with Background Featured Media or Hero Title', 'goya' ),
'section' => 'portfolio_single',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'portfolio_title_style',
'operator' => '!=',
'value' => 'regular',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'portfolio_single',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'portfolio_navigation',
'label' => esc_html__( 'Previous/Next Links', 'goya' ),
'section' => 'portfolio_single',
'priority' => 10,
'choices' => array(
'' => esc_attr__( 'Disable', 'goya' ),
'simple' => esc_attr__( 'Simple', 'goya' ),
'image' => esc_attr__( 'Background Image', 'goya' ),
),
'default' => 'simple',
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'portfolio_single',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'portfolio_related',
'label' => esc_html__( 'Portfolio Related items', 'goya' ),
'section' => 'portfolio_single',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'portfolio_single',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'portfolio_footer',
'label' => esc_html__( 'Show Footer on Portfolios', 'goya' ),
'section' => 'portfolio_single',
'default' => false,
'priority' => 10,
));
} // End Portfolio Filter
/**
* SHOP
*/
/* General Settings */
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'shop_header_description',
'label' => esc_html__( 'Main Shop Intro text', 'goya' ),
'section' => 'shop_general',
'priority' => 10,
'default' => '',
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_general',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'shop_infinite_load',
'label' => esc_html__( 'Shop Pagination', 'goya' ),
'section' => 'shop_general',
'default' => 'button',
'priority' => 10,
'choices' => array(
'regular' => esc_attr__('Regular', 'goya'),
'button' => esc_attr__('Load More', 'goya'),
'scroll' => esc_attr__('Infinite', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_general',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_catalog_mode',
'label' => esc_html__( 'Catalog Mode', 'goya' ),
'description' => sprintf( '%s ',
esc_html__( '* Turn off the shopping functionality. All cart buttons and cart icon will be removed', 'goya' )
),
'section' => 'shop_general',
'default' => false,
'priority' => 10,
));
/* Shop Header */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_homepage_title_hide',
'label' => esc_html__( 'Hide main "Shop" title', 'goya' ),
'description' => esc_html__( 'Useful if the Shop is set as homepage', 'goya' ),
'section' => 'shop_header',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_header',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_categories_list',
'label' => esc_html__( 'Show Categories List', 'goya' ),
'section' => 'shop_header',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_categories_list_thumbnail',
'label' => esc_html__( 'Show Category Thumbnail', 'goya' ),
'section' => 'shop_header',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'shop_categories_list',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_header',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'shop_hero_title',
'label' => esc_html__( 'Shop Hero Title', 'goya' ),
'description' => esc_html__( 'Use hero title (big area with custom background) on:', 'goya' ),
'section' => 'shop_header',
'choices' => array(
'none' => esc_attr__('None', 'goya'),
'main-hero' => esc_attr__('Main Shop only', 'goya'),
'shop-hero' => esc_attr__('Product archives (shop, categories, search, tags, etc)', 'goya'),
'all-hero' => esc_attr__('All WooCommerce pages', 'goya'),
),
'default' => 'none',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_header',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'shop_hero_title',
'operator' => '!=',
'value' => 'none',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_transparent_header',
'label' => esc_html__( 'Transparent header', 'goya' ),
'description' => esc_html__( 'For all product archives if hero title is active', 'goya' ),
'section' => 'shop_header',
'default' => true,
'priority' => 10,
'required' => array(
array(
'setting' => 'shop_hero_title',
'operator' => '!=',
'value' => 'none',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_header',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'shop_hero_title',
'operator' => '!=',
'value' => 'none',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'shop_menu_color',
'label' => esc_html__( 'Header/Description color mode', 'goya' ),
'description' => esc_html__('You can change the color per category on the Category edit page', 'goya'),
'section' => 'shop_header',
'default' => 'dark-title',
'priority' => 10,
'choices' => array(
'dark-title' => esc_attr__('Dark Text', 'goya'),
'light-title' => esc_attr__('Light Text', 'goya'),
),
'required' => array(
array(
'setting' => 'shop_hero_title',
'operator' => '!=',
'value' => 'none',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'shop_header_bg_color',
'label' => esc_html__( 'Hero Color Background', 'goya' ),
'description' => esc_html__( 'It can be changed on each Category', 'goya' ),
'section' => 'shop_header',
'default' => '#f8f8f8',
'priority' => 10,
'required' => array(
array(
'setting' => 'shop_hero_title',
'operator' => '!=',
'value' => 'none',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_header',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'shop_hero_title',
'operator' => '!=',
'value' => 'none',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'image',
'settings' => 'shop_header_bg_image',
'label' => esc_html__( 'Hero Image Background', 'goya' ),
'description' => esc_html__( 'This image is only for the Main Shop page', 'goya' ),
'section' => 'shop_header',
'priority' => 10,
'default' => '',
'required' => array(
array(
'setting' => 'shop_hero_title',
'operator' => '!=',
'value' => 'none',
),
),
));
/* Products Listing */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '
' .esc_html__( 'Catalog Layout', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-image',
'settings' => 'shop_product_listing',
'label' => esc_html__( 'Product style', 'goya' ),
'section' => 'shop_listing',
'default' => 'style1',
'priority' => 10,
'choices' => array(
'style1' => get_template_directory_uri() . '/assets/img/admin/options/shop-style1.png',
'style2' => get_template_directory_uri() . '/assets/img/admin/options/shop-style2.png',
'style3' => get_template_directory_uri() . '/assets/img/admin/options/shop-style3.png',
'style4' => get_template_directory_uri() . '/assets/img/admin/options/shop-style4.png',
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_full_width',
'label' => esc_html__( 'Full-width catalog', 'goya' ),
'description' => esc_html__( 'No padding between content and left/right edges', 'goya' ),
'section' => 'shop_listing',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_product_img_hover',
'label' => esc_html__( 'Additional Image on Hover', 'goya' ),
'section' => 'shop_listing',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'multicheck',
'settings' => 'shop_addtocart_visible',
'label' => esc_html__( 'Add to Cart always visible', 'goya' ),
'description' => esc_html__( 'Keep the add to cart button always visible on', 'goya' ),
'section' => 'shop_listing',
'default' => array(),
'priority' => 10,
'multiple' => 1,
'choices' => array(
'mobile' => esc_attr__('Mobiles', 'goya'),
'desktop' => esc_attr__('Desktops (Product Style 1)', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '
' . esc_html__( 'Animations', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'select',
'settings' => 'shop_product_animation',
'label' => esc_html__( 'Load animation', 'goya' ),
'transport' => 'postMessage',
'section' => 'shop_listing',
'default' => 'animation bottom-to-top',
'priority' => 10,
'choices' => $goya_animations_list,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'select',
'settings' => 'shop_product_animation_hover',
'label' => esc_html__( 'Hover animation', 'goya' ),
'transport' => 'postMessage',
'section' => 'shop_listing',
'default' => 'zoom-jump',
'priority' => 10,
'choices' => array(
'' => esc_html__( 'None', 'goya' ),
'zoom' => esc_html__( 'Zoom', 'goya' ),
'jump' => esc_html__( 'Jump', 'goya' ),
'zoom-jump' => esc_html__( 'Zoom + Jump', 'goya' ),
),
'js_vars' => array(
array(
'element' => 'li.type-product .product-inner',
'function' => 'toggleClass',
'class' => 'hover-animation-zoom',
'value' => 'zoom',
),
array(
'element' => 'li.type-product .product-inner',
'function' => 'toggleClass',
'class' => 'hover-animation-jump',
'value' => 'jump',
),
array(
'element' => 'li.type-product .product-inner',
'function' => 'toggleClass',
'class' => 'hover-animation-zoom-jump',
'value' => 'zoom-jump',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '' .
esc_html__( 'View Modes', 'goya' ) . ' ' .
esc_html__( 'Grid View icon will appear automatically if you enable one of the following options', 'goya' ) .
'
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_view_small',
'label' => esc_html__( 'Small Grid icon', 'goya' ),
'description' => esc_html__( 'On large screens only', 'goya' ),
'transport' => 'postMessage',
'section' => 'shop_listing',
'default' => true,
'priority' => 10,
'js_vars' => array(
array(
'element' => '.shop-views',
'function' => 'toggleClass',
'class' => 'small-1',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_view_list',
'label' => esc_html__( 'List View icon', 'goya' ),
'transport' => 'postMessage',
'section' => 'shop_listing',
'default' => true,
'priority' => 10,
'js_vars' => array(
array(
'element' => '.shop-views',
'function' => 'toggleClass',
'class' => 'list-1',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '
' .esc_html__( 'Elements', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_sale_flash',
'label' => esc_html__( '"Sale" Flash Badge', 'goya' ),
'section' => 'shop_listing',
'default' => 'pct',
'priority' => 10,
'choices' => array(
'disabled' => esc_attr__('Disabled', 'goya'),
'txt' => esc_attr__('Text', 'goya'),
'pct' => esc_attr__('Percentage', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_new_badge',
'label' => esc_html__( '"New" Badge', 'goya' ),
'description' => esc_html__( 'Show "New" badge on recent products', 'goya' ),
'section' => 'shop_listing',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'new_badge_duration',
'label' => esc_html__( 'Days to show "New" badge', 'goya' ),
'section' => 'shop_listing',
'default' => 5,
'priority' => 10,
'choices' => array(
'min' => 1,
'max' => 30,
'step' => 1
),
'required' => array(
array(
'setting' => 'product_new_badge',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_outofstock_badge',
'label' => esc_html__( '"Out of Stock" Badge', 'goya' ),
'description' => esc_html__( 'Show "Out of Stock" badge on the catalog', 'goya' ),
'section' => 'shop_listing',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_listing',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'rating_listing',
'label' => esc_html__( 'Rating in Catalog', 'goya' ),
'section' => 'shop_listing',
'default' => false,
'priority' => 10,
));
/* Product Filters */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_filters',
'default' => '
' .esc_html__( 'Sidebar/Filters', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_filters',
'label' => esc_html__( 'Enable Sidebar/Filters', 'goya' ),
'description' => esc_html__( 'It can display other widgets but it\'s intended for filters', 'goya' ),
'section' => 'shop_filters',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_filters',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-image',
'settings' => 'shop_filter_position',
'label' => esc_html__( 'Shop Filters Position', 'goya' ),
'description' => esc_html__( '1.Top, 2.Sidebar, 3.Off-canvas', 'goya' ),
'section' => 'shop_filters',
'default' => 'header',
'priority' => 10,
'choices' => array(
'header' => get_template_directory_uri() . '/assets/img/admin/options/filter-top.png',
'sidebar' => get_template_directory_uri() . '/assets/img/admin/options/filter-side.png',
'popup' => get_template_directory_uri() . '/assets/img/admin/options/filter-offcanvas.png',
),
/*'required' => array(
array(
'setting' => 'shop_filters',
'operator' => '==',
'value' => true,
),
),*/
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_filters',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'shop_filter_position',
'operator' => '==',
'value' => 'sidebar',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'shop_filters_sidebar_width',
'label' => esc_html__( 'Max width of side bar', 'goya' ),
'transport' => 'auto',
'section' => 'shop_filters',
'default' => 350,
'priority' => 10,
'choices' => array(
'min' => 200,
'max' => 400,
'step' => 1
),
'required' => array(
/*array(
'setting' => 'shop_filters',
'operator' => '==',
'value' => true,
),*/
array(
'setting' => 'shop_filter_position',
'operator' => '==',
'value' => 'sidebar',
),
),
'output' => array(
array(
'element' => array('.shop-sidebar-col'),
'property' => 'max-width',
'units' => 'px',
'media_query' => '@media all and (min-width:992px)'
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'shop_filters_columns',
'label' => esc_html__( 'Number of Filter Columns', 'goya' ),
'section' => 'shop_filters',
'default' => 4,
'priority' => 10,
'choices' => array(
'min' => 1,
'max' => 6,
'step' => 1
),
/* 'required' => array(
array(
'setting' => 'shop_filters',
'operator' => '==',
'value' => true,
),
array(
'setting' => 'shop_filter_position',
'operator' => '==',
'value' => 'header',
),
),*/
'required' => array(
array(
'setting' => 'shop_filter_position',
'operator' => '==',
'value' => 'header',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_filters',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_sidebar_sticky',
'label' => esc_html__( 'Sidebar Sticky', 'goya' ),
'description' => esc_html__( 'Keep the sidebar fixed while scrolling', 'goya' ),
'section' => 'shop_filters',
'default' => true,
'priority' => 10,
'required' => array(
/*array(
'setting' => 'shop_filters',
'operator' => '==',
'value' => true,
),*/
array(
'setting' => 'shop_filter_position',
'operator' => '==',
'value' => 'sidebar',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_filters',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_filters_scrollbar',
'label' => esc_html__( 'Filters Scrollbar', 'goya' ),
'description' => esc_html__( 'Disable if you are using a 3rd party plugin with its own scrolling options', 'goya' ),
'section' => 'shop_filters',
'default' => true,
'priority' => 10,
/*'required' => array(
array(
'setting' => 'shop_filters',
'operator' => '==',
'value' => true,
),
),*/
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'shop_filters_height',
'label' => esc_html__( 'Scrollbar Max Height ', 'goya' ),
'section' => 'shop_filters',
'default' => 150,
'priority' => 10,
'choices' => array(
'min' => 40,
'max' => 300,
'step' => 1
),
'required' => array(
/*array(
'setting' => 'shop_filters',
'operator' => '==',
'value' => true,
),*/
array(
'setting' => 'shop_filters_scrollbar',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_filters',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'shop_filters_sidebar_position',
'label' => esc_html__( 'Sidebar Position', 'goya' ),
'section' => 'shop_filters',
'default' => 'left',
'priority' => 10,
'choices' => array(
'left' => esc_attr__( 'Left', 'goya' ),
'right' => esc_attr__( 'Right', 'goya' ),
),
'required' => array(
/*array(
'setting' => 'shop_filters',
'operator' => '==',
'value' => true,
),*/
array(
'setting' => 'shop_filter_position',
'operator' => '==',
'value' => 'sidebar',
),
),
));
if ( class_exists('Woo_Variation_Swatches') ) {
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_variations',
'default' => '' .
esc_html__( 'Variations', 'goya' ) . ' ' .
esc_html__( 'If you have "WooCommerce Variation Swatches PRO" go to the plugin settings to enable the option.', 'goya' ) .
'
',
'priority' => 10,
));
if (!class_exists('Woo_Variation_Swatches_Pro') ) {
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'archive_show_swatches',
'label' => esc_html__( 'Display color/image swatches', 'goya' ),
'description' => esc_html__( 'For catalog pages', 'goya' ),
'section' => 'shop_variations',
'default' => false,
'priority' => 10,
));
if ( 'yes' == get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'archive_check_variants_stock',
'label' => esc_html__( 'Check variations stock', 'goya' ),
'description' => sprintf( '%s ',
esc_html__( '* Warning: For small catalogs only, it may slow down your site otherwise', 'goya' )
),
'section' => 'shop_variations',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'archive_show_swatches',
'operator' => '==',
'value' => true,
),
),
));
}
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'archive_show_all_variants',
'label' => esc_html__( 'Display all variations', 'goya' ),
'description' => esc_attr__( 'Display all variations, not just color/image swatches.', 'goya' ),
'section' => 'shop_variations',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'archive_show_swatches',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_variations',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'archive_swatches_position',
'label' => esc_html__( 'Swatches position on desktops', 'goya' ),
'description' => esc_html__( 'For product style 1 and 2 only', 'goya' ),
'transport' => 'postMessage',
'section' => 'shop_variations',
'default' => 'bottom',
'priority' => 10,
'choices' => array(
'bottom' => esc_attr__('Bottom', 'goya'),
'side' => esc_attr__('Side', 'goya')
),
'required' => array(
array(
'setting' => 'archive_show_swatches',
'operator' => '==',
'value' => true,
),
array(
'setting' => 'archive_show_all_variants',
'operator' => '!=',
'value' => true,
),
array(
'setting' => 'shop_product_listing',
'operator' => 'contains',
'value' => array('style1', 'style2'),
),
),
));
}
}
/* Minicart */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'minicart_panel',
'default' => '
' .esc_html__( 'Mini Cart', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'header_cart_icon_function',
'label' => esc_html__( 'Cart icon action', 'goya' ),
'description' => esc_html__( 'What will the cart icon do on click?', 'goya' ),
'transport' => 'postMessage',
'section' => 'minicart_panel',
'default' => 'mini-cart',
'priority' => 10,
'choices' => array(
'mini-cart' => esc_attr__('Open Minicart', 'goya'),
'cart-page' => esc_attr__('Go to Cart page', 'goya')
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'minicart_panel',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'open_minicart_automatically',
'label' => esc_html__( 'Open minicart automatically', 'goya' ),
'description' => esc_html__( 'The minicart will open automatically when a product is added to cart ', 'goya' ),
'section' => 'minicart_panel',
'default' => true,
'priority' => 10,
'required' => array(
array(
'setting' => 'header_cart_icon_function',
'operator' => '==',
'value' => 'mini-cart'
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'minicart_panel',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'header_cart_icon',
'label' => esc_html__( 'Icon type', 'goya' ),
'description' => esc_html__( 'Check in the Customizer: Header > Header Layout. It will be also used for \'add to cart\' buttons', 'goya' ),
'transport' => 'postMessage',
'section' => 'minicart_panel',
'default' => 'bag',
'priority' => 10,
'choices' => array(
'cart' => esc_attr__('Cart', 'goya'),
'bag' => esc_attr__('Bag', 'goya')
),
'partial_refresh' => array(
'header_cart_icon_partial' => array(
'selector' => '.quick_cart',
'container_inclusive' => true,
'render_callback' => function() {
get_template_part( 'inc/templates/header-parts/cart' );
},
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'minicart_panel',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-image',
'settings' => 'header_cart_position',
'label' => esc_html__( 'Cart Open Position', 'goya' ),
'transport' => 'postMessage',
'section' => 'minicart_panel',
'default' => 'side',
'priority' => 10,
'choices' => array(
'side' => get_template_directory_uri() . '/assets/img/admin/options/cart-side.png',
'top' => get_template_directory_uri() . '/assets/img/admin/options/cart-top.png',
),
'required' => array(
array(
'setting' => 'header_cart_icon_function',
'operator' => '==',
'value' => 'mini-cart'
)
),
'js_vars' => array(
array(
'element' => '#side-cart',
'function' => 'toggleClass',
'class' => 'top',
'value' => 'top',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'header_cart_color',
'label' => esc_html__( 'Cart Panel Color Scheme', 'goya' ),
'transport' => 'postMessage',
'section' => 'minicart_panel',
'default' => 'light',
'priority' => 10,
'choices' => array(
'light' => esc_attr__('Light', 'goya'),
'dark' => esc_attr__('Dark', 'goya')
),
'required' => array(
array(
'setting' => 'header_cart_icon_function',
'operator' => '==',
'value' => 'mini-cart'
)
),
'js_vars' => array(
array(
'element' => '#side-cart',
'function' => 'toggleClass',
'class' => 'dark',
'value' => 'dark',
),
),
));
/* Catalog Quick View */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_quickview',
'label' => esc_html__( 'Show Quick View', 'goya' ),
'section' => 'shop_quickview',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_quickview',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'product_quickview_width',
'label' => esc_html__( 'Quick View max-width', 'goya' ),
'transport' => 'auto',
'section' => 'shop_quickview',
'default' => 960,
'priority' => 10,
'choices' => array (
'min' => 910,
'max' => 1160,
'step' => 50
),
'required' => array(
array(
'setting' => 'product_quickview',
'operator' => '==',
'value' => true,
),
),
'output' => array(
array(
'element' => '.mfp #et-quickview',
'property' => 'max-width',
'units' => 'px',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_quickview',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_quickview_summary_layout',
'label' => esc_html__( 'Product Summary Alignment', 'goya' ),
'description' => esc_html__( 'Bottom works better when your images are taller', 'goya' ),
'transport' => 'postMessage',
'section' => 'shop_quickview',
'default' => 'align-top',
'priority' => 10,
'choices' => array(
'align-top' => esc_attr__( 'Top', 'goya' ),
'align-bottom' => esc_attr__( 'Bottom', 'goya' ),
),
'required' => array(
array(
'setting' => 'product_quickview',
'operator' => '==',
'value' => true,
),
),
'js_vars' => array(
array(
'element' => '.et-qv-summary-content',
'function' => 'toggleClass',
'class' => 'align-top',
'value' => 'align-top',
),
array(
'element' => '.et-qv-summary-content',
'function' => 'toggleClass',
'class' => 'align-bottom',
'value' => 'align-bottom',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_quickview',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_quickview_atc',
'label' => esc_html__( 'Display add-to-cart button', 'goya' ),
'section' => 'shop_quickview',
'default' => true,
'priority' => 10,
'required' => array(
array(
'setting' => 'product_quickview',
'operator' => '==',
'value' => true,
),
),
));
/* Checkout */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'checkout',
'default' => '
' .esc_html__( 'Cart', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shopping_cart_auto_update',
'label' => esc_html__( 'Auto update Cart', 'goya' ),
'description' => esc_html__( 'Auto update cart on quantity change. "Update" button will remain hidden.', 'goya' ),
'section' => 'checkout',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shopping_cart_empty_cart',
'label' => esc_html__( 'Empty Cart button', 'goya' ),
'description' => esc_html__( 'Button to remove all products from the cart.', 'goya' ),
'section' => 'checkout',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'checkout',
'default' => '
' .esc_html__( 'Checkout', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'checkout_style',
'label' => esc_html__( 'Checkout mode', 'goya' ),
'description' => esc_html__( '"Distraction Free" removes header and footer on checkout page.', 'goya' ),
'section' => 'checkout',
'default' => 'free',
'priority' => 10,
'choices' => array(
'free' => esc_attr__('Distraction Free', 'goya'),
'regular' => esc_attr__('Classic', 'goya')
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'checkout',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'checkout_terms_popup',
'label' => esc_html__( 'Terms & Conditions Lightbox', 'goya' ),
'description' => esc_html__( 'Display Terms & Conditions in Lightbox', 'goya' ),
'section' => 'checkout',
'default' => true,
'priority' => 10,
));
/* Progress Bar */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'progress_bar_enable',
'label' => esc_html__( 'Enable progress bar', 'goya' ),
'description' => esc_html__( 'Show a progress bar on the defined locations', 'goya' ),
'section' => 'shop_progress_bar',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'default' => '
',
'section' => 'shop_progress_bar',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'multicheck',
'settings' => 'progress_bar_locations',
'label' => esc_html__( 'Locations', 'goya' ),
'description' => esc_html__( 'Choose at least 1', 'goya' ),
'section' => 'shop_progress_bar',
'default' => array('minicart'),
'priority' => 10,
'multiple' => 1,
'choices' => array(
'minicart' => esc_attr__('Mini Cart', 'goya'),
'cart' => esc_attr__('Cart page', 'goya'),
'single-product' => esc_attr__('Single product', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_progress_bar',
'default' => '' .
esc_html__( 'Amount', 'goya' ) . ' ' .
esc_html__( 'This option is completely manual and not connected to Shipping methods', 'goya' ) .
'
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'number',
'settings' => 'progress_bar_goal',
'label' => esc_html__( 'Goal amount', 'goya' ),
'description' => esc_html__( 'Amount to reach 100%', 'goya' ),
'section' => 'shop_progress_bar',
'default' => 0,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_progress_bar',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'progress_bar_subtotal_taxes',
'label' => esc_html__( 'Apply taxes', 'goya' ),
'description' => esc_html__( 'Calculate subtotal with taxes', 'goya' ),
'section' => 'shop_progress_bar',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_progress_bar',
'default' => '
' .esc_html__( 'Messages', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'progress_bar_msg',
'label' => esc_html__( 'Initial Message', 'goya' ),
'description' => esc_html__( 'Message to show before reaching the goal. Use shortcode [missing_amount] to display the amount left to reach the minimum', 'goya' ),
'section' => 'shop_progress_bar',
'priority' => 10,
'default' => 'Add [missing_amount] more to get Free Shipping! ',
));
Kirki::add_field( 'goya_config', array(
'type' => 'editor',
'settings' => 'progress_bar_success_msg',
'label' => esc_html__( 'Success message', 'goya' ),
'description' => esc_html__( 'Message to show after reaching 100%.', 'goya' ),
'section' => 'shop_progress_bar',
'priority' => 10,
'default' => 'You\'ve got free shipping! ',
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_progress_bar',
'default' => '
' .esc_html__( 'Colors', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'progress_bar_color',
'label' => esc_html__( 'Progress bar color', 'goya' ),
'transport' => 'auto',
'section' => 'shop_progress_bar',
'default' => '#b9a16b',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'progress_bar_success_color',
'label' => esc_html__( 'Progress bar success color', 'goya' ),
'label' => esc_html__( 'Color after reaching 100%', 'goya' ),
'transport' => 'auto',
'section' => 'shop_progress_bar',
'default' => '#67bb67',
'priority' => 10,
));
/* Shop Mobile */
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'shop_columns_mobile',
'label' => esc_html__( 'Columns in catalog', 'goya' ),
'section' => 'shop_mobile',
'default' => 2,
'priority' => 10,
'choices' => array (
'min' => 1,
'max' => 2,
'step' => 1
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_mobile',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_sticky_filters',
'label' => esc_html__( 'Fix filters bar to bottom', 'goya' ),
'transport' => 'postMessage',
'section' => 'shop_mobile',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'shop_filters',
'operator' => '==',
'value' => true,
),
),
'js_vars' => array(
array(
'element' => '.shop-filters',
'function' => 'toggleClass',
'class' => 'sticky-filters',
'value' => true,
),
),
));
/**
* PRODUCT PAGE
*/
/* Product Page */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_layout',
'default' => '
' .esc_html__( 'Main Layout', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-image',
'settings' => 'product_layout_single',
'label' => esc_html__( 'Product Page Layout', 'goya' ),
'description' => esc_html__( '1.Regular, 2.Showcase, 3.No Padding, 4.Full Width', 'goya' ),
'section' => 'product_layout',
'default' => 'regular',
'priority' => 10,
'choices' => array(
'regular' => get_template_directory_uri() . '/assets/img/admin/options/product-regular.png',
'showcase' => get_template_directory_uri() . '/assets/img/admin/options/product-showcase.png',
'no-padding' => get_template_directory_uri() . '/assets/img/admin/options/product-nopadding.png',
'full-width' => get_template_directory_uri() . '/assets/img/admin/options/product-fullwidth.png',
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_layout',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_transparent_header',
'label' => esc_html__( 'Transparent Header', 'goya' ),
'description' => esc_html__( 'Always transparent in Showcase mode.', 'goya' ),
'section' => 'product_layout',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_header_color',
'label' => esc_html__( 'Product header mode', 'goya' ),
'section' => 'product_layout',
'default' => 'dark-title',
'priority' => 10,
'choices' => array(
'dark-title' => esc_attr__('Dark Text', 'goya'),
'light-title' => esc_attr__('Light Text', 'goya'),
),
'required' => array(
array(
'setting' => 'product_transparent_header',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_layout',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_title_position',
'label' => esc_html__( 'Title Position', 'goya' ),
'section' => 'product_layout',
'default' => 'right',
'priority' => 10,
'choices' => array(
'right' => esc_attr__('Right', 'goya'),
'top' => esc_attr__('Top', 'goya'),
),
'required' => array(
array(
'setting' => 'product_layout_single',
'operator' => '!=',
'value' => 'no-padding'
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_layout',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'single_product_background',
'label' => esc_html__( 'Product Info Background', 'goya' ),
'section' => 'product_layout',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'single_product_background_color',
'label' => esc_html__( 'Info Background Color', 'goya' ),
'description' => esc_html__( 'This is the global value. You can change the color individually on each product', 'goya' ),
'section' => 'product_layout',
'default' => '#f8f8f8',
'priority' => 10,
'required' => array(
array(
'setting' => 'single_product_background',
'operator' => '==',
'value' => true
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_showcase_style',
'label' => esc_html__( 'Info Text Color', 'goya' ),
'section' => 'product_layout',
'default' => 'dark-text',
'priority' => 10,
'choices' => array(
'dark-text' => esc_attr__('Dark Text', 'goya'),
'light-text' => esc_attr__('Light Text', 'goya'),
),
'required' => array(
array(
'setting' => 'single_product_background',
'operator' => '==',
'value' => true
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_layout',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'product_layout_single',
'operator' => '==',
'value' => 'showcase'
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_showcase_fixed',
'label' => esc_html__( 'Fixed options/buttons', 'goya' ),
'description' => esc_html__( 'Fix cart button and options to the bottom in "Showcase" layout.', 'goya' ),
'section' => 'product_layout',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'product_layout_single',
'operator' => '==',
'value' => 'showcase'
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_layout',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_variations_style',
'label' => esc_html__( 'Product variation style', 'goya' ),
'section' => 'product_layout',
'default' => 'table',
'priority' => 10,
'choices' => array(
'table' => esc_attr__('Table', 'goya'),
'vertical' => esc_attr__('Vertical', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_layout',
'default' => '
' .esc_html__( 'Product Details', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'product_details_style',
'label' => esc_html__( 'Product Details Mode', 'goya' ),
'description' => esc_html__( 'WooCommerce default is Tabs.', 'goya' ),
'section' => 'product_layout',
'default' => 'tabs',
'priority' => 10,
'choices' => array(
'tabs' => esc_attr__('Tabs', 'goya'),
'accordion' => esc_attr__('Accordion (next to product gallery)', 'goya'),
'vertical' => esc_attr__('Vertical', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_layout',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'product_details_style',
'operator' => '==',
'value' => 'accordion'
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_accordion_swap_description',
'label' => esc_html__( 'Swap short/full description', 'goya' ),
'description' => esc_html__( 'Add short description to the accordion and move full description below the product details. ', 'goya' ),
'section' => 'product_layout',
'default' => true,
'priority' => 10,
'required' => array(
array(
'setting' => 'product_details_style',
'operator' => '==',
'value' => 'accordion'
)
)
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_accordion_scrollbars',
'label' => esc_html__( 'Accordion scrollbars', 'goya' ),
'description' => esc_html__( 'Set maximum height and make accordion sections scrollable', 'goya' ),
'section' => 'product_layout',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'product_details_style',
'operator' => '==',
'value' => 'accordion'
)
)
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'product_accordion_max_height',
'label' => esc_html__( 'Scrollbar Max Height', 'goya' ),
'description' => esc_html__( 'The maximum height for accordion sections', 'goya' ),
'section' => 'product_layout',
'default' =>300,
'priority' => 10,
'choices' => array(
'min' => 50,
'max' => 500,
'step' => 5
),
'required' => array(
array(
'setting' => 'product_details_style',
'operator' => '==',
'value' => 'accordion'
),
array(
'setting' => 'product_accordion_scrollbars',
'operator' => '==',
'value' => true
)
)
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_short_desc_open',
'label' => esc_html__( 'Open first section on page load', 'goya' ),
'section' => 'product_layout',
'default' => true,
'priority' => 10,
'required' => array(
array(
'setting' => 'product_details_style',
'operator' => '==',
'value' => 'accordion'
)
)
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_layout',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_description_layout',
'label' => esc_html__( 'Description Layout', 'goya' ),
'description' => esc_html__( 'Use "Full Width" if you plan to use Page Builder for edge to edge descriptions. You can change the layout on each product too.', 'goya' ),
'section' => 'product_layout',
'default' => 'boxed',
'priority' => 10,
'choices' => array(
'boxed' => esc_attr__('Boxed', 'goya'),
'full' => esc_attr__('Full Width', 'goya'),
),
));
/* Product Gallery */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_gallery',
'default' => '
' .esc_html__( 'Gallery Layout', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-image',
'settings' => 'product_gallery_style',
'label' => esc_html__( 'Product Gallery Style', 'goya' ),
'description' => esc_html__( '1.Slider, 2. Column, 3. Grid. On mobiles it\'s always slider', 'goya' ),
'transport' => 'postMessage',
'section' => 'product_gallery',
'default' => 'carousel',
'priority' => 10,
'choices' => array(
'carousel' => get_template_directory_uri() . '/assets/img/admin/options/product-gallery-carousel.png',
'column' => get_template_directory_uri() . '/assets/img/admin/options/product-gallery-column.png',
'grid' => get_template_directory_uri() . '/assets/img/admin/options/product-gallery-grid.png',
),
'js_vars' => array(
array(
'element' => '.et-product-detail',
'function' => 'toggleClass',
'class' => 'et-product-gallery-carousel',
'value' => 'carousel',
),
array(
'element' => '.et-product-detail',
'function' => 'toggleClass',
'class' => 'et-product-gallery-column',
'value' => 'column',
),
array(
'element' => '.et-product-detail',
'function' => 'toggleClass',
'class' => 'et-product-gallery-grid',
'value' => 'grid',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_gallery',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'product_layout_single',
'operator' => '!=',
'value' => 'full-width'
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'product_gallery_width',
'label' => esc_html__( 'Gallery width ratio', 'goya' ),
'description' => esc_html__( 'In a grid of 12 columns. Default 7/12', 'goya' ),
'transport' => 'auto',
'section' => 'product_gallery',
'default' => 7,
'priority' => 10,
'choices' => array(
'min' => 5,
'max' => 8,
'step' => 1
),
'required' => array(
array(
'setting' => 'product_layout_single',
'operator' => '!=',
'value' => 'full-width'
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_gallery',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_gallery_transition',
'label' => esc_html__( 'Gallery Image Transition', 'goya' ),
'description' => esc_html__( 'Image transition with carousel gallery and mobiles', 'goya' ),
'section' => 'product_gallery',
'default' => 'slide',
'priority' => 10,
'choices' => array(
'fade' => esc_attr__( 'Fade', 'goya' ),
'slide' => esc_attr__( 'Slide', 'goya' ),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_gallery',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_sticky_section',
'label' => esc_html__( 'Sticky Section', 'goya' ),
'description' => esc_html__( 'SHORTER section to keep sticky. Automatically set to Summary with Grid or Column gallery', 'goya' ),
'section' => 'product_gallery',
'default' => 'summary',
'priority' => 10,
'choices' => array(
'gallery' => esc_attr__('Gallery', 'goya'),
'summary' => esc_attr__('Summary', 'goya'),
'none' => esc_attr__('Disable', 'goya'),
),
'required' => array(
array(
'setting' => 'product_layout_single',
'operator' => '!=',
'value' => 'full-width'
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_gallery',
'default' => '
' .esc_html__( 'Thumbnails', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'product_thumbnails_position',
'label' => esc_html__( 'Desktop Thumbnails Position', 'goya' ),
'transport' => 'postMessage',
'section' => 'product_gallery',
'default' => 'side',
'priority' => 10,
'required' => array(
array(
'setting' => 'product_gallery_style',
'operator' => '==',
'value' => 'carousel'
)
),
'choices' => array(
'side' => esc_attr__( 'Side', 'goya' ),
'bottom' => esc_attr__( 'Bottom', 'goya' ),
),
'js_vars' => array(
array(
'element' => '.et-product-detail',
'function' => 'toggleClass',
'class' => 'thumbnails-vertical',
'value' => 'side',
),
array(
'element' => '.et-product-detail',
'function' => 'toggleClass',
'class' => 'thumbnails-horizontal',
'value' => 'bottom',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_gallery',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_thumbnails_swap_hover',
'label' => esc_html__( 'Swap images on hover', 'goya' ),
'description' => esc_html__( 'Don\'t need to click on the thumbnails', 'goya' ),
'section' => 'product_gallery',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'product_gallery_style',
'operator' => '==',
'value' => 'carousel'
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_gallery',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_image_lightbox',
'label' => esc_html__( 'Product Image Lightbox', 'goya' ),
'section' => 'product_gallery',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_gallery',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_image_hover_zoom',
'label' => esc_html__( 'Product Image Zoom', 'goya' ),
'section' => 'product_gallery',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_gallery',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'featured_video',
'label' => esc_html__( 'Video link position', 'goya' ),
'section' => 'product_gallery',
'default' => 'gallery',
'priority' => 10,
'choices' => array(
'gallery' => esc_attr__( 'Icon in gallery', 'goya' ),
'summary' => esc_attr__( 'Product summary', 'goya' ),
),
));
/* Product Elements */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_single_ajax_addtocart',
'label' => esc_html__( 'Ajax Add to Cart', 'goya' ),
'description' => esc_html__( 'Enable Ajax on single product page', 'goya' ),
'section' => 'product_elements',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_elements',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_cart_buttons_layout',
'label' => esc_html__( 'Quantity / Add to Cart layout', 'goya' ),
'description' => esc_html__( 'Some 3rd party plugins may be incompatible with Horizontal or Mixed layout', 'goya' ),
'description' => sprintf( '%s ',
esc_html__( 'Some 3rd party plugins may be incompatible with Horizontal or Mixed layout', 'goya' )
),
'section' => 'product_elements',
'default' => 'mixed',
'priority' => 10,
'choices' => array(
'stacked' => esc_attr__('Classic', 'goya'),
'horizontal' => esc_attr__('Horizontal', 'goya'),
'mixed' => esc_attr__('Mixed', 'goya'),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_elements',
'default' => '
' .esc_html__( 'Sticky Bar', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_sticky_bar',
'label' => esc_html__( 'Sticky Product Bar', 'goya' ),
'description' => esc_html__( 'Show product image, name and cart button while scrolling', 'goya' ),
'section' => 'product_elements',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_sticky_bar_position',
'label' => esc_html__( 'Product Bar Position', 'goya' ),
'transport' => 'postMessage',
'section' => 'product_elements',
'default' => 'top',
'priority' => 10,
'choices' => array(
'top' => esc_attr__('Top', 'goya'),
'bottom' => esc_attr__('Bottom', 'goya')
),
'required' => array(
array(
'setting' => 'product_sticky_bar',
'operator' => '==',
'value' => true,
),
),
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'fixed-product-bar-bottom',
'value' => 'bottom',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_elements',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'product_sticky_bar',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_sticky_bar_trigger_only',
'label' => esc_html__( 'Sticky Add to Cart - button only', 'goya' ),
'description' => esc_html__( 'A single button for variable products, no variations on the sticky bar. Useful for compatiblity with 3rd party plugins or if you have a lot of variations', 'goya' ),
'section' => 'product_elements',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'product_sticky_bar',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_elements',
'default' => '
',
'priority' => 10,
'required' => array(
array(
'setting' => 'product_sticky_bar',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_sticky_bar_mobile',
'label' => esc_html__( 'Sticky Add to Cart (mobiles)', 'goya' ),
'description' => esc_html__( 'Show add to cart button fixed at the bottom on mobiles', 'goya' ),
'section' => 'product_elements',
'default' => false,
'priority' => 10,
'required' => array(
array(
'setting' => 'product_sticky_bar',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_elements',
'default' => '
' .esc_html__( 'Other Elements', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_breadcrumbs',
'label' => esc_html__( 'Breadcrumbs', 'goya' ),
'section' => 'product_elements',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_elements',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_meta_sku',
'label' => esc_html__( 'SKU', 'goya' ),
'section' => 'product_elements',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_meta_categories',
'label' => esc_html__( 'Categories', 'goya' ),
'section' => 'product_elements',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_meta_tags',
'label' => esc_html__( 'Tags', 'goya' ),
'description' => esc_html__( 'Deactivate the 3 options (SKU, Categories, Tags) to completely remove the Meta section', 'goya' ),
'section' => 'product_elements',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_elements',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_share_buttons',
'label' => esc_html__( 'Share Buttons', 'goya' ),
'section' => 'product_elements',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_elements',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_reviews',
'label' => esc_html__( 'Reviews & Ratings', 'goya' ),
'section' => 'product_elements',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_elements',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'single_product_sale_flash',
'label' => esc_html__( 'Single product "Sale" badge', 'goya' ),
'section' => 'product_elements',
'default' => true,
'priority' => 10,
));
/* Size Guide */
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_size_guide',
'label' => esc_html__( 'Enable Size Guide', 'goya' ),
'description' => esc_html__( 'You can override this setting on each product', 'goya' ),
'section' => 'product_size',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_size',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'dropdown-pages',
'settings' => 'product_size_page',
'label' => esc_html__( 'Size Guide Page', 'goya' ),
'description' => esc_html__( 'Select the page containing your Size Guide.', 'goya' ),
'section' => 'product_size',
'priority' => 10,
'default' => '',
'required' => array(
array(
'setting' => 'product_size_guide',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_size',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_size_variable',
'label' => esc_html__( 'Variable Products only', 'goya' ),
'description' => esc_html__( 'Show the Size Guide on variable products only', 'goya' ),
'section' => 'product_size',
'default' => true,
'priority' => 10,
'required' => array(
array(
'setting' => 'product_size_guide',
'operator' => '==',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_size',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'product_size_apply',
'label' => esc_html__( 'Apply to', 'goya' ),
'section' => 'product_size',
'default' => 'all',
'priority' => 10,
'choices' => array(
'all' => esc_attr__('All Categories', 'goya'),
'custom' => esc_attr__('Select Categories', 'goya'),
),
'required' => array(
array(
'setting' => 'product_size_guide',
'operator' => '==',
'value' => true,
),
),
));
add_action( 'init', 'add_events_categories_customizer_control', 12 );
function add_events_categories_customizer_control() {
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
Kirki::add_field( 'goya_config', array(
'type' => 'multicheck',
'settings' => 'product_size_categories',
'label' => esc_html__( 'Select Categories', 'goya' ),
'section' => 'product_size',
'default' => '',
'priority' => 11,
'multiple' => 1,
'choices' => Kirki_Helper::get_terms( array( 'taxonomy' => 'product_cat' ) ),
'required' => array(
array(
'setting' => 'product_size_guide',
'operator' => '==',
'value' => true,
),
array(
'setting' => 'product_size_apply',
'operator' => '==',
'value' => 'custom',
),
),
));
}
/* Related Products*/
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'related_products',
'label' => esc_html__( 'Show Related Products', 'goya' ),
'section' => 'product_related',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_related',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'upsell_products',
'label' => esc_html__( 'Show Up-sell Products', 'goya' ),
'description' => esc_html__( 'When they have been defined', 'goya' ),
'section' => 'product_related',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_related',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'product_upsell_related_per_page',
'label' => esc_html__( 'Up-sell/related Products per page', 'goya' ),
'section' => 'product_related',
'default' => 4,
'priority' => 10,
'choices' => array (
'min' => 2,
'max' => 12,
'step' => 1
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_related',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'product_upsell_related_columns',
'label' => esc_html__( 'Up-sell/related product columns', 'goya' ),
'section' => 'product_related',
'default' => 4,
'priority' => 10,
'choices' => array (
'min' => 2,
'max' => 6,
'step' => 1
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'product_related',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'product_upsell_related_slider',
'label' => esc_html__( 'Up-sell/related as carousel', 'goya' ),
'section' => 'product_related',
'default' => true,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio',
'settings' => 'product_thumbnails_mobile',
'label' => esc_html__( 'Product Gallery Thumbnails', 'goya' ),
'description' => esc_html__( 'Show gallery thumbnails on mobiles?', 'goya' ),
'section' => 'product_mobile',
'default' => 'dots',
'priority' => 10,
'choices' => array(
'thumbs' => esc_attr__( 'Show Thumbnails', 'goya' ),
'dots' => esc_attr__( 'Only dots', 'goya' ),
),
));
/**
* STYLING
*/
/* Global Colors */
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'accent_color',
'label' => esc_html__( 'Accent Color', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#b9a16b',
'priority' => 10,
'output' => array(
array(
'element' => '.mfp-wrap.quick-search .mfp-content [type="submit"], .et-close, .single-product .pswp__button:hover, .content404 h4, .woocommerce-tabs .tabs li a span, .woo-variation-gallery-wrapper .woo-variation-gallery-trigger:hover:after, .mobile-menu li.menu-item-has-children.active > .et-menu-toggle:after, .remove:hover, a.remove:hover, .minicart-counter.et-count-zero, .tag-cloud-link .tag-link-count, .wpmc-tabs-wrapper li.wpmc-tab-item.current, div.argmc-wrapper .tab-completed-icon:before, .et-wp-gallery-popup .mfp-arrow',
'property' => 'color',
),
array(
'element' => '.slick-dots li.slick-active button',
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'styling',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'main_font_color',
'label' => esc_html__( 'Body Text Color', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#686868',
'priority' => 10,
'output' => array(
array(
'element' => 'body, table, .shop_table, blockquote cite, .et-listing-style1 .product_thumbnail .et-quickview-btn, .products .single_add_to_cart_button.button, .products .add_to_cart_button.button, .products .added_to_cart.button, .side-panel header h6',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'darker_font_color',
'label' => esc_html__( 'Darker Text Color', 'goya' ),
'description' => esc_html__( 'Elements with slighly darker color than body text.', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#282828',
'priority' => 10,
'output' => array(
array(
'element' => '.cart-collaterals .woocommerce-shipping-destination strong, #order_review .shop_table, #payment .payment_methods li label, .et-product-detail .summary .variations label, .woocommerce-tabs .tabs li a:hover, .woocommerce-tabs .tabs li.active a, .et-product-detail .product_meta > span *, .sticky-product-bar .variations label, .et-product-detail .summary .sizing_guide, #side-cart .woocommerce-mini-cart__total, .woocommerce-Price-amount, .cart-collaterals .shipping-calculator-button, .woocommerce-terms-and-conditions-wrapper a, .et-checkout-login-title a, .et-checkout-coupon-title a, .woocommerce-checkout h3, .order_review_heading, .woocommerce-Address-title h3, .woocommerce-MyAccount-content h3, .woocommerce-MyAccount-content legend, .et-product-detail.et-cart-mixed .summary .yith-wcwl-add-to-wishlist > div > a, .et-product-detail.et-cart-stacked .summary .yith-wcwl-add-to-wishlist > div > a, .hentry table th, .entry-content table th, #reviews .commentlist li .comment-text .meta strong, .et-feat-video-btn, #ship-to-different-address label, .woocommerce-account-fields p.create-account label, .et-login-wrapper a, .floating-labels .form-row.float-label input:focus ~ label, .floating-labels .form-row.float-label textarea:focus ~ label, .woocommerce-info, .order_details li strong, table.order_details th, table.order_details a:not(.button), .variable-items-wrapper .variable-item:not(.radio-variable-item).button-variable-item.selected, .woocommerce-MyAccount-content p a:not(.button), .woocommerce-MyAccount-content header a, .woocommerce-MyAccount-navigation ul li a, .et-MyAccount-user-info .et-username strong, .woocommerce-MyAccount-content .shop_table tr th, mark, .woocommerce-MyAccount-content strong, .product_list_widget a, .search-panel .search-field, .goya-search .search-button-group select, .widget .slider-values p span',
'property' => 'color',
),
array(
'element' => 'input[type=radio]:checked:before, input[type=checkbox]:checked,.select2-container--default .select2-results__option--highlighted[aria-selected], .widget .noUi-horizontal .noUi-base .noUi-origin:first-child',
'property' => 'background-color',
),
array(
'element' => 'label:hover input[type=checkbox], label:hover input[type=radio], input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, input[type="date"]:focus, input[type="datetime"]:focus, input[type="datetime-local"]:focus, input[type="time"]:focus, input[type="month"]:focus, input[type="week"]:focus, input[type="email"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="url"]:focus, input.input-text:focus, select:focus, textarea:focus',
'property' => 'border-color',
),
array(
'element' => 'input[type=checkbox]:checked',
'property' => 'border-color',
'suffix' => '!important',
),
array(
'element' => '.et-product-detail .summary .yith-wcwl-add-to-wishlist a .icon svg, .sticky-product-bar .yith-wcwl-add-to-wishlist a .icon svg',
'property' => 'stroke',
),
array(
'element' => '.et-product-detail .summary .yith-wcwl-wishlistaddedbrowse a svg, .et-product-detail .summary .yith-wcwl-wishlistexistsbrowse a svg, .sticky-product-bar .yith-wcwl-wishlistaddedbrowse a svg, .sticky-product-bar .yith-wcwl-wishlistexistsbrowse a svg',
'property' => 'fill',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'lighter_font_color',
'label' => esc_html__( 'Lighter Text Color', 'goya' ),
'description' => esc_html__( 'Color used for breadcrumbs, dates and other light elements.', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#999999',
'priority' => 10,
'output' => array(
array(
'element' => '.woocommerce-breadcrumb, .woocommerce-breadcrumb a, .widget .wcapf-layered-nav ul li .count, .category_bar .header-active-filters, #reviews .commentlist li .comment-text .woocommerce-review__verified, #reviews .commentlist li .comment-text .woocommerce-review__published-date, .woof_container_inner h4, #side-filters .header-active-filters .active-filters-title, #side-filters .widget h6, .sliding-menu .sliding-menu-back, .type-post .post-meta',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'styling',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'heading_color',
'label' => esc_html__( 'Headings Color', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#282828',
'priority' => 10,
'output' => array(
array(
'element' => 'h1, h2, h3, h4, h5, h6',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'styling',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'dot_loader_color',
'label' => esc_html__( 'Dot Loader color', 'goya' ),
'description' => esc_html__( 'The pulsating circle animation', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#b9a16b',
'priority' => 10,
'output' => array(
array(
'element' => '.yith-wcan-loading:after, .blockUI.blockOverlay:after, .easyzoom-notice:after, .woocommerce-product-gallery__wrapper .slick:after, .add_to_cart_button.loading:after, .et-loader:after, .wcapf-before-update:after, #side-filters.ajax-loader .side-panel-content:after',
'property' => 'background-color',
),
array(
'element' => '.et-page-load-overlay .dot3-loader',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'styling',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'primary_buttons',
'label' => esc_html__( 'Primary Buttons Background', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#282828',
'priority' => 10,
'output' => array(
array(
'element' => '.button, input[type=submit], button[type=submit], #side-filters .et-close, .nf-form-cont .nf-form-content .submit-wrap .ninja-forms-field, .yith-wcwl-popup-footer a.button.wishlist-submit',
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'primary_buttons_text_color',
'label' => esc_html__( 'Primary Buttons Color', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#ffffff',
'priority' => 10,
'output' => array(
array(
'element' => '.button, .button:hover, button[type=submit], button[type=submit]:hover, input[type=submit], input[type=submit]:hover, .nf-form-cont .nf-form-content .submit-wrap .ninja-forms-field, .nf-form-cont .nf-form-content .submit-wrap .ninja-forms-field:hover, .yith-wcwl-popup-footer a.button.wishlist-submit',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'second_buttons',
'label' => esc_html__( 'Secondary Buttons Text/Border', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#282828',
'priority' => 10,
'output' => array(
array(
'element' => '.button.outlined, .button.outlined:hover, .button.outlined:focus, .button.outlined:active, .woocommerce-Reviews .comment-reply-title:hover',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'styling',
'default' => '' .
esc_html__( 'Helper Classes', 'goya' ) . ' ' .
esc_html__( 'Default colors, you can override or combine with other classes. For example: "fancy-title accent-color', 'goya' ) .
'
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'fancy_title_color',
'label' => esc_html__( 'Fancy Title Color', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#b9a16b',
'priority' => 10,
'output' => array(
array(
'element' => '.fancy-title',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'fancy_tag_color',
'label' => esc_html__( 'Fancy Tag Background', 'goya' ),
'transport' => 'auto',
'section' => 'styling',
'default' => '#b9a16b',
'priority' => 10,
'output' => array(
array(
'element' => '.fancy-tag',
'property' => 'background-color',
),
),
));
/* Header Colors */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_styles',
'default' => '' .
esc_html__( 'Main Header Colors', 'goya' ) . ' ' .
esc_html__( 'Default colors - if header is not transparent', 'goya' ) .
'
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'header_regular_mode',
'label' => esc_html__( 'Header - Color mode', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_styles',
'default' => 'dark',
'priority' => 10,
'choices' => array(
'dark' => esc_attr__('Dark Text', 'goya'),
'light' => esc_attr__('Light Text', 'goya'),
),
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'light-title',
'value' => 'light',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'header_background_color',
'label' => esc_html__( 'Header - Background', 'goya' ),
'transport' => 'auto',
'section' => 'header_styles',
'default' => '#ffffff',
'priority' => 10,
'output' => array(
array(
'element' => array('.page-header-regular .header, .header_on_scroll .header'),
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_styles',
'default' => '' .
esc_html__( 'Header Border', 'goya' ) . ' ' .
esc_html__( 'Applied when header is not transparent', 'goya' ) .
'
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'page_header_border',
'label' => esc_html__( 'Add Border', 'goya' ),
'description' => esc_html__( 'Border on regular pages', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_styles',
'default' => true,
'priority' => 10,
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'header-border-1',
'value' => true,
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'shop_header_border',
'label' => esc_html__( 'Add Border - Shop', 'goya' ),
'description' => esc_html__( 'Border on shop pages', 'goya' ),
'transport' => 'postMessage',
'section' => 'header_styles',
'default' => true,
'priority' => 10,
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'header-border-1',
'value' => true,
),
),
));
/* Main Menu Styles */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_styles',
'default' => '
' .esc_html__( 'Main Header Menu', 'goya' ).' ',
'priority' => 10,
));
/* Main Menu */
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'header_navigation_color',
'label' => esc_html__( 'Menu Links Color - Dark Text', 'goya' ),
'transport' => 'auto',
'section' => 'header_styles',
'default' => '#282828',
'priority' => 10,
'output' => array(
array(
'element' => array('.header a','.header .menu-toggle','.header .goya-search button, .header .et-switcher-container .selected, .header .et-header-text, .header .product.wcml-dropdown li>a, .header .product.wcml-dropdown .wcml-cs-active-currency>a, .header .product.wcml-dropdown .wcml-cs-active-currency:hover>a, .header .product.wcml-dropdown .wcml-cs-active-currency:focus>a', ),
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'header_navigation_color_light',
'label' => esc_html__( 'Menu Links Color - Light Text', 'goya' ),
'description' => esc_html__( 'Used when the header is set to Light Text mode', 'goya' ),
'transport' => 'auto',
'section' => 'header_styles',
'default' => '#ffffff',
'priority' => 10,
'output' => array(
array(
'element' => array('.sticky-header-light .header .menu-toggle:hover','.header-transparent-mobiles.sticky-header-light.header_on_scroll .header a.icon','.header-transparent-mobiles.sticky-header-light.header_on_scroll .header .menu-toggle','.header-transparent-mobiles.light-title:not(.header_on_scroll) .header a.icon','.header-transparent-mobiles.light-title:not(.header_on_scroll) .header .menu-toggle'),
'property' => 'color',
'media_query' => '@media only screen and (max-width: 767px)',
),
array(
'element' => array('.light-title:not(.header_on_scroll) .header .site-title, .light-title:not(.header_on_scroll) .header .et-header-menu > li> a, .sticky-header-light.header_on_scroll .header .et-header-menu > li> a, .light-title:not(.header_on_scroll) span.minicart-counter.et-count-zero, .sticky-header-light.header_on_scroll .header .et-header-text, .sticky-header-light.header_on_scroll .header .et-header-text a, .light-title:not(.header_on_scroll) .header .et-header-text, .light-title:not(.header_on_scroll) .header .et-header-text a, .sticky-header-light.header_on_scroll .header .header .icon, .light-title:not(.header_on_scroll) .header .icon, .sticky-header-light.header_on_scroll .header .menu-toggle, .light-title:not(.header_on_scroll) .header .menu-toggle, .sticky-header-light.header_on_scroll .header .et-switcher-container .selected, .light-title:not(.header_on_scroll) .header .et-switcher-container .selected, .light-title:not(.header_on_scroll) .header .product.wcml-dropdown li>a, .light-title:not(.header_on_scroll) .header .product.wcml-dropdown .wcml-cs-active-currency>a, .light-title:not(.header_on_scroll) .header .product.wcml-dropdown .wcml-cs-active-currency:hover>a, .light-title:not(.header_on_scroll) .header .product.wcml-dropdown .wcml-cs-active-currency:focus>a, .sticky-header-light.header_on_scroll .header .product.wcml-dropdown li>a, .sticky-header-light.header_on_scroll .header .product.wcml-dropdown .wcml-cs-active-currency>a, .sticky-header-light.header_on_scroll .header .product.wcml-dropdown .wcml-cs-active-currency:hover>a, .sticky-header-light.header_on_scroll .header .product.wcml-dropdown .wcml-cs-active-currency:focus>a'),
'property' => 'color',
'media_query' => '@media only screen and (min-width: 768px)',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'header_navigation_tag_color',
'label' => esc_html__( 'Menu Link Tags', 'goya' ),
'description' => esc_html__( 'Small labels on navigation menu. You can override the color on the Menu Manager', 'goya' ),
'transport' => 'auto',
'section' => 'header_styles',
'default' => '#bbbbbb',
'priority' => 10,
'output' => array(
array(
'element' => array('.et-header-menu .menu-label'),
'property' => 'background-color',
),
),
));
/* Dropdown Main Menu */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'header_styles',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'dropdown_menu_font_color',
'label' => esc_html__( 'Dropdown Menu Links', 'goya' ),
'transport' => 'auto',
'section' => 'header_styles',
'default' => '#444444',
'priority' => 10,
'output' => array(
array(
'element' => array('.et-header-menu ul.sub-menu li a'),
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'dropdown_menu_background_color',
'label' => esc_html__( 'Dropdown Menu Background', 'goya' ),
'transport' => 'auto',
'section' => 'header_styles',
'default' => '#ffffff',
'priority' => 10,
'output' => array(
array(
'element' => array('.et-header-menu ul.sub-menu:before','.et-header-menu .sub-menu .sub-menu'),
'property' => 'background-color',
),
array(
'element' => array('.et-header-menu>li.menu-item-has-children > a:after'),
'property' => 'border-bottom-color',
),
),
));
/* Shop Colors */
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'checkout_button_bg',
'label' => esc_html__( '"Cart | Checkout | Order" buttons', 'goya' ),
'description' => esc_html__( 'Background color for "Add to Cart | Checkout | Place Order" buttons', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#181818',
'priority' => 10,
'output' => array(
array(
'element' => array('.et-product-detail .single_add_to_cart_button, .sticky-product-bar .single_add_to_cart_button, .sticky-product-bar .add_to_cart_button, .woocommerce-mini-cart__buttons .button.checkout, .button.checkout-button, #place_order.button, .woocommerce .argmc-wrapper .argmc-nav-buttons .argmc-submit, .wishlist_table .add_to_cart'),
'property' => 'background-color',
),
array(
'element' => array('.products:not(.shop_display_list) .et-listing-style4 .after_shop_loop_actions .button'),
'property' => 'background-color',
'media_query' => '@media only screen and (min-width: 768px)'
),
array(
'element' => array('.woocommerce-mini-cart__buttons .button:not(.checkout)'),
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_styles',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'dark_product_button_bg',
'label' => esc_html__( 'Cart button background - Dark products', 'goya' ),
'description' => esc_html__( 'Button background for products with Dark Background', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#ffffff',
'priority' => 10,
'output' => array(
array(
'element' => '.product-showcase-light-text .showcase-inner .single_add_to_cart_button',
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'dark_product_button_text',
'label' => esc_html__( 'Cart button text - Dark products', 'goya' ),
'description' => esc_html__( 'Button text color for products with Dark Background', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#181818',
'priority' => 10,
'output' => array(
array(
'element' => '.product-showcase-light-text .et-product-detail .single_add_to_cart_button',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_styles',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'shop_toolbar_color',
'label' => esc_html__( 'Shop toolbar color', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#282828',
'priority' => 10,
'output' => array(
array(
'element' => '.shop_bar button, .shop_bar .woocommerce-ordering .select2-container--default .select2-selection--single, .shop_bar .shop-filters .orderby, .shop_bar .woocommerce-ordering:after',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_styles',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'product_name',
'label' => esc_html__( 'Product name', 'goya' ),
'description' => esc_html__( 'In catalog and single product page', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#282828',
'priority' => 10,
'output' => array(
array(
'element' => '.products .product-title h3 a, .et-product-detail .summary h1',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'product_price',
'label' => esc_html__( 'Product price', 'goya' ),
'description' => esc_html__( 'In catalog and single product page', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#777777',
'priority' => 10,
'output' => array(
array(
'element' => '.products .product_after_title .price ins, .products .product_after_title .price>.amount, .price ins, .price > .amount, .price del, .price .woocommerce-Price-amount',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_styles',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'rating_stars_color',
'label' => esc_html__( 'Rating Stars color', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#282828',
'priority' => 10,
'output' => array(
array(
'element' => '.star-rating > span:before, .comment-form-rating .stars > span:before',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_styles',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'sale_badge_font_color',
'label' => esc_html__( '"Sale" badge text', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#ef5c5c',
'priority' => 10,
'output' => array(
array(
'element' => '.product-inner .badge.onsale, .wc-block-grid .wc-block-grid__products .wc-block-grid__product .wc-block-grid__product-onsale',
'property' => 'color',
),
array(
'element' => '.et-product-detail .summary .badge.onsale',
'property' => 'border-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'sale_badge_background_color',
'label' => esc_html__( '"Sale" badge background', 'goya' ),
'description' => esc_html__( 'On single product page is always transparent', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#ffffff',
'priority' => 10,
'output' => array(
array(
'element' => '.product-inner .badge.onsale, .wc-block-grid .wc-block-grid__products .wc-block-grid__product .wc-block-grid__product-onsale',
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_styles',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'new_badge_font_color',
'label' => esc_html__( '"New" product text', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#585858',
'priority' => 10,
array(
'element' => '.product-inner .badge.new',
'property' => 'color',
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'new_badge_background_color',
'label' => esc_html__( '"New" product background', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#ffffff',
'priority' => 10,
'output' => array(
array(
'element' => '.product-inner .badge.new',
'property' => 'background-color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'shop_styles',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'stock_badge_font_color',
'label' => esc_html__( '"Out of Stock" text', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#585858',
'priority' => 10,
'output' => array(
array(
'element' => '.product-inner .badge.out-of-stock',
'property' => 'color',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'color',
'settings' => 'stock_badge_background_color',
'label' => esc_html__( '"Out of Stock" background', 'goya' ),
'transport' => 'auto',
'section' => 'shop_styles',
'default' => '#ffffff',
'priority' => 10,
'output' => array(
array(
'element' => '.product-inner .badge.out-of-stock',
'property' => 'background-color',
),
),
));
/* Form Styles */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'form_styles',
'default' => '
' .esc_html__( 'Inputs, buttons styles', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'elements_border_style',
'label' => esc_html__( 'Input boxes style', 'goya' ),
'transport' => 'postMessage',
'section' => 'form_styles',
'default' => 'all',
'priority' => 10,
'choices' => array(
'all' => esc_attr__('All borders', 'goya'),
'bottom' => esc_attr__('Bottom border', 'goya'),
),
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'el-style-border-all',
'value' => 'all',
),
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'el-style-border-bottom',
'value' => 'bottom',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'form_styles',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'elements_border_width',
'label' => esc_html__( 'Border width (px)', 'goya' ),
'description' => esc_html__( 'Choose the border width for input fields and buttons', 'goya' ),
'transport' => 'postMessage',
'section' => 'form_styles',
'default' => 2,
'priority' => 10,
'choices' => array(
'min' => 1,
'max' => 2,
'step' => 1
),
'js_vars' => array(
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'el-style-border-width-1',
'value' => '1',
),
array(
'element' => 'body',
'function' => 'toggleClass',
'class' => 'el-style-border-width-2',
'value' => '2',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'elements_border_radius',
'label' => esc_html__( 'Border radius (px)', 'goya' ),
'transport' => 'auto',
'section' => 'form_styles',
'default' => 0,
'priority' => 10,
'choices' => array(
'min' => 0,
'max' => 4,
'step' => 1
),
'output' => array(
array(
'element' => 'input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="time"], input[type="month"], input[type="week"], input[type="email"], input[type="search"], input[type="tel"], input[type="url"], input.input-text, select, textarea, .wp-block-button__link, .nf-form-cont .nf-form-content .list-select-wrap .nf-field-element > div, .nf-form-cont .nf-form-content input:not([type="button"]), .nf-form-cont .nf-form-content textarea, .nf-form-cont .nf-form-content .submit-wrap .ninja-forms-field, .button, .comment-form-rating, .woocommerce a.ywsl-social, .login a.ywsl-social, input[type=submit], .select2.select2-container--default .select2-selection--single, .woocommerce .woocommerce-MyAccount-content .shop_table .woocommerce-button, .woocommerce .sticky-product-bar .quantity, .woocommerce .et-product-detail .summary .quantity, .et-product-detail .summary .yith-wcwl-add-to-wishlist > div > a, .wishlist_table .add_to_cart.button, .yith-wcwl-add-button a.add_to_wishlist, .yith-wcwl-popup-button a.add_to_wishlist, .wishlist_table a.ask-an-estimate-button, .wishlist-title a.show-title-form, .hidden-title-form a.hide-title-form, .woocommerce .yith-wcwl-wishlist-new button, .wishlist_manage_table a.create-new-wishlist, .wishlist_manage_table button.submit-wishlist-changes, .yith-wcwl-wishlist-search-form button.wishlist-search-button, #side-filters.side-panel .et-close, .header .search-button-group',
'property' => 'border-radius',
'units' => 'px',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'form_styles',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'elements_floating_labels',
'label' => esc_html__( 'Floating labels', 'goya' ),
'description' => esc_html__( 'Labels for input fields will "float" on focus.', 'goya'),
'section' => 'form_styles',
'default' => true,
'priority' => 10,
));
/**
* FONTS
*/
/* Fonts */
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'main_font_source',
'label' => esc_html__( 'Main Font Source', 'goya' ),
'section' => 'fonts',
'default' => '1',
'priority' => 10,
'choices' => array(
'1' => esc_attr__('Standard + Google Fonts', 'goya'),
'2' => esc_attr__('Adobe Typekit', 'goya'),
),
));
// Main font: Standard + Google Fonts
Kirki::add_field( 'goya_config', array(
'type' => 'typography',
'settings' => 'main_font',
'label' => esc_html__( 'Main Font', 'goya' ),
'description' => esc_html__( 'Default: Jost | 400 | 1.7', 'goya' ),
'transport' => 'auto',
'section' => 'fonts',
'priority' => 10,
'choices' => goya_main_font_choices(),
'default' => array(
'font-family' => 'Jost',
'variant' => 'regular',
'line-height' => '1.7',
),
'output' => array(
array(
'element' => 'body, blockquote cite',
),
array(
'element' => '.edit-post-visual-editor.editor-styles-wrapper,.wp-block h1,.wp-block h2,.wp-block h3,.wp-block h4,.wp-block h5,.wp-block h6,.editor-post-title__block .editor-post-title__input,.wp-block-quote p,.wp-block-pullquote p,.wp-block-cover .wp-block-cover-text',
'context' => array( 'editor' ),
),
),
'required' => array(
array(
'setting' => 'main_font_source',
'operator' => '==',
'value' => '1'
)
),
));
// Main font: Adobe Typekit
Kirki::add_field( 'goya_config', array(
'type' => 'text',
'settings' => 'main_font_typekit_kit_id',
'label' => esc_html__( 'Project ID', 'goya' ),
'section' => 'fonts',
'default' => '',
'priority' => 10,
'required' => array(
array(
'setting' => 'main_font_source',
'operator' => '==',
'value' => '2'
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'text',
'settings' => 'main_typekit_font',
'label' => esc_html__( 'font-family', 'goya' ),
'description' => esc_html__( 'The font name used in the CSS output. Example: futura-pt', 'goya' ),
'section' => 'fonts',
'default' => '',
'priority' => 10,
'required' => array(
array(
'setting' => 'main_font_source',
'operator' => '==',
'value' => '2'
)
),
));
/* Second Font: Titles */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'fonts',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'radio-buttonset',
'settings' => 'second_font_source',
'label' => esc_html__( 'Second Font Source', 'goya' ),
'section' => 'fonts',
'default' => '0',
'priority' => 10,
'choices' => array(
'0' => esc_attr__( 'No Second Font', 'goya' ),
'1' => esc_attr__( 'Standard + Google Fonts', 'goya' ),
'2' => esc_attr__( 'Adobe Typekit', 'goya' ),
),
));
// Second font: Standard + Google Fonts
Kirki::add_field( 'goya_config', array(
'type' => 'typography',
'settings' => 'second_font',
'label' => esc_html__( 'Second Font', 'goya' ),
'description' => esc_html__( 'Default: Jost | regular', 'goya' ),
'transport' => 'auto',
'section' => 'fonts',
'priority' => 10,
'choices' => goya_second_font_choices(),
'default' => array(
'font-family' => 'Jost',
'variant' => 'regular',
),
'output' => array(
array(
'element' => '.site-header .main-navigation, .site-header .secondary-navigation, h1, .page-header .page-title, .entry-header .entry-title, .et-shop-title, .product-showcase.product-title-top .product_title, .et-product-detail .summary h1.product_title, .entry-title.blog-title, .post.post-detail .entry-header .entry-title, .post.post-detail .post-featured .entry-header .entry-title, .wp-block-cover .wp-block-cover-text, .wp-block-cover .wp-block-cover__inner-container, .wp-block-cover-image .wp-block-cover-image-text, .wp-block-cover-image h2, .revslider-slide-title, blockquote h1, blockquote h2, blockquote h3, blockquote h4, blockquote h5, blockquote h6, blockquote p, .post-sidebar .widget > h6, .hentry h2, .entry-content h2, .mfp-content h2, .footer h2, .entry-content h3, .hentry h3, .mfp-content h3, .footer h3, .entry-content h4, .hentry h4, .mfp-content h4, .footer h4, .post .post-title h3, .products .product .product-title h2, .et-portfolio .type-portfolio h3, .et-banner-text .et-banner-title, .woocommerce-order-received h2, .woocommerce-MyAccount-content h2, .woocommerce-MyAccount-content h3, .woocommerce-checkout h3, .order_review_heading, .woocommerce-MyAccount-content legend, .et-portfolio .type-portfolio h3, .related h2, .up-sells h2, .cross-sells h2, .cart-collaterals h5, .cart-collaterals h3, .cart-collaterals h2, .related-posts .related-title, .et_post_nav .post_nav_link h3, .comments-container .comments-title, .product-details-accordion .woocommerce-Reviews-title, .et-hovercard .et-pricing-head',
),
array(
'element' => '.wp-block h1,.wp-block h2,.wp-block h3,.editor-post-title__block .editor-post-title__input,.wp-block-quote p,.wp-block-pullquote p,.wp-block-cover .wp-block-cover-text',
'context' => array( 'editor' ),
),
),
'required' => array(
array(
'setting' => 'second_font_source',
'operator' => '==',
'value' => '1'
)
),
));
// Second font: Adobe Typekit
Kirki::add_field( 'goya_config', array(
'type' => 'text',
'settings' => 'second_font_typekit_kit_id',
'label' => esc_html__( 'Project ID', 'goya' ),
'section' => 'fonts',
'default' => '',
'priority' => 10,
'required' => array(
array(
'setting' => 'second_font_source',
'operator' => '==',
'value' => '2'
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'text',
'settings' => 'second_typekit_font',
'label' => esc_html__( 'font-family', 'goya' ),
'description' => esc_html__( 'The font name used in the CSS output. Example: futura-pt', 'goya' ),
'section' => 'fonts',
'default' => '',
'priority' => 10,
'required' => array(
array(
'setting' => 'second_font_source',
'operator' => '==',
'value' => '2'
)
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'multicheck',
'settings' => 'second_font_apply',
'label' => esc_html__( 'Elements to apply 2nd font', 'goya' ),
'description' => esc_html__( 'Select which elements will use the 2nd font', 'goya' ),
'section' => 'fonts',
'default' => array('titles','modules','widgets','blockquotes','h2','h3'),
'priority' => 10,
'multiple' => 1,
'choices' => array(
'main-menu' => esc_attr__('Main Menu', 'goya'),
'titles' => esc_attr__('Main Title (h1)', 'goya'),
'modules' => esc_attr__('Module Title (h2, h3)', 'goya'),
'widgets' => esc_attr__('Widget Title (h2)', 'goya'),
'products' => esc_attr__('Products List', 'goya'),
'posts' => esc_attr__('Posts List', 'goya'),
'portfolio' => esc_attr__('Portfolio List', 'goya'),
'h2' => esc_attr__('Content h2', 'goya'),
'h3' => esc_attr__('Content h3', 'goya'),
'h4' => esc_attr__('Content h4', 'goya'),
'blockquotes' => esc_attr__('Blockquotes', 'goya'),
),
'required' => array(
array(
'setting' => 'second_font_source',
'operator' => '!=',
'value' => '0'
)
),
));
/* Font Sizes */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'fonts',
'default' => '
' . esc_html__( 'Font Sizes', 'goya' ) . ' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'font_size_medium',
'label' => esc_html__( 'Medium Font Size (px)', 'goya' ),
'description' => esc_html__( 'General Body font', 'goya' ),
'transport' => 'auto',
'section' => 'fonts',
'default' => 16,
'priority' => 10,
'choices' => array(
'min' => 12,
'max' => 20,
'step' => 1
),
'output' => array(
array(
'element' => 'body, blockquote cite, div.vc_progress_bar .vc_single_bar .vc_label, div.vc_toggle_size_sm .vc_toggle_title h4',
'property' => 'font-size',
'units' => 'px',
),
),
));
Kirki::add_field( 'goya_config', array(
'type' => 'slider',
'settings' => 'font_size_small',
'label' => esc_html__( 'Small Font Size (px)', 'goya' ),
'transport' => 'auto',
'section' => 'fonts',
'default' => 14,
'priority' => 10,
'choices' => array(
'min' => 10,
'max' => 16,
'step' => 1
),
'output' => array(
array(
'element' => '.wp-caption-text, .woocommerce-breadcrumb, .post.listing .listing_content .post-meta, .footer-bar .footer-bar-content, .side-menu .mobile-widgets p, .side-menu .side-widgets p, .products .product.product-category a div h2 .count, #payment .payment_methods li .payment_box, #payment .payment_methods li a.about_paypal, .et-product-detail .summary .sizing_guide, #reviews .commentlist li .comment-text .woocommerce-review__verified, #reviews .commentlist li .comment-text .woocommerce-review__published-date, .commentlist > li .comment-meta, .widget .type-post .post-meta, .widget_rss .rss-date, .wp-block-latest-comments__comment-date, .wp-block-latest-posts__post-date, .commentlist > li .reply, .comment-reply-title small, .commentlist .bypostauthor .post-author, .commentlist .bypostauthor > .comment-body .fn:after, .et-portfolio.et-portfolio-style-hover-card .type-portfolio .et-portfolio-excerpt',
'property' => 'font-size',
'units' => 'px',
),
),
));
/**
* SOCIAL MEDIA
*/
/* Social Media */
Kirki::add_field( 'goya_config', array(
'type' => 'sortable',
'settings' => 'share_icons',
'label' => esc_html__( 'Share Icons', 'goya' ),
'description' => esc_html__( 'Select the share icons to show on posts and products', 'goya' ),
'section' => 'social_media',
'priority' => 10,
'choices' => array(
'facebook' => esc_attr__('Facebook', 'goya'),
'twitter' => esc_attr__('Twitter', 'goya'),
'pinterest' => esc_attr__('Pinterest', 'goya'),
'vk' => esc_attr__('VK', 'goya'),
'linkedin' => esc_attr__('LinkedIn', 'goya'),
'whatsapp' => esc_attr__('WhatsApp', 'goya'),
'telegram' => esc_attr__('Telegram', 'goya'),
'email' => esc_attr__('Email', 'goya'),
),
'default' => array('facebook', 'twitter', 'pinterest'),
));
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'social_media',
'default' => '
',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'repeater',
'settings' => 'social_links',
'label' => esc_html__( 'Social Media Links', 'goya' ),
'description' => esc_html__( 'Add your social Media URL\'s', 'goya' ),
'section' => 'social_media',
'transport' => 'postMessage',
'default' => array(),
'row_label' => array(
'type' => 'field',
'value' => esc_attr__( 'Element', 'goya' ),
'field' => 'name',
),
'fields' => array(
'name' => array(
'type' => 'select',
'label' => esc_html__( 'Social Network', 'goya' ),
'choices' => goya_social_media_icons(),
),
'url' => array(
'type' => 'text',
'label' => esc_html__( 'Link URL', 'goya' ),
),
),
));
/**
* CUSTOM CODE
*/
/* Custom Code */
Kirki::add_field( 'goya_config', array(
'type' => 'custom',
'settings' => 'separator_' . $sep++,
'section' => 'custom_css',
'default' => '
' .esc_html__( 'Goya CSS', 'goya' ).' ',
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'toggle',
'settings' => 'custom_css_status',
'label' => esc_html__( 'Enable Goya CSS', 'goya' ),
'description' => esc_html__( 'Add your theme specific code here for easy switch.', 'goya'),
'section' => 'custom_css',
'default' => false,
'priority' => 10,
));
Kirki::add_field( 'goya_config', array(
'type' => 'code',
'settings' => 'custom_css_code',
'label' => esc_html__( 'Goya CSS', 'goya' ),
'section' => 'custom_css',
'default' => '',
'priority' => 10,
'choices' => array(
'language' => 'css',
'theme' => 'monokai',
'height' => 150,
),
));
}// End if().
admin/settings/pages/header.php 0000644 00000000507 15154650146 0012545 0 ustar 00