Completed
Push — develop ( 44c344...468863 )
by David
03:05
created
src/admin/partials/wordlift-admin-settings-search-keywords-page.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,65 +6,65 @@  discard block
 block discarded – undo
6 6
  * @package Wordlift/admin
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 // Get the existing terms.
14
-$existing = get_terms( Wordlift_Search_Keyword_Taxonomy::TAXONOMY_NAME, array(
14
+$existing = get_terms(Wordlift_Search_Keyword_Taxonomy::TAXONOMY_NAME, array(
15 15
 	'hide_empty'             => false,
16 16
 	'fields'                 => 'id=>name',
17 17
 	'update_term_meta_cache' => false,
18
-) );
18
+));
19 19
 
20
-$log = Wordlift_Log_Service::get_logger( 'wordlift-admin-settings-search-keywords-page.php' );
20
+$log = Wordlift_Log_Service::get_logger('wordlift-admin-settings-search-keywords-page.php');
21 21
 
22 22
 // Save the settings.
23
-if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
23
+if ('POST' === $_SERVER['REQUEST_METHOD']) {
24 24
 
25 25
 	// Get the requested terms.
26
-	$requested = preg_split( '/\r\n|\r|\n/', filter_input( INPUT_POST, 'keywords' ) );
26
+	$requested = preg_split('/\r\n|\r|\n/', filter_input(INPUT_POST, 'keywords'));
27 27
 
28 28
 	// Remove terms.
29
-	foreach ( $existing as $id => $name ) {
30
-		if ( ! in_array( $name, $requested ) ) {
31
-			$log->debug( "Deleting term $name..." );
32
-			wp_delete_term( $id, Wordlift_Search_Keyword_Taxonomy::TAXONOMY_NAME );
29
+	foreach ($existing as $id => $name) {
30
+		if ( ! in_array($name, $requested)) {
31
+			$log->debug("Deleting term $name...");
32
+			wp_delete_term($id, Wordlift_Search_Keyword_Taxonomy::TAXONOMY_NAME);
33 33
 		}
34 34
 	}
35 35
 
36 36
 	// Add terms.
37
-	foreach ( $requested as $name ) {
38
-		if ( ! empty( $name ) && ! in_array( $name, $existing ) ) {
39
-			$log->debug( "Creating term $name..." );
40
-			wp_insert_term( $name, Wordlift_Search_Keyword_Taxonomy::TAXONOMY_NAME );
37
+	foreach ($requested as $name) {
38
+		if ( ! empty($name) && ! in_array($name, $existing)) {
39
+			$log->debug("Creating term $name...");
40
+			wp_insert_term($name, Wordlift_Search_Keyword_Taxonomy::TAXONOMY_NAME);
41 41
 		}
42 42
 	}
43 43
 
44 44
 	// Refresh the `$existing` variable.
45
-	$existing = get_terms( Wordlift_Search_Keyword_Taxonomy::TAXONOMY_NAME, array(
45
+	$existing = get_terms(Wordlift_Search_Keyword_Taxonomy::TAXONOMY_NAME, array(
46 46
 		'hide_empty'             => false,
47 47
 		'fields'                 => 'id=>name',
48 48
 		'update_term_meta_cache' => false,
49
-	) );
49
+	));
50 50
 
51 51
 }
52 52
 ?>
53 53
 
54 54
 <form method="post">
55
-	<?php wp_nonce_field( 'update_search_keywords' );
55
+	<?php wp_nonce_field('update_search_keywords');
56 56
 
57
-	$terms = get_terms( Wordlift_Search_Keyword_Taxonomy::TAXONOMY_NAME );
57
+	$terms = get_terms(Wordlift_Search_Keyword_Taxonomy::TAXONOMY_NAME);
58 58
 	?>
59 59
 
60 60
     <table class="form-table">
61 61
         <tbody>
62 62
         <tr>
63
-            <th scope="row"><label for="keywords"><?php echo esc_html( __( 'Add keywords to track', 'wordlift' ) ); ?></label>
63
+            <th scope="row"><label for="keywords"><?php echo esc_html(__('Add keywords to track', 'wordlift')); ?></label>
64 64
             </th>
65 65
             <td><textarea name="keywords" id="keywords" rows="5"
66
-                          cols="30"><?php echo implode( "\n", $existing ); ?></textarea>
67
-                <p class="description"><?php echo esc_html( __( 'Type the list of search keywords, one per line.', 'wordlift' ) ); ?></p>
66
+                          cols="30"><?php echo implode("\n", $existing); ?></textarea>
67
+                <p class="description"><?php echo esc_html(__('Type the list of search keywords, one per line.', 'wordlift')); ?></p>
68 68
             </td>
69 69
         </tr>
70 70
 
@@ -73,6 +73,6 @@  discard block
 block discarded – undo
73 73
 
74 74
     <p class="submit">
75 75
         <input type="submit" class="button button-primary"
76
-               value="<?php echo esc_attr( __( 'Add', 'wordlift' ) ); ?>"/>
76
+               value="<?php echo esc_attr(__('Add', 'wordlift')); ?>"/>
77 77
     </p>
78 78
 </form>
79 79
\ No newline at end of file
Please login to merge, or discard this patch.