Skip to content

Commit

Permalink
Add main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
raftaar1191 committed Jul 25, 2024
1 parent 11ded88 commit 6c5cb45
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 61 deletions.
19 changes: 0 additions & 19 deletions admin/licenses-update/edd/main.php

This file was deleted.

19 changes: 0 additions & 19 deletions admin/licenses-update/plugin-update-checker/main.php

This file was deleted.

18 changes: 0 additions & 18 deletions admin/partials/wordpress-plugin-boilerplate-admin-display.php

This file was deleted.

173 changes: 173 additions & 0 deletions admin/partials/wordpress-plugin-boilerplate-main-menu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<?php
/**
* Wordpress_Plugin_Boilerplate_Main_Menu Main Menu Class.
*
* @since Wordpress_Plugin_Boilerplate_Main_Menu 1.0.0
*/

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;


/**
* Fired during plugin licences.
*
* This class defines all code necessary to run during the plugin's licences and update.
*
* @since 1.0.0
* @package Wordpress_Plugin_Boilerplate_Main_Menu
* @subpackage Wordpress_Plugin_Boilerplate_Main_Menu/includes
*/
class Wordpress_Plugin_Boilerplate_Main_Menu {

/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;

/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;

/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct( $plugin_name, $version ) {

$this->plugin_name = $plugin_name;
$this->version = $version;
}

/**
* Adds the plugin license page to the admin menu.
*
* @return void
*/
public function main_menu() {
add_menu_page(
__( 'WordPress Plugin Boilerplate', 'wordpress-plugin-boilerplate' ),
__( 'WordPress Plugin Boilerplate', 'wordpress-plugin-boilerplate' ),
'manage_options',
'wordpress-plugin-boilerplate',
array( $this, 'about' )
);
}

/**
* About us for the plugins
*/
public function about() {
?>
<style>
.wordpress-plugin-boilerplate-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f7f7f7;
}

.wordpress-plugin-boilerplate-logo img {
max-width: 200px;
height: auto;
}

.wordpress-plugin-boilerplate-content {
text-align: center;
max-width: 600px;
margin-top: 20px;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
}

h2 {
color: #0073e6;
font-size: 24px;
}

h3 {
color: #333;
font-size: 20px;
}

ul {
list-style-type: disc;
padding-left: 20px;
text-align: left;
}

p {
font-size: 18px;
}
</style>

<div class="wordpress-plugin-boilerplate-container">

<div class="wordpress-plugin-boilerplate-content">
<h2>WordPress Plugin Boilerplate</h2>
<p style="text-align: left;">Welcome to WPBoilerplate, your comprehensive starting point for developing WordPress plugins with modern development practices. This boilerplate offers a structured and efficient setup, streamlining the process of creating robust and maintainable WordPress plugins.</p>

<h3>Key Features:</h3>
<ul>
<li><strong>Modular Structure:</strong> Organized codebase that promotes clean, readable, and maintainable project architecture.</li>

<li><strong>Modern Development Tools:</strong> Integrates wp-script to enhance your workflow and automate tasks.</li>

<li><strong>Best Practices:</strong> Follows WordPress coding standards and best practices to ensure high-quality code.</li>

<li><strong>Customization Ready:</strong> Easily customizable to fit the specific needs of your plugin development projects.</li>

<li><strong>Plugin Update Checker:</strong> Built-in functionality to manage and check for plugin updates, ensuring your plugins stay current.</li>
</ul>

<h3>Documentation</h3>
<p>Comprehensive documentation is available to guide you through the setup process, customization options, and deployment procedures. Whether you're a seasoned developer or new to WordPress plugin development, our documentation is designed to make your development experience as smooth as possible.</p>

<h3>Contributions</h3>
<p>We welcome contributions from the community. Feel free to fork the repository, create issues, or submit pull requests to help us improve WPBoilerplate.</p>
</div>
</div>
<?php
}

/**
* Add Settings link to plugins area.
*
* @since 1.0.0
*
* @param array $links Links array in which we would prepend our link.
* @param string $file Current plugin basename.
* @return array Processed links.
*/
public function plugin_action_links( $links, $file ) {

// Return normal links if not BuddyPress.
if ( WORDPRESS_PLUGIN_BOILERPLATE_PLUGIN_BASENAME !== $file ) {
return $links;
}

// Add a few links to the existing links array.
return array_merge(
$links,
array(
'about' => sprintf( '<a href="%sadmin.php?page=%s">%s</a>', admin_url(), 'wordpress-plugin-boilerplate', esc_html__( 'About', 'wordpress-plugin-boilerplate' ) ),
)
);
}
}
3 changes: 1 addition & 2 deletions admin/update/wordpress-plugin-boilerplate-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*
* @package Wordpress_Plugin_Boilerplate
* @subpackage Wordpress_Plugin_Boilerplate/Updater
* @author WPBoilerplate <contact@wpboilerplate.com>
*/
class Wordpress_Plugin_Boilerplate_Update {

Expand Down Expand Up @@ -82,7 +81,7 @@ public function is_install() {
* @since WordPress Plugin Boilerplate 1.0.0
*/
public function get_db_version_raw() {
return get_option( $this->plugin_name_db_version, '0.0.1' );
return get_option( $this->plugin_name_db_version, '1.0.0' );
}

/**
Expand Down
20 changes: 17 additions & 3 deletions includes/class-wordpress-plugin-boilerplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ private function define_constants() {
$this->define( 'WORDPRESS_PLUGIN_BOILERPLATE_PLUGIN_URL', plugin_dir_url( WORDPRESS_PLUGIN_BOILERPLATE_FILES ) );
$this->define( 'WORDPRESS_PLUGIN_BOILERPLATE_PLUGIN_NAME_SLUG', $this->plugin_name );
$this->define( 'WORDPRESS_PLUGIN_BOILERPLATE_PLUGIN_NAME', 'WordPress Plugin Boilerplate' );
if( ! function_exists( 'get_plugin_data' ) ){

if ( ! function_exists( 'get_plugin_data' ) ) {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
$plugin_data = get_plugin_data( WORDPRESS_PLUGIN_BOILERPLATE_PLUGIN_FILE );
Expand Down Expand Up @@ -161,7 +161,7 @@ public function load_hooks() {
*
* @since 1.0.0
*/
if( apply_filters( 'wordpress-plugin-boilerplate-load', true ) ) {
if ( apply_filters( 'wordpress-plugin-boilerplate-load', true ) ) {
$this->define_admin_hooks();
$this->define_public_hooks();
}
Expand Down Expand Up @@ -215,6 +215,11 @@ private function load_dependencies() {
*/
require_once WORDPRESS_PLUGIN_BOILERPLATE_PLUGIN_PATH . 'admin/update/wordpress-plugin-boilerplate-update.php';

/**
* The class responsible for defining the plugin menu
*/
require_once WORDPRESS_PLUGIN_BOILERPLATE_PLUGIN_PATH . 'admin/partials/wordpress-plugin-boilerplate-main-menu.php';

/**
* The class responsible for defining all actions that occur in the public-facing
* side of the site.
Expand Down Expand Up @@ -257,9 +262,18 @@ private function define_admin_hooks() {

$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );

/**
* For plugin update
*/
$plugin_update = new Wordpress_Plugin_Boilerplate_Update( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'admin_init', $plugin_update, 'setup_updater' );

/**
* Add the Plugin Main Menu
*/
$main_menu = new Wordpress_Plugin_Boilerplate_Main_Menu( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'admin_menu', $main_menu, 'main_menu' );
$this->loader->add_action( 'plugin_action_links', $main_menu, 'plugin_action_links', 1000, 2 );
}

/**
Expand Down

0 comments on commit 6c5cb45

Please sign in to comment.