@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @since 1.0.0 |
35 | 35 | */ |
36 | - public function get_all( array $args = array() ) { |
|
36 | + public function get_all(array $args = array()) { |
|
37 | 37 | |
38 | 38 | $items = array(); |
39 | 39 | |
40 | - foreach ( $this->classes as $parent_slug => $classes ) { |
|
41 | - $items[ $parent_slug ] = WordPoints_Class_Registry::construct_with_args( |
|
40 | + foreach ($this->classes as $parent_slug => $classes) { |
|
41 | + $items[$parent_slug] = WordPoints_Class_Registry::construct_with_args( |
|
42 | 42 | $classes |
43 | 43 | , $args |
44 | 44 | ); |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @since 1.0.0 |
52 | 52 | */ |
53 | - public function get_children( $parent_slug, array $args = array() ) { |
|
53 | + public function get_children($parent_slug, array $args = array()) { |
|
54 | 54 | |
55 | 55 | $items = array(); |
56 | 56 | |
57 | - if ( isset( $this->classes[ $parent_slug ] ) ) { |
|
57 | + if (isset($this->classes[$parent_slug])) { |
|
58 | 58 | |
59 | 59 | $items = WordPoints_Class_Registry::construct_with_args( |
60 | - $this->classes[ $parent_slug ] |
|
60 | + $this->classes[$parent_slug] |
|
61 | 61 | , $args |
62 | 62 | ); |
63 | 63 | } |
@@ -68,29 +68,29 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @since 1.0.0 |
70 | 70 | */ |
71 | - public function get( $parent_slug, $slug, array $args = array() ) { |
|
71 | + public function get($parent_slug, $slug, array $args = array()) { |
|
72 | 72 | |
73 | - if ( ! isset( $this->classes[ $parent_slug ][ $slug ] ) ) { |
|
73 | + if ( ! isset($this->classes[$parent_slug][$slug])) { |
|
74 | 74 | return false; |
75 | 75 | } |
76 | 76 | |
77 | - $class = $this->classes[ $parent_slug ][ $slug ]; |
|
77 | + $class = $this->classes[$parent_slug][$slug]; |
|
78 | 78 | |
79 | - if ( empty( $args ) ) { |
|
80 | - return new $class( $slug ); |
|
79 | + if (empty($args)) { |
|
80 | + return new $class($slug); |
|
81 | 81 | } else { |
82 | - array_unshift( $args, $slug ); |
|
82 | + array_unshift($args, $slug); |
|
83 | 83 | |
84 | - return wordpoints_construct_class_with_args( $class, $args ); |
|
84 | + return wordpoints_construct_class_with_args($class, $args); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @since 1.0.0 |
90 | 90 | */ |
91 | - public function register( $parent_slug, $slug, $class, array $args = array() ) { |
|
91 | + public function register($parent_slug, $slug, $class, array $args = array()) { |
|
92 | 92 | |
93 | - $this->classes[ $parent_slug ][ $slug ] = $class; |
|
93 | + $this->classes[$parent_slug][$slug] = $class; |
|
94 | 94 | |
95 | 95 | return true; |
96 | 96 | } |
@@ -98,26 +98,26 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * @since 1.0.0 |
100 | 100 | */ |
101 | - public function deregister( $parent_slug, $slug ) { |
|
102 | - unset( $this->classes[ $parent_slug ][ $slug ] ); |
|
101 | + public function deregister($parent_slug, $slug) { |
|
102 | + unset($this->classes[$parent_slug][$slug]); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | 106 | * @since 1.0.0 |
107 | 107 | */ |
108 | - public function deregister_children( $parent_slug ) { |
|
109 | - unset( $this->classes[ $parent_slug ] ); |
|
108 | + public function deregister_children($parent_slug) { |
|
109 | + unset($this->classes[$parent_slug]); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
113 | 113 | * @since 1.0.0 |
114 | 114 | */ |
115 | - public function is_registered( $parent_slug, $slug = null ) { |
|
115 | + public function is_registered($parent_slug, $slug = null) { |
|
116 | 116 | |
117 | - if ( isset( $slug ) ) { |
|
118 | - return isset( $this->classes[ $parent_slug ][ $slug ] ); |
|
117 | + if (isset($slug)) { |
|
118 | + return isset($this->classes[$parent_slug][$slug]); |
|
119 | 119 | } else { |
120 | - return isset( $this->classes[ $parent_slug ] ); |
|
120 | + return isset($this->classes[$parent_slug]); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return object[] The child objects, indexed by slug. |
39 | 39 | */ |
40 | - public function get_children( $parent_slug ); |
|
40 | + public function get_children($parent_slug); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Get an object by its slug. |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return object|false The object or false on failure. |
51 | 51 | */ |
52 | - public function get( $parent_slug, $slug ); |
|
52 | + public function get($parent_slug, $slug); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Register a type of object. |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return bool Whether the class was registered successfully. |
65 | 65 | */ |
66 | - public function register( $parent_slug, $slug, $class, array $args = array() ); |
|
66 | + public function register($parent_slug, $slug, $class, array $args = array()); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Deregister a type of object. |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param string $parent_slug The group slug. |
74 | 74 | * @param string $slug The slug of the class to deregister. |
75 | 75 | */ |
76 | - public function deregister( $parent_slug, $slug ); |
|
76 | + public function deregister($parent_slug, $slug); |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Deregister all children of a particular parent. |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @param string $parent_slug The group slug. |
84 | 84 | */ |
85 | - public function deregister_children( $parent_slug ); |
|
85 | + public function deregister_children($parent_slug); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Check if a type of object is registered by its slug. |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return bool Whether the class is registered. |
99 | 99 | */ |
100 | - public function is_registered( $parent_slug, $slug = null ); |
|
100 | + public function is_registered($parent_slug, $slug = null); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // EOF |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @since 1.0.0 |
31 | 31 | */ |
32 | - public function get_all( array $args = array() ) { |
|
32 | + public function get_all(array $args = array()) { |
|
33 | 33 | |
34 | - $classes = array_diff_key( $this->classes, $this->objects ); |
|
34 | + $classes = array_diff_key($this->classes, $this->objects); |
|
35 | 35 | |
36 | - if ( ! empty( $classes ) ) { |
|
36 | + if ( ! empty($classes)) { |
|
37 | 37 | |
38 | 38 | $objects = WordPoints_Class_Registry::construct_with_args( |
39 | 39 | $classes |
@@ -49,40 +49,40 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @since 1.0.0 |
51 | 51 | */ |
52 | - public function get( $slug, array $args = array() ) { |
|
52 | + public function get($slug, array $args = array()) { |
|
53 | 53 | |
54 | - if ( ! isset( $this->objects[ $slug ] ) ) { |
|
54 | + if ( ! isset($this->objects[$slug])) { |
|
55 | 55 | |
56 | - $object = parent::get( $slug, $args ); |
|
56 | + $object = parent::get($slug, $args); |
|
57 | 57 | |
58 | - if ( ! $object ) { |
|
58 | + if ( ! $object) { |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | |
62 | - $this->objects[ $slug ] = $object; |
|
62 | + $this->objects[$slug] = $object; |
|
63 | 63 | } |
64 | 64 | |
65 | - return $this->objects[ $slug ]; |
|
65 | + return $this->objects[$slug]; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @since 1.0.0 |
70 | 70 | */ |
71 | - public function register( $slug, $class, array $args = array() ) { |
|
71 | + public function register($slug, $class, array $args = array()) { |
|
72 | 72 | |
73 | - unset( $this->objects[ $slug ] ); |
|
73 | + unset($this->objects[$slug]); |
|
74 | 74 | |
75 | - return parent::register( $slug, $class, $args ); |
|
75 | + return parent::register($slug, $class, $args); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @since 1.0.0 |
80 | 80 | */ |
81 | - public function deregister( $slug ) { |
|
81 | + public function deregister($slug) { |
|
82 | 82 | |
83 | - parent::deregister( $slug ); |
|
83 | + parent::deregister($slug); |
|
84 | 84 | |
85 | - unset( $this->objects[ $slug ] ); |
|
85 | + unset($this->objects[$slug]); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return object|false The object or false if it is not registered. |
43 | 43 | */ |
44 | - public function get( $slug ); |
|
44 | + public function get($slug); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Register a type of object. |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return bool Whether the class was registered successfully. |
56 | 56 | */ |
57 | - public function register( $slug, $class, array $args = array() ); |
|
57 | + public function register($slug, $class, array $args = array()); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Deregister a type of object |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param string $slug The slug of the class to deregister. |
65 | 65 | */ |
66 | - public function deregister( $slug ); |
|
66 | + public function deregister($slug); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Check if a type of object is registered by its slug. |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return bool Whether the class is registered. |
76 | 76 | */ |
77 | - public function is_registered( $slug ); |
|
77 | + public function is_registered($slug); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // EOF |
@@ -17,14 +17,14 @@ |
||
17 | 17 | /** |
18 | 18 | * @since 1.0.0 |
19 | 19 | */ |
20 | - public function validate_value( $value ) { |
|
20 | + public function validate_value($value) { |
|
21 | 21 | |
22 | - wordpoints_int( $value ); |
|
22 | + wordpoints_int($value); |
|
23 | 23 | |
24 | - if ( false === $value ) { |
|
24 | + if (false === $value) { |
|
25 | 25 | return new WP_Error( |
26 | 26 | 'not_integer' |
27 | - , __( '%s must be an integer.', 'wordpoints' ) |
|
27 | + , __('%s must be an integer.', 'wordpoints') |
|
28 | 28 | ); |
29 | 29 | } |
30 | 30 |
@@ -20,12 +20,12 @@ |
||
20 | 20 | /** |
21 | 21 | * @since 1.0.0 |
22 | 22 | */ |
23 | - public function validate_value( $value ) { |
|
23 | + public function validate_value($value) { |
|
24 | 24 | |
25 | - if ( ! is_string( $value ) ) { |
|
25 | + if ( ! is_string($value)) { |
|
26 | 26 | return new WP_Error( |
27 | 27 | 'not_string' |
28 | - , __( '%s must be a text value.', 'wordpoints' ) |
|
28 | + , __('%s must be a text value.', 'wordpoints') |
|
29 | 29 | ); |
30 | 30 | } |
31 | 31 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * |
43 | 43 | * @return mixed|WP_Error The validated value or a WP_Error on failure. |
44 | 44 | */ |
45 | - public function validate_value( $value ); |
|
45 | + public function validate_value($value); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // EOF |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param string $entity_slug The slug of the entity type. |
54 | 54 | */ |
55 | - public function __construct( $entity_slug ) { |
|
55 | + public function __construct($entity_slug) { |
|
56 | 56 | |
57 | 57 | $this->entity_slug = $entity_slug; |
58 | - $this->entity_object = wordpoints_entities()->get( $this->entity_slug ); |
|
58 | + $this->entity_object = wordpoints_entities()->get($this->entity_slug); |
|
59 | 59 | |
60 | - parent::__construct( $this->entity_slug . '{}' ); |
|
60 | + parent::__construct($this->entity_slug.'{}'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return bool Whether the value was set successfully. |
82 | 82 | */ |
83 | - public function set_the_value( $values ) { |
|
83 | + public function set_the_value($values) { |
|
84 | 84 | |
85 | 85 | $this->the_entities = $this->the_value = array(); |
86 | 86 | |
87 | - if ( ! ( $this->entity_object instanceof WordPoints_Entity ) ) { |
|
87 | + if ( ! ($this->entity_object instanceof WordPoints_Entity)) { |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | |
91 | - foreach ( $values as $value ) { |
|
91 | + foreach ($values as $value) { |
|
92 | 92 | |
93 | 93 | $entity = clone $this->entity_object; |
94 | 94 | |
95 | - if ( $entity->set_the_value( $value ) ) { |
|
95 | + if ($entity->set_the_value($value)) { |
|
96 | 96 | $this->the_entities[] = $entity; |
97 | 97 | $this->the_value[] = $entity->get_the_id(); |
98 | 98 | } |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function get_title() { |
119 | 119 | |
120 | - if ( $this->entity_object ) { |
|
120 | + if ($this->entity_object) { |
|
121 | 121 | |
122 | 122 | return sprintf( |
123 | 123 | // translators: the singular name of an item |
124 | - __( '%s Collection', 'wordpoints' ) |
|
124 | + __('%s Collection', 'wordpoints') |
|
125 | 125 | , $this->entity_object->get_title() |
126 | 126 | ); |
127 | 127 | |
128 | 128 | } else { |
129 | - return __( 'Item Collection', 'wordpoints' ); |
|
129 | + return __('Item Collection', 'wordpoints'); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
@@ -78,9 +78,9 @@ |
||
78 | 78 | * |
79 | 79 | * @return bool Whether the value was set correctly. |
80 | 80 | */ |
81 | - public function set_the_value_from_entity( WordPoints_Entity $entity ) { |
|
81 | + public function set_the_value_from_entity(WordPoints_Entity $entity) { |
|
82 | 82 | |
83 | - $this->the_value = $entity->get_the_attr_value( $this->get_field() ); |
|
83 | + $this->the_value = $entity->get_the_attr_value($this->get_field()); |
|
84 | 84 | |
85 | 85 | return true; |
86 | 86 | } |