sui-listing
5 years ago
sui-wizard
5 years ago
wizard
5 years ago
modal-template.php
5 years ago
options.php
5 years ago
pagination.php
5 years ago
view-documentation.php
5 years ago
modal-template.php
190 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Shared template for simple modals. |
| 4 | * We, markup dummies, are grateful. |
| 5 | * |
| 6 | * @package Hustle |
| 7 | * @since 4.2.0 |
| 8 | */ |
| 9 | |
| 10 | $is_unwrapped = isset( $no_wrapper ) ? $no_wrapper : false; |
| 11 | |
| 12 | $modal_id = 'hustle-dialog--' . $modal_id; |
| 13 | $modal_title_id = $modal_id . '-title'; |
| 14 | $modal_description_id = $has_description ? $modal_id . '-description' : false; |
| 15 | |
| 16 | $modal_claxx = 'sui-modal'; |
| 17 | $modal_claxx .= in_array( $modal_size, array( 'sm', 'md', 'lg', 'xl' ), true ) ? ' sui-modal-' . $modal_size : ''; |
| 18 | $modal_claxx .= ! empty( $modal_class ) ? ' ' . $modal_class : ''; |
| 19 | |
| 20 | $sui_box_tag = empty( $sui_box_tag ) ? 'div' : $sui_box_tag; |
| 21 | $sui_box_id = ! empty( $sui_box_id ) ? ' id="' . esc_attr( $sui_box_id ) . '"' : ''; |
| 22 | $sui_box_attr = ! empty( $sui_box_attr ) ? $sui_box_attr : false; |
| 23 | |
| 24 | $header_classes = ! empty( $header['classes'] ) ? ' ' . $header['classes'] : ''; |
| 25 | $header_title = ! $is_unwrapped ? $header['title'] : ''; |
| 26 | $header_title_classes = ! empty( $header['title_classes'] ) ? ' ' . $header['title_classes'] : ''; |
| 27 | $header_description = ! empty( $header['description'] ) ? $header['description'] : false; |
| 28 | $header_descr_class = ! isset( $header['description_classes'] ) ? 'sui-description' : $header['description_classes']; |
| 29 | $header_content = ! empty( $header['content'] ) ? $header['content'] : false; |
| 30 | |
| 31 | $body_classes = ! empty( $body['classes'] ) ? ' ' . $body['classes'] : ''; |
| 32 | $body_description = ! empty( $body['description'] ) && ! $header_description ? $body['description'] : false; |
| 33 | $body_descr_class = ! isset( $body['description_classes'] ) ? 'sui-description' : $body['description_classes']; |
| 34 | $body_content = ! empty( $body['content'] ) ? $body['content'] : false; |
| 35 | |
| 36 | $after_body_content = ! empty( $after_body_content ) ? $after_body_content : false; |
| 37 | |
| 38 | $footer_classes = ! empty( $footer['classes'] ) ? ' ' . $footer['classes'] : ''; |
| 39 | $footer_content = ! empty( $footer['content'] ) ? $footer['content'] : false; |
| 40 | $footer_buttons = ! empty( $footer['buttons'] ) ? $footer['buttons'] : false; |
| 41 | ?> |
| 42 | <div class="<?php echo esc_attr( $modal_claxx ); ?>"> |
| 43 | |
| 44 | <div |
| 45 | class="sui-modal-content" |
| 46 | role="dialog" |
| 47 | id="<?php echo esc_attr( $modal_id ); ?>" |
| 48 | aria-labelledby="<?php echo esc_attr( $modal_title_id ); ?>" |
| 49 | <?php if ( $modal_description_id ) : ?> |
| 50 | aria-describedby="<?php echo esc_attr( $modal_description_id ); ?>" |
| 51 | <?php endif; ?> |
| 52 | > |
| 53 | |
| 54 | <?php if ( $is_unwrapped ) { ?> |
| 55 | |
| 56 | <?php echo $body_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 57 | |
| 58 | <?php } else { ?> |
| 59 | |
| 60 | <<?php echo esc_attr( $sui_box_tag ) . $sui_box_id; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 61 | <?php |
| 62 | if ( $sui_box_attr ) : |
| 63 | $this->render_attributes( $sui_box_attr ); |
| 64 | endif; |
| 65 | ?> |
| 66 | class="sui-box" |
| 67 | > |
| 68 | |
| 69 | <div class="sui-box-header<?php echo esc_attr( $header_classes ); ?>"> |
| 70 | |
| 71 | <button class="sui-button-icon sui-button-float--right hustle-modal-close" data-modal-close> |
| 72 | <span class="sui-icon-close sui-md" aria-hidden="true"></span> |
| 73 | <span class="sui-screen-reader-text"><?php esc_html_e( 'Close this dialog window', 'hustle' ); ?></span> |
| 74 | </button> |
| 75 | |
| 76 | <h3 id="<?php echo esc_attr( $modal_id ); ?>-title" class="sui-box-title<?php echo esc_attr( $header_title_classes ); ?>"> |
| 77 | <?php echo esc_html( $header_title ); ?> |
| 78 | </h3> |
| 79 | |
| 80 | <?php if ( $header_description ) : ?> |
| 81 | |
| 82 | <p id="<?php echo esc_attr( $modal_description_id ); ?>" <?php echo $header_descr_class ? 'class="' . esc_attr( $header_descr_class ) . '"' : ''; ?>><?php echo esc_html( $header_description ); ?></p> |
| 83 | |
| 84 | <?php endif; ?> |
| 85 | |
| 86 | <?php |
| 87 | if ( $header_content ) : |
| 88 | echo $header_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 89 | endif; |
| 90 | ?> |
| 91 | |
| 92 | </div> |
| 93 | |
| 94 | <?php if ( $body_content || $body_description ) : ?> |
| 95 | |
| 96 | <div class="sui-box-body<?php echo esc_attr( $body_classes ); ?>"> |
| 97 | |
| 98 | <?php if ( $body_description ) : ?> |
| 99 | |
| 100 | <p id="<?php echo esc_attr( $modal_description_id ); ?>" <?php echo $body_descr_class ? 'class="' . esc_attr( $body_descr_class ) . '"' : ''; ?>><?php echo esc_html( $body_description ); ?></p> |
| 101 | |
| 102 | <?php endif; ?> |
| 103 | |
| 104 | <?php |
| 105 | if ( $body_content ) : |
| 106 | |
| 107 | echo $body_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 108 | |
| 109 | endif; |
| 110 | ?> |
| 111 | |
| 112 | </div> |
| 113 | |
| 114 | <?php endif; ?> |
| 115 | |
| 116 | <?php |
| 117 | if ( $after_body_content ) : |
| 118 | |
| 119 | echo $after_body_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 120 | |
| 121 | endif; |
| 122 | ?> |
| 123 | |
| 124 | <?php if ( $footer_content || $footer_buttons ) : ?> |
| 125 | |
| 126 | <div class="sui-box-footer<?php echo esc_attr( $footer_classes ); ?>"> |
| 127 | |
| 128 | <?php |
| 129 | if ( $footer_content ) : |
| 130 | echo $footer_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 131 | |
| 132 | endif; |
| 133 | |
| 134 | if ( $footer_buttons ) : |
| 135 | |
| 136 | foreach ( $footer_buttons as $button ) : |
| 137 | |
| 138 | $button_classes = ! empty( $button['classes'] ) ? ' ' . $button['classes'] : ''; |
| 139 | $button_id = ! empty( $button['id'] ) ? ' id="' . esc_attr( $button['id'] ) . '"' : ''; |
| 140 | $button_type = ! empty( $button['is_submit'] ) ? '' : ' type="button"'; |
| 141 | $close_data = ! empty( $button['is_close'] ) ? ' data-modal-close' : ''; |
| 142 | $has_load = ! empty( $button['has_load'] ) ? true : false; |
| 143 | $button_attrs = ! empty( $button['attributes'] ) ? $button['attributes'] : false; |
| 144 | $button_icon = ! empty( $button['icon'] ) ? $button['icon'] : false; |
| 145 | $text = $button['text']; |
| 146 | ?> |
| 147 | |
| 148 | <button |
| 149 | class="sui-button<?php echo esc_attr( $button_classes ); ?>" |
| 150 | <?php echo $button_id . $button_type . $close_data; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 151 | <?php |
| 152 | if ( $button_attrs ) : |
| 153 | $this->render_attributes( $button_attrs ); |
| 154 | endif; |
| 155 | ?> |
| 156 | > |
| 157 | <?php if ( $has_load ) : ?> |
| 158 | <span class="sui-loading-text"> |
| 159 | <?php endif; ?> |
| 160 | |
| 161 | <?php if ( $button_icon ) : ?> |
| 162 | <span class="sui-icon-<?php echo esc_attr( $button_icon ); ?>" aria-hidden="true"></span> |
| 163 | <?php endif; ?> |
| 164 | <?php echo esc_html( $text ); ?> |
| 165 | |
| 166 | <?php if ( $has_load ) : ?> |
| 167 | </span> |
| 168 | <span class="sui-icon-loader sui-loading" aria-hidden="true"></span> |
| 169 | <?php endif; ?> |
| 170 | |
| 171 | </button> |
| 172 | |
| 173 | <?php |
| 174 | endforeach; |
| 175 | |
| 176 | endif; |
| 177 | ?> |
| 178 | |
| 179 | </div> |
| 180 | |
| 181 | <?php endif; ?> |
| 182 | |
| 183 | </<?php echo esc_attr( $sui_box_tag ); ?>> |
| 184 | |
| 185 | <?php } ?> |
| 186 | |
| 187 | </div> |
| 188 | |
| 189 | </div> |
| 190 |