Skip to content

Commit

Permalink
Fixes some coding standards (#3)
Browse files Browse the repository at this point in the history
* Fixes some coding standards

* Fixes some WordPress Coding Standards
  • Loading branch information
thejimbirch authored and michaelpporter committed Jan 12, 2018
1 parent a813842 commit 8a1fadc
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 205 deletions.
68 changes: 35 additions & 33 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,54 @@ module.exports = function( grunt ) {
'use strict';
var banner = '/**\n * <%= pkg.homepage %>\n * Copyright (c) <%= grunt.template.today("yyyy") %>\n * This file is generated automatically. Do not edit.\n */\n';
// Project configuration
grunt.initConfig( {
grunt.initConfig(
{

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

addtextdomain: {
options: {
textdomain: 'xdb',
},
target: {
files: {
src: [ '*.php', '**/*.php', '!node_modules/**', '!php-tests/**', '!bin/**' ]
addtextdomain: {
options: {
textdomain: 'xdb',
},
target: {
files: {
src: [ '*.php', '**/*.php', '!node_modules/**', '!php-tests/**', '!bin/**' ]
}
}
}
},
},

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

makepot: {
target: {
options: {
domainPath: '/languages',
mainFile: 'dashboard-connector-wp.php',
potFilename: 'dashboard-connector-wp.pot',
potHeaders: {
poedit: true,
'x-poedit-keywordslist': true
},
type: 'wp-plugin',
updateTimestamp: true
makepot: {
target: {
options: {
domainPath: '/languages',
mainFile: 'dashboard-connector-wp.php',
potFilename: 'dashboard-connector-wp.pot',
potHeaders: {
poedit: true,
'x-poedit-keywordslist': true
},
type: 'wp-plugin',
updateTimestamp: true
}
}
}
},
} );
},
}
);

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

grunt.registerTask('default', ['makepot','wp_readme_to_markdown','addtextdomain']);
grunt.registerTask( 'default', ['makepot','wp_readme_to_markdown','addtextdomain'] );
grunt.util.linefeed = '\n';

};
10 changes: 7 additions & 3 deletions dashboard-connector-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ function xdb_get_settings( $setting, $denifed ) {
* Enviroment indicator.
*/
function xdb_env_indicator() {
$colors = array( 'dev'=>'#aa3333','test'=>'#ceaf01','prod'=>'rgb(0, 0, 187)' );
$env = xdb_get_settings( $setting = 'r_env', $defined = 'XDB_ENV');
$colors = array(
'dev' => '#aa3333',
'test' => '#ceaf01',
'prod' => 'rgb(0, 0, 187)',
);
$env = xdb_get_settings( $setting = 'r_env', $defined = 'XDB_ENV' );
?>
<style>
#wpadminbar{background: <?php echo isset( $colors[$env] ) ? $colors[$env] : 'black' ;?>}
#wpadminbar{background: <?php echo isset( $colors[ $env ] ) ? $colors[ $env ] : 'black'; ?>}
</style>
<?php
}
Expand Down
14 changes: 7 additions & 7 deletions includes/CheckerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*/
interface CheckerInterface {

/**
* Gets the checks.
*
* @return array
* An array of checks.
*/
public function getChecks();
/**
* Gets the checks.
*
* @return array
* An array of checks.
*/
public function getChecks();
}

70 changes: 37 additions & 33 deletions includes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
function create_Dashboard_Connector_WP_Admin() {
if ( is_admin() ) {
new Dashboard_Connector_WP_Admin;
new Dashboard_Connector_WP_Admin();
}
}

Expand Down Expand Up @@ -104,7 +104,6 @@ public function deactivation() {
* @return void
*
* @access public
*
*/
public function load_textdomain() {
load_plugin_textdomain( 'xdb', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
Expand All @@ -120,10 +119,12 @@ public function load_textdomain() {
* @access public
*/
public function xdb_add_admin_menu() {
add_options_page( __( 'Dashboard Connector WP', 'xdb' ), __( 'Dashboard Connector WP', 'xdb' ), $this->capability, $this->slug, array(
$this,
'xdb_options_page'
) );
add_options_page(
__( 'Dashboard Connector WP', 'xdb' ), __( 'Dashboard Connector WP', 'xdb' ), $this->capability, $this->slug, array(
$this,
'xdb_options_page',
)
);
}

/**
Expand All @@ -140,22 +141,25 @@ public function xdb_options_init() {

add_settings_section( 'xdb_options_section', '', '', $this->group );

add_settings_field( 'xdb_rest', __( 'Dashboard Connector WP', 'xdb' ), array(
$this,
'xdb_rest_render'
), $this->group, 'xdb_options_section'
add_settings_field(
'xdb_rest', __( 'Dashboard Connector WP', 'xdb' ), array(
$this,
'xdb_rest_render',
), $this->group, 'xdb_options_section'
);

add_settings_field( 'xdb_slack', __( 'Slack', 'xdb' ), array(
$this,
'xdb_slack_render'
), $this->group, 'xdb_options_section'
add_settings_field(
'xdb_slack', __( 'Slack', 'xdb' ), array(
$this,
'xdb_slack_render',
), $this->group, 'xdb_options_section'
);

add_settings_field( 'xdb_jira', __( 'Jira', 'xdb' ), array(
$this,
'xdb_jira_render'
), $this->group, 'xdb_options_section'
add_settings_field(
'xdb_jira', __( 'Jira', 'xdb' ), array(
$this,
'xdb_jira_render',
), $this->group, 'xdb_options_section'
);
}

Expand Down Expand Up @@ -184,10 +188,10 @@ public function xdb_rest_render() {
foreach ( $setting_options as $list => $o ) {
$opt = empty( $options[ $o ] ) ? '' : $options[ $o ];
?>
<label><?php echo ltrim( $o, 'r_' ); ?>: </label>
<input type="<?php echo ( 'r_env' == $o || 'r_client_id' == $o || 'r_site_id' == $o ) ? 'text' : 'password'; ?>"
name='xdb_options[<?php echo $o; ?>]' value="<?php echo esc_attr( $opt, null ); ?>">
<br/>
<label><?php echo ltrim( $o, 'r_' ); ?>: </label>
<input type="<?php echo ( 'r_env' == $o || 'r_client_id' == $o || 'r_site_id' == $o ) ? 'text' : 'password'; ?>"
name='xdb_options[<?php echo $o; ?>]' value="<?php echo esc_attr( $opt, null ); ?>">
<br/>
<?php
}
}
Expand Down Expand Up @@ -217,10 +221,10 @@ public function xdb_jira_render() {
foreach ( $setting_options as $list => $o ) {
$opt = empty( $options[ $o ] ) ? '' : $options[ $o ];
?>
<label><?php echo ltrim( $o, 'j_' ); ?>: </label>
<input type="<?php echo ( 'j_trans' == $o || 'j_labels' == $o || 'j_assign' == $o || 'j_proj' == $o ) ? 'text' : 'password'; ?>"
name='xdb_options[<?php echo $o; ?>]' value="<?php echo esc_attr( $opt, null ); ?>">
<br/>
<label><?php echo ltrim( $o, 'j_' ); ?>: </label>
<input type="<?php echo ( 'j_trans' == $o || 'j_labels' == $o || 'j_assign' == $o || 'j_proj' == $o ) ? 'text' : 'password'; ?>"
name='xdb_options[<?php echo $o; ?>]' value="<?php echo esc_attr( $opt, null ); ?>">
<br/>
<?php
}
}
Expand All @@ -247,10 +251,10 @@ public function xdb_slack_render() {
foreach ( $setting_options as $list => $o ) {
$opt = empty( $options[ $o ] ) ? '' : $options[ $o ];
?>
<label><?php echo ltrim( $o, 's_' ); ?>: </label>
<input type="<?php echo ( 's_channels' == $o || 's_notify' == $o ) ? 'text' : 'password'; ?>"
name='xdb_options[<?php echo $o; ?>]' value="<?php echo esc_attr( $opt, null ); ?>">
<br/>
<label><?php echo ltrim( $o, 's_' ); ?>: </label>
<input type="<?php echo ( 's_channels' == $o || 's_notify' == $o ) ? 'text' : 'password'; ?>"
name='xdb_options[<?php echo $o; ?>]' value="<?php echo esc_attr( $opt, null ); ?>">
<br/>
<?php
}
}
Expand Down Expand Up @@ -326,15 +330,15 @@ public function sanitize_settings( $args ) {
*/
public function xdb_options_page() {
?>
<form action='options.php' method='post'>
<h2><?php echo __( 'Dashboard Connector WP', 'xdb' ); ?></h2>
<form action='options.php' method='post'>
<h2><?php echo __( 'Dashboard Connector WP', 'xdb' ); ?></h2>
<?php
wp_nonce_field( '_xdb_nonce', '_xdb_nonce' );
settings_fields( $this->group );
do_settings_sections( $this->group );
submit_button();
?>
</form>
</form>
<?php
}
}
Expand Down
25 changes: 13 additions & 12 deletions includes/jira.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ class Dashboard_Connector_WP_Jira {

/**
* Holds Jira settions.
*
* @access private
* @since 1.0.0
*/
private $settings;

/**
* Holds Jira task description.
*
* @access private
* @since 1.0.0
*/
Expand Down Expand Up @@ -120,7 +122,7 @@ private function get_description() {
$this->description = '';
foreach ( $site_data as $data => $d ) {

if ( false !== strpos( strtolower( $d['description'] ), "up to date" ) ) {
if ( false !== strpos( strtolower( $d['description'] ), 'up to date' ) ) {
unset( $d );
} else {
// Mix field with defaults.
Expand All @@ -136,7 +138,6 @@ private function get_description() {
$vulnerable = true;
}
}

}

return $vulnerable;
Expand All @@ -155,7 +156,8 @@ private function clean_transiten( $string ) {
str_replace(
array( "\r\n", "\n", "\r", "\t", 'plugin', 'theme', 'core' ),
'',
$string )
$string
)
),
'rl'
);
Expand Down Expand Up @@ -219,15 +221,14 @@ public function open_task() {
$url = $server . 'rest/api/latest/issue';
$response = $this->curl( $url, json_encode( $data ) );

// if ( false !== $response ) {
// $jira_id = json_decode( $response );
// if ( isset( $jira_id->key ) ) {
// $data = '{"update": {"comment": [{"add": {"body": "Starts progress automatically"}}]},"transition": {"id": "' . $this->settings['progress_transition_id'] . '"}}';
// $url = $server . 'rest/api/latest/issue/' . $jira_id->key . '/transitions?expand=transitions.fields';
// $jira_id = $this->curl( $url, $data );
// }
// }

// if ( false !== $response ) {
// $jira_id = json_decode( $response );
// if ( isset( $jira_id->key ) ) {
// $data = '{"update": {"comment": [{"add": {"body": "Starts progress automatically"}}]},"transition": {"id": "' . $this->settings['progress_transition_id'] . '"}}';
// $url = $server . 'rest/api/latest/issue/' . $jira_id->key . '/transitions?expand=transitions.fields';
// $jira_id = $this->curl( $url, $data );
// }
// }
// Generates new transitent.
$transiten = $this->clean_transiten( $this->description );

Expand Down
Loading

0 comments on commit 8a1fadc

Please sign in to comment.