forked from fusillicode/amr-shortcode-any-widget
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamr-admin-form-html.php
More file actions
189 lines (174 loc) · 6.73 KB
/
amr-admin-form-html.php
File metadata and controls
189 lines (174 loc) · 6.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
/**
* Backend Class for use in all amr plugins
* Version 0.1
*/
//------------------------------------------------------------------------------------------------------------------
if (!class_exists('amr_saw_plugin_admin')) {
class amr_saw_plugin_admin {
var $hook = 'amr_saw';
var $filename = 'amr_shortcode_any_widget/amr_shortcode_any_widget.php';
var $longname = 'Shortcode any widget - insert widgets or widget areas into a page.';
var $shortname = 'Shortcode any widget';
var $optionname = '';
var $homepage = '';
var $parent_slug = 'plugin_listings_menu';
var $accesslvl = 'manage_options';
function amr_saw_plugin_admin() {
add_action('admin_menu', array(&$this, 'register_settings_page') );
add_filter('plugin_action_links', array(&$this, 'add_action_link'), 10, 2 );
}
function register_settings_page() {
add_options_page( $this->longname, $this->shortname, $this->accesslvl, $this->hook, array(&$this,'config_page'));
}
function plugin_options_url() {
return admin_url( 'options-general.php?page='.$this->hook );
}
/**
* Add a link to the settings page to the plugins list
*/
function add_action_link( $links, $file ) {
static $this_plugin;
if( empty($this_plugin) )
$this_plugin = $this->filename;
if ( $file == $this_plugin ) {
$settings_link = '<a href="' . $this->plugin_options_url() . '">' . __('Settings') . '</a>';
array_unshift( $links, $settings_link );
}
return $links;
}
function admin_heading($title) {
echo '<div class="wrap" >
<div id="icon-options-general" class="icon32"><br />
</div>
<h2>'.$title.' </h2>';
// <form method="post" action="'
// .esc_url($_SERVER['PHP_SELF'])
// .'">';
// wp_nonce_field($this->hook); /* outputs hidden field */
// ;
}
function admin_subheading($title) {
echo '<h2>'.$title.'</h2>';
}
function config_page() {
$this->admin_heading($this->longname);
echo '<h3><a href="http://wordpress.org/plugins/amr-shortcode-any-widget/">More detailed instructions at the wordpress plugin page.</a></h3>';
echo '<ul>';
echo '<li>';
_e('Drag the widgets you want to use to the shortcodes sidebar.');
echo '</li>';
echo '<li>';
_e('Set the widgets parameters if there are any.');
echo '</li>';
echo '<li>';
_e('You could test the widgets out in a displayable widget area (sidebar/footer), then drag them to the widgets_for_shortcodes sidebar.');
echo '</li>';
echo '<li>';
echo '<a title="Go to widget area" href="'.get_admin_url('','widgets.php').'"> ';
_e('Go to widgets');
echo '</a>';
echo '</li>';
echo '</ul>';
echo '<h2>';
_e('To add a widget area - all widgets in the widget area:');
echo '</h2>';
echo '<ul>';
echo '<li>';
echo '<a title="Create a page" href="'
.add_query_arg('content','[do_widget_area]', get_admin_url('','post-new.php?post_type=page'))
.'"> ';
_e('Create a page with do_widget_area shortcode without the widget_area class');
echo '</a> Hoping to avoid theme styling.';
echo '</li>';
echo '<li>';
echo '<a title="Create a page" href="'
.add_query_arg('content','[do_widget_area widget_area_class=none]', get_admin_url('','post-new.php?post_type=page'))
.'"> ';
_e('Create a page with do_widget_area shortcode');
echo '</a> Hoping to use theme styling.';
echo '</li>';
echo '<li>';
_e('Examples:');
echo '</li>';
echo '<li>';
_e('[do_widget_area] or [do_widget_area widget_area=sidebar-1]');
echo '</li>';
echo '<li>';
_e('NB: Using something like the twenty-fourteen theme? you might end up with white text on a white background. Tweak the widget classes or the html of the wrap or title. If that fails, adjust your css.');
echo '</li>';
echo '</ul>';
echo '<br />';
echo '<h2>';
_e('To add a single widget to a page');
echo '</h2>';
echo '<ul>';
echo '<li>';
_e('Add the shortcode [do_widget widgetname] to a page.');
_e('Examples:');
echo '</li>';
echo '<li>';
_e('[do_widget "tag cloud"] or [do_widget id=widgetid]');
echo '</li>';
echo '<li>';
echo '<a title="Create a page" href="'
.add_query_arg('content','[do_widget Archives widget_classes=none]', get_admin_url('','post-new.php?post_type=page'))
.'"> ';
_e('Create a page with do_widget shortcode and remove widget_classes');
echo '</a>';
echo '</li>';
echo '<li>';
echo '<a title="Create a page" href="'
.add_query_arg('content','[do_widget Archives]', get_admin_url('','post-new.php?post_type=page'))
.'"> ';
_e('Create a page with do_widget shortcode');
echo '</a>';
echo '</li>';
echo '<li>';
echo 'Use title=false to hide a widget title. ';
echo 'Use title=somehtmltag and wrap=somehtmltag to change the html used.';
echo ' Use class=yourclassname to add a class - maybe to override your themes widget styling?';
echo '</li>';
echo '<li>';
echo '[do_widget pages title=false] will hide the widget title';
echo '</li>';
echo '<li>';
echo '[do_widget pages title=h3] give the title a heading 3 html tag.';
echo '</li>';
echo '<li>';
echo '[do_widget categories] or [do_widget name=categories] will do the same thing: display the categories widget.';
echo '</li>';
echo '<li>';
echo '[do_widget "tag cloud" wrap=aside] will wrap the widget in an "aside" html tag.';
echo '</li>';
echo '<li>';
echo '[do_widget "recent posts"]';
echo '</li>';
echo '</ul>';
echo '<p>';
echo 'If the plugin cannot work out what you want, it will show a debug prompt
, click on the debug prompt and look for the name or id of your widget in the shortcodes sidebar (you may have to scroll through a lot of debug info). If the name does not work, try with the id. Sometimes the widget name that wordpress calls it internally is not the same as what you see on the screen and you will need the debug to find the id.';
echo '</p><p><b>';
echo "Valid title html tags are : h1, h2, h3, h4, h5, header, strong, em ";
echo '</b></p><p><b>';
echo "Valid html wrap tags are : div, p, aside , section";
echo '</b></p>';
}
/**
* Info box with link to the support forums.
*/
function plugin_support() {
$content = '<p>'.__('If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the','amrplugin').' <a href="http://wordpress.org/tags/'.$this->hook.'">'.__("Support forums",'amrplugin').'</a>.</p>';
$this->postbox($this->hook.'support', 'Need support?', $content);
}
function text_limit( $text, $limit, $finish = ' […]') {
if( strlen( $text ) > $limit ) {
$text = substr( $text, 0, $limit );
$text = substr( $text, 0, - ( strlen( strrchr( $text,' ') ) ) );
$text .= $finish;
}
return $text;
}
}
}
?>