@@ -44,23 +44,23 @@ |
||
| 44 | 44 | , __FILE__ |
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | -WordPoints_Class_Autoloader::register_dir( dirname( __FILE__ ) . '/includes' ); |
|
| 47 | +WordPoints_Class_Autoloader::register_dir(dirname(__FILE__).'/includes'); |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * The extension's general functions. |
| 51 | 51 | * |
| 52 | 52 | * @since 1.0.0 |
| 53 | 53 | */ |
| 54 | -require_once dirname( __FILE__ ) . '/includes/functions.php'; |
|
| 54 | +require_once dirname(__FILE__).'/includes/functions.php'; |
|
| 55 | 55 | |
| 56 | -if ( is_admin() ) { |
|
| 56 | +if (is_admin()) { |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * The extension's admin-side code. |
| 60 | 60 | * |
| 61 | 61 | * @since 1.0.0 |
| 62 | 62 | */ |
| 63 | - require_once dirname( __FILE__ ) . '/admin/admin.php'; |
|
| 63 | + require_once dirname(__FILE__).'/admin/admin.php'; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // EOF |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | add_submenu_page( |
| 18 | 18 | wordpoints_get_main_admin_menu() |
| 19 | - ,__( 'WordPoints — Import', 'wordpoints-importer' ) |
|
| 20 | - ,__( 'Import', 'wordpoints-importer' ) |
|
| 19 | + ,__('WordPoints — Import', 'wordpoints-importer') |
|
| 20 | + ,__('Import', 'wordpoints-importer') |
|
| 21 | 21 | ,'manage_options' |
| 22 | 22 | ,'wordpoints_import' |
| 23 | 23 | ,'wordpoints_import_admin_screen' |
@@ -25,15 +25,15 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | add_submenu_page( |
| 27 | 27 | '_wordpoints_import' // Fake. |
| 28 | - ,__( 'WordPoints — Importing', 'wordpoints-importer' ) |
|
| 29 | - ,__( 'Importing', 'wordpoints-importer' ) |
|
| 28 | + ,__('WordPoints — Importing', 'wordpoints-importer') |
|
| 29 | + ,__('Importing', 'wordpoints-importer') |
|
| 30 | 30 | ,'manage_options' |
| 31 | 31 | ,'wordpoints_importing' |
| 32 | 32 | ,'wordpoints_importing_admin_screen' |
| 33 | 33 | ); |
| 34 | 34 | } |
| 35 | -add_action( 'admin_menu', 'wordpoints_importer_admin_menu' ); |
|
| 36 | -add_action( 'network_admin_menu', 'wordpoints_importer_admin_menu' ); |
|
| 35 | +add_action('admin_menu', 'wordpoints_importer_admin_menu'); |
|
| 36 | +add_action('network_admin_menu', 'wordpoints_importer_admin_menu'); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Display the importer administration screen. |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @since 1.0.0 |
| 49 | 49 | */ |
| 50 | - require dirname( __FILE__ ) . '/screens/import.php'; |
|
| 50 | + require dirname(__FILE__).'/screens/import.php'; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @since 1.0.0 |
| 64 | 64 | */ |
| 65 | - require dirname( __FILE__ ) . '/screens/importing.php'; |
|
| 65 | + require dirname(__FILE__).'/screens/importing.php'; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $assets_url = wordpoints_extensions_url( |
| 76 | 76 | 'admin/assets' |
| 77 | - , dirname( dirname( __FILE__ ) ) . '/importer.php' |
|
| 77 | + , dirname(dirname(__FILE__)).'/importer.php' |
|
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | 80 | $suffix = SCRIPT_DEBUG ? '' : '.min'; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | , "{$assets_url}/css/feedback{$suffix}.css" |
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | -add_action( 'init', 'wordpoints_importer_register_admin_scripts' ); |
|
| 87 | +add_action('init', 'wordpoints_importer_register_admin_scripts'); |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * Handle an import request. |
@@ -93,43 +93,43 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | function wordpoints_importer_do_import() { |
| 95 | 95 | |
| 96 | - if ( ! defined( 'IFRAME_REQUEST' ) ) { |
|
| 97 | - define( 'IFRAME_REQUEST', true ); |
|
| 96 | + if (!defined('IFRAME_REQUEST')) { |
|
| 97 | + define('IFRAME_REQUEST', true); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 101 | - wp_die( esc_html__( 'Sorry, you are not allowed to import to WordPoints.', 'wordpoints-importer' ) ); |
|
| 100 | + if (!current_user_can('manage_options')) { |
|
| 101 | + wp_die(esc_html__('Sorry, you are not allowed to import to WordPoints.', 'wordpoints-importer')); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - check_admin_referer( 'wordpoints_import' ); |
|
| 104 | + check_admin_referer('wordpoints_import'); |
|
| 105 | 105 | |
| 106 | - if ( ! isset( $_GET['importer'] ) ) { |
|
| 107 | - wp_die( esc_html__( 'No importer selected.', 'wordpoints-importer' ) ); |
|
| 106 | + if (!isset($_GET['importer'])) { |
|
| 107 | + wp_die(esc_html__('No importer selected.', 'wordpoints-importer')); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $importer = WordPoints_Importers::get_importer( |
| 111 | - sanitize_key( $_GET['importer'] ) |
|
| 111 | + sanitize_key($_GET['importer']) |
|
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - if ( ! ( $importer instanceof WordPoints_Importer ) ) { |
|
| 115 | - wp_die( esc_html__( 'Importer not installed.', 'wordpoints-importer' ) ); |
|
| 114 | + if (!($importer instanceof WordPoints_Importer)) { |
|
| 115 | + wp_die(esc_html__('Importer not installed.', 'wordpoints-importer')); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - wp_enqueue_style( 'wordpoints-importer-feedback' ); |
|
| 118 | + wp_enqueue_style('wordpoints-importer-feedback'); |
|
| 119 | 119 | |
| 120 | 120 | $args = array(); |
| 121 | 121 | |
| 122 | - if ( isset( $_GET['wordpoints_import'] ) && is_array( $_GET['wordpoints_import'] ) ) { |
|
| 123 | - $args = wp_unslash( $_GET['wordpoints_import'] ); // WPCS: sanitization OK. |
|
| 122 | + if (isset($_GET['wordpoints_import']) && is_array($_GET['wordpoints_import'])) { |
|
| 123 | + $args = wp_unslash($_GET['wordpoints_import']); // WPCS: sanitization OK. |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | iframe_header(); |
| 127 | 127 | |
| 128 | - $importer->do_import( $args ); |
|
| 128 | + $importer->do_import($args); |
|
| 129 | 129 | |
| 130 | 130 | iframe_footer(); |
| 131 | 131 | } |
| 132 | -add_action( 'update-custom_wordpoints_import', 'wordpoints_importer_do_import' ); |
|
| 132 | +add_action('update-custom_wordpoints_import', 'wordpoints_importer_do_import'); |
|
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * Display a points type dropdown above the points component settings. |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | function wordpoints_importer_admin_screen_points_type_select() { |
| 140 | 140 | |
| 141 | - $args = array( 'name' => 'wordpoints_import[points][_data][points_type]' ); |
|
| 141 | + $args = array('name' => 'wordpoints_import[points][_data][points_type]'); |
|
| 142 | 142 | |
| 143 | 143 | ?> |
| 144 | 144 | |
| 145 | 145 | <p> |
| 146 | 146 | <label for="wordpoints_import[points][_data][points_type]"> |
| 147 | - <?php esc_html_e( 'Import to points type:', 'wordpoints-importer' ); ?> |
|
| 148 | - <?php wordpoints_points_types_dropdown( $args ); ?> |
|
| 147 | + <?php esc_html_e('Import to points type:', 'wordpoints-importer'); ?> |
|
| 148 | + <?php wordpoints_points_types_dropdown($args); ?> |
|
| 149 | 149 | </label> |
| 150 | 150 | </p> |
| 151 | 151 | |
@@ -167,15 +167,15 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return bool Whether the settings are valid. |
| 169 | 169 | */ |
| 170 | -function wordpoints_importer_validate_points_type_setting( $valid, $settings, $feedback ) { |
|
| 170 | +function wordpoints_importer_validate_points_type_setting($valid, $settings, $feedback) { |
|
| 171 | 171 | |
| 172 | - if ( $valid ) { |
|
| 172 | + if ($valid) { |
|
| 173 | 173 | |
| 174 | - if ( ! isset( $settings['points_type'] ) ) { |
|
| 175 | - $feedback->warning( __( 'Skipping Points component—no points type specified.', 'wordpoints-importer' ) ); |
|
| 174 | + if (!isset($settings['points_type'])) { |
|
| 175 | + $feedback->warning(__('Skipping Points component—no points type specified.', 'wordpoints-importer')); |
|
| 176 | 176 | $valid = false; |
| 177 | - } elseif ( ! wordpoints_is_points_type( $settings['points_type'] ) ) { |
|
| 178 | - $feedback->warning( __( 'Skipping Points component—invalid points type selected.', 'wordpoints-importer' ) ); |
|
| 177 | + } elseif (!wordpoints_is_points_type($settings['points_type'])) { |
|
| 178 | + $feedback->warning(__('Skipping Points component—invalid points type selected.', 'wordpoints-importer')); |
|
| 179 | 179 | $valid = false; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -200,20 +200,20 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | // See https://github.com/WordPoints/wordpoints/issues/310. |
| 202 | 202 | $options = array(); |
| 203 | - foreach ( $rank_groups as $rank_group ) { |
|
| 204 | - $options[ $rank_group->slug ] = $rank_group->name; |
|
| 203 | + foreach ($rank_groups as $rank_group) { |
|
| 204 | + $options[$rank_group->slug] = $rank_group->name; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | $dropdown = new WordPoints_Dropdown_Builder( |
| 208 | 208 | $options |
| 209 | - , array( 'name' => 'wordpoints_import[ranks][_data][rank_group]' ) |
|
| 209 | + , array('name' => 'wordpoints_import[ranks][_data][rank_group]') |
|
| 210 | 210 | ); |
| 211 | 211 | |
| 212 | 212 | ?> |
| 213 | 213 | |
| 214 | 214 | <p> |
| 215 | 215 | <label for="wordpoints_import[ranks][_data][rank_group]"> |
| 216 | - <?php esc_html_e( 'Import to rank group:', 'wordpoints-importer' ); ?> |
|
| 216 | + <?php esc_html_e('Import to rank group:', 'wordpoints-importer'); ?> |
|
| 217 | 217 | <?php $dropdown->display(); ?> |
| 218 | 218 | </label> |
| 219 | 219 | </p> |
@@ -236,15 +236,15 @@ discard block |
||
| 236 | 236 | * |
| 237 | 237 | * @return bool Whether the settings are valid. |
| 238 | 238 | */ |
| 239 | -function wordpoints_importer_validate_rank_group_setting( $valid, $settings, $feedback ) { |
|
| 239 | +function wordpoints_importer_validate_rank_group_setting($valid, $settings, $feedback) { |
|
| 240 | 240 | |
| 241 | - if ( $valid ) { |
|
| 241 | + if ($valid) { |
|
| 242 | 242 | |
| 243 | - if ( ! isset( $settings['rank_group'] ) ) { |
|
| 244 | - $feedback->warning( __( 'Skipping Ranks component—no rank group specified.', 'wordpoints-importer' ) ); |
|
| 243 | + if (!isset($settings['rank_group'])) { |
|
| 244 | + $feedback->warning(__('Skipping Ranks component—no rank group specified.', 'wordpoints-importer')); |
|
| 245 | 245 | $valid = false; |
| 246 | - } elseif ( ! WordPoints_Rank_Groups::is_group_registered( $settings['rank_group'] ) ) { |
|
| 247 | - $feedback->warning( __( 'Skipping Ranks component—invalid rank group selected.', 'wordpoints-importer' ) ); |
|
| 246 | + } elseif (!WordPoints_Rank_Groups::is_group_registered($settings['rank_group'])) { |
|
| 247 | + $feedback->warning(__('Skipping Ranks component—invalid rank group selected.', 'wordpoints-importer')); |
|
| 248 | 248 | $valid = false; |
| 249 | 249 | } |
| 250 | 250 | } |
@@ -7,55 +7,55 @@ discard block |
||
| 7 | 7 | * @since 1.0.0 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( true !== current_user_can( 'manage_options' ) ) { |
|
| 10 | +if (true !== current_user_can('manage_options')) { |
|
| 11 | 11 | wp_die(); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -$tabs = array( 'unavailable' => __( 'Unavailable', 'wordpoints-importer' ) ); |
|
| 14 | +$tabs = array('unavailable' => __('Unavailable', 'wordpoints-importer')); |
|
| 15 | 15 | $unavailable = array(); |
| 16 | 16 | |
| 17 | -foreach ( WordPoints_Importers::get() as $slug => $args ) { |
|
| 17 | +foreach (WordPoints_Importers::get() as $slug => $args) { |
|
| 18 | 18 | |
| 19 | - $importer = WordPoints_Importers::get_importer( $slug ); |
|
| 19 | + $importer = WordPoints_Importers::get_importer($slug); |
|
| 20 | 20 | |
| 21 | 21 | $is_available = $importer->is_available(); |
| 22 | 22 | |
| 23 | - if ( is_wp_error( $is_available ) ) { |
|
| 24 | - $unavailable[ $args['name'] ] = $is_available; |
|
| 23 | + if (is_wp_error($is_available)) { |
|
| 24 | + $unavailable[$args['name']] = $is_available; |
|
| 25 | 25 | } else { |
| 26 | - $tabs[ $slug ] = $args['name']; |
|
| 26 | + $tabs[$slug] = $args['name']; |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | -if ( empty( $unavailable ) ) { |
|
| 31 | - unset( $tabs['unavailable'] ); |
|
| 30 | +if (empty($unavailable)) { |
|
| 31 | + unset($tabs['unavailable']); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -$current_tab = wordpoints_admin_get_current_tab( $tabs ); |
|
| 34 | +$current_tab = wordpoints_admin_get_current_tab($tabs); |
|
| 35 | 35 | |
| 36 | 36 | $components = WordPoints_Components::instance()->get(); |
| 37 | 37 | |
| 38 | 38 | ?> |
| 39 | 39 | |
| 40 | -<h2><?php esc_html_e( 'WordPoints Importer', 'wordpoints-importer' ); ?></h2> |
|
| 40 | +<h2><?php esc_html_e('WordPoints Importer', 'wordpoints-importer'); ?></h2> |
|
| 41 | 41 | |
| 42 | 42 | <div class="wrap"> |
| 43 | - <?php wordpoints_admin_show_tabs( $tabs, false ); ?> |
|
| 43 | + <?php wordpoints_admin_show_tabs($tabs, false); ?> |
|
| 44 | 44 | |
| 45 | - <?php if ( 'unavailable' === $current_tab ) : ?> |
|
| 45 | + <?php if ('unavailable' === $current_tab) : ?> |
|
| 46 | 46 | |
| 47 | - <p><?php esc_html_e( 'The below importers are not currently available.', 'wordpoints-importer' ); ?></p> |
|
| 47 | + <p><?php esc_html_e('The below importers are not currently available.', 'wordpoints-importer'); ?></p> |
|
| 48 | 48 | |
| 49 | 49 | <ul> |
| 50 | - <?php foreach ( $unavailable as $name => $error ) : ?> |
|
| 50 | + <?php foreach ($unavailable as $name => $error) : ?> |
|
| 51 | 51 | <li> |
| 52 | 52 | <?php |
| 53 | 53 | |
| 54 | 54 | printf( |
| 55 | 55 | /* translators: 1 is an importer name, 2 is the reason that it is unavailable. */ |
| 56 | - esc_html__( '%1$s — %2$s', 'wordpoints-importer' ) |
|
| 57 | - , '<strong>' . esc_html( $name ) . '</strong>' |
|
| 58 | - , esc_html( $error->get_error_message() ) |
|
| 56 | + esc_html__('%1$s — %2$s', 'wordpoints-importer') |
|
| 57 | + , '<strong>'.esc_html($name).'</strong>' |
|
| 58 | + , esc_html($error->get_error_message()) |
|
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | 61 | ?> |
@@ -65,16 +65,16 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | <?php else : ?> |
| 67 | 67 | |
| 68 | - <?php $importer = WordPoints_Importers::get_importer( $current_tab ); ?> |
|
| 68 | + <?php $importer = WordPoints_Importers::get_importer($current_tab); ?> |
|
| 69 | 69 | |
| 70 | - <p><?php esc_html_e( 'Select which items you would like imported.', 'wordpoints-importer' ); ?></p> |
|
| 70 | + <p><?php esc_html_e('Select which items you would like imported.', 'wordpoints-importer'); ?></p> |
|
| 71 | 71 | |
| 72 | - <form method="post" action="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_importing' ) ); ?>"> |
|
| 73 | - <?php foreach ( $components as $slug => $component ) : ?> |
|
| 72 | + <form method="post" action="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_importing')); ?>"> |
|
| 73 | + <?php foreach ($components as $slug => $component) : ?> |
|
| 74 | 74 | |
| 75 | 75 | <?php |
| 76 | 76 | |
| 77 | - if ( ! $importer->supports_component( $slug ) ) { |
|
| 77 | + if (!$importer->supports_component($slug)) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | ?> |
| 84 | 84 | |
| 85 | - <h3><?php echo esc_html( $component['name'] ); ?></h3> |
|
| 85 | + <h3><?php echo esc_html($component['name']); ?></h3> |
|
| 86 | 86 | |
| 87 | 87 | <?php |
| 88 | 88 | |
@@ -91,42 +91,42 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @since 1.0.0 |
| 93 | 93 | */ |
| 94 | - do_action( "wordpoints_importer_before_component_options-{$slug}" ); |
|
| 94 | + do_action("wordpoints_importer_before_component_options-{$slug}"); |
|
| 95 | 95 | |
| 96 | 96 | ?> |
| 97 | 97 | |
| 98 | - <?php foreach ( $importer->get_options_for_component( $slug ) as $name => $option ) : ?> |
|
| 98 | + <?php foreach ($importer->get_options_for_component($slug) as $name => $option) : ?> |
|
| 99 | 99 | |
| 100 | 100 | <?php |
| 101 | 101 | |
| 102 | 102 | $can_import = true; |
| 103 | 103 | |
| 104 | 104 | // Check if this option is available. |
| 105 | - if ( isset( $option['can_import'] ) ) { |
|
| 106 | - $can_import = call_user_func( $option['can_import'], array() ); |
|
| 105 | + if (isset($option['can_import'])) { |
|
| 106 | + $can_import = call_user_func($option['can_import'], array()); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | ?> |
| 110 | 110 | |
| 111 | - <label for="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]"> |
|
| 112 | - <input type="checkbox" value="1" id="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]" name="wordpoints_import[<?php echo esc_attr( $slug ); ?>][<?php echo esc_attr( $name ); ?>]" <?php disabled( is_wp_error( $can_import ), true ); ?> /> |
|
| 113 | - <?php echo esc_html( $option['label'] ); ?> |
|
| 114 | - <?php if ( is_wp_error( $can_import ) ) : ?> |
|
| 111 | + <label for="wordpoints_import[<?php echo esc_attr($slug); ?>][<?php echo esc_attr($name); ?>]"> |
|
| 112 | + <input type="checkbox" value="1" id="wordpoints_import[<?php echo esc_attr($slug); ?>][<?php echo esc_attr($name); ?>]" name="wordpoints_import[<?php echo esc_attr($slug); ?>][<?php echo esc_attr($name); ?>]" <?php disabled(is_wp_error($can_import), true); ?> /> |
|
| 113 | + <?php echo esc_html($option['label']); ?> |
|
| 114 | + <?php if (is_wp_error($can_import)) : ?> |
|
| 115 | 115 | |
| 116 | 116 | <em> |
| 117 | 117 | <?php |
| 118 | 118 | |
| 119 | 119 | // translators: Error message explaining the reason why the importer is disabled. |
| 120 | - printf( esc_html__( 'Disabled (%s)', 'wordpoints-importer' ), esc_html( $can_import->get_error_message() ) ); |
|
| 120 | + printf(esc_html__('Disabled (%s)', 'wordpoints-importer'), esc_html($can_import->get_error_message())); |
|
| 121 | 121 | |
| 122 | 122 | ?> |
| 123 | 123 | </em> |
| 124 | 124 | <?php endif; ?> |
| 125 | 125 | </label> |
| 126 | 126 | |
| 127 | - <?php if ( isset( $option['description'] ) ) : ?> |
|
| 127 | + <?php if (isset($option['description'])) : ?> |
|
| 128 | 128 | <p class="description" style="margin-bottom: 10px; margin-left: 25px;"> |
| 129 | - <?php echo esc_html( $option['description'] ); ?> |
|
| 129 | + <?php echo esc_html($option['description']); ?> |
|
| 130 | 130 | </p> |
| 131 | 131 | <?php else : ?> |
| 132 | 132 | <br style="margin-bottom: 10px" /> |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | <?php endforeach; ?> |
| 138 | 138 | |
| 139 | - <input type="hidden" value="<?php echo esc_attr( $current_tab ); ?>" name="importer" /> |
|
| 139 | + <input type="hidden" value="<?php echo esc_attr($current_tab); ?>" name="importer" /> |
|
| 140 | 140 | |
| 141 | 141 | <?php |
| 142 | 142 | |
| 143 | - if ( ! isset( $supported ) ) { |
|
| 143 | + if (!isset($supported)) { |
|
| 144 | 144 | |
| 145 | 145 | esc_html_e( |
| 146 | 146 | 'This importer does not support any of the installed components.' |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | } else { |
| 151 | 151 | |
| 152 | - wp_nonce_field( 'wordpoints_import' ); |
|
| 153 | - submit_button( __( 'Import', 'wordpoints-importer' ) ); |
|
| 152 | + wp_nonce_field('wordpoints_import'); |
|
| 153 | + submit_button(__('Import', 'wordpoints-importer')); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | ?> |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @param string $name The name of the importer. |
| 64 | 64 | */ |
| 65 | - public function __construct( $name ) { |
|
| 65 | + public function __construct($name) { |
|
| 66 | 66 | |
| 67 | 67 | $this->name = $name; |
| 68 | 68 | } |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return bool True if the component is supported, otherwise false. |
| 78 | 78 | */ |
| 79 | - public function supports_component( $component ) { |
|
| 79 | + public function supports_component($component) { |
|
| 80 | 80 | |
| 81 | - return isset( $this->components[ $component ] ); |
|
| 81 | + return isset($this->components[$component]); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -90,13 +90,13 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return array[] The options for this component. |
| 92 | 92 | */ |
| 93 | - public function get_options_for_component( $component ) { |
|
| 93 | + public function get_options_for_component($component) { |
|
| 94 | 94 | |
| 95 | - if ( ! $this->supports_component( $component ) ) { |
|
| 95 | + if (!$this->supports_component($component)) { |
|
| 96 | 96 | return array(); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - return $this->components[ $component ]; |
|
| 99 | + return $this->components[$component]; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -107,24 +107,24 @@ discard block |
||
| 107 | 107 | * @param array $args The settings for the import. |
| 108 | 108 | * @param WordPoints_Importer_Feedback $feedback The feedback object. |
| 109 | 109 | */ |
| 110 | - public function do_import( array $args, $feedback = null ) { |
|
| 110 | + public function do_import(array $args, $feedback = null) { |
|
| 111 | 111 | |
| 112 | - if ( ! ( $feedback instanceof WordPoints_Importer_Feedback ) ) { |
|
| 112 | + if (!($feedback instanceof WordPoints_Importer_Feedback)) { |
|
| 113 | 113 | $feedback = new WordPoints_Importer_Feedback(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $this->feedback = $feedback; |
| 117 | 117 | |
| 118 | 118 | // translators: Plugin name. |
| 119 | - $this->feedback->info( sprintf( __( 'Importing from %s…', 'wordpoints-importer' ), $this->name ) ); |
|
| 119 | + $this->feedback->info(sprintf(__('Importing from %s…', 'wordpoints-importer'), $this->name)); |
|
| 120 | 120 | |
| 121 | 121 | $this->no_interruptions(); |
| 122 | 122 | |
| 123 | - foreach ( $args as $component => $options ) { |
|
| 124 | - $this->do_import_for_component( $component, $options ); |
|
| 123 | + foreach ($args as $component => $options) { |
|
| 124 | + $this->do_import_for_component($component, $options); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $this->feedback->info( __( 'Import complete.', 'wordpoints-importer' ) ); |
|
| 127 | + $this->feedback->info(__('Import complete.', 'wordpoints-importer')); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return bool Whether the settings are valid. |
| 149 | 149 | */ |
| 150 | - protected function validate_import_settings( $component, $settings ) { |
|
| 150 | + protected function validate_import_settings($component, $settings) { |
|
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * Filter whether the settings are valid before importing. |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param array $settings The settings for this component. |
| 159 | 159 | * @param WordPoints_Importer_Feedback $feedback The feedback object. |
| 160 | 160 | */ |
| 161 | - return apply_filters( "wordpoints_import_settings_valid-{$component}", true, $settings, $this->feedback ); |
|
| 161 | + return apply_filters("wordpoints_import_settings_valid-{$component}", true, $settings, $this->feedback); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -169,40 +169,40 @@ discard block |
||
| 169 | 169 | * @param string $component The component to run the import for. |
| 170 | 170 | * @param array $options The selected options of what to import. |
| 171 | 171 | */ |
| 172 | - protected function do_import_for_component( $component, $options ) { |
|
| 172 | + protected function do_import_for_component($component, $options) { |
|
| 173 | 173 | |
| 174 | 174 | $component_data = WordPoints_Components::instance()->get_component( |
| 175 | 175 | $component |
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | - if ( false === $component_data ) { |
|
| 178 | + if (false === $component_data) { |
|
| 179 | 179 | // translators: Component name. |
| 180 | - $this->feedback->warning( sprintf( __( 'Skipping %s component—not installed.', 'wordpoints-importer' ), esc_html( $component ) ) ); |
|
| 180 | + $this->feedback->warning(sprintf(__('Skipping %s component—not installed.', 'wordpoints-importer'), esc_html($component))); |
|
| 181 | 181 | return; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( true !== $this->supports_component( $component ) ) { |
|
| 184 | + if (true !== $this->supports_component($component)) { |
|
| 185 | 185 | // translators: Component name. |
| 186 | - $this->feedback->warning( sprintf( __( 'Skipping the %s component—not supported.', 'wordpoints-importer' ), $component_data['name'] ) ); |
|
| 186 | + $this->feedback->warning(sprintf(__('Skipping the %s component—not supported.', 'wordpoints-importer'), $component_data['name'])); |
|
| 187 | 187 | return; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $settings = array(); |
| 191 | 191 | |
| 192 | - if ( isset( $options['_data'] ) ) { |
|
| 192 | + if (isset($options['_data'])) { |
|
| 193 | 193 | $settings = $options['_data']; |
| 194 | - unset( $options['_data'] ); |
|
| 194 | + unset($options['_data']); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if ( empty( $options ) || ! $this->validate_import_settings( $component, $settings ) ) { |
|
| 197 | + if (empty($options) || !$this->validate_import_settings($component, $settings)) { |
|
| 198 | 198 | return; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // translators: Component name. |
| 202 | - $this->feedback->info( sprintf( __( 'Importing data to the %s component…', 'wordpoints-importer' ), $component_data['name'] ) ); |
|
| 202 | + $this->feedback->info(sprintf(__('Importing data to the %s component…', 'wordpoints-importer'), $component_data['name'])); |
|
| 203 | 203 | |
| 204 | - foreach ( $options as $option => $unused ) { |
|
| 205 | - $this->do_import_for_option( $option, $component, $settings ); |
|
| 204 | + foreach ($options as $option => $unused) { |
|
| 205 | + $this->do_import_for_option($option, $component, $settings); |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
@@ -220,30 +220,30 @@ discard block |
||
| 220 | 220 | * @param string $component The component this option is for. |
| 221 | 221 | * @param array $settings Other settings for this component. |
| 222 | 222 | */ |
| 223 | - protected function do_import_for_option( $option, $component, $settings ) { |
|
| 223 | + protected function do_import_for_option($option, $component, $settings) { |
|
| 224 | 224 | |
| 225 | - if ( ! isset( $this->components[ $component ][ $option ] ) ) { |
|
| 225 | + if (!isset($this->components[$component][$option])) { |
|
| 226 | 226 | // translators: Option name. |
| 227 | - $this->feedback->warning( sprintf( __( 'Skipping unrecognized import option “%s”…', 'wordpoints-importer' ), $option ) ); |
|
| 227 | + $this->feedback->warning(sprintf(__('Skipping unrecognized import option “%s”…', 'wordpoints-importer'), $option)); |
|
| 228 | 228 | return; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - $option_data = $this->components[ $component ][ $option ]; |
|
| 231 | + $option_data = $this->components[$component][$option]; |
|
| 232 | 232 | |
| 233 | 233 | // Check if we can actually run this option. |
| 234 | - if ( isset( $option_data['can_import'] ) ) { |
|
| 234 | + if (isset($option_data['can_import'])) { |
|
| 235 | 235 | |
| 236 | - $cant_import = call_user_func( $option_data['can_import'], $settings ); |
|
| 236 | + $cant_import = call_user_func($option_data['can_import'], $settings); |
|
| 237 | 237 | |
| 238 | - if ( is_wp_error( $cant_import ) ) { |
|
| 238 | + if (is_wp_error($cant_import)) { |
|
| 239 | 239 | // translators: 1. Option name; 2. Reason the import was skipped. |
| 240 | - $this->feedback->warning( sprintf( __( 'Skipping importing %1$s. Reason: %2$s', 'wordpoints-importer' ), $option_data['label'], $cant_import->get_error_message() ) ); |
|
| 240 | + $this->feedback->warning(sprintf(__('Skipping importing %1$s. Reason: %2$s', 'wordpoints-importer'), $option_data['label'], $cant_import->get_error_message())); |
|
| 241 | 241 | return; |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // OK, we can run the import method for this option. |
| 246 | - call_user_func( $option_data['function'], $settings ); |
|
| 246 | + call_user_func($option_data['function'], $settings); |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param string $message The info message. |
| 28 | 28 | */ |
| 29 | - public function info( $message ) { |
|
| 30 | - $this->_send( $message, 'info' ); |
|
| 29 | + public function info($message) { |
|
| 30 | + $this->_send($message, 'info'); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @param string $message The success message. |
| 41 | 41 | */ |
| 42 | - public function success( $message ) { |
|
| 43 | - $this->_send( $message, 'success' ); |
|
| 42 | + public function success($message) { |
|
| 43 | + $this->_send($message, 'success'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @param string $message The error message. |
| 54 | 54 | */ |
| 55 | - public function error( $message ) { |
|
| 56 | - $this->_send( $message, 'error' ); |
|
| 55 | + public function error($message) { |
|
| 56 | + $this->_send($message, 'error'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param string $message The warning message. |
| 69 | 69 | */ |
| 70 | - public function warning( $message ) { |
|
| 71 | - $this->_send( $message, 'warning' ); |
|
| 70 | + public function warning($message) { |
|
| 71 | + $this->_send($message, 'warning'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // |
@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | * @param string $type The type of message: 'info' (defuault), 'sucess', |
| 85 | 85 | * 'error', 'warning'. |
| 86 | 86 | */ |
| 87 | - protected function _send( $message, $type = 'info' ) { // @codingStandardsIgnoreLine |
|
| 87 | + protected function _send($message, $type = 'info') { // @codingStandardsIgnoreLine |
|
| 88 | 88 | |
| 89 | 89 | ?> |
| 90 | 90 | |
| 91 | - <p class="wordpoints-feedback wordpoints-feedback-<?php echo esc_attr( $type ); ?>"> |
|
| 92 | - <?php echo wp_kses( $message, 'wordpoints_importer_feedback' ); ?> |
|
| 91 | + <p class="wordpoints-feedback wordpoints-feedback-<?php echo esc_attr($type); ?>"> |
|
| 92 | + <?php echo wp_kses($message, 'wordpoints_importer_feedback'); ?> |
|
| 93 | 93 | </p> |
| 94 | 94 | |
| 95 | 95 | <?php |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | function wordpoints_importer_load_textdomain() { |
| 17 | 17 | |
| 18 | - _deprecated_function( __FUNCTION__, '1.3.0' ); |
|
| 18 | + _deprecated_function(__FUNCTION__, '1.3.0'); |
|
| 19 | 19 | |
| 20 | 20 | wordpoints_load_module_textdomain( |
| 21 | 21 | 'wordpoints-importer' |
| 22 | - , wordpoints_module_basename( dirname( dirname( __FILE__ ) ) ) . '/languages' |
|
| 22 | + , wordpoints_module_basename(dirname(dirname(__FILE__))).'/languages' |
|
| 23 | 23 | ); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $args = array( |
| 34 | 34 | 'class' => 'WordPoints_CubePoints_Importer', |
| 35 | - 'name' => __( 'CubePoints', 'wordpoints-importer' ), |
|
| 35 | + 'name' => __('CubePoints', 'wordpoints-importer'), |
|
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | - WordPoints_Importers::register( 'cubepoints', $args ); |
|
| 38 | + WordPoints_Importers::register('cubepoints', $args); |
|
| 39 | 39 | } |
| 40 | -add_action( 'wordpoints_register_importers', 'wordpoints_importer_register_importers' ); |
|
| 40 | +add_action('wordpoints_register_importers', 'wordpoints_importer_register_importers'); |
|
| 41 | 41 | |
| 42 | 42 | // EOF |
@@ -66,36 +66,36 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * @since 1.0.0 |
| 68 | 68 | */ |
| 69 | - public function __construct( $name ) { |
|
| 69 | + public function __construct($name) { |
|
| 70 | 70 | |
| 71 | - parent::__construct( $name ); |
|
| 71 | + parent::__construct($name); |
|
| 72 | 72 | |
| 73 | 73 | $this->components = array( |
| 74 | 74 | 'points' => array( |
| 75 | 75 | 'excluded_users' => array( |
| 76 | - 'label' => __( 'Excluded users', 'wordpoints-importer' ), |
|
| 77 | - 'function' => array( $this, 'import_excluded_users' ), |
|
| 76 | + 'label' => __('Excluded users', 'wordpoints-importer'), |
|
| 77 | + 'function' => array($this, 'import_excluded_users'), |
|
| 78 | 78 | ), |
| 79 | 79 | 'settings' => array( |
| 80 | - 'label' => __( 'Points Reactions', 'wordpoints-importer' ), |
|
| 81 | - 'description' => __( 'If checked, the settings for the number of points to award for posts, comments, etc. are imported.', 'wordpoints-importer' ), |
|
| 82 | - 'function' => array( $this, 'import_points_settings' ), |
|
| 80 | + 'label' => __('Points Reactions', 'wordpoints-importer'), |
|
| 81 | + 'description' => __('If checked, the settings for the number of points to award for posts, comments, etc. are imported.', 'wordpoints-importer'), |
|
| 82 | + 'function' => array($this, 'import_points_settings'), |
|
| 83 | 83 | ), |
| 84 | 84 | 'user_points' => array( |
| 85 | - 'label' => __( 'User points', 'wordpoints-importer' ), |
|
| 86 | - 'function' => array( $this, 'import_user_points' ), |
|
| 85 | + 'label' => __('User points', 'wordpoints-importer'), |
|
| 86 | + 'function' => array($this, 'import_user_points'), |
|
| 87 | 87 | ), |
| 88 | 88 | 'logs' => array( |
| 89 | - 'label' => __( 'Points logs', 'wordpoints-importer' ), |
|
| 90 | - 'function' => array( $this, 'import_points_logs' ), |
|
| 91 | - 'can_import' => array( $this, 'can_import_points_logs' ), |
|
| 89 | + 'label' => __('Points logs', 'wordpoints-importer'), |
|
| 90 | + 'function' => array($this, 'import_points_logs'), |
|
| 91 | + 'can_import' => array($this, 'can_import_points_logs'), |
|
| 92 | 92 | ), |
| 93 | 93 | ), |
| 94 | 94 | 'ranks' => array( |
| 95 | 95 | 'ranks' => array( |
| 96 | - 'label' => __( 'Rank settings', 'wordpoints-importer' ), |
|
| 97 | - 'description' => __( 'If checked, the list of ranks is imported, and users will have the correct ranks assigned to them.', 'wordpoints-importer' ), |
|
| 98 | - 'function' => array( $this, 'import_ranks' ), |
|
| 96 | + 'label' => __('Rank settings', 'wordpoints-importer'), |
|
| 97 | + 'description' => __('If checked, the list of ranks is imported, and users will have the correct ranks assigned to them.', 'wordpoints-importer'), |
|
| 98 | + 'function' => array($this, 'import_ranks'), |
|
| 99 | 99 | ), |
| 100 | 100 | ), |
| 101 | 101 | ); |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function is_available() { |
| 108 | 108 | |
| 109 | - if ( ! $this->is_cubepoints_installed() ) { |
|
| 109 | + if (!$this->is_cubepoints_installed()) { |
|
| 110 | 110 | return new WP_Error( |
| 111 | 111 | 'cubepoints_not_installed' |
| 112 | - , __( 'CubePoints is not installed', 'wordpoints-importer' ) |
|
| 112 | + , __('CubePoints is not installed', 'wordpoints-importer') |
|
| 113 | 113 | ); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function is_cubepoints_installed() { |
| 125 | 125 | |
| 126 | - return (bool) get_option( 'cp_db_version' ); |
|
| 126 | + return (bool) get_option('cp_db_version'); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function is_cubepoints_active() { |
| 135 | 135 | |
| 136 | - return function_exists( 'cp_ready' ); |
|
| 136 | + return function_exists('cp_ready'); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -143,22 +143,22 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | protected function import_excluded_users() { |
| 145 | 145 | |
| 146 | - $this->feedback->info( __( 'Importing excluded users…', 'wordpoints-importer' ) ); |
|
| 146 | + $this->feedback->info(__('Importing excluded users…', 'wordpoints-importer')); |
|
| 147 | 147 | |
| 148 | - $excluded_users = get_option( 'cp_topfilter' ); |
|
| 148 | + $excluded_users = get_option('cp_topfilter'); |
|
| 149 | 149 | |
| 150 | - if ( ! is_array( $excluded_users ) ) { |
|
| 151 | - $this->feedback->warning( __( 'No excluded users found.', 'wordpoints-importer' ) ); |
|
| 150 | + if (!is_array($excluded_users)) { |
|
| 151 | + $this->feedback->warning(__('No excluded users found.', 'wordpoints-importer')); |
|
| 152 | 152 | return; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | $user_ids = array(); |
| 156 | 156 | |
| 157 | - foreach ( $excluded_users as $user_login ) { |
|
| 157 | + foreach ($excluded_users as $user_login) { |
|
| 158 | 158 | |
| 159 | - $user = get_user_by( 'login', $user_login ); |
|
| 159 | + $user = get_user_by('login', $user_login); |
|
| 160 | 160 | |
| 161 | - if ( $user instanceof WP_User ) { |
|
| 161 | + if ($user instanceof WP_User) { |
|
| 162 | 162 | $user_ids[] = $user->ID; |
| 163 | 163 | } |
| 164 | 164 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | 170 | $excluded_user_ids = array_unique( |
| 171 | - array_merge( $excluded_user_ids, $user_ids ) |
|
| 171 | + array_merge($excluded_user_ids, $user_ids) |
|
| 172 | 172 | ); |
| 173 | 173 | |
| 174 | 174 | wordpoints_update_maybe_network_option( |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | $this->feedback->success( |
| 180 | 180 | sprintf( |
| 181 | 181 | // translators: Number of users. |
| 182 | - __( 'Imported %s excluded users.', 'wordpoints-importer' ) |
|
| 183 | - , count( $user_ids ) |
|
| 182 | + __('Imported %s excluded users.', 'wordpoints-importer') |
|
| 183 | + , count($user_ids) |
|
| 184 | 184 | ) |
| 185 | 185 | ); |
| 186 | 186 | } |
@@ -192,64 +192,64 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * @param array $settings The settings for the points component import. |
| 194 | 194 | */ |
| 195 | - protected function import_points_settings( $settings ) { |
|
| 195 | + protected function import_points_settings($settings) { |
|
| 196 | 196 | |
| 197 | - $this->feedback->info( __( 'Importing points reactions…', 'wordpoints-importer' ) ); |
|
| 197 | + $this->feedback->info(__('Importing points reactions…', 'wordpoints-importer')); |
|
| 198 | 198 | |
| 199 | 199 | $options = array( |
| 200 | 200 | 'cp_comment_points' => array( |
| 201 | 201 | 'event' => 'comment_leave\post', |
| 202 | - 'target' => array( 'comment\post', 'author', 'user' ), |
|
| 202 | + 'target' => array('comment\post', 'author', 'user'), |
|
| 203 | 203 | /* translators: The post type name */ |
| 204 | - 'log_text' => __( 'Comment on a %s.', 'wordpoints-importer' ), |
|
| 204 | + 'log_text' => __('Comment on a %s.', 'wordpoints-importer'), |
|
| 205 | 205 | /* translators: The post type name */ |
| 206 | - 'description' => __( 'Commenting on a %s.', 'wordpoints-importer' ), |
|
| 206 | + 'description' => __('Commenting on a %s.', 'wordpoints-importer'), |
|
| 207 | 207 | 'legacy_log_type' => 'cubepoints-comment', |
| 208 | 208 | 'legacy_meta_key' => 'comment', |
| 209 | 209 | ), |
| 210 | 210 | 'cp_post_points' => array( |
| 211 | 211 | 'event' => 'post_publish\post', |
| 212 | - 'target' => array( 'post\post', 'author', 'user' ), |
|
| 212 | + 'target' => array('post\post', 'author', 'user'), |
|
| 213 | 213 | /* translators: The post type name */ |
| 214 | - 'log_text' => __( 'Published a Post.', 'wordpoints-importer' ), |
|
| 214 | + 'log_text' => __('Published a Post.', 'wordpoints-importer'), |
|
| 215 | 215 | /* translators: The post type name */ |
| 216 | - 'description' => __( 'Publishing a Post.', 'wordpoints-importer' ), |
|
| 216 | + 'description' => __('Publishing a Post.', 'wordpoints-importer'), |
|
| 217 | 217 | 'legacy_log_type' => 'cubepoints-post', |
| 218 | 218 | 'legacy_meta_key' => 'post', |
| 219 | 219 | // CubePoints doesn't remove points when a post is deleted. |
| 220 | - 'blocker' => array( 'toggle_off' => true ), |
|
| 221 | - 'points_legacy_repeat_blocker' => array( 'toggle_on' => true ), |
|
| 220 | + 'blocker' => array('toggle_off' => true), |
|
| 221 | + 'points_legacy_repeat_blocker' => array('toggle_on' => true), |
|
| 222 | 222 | ), |
| 223 | 223 | 'cp_reg_points' => array( |
| 224 | 224 | 'event' => 'user_register', |
| 225 | - 'log_text' => __( 'Registration.', 'wordpoints-importer' ), |
|
| 226 | - 'description' => __( 'Registration.', 'wordpoints-importer' ), |
|
| 225 | + 'log_text' => __('Registration.', 'wordpoints-importer'), |
|
| 226 | + 'description' => __('Registration.', 'wordpoints-importer'), |
|
| 227 | 227 | 'legacy_log_type' => 'cubepoints-register', |
| 228 | 228 | ), |
| 229 | 229 | 'cp_post_author_points' => array( |
| 230 | 230 | 'event' => 'comment_leave\post', |
| 231 | - 'target' => array( 'comment\post', 'post\post', 'post\post', 'author', 'user' ), |
|
| 231 | + 'target' => array('comment\post', 'post\post', 'post\post', 'author', 'user'), |
|
| 232 | 232 | /* translators: The post type name */ |
| 233 | - 'log_text' => __( 'Received a comment on a %s.', 'wordpoints-importer' ), |
|
| 233 | + 'log_text' => __('Received a comment on a %s.', 'wordpoints-importer'), |
|
| 234 | 234 | /* translators: The post type name */ |
| 235 | - 'description' => __( 'Receiving a comment on a %s.', 'wordpoints-importer' ), |
|
| 235 | + 'description' => __('Receiving a comment on a %s.', 'wordpoints-importer'), |
|
| 236 | 236 | 'legacy_log_type' => 'cubepoints-post_author', |
| 237 | 237 | 'legacy_meta_key' => 'comment', |
| 238 | 238 | ), |
| 239 | 239 | ); |
| 240 | 240 | |
| 241 | 241 | // Don't import this module setting if the module isn't active. |
| 242 | - if ( function_exists( 'cp_module_activated' ) && ! cp_module_activated( 'post_author_points' ) ) { |
|
| 243 | - unset( $options['cp_post_author_points'] ); |
|
| 242 | + if (function_exists('cp_module_activated') && !cp_module_activated('post_author_points')) { |
|
| 243 | + unset($options['cp_post_author_points']); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $imported = 0; |
| 247 | 247 | |
| 248 | - foreach ( $options as $option => $hook_settings ) { |
|
| 248 | + foreach ($options as $option => $hook_settings) { |
|
| 249 | 249 | |
| 250 | - $points = get_option( $option ); |
|
| 250 | + $points = get_option($option); |
|
| 251 | 251 | |
| 252 | - if ( wordpoints_posint( $points ) ) { |
|
| 252 | + if (wordpoints_posint($points)) { |
|
| 253 | 253 | |
| 254 | 254 | $hook_settings['points'] = $points; |
| 255 | 255 | $hook_settings['points_type'] = $settings['points_type']; |
@@ -257,12 +257,12 @@ discard block |
||
| 257 | 257 | if ( |
| 258 | 258 | // The CubePoints post points were only awarded for Posts. |
| 259 | 259 | 'post_publish\post' !== $hook_settings['event'] |
| 260 | - && strpos( $hook_settings['event'], '\post' ) |
|
| 260 | + && strpos($hook_settings['event'], '\post') |
|
| 261 | 261 | ) { |
| 262 | 262 | |
| 263 | - $post_type_slugs = get_post_types( array( 'public' => true ) ); |
|
| 263 | + $post_type_slugs = get_post_types(array('public' => true)); |
|
| 264 | 264 | |
| 265 | - foreach ( $post_type_slugs as $post_type_slug ) { |
|
| 265 | + foreach ($post_type_slugs as $post_type_slug) { |
|
| 266 | 266 | |
| 267 | 267 | $added = $this->add_points_hook( |
| 268 | 268 | $this->format_settings_for_post_type( |
@@ -271,13 +271,13 @@ discard block |
||
| 271 | 271 | ) |
| 272 | 272 | ); |
| 273 | 273 | |
| 274 | - if ( $added ) { |
|
| 274 | + if ($added) { |
|
| 275 | 275 | $imported++; |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | } else { |
| 280 | - if ( $this->add_points_hook( $hook_settings ) ) { |
|
| 280 | + if ($this->add_points_hook($hook_settings)) { |
|
| 281 | 281 | $imported++; |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -285,13 +285,13 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | } // End foreach ( $options ). |
| 287 | 287 | |
| 288 | - if ( $this->import_daily_points_hook( $settings ) ) { |
|
| 288 | + if ($this->import_daily_points_hook($settings)) { |
|
| 289 | 289 | $imported++; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | $this->feedback->success( |
| 293 | 293 | // translators: Number of reactions. |
| 294 | - sprintf( __( 'Imported %s points reactions.', 'wordpoints-importer' ), $imported ) |
|
| 294 | + sprintf(__('Imported %s points reactions.', 'wordpoints-importer'), $imported) |
|
| 295 | 295 | ); |
| 296 | 296 | } |
| 297 | 297 | |
@@ -304,24 +304,24 @@ discard block |
||
| 304 | 304 | * |
| 305 | 305 | * @return bool True if the settings were imported, false otherwise. |
| 306 | 306 | */ |
| 307 | - protected function import_daily_points_hook( $settings ) { |
|
| 307 | + protected function import_daily_points_hook($settings) { |
|
| 308 | 308 | |
| 309 | 309 | // Don't import this module setting if the module isn't active. |
| 310 | - if ( function_exists( 'cp_module_activated' ) && ! cp_module_activated( 'dailypoints' ) ) { |
|
| 310 | + if (function_exists('cp_module_activated') && !cp_module_activated('dailypoints')) { |
|
| 311 | 311 | return false; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - $points = get_option( 'cp_module_dailypoints_points' ); |
|
| 315 | - $period = get_option( 'cp_module_dailypoints_time' ); |
|
| 314 | + $points = get_option('cp_module_dailypoints_points'); |
|
| 315 | + $period = get_option('cp_module_dailypoints_time'); |
|
| 316 | 316 | |
| 317 | - if ( ! wordpoints_int( $points ) || ! wordpoints_posint( $period ) ) { |
|
| 317 | + if (!wordpoints_int($points) || !wordpoints_posint($period)) { |
|
| 318 | 318 | return false; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | return $this->add_points_hook( |
| 322 | 322 | array( |
| 323 | 323 | 'event' => 'user_visit', |
| 324 | - 'target' => array( 'current:user' ), |
|
| 324 | + 'target' => array('current:user'), |
|
| 325 | 325 | 'reactor' => 'points_legacy', |
| 326 | 326 | 'points' => $points, |
| 327 | 327 | 'points_type' => $settings['points_type'], |
@@ -329,13 +329,13 @@ discard block |
||
| 329 | 329 | 'fire' => array( |
| 330 | 330 | array( |
| 331 | 331 | 'length' => $period, |
| 332 | - 'args' => array( array( 'current:user' ) ), |
|
| 332 | + 'args' => array(array('current:user')), |
|
| 333 | 333 | 'relative' => true, |
| 334 | 334 | ), |
| 335 | 335 | ), |
| 336 | 336 | ), |
| 337 | - 'log_text' => __( 'Visiting the site.', 'wordpoints-importer' ), |
|
| 338 | - 'description' => __( 'Visiting the site.', 'wordpoints-importer' ), |
|
| 337 | + 'log_text' => __('Visiting the site.', 'wordpoints-importer'), |
|
| 338 | + 'description' => __('Visiting the site.', 'wordpoints-importer'), |
|
| 339 | 339 | 'points_legacy_reversals' => array(), |
| 340 | 340 | 'legacy_log_type' => 'cubepoints-dailypoints', |
| 341 | 341 | ) |
@@ -352,22 +352,22 @@ discard block |
||
| 352 | 352 | * |
| 353 | 353 | * @return bool True if added successfully, or false on failure. |
| 354 | 354 | */ |
| 355 | - private function add_points_hook( $settings = array() ) { |
|
| 355 | + private function add_points_hook($settings = array()) { |
|
| 356 | 356 | |
| 357 | - $reaction_store = wordpoints_hooks()->get_reaction_store( 'points' ); |
|
| 357 | + $reaction_store = wordpoints_hooks()->get_reaction_store('points'); |
|
| 358 | 358 | |
| 359 | 359 | $settings = array_merge( |
| 360 | 360 | array( |
| 361 | - 'target' => array( 'user' ), |
|
| 361 | + 'target' => array('user'), |
|
| 362 | 362 | 'reactor' => 'points_legacy', |
| 363 | - 'points_legacy_reversals' => array( 'toggle_off' => 'toggle_on' ), |
|
| 363 | + 'points_legacy_reversals' => array('toggle_off' => 'toggle_on'), |
|
| 364 | 364 | ) |
| 365 | 365 | , $settings |
| 366 | 366 | ); |
| 367 | 367 | |
| 368 | - $reaction = $reaction_store->create_reaction( $settings ); |
|
| 368 | + $reaction = $reaction_store->create_reaction($settings); |
|
| 369 | 369 | |
| 370 | - if ( ! $reaction instanceof WordPoints_Hook_ReactionI ) { |
|
| 370 | + if (!$reaction instanceof WordPoints_Hook_ReactionI) { |
|
| 371 | 371 | return false; |
| 372 | 372 | } |
| 373 | 373 | |
@@ -384,24 +384,24 @@ discard block |
||
| 384 | 384 | * |
| 385 | 385 | * @return array The settings modified for this particular post type. |
| 386 | 386 | */ |
| 387 | - protected function format_settings_for_post_type( $post_type, $settings ) { |
|
| 387 | + protected function format_settings_for_post_type($post_type, $settings) { |
|
| 388 | 388 | |
| 389 | 389 | $settings['event'] = str_replace( |
| 390 | 390 | '\post' |
| 391 | - , '\\' . $post_type |
|
| 391 | + , '\\'.$post_type |
|
| 392 | 392 | , $settings['event'] |
| 393 | 393 | ); |
| 394 | 394 | |
| 395 | 395 | $settings['target'] = str_replace( |
| 396 | 396 | '\post' |
| 397 | - , '\\' . $post_type |
|
| 397 | + , '\\'.$post_type |
|
| 398 | 398 | , $settings['target'] |
| 399 | 399 | ); |
| 400 | 400 | |
| 401 | - $labels = get_post_type_labels( get_post_type_object( $post_type ) ); |
|
| 401 | + $labels = get_post_type_labels(get_post_type_object($post_type)); |
|
| 402 | 402 | |
| 403 | - $settings['log_text'] = sprintf( $settings['log_text'], $labels->singular_name ); |
|
| 404 | - $settings['description'] = sprintf( $settings['description'], $labels->singular_name ); |
|
| 403 | + $settings['log_text'] = sprintf($settings['log_text'], $labels->singular_name); |
|
| 404 | + $settings['description'] = sprintf($settings['description'], $labels->singular_name); |
|
| 405 | 405 | |
| 406 | 406 | return $settings; |
| 407 | 407 | } |
@@ -413,20 +413,20 @@ discard block |
||
| 413 | 413 | * |
| 414 | 414 | * @param array $settings The settings for the points component import. |
| 415 | 415 | */ |
| 416 | - protected function import_user_points( $settings ) { |
|
| 416 | + protected function import_user_points($settings) { |
|
| 417 | 417 | |
| 418 | - $this->feedback->info( __( 'Importing users' points…', 'wordpoints-importer' ) ); |
|
| 418 | + $this->feedback->info(__('Importing users' points…', 'wordpoints-importer')); |
|
| 419 | 419 | |
| 420 | 420 | // We don't log the import transactions. |
| 421 | - add_filter( 'wordpoints_points_log', '__return_false' ); |
|
| 421 | + add_filter('wordpoints_points_log', '__return_false'); |
|
| 422 | 422 | |
| 423 | 423 | $start = 0; |
| 424 | - $rows = $this->get_next_user_points_batch( $start ); |
|
| 424 | + $rows = $this->get_next_user_points_batch($start); |
|
| 425 | 425 | |
| 426 | 426 | // We do the import in batches. |
| 427 | - while ( $rows ) { |
|
| 427 | + while ($rows) { |
|
| 428 | 428 | |
| 429 | - foreach ( $rows as $row ) { |
|
| 429 | + foreach ($rows as $row) { |
|
| 430 | 430 | |
| 431 | 431 | wordpoints_alter_points( |
| 432 | 432 | $row->user_id |
@@ -436,14 +436,14 @@ discard block |
||
| 436 | 436 | ); |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - $start += count( $rows ); |
|
| 440 | - $rows = $this->get_next_user_points_batch( $start ); |
|
| 439 | + $start += count($rows); |
|
| 440 | + $rows = $this->get_next_user_points_batch($start); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - remove_filter( 'wordpoints_points_log', '__return_false' ); |
|
| 443 | + remove_filter('wordpoints_points_log', '__return_false'); |
|
| 444 | 444 | |
| 445 | 445 | // translators: Number of users. |
| 446 | - $this->feedback->success( sprintf( __( 'Imported points for %s users…', 'wordpoints-importer' ), $start ) ); |
|
| 446 | + $this->feedback->success(sprintf(__('Imported points for %s users…', 'wordpoints-importer'), $start)); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | * |
| 456 | 456 | * @return object[]|false The rows, or false. |
| 457 | 457 | */ |
| 458 | - protected function get_next_user_points_batch( $start ) { |
|
| 458 | + protected function get_next_user_points_batch($start) { |
|
| 459 | 459 | |
| 460 | 460 | global $wpdb; |
| 461 | 461 | |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | ) |
| 473 | 473 | ); // WPCS: cache OK. |
| 474 | 474 | |
| 475 | - if ( ! is_array( $rows ) ) { |
|
| 475 | + if (!is_array($rows)) { |
|
| 476 | 476 | return false; |
| 477 | 477 | } |
| 478 | 478 | |
@@ -488,11 +488,11 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | public function can_import_points_logs() { |
| 490 | 490 | |
| 491 | - if ( ! $this->is_cubepoints_active() ) { |
|
| 491 | + if (!$this->is_cubepoints_active()) { |
|
| 492 | 492 | |
| 493 | 493 | return new WP_Error( |
| 494 | 494 | 'wordpoints_import_points_logs_cubepoints_inactive' |
| 495 | - , __( 'CubePoints must be active.', 'wordpoints-importer' ) |
|
| 495 | + , __('CubePoints must be active.', 'wordpoints-importer') |
|
| 496 | 496 | ); |
| 497 | 497 | } |
| 498 | 498 | |
@@ -506,16 +506,16 @@ discard block |
||
| 506 | 506 | * |
| 507 | 507 | * @param array $settings The import settings for the points component. |
| 508 | 508 | */ |
| 509 | - protected function import_points_logs( $settings ) { |
|
| 509 | + protected function import_points_logs($settings) { |
|
| 510 | 510 | |
| 511 | - $this->feedback->info( __( 'Importing points logs…', 'wordpoints-importer' ) ); |
|
| 511 | + $this->feedback->info(__('Importing points logs…', 'wordpoints-importer')); |
|
| 512 | 512 | |
| 513 | 513 | $start = 0; |
| 514 | - $logs = $this->get_next_points_logs_batch( $start ); |
|
| 514 | + $logs = $this->get_next_points_logs_batch($start); |
|
| 515 | 515 | |
| 516 | - while ( $logs ) { |
|
| 516 | + while ($logs) { |
|
| 517 | 517 | |
| 518 | - foreach ( $logs as $log ) { |
|
| 518 | + foreach ($logs as $log) { |
|
| 519 | 519 | |
| 520 | 520 | $this->import_points_log( |
| 521 | 521 | $log->uid |
@@ -526,16 +526,16 @@ discard block |
||
| 526 | 526 | 'cubepoints_type' => $log->type, |
| 527 | 527 | 'cubepoints_data' => $log->data, |
| 528 | 528 | ) |
| 529 | - , date( 'Y-m-d H:i:s', $log->timestamp ) |
|
| 529 | + , date('Y-m-d H:i:s', $log->timestamp) |
|
| 530 | 530 | ); |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - $start += count( $logs ); |
|
| 534 | - $logs = $this->get_next_points_logs_batch( $start ); |
|
| 533 | + $start += count($logs); |
|
| 534 | + $logs = $this->get_next_points_logs_batch($start); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | // translators: Number of points logs. |
| 538 | - $this->feedback->success( sprintf( __( 'Imported %s points log entries.', 'wordpoints-importer' ), $start ) ); |
|
| 538 | + $this->feedback->success(sprintf(__('Imported %s points log entries.', 'wordpoints-importer'), $start)); |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | /** |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | * @param array $meta The metadata for this log. |
| 551 | 551 | * @param int $date The date the transaction took place. |
| 552 | 552 | */ |
| 553 | - protected function import_points_log( $user_id, $points, $points_type, $log_type, $meta, $date ) { |
|
| 553 | + protected function import_points_log($user_id, $points, $points_type, $log_type, $meta, $date) { |
|
| 554 | 554 | |
| 555 | 555 | global $wpdb; |
| 556 | 556 | |
@@ -561,54 +561,54 @@ discard block |
||
| 561 | 561 | 'points' => $points, |
| 562 | 562 | 'points_type' => $points_type, |
| 563 | 563 | 'log_type' => $log_type, |
| 564 | - 'text' => $this->render_points_log_text( '', $user_id, $points, $points_type, $log_type, $meta ), |
|
| 564 | + 'text' => $this->render_points_log_text('', $user_id, $points, $points_type, $log_type, $meta), |
|
| 565 | 565 | 'date' => $date, |
| 566 | 566 | 'site_id' => $wpdb->siteid, |
| 567 | 567 | 'blog_id' => $wpdb->blogid, |
| 568 | 568 | ), |
| 569 | - array( '%d', '%d', '%s', '%s', '%s', '%s', '%d', '%d' ) |
|
| 569 | + array('%d', '%d', '%s', '%s', '%s', '%s', '%d', '%d') |
|
| 570 | 570 | ); |
| 571 | 571 | |
| 572 | - if ( false !== $result ) { |
|
| 572 | + if (false !== $result) { |
|
| 573 | 573 | |
| 574 | 574 | $log_id = (int) $wpdb->insert_id; |
| 575 | 575 | |
| 576 | 576 | // Set auto_reversed and original_log_id metadata for reversed logs. |
| 577 | - foreach ( $this->reversible_log_types as $reverse_type => $type ) { |
|
| 577 | + foreach ($this->reversible_log_types as $reverse_type => $type) { |
|
| 578 | 578 | |
| 579 | - if ( $meta['cubepoints_type'] === $type ) { |
|
| 579 | + if ($meta['cubepoints_type'] === $type) { |
|
| 580 | 580 | |
| 581 | 581 | // Save this log ID for later, in case this log was reversed. |
| 582 | 582 | // cubepoints_data will contain the entity ID. |
| 583 | - $this->reversible_log_ids[ $type ][ $meta['cubepoints_data'] ] = $log_id; |
|
| 583 | + $this->reversible_log_ids[$type][$meta['cubepoints_data']] = $log_id; |
|
| 584 | 584 | |
| 585 | 585 | } elseif ( |
| 586 | 586 | $meta['cubepoints_type'] === $reverse_type |
| 587 | - && isset( $this->reversible_log_ids[ $type ][ $meta['cubepoints_data'] ] ) |
|
| 587 | + && isset($this->reversible_log_ids[$type][$meta['cubepoints_data']]) |
|
| 588 | 588 | ) { |
| 589 | 589 | |
| 590 | 590 | // This log was reverses another one. Set the original log ID. |
| 591 | - $meta['original_log_id'] = $this->reversible_log_ids[ $type ][ $meta['cubepoints_data'] ]; |
|
| 591 | + $meta['original_log_id'] = $this->reversible_log_ids[$type][$meta['cubepoints_data']]; |
|
| 592 | 592 | |
| 593 | 593 | // And mark the original as auto_reversed. |
| 594 | - wordpoints_add_points_log_meta( $meta['original_log_id'], 'auto_reversed', $log_id ); |
|
| 594 | + wordpoints_add_points_log_meta($meta['original_log_id'], 'auto_reversed', $log_id); |
|
| 595 | 595 | |
| 596 | 596 | // No need to keep this info anymore. |
| 597 | - unset( $this->reversible_log_ids[ $type ][ $meta['cubepoints_data'] ] ); |
|
| 597 | + unset($this->reversible_log_ids[$type][$meta['cubepoints_data']]); |
|
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | // Set the entity IDs to their own meta keys, for the sake of reversals. |
| 602 | - if ( isset( $this->log_type_entities[ $meta['cubepoints_type'] ] ) ) { |
|
| 603 | - $meta[ $this->log_type_entities[ $meta['cubepoints_type'] ] ] = $meta['cubepoints_data']; |
|
| 602 | + if (isset($this->log_type_entities[$meta['cubepoints_type']])) { |
|
| 603 | + $meta[$this->log_type_entities[$meta['cubepoints_type']]] = $meta['cubepoints_data']; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - foreach ( $meta as $meta_key => $meta_value ) { |
|
| 606 | + foreach ($meta as $meta_key => $meta_value) { |
|
| 607 | 607 | |
| 608 | - wordpoints_add_points_log_meta( $log_id, $meta_key, $meta_value ); |
|
| 608 | + wordpoints_add_points_log_meta($log_id, $meta_key, $meta_value); |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - do_action( 'wordpoints_points_log', $user_id, $points, $points_type, $log_type, $meta, $log_id ); |
|
| 611 | + do_action('wordpoints_points_log', $user_id, $points, $points_type, $log_type, $meta, $log_id); |
|
| 612 | 612 | |
| 613 | 613 | } // End if ( inserted successfully ). |
| 614 | 614 | } |
@@ -618,10 +618,10 @@ discard block |
||
| 618 | 618 | * |
| 619 | 619 | * @since 1.0.0 |
| 620 | 620 | */ |
| 621 | - public function render_points_log_text( $text, $user_id, $points, $points_type, $log_type, $meta ) { |
|
| 621 | + public function render_points_log_text($text, $user_id, $points, $points_type, $log_type, $meta) { |
|
| 622 | 622 | |
| 623 | 623 | ob_start(); |
| 624 | - do_action( 'cp_logs_description', $meta['cubepoints_type'], $user_id, $points, $meta['cubepoints_data'] ); |
|
| 624 | + do_action('cp_logs_description', $meta['cubepoints_type'], $user_id, $points, $meta['cubepoints_data']); |
|
| 625 | 625 | return ob_get_clean(); |
| 626 | 626 | } |
| 627 | 627 | |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | * |
| 635 | 635 | * @return object[]|false The rows from the database. |
| 636 | 636 | */ |
| 637 | - protected function get_next_points_logs_batch( $start ) { |
|
| 637 | + protected function get_next_points_logs_batch($start) { |
|
| 638 | 638 | |
| 639 | 639 | global $wpdb; |
| 640 | 640 | |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | $wpdb->prepare( // WPCS: unprepared SQL OK. |
| 643 | 643 | ' |
| 644 | 644 | SELECT * |
| 645 | - FROM `' . CP_DB . '` |
|
| 645 | + FROM `' . CP_DB.'` |
|
| 646 | 646 | ORDER BY `id` |
| 647 | 647 | LIMIT %d,500 |
| 648 | 648 | ' |
@@ -650,8 +650,8 @@ discard block |
||
| 650 | 650 | ) |
| 651 | 651 | ); // WPCS: cache OK. |
| 652 | 652 | |
| 653 | - if ( ! is_array( $logs ) ) { |
|
| 654 | - $this->feedback->error( __( 'Unable to retrieve the logs from CubePoints…', 'wordpoints-importer' ) ); |
|
| 653 | + if (!is_array($logs)) { |
|
| 654 | + $this->feedback->error(__('Unable to retrieve the logs from CubePoints…', 'wordpoints-importer')); |
|
| 655 | 655 | return false; |
| 656 | 656 | } |
| 657 | 657 | |
@@ -665,24 +665,24 @@ discard block |
||
| 665 | 665 | * |
| 666 | 666 | * @param array $settings The import settings for the ranks component. |
| 667 | 667 | */ |
| 668 | - public function import_ranks( $settings ) { |
|
| 668 | + public function import_ranks($settings) { |
|
| 669 | 669 | |
| 670 | - $this->feedback->info( __( 'Importing ranks…', 'wordpoints-importer' ) ); |
|
| 670 | + $this->feedback->info(__('Importing ranks…', 'wordpoints-importer')); |
|
| 671 | 671 | |
| 672 | - $ranks_data = get_option( 'cp_module_ranks_data' ); |
|
| 672 | + $ranks_data = get_option('cp_module_ranks_data'); |
|
| 673 | 673 | |
| 674 | - if ( empty( $ranks_data ) || ! is_array( $ranks_data ) ) { |
|
| 675 | - $this->feedback->error( __( 'No ranks found.', 'wordpoints-importer' ) ); |
|
| 674 | + if (empty($ranks_data) || !is_array($ranks_data)) { |
|
| 675 | + $this->feedback->error(__('No ranks found.', 'wordpoints-importer')); |
|
| 676 | 676 | return; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | $i = 0; |
| 680 | 680 | |
| 681 | 681 | // The base rank already exists, so we just update it. |
| 682 | - if ( isset( $ranks_data[0] ) ) { |
|
| 682 | + if (isset($ranks_data[0])) { |
|
| 683 | 683 | |
| 684 | 684 | wordpoints_update_rank( |
| 685 | - WordPoints_Rank_Groups::get_group( $settings['rank_group'] )->get_rank( 0 ) |
|
| 685 | + WordPoints_Rank_Groups::get_group($settings['rank_group'])->get_rank(0) |
|
| 686 | 686 | , $ranks_data[0] |
| 687 | 687 | , 'base' |
| 688 | 688 | , $settings['rank_group'] |
@@ -691,29 +691,29 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | $i++; |
| 693 | 693 | |
| 694 | - unset( $ranks_data[0] ); |
|
| 694 | + unset($ranks_data[0]); |
|
| 695 | 695 | } |
| 696 | 696 | |
| 697 | - $points_type = substr( $settings['rank_group'], strlen( 'points_type-' ) ); |
|
| 698 | - $rank_type = 'points-' . $points_type; |
|
| 697 | + $points_type = substr($settings['rank_group'], strlen('points_type-')); |
|
| 698 | + $rank_type = 'points-'.$points_type; |
|
| 699 | 699 | |
| 700 | - ksort( $ranks_data ); |
|
| 700 | + ksort($ranks_data); |
|
| 701 | 701 | |
| 702 | - foreach ( $ranks_data as $points => $rank_name ) { |
|
| 702 | + foreach ($ranks_data as $points => $rank_name) { |
|
| 703 | 703 | |
| 704 | 704 | wordpoints_add_rank( |
| 705 | 705 | $rank_name |
| 706 | 706 | , $rank_type |
| 707 | 707 | , $settings['rank_group'] |
| 708 | 708 | , $i |
| 709 | - , array( 'points' => $points, 'points_type' => $points_type ) |
|
| 709 | + , array('points' => $points, 'points_type' => $points_type) |
|
| 710 | 710 | ); |
| 711 | 711 | |
| 712 | 712 | $i++; |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | // translators: Number of ranks. |
| 716 | - $this->feedback->success( sprintf( __( 'Imported %s ranks.', 'wordpoints-importer' ), $i ) ); |
|
| 716 | + $this->feedback->success(sprintf(__('Imported %s ranks.', 'wordpoints-importer'), $i)); |
|
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @since 1.0.0 |
| 58 | 58 | */ |
| 59 | - do_action( 'wordpoints_register_importers' ); |
|
| 59 | + do_action('wordpoints_register_importers'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public static function get() { |
| 74 | 74 | |
| 75 | - if ( ! self::$initialized ) { |
|
| 75 | + if (!self::$initialized) { |
|
| 76 | 76 | self::init(); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | * @type string $name The name of this importer. |
| 95 | 95 | * } |
| 96 | 96 | */ |
| 97 | - public static function register( $slug, array $args ) { |
|
| 98 | - self::$importers[ $slug ] = $args; |
|
| 97 | + public static function register($slug, array $args) { |
|
| 98 | + self::$importers[$slug] = $args; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @param string $slug The slug of the importer to deregister. |
| 107 | 107 | */ |
| 108 | - public static function deregister( $slug ) { |
|
| 109 | - unset( self::$importers[ $slug ] ); |
|
| 108 | + public static function deregister($slug) { |
|
| 109 | + unset(self::$importers[$slug]); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | * @return bool True if the importer is registered, otherwise false. |
| 120 | 120 | */ |
| 121 | - public static function is_registered( $slug ) { |
|
| 121 | + public static function is_registered($slug) { |
|
| 122 | 122 | |
| 123 | - if ( ! self::$initialized ) { |
|
| 123 | + if (!self::$initialized) { |
|
| 124 | 124 | self::init(); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - return isset( self::$importers[ $slug ] ); |
|
| 127 | + return isset(self::$importers[$slug]); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -136,15 +136,15 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @return WordPoints_Importer|false The importer, or false if it isn't registered. |
| 138 | 138 | */ |
| 139 | - public static function get_importer( $slug ) { |
|
| 139 | + public static function get_importer($slug) { |
|
| 140 | 140 | |
| 141 | - if ( ! self::is_registered( $slug ) ) { |
|
| 141 | + if (!self::is_registered($slug)) { |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $importer = self::$importers[ $slug ]; |
|
| 145 | + $importer = self::$importers[$slug]; |
|
| 146 | 146 | |
| 147 | - return new $importer['class']( $importer['name'] ); |
|
| 147 | + return new $importer['class']($importer['name']); |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | WordPoints_Importers::register( |
| 38 | 38 | 'test' |
| 39 | - , array( 'class' => 'WordPoints_Importer_Mock', 'name' => 'Test' ) |
|
| 39 | + , array('class' => 'WordPoints_Importer_Mock', 'name' => 'Test') |
|
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | 42 | } |
@@ -48,17 +48,17 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $importers = WordPoints_Importers::get(); |
| 50 | 50 | |
| 51 | - foreach ( $this->_backup_importers as $slug => $args ) { |
|
| 51 | + foreach ($this->_backup_importers as $slug => $args) { |
|
| 52 | 52 | |
| 53 | - if ( ! isset( $importers[ $slug ] ) ) { |
|
| 54 | - WordPoints_Importers::register( $slug, $args ); |
|
| 53 | + if (!isset($importers[$slug])) { |
|
| 54 | + WordPoints_Importers::register($slug, $args); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - unset( $importers[ $slug ] ); |
|
| 57 | + unset($importers[$slug]); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - foreach ( $importers as $slug => $args ) { |
|
| 61 | - WordPoints_Importers::deregister( $slug ); |
|
| 60 | + foreach ($importers as $slug => $args) { |
|
| 61 | + WordPoints_Importers::deregister($slug); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | parent::tearDown(); |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | WordPoints_Importers::register( |
| 78 | 78 | __METHOD__ |
| 79 | - , array( 'class' => 'WordPoints_Importer_Mock', 'name' => 'Test' ) |
|
| 79 | + , array('class' => 'WordPoints_Importer_Mock', 'name' => 'Test') |
|
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | $importers = WordPoints_Importers::get(); |
| 83 | 83 | |
| 84 | - $this->assertArrayHasKey( 'test', $importers ); |
|
| 84 | + $this->assertArrayHasKey('test', $importers); |
|
| 85 | 85 | $this->assertSame( |
| 86 | - array( 'class' => 'WordPoints_Importer_Mock', 'name' => 'Test' ) |
|
| 86 | + array('class' => 'WordPoints_Importer_Mock', 'name' => 'Test') |
|
| 87 | 87 | , $importers['test'] |
| 88 | 88 | ); |
| 89 | 89 | } |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function test_deregister() { |
| 100 | 100 | |
| 101 | - WordPoints_Importers::deregister( 'test' ); |
|
| 101 | + WordPoints_Importers::deregister('test'); |
|
| 102 | 102 | |
| 103 | 103 | $importers = WordPoints_Importers::get(); |
| 104 | 104 | |
| 105 | - $this->assertArrayNotHasKey( 'test', $importers ); |
|
| 105 | + $this->assertArrayNotHasKey('test', $importers); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function test_is_registered() { |
| 116 | 116 | |
| 117 | - $this->assertTrue( WordPoints_Importers::is_registered( 'test' ) ); |
|
| 117 | + $this->assertTrue(WordPoints_Importers::is_registered('test')); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function test_is_registered_unregistered() { |
| 128 | 128 | |
| 129 | - WordPoints_Importers::deregister( 'test' ); |
|
| 129 | + WordPoints_Importers::deregister('test'); |
|
| 130 | 130 | |
| 131 | - $this->assertFalse( WordPoints_Importers::is_registered( 'test' ) ); |
|
| 131 | + $this->assertFalse(WordPoints_Importers::is_registered('test')); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function test_get_unregistered_importer() { |
| 142 | 142 | |
| 143 | - WordPoints_Importers::deregister( 'test' ); |
|
| 143 | + WordPoints_Importers::deregister('test'); |
|
| 144 | 144 | |
| 145 | - $this->assertFalse( WordPoints_Importers::get_importer( 'test' ) ); |
|
| 145 | + $this->assertFalse(WordPoints_Importers::get_importer('test')); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | $this->assertInstanceOf( |
| 158 | 158 | 'WordPoints_Importer_Mock' |
| 159 | - , WordPoints_Importers::get_importer( 'test' ) |
|
| 159 | + , WordPoints_Importers::get_importer('test') |
|
| 160 | 160 | ); |
| 161 | 161 | } |
| 162 | 162 | |