Skip to content

Commit

Permalink
lint all the other classes as well sabe for the commons folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ingeniumed committed Jun 26, 2024
1 parent 1a2a6a1 commit b4aff7c
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 36 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
},
"scripts": {
"cs": [
"@php ./vendor/bin/phpcs -p -s -v -n . --standard=\"phpcs.xml.dist\" --extensions=php --ignore=\"/vendor/*,/node_modules/*,/tests/*\""
"@php ./vendor/bin/phpcs -p -s -v -n . --standard=\"phpcs.xml.dist\" --extensions=php --ignore=\"/vendor/*,/node_modules/*,/tests/*,/common/*\""
],
"cbf": [
"@php ./vendor/bin/phpcbf -p -s -v -n . --standard=\"phpcs.xml.dist\" --extensions=php --ignore=\"/vendor/*,/node_modules/*,/tests/*\""
"@php ./vendor/bin/phpcbf -p -s -v -n . --standard=\"phpcs.xml.dist\" --extensions=php --ignore=\"/vendor/*,/node_modules/*,/tests/*,/common/*\""
],
"integration": "wp-env run tests-cli --env-cwd=wp-content/plugins/Edit-Flow ./vendor/bin/phpunit",
"integration-ms": "wp-env run tests-cli --env-cwd=wp-content/plugins/Edit-Flow /bin/bash -c 'WP_MULTISITE=1 ./vendor/bin/phpunit'"
Expand Down
2 changes: 1 addition & 1 deletion edit-flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
*
* Since this is not the primary plugin file, it does not have the standard WordPress headers.
*/
require_once dirname( __FILE__ ) . '/edit_flow.php';
require_once __DIR__ . '/edit_flow.php';
19 changes: 10 additions & 9 deletions edit_flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ private function setup_actions() {
* Inititalizes the Edit Flows!
* Loads options for each registered module and then initializes it if it's active
*/
function action_init() {
public function action_init() {

load_plugin_textdomain( 'edit-flow', null, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
load_plugin_textdomain( 'edit-flow', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );

$this->load_modules();

Expand All @@ -218,7 +218,7 @@ function action_init() {
/**
* Initialize the plugin for the admin
*/
function action_admin_init() {
public function action_admin_init() {

// Upgrade if need be but don't run the upgrade if the plugin has never been used
$previous_version = get_option( $this->options_group . 'version' );
Expand Down Expand Up @@ -315,7 +315,7 @@ public function register_module( $name, $args = array() ) {
* Load all of the module options from the database
* If a given option isn't yet set, then set it to the module's default (upgrades, etc.)
*/
function load_module_options() {
public function load_module_options() {

foreach ( $this->modules as $mod_name => $mod_data ) {

Expand Down Expand Up @@ -343,7 +343,7 @@ function load_module_options() {
*
* @see http://dev.editflow.org/2011/11/17/edit-flow-v0-7-alpha2-notes/#comment-232
*/
function action_init_after() {
public function action_init_after() {
foreach ( $this->modules as $mod_name => $mod_data ) {

if ( isset( $this->modules->$mod_name->options->post_types ) ) {
Expand All @@ -360,7 +360,7 @@ function action_init_after() {
* @param string $key The property to use for searching a module (ex: 'name')
* @param string|int|array $value The value to compare (using ==)
*/
function get_module_by( $key, $value ) {
public function get_module_by( $key, $value ) {
$module = false;
foreach ( $this->modules as $mod_name => $mod_data ) {

Expand All @@ -380,13 +380,13 @@ function get_module_by( $key, $value ) {
/**
* Update the $edit_flow object with new value and save to the database
*/
function update_module_option( $mod_name, $key, $value ) {
public function update_module_option( $mod_name, $key, $value ) {
$this->modules->$mod_name->options->$key = $value;
$this->$mod_name->module = $this->modules->$mod_name;
return update_option( $this->options_group . $mod_name . '_options', $this->modules->$mod_name->options );
}

function update_all_module_options( $mod_name, $new_options ) {
public function update_all_module_options( $mod_name, $new_options ) {
if ( is_array( $new_options ) ) {
$new_options = (object) $new_options;
}
Expand All @@ -398,7 +398,7 @@ function update_all_module_options( $mod_name, $new_options ) {
/**
* Registers commonly used scripts + styles for easy enqueueing
*/
function register_scripts_and_styles() {
public function register_scripts_and_styles() {
wp_enqueue_style( 'ef-admin-css', EDIT_FLOW_URL . 'common/css/edit-flow-admin.css', false, EDIT_FLOW_VERSION, 'all' );

wp_register_script( 'jquery-listfilterizer', EDIT_FLOW_URL . 'common/js/jquery.listfilterizer.js', array( 'jquery' ), EDIT_FLOW_VERSION, true );
Expand All @@ -418,6 +418,7 @@ function register_scripts_and_styles() {
}
}

// phpcs:disable WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
function EditFlow() {
return edit_flow::instance();
}
Expand Down
32 changes: 17 additions & 15 deletions modules/dashboard/widgets/dashboard-notepad.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

class EF_Dashboard_Notepad_Widget {

// phpcs:ignore Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
const notepad_post_type = 'dashboard-note';

public $edit_cap = 'edit_others_posts';

function __construct() {
public function __construct() {
// Silence is golden
}

public function init() {

register_post_type( self::notepad_post_type, array(
'rewrite' => false,
'label' => __( 'Dashboard Note', 'edit-flow' )
)
);
'rewrite' => false,
'label' => __( 'Dashboard Note', 'edit-flow' ),
));

$this->edit_cap = apply_filters( 'ef_dashboard_notepad_edit_cap', $this->edit_cap );

Expand All @@ -41,7 +41,7 @@ public function handle_notepad_update() {
check_admin_referer( 'dashboard-notepad' );

if ( ! current_user_can( $this->edit_cap ) ) {
wp_die( EditFlow()->dashboard->messages['invalid-permissions'] );
wp_die( esc_html( EditFlow()->dashboard->messages['invalid-permissions'] ) );
}

$note_data = array(
Expand All @@ -68,19 +68,22 @@ public function handle_notepad_update() {
public function notepad_widget() {

$args = array(
'posts_per_page' => 1,
'post_status' => 'draft',
'post_type' => self::notepad_post_type,
);
'posts_per_page' => 1,
'post_status' => 'draft',
'post_type' => self::notepad_post_type,
);

$posts = get_posts( $args );
$current_note = ( ! empty( $posts[0]->post_content ) ) ? $posts[0]->post_content : '';
$current_id = ( ! empty( $posts[0]->ID ) ) ? $posts[0]->ID : 0;
$current_post = ( ! empty( $posts[0] ) ) ? $posts[0] : false;

if ( $current_post )
if ( $current_post ) {
// translators: %1$s is the author name, %2$s is the date the note was last updated
$last_updated = '<span id="dashboard-notepad-last-updated">' . sprintf( __( '%1$s last updated on %2$s', 'edit-flow' ), get_user_by( 'id', $current_post->post_author )->display_name, get_the_modified_time( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $current_post ) ) . '</span>';
else
} else {
$last_updated = '';
}

if ( current_user_can( $this->edit_cap ) ) {
echo '<form method="post" id="dashboard-notepad">';
Expand All @@ -90,7 +93,7 @@ public function notepad_widget() {
echo esc_textarea( trim( $current_note ) );
echo '</textarea>';
echo '<p class="submit">';
echo $last_updated;
echo wp_kses_post( $last_updated );
echo '<span id="dashboard-notepad-submit-buttons">';
submit_button( __( 'Update Note', 'edit-flow' ), 'primary', 'update-note', false );
echo '</span>';
Expand All @@ -102,9 +105,8 @@ public function notepad_widget() {
echo '<textarea style="width:100%" rows="10" name="note" disabled="disabled">';
echo esc_textarea( trim( $current_note ) );
echo '</textarea>';
echo $last_updated;
echo wp_kses_post( $last_updated );
echo '</form>';
}
}

}
7 changes: 7 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
<!-- Allow short ternaries -->
<exclude name="WordPress.PHP.DisallowShortTernary.Found" />

<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<exclude name="Universal.Files.SeparateFunctionsFromOO.Mixed" />
<exclude name="PEAR.NamingConventions.ValidClassName.StartWithCapital" />
<exclude name="PEAR.NamingConventions.ValidClassName.Invalid" />

<exclude name="WordPressVIPMinimum.Hooks.AlwaysReturnInFilter.MissingReturnStatement" />

<!-- Generates too many false positives -->
<exclude name="WordPress.WP.CapitalPDangit.Misspelled" />
<!-- We use trigger_error extensively -->
Expand Down
16 changes: 12 additions & 4 deletions vipgo-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@
* them via filters.
*/
add_filter( 'ef_kill_add_caps_to_role', '__return_true' );
add_filter( 'ef_view_calendar_cap', function() {return 'edit_posts'; } );
add_filter( 'ef_view_story_budget_cap', function() { return 'edit_posts'; } );
add_filter( 'ef_edit_post_subscriptions_cap', function() { return 'edit_others_posts'; } );
add_filter( 'ef_manage_usergroups_cap', function() { return 'manage_options'; } );
add_filter( 'ef_view_calendar_cap', function () {
return 'edit_posts';
} );
add_filter( 'ef_view_story_budget_cap', function () {
return 'edit_posts';
} );
add_filter( 'ef_edit_post_subscriptions_cap', function () {
return 'edit_others_posts';
} );
add_filter( 'ef_manage_usergroups_cap', function () {
return 'manage_options';
} );

/**
* Edit Flow loads modules after plugins_loaded, which has already been fired when loading via wpcom_vip_load_plugins
Expand Down
18 changes: 13 additions & 5 deletions wpcom-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@
* them with the WP.com + core caps approach
*/
add_filter( 'ef_kill_add_caps_to_role', '__return_true' );
add_filter( 'ef_view_calendar_cap', function() { return 'edit_posts'; } );
add_filter( 'ef_view_story_budget_cap', function() { return 'edit_posts'; } );
add_filter( 'ef_edit_post_subscriptions_cap', function() { return 'edit_others_posts'; } );
add_filter( 'ef_manage_usergroups_cap', function() { return 'manage_options'; } );
add_filter( 'ef_view_calendar_cap', function () {
return 'edit_posts';
} );
add_filter( 'ef_view_story_budget_cap', function () {
return 'edit_posts';
} );
add_filter( 'ef_edit_post_subscriptions_cap', function () {
return 'edit_others_posts';
} );
add_filter( 'ef_manage_usergroups_cap', function () {
return 'manage_options';
} );

/**
* Edit Flow loads modules after plugins_loaded, which has already been fired on WP.com
Expand Down Expand Up @@ -52,4 +60,4 @@ function edit_flow_fix_fix_post_name( $post ) {
}

return $post;
}
}

0 comments on commit b4aff7c

Please sign in to comment.