@@ -21,113 +21,113 @@ |
||
21 | 21 | * @coversNothing |
22 | 22 | */ |
23 | 23 | abstract class WordPoints_Importer_Hook_UnitTestCase |
24 | - extends WordPoints_Points_UnitTestCase { |
|
25 | - |
|
26 | - /** |
|
27 | - * The option where CubePoints stores the number of points to award for this. |
|
28 | - * |
|
29 | - * @since 1.2.0 |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - protected $cubepoints_option; |
|
34 | - |
|
35 | - /** |
|
36 | - * The type of hook being tested. |
|
37 | - * |
|
38 | - * @since 1.2.0 |
|
39 | - * |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - protected $type; |
|
43 | - |
|
44 | - /** |
|
45 | - * Test that the hook behaves properly. |
|
46 | - * |
|
47 | - * @since 1.2.0 |
|
48 | - * |
|
49 | - * @param string $type The type of test. |
|
50 | - * |
|
51 | - * @dataProvider data_provider_types |
|
52 | - */ |
|
53 | - abstract public function test( $type ); |
|
54 | - |
|
55 | - /** |
|
56 | - * Data provider for types of tests. |
|
57 | - * |
|
58 | - * @since 1.2.0 |
|
59 | - * |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - public function data_provider_types() { |
|
63 | - return array( |
|
64 | - 'cubepoints' => array( 'cubepoints' ), |
|
65 | - 'wordpoints' => array( 'wordpoints' ), |
|
66 | - ); |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Set up before a test. |
|
71 | - * |
|
72 | - * @since 1.2.0 |
|
73 | - * |
|
74 | - * @param string $type The type of test being run. |
|
75 | - */ |
|
76 | - protected function before( $type ) { |
|
77 | - |
|
78 | - update_option( 'cp_reg_points', 0 ); |
|
79 | - |
|
80 | - $this->type = $type; |
|
81 | - |
|
82 | - update_option( $this->cubepoints_option, 10 ); |
|
83 | - |
|
84 | - if ( 'wordpoints' === $this->type ) { |
|
85 | - $this->do_points_import( 'settings' ); |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Get the number of points a user has. |
|
91 | - * |
|
92 | - * @since 1.2.0 |
|
93 | - * |
|
94 | - * @param int $user_id The user ID. |
|
95 | - * |
|
96 | - * @return int The number of points the user has. |
|
97 | - */ |
|
98 | - protected function get_user_points( $user_id ) { |
|
99 | - if ( 'cubepoints' === $this->type ) { |
|
100 | - return cp_getPoints( $user_id ); |
|
101 | - } else { |
|
102 | - return wordpoints_get_points( $user_id, 'points' ); |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Do the import for the points settings. |
|
108 | - * |
|
109 | - * @since 1.2.0 |
|
110 | - * |
|
111 | - * @param string $type The type of points import. |
|
112 | - */ |
|
113 | - protected function do_points_import( $type ) { |
|
114 | - |
|
115 | - $importer = new WordPoints_CubePoints_Importer( 'Test CubePoints' ); |
|
116 | - $feedback = new WordPoints_Importer_Tests_Feedback(); |
|
117 | - |
|
118 | - $importer->do_import( |
|
119 | - array( |
|
120 | - 'points' => array( |
|
121 | - $type => '1', |
|
122 | - '_data' => array( 'points_type' => 'points' ), |
|
123 | - ), |
|
124 | - ) |
|
125 | - , $feedback |
|
126 | - ); |
|
127 | - |
|
128 | - $this->assertCount( 4, $feedback->messages['info'] ); |
|
129 | - $this->assertCount( 1, $feedback->messages['success'] ); |
|
130 | - } |
|
24 | + extends WordPoints_Points_UnitTestCase { |
|
25 | + |
|
26 | + /** |
|
27 | + * The option where CubePoints stores the number of points to award for this. |
|
28 | + * |
|
29 | + * @since 1.2.0 |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + protected $cubepoints_option; |
|
34 | + |
|
35 | + /** |
|
36 | + * The type of hook being tested. |
|
37 | + * |
|
38 | + * @since 1.2.0 |
|
39 | + * |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + protected $type; |
|
43 | + |
|
44 | + /** |
|
45 | + * Test that the hook behaves properly. |
|
46 | + * |
|
47 | + * @since 1.2.0 |
|
48 | + * |
|
49 | + * @param string $type The type of test. |
|
50 | + * |
|
51 | + * @dataProvider data_provider_types |
|
52 | + */ |
|
53 | + abstract public function test( $type ); |
|
54 | + |
|
55 | + /** |
|
56 | + * Data provider for types of tests. |
|
57 | + * |
|
58 | + * @since 1.2.0 |
|
59 | + * |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + public function data_provider_types() { |
|
63 | + return array( |
|
64 | + 'cubepoints' => array( 'cubepoints' ), |
|
65 | + 'wordpoints' => array( 'wordpoints' ), |
|
66 | + ); |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Set up before a test. |
|
71 | + * |
|
72 | + * @since 1.2.0 |
|
73 | + * |
|
74 | + * @param string $type The type of test being run. |
|
75 | + */ |
|
76 | + protected function before( $type ) { |
|
77 | + |
|
78 | + update_option( 'cp_reg_points', 0 ); |
|
79 | + |
|
80 | + $this->type = $type; |
|
81 | + |
|
82 | + update_option( $this->cubepoints_option, 10 ); |
|
83 | + |
|
84 | + if ( 'wordpoints' === $this->type ) { |
|
85 | + $this->do_points_import( 'settings' ); |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Get the number of points a user has. |
|
91 | + * |
|
92 | + * @since 1.2.0 |
|
93 | + * |
|
94 | + * @param int $user_id The user ID. |
|
95 | + * |
|
96 | + * @return int The number of points the user has. |
|
97 | + */ |
|
98 | + protected function get_user_points( $user_id ) { |
|
99 | + if ( 'cubepoints' === $this->type ) { |
|
100 | + return cp_getPoints( $user_id ); |
|
101 | + } else { |
|
102 | + return wordpoints_get_points( $user_id, 'points' ); |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Do the import for the points settings. |
|
108 | + * |
|
109 | + * @since 1.2.0 |
|
110 | + * |
|
111 | + * @param string $type The type of points import. |
|
112 | + */ |
|
113 | + protected function do_points_import( $type ) { |
|
114 | + |
|
115 | + $importer = new WordPoints_CubePoints_Importer( 'Test CubePoints' ); |
|
116 | + $feedback = new WordPoints_Importer_Tests_Feedback(); |
|
117 | + |
|
118 | + $importer->do_import( |
|
119 | + array( |
|
120 | + 'points' => array( |
|
121 | + $type => '1', |
|
122 | + '_data' => array( 'points_type' => 'points' ), |
|
123 | + ), |
|
124 | + ) |
|
125 | + , $feedback |
|
126 | + ); |
|
127 | + |
|
128 | + $this->assertCount( 4, $feedback->messages['info'] ); |
|
129 | + $this->assertCount( 1, $feedback->messages['success'] ); |
|
130 | + } |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // EOF |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @dataProvider data_provider_types |
52 | 52 | */ |
53 | - abstract public function test( $type ); |
|
53 | + abstract public function test($type); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Data provider for types of tests. |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function data_provider_types() { |
63 | 63 | return array( |
64 | - 'cubepoints' => array( 'cubepoints' ), |
|
65 | - 'wordpoints' => array( 'wordpoints' ), |
|
64 | + 'cubepoints' => array('cubepoints'), |
|
65 | + 'wordpoints' => array('wordpoints'), |
|
66 | 66 | ); |
67 | 67 | } |
68 | 68 | |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param string $type The type of test being run. |
75 | 75 | */ |
76 | - protected function before( $type ) { |
|
76 | + protected function before($type) { |
|
77 | 77 | |
78 | - update_option( 'cp_reg_points', 0 ); |
|
78 | + update_option('cp_reg_points', 0); |
|
79 | 79 | |
80 | 80 | $this->type = $type; |
81 | 81 | |
82 | - update_option( $this->cubepoints_option, 10 ); |
|
82 | + update_option($this->cubepoints_option, 10); |
|
83 | 83 | |
84 | - if ( 'wordpoints' === $this->type ) { |
|
85 | - $this->do_points_import( 'settings' ); |
|
84 | + if ('wordpoints' === $this->type) { |
|
85 | + $this->do_points_import('settings'); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return int The number of points the user has. |
97 | 97 | */ |
98 | - protected function get_user_points( $user_id ) { |
|
99 | - if ( 'cubepoints' === $this->type ) { |
|
100 | - return cp_getPoints( $user_id ); |
|
98 | + protected function get_user_points($user_id) { |
|
99 | + if ('cubepoints' === $this->type) { |
|
100 | + return cp_getPoints($user_id); |
|
101 | 101 | } else { |
102 | - return wordpoints_get_points( $user_id, 'points' ); |
|
102 | + return wordpoints_get_points($user_id, 'points'); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -110,23 +110,23 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @param string $type The type of points import. |
112 | 112 | */ |
113 | - protected function do_points_import( $type ) { |
|
113 | + protected function do_points_import($type) { |
|
114 | 114 | |
115 | - $importer = new WordPoints_CubePoints_Importer( 'Test CubePoints' ); |
|
115 | + $importer = new WordPoints_CubePoints_Importer('Test CubePoints'); |
|
116 | 116 | $feedback = new WordPoints_Importer_Tests_Feedback(); |
117 | 117 | |
118 | 118 | $importer->do_import( |
119 | 119 | array( |
120 | 120 | 'points' => array( |
121 | 121 | $type => '1', |
122 | - '_data' => array( 'points_type' => 'points' ), |
|
122 | + '_data' => array('points_type' => 'points'), |
|
123 | 123 | ), |
124 | 124 | ) |
125 | 125 | , $feedback |
126 | 126 | ); |
127 | 127 | |
128 | - $this->assertCount( 4, $feedback->messages['info'] ); |
|
129 | - $this->assertCount( 1, $feedback->messages['success'] ); |
|
128 | + $this->assertCount(4, $feedback->messages['info']); |
|
129 | + $this->assertCount(1, $feedback->messages['success']); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 |
@@ -8,7 +8,7 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( true !== current_user_can( 'manage_options' ) ) { |
11 | - wp_die(); |
|
11 | + wp_die(); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | check_admin_referer( 'wordpoints_import' ); |
@@ -7,18 +7,18 @@ |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( true !== current_user_can( 'manage_options' ) ) { |
|
10 | +if (true !== current_user_can('manage_options')) { |
|
11 | 11 | wp_die(); |
12 | 12 | } |
13 | 13 | |
14 | -check_admin_referer( 'wordpoints_import' ); |
|
14 | +check_admin_referer('wordpoints_import'); |
|
15 | 15 | |
16 | 16 | ?> |
17 | 17 | |
18 | -<h2><?php esc_html_e( 'WordPoints Importer', 'wordpoints-importer' ); ?></h2> |
|
18 | +<h2><?php esc_html_e('WordPoints Importer', 'wordpoints-importer'); ?></h2> |
|
19 | 19 | |
20 | 20 | <div class="wrap"> |
21 | - <p><?php esc_html_e( 'Starting import (this could take a few moments)…', 'wordpoints-importer' ); ?></p> |
|
21 | + <p><?php esc_html_e('Starting import (this could take a few moments)…', 'wordpoints-importer'); ?></p> |
|
22 | 22 | |
23 | - <iframe src="<?php echo esc_url( self_admin_url( 'update.php?action=wordpoints_import&' . http_build_query( $_POST ) ) ); ?>" style="width: 100%; height:100%; min-height:850px;"></iframe> |
|
23 | + <iframe src="<?php echo esc_url(self_admin_url('update.php?action=wordpoints_import&'.http_build_query($_POST))); ?>" style="width: 100%; height:100%; min-height:850px;"></iframe> |
|
24 | 24 | </div> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( true !== current_user_can( 'manage_options' ) ) { |
11 | - wp_die(); |
|
11 | + wp_die(); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | $tabs = array( 'unavailable' => __( 'Unavailable', 'wordpoints-importer' ) ); |
@@ -16,19 +16,19 @@ discard block |
||
16 | 16 | |
17 | 17 | foreach ( WordPoints_Importers::get() as $slug => $args ) { |
18 | 18 | |
19 | - $importer = WordPoints_Importers::get_importer( $slug ); |
|
19 | + $importer = WordPoints_Importers::get_importer( $slug ); |
|
20 | 20 | |
21 | - $is_available = $importer->is_available(); |
|
21 | + $is_available = $importer->is_available(); |
|
22 | 22 | |
23 | - if ( is_wp_error( $is_available ) ) { |
|
24 | - $unavailable[ $args['name'] ] = $is_available; |
|
25 | - } else { |
|
26 | - $tabs[ $slug ] = $args['name']; |
|
27 | - } |
|
23 | + if ( is_wp_error( $is_available ) ) { |
|
24 | + $unavailable[ $args['name'] ] = $is_available; |
|
25 | + } else { |
|
26 | + $tabs[ $slug ] = $args['name']; |
|
27 | + } |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | if ( empty( $unavailable ) ) { |
31 | - unset( $tabs['unavailable'] ); |
|
31 | + unset( $tabs['unavailable'] ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | $current_tab = wordpoints_admin_get_current_tab( $tabs ); |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | <li> |
52 | 52 | <?php |
53 | 53 | |
54 | - printf( |
|
55 | - /* translators: 1 is an importer name, 2 is the reason that it is unavailable. */ |
|
56 | - esc_html__( '%1$s — %2$s', 'wordpoints-importer' ) |
|
57 | - , '<strong>' . esc_html( $name ) . '</strong>' |
|
58 | - , esc_html( $error->get_error_message() ) |
|
59 | - ); |
|
54 | + printf( |
|
55 | + /* translators: 1 is an importer name, 2 is the reason that it is unavailable. */ |
|
56 | + esc_html__( '%1$s — %2$s', 'wordpoints-importer' ) |
|
57 | + , '<strong>' . esc_html( $name ) . '</strong>' |
|
58 | + , esc_html( $error->get_error_message() ) |
|
59 | + ); |
|
60 | 60 | |
61 | - ?> |
|
61 | + ?> |
|
62 | 62 | </li> |
63 | 63 | <?php endforeach; ?> |
64 | 64 | </ul> |
@@ -74,39 +74,39 @@ discard block |
||
74 | 74 | |
75 | 75 | <?php |
76 | 76 | |
77 | - if ( ! $importer->supports_component( $slug ) ) { |
|
78 | - continue; |
|
79 | - } |
|
77 | + if ( ! $importer->supports_component( $slug ) ) { |
|
78 | + continue; |
|
79 | + } |
|
80 | 80 | |
81 | - $supported = true; |
|
81 | + $supported = true; |
|
82 | 82 | |
83 | - ?> |
|
83 | + ?> |
|
84 | 84 | |
85 | 85 | <h3><?php echo esc_html( $component['name'] ); ?></h3> |
86 | 86 | |
87 | 87 | <?php |
88 | 88 | |
89 | - /** |
|
90 | - * Before the import option fields for a component. |
|
91 | - * |
|
92 | - * @since 1.0.0 |
|
93 | - */ |
|
94 | - do_action( "wordpoints_importer_before_component_options-{$slug}" ); |
|
89 | + /** |
|
90 | + * Before the import option fields for a component. |
|
91 | + * |
|
92 | + * @since 1.0.0 |
|
93 | + */ |
|
94 | + do_action( "wordpoints_importer_before_component_options-{$slug}" ); |
|
95 | 95 | |
96 | - ?> |
|
96 | + ?> |
|
97 | 97 | |
98 | 98 | <?php foreach ( $importer->get_options_for_component( $slug ) as $name => $option ) : ?> |
99 | 99 | |
100 | 100 | <?php |
101 | 101 | |
102 | - $can_import = true; |
|
102 | + $can_import = true; |
|
103 | 103 | |
104 | - // Check if this option is available. |
|
105 | - if ( isset( $option['can_import'] ) ) { |
|
106 | - $can_import = call_user_func( $option['can_import'], array() ); |
|
107 | - } |
|
104 | + // Check if this option is available. |
|
105 | + if ( isset( $option['can_import'] ) ) { |
|
106 | + $can_import = call_user_func( $option['can_import'], array() ); |
|
107 | + } |
|
108 | 108 | |
109 | - ?> |
|
109 | + ?> |
|
110 | 110 | |
111 | 111 | <label for="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]"> |
112 | 112 | <input type="checkbox" value="1" id="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]" name="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]" <?php disabled( is_wp_error( $can_import ), true ); ?> /> |
@@ -132,20 +132,20 @@ discard block |
||
132 | 132 | |
133 | 133 | <?php |
134 | 134 | |
135 | - if ( ! isset( $supported ) ) { |
|
135 | + if ( ! isset( $supported ) ) { |
|
136 | 136 | |
137 | - esc_html_e( |
|
138 | - 'This importer does not support any of the installed components.' |
|
139 | - , 'wordpoints-importer' |
|
140 | - ); |
|
137 | + esc_html_e( |
|
138 | + 'This importer does not support any of the installed components.' |
|
139 | + , 'wordpoints-importer' |
|
140 | + ); |
|
141 | 141 | |
142 | - } else { |
|
142 | + } else { |
|
143 | 143 | |
144 | - wp_nonce_field( 'wordpoints_import' ); |
|
145 | - submit_button( __( 'Import', 'wordpoints-importer' ) ); |
|
146 | - } |
|
144 | + wp_nonce_field( 'wordpoints_import' ); |
|
145 | + submit_button( __( 'Import', 'wordpoints-importer' ) ); |
|
146 | + } |
|
147 | 147 | |
148 | - ?> |
|
148 | + ?> |
|
149 | 149 | </form> |
150 | 150 | <?php endif; ?> |
151 | 151 | </div> |
@@ -63,9 +63,12 @@ discard block |
||
63 | 63 | <?php endforeach; ?> |
64 | 64 | </ul> |
65 | 65 | |
66 | - <?php else : ?> |
|
66 | + <?php else { |
|
67 | + : ?> |
|
67 | 68 | |
68 | - <?php $importer = WordPoints_Importers::get_importer( $current_tab ); ?> |
|
69 | + <?php $importer = WordPoints_Importers::get_importer( $current_tab ); |
|
70 | +} |
|
71 | +?> |
|
69 | 72 | |
70 | 73 | <p><?php esc_html_e( 'Select which items you would like imported.', 'wordpoints-importer' ); ?></p> |
71 | 74 | |
@@ -120,9 +123,12 @@ discard block |
||
120 | 123 | <p class="description" style="margin-bottom: 10px; margin-left: 25px;"> |
121 | 124 | <?php echo esc_html( $option['description'] ); ?> |
122 | 125 | </p> |
123 | - <?php else : ?> |
|
126 | + <?php else { |
|
127 | + : ?> |
|
124 | 128 | <br style="margin-bottom: 10px" /> |
125 | - <?php endif; ?> |
|
129 | + <?php endif; |
|
130 | +} |
|
131 | +?> |
|
126 | 132 | |
127 | 133 | <?php endforeach; ?> |
128 | 134 |
@@ -7,55 +7,55 @@ discard block |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( true !== current_user_can( 'manage_options' ) ) { |
|
10 | +if (true !== current_user_can('manage_options')) { |
|
11 | 11 | wp_die(); |
12 | 12 | } |
13 | 13 | |
14 | -$tabs = array( 'unavailable' => __( 'Unavailable', 'wordpoints-importer' ) ); |
|
14 | +$tabs = array('unavailable' => __('Unavailable', 'wordpoints-importer')); |
|
15 | 15 | $unavailable = array(); |
16 | 16 | |
17 | -foreach ( WordPoints_Importers::get() as $slug => $args ) { |
|
17 | +foreach (WordPoints_Importers::get() as $slug => $args) { |
|
18 | 18 | |
19 | - $importer = WordPoints_Importers::get_importer( $slug ); |
|
19 | + $importer = WordPoints_Importers::get_importer($slug); |
|
20 | 20 | |
21 | 21 | $is_available = $importer->is_available(); |
22 | 22 | |
23 | - if ( is_wp_error( $is_available ) ) { |
|
24 | - $unavailable[ $args['name'] ] = $is_available; |
|
23 | + if (is_wp_error($is_available)) { |
|
24 | + $unavailable[$args['name']] = $is_available; |
|
25 | 25 | } else { |
26 | - $tabs[ $slug ] = $args['name']; |
|
26 | + $tabs[$slug] = $args['name']; |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | -if ( empty( $unavailable ) ) { |
|
31 | - unset( $tabs['unavailable'] ); |
|
30 | +if (empty($unavailable)) { |
|
31 | + unset($tabs['unavailable']); |
|
32 | 32 | } |
33 | 33 | |
34 | -$current_tab = wordpoints_admin_get_current_tab( $tabs ); |
|
34 | +$current_tab = wordpoints_admin_get_current_tab($tabs); |
|
35 | 35 | |
36 | 36 | $components = WordPoints_Components::instance()->get(); |
37 | 37 | |
38 | 38 | ?> |
39 | 39 | |
40 | -<h2><?php esc_html_e( 'WordPoints Importer', 'wordpoints-importer' ); ?></h2> |
|
40 | +<h2><?php esc_html_e('WordPoints Importer', 'wordpoints-importer'); ?></h2> |
|
41 | 41 | |
42 | 42 | <div class="wrap"> |
43 | - <?php wordpoints_admin_show_tabs( $tabs, false ); ?> |
|
43 | + <?php wordpoints_admin_show_tabs($tabs, false); ?> |
|
44 | 44 | |
45 | - <?php if ( 'unavailable' === $current_tab ) : ?> |
|
45 | + <?php if ('unavailable' === $current_tab) : ?> |
|
46 | 46 | |
47 | - <p><?php esc_html_e( 'The below importers are not currently available.', 'wordpoints-importer' ); ?></p> |
|
47 | + <p><?php esc_html_e('The below importers are not currently available.', 'wordpoints-importer'); ?></p> |
|
48 | 48 | |
49 | 49 | <ul> |
50 | - <?php foreach ( $unavailable as $name => $error ) : ?> |
|
50 | + <?php foreach ($unavailable as $name => $error) : ?> |
|
51 | 51 | <li> |
52 | 52 | <?php |
53 | 53 | |
54 | 54 | printf( |
55 | 55 | /* translators: 1 is an importer name, 2 is the reason that it is unavailable. */ |
56 | - esc_html__( '%1$s — %2$s', 'wordpoints-importer' ) |
|
57 | - , '<strong>' . esc_html( $name ) . '</strong>' |
|
58 | - , esc_html( $error->get_error_message() ) |
|
56 | + esc_html__('%1$s — %2$s', 'wordpoints-importer') |
|
57 | + , '<strong>'.esc_html($name).'</strong>' |
|
58 | + , esc_html($error->get_error_message()) |
|
59 | 59 | ); |
60 | 60 | |
61 | 61 | ?> |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | |
66 | 66 | <?php else : ?> |
67 | 67 | |
68 | - <?php $importer = WordPoints_Importers::get_importer( $current_tab ); ?> |
|
68 | + <?php $importer = WordPoints_Importers::get_importer($current_tab); ?> |
|
69 | 69 | |
70 | - <p><?php esc_html_e( 'Select which items you would like imported.', 'wordpoints-importer' ); ?></p> |
|
70 | + <p><?php esc_html_e('Select which items you would like imported.', 'wordpoints-importer'); ?></p> |
|
71 | 71 | |
72 | - <form method="post" action="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_importing' ) ); ?>"> |
|
73 | - <?php foreach ( $components as $slug => $component ) : ?> |
|
72 | + <form method="post" action="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_importing')); ?>"> |
|
73 | + <?php foreach ($components as $slug => $component) : ?> |
|
74 | 74 | |
75 | 75 | <?php |
76 | 76 | |
77 | - if ( ! $importer->supports_component( $slug ) ) { |
|
77 | + if (!$importer->supports_component($slug)) { |
|
78 | 78 | continue; |
79 | 79 | } |
80 | 80 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | ?> |
84 | 84 | |
85 | - <h3><?php echo esc_html( $component['name'] ); ?></h3> |
|
85 | + <h3><?php echo esc_html($component['name']); ?></h3> |
|
86 | 86 | |
87 | 87 | <?php |
88 | 88 | |
@@ -91,34 +91,34 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @since 1.0.0 |
93 | 93 | */ |
94 | - do_action( "wordpoints_importer_before_component_options-{$slug}" ); |
|
94 | + do_action("wordpoints_importer_before_component_options-{$slug}"); |
|
95 | 95 | |
96 | 96 | ?> |
97 | 97 | |
98 | - <?php foreach ( $importer->get_options_for_component( $slug ) as $name => $option ) : ?> |
|
98 | + <?php foreach ($importer->get_options_for_component($slug) as $name => $option) : ?> |
|
99 | 99 | |
100 | 100 | <?php |
101 | 101 | |
102 | 102 | $can_import = true; |
103 | 103 | |
104 | 104 | // Check if this option is available. |
105 | - if ( isset( $option['can_import'] ) ) { |
|
106 | - $can_import = call_user_func( $option['can_import'], array() ); |
|
105 | + if (isset($option['can_import'])) { |
|
106 | + $can_import = call_user_func($option['can_import'], array()); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | ?> |
110 | 110 | |
111 | - <label for="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]"> |
|
112 | - <input type="checkbox" value="1" id="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]" name="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]" <?php disabled( is_wp_error( $can_import ), true ); ?> /> |
|
113 | - <?php echo esc_html( $option['label'] ); ?> |
|
114 | - <?php if ( is_wp_error( $can_import ) ) : ?> |
|
115 | - <em><?php printf( esc_html__( 'Disabled (%s)', 'wordpoints-importer' ), esc_html( $can_import->get_error_message() ) ); ?></em> |
|
111 | + <label for="wordpoints_import[<?php echo esc_attr($slug); ?>][<?php echo esc_attr($name); ?>]"> |
|
112 | + <input type="checkbox" value="1" id="wordpoints_import[<?php echo esc_attr($slug); ?>][<?php echo esc_attr($name); ?>]" name="wordpoints_import[<?php echo esc_attr($slug); ?>][<?php echo esc_attr($name); ?>]" <?php disabled(is_wp_error($can_import), true); ?> /> |
|
113 | + <?php echo esc_html($option['label']); ?> |
|
114 | + <?php if (is_wp_error($can_import)) : ?> |
|
115 | + <em><?php printf(esc_html__('Disabled (%s)', 'wordpoints-importer'), esc_html($can_import->get_error_message())); ?></em> |
|
116 | 116 | <?php endif; ?> |
117 | 117 | </label> |
118 | 118 | |
119 | - <?php if ( isset( $option['description'] ) ) : ?> |
|
119 | + <?php if (isset($option['description'])) : ?> |
|
120 | 120 | <p class="description" style="margin-bottom: 10px; margin-left: 25px;"> |
121 | - <?php echo esc_html( $option['description'] ); ?> |
|
121 | + <?php echo esc_html($option['description']); ?> |
|
122 | 122 | </p> |
123 | 123 | <?php else : ?> |
124 | 124 | <br style="margin-bottom: 10px" /> |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | |
129 | 129 | <?php endforeach; ?> |
130 | 130 | |
131 | - <input type="hidden" value="<?php echo esc_attr( $current_tab ); ?>" name="importer" /> |
|
131 | + <input type="hidden" value="<?php echo esc_attr($current_tab); ?>" name="importer" /> |
|
132 | 132 | |
133 | 133 | <?php |
134 | 134 | |
135 | - if ( ! isset( $supported ) ) { |
|
135 | + if (!isset($supported)) { |
|
136 | 136 | |
137 | 137 | esc_html_e( |
138 | 138 | 'This importer does not support any of the installed components.' |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | |
142 | 142 | } else { |
143 | 143 | |
144 | - wp_nonce_field( 'wordpoints_import' ); |
|
145 | - submit_button( __( 'Import', 'wordpoints-importer' ) ); |
|
144 | + wp_nonce_field('wordpoints_import'); |
|
145 | + submit_button(__('Import', 'wordpoints-importer')); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | ?> |
@@ -64,12 +64,12 @@ |
||
64 | 64 | |
65 | 65 | if ( is_admin() ) { |
66 | 66 | |
67 | - /** |
|
68 | - * The module's admin-side code. |
|
69 | - * |
|
70 | - * @since 1.0.0 |
|
71 | - */ |
|
72 | - require_once( dirname( __FILE__ ) . '/admin/admin.php' ); |
|
67 | + /** |
|
68 | + * The module's admin-side code. |
|
69 | + * |
|
70 | + * @since 1.0.0 |
|
71 | + */ |
|
72 | + require_once( dirname( __FILE__ ) . '/admin/admin.php' ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // EOF |
@@ -46,30 +46,30 @@ |
||
46 | 46 | * |
47 | 47 | * @since 1.0.0 |
48 | 48 | */ |
49 | -require_once( dirname( __FILE__ ) . '/includes/class-feedback.php' ); |
|
49 | +require_once(dirname(__FILE__).'/includes/class-feedback.php'); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * The base importer class. |
53 | 53 | * |
54 | 54 | * @since 1.0.0 |
55 | 55 | */ |
56 | -require_once( dirname( __FILE__ ) . '/includes/class-importer.php' ); |
|
56 | +require_once(dirname(__FILE__).'/includes/class-importer.php'); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * The module's general functions. |
60 | 60 | * |
61 | 61 | * @since 1.0.0 |
62 | 62 | */ |
63 | -require_once( dirname( __FILE__ ) . '/includes/functions.php' ); |
|
63 | +require_once(dirname(__FILE__).'/includes/functions.php'); |
|
64 | 64 | |
65 | -if ( is_admin() ) { |
|
65 | +if (is_admin()) { |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * The module's admin-side code. |
69 | 69 | * |
70 | 70 | * @since 1.0.0 |
71 | 71 | */ |
72 | - require_once( dirname( __FILE__ ) . '/admin/admin.php' ); |
|
72 | + require_once(dirname(__FILE__).'/admin/admin.php'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // EOF |
@@ -16,84 +16,84 @@ |
||
16 | 16 | */ |
17 | 17 | class WordPoints_Importer_Feedback { |
18 | 18 | |
19 | - /** |
|
20 | - * Send an info message. |
|
21 | - * |
|
22 | - * Use this to give the user any info that wouldn't be handles by the other |
|
23 | - * methods. |
|
24 | - * |
|
25 | - * @since 1.0.0 |
|
26 | - * |
|
27 | - * @param string $message The info message. |
|
28 | - */ |
|
29 | - public function info( $message ) { |
|
30 | - $this->_send( $message, 'info' ); |
|
31 | - } |
|
19 | + /** |
|
20 | + * Send an info message. |
|
21 | + * |
|
22 | + * Use this to give the user any info that wouldn't be handles by the other |
|
23 | + * methods. |
|
24 | + * |
|
25 | + * @since 1.0.0 |
|
26 | + * |
|
27 | + * @param string $message The info message. |
|
28 | + */ |
|
29 | + public function info( $message ) { |
|
30 | + $this->_send( $message, 'info' ); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Send a success message. |
|
35 | - * |
|
36 | - * Use this when you want to let the user know that something was a success. |
|
37 | - * |
|
38 | - * @since 1.0.0 |
|
39 | - * |
|
40 | - * @param string $message The success message. |
|
41 | - */ |
|
42 | - public function success( $message ) { |
|
43 | - $this->_send( $message, 'success' ); |
|
44 | - } |
|
33 | + /** |
|
34 | + * Send a success message. |
|
35 | + * |
|
36 | + * Use this when you want to let the user know that something was a success. |
|
37 | + * |
|
38 | + * @since 1.0.0 |
|
39 | + * |
|
40 | + * @param string $message The success message. |
|
41 | + */ |
|
42 | + public function success( $message ) { |
|
43 | + $this->_send( $message, 'success' ); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Send an error message. |
|
48 | - * |
|
49 | - * Use this when you want to let the user know that there was an error. |
|
50 | - * |
|
51 | - * @since 1.0.0 |
|
52 | - * |
|
53 | - * @param string $message The error message. |
|
54 | - */ |
|
55 | - public function error( $message ) { |
|
56 | - $this->_send( $message, 'error' ); |
|
57 | - } |
|
46 | + /** |
|
47 | + * Send an error message. |
|
48 | + * |
|
49 | + * Use this when you want to let the user know that there was an error. |
|
50 | + * |
|
51 | + * @since 1.0.0 |
|
52 | + * |
|
53 | + * @param string $message The error message. |
|
54 | + */ |
|
55 | + public function error( $message ) { |
|
56 | + $this->_send( $message, 'error' ); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Send a warning message. |
|
61 | - * |
|
62 | - * Use this to warn the user about something. A warning doesn't necessarily imply |
|
63 | - * an error, but that something unexpected has occured that the user might need |
|
64 | - * to know. |
|
65 | - * |
|
66 | - * @since 1.0.0 |
|
67 | - * |
|
68 | - * @param string $message The warning message. |
|
69 | - */ |
|
70 | - public function warning( $message ) { |
|
71 | - $this->_send( $message, 'warning' ); |
|
72 | - } |
|
59 | + /** |
|
60 | + * Send a warning message. |
|
61 | + * |
|
62 | + * Use this to warn the user about something. A warning doesn't necessarily imply |
|
63 | + * an error, but that something unexpected has occured that the user might need |
|
64 | + * to know. |
|
65 | + * |
|
66 | + * @since 1.0.0 |
|
67 | + * |
|
68 | + * @param string $message The warning message. |
|
69 | + */ |
|
70 | + public function warning( $message ) { |
|
71 | + $this->_send( $message, 'warning' ); |
|
72 | + } |
|
73 | 73 | |
74 | - // |
|
75 | - // Protected Methods. |
|
76 | - // |
|
74 | + // |
|
75 | + // Protected Methods. |
|
76 | + // |
|
77 | 77 | |
78 | - /** |
|
79 | - * Send a message to the user. |
|
80 | - * |
|
81 | - * @since 1.0.0 |
|
82 | - * |
|
83 | - * @param string $message The feedback message. |
|
84 | - * @param string $type The type of message: 'info' (defuault), 'sucess', |
|
85 | - * 'error', 'warning'. |
|
86 | - */ |
|
87 | - protected function _send( $message, $type = 'info' ) { |
|
78 | + /** |
|
79 | + * Send a message to the user. |
|
80 | + * |
|
81 | + * @since 1.0.0 |
|
82 | + * |
|
83 | + * @param string $message The feedback message. |
|
84 | + * @param string $type The type of message: 'info' (defuault), 'sucess', |
|
85 | + * 'error', 'warning'. |
|
86 | + */ |
|
87 | + protected function _send( $message, $type = 'info' ) { |
|
88 | 88 | |
89 | - ?> |
|
89 | + ?> |
|
90 | 90 | |
91 | 91 | <p class="wordpoints-feedback wordpoints-feedback-<?php echo esc_attr( $type ); ?>"> |
92 | 92 | <?php echo wp_kses( $message, 'wordpoints_importer_feedback' ); ?> |
93 | 93 | </p> |
94 | 94 | |
95 | 95 | <?php |
96 | - } |
|
96 | + } |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // EOF |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param string $message The info message. |
28 | 28 | */ |
29 | - public function info( $message ) { |
|
30 | - $this->_send( $message, 'info' ); |
|
29 | + public function info($message) { |
|
30 | + $this->_send($message, 'info'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param string $message The success message. |
41 | 41 | */ |
42 | - public function success( $message ) { |
|
43 | - $this->_send( $message, 'success' ); |
|
42 | + public function success($message) { |
|
43 | + $this->_send($message, 'success'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param string $message The error message. |
54 | 54 | */ |
55 | - public function error( $message ) { |
|
56 | - $this->_send( $message, 'error' ); |
|
55 | + public function error($message) { |
|
56 | + $this->_send($message, 'error'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param string $message The warning message. |
69 | 69 | */ |
70 | - public function warning( $message ) { |
|
71 | - $this->_send( $message, 'warning' ); |
|
70 | + public function warning($message) { |
|
71 | + $this->_send($message, 'warning'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | * @param string $type The type of message: 'info' (defuault), 'sucess', |
85 | 85 | * 'error', 'warning'. |
86 | 86 | */ |
87 | - protected function _send( $message, $type = 'info' ) { |
|
87 | + protected function _send($message, $type = 'info') { |
|
88 | 88 | |
89 | 89 | ?> |
90 | 90 | |
91 | - <p class="wordpoints-feedback wordpoints-feedback-<?php echo esc_attr( $type ); ?>"> |
|
92 | - <?php echo wp_kses( $message, 'wordpoints_importer_feedback' ); ?> |
|
91 | + <p class="wordpoints-feedback wordpoints-feedback-<?php echo esc_attr($type); ?>"> |
|
92 | + <?php echo wp_kses($message, 'wordpoints_importer_feedback'); ?> |
|
93 | 93 | </p> |
94 | 94 | |
95 | 95 | <?php |
@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wordpoints_importer_load_textdomain() { |
16 | 16 | |
17 | - wordpoints_load_module_textdomain( |
|
18 | - 'wordpointsorg' |
|
19 | - , wordpoints_module_basename( dirname( dirname( __FILE__ ) ) ) . '/languages' |
|
20 | - ); |
|
17 | + wordpoints_load_module_textdomain( |
|
18 | + 'wordpointsorg' |
|
19 | + , wordpoints_module_basename( dirname( dirname( __FILE__ ) ) ) . '/languages' |
|
20 | + ); |
|
21 | 21 | } |
22 | 22 | add_action( 'wordpoints_modules_loaded', 'wordpoints_importer_load_textdomain' ); |
23 | 23 | |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function wordpoints_importer_register_importers() { |
30 | 30 | |
31 | - /** |
|
32 | - * The CubePoints importer. |
|
33 | - * |
|
34 | - * @since 1.0.0 |
|
35 | - */ |
|
36 | - require_once( dirname( __FILE__ ) . '/importers/cubepoints.php' ); |
|
31 | + /** |
|
32 | + * The CubePoints importer. |
|
33 | + * |
|
34 | + * @since 1.0.0 |
|
35 | + */ |
|
36 | + require_once( dirname( __FILE__ ) . '/importers/cubepoints.php' ); |
|
37 | 37 | |
38 | - $args = array( |
|
39 | - 'class' => 'WordPoints_CubePoints_Importer', |
|
40 | - 'name' => __( 'CubePoints', 'wordpoints-importer' ), |
|
41 | - ); |
|
38 | + $args = array( |
|
39 | + 'class' => 'WordPoints_CubePoints_Importer', |
|
40 | + 'name' => __( 'CubePoints', 'wordpoints-importer' ), |
|
41 | + ); |
|
42 | 42 | |
43 | - WordPoints_Importers::register( 'cubepoints', $args ); |
|
43 | + WordPoints_Importers::register( 'cubepoints', $args ); |
|
44 | 44 | } |
45 | 45 | add_action( 'wordpoints_register_importers', 'wordpoints_importer_register_importers' ); |
46 | 46 |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | |
17 | 17 | wordpoints_load_module_textdomain( |
18 | 18 | 'wordpointsorg' |
19 | - , wordpoints_module_basename( dirname( dirname( __FILE__ ) ) ) . '/languages' |
|
19 | + , wordpoints_module_basename(dirname(dirname(__FILE__))).'/languages' |
|
20 | 20 | ); |
21 | 21 | } |
22 | -add_action( 'wordpoints_modules_loaded', 'wordpoints_importer_load_textdomain' ); |
|
22 | +add_action('wordpoints_modules_loaded', 'wordpoints_importer_load_textdomain'); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Register the included importers. |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @since 1.0.0 |
35 | 35 | */ |
36 | - require_once( dirname( __FILE__ ) . '/importers/cubepoints.php' ); |
|
36 | + require_once(dirname(__FILE__).'/importers/cubepoints.php'); |
|
37 | 37 | |
38 | 38 | $args = array( |
39 | 39 | 'class' => 'WordPoints_CubePoints_Importer', |
40 | - 'name' => __( 'CubePoints', 'wordpoints-importer' ), |
|
40 | + 'name' => __('CubePoints', 'wordpoints-importer'), |
|
41 | 41 | ); |
42 | 42 | |
43 | - WordPoints_Importers::register( 'cubepoints', $args ); |
|
43 | + WordPoints_Importers::register('cubepoints', $args); |
|
44 | 44 | } |
45 | -add_action( 'wordpoints_register_importers', 'wordpoints_importer_register_importers' ); |
|
45 | +add_action('wordpoints_register_importers', 'wordpoints_importer_register_importers'); |
|
46 | 46 | |
47 | 47 | // EOF |
@@ -14,138 +14,138 @@ discard block |
||
14 | 14 | */ |
15 | 15 | final class WordPoints_Importers { |
16 | 16 | |
17 | - // |
|
18 | - // Private Vars. |
|
19 | - // |
|
20 | - |
|
21 | - /** |
|
22 | - * The registered importers. |
|
23 | - * |
|
24 | - * @since 1.0.0 |
|
25 | - * |
|
26 | - * @type array $importers |
|
27 | - */ |
|
28 | - private static $importers = array(); |
|
29 | - |
|
30 | - /** |
|
31 | - * Whether the class has been initialized yet. |
|
32 | - * |
|
33 | - * @since 1.0.0 |
|
34 | - * |
|
35 | - * @type bool $initialized |
|
36 | - */ |
|
37 | - private static $initialized = false; |
|
38 | - |
|
39 | - // |
|
40 | - // Private Functions. |
|
41 | - // |
|
42 | - |
|
43 | - /** |
|
44 | - * Initialize the class. |
|
45 | - * |
|
46 | - * @since 1.0.0 |
|
47 | - */ |
|
48 | - private static function init() { |
|
49 | - |
|
50 | - // We do this first so we avoid infinite loops if this class is called by a |
|
51 | - // function hooked to the below action. |
|
52 | - self::$initialized = true; |
|
53 | - |
|
54 | - /** |
|
55 | - * Register importers. |
|
56 | - * |
|
57 | - * @since 1.0.0 |
|
58 | - */ |
|
59 | - do_action( 'wordpoints_register_importers' ); |
|
60 | - } |
|
61 | - |
|
62 | - // |
|
63 | - // Public Functions. |
|
64 | - // |
|
65 | - |
|
66 | - /** |
|
67 | - * Get all of the registered importers. |
|
68 | - * |
|
69 | - * @since 1.0.0 |
|
70 | - * |
|
71 | - * @return array All of the registered importers. |
|
72 | - */ |
|
73 | - public static function get() { |
|
74 | - |
|
75 | - if ( ! self::$initialized ) { |
|
76 | - self::init(); |
|
77 | - } |
|
78 | - |
|
79 | - return self::$importers; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Register an importer. |
|
84 | - * |
|
85 | - * If the importer is already registered, it will be overwritten. |
|
86 | - * |
|
87 | - * @since 1.0.0 |
|
88 | - * |
|
89 | - * @param string $slug The unique identifier for this importer. |
|
90 | - * @param array $args { |
|
91 | - * Other importer arguments. |
|
92 | - * |
|
93 | - * @type string $class The Importer class. |
|
94 | - * @type string $name The name of this importer. |
|
95 | - * } |
|
96 | - */ |
|
97 | - public static function register( $slug, array $args ) { |
|
98 | - self::$importers[ $slug ] = $args; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Deregister an importer. |
|
103 | - * |
|
104 | - * @since 1.0.0 |
|
105 | - * |
|
106 | - * @param string $slug The slug of the importer to deregister. |
|
107 | - */ |
|
108 | - public static function deregister( $slug ) { |
|
109 | - unset( self::$importers[ $slug ] ); |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Check if an importer is registered. |
|
114 | - * |
|
115 | - * @since 1.0.0 |
|
116 | - * |
|
117 | - * @param string $slug The slug of the importer. |
|
118 | - * |
|
119 | - * @return bool True if the importer is registered, otherwise false. |
|
120 | - */ |
|
121 | - public static function is_registered( $slug ) { |
|
122 | - |
|
123 | - if ( ! self::$initialized ) { |
|
124 | - self::init(); |
|
125 | - } |
|
126 | - |
|
127 | - return isset( self::$importers[ $slug ] ); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Get an instance of an importer. |
|
132 | - * |
|
133 | - * @since 1.0.0 |
|
134 | - * |
|
135 | - * @param string $slug The slug of the importer to get an instance of. |
|
136 | - * |
|
137 | - * @return WordPoints_Importer|false The importer, or false if it isn't registered. |
|
138 | - */ |
|
139 | - public static function get_importer( $slug ) { |
|
140 | - |
|
141 | - if ( ! self::is_registered( $slug ) ) { |
|
142 | - return false; |
|
143 | - } |
|
144 | - |
|
145 | - $importer = self::$importers[ $slug ]; |
|
146 | - |
|
147 | - return new $importer['class']( $importer['name'] ); |
|
148 | - } |
|
17 | + // |
|
18 | + // Private Vars. |
|
19 | + // |
|
20 | + |
|
21 | + /** |
|
22 | + * The registered importers. |
|
23 | + * |
|
24 | + * @since 1.0.0 |
|
25 | + * |
|
26 | + * @type array $importers |
|
27 | + */ |
|
28 | + private static $importers = array(); |
|
29 | + |
|
30 | + /** |
|
31 | + * Whether the class has been initialized yet. |
|
32 | + * |
|
33 | + * @since 1.0.0 |
|
34 | + * |
|
35 | + * @type bool $initialized |
|
36 | + */ |
|
37 | + private static $initialized = false; |
|
38 | + |
|
39 | + // |
|
40 | + // Private Functions. |
|
41 | + // |
|
42 | + |
|
43 | + /** |
|
44 | + * Initialize the class. |
|
45 | + * |
|
46 | + * @since 1.0.0 |
|
47 | + */ |
|
48 | + private static function init() { |
|
49 | + |
|
50 | + // We do this first so we avoid infinite loops if this class is called by a |
|
51 | + // function hooked to the below action. |
|
52 | + self::$initialized = true; |
|
53 | + |
|
54 | + /** |
|
55 | + * Register importers. |
|
56 | + * |
|
57 | + * @since 1.0.0 |
|
58 | + */ |
|
59 | + do_action( 'wordpoints_register_importers' ); |
|
60 | + } |
|
61 | + |
|
62 | + // |
|
63 | + // Public Functions. |
|
64 | + // |
|
65 | + |
|
66 | + /** |
|
67 | + * Get all of the registered importers. |
|
68 | + * |
|
69 | + * @since 1.0.0 |
|
70 | + * |
|
71 | + * @return array All of the registered importers. |
|
72 | + */ |
|
73 | + public static function get() { |
|
74 | + |
|
75 | + if ( ! self::$initialized ) { |
|
76 | + self::init(); |
|
77 | + } |
|
78 | + |
|
79 | + return self::$importers; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Register an importer. |
|
84 | + * |
|
85 | + * If the importer is already registered, it will be overwritten. |
|
86 | + * |
|
87 | + * @since 1.0.0 |
|
88 | + * |
|
89 | + * @param string $slug The unique identifier for this importer. |
|
90 | + * @param array $args { |
|
91 | + * Other importer arguments. |
|
92 | + * |
|
93 | + * @type string $class The Importer class. |
|
94 | + * @type string $name The name of this importer. |
|
95 | + * } |
|
96 | + */ |
|
97 | + public static function register( $slug, array $args ) { |
|
98 | + self::$importers[ $slug ] = $args; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Deregister an importer. |
|
103 | + * |
|
104 | + * @since 1.0.0 |
|
105 | + * |
|
106 | + * @param string $slug The slug of the importer to deregister. |
|
107 | + */ |
|
108 | + public static function deregister( $slug ) { |
|
109 | + unset( self::$importers[ $slug ] ); |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Check if an importer is registered. |
|
114 | + * |
|
115 | + * @since 1.0.0 |
|
116 | + * |
|
117 | + * @param string $slug The slug of the importer. |
|
118 | + * |
|
119 | + * @return bool True if the importer is registered, otherwise false. |
|
120 | + */ |
|
121 | + public static function is_registered( $slug ) { |
|
122 | + |
|
123 | + if ( ! self::$initialized ) { |
|
124 | + self::init(); |
|
125 | + } |
|
126 | + |
|
127 | + return isset( self::$importers[ $slug ] ); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Get an instance of an importer. |
|
132 | + * |
|
133 | + * @since 1.0.0 |
|
134 | + * |
|
135 | + * @param string $slug The slug of the importer to get an instance of. |
|
136 | + * |
|
137 | + * @return WordPoints_Importer|false The importer, or false if it isn't registered. |
|
138 | + */ |
|
139 | + public static function get_importer( $slug ) { |
|
140 | + |
|
141 | + if ( ! self::is_registered( $slug ) ) { |
|
142 | + return false; |
|
143 | + } |
|
144 | + |
|
145 | + $importer = self::$importers[ $slug ]; |
|
146 | + |
|
147 | + return new $importer['class']( $importer['name'] ); |
|
148 | + } |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -155,239 +155,239 @@ discard block |
||
155 | 155 | */ |
156 | 156 | abstract class WordPoints_Importer { |
157 | 157 | |
158 | - /** |
|
159 | - * The name of the importer. |
|
160 | - * |
|
161 | - * @since 1.0.0 |
|
162 | - * |
|
163 | - * @type string $name |
|
164 | - */ |
|
165 | - protected $name; |
|
166 | - |
|
167 | - /** |
|
168 | - * The components supported by this importer. |
|
169 | - * |
|
170 | - * The keys are the component slugs, the values arrays of options for importing |
|
171 | - * to that component. |
|
172 | - * |
|
173 | - * @since 1.0.0 |
|
174 | - * |
|
175 | - * @type array[] $components |
|
176 | - */ |
|
177 | - protected $components = array(); |
|
178 | - |
|
179 | - /** |
|
180 | - * The feedback provider object. |
|
181 | - * |
|
182 | - * This is only set by self::do_import(). |
|
183 | - * |
|
184 | - * @since 1.0.0 |
|
185 | - * |
|
186 | - * @type WordPoints_Importer_Feedback $feedback |
|
187 | - */ |
|
188 | - protected $feedback; |
|
189 | - |
|
190 | - /** |
|
191 | - * Check if this importer is available. |
|
192 | - * |
|
193 | - * @since 1.0.0 |
|
194 | - * |
|
195 | - * @return true|WP_Error A WP_Error if the importer is not available. |
|
196 | - */ |
|
197 | - abstract public function is_available(); |
|
198 | - |
|
199 | - /** |
|
200 | - * Construct the importer. |
|
201 | - * |
|
202 | - * @since 1.0.0 |
|
203 | - * |
|
204 | - * @param string $name The name of the importer. |
|
205 | - */ |
|
206 | - public function __construct( $name ) { |
|
207 | - |
|
208 | - $this->name = $name; |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * Check if this importer supports a specific component. |
|
213 | - * |
|
214 | - * @since 1.0.0 |
|
215 | - * |
|
216 | - * @param string $component The slug of a component. |
|
217 | - * |
|
218 | - * @return bool True if the component is supported, otherwise false. |
|
219 | - */ |
|
220 | - public function supports_component( $component ) { |
|
221 | - |
|
222 | - return isset( $this->components[ $component ] ); |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * Get the import options for a component. |
|
227 | - * |
|
228 | - * @since 1.0.0 |
|
229 | - * |
|
230 | - * @param string $component The slug of a component. |
|
231 | - * |
|
232 | - * @return array[] The options for this component. |
|
233 | - */ |
|
234 | - public function get_options_for_component( $component ) { |
|
235 | - |
|
236 | - if ( ! $this->supports_component( $component ) ) { |
|
237 | - return array(); |
|
238 | - } |
|
239 | - |
|
240 | - return $this->components[ $component ]; |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Run the import. |
|
245 | - * |
|
246 | - * @since 1.0.0 |
|
247 | - * |
|
248 | - * @param array $args The settings for the import. |
|
249 | - * @param WordPoints_Importer_Feedback $feedback The feedback object. |
|
250 | - */ |
|
251 | - public function do_import( array $args, $feedback = null ) { |
|
252 | - |
|
253 | - if ( ! ( $feedback instanceof WordPoints_Importer_Feedback ) ) { |
|
254 | - $feedback = new WordPoints_Importer_Feedback; |
|
255 | - } |
|
256 | - |
|
257 | - $this->feedback = $feedback; |
|
258 | - |
|
259 | - $this->feedback->info( sprintf( __( 'Importing from %s…', 'wordpoints-importer' ), $this->name ) ); |
|
260 | - |
|
261 | - $this->no_interruptions(); |
|
262 | - |
|
263 | - foreach ( $args as $component => $options ) { |
|
264 | - $this->do_import_for_component( $component, $options ); |
|
265 | - } |
|
266 | - |
|
267 | - $this->feedback->info( __( 'Import complete.', 'wordpoints-importer' ) ); |
|
268 | - } |
|
269 | - |
|
270 | - /** |
|
271 | - * Prevent any interruptions from occurring during the import. |
|
272 | - * |
|
273 | - * @since 1.2.1 |
|
274 | - */ |
|
275 | - protected function no_interruptions() { |
|
276 | - |
|
277 | - ignore_user_abort( true ); |
|
278 | - |
|
279 | - if ( |
|
280 | - // Back-compat with WordPoints 2.1. |
|
281 | - function_exists( 'wordpoints_is_function_disabled' ) |
|
282 | - && ! wordpoints_is_function_disabled( 'set_time_limit' ) |
|
283 | - ) { |
|
284 | - set_time_limit( 0 ); |
|
285 | - } |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Validate the import settings for a component. |
|
290 | - * |
|
291 | - * @since 1.0.0 |
|
292 | - * |
|
293 | - * @param string $component The slug of the component. |
|
294 | - * @param array $settings The settings supplied for this component. |
|
295 | - * |
|
296 | - * @return bool Whether the settings are valid. |
|
297 | - */ |
|
298 | - protected function validate_import_settings( $component, $settings ) { |
|
299 | - |
|
300 | - /** |
|
301 | - * Filter whether the settings are valid before importing. |
|
302 | - * |
|
303 | - * @since 1.0.0 |
|
304 | - * |
|
305 | - * @param bool $valid Whether the settings are valid. |
|
306 | - * @param array $settings The settings for this component. |
|
307 | - * @param WordPoints_Importer_Feedback $feedback The feedback object. |
|
308 | - */ |
|
309 | - return apply_filters( "wordpoints_import_settings_valid-{$component}", true, $settings, $this->feedback ); |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * Run the import for a component. |
|
314 | - * |
|
315 | - * @since 1.0.0 |
|
316 | - * |
|
317 | - * @param string $component The component to run the import for. |
|
318 | - * @param array $options The selected options of what to import. |
|
319 | - */ |
|
320 | - protected function do_import_for_component( $component, $options ) { |
|
321 | - |
|
322 | - $component_data = WordPoints_Components::instance()->get_component( |
|
323 | - $component |
|
324 | - ); |
|
325 | - |
|
326 | - if ( false === $component_data ) { |
|
327 | - $this->feedback->warning( sprintf( __( 'Skipping %s component—not installed.', 'wordpoints-importer' ), esc_html( $component ) ) ); |
|
328 | - return; |
|
329 | - } |
|
330 | - |
|
331 | - if ( true !== $this->supports_component( $component ) ) { |
|
332 | - $this->feedback->warning( sprintf( __( 'Skipping the %s component—not supported.', 'wordpoints-importer' ), $component_data['name'] ) ); |
|
333 | - return; |
|
334 | - } |
|
335 | - |
|
336 | - $settings = array(); |
|
337 | - |
|
338 | - if ( isset( $options['_data'] ) ) { |
|
339 | - $settings = $options['_data']; |
|
340 | - unset( $options['_data'] ); |
|
341 | - } |
|
342 | - |
|
343 | - if ( empty( $options ) || ! $this->validate_import_settings( $component, $settings ) ) { |
|
344 | - return; |
|
345 | - } |
|
346 | - |
|
347 | - $this->feedback->info( sprintf( __( 'Importing data to the %s component…', 'wordpoints-importer' ), $component_data['name'] ) ); |
|
348 | - |
|
349 | - foreach ( $options as $option => $unused ) { |
|
350 | - $this->do_import_for_option( $option, $component, $settings ); |
|
351 | - } |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * Run the import for an option. |
|
356 | - * |
|
357 | - * The import is split up into different options which the user can select (these |
|
358 | - * are displayed to the user as checkboxes in the form). This handles the import |
|
359 | - * for each of the individual things the user has selected to import. These are |
|
360 | - * all optional, so each is just termed an import "option" here. |
|
361 | - * |
|
362 | - * @since 1.0.0 |
|
363 | - * |
|
364 | - * @param string $option An import option that has been selected. |
|
365 | - * @param string $component The component this option is for. |
|
366 | - * @param array $settings Other settings for this component. |
|
367 | - */ |
|
368 | - protected function do_import_for_option( $option, $component, $settings ) { |
|
369 | - |
|
370 | - if ( ! isset( $this->components[ $component ][ $option ] ) ) { |
|
371 | - $this->feedback->warning( sprintf( __( 'Skipping unrecognized import option “%s”…', 'wordpoints-importer' ), $option ) ); |
|
372 | - return; |
|
373 | - } |
|
374 | - |
|
375 | - $option_data = $this->components[ $component ][ $option ]; |
|
376 | - |
|
377 | - // Check if we can actually run this option. |
|
378 | - if ( isset( $option_data['can_import'] ) ) { |
|
379 | - |
|
380 | - $cant_import = call_user_func( $option_data['can_import'], $settings ); |
|
381 | - |
|
382 | - if ( is_wp_error( $cant_import ) ) { |
|
383 | - $this->feedback->warning( sprintf( __( 'Skipping importing %1$s. Reason: %2$s', 'wordpoints-importer' ), $option_data['label'], $cant_import->get_error_message() ) ); |
|
384 | - return; |
|
385 | - } |
|
386 | - } |
|
387 | - |
|
388 | - // OK, we can run the import method for this option. |
|
389 | - call_user_func( $option_data['function'], $settings ); |
|
390 | - } |
|
158 | + /** |
|
159 | + * The name of the importer. |
|
160 | + * |
|
161 | + * @since 1.0.0 |
|
162 | + * |
|
163 | + * @type string $name |
|
164 | + */ |
|
165 | + protected $name; |
|
166 | + |
|
167 | + /** |
|
168 | + * The components supported by this importer. |
|
169 | + * |
|
170 | + * The keys are the component slugs, the values arrays of options for importing |
|
171 | + * to that component. |
|
172 | + * |
|
173 | + * @since 1.0.0 |
|
174 | + * |
|
175 | + * @type array[] $components |
|
176 | + */ |
|
177 | + protected $components = array(); |
|
178 | + |
|
179 | + /** |
|
180 | + * The feedback provider object. |
|
181 | + * |
|
182 | + * This is only set by self::do_import(). |
|
183 | + * |
|
184 | + * @since 1.0.0 |
|
185 | + * |
|
186 | + * @type WordPoints_Importer_Feedback $feedback |
|
187 | + */ |
|
188 | + protected $feedback; |
|
189 | + |
|
190 | + /** |
|
191 | + * Check if this importer is available. |
|
192 | + * |
|
193 | + * @since 1.0.0 |
|
194 | + * |
|
195 | + * @return true|WP_Error A WP_Error if the importer is not available. |
|
196 | + */ |
|
197 | + abstract public function is_available(); |
|
198 | + |
|
199 | + /** |
|
200 | + * Construct the importer. |
|
201 | + * |
|
202 | + * @since 1.0.0 |
|
203 | + * |
|
204 | + * @param string $name The name of the importer. |
|
205 | + */ |
|
206 | + public function __construct( $name ) { |
|
207 | + |
|
208 | + $this->name = $name; |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * Check if this importer supports a specific component. |
|
213 | + * |
|
214 | + * @since 1.0.0 |
|
215 | + * |
|
216 | + * @param string $component The slug of a component. |
|
217 | + * |
|
218 | + * @return bool True if the component is supported, otherwise false. |
|
219 | + */ |
|
220 | + public function supports_component( $component ) { |
|
221 | + |
|
222 | + return isset( $this->components[ $component ] ); |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * Get the import options for a component. |
|
227 | + * |
|
228 | + * @since 1.0.0 |
|
229 | + * |
|
230 | + * @param string $component The slug of a component. |
|
231 | + * |
|
232 | + * @return array[] The options for this component. |
|
233 | + */ |
|
234 | + public function get_options_for_component( $component ) { |
|
235 | + |
|
236 | + if ( ! $this->supports_component( $component ) ) { |
|
237 | + return array(); |
|
238 | + } |
|
239 | + |
|
240 | + return $this->components[ $component ]; |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Run the import. |
|
245 | + * |
|
246 | + * @since 1.0.0 |
|
247 | + * |
|
248 | + * @param array $args The settings for the import. |
|
249 | + * @param WordPoints_Importer_Feedback $feedback The feedback object. |
|
250 | + */ |
|
251 | + public function do_import( array $args, $feedback = null ) { |
|
252 | + |
|
253 | + if ( ! ( $feedback instanceof WordPoints_Importer_Feedback ) ) { |
|
254 | + $feedback = new WordPoints_Importer_Feedback; |
|
255 | + } |
|
256 | + |
|
257 | + $this->feedback = $feedback; |
|
258 | + |
|
259 | + $this->feedback->info( sprintf( __( 'Importing from %s…', 'wordpoints-importer' ), $this->name ) ); |
|
260 | + |
|
261 | + $this->no_interruptions(); |
|
262 | + |
|
263 | + foreach ( $args as $component => $options ) { |
|
264 | + $this->do_import_for_component( $component, $options ); |
|
265 | + } |
|
266 | + |
|
267 | + $this->feedback->info( __( 'Import complete.', 'wordpoints-importer' ) ); |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * Prevent any interruptions from occurring during the import. |
|
272 | + * |
|
273 | + * @since 1.2.1 |
|
274 | + */ |
|
275 | + protected function no_interruptions() { |
|
276 | + |
|
277 | + ignore_user_abort( true ); |
|
278 | + |
|
279 | + if ( |
|
280 | + // Back-compat with WordPoints 2.1. |
|
281 | + function_exists( 'wordpoints_is_function_disabled' ) |
|
282 | + && ! wordpoints_is_function_disabled( 'set_time_limit' ) |
|
283 | + ) { |
|
284 | + set_time_limit( 0 ); |
|
285 | + } |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Validate the import settings for a component. |
|
290 | + * |
|
291 | + * @since 1.0.0 |
|
292 | + * |
|
293 | + * @param string $component The slug of the component. |
|
294 | + * @param array $settings The settings supplied for this component. |
|
295 | + * |
|
296 | + * @return bool Whether the settings are valid. |
|
297 | + */ |
|
298 | + protected function validate_import_settings( $component, $settings ) { |
|
299 | + |
|
300 | + /** |
|
301 | + * Filter whether the settings are valid before importing. |
|
302 | + * |
|
303 | + * @since 1.0.0 |
|
304 | + * |
|
305 | + * @param bool $valid Whether the settings are valid. |
|
306 | + * @param array $settings The settings for this component. |
|
307 | + * @param WordPoints_Importer_Feedback $feedback The feedback object. |
|
308 | + */ |
|
309 | + return apply_filters( "wordpoints_import_settings_valid-{$component}", true, $settings, $this->feedback ); |
|
310 | + } |
|
311 | + |
|
312 | + /** |
|
313 | + * Run the import for a component. |
|
314 | + * |
|
315 | + * @since 1.0.0 |
|
316 | + * |
|
317 | + * @param string $component The component to run the import for. |
|
318 | + * @param array $options The selected options of what to import. |
|
319 | + */ |
|
320 | + protected function do_import_for_component( $component, $options ) { |
|
321 | + |
|
322 | + $component_data = WordPoints_Components::instance()->get_component( |
|
323 | + $component |
|
324 | + ); |
|
325 | + |
|
326 | + if ( false === $component_data ) { |
|
327 | + $this->feedback->warning( sprintf( __( 'Skipping %s component—not installed.', 'wordpoints-importer' ), esc_html( $component ) ) ); |
|
328 | + return; |
|
329 | + } |
|
330 | + |
|
331 | + if ( true !== $this->supports_component( $component ) ) { |
|
332 | + $this->feedback->warning( sprintf( __( 'Skipping the %s component—not supported.', 'wordpoints-importer' ), $component_data['name'] ) ); |
|
333 | + return; |
|
334 | + } |
|
335 | + |
|
336 | + $settings = array(); |
|
337 | + |
|
338 | + if ( isset( $options['_data'] ) ) { |
|
339 | + $settings = $options['_data']; |
|
340 | + unset( $options['_data'] ); |
|
341 | + } |
|
342 | + |
|
343 | + if ( empty( $options ) || ! $this->validate_import_settings( $component, $settings ) ) { |
|
344 | + return; |
|
345 | + } |
|
346 | + |
|
347 | + $this->feedback->info( sprintf( __( 'Importing data to the %s component…', 'wordpoints-importer' ), $component_data['name'] ) ); |
|
348 | + |
|
349 | + foreach ( $options as $option => $unused ) { |
|
350 | + $this->do_import_for_option( $option, $component, $settings ); |
|
351 | + } |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * Run the import for an option. |
|
356 | + * |
|
357 | + * The import is split up into different options which the user can select (these |
|
358 | + * are displayed to the user as checkboxes in the form). This handles the import |
|
359 | + * for each of the individual things the user has selected to import. These are |
|
360 | + * all optional, so each is just termed an import "option" here. |
|
361 | + * |
|
362 | + * @since 1.0.0 |
|
363 | + * |
|
364 | + * @param string $option An import option that has been selected. |
|
365 | + * @param string $component The component this option is for. |
|
366 | + * @param array $settings Other settings for this component. |
|
367 | + */ |
|
368 | + protected function do_import_for_option( $option, $component, $settings ) { |
|
369 | + |
|
370 | + if ( ! isset( $this->components[ $component ][ $option ] ) ) { |
|
371 | + $this->feedback->warning( sprintf( __( 'Skipping unrecognized import option “%s”…', 'wordpoints-importer' ), $option ) ); |
|
372 | + return; |
|
373 | + } |
|
374 | + |
|
375 | + $option_data = $this->components[ $component ][ $option ]; |
|
376 | + |
|
377 | + // Check if we can actually run this option. |
|
378 | + if ( isset( $option_data['can_import'] ) ) { |
|
379 | + |
|
380 | + $cant_import = call_user_func( $option_data['can_import'], $settings ); |
|
381 | + |
|
382 | + if ( is_wp_error( $cant_import ) ) { |
|
383 | + $this->feedback->warning( sprintf( __( 'Skipping importing %1$s. Reason: %2$s', 'wordpoints-importer' ), $option_data['label'], $cant_import->get_error_message() ) ); |
|
384 | + return; |
|
385 | + } |
|
386 | + } |
|
387 | + |
|
388 | + // OK, we can run the import method for this option. |
|
389 | + call_user_func( $option_data['function'], $settings ); |
|
390 | + } |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | // EOF |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @since 1.0.0 |
58 | 58 | */ |
59 | - do_action( 'wordpoints_register_importers' ); |
|
59 | + do_action('wordpoints_register_importers'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public static function get() { |
74 | 74 | |
75 | - if ( ! self::$initialized ) { |
|
75 | + if (!self::$initialized) { |
|
76 | 76 | self::init(); |
77 | 77 | } |
78 | 78 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @type string $name The name of this importer. |
95 | 95 | * } |
96 | 96 | */ |
97 | - public static function register( $slug, array $args ) { |
|
98 | - self::$importers[ $slug ] = $args; |
|
97 | + public static function register($slug, array $args) { |
|
98 | + self::$importers[$slug] = $args; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @param string $slug The slug of the importer to deregister. |
107 | 107 | */ |
108 | - public static function deregister( $slug ) { |
|
109 | - unset( self::$importers[ $slug ] ); |
|
108 | + public static function deregister($slug) { |
|
109 | + unset(self::$importers[$slug]); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return bool True if the importer is registered, otherwise false. |
120 | 120 | */ |
121 | - public static function is_registered( $slug ) { |
|
121 | + public static function is_registered($slug) { |
|
122 | 122 | |
123 | - if ( ! self::$initialized ) { |
|
123 | + if (!self::$initialized) { |
|
124 | 124 | self::init(); |
125 | 125 | } |
126 | 126 | |
127 | - return isset( self::$importers[ $slug ] ); |
|
127 | + return isset(self::$importers[$slug]); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return WordPoints_Importer|false The importer, or false if it isn't registered. |
138 | 138 | */ |
139 | - public static function get_importer( $slug ) { |
|
139 | + public static function get_importer($slug) { |
|
140 | 140 | |
141 | - if ( ! self::is_registered( $slug ) ) { |
|
141 | + if (!self::is_registered($slug)) { |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | |
145 | - $importer = self::$importers[ $slug ]; |
|
145 | + $importer = self::$importers[$slug]; |
|
146 | 146 | |
147 | - return new $importer['class']( $importer['name'] ); |
|
147 | + return new $importer['class']($importer['name']); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @param string $name The name of the importer. |
205 | 205 | */ |
206 | - public function __construct( $name ) { |
|
206 | + public function __construct($name) { |
|
207 | 207 | |
208 | 208 | $this->name = $name; |
209 | 209 | } |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return bool True if the component is supported, otherwise false. |
219 | 219 | */ |
220 | - public function supports_component( $component ) { |
|
220 | + public function supports_component($component) { |
|
221 | 221 | |
222 | - return isset( $this->components[ $component ] ); |
|
222 | + return isset($this->components[$component]); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -231,13 +231,13 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return array[] The options for this component. |
233 | 233 | */ |
234 | - public function get_options_for_component( $component ) { |
|
234 | + public function get_options_for_component($component) { |
|
235 | 235 | |
236 | - if ( ! $this->supports_component( $component ) ) { |
|
236 | + if (!$this->supports_component($component)) { |
|
237 | 237 | return array(); |
238 | 238 | } |
239 | 239 | |
240 | - return $this->components[ $component ]; |
|
240 | + return $this->components[$component]; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -248,23 +248,23 @@ discard block |
||
248 | 248 | * @param array $args The settings for the import. |
249 | 249 | * @param WordPoints_Importer_Feedback $feedback The feedback object. |
250 | 250 | */ |
251 | - public function do_import( array $args, $feedback = null ) { |
|
251 | + public function do_import(array $args, $feedback = null) { |
|
252 | 252 | |
253 | - if ( ! ( $feedback instanceof WordPoints_Importer_Feedback ) ) { |
|
253 | + if (!($feedback instanceof WordPoints_Importer_Feedback)) { |
|
254 | 254 | $feedback = new WordPoints_Importer_Feedback; |
255 | 255 | } |
256 | 256 | |
257 | 257 | $this->feedback = $feedback; |
258 | 258 | |
259 | - $this->feedback->info( sprintf( __( 'Importing from %s…', 'wordpoints-importer' ), $this->name ) ); |
|
259 | + $this->feedback->info(sprintf(__('Importing from %s…', 'wordpoints-importer'), $this->name)); |
|
260 | 260 | |
261 | 261 | $this->no_interruptions(); |
262 | 262 | |
263 | - foreach ( $args as $component => $options ) { |
|
264 | - $this->do_import_for_component( $component, $options ); |
|
263 | + foreach ($args as $component => $options) { |
|
264 | + $this->do_import_for_component($component, $options); |
|
265 | 265 | } |
266 | 266 | |
267 | - $this->feedback->info( __( 'Import complete.', 'wordpoints-importer' ) ); |
|
267 | + $this->feedback->info(__('Import complete.', 'wordpoints-importer')); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -274,14 +274,14 @@ discard block |
||
274 | 274 | */ |
275 | 275 | protected function no_interruptions() { |
276 | 276 | |
277 | - ignore_user_abort( true ); |
|
277 | + ignore_user_abort(true); |
|
278 | 278 | |
279 | 279 | if ( |
280 | 280 | // Back-compat with WordPoints 2.1. |
281 | - function_exists( 'wordpoints_is_function_disabled' ) |
|
282 | - && ! wordpoints_is_function_disabled( 'set_time_limit' ) |
|
281 | + function_exists('wordpoints_is_function_disabled') |
|
282 | + && !wordpoints_is_function_disabled('set_time_limit') |
|
283 | 283 | ) { |
284 | - set_time_limit( 0 ); |
|
284 | + set_time_limit(0); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return bool Whether the settings are valid. |
297 | 297 | */ |
298 | - protected function validate_import_settings( $component, $settings ) { |
|
298 | + protected function validate_import_settings($component, $settings) { |
|
299 | 299 | |
300 | 300 | /** |
301 | 301 | * Filter whether the settings are valid before importing. |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @param array $settings The settings for this component. |
307 | 307 | * @param WordPoints_Importer_Feedback $feedback The feedback object. |
308 | 308 | */ |
309 | - return apply_filters( "wordpoints_import_settings_valid-{$component}", true, $settings, $this->feedback ); |
|
309 | + return apply_filters("wordpoints_import_settings_valid-{$component}", true, $settings, $this->feedback); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -317,37 +317,37 @@ discard block |
||
317 | 317 | * @param string $component The component to run the import for. |
318 | 318 | * @param array $options The selected options of what to import. |
319 | 319 | */ |
320 | - protected function do_import_for_component( $component, $options ) { |
|
320 | + protected function do_import_for_component($component, $options) { |
|
321 | 321 | |
322 | 322 | $component_data = WordPoints_Components::instance()->get_component( |
323 | 323 | $component |
324 | 324 | ); |
325 | 325 | |
326 | - if ( false === $component_data ) { |
|
327 | - $this->feedback->warning( sprintf( __( 'Skipping %s component—not installed.', 'wordpoints-importer' ), esc_html( $component ) ) ); |
|
326 | + if (false === $component_data) { |
|
327 | + $this->feedback->warning(sprintf(__('Skipping %s component—not installed.', 'wordpoints-importer'), esc_html($component))); |
|
328 | 328 | return; |
329 | 329 | } |
330 | 330 | |
331 | - if ( true !== $this->supports_component( $component ) ) { |
|
332 | - $this->feedback->warning( sprintf( __( 'Skipping the %s component—not supported.', 'wordpoints-importer' ), $component_data['name'] ) ); |
|
331 | + if (true !== $this->supports_component($component)) { |
|
332 | + $this->feedback->warning(sprintf(__('Skipping the %s component—not supported.', 'wordpoints-importer'), $component_data['name'])); |
|
333 | 333 | return; |
334 | 334 | } |
335 | 335 | |
336 | 336 | $settings = array(); |
337 | 337 | |
338 | - if ( isset( $options['_data'] ) ) { |
|
338 | + if (isset($options['_data'])) { |
|
339 | 339 | $settings = $options['_data']; |
340 | - unset( $options['_data'] ); |
|
340 | + unset($options['_data']); |
|
341 | 341 | } |
342 | 342 | |
343 | - if ( empty( $options ) || ! $this->validate_import_settings( $component, $settings ) ) { |
|
343 | + if (empty($options) || !$this->validate_import_settings($component, $settings)) { |
|
344 | 344 | return; |
345 | 345 | } |
346 | 346 | |
347 | - $this->feedback->info( sprintf( __( 'Importing data to the %s component…', 'wordpoints-importer' ), $component_data['name'] ) ); |
|
347 | + $this->feedback->info(sprintf(__('Importing data to the %s component…', 'wordpoints-importer'), $component_data['name'])); |
|
348 | 348 | |
349 | - foreach ( $options as $option => $unused ) { |
|
350 | - $this->do_import_for_option( $option, $component, $settings ); |
|
349 | + foreach ($options as $option => $unused) { |
|
350 | + $this->do_import_for_option($option, $component, $settings); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
@@ -365,28 +365,28 @@ discard block |
||
365 | 365 | * @param string $component The component this option is for. |
366 | 366 | * @param array $settings Other settings for this component. |
367 | 367 | */ |
368 | - protected function do_import_for_option( $option, $component, $settings ) { |
|
368 | + protected function do_import_for_option($option, $component, $settings) { |
|
369 | 369 | |
370 | - if ( ! isset( $this->components[ $component ][ $option ] ) ) { |
|
371 | - $this->feedback->warning( sprintf( __( 'Skipping unrecognized import option “%s”…', 'wordpoints-importer' ), $option ) ); |
|
370 | + if (!isset($this->components[$component][$option])) { |
|
371 | + $this->feedback->warning(sprintf(__('Skipping unrecognized import option “%s”…', 'wordpoints-importer'), $option)); |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | - $option_data = $this->components[ $component ][ $option ]; |
|
375 | + $option_data = $this->components[$component][$option]; |
|
376 | 376 | |
377 | 377 | // Check if we can actually run this option. |
378 | - if ( isset( $option_data['can_import'] ) ) { |
|
378 | + if (isset($option_data['can_import'])) { |
|
379 | 379 | |
380 | - $cant_import = call_user_func( $option_data['can_import'], $settings ); |
|
380 | + $cant_import = call_user_func($option_data['can_import'], $settings); |
|
381 | 381 | |
382 | - if ( is_wp_error( $cant_import ) ) { |
|
383 | - $this->feedback->warning( sprintf( __( 'Skipping importing %1$s. Reason: %2$s', 'wordpoints-importer' ), $option_data['label'], $cant_import->get_error_message() ) ); |
|
382 | + if (is_wp_error($cant_import)) { |
|
383 | + $this->feedback->warning(sprintf(__('Skipping importing %1$s. Reason: %2$s', 'wordpoints-importer'), $option_data['label'], $cant_import->get_error_message())); |
|
384 | 384 | return; |
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | 388 | // OK, we can run the import method for this option. |
389 | - call_user_func( $option_data['function'], $settings ); |
|
389 | + call_user_func($option_data['function'], $settings); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 |
@@ -14,23 +14,23 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wordpoints_importer_admin_menu() { |
16 | 16 | |
17 | - add_submenu_page( |
|
18 | - wordpoints_get_main_admin_menu() |
|
19 | - ,__( 'WordPoints — Import', 'wordpoints-importer' ) |
|
20 | - ,__( 'Import', 'wordpoints-importer' ) |
|
21 | - ,'manage_options' |
|
22 | - ,'wordpoints_import' |
|
23 | - ,'wordpoints_import_admin_screen' |
|
24 | - ); |
|
25 | - |
|
26 | - add_submenu_page( |
|
27 | - '_wordpoints_import' // Fake. |
|
28 | - ,__( 'WordPoints — Importing', 'wordpoints-importer' ) |
|
29 | - ,__( 'Importing', 'wordpoints-importer' ) |
|
30 | - ,'manage_options' |
|
31 | - ,'wordpoints_importing' |
|
32 | - ,'wordpoints_importing_admin_screen' |
|
33 | - ); |
|
17 | + add_submenu_page( |
|
18 | + wordpoints_get_main_admin_menu() |
|
19 | + ,__( 'WordPoints — Import', 'wordpoints-importer' ) |
|
20 | + ,__( 'Import', 'wordpoints-importer' ) |
|
21 | + ,'manage_options' |
|
22 | + ,'wordpoints_import' |
|
23 | + ,'wordpoints_import_admin_screen' |
|
24 | + ); |
|
25 | + |
|
26 | + add_submenu_page( |
|
27 | + '_wordpoints_import' // Fake. |
|
28 | + ,__( 'WordPoints — Importing', 'wordpoints-importer' ) |
|
29 | + ,__( 'Importing', 'wordpoints-importer' ) |
|
30 | + ,'manage_options' |
|
31 | + ,'wordpoints_importing' |
|
32 | + ,'wordpoints_importing_admin_screen' |
|
33 | + ); |
|
34 | 34 | } |
35 | 35 | add_action( 'admin_menu', 'wordpoints_importer_admin_menu' ); |
36 | 36 | add_action( 'network_admin_menu', 'wordpoints_importer_admin_menu' ); |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | */ |
43 | 43 | function wordpoints_import_admin_screen() { |
44 | 44 | |
45 | - /** |
|
46 | - * The importer admin screen. |
|
47 | - * |
|
48 | - * @since 1.0.0 |
|
49 | - */ |
|
50 | - require( dirname( __FILE__ ) . '/screens/import.php' ); |
|
45 | + /** |
|
46 | + * The importer admin screen. |
|
47 | + * |
|
48 | + * @since 1.0.0 |
|
49 | + */ |
|
50 | + require( dirname( __FILE__ ) . '/screens/import.php' ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function wordpoints_importing_admin_screen() { |
59 | 59 | |
60 | - /** |
|
61 | - * The importer admin screen. |
|
62 | - * |
|
63 | - * @since 1.0.0 |
|
64 | - */ |
|
65 | - require( dirname( __FILE__ ) . '/screens/importing.php' ); |
|
60 | + /** |
|
61 | + * The importer admin screen. |
|
62 | + * |
|
63 | + * @since 1.0.0 |
|
64 | + */ |
|
65 | + require( dirname( __FILE__ ) . '/screens/importing.php' ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function wordpoints_importer_register_admin_scripts() { |
74 | 74 | |
75 | - $assets_url = wordpoints_modules_url( |
|
76 | - 'admin/assets' |
|
77 | - , dirname( dirname( __FILE__ ) ) . '/importer.php' |
|
78 | - ); |
|
75 | + $assets_url = wordpoints_modules_url( |
|
76 | + 'admin/assets' |
|
77 | + , dirname( dirname( __FILE__ ) ) . '/importer.php' |
|
78 | + ); |
|
79 | 79 | |
80 | - wp_register_style( |
|
81 | - 'wordpoints-importer-feedback' |
|
82 | - , $assets_url . '/css/feedback.css' |
|
83 | - ); |
|
80 | + wp_register_style( |
|
81 | + 'wordpoints-importer-feedback' |
|
82 | + , $assets_url . '/css/feedback.css' |
|
83 | + ); |
|
84 | 84 | } |
85 | 85 | add_action( 'init', 'wordpoints_importer_register_admin_scripts' ); |
86 | 86 | |
@@ -91,41 +91,41 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function wordpoints_importer_do_import() { |
93 | 93 | |
94 | - if ( ! defined( 'IFRAME_REQUEST' ) ) { |
|
95 | - define( 'IFRAME_REQUEST', true ); |
|
96 | - } |
|
94 | + if ( ! defined( 'IFRAME_REQUEST' ) ) { |
|
95 | + define( 'IFRAME_REQUEST', true ); |
|
96 | + } |
|
97 | 97 | |
98 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
99 | - wp_die( esc_html__( 'Sorry, you are not allowed to import to WordPoints.', 'wordpoints-importer' ) ); |
|
100 | - } |
|
98 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
99 | + wp_die( esc_html__( 'Sorry, you are not allowed to import to WordPoints.', 'wordpoints-importer' ) ); |
|
100 | + } |
|
101 | 101 | |
102 | - check_admin_referer( 'wordpoints_import' ); |
|
102 | + check_admin_referer( 'wordpoints_import' ); |
|
103 | 103 | |
104 | - if ( ! isset( $_GET['importer'] ) ) { |
|
105 | - wp_die( esc_html__( 'No importer selected.', 'wordpoints-importer' ) ); |
|
106 | - } |
|
104 | + if ( ! isset( $_GET['importer'] ) ) { |
|
105 | + wp_die( esc_html__( 'No importer selected.', 'wordpoints-importer' ) ); |
|
106 | + } |
|
107 | 107 | |
108 | - $importer = WordPoints_Importers::get_importer( |
|
109 | - sanitize_key( $_GET['importer'] ) |
|
110 | - ); |
|
108 | + $importer = WordPoints_Importers::get_importer( |
|
109 | + sanitize_key( $_GET['importer'] ) |
|
110 | + ); |
|
111 | 111 | |
112 | - if ( ! ( $importer instanceof WordPoints_Importer ) ) { |
|
113 | - wp_die( esc_html__( 'Importer not installed.', 'wordpoints-importer' ) ); |
|
114 | - } |
|
112 | + if ( ! ( $importer instanceof WordPoints_Importer ) ) { |
|
113 | + wp_die( esc_html__( 'Importer not installed.', 'wordpoints-importer' ) ); |
|
114 | + } |
|
115 | 115 | |
116 | - wp_enqueue_style( 'wordpoints-importer-feedback' ); |
|
116 | + wp_enqueue_style( 'wordpoints-importer-feedback' ); |
|
117 | 117 | |
118 | - $args = array(); |
|
118 | + $args = array(); |
|
119 | 119 | |
120 | - if ( isset( $_GET['wordpoints_import'] ) && is_array( $_GET['wordpoints_import'] ) ) { |
|
121 | - $args = wp_unslash( $_GET['wordpoints_import'] ); // WPCS: sanitization OK. |
|
122 | - } |
|
120 | + if ( isset( $_GET['wordpoints_import'] ) && is_array( $_GET['wordpoints_import'] ) ) { |
|
121 | + $args = wp_unslash( $_GET['wordpoints_import'] ); // WPCS: sanitization OK. |
|
122 | + } |
|
123 | 123 | |
124 | - iframe_header(); |
|
124 | + iframe_header(); |
|
125 | 125 | |
126 | - $importer->do_import( $args ); |
|
126 | + $importer->do_import( $args ); |
|
127 | 127 | |
128 | - iframe_footer(); |
|
128 | + iframe_footer(); |
|
129 | 129 | } |
130 | 130 | add_action( 'update-custom_wordpoints_import', 'wordpoints_importer_do_import' ); |
131 | 131 | |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | */ |
137 | 137 | function wordpoints_importer_admin_screen_points_type_select() { |
138 | 138 | |
139 | - $args = array( 'name' => 'wordpoints_import[points][_data][points_type]' ); |
|
139 | + $args = array( 'name' => 'wordpoints_import[points][_data][points_type]' ); |
|
140 | 140 | |
141 | - ?> |
|
141 | + ?> |
|
142 | 142 | |
143 | 143 | <p> |
144 | 144 | <label for="wordpoints_import[points][_data][points_type]"> |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | <?php |
151 | 151 | } |
152 | 152 | add_action( |
153 | - 'wordpoints_importer_before_component_options-points' |
|
154 | - , 'wordpoints_importer_admin_screen_points_type_select' |
|
153 | + 'wordpoints_importer_before_component_options-points' |
|
154 | + , 'wordpoints_importer_admin_screen_points_type_select' |
|
155 | 155 | ); |
156 | 156 | |
157 | 157 | /** |
@@ -167,24 +167,24 @@ discard block |
||
167 | 167 | */ |
168 | 168 | function wordpoints_importer_validate_points_type_setting( $valid, $settings, $feedback ) { |
169 | 169 | |
170 | - if ( $valid ) { |
|
170 | + if ( $valid ) { |
|
171 | 171 | |
172 | - if ( ! isset( $settings['points_type'] ) ) { |
|
173 | - $feedback->warning( __( 'Skipping Points component—no points type specified.', 'wordpoints-importer' ) ); |
|
174 | - $valid = false; |
|
175 | - } elseif ( ! wordpoints_is_points_type( $settings['points_type'] ) ) { |
|
176 | - $feedback->warning( __( 'Skipping Points component—invalid points type selected.', 'wordpoints-importer' ) ); |
|
177 | - $valid = false; |
|
178 | - } |
|
179 | - } |
|
172 | + if ( ! isset( $settings['points_type'] ) ) { |
|
173 | + $feedback->warning( __( 'Skipping Points component—no points type specified.', 'wordpoints-importer' ) ); |
|
174 | + $valid = false; |
|
175 | + } elseif ( ! wordpoints_is_points_type( $settings['points_type'] ) ) { |
|
176 | + $feedback->warning( __( 'Skipping Points component—invalid points type selected.', 'wordpoints-importer' ) ); |
|
177 | + $valid = false; |
|
178 | + } |
|
179 | + } |
|
180 | 180 | |
181 | - return $valid; |
|
181 | + return $valid; |
|
182 | 182 | } |
183 | 183 | add_action( |
184 | - 'wordpoints_import_settings_valid-points' |
|
185 | - , 'wordpoints_importer_validate_points_type_setting' |
|
186 | - , 10 |
|
187 | - , 3 |
|
184 | + 'wordpoints_import_settings_valid-points' |
|
185 | + , 'wordpoints_importer_validate_points_type_setting' |
|
186 | + , 10 |
|
187 | + , 3 |
|
188 | 188 | ); |
189 | 189 | |
190 | 190 | /** |
@@ -194,20 +194,20 @@ discard block |
||
194 | 194 | */ |
195 | 195 | function wordpoints_importer_admin_screen_rank_group_select() { |
196 | 196 | |
197 | - $rank_groups = WordPoints_Rank_Groups::get(); |
|
197 | + $rank_groups = WordPoints_Rank_Groups::get(); |
|
198 | 198 | |
199 | - // See https://github.com/WordPoints/wordpoints/issues/310. |
|
200 | - $options = array(); |
|
201 | - foreach ( $rank_groups as $rank_group ) { |
|
202 | - $options[ $rank_group->slug ] = $rank_group->name; |
|
203 | - } |
|
199 | + // See https://github.com/WordPoints/wordpoints/issues/310. |
|
200 | + $options = array(); |
|
201 | + foreach ( $rank_groups as $rank_group ) { |
|
202 | + $options[ $rank_group->slug ] = $rank_group->name; |
|
203 | + } |
|
204 | 204 | |
205 | - $dropdown = new WordPoints_Dropdown_Builder( |
|
206 | - $options |
|
207 | - , array( 'name' => 'wordpoints_import[ranks][_data][rank_group]' ) |
|
208 | - ); |
|
205 | + $dropdown = new WordPoints_Dropdown_Builder( |
|
206 | + $options |
|
207 | + , array( 'name' => 'wordpoints_import[ranks][_data][rank_group]' ) |
|
208 | + ); |
|
209 | 209 | |
210 | - ?> |
|
210 | + ?> |
|
211 | 211 | |
212 | 212 | <p> |
213 | 213 | <label for="wordpoints_import[ranks][_data][rank_group]"> |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | <?php |
220 | 220 | } |
221 | 221 | add_action( |
222 | - 'wordpoints_importer_before_component_options-ranks' |
|
223 | - , 'wordpoints_importer_admin_screen_rank_group_select' |
|
222 | + 'wordpoints_importer_before_component_options-ranks' |
|
223 | + , 'wordpoints_importer_admin_screen_rank_group_select' |
|
224 | 224 | ); |
225 | 225 | |
226 | 226 | /** |
@@ -236,24 +236,24 @@ discard block |
||
236 | 236 | */ |
237 | 237 | function wordpoints_importer_validate_rank_group_setting( $valid, $settings, $feedback ) { |
238 | 238 | |
239 | - if ( $valid ) { |
|
239 | + if ( $valid ) { |
|
240 | 240 | |
241 | - if ( ! isset( $settings['rank_group'] ) ) { |
|
242 | - $feedback->warning( __( 'Skipping Ranks component—no rank group specified.', 'wordpoints-importer' ) ); |
|
243 | - $valid = false; |
|
244 | - } elseif ( ! WordPoints_Rank_Groups::is_group_registered( $settings['rank_group'] ) ) { |
|
245 | - $feedback->warning( __( 'Skipping Ranks component—invalid rank group selected.', 'wordpoints-importer' ) ); |
|
246 | - $valid = false; |
|
247 | - } |
|
248 | - } |
|
241 | + if ( ! isset( $settings['rank_group'] ) ) { |
|
242 | + $feedback->warning( __( 'Skipping Ranks component—no rank group specified.', 'wordpoints-importer' ) ); |
|
243 | + $valid = false; |
|
244 | + } elseif ( ! WordPoints_Rank_Groups::is_group_registered( $settings['rank_group'] ) ) { |
|
245 | + $feedback->warning( __( 'Skipping Ranks component—invalid rank group selected.', 'wordpoints-importer' ) ); |
|
246 | + $valid = false; |
|
247 | + } |
|
248 | + } |
|
249 | 249 | |
250 | - return $valid; |
|
250 | + return $valid; |
|
251 | 251 | } |
252 | 252 | add_action( |
253 | - 'wordpoints_import_settings_valid-ranks' |
|
254 | - , 'wordpoints_importer_validate_rank_group_setting' |
|
255 | - , 10 |
|
256 | - , 3 |
|
253 | + 'wordpoints_import_settings_valid-ranks' |
|
254 | + , 'wordpoints_importer_validate_rank_group_setting' |
|
255 | + , 10 |
|
256 | + , 3 |
|
257 | 257 | ); |
258 | 258 | |
259 | 259 | // EOF |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | |
17 | 17 | add_submenu_page( |
18 | 18 | wordpoints_get_main_admin_menu() |
19 | - ,__( 'WordPoints — Import', 'wordpoints-importer' ) |
|
20 | - ,__( 'Import', 'wordpoints-importer' ) |
|
19 | + ,__('WordPoints — Import', 'wordpoints-importer') |
|
20 | + ,__('Import', 'wordpoints-importer') |
|
21 | 21 | ,'manage_options' |
22 | 22 | ,'wordpoints_import' |
23 | 23 | ,'wordpoints_import_admin_screen' |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | |
26 | 26 | add_submenu_page( |
27 | 27 | '_wordpoints_import' // Fake. |
28 | - ,__( 'WordPoints — Importing', 'wordpoints-importer' ) |
|
29 | - ,__( 'Importing', 'wordpoints-importer' ) |
|
28 | + ,__('WordPoints — Importing', 'wordpoints-importer') |
|
29 | + ,__('Importing', 'wordpoints-importer') |
|
30 | 30 | ,'manage_options' |
31 | 31 | ,'wordpoints_importing' |
32 | 32 | ,'wordpoints_importing_admin_screen' |
33 | 33 | ); |
34 | 34 | } |
35 | -add_action( 'admin_menu', 'wordpoints_importer_admin_menu' ); |
|
36 | -add_action( 'network_admin_menu', 'wordpoints_importer_admin_menu' ); |
|
35 | +add_action('admin_menu', 'wordpoints_importer_admin_menu'); |
|
36 | +add_action('network_admin_menu', 'wordpoints_importer_admin_menu'); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Display the importer administration screen. |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @since 1.0.0 |
49 | 49 | */ |
50 | - require( dirname( __FILE__ ) . '/screens/import.php' ); |
|
50 | + require(dirname(__FILE__).'/screens/import.php'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @since 1.0.0 |
64 | 64 | */ |
65 | - require( dirname( __FILE__ ) . '/screens/importing.php' ); |
|
65 | + require(dirname(__FILE__).'/screens/importing.php'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | |
75 | 75 | $assets_url = wordpoints_modules_url( |
76 | 76 | 'admin/assets' |
77 | - , dirname( dirname( __FILE__ ) ) . '/importer.php' |
|
77 | + , dirname(dirname(__FILE__)).'/importer.php' |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | wp_register_style( |
81 | 81 | 'wordpoints-importer-feedback' |
82 | - , $assets_url . '/css/feedback.css' |
|
82 | + , $assets_url.'/css/feedback.css' |
|
83 | 83 | ); |
84 | 84 | } |
85 | -add_action( 'init', 'wordpoints_importer_register_admin_scripts' ); |
|
85 | +add_action('init', 'wordpoints_importer_register_admin_scripts'); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Handle an import request. |
@@ -91,43 +91,43 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function wordpoints_importer_do_import() { |
93 | 93 | |
94 | - if ( ! defined( 'IFRAME_REQUEST' ) ) { |
|
95 | - define( 'IFRAME_REQUEST', true ); |
|
94 | + if (!defined('IFRAME_REQUEST')) { |
|
95 | + define('IFRAME_REQUEST', true); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
99 | - wp_die( esc_html__( 'Sorry, you are not allowed to import to WordPoints.', 'wordpoints-importer' ) ); |
|
98 | + if (!current_user_can('manage_options')) { |
|
99 | + wp_die(esc_html__('Sorry, you are not allowed to import to WordPoints.', 'wordpoints-importer')); |
|
100 | 100 | } |
101 | 101 | |
102 | - check_admin_referer( 'wordpoints_import' ); |
|
102 | + check_admin_referer('wordpoints_import'); |
|
103 | 103 | |
104 | - if ( ! isset( $_GET['importer'] ) ) { |
|
105 | - wp_die( esc_html__( 'No importer selected.', 'wordpoints-importer' ) ); |
|
104 | + if (!isset($_GET['importer'])) { |
|
105 | + wp_die(esc_html__('No importer selected.', 'wordpoints-importer')); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | $importer = WordPoints_Importers::get_importer( |
109 | - sanitize_key( $_GET['importer'] ) |
|
109 | + sanitize_key($_GET['importer']) |
|
110 | 110 | ); |
111 | 111 | |
112 | - if ( ! ( $importer instanceof WordPoints_Importer ) ) { |
|
113 | - wp_die( esc_html__( 'Importer not installed.', 'wordpoints-importer' ) ); |
|
112 | + if (!($importer instanceof WordPoints_Importer)) { |
|
113 | + wp_die(esc_html__('Importer not installed.', 'wordpoints-importer')); |
|
114 | 114 | } |
115 | 115 | |
116 | - wp_enqueue_style( 'wordpoints-importer-feedback' ); |
|
116 | + wp_enqueue_style('wordpoints-importer-feedback'); |
|
117 | 117 | |
118 | 118 | $args = array(); |
119 | 119 | |
120 | - if ( isset( $_GET['wordpoints_import'] ) && is_array( $_GET['wordpoints_import'] ) ) { |
|
121 | - $args = wp_unslash( $_GET['wordpoints_import'] ); // WPCS: sanitization OK. |
|
120 | + if (isset($_GET['wordpoints_import']) && is_array($_GET['wordpoints_import'])) { |
|
121 | + $args = wp_unslash($_GET['wordpoints_import']); // WPCS: sanitization OK. |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | iframe_header(); |
125 | 125 | |
126 | - $importer->do_import( $args ); |
|
126 | + $importer->do_import($args); |
|
127 | 127 | |
128 | 128 | iframe_footer(); |
129 | 129 | } |
130 | -add_action( 'update-custom_wordpoints_import', 'wordpoints_importer_do_import' ); |
|
130 | +add_action('update-custom_wordpoints_import', 'wordpoints_importer_do_import'); |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * Display a points type dropdown above the points component settings. |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | */ |
137 | 137 | function wordpoints_importer_admin_screen_points_type_select() { |
138 | 138 | |
139 | - $args = array( 'name' => 'wordpoints_import[points][_data][points_type]' ); |
|
139 | + $args = array('name' => 'wordpoints_import[points][_data][points_type]'); |
|
140 | 140 | |
141 | 141 | ?> |
142 | 142 | |
143 | 143 | <p> |
144 | 144 | <label for="wordpoints_import[points][_data][points_type]"> |
145 | - <?php esc_html_e( 'Import to points type:', 'wordpoints-importer' ); ?> |
|
146 | - <?php wordpoints_points_types_dropdown( $args ); ?> |
|
145 | + <?php esc_html_e('Import to points type:', 'wordpoints-importer'); ?> |
|
146 | + <?php wordpoints_points_types_dropdown($args); ?> |
|
147 | 147 | </label> |
148 | 148 | </p> |
149 | 149 | |
@@ -165,15 +165,15 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return bool Whether the settings are valid. |
167 | 167 | */ |
168 | -function wordpoints_importer_validate_points_type_setting( $valid, $settings, $feedback ) { |
|
168 | +function wordpoints_importer_validate_points_type_setting($valid, $settings, $feedback) { |
|
169 | 169 | |
170 | - if ( $valid ) { |
|
170 | + if ($valid) { |
|
171 | 171 | |
172 | - if ( ! isset( $settings['points_type'] ) ) { |
|
173 | - $feedback->warning( __( 'Skipping Points component—no points type specified.', 'wordpoints-importer' ) ); |
|
172 | + if (!isset($settings['points_type'])) { |
|
173 | + $feedback->warning(__('Skipping Points component—no points type specified.', 'wordpoints-importer')); |
|
174 | 174 | $valid = false; |
175 | - } elseif ( ! wordpoints_is_points_type( $settings['points_type'] ) ) { |
|
176 | - $feedback->warning( __( 'Skipping Points component—invalid points type selected.', 'wordpoints-importer' ) ); |
|
175 | + } elseif (!wordpoints_is_points_type($settings['points_type'])) { |
|
176 | + $feedback->warning(__('Skipping Points component—invalid points type selected.', 'wordpoints-importer')); |
|
177 | 177 | $valid = false; |
178 | 178 | } |
179 | 179 | } |
@@ -198,20 +198,20 @@ discard block |
||
198 | 198 | |
199 | 199 | // See https://github.com/WordPoints/wordpoints/issues/310. |
200 | 200 | $options = array(); |
201 | - foreach ( $rank_groups as $rank_group ) { |
|
202 | - $options[ $rank_group->slug ] = $rank_group->name; |
|
201 | + foreach ($rank_groups as $rank_group) { |
|
202 | + $options[$rank_group->slug] = $rank_group->name; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $dropdown = new WordPoints_Dropdown_Builder( |
206 | 206 | $options |
207 | - , array( 'name' => 'wordpoints_import[ranks][_data][rank_group]' ) |
|
207 | + , array('name' => 'wordpoints_import[ranks][_data][rank_group]') |
|
208 | 208 | ); |
209 | 209 | |
210 | 210 | ?> |
211 | 211 | |
212 | 212 | <p> |
213 | 213 | <label for="wordpoints_import[ranks][_data][rank_group]"> |
214 | - <?php esc_html_e( 'Import to rank group:', 'wordpoints-importer' ); ?> |
|
214 | + <?php esc_html_e('Import to rank group:', 'wordpoints-importer'); ?> |
|
215 | 215 | <?php $dropdown->display(); ?> |
216 | 216 | </label> |
217 | 217 | </p> |
@@ -234,15 +234,15 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return bool Whether the settings are valid. |
236 | 236 | */ |
237 | -function wordpoints_importer_validate_rank_group_setting( $valid, $settings, $feedback ) { |
|
237 | +function wordpoints_importer_validate_rank_group_setting($valid, $settings, $feedback) { |
|
238 | 238 | |
239 | - if ( $valid ) { |
|
239 | + if ($valid) { |
|
240 | 240 | |
241 | - if ( ! isset( $settings['rank_group'] ) ) { |
|
242 | - $feedback->warning( __( 'Skipping Ranks component—no rank group specified.', 'wordpoints-importer' ) ); |
|
241 | + if (!isset($settings['rank_group'])) { |
|
242 | + $feedback->warning(__('Skipping Ranks component—no rank group specified.', 'wordpoints-importer')); |
|
243 | 243 | $valid = false; |
244 | - } elseif ( ! WordPoints_Rank_Groups::is_group_registered( $settings['rank_group'] ) ) { |
|
245 | - $feedback->warning( __( 'Skipping Ranks component—invalid rank group selected.', 'wordpoints-importer' ) ); |
|
244 | + } elseif (!WordPoints_Rank_Groups::is_group_registered($settings['rank_group'])) { |
|
245 | + $feedback->warning(__('Skipping Ranks component—invalid rank group selected.', 'wordpoints-importer')); |
|
246 | 246 | $valid = false; |
247 | 247 | } |
248 | 248 | } |
@@ -19,22 +19,22 @@ discard block |
||
19 | 19 | // Back-compat with WordPoints 2.1. |
20 | 20 | if ( class_exists( 'WordPoints_PHPUnit_Bootstrap_Loader' ) ) { |
21 | 21 | |
22 | - $loader = WordPoints_PHPUnit_Bootstrap_Loader::instance(); |
|
23 | - $loader->add_plugin( 'cubepoints/cubepoints.php' ); |
|
24 | - $loader->add_php_file( |
|
25 | - WORDPOINTS_IMPORTER_TESTS_DIR . '/includes/activate-cubepoints-components.php' |
|
26 | - , 'after' |
|
27 | - , array( 'dailypoints', 'post_author_points' ) |
|
28 | - ); |
|
22 | + $loader = WordPoints_PHPUnit_Bootstrap_Loader::instance(); |
|
23 | + $loader->add_plugin( 'cubepoints/cubepoints.php' ); |
|
24 | + $loader->add_php_file( |
|
25 | + WORDPOINTS_IMPORTER_TESTS_DIR . '/includes/activate-cubepoints-components.php' |
|
26 | + , 'after' |
|
27 | + , array( 'dailypoints', 'post_author_points' ) |
|
28 | + ); |
|
29 | 29 | |
30 | 30 | } elseif ( ! defined( 'WORDPOINTS_MODULE_TESTS_LOADER' ) ) { |
31 | 31 | |
32 | - /** |
|
33 | - * The function that loads the module for the tests. |
|
34 | - * |
|
35 | - * @since 1.0.0 |
|
36 | - */ |
|
37 | - define( 'WORDPOINTS_MODULE_TESTS_LOADER', 'wordpoints_importer_tests_manually_load_module' ); |
|
32 | + /** |
|
33 | + * The function that loads the module for the tests. |
|
34 | + * |
|
35 | + * @since 1.0.0 |
|
36 | + */ |
|
37 | + define( 'WORDPOINTS_MODULE_TESTS_LOADER', 'wordpoints_importer_tests_manually_load_module' ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | */ |
46 | 46 | function wordpoints_importer_tests_manually_load_module() { |
47 | 47 | |
48 | - require( WORDPOINTS_IMPORTER_TESTS_DIR . '/../../src/importer.php' ); |
|
49 | - require( WORDPOINTS_IMPORTER_TESTS_DIR . '/../../src/admin/admin.php' ); |
|
48 | + require( WORDPOINTS_IMPORTER_TESTS_DIR . '/../../src/importer.php' ); |
|
49 | + require( WORDPOINTS_IMPORTER_TESTS_DIR . '/../../src/admin/admin.php' ); |
|
50 | 50 | |
51 | - wordpoints_importer_tests_manually_load_cubepoints(); |
|
51 | + wordpoints_importer_tests_manually_load_cubepoints(); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -59,25 +59,25 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function wordpoints_importer_tests_manually_load_cubepoints() { |
61 | 61 | |
62 | - require( WP_PLUGIN_DIR . '/cubepoints/cubepoints.php' ); |
|
62 | + require( WP_PLUGIN_DIR . '/cubepoints/cubepoints.php' ); |
|
63 | 63 | |
64 | - cp_activate(); |
|
64 | + cp_activate(); |
|
65 | 65 | |
66 | - // We activate these now so that they will be fully loaded. Otherwise only part |
|
67 | - // of their functions will be loaded, as the rest are defined in a conditional. |
|
68 | - // Because of some of the functions are defined outside of the conditional, there |
|
69 | - // is no way for us to load the functions later without a fatal error from |
|
70 | - // "already defined function". |
|
71 | - cp_module_activation_set( 'dailypoints', 'active' ); |
|
72 | - cp_module_activation_set( 'post_author_points', 'active' ); |
|
66 | + // We activate these now so that they will be fully loaded. Otherwise only part |
|
67 | + // of their functions will be loaded, as the rest are defined in a conditional. |
|
68 | + // Because of some of the functions are defined outside of the conditional, there |
|
69 | + // is no way for us to load the functions later without a fatal error from |
|
70 | + // "already defined function". |
|
71 | + cp_module_activation_set( 'dailypoints', 'active' ); |
|
72 | + cp_module_activation_set( 'post_author_points', 'active' ); |
|
73 | 73 | |
74 | - // We have to do this manually here after WordPress 4.7. |
|
75 | - // https://core.trac.wordpress.org/ticket/38011#comment:3 |
|
76 | - global $wp_version; |
|
74 | + // We have to do this manually here after WordPress 4.7. |
|
75 | + // https://core.trac.wordpress.org/ticket/38011#comment:3 |
|
76 | + global $wp_version; |
|
77 | 77 | |
78 | - if ( version_compare( $wp_version, '4.6', '>' ) ) { |
|
79 | - cp_modules_include(); |
|
80 | - } |
|
78 | + if ( version_compare( $wp_version, '4.6', '>' ) ) { |
|
79 | + cp_modules_include(); |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | // EOF |
@@ -14,27 +14,27 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @type string |
16 | 16 | */ |
17 | -define( 'WORDPOINTS_IMPORTER_TESTS_DIR', dirname( dirname( __FILE__ ) ) ); |
|
17 | +define('WORDPOINTS_IMPORTER_TESTS_DIR', dirname(dirname(__FILE__))); |
|
18 | 18 | |
19 | 19 | // Back-compat with WordPoints 2.1. |
20 | -if ( class_exists( 'WordPoints_PHPUnit_Bootstrap_Loader' ) ) { |
|
20 | +if (class_exists('WordPoints_PHPUnit_Bootstrap_Loader')) { |
|
21 | 21 | |
22 | 22 | $loader = WordPoints_PHPUnit_Bootstrap_Loader::instance(); |
23 | - $loader->add_plugin( 'cubepoints/cubepoints.php' ); |
|
23 | + $loader->add_plugin('cubepoints/cubepoints.php'); |
|
24 | 24 | $loader->add_php_file( |
25 | - WORDPOINTS_IMPORTER_TESTS_DIR . '/includes/activate-cubepoints-components.php' |
|
25 | + WORDPOINTS_IMPORTER_TESTS_DIR.'/includes/activate-cubepoints-components.php' |
|
26 | 26 | , 'after' |
27 | - , array( 'dailypoints', 'post_author_points' ) |
|
27 | + , array('dailypoints', 'post_author_points') |
|
28 | 28 | ); |
29 | 29 | |
30 | -} elseif ( ! defined( 'WORDPOINTS_MODULE_TESTS_LOADER' ) ) { |
|
30 | +} elseif (!defined('WORDPOINTS_MODULE_TESTS_LOADER')) { |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * The function that loads the module for the tests. |
34 | 34 | * |
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | - define( 'WORDPOINTS_MODULE_TESTS_LOADER', 'wordpoints_importer_tests_manually_load_module' ); |
|
37 | + define('WORDPOINTS_MODULE_TESTS_LOADER', 'wordpoints_importer_tests_manually_load_module'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | */ |
46 | 46 | function wordpoints_importer_tests_manually_load_module() { |
47 | 47 | |
48 | - require( WORDPOINTS_IMPORTER_TESTS_DIR . '/../../src/importer.php' ); |
|
49 | - require( WORDPOINTS_IMPORTER_TESTS_DIR . '/../../src/admin/admin.php' ); |
|
48 | + require(WORDPOINTS_IMPORTER_TESTS_DIR.'/../../src/importer.php'); |
|
49 | + require(WORDPOINTS_IMPORTER_TESTS_DIR.'/../../src/admin/admin.php'); |
|
50 | 50 | |
51 | 51 | wordpoints_importer_tests_manually_load_cubepoints(); |
52 | 52 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function wordpoints_importer_tests_manually_load_cubepoints() { |
61 | 61 | |
62 | - require( WP_PLUGIN_DIR . '/cubepoints/cubepoints.php' ); |
|
62 | + require(WP_PLUGIN_DIR.'/cubepoints/cubepoints.php'); |
|
63 | 63 | |
64 | 64 | cp_activate(); |
65 | 65 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | // Because of some of the functions are defined outside of the conditional, there |
69 | 69 | // is no way for us to load the functions later without a fatal error from |
70 | 70 | // "already defined function". |
71 | - cp_module_activation_set( 'dailypoints', 'active' ); |
|
72 | - cp_module_activation_set( 'post_author_points', 'active' ); |
|
71 | + cp_module_activation_set('dailypoints', 'active'); |
|
72 | + cp_module_activation_set('post_author_points', 'active'); |
|
73 | 73 | |
74 | 74 | // We have to do this manually here after WordPress 4.7. |
75 | 75 | // https://core.trac.wordpress.org/ticket/38011#comment:3 |
76 | 76 | global $wp_version; |
77 | 77 | |
78 | - if ( version_compare( $wp_version, '4.6', '>' ) ) { |
|
78 | + if (version_compare($wp_version, '4.6', '>')) { |
|
79 | 79 | cp_modules_include(); |
80 | 80 | } |
81 | 81 | } |