Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 41 additions & 43 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,56 @@
module.exports = function( grunt ) {
if ( ! grunt.option( 'wp' ) ) {
grunt.option( 'wp', 'master' );
}

grunt.initConfig({
connect: {
server: {
options: {
base: '.'
}
}
},
qunit: {
'use strict';

// Project configuration
grunt.initConfig( {

pkg: grunt.file.readJSON( 'package.json' ),

addtextdomain: {
options: {
timeout: 7000
},
latest: {
options: {
urls: ['http://localhost:8000/tests/js/index.html']
}
textdomain: 'fieldmanager',
},
recent: {
update_all_domains: {
options: {
urls: [
'http://localhost:8000/tests/js/index.html',
'http://localhost:8000/tests/js/index.html?wp=4.9',
'http://localhost:8000/tests/js/index.html?wp=4.8'
]
updateDomains: true
},
src: [ '*.php', '**/*.php', '!\.git/**/*', '!bin/**/*', '!node_modules/**/*', '!tests/**/*' ]
}
},

wp_readme_to_markdown: {
your_target: {
files: {
'README.md': 'readme.txt'
}
},
specific: {
},

makepot: {
target: {
options: {
urls: [ 'http://localhost:8000/tests/js/index.html?wp=' + grunt.option( 'wp' ) ]
domainPath: '/languages',
exclude: [ '\.git/*', 'bin/*', 'node_modules/*', 'tests/*' ],
mainFile: 'fieldmanager.php',
potFilename: 'fieldmanager.pot',
potHeaders: {
poedit: true,
'x-poedit-keywordslist': true
},
type: 'wp-plugin',
updateTimestamp: true
}
}
},
phpcs: {
plugin: {},
options: {
bin: "vendor/bin/phpcs",
showSniffCodes: true,
standard: "phpcs.ruleset.xml",
verbose: true,
warningSeverity: 0,
}
},
});

} );

grunt.loadNpmTasks( 'grunt-contrib-connect' );
grunt.loadNpmTasks( 'grunt-contrib-qunit' );
grunt.loadNpmTasks( 'grunt-phpcs' );
grunt.loadNpmTasks( 'grunt-wp-i18n' );
grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' );
grunt.registerTask( 'default', [ 'i18n','readme' ] );
grunt.registerTask( 'i18n', ['addtextdomain', 'makepot'] );
grunt.registerTask( 'readme', ['wp_readme_to_markdown'] );

grunt.task.run( 'connect' );
grunt.util.linefeed = '\n';

grunt.registerTask( 'default', ['qunit:latest'] );
};
16 changes: 14 additions & 2 deletions fieldmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Author: Alley
Version: 1.3.0
Author URI: https://www.alley.co/
Text Domain: fieldmanager
Domain Path: /languages
*/

/**
Expand Down Expand Up @@ -139,6 +141,16 @@ function fieldmanager_get_template( $tpl_slug ) {
return plugin_dir_path( __FILE__ ) . 'templates/' . $tpl_slug . '.php';
}

/**
* Load Fieldmanager's translated strings.
*
* @return bool @see load_plugin_textdomain().
*/
function fm_load_textdomain() {
return load_plugin_textdomain( 'fieldmanager', false, plugin_basename( FM_BASE_DIR ) . '/languages/' );
}
add_action( 'init', 'fm_load_textdomain' );

/**
* Enqueue a script, optionally localizing data to it.
*
Expand Down Expand Up @@ -473,7 +485,7 @@ function fm_register_submenu_page( $group_name, $parent_slug, $page_title, $menu
}
if ( isset( $submenus[ $group_name ] ) ) {
/* translators: %s: group name */
throw new FM_Duplicate_Submenu_Name_Exception( sprintf( esc_html__( '%s is already in use as a submenu name', 'fieldmanager' ), $group_name ) );
throw new FM_Duplicate_Submenu_Name_Exception( sprintf( esc_html__( '%s is already in use as a submenu name.', 'fieldmanager' ), $group_name ) );
}

if ( ! $menu_title ) {
Expand Down Expand Up @@ -501,7 +513,7 @@ function fm_register_submenu_page( $group_name, $parent_slug, $page_title, $menu
function _fm_submenu_render() {
$context = _fieldmanager_registry( 'active_submenu' );
if ( ! is_object( $context ) ) {
throw new FM_Submenu_Not_Initialized_Exception( esc_html__( 'The Fieldmanger context for this submenu was not initialized', 'fieldmanager' ) );
throw new FM_Submenu_Not_Initialized_Exception( esc_html__( 'The Fieldmanger context for this submenu was not initialized.', 'fieldmanager' ) );
}
$context->render_submenu_page();
}
Expand Down
Loading