integration-row.php
9 months ago
page-table-connected.php
3 years ago
page-table-not-connected.php
6 years ago
wizard-table-connected.php
3 years ago
wizard-table-not-connected.php
3 years ago
integration-row.php
251 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Row for the integrations table for both global and wizard. |
| 4 | * |
| 5 | * @package Hustle |
| 6 | * @since 4.0.0 |
| 7 | */ |
| 8 | |
| 9 | $empty_icon = self::$plugin_url . 'assets/images/hustle-empty-icon.png'; |
| 10 | |
| 11 | $module_id = isset( $module_id ) ? $module_id : 0; |
| 12 | |
| 13 | $show_action = false; |
| 14 | |
| 15 | $icon_class_action = 'sui-icon-plus'; |
| 16 | $tooltip = __( 'Configure Integration', 'hustle' ); |
| 17 | $providers_action = 'hustle_provider_settings'; |
| 18 | |
| 19 | $multi_id = 0; |
| 20 | $global_multi_id = 0; |
| 21 | $multi_name = false; |
| 22 | |
| 23 | $advertising = false; |
| 24 | $hide = apply_filters( 'wpmudev_branding_hide_doc_link', false ); |
| 25 | |
| 26 | if ( ! empty( $module_id ) ) { |
| 27 | |
| 28 | // On wizards. |
| 29 | $providers_action = 'hustle_provider_form_settings'; |
| 30 | $show_action = false; |
| 31 | $icon_class_action = 'sui-icon-plus'; |
| 32 | |
| 33 | if ( |
| 34 | isset( $provider['is_form_settings_available'] ) && |
| 35 | ! empty( $provider['is_form_settings_available'] ) && |
| 36 | true === $provider['is_form_settings_available'] |
| 37 | ) { |
| 38 | |
| 39 | $show_action = true; |
| 40 | |
| 41 | if ( $provider['is_allow_multi_on_form'] ) { |
| 42 | |
| 43 | if ( isset( $provider['multi_name'] ) ) { |
| 44 | |
| 45 | $icon_class_action = 'sui-icon-widget-settings-config'; |
| 46 | $tooltip = __( 'Configure Integration', 'hustle' ); |
| 47 | $multi_id = $provider['multi_id']; |
| 48 | $multi_name = $provider['multi_name']; |
| 49 | |
| 50 | } else { |
| 51 | |
| 52 | if ( isset( $provider['multi_id'] ) ) { |
| 53 | $multi_id = $provider['multi_id']; |
| 54 | } |
| 55 | |
| 56 | $icon_class_action = 'sui-icon-plus'; |
| 57 | $tooltip = __( 'Add Integration', 'hustle' ); |
| 58 | |
| 59 | } |
| 60 | } elseif ( $provider['is_form_connected'] ) { |
| 61 | |
| 62 | $icon_class_action = 'sui-icon-widget-settings-config'; |
| 63 | $tooltip = __( 'Configure Integration', 'hustle' ); |
| 64 | |
| 65 | } else { |
| 66 | |
| 67 | $icon_class_action = 'sui-icon-plus'; |
| 68 | $tooltip = __( 'Add Integration', 'hustle' ); |
| 69 | |
| 70 | } |
| 71 | } |
| 72 | } elseif ( |
| 73 | isset( $provider['is_settings_available'] ) && |
| 74 | ! empty( $provider['is_settings_available'] ) && |
| 75 | true === $provider['is_settings_available'] |
| 76 | ) { |
| 77 | |
| 78 | $show_action = true; |
| 79 | |
| 80 | if ( $provider['is_multi_on_global'] ) { |
| 81 | |
| 82 | if ( isset( $provider['multi_name'] ) ) { |
| 83 | |
| 84 | $icon_class_action = 'sui-icon-widget-settings-config'; |
| 85 | $tooltip = __( 'Configure Integration', 'hustle' ); |
| 86 | $global_multi_id = $provider['global_multi_id']; |
| 87 | $multi_name = $provider['multi_name']; |
| 88 | |
| 89 | } else { |
| 90 | |
| 91 | if ( isset( $provider['global_multi_id'] ) ) { |
| 92 | $global_multi_id = $provider['global_multi_id']; |
| 93 | } |
| 94 | |
| 95 | $icon_class_action = 'sui-icon-plus'; |
| 96 | $tooltip = __( 'Add Integration', 'hustle' ); |
| 97 | |
| 98 | } |
| 99 | } elseif ( $provider['is_connected'] ) { |
| 100 | |
| 101 | $icon_class_action = 'sui-icon-widget-settings-config'; |
| 102 | $tooltip = __( 'Configure Integration', 'hustle' ); |
| 103 | |
| 104 | } else { |
| 105 | |
| 106 | $icon_class_action = 'sui-icon-plus'; |
| 107 | $tooltip = __( 'Add Integration', 'hustle' ); |
| 108 | |
| 109 | if ( 'zapier' === $provider['slug'] ) { |
| 110 | $advertising = true; |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | ?> |
| 115 | |
| 116 | <tr |
| 117 | <?php |
| 118 | if ( true === $advertising ) { |
| 119 | echo ' class="hui-app--promote"'; } |
| 120 | ?> |
| 121 | > |
| 122 | |
| 123 | <td class="sui-table-item-title"> |
| 124 | |
| 125 | <div class="hui-app--wrapper"> |
| 126 | |
| 127 | <?php if ( true === $advertising ) { ?> |
| 128 | |
| 129 | <?php if ( ! empty( $provider['banner_1x'] ) || ! empty( $provider['banner_2x'] ) ) { ?> |
| 130 | |
| 131 | <div |
| 132 | role="banner" |
| 133 | class="hui-app--banner" |
| 134 | data-app="<?php echo esc_attr( $provider['slug'] ); ?>" |
| 135 | <?php ( ! empty( $provider['title'] ) ) ? '' : 'aria-hidden="true"'; ?> |
| 136 | > |
| 137 | |
| 138 | <?php if ( ! empty( $provider['banner_1x'] ) && ! empty( $provider['banner_2x'] ) ) { ?> |
| 139 | |
| 140 | <img |
| 141 | src="<?php echo esc_url( $provider['banner_1x'] ); ?>" |
| 142 | srcset="<?php echo esc_url( $provider['banner_1x'] ); ?> 1x, <?php echo esc_url( $provider['banner_2x'] ); ?> 2x" |
| 143 | alt="<?php echo esc_attr( $provider['title'] ); ?>" |
| 144 | class="sui-image" |
| 145 | /> |
| 146 | |
| 147 | <?php } else { ?> |
| 148 | |
| 149 | <?php |
| 150 | $banner = ''; |
| 151 | |
| 152 | if ( ! empty( $provider['banner_1x'] ) ) { |
| 153 | $banner = $provider['banner_1x']; |
| 154 | } |
| 155 | |
| 156 | if ( ! empty( $provider['banner_2x'] ) ) { |
| 157 | $banner = $provider['banner_2x']; |
| 158 | } |
| 159 | ?> |
| 160 | |
| 161 | <img |
| 162 | src="<?php echo esc_url( $banner ); ?>" |
| 163 | alt="<?php echo esc_attr( $provider['title'] ); ?>" |
| 164 | class="sui-image" |
| 165 | /> |
| 166 | |
| 167 | <?php } ?> |
| 168 | |
| 169 | </div> |
| 170 | |
| 171 | <?php } ?> |
| 172 | |
| 173 | <div class="hui-app--content"> |
| 174 | |
| 175 | <div class="hui-app--title"> |
| 176 | |
| 177 | <span><?php echo esc_html( $provider['title'] ) . ( ! empty( $provider['multi_name'] ) ? ' – ' . esc_html( $provider['multi_name'] ) : '' ); ?></span> |
| 178 | |
| 179 | <?php if ( ! empty( $provider['documentation_url'] ) && ! $hide ) { ?> |
| 180 | <a href="<?php echo esc_url( $provider['documentation_url'] ); ?>" target="_blank"><?php esc_html_e( 'View Docs', 'hustle' ); ?></a> |
| 181 | <?php } ?> |
| 182 | |
| 183 | <?php if ( $show_action ) : ?> |
| 184 | |
| 185 | <button class="sui-button-icon sui-tooltip sui-tooltip-top-right connect-integration" |
| 186 | type="button" |
| 187 | aria-label="<?php echo esc_attr( sprintf( /* translators: 1. Action name 2. Integration name */ __( '%1$s for %2$s', 'hustle' ), $tooltip, $provider['title'] ) ); ?>" |
| 188 | data-tooltip="<?php echo esc_html( $tooltip ); ?>" |
| 189 | data-slug="<?php echo esc_attr( $provider['slug'] ); ?>" |
| 190 | data-image="<?php echo esc_attr( $provider['logo_2x'] ); ?>" |
| 191 | data-module_id="<?php echo esc_attr( $module_id ); ?>" |
| 192 | data-multi_id="<?php echo esc_attr( $multi_id ); ?>" |
| 193 | data-global_multi_id="<?php echo esc_attr( $global_multi_id ); ?>" |
| 194 | data-action="<?php echo esc_attr( $providers_action ); ?>" |
| 195 | data-nonce="<?php echo esc_attr( wp_create_nonce( 'hustle_provider_action' ) ); ?>"> |
| 196 | <span class="<?php echo esc_attr( $icon_class_action ); ?>" aria-hidden="true"></span> |
| 197 | </button> |
| 198 | |
| 199 | <?php endif; ?> |
| 200 | |
| 201 | </div> |
| 202 | |
| 203 | <?php if ( ! empty( $provider['short_description'] ) ) { ?> |
| 204 | <span class="hui-app--description"><?php echo wp_kses_post( $provider['short_description'] ); ?></span> |
| 205 | <?php } ?> |
| 206 | |
| 207 | </div> |
| 208 | |
| 209 | <?php } else { ?> |
| 210 | |
| 211 | <?php |
| 212 | if ( ! empty( $provider['icon_2x'] ) ) { |
| 213 | $image_attrs = array( |
| 214 | 'path' => $provider['icon_2x'], |
| 215 | 'class' => 'sui-image', |
| 216 | ); |
| 217 | |
| 218 | $this->render( 'admin/image-markup', $image_attrs ); |
| 219 | } else { |
| 220 | echo '<span class="hui-noicon" aria-hidden="true">' . esc_html__( 'Icon', 'hustle' ) . '</span>'; |
| 221 | } |
| 222 | ?> |
| 223 | |
| 224 | <span><?php echo esc_html( $provider['title'] ) . ( ! empty( $provider['multi_name'] ) ? ' – ' . esc_html( $provider['multi_name'] ) : '' ); ?></span> |
| 225 | |
| 226 | <?php if ( $show_action ) : ?> |
| 227 | |
| 228 | <button class="sui-button-icon sui-tooltip sui-tooltip-top-right connect-integration" |
| 229 | type="button" |
| 230 | aria-label="<?php echo esc_attr( sprintf( /* translators: 1. Action name 2. Integration name */ __( '%1$s for %2$s', 'hustle' ), $tooltip, $provider['title'] ) ); ?>" |
| 231 | data-tooltip="<?php echo esc_html( $tooltip ); ?>" |
| 232 | data-slug="<?php echo esc_attr( $provider['slug'] ); ?>" |
| 233 | data-image="<?php echo esc_attr( $provider['logo_2x'] ); ?>" |
| 234 | data-module_id="<?php echo esc_attr( $module_id ); ?>" |
| 235 | data-multi_id="<?php echo esc_attr( $multi_id ); ?>" |
| 236 | data-global_multi_id="<?php echo esc_attr( $global_multi_id ); ?>" |
| 237 | data-action="<?php echo esc_attr( $providers_action ); ?>" |
| 238 | data-nonce="<?php echo esc_attr( wp_create_nonce( 'hustle_provider_action' ) ); ?>"> |
| 239 | <span class="<?php echo esc_attr( $icon_class_action ); ?>" aria-hidden="true"></span> |
| 240 | </button> |
| 241 | |
| 242 | <?php endif; ?> |
| 243 | |
| 244 | <?php } ?> |
| 245 | |
| 246 | </div> |
| 247 | |
| 248 | </td> |
| 249 | |
| 250 | </tr> |
| 251 |