Skip to content

Commit

Permalink
v 0.9.0
Browse files Browse the repository at this point in the history
- Update dependencies
- Update github actions.
- Update lang loading method.
  • Loading branch information
Darklg committed Dec 11, 2024
1 parent 2897551 commit c4f35cc
Show file tree
Hide file tree
Showing 11 changed files with 271 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: PHP Lint
uses: michaelw90/[email protected]
2 changes: 1 addition & 1 deletion inc/WPUBaseAdminPage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $pages_options = array(
);

// Init admin page
include dirname( __FILE__ ) . '/inc/WPUBaseAdminPage/WPUBaseAdminPage.php';
require_once __DIR__ . '/inc/WPUBaseAdminPage/WPUBaseAdminPage.php';
$this->adminpages = new \wpubaseplugin\WPUBaseAdminPage();
$this->adminpages->init($pages_options, $admin_pages);

Expand Down
15 changes: 11 additions & 4 deletions inc/WPUBaseAdminPage/WPUBaseAdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
Class Name: WPU Base Admin page
Description: A class to handle pages in WordPress
Version: 1.7.0
Version: 1.8.0
Class URI: https://github.com/WordPressUtilities/wpubaseplugin
Author: Darklg
Author URI: https://darklg.me/
Expand Down Expand Up @@ -72,6 +72,10 @@ public function init($options, $pages) {
add_filter($filter[0], $filter[1]);
}
}
if (in_array($current_page, $p['aliases'])) {
wp_redirect($this->get_page_url($p_id));
die;
}
}
}

Expand Down Expand Up @@ -100,9 +104,12 @@ public function set_pages($pages) {
if (!isset($page['actions'])) {
$page['actions'] = array();
}
if (!isset($page['filters'])) {
if (!isset($page['filters']) || !is_array($page['filters'])) {
$page['filters'] = array();
}
if (!isset($page['aliases']) || !is_array($page['aliases'])) {
$page['aliases'] = array();
}
if (!isset($page['display_banner_menu'])) {
$page['display_banner_menu'] = false;
}
Expand Down Expand Up @@ -286,8 +293,8 @@ private function get_page() {
return $page;
}

public function get_page_url($page_id){
if(!isset($this->pages[$page_id])){
public function get_page_url($page_id) {
if (!isset($this->pages[$page_id])) {
return false;
}
return $this->pages[$page_id]['url'];
Expand Down
48 changes: 48 additions & 0 deletions inc/WPUBaseToolbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,51 @@ echo $this->basetoolbox->get_form_html('form_edit_note', array(
)
));
```

### Get user IP

```php
$anonymized = false;
echo $this->basetoolbox->get_user_ip($anonymized);
```

### Handle plugin dependencies

```php
$this->basetoolbox->check_plugins_dependencies(array(
'wpuoptions' => array(
'path' => 'wpuoptions/wpuoptions.php',
'url' => 'https://github.com/WordPressUtilities/wpuoptions',
'name' => 'WPU Options'
),
'wputaxometas' => array(
'path' => 'wputaxometas/wputaxometas.php',
'url' => 'https://github.com/WordPressUtilities/wputaxometas',
'name' => 'WPU Taxo Metas'
)
));
```

### Array helpers

#### Get a value from an array

```php

$data = array(
'key1' => 'value1',
'key2' => 'value2'
);

# Get HTML attributes from an array
echo $this->basetoolbox->array_to_html_attributes($data);

# Create an HTML table from an array
echo $this->basetoolbox->array_to_html_table($data);

# Export an array as a JSON file
$this->basetoolbox->export_array_to_json($data, 'filename');

# Export an array as a CSV file
$this->basetoolbox->export_array_to_csv($data, 'filename');
```
Loading

0 comments on commit c4f35cc

Please sign in to comment.