Skip to content

Commit

Permalink
v 0.27.0
Browse files Browse the repository at this point in the history
- Fix styles in front.
- Avoid link to invalid post types or invalid statuses.
  • Loading branch information
Darklg committed Nov 15, 2024
1 parent f4ec950 commit e44f8bb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
19 changes: 16 additions & 3 deletions inc/WPUBaseUpdate/WPUBaseUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
Class Name: WPU Base Update
Description: A class to handle plugin update from github
Version: 0.5.0
Version: 0.6.0
Class URI: https://github.com/WordPressUtilities/wpubaseplugin
Author: Darklg
Author URI: https://darklg.me/
Expand Down Expand Up @@ -176,7 +176,7 @@ public function plugins_api($res, $action, $args) {
return false;
}

if ('github-' . $this->github_project !== $args->slug) {
if ('github-' . $this->github_project !== $args->slug && $this->github_project !== $args->slug) {
return $res;
}

Expand All @@ -185,7 +185,20 @@ public function plugins_api($res, $action, $args) {
return (object) $plugin_info;
}

return false;
$plugin_details = array(
'name' => $this->github_project,
'slug' => $this->github_project
);

$parent_plugin = __DIR__ . '/../../' . $this->github_project . '.php';
if (file_exists($parent_plugin)) {
$plugin_name = get_plugin_data($parent_plugin);
if (isset($plugin_name['Name'])) {
$plugin_details['name'] = $plugin_name['Name'];
}
}

return (object) $plugin_details;

}

Expand Down
44 changes: 30 additions & 14 deletions wpuactionlogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Plugin URI: https://github.com/WordPressUtilities/wpuactionlogs
Update URI: https://github.com/WordPressUtilities/wpuactionlogs
Description: Useful logs about what’s happening on your website admin.
Version: 0.26.1
Version: 0.27.0
Author: Darklg
Author URI: https://darklg.me/
Text Domain: wpuactionlogs
Expand All @@ -26,7 +26,7 @@ class WPUActionLogs {
public $baseadmindatas;
public $settings_details;
public $settings;
private $plugin_version = '0.26.1';
private $plugin_version = '0.27.0';
private $transient_active_duration = 60;
private $plugin_settings = array(
'id' => 'wpuactionlogs',
Expand All @@ -38,32 +38,37 @@ class WPUActionLogs {
private $admin_page_id = 'wpuactionlogs-main';
private $excluded_functions = array(
'get_call_stack',
'log_line',
'log_line'
);
private $excluded_post_types_ids = array(
'attachment',
'auto-draft',
'customize_changeset'
);

public function __construct() {
add_filter('plugins_loaded', array(&$this,
add_action('plugins_loaded', array(&$this,
'load_translation'
));
add_filter('plugins_loaded', array(&$this,
add_action('plugins_loaded', array(&$this,
'load_update'
));
add_filter('plugins_loaded', array(&$this,
add_action('plugins_loaded', array(&$this,
'load_custom_table'
));
add_filter('plugins_loaded', array(&$this,
add_action('plugins_loaded', array(&$this,
'load_settings'
));
add_filter('plugins_loaded', array(&$this,
add_action('plugins_loaded', array(&$this,
'load_admin_page'
));
add_filter('plugins_loaded', array(&$this,
add_action('plugins_loaded', array(&$this,
'load_messages'
));
add_filter('plugins_loaded', array(&$this,
add_action('plugins_loaded', array(&$this,
'load_cron'
));
add_filter('plugins_loaded', array(&$this,
add_action('plugins_loaded', array(&$this,
'load_actions'
));
add_action('admin_init', array(&$this,
Expand All @@ -73,7 +78,10 @@ public function __construct() {
'log_current_user_action'
));
add_action('admin_enqueue_scripts', array(&$this,
'admin_enqueue_scripts'
'enqueue_styles'
));
add_action('wp_enqueue_scripts', array(&$this,
'enqueue_styles'
));

add_action('wp_dashboard_setup', function () {
Expand Down Expand Up @@ -109,7 +117,10 @@ public function load_translation() {
}

# ASSETS
public function admin_enqueue_scripts() {
public function enqueue_styles() {
if (!is_user_logged_in()) {
return;
}
wp_enqueue_style('wpuactionlogs-style', plugins_url('assets/admin.css', __FILE__), array(), $this->plugin_version);
}

Expand Down Expand Up @@ -457,7 +468,12 @@ public function wpubaseadmindatas_cellcontent($cellcontent, $cell_id, $settings)
}
/* Post ids */
$post_id = false;
if (isset($data['post_id']) && is_numeric($data['post_id']) && get_post($data['post_id'])) {
if (isset($data['post_id'], $data['post_type']) &&
is_numeric($data['post_id']) &&
!in_array($data['post_type'], $this->excluded_post_types_ids) &&
(!isset($data['post_status']) || $data['post_status'] != 'auto-draft') &&
get_post($data['post_id'])
) {
$post_id = $data['post_id'];
$data['post_id'] = '<a href="' . get_edit_post_link($data['post_id']) . '">' . $data['post_id'] . '</a>';
}
Expand Down

0 comments on commit e44f8bb

Please sign in to comment.