Skip to content

Commit f44ddad

Browse files
committed
WordPress plugin boilerplate starter
1 parent 40aa358 commit f44ddad

27 files changed

+657
-0
lines changed

admin/assets/css/admin.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This stylesheet is used to style the admin option form of the plugin. */

admin/assets/css/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

admin/assets/js/admin.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(function ( $ ) {
2+
"use strict";
3+
4+
$(function () {
5+
6+
// Place your administration-specific JavaScript here
7+
8+
});
9+
10+
}(jQuery));

admin/assets/js/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

admin/class-pods-export-code.php

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
<?php
2+
/**
3+
* Class Pods_Export_Code_Admin
4+
*/
5+
class Pods_Export_Code_Admin {
6+
7+
/**
8+
* Instance of this class.
9+
*
10+
* @since 1.0.0
11+
*
12+
* @var object
13+
*/
14+
protected static $instance = null;
15+
16+
/**
17+
* Slug of the plugin screen.
18+
*
19+
* @since 1.0.0
20+
*
21+
* @var string
22+
*/
23+
protected $plugin_screen_hook_suffix = null;
24+
25+
/**
26+
* Initialize the plugin by loading admin scripts & styles and adding a
27+
* settings page and menu.
28+
*
29+
* @since 1.0.0
30+
*/
31+
private function __construct() {
32+
33+
/*
34+
* Call $plugin_slug from public plugin class.
35+
*/
36+
$plugin = Pods_Export_Code::get_instance();
37+
$this->plugin_slug = $plugin->get_plugin_slug();
38+
39+
// Load admin style sheet and JavaScript.
40+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
41+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
42+
43+
// Add the options page and menu item.
44+
add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) );
45+
46+
// Add an action link pointing to the options page.
47+
$plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_slug . '.php' );
48+
add_filter( 'plugin_action_links_' . $plugin_basename, array( $this, 'add_action_links' ) );
49+
50+
/*
51+
* Define custom functionality.
52+
*
53+
* Read more about actions and filters:
54+
* http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters
55+
*/
56+
add_action( '@TODO', array( $this, 'action_method_name' ) );
57+
add_filter( '@TODO', array( $this, 'filter_method_name' ) );
58+
59+
}
60+
61+
/**
62+
* Return an instance of this class.
63+
*
64+
* @since 1.0.0
65+
*
66+
* @return object A single instance of this class.
67+
*/
68+
public static function get_instance() {
69+
70+
/*
71+
* @TODO :
72+
*
73+
* - Uncomment following lines if the admin class should only be available for super admins
74+
*/
75+
/* if( ! is_super_admin() ) {
76+
return;
77+
} */
78+
79+
// If the single instance hasn't been set, set it now.
80+
if ( null == self::$instance ) {
81+
self::$instance = new self;
82+
}
83+
84+
return self::$instance;
85+
}
86+
87+
/**
88+
* Register and enqueue admin-specific style sheet.
89+
*
90+
* @since 1.0.0
91+
*
92+
* @return null Return early if no settings page is registered.
93+
*/
94+
public function enqueue_admin_styles() {
95+
96+
if ( ! isset( $this->plugin_screen_hook_suffix ) ) {
97+
return;
98+
}
99+
100+
$screen = get_current_screen();
101+
if ( $this->plugin_screen_hook_suffix == $screen->id ) {
102+
wp_enqueue_style( $this->plugin_slug .'-admin-styles', plugins_url( 'assets/css/admin.css', __FILE__ ), array(), Pods_Export_Code::VERSION );
103+
}
104+
105+
}
106+
107+
/**
108+
* Register and enqueue admin-specific JavaScript.
109+
*
110+
* @since 1.0.0
111+
*
112+
* @return null Return early if no settings page is registered.
113+
*/
114+
public function enqueue_admin_scripts() {
115+
116+
if ( ! isset( $this->plugin_screen_hook_suffix ) ) {
117+
return;
118+
}
119+
120+
$screen = get_current_screen();
121+
if ( $this->plugin_screen_hook_suffix == $screen->id ) {
122+
wp_enqueue_script( $this->plugin_slug . '-admin-script', plugins_url( 'assets/js/admin.js', __FILE__ ), array( 'jquery' ), Pods_Export_Code::VERSION );
123+
}
124+
125+
}
126+
127+
/**
128+
* Register the administration menu for this plugin into the WordPress Dashboard menu.
129+
*
130+
* @since 1.0.0
131+
*/
132+
public function add_plugin_admin_menu() {
133+
134+
/*
135+
* Add a settings page for this plugin to the Settings menu.
136+
*
137+
* NOTE: Alternative menu locations are available via WordPress administration menu functions.
138+
*
139+
* Administration Menus: http://codex.wordpress.org/Administration_Menus
140+
*
141+
*/
142+
$this->plugin_screen_hook_suffix = add_options_page(
143+
__( 'Pods Export to Code', $this->plugin_slug ),
144+
__( 'Menu Text', $this->plugin_slug ),
145+
'manage_options',
146+
$this->plugin_slug,
147+
array( $this, 'display_plugin_admin_page' )
148+
);
149+
150+
}
151+
152+
/**
153+
* Render the settings page for this plugin.
154+
*
155+
* @since 1.0.0
156+
*/
157+
public function display_plugin_admin_page() {
158+
include_once( 'views/admin.php' );
159+
}
160+
161+
/**
162+
* Add settings action link to the plugins page.
163+
*
164+
* @since 1.0.0
165+
*/
166+
public function add_action_links( $links ) {
167+
168+
return array_merge(
169+
array(
170+
'settings' => '<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_slug ) . '">' . __( 'Settings', $this->plugin_slug ) . '</a>'
171+
),
172+
$links
173+
);
174+
175+
}
176+
177+
/**
178+
* NOTE: Actions are points in the execution of a page or process
179+
* lifecycle that WordPress fires.
180+
*
181+
* Actions: http://codex.wordpress.org/Plugin_API#Actions
182+
* Reference: http://codex.wordpress.org/Plugin_API/Action_Reference
183+
*
184+
* @since 1.0.0
185+
*/
186+
public function action_method_name() {
187+
// @TODO: Define your action hook callback here
188+
}
189+
190+
/**
191+
* NOTE: Filters are points of execution in which WordPress modifies data
192+
* before saving it or sending it to the browser.
193+
*
194+
* Filters: http://codex.wordpress.org/Plugin_API#Filters
195+
* Reference: http://codex.wordpress.org/Plugin_API/Filter_Reference
196+
*
197+
* @since 1.0.0
198+
*/
199+
public function filter_method_name() {
200+
// @TODO: Define your filter hook callback here
201+
}
202+
203+
}

admin/includes/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

admin/views/admin.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Represents the view for the administration dashboard.
4+
*
5+
* This includes the header, options, and other information that should provide
6+
* The User Interface to the end user.
7+
*
8+
* @package Plugin_Name
9+
* @author Your Name <[email protected]>
10+
* @license GPL-2.0+
11+
* @link http://example.com
12+
* @copyright 2013 Your Name or Company Name
13+
*/
14+
?>
15+
16+
<div class="wrap">
17+
18+
<?php screen_icon(); ?>
19+
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
20+
21+
<!-- @TODO: Provide markup for your options page here. -->
22+
23+
</div>

admin/views/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

assets/banner-1544x500.png

23.1 KB
Loading

assets/banner-772x250.png

11.5 KB
Loading

assets/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

assets/screenshot-1.png

451 KB
Loading

includes/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

languages/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

languages/plugin-name.pot

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (C) 2013 TODO
2+
# This file is distributed under the same license as the TODO package.
3+
msgid ""
4+
msgstr ""
5+
"Project-Id-Version: TODO 1.0.0\n"
6+
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/plugin-name\n"
7+
"POT-Creation-Date: 2013-05-10 11:23:19+00:00\n"
8+
"PO-Revision-Date: 2013-05-10 10:37-0500\n"
9+
"Last-Translator: FULL NAME <[email protected]>\n"
10+
"Language-Team: LANGUAGE <[email protected] >\n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: 8bit\n"
14+
"X-Generator: Poedit 1.5.7\n"
15+
"X-Poedit-KeywordsList: __;_e;_n;_x;esc_html_e;esc_html__;esc_attr_e;"
16+
"esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_x:1,2c;_n:1,2\n"
17+
"X-Poedit-Basepath: ../\n"
18+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
19+
"X-Poedit-SearchPath-0: .\n"
20+
21+
#: class-plugin-name-admin.php:170
22+
msgid "Page Title"
23+
msgstr ""
24+
25+
#: class-plugin-name-admin.php:171
26+
msgid "Menu Text"
27+
msgstr ""
28+
29+
#: class-plugin-name-admin.php:197
30+
msgid "Settings"
31+
msgstr ""

pods-export-code.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Plugin Name: Pods Export to Code
4+
* Plugin URI: http://pods.io/
5+
* Description: Pods Export to Code
6+
* Version: 0.9
7+
* Author: Pods Framework Team
8+
* Author URI: http://pods.io/about/
9+
10+
Copyright 2013-2014 Pods Foundation, Inc (email : [email protected])
11+
12+
This program is free software; you can redistribute it and/or modify
13+
it under the terms of the GNU General Public License as published by
14+
the Free Software Foundation; either version 2 of the License, or
15+
(at your option) any later version.
16+
17+
This program is distributed in the hope that it will be useful,
18+
but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
GNU General Public License for more details.
21+
22+
You should have received a copy of the GNU General Public License
23+
along with this program; if not, write to the Free Software
24+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25+
*/
26+
27+
// If this file is called directly, abort.
28+
if ( ! defined( 'WPINC' ) ) {
29+
die;
30+
}
31+
32+
/*----------------------------------------------------------------------------*
33+
* Public-Facing Functionality
34+
*----------------------------------------------------------------------------*/
35+
36+
require_once( plugin_dir_path( __FILE__ ) . 'public/class-pods-export-code.php' );
37+
38+
/*
39+
* Register hooks that are fired when the plugin is activated or deactivated.
40+
* When the plugin is deleted, the uninstall.php file is loaded.
41+
*/
42+
register_activation_hook( __FILE__, array( 'Pods_Export_Code', 'activate' ) );
43+
register_deactivation_hook( __FILE__, array( 'Pods_Export_Code', 'deactivate' ) );
44+
45+
add_action( 'plugins_loaded', array( 'Pods_Export_Code', 'get_instance' ) );
46+
47+
/*----------------------------------------------------------------------------*
48+
* Dashboard and Administrative Functionality
49+
*----------------------------------------------------------------------------*/
50+
51+
/*
52+
* If you want to include Ajax within the dashboard, change the following
53+
* conditional to:
54+
*
55+
* if ( is_admin() ) {
56+
* ...
57+
* }
58+
*
59+
* The code below is intended to to give the lightest footprint possible.
60+
*/
61+
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
62+
63+
require_once( plugin_dir_path( __FILE__ ) . 'admin/class-pods-export-code.php' );
64+
add_action( 'plugins_loaded', array( 'Pods_Export_Code_Admin', 'get_instance' ) );
65+
66+
}

public/assets/css/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

public/assets/css/public.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This stylesheet is used to style the public-facing components of the plugin. */

public/assets/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

public/assets/js/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php // Silence is golden

public/assets/js/public.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(function ( $ ) {
2+
"use strict";
3+
4+
$(function () {
5+
6+
// Place your public-facing JavaScript here
7+
8+
});
9+
10+
}(jQuery));

0 commit comments

Comments
 (0)