-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from WordPoints/develop
Version 1.1.0
- Loading branch information
Showing
11 changed files
with
424 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# L10n Validator Config | ||
|
||
WordPoints-specific configuration for [the WP L10n Validator] | ||
(https://github.com/JDGrimes/wp-l10n-validator). | ||
|
||
## Usage | ||
|
||
Load these ignore rules using the `bootstrap` option in your JSON config file for the | ||
validator: | ||
|
||
```json | ||
{ | ||
... | ||
"bootstrap": "dev-lib/l10n-validator/bootstrap.php" | ||
... | ||
} | ||
``` | ||
|
||
You can set up a basic config for the L10n validator by copying the [example JSON | ||
config file](example-config.json), and changing the `textdomain` to match your project: | ||
|
||
```bash | ||
cp dev-lib/l10n-validator/example-config.json wp-l10n-validator.json | ||
``` | ||
|
||
This will configure the validator with the same rules used for the WordPoints plugin. | ||
This includes ignoring some PHP predefined and WordPress functions that you might not | ||
always want to ignore, depending on your project. To only use the ignore rules for | ||
functions defined by WordPoints itself, use the `wordpoints.php` file instead. | ||
|
||
See here for [more information on the other configuration options] | ||
(https://github.com/JDGrimes/wp-l10n-validator#configuration) for the validator. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/** | ||
* Bootstrap for ignores used by the WordPoints plugin. | ||
* | ||
* @package WordPoints_Dev_Lib\L10n-Validator | ||
* @since 1.1.0 | ||
*/ | ||
|
||
/** | ||
* The ignores for basic stuff like PHP functions. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
include_once( __DIR__ . '/php.php' ); | ||
|
||
/** | ||
* The ignores for WordPress stuff. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
include_once( __DIR__ . '/wordpress.php' ); | ||
|
||
/** | ||
* The ignores for WordPoints stuff. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
include_once( __DIR__ . '/wordpoints.php' ); | ||
|
||
// EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"textdomain": "your-textdomain", | ||
"basedir": "./src", | ||
"bootstrap": "dev-lib/l10n-validator/bootstrap.php", | ||
"cache": "./tools/wp-l10n-validator/cache.json", | ||
"ignores-cache": "./tools/wp-l10n-validator/ignores-cache.json", | ||
"ignores-tolerance": 25 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* Ignores of PHP things. | ||
* | ||
* @package WordPoints_Dev_Lib\L10n-Validator | ||
* @since 1.1.0 | ||
*/ | ||
|
||
WP_L10n_Validator::register_config_callback( function( $parser ) { | ||
|
||
$parser->add_ignored_functions( | ||
array( | ||
// Functions. | ||
'define' => true, | ||
) | ||
); | ||
|
||
$parser->add_ignored_strings( array( 'style="display:none;"' ) ); | ||
}); | ||
|
||
// EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
/** | ||
* Ignores of WordPoints plugin things. | ||
* | ||
* @package WordPoints_Dev_Lib\L10n-Validator | ||
* @since 1.1.0 | ||
*/ | ||
|
||
WP_L10n_Validator::register_config_callback( function( $parser ) { | ||
|
||
$parser->add_ignored_functions( | ||
array( | ||
// Functions. | ||
'wordpoints_add_network_option' => true, | ||
'wordpoints_add_points' => true, | ||
'wordpoints_add_rank' => array( 2, 3, 4 ), | ||
'wordpoints_alter_points' => true, | ||
'wordpoints_debug_message' => true, | ||
'wordpoints_dir_include' => true, | ||
'wordpoints_display_points' => true, | ||
'wordpoints_enqueue_datatables' => array( 1 ), | ||
'wordpoints_format_points' => true, | ||
'wordpoints_get_array_option' => true, | ||
'wordpoints_get_excluded_users' => true, | ||
'wordpoints_get_formatted_points' => true, | ||
'wordpoints_get_formatted_user_rank' => array( 1, 2, 3 ), | ||
'wordpoints_get_points_logs_query' => true, | ||
'wordpoints_get_points_logs_query_args' => true, | ||
'wordpoints_get_points_type_setting' => true, | ||
'wordpoints_list_post_types' => true, | ||
'wordpoints_load_module_textdomain' => true, | ||
'wordpoints_points_show_top_users' => array( 3 ), | ||
'wordpoints_prepare__in' => true, | ||
'wordpoints_register_points_logs_query' => true, | ||
'wordpoints_show_admin_message' => array( 2 ), | ||
'wordpoints_show_points_logs_query' => true, | ||
'wordpoints_subtract_points' => true, | ||
'wordpoints_verify_nonce' => true, | ||
|
||
// Class methods. | ||
'WordPoints_Points_Hook::_set' => true, | ||
'WordPoints_Points_Hook::get_description' => true, | ||
'WordPoints_Points_Hook::get_field_id' => true, | ||
'WordPoints_Points_Hook::get_field_name' => true, | ||
'WordPoints_Points_Hook::get_instances' => true, | ||
'WordPoints_Points_Hook::the_field_id' => true, | ||
'WordPoints_Points_Hook::the_field_name' => true, | ||
'WordPoints_Points_Hooks::get_handler_by_id_base' => true, | ||
'WordPoints_Points_Hooks::register' => true, | ||
'WordPoints_Points_Hooks::points_type_form' => true, | ||
'WordPoints_Points_Log_Queries::get_query_data' => true, | ||
'WordPoints_Points_Log_Queries::register_query' => true, | ||
'WordPoints_Points_Logs_Query::__construct' => true, | ||
'WordPoints_Points_Logs_Query::_cache_get' => true, | ||
'WordPoints_Points_Logs_Query::_cache_set' => true, | ||
'WordPoints_Points_Logs_Query::_get' => true, | ||
'WordPoints_Points_Logs_Query::_prepare__in' => true, | ||
'WordPoints_Points_Logs_Query::_prepare_posint__in' => true, | ||
'WordPoints_Points_Logs_Query::get' => true, | ||
'WordPoints_Points_Logs_Query::prime_cache' => true, | ||
'WordPoints_Rank_Groups::register_type_for_group' => true, | ||
'WordPoints_Rank_Types::register_type' => array( 1, 2 ), | ||
'WordPoints_Ranks_Admin_Screen_Ajax::_send_json_result' => true, | ||
'WordPoints_Ranks_Admin_Screen_Ajax::_unexpected_error' => true, | ||
'WordPoints_Ranks_Admin_Screen_Ajax::_verify_request' => true, | ||
'WordPoints_Points_Un_Installer::_1_4_0_split_points_hooks' => true, | ||
'WordPoints_Points_Widget::__construct' => array( 1 ), | ||
'WordPoints_Points_Widget::get_field_id' => true, | ||
'WordPoints_Points_Widget::get_field_name' => true, | ||
'WordPoints_Shortcodes::register' => true, | ||
'WordPoints_Un_Installer_Base::update_' => true, | ||
'WordPoints_Un_Installer_Base::get_updates_for' => true, | ||
'WordPoints_Un_Installer_Base::set_component_version' => true, | ||
|
||
// Instance methods. | ||
'$hook->get_description' => true, | ||
'$hook->get_option' => true, | ||
'$wordpoints_components->activate' => true, | ||
) | ||
); | ||
|
||
$parser->add_ignored_strings( array( '%points%' ) ); | ||
}); | ||
|
||
// EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/** | ||
* Ignores of WordPress things. | ||
* | ||
* @package WordPoints_Dev_Lib\L10n-Validator | ||
* @since 1.1.0 | ||
*/ | ||
|
||
WP_L10n_Validator::register_config_callback( function( $parser ) { | ||
|
||
$parser->add_ignored_functions( | ||
array( | ||
// Functions. | ||
'_deprecated_argument' => true, | ||
'_deprecated_file' => true, | ||
'_doing_it_wrong' => true, | ||
'add_site_option' => true, | ||
) | ||
); | ||
|
||
$parser->add_ignored_strings( | ||
array( | ||
'admin.php', | ||
'widefat', | ||
) | ||
); | ||
}); | ||
|
||
// EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
/** | ||
* Functions used by the PHPUnit bootstrap. | ||
* | ||
* @package WordPoints_Dev_Lib\PHPUnit | ||
* @since 1.1.0 | ||
*/ | ||
|
||
/** | ||
* Locate the main file for a module. | ||
* | ||
* @since 1.1.0 | ||
* | ||
* @param string $module_folder The full path to the module's folder. | ||
* | ||
* @return array A list of the module files found (files with module headers), | ||
* indexed by the file names. | ||
*/ | ||
function wordpoints_dev_lib_get_modules( $module_folder = '' ) { | ||
|
||
$modules = array(); | ||
|
||
// Escape pattern-matching characters in the path. | ||
$module_escape_path = str_replace( | ||
array( '*', '?', '[' ) | ||
, array( '[*]', '[?]', '[[]' ) | ||
, $module_folder | ||
); | ||
|
||
$module_files = glob( "{$module_escape_path}/*.php" ); | ||
|
||
if ( false === $module_files ) { | ||
return $modules; | ||
} | ||
|
||
foreach ( $module_files as $module_file ) { | ||
|
||
if ( ! is_readable( $module_file ) ) { | ||
continue; | ||
} | ||
|
||
$module_data = wordpoints_get_module_data( $module_file, false, false ); | ||
|
||
if ( empty( $module_data['name'] ) ) { | ||
continue; | ||
} | ||
|
||
$modules[ basename( $module_file ) ] = $module_data; | ||
} | ||
|
||
uasort( $modules, '_wordpoints_sort_uname_callback' ); | ||
|
||
return $modules; | ||
} | ||
|
||
/** | ||
* Load and activate a module. | ||
* | ||
* @since 1.1.0 | ||
* | ||
* @param string $module_file The main file of the module to load. | ||
*/ | ||
function wordpoints_dev_lib_load_module( $module_file ) { | ||
|
||
WordPoints_Module_Paths::register( $module_file ); | ||
|
||
require( $module_file ); | ||
|
||
$module = wordpoints_module_basename( $module_file ); | ||
$network_wide = is_multisite() && getenv( 'WORDPOINTS_NETWORK_ACTIVE' ); | ||
|
||
/** | ||
* @since 1.1.0 | ||
*/ | ||
do_action( "wordpoints_module_activate-{$module}", $network_wide ); | ||
} | ||
|
||
/** | ||
* Load and activate the module being tested. | ||
* | ||
* @since 1.1.0 | ||
*/ | ||
function wordpoints_dev_lib_load_the_module() { | ||
|
||
$src = WORDPOINTS_MODULE_TESTS_DIR . '/../../src'; | ||
|
||
// Find the module file. | ||
$modules = wordpoints_dev_lib_get_modules( $src ); | ||
|
||
wordpoints_dev_lib_load_module( $src . '/' . key( $modules ) ); | ||
|
||
// Load the module's admin-side code too, if asked. | ||
if ( defined( 'WORDPOINTS_TESTS_LOAD_MODULE_ADMIN' ) ) { | ||
require( WORDPOINTS_TESTS_LOAD_MODULE_ADMIN ); | ||
} | ||
} | ||
|
||
// EOF |
Oops, something went wrong.