Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename “methodes” to “methods” #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions plugin-name/admin/class-plugin-name-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class Plugin_Name_Admin {
private $version;

/*************************************************************
* ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
* ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE
*
* @tutorial access_plugin_admin_public_methodes_from_inside.php
* @tutorial access_plugin_admin_public_methods_from_inside.php
*/
/**
* Store plugin main class to allow public access.
Expand All @@ -52,7 +52,7 @@ class Plugin_Name_Admin {
* @var object The main class.
*/
public $main;
// ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
// ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE

/**
* Initialize the class and set its properties.
Expand All @@ -69,9 +69,9 @@ class Plugin_Name_Admin {
// }

/*************************************************************
* ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
* ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE
*
* @tutorial access_plugin_admin_public_methodes_from_inside.php
* @tutorial access_plugin_admin_public_methods_from_inside.php
*/
/**
* Initialize the class and set its properties.
Expand All @@ -87,7 +87,7 @@ public function __construct( $plugin_name, $version, $plugin_main ) {
$this->main = $plugin_main;

}
// ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
// ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE

/**
* Register the stylesheets for the admin area.
Expand Down
46 changes: 23 additions & 23 deletions plugin-name/includes/class-plugin-name.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class Plugin_Name {
protected $version;

/*************************************************************
* ACCESS PLUGIN AND ITS METHODES LATER FROM OUTSIDE OF PLUGIN
* ACCESS PLUGIN AND ITS METHODS LATER FROM OUTSIDE OF PLUGIN
*
* @tutorial access_plugin_and_its_methodes_later_from_outside_of_plugin.php
* @tutorial access_plugin_and_its_methods_later_from_outside_of_plugin.php
*/
/**
* Store plugin admin class to allow public access.
Expand All @@ -78,12 +78,12 @@ class Plugin_Name {
* @var object The admin class.
*/
public $public;
// END ACCESS PLUGIN AND ITS METHODES LATER FROM OUTSIDE OF PLUGIN
// END ACCESS PLUGIN AND ITS METHODS LATER FROM OUTSIDE OF PLUGIN

/*************************************************************
* ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
* ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE
*
* @tutorial access_plugin_admin_public_methodes_from_inside.php
* @tutorial access_plugin_admin_public_methods_from_inside.php
*/
/**
* Store plugin main class to allow public access.
Expand All @@ -92,7 +92,7 @@ class Plugin_Name {
* @var object The main class.
*/
public $main;
// ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
// ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE

/**
* Define the core functionality of the plugin.
Expand All @@ -109,12 +109,12 @@ public function __construct() {
$this->version = '1.0.0';

/*************************************************************
* ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
* ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE
*
* @tutorial access_plugin_admin_public_methodes_from_inside.php
* @tutorial access_plugin_admin_public_methods_from_inside.php
*/
$this->main = $this;
// ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
// ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE

$this->load_dependencies();
$this->set_locale();
Expand Down Expand Up @@ -223,25 +223,25 @@ private function define_admin_hooks() {
// $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );

/*************************************************************
* ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
* (COMBINED WITH ACCESS PLUGIN AND ITS METHODES LATER FROM OUTSIDE OF PLUGIN)
* ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE
* (COMBINED WITH ACCESS PLUGIN AND ITS METHODS LATER FROM OUTSIDE OF PLUGIN)
*
*
* @tutorial access_plugin_admin_public_methodes_from_inside.php
* @tutorial access_plugin_admin_public_methods_from_inside.php
*/
$this->admin = new Plugin_Name_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );
// END ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
// END ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE

/*************************************************************
* ACCESS PLUGIN AND ITS METHODES LATER FROM OUTSIDE OF PLUGIN
* ACCESS PLUGIN AND ITS METHODS LATER FROM OUTSIDE OF PLUGIN
*
* @tutorial access_plugin_and_its_methodes_later_from_outside_of_plugin.php
* @tutorial access_plugin_and_its_methods_later_from_outside_of_plugin.php
*/
// $this->admin = new Plugin_Name_Admin( $this->get_plugin_name(), $this->get_version() );

$this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_styles' );
$this->loader->add_action( 'admin_enqueue_scripts', $this->admin, 'enqueue_scripts' );
// END ACCESS PLUGIN AND ITS METHODES LATER FROM OUTSIDE OF PLUGIN
// END ACCESS PLUGIN AND ITS METHODS LATER FROM OUTSIDE OF PLUGIN

/**************************
* CREATE CUSTOM POST TYPES
Expand Down Expand Up @@ -348,23 +348,23 @@ private function define_public_hooks() {
// $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );

/*************************************************************
* ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
* (COMBINED WITH ACCESS PLUGIN AND ITS METHODES LATER FROM OUTSIDE OF PLUGIN)
* ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE
* (COMBINED WITH ACCESS PLUGIN AND ITS METHODS LATER FROM OUTSIDE OF PLUGIN)
*
* @tutorial access_plugin_admin_public_methodes_from_inside.php
* @tutorial access_plugin_admin_public_methods_from_inside.php
*/
$this->public = new Plugin_Name_Public( $this->get_plugin_name(), $this->get_version(), $this->main );
// END ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
// END ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE

/*************************************************************
* ACCESS PLUGIN AND ITS METHODES LATER FROM OUTSIDE OF PLUGIN
* ACCESS PLUGIN AND ITS METHODS LATER FROM OUTSIDE OF PLUGIN
*
* @tutorial access_plugin_and_its_methodes_later_from_outside_of_plugin.php
* @tutorial access_plugin_and_its_methods_later_from_outside_of_plugin.php
*/
// $this->public = new Plugin_Name_Public( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'wp_enqueue_scripts', $this->public, 'enqueue_styles' );
$this->loader->add_action( 'wp_enqueue_scripts', $this->public, 'enqueue_scripts' );
// END ACCESS PLUGIN AND ITS METHODES LATER FROM OUTSIDE OF PLUGIN
// END ACCESS PLUGIN AND ITS METHODS LATER FROM OUTSIDE OF PLUGIN
}

/**
Expand Down
2 changes: 1 addition & 1 deletion plugin-name/plugin-name.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function plugin_name_show_upgrade_notification( $current_plugin_metadata, $new_p
* or you can store it in a static class,
* etc...
*
* @tutorial access_plugin_and_its_methodes_later_from_outside_of_plugin.php
* @tutorial access_plugin_and_its_methods_later_from_outside_of_plugin.php
*/
global $pbt_prefix_plugin_name;
$pbt_prefix_plugin_name = new Plugin_Name();
Expand Down
12 changes: 6 additions & 6 deletions plugin-name/public/class-plugin-name-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class Plugin_Name_Public {
private $version;

/*************************************************************
* ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
* ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE
*
* @tutorial access_plugin_admin_public_methodes_from_inside.php
* @tutorial access_plugin_admin_public_methods_from_inside.php
*/
/**
* Store plugin main class to allow public access.
Expand All @@ -52,7 +52,7 @@ class Plugin_Name_Public {
* @var object The main class.
*/
public $main;
// END ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
// END ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE

/**
* Initialize the class and set its properties.
Expand All @@ -69,9 +69,9 @@ class Plugin_Name_Public {
// }

/*************************************************************
* ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
* ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE
*
* @tutorial access_plugin_admin_public_methodes_from_inside.php
* @tutorial access_plugin_admin_public_methods_from_inside.php
*/
/**
* Initialize the class and set its properties.
Expand All @@ -87,7 +87,7 @@ public function __construct( $plugin_name, $version, $plugin_main ) {
$this->main = $plugin_main;

}
// END ACCESS PLUGIN ADMIN PUBLIC METHODES FROM INSIDE
// END ACCESS PLUGIN ADMIN PUBLIC METHODS FROM INSIDE

/**
* Register the stylesheets for the public-facing side of the site.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*******************************************************
* ACCESS PLUGIN ADMIN AND PUBLIC METHODES FROM INSIDE *
* ACCESS PLUGIN ADMIN AND PUBLIC METHODS FROM INSIDE *
* --------------------------------------------------- *
*******************************************************/

Expand Down Expand Up @@ -45,7 +45,7 @@ private function define_admin_hooks() {
// of course, now you do not have "$plugin_admin", you need to use "$this->plugin_admin" instead.
$plugin_admin = new Plugin_Name_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );

// -- OR IF YOU WANT TO ACCESS FROM OUTSIDE TOO, SEE access_plugin_and_its_methodes_later_from_outside_of_plugin.php --
// -- OR IF YOU WANT TO ACCESS FROM OUTSIDE TOO, SEE access_plugin_and_its_methods_later_from_outside_of_plugin.php --
// $this->admin = new Plugin_Name_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php

/*******************************************************
* ACCESS PLUGIN ADMIN AND PUBLIC METHODS FROM INSIDE *
* --------------------------------------------------- *
*******************************************************/

/**
* Instead of this, you could use a "shared" class static or otherwise for
* shared functions.
*/

////////////////////////////////////////////////
// ADD TO FILE -> includes/class-plugin-name.php


/**
* Store plugin main class to allow public access.
*
* @since 20180622
* @var object The main class.
*/
public $main;

// ...

public function __construct() {

// ...

$this->main = $this;


}

// ...

private function define_admin_hooks() {



// CHANGE THIS
$plugin_admin = new Plugin_Name_Admin( $this->get_plugin_name(), $this->get_version() );
// TO THIS:
// of course, now you do not have "$plugin_admin", you need to use "$this->plugin_admin" instead.
$plugin_admin = new Plugin_Name_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );

// -- OR IF YOU WANT TO ACCESS FROM OUTSIDE TOO, SEE access_plugin_and_its_methods_later_from_outside_of_plugin.php --
// $this->admin = new Plugin_Name_Admin( $this->get_plugin_name(), $this->get_version(), $this->main );


}

/**
* Register all of the hooks related to the public-facing functionality
* of the plugin.
*
* @since 1.0.0
* @access private
*/
private function define_public_hooks() {

// CHANGE THIS
$plugin_public = new Plugin_Name_Public( $this->get_plugin_name(), $this->get_version() );
// TO THIS:
$this->public = new Plugin_Name_Public( $this->get_plugin_name(), $this->get_version(), $this->main );

////////////////////////////////////////////////
// ADD TO FILE -> admin/class-plugin-name-admin.php
// -- AND --
// ADD TO FILE -> public/class-plugin-name-public.php

/**
* Store plugin main class to allow public access.
*
* @since 20180622
* @var object The main class.
*/
public $main;

public function __construct( $plugin_name, $version, $plugin_main ) {

$this->main = $plugin_main;

// ...

}

/**
* Now you can access to your functions.
* Example:
*/
////////////////////////////////////////////////
// ADD TO FILE -> public/class-plugin-name-public.php

// ...


// ACCESS FROM ADMIN FROM PUBLIC
public function access_test() {
$test_var = $this->main->admin->function_from_admin();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*******************************************************************
* ACCESS PLUGIN AND ITS METHODES LATER FROM OUTSIDE OF THE PLUGIN *
* ACCESS PLUGIN AND ITS METHODS LATER FROM OUTSIDE OF THE PLUGIN *
* --------------------------------------------------------------- *
*******************************************************************/

Expand Down