wordpress/wp-content/plugins/widget-css-classes/includes/widget-css-classes.class.php
/**
	 * Get the HTML for the class input field.
	 * @static
	 * @since  1.5.0
	 * @param  WP_Widget $widget
	 * @param  array     $instance
	 * @param  bool      $do_class_field Will echo a class input field if not null. Pass false for a hidden field.
	 * @return string
	 */
Get the HTML for the class input field.
Get the HTML for the class input field .
private static function do_predefined_field( $widget, $instance, $do_class_field = null ) {
		$field = '';
		$id    = $widget->get_field_id( 'classes-defined' );
		$name  = $widget->get_field_name( 'classes-defined' );
		$label = apply_filters( 'widget_css_classes_class', esc_html__( 'CSS Classes', WCSSC_Lib::DOMAIN ) );
		$predefined_classes = WCSSC_Lib::get_settings( 'defined_classes' );
				if ( ! empty( $instance['classes'] ) ) {
			$text_classes = explode( ' ', $instance['classes'] );
			$exists_defined = array_intersect( $text_classes, $predefined_classes );
			$instance['classes-defined'] = array_merge( $instance['classes-defined'], $exists_defined );
			$text_classes = array_diff( $text_classes, $predefined_classes );
			$instance['classes'] = implode( ' ', $text_classes );
		}
		$style = array(
			'padding'    => 'padding: 5px;',
			'max-height' => 'max-height: 75px;',
			'overflow'   => 'overflow: hidden;',
			'overflow-y' => 'overflow-y: auto;',
			'border'     => 'border: 1px solid #ddd;',
			'box-shadow' => 'box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07) inset;',
			'color'      => 'color: #32373c;',
			'margin-top' => 'margin-top: 1px;',
		);
		if ( 3 < count( $predefined_classes ) ) {
			unset( $style['max-height'] );
			$style['height'] = 'height: 75px;';
			$style['resize'] = 'resize: vertical;';
		}
		if ( null !== $do_class_field ) {
			if ( $do_class_field ) {
				$field .= self::do_class_field( $widget, $instance );
				$style['margin-top'] = 'margin-top: -10px;';
			} else {
				$field .= self::do_hidden( $widget->get_field_name( 'classes' ), $instance['classes'] );
				$field .= self::do_label( $label, $id );
			}
		} else {
			$field .= self::do_label( $label, $id );
		}
		$style  = implode( ' ', $style );
		$field .= "<ul id='{$id}' style='{$style}'>";
		foreach ( $predefined_classes as $preset ) {
			$preset_checked = '';
			if ( in_array( $preset, $instance['classes-defined'], true ) ) {
				$preset_checked = ' checked="checked"';
			}
			$option_id = $id . '-' . esc_attr( $preset );
			$option  = "<label for='{$option_id}'>";
			$option .= "<input id='{$option_id}' name='{$name}[]' type='checkbox' value='{$preset}' {$preset_checked} />";
			$option .= ' ' . $preset . '</label>';
			$field .= "<li>{$option}</li>";
		}
		$field .= '</ul>';
		return $field;
	}
private static function do_predefined_field ( $ widget , $ instance , $ do_class_field = null ) { $ field = '' ; $ id = $ widget -> get_field_id ( 'classes-defined' ) ; $ name = $ widget -> get_field_name ( 'classes-defined' ) ; $ label = apply_filters ( 'widget_css_classes_class' , esc_html__ ( 'CSS Classes' , WCSSC_Lib :: DOMAIN ) ) ; $ predefined_classes = WCSSC_Lib :: get_settings ( 'defined_classes' ) ; if ( ! empty ( $ instance [ 'classes' ] ) ) { $ text_classes = explode ( ' ' , $ instance [ 'classes' ] ) ; $ exists_defined = array_intersect ( $ text_classes , $ predefined_classes ) ; $ instance [ 'classes-defined' ] = array_merge ( $ instance [ 'classes-defined' ] , $ exists_defined ) ; $ text_classes = array_diff ( $ text_classes , $ predefined_classes ) ; $ instance [ 'classes' ] = implode ( ' ' , $ text_classes ) ; } $ style = array ( 'padding' => 'padding: 5px;' , 'max-height' => 'max-height: 75px;' , 'overflow' => 'overflow: hidden;' , 'overflow-y' => 'overflow-y: auto;' , 'border' => 'border: 1px solid #ddd;' , 'box-shadow' => 'box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07) inset;' , 'color' => 'color: #32373c;' , 'margin-top' => 'margin-top: 1px;' , ) ; if ( 3 < count ( $ predefined_classes ) ) { unset ( $ style [ 'max-height' ] ) ; $ style [ 'height' ] = 'height: 75px;' ; $ style [ 'resize' ] = 'resize: vertical;' ; } if ( null !== $ do_class_field ) { if ( $ do_class_field ) { $ field .= self :: do_class_field ( $ widget , $ instance ) ; $ style [ 'margin-top' ] = 'margin-top: -10px;' ; } else { $ field .= self :: do_hidden ( $ widget -> get_field_name ( 'classes' ) , $ instance [ 'classes' ] ) ; $ field .= self :: do_label ( $ label , $ id ) ; } } else { $ field .= self :: do_label ( $ label , $ id ) ; } $ style = implode ( ' ' , $ style ) ; $ field .= " <ul id=' { $ id } ' style=' { $ style } '> " ; foreach ( $ predefined_classes as $ preset ) { $ preset_checked = '' ; if ( in_array ( $ preset , $ instance [ 'classes-defined' ] , true ) ) { $ preset_checked = ' checked="checked"' ; } $ option_id = $ id . '-' . esc_attr ( $ preset ) ; $ option = " <label for=' { $ option_id } '> " ; $ option .= " <input id=' { $ option_id } ' name=' { $ name } []' type='checkbox' value=' { $ preset } '  { $ preset_checked }  /> " ; $ option .= ' ' . $ preset . '</label>' ; $ field .= " <li> { $ option } </li> " ; } $ field .= '</ul>' ; return $ field ; }
Get the HTML for the class input field.
Get the HTML for the class input field .
/**
		 * @see WCSSC::do_class_field()
		 */ // Merge input classes with predefined classes. // Do we have existing classes and is the user allowed to select defined classes?
 // Get the classes that exist in the predefined classes and merge them with the existing. // Add them to the defined classes of this instance. // Remove classes that exist in the predefined classes from the normal (custom) classes. // @since  1.5.2