@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @since 2.1.0 |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | - add_action( 'current_screen', array( $this, 'set_current_screen' ) ); |
|
30 | + add_action('current_screen', array($this, 'set_current_screen')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -37,23 +37,23 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @param WP_Screen $current_screen The WP_Screen object for the current screen. |
39 | 39 | */ |
40 | - public function set_current_screen( $current_screen ) { |
|
40 | + public function set_current_screen($current_screen) { |
|
41 | 41 | |
42 | 42 | $screen_id = $current_screen->id; |
43 | 43 | |
44 | - if ( is_network_admin() ) { |
|
45 | - $screen_id = substr( $screen_id, 0, -8 /* -network */ ); |
|
44 | + if (is_network_admin()) { |
|
45 | + $screen_id = substr($screen_id, 0, -8 /* -network */); |
|
46 | 46 | } |
47 | 47 | |
48 | - $screen = $this->get( $screen_id ); |
|
48 | + $screen = $this->get($screen_id); |
|
49 | 49 | |
50 | - if ( ! ( $screen instanceof WordPoints_Admin_Screen ) ) { |
|
50 | + if ( ! ($screen instanceof WordPoints_Admin_Screen)) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $this->current_screen = $screen; |
55 | 55 | |
56 | - add_action( "load-{$screen_id}", array( $this->current_screen, 'load' ) ); |
|
56 | + add_action("load-{$screen_id}", array($this->current_screen, 'load')); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | global $tab; |
11 | 11 | |
12 | -if ( empty( $tab ) ) { |
|
12 | +if (empty($tab)) { |
|
13 | 13 | $tab = 'upload'; |
14 | 14 | } |
15 | 15 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | }); |
26 | 26 | </script> |
27 | 27 | <div class="wrap"> |
28 | - <h1><?php esc_html_e( 'Install Modules', 'wordpoints' ); ?></h1> |
|
28 | + <h1><?php esc_html_e('Install Modules', 'wordpoints'); ?></h1> |
|
29 | 29 | <?php |
30 | 30 | |
31 | 31 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @since 1.1.0 |
37 | 37 | */ |
38 | - do_action( 'wordpoints_install_modules_screen' ); |
|
38 | + do_action('wordpoints_install_modules_screen'); |
|
39 | 39 | |
40 | 40 | ?> |
41 | 41 | <br class="clear" /> |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @since 1.1.0 |
51 | 51 | */ |
52 | - do_action( "wordpoints_install_modules-{$tab}" ); |
|
52 | + do_action("wordpoints_install_modules-{$tab}"); |
|
53 | 53 | |
54 | 54 | ?> |
55 | 55 | </div> |
@@ -7,45 +7,45 @@ discard block |
||
7 | 7 | * @since 1.1.0 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! current_user_can( 'manage_options' ) ) { |
|
10 | +if ( ! current_user_can('manage_options')) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
14 | 14 | if ( |
15 | 15 | 'components' !== wordpoints_admin_get_current_tab() |
16 | - || ! isset( $_POST['wordpoints_component'], $_POST['wordpoints_component_action'], $_POST['_wpnonce'] ) |
|
16 | + || ! isset($_POST['wordpoints_component'], $_POST['wordpoints_component_action'], $_POST['_wpnonce']) |
|
17 | 17 | ) { |
18 | 18 | return; |
19 | 19 | } |
20 | 20 | |
21 | 21 | $components = WordPoints_Components::instance(); |
22 | -$component = sanitize_key( $_POST['wordpoints_component'] ); |
|
22 | +$component = sanitize_key($_POST['wordpoints_component']); |
|
23 | 23 | |
24 | -$action = sanitize_key( $_POST['wordpoints_component_action'] ); |
|
24 | +$action = sanitize_key($_POST['wordpoints_component_action']); |
|
25 | 25 | |
26 | -check_admin_referer( "wordpoints_{$action}_component-{$component}" ); |
|
26 | +check_admin_referer("wordpoints_{$action}_component-{$component}"); |
|
27 | 27 | |
28 | -switch ( $action ) { |
|
28 | +switch ($action) { |
|
29 | 29 | |
30 | 30 | case 'activate': |
31 | - if ( $components->activate( $component ) ) { |
|
31 | + if ($components->activate($component)) { |
|
32 | 32 | |
33 | - $message = array( 'message' => 1 ); |
|
33 | + $message = array('message' => 1); |
|
34 | 34 | |
35 | 35 | } else { |
36 | 36 | |
37 | - $message = array( 'error' => 1 ); |
|
37 | + $message = array('error' => 1); |
|
38 | 38 | } |
39 | 39 | break; |
40 | 40 | |
41 | 41 | case 'deactivate': |
42 | - if ( $components->deactivate( $component ) ) { |
|
42 | + if ($components->deactivate($component)) { |
|
43 | 43 | |
44 | - $message = array( 'message' => 2 ); |
|
44 | + $message = array('message' => 2); |
|
45 | 45 | |
46 | 46 | } else { |
47 | 47 | |
48 | - $message = array( 'error' => 2 ); |
|
48 | + $message = array('error' => 2); |
|
49 | 49 | } |
50 | 50 | break; |
51 | 51 | |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | 'page' => 'wordpoints_configure', |
59 | 59 | 'tab' => 'components', |
60 | 60 | 'wordpoints_component' => $component, |
61 | - '_wpnonce' => wp_create_nonce( 'wordpoints_component_' . key( $message ) . "-{$component}" ), |
|
61 | + '_wpnonce' => wp_create_nonce('wordpoints_component_' . key($message) . "-{$component}"), |
|
62 | 62 | ) |
63 | - , self_admin_url( 'admin.php' ) |
|
63 | + , self_admin_url('admin.php') |
|
64 | 64 | ) |
65 | 65 | ); |
66 | 66 |
@@ -12,18 +12,18 @@ |
||
12 | 12 | $screen->add_help_tab( |
13 | 13 | array( |
14 | 14 | 'id' => 'overview', |
15 | - 'title' => __( 'Overview', 'wordpoints' ), |
|
15 | + 'title' => __('Overview', 'wordpoints'), |
|
16 | 16 | 'content' => |
17 | - '<p>' . esc_html__( 'WordPoints doesn’t have a lot of configuration options, which makes it simple and easy to use.', 'wordpoints' ) . '</p> |
|
18 | - <p>' . esc_html__( 'The settings provided below are optional, and are mainly for convenience', 'wordpoints' ) . '</p> |
|
19 | - <p>' . esc_html__( 'If you need more help getting started with WordPoints, see the links in the help sidebar.', 'wordpoints' ) . '</p>', |
|
17 | + '<p>' . esc_html__('WordPoints doesn’t have a lot of configuration options, which makes it simple and easy to use.', 'wordpoints') . '</p> |
|
18 | + <p>' . esc_html__('The settings provided below are optional, and are mainly for convenience', 'wordpoints') . '</p> |
|
19 | + <p>' . esc_html__('If you need more help getting started with WordPoints, see the links in the help sidebar.', 'wordpoints') . '</p>', |
|
20 | 20 | ) |
21 | 21 | ); |
22 | 22 | |
23 | 23 | $screen->set_help_sidebar( |
24 | - '<p><strong>' . esc_html__( 'For more information:', 'wordpoints' ) . '</strong></p> |
|
25 | - <p><a href="https://wordpoints.org/user-guide/">' . esc_html__( 'User Guide', 'wordpoints' ) . '</a></p> |
|
26 | - <p><a href="https://wordpress.org/support/plugin/wordpoints">' . esc_html__( 'Support Forums', 'wordpoints' ) . '</a></p>' |
|
24 | + '<p><strong>' . esc_html__('For more information:', 'wordpoints') . '</strong></p> |
|
25 | + <p><a href="https://wordpoints.org/user-guide/">' . esc_html__('User Guide', 'wordpoints') . '</a></p> |
|
26 | + <p><a href="https://wordpress.org/support/plugin/wordpoints">' . esc_html__('Support Forums', 'wordpoints') . '</a></p>' |
|
27 | 27 | ); |
28 | 28 | |
29 | 29 | // EOF |
@@ -7,24 +7,24 @@ discard block |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! current_user_can( 'manage_options' ) ) { |
|
10 | +if ( ! current_user_can('manage_options')) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
14 | 14 | if ( |
15 | - isset( $_POST['wordpoints_settings_nonce'], $_POST['excluded_users'] ) |
|
16 | - && wordpoints_verify_nonce( 'wordpoints_settings_nonce', 'wordpoints_settings_submit', null, 'post' ) |
|
15 | + isset($_POST['wordpoints_settings_nonce'], $_POST['excluded_users']) |
|
16 | + && wordpoints_verify_nonce('wordpoints_settings_nonce', 'wordpoints_settings_submit', null, 'post') |
|
17 | 17 | ) { |
18 | 18 | |
19 | 19 | // - The form has been submitted. |
20 | 20 | |
21 | - $excluded_users = preg_replace( '/\s/', '', sanitize_text_field( wp_unslash( $_POST['excluded_users'] ) ) ); |
|
21 | + $excluded_users = preg_replace('/\s/', '', sanitize_text_field(wp_unslash($_POST['excluded_users']))); |
|
22 | 22 | |
23 | - if ( ! empty( $excluded_users ) ) { |
|
23 | + if ( ! empty($excluded_users)) { |
|
24 | 24 | |
25 | - $excluded_users = explode( ',', $excluded_users ); |
|
25 | + $excluded_users = explode(',', $excluded_users); |
|
26 | 26 | |
27 | - $excluded_users = array_unique( array_filter( $excluded_users, 'wordpoints_posint' ) ); |
|
27 | + $excluded_users = array_unique(array_filter($excluded_users, 'wordpoints_posint')); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | wordpoints_update_maybe_network_option( |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @since 1.0.0 |
41 | 41 | */ |
42 | - do_action( 'wordpoints_admin_settings_update' ); |
|
42 | + do_action('wordpoints_admin_settings_update'); |
|
43 | 43 | |
44 | 44 | wordpoints_show_admin_message( |
45 | - esc_html__( 'Settings updated.', 'wordpoints' ) |
|
45 | + esc_html__('Settings updated.', 'wordpoints') |
|
46 | 46 | , 'success' |
47 | - , array( 'dismissible' => true ) |
|
47 | + , array('dismissible' => true) |
|
48 | 48 | ); |
49 | 49 | } |
50 | 50 | |
51 | 51 | ?> |
52 | 52 | |
53 | -<p><?php esc_html_e( 'Configure WordPoints to your liking.', 'wordpoints' ); ?></p> |
|
53 | +<p><?php esc_html_e('Configure WordPoints to your liking.', 'wordpoints'); ?></p> |
|
54 | 54 | <form id="wordpoints-settings" method="post"> |
55 | 55 | |
56 | 56 | <?php |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @since 1.0.0 |
62 | 62 | */ |
63 | - do_action( 'wordpoints_admin_settings_top' ); |
|
63 | + do_action('wordpoints_admin_settings_top'); |
|
64 | 64 | |
65 | 65 | ?> |
66 | 66 | |
67 | - <h3><?php esc_html_e( 'Excluded Users', 'wordpoints' ); ?></h3> |
|
68 | - <p><?php esc_html_e( 'Enter the IDs of users to exclude from leader boards, logs, etc. This may be useful if you use certain accounts for testing.', 'wordpoints' ); ?></p> |
|
67 | + <h3><?php esc_html_e('Excluded Users', 'wordpoints'); ?></h3> |
|
68 | + <p><?php esc_html_e('Enter the IDs of users to exclude from leader boards, logs, etc. This may be useful if you use certain accounts for testing.', 'wordpoints'); ?></p> |
|
69 | 69 | <table class="form-table"> |
70 | 70 | <tbody> |
71 | 71 | <tr> |
72 | 72 | <th> |
73 | - <label for="excluded_users"><?php esc_html_e( 'Excluded Users', 'wordpoints' ); ?></label> |
|
73 | + <label for="excluded_users"><?php esc_html_e('Excluded Users', 'wordpoints'); ?></label> |
|
74 | 74 | </th> |
75 | 75 | <td> |
76 | - <input type="text" name="excluded_users" id="excluded_users" value="<?php echo esc_attr( implode( ', ', wordpoints_get_maybe_network_array_option( 'wordpoints_excluded_users' ) ) ); ?>" /> |
|
76 | + <input type="text" name="excluded_users" id="excluded_users" value="<?php echo esc_attr(implode(', ', wordpoints_get_maybe_network_array_option('wordpoints_excluded_users'))); ?>" /> |
|
77 | 77 | </td> |
78 | 78 | </tr> |
79 | 79 | </tbody> |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @since 1.0.0 |
88 | 88 | */ |
89 | - do_action( 'wordpoints_admin_settings_bottom' ); |
|
89 | + do_action('wordpoints_admin_settings_bottom'); |
|
90 | 90 | |
91 | 91 | ?> |
92 | 92 | |
93 | - <?php wp_nonce_field( 'wordpoints_settings_submit', 'wordpoints_settings_nonce' ); ?> |
|
93 | + <?php wp_nonce_field('wordpoints_settings_submit', 'wordpoints_settings_nonce'); ?> |
|
94 | 94 | <?php submit_button(); ?> |
95 | 95 | </form> |
@@ -567,9 +567,12 @@ |
||
567 | 567 | <p> |
568 | 568 | <?php if ( ! empty( $module_data['description'] ) ) : ?> |
569 | 569 | <?php echo wp_kses( $module_data['description'] , 'wordoints_module_description' ); ?> |
570 | - <?php else : ?> |
|
570 | + <?php else { |
|
571 | + : ?> |
|
571 | 572 | |
572 | - <?php endif; ?> |
|
573 | + <?php endif; |
|
574 | +} |
|
575 | +?> |
|
573 | 576 | </p> |
574 | 577 | </div> |
575 | 578 | <div class="<?php echo esc_attr( $class ); ?> second module-version-author-uri"> |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @param array $args {@see WP_List_Table::__construct()}. |
43 | 43 | */ |
44 | - public function __construct( $args = array() ) { |
|
44 | + public function __construct($args = array()) { |
|
45 | 45 | |
46 | 46 | global $status, $page; |
47 | 47 | |
48 | 48 | parent::__construct( |
49 | 49 | array( |
50 | 50 | 'plural' => 'modules', |
51 | - 'screen' => ( isset( $args['screen'] ) ) ? $args['screen'] : null, |
|
51 | + 'screen' => (isset($args['screen'])) ? $args['screen'] : null, |
|
52 | 52 | ) |
53 | 53 | ); |
54 | 54 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $status = 'all'; |
58 | 58 | |
59 | - $module_statuses = array( 'active', 'inactive', 'recently_activated', 'search' ); |
|
59 | + $module_statuses = array('active', 'inactive', 'recently_activated', 'search'); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Filter the module statuses on the modules administration panel. |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * @param array $statuses The module statuses. The defaults are 'active', |
67 | 67 | * 'inactive', 'recently_activated', and 'search'. |
68 | 68 | */ |
69 | - $module_statuses = apply_filters( 'wordpoints_module_statuses', $module_statuses ); |
|
69 | + $module_statuses = apply_filters('wordpoints_module_statuses', $module_statuses); |
|
70 | 70 | |
71 | - if ( isset( $_REQUEST['module_status'] ) && in_array( wp_unslash( $_REQUEST['module_status'] ), $module_statuses ) ) { |
|
72 | - $status = sanitize_key( $_REQUEST['module_status'] ); |
|
71 | + if (isset($_REQUEST['module_status']) && in_array(wp_unslash($_REQUEST['module_status']), $module_statuses)) { |
|
72 | + $status = sanitize_key($_REQUEST['module_status']); |
|
73 | 73 | } |
74 | 74 | |
75 | - if ( isset( $_REQUEST['s'] ) ) { |
|
76 | - $_SERVER['REQUEST_URI'] = add_query_arg( 's', sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) ); |
|
75 | + if (isset($_REQUEST['s'])) { |
|
76 | + $_SERVER['REQUEST_URI'] = add_query_arg('s', sanitize_text_field(wp_unslash($_REQUEST['s']))); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $page = $this->get_pagenum(); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function get_table_classes() { |
90 | 90 | |
91 | - return array( 'widefat', $this->_args['plural'], 'plugins' ); |
|
91 | + return array('widefat', $this->_args['plural'], 'plugins'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function ajax_user_can() { |
102 | 102 | |
103 | - return current_user_can( 'activate_wordpoints_modules' ); |
|
103 | + return current_user_can('activate_wordpoints_modules'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | global $status, $modules, $totals, $page, $orderby, $order, $s; |
114 | 114 | |
115 | - wp_reset_vars( array( 'orderby', 'order', 's' ) ); |
|
115 | + wp_reset_vars(array('orderby', 'order', 's')); |
|
116 | 116 | |
117 | 117 | $modules = array( |
118 | 118 | /** |
@@ -122,70 +122,70 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @param array $modules All of the installed modules. |
124 | 124 | */ |
125 | - 'all' => apply_filters( 'all_wordpoints_modules', wordpoints_get_modules() ), |
|
125 | + 'all' => apply_filters('all_wordpoints_modules', wordpoints_get_modules()), |
|
126 | 126 | 'search' => array(), |
127 | 127 | 'active' => array(), |
128 | 128 | 'inactive' => array(), |
129 | 129 | 'recently_activated' => array(), |
130 | 130 | ); |
131 | 131 | |
132 | - if ( ! $this->screen->in_admin( 'network' ) ) { |
|
132 | + if ( ! $this->screen->in_admin('network')) { |
|
133 | 133 | |
134 | - $recently_activated = get_option( 'wordpoints_recently_activated_modules' ); |
|
134 | + $recently_activated = get_option('wordpoints_recently_activated_modules'); |
|
135 | 135 | |
136 | - if ( ! is_array( $recently_activated ) ) { |
|
137 | - add_option( 'wordpoints_recently_activated_modules', array(), '', 'no' ); |
|
136 | + if ( ! is_array($recently_activated)) { |
|
137 | + add_option('wordpoints_recently_activated_modules', array(), '', 'no'); |
|
138 | 138 | $recently_activated = array(); |
139 | 139 | } |
140 | 140 | |
141 | - foreach ( $recently_activated as $key => $time ) { |
|
141 | + foreach ($recently_activated as $key => $time) { |
|
142 | 142 | |
143 | - if ( $time + WEEK_IN_SECONDS < time() ) { |
|
144 | - unset( $recently_activated[ $key ] ); |
|
143 | + if ($time + WEEK_IN_SECONDS < time()) { |
|
144 | + unset($recently_activated[$key]); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - update_option( 'wordpoints_recently_activated_modules', $recently_activated ); |
|
148 | + update_option('wordpoints_recently_activated_modules', $recently_activated); |
|
149 | 149 | } |
150 | 150 | |
151 | - foreach ( (array) $modules['all'] as $module_file => $module_data ) { |
|
151 | + foreach ((array) $modules['all'] as $module_file => $module_data) { |
|
152 | 152 | |
153 | 153 | // Filter into individual sections. |
154 | - if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && is_network_only_wordpoints_module( $module_file ) ) { |
|
154 | + if (is_multisite() && ! $this->screen->in_admin('network') && is_network_only_wordpoints_module($module_file)) { |
|
155 | 155 | |
156 | - unset( $modules['all'][ $module_file ] ); |
|
156 | + unset($modules['all'][$module_file]); |
|
157 | 157 | |
158 | - } elseif ( ! $this->screen->in_admin( 'network' ) && is_wordpoints_module_active_for_network( $module_file ) ) { |
|
158 | + } elseif ( ! $this->screen->in_admin('network') && is_wordpoints_module_active_for_network($module_file)) { |
|
159 | 159 | |
160 | - unset( $modules['all'][ $module_file ] ); |
|
160 | + unset($modules['all'][$module_file]); |
|
161 | 161 | |
162 | 162 | } elseif ( |
163 | 163 | ( |
164 | - ! $this->screen->in_admin( 'network' ) |
|
165 | - && is_wordpoints_module_active( $module_file ) |
|
164 | + ! $this->screen->in_admin('network') |
|
165 | + && is_wordpoints_module_active($module_file) |
|
166 | 166 | ) || ( |
167 | - $this->screen->in_admin( 'network' ) |
|
168 | - && is_wordpoints_module_active_for_network( $module_file ) |
|
167 | + $this->screen->in_admin('network') |
|
168 | + && is_wordpoints_module_active_for_network($module_file) |
|
169 | 169 | ) |
170 | 170 | ) { |
171 | 171 | |
172 | - $modules['active'][ $module_file ] = $module_data; |
|
172 | + $modules['active'][$module_file] = $module_data; |
|
173 | 173 | |
174 | 174 | } else { |
175 | 175 | |
176 | 176 | // Was the module recently activated? |
177 | - if ( ! $this->screen->in_admin( 'network' ) && isset( $recently_activated[ $module_file ] ) ) { |
|
178 | - $modules['recently_activated'][ $module_file ] = $module_data; |
|
177 | + if ( ! $this->screen->in_admin('network') && isset($recently_activated[$module_file])) { |
|
178 | + $modules['recently_activated'][$module_file] = $module_data; |
|
179 | 179 | } |
180 | 180 | |
181 | - $modules['inactive'][ $module_file ] = $module_data; |
|
181 | + $modules['inactive'][$module_file] = $module_data; |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - if ( $s ) { |
|
185 | + if ($s) { |
|
186 | 186 | |
187 | 187 | $status = 'search'; |
188 | - $modules['search'] = array_filter( $modules['all'], array( $this, '_search_callback' ) ); |
|
188 | + $modules['search'] = array_filter($modules['all'], array($this, '_search_callback')); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -203,42 +203,42 @@ discard block |
||
203 | 203 | * @type array $recently_activated Modules that were recently active. |
204 | 204 | * } |
205 | 205 | */ |
206 | - $modules = apply_filters( 'wordpoints_modules_list_table_items', $modules ); |
|
206 | + $modules = apply_filters('wordpoints_modules_list_table_items', $modules); |
|
207 | 207 | |
208 | 208 | // Calculate the totals. |
209 | 209 | $totals = array(); |
210 | 210 | |
211 | - foreach ( $modules as $type => $list ) { |
|
212 | - $totals[ $type ] = count( $list ); |
|
211 | + foreach ($modules as $type => $list) { |
|
212 | + $totals[$type] = count($list); |
|
213 | 213 | } |
214 | 214 | |
215 | - if ( empty( $modules[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) ) { |
|
215 | + if (empty($modules[$status]) && ! in_array($status, array('all', 'search'))) { |
|
216 | 216 | $status = 'all'; |
217 | 217 | } |
218 | 218 | |
219 | 219 | $this->items = array(); |
220 | 220 | |
221 | - foreach ( $modules[ $status ] as $module_file => $module_data ) { |
|
221 | + foreach ($modules[$status] as $module_file => $module_data) { |
|
222 | 222 | |
223 | - $this->items[ $module_file ] = wordpoints_get_module_data( wordpoints_modules_dir() . '/' . $module_file, false ); |
|
223 | + $this->items[$module_file] = wordpoints_get_module_data(wordpoints_modules_dir() . '/' . $module_file, false); |
|
224 | 224 | } |
225 | 225 | |
226 | - $total_this_page = $totals[ $status ]; |
|
226 | + $total_this_page = $totals[$status]; |
|
227 | 227 | |
228 | - if ( ! $orderby ) { |
|
228 | + if ( ! $orderby) { |
|
229 | 229 | $orderby = 'name'; |
230 | 230 | } |
231 | 231 | |
232 | - $order = strtoupper( $order ); |
|
232 | + $order = strtoupper($order); |
|
233 | 233 | |
234 | - uasort( $this->items, array( $this, '_order_callback' ) ); |
|
234 | + uasort($this->items, array($this, '_order_callback')); |
|
235 | 235 | |
236 | - $modules_per_page = $this->get_items_per_page( str_replace( '-', '_', $this->screen->id . '_per_page' ), 999 ); |
|
236 | + $modules_per_page = $this->get_items_per_page(str_replace('-', '_', $this->screen->id . '_per_page'), 999); |
|
237 | 237 | |
238 | - $start = ( $page - 1 ) * $modules_per_page; |
|
238 | + $start = ($page - 1) * $modules_per_page; |
|
239 | 239 | |
240 | - if ( $total_this_page > $modules_per_page ) { |
|
241 | - $this->items = array_slice( $this->items, $start, $modules_per_page ); |
|
240 | + if ($total_this_page > $modules_per_page) { |
|
241 | + $this->items = array_slice($this->items, $start, $modules_per_page); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | $this->set_pagination_args( |
@@ -258,17 +258,17 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return bool Whether any of the module's data matches the search. |
260 | 260 | */ |
261 | - private function _search_callback( $module_data ) { |
|
261 | + private function _search_callback($module_data) { |
|
262 | 262 | |
263 | 263 | static $term; |
264 | 264 | |
265 | - if ( is_null( $term ) && isset( $_REQUEST['s'] ) ) { |
|
266 | - $term = sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ); |
|
265 | + if (is_null($term) && isset($_REQUEST['s'])) { |
|
266 | + $term = sanitize_text_field(wp_unslash($_REQUEST['s'])); |
|
267 | 267 | } |
268 | 268 | |
269 | - foreach ( $module_data as $value ) { |
|
269 | + foreach ($module_data as $value) { |
|
270 | 270 | |
271 | - if ( false !== stripos( strip_tags( $value ), $term ) ) { |
|
271 | + if (false !== stripos(strip_tags($value), $term)) { |
|
272 | 272 | return true; |
273 | 273 | } |
274 | 274 | } |
@@ -288,21 +288,21 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return int How the modules compare. |
290 | 290 | */ |
291 | - private function _order_callback( $module_a, $module_b ) { |
|
291 | + private function _order_callback($module_a, $module_b) { |
|
292 | 292 | |
293 | 293 | global $orderby, $order; |
294 | 294 | |
295 | - $a = $module_a[ $orderby ]; |
|
296 | - $b = $module_b[ $orderby ]; |
|
295 | + $a = $module_a[$orderby]; |
|
296 | + $b = $module_b[$orderby]; |
|
297 | 297 | |
298 | - if ( $a === $b ) { |
|
298 | + if ($a === $b) { |
|
299 | 299 | return 0; |
300 | 300 | } |
301 | 301 | |
302 | - if ( 'DESC' === $order ) { |
|
303 | - return strcasecmp( $b, $a ); |
|
302 | + if ('DESC' === $order) { |
|
303 | + return strcasecmp($b, $a); |
|
304 | 304 | } else { |
305 | - return strcasecmp( $a, $b ); |
|
305 | + return strcasecmp($a, $b); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | |
316 | 316 | global $modules; |
317 | 317 | |
318 | - if ( ! empty( $modules['all'] ) ) { |
|
319 | - esc_html_e( 'No modules found.', 'wordpoints' ); |
|
318 | + if ( ! empty($modules['all'])) { |
|
319 | + esc_html_e('No modules found.', 'wordpoints'); |
|
320 | 320 | } else { |
321 | - esc_html_e( 'There are not any modules installed.', 'wordpoints' ); |
|
321 | + esc_html_e('There are not any modules installed.', 'wordpoints'); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | |
334 | 334 | return array( |
335 | 335 | 'cb' => '<input type="checkbox" />', |
336 | - 'name' => esc_html__( 'Module', 'wordpoints' ), |
|
337 | - 'description' => esc_html__( 'Description', 'wordpoints' ), |
|
336 | + 'name' => esc_html__('Module', 'wordpoints'), |
|
337 | + 'description' => esc_html__('Description', 'wordpoints'), |
|
338 | 338 | ); |
339 | 339 | } |
340 | 340 | |
@@ -351,39 +351,39 @@ discard block |
||
351 | 351 | |
352 | 352 | $status_links = array(); |
353 | 353 | |
354 | - foreach ( $totals as $type => $count ) { |
|
354 | + foreach ($totals as $type => $count) { |
|
355 | 355 | |
356 | - if ( ! $count ) { |
|
356 | + if ( ! $count) { |
|
357 | 357 | continue; |
358 | 358 | } |
359 | 359 | |
360 | - switch ( $type ) { |
|
360 | + switch ($type) { |
|
361 | 361 | |
362 | 362 | case 'all': |
363 | 363 | // translators: Count. |
364 | - $text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'modules', 'wordpoints' ); |
|
364 | + $text = _nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'modules', 'wordpoints'); |
|
365 | 365 | break; |
366 | 366 | |
367 | 367 | case 'active': |
368 | 368 | // translators: Count. |
369 | - $text = _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count, 'wordpoints' ); |
|
369 | + $text = _n('Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count, 'wordpoints'); |
|
370 | 370 | break; |
371 | 371 | |
372 | 372 | case 'recently_activated': |
373 | 373 | // translators: Count. |
374 | - $text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count, 'wordpoints' ); |
|
374 | + $text = _n('Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count, 'wordpoints'); |
|
375 | 375 | break; |
376 | 376 | |
377 | 377 | case 'inactive': |
378 | 378 | // translators: Count. |
379 | - $text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count, 'wordpoints' ); |
|
379 | + $text = _n('Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count, 'wordpoints'); |
|
380 | 380 | break; |
381 | 381 | |
382 | 382 | default: |
383 | 383 | $text = $type; |
384 | 384 | } |
385 | 385 | |
386 | - if ( 'search' !== $type ) { |
|
386 | + if ('search' !== $type) { |
|
387 | 387 | |
388 | 388 | /** |
389 | 389 | * Filter the text for a module status link for the module list table. |
@@ -393,13 +393,13 @@ discard block |
||
393 | 393 | * @param string $text The link text. |
394 | 394 | * @param int $count The number of modules matching this filter. |
395 | 395 | */ |
396 | - $text = apply_filters( "wordpoints_modules_status_link_text-{$type}", $text, $count ); |
|
396 | + $text = apply_filters("wordpoints_modules_status_link_text-{$type}", $text, $count); |
|
397 | 397 | |
398 | - $status_links[ $type ] = sprintf( |
|
398 | + $status_links[$type] = sprintf( |
|
399 | 399 | "<a href='%s' %s>%s</a>" |
400 | - , esc_url( add_query_arg( 'module_status', $type, self_admin_url( 'admin.php?page=wordpoints_modules' ) ) ) |
|
401 | - , ( $type === $status ) ? ' class="current"' : '' |
|
402 | - , sprintf( $text, number_format_i18n( $count ) ) |
|
400 | + , esc_url(add_query_arg('module_status', $type, self_admin_url('admin.php?page=wordpoints_modules'))) |
|
401 | + , ($type === $status) ? ' class="current"' : '' |
|
402 | + , sprintf($text, number_format_i18n($count)) |
|
403 | 403 | ); |
404 | 404 | } |
405 | 405 | |
@@ -428,20 +428,20 @@ discard block |
||
428 | 428 | |
429 | 429 | $actions = array(); |
430 | 430 | |
431 | - if ( 'active' !== $status ) { |
|
432 | - $actions['activate-selected'] = ( $this->screen->in_admin( 'network' ) ) ? esc_html__( 'Network Activate', 'wordpoints' ) : esc_html__( 'Activate', 'wordpoints' ); |
|
431 | + if ('active' !== $status) { |
|
432 | + $actions['activate-selected'] = ($this->screen->in_admin('network')) ? esc_html__('Network Activate', 'wordpoints') : esc_html__('Activate', 'wordpoints'); |
|
433 | 433 | } |
434 | 434 | |
435 | - if ( 'inactive' !== $status && 'recent' !== $status ) { |
|
436 | - $actions['deactivate-selected'] = ( $this->screen->in_admin( 'network' ) ) ? esc_html__( 'Network Deactivate', 'wordpoints' ) : esc_html__( 'Deactivate', 'wordpoints' ); |
|
435 | + if ('inactive' !== $status && 'recent' !== $status) { |
|
436 | + $actions['deactivate-selected'] = ($this->screen->in_admin('network')) ? esc_html__('Network Deactivate', 'wordpoints') : esc_html__('Deactivate', 'wordpoints'); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | if ( |
440 | - ( ! is_multisite() || $this->screen->in_admin( 'network' ) ) |
|
441 | - && current_user_can( 'delete_wordpoints_modules' ) |
|
440 | + ( ! is_multisite() || $this->screen->in_admin('network')) |
|
441 | + && current_user_can('delete_wordpoints_modules') |
|
442 | 442 | && 'active' !== $status |
443 | 443 | ) { |
444 | - $actions['delete-selected'] = esc_html__( 'Delete', 'wordpoints' ); |
|
444 | + $actions['delete-selected'] = esc_html__('Delete', 'wordpoints'); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | * @param array $actions The bulk action links. |
453 | 453 | * @param string $status The current module status being displayed. |
454 | 454 | */ |
455 | - $actions = apply_filters( 'wordpoints_module_bulk_actions', $actions, $status ); |
|
455 | + $actions = apply_filters('wordpoints_module_bulk_actions', $actions, $status); |
|
456 | 456 | |
457 | 457 | return $actions; |
458 | 458 | } |
@@ -464,18 +464,18 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @param string $which Not used. |
466 | 466 | */ |
467 | - public function extra_tablenav( $which ) { |
|
467 | + public function extra_tablenav($which) { |
|
468 | 468 | |
469 | 469 | global $status; |
470 | 470 | |
471 | - if ( 'recently_activated' !== $status ) { |
|
471 | + if ('recently_activated' !== $status) { |
|
472 | 472 | return; |
473 | 473 | } |
474 | 474 | |
475 | 475 | echo '<div class="alignleft actions">'; |
476 | 476 | |
477 | - if ( ! $this->screen->in_admin( 'network' ) ) { |
|
478 | - submit_button( __( 'Clear List', 'wordpoints' ), 'button', 'clear-recent-list', false ); |
|
477 | + if ( ! $this->screen->in_admin('network')) { |
|
478 | + submit_button(__('Clear List', 'wordpoints'), 'button', 'clear-recent-list', false); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | echo '</div>'; |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | */ |
489 | 489 | public function display_rows() { |
490 | 490 | |
491 | - foreach ( $this->items as $module_file => $module_data ) { |
|
491 | + foreach ($this->items as $module_file => $module_data) { |
|
492 | 492 | |
493 | - $this->single_row( array( $module_file, $module_data ) ); |
|
493 | + $this->single_row(array($module_file, $module_data)); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
@@ -501,20 +501,20 @@ discard block |
||
501 | 501 | * |
502 | 502 | * @param array $item The module file and the module data. |
503 | 503 | */ |
504 | - public function single_row( $item ) { |
|
504 | + public function single_row($item) { |
|
505 | 505 | |
506 | 506 | global $status; |
507 | 507 | |
508 | - list( $module_file, $module_data ) = $item; |
|
508 | + list($module_file, $module_data) = $item; |
|
509 | 509 | $context = $status; |
510 | 510 | |
511 | - if ( $this->screen->in_admin( 'network' ) ) { |
|
512 | - $is_active = is_wordpoints_module_active_for_network( $module_file ); |
|
511 | + if ($this->screen->in_admin('network')) { |
|
512 | + $is_active = is_wordpoints_module_active_for_network($module_file); |
|
513 | 513 | } else { |
514 | - $is_active = is_wordpoints_module_active( $module_file ); |
|
514 | + $is_active = is_wordpoints_module_active($module_file); |
|
515 | 515 | } |
516 | 516 | |
517 | - $class = ( $is_active ) ? 'active' : 'inactive'; |
|
517 | + $class = ($is_active) ? 'active' : 'inactive'; |
|
518 | 518 | |
519 | 519 | /** |
520 | 520 | * Filter the class of a row of the module's list table. |
@@ -526,88 +526,88 @@ discard block |
||
526 | 526 | * @param string $module_data The module's data. |
527 | 527 | * @param string $context The current status context in which the modules are being displayed. |
528 | 528 | */ |
529 | - $class = apply_filters( 'wordpoints_module_list_row_class', $class, $module_file, $module_data, $context ); |
|
529 | + $class = apply_filters('wordpoints_module_list_row_class', $class, $module_file, $module_data, $context); |
|
530 | 530 | |
531 | 531 | ?> |
532 | - <tr id="<?php echo esc_attr( sanitize_title( $module_data['name'] ) ); ?>" class="<?php echo esc_attr( $class ); ?>"> |
|
532 | + <tr id="<?php echo esc_attr(sanitize_title($module_data['name'])); ?>" class="<?php echo esc_attr($class); ?>"> |
|
533 | 533 | <?php |
534 | 534 | |
535 | - list( $columns, $hidden ) = $this->get_column_info(); |
|
535 | + list($columns, $hidden) = $this->get_column_info(); |
|
536 | 536 | |
537 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
537 | + foreach ($columns as $column_name => $column_display_name) { |
|
538 | 538 | |
539 | - $is_hidden = in_array( $column_name, $hidden ); |
|
539 | + $is_hidden = in_array($column_name, $hidden); |
|
540 | 540 | |
541 | - switch ( $column_name ) { |
|
541 | + switch ($column_name) { |
|
542 | 542 | |
543 | 543 | case 'cb': |
544 | - $checkbox_id = 'checkbox_' . sanitize_key( $module_file ); |
|
544 | + $checkbox_id = 'checkbox_' . sanitize_key($module_file); |
|
545 | 545 | |
546 | 546 | ?> |
547 | 547 | <th scope="row" class="check-column"> |
548 | - <label class="screen-reader-text" for="<?php echo esc_attr( $checkbox_id ); ?>"> |
|
548 | + <label class="screen-reader-text" for="<?php echo esc_attr($checkbox_id); ?>"> |
|
549 | 549 | <?php |
550 | 550 | |
551 | 551 | echo esc_html( |
552 | 552 | sprintf( |
553 | 553 | // translators: Module name. |
554 | - __( 'Select %s', 'wordpoints' ) |
|
554 | + __('Select %s', 'wordpoints') |
|
555 | 555 | , $module_data['name'] |
556 | 556 | ) |
557 | 557 | ); |
558 | 558 | |
559 | 559 | ?> |
560 | 560 | </label> |
561 | - <input type="checkbox" name="checked[]" value="<?php echo esc_attr( $module_file ); ?>" id="<?php echo esc_attr( $checkbox_id ); ?>" /> |
|
561 | + <input type="checkbox" name="checked[]" value="<?php echo esc_attr($module_file); ?>" id="<?php echo esc_attr($checkbox_id); ?>" /> |
|
562 | 562 | </th> |
563 | 563 | <?php |
564 | 564 | break; |
565 | 565 | |
566 | 566 | case 'name': |
567 | 567 | ?> |
568 | - <td class="module-title<?php echo ( $is_hidden ) ? ' hidden' : ''; ?>"> |
|
569 | - <strong><?php echo esc_html( $module_data['name'] ); ?></strong> |
|
570 | - <?php echo $this->row_actions( $this->get_module_row_actions( $module_file, $module_data, $is_active ), true ); // XSS OK WPCS ?> |
|
568 | + <td class="module-title<?php echo ($is_hidden) ? ' hidden' : ''; ?>"> |
|
569 | + <strong><?php echo esc_html($module_data['name']); ?></strong> |
|
570 | + <?php echo $this->row_actions($this->get_module_row_actions($module_file, $module_data, $is_active), true); // XSS OK WPCS ?> |
|
571 | 571 | </td> |
572 | 572 | <?php |
573 | 573 | break; |
574 | 574 | |
575 | 575 | case 'description': |
576 | 576 | ?> |
577 | - <td class="column-description desc<?php echo ( $is_hidden ) ? ' hidden' : ''; ?>"> |
|
577 | + <td class="column-description desc<?php echo ($is_hidden) ? ' hidden' : ''; ?>"> |
|
578 | 578 | <div class="module-description"> |
579 | 579 | <p> |
580 | - <?php if ( ! empty( $module_data['description'] ) ) : ?> |
|
581 | - <?php echo wp_kses( $module_data['description'] , 'wordpoints_module_description' ); ?> |
|
580 | + <?php if ( ! empty($module_data['description'])) : ?> |
|
581 | + <?php echo wp_kses($module_data['description'], 'wordpoints_module_description'); ?> |
|
582 | 582 | <?php else : ?> |
583 | 583 | |
584 | 584 | <?php endif; ?> |
585 | 585 | </p> |
586 | 586 | </div> |
587 | - <div class="<?php echo esc_attr( $class ); ?> second module-version-author-uri"> |
|
587 | + <div class="<?php echo esc_attr($class); ?> second module-version-author-uri"> |
|
588 | 588 | <?php |
589 | 589 | |
590 | 590 | $module_meta = array(); |
591 | 591 | |
592 | - if ( ! empty( $module_data['version'] ) ) { |
|
592 | + if ( ! empty($module_data['version'])) { |
|
593 | 593 | // translators: Module version. |
594 | - $module_meta[] = sprintf( esc_html__( 'Version %s', 'wordpoints' ), $module_data['version'] ); |
|
594 | + $module_meta[] = sprintf(esc_html__('Version %s', 'wordpoints'), $module_data['version']); |
|
595 | 595 | } |
596 | 596 | |
597 | - if ( ! empty( $module_data['author'] ) ) { |
|
597 | + if ( ! empty($module_data['author'])) { |
|
598 | 598 | |
599 | 599 | $author = $module_data['author']; |
600 | 600 | |
601 | - if ( ! empty( $module_data['author_uri'] ) ) { |
|
602 | - $author = '<a href="' . esc_url( $module_data['author_uri'] ) . '">' . esc_html( $module_data['author'] ) . '</a>'; |
|
601 | + if ( ! empty($module_data['author_uri'])) { |
|
602 | + $author = '<a href="' . esc_url($module_data['author_uri']) . '">' . esc_html($module_data['author']) . '</a>'; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | // translators: Author name. |
606 | - $module_meta[] = sprintf( __( 'By %s', 'wordpoints' ), $author ); |
|
606 | + $module_meta[] = sprintf(__('By %s', 'wordpoints'), $author); |
|
607 | 607 | } |
608 | 608 | |
609 | - if ( ! empty( $module_data['module_uri'] ) ) { |
|
610 | - $module_meta[] = '<a href="' . esc_url( $module_data['module_uri'] ) . '">' . esc_html__( 'Visit module site', 'wordpoints' ) . '</a>'; |
|
609 | + if ( ! empty($module_data['module_uri'])) { |
|
610 | + $module_meta[] = '<a href="' . esc_url($module_data['module_uri']) . '">' . esc_html__('Visit module site', 'wordpoints') . '</a>'; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | * @param array $module_data The info about the module. |
624 | 624 | * @param string $status The module status being displayed. |
625 | 625 | */ |
626 | - $module_meta = apply_filters( 'wordpoints_module_row_meta', $module_meta, $module_file, $module_data, $status ); |
|
626 | + $module_meta = apply_filters('wordpoints_module_row_meta', $module_meta, $module_file, $module_data, $status); |
|
627 | 627 | |
628 | - echo wp_kses( implode( ' | ', $module_meta ), 'data' ); |
|
628 | + echo wp_kses(implode(' | ', $module_meta), 'data'); |
|
629 | 629 | |
630 | 630 | ?> |
631 | 631 | </div> |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | |
636 | 636 | default: |
637 | 637 | ?> |
638 | - <td class="<?php echo sanitize_html_class( $column_name ); ?> column-<?php echo sanitize_html_class( $column_name ); ?><?php echo ( $is_hidden ) ? ' hidden' : ''; ?>"> |
|
638 | + <td class="<?php echo sanitize_html_class($column_name); ?> column-<?php echo sanitize_html_class($column_name); ?><?php echo ($is_hidden) ? ' hidden' : ''; ?>"> |
|
639 | 639 | <?php |
640 | 640 | /** |
641 | 641 | * Display the row contents for a custom column in the module list table. |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | * @param string $module_file The main file of the current module. |
647 | 647 | * @param array $module_data The module's info. |
648 | 648 | */ |
649 | - do_action( 'wordpoints_manage_modules_custom_column', $column_name, $module_file, $module_data ); |
|
649 | + do_action('wordpoints_manage_modules_custom_column', $column_name, $module_file, $module_data); |
|
650 | 650 | ?> |
651 | 651 | </td> |
652 | 652 | <?php |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | * @param array $module_data The module's info. |
669 | 669 | * @param string $status The status of the module's being displayed. |
670 | 670 | */ |
671 | - do_action( 'wordpoints_after_module_row', $module_file, $module_data, $status ); |
|
671 | + do_action('wordpoints_after_module_row', $module_file, $module_data, $status); |
|
672 | 672 | |
673 | 673 | /** |
674 | 674 | * After row for a module is displayed in the list table. |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | * |
678 | 678 | * @since 1.1.0 |
679 | 679 | */ |
680 | - do_action( "wordpoints_after_module_row_{$module_file}", $module_file, $module_data, $status ); |
|
680 | + do_action("wordpoints_after_module_row_{$module_file}", $module_file, $module_data, $status); |
|
681 | 681 | |
682 | 682 | } // function single_row() |
683 | 683 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return string[] The action links for this module. |
694 | 694 | */ |
695 | - private function get_module_row_actions( $module_file, $module_data, $is_active ) { |
|
695 | + private function get_module_row_actions($module_file, $module_data, $is_active) { |
|
696 | 696 | |
697 | 697 | global $page, $s, $status; |
698 | 698 | |
@@ -705,51 +705,51 @@ discard block |
||
705 | 705 | 'delete' => '', |
706 | 706 | ); |
707 | 707 | |
708 | - $url = self_admin_url( 'admin.php?page=wordpoints_modules&module=' . $module_file . '&module_status=' . $context . '&paged=' . $page . '&s=' . $s ); |
|
708 | + $url = self_admin_url('admin.php?page=wordpoints_modules&module=' . $module_file . '&module_status=' . $context . '&paged=' . $page . '&s=' . $s); |
|
709 | 709 | |
710 | - if ( $this->screen->in_admin( 'network' ) ) { |
|
710 | + if ($this->screen->in_admin('network')) { |
|
711 | 711 | |
712 | - if ( $is_active ) { |
|
712 | + if ($is_active) { |
|
713 | 713 | |
714 | - if ( current_user_can( 'manage_network_wordpoints_modules' ) ) { |
|
714 | + if (current_user_can('manage_network_wordpoints_modules')) { |
|
715 | 715 | // translators: Module name. |
716 | - $actions['deactivate'] = '<a href="' . wp_nonce_url( add_query_arg( 'action', 'deactivate', $url ), "deactivate-module_{$module_file}" ) . '" aria-label="' . esc_attr( sprintf( __( 'Network deactivate %s', 'wordpoints' ), $module_data['name'] ) ) . '">' . esc_html__( 'Network Deactivate', 'wordpoints' ) . '</a>'; |
|
716 | + $actions['deactivate'] = '<a href="' . wp_nonce_url(add_query_arg('action', 'deactivate', $url), "deactivate-module_{$module_file}") . '" aria-label="' . esc_attr(sprintf(__('Network deactivate %s', 'wordpoints'), $module_data['name'])) . '">' . esc_html__('Network Deactivate', 'wordpoints') . '</a>'; |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | } else { |
720 | 720 | |
721 | - if ( current_user_can( 'manage_network_wordpoints_modules' ) ) { |
|
721 | + if (current_user_can('manage_network_wordpoints_modules')) { |
|
722 | 722 | // translators: Module name. |
723 | - $actions['activate'] = '<a href="' . wp_nonce_url( add_query_arg( 'action', 'activate', $url ), "activate-module_{$module_file}" ) . '" aria-label="' . esc_attr( sprintf( __( 'Network activate %s', 'wordpoints' ), $module_data['name'] ) ) . '" class="edit">' . esc_html__( 'Network Activate', 'wordpoints' ) . '</a>'; |
|
723 | + $actions['activate'] = '<a href="' . wp_nonce_url(add_query_arg('action', 'activate', $url), "activate-module_{$module_file}") . '" aria-label="' . esc_attr(sprintf(__('Network activate %s', 'wordpoints'), $module_data['name'])) . '" class="edit">' . esc_html__('Network Activate', 'wordpoints') . '</a>'; |
|
724 | 724 | } |
725 | 725 | |
726 | - if ( current_user_can( 'delete_wordpoints_modules' ) && ! is_wordpoints_module_active( $module_file ) ) { |
|
726 | + if (current_user_can('delete_wordpoints_modules') && ! is_wordpoints_module_active($module_file)) { |
|
727 | 727 | // translators: Module name. |
728 | - $actions['delete'] = '<a href="' . wp_nonce_url( self_admin_url( 'admin.php?page=wordpoints_modules&action=delete-selected&checked[]=' . $module_file . '&module_status=' . $context . '&paged=' . $page . '&s=' . $s ), 'bulk-modules' ) . '" aria-label="' . esc_attr( sprintf( __( 'Delete %s', 'wordpoints' ), $module_data['name'] ) ) . '" class="delete">' . esc_html__( 'Delete', 'wordpoints' ) . '</a>'; |
|
728 | + $actions['delete'] = '<a href="' . wp_nonce_url(self_admin_url('admin.php?page=wordpoints_modules&action=delete-selected&checked[]=' . $module_file . '&module_status=' . $context . '&paged=' . $page . '&s=' . $s), 'bulk-modules') . '" aria-label="' . esc_attr(sprintf(__('Delete %s', 'wordpoints'), $module_data['name'])) . '" class="delete">' . esc_html__('Delete', 'wordpoints') . '</a>'; |
|
729 | 729 | } |
730 | 730 | } |
731 | 731 | |
732 | 732 | } else { |
733 | 733 | |
734 | - if ( $is_active ) { |
|
734 | + if ($is_active) { |
|
735 | 735 | |
736 | 736 | // translators: Module name. |
737 | - $actions['deactivate'] = '<a href="' . wp_nonce_url( add_query_arg( 'action', 'deactivate', $url ), "deactivate-module_{$module_file}" ) . '" aria-label="' . esc_attr( sprintf( __( 'Deactivate %s', 'wordpoints' ), $module_data['name'] ) ) . '">' . esc_html__( 'Deactivate', 'wordpoints' ) . '</a>'; |
|
737 | + $actions['deactivate'] = '<a href="' . wp_nonce_url(add_query_arg('action', 'deactivate', $url), "deactivate-module_{$module_file}") . '" aria-label="' . esc_attr(sprintf(__('Deactivate %s', 'wordpoints'), $module_data['name'])) . '">' . esc_html__('Deactivate', 'wordpoints') . '</a>'; |
|
738 | 738 | |
739 | 739 | } else { |
740 | 740 | |
741 | 741 | // translators: Module name. |
742 | - $actions['activate'] = '<a href="' . wp_nonce_url( add_query_arg( 'action', 'activate', $url ), "activate-module_{$module_file}" ) . '" aria-label="' . esc_attr( sprintf( __( 'Activate %s', 'wordpoints' ), $module_data['name'] ) ) . '" class="edit">' . esc_html__( 'Activate', 'wordpoints' ) . '</a>'; |
|
742 | + $actions['activate'] = '<a href="' . wp_nonce_url(add_query_arg('action', 'activate', $url), "activate-module_{$module_file}") . '" aria-label="' . esc_attr(sprintf(__('Activate %s', 'wordpoints'), $module_data['name'])) . '" class="edit">' . esc_html__('Activate', 'wordpoints') . '</a>'; |
|
743 | 743 | |
744 | - if ( ! is_multisite() && current_user_can( 'delete_wordpoints_modules' ) ) { |
|
744 | + if ( ! is_multisite() && current_user_can('delete_wordpoints_modules')) { |
|
745 | 745 | // translators: Module name. |
746 | - $actions['delete'] = '<a href="' . wp_nonce_url( self_admin_url( 'admin.php?page=wordpoints_modules&action=delete-selected&checked[]=' . $module_file . '&module_status=' . $context . '&paged=' . $page . '&s=' . $s ), 'bulk-modules' ) . '" aria-label="' . esc_attr( sprintf( __( 'Delete %s', 'wordpoints' ), $module_data['name'] ) ) . '" class="delete">' . esc_html__( 'Delete', 'wordpoints' ) . '</a>'; |
|
746 | + $actions['delete'] = '<a href="' . wp_nonce_url(self_admin_url('admin.php?page=wordpoints_modules&action=delete-selected&checked[]=' . $module_file . '&module_status=' . $context . '&paged=' . $page . '&s=' . $s), 'bulk-modules') . '" aria-label="' . esc_attr(sprintf(__('Delete %s', 'wordpoints'), $module_data['name'])) . '" class="delete">' . esc_html__('Delete', 'wordpoints') . '</a>'; |
|
747 | 747 | } |
748 | 748 | } |
749 | 749 | |
750 | 750 | } // End if ( network admin ) {} else {}. |
751 | 751 | |
752 | - $prefix = $this->screen->in_admin( 'network' ) ? 'network_admin_' : ''; |
|
752 | + $prefix = $this->screen->in_admin('network') ? 'network_admin_' : ''; |
|
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Filter the module action links. |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | * @param array $module_data The module's info. |
772 | 772 | * @param string $context The status of the modules being displayed. |
773 | 773 | */ |
774 | - $actions = apply_filters( $prefix . 'wordpoints_module_action_links', array_filter( $actions ), $module_file, $module_data, $context ); |
|
774 | + $actions = apply_filters($prefix . 'wordpoints_module_action_links', array_filter($actions), $module_file, $module_data, $context); |
|
775 | 775 | |
776 | 776 | /** |
777 | 777 | * Filter the action links for a specific module. |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | * |
781 | 781 | * @since 1.1.0 |
782 | 782 | */ |
783 | - return apply_filters( $prefix . "wordpoints_module_action_links_{$module_file}", $actions, $module_file, $module_data, $context ); |
|
783 | + return apply_filters($prefix . "wordpoints_module_action_links_{$module_file}", $actions, $module_file, $module_data, $context); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | } // class WordPoints_Modules_List_Table |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return bool Whether the module is active. |
20 | 20 | */ |
21 | -function is_wordpoints_module_active( $module ) { |
|
21 | +function is_wordpoints_module_active($module) { |
|
22 | 22 | |
23 | 23 | return ( |
24 | - in_array( $module, wordpoints_get_array_option( 'wordpoints_active_modules' ) ) |
|
25 | - || is_wordpoints_module_active_for_network( $module ) |
|
24 | + in_array($module, wordpoints_get_array_option('wordpoints_active_modules')) |
|
25 | + || is_wordpoints_module_active_for_network($module) |
|
26 | 26 | ); |
27 | 27 | } |
28 | 28 | |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return bool Whether the module is network active. |
37 | 37 | */ |
38 | -function is_wordpoints_module_active_for_network( $module ) { |
|
38 | +function is_wordpoints_module_active_for_network($module) { |
|
39 | 39 | |
40 | - if ( ! is_wordpoints_network_active() ) { |
|
40 | + if ( ! is_wordpoints_network_active()) { |
|
41 | 41 | return false; |
42 | 42 | } |
43 | 43 | |
44 | - $modules = wordpoints_get_array_option( 'wordpoints_sitewide_active_modules', 'site' ); |
|
44 | + $modules = wordpoints_get_array_option('wordpoints_sitewide_active_modules', 'site'); |
|
45 | 45 | |
46 | - if ( isset( $modules[ $module ] ) ) { |
|
46 | + if (isset($modules[$module])) { |
|
47 | 47 | return true; |
48 | 48 | } |
49 | 49 | |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return bool True if the module is network only, false otherwise. |
67 | 67 | */ |
68 | -function is_network_only_wordpoints_module( $module ) { |
|
68 | +function is_network_only_wordpoints_module($module) { |
|
69 | 69 | |
70 | - $module_data = wordpoints_get_module_data( wordpoints_modules_dir() . '/' . $module ); |
|
70 | + $module_data = wordpoints_get_module_data(wordpoints_modules_dir() . '/' . $module); |
|
71 | 71 | |
72 | 72 | return $module_data['network']; |
73 | 73 | } |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return bool True if the module has an uninstall script, false otherwise. |
83 | 83 | */ |
84 | -function is_uninstallable_wordpoints_module( $module ) { |
|
84 | +function is_uninstallable_wordpoints_module($module) { |
|
85 | 85 | |
86 | - return ( file_exists( wordpoints_modules_dir() . '/' . dirname( wordpoints_module_basename( $module ) ) . '/uninstall.php' ) ); |
|
86 | + return (file_exists(wordpoints_modules_dir() . '/' . dirname(wordpoints_module_basename($module)) . '/uninstall.php')); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -143,30 +143,30 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return bool Whether the path was able to be registered. |
145 | 145 | */ |
146 | - public static function register( $file ) { |
|
146 | + public static function register($file) { |
|
147 | 147 | |
148 | - $file = wp_normalize_path( $file ); |
|
148 | + $file = wp_normalize_path($file); |
|
149 | 149 | |
150 | 150 | // We store this so that we don't have to keep normalizing a constant value. |
151 | - if ( ! isset( self::$modules_dir ) ) { |
|
152 | - self::$modules_dir = wp_normalize_path( wordpoints_modules_dir() ); |
|
151 | + if ( ! isset(self::$modules_dir)) { |
|
152 | + self::$modules_dir = wp_normalize_path(wordpoints_modules_dir()); |
|
153 | 153 | } |
154 | 154 | |
155 | - $module_path = wp_normalize_path( dirname( $file ) ); |
|
155 | + $module_path = wp_normalize_path(dirname($file)); |
|
156 | 156 | |
157 | 157 | // It was a single-file module. |
158 | - if ( $module_path . '/' === self::$modules_dir ) { |
|
158 | + if ($module_path . '/' === self::$modules_dir) { |
|
159 | 159 | return false; |
160 | 160 | } |
161 | 161 | |
162 | - $module_realpath = wp_normalize_path( dirname( realpath( $file ) ) ); |
|
162 | + $module_realpath = wp_normalize_path(dirname(realpath($file))); |
|
163 | 163 | |
164 | - if ( $module_path !== $module_realpath ) { |
|
164 | + if ($module_path !== $module_realpath) { |
|
165 | 165 | |
166 | - $realpath_length = strlen( $module_realpath ); |
|
166 | + $realpath_length = strlen($module_realpath); |
|
167 | 167 | |
168 | 168 | // Use unique keys, but still easy to sort by realpath length. |
169 | - self::$paths[ $realpath_length . '-' . $module_path ] = array( |
|
169 | + self::$paths[$realpath_length . '-' . $module_path] = array( |
|
170 | 170 | 'module_path' => $module_path, |
171 | 171 | 'module_realpath' => $module_realpath, |
172 | 172 | 'realpath_length' => $realpath_length, |
@@ -187,19 +187,19 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string The path to the symlink in the modules directory. |
189 | 189 | */ |
190 | - public static function resolve( $file ) { |
|
190 | + public static function resolve($file) { |
|
191 | 191 | |
192 | - $file = wp_normalize_path( $file ); |
|
192 | + $file = wp_normalize_path($file); |
|
193 | 193 | |
194 | 194 | // Sort the paths by the realpath length, see https://core.trac.wordpress.org/ticket/28441. |
195 | - if ( ! self::$paths_sorted ) { |
|
196 | - krsort( self::$paths ); |
|
195 | + if ( ! self::$paths_sorted) { |
|
196 | + krsort(self::$paths); |
|
197 | 197 | self::$paths_sorted = true; |
198 | 198 | } |
199 | 199 | |
200 | - foreach ( self::$paths as $path ) { |
|
201 | - if ( 0 === strpos( $file, $path['module_realpath'] ) ) { |
|
202 | - $file = $path['module_path'] . substr( $file, $path['realpath_length'] ); |
|
200 | + foreach (self::$paths as $path) { |
|
201 | + if (0 === strpos($file, $path['module_realpath'])) { |
|
202 | + $file = $path['module_path'] . substr($file, $path['realpath_length']); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | |
229 | 229 | static $modules_dir; |
230 | 230 | |
231 | - if ( ! $modules_dir ) { |
|
231 | + if ( ! $modules_dir) { |
|
232 | 232 | |
233 | - if ( defined( 'WORDPOINTS_MODULES_DIR' ) ) { |
|
233 | + if (defined('WORDPOINTS_MODULES_DIR')) { |
|
234 | 234 | |
235 | - $modules_dir = trailingslashit( WORDPOINTS_MODULES_DIR ); |
|
235 | + $modules_dir = trailingslashit(WORDPOINTS_MODULES_DIR); |
|
236 | 236 | |
237 | 237 | } else { |
238 | 238 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @param string $module_dir The full path to the modules folder. |
250 | 250 | */ |
251 | - return apply_filters( 'wordpoints_modules_dir', $modules_dir ); |
|
251 | + return apply_filters('wordpoints_modules_dir', $modules_dir); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -261,30 +261,30 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return string The URL for the path passed. |
263 | 263 | */ |
264 | -function wordpoints_modules_url( $path = '', $module = '' ) { |
|
264 | +function wordpoints_modules_url($path = '', $module = '') { |
|
265 | 265 | |
266 | - $path = wp_normalize_path( $path ); |
|
267 | - $module = wp_normalize_path( $module ); |
|
266 | + $path = wp_normalize_path($path); |
|
267 | + $module = wp_normalize_path($module); |
|
268 | 268 | |
269 | - if ( defined( 'WORDPOINTS_MODULES_URL' ) ) { |
|
269 | + if (defined('WORDPOINTS_MODULES_URL')) { |
|
270 | 270 | $url = WORDPOINTS_MODULES_URL; |
271 | 271 | } else { |
272 | 272 | $url = WP_CONTENT_URL . '/wordpoints-modules'; |
273 | 273 | } |
274 | 274 | |
275 | - $url = set_url_scheme( $url ); |
|
275 | + $url = set_url_scheme($url); |
|
276 | 276 | |
277 | - if ( ! empty( $module ) && is_string( $module ) ) { |
|
277 | + if ( ! empty($module) && is_string($module)) { |
|
278 | 278 | |
279 | - $folder = dirname( wordpoints_module_basename( $module ) ); |
|
279 | + $folder = dirname(wordpoints_module_basename($module)); |
|
280 | 280 | |
281 | - if ( '.' !== $folder ) { |
|
282 | - $url .= '/' . ltrim( $folder, '/' ); |
|
281 | + if ('.' !== $folder) { |
|
282 | + $url .= '/' . ltrim($folder, '/'); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | - if ( $path && is_string( $path ) ) { |
|
287 | - $url .= '/' . ltrim( $path, '/' ); |
|
286 | + if ($path && is_string($path)) { |
|
287 | + $url .= '/' . ltrim($path, '/'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @param string $path A relative path to a file or folder. |
297 | 297 | * @param string $module A module file that the $path should be relative to. |
298 | 298 | */ |
299 | - return apply_filters( 'wordpoints_modules_url', $url, $path, $module ); |
|
299 | + return apply_filters('wordpoints_modules_url', $url, $path, $module); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -308,17 +308,17 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return string The name of the module file. |
310 | 310 | */ |
311 | -function wordpoints_module_basename( $file ) { |
|
311 | +function wordpoints_module_basename($file) { |
|
312 | 312 | |
313 | 313 | // Sanitize, and resolve possible symlink path from what is likely a real path. |
314 | - $file = WordPoints_Module_Paths::resolve( $file ); |
|
314 | + $file = WordPoints_Module_Paths::resolve($file); |
|
315 | 315 | |
316 | 316 | // Sanitize for Win32 installs and remove any duplicate slashes. |
317 | - $modules_dir = wp_normalize_path( wordpoints_modules_dir() ); |
|
317 | + $modules_dir = wp_normalize_path(wordpoints_modules_dir()); |
|
318 | 318 | |
319 | 319 | // Get the relative path from the modules directory, and trim off the slashes. |
320 | - $file = preg_replace( '#^' . preg_quote( $modules_dir, '#' ) . '#', '', $file ); |
|
321 | - $file = trim( $file, '/' ); |
|
320 | + $file = preg_replace('#^' . preg_quote($modules_dir, '#') . '#', '', $file); |
|
321 | + $file = trim($file, '/'); |
|
322 | 322 | |
323 | 323 | return $file; |
324 | 324 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @type string $namespace The namespace for this module. Should be Title_Case, and omit "WordPoints" prefix. |
359 | 359 | * } |
360 | 360 | */ |
361 | -function wordpoints_get_module_data( $module_file, $markup = true, $translate = true ) { |
|
361 | +function wordpoints_get_module_data($module_file, $markup = true, $translate = true) { |
|
362 | 362 | |
363 | 363 | $default_headers = array( |
364 | 364 | 'name' => 'Module Name', |
@@ -376,94 +376,94 @@ discard block |
||
376 | 376 | 'namespace' => 'Namespace', |
377 | 377 | ); |
378 | 378 | |
379 | - $module_data = WordPoints_Modules::get_data( $module_file ); |
|
379 | + $module_data = WordPoints_Modules::get_data($module_file); |
|
380 | 380 | |
381 | - if ( $module_data && wp_normalize_path( $module_file ) === $module_data['raw_file'] ) { |
|
382 | - unset( $module_data['raw'], $module_data['raw_file'] ); |
|
381 | + if ($module_data && wp_normalize_path($module_file) === $module_data['raw_file']) { |
|
382 | + unset($module_data['raw'], $module_data['raw_file']); |
|
383 | 383 | } else { |
384 | - $module_data = get_file_data( $module_file, $default_headers, 'wordpoints_module' ); |
|
384 | + $module_data = get_file_data($module_file, $default_headers, 'wordpoints_module'); |
|
385 | 385 | } |
386 | 386 | |
387 | - if ( ! empty( $module_data['update_api'] ) ) { |
|
388 | - _deprecated_argument( __FUNCTION__, '1.10.0', 'The "Update API" module header has been deprecated in favor of "Channel".' ); |
|
387 | + if ( ! empty($module_data['update_api'])) { |
|
388 | + _deprecated_argument(__FUNCTION__, '1.10.0', 'The "Update API" module header has been deprecated in favor of "Channel".'); |
|
389 | 389 | } |
390 | 390 | |
391 | - $module_data['network'] = ( 'true' === strtolower( $module_data['network'] ) ); |
|
391 | + $module_data['network'] = ('true' === strtolower($module_data['network'])); |
|
392 | 392 | |
393 | - if ( $markup || $translate ) { |
|
393 | + if ($markup || $translate) { |
|
394 | 394 | |
395 | 395 | // Sanitize the plugin filename to a WP_module_DIR relative path |
396 | - $module_file = wordpoints_module_basename( $module_file ); |
|
396 | + $module_file = wordpoints_module_basename($module_file); |
|
397 | 397 | |
398 | 398 | // Translate fields |
399 | - if ( $translate ) { |
|
399 | + if ($translate) { |
|
400 | 400 | |
401 | 401 | $textdomain = $module_data['text_domain']; |
402 | 402 | |
403 | - if ( $textdomain ) { |
|
403 | + if ($textdomain) { |
|
404 | 404 | |
405 | - if ( ! is_textdomain_loaded( $textdomain ) ) { |
|
405 | + if ( ! is_textdomain_loaded($textdomain)) { |
|
406 | 406 | |
407 | - $domain_path = dirname( $module_file ); |
|
407 | + $domain_path = dirname($module_file); |
|
408 | 408 | |
409 | - if ( $module_data['domain_path'] ) { |
|
409 | + if ($module_data['domain_path']) { |
|
410 | 410 | $domain_path .= $module_data['domain_path']; |
411 | 411 | } |
412 | 412 | |
413 | - wordpoints_load_module_textdomain( $textdomain, $domain_path ); |
|
413 | + wordpoints_load_module_textdomain($textdomain, $domain_path); |
|
414 | 414 | } |
415 | 415 | |
416 | - foreach ( array( 'name', 'module_uri', 'description', 'author', 'author_uri', 'version' ) as $field ) { |
|
416 | + foreach (array('name', 'module_uri', 'description', 'author', 'author_uri', 'version') as $field) { |
|
417 | 417 | |
418 | - $module_data[ $field ] = translate( $module_data[ $field ], $textdomain ); // @codingStandardsIgnoreLine |
|
418 | + $module_data[$field] = translate($module_data[$field], $textdomain); // @codingStandardsIgnoreLine |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | } |
422 | 422 | |
423 | 423 | // Sanitize fields. |
424 | 424 | $allowed_tags_in_links = array( |
425 | - 'abbr' => array( 'title' => true ), |
|
426 | - 'acronym' => array( 'title' => true ), |
|
425 | + 'abbr' => array('title' => true), |
|
426 | + 'acronym' => array('title' => true), |
|
427 | 427 | 'code' => true, |
428 | 428 | 'em' => true, |
429 | 429 | 'strong' => true, |
430 | 430 | ); |
431 | 431 | |
432 | 432 | $allowed_tags = $allowed_tags_in_links; |
433 | - $allowed_tags['a'] = array( 'href' => true, 'title' => true ); |
|
433 | + $allowed_tags['a'] = array('href' => true, 'title' => true); |
|
434 | 434 | |
435 | 435 | // Name and author ar marked up inside <a> tags. Don't allow these. |
436 | - $module_data['name'] = wp_kses( $module_data['name'], $allowed_tags_in_links ); |
|
437 | - $module_data['author'] = wp_kses( $module_data['author'], $allowed_tags_in_links ); |
|
436 | + $module_data['name'] = wp_kses($module_data['name'], $allowed_tags_in_links); |
|
437 | + $module_data['author'] = wp_kses($module_data['author'], $allowed_tags_in_links); |
|
438 | 438 | |
439 | - $module_data['description'] = wp_kses( $module_data['description'], $allowed_tags ); |
|
440 | - $module_data['version'] = wp_kses( $module_data['version'], $allowed_tags ); |
|
439 | + $module_data['description'] = wp_kses($module_data['description'], $allowed_tags); |
|
440 | + $module_data['version'] = wp_kses($module_data['version'], $allowed_tags); |
|
441 | 441 | |
442 | - $module_data['module_uri'] = esc_url( $module_data['module_uri'] ); |
|
443 | - $module_data['author_uri'] = esc_url( $module_data['author_uri'] ); |
|
442 | + $module_data['module_uri'] = esc_url($module_data['module_uri']); |
|
443 | + $module_data['author_uri'] = esc_url($module_data['author_uri']); |
|
444 | 444 | |
445 | 445 | $module_data['title'] = $module_data['name']; |
446 | 446 | $module_data['author_name'] = $module_data['author']; |
447 | 447 | |
448 | 448 | // Apply markup. |
449 | - if ( $markup ) { |
|
449 | + if ($markup) { |
|
450 | 450 | |
451 | - if ( $module_data['module_uri'] && $module_data['name'] ) { |
|
451 | + if ($module_data['module_uri'] && $module_data['name']) { |
|
452 | 452 | $module_data['title'] = '<a href="' . $module_data['module_uri'] |
453 | 453 | . '">' . $module_data['name'] . '</a>'; |
454 | 454 | } |
455 | 455 | |
456 | - if ( $module_data['author_uri'] && $module_data['author'] ) { |
|
456 | + if ($module_data['author_uri'] && $module_data['author']) { |
|
457 | 457 | $module_data['author'] = '<a href="' . $module_data['author_uri'] |
458 | 458 | . '">' . $module_data['author'] . '</a>'; |
459 | 459 | } |
460 | 460 | |
461 | - $module_data['description'] = wptexturize( $module_data['description'] ); |
|
461 | + $module_data['description'] = wptexturize($module_data['description']); |
|
462 | 462 | |
463 | - if ( $module_data['author'] ) { |
|
463 | + if ($module_data['author']) { |
|
464 | 464 | $module_data['description'] .= ' <cite>' |
465 | 465 | // translators: Author name. |
466 | - . sprintf( __( 'By %s.', 'wordpoints' ), $module_data['author'] ) |
|
466 | + . sprintf(__('By %s.', 'wordpoints'), $module_data['author']) |
|
467 | 467 | . '</cite>'; |
468 | 468 | } |
469 | 469 | } |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return bool Whether the textdoamin was loaded successfully. |
491 | 491 | */ |
492 | -function wordpoints_load_module_textdomain( $domain, $module_rel_path = false ) { |
|
492 | +function wordpoints_load_module_textdomain($domain, $module_rel_path = false) { |
|
493 | 493 | |
494 | 494 | $locale = get_locale(); |
495 | 495 | |
@@ -501,11 +501,11 @@ discard block |
||
501 | 501 | * @param string $locale The module's current locale. |
502 | 502 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
503 | 503 | */ |
504 | - $locale = apply_filters( 'wordpoints_module_locale', $locale, $domain ); |
|
504 | + $locale = apply_filters('wordpoints_module_locale', $locale, $domain); |
|
505 | 505 | |
506 | - if ( false !== $module_rel_path ) { |
|
506 | + if (false !== $module_rel_path) { |
|
507 | 507 | |
508 | - $path = wordpoints_modules_dir() . '/' . trim( $module_rel_path, '/' ); |
|
508 | + $path = wordpoints_modules_dir() . '/' . trim($module_rel_path, '/'); |
|
509 | 509 | |
510 | 510 | } else { |
511 | 511 | |
@@ -515,14 +515,14 @@ discard block |
||
515 | 515 | // Load the textdomain according to the module first. |
516 | 516 | $mofile = $domain . '-' . $locale . '.mo'; |
517 | 517 | |
518 | - if ( load_textdomain( $domain, $path . '/' . $mofile ) ) { |
|
518 | + if (load_textdomain($domain, $path . '/' . $mofile)) { |
|
519 | 519 | return true; |
520 | 520 | } |
521 | 521 | |
522 | 522 | // Otherwise, load from the languages directory. |
523 | 523 | $mofile = WP_LANG_DIR . '/wordpoints-modules/' . $mofile; |
524 | 524 | |
525 | - return load_textdomain( $domain, $mofile ); |
|
525 | + return load_textdomain($domain, $mofile); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -542,76 +542,76 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @return array A list of the module files found (files with module headers). |
544 | 544 | */ |
545 | -function wordpoints_get_modules( $module_folder = '', $markup = false, $translate = false ) { |
|
545 | +function wordpoints_get_modules($module_folder = '', $markup = false, $translate = false) { |
|
546 | 546 | |
547 | - $cache_modules = wp_cache_get( 'wordpoints_modules', 'wordpoints_modules' ); |
|
547 | + $cache_modules = wp_cache_get('wordpoints_modules', 'wordpoints_modules'); |
|
548 | 548 | |
549 | - if ( ! $cache_modules ) { |
|
549 | + if ( ! $cache_modules) { |
|
550 | 550 | $cache_modules = array(); |
551 | 551 | } |
552 | 552 | |
553 | - if ( isset( $cache_modules[ $module_folder ] ) ) { |
|
554 | - return $cache_modules[ $module_folder ]; |
|
553 | + if (isset($cache_modules[$module_folder])) { |
|
554 | + return $cache_modules[$module_folder]; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | $modules = array(); |
558 | 558 | $module_root = wordpoints_modules_dir(); |
559 | 559 | |
560 | - if ( ! empty( $module_folder ) ) { |
|
560 | + if ( ! empty($module_folder)) { |
|
561 | 561 | $module_root .= $module_folder; |
562 | 562 | } |
563 | 563 | |
564 | 564 | // Escape pattern-matching characters in the path. |
565 | - $module_escape_root = str_replace( array( '*', '?', '[' ), array( '[*]', '[?]', '[[]' ), $module_root ); |
|
565 | + $module_escape_root = str_replace(array('*', '?', '['), array('[*]', '[?]', '[[]'), $module_root); |
|
566 | 566 | |
567 | 567 | // Get the top level files. |
568 | - $module_files = glob( "{$module_escape_root}/*.php" ); |
|
568 | + $module_files = glob("{$module_escape_root}/*.php"); |
|
569 | 569 | |
570 | - if ( false === $module_files ) { |
|
570 | + if (false === $module_files) { |
|
571 | 571 | return $modules; |
572 | 572 | } |
573 | 573 | |
574 | 574 | // Get the files of subfolders, if not already searching in a subfolder. |
575 | - if ( empty( $module_folder ) ) { |
|
575 | + if (empty($module_folder)) { |
|
576 | 576 | |
577 | - $subfolder_files = glob( "{$module_escape_root}/*/*.php" ); |
|
577 | + $subfolder_files = glob("{$module_escape_root}/*/*.php"); |
|
578 | 578 | |
579 | - if ( false === $subfolder_files ) { |
|
579 | + if (false === $subfolder_files) { |
|
580 | 580 | return $modules; |
581 | 581 | } |
582 | 582 | |
583 | - $module_files = array_merge( $module_files, $subfolder_files ); |
|
583 | + $module_files = array_merge($module_files, $subfolder_files); |
|
584 | 584 | } |
585 | 585 | |
586 | - if ( empty( $module_files ) ) { |
|
586 | + if (empty($module_files)) { |
|
587 | 587 | return $modules; |
588 | 588 | } |
589 | 589 | |
590 | - foreach ( $module_files as $module_file ) { |
|
590 | + foreach ($module_files as $module_file) { |
|
591 | 591 | |
592 | - if ( ! is_readable( $module_file ) ) { |
|
592 | + if ( ! is_readable($module_file)) { |
|
593 | 593 | continue; |
594 | 594 | } |
595 | 595 | |
596 | - $module_data = wordpoints_get_module_data( $module_file, $markup, $translate ); |
|
596 | + $module_data = wordpoints_get_module_data($module_file, $markup, $translate); |
|
597 | 597 | |
598 | - if ( empty( $module_data['name'] ) ) { |
|
598 | + if (empty($module_data['name'])) { |
|
599 | 599 | continue; |
600 | 600 | } |
601 | 601 | |
602 | - $module_file = wordpoints_module_basename( $module_file ); |
|
602 | + $module_file = wordpoints_module_basename($module_file); |
|
603 | 603 | |
604 | - if ( $module_folder ) { |
|
605 | - $module_file = basename( $module_file ); |
|
604 | + if ($module_folder) { |
|
605 | + $module_file = basename($module_file); |
|
606 | 606 | } |
607 | 607 | |
608 | - $modules[ $module_file ] = $module_data; |
|
608 | + $modules[$module_file] = $module_data; |
|
609 | 609 | } |
610 | 610 | |
611 | - uasort( $modules, '_wordpoints_sort_uname_callback' ); |
|
611 | + uasort($modules, '_wordpoints_sort_uname_callback'); |
|
612 | 612 | |
613 | - $cache_modules[ $module_folder ] = $modules; |
|
614 | - wp_cache_set( 'wordpoints_modules', $cache_modules, 'wordpoints_modules' ); |
|
613 | + $cache_modules[$module_folder] = $modules; |
|
614 | + wp_cache_set('wordpoints_modules', $cache_modules, 'wordpoints_modules'); |
|
615 | 615 | |
616 | 616 | return $modules; |
617 | 617 | } |
@@ -625,20 +625,20 @@ discard block |
||
625 | 625 | * |
626 | 626 | * @return true|WP_Error True on success, a WP_Error on failure. |
627 | 627 | */ |
628 | -function wordpoints_validate_module( $module ) { |
|
628 | +function wordpoints_validate_module($module) { |
|
629 | 629 | |
630 | - if ( validate_file( $module ) ) { |
|
631 | - return new WP_Error( 'module_invalid', __( 'Invalid module path.', 'wordpoints' ) ); |
|
630 | + if (validate_file($module)) { |
|
631 | + return new WP_Error('module_invalid', __('Invalid module path.', 'wordpoints')); |
|
632 | 632 | } |
633 | 633 | |
634 | - if ( ! file_exists( wordpoints_modules_dir() . '/' . $module ) ) { |
|
635 | - return new WP_Error( 'module_not_found', __( 'Module file does not exist.', 'wordpoints' ) ); |
|
634 | + if ( ! file_exists(wordpoints_modules_dir() . '/' . $module)) { |
|
635 | + return new WP_Error('module_not_found', __('Module file does not exist.', 'wordpoints')); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | $installed_modules = wordpoints_get_modules(); |
639 | 639 | |
640 | - if ( ! isset( $installed_modules[ $module ] ) ) { |
|
641 | - return new WP_Error( 'no_module_header', __( 'The module does not have a valid header.', 'wordpoints' ) ); |
|
640 | + if ( ! isset($installed_modules[$module])) { |
|
641 | + return new WP_Error('no_module_header', __('The module does not have a valid header.', 'wordpoints')); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | return true; |
@@ -655,27 +655,27 @@ discard block |
||
655 | 655 | */ |
656 | 656 | function wordpoints_validate_active_modules() { |
657 | 657 | |
658 | - $modules = wordpoints_get_array_option( 'wordpoints_active_modules' ); |
|
658 | + $modules = wordpoints_get_array_option('wordpoints_active_modules'); |
|
659 | 659 | |
660 | - if ( is_multisite() && current_user_can( 'manage_network_wordpoints_modules' ) ) { |
|
660 | + if (is_multisite() && current_user_can('manage_network_wordpoints_modules')) { |
|
661 | 661 | |
662 | - $network_modules = wordpoints_get_array_option( 'wordpoints_sitewide_active_modules', 'site' ); |
|
663 | - $modules = array_merge( $modules, array_keys( $network_modules ) ); |
|
662 | + $network_modules = wordpoints_get_array_option('wordpoints_sitewide_active_modules', 'site'); |
|
663 | + $modules = array_merge($modules, array_keys($network_modules)); |
|
664 | 664 | } |
665 | 665 | |
666 | - if ( empty( $modules ) ) { |
|
666 | + if (empty($modules)) { |
|
667 | 667 | return null; |
668 | 668 | } |
669 | 669 | |
670 | 670 | $invalid = array(); |
671 | 671 | |
672 | - foreach ( $modules as $module ) { |
|
672 | + foreach ($modules as $module) { |
|
673 | 673 | |
674 | - $result = wordpoints_validate_module( $module ); |
|
674 | + $result = wordpoints_validate_module($module); |
|
675 | 675 | |
676 | - if ( is_wp_error( $result ) ) { |
|
677 | - $invalid[ $module ] = $result; |
|
678 | - wordpoints_deactivate_modules( $module, true ); |
|
676 | + if (is_wp_error($result)) { |
|
677 | + $invalid[$module] = $result; |
|
678 | + wordpoints_deactivate_modules($module, true); |
|
679 | 679 | } |
680 | 680 | } |
681 | 681 | |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return int {@see strnatcasecmp()}. |
694 | 694 | */ |
695 | -function _wordpoints_sort_uname_callback( $a, $b ) { |
|
695 | +function _wordpoints_sort_uname_callback($a, $b) { |
|
696 | 696 | |
697 | - return strnatcasecmp( $a['name'], $b['name'] ); |
|
697 | + return strnatcasecmp($a['name'], $b['name']); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -725,33 +725,33 @@ discard block |
||
725 | 725 | * |
726 | 726 | * @return WP_Error|null An error object on failure, or null on success. |
727 | 727 | */ |
728 | -function wordpoints_activate_module( $module, $redirect = '', $network_wide = false, $silent = false ) { |
|
728 | +function wordpoints_activate_module($module, $redirect = '', $network_wide = false, $silent = false) { |
|
729 | 729 | |
730 | - $module = wordpoints_module_basename( $module ); |
|
730 | + $module = wordpoints_module_basename($module); |
|
731 | 731 | |
732 | - $valid = wordpoints_validate_module( $module ); |
|
732 | + $valid = wordpoints_validate_module($module); |
|
733 | 733 | |
734 | - if ( is_wp_error( $valid ) ) { |
|
734 | + if (is_wp_error($valid)) { |
|
735 | 735 | return $valid; |
736 | 736 | } |
737 | 737 | |
738 | - if ( is_multisite() && ( $network_wide || is_network_only_wordpoints_module( $module ) ) ) { |
|
738 | + if (is_multisite() && ($network_wide || is_network_only_wordpoints_module($module))) { |
|
739 | 739 | |
740 | 740 | $network_wide = true; |
741 | - $network_current = wordpoints_get_array_option( 'wordpoints_sitewide_active_modules', 'site' ); |
|
742 | - $current = array_keys( $network_current ); |
|
741 | + $network_current = wordpoints_get_array_option('wordpoints_sitewide_active_modules', 'site'); |
|
742 | + $current = array_keys($network_current); |
|
743 | 743 | |
744 | 744 | } else { |
745 | 745 | |
746 | - $current = wordpoints_get_array_option( 'wordpoints_active_modules' ); |
|
746 | + $current = wordpoints_get_array_option('wordpoints_active_modules'); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | // If the module is already active, return. |
750 | - if ( in_array( $module, $current ) ) { |
|
750 | + if (in_array($module, $current)) { |
|
751 | 751 | return null; |
752 | 752 | } |
753 | 753 | |
754 | - if ( ! empty( $redirect ) ) { |
|
754 | + if ( ! empty($redirect)) { |
|
755 | 755 | |
756 | 756 | /* |
757 | 757 | * Redirect. We'll override this later if the module can be included |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | wp_safe_redirect( |
761 | 761 | add_query_arg( |
762 | 762 | '_error_nonce' |
763 | - , wp_create_nonce( 'module-activation-error_' . $module ) |
|
763 | + , wp_create_nonce('module-activation-error_' . $module) |
|
764 | 764 | , $redirect |
765 | 765 | ) |
766 | 766 | ); |
@@ -769,11 +769,11 @@ discard block |
||
769 | 769 | ob_start(); |
770 | 770 | |
771 | 771 | $module_file = wordpoints_modules_dir() . '/' . $module; |
772 | - WordPoints_Module_Paths::register( $module_file ); |
|
772 | + WordPoints_Module_Paths::register($module_file); |
|
773 | 773 | |
774 | 774 | include_once $module_file; |
775 | 775 | |
776 | - if ( ! $silent ) { |
|
776 | + if ( ! $silent) { |
|
777 | 777 | |
778 | 778 | /** |
779 | 779 | * Fires before a module is activated. |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | * all sites in the network or just the |
786 | 786 | * current site. |
787 | 787 | */ |
788 | - do_action( 'wordpoints_module_activate', $module, $network_wide ); |
|
788 | + do_action('wordpoints_module_activate', $module, $network_wide); |
|
789 | 789 | |
790 | 790 | /** |
791 | 791 | * Fires before a module is activated. |
@@ -796,28 +796,28 @@ discard block |
||
796 | 796 | * all sites in the network or just the current |
797 | 797 | * site. |
798 | 798 | */ |
799 | - do_action( "wordpoints_module_activate-{$module}", $network_wide ); |
|
799 | + do_action("wordpoints_module_activate-{$module}", $network_wide); |
|
800 | 800 | |
801 | 801 | WordPoints_Installables::install( |
802 | 802 | 'module' |
803 | - , WordPoints_Modules::get_slug( $module ) |
|
803 | + , WordPoints_Modules::get_slug($module) |
|
804 | 804 | , $network_wide |
805 | 805 | ); |
806 | 806 | } |
807 | 807 | |
808 | - if ( $network_wide ) { |
|
808 | + if ($network_wide) { |
|
809 | 809 | |
810 | - $network_current[ $module ] = time(); |
|
811 | - update_site_option( 'wordpoints_sitewide_active_modules', $network_current ); |
|
810 | + $network_current[$module] = time(); |
|
811 | + update_site_option('wordpoints_sitewide_active_modules', $network_current); |
|
812 | 812 | |
813 | 813 | } else { |
814 | 814 | |
815 | 815 | $current[] = $module; |
816 | - sort( $current ); |
|
817 | - update_option( 'wordpoints_active_modules', $current ); |
|
816 | + sort($current); |
|
817 | + update_option('wordpoints_active_modules', $current); |
|
818 | 818 | } |
819 | 819 | |
820 | - if ( ! $silent ) { |
|
820 | + if ( ! $silent) { |
|
821 | 821 | /** |
822 | 822 | * Fires after a module has been activated in activate_plugin() when the $silent parameter is false. |
823 | 823 | * |
@@ -828,14 +828,14 @@ discard block |
||
828 | 828 | * all sites in the network or just the |
829 | 829 | * current site. |
830 | 830 | */ |
831 | - do_action( 'wordpoints_activated_module', $module, $network_wide ); |
|
831 | + do_action('wordpoints_activated_module', $module, $network_wide); |
|
832 | 832 | } |
833 | 833 | |
834 | - if ( ob_get_length() > 0 ) { |
|
834 | + if (ob_get_length() > 0) { |
|
835 | 835 | |
836 | 836 | return new WP_Error( |
837 | 837 | 'unexpected_output' |
838 | - , __( 'The module generated unexpected output.', 'wordpoints' ) |
|
838 | + , __('The module generated unexpected output.', 'wordpoints') |
|
839 | 839 | , ob_get_contents() |
840 | 840 | ); |
841 | 841 | } |
@@ -855,29 +855,29 @@ discard block |
||
855 | 855 | * Default is false. |
856 | 856 | * @param bool $network_wide Whether to apply the change network wide. |
857 | 857 | */ |
858 | -function wordpoints_deactivate_modules( $modules, $silent = false, $network_wide = null ) { |
|
858 | +function wordpoints_deactivate_modules($modules, $silent = false, $network_wide = null) { |
|
859 | 859 | |
860 | 860 | $network_current = array(); |
861 | - if ( is_wordpoints_network_active() ) { |
|
862 | - $network_current = wordpoints_get_array_option( 'wordpoints_sitewide_active_modules', 'site' ); |
|
861 | + if (is_wordpoints_network_active()) { |
|
862 | + $network_current = wordpoints_get_array_option('wordpoints_sitewide_active_modules', 'site'); |
|
863 | 863 | } |
864 | 864 | |
865 | - $current = wordpoints_get_array_option( 'wordpoints_active_modules' ); |
|
865 | + $current = wordpoints_get_array_option('wordpoints_active_modules'); |
|
866 | 866 | |
867 | 867 | $do_network = false; |
868 | 868 | $do_blog = false; |
869 | 869 | |
870 | - foreach ( (array) $modules as $module ) { |
|
870 | + foreach ((array) $modules as $module) { |
|
871 | 871 | |
872 | - $module = wordpoints_module_basename( $module ); |
|
872 | + $module = wordpoints_module_basename($module); |
|
873 | 873 | |
874 | - if ( ! is_wordpoints_module_active( $module ) ) { |
|
874 | + if ( ! is_wordpoints_module_active($module)) { |
|
875 | 875 | continue; |
876 | 876 | } |
877 | 877 | |
878 | - $network_deactivating = ( false !== $network_wide && is_wordpoints_module_active_for_network( $module ) ); |
|
878 | + $network_deactivating = (false !== $network_wide && is_wordpoints_module_active_for_network($module)); |
|
879 | 879 | |
880 | - if ( ! $silent ) { |
|
880 | + if ( ! $silent) { |
|
881 | 881 | /** |
882 | 882 | * Fires for each module being deactivated in wordpoints_deactivate_modules(), before deactivation |
883 | 883 | * and when the $silent parameter is false. |
@@ -888,34 +888,34 @@ discard block |
||
888 | 888 | * @param bool $network_deactivating Whether the module is deactivated for all sites in the network |
889 | 889 | * or just the current site. Multisite only. Default is false. |
890 | 890 | */ |
891 | - do_action( 'wordpoints_deactivate_module', $module, $network_deactivating ); |
|
891 | + do_action('wordpoints_deactivate_module', $module, $network_deactivating); |
|
892 | 892 | } |
893 | 893 | |
894 | - if ( false !== $network_wide ) { |
|
894 | + if (false !== $network_wide) { |
|
895 | 895 | |
896 | - if ( is_wordpoints_module_active_for_network( $module ) ) { |
|
896 | + if (is_wordpoints_module_active_for_network($module)) { |
|
897 | 897 | |
898 | 898 | $do_network = true; |
899 | - unset( $network_current[ $module ] ); |
|
899 | + unset($network_current[$module]); |
|
900 | 900 | |
901 | - } elseif ( $network_wide ) { |
|
901 | + } elseif ($network_wide) { |
|
902 | 902 | |
903 | 903 | continue; |
904 | 904 | } |
905 | 905 | } |
906 | 906 | |
907 | - if ( true !== $network_wide ) { |
|
907 | + if (true !== $network_wide) { |
|
908 | 908 | |
909 | - $key = array_search( $module, $current ); |
|
909 | + $key = array_search($module, $current); |
|
910 | 910 | |
911 | - if ( false !== $key ) { |
|
911 | + if (false !== $key) { |
|
912 | 912 | |
913 | 913 | $do_blog = true; |
914 | - unset( $current[ $key ] ); |
|
914 | + unset($current[$key]); |
|
915 | 915 | } |
916 | 916 | } |
917 | 917 | |
918 | - if ( ! $silent ) { |
|
918 | + if ( ! $silent) { |
|
919 | 919 | /** |
920 | 920 | * Fires for each module being deactivated in wordpoints_deactivate_module(), after deactivation |
921 | 921 | * and when the $silent parameter is false. |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | * @param bool $network_deactivating Whether the module is deactivated for all sites in the network |
929 | 929 | * or just the current site. Multisite only. Default is false. |
930 | 930 | */ |
931 | - do_action( 'wordpoints_deactivate_module-' . $module, $network_deactivating ); |
|
931 | + do_action('wordpoints_deactivate_module-' . $module, $network_deactivating); |
|
932 | 932 | |
933 | 933 | /** |
934 | 934 | * Fires for each module being deactivated in deactivate_plugins(), after deactivation |
@@ -940,17 +940,17 @@ discard block |
||
940 | 940 | * @param bool $network_deactivating Whether the module is deactivated for all sites in the network |
941 | 941 | * or just the current site. Multisite only. Default is false. |
942 | 942 | */ |
943 | - do_action( 'wordpoints_deactivated_module', $module, $network_deactivating ); |
|
943 | + do_action('wordpoints_deactivated_module', $module, $network_deactivating); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | } // End foreach ( $modules ). |
947 | 947 | |
948 | - if ( $do_blog ) { |
|
949 | - update_option( 'wordpoints_active_modules', $current ); |
|
948 | + if ($do_blog) { |
|
949 | + update_option('wordpoints_active_modules', $current); |
|
950 | 950 | } |
951 | 951 | |
952 | - if ( $do_network ) { |
|
953 | - update_site_option( 'wordpoints_sitewide_active_modules', $network_current ); |
|
952 | + if ($do_network) { |
|
953 | + update_site_option('wordpoints_sitewide_active_modules', $network_current); |
|
954 | 954 | } |
955 | 955 | } |
956 | 956 | |
@@ -967,31 +967,31 @@ discard block |
||
967 | 967 | * @return bool|WP_Error True if all modules deleted successfully, false or WP_Error |
968 | 968 | * on failure. |
969 | 969 | */ |
970 | -function wordpoints_delete_modules( $modules ) { |
|
970 | +function wordpoints_delete_modules($modules) { |
|
971 | 971 | |
972 | 972 | global $wp_filesystem; |
973 | 973 | |
974 | - if ( empty( $modules ) ) { |
|
974 | + if (empty($modules)) { |
|
975 | 975 | return false; |
976 | 976 | } |
977 | 977 | |
978 | 978 | $checked = array(); |
979 | 979 | |
980 | - foreach ( $modules as $module ) { |
|
980 | + foreach ($modules as $module) { |
|
981 | 981 | $checked[] = 'checked[]=' . $module; |
982 | 982 | } |
983 | 983 | |
984 | 984 | ob_start(); |
985 | 985 | |
986 | - $url = wp_nonce_url( self_admin_url( 'admin.php?page=wordpoints_modules&action=delete-selected&verify-delete=1&' . implode( '&', $checked ) ), 'bulk-modules' ); |
|
986 | + $url = wp_nonce_url(self_admin_url('admin.php?page=wordpoints_modules&action=delete-selected&verify-delete=1&' . implode('&', $checked)), 'bulk-modules'); |
|
987 | 987 | |
988 | - $credentials = request_filesystem_credentials( $url ); |
|
988 | + $credentials = request_filesystem_credentials($url); |
|
989 | 989 | |
990 | - if ( false === $credentials ) { |
|
990 | + if (false === $credentials) { |
|
991 | 991 | |
992 | 992 | $data = ob_get_clean(); |
993 | 993 | |
994 | - if ( ! empty( $data ) ) { |
|
994 | + if ( ! empty($data)) { |
|
995 | 995 | |
996 | 996 | include_once ABSPATH . 'wp-admin/admin-header.php'; |
997 | 997 | echo $data; // XSS OK here, WPCS. |
@@ -1002,14 +1002,14 @@ discard block |
||
1002 | 1002 | return false; |
1003 | 1003 | } |
1004 | 1004 | |
1005 | - if ( ! WP_Filesystem( $credentials ) ) { |
|
1005 | + if ( ! WP_Filesystem($credentials)) { |
|
1006 | 1006 | |
1007 | 1007 | // Failed to connect, Error and request again |
1008 | - request_filesystem_credentials( $url, '', true ); |
|
1008 | + request_filesystem_credentials($url, '', true); |
|
1009 | 1009 | |
1010 | 1010 | $data = ob_get_clean(); |
1011 | 1011 | |
1012 | - if ( ! empty( $data ) ) { |
|
1012 | + if ( ! empty($data)) { |
|
1013 | 1013 | |
1014 | 1014 | include_once ABSPATH . 'wp-admin/admin-header.php'; |
1015 | 1015 | echo $data; // XSS OK here too, WPCS. |
@@ -1020,41 +1020,41 @@ discard block |
||
1020 | 1020 | return false; |
1021 | 1021 | } |
1022 | 1022 | |
1023 | - if ( ! is_object( $wp_filesystem ) ) { |
|
1024 | - return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.', 'wordpoints' ) ); |
|
1023 | + if ( ! is_object($wp_filesystem)) { |
|
1024 | + return new WP_Error('fs_unavailable', __('Could not access filesystem.', 'wordpoints')); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | - if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
1028 | - return new WP_Error( 'fs_error', __( 'Filesystem error.', 'wordpoints' ), $wp_filesystem->errors ); |
|
1027 | + if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
1028 | + return new WP_Error('fs_error', __('Filesystem error.', 'wordpoints'), $wp_filesystem->errors); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | // Get the base module folder. |
1032 | - $modules_dir = $wp_filesystem->find_folder( wordpoints_modules_dir() ); |
|
1032 | + $modules_dir = $wp_filesystem->find_folder(wordpoints_modules_dir()); |
|
1033 | 1033 | |
1034 | - if ( empty( $modules_dir ) ) { |
|
1035 | - return new WP_Error( 'fs_no_modules_dir', __( 'Unable to locate WordPoints Module directory.', 'wordpoints' ) ); |
|
1034 | + if (empty($modules_dir)) { |
|
1035 | + return new WP_Error('fs_no_modules_dir', __('Unable to locate WordPoints Module directory.', 'wordpoints')); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | - $modules_dir = trailingslashit( $modules_dir ); |
|
1038 | + $modules_dir = trailingslashit($modules_dir); |
|
1039 | 1039 | $errors = array(); |
1040 | 1040 | |
1041 | - foreach ( $modules as $module_file ) { |
|
1041 | + foreach ($modules as $module_file) { |
|
1042 | 1042 | |
1043 | 1043 | // Run uninstall hook. |
1044 | - if ( is_uninstallable_wordpoints_module( $module_file ) ) { |
|
1045 | - wordpoints_uninstall_module( $module_file ); |
|
1044 | + if (is_uninstallable_wordpoints_module($module_file)) { |
|
1045 | + wordpoints_uninstall_module($module_file); |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | - $this_module_dir = trailingslashit( dirname( $modules_dir . $module_file ) ); |
|
1048 | + $this_module_dir = trailingslashit(dirname($modules_dir . $module_file)); |
|
1049 | 1049 | |
1050 | 1050 | // If module is in its own directory, recursively delete the directory. |
1051 | - if ( strpos( $module_file, '/' ) && $this_module_dir !== $modules_dir ) { |
|
1052 | - $deleted = $wp_filesystem->delete( $this_module_dir, true ); |
|
1051 | + if (strpos($module_file, '/') && $this_module_dir !== $modules_dir) { |
|
1052 | + $deleted = $wp_filesystem->delete($this_module_dir, true); |
|
1053 | 1053 | } else { |
1054 | - $deleted = $wp_filesystem->delete( $modules_dir . $module_file ); |
|
1054 | + $deleted = $wp_filesystem->delete($modules_dir . $module_file); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | - if ( ! $deleted ) { |
|
1057 | + if ( ! $deleted) { |
|
1058 | 1058 | $errors[] = $module_file; |
1059 | 1059 | } |
1060 | 1060 | } |
@@ -1071,9 +1071,9 @@ discard block |
||
1071 | 1071 | * @param array $modules The modules that were to be deleted. |
1072 | 1072 | * @param array $errors The modules that failed to delete. |
1073 | 1073 | */ |
1074 | - do_action( 'wordpoints_deleted_modules', $modules, $errors ); |
|
1074 | + do_action('wordpoints_deleted_modules', $modules, $errors); |
|
1075 | 1075 | |
1076 | - if ( ! empty( $errors ) ) { |
|
1076 | + if ( ! empty($errors)) { |
|
1077 | 1077 | return new WP_Error( |
1078 | 1078 | 'could_not_remove_module' |
1079 | 1079 | , sprintf( |
@@ -1081,10 +1081,10 @@ discard block |
||
1081 | 1081 | _n( |
1082 | 1082 | 'Could not fully remove the module %s.' |
1083 | 1083 | , 'Could not fully remove the modules %s.' |
1084 | - , count( $errors ) |
|
1084 | + , count($errors) |
|
1085 | 1085 | , 'wordpoints' |
1086 | 1086 | ) |
1087 | - , implode( ', ', $errors ) |
|
1087 | + , implode(', ', $errors) |
|
1088 | 1088 | ) |
1089 | 1089 | ); |
1090 | 1090 | } |
@@ -1103,16 +1103,16 @@ discard block |
||
1103 | 1103 | * |
1104 | 1104 | * @return bool Whether the module had an uninstall process. |
1105 | 1105 | */ |
1106 | -function wordpoints_uninstall_module( $module ) { |
|
1106 | +function wordpoints_uninstall_module($module) { |
|
1107 | 1107 | |
1108 | - $file = wordpoints_module_basename( $module ); |
|
1109 | - $module_dir = wordpoints_modules_dir() . '/' . dirname( $file ); |
|
1108 | + $file = wordpoints_module_basename($module); |
|
1109 | + $module_dir = wordpoints_modules_dir() . '/' . dirname($file); |
|
1110 | 1110 | $uninstall_file = $module_dir . '/uninstall.php'; |
1111 | 1111 | $un_installer_file = $module_dir . '/includes/class-un-installer.php'; |
1112 | 1112 | |
1113 | - if ( file_exists( $uninstall_file ) ) { |
|
1113 | + if (file_exists($uninstall_file)) { |
|
1114 | 1114 | |
1115 | - if ( ! defined( 'WORDPOINTS_UNINSTALL_MODULE' ) ) { |
|
1115 | + if ( ! defined('WORDPOINTS_UNINSTALL_MODULE')) { |
|
1116 | 1116 | /** |
1117 | 1117 | * Uninstalling a module. |
1118 | 1118 | * |
@@ -1126,17 +1126,17 @@ discard block |
||
1126 | 1126 | * |
1127 | 1127 | * @const WORDPOINTS_UNINSTALL_MODULE |
1128 | 1128 | */ |
1129 | - define( 'WORDPOINTS_UNINSTALL_MODULE', true ); |
|
1129 | + define('WORDPOINTS_UNINSTALL_MODULE', true); |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | - WordPoints_Module_Paths::register( $uninstall_file ); |
|
1132 | + WordPoints_Module_Paths::register($uninstall_file); |
|
1133 | 1133 | include $uninstall_file; |
1134 | 1134 | |
1135 | 1135 | return true; |
1136 | 1136 | |
1137 | - } elseif ( file_exists( $un_installer_file ) ) { |
|
1137 | + } elseif (file_exists($un_installer_file)) { |
|
1138 | 1138 | |
1139 | - $slug = WordPoints_Modules::get_slug( $module ); |
|
1139 | + $slug = WordPoints_Modules::get_slug($module); |
|
1140 | 1140 | |
1141 | 1141 | WordPoints_Installables::register( |
1142 | 1142 | 'module' |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | ) |
1149 | 1149 | ); |
1150 | 1150 | |
1151 | - return WordPoints_Installables::uninstall( 'module', $slug ); |
|
1151 | + return WordPoints_Installables::uninstall('module', $slug); |
|
1152 | 1152 | |
1153 | 1153 | } else { |
1154 | 1154 | |
@@ -1174,34 +1174,34 @@ discard block |
||
1174 | 1174 | */ |
1175 | 1175 | function wordpoints_load_modules() { |
1176 | 1176 | |
1177 | - $active_modules = wordpoints_get_array_option( 'wordpoints_active_modules' ); |
|
1177 | + $active_modules = wordpoints_get_array_option('wordpoints_active_modules'); |
|
1178 | 1178 | |
1179 | - if ( is_wordpoints_network_active() ) { |
|
1179 | + if (is_wordpoints_network_active()) { |
|
1180 | 1180 | |
1181 | 1181 | $network_active_modules = array_keys( |
1182 | - wordpoints_get_array_option( 'wordpoints_sitewide_active_modules', 'site' ) |
|
1182 | + wordpoints_get_array_option('wordpoints_sitewide_active_modules', 'site') |
|
1183 | 1183 | ); |
1184 | 1184 | |
1185 | 1185 | // On the network admin screens we only load the network active modules. |
1186 | - if ( is_network_admin() ) { |
|
1186 | + if (is_network_admin()) { |
|
1187 | 1187 | $active_modules = $network_active_modules; |
1188 | 1188 | } else { |
1189 | - $active_modules = array_merge( $active_modules, $network_active_modules ); |
|
1189 | + $active_modules = array_merge($active_modules, $network_active_modules); |
|
1190 | 1190 | } |
1191 | 1191 | } |
1192 | 1192 | |
1193 | - if ( ! empty( $active_modules ) ) { |
|
1193 | + if ( ! empty($active_modules)) { |
|
1194 | 1194 | |
1195 | 1195 | $modules_dir = wordpoints_modules_dir(); |
1196 | 1196 | |
1197 | - foreach ( $active_modules as $module ) { |
|
1197 | + foreach ($active_modules as $module) { |
|
1198 | 1198 | |
1199 | 1199 | if ( |
1200 | - 0 === validate_file( $module ) |
|
1201 | - && '.php' === substr( $module, -4 ) |
|
1202 | - && file_exists( $modules_dir . '/' . $module ) |
|
1200 | + 0 === validate_file($module) |
|
1201 | + && '.php' === substr($module, -4) |
|
1202 | + && file_exists($modules_dir . '/' . $module) |
|
1203 | 1203 | ) { |
1204 | - WordPoints_Module_Paths::register( $modules_dir . '/' . $module ); |
|
1204 | + WordPoints_Module_Paths::register($modules_dir . '/' . $module); |
|
1205 | 1205 | include $modules_dir . '/' . $module; |
1206 | 1206 | } |
1207 | 1207 | } |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | * |
1215 | 1215 | * @since 1.0.0 |
1216 | 1216 | */ |
1217 | - do_action( 'wordpoints_modules_loaded' ); |
|
1217 | + do_action('wordpoints_modules_loaded'); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | /** |
@@ -1225,11 +1225,11 @@ discard block |
||
1225 | 1225 | * @param string $file The main file of the module the hook is for. |
1226 | 1226 | * @param string $function The callback function. |
1227 | 1227 | */ |
1228 | -function wordpoints_register_module_activation_hook( $file, $function ) { |
|
1228 | +function wordpoints_register_module_activation_hook($file, $function) { |
|
1229 | 1229 | |
1230 | - $module_file = wordpoints_module_basename( $file ); |
|
1230 | + $module_file = wordpoints_module_basename($file); |
|
1231 | 1231 | |
1232 | - add_action( "wordpoints_module_activate-{$module_file}", $function ); |
|
1232 | + add_action("wordpoints_module_activate-{$module_file}", $function); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | 1235 | /** |
@@ -1240,11 +1240,11 @@ discard block |
||
1240 | 1240 | * @param string $file The main file of the module the hook is for. |
1241 | 1241 | * @param string $function The callback function. |
1242 | 1242 | */ |
1243 | -function wordpoints_register_module_deactivation_hook( $file, $function ) { |
|
1243 | +function wordpoints_register_module_deactivation_hook($file, $function) { |
|
1244 | 1244 | |
1245 | - $module_file = wordpoints_module_basename( $file ); |
|
1245 | + $module_file = wordpoints_module_basename($file); |
|
1246 | 1246 | |
1247 | - add_action( "wordpoints_deactivate_module-{$module_file}", $function ); |
|
1247 | + add_action("wordpoints_deactivate_module-{$module_file}", $function); |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | // EOF |
@@ -38,7 +38,7 @@ |
||
38 | 38 | * @since 2.1.0 |
39 | 39 | */ |
40 | 40 | public function get_title() { |
41 | - return __( 'Author', 'wordpoints' ); |
|
41 | + return __('Author', 'wordpoints'); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 |
@@ -34,8 +34,8 @@ |
||
34 | 34 | /** |
35 | 35 | * @since 2.1.0 |
36 | 36 | */ |
37 | - protected function get_related_entity_ids( WordPoints_Entity $entity ) { |
|
38 | - return $entity->get_the_attr_value( $this->related_ids_field ); |
|
37 | + protected function get_related_entity_ids(WordPoints_Entity $entity) { |
|
38 | + return $entity->get_the_attr_value($this->related_ids_field); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |