├── .gitignore
├── .htaccess
├── COPYRIGHT
├── README
├── README.forms
├── assets
├── cpt.css
├── css
│ ├── forms.css
│ ├── global.css
│ ├── messages.css
│ ├── tables.css
│ └── wpf.css
├── img
│ ├── tab_arrow.png
│ └── wimmostmans.jpeg
├── script.js
└── style.css
├── custom-post-type.php
├── dashboard.php
├── languages
├── wpframework-en_US.mo
├── wpframework-en_US.po
├── wpframework-nl_NL.mo
└── wpframework-nl_NL.po
├── library
└── wp-framework
│ ├── Base.php
│ ├── Validators
│ ├── Abstract.php
│ ├── Contains.php
│ ├── Email.php
│ ├── FileSize.php
│ ├── ImageDimensions.php
│ ├── Integer.php
│ ├── Ip.php
│ ├── NotEmpty.php
│ └── Url.php
│ └── Vo
│ └── Form.php
├── plugin.php
├── readme.txt
├── screenshot-1.jpg
├── screenshot-2.jpg
├── views
├── cpt-options.php
├── dashboard-options.php
├── plugin-help.php
├── plugin-index.php
├── plugin-settings.php
├── plugin-side.php
├── widget-options.php
└── widget-view.php
└── widget.php
/.gitignore:
--------------------------------------------------------------------------------
1 | *.DS_Store
2 | *.swp
3 | *.git
4 |
5 | # Exclude textmate project files
6 | *.tmproj
7 |
8 | # Exclude project files
9 | */.idea
10 | *.idea
11 | *.project
12 | *.settings/
13 | *.buildpath
14 |
15 | # Exclude logs
16 | *log
17 | *logs
18 |
19 | # Exclude cache
20 | *cache
21 |
22 | # Builds
23 | *builds
24 | *release
25 | *Preview.zip
26 |
--------------------------------------------------------------------------------
/.htaccess:
--------------------------------------------------------------------------------
1 | Options -Indexes
--------------------------------------------------------------------------------
/COPYRIGHT:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011, Sitebase (http://www.sitebase.be)
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 |
6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 | * Neither the name of Sitebase nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9 |
10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | This is a little framework that I've written so that I finally can write OO-plugins for WordPress.
2 | You can create actions and filter methods that will automaticly get called.
3 | This class is still in a *beta* stage so let me know if you have any tips, suggestions or find any bugs.
4 |
5 | I've included 4 examples so you can take a look how you can write plugins with this framework.
6 | The following examples are included:
7 | - Dashboard widget
8 | - Widget
9 | - Custom post type
10 | - Plugin
11 |
12 | == Tips ==
13 | - When creating a widget from the template don't forget to you need to change the class name and the class constructor name!
14 |
15 |
16 |
17 | == Changelog ==
18 |
19 | = 0.6 =
20 | Remove deprecated function use
21 | Add extra filter and action
22 | Skip extract in load_view if array has no values
23 | NotEmpty validator now also accepts 0 as value
24 |
25 | = 0.5 =
26 | Add filter post_type_link
27 | Add filter post_update_messages
28 | Merge $_FILES and $_POST so can now also apply validators to upload fields
29 | Remove static from load_view method so you can use $this in your views
30 | Add image size validator
31 | Add file size validator
32 | Fixed bug when you add another validator before notempty
33 | Change lowercase directories to camelcase
34 | Added method load to load framework classes
35 | Added cache methods that uses WordPress transient
36 |
37 | = 0.1 =
38 | Initial version release
--------------------------------------------------------------------------------
/README.forms:
--------------------------------------------------------------------------------
1 |
Fields marked with * are required.
2 |
3 |
28 |
29 |
--------------------------------------------------------------------------------
/assets/cpt.css:
--------------------------------------------------------------------------------
1 | /* Form styling */
2 | .options label {
3 | display:block;
4 | float:left;
5 | font-size:12px;
6 | font-weight:bold;
7 | line-height:1.2em;
8 | margin-right:10px;
9 | padding-top:4px;
10 | width:150px;
11 | }
12 | .options label span {
13 | color: #C00;
14 | font-size: 10px;
15 | padding-left: 4px;
16 | }
17 | .options selec{
18 | float: left;
19 | }
20 | .options .form-invalid textarea{
21 | border-color:#CC0000 !important;
22 | }
23 | .options .error {
24 | color: #c00;
25 | }
26 |
27 | /* Table styling */
28 | table.options{
29 | border-top: 1px solid #E3E3E3;
30 | }
31 | table.options input, table.options textarea{
32 | border: 1px solid #DFDFDF;
33 | }
34 | table.options td{
35 | padding: 15px 0px;
36 | border-bottom: 1px solid #E3E3E3;
37 | }
38 |
--------------------------------------------------------------------------------
/assets/css/forms.css:
--------------------------------------------------------------------------------
1 | /**
2 | * CSS Styling forms
3 | *
4 | * @package WPFramework
5 | * @author Sitebase (www.sitebase.be)
6 | * @version 1.0
7 | * @license ${license}
8 | * @copyright Sitebase
9 | */
10 | .wpframework label {
11 | display: block;
12 | float: left;
13 | font-size: 12px;
14 | font-weight: bold;
15 | line-height: 1.2em;
16 | margin-right: 10px;
17 | padding-top: 4px;
18 | /*width: 150px;*/
19 | }
20 |
21 | /** Required start **/
22 | .wpframework label span, .legend-required span {
23 | color: #239CCC;
24 | font-size: 12px;
25 | padding-left: 4px;
26 | }
27 |
28 | .wpframework input,
29 | .wpframework textarea {
30 | border: 1px solid #DFDFDF;
31 | padding: 4px;
32 | }
33 | .wpframework li input,
34 | .wpframework li textarea,
35 | .wpframework li select {
36 | width: 100%;
37 | }
38 | .wpframework .input-file {
39 | position: relative
40 | }
41 | .wpframework input[type="file"] {
42 | display: inline-block;
43 | position: absolute;
44 | left: 0;
45 | top: 0;
46 | opacity: 0;
47 | -moz-opacity: 0;
48 | filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);
49 | }
50 |
51 | .wpframework .button-primary, .wpframework .button {
52 | font-size: 11px !important;
53 | padding: 5px 8px;
54 | }
55 |
56 | /** Checkbox/radio list **/
57 | .wpframework .form-field label{
58 | display: block;
59 | float: none;
60 | font-size: 11px;
61 | }
62 | .wpframework .form-field label input{
63 | display: inline-block;
64 | float: left;
65 | width: auto;
66 | margin-right: 5px;
67 | }
68 |
69 | /** Form extra elements **/
70 | .wpframework fieldset {
71 | margin-bottom: 14px;
72 | }
73 | .wpframework fieldset legend {
74 | border-top: 1px solid #EDEDED;
75 | padding: 4px 10px;
76 | font-weight: bold;
77 | background-color: #F8F8F8;
78 | display: block;
79 | width: 100%;
80 | color: #999;
81 | box-sizing: border-box;
82 | -webkit-box-sizing: border-box;
83 | -moz-box-sizing: border-box;
84 | -ms-box-sizing: border-box;
85 | font-size: 10px;
86 | text-transform: uppercase;
87 | }
88 |
89 | /** Form fields holder labe/field/description **/
90 | .wpframework .field-holder {
91 | border-top: 1px solid #EDEDED;
92 | }
93 | .wpframework .field-holder li {
94 | padding: 15px 5px;
95 | border-bottom: 1px solid #EDEDED;
96 | }
97 | .wpframework .field-holder .form-label, .field-holder .form-field, .field-holder .form-description {
98 | float: left;
99 | box-sizing: border-box;
100 | -webkit-box-sizing: border-box;
101 | -moz-box-sizing: border-box;
102 | -ms-box-sizing: border-box;
103 | }
104 | .wpframework .field-holder .form-label {
105 | width: 20%;
106 | }
107 | .wpframework .field-holder .form-field {
108 | width: 40%;
109 | }
110 | .wpframework .field-holder .form-description {
111 | width: 40%;
112 | padding: 7px 0 0 10px;
113 | }
--------------------------------------------------------------------------------
/assets/css/global.css:
--------------------------------------------------------------------------------
1 | /**
2 | * CSS Global styles
3 | *
4 | * @package WPFramework
5 | * @author Sitebase (www.sitebase.be)
6 | * @version 1.0
7 | * @license ${license}
8 | * @copyright Sitebase
9 | */
10 |
11 | /** Clearfix **/
12 | .clearfix:before, .clearfix:after, .field-holder li:before, .field-holder li:after { content: ""; display: table; }
13 | .clearfix:after, .field-holder li:after { clear: both; }
14 | .clearfix, .field-holder li { zoom: 1; }
15 |
16 | /** Main styling **/
17 | .wpf_content {
18 | width: 100%;
19 | box-shadow: 0 0 3px #c3c3c3;
20 | -webkit-box-shadow: 0 0 3px #c3c3c3;
21 | border-radius: 10px;
22 | background-color: #F8F8F8;
23 | overflow: hidden;
24 | position: relative;
25 | margin: 20px 20px 0 0;
26 | }
27 | .wpf_content .container {
28 | background-color: #FFF;
29 | height: 100%;
30 | box-shadow: inherit;
31 | -webkit-box-shadow: inherit;
32 | overflow: auto;
33 | z-index: 1000;
34 | margin-right: 22%;
35 | }
36 | .wpf_content .content {
37 | margin: 20px;
38 | line-height: 26px;
39 | }
40 | .wpf_content .content h2 {
41 | font-size: 18px;
42 | padding-top: 0px;
43 | }
44 | .wpf_content .content img, .wpf_content .content video {
45 | border: 1px solid #EDEDED;
46 | padding: 5px;
47 | background: #FFF;
48 | }
49 | .wpf_content .content img.left, .wpf_content .content img.right {
50 | margin: 5px 11px 11px 0;
51 | }
52 | .wpf_content .content figure {
53 | text-align: center;
54 | }
55 | .wpf_content .content figcaption {
56 | color: #888;
57 | font-size: 11px;
58 | font-style: italic;
59 | line-height: 14px;
60 | text-align: center;
61 | vertical-align: baseline;
62 | display: block;
63 | padding-top: 5px;
64 | }
65 |
66 |
67 | /** Side styling **/
68 | .wpf_content .side {
69 | position: absolute;
70 | top: 0;
71 | right: 0;
72 | width: 22%;
73 | }
74 | .wpf_content h3 {
75 | display: block;
76 | font-size: 1.17em;
77 | font-weight: normal;
78 | margin: 1em 0 0.3em 0;
79 | color: #666;
80 | }
81 | .wpf_content h4 {
82 | display: block;
83 | font-size: 1.00em;
84 | font-weight: normal;
85 | margin: 0.5em 0;
86 | color: #888;
87 | }
88 | .wpf_content .side p {
89 | font-size: 11px;
90 | color: #333;
91 | }
92 | .wpf_content .side ul {
93 | font-size: 11px;
94 | color: #333;
95 | list-style: disc;
96 | list-style-position: inside;
97 | }
98 | .wpf_content .side img {
99 | border: 1px solid #EDEDED;
100 | padding: 5px;
101 | background: #FFF;
102 | }
103 |
104 |
105 | /** Extra stylings **/
106 | .wpframework .wpfextra {
107 | color: #999;
108 | }
109 | .wpframework .error {
110 | color: #c00;
111 | }
112 | .wpframework .wpfsmall {
113 | font-size: 10px;
114 | line-height: 12px;
115 | }
116 | .wpframework blockquote {
117 | border-left: 4px solid #656565;
118 | padding: 5px 0 5px 10px;
119 | }
120 | .wpframework .left { float: left; }
121 | .wpframework .right { float: right; }
122 |
123 | /** Form footer/header with save buttons **/
124 | .wpframework .wpf_header, .wpframework .wpf_footer {
125 | padding: 10px;
126 | margin-right: 22%;
127 | height: 10px;
128 | }
--------------------------------------------------------------------------------
/assets/css/messages.css:
--------------------------------------------------------------------------------
1 | /**
2 | * This CSS file contains styling for all messages
3 | */
4 |
5 | .wpf_message {
6 | margin: 2px 0 10px 0;
7 | padding: 0 12px;
8 | background-color: #F8F8F8;
9 | background: linear-gradient(top,
10 | white,
11 | #F0F0F0 2%,
12 | #E4E4E4
13 | );
14 | border-color: #E4E4E4 #D9D9D9 #CBCBCB;
15 | background: -moz-linear-gradient(top,
16 | white,
17 | #F0F0F0 2%,
18 | #E4E4E4
19 | );
20 | background: -webkit-gradient(linear, left top, left bottom,
21 | from(white),
22 | color-stop(0.02, #F0F0F0),
23 | to(#E4E4E4)
24 | );
25 | background: linear-gradient(top,
26 | white,
27 | #F0F0F0 2%,
28 | #E4E4E4
29 | );
30 | filter: PROGID:DXImageTransform.Microsoft.Gradient(StartColorStr='#f0f0f0',EndColorStr='#e4e4e4');
31 | border: 1px solid #DFDFDF;
32 | text-shadow: 0 1px 0 white;
33 | box-shadow: 0 1px 0 #FFFFFF inset;
34 | -moz-border-radius: 3px;
35 | -webkit-border-radius: 3px;
36 | border-radius: 3px;
37 | }
38 | .wpf_message p {
39 | color: #4F4F4F;
40 | line-height: 18px;
41 | }
42 |
43 | .wpf_message.success {
44 | background-color: #dde6ba;
45 | border-color: #d0e289 #c6d881 #b8cb71;
46 | background: -moz-linear-gradient(top,
47 | #fff,
48 | #e6efc2 2%,
49 | #d9e2b7
50 | );
51 | background: -webkit-gradient(linear, left top, left bottom,
52 | from(#fff),
53 | color-stop(0.02, #e6efc2),
54 | to(#d9e2b7)
55 | );
56 | background: linear-gradient(top,
57 | #fff,
58 | #e6efc2 2%,
59 | #d9e2b7
60 | );
61 | filter: PROGID:DXImageTransform.Microsoft.Gradient(StartColorStr='#e6efc2',EndColorStr='#d9e2b7');
62 | }
63 |
64 | .wpf_message.problem {
65 | background-color: #f6dbd6;
66 | border-color: #f7d5d6 #f1c8ca #f2b5b8;
67 | background: -moz-linear-gradient(top,
68 | #fff,
69 | #fbe2e3 2%,
70 | #eeccce
71 | );
72 | background: -webkit-gradient(linear, left top, left bottom,
73 | from(#fff),
74 | color-stop(0.02, #fbe2e3),
75 | to(#eeccce)
76 | );
77 | background: linear-gradient(top,
78 | #fff,
79 | #fbe2e3 2%,
80 | #eeccce
81 | );
82 | filter: PROGID:DXImageTransform.Microsoft.Gradient(StartColorStr='#fbe2e3',EndColorStr='#eeccce');
83 | }
84 |
85 | .wpf_message.tip {
86 | background: linear-gradient(top,
87 | white,
88 | #E0F4FF 2%,
89 | #D4E6F0
90 | );
91 | border-color: #B8E1FD #A6D4F4 #9ED1F5;
92 | background: -moz-linear-gradient(top,
93 | white,
94 | #E0F4FF 2%,
95 | #D4E6F0
96 | );
97 | background: -webkit-gradient(linear, left top, left bottom,
98 | from(white),
99 | color-stop(0.02, #E0F4FF),
100 | to(#D4E6F0)
101 | );
102 | background: linear-gradient(top,
103 | white,
104 | #E0F4FF 2%,
105 | #D4E6F0
106 | );
107 | filter: PROGID:DXImageTransform.Microsoft.Gradient(StartColorStr='#e0f4ff',EndColorStr='#d4e6f0');
108 | }
109 |
110 | .wpf_message.warning {
111 | background: linear-gradient(top,
112 | white,
113 | #FFFFB9 2%,
114 | #F0EFAE
115 | );
116 | border-color: #F7DC72 #F4D96C #EACE61;
117 | background: -moz-linear-gradient(top,
118 | white,
119 | #FFFFB9 2%,
120 | #F0EFAE
121 | );
122 | background: -webkit-gradient(linear, left top, left bottom,
123 | from(white),
124 | color-stop(0.02, #FFFFB9),
125 | to(#F0EFAE)
126 | );
127 | background: linear-gradient(top,
128 | white,
129 | #FFFFB9 2%,
130 | #F0EFAE
131 | );
132 | filter: PROGID:DXImageTransform.Microsoft.Gradient(StartColorStr='#ffffb9',EndColorStr='#f0efae');
133 | }
134 |
135 | .base_message {
136 | border: 1px solid;
137 | border-bottom-width: 2px;
138 | color: #4f4f4f;
139 | display: block;
140 | font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif;
141 | font-size: 11px;
142 | line-height: 19px;
143 | margin-bottom: 20px;
144 | overflow: hidden;
145 | position: relative;
146 | -moz-box-shadow: 0px 1px 2px rgba(0,0,0,0.15), 0px 0px 2px rgba(0,0,0,0.05);
147 | -webkit-box-shadow: 0px 1px 2px rgba(0,0,0,0.15), 0px 0px 2px rgba(0,0,0,0.05);
148 | box-shadow: 0px 1px 2px rgba(0,0,0,0.15), 0px 0px 2px rgba(0,0,0,0.05);
149 | -moz-border-radius: 4px;
150 | -webkit-border-radius: 4px;
151 | border-radius: 4px;
152 | }
153 |
154 | .base_message.error {
155 | /* GENERAL */
156 |
157 | }
158 |
--------------------------------------------------------------------------------
/assets/css/tables.css:
--------------------------------------------------------------------------------
1 | /**
2 | * CSS Styling for tables. For example that tables used
3 | * to layout the settings forms
4 | *
5 | * @package WPFramework
6 | * @author Sitebase (www.sitebase.be)
7 | * @version 1.0
8 | * @license ${license}
9 | * @copyright Sitebase
10 | */
11 | .wpf_table {
12 | border-top: 1px solid #EDEDED;
13 | }
14 | .wpf_table td {
15 | padding: 15px 5px;
16 | border-bottom: 1px solid #EDEDED;
17 | }
--------------------------------------------------------------------------------
/assets/css/wpf.css:
--------------------------------------------------------------------------------
1 | @import "global.css";
2 | @import "forms.css";
3 | @import "tables.css";
4 | @import "messages.css";
--------------------------------------------------------------------------------
/assets/img/tab_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sitebase/wpframework/37def493f7a4397e4a2ff1ce986fabd3602de014/assets/img/tab_arrow.png
--------------------------------------------------------------------------------
/assets/img/wimmostmans.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sitebase/wpframework/37def493f7a4397e4a2ff1ce986fabd3602de014/assets/img/wimmostmans.jpeg
--------------------------------------------------------------------------------
/assets/script.js:
--------------------------------------------------------------------------------
1 | // JavaScript Document
2 | jQuery(document).ready(function($) {
3 |
4 | /**
5 | * Handles toggoling of menus
6 | */
7 | $('.toggle-buttton').bind('click', function() {
8 | var content = $(this).parent().next();
9 | var button = $(this);
10 | if(content.is(':visible')){
11 | content.animate({
12 | opacity: 0,
13 | height: 'toggle'
14 | }, 500, 'swing');
15 | button.html("+");
16 | }else{
17 | content.animate({
18 | opacity: 1,
19 | height: 'toggle'
20 | }, 500, 'swing');
21 | button.html("-");
22 | }
23 | });
24 |
25 | });
--------------------------------------------------------------------------------
/assets/style.css:
--------------------------------------------------------------------------------
1 | .wpframework{
2 | position: relative;
3 | }
4 |
5 | /* Style header */
6 | .wpframework h3{
7 | background: #DFDFDF url(../../../../wp-admin/images/gray-grad.png) repeat-x left top;
8 | padding: 10px;
9 | text-shadow: 0 1px 0 #FFFFFF;
10 | font-size: 12px;
11 | border: solid 1px #E3E3E3;
12 | -webkit-border-radius: 6px;
13 | -moz-border-radius: 6px;
14 | }
15 |
16 | /* Header toggle button */
17 | .wpframework h3 a:link, h3 a:visited, h3 a:active{
18 | text-shadow: none;
19 | background-color: #999;
20 | cursor:pointer;
21 | display:block;
22 | float:left;
23 | color:#eee;
24 | padding: 0px 4px;
25 | width: 10px;
26 | text-align: center;
27 | font-size: 10px;
28 | margin-right: 8px;
29 | -webkit-border-radius: 10px;
30 | -moz-border-radius: 10px;
31 | text-decoration: none;
32 | box-shadow:inset 2px 0 10px #000000;
33 | -moz-box-shadow:inset 1px 1px 0px #464646;
34 | }
35 | .wpframework h3 a:hover{
36 | background-color: #464646;
37 | color:#eee;
38 | }
39 |
40 | /* Main layout columns */
41 | .wpframework #column-main {
42 | margin: 0px 315px 0px 0px;
43 | }
44 | .wpframework #column-side {
45 | position: absolute;
46 | top: 52px;
47 | right: 0px;
48 | width: 300px;
49 | }
50 |
51 | /* Link menu */
52 | .wpframework ul.menu {
53 | border-top: 1px solid #E3E3E3;
54 | }
55 | .wpframework ul.menu li {
56 | border-bottom: 1px solid #E3E3E3;
57 | padding: 0px;
58 | margin: 0px;
59 | }
60 | .wpframework ul.menu li a {
61 | display: block;
62 | padding: 5px;
63 | text-decoration: none;
64 | }
65 | .wpframework ul.menu li a:hover{
66 | background-color:#EAF2FA;
67 | color:#333333;
68 | }
69 |
70 | /* Text formatting */
71 | .wpframework .extra {
72 | color:#6B6B6B;
73 | }
74 | .wpframework .small {
75 | font-size: 10px;
76 | line-height: 12px;
77 | }
78 | .wpframework blockquote {
79 | border-left: 4px solid #656565;
80 | padding: 5px 0 5px 10px;
81 | }
82 |
83 | /* Form styling */
84 | .wpframework label {
85 | display:block;
86 | float:left;
87 | font-size:12px;
88 | font-weight:bold;
89 | line-height:1.2em;
90 | margin-right:10px;
91 | padding-top:4px;
92 | width:150px;
93 | }
94 | .wpframework label span {
95 | color: #C00;
96 | font-size: 10px;
97 | padding-left: 4px;
98 | }
99 | .wpframework selec{
100 | float: left;
101 | }
102 | .wpframework .form-invalid textarea{
103 | border-color:#CC0000 !important;
104 | }
105 | .wpframework .error {
106 | color: #c00;
107 | }
108 |
109 | /* Table styling */
110 | .wpframework table{
111 |
112 | }
113 | .wpframework table.options{
114 | border-top: 1px solid #E3E3E3;
115 | }
116 | .wpframework table.options input, .wpframework table.options textarea{
117 | border: 1px solid #DFDFDF;
118 | }
119 | .wpframework table.options td{
120 | padding: 15px 5px;
121 | border-bottom: 1px solid #E3E3E3;
122 | }
123 |
124 | .wpframework .success{
125 | padding: 10px;
126 | margin: 5px 0px;
127 | color: #4F8A10;
128 | background-color: #DFF2BF;
129 | font-size: 11px;
130 | }
131 |
132 | .wpframework .day-part{
133 | width: 13%;
134 | height: 300px;
135 | position: relative;
136 | margin: 0px 5px 0px 0px;
137 | float: left;
138 | color: #FFF;
139 | border-right:1px solid #E3E3E3;
140 | }
141 | .wpframework .day-label{
142 | position: absolute;
143 | top: 0px;
144 | left: 0px;
145 | right: 0px;
146 | text-align: center;
147 | font-size: 9px;
148 | color: #464646;
149 | font-weight: bold;
150 | }
151 | .wpframework .day-in{
152 | position: absolute;
153 | left: 0px;
154 | bottom: 0px;
155 | width: 95%;
156 | background-color: #70883E;
157 | height: 200px;
158 | text-align: center;
159 | font-size: 9px;
160 | }
161 | .wpframework .spacer{
162 | clear: both;
163 | display: block;
164 | }
165 |
--------------------------------------------------------------------------------
/custom-post-type.php:
--------------------------------------------------------------------------------
1 | '',
36 | 'year' => ''
37 | );
38 |
39 | /**
40 | * Constructor
41 | *
42 | * @return void
43 | */
44 | public function __construct(){
45 |
46 | // Call parent constructor
47 | parent::__construct();
48 |
49 | // Validate input
50 | if(!class_exists('WpFramework_Validators_Abstract')) include_once $this->plugin_path . '/library/wp-framework/Validators/Abstract.php';
51 | if(!class_exists('WpFramework_Validators_NotEmpty')) include_once $this->plugin_path . '/library/wp-framework/Validators/NotEmpty.php';
52 | if(!class_exists('WpFramework_Validators_Url')) include_once $this->plugin_path . '/library/wp-framework/Validators/Url.php';
53 | if(!class_exists('WpFramework_Validators_Integer')) include_once $this->plugin_path . '/library/wp-framework/Validators/Integer.php';
54 | $this->_form_validators['website_url'][] = new WpFramework_Validators_NotEmpty(__('This field is required'));
55 | $this->_form_validators['website_url'][] = new WpFramework_Validators_Url(__('This isn\'t a valid URL'));
56 | $this->_form_validators['year'][] = new WpFramework_Validators_Integer(__('This input must be a numeric value'));
57 |
58 | }
59 |
60 | /**********************************************************
61 | * PRIVATE METHODS
62 | **********************************************************/
63 |
64 |
65 | /**********************************************************
66 | * PUBLIC METHODS
67 | **********************************************************/
68 |
69 | public function action_init() {
70 | $portfolio_args = array(
71 | 'label' => __('Portfolio'),
72 | 'singular_label' => __('Portfolio'),
73 | 'public' => true,
74 | 'show_ui' => true,
75 | 'capability_type' => 'post',
76 | 'hierarchical' => false,
77 | 'rewrite' => true,
78 | 'supports' => array('title', 'editor', 'thumbnail')
79 | );
80 |
81 | register_post_type('portfolio',$portfolio_args);
82 | }
83 |
84 | public function action_admin_init() {
85 | add_meta_box("details", "Options", array($this, "options"), "portfolio", "normal", "low");
86 | }
87 |
88 | public function action_save_post($postpage_id) {
89 | $this->save_post_meta($postpage_id, array_keys($this->_form_fields_default), $_POST);
90 | }
91 |
92 | function options(){
93 | global $post;
94 | $data = $this->get_post_meta($post->ID, array_keys($this->_form_fields_default));
95 | if(!is_array($data)) $data = array();
96 |
97 | // If not isset the form is not submitted
98 | $validation_results = $this->validate_fields(array_merge($this->_form_fields_default, $data), $this->_form_validators);
99 | $data['wpform'] = new WpFramework_Vo_Form(array_merge($this->_form_fields_default, $data), $validation_results);
100 | $this->load_view($this->plugin_path . "/views/cpt-options.php", $data);
101 | }
102 |
103 | /**
104 | * Load stylesheet
105 | *
106 | * @return void
107 | */
108 | public function action_admin_print_styles() {
109 | //$this->enqueue_style('cpt-portfolio-style', $this->plugin_url . '/assets/cpt.css', null, '1.0');
110 | $this->enqueue_style('wpframeworktest-style', $this->plugin_url . '/assets/css/wpf.css', null, '1.0');
111 | }
112 |
113 | }
114 |
115 | $_GLOBALS['cpt-example'] = new CptExample();
116 |
--------------------------------------------------------------------------------
/dashboard.php:
--------------------------------------------------------------------------------
1 | plugin_path . '/library/wp-framework/Validators/Abstract.php';
33 | if(!class_exists('WpFramework_Validators_NotEmpty')) include_once $this->plugin_path . '/library/wp-framework/Validators/NotEmpty.php';
34 | $this->_form_validators['text'][] = new WpFramework_Validators_NotEmpty(__('This field is required'));
35 | wp_add_dashboard_widget( self::NAME_SLUG, __( self::NAME, $this->plugin_name ), array(&$this, "display"), array(&$this, "setup") );
36 | }
37 |
38 | public function display() {
39 | $data = $this->get_option(self::NAME_SLUG);
40 | echo 'Your text is: ' . $data['text'];
41 | }
42 |
43 | public function setup() {
44 |
45 | $data = $this->get_option(self::NAME_SLUG);
46 |
47 | // Do form validation
48 | if(!isset($_POST)) $_POST = array();
49 | if(!is_array($data)) $data = array();
50 | $validation_results = $this->validate_fields(array_merge($data, $_POST), $this->_form_validators);
51 | $data['wpform'] = new WpFramework_Vo_Form(array_merge(array_merge($data, $_POST)), $validation_results);
52 |
53 | // Save data if posted
54 | if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset( $_POST['widget_id'] ) && self::NAME_SLUG == $_POST['widget_id'] ) {
55 | $this->save_option(self::NAME_SLUG, $data['wpform']->getFields());
56 | }
57 |
58 | // Load view
59 | $this->load_view($this->plugin_path . "/views/dashboard-options.php", $data);
60 |
61 | }
62 |
63 | }
64 |
65 | $_GLOBALS['dashboard-example'] = new DashboardExample();
66 |
--------------------------------------------------------------------------------
/languages/wpframework-en_US.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sitebase/wpframework/37def493f7a4397e4a2ff1ce986fabd3602de014/languages/wpframework-en_US.mo
--------------------------------------------------------------------------------
/languages/wpframework-en_US.po:
--------------------------------------------------------------------------------
1 | msgid ""
2 | msgstr ""
3 | "Project-Id-Version: Plugin\n"
4 | "Report-Msgid-Bugs-To: \n"
5 | "POT-Creation-Date: 2010-12-11 15:55+0100\n"
6 | "PO-Revision-Date: 2010-12-11 16:15+0100\n"
7 | "Last-Translator: Wim Mostmans \n"
8 | "Language-Team: \n"
9 | "MIME-Version: 1.0\n"
10 | "Content-Type: text/plain; charset=UTF-8\n"
11 | "Content-Transfer-Encoding: 8bit\n"
12 | "X-Poedit-KeywordsList: _;gettext;gettext_noop;__\n"
13 | "X-Poedit-Basepath: .\n"
14 | "X-Poedit-SourceCharset: utf-8\n"
15 | "X-Poedit-SearchPath-0: .\n"
16 | "X-Poedit-SearchPath-1: ..\n"
17 |
18 | #: ../documents/examples/xavisys-plugin-framework.php:249
19 | #: ../documents/examples/efficient-related-posts/xavisys-plugin-framework.php:249
20 | msgid "Donate"
21 | msgstr ""
22 |
23 | #: ../documents/examples/xavisys-plugin-framework.php:256
24 | #: ../documents/examples/efficient-related-posts/xavisys-plugin-framework.php:256
25 | msgid "Support Forum"
26 | msgstr ""
27 |
28 | #: ../documents/examples/xavisys-plugin-framework.php:264
29 | #: ../documents/examples/efficient-related-posts/xavisys-plugin-framework.php:264
30 | msgid "Donate to show your appreciation."
31 | msgstr ""
32 |
33 | #: ../documents/examples/xavisys-plugin-framework.php:275
34 | #: ../documents/examples/efficient-related-posts/xavisys-plugin-framework.php:275
35 | msgid "Settings"
36 | msgstr ""
37 |
38 | #: ../documents/examples/xavisys-plugin-framework.php:292
39 | #: ../documents/examples/efficient-related-posts/xavisys-plugin-framework.php:292
40 | msgid "Like this Plugin?"
41 | msgstr ""
42 |
43 | #: ../documents/examples/xavisys-plugin-framework.php:293
44 | #: ../documents/examples/efficient-related-posts/xavisys-plugin-framework.php:293
45 | msgid "Need Support?"
46 | msgstr ""
47 |
48 | #: ../documents/examples/xavisys-plugin-framework.php:294
49 | #: ../documents/examples/efficient-related-posts/xavisys-plugin-framework.php:294
50 | msgid "Latest news from Xavisys"
51 | msgstr ""
52 |
53 | #: ../documents/examples/xavisys-plugin-framework.php:319
54 | #: ../documents/examples/efficient-related-posts/xavisys-plugin-framework.php:319
55 | #, php-format
56 | msgid "If you have any problems with this plugin or ideas for improvements or enhancements, please use the Xavisys Support Forums."
57 | msgstr ""
58 |
59 | #: ../documents/examples/efficient-related-posts/efficient-related-posts.php:32
60 | msgid "Efficient Related Posts"
61 | msgstr ""
62 |
63 | #: ../documents/examples/efficient-related-posts/efficient-related-posts.php:33
64 | msgid "Related Posts"
65 | msgstr ""
66 |
67 | #: ../documents/examples/efficient-related-posts/efficient-related-posts.php:64
68 | msgid "General Settings"
69 | msgstr ""
70 |
71 | #: ../documents/examples/efficient-related-posts/efficient-related-posts.php:65
72 | msgid "Build Relations"
73 | msgstr ""
74 |
75 | #: ../documents/examples/efficient-related-posts/efficient-related-posts.php:67
76 | msgid "Continue Processing Posts/Pages"
77 | msgstr ""
78 |
79 | #: ../documents/examples/efficient-related-posts/efficient-related-posts.php:535
80 | msgid "Related Posts:"
81 | msgstr ""
82 |
83 | #: ../documents/examples/efficient-related-posts/efficient-related-posts.php:536
84 | msgid "No Related Posts"
85 | msgstr ""
86 |
87 | #: ../views/settings.php:9
88 | msgid "Firstname"
89 | msgstr "Firstname"
90 |
91 | #: ../views/settings.php:11
92 | msgid "This is a little test."
93 | msgstr "This is a little test."
94 |
95 |
--------------------------------------------------------------------------------
/languages/wpframework-nl_NL.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sitebase/wpframework/37def493f7a4397e4a2ff1ce986fabd3602de014/languages/wpframework-nl_NL.mo
--------------------------------------------------------------------------------
/library/wp-framework/Base.php:
--------------------------------------------------------------------------------
1 | array(VALIDATE_REQUIRED, VALIDATE_EMAIL));
81 | * When a form is submitted and there is a field in the form with name "email" then this
82 | * field is checked with to validator methods (validator_required and validator_email)
83 | * if they both return valid than the field has a valid id and the form will be processed
84 | * if all other fields are valid.
85 | *
86 | * You can also use a custom validator. If you for example add "custom_password" then
87 | * the method "validator_custom_password" is called to validate the field.
88 | * Offcourse you will need to add this method to your plugin class.
89 | *
90 | * @deprecated
91 | * @var array
92 | */
93 | protected $form_field_validators = array();
94 |
95 | /**
96 | * Wordpress var types
97 | */
98 | const ACTION = "ACTION";
99 | const FILTER = "FILTER";
100 | const OPTION = "OPTION";
101 |
102 | /**
103 | * User level
104 | */
105 | const USER_LEVEL_ADMINISTRATOR = 8;
106 | const USER_LEVEL_EDITOR = 3;
107 | const USER_LEVEL_AUTHOR = 2;
108 | const USER_LEVEL_CONTRIBUTOR = 1;
109 | const USER_LEVEL_SUBSCRIBER = 0;
110 |
111 | /**
112 | * Option constants that can be retrieved with get_option(CONSTANT);
113 | */
114 | const OPTION_ACTIVE_PLUGINS = "active_plugins";
115 | const OPTION_ADMIN_EMAIL = "admin_email";
116 | const OPTION_SITE_URL = "siteurl";
117 | const OPTION_BLOG_NAME = "blogname";
118 | const OPTION_BLOG_DESCRIPTION = "blogdescription";
119 | const OPTION_DATE_FORMAT = "date_format";
120 | const OPTION_TIME_FORMAT = "time_format";
121 | const OPTION_UPLOAD_PATH = "upload_PATH";
122 | const OPTION_UPLOAD_URL = "upload_url";
123 | const OPTION_PLUGIN_URL = "plugin_url";
124 | const OPTION_WORDPRESS_PATH = "wordpress_path";
125 | const OPTION_DATABASE_INSTANCE = "database_instance";
126 | const OPTION_USERNAME = "username";
127 | const OPTION_USER_LEVEL = "user_level";
128 | const OPTION_USER_ID = "user_id";
129 | const OPTION_LOCALE = "locale";
130 |
131 | /**
132 | * Slug constanct
133 | * Use these to add menu items to existing menus
134 | */
135 | const SLUG_DASHBOARD = "index.php";
136 | const SLUG_POSTS = "edit.php";
137 | const SLUG_MEDIA = "upload.php";
138 | const SLUG_LINKS = "link-manager.php";
139 | const SLUG_PAGES = "edit.php?post_type=page";
140 | const SLUG_COMMENTS = "edit-comment.php";
141 | const SLUG_APPEARANCE = "themes.php";
142 | const SLUG_PLUGINS = "plugins.php";
143 | const SLUG_USERS = "users.php";
144 | const SLUG_TOOLS = "tools.php";
145 | const SLUG_SETTINGS = "options-general.php";
146 |
147 | /**
148 | * Validators
149 | * @var string
150 | */
151 | const VALIDATE_REQUIRED = "required";
152 | const VALIDATE_NUMERIC = "numeric";
153 | const VALIDATE_EMAIL = "email";
154 | const VALIDATE_URL = "url";
155 | const VALIDATE_IP = "ip";
156 | const VALIDATE_ALPHA = "alpha";
157 | const VALIDATE_ALPHA_NUMERIC = "alpha_numeric";
158 | const VALIDATE_LENGTH = "length";
159 | const VALIDATE_HEX_COLOR = "hex_color";
160 | const VALIDATE_DATE = "date";
161 | const VALIDATE_PHONE = "phone";
162 |
163 | /**
164 | * Stylesheet media types
165 | * @var string
166 | */
167 | const MEDIA_ALL = "all";
168 | const MEDIA_SCREEN = "screen";
169 | const MEDIA_HANDHELD = "handheld";
170 | const MEDIA_PRINT = "print";
171 |
172 | /**
173 | * Cache expiration constanct
174 | * @var string
175 | */
176 | const TIME_HOUR = 3600;
177 | const TIME_DAY = 43200;
178 |
179 | /**
180 | * Filter constants
181 | */
182 | //const FILTER_THE_CONTENT = "the_content";
183 |
184 | public function __construct(){
185 | // Set plugin path information
186 | $full_path = $this->get_child_path();
187 | $this->plugin_file = basename($full_path);
188 | $this->plugin_name = basename($full_path, '.php');
189 | $this->plugin_path = dirname($full_path);
190 | $this->plugin_url = $this->get_option(self::OPTION_PLUGIN_URL);
191 |
192 | // Call overwritten methods
193 | $this->call_hooks(self::ACTION);
194 | $this->call_hooks(self::FILTER);
195 |
196 | // Register for activation/deactivation hook if activate is overriden
197 | $overriden_methods = $this->get_overriden_methods(get_class($this));
198 |
199 | if(in_array('activate', $overriden_methods)){
200 | register_activation_hook($full_path, array(&$this, "activate"));
201 | }
202 | if(in_array('deactivate', $overriden_methods)){
203 | register_deactivation_hook($full_path, array(&$this, "deactivate"));
204 | }
205 |
206 | // Enable multilanguage
207 | add_action('init', array(&$this, 'add_textdomain'));
208 |
209 | }
210 |
211 | /**
212 | * This function returns a list of usable wordpress variables
213 | * from a specific type
214 | *
215 | * For example: it can return a list a ACTION constants you can use
216 | *
217 | * This method is for internal use. It is need to auto check wich actions
218 | * are overwritten in the child class
219 | *
220 | * @param string $type
221 | * @return array
222 | */
223 | private function get_wp_type_methods($type=self::ACTION){
224 |
225 | // Get class object
226 | $oClass = new ReflectionClass(get_class($this));
227 | $parent = $oClass->getParentClass();
228 | $methods = $parent->getMethods();
229 |
230 | // Filter out other types than $type
231 | $vars = array();
232 | foreach($methods as $method){
233 | if(substr($method->name, 0, 6) == strtolower($type) && strlen($method->name) > 6){
234 | $vars[] = $method->name;
235 | }
236 | }
237 |
238 | // Return result
239 | return $vars;
240 |
241 | }
242 |
243 | /**
244 | * Get overriden methods for a specific class
245 | *
246 | * @param string $class_name
247 | * @return array
248 | */
249 | private function get_overriden_methods($class_name){
250 | $class = new ReflectionClass($class_name);
251 | $parent = $class->getParentClass();
252 | $methods = $class->getMethods();
253 | $overriden = array();
254 | foreach ($methods as $method)
255 | {
256 | try
257 | {
258 | new ReflectionMethod($parent->getName(), $method->getName());
259 | $decClass = $method->getDeclaringClass();
260 | if ($decClass->getName() == $class_name)
261 | {
262 | $overriden[] = $method->getName();
263 | }
264 | }
265 | catch (exception $e){}
266 | }
267 | return $overriden;
268 | }
269 |
270 | /**
271 | * This function will loop throuh all actions and see if it is
272 | * overwritten in the child calls.
273 | * If that's the case it will call that method
274 | *
275 | * @return void
276 | */
277 | private function call_hooks($type=self::ACTION){
278 |
279 | // Get type vars
280 | $calls = $this->get_wp_type_methods($type);
281 |
282 | // Get a list of overriden methods
283 | $overriden_methods = $this->get_overriden_methods(get_class($this));
284 |
285 | // Check if the action or filter is implemented
286 | // If so, call it
287 | foreach($calls as $method){
288 | if(in_array($method, $overriden_methods)){
289 | switch($method){
290 | case 'filter_plugin_action_links':
291 | $method_string = $method . '_' . plugin_basename($this->plugin_path . '/' . $this->plugin_file);
292 | break;
293 | default:
294 | $method_string = $method;
295 | break;
296 | }
297 | add_action( str_replace(strtolower($type) . '_', '', $method_string), array(&$this, $method) );
298 | }
299 | }
300 |
301 | }
302 |
303 | /**
304 | * Get the path of the child class
305 | *
306 | * @return string
307 | */
308 | private function get_child_path(){
309 | $reflector = new ReflectionClass(get_class($this));
310 | return $this->clean_path($reflector->getFileName());
311 | }
312 |
313 | /**
314 | * Path cleanup function
315 | * - Replaces backslashes with forward slashes
316 | * - Removes trail slashes
317 | *
318 | * @param string $path
319 | * @return string
320 | */
321 | public static function clean_path($path){
322 | $path = str_replace('\\','/', $path);
323 | if(substr($path, -1) == '/'){
324 | return substr($path, 0, -1);
325 | }
326 | return $path;
327 | }
328 |
329 | /**
330 | * Read value from a file
331 | *
332 | * @param string $path
333 | * @param string $method
334 | */
335 | public static function file_read($path, $method='r'){
336 | if(file_exists($path)) {
337 | $handle = fopen($path, "r");
338 | $content = fread($handle, filesize($path));
339 | fclose($handle);
340 | return $content;
341 | } else {
342 | return FALSE;
343 | }
344 | }
345 |
346 | /**
347 | * Read remote file
348 | *
349 | * @param string $url
350 | * @param bool $force_curl
351 | */
352 | public static function file_read_remote($url, $force_curl=false){
353 |
354 | if(function_exists('file_get_contents') && !$force_curl){
355 | return file_get_contents($url);
356 | }else{
357 | if (function_exists('curl_init')) {
358 | $ch = curl_init();
359 | curl_setopt($ch, CURLOPT_URL, $url);
360 | curl_setopt($ch, CURLOPT_HEADER, 0);
361 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
362 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
363 | $content = curl_exec($ch);
364 | curl_close($ch);
365 | return $content;
366 | }
367 | }
368 | trigger_error('Could not read remote file.', E_USER_WARNING);
369 | }
370 |
371 | /**
372 | * Write value to a file
373 | *
374 | * @param string $path
375 | * @param string $value
376 | * @param string $method
377 | * @return void
378 | */
379 | public static function file_write($path, $value, $method='a'){
380 | if(!file_exists($path)) self::file_create($path);
381 | $fh = fopen($path, $method);
382 | fwrite($fh, $value);
383 | fclose($fh);
384 | }
385 |
386 | /**
387 | * Create a file
388 | *
389 | * @param string $path
390 | * @return bool
391 | */
392 | public static function file_create($path){
393 | echo 'create file' . $path;
394 | $fh = @fopen($path, 'w');
395 | if($fh == NULL) return false;
396 | fclose($fh);
397 | if(file_exists($path)) return true;
398 | return false;
399 | }
400 |
401 | /**
402 | * Get file and directory permissions
403 | *
404 | * @param string $path
405 | * @return string
406 | */
407 | public static function file_permission($path){
408 | return substr(fileperms($path), -3);
409 | }
410 |
411 | /**
412 | * Proxy for the get_option function
413 | * This is needed to handle some of the WPBase option constants
414 | * because they are not directly accisble by get_option
415 | *
416 | * @param string $option
417 | * @return *
418 | */
419 | protected function get_option($option){
420 |
421 | switch($option){
422 | case self::OPTION_UPLOAD_PATH:
423 | $upload_dir_info = wp_upload_dir();
424 | return $upload_dir_info['basedir'];
425 | case self::OPTION_UPLOAD_URL:
426 | $upload_dir_info = wp_upload_dir();
427 | return $upload_dir_info['baseurl'];
428 | case self::OPTION_PLUGIN_URL:
429 | return WP_PLUGIN_URL . "/" . basename($this->plugin_path);
430 | case self::OPTION_WORDPRESS_PATH:
431 | return $this->clean_path(ABSPATH);
432 | case self::OPTION_DATABASE_INSTANCE:
433 | global $wpdb;
434 | return $wpdb;
435 | case self::OPTION_USER_ID:
436 | $user_info = get_userdata(1);
437 | return $user_info->ID;
438 | case self::OPTION_USERNAME:
439 | $user_info = get_userdata(1);
440 | return $user_info->user_login;
441 | case self::OPTION_USER_LEVEL:
442 | $user_info = get_userdata(1);
443 | return $user_info->user_level;
444 | case self::OPTION_LOCALE:
445 | return get_locale();
446 | default:
447 | return get_option($option);
448 | }
449 |
450 | }
451 |
452 | /**
453 | * Set opions in the database
454 | * with this method you can save/update an array/object in the WP database
455 | *
456 | * @param string $name Unique name to save the data to. For example use the plugin name
457 | * @param * $data
458 | * @return void
459 | */
460 | public function save_option($name, $data){
461 | $option = get_option($name);
462 | if (!isset($option)){
463 | add_option($name, $data);
464 | }else{
465 | update_option($name, $data);
466 | }
467 | }
468 |
469 | /**
470 | * Delete options from the database
471 | *
472 | * @param string $name
473 | * @return bool
474 | */
475 | public function delete_option($name){
476 | delete_option($name);
477 | return !get_option($name);
478 | }
479 |
480 | /**
481 | * Get the current opened url
482 | *
483 | * @param array $strip_attributes The attributes you want to strip from the returned url. For example ?name=sitebase&age=24 strip age will return ?name=sitebase
484 | * @return string
485 | */
486 | public function get_current_url($strip_attributes=array(), $strip_all=false) {
487 | $pageURL = 'http';
488 | if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") $pageURL .= "s";
489 | $pageURL .= "://";
490 | if ($_SERVER["SERVER_PORT"] != "80") {
491 | $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
492 | }else {
493 | $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
494 | }
495 |
496 | if($strip_all){
497 | $parts = explode('?', $pageURL);
498 | return $parts[0];
499 | }
500 |
501 | $parts = explode("&", $pageURL);
502 | $clean_parts = array();
503 | foreach($parts as $part){
504 | $key_value = explode("=", $part);
505 | if(!in_array($key_value[0], $strip_attributes)){
506 | $clean_parts[] = $part;
507 | }
508 | }
509 |
510 | return implode("&", $clean_parts);
511 | }
512 |
513 | /**
514 | * Get the total table name
515 | * this adds the prefix to the name
516 | *
517 | * @param string $table
518 | * @return string
519 | */
520 | protected function get_table_name($table){
521 | return $this->get_option(self::OPTION_DATABASE_INSTANCE)->prefix . $table;
522 | }
523 |
524 | /**
525 | * Check if a database exists
526 | *
527 | * @param string $ptable Prefixed table name
528 | * @return bool
529 | */
530 | protected function table_exists($ptable){
531 | return ($this->get_option(self::OPTION_DATABASE_INSTANCE)->get_var("SHOW TABLES LIKE '" . $ptable . "'") == $ptable );
532 | }
533 |
534 | /**
535 | * Create table and check if the table exists
536 | * This functions uses the dbDelta
537 | * The advantage of this is that it can change the
538 | * structure of a table if it is changed
539 | *
540 | * @param string $create The SQL create statement
541 | * @param string $ptable Fill in this if you want the method to check if the table is created
542 | * @return bool
543 | */
544 | protected function table_create($create, $ptable=null){
545 | require_once( $this->get_option(self::OPTION_WORDPRESS_PATH) . '/wp-admin/includes/upgrade.pgp');
546 | dbDelta($create);
547 | if($table == null) return true;
548 | return $this->table_exists($ptable);
549 | }
550 |
551 | /**
552 | * Delete a table
553 | *
554 | * @param string $ptable
555 | * @return bool
556 | */
557 | protected function table_delete($ptable){
558 | $database = $this->get_option(self::OPTION_DATABASE_INSTANCE);
559 | $database->query("DROP TABLE '" . $database->escape($ptable) . "'");
560 | return !$this->table_exists($ptable);
561 | }
562 |
563 | /**
564 | * Writes a logtext to a file in the plugin root directory
565 | *
566 | * @param string $value
567 | * @return void
568 | */
569 | public function log($value){
570 |
571 | // If debug mode off stop
572 | if(!$this->debug_mode) return;
573 |
574 | // Get backtrace
575 | $trace = debug_backtrace();
576 |
577 | // If value is object or array convert it to string
578 | if(is_object($value) || is_array($value)) $value = print_r($value, true);
579 |
580 | // Vars
581 | $find = array('%ip%', '%date%', '%time%', '%message%', '%file%', '%line%');
582 | $replace = array($_SERVER['REMOTE_ADDR'], date("m/d/y"), date('H:i:s'), $value, $trace[0]['file'], $trace[0]['line']);
583 | $line_format = '%ip% - [%date% %time%] %message% (%file%:%line%)' . "\n";
584 | $line = str_replace( $find, $replace, $line_format);
585 |
586 | // Create log file path
587 | $logfile = $this->plugin_path . "/logs/" . date('Ymd') . ".log";
588 |
589 | // Write to log
590 | $this->file_write($logfile, $line);
591 |
592 | }
593 |
594 | /**
595 | * Check if a file is still valid as cache
596 | *
597 | * @param string $file
598 | * @param int $ttl Time to live in seconds
599 | * @
600 | */
601 | protected function is_valid_cache_file($file, $ttl){
602 | if(file_exists($file) && (filemtime($file) > (time() - $ttl))){
603 | return TRUE;
604 | }else{
605 | return FALSE;
606 | }
607 | }
608 |
609 | /**
610 | * Save data to cache
611 | *
612 | * @param string $name
613 | * @param * $value
614 | * @param int $expiration
615 | */
616 | public function save_cache($name, $value, $expiration=null) {
617 | set_transient($name, $value, $expiration);
618 | }
619 |
620 | /**
621 | * Get cache
622 | *
623 | * @param $name
624 | * @return *
625 | */
626 | public function get_cache($name) {
627 | return get_transient($name);
628 | }
629 |
630 | /**
631 | * Delete a cache items
632 | *
633 | * @param string $name
634 | * @return void
635 | */
636 | public function delete_cache($name) {
637 | delete_transient($name);
638 | }
639 |
640 | /**
641 | * Add an options page
642 | *
643 | * @param string $page_title The page title
644 | * @param string $menu_title The text to use as menu link
645 | * @param int $user_level Use the USER_LEVEL constants
646 | * @param string $menu_slug The string used in the url
647 | * @param array $function The function to call when the menu link is clicked
648 | * @return void
649 | */
650 | protected function add_options_page($page_title, $menu_title, $user_level, $menu_slug, $function){
651 | return add_options_page($page_title, $menu_title, $user_level, $menu_slug, $function);
652 | }
653 |
654 | /**
655 | * Add a new menu
656 | *
657 | * @param string $page_title The page title
658 | * @param string $menu_title The text to use as menu link
659 | * @param int $user_level Use the USER_LEVEL constants
660 | * @param string $menu_slug The string used in the url
661 | * @param array $function The function to call when the menu link is clicked
662 | * @param string $icon_url Url to an icon
663 | * @param int $position Menu order
664 | * @return void
665 | */
666 | protected function add_menu_page($page_title, $menu_title, $user_level, $menu_slug, $function, $icon_url, $position){
667 | return add_menu_page($page_title, $menu_title, $user_level, $menu_slug, $function, $icon_url, $position);
668 | }
669 |
670 | /**
671 | * Add a sub menu
672 | *
673 | * @param string $parent_slug The slug of the parent menu (Use the SLUG_... constants to add to existing menus)
674 | * @param string $page_title The page title
675 | * @param string $menu_title The text to use as menu link
676 | * @param int $user_level Use the USER_LEVEL constants
677 | * @param string $menu_slug The string used in the url
678 | * @param array $function The function to call when the menu link is clicked
679 | * @return void
680 | */
681 | protected function add_submenu_page($parent_slug, $page_title, $menu_title, $user_level, $menu_slug, $function){
682 | return add_submenu_page($parent_slug, $page_title, $menu_title, $user_level, $menu_slug, $function);
683 | }
684 |
685 | /**
686 | * Parse a view file
687 | *
688 | * @param string $file The view file you want to use
689 | * @param array $data Data that you want to use in the template
690 | * @return void
691 | */
692 | public function load_view($file, $data=array(), $echo=true){
693 |
694 | // Make variables
695 | if(is_array($data) && (count($data) > 0)) {
696 | extract( $data );
697 | }
698 |
699 | // Check if template exists
700 | if( file_exists($file) ){
701 | ob_start();
702 | include($file);
703 | $parsed = ob_get_contents();
704 | ob_end_clean();
705 |
706 | if(!$echo) {
707 | return $parsed;
708 | }
709 | echo $parsed;
710 | } else {
711 | throw new Exception('Template file doesn\'t exist');
712 | }
713 | }
714 |
715 | /**
716 | * Clean up a string to show on the screen.
717 | * This can be used to secure your plugins against XSS and other security bugs
718 | *
719 | * I use wp_specialchars instead of htmlspecialchars
720 | * htmlspecialchars will double encode html entities if run twice
721 | *
722 | * @param string $value
723 | * @return string
724 | */
725 | protected function clean_display_string($value){
726 | if(!is_string($value)) return $value;
727 | return stripslashes(esc_html($value));
728 | }
729 |
730 | /**
731 | * The same as clean_display_string but applies this
732 | * to all values in the array
733 | *
734 | * @param array $values
735 | * @return array
736 | */
737 | protected function clean_display_array($values){
738 | return array_map(array(&$this, 'clean_display_string'), $values);
739 | }
740 |
741 |
742 | /**
743 | *
744 | * Enter description here ...
745 | */
746 | public function auto_handle_forms($defaults=array()) {
747 | if(!count($_POST) || !count($this->form_handlers)) return new WpFramework_Vo_Form($defaults);
748 | foreach($this->form_handlers as $key => $settings) {
749 | if(isset($_POST[$key])){
750 | $form_vo = $this->handle_form($defaults, $settings['validators'], $settings['callback']);
751 | }
752 | }
753 | return $form_vo;
754 | }
755 |
756 | /**
757 | * Handle forms
758 | * The first thing this method does is check if the submitted values are valid
759 | * If not it returns an array with invalid fields
760 | * else it calls the correct form handler
761 | *
762 | * @param array $default Default form values
763 | * @param array $validators Optitional array of validators to use
764 | * @param array $callback Optitional method/function to call after validation
765 | * @return array
766 | */
767 | public static function handle_form($defaults, $validators=null, $callback=null){
768 |
769 | // Validate form fields
770 | $validation_results = self::validate_fields(array_merge($_POST, $_FILES), $validators);
771 |
772 | // Set defaults to array if not array
773 | if(!is_array($defaults)) $defaults = array();
774 |
775 | // Call form handler method if there is one defined and form is valid
776 | // Else return the validation result
777 | if(self::is_form_valid($validation_results) && isset($callback)){
778 | if(is_callable($callback, false)){
779 | $form_vo = new WpFramework_Vo_Form(array_merge($defaults, $_POST, $_FILES));
780 | $form_vo->setSaved(true);
781 | call_user_func($callback, &$form_vo);
782 | return $form_vo;
783 | }else{
784 | throw new Exception('Form handler method "' . $current_form_handler[1] . '" is not callable.');
785 | }
786 | }else{
787 | $form_vo = new WpFramework_Vo_Form(array_merge($defaults, $_POST, $_FILES), $validation_results);
788 | return $form_vo;
789 | }
790 |
791 | }
792 |
793 | /**
794 | * Call validation methods for the coresponding post data fields
795 | *
796 | * @param array $data
797 | * @param array $validators
798 | * @return array
799 | */
800 | public static function validate_fields($data, $validators){
801 | $results = array();
802 | foreach($data as $key => $value){
803 | if(isset($validators[$key]) && count($validators[$key]) > 0){
804 |
805 | // Need to do a separate loop because otherwise
806 | // if another validator is added before the NotEmpty validator
807 | // the field will not show an error if it's empty although it's required.
808 | $is_required = false;
809 | foreach($validators[$key] as $validator){
810 | if(get_class($validator) == 'WpFramework_Validators_NotEmpty') $is_required = true;
811 | }
812 |
813 | foreach($validators[$key] as $validator){
814 | $valid = $validator->Validate($value);
815 | if(!$valid){
816 | $results[$key][] = $validator->GetMessage();
817 | break;
818 | }
819 | }
820 | if(!$is_required && !is_array($value) && trim($value) == '') {
821 | unset($results[$key]);
822 | }
823 | }
824 | }
825 | return $results;
826 | }
827 |
828 | /**
829 | * Check based on the result array of validateFields if
830 | * a form is valid or not
831 | *
832 | * @param array $validation_results
833 | * @return bool
834 | */
835 | private static function is_form_valid($validation_results){
836 | foreach($validation_results as $key => $value){
837 | if($value != ""){
838 | return false;
839 | }
840 | }
841 | return true;
842 | }
843 |
844 | /**
845 | * Load a js script files
846 | *
847 | * @param string $handle Name of the script. Lowercase string
848 | * @param string $src Url to the script. Example $this->plugin_url . '/js/file.js'
849 | * @param array $deps Array of files where this script depends on. For example array('jquery')
850 | * @param string $ver Specify script version. This solves caching problems when you changes things in your code
851 | * @param bool $in_footer Normally scripts are placed in the head, if this is set to true it will be placed at the bottom of the .
852 | * @return void
853 | */
854 | protected function enqueue_script($handle, $src=null, $deps=null, $ver='1.0', $in_footer=true ){
855 | wp_enqueue_script($handle, $src, $deps, $ver, $in_footer);
856 | }
857 |
858 | /**
859 | * Load a css stylesheet
860 | *
861 | * @param string $handle Name of the stylesheet
862 | * @param string $src Url to the stylesheet. Example $this->plugin_url . '/css/file.css'
863 | * @param array $deps Array of files where this style depends on. For example array(handle_name)
864 | * @param string $ver Specify stylesheet version. This solves caching problems when you changes things in your code
865 | * @param string $media Media type for your stylesheet
866 | * @return void
867 | */
868 | protected function enqueue_style($handle, $src=null, $deps=null, $ver='1.0', $media=self::MEDIA_ALL){
869 | wp_enqueue_style($handle, $src, $deps, $ver, $media);
870 | }
871 |
872 | /**
873 | * Init action
874 | * Load the text domain
875 | * enables translations for plugin
876 | *
877 | * @return void
878 | */
879 | public function add_textdomain(){
880 | load_plugin_textdomain( $this->plugin_name, false, $this->plugin_name . '/languages/' );
881 | }
882 |
883 | /**
884 | * Add a form handler for a specific form
885 | *
886 | * This method takes 3 params. With the first parameter
887 | * you specify which form you want to handle. You for this paramter the name of the submit button
888 | * So make sure to give every form a unique submit button name.
889 | *
890 | * @param string $submit_name Name of the submit button
891 | * @param array $validators A list of validators to use for the different fields. It's an array of form field names as keys and the value is a array of validators to apply to that field.
892 | * @param function/array $callback The function or method to call after this form is valid. To call a method you can use array($this, 'method_name')
893 | */
894 | public function add_form_handler($submit_name, $validators, $callback) {
895 | $this->form_handlers[$submit_name] = array('callback' => $callback, 'validators' => $validators);
896 | }
897 |
898 | /**
899 | * Update post meta
900 | * This can be used to save meta field for custom post types
901 | *
902 | * @param int $post_id
903 | * @param array $fields An array of fields you want to save from the $data param
904 | * @param array $data Data array
905 | * @return void
906 | */
907 | public function save_post_meta($post_id, $fields, $data) {
908 | foreach($fields as $field) {
909 | if(isset($data[$field])) {
910 | update_post_meta($post_id, $field, $data[$field]);
911 | }
912 | }
913 | }
914 |
915 | /**
916 | * Get post meta data
917 | *
918 | * @param int $post_id
919 | * @param array $fields
920 | * @return array
921 | */
922 | public function get_post_meta($post_id, $fields=null) {
923 | $data = get_post_custom($post_id);
924 | if(!isset($fields))
925 | $result = array();
926 | foreach($fields as $field) {
927 | if(isset($data[$field])) {
928 | $result[$field] = trim($data[$field][0]);
929 | }
930 | }
931 | return $result;
932 | }
933 |
934 | public function shortcode($atts){
935 | $class = str_replace("_main", "", get_class($this));
936 | $args['widget_id'] = WB_WidgetHelper::generate_widget_id($class);
937 | $args['widget_name'] = str_replace("_", " ", $class);
938 | $args['before_widget'] = '
';
939 | $args['after_widget'] = '
';
940 | $args['before_title'] = '
';
941 | $args['after_title'] = '
';
942 |
943 | // Convert Yes checkbox value
944 | foreach($atts as $key => $value){
945 | if(!strcmp($value, 'true') || $value == 'yes'){
946 | $atts[$key] = 'Yes';
947 | }
948 | }
949 |
950 | // Buffer output and return
951 | ob_start();
952 | $this->widget($args, $atts);
953 | $content = ob_get_contents();
954 | ob_end_clean();
955 |
956 | return $content;
957 | }
958 |
959 | /**
960 | * Widget display method
961 | *
962 | * @param array $args
963 | * @param array $instance
964 | * @return void
965 | */
966 | public function widget($args, $instance) {}
967 |
968 | /**
969 | * Widget update method
970 | *
971 | * @param array $new_instance
972 | * @param array $old_instance
973 | * @return void
974 | */
975 | public function update($new_instance, $old_instance) {
976 | logpress($old_instance);
977 | }
978 |
979 | /**
980 | * Widget form method
981 | *
982 | * @param array $instance
983 | * @return void
984 | */
985 | public function form($instance) {}
986 |
987 | /**
988 | * Load method to load core classes like validators or value objects
989 | *
990 | * @param string/array $class
991 | * @param string $prefix Prefix to use if you load an array of classes. This way you don't always need to include the complete prefix
992 | * @return void
993 | */
994 | public function load($class, $prefix=null) {
995 | if(is_array($class)){
996 | foreach($class as $res) {
997 | if(isset($prefix)) $res = $prefix . $res;
998 | self::_load($res);
999 | }
1000 | return;
1001 | }
1002 | if(isset($prefix)) $class = $prefix . $class;
1003 | $this->_load($class);
1004 | }
1005 |
1006 | private function _load($class) {
1007 | $path = str_replace(array('_', 'WpFramework'), array('/', ''), $class) . '.php';
1008 | $full_path = self::clean_path(dirname(__FILE__)) . $path;
1009 | if(!class_exists($class) && file_exists($full_path)) {
1010 | require_once $full_path;
1011 | }
1012 | }
1013 |
1014 |
1015 |
1016 | /**
1017 | * WP_Widget trigger
1018 | *
1019 | * @param string $id_base Optional Base ID for the widget, lower case,
1020 | * if left empty a portion of the widget's class name will be used. Has to be unique.
1021 | * @param string $name Name for the widget displayed on the configuration page.
1022 | * @param array $widget_options Optional Passed to wp_register_sidebar_widget()
1023 | * - description: shown on the configuration page
1024 | * - classname
1025 | * @param array $control_options Optional Passed to wp_register_widget_control()
1026 | * - width: required if more than 250px
1027 | * - height: currently not used but may be needed in the future
1028 | */
1029 | public function WP_Widget( $id_base = false, $name, $widget_options = array(), $control_options = array() ) {
1030 | parent::__construct( $id_base, $name, $widget_options, $control_options );
1031 | }
1032 |
1033 | /**
1034 | * Get admin page nav tabs
1035 | *
1036 | * @param array $tabs
1037 | * @return string
1038 | */
1039 | public function getNavTabs($tabs, $current=null) {
1040 | $html = "";
1041 | $html_tab_format = '%s';
1042 | foreach($tabs as $key => $name) {
1043 | if(!is_null($current)) {
1044 | $class = $current == $key ? ' nav-tab-active' : '';
1045 | } else {
1046 | $class = isset($_GET['tab']) && $_GET['tab'] == $key ? ' nav-tab-active' : '';
1047 | }
1048 | $html .= sprintf($html_tab_format, $class, $this->get_current_url(array('tab')) . '&tab=' . $key, $name);
1049 | }
1050 | return $html;
1051 | }
1052 |
1053 | /**
1054 | * Overwritable functions
1055 | * The reason we create empty method for these actions/filters
1056 | * is code completitions
1057 | */
1058 | public function action_muplugins_loaded(){}
1059 | public function action_plugins_loaded(){}
1060 | public function action_sanitize_commmnt_cookies(){}
1061 | public function action_setup_theme(){}
1062 | public function action_load_textdomain(){}
1063 | public function action_after_setup_theme(){}
1064 | public function action_auth_cookie_valid(){}
1065 | public function action_set_current_user(){}
1066 | public function action_init(){}
1067 | public function action_widgets_init(){}
1068 | public function action_register_sidebar(){}
1069 | public function action_wp_register_sidebar_widget(){}
1070 | public function action_wp_loaded(){}
1071 | public function action_auth_redirect(){}
1072 | public function action_wp_default_scripts($params){}
1073 | public function action_admin_menu(){}
1074 | public function action_admin_init(){}
1075 | public function action_parse_request($params){}
1076 | public function action_send_headers($wp_obj){}
1077 | public function action_parse_query($params){}
1078 | public function action_pre_get_posts($query_obj){}
1079 | public function action_posts_selection(){}
1080 | public function action_wp($wp_obj){}
1081 | public function action_admin_xml_ns(){}
1082 | public function action_wp_default_styles($params){}
1083 | public function action_admin_enqueue_scripts(){}
1084 | public function action_admin_print_styles(){}
1085 | public function action_admin_print_scripts(){}
1086 | public function action_wp_print_styles(){}
1087 | public function action_wp_print_scripts(){}
1088 | public function action_admin_head(){}
1089 | public function action_in_admin_header(){}
1090 | public function action_adminmenu(){}
1091 | public function action_admin_notices(){}
1092 | public function action_restrict_manage_posts(){}
1093 | public function action_the_post($params){}
1094 | public function action_in_admin_footer(){}
1095 | public function action_admin_footer(){}
1096 | public function action_admin_print_footer_scripts(){}
1097 | public function action_wp_print_footer_scripts(){}
1098 | public function action_shutdown(){}
1099 | public function action_add_attachment($attachment_id){}
1100 | public function action_clean_post_cache($post_id){}
1101 | public function action_create_category($category_id){}
1102 | public function action_delete_attachment($attachement_id){}
1103 | public function action_delete_category($category_id){}
1104 | public function action_delete_post($postpage_id){}
1105 | public function action_deleted_post($postpage_id){}
1106 | public function action_edit_attachment($attachment_id){}
1107 | public function action_edit_category($category_id){}
1108 | public function action_edit_post($postpage_id){}
1109 | public function action_pre_post_update($post_id){}
1110 | public function action_private_to_publish($post_obj){}
1111 | public function action_publish_page($page_id){}
1112 | public function action_publish_phone($post_id){}
1113 | public function action_publish_post($post_id){}
1114 | public function action_save_post($postpage_id){}
1115 | public function action_xmlrpc_publish_post($post_id){}
1116 | public function action_comment_closed($post_id){}
1117 | public function action_comment_id_not_found($post_id){}
1118 | public function action_comment_flood_trigger($time_prev_comment, $time_curr_comment){}
1119 | public function action_comment_on_draft($post_id){}
1120 | public function action_comment_post($comment_id, $status){}
1121 | public function action_edit_comment($comment_id){}
1122 | public function action_delete_comment($comment_id){}
1123 | public function action_pingback_post($comment_id){}
1124 | public function action_pre_ping(array $links, $pung){}
1125 | public function action_trackback_post($comment_id){}
1126 | public function action_wp_insert_post($post_id, $post=null){}
1127 |
1128 | /**
1129 | * Runs to check whether a comment should be blacklisted.
1130 | * wp_die to reject the comment.
1131 | */
1132 | public function action_wp_blacklist_check($author, $email, $url, $text, $ip, $user_agent){}
1133 | public function action_wp_set_comment_status($status){}
1134 | public function action_add_link($line_id){}
1135 | public function action_delete_link($link_id){}
1136 | public function action_edit_link($link_id){}
1137 | public function action_atom_entry(){}
1138 | public function action_atom_head(){}
1139 | public function action_atom_ns(){}
1140 | public function action_commentrss2_item(){}
1141 | public function action_do_feed_rss2(){}
1142 | public function action_do_feed_atom(){}
1143 | public function action_do_feed_rdf(){}
1144 | public function action_rdf_header(){}
1145 | public function action_rdf_item(){}
1146 | public function action_rdf_ns(){}
1147 | public function action_rss_head(){}
1148 | public function action_rss_item(){}
1149 | public function action_rss2_head(){}
1150 | public function action_rss2_item(){}
1151 | public function action_rss2_ns(){}
1152 | public function action_comment_form($post_id){}
1153 | public function action_do_robots(){}
1154 | public function action_do_robotstxt(){}
1155 | public function action_get_footer(){}
1156 | public function action_get_header(){}
1157 | public function action_switch_theme($theme_name){}
1158 | public function action_template_redirect(){}
1159 | public function action_wp_footer(){}
1160 | public function action_wp_head(){}
1161 | public function action_wp_meta(){}
1162 | public function action_activity_box_end(){}
1163 | public function action_add_category_form_pre(){}
1164 | public function action_check_passwords (){}
1165 | public function action_dbx_page_advanced (){}
1166 | public function action_dbx_page_sidebar (){}
1167 | public function action_dbx_post_advanced (){}
1168 | public function action_dbx_post_sidebar (){}
1169 | public function action_delete_user($user_id){}
1170 | public function action_edit_category_form (){}
1171 | public function action_edit_category_form_pre(){}
1172 | public function action_edit_tag_form(){}
1173 | public function action_edit_tag_form_pre(){}
1174 | public function action_edit_form_advanced(){}
1175 | public function action_edit_page_form(){}
1176 | public function action_edit_user_profile(){}
1177 | public function action_login_form(){}
1178 | public function action_login_head(){}
1179 | public function action_lost_password(){}
1180 | public function action_lostpassword_form(){}
1181 | public function action_lostpassword_post(){}
1182 | public function action_manage_link_custom_column(){}
1183 | public function action_manage_posts_custom_column(){}
1184 | public function action_manage_pages_custom_column(){}
1185 | public function action_password_reset(){}
1186 | public function action_personal_options_update(){}
1187 | public function action_profile_personal_options (){}
1188 | public function action_profile_update($user_id){}
1189 | public function action_register_form(){}
1190 | public function action_register_post(){}
1191 | public function action_retrieve_password(){}
1192 | public function action_show_user_profile(){}
1193 | public function action_simple_edit_form (){}
1194 | public function action_user_register(){}
1195 | public function action_wp_authenticate(array $data){}
1196 | public function action_wp_login(){}
1197 | public function action_wp_logout(){}
1198 | public function action_wp_dashboard_setup(){}
1199 | public function action_right_now_content_table_end(){}
1200 | public function action_right_now_table_end(){}
1201 | public function action_right_now_discussion_table_end(){}
1202 | public function action_right_now_end(){}
1203 | public function action_blog_privacy_selector(){}
1204 | public function action_check_admin_referer(){}
1205 | public function action_check_ajax_referer(){}
1206 | public function action_generate_rewrite_rules($wp_rewrite){}
1207 | public function action_loop_end(){}
1208 | public function action_loop_start(){}
1209 | public function action_sanitize_comment_cookies(){}
1210 | public function action_wp_scheduled_delete(){}
1211 |
1212 |
1213 | public function filter_plugin_action_links($links){}
1214 | public function filter_attachment_fields_to_edit(array $form_fields, $post_obj){}
1215 | public function filter_attachment_icon($img_tag, $attachment_id){}
1216 | public function filter_attachment_innerHTML($inner_html, $attachment_id){}
1217 | public function filter_content_edit_pre(){}
1218 | public function filter_excerpt_edit_pre(){}
1219 | public function filter_get_attached_file($file_information, $attachment_id){}
1220 | public function filter_get_enclosed(){}
1221 | public function filter_get_pages($pages){}
1222 | public function filter_get_pung(){}
1223 | public function filter_get_the_excerpt(){}
1224 | public function filter_get_the_guid(){}
1225 | public function filter_get_to_ping(){}
1226 | public function filter_icon_dir(){}
1227 | public function filter_icon_dir_uri(){}
1228 | public function filter_prepend_attachment(){}
1229 | public function filter_sanitize_title(){}
1230 | public function filter_single_post_title(){}
1231 | public function filter_the_content(){}
1232 | public function filter_the_content_rss(){}
1233 | public function filter_the_editor_content(){}
1234 | public function filter_the_excerpt(){}
1235 | public function filter_the_excerpt_rss(){}
1236 | public function filter_the_tags(){}
1237 | public function filter_the_title($title){}
1238 | public function filter_the_title_rss(){}
1239 | public function filter_title_edit_pre(){}
1240 | public function filter_wp_dropdown_pages(){}
1241 | public function filter_wp_list_pages(){}
1242 | public function filter_wp_list_pages_excludes(){}
1243 | public function filter_wp_get_attachment_metadata(){}
1244 | public function filter_wp_get_attachment_thumb_file($thumb_file, $attachment_id){}
1245 | public function filter_wp_get_attachment_thumb_url($thumb_file, $attchment_id){}
1246 | public function filter_wp_get_attachment_url($url, $attachment_id){}
1247 | public function filter_wp_mime_type_icon($icon_uri, $mime, $post_id){}
1248 | public function filter_wp_title(){}
1249 | public function filter_add_ping(){}
1250 | public function filter_attachment_fields_to_save($post_attributes, $attachment_fields){}
1251 | public function filter_attachment_max_dims(){}
1252 | public function filter_category_save_pre(){}
1253 | public function filter_comment_status_pre(){}
1254 | public function filter_content_filtered_save_pre(){}
1255 | public function filter_content_save_pre(){}
1256 | public function filter_excerpt_save_pre(){}
1257 | public function filter_name_save_pre (){}
1258 | public function filter_phone_content(){}
1259 | public function filter_ping_status_pre(){}
1260 | public function filter_post_mime_type_pre(){}
1261 | public function filter_status_save_pre(){}
1262 | public function filter_thumbnail_filename(){}
1263 | public function filter_wp_thumbnail_creation_size_limit($max_file_size, $attachment_id, $attachment_file_name){}
1264 | public function filter_wp_thumbnail_max_side_length($image_side_max_size, $attachment_id, $attachment_file_name){}
1265 | public function filter_title_save_pre(){}
1266 | public function filter_update_attached_file($attachment_info, $attachment_id){}
1267 | public function filter_wp_delete_file(){}
1268 | public function filter_wp_generate_attachment_metadata(){}
1269 | public function filter_wp_update_attachment_metadata($meta_data, $attachment_id){}
1270 | public function filter_comment_excerpt(){}
1271 | public function filter_comment_post_redirect($location, $comment_info){}
1272 | public function filter_comment_text(){}
1273 | public function filter_comment_text_rss(){}
1274 | public function filter_comments_array($comment_info, $post_id){}
1275 | public function filter_comments_number(){}
1276 | public function filter_get_comment_excerpt(){}
1277 | public function filter_get_comment_ID(){}
1278 | public function filter_get_comment_text(){}
1279 | public function filter_get_comment_type(){}
1280 | public function filter_get_comments_number(){}
1281 | public function filter_post_comments_feed_link(){}
1282 | public function filter_comment_save_pre($comment_data, $author, $email, $url, $content, $type, $user_id){}
1283 | public function filter_pre_comment_approved(){}
1284 | public function filter_pre_comment_content(){}
1285 | public function filter_wp_insert_post_data($data, $post){}
1286 | public function filter_category_description($description, $category_id, $description, array $category){}
1287 | public function filter_category_feed_link(){}
1288 | public function filter_category_link($link_url, $category_id){}
1289 | public function filter_get_categories($category_list){}
1290 | public function filter_get_category(){}
1291 | public function filter_list_cats(){}
1292 | public function filter_list_cats_exclusions(){}
1293 | public function filter_single_cat_title(){}
1294 | public function filter_the_category($list, $separator=''){}
1295 | public function filter_the_category_rss(){}
1296 | public function filter_wp_dropdown_cats(){}
1297 | public function filter_wp_list_categories(){}
1298 | public function filter_pre_category_description(){}
1299 | public function filter_pre_category_name(){}
1300 | public function filter_pre_category_nicename(){}
1301 | public function filter_attachment_link($link_url, $attachment_id){}
1302 | public function filter_author_feed_link(){}
1303 | public function filter_author_link($url, $author_name, $author_id){}
1304 | public function filter_comment_reply_link($url, $custom_options, $comment_obj, $post_obj){}
1305 | public function filter_day_link($url, $year, $month, $day){}
1306 | public function filter_feed_link($url, $type){}
1307 | public function filter_get_comment_author_link($username){}
1308 | public function filter_get_comment_author_url_link(){}
1309 | public function filter_month_link($url, $year, $month){}
1310 | public function filter_page_link($url, $page_id){}
1311 | public function filter_post_link($url, $post_data){}
1312 | public function filter_the_permalink(){}
1313 | public function filter_year_link($url, $year){}
1314 | public function filter_tag_link($url, $tag_id){}
1315 | public function filter_get_comment_date(){}
1316 | public function filter_get_comment_time(){}
1317 | public function filter_get_the_modified_date(){}
1318 | public function filter_get_the_modified_time(){}
1319 | public function filter_get_the_time(){}
1320 | public function filter_the_date(){}
1321 | public function filter_the_modified_date(){}
1322 | public function filter_the_modified_time(){}
1323 | public function filter_the_time(){}
1324 | public function filter_the_weekday(){}
1325 | public function filter_the_weekday_date($weekday_text, $before_text, $after_text){}
1326 | public function filter_login_redirect(){}
1327 | public function filter_author_email(){}
1328 | public function filter_comment_author(){}
1329 | public function filter_comment_author_rss(){}
1330 | public function filter_comment_email(){}
1331 | public function filter_comment_url(){}
1332 | public function filter_get_comment_author(){}
1333 | public function filter_get_comment_author_email(){}
1334 | public function filter_get_comment_author_IP(){}
1335 | public function filter_get_comment_author_url(){}
1336 | public function filter_login_errors(){}
1337 | public function filter_login_headertitle(){}
1338 | public function filter_login_headerurl(){}
1339 | public function filter_login_message(){}
1340 | public function filter_role_has_cap(){}
1341 | public function filter_sanitize_user($username, $raw_username, $strict){}
1342 | public function filter_the_author(){}
1343 | public function filter_the_author_email(){}
1344 | public function filter_pre_comment_author_email(){}
1345 | public function filter_pre_comment_author_name(){}
1346 | public function filter_pre_comment_author_url(){}
1347 | public function filter_pre_comment_user_agent(){}
1348 | public function filter_pre_comment_user_ip(){}
1349 | public function filter_pre_user_id(){}
1350 | public function filter_pre_user_description(){}
1351 | public function filter_pre_user_display_name(){}
1352 | public function filter_pre_user_email(){}
1353 | public function filter_pre_user_first_name(){}
1354 | public function filter_pre_user_last_name(){}
1355 | public function filter_pre_user_login(){}
1356 | public function filter_pre_user_nicename(){}
1357 | public function filter_pre_user_nickname(){}
1358 | public function filter_pre_user_url(){}
1359 | public function filter_registration_errors(){}
1360 | public function filter_user_registration_email(){}
1361 | public function filter_validate_username($valid, $username){}
1362 | public function filter_get_bookmarks($query_result, $arguments){}
1363 | public function filter_link_category(){}
1364 | public function filter_link_description(){}
1365 | public function filter_link_rating(){}
1366 | public function filter_link_title(){}
1367 | public function filter_pre_link_description(){}
1368 | public function filter_pre_link_image(){}
1369 | public function filter_pre_link_name(){}
1370 | public function filter_pre_link_notes(){}
1371 | public function filter_pre_link_rel(){}
1372 | public function filter_pre_link_rss(){}
1373 | public function filter_pre_link_target(){}
1374 | public function filter_pre_link_url(){}
1375 | public function filter_all_options(){}
1376 | public function filter_bloginfo($info, $show){}
1377 | public function filter_bloginfo_rss($info, $show){}
1378 | public function filter_bloginfo_url(){}
1379 | public function filter_loginout(){}
1380 | public function filter_register(){}
1381 | public function filter_upload_dir($dir, $url, $error=false){}
1382 | public function filter_upload_mimes($mimes){}
1383 | public function filter_attribute_escape(){}
1384 | public function filter_js_escape(){}
1385 | public function filter_autosave_interval(){}
1386 | public function filter_cat_rows(){}
1387 | public function filter_comment_edit_pre(){}
1388 | public function filter_comment_edit_redirect($location, $commend_id){}
1389 | public function filter_comment_moderation_subject($mail_subject, $comment_id){}
1390 | public function filter_comment_moderation_text($mail_body_text, $comment_id){}
1391 | public function filter_comment_notification_headers($mail_header_text, $comment_id){}
1392 | public function filter_comment_notification_subject($mail_subject, $comment_id){}
1393 | public function filter_comment_notification_text($mail_body_text, $comment_id){}
1394 | public function filter_cron_schedules(){}
1395 | public function filter_custom_menu_order(){}
1396 | public function filter_default_content(){}
1397 | public function filter_default_excerpt(){}
1398 | public function filter_default_title(){}
1399 | public function filter_editable_slug(){}
1400 | public function filter_format_to_edit(){}
1401 | public function filter_format_to_post(){}
1402 | public function filter_manage_posts_columns(){}
1403 | public function filter_manage_pages_columns(){}
1404 | public function filter_menu_order(){}
1405 | public function filter_postmeta_form_limit(){}
1406 | public function filter_pre_upload_error(){}
1407 | public function filter_preview_page_link(){}
1408 | public function filter_preview_post_link(){}
1409 | public function filter_richedit_pre(){}
1410 | public function filter_show_password_fields(){}
1411 | public function filter_the_editor($value){}
1412 | public function filter_user_can_richedit($bool){}
1413 | public function filter_user_has_cap(){}
1414 | public function filter_wp_handle_upload($info, $url, $type){}
1415 | public function filter_wp_upload_tabs(){}
1416 | public function filter_mce_spellchecker_languages(){}
1417 | public function filter_mce_css(){}
1418 | public function filter_mce_external_plugins(){}
1419 | public function filter_mce_external_languages(){}
1420 | public function filter_tiny_mce_before_init(){}
1421 | public function filter_locale_stylesheet_uri($uri, $style_dir_uri){}
1422 | public function filter_stylesheet(){}
1423 | public function filter_stylesheet_directory($dir, $stylesheet){}
1424 | public function filter_stylesheet_directory_uri($style_dir_uri, $stylesheet){}
1425 | public function filter_stylesheet_uri($style_uri, $stylesheet){}
1426 | public function filter_template(){}
1427 | public function filter_template_directory($template_dir, $template){}
1428 | public function filter_template_directory_uri($template_dir_uri, $template){}
1429 | public function filter_theme_root(){}
1430 | public function filter_theme_root_uri(){}
1431 | public function filter_404_template(){}
1432 | public function filter_archive_template(){}
1433 | public function filter_attachment_template(){}
1434 | public function filter_author_template(){}
1435 | public function filter_category_template(){}
1436 | public function filter_comments_popup_template(){}
1437 | public function filter_comments_template(){}
1438 | public function filter_date_template(){}
1439 | public function filter_home_template(){}
1440 | public function filter_page_template(){}
1441 | public function filter_paged_template(){}
1442 | public function filter_search_template(){}
1443 | public function filter_single_template(){}
1444 | public function filter_template_include(){}
1445 | public function filter_allowed_redirect_hosts(){}
1446 | public function filter_author_rewrite_rules(){}
1447 | public function filter_category_rewrite_rules(){}
1448 | public function filter_comments_rewrite_rules(){}
1449 | public function filter_create_user_query(){}
1450 | public function filter_date_rewrite_rules(){}
1451 | public function filter_found_posts(){}
1452 | public function filter_found_posts_query(){}
1453 | public function filter_get_editable_authors(){}
1454 | public function filter_gettext($translated_text, $untranslated_text){}
1455 | public function filter_override_load_textdomain(){}
1456 | public function filter_get_next_post_join(){}
1457 | public function filter_get_next_post_sort(){}
1458 | public function filter_get_next_post_where(){}
1459 | public function filter_get_others_drafts(){}
1460 | public function filter_get_previous_post_join(){}
1461 | public function filter_get_previous_post_sort(){}
1462 | public function filter_get_previous_post_where(){}
1463 | public function filter_get_users_drafts(){}
1464 | public function filter_locale(){}
1465 | public function filter_mod_rewrite_rules(){}
1466 | public function filter_post_limits(){}
1467 | public function filter_posts_distinct(){}
1468 | public function filter_posts_fields(){}
1469 | public function filter_posts_groupby(){}
1470 | public function filter_posts_join_paged(){}
1471 | public function filter_posts_orderby(){}
1472 | public function filter_posts_request(){}
1473 | public function filter_post_rewrite_rules(){}
1474 | public function filter_root_rewrite_rules(){}
1475 | public function filter_page_rewrite_rules(){}
1476 | public function filter_posts_where_paged(){}
1477 | public function filter_posts_join(){}
1478 | public function filter_posts_where(){}
1479 | public function filter_query(){}
1480 | public function filter_query_string(){}
1481 | public function filter_query_vars(){}
1482 | public function filter_request(){}
1483 | public function filter_rewrite_rules_array(){}
1484 | public function filter_search_rewrite_rules(){}
1485 | public function filter_the_posts(){}
1486 | public function filter_excerpt_length(){}
1487 | public function filter_excerpt_more(){}
1488 | public function filter_post_edit_form_tag(){}
1489 | public function filter_update_user_query(){}
1490 | public function filter_wp_redirect($url, $http_code){}
1491 | public function filter_xmlrpc_methods(){}
1492 | public function filter_wp_mail_from(){}
1493 | public function filter_wp_mail_from_name(){}
1494 | public function filter_pre_update_option_active_plugins(){}
1495 | public function filter_post_type_link(){}
1496 | public function filter_post_updated_messages(){}
1497 | public function filter_media_buttons_context(){}
1498 |
1499 | public function activate(){}
1500 | public function deactivate(){}
1501 | }
1502 | }
--------------------------------------------------------------------------------
/library/wp-framework/Validators/Abstract.php:
--------------------------------------------------------------------------------
1 | failMessage;
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/library/wp-framework/Validators/Contains.php:
--------------------------------------------------------------------------------
1 | failMessage = $message;
23 | $this->_contain = $contain;
24 | }
25 |
26 | /**
27 | * Validate this element
28 | *
29 | * @access public
30 | * @param int $var
31 | * @return bool
32 | */
33 | public function validate($var){
34 | return strstr(strtolower($var), $this->_contain);
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/library/wp-framework/Validators/Email.php:
--------------------------------------------------------------------------------
1 | failMessage = $message;
20 | }
21 |
22 | /**
23 | * Validate this element
24 | *
25 | * @access public
26 | * @param string $string
27 | * @return string
28 | */
29 | public function validate($string){
30 | return (bool)preg_match("/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i", $string);
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/library/wp-framework/Validators/FileSize.php:
--------------------------------------------------------------------------------
1 | failMessage = $message;
22 | $this->_max_size = $max_bytes_size;
23 | $this->_min_size = $min_bytes_size;
24 | }
25 |
26 | /**
27 | * Validate this element
28 | *
29 | * @access public
30 | * @param string $string
31 | * @return string
32 | */
33 | public function validate($file){
34 | if(isset($this->_max_size) && $file['size'] > $this->_max_size) return false;
35 | if(isset($this->_min_size) && $file['size'] < $this->_min_size) return false;
36 | return true;
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/library/wp-framework/Validators/ImageDimensions.php:
--------------------------------------------------------------------------------
1 | failMessage = $message;
25 | $this->_min_height = $min_height;
26 | $this->_min_width = $min_width;
27 | $this->_max_height = $max_height;
28 | $this->_max_width = $max_width;
29 | }
30 |
31 | /**
32 | * Validate this element
33 | *
34 | * @access public
35 | * @param string $string
36 | * @return string
37 | */
38 | public function validate($image){
39 | list($width, $height, $type, $attr) = getimagesize($image['tmp_name']);
40 | if(isset($this->_max_width) && $width > $this->_max_width) return false;
41 | if(isset($this->_max_height) && $height > $this->_max_height) return false;
42 | if(isset($this->_min_width) && $width < $this->_min_width) return false;
43 | if(isset($this->_min_height) && $height < $this->_min_height) return false;
44 | return true;
45 | }
46 |
47 | }
--------------------------------------------------------------------------------
/library/wp-framework/Validators/Integer.php:
--------------------------------------------------------------------------------
1 | failMessage = $message;
25 | $this->_min = $min;
26 | $this->_max = $max;
27 | }
28 |
29 | /**
30 | * Validate this element
31 | *
32 | * @access public
33 | * @param int $var
34 | * @return bool
35 | */
36 | public function validate($var){
37 |
38 | $valid = TRUE;
39 |
40 | if(is_numeric($this->_min) && $this->_min > $var){
41 | $valid = FALSE;
42 | }
43 |
44 | if(is_numeric($this->_max) && $this->_max < $var){
45 | $valid = FALSE;
46 | }
47 |
48 | if(!is_numeric($var)){
49 | $valid = FALSE;
50 | }
51 |
52 | return $valid;
53 | }
54 |
55 | }
--------------------------------------------------------------------------------
/library/wp-framework/Validators/Ip.php:
--------------------------------------------------------------------------------
1 | failMessage = $message;
20 | }
21 |
22 | /**
23 | * Validate this element
24 | *
25 | * @access public
26 | * @param string $string
27 | * @return string
28 | */
29 | public function validate($string){
30 | return (bool)preg_match("/^(1?\d{1,2}|2([0-4]\d|5[0-5]))(\.(1?\d{1,2}|2([0-4]\d|5[0-5]))){3}$/", $string);
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/library/wp-framework/Validators/NotEmpty.php:
--------------------------------------------------------------------------------
1 | failMessage = $message;
20 | }
21 |
22 | /**
23 | * Validate this element
24 | *
25 | * @access public
26 | * @param string $string
27 | * @return string
28 | */
29 | public function validate($string){
30 | $trim_value = trim($string);
31 | // Not use empty() because in that case 0 is also invalid
32 | return !($trim_value == "");
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/library/wp-framework/Validators/Url.php:
--------------------------------------------------------------------------------
1 | failMessage = $message;
20 | }
21 |
22 | /**
23 | * Validate this element
24 | *
25 | * @access public
26 | * @param string $string
27 | * @return string
28 | */
29 | public function validate($string){
30 | return (bool)preg_match("/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i", $string);
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/library/wp-framework/Vo/Form.php:
--------------------------------------------------------------------------------
1 | _data = $data;
38 | if(isset($errors)) $this->_errors = $errors;
39 | }
40 |
41 | /**
42 | * Set errors
43 | *
44 | * @param array $errors
45 | * @return void
46 | */
47 | public function setErrors($errors) {
48 | $this->_errors = $errors;
49 | }
50 |
51 | /**
52 | * Get errors
53 | *
54 | * @param string $field Optitional name of field to get the errors from
55 | * @param int $limit How many errors to return
56 | * @return array/string
57 | */
58 | public function getErrors($field=null, $limit=0){
59 |
60 | // Get errors from field or all
61 | $errors = array();
62 | if(!isset($field)) {
63 | foreach($this->_errors as $field => $field_errors){
64 | $errors = array_merge($errors, $field_errors);
65 | }
66 | } else {
67 | if(!isset($this->_errors[$field])) return false;
68 | $errors = $this->_errors[$field];
69 | }
70 |
71 | // Limit
72 | if($limit === 0) return $errors;
73 | if($limit === 1) return $errors[0];
74 | return array_slice($errors, $limit);
75 | }
76 |
77 | /**
78 | * Check if a field has errors
79 | *
80 | * @param string $fieldname
81 | * @return bool
82 | */
83 | public function hasErrors($field=null) {
84 | if(isset($field)) {
85 | return isset($this->_errors[$field]) && is_array($this->_errors[$field]) ? true : false;
86 | } else {
87 | return count($this->_errors) > 0;
88 | }
89 | }
90 |
91 | /**
92 | * Set form data
93 | *
94 | * @param array $data
95 | * @return void
96 | */
97 | public function setData($data) {
98 | $this->_data = $data;
99 | }
100 |
101 | /**
102 | * Get current field value
103 | * This is very handy because this way you wouldn't get any undefined variable notices
104 | *
105 | * @todo a sanitized prefix
106 | *
107 | * @return void
108 | */
109 | public function getField($name, $sanitize=true) {
110 | if(isset($this->_data[$name])) {
111 | return $sanitize ? esc_html($this->_data[$name]) : $this->_data[$name];
112 | }
113 | return;
114 | }
115 |
116 | /**
117 | * Get all the fields
118 | *
119 | * @param $sanitize
120 | * @return array
121 | */
122 | public function getFields($sanitize=false) {
123 | if($sanitize) {
124 | return array_map('esc_html', $this->_data);
125 | }
126 | return $this->_data;
127 | }
128 |
129 | /**
130 | * Check if saved
131 | *
132 | * @return bool
133 | */
134 | public function isSaved() {
135 | return $this->_saved;
136 | }
137 |
138 | /**
139 | * Set saved
140 | *
141 | * @param bool $bool
142 | * @return void
143 | */
144 | public function setSaved($bool) {
145 | $this->_saved = $bool;
146 | }
147 |
148 | }
149 |
--------------------------------------------------------------------------------
/plugin.php:
--------------------------------------------------------------------------------
1 | load(array('Abstract', 'NotEmpty', 'Integer', 'FileSize'), 'WpFramework_Validators_');
34 | $validators['firstname'][] = new WpFramework_Validators_NotEmpty(__('This field is required'));
35 | $validators['lastname'][] = new WpFramework_Validators_NotEmpty(__('This field is required'));
36 | $validators['age'][] = new WpFramework_Validators_Integer(__('Make sure this field is between 10 and 99.'));
37 | $validators['age'][] = new WpFramework_Validators_NotEmpty(__('This field is required.'));
38 | $validators['avatar'][] = new WpFramework_Validators_FileSize(__('Maximum 200'), 100000);
39 | $this->add_form_handler('save-settings', $validators, array(&$this, 'save_settings'));
40 |
41 | }
42 |
43 | /**
44 | * Add item to admin menu
45 | *
46 | * @return void
47 | */
48 | public function action_admin_menu(){
49 | $plugin_page = $this->add_options_page('Framework Options', 'Framework Example', self::USER_LEVEL_SUBSCRIBER, self::NAME_SLUG, array(&$this, "admin_page_show"));
50 | }
51 |
52 | /**
53 | * Load stylesheet
54 | *
55 | * @return void
56 | */
57 | public function action_admin_print_styles() {
58 | if(isset($_GET['page']) && $_GET['page'] == self::NAME_SLUG) {
59 | $this->enqueue_style('wpframeworktest-style', $this->plugin_url . '/assets/css/wpf.css', null, '1.0');
60 | }
61 | }
62 |
63 | /**
64 | * Load javascript
65 | *
66 | * @return void
67 | */
68 | public function action_admin_print_scripts() {
69 | if(isset($_GET['page']) && $_GET['page'] == self::NAME_SLUG) {
70 | $this->enqueue_script('jquery');
71 | $this->enqueue_script('wpframeworktest-style', $this->plugin_url . '/assets/script.js', array("jquery"), '1.0');
72 | }
73 | }
74 |
75 | /**
76 | * Load settings page & handle form submit
77 | *
78 | * @return void
79 | */
80 | public function admin_page_show(){
81 |
82 | // Add selected page
83 | // @todo In framework
84 | $data['page'] = isset($_GET['tab']) && in_array($_GET['tab'], array("settings", "help")) ? $_GET['tab'] : "settings";
85 |
86 | $data['options'] = $this->get_option( self::NAME_SLUG );
87 |
88 | // Validate fields and trigger form handler
89 | //$data['validation'] = $this->handle_form();
90 | $data['wpform'] = $this->auto_handle_forms($data['options']);
91 |
92 | // Make sure the data is secure to display
93 | $clean_data = $this->clean_display_array($data);
94 |
95 | // Load view
96 | // The tab to show is handled in the index.php view
97 | $this->load_view($this->plugin_path . "/views/plugin-index.php", $clean_data);
98 | }
99 |
100 | /**
101 | * Handle save settings
102 | *
103 | * @param array $data
104 | * @return void
105 | */
106 | public function save_settings(&$form){
107 | $this->save_option(self::NAME_SLUG, $form->getFields());
108 | }
109 |
110 | /**
111 | * Add a settings link to the plugin overview page
112 | *
113 | * @param array $links
114 | * @return array
115 | */
116 | public function filter_plugin_action_links($links){
117 | $settings_link = 'Settings';
118 | array_unshift($links, $settings_link);
119 | return $links;
120 | }
121 |
122 | /**
123 | * Add some content to the footer
124 | *
125 | * @return void
126 | */
127 | public function action_get_footer() {
128 | $options = $this->get_option(self::NAME_SLUG);
129 | echo 'My name is ' . $options['firstname'] . ' ' . $options['lastname'];
130 | if(is_numeric($options['age'])) {
131 | echo ' and my age is ' . $options['age'];
132 | }
133 | echo '.';
134 | }
135 |
136 | /**
137 | * Delete option when the plugin is deactivated
138 | * Clean up your garbage!
139 | *
140 | * @return void
141 | */
142 | public function deactivate() {
143 | $this->delete_option( self::NAME_SLUG );
144 | }
145 |
146 | }
147 |
148 | $_GLOBALS['plugin-example'] = new PluginExample();
149 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | === Plugin Name ===
2 | Contributors: sitebase
3 | Donate link: http://example.com/
4 | Tags: comments, spam
5 | Requires at least: 2.0.2
6 | Tested up to: 2.1
7 | Stable tag: 4.3
8 |
9 | Here is a short description of the plugin. This should be no more than 150 characters. No markup here.
10 |
11 | == Description ==
12 |
13 | Description
14 |
15 | == Installation ==
16 |
17 | Installation instruction
18 |
19 | 1. Upload `plugin-name.php` to the `/wp-content/plugins/` directory
20 | 2. Activate the plugin through the 'Plugins' menu in WordPress
21 |
22 | == Frequently Asked Questions ==
23 |
24 | = Question 1 =
25 |
26 | Answer 1
27 |
28 | = Question 2 =
29 |
30 | Answer 2
31 |
32 | == Screenshots ==
33 |
34 | 1. Description for screenshot-1.jpg
35 | 2. Description for screenshot-2.jpg
36 |
37 | == Changelog ==
38 |
39 | = 0.1 =
40 | Initial version release
--------------------------------------------------------------------------------
/screenshot-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sitebase/wpframework/37def493f7a4397e4a2ff1ce986fabd3602de014/screenshot-1.jpg
--------------------------------------------------------------------------------
/screenshot-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sitebase/wpframework/37def493f7a4397e4a2ff1ce986fabd3602de014/screenshot-2.jpg
--------------------------------------------------------------------------------
/views/cpt-options.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
hasErrors('website_url') ? '' . $wpform->getErrors('website_url', 1) . '' : __('Fill in the url of the website.', $this->plugin_name) ?>
7 |
8 |
9 |
10 |
11 |
hasErrors('year') ? '' . $wpform->getErrors('year', 1) . '' : __('When did you made this item?', $this->plugin_name) ?>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"
5 |
6 |
7 | A description for your figure
8 |
9 |
1914 translation
10 |
11 |
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?