Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wordpress-snippets
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Simone
wordpress-snippets
Commits
7e02a871
Commit
7e02a871
authored
Apr 03, 2018
by
Simone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added plugin boilerplate
parent
648f208e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
115 additions
and
0 deletions
+115
-0
myPlugin.php
myPlugin/myPlugin.php
+115
-0
No files found.
myPlugin/myPlugin.php
0 → 100644
View file @
7e02a871
<?php
/**
* Plugin Name: MyPlugin
* Description: my plugin description
* Version: 1.0.0
* Author: AIM srl
* Author URI: www.aimconsulting.it
* Developer: Zer0Overflow
* Developer URI: github.com/zerooverflow
* Text Domain: myplugin-domain
*
* WC requires at least: 3.5
* WC tested up to: 4.9.4
*
*/
if
(
!
defined
(
'ABSPATH'
)
)
{
exit
;
}
$wp_ver
=
explode
(
'.'
,
get_bloginfo
(
'version'
));
// controllo versione wp 3.5+ :
if
(
$wp_ver
[
0
]
<
3
&&
$wp_ver
[
1
]
<
5
){
add_action
(
'admin_notices'
,
function
(){
?>
<div
class=
"notice notice-error is-dismissible"
>
<p>
<?php
_e
(
'Il plugin richiede Wordpress versione 3.5 o superiore '
,
'myplugin-domain'
);
?>
</p>
</div>
<?php
});
return
;
}
define
(
'MYPLUGIN_DIRPATH'
,
plugin_dir_path
(
__FILE__
));
define
(
'MYPLUGIN_URL'
,
plugin_dir_url
(
__FILE__
)
);
class
My_Plugin
{
public
static
function
instance
()
{
static
$instance
=
false
;
if
(
$instance
===
false
)
{
// Late static binding (PHP 5.3+)
$instance
=
new
static
();
}
return
$instance
;
}
public
function
admin_scripts
(
$hook_suffix
){
wp_enqueue_style
(
'myplugin-style'
,
MYPLUGIN_URL
.
'/assets/css/myplugin.css'
,
array
(),
'1.0.0'
);
wp_enqueue_script
(
'myplugin-script'
,
MYPLUGIN_URL
.
'/assets/js/myplugin.js'
,
array
(
'jquery'
));
}
public
function
load_textdomain
(){
//
load_plugin_textdomain
(
'myplugin-domain'
,
false
,
basename
(
dirname
(
__FILE__
)
)
.
'/languages'
);
}
private
function
includes
()
{
}
private
function
hooks
()
{
add_action
(
'plugins_loaded'
,
array
(
$this
,
'load_textdomain'
)
);
}
private
function
is_request
(
$type
)
{
switch
(
$type
)
{
case
'admin'
:
return
is_admin
();
case
'ajax'
:
return
defined
(
'DOING_AJAX'
);
case
'cron'
:
return
defined
(
'DOING_CRON'
);
case
'frontend'
:
return
(
!
is_admin
()
||
defined
(
'DOING_AJAX'
)
)
&&
!
defined
(
'DOING_CRON'
);
}
}
private
function
__construct
()
{
$this
->
includes
();
$this
->
hooks
();
}
private
function
__clone
()
{}
private
function
__sleep
()
{}
private
function
__wakeup
()
{}
}
function
my_plugin
(){
return
My_Plugin
::
instance
();
}
my_plugin
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment