| 1 |
<?php |
| 2 |
/** |
| 3 |
* This template contains the friend editor. |
| 4 |
* |
| 5 |
* @version 1.0 |
| 6 |
* @package Friends |
| 7 |
*/ |
| 8 |
|
| 9 |
$active_feeds = $args['friend']->get_active_feeds(); |
| 10 |
$feeds = $args['friend']->get_feeds(); |
| 11 |
|
| 12 |
$has_last_log = false; |
| 13 |
?><form method="post"> |
| 14 |
<?php wp_nonce_field( 'edit-friend-feeds-' . $args['friend']->user_login ); ?> |
| 15 |
<table class="form-table"> |
| 16 |
<tbody> |
| 17 |
<tr> |
| 18 |
<th><label for="url"><?php esc_html_e( 'Feeds', 'friends' ); ?></label></th> |
| 19 |
<td> |
| 20 |
<?php if ( empty( $active_feeds ) ) : ?> |
| 21 |
<?php esc_html_e( 'There are no active feeds.', 'friends' ); ?> |
| 22 |
<?php endif; ?> |
| 23 |
<table class="feed-table widefat<?php echo empty( $active_feeds ) ? ' hidden' : ''; ?>"> |
| 24 |
<thead> |
| 25 |
<tr> |
| 26 |
<th class="manage-column column-cb check-column"><?php esc_html_e( 'Active', 'friends' ); ?></th> |
| 27 |
<th><?php esc_html_e( 'Feed URL', 'friends' ); ?></th> |
| 28 |
<th><?php esc_html_e( 'Parser', 'friends' ); ?></th> |
| 29 |
<th><?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_html_e( 'Post Format' ); ?></th> |
| 30 |
<th><?php esc_html_e( 'Remarks', 'friends' ); ?></th> |
| 31 |
<?php do_action( 'friends_feed_table_header' ); ?> |
| 32 |
<th><?php esc_html_e( 'Actions', 'friends' ); ?></th> |
| 33 |
</tr> |
| 34 |
</thead> |
| 35 |
<tbody> |
| 36 |
<?php |
| 37 |
$alternate = 0; |
| 38 |
foreach ( $feeds as $term_id => $feed ) : |
| 39 |
if ( $feed->get_last_log() ) { |
| 40 |
$has_last_log = true; |
| 41 |
$last_log = $feed->get_last_log(); |
| 42 |
} |
| 43 |
?> |
| 44 |
<tr class="<?php echo esc_attr( ( ++$alternate % 2 ? 'alternate ' : ' ' ) . ( $feed->get_active() ? 'active' : 'inactive hidden' ) ); ?>"> |
| 45 |
<th class="checkbox"><input type="checkbox" name="feeds[<?php echo esc_attr( $term_id ); ?>][active]" value="1" aria-label="<?php esc_attr_e( 'Feed is active', 'friends' ); ?>"<?php checked( $feed->get_active() ); ?> /></th> |
| 46 |
<td><input type="text" name="feeds[<?php echo esc_attr( $term_id ); ?>][url]" value="<?php echo esc_attr( $feed->get_url() ); ?>" size="30" aria-label="<?php esc_attr_e( 'Feed URL', 'friends' ); ?>" class="url" /></td> |
| 47 |
<td class="nowrap"><select name="feeds[<?php echo esc_attr( $term_id ); ?>][parser]" aria-label="<?php esc_attr_e( 'Parser', 'friends' ); ?>"> |
| 48 |
<?php foreach ( $args['registered_parsers'] as $slug => $parser_name ) : ?> |
| 49 |
<option value="<?php echo esc_attr( $slug ); ?>"<?php selected( $slug, $feed->get_parser() ); ?>><?php echo esc_html( strip_tags( $parser_name ) ); ?></option> |
| 50 |
<?php endforeach; ?> |
| 51 |
<?php if ( 'unsupported' === $feed->get_parser() ) : ?> |
| 52 |
<option value="<?php echo esc_attr( $feed->get_parser() ); ?>" selected="selected"> |
| 53 |
<?php |
| 54 |
// translators: %s is the name of a deleted parser. |
| 55 |
echo esc_html( $feed->get_parser() ); |
| 56 |
?> |
| 57 |
</option> |
| 58 |
<?php elseif ( ! isset( $args['registered_parsers'][ $feed->get_parser() ] ) ) : ?> |
| 59 |
<option value="<?php echo esc_attr( $feed->get_parser() ); ?>" selected="selected"> |
| 60 |
<?php |
| 61 |
// translators: %s is the name of a deleted parser. |
| 62 |
echo esc_html( sprintf( __( '%s (deleted)', 'friends' ), $feed->get_parser() ) ); |
| 63 |
?> |
| 64 |
</option> |
| 65 |
<?php endif; ?> |
| 66 |
</select> <a href="<?php echo 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( $feed->get_parser() ) . '&feed=' . urlencode( $term_id ) . '&preview=' . urlencode( $feed->get_url() ) ) ), 'preview-feed' ) ); ?>" class="preview-parser" target="_blank" rel="noopener noreferrer"><?php esc_attr_e( 'Preview', 'friends' ); ?></a></td> |
| 67 |
<td><select name="feeds[<?php echo esc_attr( $term_id ); ?>][post-format]" aria-label="<?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_attr_e( 'Post Format' ); ?>"> |
| 68 |
<?php foreach ( $args['post_formats'] as $format => $title ) : ?> |
| 69 |
<option value="<?php echo esc_attr( $format ); ?>"<?php selected( $format, $feed->get_post_format() ); ?>><?php echo esc_html( $title ); ?></option> |
| 70 |
<?php endforeach; ?> |
| 71 |
</select></td> |
| 72 |
<td><input type="text" name="feeds[<?php echo esc_attr( $term_id ); ?>][title]" value="<?php echo esc_attr( $feed->get_title() ); ?>" size="20" aria-label="<?php esc_attr_e( 'Feed Name', 'friends' ); ?>" /></td> |
| 73 |
<?php do_action( 'friends_feed_table_row', $feed, $term_id ); ?> |
| 74 |
<td><a href="#" class="delete-feed">Delete</a></td> |
| 75 |
</tr> |
| 76 |
<?php if ( $feed->get_last_log() ) : ?> |
| 77 |
<tr class="<?php echo esc_attr( ( $alternate % 2 ? 'alternate ' : ' ' ) . ( $feed->get_active() ? 'active' : 'inactive' ) ); ?> lastlog hidden"> |
| 78 |
<td colspan="5" class="notice"> |
| 79 |
<?php |
| 80 |
echo esc_html( $feed->get_last_log() ); |
| 81 |
echo ' '; |
| 82 |
echo wp_kses_post( |
| 83 |
sprintf( |
| 84 |
// translators: %s is a date. |
| 85 |
__( 'Will be fetched again at %s.', 'friends' ), |
| 86 |
esc_html( $feed->get_next_poll() ) |
| 87 |
) |
| 88 |
); |
| 89 |
?> |
| 90 |
</td> |
| 91 |
</tr> |
| 92 |
<?php endif; ?> |
| 93 |
<?php endforeach; ?> |
| 94 |
<tr class="template hidden"> |
| 95 |
<td></td> |
| 96 |
<td><input type="url" name="feeds[new][url]" value="" size="20" aria-label="<?php esc_attr_e( 'Feed URL', 'friends' ); ?>" class="url" /></td> |
| 97 |
<td><select name="feeds[new][parser]" aria-label="<?php esc_attr_e( 'Parser', 'friends' ); ?>"> |
| 98 |
<?php foreach ( $args['registered_parsers'] as $slug => $parser_name ) : ?> |
| 99 |
<option value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( strip_tags( $parser_name ) ); ?></option> |
| 100 |
<?php endforeach; ?> |
| 101 |
</select> <a href="<?php echo 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=&preview=' ) ), 'preview-feed' ) ); ?>" class="preview-parser" target="_blank" rel="noopener noreferrer"><?php esc_attr_e( 'Preview', 'friends' ); ?></a></td> |
| 102 |
<td><select name="feeds[new][post-format]" aria-label="<?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_attr_e( 'Post Format' ); ?>"> |
| 103 |
<?php foreach ( $args['post_formats'] as $format => $title ) : ?> |
| 104 |
<option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( $title ); ?></option> |
| 105 |
<?php endforeach; ?> |
| 106 |
</select></td> |
| 107 |
<td><input type="text" name="feeds[new][title]" value="" size="20" aria-label="<?php esc_attr_e( 'Feed Name', 'friends' ); ?>" /></td> |
| 108 |
<?php do_action( 'friends_feed_table_row', isset( $feed ) ? $feed : array(), 'new' ); ?> |
| 109 |
<td></td> |
| 110 |
</tr> |
| 111 |
</tbody> |
| 112 |
</table> |
| 113 |
<?php if ( count( $active_feeds ) !== count( $feeds ) ) : ?> |
| 114 |
<a href="" class="show-inactive-feeds"><?php esc_html_e( 'Show inactive feeds', 'friends' ); ?></a> | |
| 115 |
<?php endif; ?> |
| 116 |
<?php if ( $has_last_log ) : ?> |
| 117 |
<a href="" class="show-log-lines"><?php esc_html_e( 'Show log output', 'friends' ); ?></a> | |
| 118 |
<?php endif; ?> |
| 119 |
<a href="" class="add-feed"><?php esc_html_e( 'Add a feed', 'friends' ); ?></a> |
| 120 |
</td> |
| 121 |
</tr> |
| 122 |
<?php if ( $args['friend']->can_refresh_feeds() ) : ?> |
| 123 |
<tr> |
| 124 |
<th><?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_html_e( 'Posts' ); ?></th> |
| 125 |
<td> |
| 126 |
<fieldset> |
| 127 |
<label for="show_on_friends_page"> |
| 128 |
<input name="show_on_friends_page" type="checkbox" id="show_on_friends_page" value="1" <?php checked( '1', ! in_array( $args['friend']->user_login, $args['hide_from_friends_page'] ) ); ?>> |
| 129 |
<?php esc_html_e( 'Show posts on your friends page', 'friends' ); ?> |
| 130 |
</label> |
| 131 |
</fieldset> |
| 132 |
<fieldset> |
| 133 |
<a href="<?php echo esc_url( $args['friend']->get_local_friends_page_url() ); ?>"> |
| 134 |
<?php |
| 135 |
// translators: %d is the number of posts. |
| 136 |
echo esc_html( sprintf( _n( 'View %d post', 'View %d posts', $args['post_count'], 'friends' ), $args['post_count'] ) ); |
| 137 |
?> |
| 138 |
</a> |
| 139 |
<?php if ( apply_filters( 'friends_debug', false ) ) : ?> |
| 140 |
| <a href="<?php echo esc_url( self_admin_url( 'edit.php?post_type=' . Friends\Friends::CPT . '&author=' . $args['friend']->ID ) ); ?>"> |
| 141 |
<?php |
| 142 |
// translators: %d is the number of posts. |
| 143 |
echo esc_html( sprintf( _n( 'View %d cached post', 'View %d cached posts', $args['post_count'], 'friends' ), $args['post_count'] ) ); |
| 144 |
?> |
| 145 |
</a> |
| 146 |
|
| 147 |
<?php endif; ?> |
| 148 |
</fieldset> |
| 149 |
<p class="description"> |
| 150 |
<?php |
| 151 |
// translators: %s is a URL. |
| 152 |
printf( __( '<a href=%s>Refresh</a> this feed now.', 'friends' ), esc_url( self_admin_url( 'admin.php?page=friends-refresh&user=' . $args['friend']->user_login ) ) ); |
| 153 |
?> |
| 154 |
</p> |
| 155 |
</td> |
| 156 |
</tr> |
| 157 |
<tr> |
| 158 |
<th><?php esc_html_e( 'Retention', 'friends' ); ?></th> |
| 159 |
<td> |
| 160 |
<fieldset> |
| 161 |
<div> |
| 162 |
<input type="checkbox" name="friends_enable_retention_days" id="friends_enable_retention_days" value="1" <?php checked( '1', $args['friend']->is_retention_days_enabled() ); ?> /> |
| 163 |
<span id="friends_enable_retention_days_line" class="<?php echo esc_attr( $args['friend']->is_retention_days_enabled() ? '' : 'disabled' ); ?>"> |
| 164 |
<?php |
| 165 |
echo wp_kses( |
| 166 |
sprintf( |
| 167 |
// translators: %s is an input field that allows specifying a number. |
| 168 |
__( 'Only keep posts for %s days', 'friends' ), |
| 169 |
'<input type="number" min="1" id="friends_retention_days" name="friends_retention_days" value="' . esc_attr( $args['friend']->get_retention_days() ) . '"' . ( $args['friend']->is_retention_days_enabled() ? '' : ' disabled="disabled"' ) . ' size="3">' |
| 170 |
), |
| 171 |
array( |
| 172 |
'input' => array( |
| 173 |
'type' => array(), |
| 174 |
'min' => array(), |
| 175 |
'id' => array(), |
| 176 |
'name' => array(), |
| 177 |
'value' => array(), |
| 178 |
'size' => array(), |
| 179 |
'disabled' => array(), |
| 180 |
), |
| 181 |
) |
| 182 |
); |
| 183 |
echo '. '; |
| 184 |
echo esc_html( |
| 185 |
sprintf( |
| 186 |
// translators: %s is a date. |
| 187 |
__( 'Earliest post: %s', 'friends' ), |
| 188 |
/* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ date_i18n( __( 'F j, Y' ), $args['earliest_post_date'] ) |
| 189 |
) |
| 190 |
); |
| 191 |
if ( $args['global_retention_days_enabled'] ) { |
| 192 |
echo '. '; |
| 193 |
echo esc_html( |
| 194 |
sprintf( |
| 195 |
// translators: %s is a number of days. |
| 196 |
__( 'Global setting: %s days', 'friends' ), |
| 197 |
number_format_i18n( $args['global_retention_days'] ) |
| 198 |
) |
| 199 |
); |
| 200 |
} |
| 201 |
|
| 202 |
?> |
| 203 |
</span> |
| 204 |
</div> |
| 205 |
<div> |
| 206 |
<input type="checkbox" name="friends_enable_retention_number" id="friends_enable_retention_number" value="1" <?php checked( '1', $args['friend']->is_retention_number_enabled() ); ?> /> |
| 207 |
<span id="friends_enable_retention_number_line" class="<?php echo esc_attr( $args['friend']->is_retention_number_enabled() ? '' : 'disabled' ); ?>"> |
| 208 |
<?php |
| 209 |
echo wp_kses( |
| 210 |
sprintf( |
| 211 |
// translators: %s is an input field that allows specifying a number. |
| 212 |
__( 'Only keep the last %s posts', 'friends' ), |
| 213 |
'<input type="number" min="1" id="friends_retention_number" name="friends_retention_number" value="' . esc_attr( $args['friend']->get_retention_number() ) . '"' . ( $args['friend']->is_retention_number_enabled() ? '' : ' disabled="disabled"' ) . ' size="3">' |
| 214 |
), |
| 215 |
array( |
| 216 |
'input' => array( |
| 217 |
'type' => array(), |
| 218 |
'min' => array(), |
| 219 |
'id' => array(), |
| 220 |
'name' => array(), |
| 221 |
'value' => array(), |
| 222 |
'size' => array(), |
| 223 |
'disabled' => array(), |
| 224 |
), |
| 225 |
) |
| 226 |
); |
| 227 |
if ( $args['global_retention_number_enabled'] ) { |
| 228 |
echo '. '; |
| 229 |
echo esc_html( |
| 230 |
sprintf( |
| 231 |
// translators: %s is a number. |
| 232 |
__( 'Global setting: %s posts', 'friends' ), |
| 233 |
number_format_i18n( $args['global_retention_number'] ) |
| 234 |
) |
| 235 |
); |
| 236 |
} |
| 237 |
?> |
| 238 |
</span> |
| 239 |
</div> |
| 240 |
</fieldset> |
| 241 |
<p class="description"> |
| 242 |
<?php |
| 243 |
echo esc_html( |
| 244 |
sprintf( |
| 245 |
// translators: %s is a size in bytes or kilo bytes (kB). |
| 246 |
__( 'Currently the posts use %s of disk space.', 'friends' ), |
| 247 |
size_format( $args['total_size'], 1 ) |
| 248 |
) |
| 249 |
); |
| 250 |
?> |
| 251 |
</p> |
| 252 |
<p class="description"> |
| 253 |
<?php |
| 254 |
echo ' '; |
| 255 |
esc_html_e( 'If you need to limit the amount of space, choose one of the options above (they can be combined).', 'friends' ); |
| 256 |
echo ' '; |
| 257 |
esc_html_e( 'The next auto-delete will kick in when refreshing the feeds of this friend.', 'friends' ); |
| 258 |
?> |
| 259 |
</p> |
| 260 |
</p> |
| 261 |
<p class="description"> |
| 262 |
<?php |
| 263 |
esc_html_e( 'Lower global settings have preceedence over the friend settings.', 'friends' ); |
| 264 |
?> |
| 265 |
</p> |
| 266 |
</td> |
| 267 |
</tr> |
| 268 |
<?php endif; ?> |
| 269 |
<?php do_action( 'friends_edit_friend_table_end', $args['friend'] ); ?> |
| 270 |
</table> |
| 271 |
<?php do_action( 'friends_edit_friend_after_form', $args['friend'] ); ?> |
| 272 |
<p class="submit"> |
| 273 |
<input type="submit" id="submit" class="button button-primary" value="<?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_html_e( 'Save Changes' ); ?>"> |
| 274 |
</p> |
| 275 |
</form> |
| 276 |
|