| 1 |
<?php |
| 2 |
/** |
| 3 |
* This template contains the rules editor. |
| 4 |
* |
| 5 |
* @version 1.0 |
| 6 |
* @package Friends |
| 7 |
*/ |
| 8 |
|
| 9 |
?><form method="post" id="edit-rules"> |
| 10 |
<?php wp_nonce_field( 'edit-friend-rules-' . $args['friend']->user_login ); ?> |
| 11 |
<input type="hidden" name="friend" value="<?php echo esc_attr( $args['friend']->user_login ); ?>" /> |
| 12 |
<p class="description"><?php esc_html_e( 'By specifying rules, you can automatically accept, trash, or transform individual feed items, thus filter incoming posts according to your interest.', 'friends' ); ?></p> |
| 13 |
<p class="description"><?php esc_html_e( 'Save changes to add another rule, leave the rule text empty to delete the rule.', 'friends' ); ?></p> |
| 14 |
<table> |
| 15 |
<tbody> |
| 16 |
<?php foreach ( $args['rules'] as $rule ) : ?> |
| 17 |
<tr> |
| 18 |
<th> |
| 19 |
<select name="rules[field][]"> |
| 20 |
<option value="title" <?php selected( 'title', $rule['field'] ); ?>><?php echo esc_html_e( 'If the title contains', 'friends' ); ?></option> |
| 21 |
<option value="content" <?php selected( 'content', $rule['field'] ); ?>><?php echo esc_html_e( 'If the content contains', 'friends' ); ?></option> |
| 22 |
<option value="author" <?php selected( 'author', $rule['field'] ); ?>><?php echo esc_html_e( 'If the author contains', 'friends' ); ?></option> |
| 23 |
<option value="permalink" <?php selected( 'permalink', $rule['field'] ); ?>><?php echo esc_html_e( 'If the URL contains', 'friends' ); ?></option> |
| 24 |
</select> |
| 25 |
</th> |
| 26 |
<td><input type="text" name="rules[regex][]" value="<?php echo esc_attr( $rule['regex'] ); ?>" class="regular-text" placeholder="<?php esc_attr_e( 'Enter a text or regular expression', 'friends' ); ?>" /></td> |
| 27 |
<td> |
| 28 |
<select name="rules[action][]" class="rule-action"> |
| 29 |
<option value="accept" <?php selected( 'accept', $rule['action'] ); ?>><?php echo esc_html_e( 'accept the item', 'friends' ); ?></option> |
| 30 |
<option value="trash" <?php selected( 'trash', $rule['action'] ); ?>><?php echo esc_html_e( 'trash the item', 'friends' ); ?></option> |
| 31 |
<option value="delete" <?php selected( 'delete', $rule['action'] ); ?>><?php echo esc_html_e( 'delete the item', 'friends' ); ?></option> |
| 32 |
<option value="replace" <?php selected( 'replace', $rule['action'] ); ?>><?php echo esc_html_e( 'replace the match with this:', 'friends' ); ?></option> |
| 33 |
</select> |
| 34 |
</td> |
| 35 |
<td style="<?php echo esc_attr( 'replace' !== $rule['action'] ? 'display: none' : '' ); ?>" class="replace-with"><input type="text" name="rules[replace][]" value="<?php echo esc_attr( isset( $rule['replace'] ) ? $rule['replace'] : '' ); ?>" class="regular-text" placeholder="<?php esc_attr_e( 'Enter the text to replace it with', 'friends' ); ?>" /></td> |
| 36 |
<?php if ( empty( $rule['regex'] ) ) : ?> |
| 37 |
<td><span class="description">(<?php esc_html_e( 'Unsubmitted rule', 'friends' ); ?>)</span></td> |
| 38 |
<?php endif; ?> |
| 39 |
</tr> |
| 40 |
<?php endforeach; ?> |
| 41 |
<tr> |
| 42 |
<th><label for="field"><?php esc_html_e( 'In any other case', 'friends' ); ?></label></th> |
| 43 |
<td colspan="3"> |
| 44 |
<select name="catch_all"> |
| 45 |
<option value="accept" <?php selected( 'accept', $args['catch_all'] ); ?>><?php echo esc_html_e( 'accept the item', 'friends' ); ?></option> |
| 46 |
<option value="trash" <?php selected( 'trash', $args['catch_all'] ); ?>><?php echo esc_html_e( 'trash the item', 'friends' ); ?></option> |
| 47 |
<option value="delete" <?php selected( 'delete', $args['catch_all'] ); ?>><?php echo esc_html_e( 'delete the item', 'friends' ); ?></option> |
| 48 |
</select> |
| 49 |
</td> |
| 50 |
</tr> |
| 51 |
</tbody> |
| 52 |
</table> |
| 53 |
<p class="submit"> |
| 54 |
<input type="submit" id="submit" class="button button-primary" value="<?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_html_e( 'Save Changes' ); ?>"> |
| 55 |
<a href="<?php echo esc_url( self_admin_url( 'admin.php?page=edit-friend&user=' . $args['friend']->user_login ) ); ?>" style="margin-left: 1em"><?php /* phpcs:ignore WordPress.WP.I18n.MissingArgDomain */ esc_html_e( 'Back' ); ?></a> |
| 56 |
</p> |
| 57 |
</form> |
| 58 |
|
| 59 |
<p class="description"><?php esc_html_e( 'See how the rules apply to these items:', 'friends' ); ?> <button id="refresh-preview-rules" data-friend="<?php echo esc_attr( $args['friend']->user_login ); ?>" data-post="<?php echo $args['post'] ? esc_attr( $args['post']->ID ) : ''; ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'preview-rules-' . $args['friend']->user_login ) ); ?>"><?php esc_html_e( 'Refresh', 'friends' ); ?></button></p> |
| 60 |
|