Completed
Pull Request — develop (#900)
by William
04:03
created
src/install/class-wordlift-install-3-10-0.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,41 +15,41 @@
 block discarded – undo
15 15
  * @subpackage Wordlift/install
16 16
  */
17 17
 class Wordlift_Install_3_10_0 extends Wordlift_Install {
18
-	/**
19
-	 * @inheritdoc
20
-	 */
21
-	protected static $version = '3.10.0';
18
+    /**
19
+     * @inheritdoc
20
+     */
21
+    protected static $version = '3.10.0';
22 22
 
23
-	/**
24
-	 * @inheritdoc
25
-	 */
26
-	public function install() {
23
+    /**
24
+     * @inheritdoc
25
+     */
26
+    public function install() {
27 27
 
28
-		$term_slugs = array(
29
-			'thing',
30
-			'creative-work',
31
-			'event',
32
-			'organization',
33
-			'person',
34
-			'place',
35
-			'localbusiness',
36
-		);
28
+        $term_slugs = array(
29
+            'thing',
30
+            'creative-work',
31
+            'event',
32
+            'organization',
33
+            'person',
34
+            'place',
35
+            'localbusiness',
36
+        );
37 37
 
38
-		foreach ( $term_slugs as $slug ) {
38
+        foreach ( $term_slugs as $slug ) {
39 39
 
40
-			$term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
40
+            $term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
41 41
 
42
-			// Set the term's parent to 0.
43
-			if ( $term ) {
44
-				wp_update_term(
45
-					$term->term_id,
46
-					Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
47
-					array(
48
-						'parent' => 0,
49
-					)
50
-				);
51
-			}
52
-		}
53
-	}
42
+            // Set the term's parent to 0.
43
+            if ( $term ) {
44
+                wp_update_term(
45
+                    $term->term_id,
46
+                    Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
47
+                    array(
48
+                        'parent' => 0,
49
+                    )
50
+                );
51
+            }
52
+        }
53
+    }
54 54
 
55 55
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,12 +35,12 @@
 block discarded – undo
35 35
 			'localbusiness',
36 36
 		);
37 37
 
38
-		foreach ( $term_slugs as $slug ) {
38
+		foreach ($term_slugs as $slug) {
39 39
 
40
-			$term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
40
+			$term = get_term_by('slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
41 41
 
42 42
 			// Set the term's parent to 0.
43
-			if ( $term ) {
43
+			if ($term) {
44 44
 				wp_update_term(
45 45
 					$term->term_id,
46 46
 					Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
Please login to merge, or discard this patch.
src/install/class-wordlift-install-3-12-0.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,23 +15,23 @@
 block discarded – undo
15 15
  * @subpackage Wordlift/install
16 16
  */
17 17
 class Wordlift_Install_3_12_0 extends Wordlift_Install {
18
-	/**
19
-	 * @inheritdoc
20
-	 */
21
-	protected static $version = '3.12.0';
18
+    /**
19
+     * @inheritdoc
20
+     */
21
+    protected static $version = '3.12.0';
22 22
 
23
-	/**
24
-	 * @inheritdoc
25
-	 */
26
-	public function install() {
27
-		/*
23
+    /**
24
+     * @inheritdoc
25
+     */
26
+    public function install() {
27
+        /*
28 28
 		 * As this upgrade functionality runs on the init hook, and the AMP plugin
29 29
 		 * initialization does the same, avoid possible race conditions by
30 30
 		 * deferring the actual flush to a later hook.
31 31
 		 */
32
-		add_action( 'wp_loaded', function () {
33
-			flush_rewrite_rules();
34
-		} );
35
-	}
32
+        add_action( 'wp_loaded', function () {
33
+            flush_rewrite_rules();
34
+        } );
35
+    }
36 36
 
37 37
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 		 * initialization does the same, avoid possible race conditions by
30 30
 		 * deferring the actual flush to a later hook.
31 31
 		 */
32
-		add_action( 'wp_loaded', function () {
32
+		add_action('wp_loaded', function() {
33 33
 			flush_rewrite_rules();
34 34
 		} );
35 35
 	}
Please login to merge, or discard this patch.
src/shortcodes/wordlift_shortcode_chord.php 2 patches
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -15,45 +15,45 @@  discard block
 block discarded – undo
15 15
  * @return mixed
16 16
  */
17 17
 function wl_shortcode_chord_most_referenced_entity_id() {
18
-	// Get the last 20 articles by post date.
19
-	// For each article get the entities they reference.
20
-	$post_ids = get_posts( array(
21
-		'numberposts' => 20,
22
-		'post_type'   => Wordlift_Entity_Service::valid_entity_post_types(),
23
-		'fields'      => 'ids', // Only get post IDs.
24
-		'post_status' => 'publish',
25
-		'tax_query'   => array(
26
-			'relation' => 'OR',
27
-			array(
28
-				'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
29
-				'operator' => 'NOT EXISTS',
30
-			),
31
-			array(
32
-				'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
33
-				'field'    => 'slug',
34
-				'terms'    => 'article',
35
-			),
36
-		),
37
-		'orderby'     => 'post_date',
38
-		'order'       => 'DESC',
39
-	) );
40
-
41
-	if ( empty( $post_ids ) ) {
42
-		return null;
43
-	}
44
-
45
-	$entities = array();
46
-	foreach ( $post_ids as $id ) {
47
-		$entities = array_merge( $entities, wl_core_get_related_entity_ids( $id ) );
48
-	}
49
-
50
-	$famous_entities = array_count_values( $entities );
51
-	arsort( $famous_entities );
52
-	if ( sizeof( $famous_entities ) >= 1 ) {
53
-		return key( $famous_entities );
54
-	} else {
55
-		return $post_ids[0];
56
-	}
18
+    // Get the last 20 articles by post date.
19
+    // For each article get the entities they reference.
20
+    $post_ids = get_posts( array(
21
+        'numberposts' => 20,
22
+        'post_type'   => Wordlift_Entity_Service::valid_entity_post_types(),
23
+        'fields'      => 'ids', // Only get post IDs.
24
+        'post_status' => 'publish',
25
+        'tax_query'   => array(
26
+            'relation' => 'OR',
27
+            array(
28
+                'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
29
+                'operator' => 'NOT EXISTS',
30
+            ),
31
+            array(
32
+                'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
33
+                'field'    => 'slug',
34
+                'terms'    => 'article',
35
+            ),
36
+        ),
37
+        'orderby'     => 'post_date',
38
+        'order'       => 'DESC',
39
+    ) );
40
+
41
+    if ( empty( $post_ids ) ) {
42
+        return null;
43
+    }
44
+
45
+    $entities = array();
46
+    foreach ( $post_ids as $id ) {
47
+        $entities = array_merge( $entities, wl_core_get_related_entity_ids( $id ) );
48
+    }
49
+
50
+    $famous_entities = array_count_values( $entities );
51
+    arsort( $famous_entities );
52
+    if ( sizeof( $famous_entities ) >= 1 ) {
53
+        return key( $famous_entities );
54
+    } else {
55
+        return $post_ids[0];
56
+    }
57 57
 
58 58
 }
59 59
 
@@ -71,60 +71,60 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function wl_shortcode_chord_get_relations( $entity_id, $depth = 2, $related = null, $max_size = 9 ) {
73 73
 
74
-	if ( ! is_null( $related ) ) {
75
-		if ( 0 === $depth ) {
76
-			return $related;
77
-		}
78
-	}
74
+    if ( ! is_null( $related ) ) {
75
+        if ( 0 === $depth ) {
76
+            return $related;
77
+        }
78
+    }
79 79
 
80
-	wl_write_log( "wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: " . ( is_null( $related ) ? 'yes' : 'no' ) . " ]" );
80
+    wl_write_log( "wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: " . ( is_null( $related ) ? 'yes' : 'no' ) . " ]" );
81 81
 
82
-	// Create a related array which will hold entities and relations.
83
-	if ( is_null( $related ) ) {
84
-		$related = array(
85
-			'entities'  => array( $entity_id ),
86
-			'relations' => array(),
87
-		);
88
-	}
82
+    // Create a related array which will hold entities and relations.
83
+    if ( is_null( $related ) ) {
84
+        $related = array(
85
+            'entities'  => array( $entity_id ),
86
+            'relations' => array(),
87
+        );
88
+    }
89 89
 
90
-	// Get related entities
91
-	$related_entity_ids = wl_core_get_related_entity_ids( $entity_id, array(
92
-		'status' => 'publish',
93
-	) );
90
+    // Get related entities
91
+    $related_entity_ids = wl_core_get_related_entity_ids( $entity_id, array(
92
+        'status' => 'publish',
93
+    ) );
94 94
 
95
-	// If the current node is an entity, add related posts too
96
-	$related_post_ids = ( Wordlift_Entity_Service::get_instance()
97
-	                                             ->is_entity( $entity_id ) ) ?
98
-		wl_core_get_related_post_ids( $entity_id, array(
99
-			'status' => 'publish',
100
-		) ) :
101
-		array();
95
+    // If the current node is an entity, add related posts too
96
+    $related_post_ids = ( Wordlift_Entity_Service::get_instance()
97
+                                                    ->is_entity( $entity_id ) ) ?
98
+        wl_core_get_related_post_ids( $entity_id, array(
99
+            'status' => 'publish',
100
+        ) ) :
101
+        array();
102 102
 
103
-	// Merge results and remove duplicated entries
104
-	$related_ids = array_unique( array_merge( $related_post_ids, $related_entity_ids ) );
103
+    // Merge results and remove duplicated entries
104
+    $related_ids = array_unique( array_merge( $related_post_ids, $related_entity_ids ) );
105 105
 
106
-	// TODO: List of entities ($rel) should be ordered by interest factors.
107
-	shuffle( $related_ids );
106
+    // TODO: List of entities ($rel) should be ordered by interest factors.
107
+    shuffle( $related_ids );
108 108
 
109
-	// Now we have all the related IDs.
110
-	foreach ( $related_ids as $related_id ) {
109
+    // Now we have all the related IDs.
110
+    foreach ( $related_ids as $related_id ) {
111 111
 
112
-		if ( count( $related['entities'] ) >= $max_size ) {
113
-			return $related;
114
-		}
112
+        if ( count( $related['entities'] ) >= $max_size ) {
113
+            return $related;
114
+        }
115 115
 
116
-		$related['relations'][] = array( $entity_id, $related_id );
116
+        $related['relations'][] = array( $entity_id, $related_id );
117 117
 
118
-		if ( ! in_array( $related_id, $related['entities'] ) ) {
119
-			// Found new related entity!
120
-			$related['entities'][] = $related_id;
118
+        if ( ! in_array( $related_id, $related['entities'] ) ) {
119
+            // Found new related entity!
120
+            $related['entities'][] = $related_id;
121 121
 
122
-			$related = wl_shortcode_chord_get_relations( $related_id, ( $depth - 1 ), $related, $max_size );
123
-		}
124
-	}
122
+            $related = wl_shortcode_chord_get_relations( $related_id, ( $depth - 1 ), $related, $max_size );
123
+        }
124
+    }
125 125
 
126
-	// End condition 2: no more entities to search for.
127
-	return $related;
126
+    // End condition 2: no more entities to search for.
127
+    return $related;
128 128
 }
129 129
 
130 130
 /**
@@ -138,57 +138,57 @@  discard block
 block discarded – undo
138 138
  */
139 139
 function wl_shortcode_chord_get_graph( $data ) {
140 140
 
141
-	// Refactor the entities array in order to provide entities relevant data (uri, url, label, type, css_class).
142
-	array_walk( $data['entities'], function ( &$item ) {
143
-		$post = get_post( $item );
144
-
145
-		// Skip non-existing posts.
146
-		if ( is_null( $post ) ) {
147
-			wl_write_log( "wl_shortcode_chord_get_graph : post not found [ post id :: $item ]" );
148
-
149
-			return $item;
150
-		}
151
-
152
-		// Get the entity taxonomy bound to this post (if there's no taxonomy, no stylesheet will be set).
153
-		$term = Wordlift_Entity_Type_Service::get_instance()->get( $item );
154
-
155
-		// The following log may create a circular loop.
156
-		// wl_write_log( "wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: " . var_export( $term, true ) . " ]" );
157
-
158
-		// TODO: get all images
159
-		$thumbnail    = null;
160
-		$thumbnail_id = get_post_thumbnail_id( $post->ID );
161
-		if ( '' !== $thumbnail_id ) {
162
-			$attachment = wp_get_attachment_image_src( $thumbnail_id );
163
-			if ( false !== $attachment ) {
164
-				$thumbnail = esc_attr( $attachment[0] );
165
-			}
166
-		}
167
-
168
-		$entity = array(
169
-			'uri'        => wl_get_entity_uri( $item ),
170
-			'url'        => get_permalink( $item ),
171
-			'label'      => $post->post_title,
172
-			'type'       => $post->post_type,
173
-			'thumbnails' => array( $thumbnail ),
174
-			'css_class'  => ( isset( $term['css_class'] ) ? $term['css_class'] : '' ),
175
-		);
176
-
177
-		$item = $entity;
178
-	} );
179
-
180
-	// Refactor the relations.
181
-	array_walk( $data['relations'], function ( &$item ) {
182
-		$relation = array(
183
-			's' => wl_get_entity_uri( $item[0] ),
184
-			'o' => wl_get_entity_uri( $item[1] ),
185
-		);
186
-
187
-		$item = $relation;
188
-	} );
189
-
190
-	// Return the JSON representation.
191
-	return $data;
141
+    // Refactor the entities array in order to provide entities relevant data (uri, url, label, type, css_class).
142
+    array_walk( $data['entities'], function ( &$item ) {
143
+        $post = get_post( $item );
144
+
145
+        // Skip non-existing posts.
146
+        if ( is_null( $post ) ) {
147
+            wl_write_log( "wl_shortcode_chord_get_graph : post not found [ post id :: $item ]" );
148
+
149
+            return $item;
150
+        }
151
+
152
+        // Get the entity taxonomy bound to this post (if there's no taxonomy, no stylesheet will be set).
153
+        $term = Wordlift_Entity_Type_Service::get_instance()->get( $item );
154
+
155
+        // The following log may create a circular loop.
156
+        // wl_write_log( "wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: " . var_export( $term, true ) . " ]" );
157
+
158
+        // TODO: get all images
159
+        $thumbnail    = null;
160
+        $thumbnail_id = get_post_thumbnail_id( $post->ID );
161
+        if ( '' !== $thumbnail_id ) {
162
+            $attachment = wp_get_attachment_image_src( $thumbnail_id );
163
+            if ( false !== $attachment ) {
164
+                $thumbnail = esc_attr( $attachment[0] );
165
+            }
166
+        }
167
+
168
+        $entity = array(
169
+            'uri'        => wl_get_entity_uri( $item ),
170
+            'url'        => get_permalink( $item ),
171
+            'label'      => $post->post_title,
172
+            'type'       => $post->post_type,
173
+            'thumbnails' => array( $thumbnail ),
174
+            'css_class'  => ( isset( $term['css_class'] ) ? $term['css_class'] : '' ),
175
+        );
176
+
177
+        $item = $entity;
178
+    } );
179
+
180
+    // Refactor the relations.
181
+    array_walk( $data['relations'], function ( &$item ) {
182
+        $relation = array(
183
+            's' => wl_get_entity_uri( $item[0] ),
184
+            'o' => wl_get_entity_uri( $item[1] ),
185
+        );
186
+
187
+        $item = $relation;
188
+    } );
189
+
190
+    // Return the JSON representation.
191
+    return $data;
192 192
 }
193 193
 
194 194
 /**
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
  */
200 200
 function wl_shortcode_chord_ajax() {
201 201
 
202
-	$post_id = $_REQUEST['post_id'];
203
-	$depth   = $_REQUEST['depth'];
202
+    $post_id = $_REQUEST['post_id'];
203
+    $depth   = $_REQUEST['depth'];
204 204
 
205
-	$relations = wl_shortcode_chord_get_relations( $post_id, $depth );
206
-	$graph     = wl_shortcode_chord_get_graph( $relations );
205
+    $relations = wl_shortcode_chord_get_relations( $post_id, $depth );
206
+    $graph     = wl_shortcode_chord_get_graph( $relations );
207 207
 
208
-	wl_core_send_json( $graph );
208
+    wl_core_send_json( $graph );
209 209
 }
210 210
 
211 211
 add_action( 'wp_ajax_wl_chord', 'wl_shortcode_chord_ajax' );
Please login to merge, or discard this patch.
Spacing   +51 added lines, -52 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 function wl_shortcode_chord_most_referenced_entity_id() {
18 18
 	// Get the last 20 articles by post date.
19 19
 	// For each article get the entities they reference.
20
-	$post_ids = get_posts( array(
20
+	$post_ids = get_posts(array(
21 21
 		'numberposts' => 20,
22 22
 		'post_type'   => Wordlift_Entity_Service::valid_entity_post_types(),
23 23
 		'fields'      => 'ids', // Only get post IDs.
@@ -36,21 +36,21 @@  discard block
 block discarded – undo
36 36
 		),
37 37
 		'orderby'     => 'post_date',
38 38
 		'order'       => 'DESC',
39
-	) );
39
+	));
40 40
 
41
-	if ( empty( $post_ids ) ) {
41
+	if (empty($post_ids)) {
42 42
 		return null;
43 43
 	}
44 44
 
45 45
 	$entities = array();
46
-	foreach ( $post_ids as $id ) {
47
-		$entities = array_merge( $entities, wl_core_get_related_entity_ids( $id ) );
46
+	foreach ($post_ids as $id) {
47
+		$entities = array_merge($entities, wl_core_get_related_entity_ids($id));
48 48
 	}
49 49
 
50
-	$famous_entities = array_count_values( $entities );
51
-	arsort( $famous_entities );
52
-	if ( sizeof( $famous_entities ) >= 1 ) {
53
-		return key( $famous_entities );
50
+	$famous_entities = array_count_values($entities);
51
+	arsort($famous_entities);
52
+	if (sizeof($famous_entities) >= 1) {
53
+		return key($famous_entities);
54 54
 	} else {
55 55
 		return $post_ids[0];
56 56
 	}
@@ -69,57 +69,56 @@  discard block
 block discarded – undo
69 69
  *
70 70
  * @return array
71 71
  */
72
-function wl_shortcode_chord_get_relations( $entity_id, $depth = 2, $related = null, $max_size = 9 ) {
72
+function wl_shortcode_chord_get_relations($entity_id, $depth = 2, $related = null, $max_size = 9) {
73 73
 
74
-	if ( ! is_null( $related ) ) {
75
-		if ( 0 === $depth ) {
74
+	if ( ! is_null($related)) {
75
+		if (0 === $depth) {
76 76
 			return $related;
77 77
 		}
78 78
 	}
79 79
 
80
-	wl_write_log( "wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: " . ( is_null( $related ) ? 'yes' : 'no' ) . " ]" );
80
+	wl_write_log("wl_shortcode_chord_get_relations [ post id :: $entity_id ][ depth :: $depth ][ related? :: ".(is_null($related) ? 'yes' : 'no')." ]");
81 81
 
82 82
 	// Create a related array which will hold entities and relations.
83
-	if ( is_null( $related ) ) {
83
+	if (is_null($related)) {
84 84
 		$related = array(
85
-			'entities'  => array( $entity_id ),
85
+			'entities'  => array($entity_id),
86 86
 			'relations' => array(),
87 87
 		);
88 88
 	}
89 89
 
90 90
 	// Get related entities
91
-	$related_entity_ids = wl_core_get_related_entity_ids( $entity_id, array(
91
+	$related_entity_ids = wl_core_get_related_entity_ids($entity_id, array(
92 92
 		'status' => 'publish',
93
-	) );
93
+	));
94 94
 
95 95
 	// If the current node is an entity, add related posts too
96
-	$related_post_ids = ( Wordlift_Entity_Service::get_instance()
97
-	                                             ->is_entity( $entity_id ) ) ?
98
-		wl_core_get_related_post_ids( $entity_id, array(
96
+	$related_post_ids = (Wordlift_Entity_Service::get_instance()
97
+	                                             ->is_entity($entity_id)) ?
98
+		wl_core_get_related_post_ids($entity_id, array(
99 99
 			'status' => 'publish',
100
-		) ) :
101
-		array();
100
+		)) : array();
102 101
 
103 102
 	// Merge results and remove duplicated entries
104
-	$related_ids = array_unique( array_merge( $related_post_ids, $related_entity_ids ) );
103
+	$related_ids = array_unique(array_merge($related_post_ids, $related_entity_ids));
105 104
 
106 105
 	// TODO: List of entities ($rel) should be ordered by interest factors.
107
-	shuffle( $related_ids );
106
+	shuffle($related_ids);
108 107
 
109 108
 	// Now we have all the related IDs.
110
-	foreach ( $related_ids as $related_id ) {
109
+	foreach ($related_ids as $related_id) {
111 110
 
112
-		if ( count( $related['entities'] ) >= $max_size ) {
111
+		if (count($related['entities']) >= $max_size) {
113 112
 			return $related;
114 113
 		}
115 114
 
116
-		$related['relations'][] = array( $entity_id, $related_id );
115
+		$related['relations'][] = array($entity_id, $related_id);
117 116
 
118
-		if ( ! in_array( $related_id, $related['entities'] ) ) {
117
+		if ( ! in_array($related_id, $related['entities'])) {
119 118
 			// Found new related entity!
120 119
 			$related['entities'][] = $related_id;
121 120
 
122
-			$related = wl_shortcode_chord_get_relations( $related_id, ( $depth - 1 ), $related, $max_size );
121
+			$related = wl_shortcode_chord_get_relations($related_id, ($depth - 1), $related, $max_size);
123 122
 		}
124 123
 	}
125 124
 
@@ -136,52 +135,52 @@  discard block
 block discarded – undo
136 135
  *
137 136
  * @return mixed|string
138 137
  */
139
-function wl_shortcode_chord_get_graph( $data ) {
138
+function wl_shortcode_chord_get_graph($data) {
140 139
 
141 140
 	// Refactor the entities array in order to provide entities relevant data (uri, url, label, type, css_class).
142
-	array_walk( $data['entities'], function ( &$item ) {
143
-		$post = get_post( $item );
141
+	array_walk($data['entities'], function(&$item) {
142
+		$post = get_post($item);
144 143
 
145 144
 		// Skip non-existing posts.
146
-		if ( is_null( $post ) ) {
147
-			wl_write_log( "wl_shortcode_chord_get_graph : post not found [ post id :: $item ]" );
145
+		if (is_null($post)) {
146
+			wl_write_log("wl_shortcode_chord_get_graph : post not found [ post id :: $item ]");
148 147
 
149 148
 			return $item;
150 149
 		}
151 150
 
152 151
 		// Get the entity taxonomy bound to this post (if there's no taxonomy, no stylesheet will be set).
153
-		$term = Wordlift_Entity_Type_Service::get_instance()->get( $item );
152
+		$term = Wordlift_Entity_Type_Service::get_instance()->get($item);
154 153
 
155 154
 		// The following log may create a circular loop.
156 155
 		// wl_write_log( "wl_shortcode_chord_get_graph [ post id :: $post->ID ][ term :: " . var_export( $term, true ) . " ]" );
157 156
 
158 157
 		// TODO: get all images
159 158
 		$thumbnail    = null;
160
-		$thumbnail_id = get_post_thumbnail_id( $post->ID );
161
-		if ( '' !== $thumbnail_id ) {
162
-			$attachment = wp_get_attachment_image_src( $thumbnail_id );
163
-			if ( false !== $attachment ) {
164
-				$thumbnail = esc_attr( $attachment[0] );
159
+		$thumbnail_id = get_post_thumbnail_id($post->ID);
160
+		if ('' !== $thumbnail_id) {
161
+			$attachment = wp_get_attachment_image_src($thumbnail_id);
162
+			if (false !== $attachment) {
163
+				$thumbnail = esc_attr($attachment[0]);
165 164
 			}
166 165
 		}
167 166
 
168 167
 		$entity = array(
169
-			'uri'        => wl_get_entity_uri( $item ),
170
-			'url'        => get_permalink( $item ),
168
+			'uri'        => wl_get_entity_uri($item),
169
+			'url'        => get_permalink($item),
171 170
 			'label'      => $post->post_title,
172 171
 			'type'       => $post->post_type,
173
-			'thumbnails' => array( $thumbnail ),
174
-			'css_class'  => ( isset( $term['css_class'] ) ? $term['css_class'] : '' ),
172
+			'thumbnails' => array($thumbnail),
173
+			'css_class'  => (isset($term['css_class']) ? $term['css_class'] : ''),
175 174
 		);
176 175
 
177 176
 		$item = $entity;
178 177
 	} );
179 178
 
180 179
 	// Refactor the relations.
181
-	array_walk( $data['relations'], function ( &$item ) {
180
+	array_walk($data['relations'], function(&$item) {
182 181
 		$relation = array(
183
-			's' => wl_get_entity_uri( $item[0] ),
184
-			'o' => wl_get_entity_uri( $item[1] ),
182
+			's' => wl_get_entity_uri($item[0]),
183
+			'o' => wl_get_entity_uri($item[1]),
185 184
 		);
186 185
 
187 186
 		$item = $relation;
@@ -202,11 +201,11 @@  discard block
 block discarded – undo
202 201
 	$post_id = $_REQUEST['post_id'];
203 202
 	$depth   = $_REQUEST['depth'];
204 203
 
205
-	$relations = wl_shortcode_chord_get_relations( $post_id, $depth );
206
-	$graph     = wl_shortcode_chord_get_graph( $relations );
204
+	$relations = wl_shortcode_chord_get_relations($post_id, $depth);
205
+	$graph     = wl_shortcode_chord_get_graph($relations);
207 206
 
208
-	wl_core_send_json( $graph );
207
+	wl_core_send_json($graph);
209 208
 }
210 209
 
211
-add_action( 'wp_ajax_wl_chord', 'wl_shortcode_chord_ajax' );
212
-add_action( 'wp_ajax_nopriv_wl_chord', 'wl_shortcode_chord_ajax' );
210
+add_action('wp_ajax_wl_chord', 'wl_shortcode_chord_ajax');
211
+add_action('wp_ajax_nopriv_wl_chord', 'wl_shortcode_chord_ajax');
Please login to merge, or discard this patch.
src/uninstall.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 // If uninstall not called from WordPress, then exit.
29 29
 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
30
-	exit;
30
+    exit;
31 31
 }
32 32
 
33 33
 // Get a reference to WP and the Wordlift plugin
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 
41 41
 // Do a db search for posts of type entity
42 42
 $args           = array(
43
-	'posts_per_page' => - 1,
44
-	'post_type'      => Wordlift_Entity_Service::TYPE_NAME,
45
-	'post_status'    => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
46
-	'fields'         => 'ids'
43
+    'posts_per_page' => - 1,
44
+    'post_type'      => Wordlift_Entity_Service::TYPE_NAME,
45
+    'post_status'    => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
46
+    'fields'         => 'ids'
47 47
 );
48 48
 $entities_array = get_posts( $args );
49 49
 
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 wl_write_log( 'Deleting entities and their meta... ' );
53 53
 wl_write_log( $entities_array );
54 54
 foreach ( $entities_array as $entity_id ) {
55
-	// Delete the whole entity and its metas.
56
-	wp_delete_post( $entity_id, true );
55
+    // Delete the whole entity and its metas.
56
+    wp_delete_post( $entity_id, true );
57 57
 }
58 58
 wl_write_log( 'Done.' );
59 59
 
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 // We loop over terms in this rude way because in the uninstall script
75 75
 // is not possible to call WP custom taxonomy functions.
76 76
 foreach ( range( 0, 100 ) as $index ) {
77
-	delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_' . $index );
78
-	wp_delete_term( $index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
77
+    delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_' . $index );
78
+    wp_delete_term( $index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
79 79
 }
80 80
 delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_children' );  // it's a hierarchical taxonomy
81 81
 wl_write_log( 'Done.' );
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  */
27 27
 
28 28
 // If uninstall not called from WordPress, then exit.
29
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
29
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
30 30
 	exit;
31 31
 }
32 32
 
@@ -39,53 +39,53 @@  discard block
 block discarded – undo
39 39
  */
40 40
 
41 41
 // Do a db search for posts of type entity
42
-$args           = array(
43
-	'posts_per_page' => - 1,
42
+$args = array(
43
+	'posts_per_page' => -1,
44 44
 	'post_type'      => Wordlift_Entity_Service::TYPE_NAME,
45
-	'post_status'    => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
45
+	'post_status'    => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'),
46 46
 	'fields'         => 'ids'
47 47
 );
48
-$entities_array = get_posts( $args );
48
+$entities_array = get_posts($args);
49 49
 
50 50
 // Loop over entities and delete them.
51 51
 // TODO: thumbnails?
52
-wl_write_log( 'Deleting entities and their meta... ' );
53
-wl_write_log( $entities_array );
54
-foreach ( $entities_array as $entity_id ) {
52
+wl_write_log('Deleting entities and their meta... ');
53
+wl_write_log($entities_array);
54
+foreach ($entities_array as $entity_id) {
55 55
 	// Delete the whole entity and its metas.
56
-	wp_delete_post( $entity_id, true );
56
+	wp_delete_post($entity_id, true);
57 57
 }
58
-wl_write_log( 'Done.' );
58
+wl_write_log('Done.');
59 59
 
60 60
 /*
61 61
  * Delete post-entity relationships
62 62
  */
63
-wl_write_log( 'Deleting post-entity relationships... ' );
64
-$sql = 'DROP TABLE IF EXISTS ' . wl_core_get_relation_instances_table_name() . ';';
65
-$wpdb->query( $sql );
66
-delete_option( 'wl_db_version' );
67
-wl_write_log( 'Done.' );
63
+wl_write_log('Deleting post-entity relationships... ');
64
+$sql = 'DROP TABLE IF EXISTS '.wl_core_get_relation_instances_table_name().';';
65
+$wpdb->query($sql);
66
+delete_option('wl_db_version');
67
+wl_write_log('Done.');
68 68
 
69 69
 /*
70 70
  * Delete taxonomy
71 71
  */
72
-wl_write_log( 'Cleaning entities taxonomy... ' );
72
+wl_write_log('Cleaning entities taxonomy... ');
73 73
 // Delte custom taxonomy terms.
74 74
 // We loop over terms in this rude way because in the uninstall script
75 75
 // is not possible to call WP custom taxonomy functions.
76
-foreach ( range( 0, 100 ) as $index ) {
77
-	delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_' . $index );
78
-	wp_delete_term( $index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
76
+foreach (range(0, 100) as $index) {
77
+	delete_option(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'_'.$index);
78
+	wp_delete_term($index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
79 79
 }
80
-delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_children' );  // it's a hierarchical taxonomy
81
-wl_write_log( 'Done.' );
80
+delete_option(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'_children'); // it's a hierarchical taxonomy
81
+wl_write_log('Done.');
82 82
 
83 83
 /**
84 84
  * Delete options
85 85
  */
86
-wl_write_log( 'Cleaning WordLift options... ' );
86
+wl_write_log('Cleaning WordLift options... ');
87 87
 // delete_option( WL_OPTIONS_NAME );
88
-delete_option( 'wl_option_prefixes' );
89
-delete_option( 'wl_general_settings' );
90
-delete_option( 'wl_advanced_settings' );
91
-wl_write_log( 'Done. WordLift successfully uninstalled.' );
88
+delete_option('wl_option_prefixes');
89
+delete_option('wl_general_settings');
90
+delete_option('wl_advanced_settings');
91
+wl_write_log('Done. WordLift successfully uninstalled.');
Please login to merge, or discard this patch.
src/modules/core/wordlift_core.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Include constants
4
-require_once( 'wordlift_core_constants.php' );
4
+require_once('wordlift_core_constants.php');
5 5
 
6 6
 // Include methods that deal with post/entity relations
7
-require_once( 'wordlift_core_post_entity_relations.php' );
7
+require_once('wordlift_core_post_entity_relations.php');
8 8
 
9 9
 // Include wl_schema api
10
-require_once( 'wordlift_core_schema_api.php' );
10
+require_once('wordlift_core_schema_api.php');
11 11
 
12 12
 // Include the Entity API which allow to query for entity posts.
13
-require_once( 'wordlift_core_entity_api.php' );
13
+require_once('wordlift_core_entity_api.php');
14 14
 
15 15
 // Include utility global functions 
16
-require_once( 'wordlift_core_functions.php' );
17 16
\ No newline at end of file
17
+require_once('wordlift_core_functions.php');
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
src/modules/core/wordlift_core_entity_api.php 2 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -20,54 +20,54 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wl_entity_get_by_title( $title, $autocomplete = false, $include_alias = true ) {
22 22
 
23
-	global $wpdb;
24
-
25
-	// Search by substring
26
-	if ( $autocomplete ) {
27
-		$title = '%' . $title . '%';
28
-	}
29
-
30
-	// The title is a LIKE query.
31
-	$query = "SELECT DISTINCT p.ID AS id, p.post_title AS title, t.name AS schema_type_name, t.slug AS type_slug"
32
-			 . " FROM $wpdb->posts p, $wpdb->term_taxonomy tt, $wpdb->term_relationships tr, $wpdb->terms t"
33
-			 . "  WHERE p.post_title LIKE %s"
34
-			 . "   AND t.term_id = tt.term_id"
35
-			 . "   AND tt.taxonomy = %s"
36
-			 . "   AND tt.term_taxonomy_id = tr.term_taxonomy_id"
37
-			 . "   AND tr.object_id = p.ID"
38
-			 // Ensure we don't load entities from the trash, see https://github.com/insideout10/wordlift-plugin/issues/278.
39
-			 . "   AND p.post_status != 'trash'";
40
-
41
-	$params = array(
42
-		$title,
43
-		Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
44
-	);
45
-
46
-	if ( $include_alias ) {
47
-
48
-		$query .= " UNION"
49
-				  . "  SELECT DISTINCT p.ID AS id, CONCAT( m.meta_value, ' (', p.post_title, ')' ) AS title, t.name AS schema_type_name, t.slug AS type_slug"
50
-				  . "  FROM $wpdb->posts p, $wpdb->term_taxonomy tt, $wpdb->term_relationships tr, $wpdb->terms t, $wpdb->postmeta m"
51
-				  . "   WHERE m.meta_key = %s AND m.meta_value LIKE %s"
52
-				  . "    AND m.post_id = p.ID"
53
-				  . "    AND t.term_id = tt.term_id"
54
-				  . "    AND tt.taxonomy = %s"
55
-				  . "    AND tt.term_taxonomy_id = tr.term_taxonomy_id"
56
-				  . "    AND tr.object_id = p.ID"
57
-				  // Ensure we don't load entities from the trash, see https://github.com/insideout10/wordlift-plugin/issues/278.
58
-				  . "    AND p.post_status != 'trash'";
59
-
60
-		$params = array_merge( $params, array(
61
-			Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY,
62
-			$title,
63
-			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
64
-		) );
65
-	}
66
-
67
-	return $wpdb->get_results( $wpdb->prepare(
68
-		$query,
69
-		$params
70
-	) );
23
+    global $wpdb;
24
+
25
+    // Search by substring
26
+    if ( $autocomplete ) {
27
+        $title = '%' . $title . '%';
28
+    }
29
+
30
+    // The title is a LIKE query.
31
+    $query = "SELECT DISTINCT p.ID AS id, p.post_title AS title, t.name AS schema_type_name, t.slug AS type_slug"
32
+                . " FROM $wpdb->posts p, $wpdb->term_taxonomy tt, $wpdb->term_relationships tr, $wpdb->terms t"
33
+                . "  WHERE p.post_title LIKE %s"
34
+                . "   AND t.term_id = tt.term_id"
35
+                . "   AND tt.taxonomy = %s"
36
+                . "   AND tt.term_taxonomy_id = tr.term_taxonomy_id"
37
+                . "   AND tr.object_id = p.ID"
38
+                // Ensure we don't load entities from the trash, see https://github.com/insideout10/wordlift-plugin/issues/278.
39
+                . "   AND p.post_status != 'trash'";
40
+
41
+    $params = array(
42
+        $title,
43
+        Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
44
+    );
45
+
46
+    if ( $include_alias ) {
47
+
48
+        $query .= " UNION"
49
+                    . "  SELECT DISTINCT p.ID AS id, CONCAT( m.meta_value, ' (', p.post_title, ')' ) AS title, t.name AS schema_type_name, t.slug AS type_slug"
50
+                    . "  FROM $wpdb->posts p, $wpdb->term_taxonomy tt, $wpdb->term_relationships tr, $wpdb->terms t, $wpdb->postmeta m"
51
+                    . "   WHERE m.meta_key = %s AND m.meta_value LIKE %s"
52
+                    . "    AND m.post_id = p.ID"
53
+                    . "    AND t.term_id = tt.term_id"
54
+                    . "    AND tt.taxonomy = %s"
55
+                    . "    AND tt.term_taxonomy_id = tr.term_taxonomy_id"
56
+                    . "    AND tr.object_id = p.ID"
57
+                    // Ensure we don't load entities from the trash, see https://github.com/insideout10/wordlift-plugin/issues/278.
58
+                    . "    AND p.post_status != 'trash'";
59
+
60
+        $params = array_merge( $params, array(
61
+            Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY,
62
+            $title,
63
+            Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
64
+        ) );
65
+    }
66
+
67
+    return $wpdb->get_results( $wpdb->prepare(
68
+        $query,
69
+        $params
70
+    ) );
71 71
 }
72 72
 
73 73
 /**
@@ -77,41 +77,41 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function wl_entity_ajax_get_by_title() {
79 79
 
80
-	// `wl_entity_metaboxes_utilities.js` still uses `GET`.
81
-	//
82
-	// See https://github.com/insideout10/wordlift-plugin/issues/438.
83
-	// Get the title to search.
84
-	if ( empty( $_POST['title'] ) && empty( $_GET['title'] ) ) {
85
-		@ob_clean();
86
-		wp_send_json_error( 'The title parameter is required.' );
87
-	}
88
-
89
-	// `wl_entity_metaboxes_utilities.js` still uses `GET`.
90
-	//
91
-	// See https://github.com/insideout10/wordlift-plugin/issues/438.
92
-	$title = $_POST['title'] ?: $_GET['title'];
93
-
94
-	// Are we searching for a specific title or for a containing title?
95
-	$autocomplete = isset( $_GET['autocomplete'] );
96
-
97
-	// Are we searching also for the aliases?
98
-	$include_alias = isset( $_GET['alias'] );
99
-
100
-	// Get the edit link.
101
-	$post_type_object = get_post_type_object( Wordlift_Entity_Service::TYPE_NAME );
102
-	$edit_link        = $post_type_object->_edit_link . '&action=edit';
103
-
104
-	// Prepare the response with the edit link.
105
-	$response = array(
106
-		'edit_link' => $edit_link,
107
-		'results'   => wl_entity_get_by_title( $title, $autocomplete, $include_alias ),
108
-	);
109
-
110
-	// Clean any buffer.
111
-	@ob_clean();
112
-
113
-	// Send the success response.
114
-	wp_send_json_success( $response );
80
+    // `wl_entity_metaboxes_utilities.js` still uses `GET`.
81
+    //
82
+    // See https://github.com/insideout10/wordlift-plugin/issues/438.
83
+    // Get the title to search.
84
+    if ( empty( $_POST['title'] ) && empty( $_GET['title'] ) ) {
85
+        @ob_clean();
86
+        wp_send_json_error( 'The title parameter is required.' );
87
+    }
88
+
89
+    // `wl_entity_metaboxes_utilities.js` still uses `GET`.
90
+    //
91
+    // See https://github.com/insideout10/wordlift-plugin/issues/438.
92
+    $title = $_POST['title'] ?: $_GET['title'];
93
+
94
+    // Are we searching for a specific title or for a containing title?
95
+    $autocomplete = isset( $_GET['autocomplete'] );
96
+
97
+    // Are we searching also for the aliases?
98
+    $include_alias = isset( $_GET['alias'] );
99
+
100
+    // Get the edit link.
101
+    $post_type_object = get_post_type_object( Wordlift_Entity_Service::TYPE_NAME );
102
+    $edit_link        = $post_type_object->_edit_link . '&action=edit';
103
+
104
+    // Prepare the response with the edit link.
105
+    $response = array(
106
+        'edit_link' => $edit_link,
107
+        'results'   => wl_entity_get_by_title( $title, $autocomplete, $include_alias ),
108
+    );
109
+
110
+    // Clean any buffer.
111
+    @ob_clean();
112
+
113
+    // Send the success response.
114
+    wp_send_json_success( $response );
115 115
 
116 116
 }
117 117
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @return array An array of WP_Post instances.
20 20
  */
21
-function wl_entity_get_by_title( $title, $autocomplete = false, $include_alias = true ) {
21
+function wl_entity_get_by_title($title, $autocomplete = false, $include_alias = true) {
22 22
 
23 23
 	global $wpdb;
24 24
 
25 25
 	// Search by substring
26
-	if ( $autocomplete ) {
27
-		$title = '%' . $title . '%';
26
+	if ($autocomplete) {
27
+		$title = '%'.$title.'%';
28 28
 	}
29 29
 
30 30
 	// The title is a LIKE query.
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
44 44
 	);
45 45
 
46
-	if ( $include_alias ) {
46
+	if ($include_alias) {
47 47
 
48 48
 		$query .= " UNION"
49 49
 				  . "  SELECT DISTINCT p.ID AS id, CONCAT( m.meta_value, ' (', p.post_title, ')' ) AS title, t.name AS schema_type_name, t.slug AS type_slug"
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
 				  // Ensure we don't load entities from the trash, see https://github.com/insideout10/wordlift-plugin/issues/278.
58 58
 				  . "    AND p.post_status != 'trash'";
59 59
 
60
-		$params = array_merge( $params, array(
60
+		$params = array_merge($params, array(
61 61
 			Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY,
62 62
 			$title,
63 63
 			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
64
-		) );
64
+		));
65 65
 	}
66 66
 
67
-	return $wpdb->get_results( $wpdb->prepare(
67
+	return $wpdb->get_results($wpdb->prepare(
68 68
 		$query,
69 69
 		$params
70
-	) );
70
+	));
71 71
 }
72 72
 
73 73
 /**
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 	//
82 82
 	// See https://github.com/insideout10/wordlift-plugin/issues/438.
83 83
 	// Get the title to search.
84
-	if ( empty( $_POST['title'] ) && empty( $_GET['title'] ) ) {
84
+	if (empty($_POST['title']) && empty($_GET['title'])) {
85 85
 		@ob_clean();
86
-		wp_send_json_error( 'The title parameter is required.' );
86
+		wp_send_json_error('The title parameter is required.');
87 87
 	}
88 88
 
89 89
 	// `wl_entity_metaboxes_utilities.js` still uses `GET`.
@@ -92,27 +92,27 @@  discard block
 block discarded – undo
92 92
 	$title = $_POST['title'] ?: $_GET['title'];
93 93
 
94 94
 	// Are we searching for a specific title or for a containing title?
95
-	$autocomplete = isset( $_GET['autocomplete'] );
95
+	$autocomplete = isset($_GET['autocomplete']);
96 96
 
97 97
 	// Are we searching also for the aliases?
98
-	$include_alias = isset( $_GET['alias'] );
98
+	$include_alias = isset($_GET['alias']);
99 99
 
100 100
 	// Get the edit link.
101
-	$post_type_object = get_post_type_object( Wordlift_Entity_Service::TYPE_NAME );
102
-	$edit_link        = $post_type_object->_edit_link . '&action=edit';
101
+	$post_type_object = get_post_type_object(Wordlift_Entity_Service::TYPE_NAME);
102
+	$edit_link        = $post_type_object->_edit_link.'&action=edit';
103 103
 
104 104
 	// Prepare the response with the edit link.
105 105
 	$response = array(
106 106
 		'edit_link' => $edit_link,
107
-		'results'   => wl_entity_get_by_title( $title, $autocomplete, $include_alias ),
107
+		'results'   => wl_entity_get_by_title($title, $autocomplete, $include_alias),
108 108
 	);
109 109
 
110 110
 	// Clean any buffer.
111 111
 	@ob_clean();
112 112
 
113 113
 	// Send the success response.
114
-	wp_send_json_success( $response );
114
+	wp_send_json_success($response);
115 115
 
116 116
 }
117 117
 
118
-add_action( 'wp_ajax_entity_by_title', 'wl_entity_ajax_get_by_title' );
118
+add_action('wp_ajax_entity_by_title', 'wl_entity_ajax_get_by_title');
Please login to merge, or discard this patch.
src/admin/class-wordlift-entity-types-taxonomy-walker.php 2 patches
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @subpackage Wordlift/includes
11 11
  */
12 12
 if ( ! class_exists( 'Walker_Category_Checklist' ) ) {
13
-	require_once( ABSPATH . 'wp-admin/includes/template.php' );
13
+    require_once( ABSPATH . 'wp-admin/includes/template.php' );
14 14
 }
15 15
 
16 16
 /**
@@ -23,113 +23,113 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class Wordlift_Entity_Types_Taxonomy_Walker extends Walker_Category_Checklist {
25 25
 
26
-	/**
27
-	 * Entity taxonomy metabox must show exclusive options, no checkboxes.
28
-	 *
29
-	 * @since 3.1.0
30
-	 *
31
-	 * @param       $args     {
32
-	 *                        An array of arguments.
33
-	 *
34
-	 * @type string $taxonomy The taxonomy name.
35
-	 *              }
36
-	 *
37
-	 * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy.
38
-	 */
39
-	function terms_checklist_args( $args ) {
40
-
41
-		if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
42
-			return $args;
43
-		}
44
-
45
-		// We override the way WP prints the taxonomy metabox HTML.
46
-		$args['walker']        = $this;
47
-		$args['checked_ontop'] = false;
48
-
49
-		return $args;
50
-
51
-	}
52
-
53
-	/**
54
-	 * Change checkboxes to radios.
55
-	 *
56
-	 * $max_depth = -1 means flatly display every element.
57
-	 * $max_depth = 0 means display all levels.
58
-	 * $max_depth > 0 specifies the number of display levels.
59
-	 *
60
-	 * @since 3.1.0
61
-	 *
62
-	 * @param array $elements  An array of elements.
63
-	 * @param int   $max_depth The maximum hierarchical depth.
64
-	 *
65
-	 * @param array $args      Additional arguments.
66
-	 *
67
-	 * @return string The hierarchical item output.
68
-	 */
69
-	public function walk( $elements, $max_depth, $args = array() ) {
70
-
71
-		// `max_depth` force to -1 to display a flat taxonomy.
72
-		//
73
-		// See https://github.com/insideout10/wordlift-plugin/issues/305
74
-		$output = parent::walk( $elements, - 1, $args );
75
-
76
-		$output = str_replace(
77
-			array( "type=\"checkbox\"", "type='checkbox'" ),
78
-			array( "type=\"radio\"", "type='radio'" ),
79
-			$output
80
-		);
81
-
82
-		return $output;
83
-	}
84
-
85
-	/**
86
-	 * Start the element output, output nothing in case of article term.
87
-	 *
88
-	 * @since 3.15.0
89
-	 *
90
-	 * @param string $output   Passed by reference. Used to append additional content.
91
-	 * @param object $category The current term object.
92
-	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
93
-	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
94
-	 * @param int    $id       ID of the current term.
95
-	 */
96
-	public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
97
-		global $post;
98
-
99
-		if ( ! isset( $post ) ) {
100
-			return;
101
-		}
102
-
103
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
104
-		     || 'article' !== $category->slug
105
-		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
106
-			parent::start_el( $output, $category, $depth, $args, $id );
107
-		}
108
-	}
109
-
110
-	/**
111
-	 * End the element output, output nothing in case of article term.
112
-	 *
113
-	 * @since 3.15.0
114
-	 *
115
-	 * @param string $output   Passed by reference. Used to append additional content.
116
-	 * @param object $category The current term object.
117
-	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
118
-	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
119
-	 */
120
-	public function end_el( &$output, $category, $depth = 0, $args = array() ) {
121
-		global $post;
122
-
123
-		if ( ! isset( $post ) ) {
124
-			return;
125
-		}
126
-
127
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
128
-		     || 'article' !== $category->slug
129
-		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
130
-			parent::end_el( $output, $category, $depth, $args );
131
-		}
132
-
133
-	}
26
+    /**
27
+     * Entity taxonomy metabox must show exclusive options, no checkboxes.
28
+     *
29
+     * @since 3.1.0
30
+     *
31
+     * @param       $args     {
32
+     *                        An array of arguments.
33
+     *
34
+     * @type string $taxonomy The taxonomy name.
35
+     *              }
36
+     *
37
+     * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy.
38
+     */
39
+    function terms_checklist_args( $args ) {
40
+
41
+        if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
42
+            return $args;
43
+        }
44
+
45
+        // We override the way WP prints the taxonomy metabox HTML.
46
+        $args['walker']        = $this;
47
+        $args['checked_ontop'] = false;
48
+
49
+        return $args;
50
+
51
+    }
52
+
53
+    /**
54
+     * Change checkboxes to radios.
55
+     *
56
+     * $max_depth = -1 means flatly display every element.
57
+     * $max_depth = 0 means display all levels.
58
+     * $max_depth > 0 specifies the number of display levels.
59
+     *
60
+     * @since 3.1.0
61
+     *
62
+     * @param array $elements  An array of elements.
63
+     * @param int   $max_depth The maximum hierarchical depth.
64
+     *
65
+     * @param array $args      Additional arguments.
66
+     *
67
+     * @return string The hierarchical item output.
68
+     */
69
+    public function walk( $elements, $max_depth, $args = array() ) {
70
+
71
+        // `max_depth` force to -1 to display a flat taxonomy.
72
+        //
73
+        // See https://github.com/insideout10/wordlift-plugin/issues/305
74
+        $output = parent::walk( $elements, - 1, $args );
75
+
76
+        $output = str_replace(
77
+            array( "type=\"checkbox\"", "type='checkbox'" ),
78
+            array( "type=\"radio\"", "type='radio'" ),
79
+            $output
80
+        );
81
+
82
+        return $output;
83
+    }
84
+
85
+    /**
86
+     * Start the element output, output nothing in case of article term.
87
+     *
88
+     * @since 3.15.0
89
+     *
90
+     * @param string $output   Passed by reference. Used to append additional content.
91
+     * @param object $category The current term object.
92
+     * @param int    $depth    Depth of the term in reference to parents. Default 0.
93
+     * @param array  $args     An array of arguments. @see wp_terms_checklist()
94
+     * @param int    $id       ID of the current term.
95
+     */
96
+    public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
97
+        global $post;
98
+
99
+        if ( ! isset( $post ) ) {
100
+            return;
101
+        }
102
+
103
+        if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
104
+             || 'article' !== $category->slug
105
+             || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
106
+            parent::start_el( $output, $category, $depth, $args, $id );
107
+        }
108
+    }
109
+
110
+    /**
111
+     * End the element output, output nothing in case of article term.
112
+     *
113
+     * @since 3.15.0
114
+     *
115
+     * @param string $output   Passed by reference. Used to append additional content.
116
+     * @param object $category The current term object.
117
+     * @param int    $depth    Depth of the term in reference to parents. Default 0.
118
+     * @param array  $args     An array of arguments. @see wp_terms_checklist()
119
+     */
120
+    public function end_el( &$output, $category, $depth = 0, $args = array() ) {
121
+        global $post;
122
+
123
+        if ( ! isset( $post ) ) {
124
+            return;
125
+        }
126
+
127
+        if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
128
+             || 'article' !== $category->slug
129
+             || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
130
+            parent::end_el( $output, $category, $depth, $args );
131
+        }
132
+
133
+    }
134 134
 
135 135
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  * @package    Wordlift
10 10
  * @subpackage Wordlift/includes
11 11
  */
12
-if ( ! class_exists( 'Walker_Category_Checklist' ) ) {
13
-	require_once( ABSPATH . 'wp-admin/includes/template.php' );
12
+if ( ! class_exists('Walker_Category_Checklist')) {
13
+	require_once(ABSPATH.'wp-admin/includes/template.php');
14 14
 }
15 15
 
16 16
 /**
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy.
38 38
 	 */
39
-	function terms_checklist_args( $args ) {
39
+	function terms_checklist_args($args) {
40 40
 
41
-		if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
41
+		if ( ! isset($args['taxonomy']) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) {
42 42
 			return $args;
43 43
 		}
44 44
 
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @return string The hierarchical item output.
68 68
 	 */
69
-	public function walk( $elements, $max_depth, $args = array() ) {
69
+	public function walk($elements, $max_depth, $args = array()) {
70 70
 
71 71
 		// `max_depth` force to -1 to display a flat taxonomy.
72 72
 		//
73 73
 		// See https://github.com/insideout10/wordlift-plugin/issues/305
74
-		$output = parent::walk( $elements, - 1, $args );
74
+		$output = parent::walk($elements, - 1, $args);
75 75
 
76 76
 		$output = str_replace(
77
-			array( "type=\"checkbox\"", "type='checkbox'" ),
78
-			array( "type=\"radio\"", "type='radio'" ),
77
+			array("type=\"checkbox\"", "type='checkbox'"),
78
+			array("type=\"radio\"", "type='radio'"),
79 79
 			$output
80 80
 		);
81 81
 
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
94 94
 	 * @param int    $id       ID of the current term.
95 95
 	 */
96
-	public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
96
+	public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) {
97 97
 		global $post;
98 98
 
99
-		if ( ! isset( $post ) ) {
99
+		if ( ! isset($post)) {
100 100
 			return;
101 101
 		}
102 102
 
103
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
103
+		if (Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
104 104
 		     || 'article' !== $category->slug
105
-		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
106
-			parent::start_el( $output, $category, $depth, $args, $id );
105
+		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) {
106
+			parent::start_el($output, $category, $depth, $args, $id);
107 107
 		}
108 108
 	}
109 109
 
@@ -117,17 +117,17 @@  discard block
 block discarded – undo
117 117
 	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
118 118
 	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
119 119
 	 */
120
-	public function end_el( &$output, $category, $depth = 0, $args = array() ) {
120
+	public function end_el(&$output, $category, $depth = 0, $args = array()) {
121 121
 		global $post;
122 122
 
123
-		if ( ! isset( $post ) ) {
123
+		if ( ! isset($post)) {
124 124
 			return;
125 125
 		}
126 126
 
127
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
127
+		if (Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
128 128
 		     || 'article' !== $category->slug
129
-		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
130
-			parent::end_el( $output, $category, $depth, $args );
129
+		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) {
130
+			parent::end_el($output, $category, $depth, $args);
131 131
 		}
132 132
 
133 133
 	}
Please login to merge, or discard this patch.
src/admin/wordlift_admin_menu.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
  */
16 16
 function wl_admin_menu() {
17 17
 
18
-	$menu_slug  = 'wl_admin_menu';
19
-	$capability = 'manage_options';
18
+    $menu_slug  = 'wl_admin_menu';
19
+    $capability = 'manage_options';
20 20
 
21
-	// see http://codex.wordpress.org/Function_Reference/add_menu_page
22
-	add_menu_page(
23
-		__( 'WordLift', 'wordlift' ), // page title
24
-		__( 'WordLift', 'wordlift' ), // menu title
25
-		$capability,                 // capabilities
26
-		$menu_slug,                  // menu slug
27
-		//'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
28
-		'wl_configuration_admin_menu_callback',
29
-		WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg' );  // icon URL 20x20 px
21
+    // see http://codex.wordpress.org/Function_Reference/add_menu_page
22
+    add_menu_page(
23
+        __( 'WordLift', 'wordlift' ), // page title
24
+        __( 'WordLift', 'wordlift' ), // menu title
25
+        $capability,                 // capabilities
26
+        $menu_slug,                  // menu slug
27
+        //'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
28
+        'wl_configuration_admin_menu_callback',
29
+        WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg' );  // icon URL 20x20 px
30 30
 
31
-	// Call hooked functions.
32
-	do_action( 'wl_admin_menu', $menu_slug, $capability );
31
+    // Call hooked functions.
32
+    do_action( 'wl_admin_menu', $menu_slug, $capability );
33 33
 
34
-	// Remove duplicate 'WordLift' subpage created by WordPress.
35
-	remove_submenu_page( $menu_slug, $menu_slug );
34
+    // Remove duplicate 'WordLift' subpage created by WordPress.
35
+    remove_submenu_page( $menu_slug, $menu_slug );
36 36
 
37 37
 }
38 38
 
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
  * @since 3.15.0
47 47
  */
48 48
 function wl_remove_entity_type_menu() {
49
-	/*
49
+    /*
50 50
 	 * Remove from the menu links to the entity type admin page when
51 51
 	 * under non entity hierarchy.
52 52
 	 */
53
-	foreach ( Wordlift_Entity_Service::valid_entity_post_types() as $post_type ) {
54
-		// In the context of admin menues post has no explicit indication of post type in the urls.
55
-		if ( 'post' !== $post_type ) {
56
-			remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
57
-		}
53
+    foreach ( Wordlift_Entity_Service::valid_entity_post_types() as $post_type ) {
54
+        // In the context of admin menues post has no explicit indication of post type in the urls.
55
+        if ( 'post' !== $post_type ) {
56
+            remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
57
+        }
58 58
 
59
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post_type ) {
60
-			remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '&amp;post_type=' . $post_type );
61
-		}
62
-	}
59
+        if ( Wordlift_Entity_Service::TYPE_NAME !== $post_type ) {
60
+            remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '&amp;post_type=' . $post_type );
61
+        }
62
+    }
63 63
 }
64 64
 
65 65
 add_action( 'admin_menu', 'wl_remove_entity_type_menu', 100 );
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function wl_admin_menu_callback() {
73 73
 
74
-	if ( ! current_user_can( 'manage_options' ) ) {
75
-		wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
76
-	}
74
+    if ( ! current_user_can( 'manage_options' ) ) {
75
+        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
76
+    }
77 77
 
78
-	echo '<div class="wrap">';
79
-	echo '<p>Here is where the form would go if I actually had options.</p>';
80
-	echo '</div>';
78
+    echo '<div class="wrap">';
79
+    echo '<p>Here is where the form would go if I actually had options.</p>';
80
+    echo '</div>';
81 81
 
82 82
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,23 +20,23 @@  discard block
 block discarded – undo
20 20
 
21 21
 	// see http://codex.wordpress.org/Function_Reference/add_menu_page
22 22
 	add_menu_page(
23
-		__( 'WordLift', 'wordlift' ), // page title
24
-		__( 'WordLift', 'wordlift' ), // menu title
25
-		$capability,                 // capabilities
26
-		$menu_slug,                  // menu slug
23
+		__('WordLift', 'wordlift'), // page title
24
+		__('WordLift', 'wordlift'), // menu title
25
+		$capability, // capabilities
26
+		$menu_slug, // menu slug
27 27
 		//'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
28 28
 		'wl_configuration_admin_menu_callback',
29
-		WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg' );  // icon URL 20x20 px
29
+		WP_CONTENT_URL.'/plugins/wordlift/images/svg/wl-logo-icon.svg' ); // icon URL 20x20 px
30 30
 
31 31
 	// Call hooked functions.
32
-	do_action( 'wl_admin_menu', $menu_slug, $capability );
32
+	do_action('wl_admin_menu', $menu_slug, $capability);
33 33
 
34 34
 	// Remove duplicate 'WordLift' subpage created by WordPress.
35
-	remove_submenu_page( $menu_slug, $menu_slug );
35
+	remove_submenu_page($menu_slug, $menu_slug);
36 36
 
37 37
 }
38 38
 
39
-add_action( 'admin_menu', 'wl_admin_menu' );
39
+add_action('admin_menu', 'wl_admin_menu');
40 40
 
41 41
 /**
42 42
  * This function is called by the *admin_menu* hook to remove for the admin menu
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
 	 * Remove from the menu links to the entity type admin page when
51 51
 	 * under non entity hierarchy.
52 52
 	 */
53
-	foreach ( Wordlift_Entity_Service::valid_entity_post_types() as $post_type ) {
53
+	foreach (Wordlift_Entity_Service::valid_entity_post_types() as $post_type) {
54 54
 		// In the context of admin menues post has no explicit indication of post type in the urls.
55
-		if ( 'post' !== $post_type ) {
56
-			remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
55
+		if ('post' !== $post_type) {
56
+			remove_submenu_page('edit.php', 'edit-tags.php?taxonomy='.Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
57 57
 		}
58 58
 
59
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post_type ) {
60
-			remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '&amp;post_type=' . $post_type );
59
+		if (Wordlift_Entity_Service::TYPE_NAME !== $post_type) {
60
+			remove_submenu_page('edit.php?post_type='.$post_type, 'edit-tags.php?taxonomy='.Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'&amp;post_type='.$post_type);
61 61
 		}
62 62
 	}
63 63
 }
64 64
 
65
-add_action( 'admin_menu', 'wl_remove_entity_type_menu', 100 );
65
+add_action('admin_menu', 'wl_remove_entity_type_menu', 100);
66 66
 
67 67
 /**
68 68
  * This function is called as a callback by the *wl_admin_menu* to display the actual page.
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function wl_admin_menu_callback() {
73 73
 
74
-	if ( ! current_user_can( 'manage_options' ) ) {
75
-		wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
74
+	if ( ! current_user_can('manage_options')) {
75
+		wp_die(__('You do not have sufficient permissions to access this page.'));
76 76
 	}
77 77
 
78 78
 	echo '<div class="wrap">';
Please login to merge, or discard this patch.
src/admin/class-wordlift-entity-type-settings.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -30,208 +30,208 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class Wordlift_Admin_Entity_Type_Settings {
32 32
 
33
-	/**
34
-	 * A {@link Wordlift_Log_Service} instance.
35
-	 *
36
-	 * @since  3.14.0
37
-	 * @access private
38
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
39
-	 */
40
-	private $log;
41
-
42
-	/**
43
-	 * Create a {@link Wordlift_Admin_Entity_Type_Settings} instance.
44
-	 *
45
-	 * @since 3.14.0
46
-	 */
47
-	public function __construct() {
48
-
49
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Admin_Entity_Type_Settings' );
50
-
51
-	}
52
-
53
-	/**
54
-	 * Handle menu registration.
55
-	 *
56
-	 * The registration is required, although we do not want to actually to add
57
-	 * an item to the menu, in order to "whitelist" the access to the settings page in
58
-	 * the admin.
59
-	 *
60
-	 * @since 3.11.0
61
-	 */
62
-	public function admin_menu() {
63
-
64
-		/*
33
+    /**
34
+     * A {@link Wordlift_Log_Service} instance.
35
+     *
36
+     * @since  3.14.0
37
+     * @access private
38
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
39
+     */
40
+    private $log;
41
+
42
+    /**
43
+     * Create a {@link Wordlift_Admin_Entity_Type_Settings} instance.
44
+     *
45
+     * @since 3.14.0
46
+     */
47
+    public function __construct() {
48
+
49
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Admin_Entity_Type_Settings' );
50
+
51
+    }
52
+
53
+    /**
54
+     * Handle menu registration.
55
+     *
56
+     * The registration is required, although we do not want to actually to add
57
+     * an item to the menu, in order to "whitelist" the access to the settings page in
58
+     * the admin.
59
+     *
60
+     * @since 3.11.0
61
+     */
62
+    public function admin_menu() {
63
+
64
+        /*
65 65
 		 * Before anything else check if an settings form was submitted.
66 66
 		 * This has to be done before any output happens in order to be able to
67 67
 		 * display proper "die" error messages and redirect.
68 68
 		 */
69
-		if ( isset( $_GET['page'] ) && ( 'wl_entity_type_settings' === $_GET['page'] ) ) {
69
+        if ( isset( $_GET['page'] ) && ( 'wl_entity_type_settings' === $_GET['page'] ) ) {
70 70
 
71
-			// Validate inputs. Do not return on invalid parameters or capabilities.
72
-			$this->validate_proper_term();
71
+            // Validate inputs. Do not return on invalid parameters or capabilities.
72
+            $this->validate_proper_term();
73 73
 
74
-			// If proper form submission, handle it and redirect back to the settings page.
75
-			if ( isset( $_POST['action'] ) && ( 'wl_edit_entity_type_term' === $_POST['action'] ) ) {
76
-				$this->handle_form_submission();
77
-			}
74
+            // If proper form submission, handle it and redirect back to the settings page.
75
+            if ( isset( $_POST['action'] ) && ( 'wl_edit_entity_type_term' === $_POST['action'] ) ) {
76
+                $this->handle_form_submission();
77
+            }
78 78
 
79
-			// Register admin notices handler.
80
-			add_action( 'admin_notices', array( $this, 'admin_notice' ) );
79
+            // Register admin notices handler.
80
+            add_action( 'admin_notices', array( $this, 'admin_notice' ) );
81 81
 
82
-		}
82
+        }
83 83
 
84
-		/*
84
+        /*
85 85
 		 * Use a null parent slug to prevent the menu from actually appearing
86 86
 		 * in the admin menu.
87 87
 		 */
88
-		// @todo: use the new {@link Wordlift_Admin_Page}.
89
-		add_submenu_page(
90
-			null,
91
-			__( 'Edit Entity term', 'wordlift' ),
92
-			__( 'Edit Entity term', 'wordlift' ),
93
-			'manage_options',
94
-			'wl_entity_type_settings',
95
-			array( $this, 'render' )
96
-		);
97
-	}
98
-
99
-	/**
100
-	 * Output admin notices if needed, based on the message url parameter.
101
-	 * A value of 1 indicates that a successful save was done.
102
-	 *
103
-	 * @since 3.11.0
104
-	 */
105
-	function admin_notice() {
106
-		if ( isset( $_GET['message'] ) && ( '1' === $_GET['message'] ) ) {
107
-			?>
88
+        // @todo: use the new {@link Wordlift_Admin_Page}.
89
+        add_submenu_page(
90
+            null,
91
+            __( 'Edit Entity term', 'wordlift' ),
92
+            __( 'Edit Entity term', 'wordlift' ),
93
+            'manage_options',
94
+            'wl_entity_type_settings',
95
+            array( $this, 'render' )
96
+        );
97
+    }
98
+
99
+    /**
100
+     * Output admin notices if needed, based on the message url parameter.
101
+     * A value of 1 indicates that a successful save was done.
102
+     *
103
+     * @since 3.11.0
104
+     */
105
+    function admin_notice() {
106
+        if ( isset( $_GET['message'] ) && ( '1' === $_GET['message'] ) ) {
107
+            ?>
108 108
 			<div class="notice notice-success is-dismissible">
109 109
 				<p><?php esc_html_e( 'Settings saved', 'wordlift' ) ?></p>
110 110
 			</div>
111 111
 			<?php
112
-		}
113
-	}
114
-
115
-	/**
116
-	 * Validate the existence of the entity type indicated by the tag_ID url
117
-	 * parameter before doing any processing. Done before any output to mimic
118
-	 * the way WordPress handles same situation with "normal" term editing screens.
119
-	 *
120
-	 * @since 3.11.0
121
-	 */
122
-	function validate_proper_term() {
123
-
124
-		// Validate capabilities.
125
-		if ( ! current_user_can( 'manage_options' ) ) {
126
-			wp_die(
127
-				'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
128
-				'<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
129
-				403
130
-			);
131
-		}
132
-
133
-		// Get the term id and the actual term.
134
-		$term_id = (int) $_REQUEST['tag_ID'];
135
-
136
-		if ( ! term_exists( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) ) {
137
-			wp_die( __( 'You attempted to edit an entity type term that doesn&#8217;t exist.', 'wordlift' ) );
138
-		}
139
-
140
-	}
141
-
142
-	/**
143
-	 * Handle the form submission of the settings form. On successful
144
-	 * handling redirect tp the setting edit page.
145
-	 *
146
-	 * @since 3.11.0
147
-	 */
148
-	function handle_form_submission() {
149
-
150
-		$term_id = (int) $_POST['tag_ID'];
151
-
152
-		// Check the nonce.
153
-		check_admin_referer( 'update-entity_type_term_' . $term_id );
154
-
155
-		$term = get_term( $term_id, 'wl_entity_type' );
156
-
157
-		$this->set_setting(
158
-			$term_id,
159
-			trim( wp_unslash( $_POST['title'] ) ),
160
-			wp_unslash( $_POST['description'] )
161
-		);
162
-
163
-		// Redirect back to the term settings page and indicate a save was done.
164
-		$url = admin_url( "admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id&message=1" );
165
-
166
-		wp_redirect( $url );
167
-		exit;
168
-
169
-	}
170
-
171
-	/**
172
-	 * Render the settings page for the term.
173
-	 *
174
-	 * Access and parameter validity is assumed to be done earlier.
175
-	 *
176
-	 * @since 3.11.0
177
-	 */
178
-	function render() {
179
-
180
-		// Set variables used by the partial
181
-		$term_id  = absint( $_REQUEST['tag_ID'] );
182
-		$settings = $this->get_setting( $term_id );
183
-
184
-		include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-entity-type-settings.php';
185
-
186
-	}
187
-
188
-	/**
189
-	 * Store the entity type term settings in the DB
190
-	 *
191
-	 * @since 3.11.0
192
-	 *
193
-	 * @param    integer $term_id     The ID of the entity type term
194
-	 * @param    string  $title       The override for the terms title.
195
-	 * @param    string  $description The override for the terms description.
196
-	 *
197
-	 */
198
-	function set_setting( $term_id, $title, $description ) {
199
-
200
-		$settings             = get_option( 'wl_entity_type_settings', array() );
201
-		$settings[ $term_id ] = array(
202
-			'title'       => $title,
203
-			'description' => $description,
204
-		);
205
-		update_option( 'wl_entity_type_settings', $settings );
206
-
207
-	}
208
-
209
-	/**
210
-	 * Retrieve the entity type term settings from the DB
211
-	 *
212
-	 * @since 3.11.0
213
-	 *
214
-	 * @param    integer $term_id The ID of the entity type term
215
-	 *
216
-	 * @return    null|array {
217
-	 *                null is returned when there are no settings otherwise
218
-	 *                an array is returned with following fields
219
-	 *
220
-	 * @type    string    title    The overriding title for the term
221
-	 * @type    string    description    The overriding description for the term
222
-	 *            }
223
-	 */
224
-	function get_setting( $term_id ) {
225
-
226
-		$settings = get_option( 'wl_entity_type_settings', array() );
227
-
228
-		if ( isset( $settings[ $term_id ] ) ) {
229
-			return $settings[ $term_id ];
230
-		}
231
-
232
-		$this->log->warn( "No settings found for term id $term_id." );
233
-
234
-		return null;
235
-	}
112
+        }
113
+    }
114
+
115
+    /**
116
+     * Validate the existence of the entity type indicated by the tag_ID url
117
+     * parameter before doing any processing. Done before any output to mimic
118
+     * the way WordPress handles same situation with "normal" term editing screens.
119
+     *
120
+     * @since 3.11.0
121
+     */
122
+    function validate_proper_term() {
123
+
124
+        // Validate capabilities.
125
+        if ( ! current_user_can( 'manage_options' ) ) {
126
+            wp_die(
127
+                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
128
+                '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
129
+                403
130
+            );
131
+        }
132
+
133
+        // Get the term id and the actual term.
134
+        $term_id = (int) $_REQUEST['tag_ID'];
135
+
136
+        if ( ! term_exists( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) ) {
137
+            wp_die( __( 'You attempted to edit an entity type term that doesn&#8217;t exist.', 'wordlift' ) );
138
+        }
139
+
140
+    }
141
+
142
+    /**
143
+     * Handle the form submission of the settings form. On successful
144
+     * handling redirect tp the setting edit page.
145
+     *
146
+     * @since 3.11.0
147
+     */
148
+    function handle_form_submission() {
149
+
150
+        $term_id = (int) $_POST['tag_ID'];
151
+
152
+        // Check the nonce.
153
+        check_admin_referer( 'update-entity_type_term_' . $term_id );
154
+
155
+        $term = get_term( $term_id, 'wl_entity_type' );
156
+
157
+        $this->set_setting(
158
+            $term_id,
159
+            trim( wp_unslash( $_POST['title'] ) ),
160
+            wp_unslash( $_POST['description'] )
161
+        );
162
+
163
+        // Redirect back to the term settings page and indicate a save was done.
164
+        $url = admin_url( "admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id&message=1" );
165
+
166
+        wp_redirect( $url );
167
+        exit;
168
+
169
+    }
170
+
171
+    /**
172
+     * Render the settings page for the term.
173
+     *
174
+     * Access and parameter validity is assumed to be done earlier.
175
+     *
176
+     * @since 3.11.0
177
+     */
178
+    function render() {
179
+
180
+        // Set variables used by the partial
181
+        $term_id  = absint( $_REQUEST['tag_ID'] );
182
+        $settings = $this->get_setting( $term_id );
183
+
184
+        include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-entity-type-settings.php';
185
+
186
+    }
187
+
188
+    /**
189
+     * Store the entity type term settings in the DB
190
+     *
191
+     * @since 3.11.0
192
+     *
193
+     * @param    integer $term_id     The ID of the entity type term
194
+     * @param    string  $title       The override for the terms title.
195
+     * @param    string  $description The override for the terms description.
196
+     *
197
+     */
198
+    function set_setting( $term_id, $title, $description ) {
199
+
200
+        $settings             = get_option( 'wl_entity_type_settings', array() );
201
+        $settings[ $term_id ] = array(
202
+            'title'       => $title,
203
+            'description' => $description,
204
+        );
205
+        update_option( 'wl_entity_type_settings', $settings );
206
+
207
+    }
208
+
209
+    /**
210
+     * Retrieve the entity type term settings from the DB
211
+     *
212
+     * @since 3.11.0
213
+     *
214
+     * @param    integer $term_id The ID of the entity type term
215
+     *
216
+     * @return    null|array {
217
+     *                null is returned when there are no settings otherwise
218
+     *                an array is returned with following fields
219
+     *
220
+     * @type    string    title    The overriding title for the term
221
+     * @type    string    description    The overriding description for the term
222
+     *            }
223
+     */
224
+    function get_setting( $term_id ) {
225
+
226
+        $settings = get_option( 'wl_entity_type_settings', array() );
227
+
228
+        if ( isset( $settings[ $term_id ] ) ) {
229
+            return $settings[ $term_id ];
230
+        }
231
+
232
+        $this->log->warn( "No settings found for term id $term_id." );
233
+
234
+        return null;
235
+    }
236 236
 
237 237
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @since      3.11.0
13 13
  */
14 14
 
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function __construct() {
48 48
 
49
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Admin_Entity_Type_Settings' );
49
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Admin_Entity_Type_Settings');
50 50
 
51 51
 	}
52 52
 
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
 		 * This has to be done before any output happens in order to be able to
67 67
 		 * display proper "die" error messages and redirect.
68 68
 		 */
69
-		if ( isset( $_GET['page'] ) && ( 'wl_entity_type_settings' === $_GET['page'] ) ) {
69
+		if (isset($_GET['page']) && ('wl_entity_type_settings' === $_GET['page'])) {
70 70
 
71 71
 			// Validate inputs. Do not return on invalid parameters or capabilities.
72 72
 			$this->validate_proper_term();
73 73
 
74 74
 			// If proper form submission, handle it and redirect back to the settings page.
75
-			if ( isset( $_POST['action'] ) && ( 'wl_edit_entity_type_term' === $_POST['action'] ) ) {
75
+			if (isset($_POST['action']) && ('wl_edit_entity_type_term' === $_POST['action'])) {
76 76
 				$this->handle_form_submission();
77 77
 			}
78 78
 
79 79
 			// Register admin notices handler.
80
-			add_action( 'admin_notices', array( $this, 'admin_notice' ) );
80
+			add_action('admin_notices', array($this, 'admin_notice'));
81 81
 
82 82
 		}
83 83
 
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 		// @todo: use the new {@link Wordlift_Admin_Page}.
89 89
 		add_submenu_page(
90 90
 			null,
91
-			__( 'Edit Entity term', 'wordlift' ),
92
-			__( 'Edit Entity term', 'wordlift' ),
91
+			__('Edit Entity term', 'wordlift'),
92
+			__('Edit Entity term', 'wordlift'),
93 93
 			'manage_options',
94 94
 			'wl_entity_type_settings',
95
-			array( $this, 'render' )
95
+			array($this, 'render')
96 96
 		);
97 97
 	}
98 98
 
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
 	 * @since 3.11.0
104 104
 	 */
105 105
 	function admin_notice() {
106
-		if ( isset( $_GET['message'] ) && ( '1' === $_GET['message'] ) ) {
106
+		if (isset($_GET['message']) && ('1' === $_GET['message'])) {
107 107
 			?>
108 108
 			<div class="notice notice-success is-dismissible">
109
-				<p><?php esc_html_e( 'Settings saved', 'wordlift' ) ?></p>
109
+				<p><?php esc_html_e('Settings saved', 'wordlift') ?></p>
110 110
 			</div>
111 111
 			<?php
112 112
 		}
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 	function validate_proper_term() {
123 123
 
124 124
 		// Validate capabilities.
125
-		if ( ! current_user_can( 'manage_options' ) ) {
125
+		if ( ! current_user_can('manage_options')) {
126 126
 			wp_die(
127
-				'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
128
-				'<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
127
+				'<h1>'.__('Cheatin&#8217; uh?').'</h1>'.
128
+				'<p>'.__('Sorry, you are not allowed to edit this item.').'</p>',
129 129
 				403
130 130
 			);
131 131
 		}
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 		// Get the term id and the actual term.
134 134
 		$term_id = (int) $_REQUEST['tag_ID'];
135 135
 
136
-		if ( ! term_exists( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) ) {
137
-			wp_die( __( 'You attempted to edit an entity type term that doesn&#8217;t exist.', 'wordlift' ) );
136
+		if ( ! term_exists($term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME)) {
137
+			wp_die(__('You attempted to edit an entity type term that doesn&#8217;t exist.', 'wordlift'));
138 138
 		}
139 139
 
140 140
 	}
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
 		$term_id = (int) $_POST['tag_ID'];
151 151
 
152 152
 		// Check the nonce.
153
-		check_admin_referer( 'update-entity_type_term_' . $term_id );
153
+		check_admin_referer('update-entity_type_term_'.$term_id);
154 154
 
155
-		$term = get_term( $term_id, 'wl_entity_type' );
155
+		$term = get_term($term_id, 'wl_entity_type');
156 156
 
157 157
 		$this->set_setting(
158 158
 			$term_id,
159
-			trim( wp_unslash( $_POST['title'] ) ),
160
-			wp_unslash( $_POST['description'] )
159
+			trim(wp_unslash($_POST['title'])),
160
+			wp_unslash($_POST['description'])
161 161
 		);
162 162
 
163 163
 		// Redirect back to the term settings page and indicate a save was done.
164
-		$url = admin_url( "admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id&message=1" );
164
+		$url = admin_url("admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id&message=1");
165 165
 
166
-		wp_redirect( $url );
166
+		wp_redirect($url);
167 167
 		exit;
168 168
 
169 169
 	}
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 	function render() {
179 179
 
180 180
 		// Set variables used by the partial
181
-		$term_id  = absint( $_REQUEST['tag_ID'] );
182
-		$settings = $this->get_setting( $term_id );
181
+		$term_id  = absint($_REQUEST['tag_ID']);
182
+		$settings = $this->get_setting($term_id);
183 183
 
184
-		include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-entity-type-settings.php';
184
+		include plugin_dir_path(dirname(__FILE__)).'admin/partials/wordlift-admin-entity-type-settings.php';
185 185
 
186 186
 	}
187 187
 
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
 	 * @param    string  $description The override for the terms description.
196 196
 	 *
197 197
 	 */
198
-	function set_setting( $term_id, $title, $description ) {
198
+	function set_setting($term_id, $title, $description) {
199 199
 
200
-		$settings             = get_option( 'wl_entity_type_settings', array() );
201
-		$settings[ $term_id ] = array(
200
+		$settings             = get_option('wl_entity_type_settings', array());
201
+		$settings[$term_id] = array(
202 202
 			'title'       => $title,
203 203
 			'description' => $description,
204 204
 		);
205
-		update_option( 'wl_entity_type_settings', $settings );
205
+		update_option('wl_entity_type_settings', $settings);
206 206
 
207 207
 	}
208 208
 
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
 	 * @type    string    description    The overriding description for the term
222 222
 	 *            }
223 223
 	 */
224
-	function get_setting( $term_id ) {
224
+	function get_setting($term_id) {
225 225
 
226
-		$settings = get_option( 'wl_entity_type_settings', array() );
226
+		$settings = get_option('wl_entity_type_settings', array());
227 227
 
228
-		if ( isset( $settings[ $term_id ] ) ) {
229
-			return $settings[ $term_id ];
228
+		if (isset($settings[$term_id])) {
229
+			return $settings[$term_id];
230 230
 		}
231 231
 
232
-		$this->log->warn( "No settings found for term id $term_id." );
232
+		$this->log->warn("No settings found for term id $term_id.");
233 233
 
234 234
 		return null;
235 235
 	}
Please login to merge, or discard this patch.