@@ -44,21 +44,21 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @since 1.0.0 |
46 | 46 | */ |
47 | -require_once( dirname( __FILE__ ) . '/includes/constants.php' ); |
|
47 | +require_once(dirname(__FILE__).'/includes/constants.php'); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * The module's functions. |
51 | 51 | * |
52 | 52 | * @since 1.0.0 |
53 | 53 | */ |
54 | -require_once( dirname( __FILE__ ) . '/includes/functions.php' ); |
|
54 | +require_once(dirname(__FILE__).'/includes/functions.php'); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * The module's actions and filters. |
58 | 58 | * |
59 | 59 | * @since 1.0.0 |
60 | 60 | */ |
61 | -require_once( dirname( __FILE__ ) . '/includes/actions.php' ); |
|
61 | +require_once(dirname(__FILE__).'/includes/actions.php'); |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Class autoloader. |
@@ -67,22 +67,22 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @since 1.0.0 |
69 | 69 | */ |
70 | -require_once( dirname( __FILE__ ) . '/includes/classes/class/autoloader.php' ); |
|
70 | +require_once(dirname(__FILE__).'/includes/classes/class/autoloader.php'); |
|
71 | 71 | |
72 | 72 | // Register the classes to autoload. |
73 | 73 | WordPoints_Class_Autoloader::register_dir( |
74 | - dirname( __FILE__ ) . '/includes/classes' |
|
74 | + dirname(__FILE__).'/includes/classes' |
|
75 | 75 | , 'WordPoints_' |
76 | 76 | ); |
77 | 77 | |
78 | -if ( is_admin() ) { |
|
78 | +if (is_admin()) { |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Administration-side code. |
82 | 82 | * |
83 | 83 | * @since 1.0.0 |
84 | 84 | */ |
85 | - require_once( dirname( __FILE__ ) . '/admin/admin.php' ); |
|
85 | + require_once(dirname(__FILE__).'/admin/admin.php'); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // EOF |
@@ -28,46 +28,46 @@ |
||
28 | 28 | /** |
29 | 29 | * @since 1.0.0 |
30 | 30 | */ |
31 | - public function __construct( $slug ) { |
|
31 | + public function __construct($slug) { |
|
32 | 32 | |
33 | 33 | $this->registry = new WordPoints_Class_Registry(); |
34 | 34 | |
35 | - parent::__construct( $slug ); |
|
35 | + parent::__construct($slug); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @since 1.0.0 |
40 | 40 | */ |
41 | - public function get_all( array $args = array() ) { |
|
42 | - return $this->registry->get_all( $args ); |
|
41 | + public function get_all(array $args = array()) { |
|
42 | + return $this->registry->get_all($args); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @since 1.0.0 |
47 | 47 | */ |
48 | - public function get( $slug, array $args = array() ) { |
|
49 | - return $this->registry->get( $slug, $args ); |
|
48 | + public function get($slug, array $args = array()) { |
|
49 | + return $this->registry->get($slug, $args); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @since 1.0.0 |
54 | 54 | */ |
55 | - public function register( $slug, $class, array $args = array() ) { |
|
56 | - return $this->registry->register( $slug, $class, $args ); |
|
55 | + public function register($slug, $class, array $args = array()) { |
|
56 | + return $this->registry->register($slug, $class, $args); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @since 1.0.0 |
61 | 61 | */ |
62 | - public function deregister( $slug ) { |
|
63 | - $this->registry->deregister( $slug ); |
|
62 | + public function deregister($slug) { |
|
63 | + $this->registry->deregister($slug); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @since 1.0.0 |
68 | 68 | */ |
69 | - public function is_registered( $slug ) { |
|
70 | - return $this->registry->is_registered( $slug ); |
|
69 | + public function is_registered($slug) { |
|
70 | + return $this->registry->is_registered($slug); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | * @param string $dir The full path of the directory. |
63 | 63 | * @param string $prefix The prefix used for class names in this directory. |
64 | 64 | */ |
65 | - public static function register_dir( $dir, $prefix ) { |
|
65 | + public static function register_dir($dir, $prefix) { |
|
66 | 66 | |
67 | - if ( ! self::$added_action ) { |
|
68 | - add_action( 'wordpoints_modules_loaded', __CLASS__ . '::init', 0 ); |
|
67 | + if ( ! self::$added_action) { |
|
68 | + add_action('wordpoints_modules_loaded', __CLASS__.'::init', 0); |
|
69 | 69 | self::$added_action = true; |
70 | 70 | } |
71 | 71 | |
72 | - self::$prefixes[ $prefix ]['length'] = strlen( $prefix ); |
|
73 | - self::$prefixes[ $prefix ]['dirs'][] = trailingslashit( $dir ); |
|
72 | + self::$prefixes[$prefix]['length'] = strlen($prefix); |
|
73 | + self::$prefixes[$prefix]['dirs'][] = trailingslashit($dir); |
|
74 | 74 | |
75 | 75 | self::$sorted = false; |
76 | 76 | } |
@@ -86,31 +86,31 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param string $class_name The name fo the class to load. |
88 | 88 | */ |
89 | - public static function load_class( $class_name ) { |
|
89 | + public static function load_class($class_name) { |
|
90 | 90 | |
91 | - if ( ! self::$sorted ) { |
|
92 | - arsort( self::$prefixes ); |
|
91 | + if ( ! self::$sorted) { |
|
92 | + arsort(self::$prefixes); |
|
93 | 93 | self::$sorted = true; |
94 | 94 | } |
95 | 95 | |
96 | - foreach ( self::$prefixes as $prefix => $data ) { |
|
96 | + foreach (self::$prefixes as $prefix => $data) { |
|
97 | 97 | |
98 | - if ( substr( $class_name, 0, $data['length'] ) !== $prefix ) { |
|
98 | + if (substr($class_name, 0, $data['length']) !== $prefix) { |
|
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | |
102 | - $trimmed_class_name = substr( $class_name, $data['length'] ); |
|
102 | + $trimmed_class_name = substr($class_name, $data['length']); |
|
103 | 103 | |
104 | - $file_name = str_replace( '_', '/', strtolower( $trimmed_class_name ) ); |
|
105 | - $file_name = $file_name . '.php'; |
|
104 | + $file_name = str_replace('_', '/', strtolower($trimmed_class_name)); |
|
105 | + $file_name = $file_name.'.php'; |
|
106 | 106 | |
107 | - foreach ( $data['dirs'] as $dir ) { |
|
107 | + foreach ($data['dirs'] as $dir) { |
|
108 | 108 | |
109 | - if ( ! file_exists( $dir . $file_name ) ) { |
|
109 | + if ( ! file_exists($dir.$file_name)) { |
|
110 | 110 | continue; |
111 | 111 | } |
112 | 112 | |
113 | - require_once( $dir . $file_name ); |
|
113 | + require_once($dir.$file_name); |
|
114 | 114 | |
115 | 115 | return; |
116 | 116 | } |
@@ -135,16 +135,16 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public static function init() { |
137 | 137 | |
138 | - if ( function_exists( 'spl_autoload_register' ) ) { |
|
138 | + if (function_exists('spl_autoload_register')) { |
|
139 | 139 | |
140 | - spl_autoload_register( __CLASS__ . '::load_class' ); |
|
140 | + spl_autoload_register(__CLASS__.'::load_class'); |
|
141 | 141 | |
142 | 142 | } else { |
143 | 143 | |
144 | - foreach ( self::$prefixes as $prefix => $data ) { |
|
145 | - foreach ( $data['dirs'] as $dir ) { |
|
146 | - if ( file_exists( $dir . '/index.php' ) ) { |
|
147 | - require( $dir . '/index.php' ); |
|
144 | + foreach (self::$prefixes as $prefix => $data) { |
|
145 | + foreach ($data['dirs'] as $dir) { |
|
146 | + if (file_exists($dir.'/index.php')) { |
|
147 | + require($dir.'/index.php'); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | } |
@@ -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 | } |