Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add naming convention rule #70

Merged
merged 2 commits into from
Apr 5, 2024
Merged
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
10 changes: 5 additions & 5 deletions admin/class-openedx-commerce-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
* @since 1.0.0
*/

namespace OpenedXCommerce\admin;
namespace OpenedX_Commerce\admin;

use OpenedXCommerce\model\Openedx_Commerce_Enrollment;
use OpenedXCommerce\model\Openedx_Commerce_Post_Type;
use OpenedXCommerce\admin\views\Openedx_Commerce_Enrollment_Info_Form;
use OpenedXCommerce\utils;
use OpenedX_Commerce\model\Openedx_Commerce_Enrollment;
use OpenedX_Commerce\model\Openedx_Commerce_Post_Type;
use OpenedX_Commerce\admin\views\Openedx_Commerce_Enrollment_Info_Form;
use OpenedX_Commerce\utils;


/**
Expand Down
6 changes: 3 additions & 3 deletions admin/views/class-openedx-commerce-enrollment-info-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
* @since 1.0.0
*/

namespace OpenedXCommerce\admin\views;
namespace OpenedX_Commerce\admin\views;

use OpenedXCommerce\model\Openedx_Commerce_Log;
use OpenedXCommerce\utils;
use OpenedX_Commerce\model\Openedx_Commerce_Log;
use OpenedX_Commerce\utils;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand Down
4 changes: 2 additions & 2 deletions admin/views/class-openedx-commerce-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* @since 1.6.0
*/

namespace OpenedXCommerce\admin\views;
namespace OpenedX_Commerce\admin\views;

use OpenedXCommerce\model\Openedx_Commerce_Api_Calls;
use OpenedX_Commerce\model\Openedx_Commerce_Api_Calls;
use DateTime;
use DateInterval;

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"test/"
],
"psr-4": {
"OpenedXCommerce\\": "includes/",
"OpenedXCommerce\\model\\": "includes/model/",
"OpenedXCommerce\\admin\\": "admin/",
"OpenedXCommerce\\admin\\views\\": "admin/views/",
"OpenedXCommerce\\public\\": "public/",
"OpenedXCommerce\\utils\\": "utils/",
"OpenedXCommerce\\tests\\": "test/"
"OpenedX_Commerce\\": "includes/",
"OpenedX_Commerce\\model\\": "includes/model/",
"OpenedX_Commerce\\admin\\": "admin/",
"OpenedX_Commerce\\admin\\views\\": "admin/views/",
"OpenedX_Commerce\\public\\": "public/",
"OpenedX_Commerce\\utils\\": "utils/",
"OpenedX_Commerce\\tests\\": "test/"
}
},
"require": {
Expand Down
2 changes: 1 addition & 1 deletion includes/class-openedx-commerce-activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @subpackage Openedx_Commerce/includes
*/

namespace OpenedXCommerce;
namespace OpenedX_Commerce;

/**
* Fired during plugin activation.
Expand Down
2 changes: 1 addition & 1 deletion includes/class-openedx-commerce-deactivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @subpackage Openedx_Commerce/includes
*/

namespace OpenedXCommerce;
namespace OpenedX_Commerce;

/**
* Fired during plugin deactivation.
Expand Down
2 changes: 1 addition & 1 deletion includes/class-openedx-commerce-i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @subpackage Openedx_Commerce/includes
*/

namespace OpenedXCommerce;
namespace OpenedX_Commerce;

/**
* Define the internationalization functionality.
Expand Down
2 changes: 1 addition & 1 deletion includes/class-openedx-commerce-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @subpackage Openedx_Commerce/includes
*/

namespace OpenedXCommerce;
namespace OpenedX_Commerce;

/**
* Register all actions and filters for the plugin.
Expand Down
10 changes: 5 additions & 5 deletions includes/class-openedx-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* @author eduNEXT <[email protected]>
*/

namespace OpenedXCommerce;
namespace OpenedX_Commerce;

use OpenedXCommerce\admin\Openedx_Commerce_Admin;
use OpenedXCommerce\public\Openedx_Commerce_Public;
use OpenedXCommerce\admin\views\Openedx_Commerce_Settings;
use OpenedXCommerce\model\Openedx_Commerce_Enrollment;
use OpenedX_Commerce\admin\Openedx_Commerce_Admin;
use OpenedX_Commerce\public\Openedx_Commerce_Public;
use OpenedX_Commerce\admin\views\Openedx_Commerce_Settings;
use OpenedX_Commerce\model\Openedx_Commerce_Enrollment;

/**
* This class contains the function to register a new custom post type.
Expand Down
2 changes: 1 addition & 1 deletion includes/model/class-openedx-commerce-api-calls.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @since 1.6.0
*/

namespace OpenedXCommerce\model;
namespace OpenedX_Commerce\model;

require_once plugin_dir_path( dirname( __DIR__ ) ) . 'vendor/autoload.php';
use DateTime;
Expand Down
10 changes: 5 additions & 5 deletions includes/model/class-openedx-commerce-enrollment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* @since 1.0.0
*/

namespace OpenedXCommerce\model;
namespace OpenedX_Commerce\model;

use OpenedXCommerce\model\Openedx_Commerce_Log;
use OpenedXCommerce\Openedx_Commerce;
use OpenedXCommerce\admin\Openedx_Commerce_Admin;
use OpenedXCommerce\model\Openedx_Commerce_Api_Calls;
use OpenedX_Commerce\model\Openedx_Commerce_Log;
use OpenedX_Commerce\Openedx_Commerce;
use OpenedX_Commerce\admin\Openedx_Commerce_Admin;
use OpenedX_Commerce\model\Openedx_Commerce_Api_Calls;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand Down
2 changes: 1 addition & 1 deletion includes/model/class-openedx-commerce-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @since 1.4.0
*/

namespace OpenedXCommerce\model;
namespace OpenedX_Commerce\model;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand Down
6 changes: 3 additions & 3 deletions includes/model/class-openedx-commerce-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 1.0.0
*/

namespace OpenedXCommerce\model;
namespace OpenedX_Commerce\model;

if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand Down Expand Up @@ -124,7 +124,7 @@ public function register_post_type() {
);

$args = array(
'labels' => apply_filters( $this->post_type . '_labels', $labels ),
'labels' => apply_filters( "openedx_commerce_{$this->post_type}_labels", $labels ),
'description' => $this->description,
'public' => true,
'publicly_queryable' => true,
Expand All @@ -148,6 +148,6 @@ public function register_post_type() {

$args = array_merge( $args, $this->options );

register_post_type( $this->post_type, apply_filters( $this->post_type . '_register_args', $args, $this->post_type ) );
register_post_type( $this->post_type, apply_filters( "openedx_commerce_{$this->post_type}_register_args", $args, $this->post_type ) );
}
}
24 changes: 12 additions & 12 deletions openedx-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
* Requires at least: 6.3
* Requires PHP: 8.0
*
* @package Openedx_Commerce
* @package OpenedX_Commerce
*
* @wordpress-plugin
*/

use OpenedXCommerce\Openedx_Commerce_Activator;
use OpenedXCommerce\Openedx_Commerce_Deactivator;
use OpenedXCommerce\Openedx_Commerce;
use OpenedX_Commerce\Openedx_Commerce_Activator;
use OpenedX_Commerce\Openedx_Commerce_Deactivator;
use OpenedX_Commerce\Openedx_Commerce;

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
Expand All @@ -38,7 +38,7 @@
* The code that runs during plugin activation.
* This action is documented in includes/class-openedx-commerce-activator.php
*/
function activate_openedx_commerce_plugin() {
function openedx_commerce_plugin_activate() {
include_once plugin_dir_path( __FILE__ ) . 'includes/class-openedx-commerce-activator.php';
Openedx_Commerce_Activator::activate();
}
Expand All @@ -47,15 +47,15 @@ function activate_openedx_commerce_plugin() {
* The code that runs during plugin deactivation.
* This action is documented in includes/class-openedx-commerce-deactivator.php
*/
function deactivate_openedx_commerce_plugin() {
function openedx_commerce_plugin_deactivate() {
include_once plugin_dir_path( __FILE__ ) . 'includes/class-openedx-commerce-deactivator.php';
Openedx_Commerce_Deactivator::deactivate();
}

/**
* Create the table for the logs on plugin activation
*/
function create_enrollment_logs_table() {
function openedx_commerce_create_enrollment_logs_table() {
global $wpdb;
$logs_table = wp_cache_get( 'enrollment_logs_req_table', 'db' );
$logs_table_name = $wpdb->prefix . 'enrollment_logs_req_table';
Expand Down Expand Up @@ -85,9 +85,9 @@ function create_enrollment_logs_table() {
}
}

register_activation_hook( __FILE__, 'activate_openedx_commerce_plugin' );
register_activation_hook( __FILE__, 'create_enrollment_logs_table' );
register_deactivation_hook( __FILE__, 'deactivate_openedx_commerce_plugin' );
register_activation_hook( __FILE__, 'openedx_commerce_plugin_activate' );
register_activation_hook( __FILE__, 'openedx_commerce_create_enrollment_logs_table' );
register_deactivation_hook( __FILE__, 'openedx_commerce_plugin_deactivate' );

/**
* The core plugin class that is used to define internationalization,
Expand All @@ -104,9 +104,9 @@ function create_enrollment_logs_table() {
*
* @since 1.0.0
*/
function run_openedx_commerce_plugin() {
function openedx_commerce_plugin_run() {

$plugin = new Openedx_Commerce();
$plugin->run();
}
run_openedx_commerce_plugin();
openedx_commerce_plugin_run();
5 changes: 5 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

<rule ref="WordPress">
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array" value="openedx_commerce" />
</properties>
</rule>

<rule ref="WordPress.WP.I18n">
<properties>
Expand Down
2 changes: 1 addition & 1 deletion public/class-openedx-commerce-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @subpackage Openedx_Commerce/public
*/

namespace OpenedXCommerce\public;
namespace OpenedX_Commerce\public;

/**
* The public-facing functionality of the plugin.
Expand Down
8 changes: 4 additions & 4 deletions test/class-enrollment-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* @subpackage openedx-commerce/tests
*/

namespace OpenedXCommerce\tests;
namespace OpenedX_Commerce\tests;

use OpenedXCommerce\model\Openedx_Commerce_Enrollment;
use OpenedXCommerce\model\Openedx_Commerce_Post_Type;
use OpenedXCommerce\admin\Openedx_Commerce_Admin;
use OpenedX_Commerce\model\Openedx_Commerce_Enrollment;
use OpenedX_Commerce\model\Openedx_Commerce_Post_Type;
use OpenedX_Commerce\admin\Openedx_Commerce_Admin;
use PHPUnit\Framework\TestCase;

/**
Expand Down
2 changes: 1 addition & 1 deletion utils/openedx-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @since 1.6.0
*/

namespace OpenedXCommerce\utils;
namespace OpenedX_Commerce\utils;

/**
* Enrollment Request mode options.
Expand Down
Loading