Skip to content

Commit

Permalink
v 0.5.0
Browse files Browse the repository at this point in the history
- Add github actions.
- Add PHP language file.
- Grouped some methods.
- Better PHP 8 compatibility.
  • Loading branch information
Darklg committed Jul 3, 2024
1 parent 5f05ebc commit 9823f86
Show file tree
Hide file tree
Showing 32 changed files with 306 additions and 120 deletions.
1 change: 1 addition & 0 deletions .github/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
19 changes: 19 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: PHP Lint

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
phplint:

runs-on: ubuntu-latest

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

- name: PHP Lint
uses: michaelw90/[email protected]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.mo.php
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 WPUtilities
Copyright (c) 2024 WPUtilities

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Link WPUContactForms results to Zoho CRM

[![PHP workflow](https://github.com/WordPressUtilities/wpucontactforms_zohocrm/actions/workflows/php.yml/badge.svg 'PHP workflow')](https://github.com/WordPressUtilities/wpucontactforms_zohocrm/actions)

## How to use :

- Configure the plugin with a client ID and a client Secret.
Expand Down
1 change: 1 addition & 0 deletions inc/WPUBaseAdminPage/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
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
43 changes: 37 additions & 6 deletions inc/WPUBaseAdminPage/WPUBaseAdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@
/*
Class Name: WPU Base Admin page
Description: A class to handle pages in WordPress
Version: 1.5.1
Version: 1.8.0
Class URI: https://github.com/WordPressUtilities/wpubaseplugin
Author: Darklg
Author URI: http://darklg.me/
Author URI: https://darklg.me/
License: MIT License
License URI: http://opensource.org/licenses/MIT
License URI: https://opensource.org/licenses/MIT
*/

defined('ABSPATH') || die;

class WPUBaseAdminPage {

public $page_hook = false;
private $pages;
private $options;
private $prefix;

private $default_options = array(
'level' => 'manage_options',
'network_page' => false
);

public function __construct() {}

/* ----------------------------------------------------------
Expand All @@ -32,7 +40,14 @@ public function init($options, $pages) {
$this->pages = $pages;
$this->prefix = $this->options['id'] . '-';
$this->pages = $this->set_pages($this->pages);
add_action('admin_menu', array(&$this,

/* Set default options */
if (!is_array($this->options)) {
$this->options = array();
}
$this->options = array_merge($this->default_options, $this->options);

add_action($this->options['network_page'] ? 'network_admin_menu' : 'admin_menu', array(&$this,
'set_admin_menu'
));
add_action('admin_bar_menu', array(&$this,
Expand All @@ -57,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 @@ -85,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 @@ -223,11 +245,13 @@ public function add_settings_link($links) {
public function set_admin_page_main() {
$page = $this->get_page();

$form_classname = $this->prefix . $page . '-form';

echo $this->get_wrapper_start();

// Default Form
if ($this->pages[$page]['has_form']):
echo '<form action="' . admin_url('admin-post.php') . '" method="post" ' . ($this->pages[$page]['has_file'] ? ' enctype="multipart/form-data"' : '') . '><div>';
echo '<form class="' . esc_attr($form_classname) . '" action="' . admin_url('admin-post.php') . '" method="post" ' . ($this->pages[$page]['has_file'] ? ' enctype="multipart/form-data"' : '') . '><div>';
echo '<input type="hidden" name="action" value="' . $this->options['id'] . '">';
echo '<input type="hidden" name="page_name" value="' . $page . '" />';
wp_nonce_field('action-main-form-' . $page, 'action-main-form-' . $this->options['id'] . '-' . $page);
Expand Down Expand Up @@ -268,4 +292,11 @@ private function get_page() {
}
return $page;
}

public function get_page_url($page_id) {
if (!isset($this->pages[$page_id])) {
return false;
}
return $this->pages[$page_id]['url'];
}
}
1 change: 1 addition & 0 deletions inc/WPUBaseAdminPage/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
1 change: 1 addition & 0 deletions inc/WPUBaseCron/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
8 changes: 6 additions & 2 deletions inc/WPUBaseCron/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
WPU Base Cron
---

Add Cron in your plugin.
Add Cron to your plugin.

## Insert in the plugins_loaded hook

```php
include 'inc/WPUBaseCron.php';
require_once __DIR__ . '/inc/WPUBaseCron/WPUBaseCron.php';
$this->basecron = new \wpubaseplugin\WPUBaseCron(array(
'pluginname' => 'Base Plugin', // Default : [Namespace]
'cronhook' => 'wpubaseplugin__cron_hook', // Default : [namespace__cron_hook]
'croninterval' => 900 // Default : [3600]
));
/* Callback when hook is triggered by the cron */
add_action('wpubaseplugin__cron_hook', array(&$this,
'wpubaseplugin__callback_function'
), 10);
```

## uninstall hook ##
Expand Down
13 changes: 9 additions & 4 deletions inc/WPUBaseCron/WPUBaseCron.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
/*
Class Name: WPU Base Cron
Description: A class to handle crons
Version: 0.2.7
Version: 0.2.10
Author: Darklg
Author URI: http://darklg.me/
Author URI: https://darklg.me/
License: MIT License
License URI: http://opensource.org/licenses/MIT
License URI: https://opensource.org/licenses/MIT
*/

defined('ABSPATH') || die;

class WPUBaseCron {
public $ns = '';
public $pluginname = '';
Expand Down Expand Up @@ -42,7 +44,10 @@ public function __construct($settings = array()) {
), 99);

/* Check cron */
add_action('init', array(&$this,
add_action('wp', array(&$this,
'check_cron'
));
add_action('admin_init', array(&$this,
'check_cron'
));
}
Expand Down
1 change: 1 addition & 0 deletions inc/WPUBaseCron/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
1 change: 1 addition & 0 deletions inc/WPUBaseMessages/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
2 changes: 1 addition & 1 deletion inc/WPUBaseMessages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Add notices in your plugin.

```php
if (is_admin()) {
include dirname( __FILE__ ) . '/inc/WPUBaseMessages/WPUBaseMessages.php';
require_once __DIR__ . '/inc/WPUBaseMessages/WPUBaseMessages.php';
$this->messages = new \wpubaseplugin\WPUBaseMessages($this->options['plugin_id']);
}
```
9 changes: 6 additions & 3 deletions inc/WPUBaseMessages/WPUBaseMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
/*
Class Name: WPU Base Messages
Description: A class to handle messages in WordPress
Version: 1.3.3
Version: 1.3.4
Class URI: https://github.com/WordPressUtilities/wpubaseplugin
Author: Darklg
Author URI: http://darklg.me/
Author URI: https://darklg.me/
License: MIT License
License URI: http://opensource.org/licenses/MIT
License URI: https://opensource.org/licenses/MIT
*/

defined('ABSPATH') || die;

class WPUBaseMessages {

private $transient_msg;
Expand Down
1 change: 1 addition & 0 deletions inc/WPUBaseMessages/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
1 change: 1 addition & 0 deletions inc/WPUBaseSettings/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
3 changes: 2 additions & 1 deletion inc/WPUBaseSettings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ $this->settings = array(
)
);
if (is_admin()) {
include dirname( __FILE__ ) . '/inc/WPUBaseSettings/WPUBaseSettings.php';
require_once __DIR__ . '/inc/WPUBaseSettings/WPUBaseSettings.php';
new \wpuimporttwitter\WPUBaseSettings($this->settings_details,$this->settings);
}
```

## Insert in your admin page content ( if needed )

```php
settings_errors();
echo '<form action="' . admin_url('options.php') . '" method="post">';
settings_fields($this->settings_details['option_id']);
do_settings_sections($this->options['plugin_id']);
Expand Down
Loading

0 comments on commit 9823f86

Please sign in to comment.