Completed
Push — develop ( 234d87...0f24a0 )
by David
02:37 queued 10s
created
src/admin/class-wordlift-entity-types-taxonomy-walker-5-3.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 ) {
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 ) {
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 ) {
69
+	public function walk($elements, $max_depth, ...$args) {
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.