| 1 |
<?php |
| 2 |
/** |
| 3 |
* This template contains the Admin Send Friend Request form. |
| 4 |
* |
| 5 |
* @package Friends |
| 6 |
*/ |
| 7 |
|
| 8 |
$c = -1; |
| 9 |
$hidden_feed_count = 0; |
| 10 |
$unsupported_feeds = array(); |
| 11 |
$friends_host = false; |
| 12 |
if ( $args['friends_plugin'] ) { |
| 13 |
$friends_host = parse_url( $args['friends_plugin'], PHP_URL_HOST ); |
| 14 |
} |
| 15 |
|
| 16 |
foreach ( $args['feeds'] as $feed_url => $details ) { |
| 17 |
if ( ! isset( $details['parser'] ) || 'unsupported' === $details['parser'] ) { |
| 18 |
$unsupported_feeds[ $feed_url ] = $details; |
| 19 |
unset( $args['feeds'][ $feed_url ] ); |
| 20 |
continue; |
| 21 |
} |
| 22 |
if ( ! isset( $details['url'] ) ) { |
| 23 |
$args['feeds'][ $feed_url ]['url'] = $feed_url; |
| 24 |
} |
| 25 |
if ( ! isset( $details['autoselect'] ) ) { |
| 26 |
$args['feeds'][ $feed_url ]['autoselect'] = false; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
?><div class="wrap"><form method="post"> |
| 31 |
<?php wp_nonce_field( 'add-friend' ); ?> |
| 32 |
<input type="hidden" name="friend_url" value="<?php echo esc_url( $args['friend_url'] ); ?>" /> |
| 33 |
<p> |
| 34 |
<?php |
| 35 |
// translators: %s is a URL. |
| 36 |
echo wp_kses( |
| 37 |
// translators: %1$s is a URL, %2$s is an admin link. |
| 38 |
sprintf( __( 'You\'re looking to add the URL %1$s (<a href=%2$s>edit</a>). The site has been analyzed and you now have the following options:', 'friends' ), '<strong>' . esc_html( $args['friend_url'] ) . '</strong>', '"' . admin_url( 'admin.php?page=add-friend&url=' . $args['friend_url'] ) . '"' ), |
| 39 |
array( |
| 40 |
'strong' => array(), |
| 41 |
'a' => array( 'href' => array() ), |
| 42 |
) |
| 43 |
); |
| 44 |
?> |
| 45 |
</p> |
| 46 |
|
| 47 |
<table class="form-table"> |
| 48 |
<tbody> |
| 49 |
<tr> |
| 50 |
<th scope="row"><label for="user_login"><?php esc_html_e( 'Display Name', 'friends' ); ?></label></th> |
| 51 |
<td> |
| 52 |
<?php if ( ! empty( $args['friends_multisite_display_name'] ) ) : ?> |
| 53 |
<?php echo esc_html( $args['friends_multisite_display_name'] ); ?> |
| 54 |
<input type="hidden" id="user_login" name="display_name" value="<?php echo esc_attr( $args['friend_display_name'] ); ?>" /> |
| 55 |
<?php else : ?> |
| 56 |
<input type="text" id="user_login" name="display_name" value="<?php echo esc_attr( $args['friend_display_name'] ); ?>" required placeholder="" class="regular-text" /> |
| 57 |
<?php endif; ?> |
| 58 |
</td> |
| 59 |
</tr> |
| 60 |
<tr> |
| 61 |
<th scope="row"><label for="user_login"><?php esc_html_e( 'Username', 'friends' ); ?></label></th> |
| 62 |
<td> |
| 63 |
<?php if ( ! empty( $args['friends_multisite_user_login'] ) ) : ?> |
| 64 |
<?php echo esc_html( $args['friends_multisite_user_login'] ); ?> |
| 65 |
<input type="hidden" id="user_login" name="user_login" value="<?php echo esc_attr( $args['friends_multisite_user_login'] ); ?>" /> |
| 66 |
<?php else : ?> |
| 67 |
<input type="text" id="user_login" name="user_login" value="<?php echo esc_attr( $args['friend_user_login'] ); ?>" required placeholder="" class="regular-text" /> |
| 68 |
<?php endif; ?> |
| 69 |
</td> |
| 70 |
</tr> |
| 71 |
<?php if ( $args['friends_plugin'] ) : ?> |
| 72 |
<tr> |
| 73 |
<th scope="row"><label for="friendship"><?php esc_html_e( 'Friendship', 'friends' ); ?></label></th> |
| 74 |
<td title="<?php echo esc_attr( $args['friends_plugin'] ); ?>"> |
| 75 |
<label><input type="checkbox" id="friendship" name="friendship" value="<?php echo esc_attr( $args['friends_plugin'] ); ?>" checked /> <?php esc_html_e( 'Send request for friendship', 'friends' ); ?></label> โ |
| 76 |
<label><?php esc_html_e( 'Their role will be:', 'friends' ); ?> <select name="role" id="friendship-status"> |
| 77 |
<?php |
| 78 |
foreach ( $args['friend_roles'] as $role => $title ) : |
| 79 |
?> |
| 80 |
<option value="<?php echo esc_attr( $role ); ?>"<?php selected( $args['default_role'], $role ); ?>><?php echo esc_html( $title ); ?></option> |
| 81 |
<?php endforeach; ?> |
| 82 |
</select></label> |
| 83 |
<p class="description details hidden"><small> |
| 84 |
<?php |
| 85 |
// translators: %s is a URL. |
| 86 |
echo esc_html( sprintf( __( 'API URL: %s', 'friends' ), $args['friends_plugin'] ) ); |
| 87 |
?> |
| 88 |
</small> |
| 89 |
</p> |
| 90 |
<p class="description"> |
| 91 |
<?php esc_html_e( 'When the other side accepts your friend request, a trusted connection between your sites is established.', 'friends' ); ?> |
| 92 |
</p> |
| 93 |
<p><small><a href="" id="send-friends-advanced"><?php esc_html_e( 'Add optional information ยป', 'friends' ); ?></a></small></p> |
| 94 |
</td> |
| 95 |
</tr> |
| 96 |
<tr class="friends-advanced hidden"> |
| 97 |
<th scope="row"><label for="message"><?php esc_html_e( 'Message (Optional)', 'friends' ); ?></label></th> |
| 98 |
<td> |
| 99 |
<input type="text" autofocus id="message" name="message" value="<?php echo esc_attr( $args['message'] ); ?>" placeholder="<?php esc_attr_e( 'Enter a message for your friend', 'friends' ); ?>" class="large-text" maxlength="2000" /> |
| 100 |
<p class="description" id="message-description"> |
| 101 |
<?php esc_html_e( 'The short message you supply will be sent along with your friend request.', 'friends' ); ?> |
| 102 |
</p> |
| 103 |
</td> |
| 104 |
</tr> |
| 105 |
<tr class="friends-advanced hidden"> |
| 106 |
<th scope="row"><label for="codeword"><?php esc_html_e( 'Code word (Optional)', 'friends' ); ?></label></th> |
| 107 |
<td> |
| 108 |
<input type="text" autofocus id="codeword" name="codeword" value="<?php echo esc_attr( $args['codeword'] ); ?>" placeholder="<?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_attr_e( 'None' ); ?>" class="regular-text" /> |
| 109 |
<p class="description" id="codeword-description"> |
| 110 |
<?php esc_html_e( 'Your friend might have told you to provide something here.', 'friends' ); ?> |
| 111 |
</p> |
| 112 |
</td> |
| 113 |
</tr> |
| 114 |
<?php else : ?> |
| 115 |
<tr> |
| 116 |
<th scope="row"><label for="friendship"><?php esc_html_e( 'Friendship', 'friends' ); ?></label></th> |
| 117 |
<td> |
| 118 |
<p class="description"> |
| 119 |
<?php |
| 120 |
// translators: %s is a URL. |
| 121 |
echo wp_kses( sprintf( __( 'No friends plugin could be found on %s, therefore only subscription options are available.', 'friends' ), '<strong>' . esc_html( $args['friend_url'] ) . '</strong>' ), array( 'strong' => array() ) ); |
| 122 |
?> |
| 123 |
</p> |
| 124 |
</td> |
| 125 |
</tr> |
| 126 |
<?php endif; ?> |
| 127 |
<tr> |
| 128 |
<th scope="row"><?php esc_html_e( 'Subscription', 'friends' ); ?></th> |
| 129 |
<td> |
| 130 |
<ul> |
| 131 |
<?php foreach ( $args['feeds'] as $feed_url => $details ) : ?> |
| 132 |
<?php |
| 133 |
$c += 1; |
| 134 |
$classes = ''; |
| 135 |
if ( $c > 0 && ! $details['autoselect'] ) { |
| 136 |
$hidden_feed_count += 1; |
| 137 |
$classes .= 'rel-alternate hidden'; |
| 138 |
} |
| 139 |
?> |
| 140 |
<li class="<?php echo esc_attr( $classes ); ?>"> |
| 141 |
<?php foreach ( $details as $key => $value ) : ?> |
| 142 |
<?php |
| 143 |
if ( 'post-format' === $key ) { |
| 144 |
continue; |
| 145 |
} |
| 146 |
?> |
| 147 |
<input type="hidden" name="feeds[<?php echo esc_attr( $c ); ?>][<?php echo esc_attr( $key ); ?>]" value="<?php echo esc_attr( $value ); ?>" /> |
| 148 |
<?php endforeach; ?> |
| 149 |
<label><input type="checkbox" name="subscribe[]" value="<?php echo esc_attr( $feed_url ); ?>" <?php echo ( isset( $details['autoselect'] ) && $details['autoselect'] ) ? ' checked' : ''; ?> /> |
| 150 |
<?php |
| 151 |
if ( ! isset( $details['post-format'] ) ) { |
| 152 |
$details['post-format'] = 'standard'; |
| 153 |
} |
| 154 |
$select = '<select name="feeds[' . esc_attr( $c ) . '][post-format]">'; |
| 155 |
foreach ( $args['post_formats'] as $format => $title ) { |
| 156 |
$select .= '<option value="' . esc_attr( $format ) . '"' . selected( $details['post-format'], $format, false ) . '>' . esc_html( $title ) . '</option>'; |
| 157 |
} |
| 158 |
$select .= '</select>'; |
| 159 |
|
| 160 |
echo wp_kses( |
| 161 |
sprintf( |
| 162 |
// translators: 1: is a link to a feed with its name as text, 2: url for a preview, 3: a select dropdown with post formats. |
| 163 |
__( 'Subscribe %1$s (<a href=%2$s>preview</a>) as %3$s', 'friends' ), |
| 164 |
'<a href="' . esc_attr( $feed_url ) . '" target="_blank" rel="noopener noreferrer">' . esc_html( $details['title'] ) . '</a>', |
| 165 |
'"' . esc_url( wp_nonce_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), self_admin_url( 'admin.php?page=add-friend&parser=' . urlencode( $details['parser'] ) . '&preview=' . urlencode( $feed_url ) ) ), 'preview-feed' ) ) . '" target="_blank"', |
| 166 |
'</label>' . $select |
| 167 |
), |
| 168 |
array( |
| 169 |
'select' => array( |
| 170 |
'name' => array(), |
| 171 |
), |
| 172 |
'label' => array(), |
| 173 |
'option' => array( |
| 174 |
'value' => array(), |
| 175 |
'selected' => array(), |
| 176 |
), |
| 177 |
'a' => array( |
| 178 |
'href' => array(), |
| 179 |
'rel' => array(), |
| 180 |
'target' => array(), |
| 181 |
), |
| 182 |
) |
| 183 |
); |
| 184 |
?> |
| 185 |
<p class="description details hidden"> |
| 186 |
<?php |
| 187 |
// translators: %s is the type of a feed, for example Atom or RSS. |
| 188 |
echo esc_html( sprintf( __( 'Type: %s', 'friends' ), $details['type'] ) ); |
| 189 |
echo ' | '; |
| 190 |
|
| 191 |
$select = '<select name="feeds[' . esc_attr( $c ) . '][parser]">'; |
| 192 |
foreach ( $args['registered_parsers'] as $slug => $parser_name ) { |
| 193 |
$select .= '<option value="' . esc_attr( $slug ) . '"' . selected( $details['parser'], $slug, false ) . '>' . esc_html( strip_tags( $parser_name ) ) . '</option>'; |
| 194 |
} |
| 195 |
if ( ! isset( $args['registered_parsers'][ $details['parser'] ] ) ) { |
| 196 |
// translators: %s is the name of a deleted parser. |
| 197 |
$select .= '<option value="' . esc_attr( $details['parser'] ) . '" selected="selected">' . esc_html( sprintf( __( '%s (deleted)', 'friends' ), $details['parser'] ) ) . '</option>'; |
| 198 |
} |
| 199 |
$select .= '</select>'; |
| 200 |
|
| 201 |
echo wp_kses( |
| 202 |
// translators: %s is the name of a parser, e.g. simplepie. |
| 203 |
sprintf( __( 'Parser: %s', 'friends' ), $select ), |
| 204 |
array( |
| 205 |
'select' => array( |
| 206 |
'name' => array(), |
| 207 |
), |
| 208 |
'label' => array(), |
| 209 |
'option' => array( |
| 210 |
'value' => array(), |
| 211 |
'selected' => array(), |
| 212 |
), |
| 213 |
) |
| 214 |
); |
| 215 |
echo ' | '; |
| 216 |
// translators: %s is relation to the URL, e.g. self or alternate. |
| 217 |
echo esc_html( sprintf( __( 'rel: %s', 'friends' ), $details['rel'] ) ); |
| 218 |
?> |
| 219 |
</p> |
| 220 |
</li> |
| 221 |
<?php endforeach; ?> |
| 222 |
</ul> |
| 223 |
<p> |
| 224 |
<a href="" id="show-alternate-feeds"> |
| 225 |
<?php |
| 226 |
// translators: %d is the number of feeds. |
| 227 |
echo esc_html( sprintf( _n( '%d more feed is available', '%d more feeds are available', $hidden_feed_count, 'friends' ), $hidden_feed_count ) ); |
| 228 |
?> |
| 229 |
</a> |
| 230 |
| <a href="" id="show-details"><?php esc_html_e( 'Display feed metadata', 'friends' ); ?></a> |
| 231 |
</p> |
| 232 |
<?php if ( ! empty( $unsupported_feeds ) ) : ?> |
| 233 |
<p> |
| 234 |
<small> |
| 235 |
<a href="" id="show-unsupported-feeds"> |
| 236 |
<?php |
| 237 |
// translators: %d is the number of feeds. |
| 238 |
echo esc_html( sprintf( _n( 'Show %d unsupported feed', 'Show %d unsupported feeds', count( $unsupported_feeds ), 'friends' ), count( $unsupported_feeds ) ) ); |
| 239 |
?> |
| 240 |
</a> |
| 241 |
</small> |
| 242 |
</p> |
| 243 |
<div id="unsupported-feeds" class="hidden"> |
| 244 |
<p class="description details"> |
| 245 |
<?php |
| 246 |
echo wp_kses( |
| 247 |
// translators: %s is a URL to the plugin install page. |
| 248 |
sprintf( _n( '<a href=%s>There might be a plugin available</a> to add support for it.', '<a href=%s>There might be a plugin available</a> to add support for them.', count( $unsupported_feeds ), 'friends' ), '"' . self_admin_url( 'admin.php?page=friends-plugins' ) . '"' ), |
| 249 |
array( 'a' => array( 'href' => array() ) ) |
| 250 |
); |
| 251 |
?> |
| 252 |
</p> |
| 253 |
<ul> |
| 254 |
<?php foreach ( $unsupported_feeds as $feed_url => $details ) : ?> |
| 255 |
<?php $c += 1; ?> |
| 256 |
<li> |
| 257 |
<?php foreach ( $details as $key => $value ) : ?> |
| 258 |
<input type="hidden" name="feeds[<?php echo esc_attr( $c ); ?>][<?php echo esc_attr( $key ); ?>]" value="<?php echo esc_attr( $value ); ?>" /> |
| 259 |
<?php endforeach; ?> |
| 260 |
<?php |
| 261 |
echo wp_kses( |
| 262 |
sprintf( |
| 263 |
// translators: %s is a link to a feed with its name as text. |
| 264 |
__( 'Unsupported: %s', 'friends' ), |
| 265 |
'<a href="' . esc_attr( $feed_url ) . '" target="_blank" rel="noopener noreferrer">' . esc_html( $details['title'] ) . '</a> <small>' . esc_html( $feed_url ) . '</small>' |
| 266 |
), |
| 267 |
array( |
| 268 |
'a' => array( |
| 269 |
'href' => array(), |
| 270 |
'rel' => array(), |
| 271 |
'target' => array(), |
| 272 |
), |
| 273 |
'small' => array(), |
| 274 |
) |
| 275 |
); |
| 276 |
?> |
| 277 |
<p class="description details hidden"> |
| 278 |
<?php |
| 279 |
// translators: %s is the type of a feed, for example Atom or RSS. |
| 280 |
echo esc_html( sprintf( __( 'Type: %s', 'friends' ), $details['type'] ) ); |
| 281 |
echo ' | '; |
| 282 |
// translators: %s is relation to the URL, e.g. self or alternate. |
| 283 |
echo esc_html( sprintf( __( 'rel: %s', 'friends' ), $details['rel'] ) ); |
| 284 |
?> |
| 285 |
</p> |
| 286 |
</li> |
| 287 |
<?php endforeach; ?> |
| 288 |
</ul> |
| 289 |
</div> |
| 290 |
<?php endif; ?> |
| 291 |
</td> |
| 292 |
</tr> |
| 293 |
<tr class="another-feed hidden"> |
| 294 |
<th scope="row"></th> |
| 295 |
<td> |
| 296 |
<input type="url" name="add_feed[]" value="" placeholder="Add another feed URL" /> |
| 297 |
<input type="submit" class="button" name="step2" value="<?php echo esc_attr_x( 'Check & add feed', 'button', 'friends' ); ?>" /> |
| 298 |
<p class="description"> |
| 299 |
<?php |
| 300 |
echo wp_kses( |
| 301 |
// translators: %s is a list of parser names. |
| 302 |
sprintf( __( 'The following parsers are available: %s', 'friends' ), implode( ', ', $args['registered_parsers'] ) ), |
| 303 |
array( |
| 304 |
'a' => array( |
| 305 |
'href' => array(), |
| 306 |
'rel' => array(), |
| 307 |
'target' => array(), |
| 308 |
), |
| 309 |
) |
| 310 |
); |
| 311 |
?> |
| 312 |
</p> |
| 313 |
</td> |
| 314 |
</tr> |
| 315 |
<tr> |
| 316 |
<th></th> |
| 317 |
<td> |
| 318 |
<input type="submit" class="button button-primary" name="step3" value="<?php echo esc_attr_x( 'Add Friend ยป', 'button', 'friends' ); ?>" /> |
| 319 |
</td> |
| 320 |
</tr> |
| 321 |
</tbody> |
| 322 |
</table> |
| 323 |
|
| 324 |
</form> |
| 325 |
|