Skip to content

Commit

Permalink
replaced $GLOBALS array with global keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihbalsoy committed Apr 20, 2024
1 parent a996e1f commit 66490e7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
35 changes: 27 additions & 8 deletions src/material-board.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,32 @@
if (!defined('ABSPATH'))
exit;

global $fbwpmdp_is_dev;
$fbwpmdp_is_dev = 0;
global $fbwpmdp_author;
$fbwpmdp_author = "Fatih Balsoy";
global $fbwpmdp_author_website;
$fbwpmdp_author_website = "https://fatih.bal.soy";
global $fbwpmdp_website;
$fbwpmdp_website = "https://fatih.bal.soy/projects/material-board";

global $fbwpmdp_github_slug;
$fbwpmdp_github_slug = "fatihbalsoy/material-board";
global $fbwpmdp_github;
$fbwpmdp_github = "https://github.com/" . $fbwpmdp_github_slug;
global $fbwpmdp_github_releases;
$fbwpmdp_github_releases = "https://api.github.com/repos/" . $fbwpmdp_github_slug . "/releases";
global $fbwpmdp_report_bugs;
$fbwpmdp_report_bugs = $fbwpmdp_github . "/issues/new";

global $fbwpmdp_crowdin;
$fbwpmdp_crowdin = "https://crowdin.com/project/material-dashboard";

global $fbwpmdp_name;
$fbwpmdp_name = "Material Board";
global $fbwpmdp_bundle;
$fbwpmdp_bundle = "material-board";
global $fbwpmdp_settings_title;
$fbwpmdp_settings_title = $fbwpmdp_name;

class MaterialBoardPlugin
Expand Down Expand Up @@ -70,17 +82,20 @@ class MaterialBoardPlugin

function __construct()
{
// TODO: setting this to $GLOBALS['fbwpmdp_bundle'] causes a fatal crash
$this->settings_slug = 'material-board';
global $fbwpmdp_bundle;
global $fbwpmdp_is_dev;
global $fbwpmdp_version;

$this->settings_slug = $fbwpmdp_bundle;
if (is_admin()) {
if (!function_exists('get_plugin_data')) {
require_once (ABSPATH . 'wp-admin/includes/plugin.php');
}
$plugin_data = get_plugin_data(__FILE__);
$GLOBALS["fbwpmdp_version"] = $plugin_data["Version"];
$fbwpmdp_version = $plugin_data["Version"];
}

$GLOBALS['fbwpmdp_is_dev'] = file_exists(WP_PLUGIN_DIR . '/' . $GLOBALS['fbwpmdp_bundle'] . '/.dev');
$fbwpmdp_is_dev = file_exists(WP_PLUGIN_DIR . '/' . $fbwpmdp_bundle . '/.dev');

add_action('wp_enqueue_scripts', array($this, 'fbwpmdp_admin_user_theme_style'));
add_action('admin_enqueue_scripts', array($this, 'fbwpmdp_admin_theme_style'));
Expand All @@ -97,7 +112,8 @@ function __construct()
function setup_languages()
{
// Set the theme's text domain
load_plugin_textdomain($GLOBALS['fbwpmdp_bundle'], false, dirname(plugin_basename(__FILE__)) . '/languages/');
global $fbwpmdp_bundle;
load_plugin_textdomain($fbwpmdp_bundle, false, dirname(plugin_basename(__FILE__)) . '/languages/');
}

/** User-facing Admin Theme (Admin Bar) **/
Expand All @@ -114,7 +130,8 @@ function fbwpmdp_admin_theme_style()
// wp_enqueue_script('theme-script', plugins_url('app.js', __FILE__), array('jquery'));
wp_enqueue_style('fbwpmdp-admin-theme', plugins_url('styles/wp-admin.css', __FILE__));

$split_wp_version = explode(".", $GLOBALS['wp_version']);
global $wp_version;
$split_wp_version = explode(".", $wp_version);
$wp_ver_major = intval($split_wp_version[0]);
$wp_ver_minor = intval($split_wp_version[1]);
if ($wp_ver_major >= 6 || ($wp_ver_major == 5 && $wp_ver_minor >= 9)) {
Expand All @@ -127,7 +144,8 @@ function fbwpmdp_admin_theme_style()
/** Gutenburg Block Editor Theme **/
function fbwpmdp_gutenburg_style()
{
if ($this->fbwpmdp_is_gutenberg_editor() && !$GLOBALS['fbwpmdp_is_dev']) {
global $fbwpmdp_is_dev;
if ($this->fbwpmdp_is_gutenberg_editor() && !$fbwpmdp_is_dev) {
wp_dequeue_style('fbwpmdp-admin-theme');
}
}
Expand All @@ -151,7 +169,8 @@ function fbwpmdp_login_theme_style()
/** Plugin Menu **/
function fbwpmdp_plugin_menu()
{
add_theme_page($GLOBALS["fbwpmdp_name"], $GLOBALS["fbwpmdp_name"], 'manage_options', $this->settings_slug, array($this, 'fbwpmdp_plugin_options'));
global $fbwpmdp_name;
add_theme_page($fbwpmdp_name, $fbwpmdp_name, 'manage_options', $this->settings_slug, array($this, 'fbwpmdp_plugin_options'));
}

/** Plugin Settings Link **/
Expand Down
16 changes: 12 additions & 4 deletions src/settings/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

<?php

global $fbwpmdp_website;
global $fbwpmdp_author;
global $fbwpmdp_author_website;
global $fbwpmdp_version;
global $fbwpmdp_report_bugs;
global $fbwpmdp_crowdin;

// If this file is called directly, abort.
if (!defined('ABSPATH'))
exit;
Expand Down Expand Up @@ -96,11 +103,12 @@ function fbwpmdp_get_local_file_contents($file_path)
<!-- Developed by [Author] | Version | Request Features & Report Issues | Help translate this page -->
<div>
<?php esc_html_e('Developed by', 'material-board') ?>
<a href="<?php echo esc_attr($GLOBALS["fbwpmdp_author_website"]) ?>"><?php echo esc_attr($GLOBALS["fbwpmdp_author"]) ?></a>
<a href="<?php echo esc_attr($fbwpmdp_author_website) ?>"><?php echo esc_attr($fbwpmdp_author) ?></a>
| <?php esc_html_e('Version', 'material-board') ?>
<?php echo esc_attr($GLOBALS["fbwpmdp_version"]) ?> | <a href="<?php echo esc_attr($GLOBALS["fbwpmdp_report_bugs"]) ?>">
<?php esc_html_e('Request Features & Report Issues', 'material-board') ?></a> |
<a href="<?php echo esc_attr($GLOBALS["fbwpmdp_crowdin"]) ?>"><?php esc_html_e('Help translate this page', 'material-board') ?></a>
<?php echo esc_attr($fbwpmdp_version) ?> | <a href="<?php echo esc_attr($fbwpmdp_report_bugs) ?>">
<?php esc_html_e('Request Features & Report Issues', 'material-board') ?></a> |
<a
href="<?php echo esc_attr($fbwpmdp_crowdin) ?>"><?php esc_html_e('Help translate this page', 'material-board') ?></a>
</div>
</div>

Expand Down

0 comments on commit 66490e7

Please sign in to comment.