Skip to content

Commit

Permalink
Merge branch 'add/lint-modules' into add/workflow-configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
alecgeatches committed Jun 27, 2024
2 parents 873097a + b8e68c1 commit 773231d
Show file tree
Hide file tree
Showing 18 changed files with 6,578 additions and 6,139 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/php-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ jobs:
env:
WP_ENV_CORE: WordPress/WordPress#${{ matrix.wp }}

- name: Run PHPCS diff tests
run: bash bin/phpcs-diff.sh
# Commented out until we finish linting all the files
# - name: Run PHPCS diff tests
# run: bash bin/phpcs-diff.sh

- name: Run PHPUnit tests (single site)
run: composer integration
Expand Down
16 changes: 12 additions & 4 deletions common/php/class-module.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,20 @@ protected function is_analytics_enabled() {
* Check if the site is a WPVIP site.
*
* @since 0.10.0
*
* @param bool $only_production Whether to only allow production sites to be considered WPVIP sites
* @return true, if it is a WPVIP site, false otherwise
*/
protected function is_vip_site() {
return defined( 'WPCOM_IS_VIP_ENV' ) && constant( 'WPCOM_IS_VIP_ENV' ) === true
&& defined( 'WPCOM_SANDBOXED' ) && constant( 'WPCOM_SANDBOXED' ) === false
&& defined( 'FILES_CLIENT_SITE_ID' );
protected function is_vip_site( $only_production = false ) {
$is_vip_site = defined( 'VIP_GO_ENV' )
&& defined( 'WPCOM_SANDBOXED' ) && constant( 'WPCOM_SANDBOXED' ) === false
&& defined( 'FILES_CLIENT_SITE_ID' );

if ( $only_production ) {
$is_vip_site = $is_vip_site && defined( 'VIP_GO_ENV' ) && 'production' === constant( 'VIP_GO_ENV' );
}

return $is_vip_site;
}

/**
Expand Down
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=\"WordPress-VIP-Go\" --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=\"WordPress-VIP-Go\" --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
Loading

0 comments on commit 773231d

Please sign in to comment.