PluginProbe
Print, PDF & Email by PrintFriendly / 2.0
Print, PDF & Email by PrintFriendly v2.0
5.5.12 5.5.11 trunk 0.2 0.9 1.0 2.0 2.1.8 3.0 3.0.9 3.1.6 3.10.0 3.11.0 3.11.1 3.11.2 3.12.0 3.12.1 3.12.2 3.12.3 3.12.4 3.12.5 3.13.0 3.14.0 3.14.1 3.14.2 All 94 releases
printfriendly / pf_admin.php

pf_admin.php in Print, PDF & Email by PrintFriendly 2.0, at pf_admin.php

264 lines 11.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if(isset($_POST['pf_save'])){
3 $error = false;
4 // we should always have a response, but lets still validate it for security
5 if($_POST['pf_button_type'] == 'pf-button.gif' || $_POST['pf_button_type'] == 'pf-button-big.gif' || $_POST['pf_button_type'] == 'pf-icon-small.gif' || $_POST['pf_button_type'] == 'pf-icon.gif' || $_POST['pf_button_type'] == 'pf-button-both.gif' || $_POST['pf_button_type'] == 'pf-icon-both.gif' || $_POST['pf_button_type'] == 'text-only' || $_POST['pf_button_type'] == 'custom-image'){
6 update_option('pf_button_type',$_POST['pf_button_type']);
7 }else{
8 $error[] = 'Invalid entry for the "Pick Your Button" field. That isn\'t an option to select from! Quit messing with the DOM.';
9 }
10
11 // custom image
12 if(isset($_POST['upload_image'])){
13 if(trim($_POST['upload_image']) == ''){
14 update_option('pf_custom_image',null);
15 }else{
16 $imagedata = @getimagesize($_POST['upload_image']);
17 if(is_array($imagedata)){
18 // well by golly we have an image
19 update_option('pf_custom_image',$_POST['upload_image']);
20 }else{
21 // we need to trigger an error
22 $error[] = 'Please provide a valid image link for the "Custom Image URL" field.';
23 }
24 }
25 }
26
27 // Custom Text
28 if(isset($_POST['custom_text'])){
29 update_option('pf_custom_text',htmlspecialchars($_POST['custom_text']) );
30 }
31
32 // Display custom image with custom text
33 if(isset($_POST['custom_both'])){
34 update_option('pf_custom_both',true);
35 }else{
36 update_option('pf_custom_both',null);
37 }
38
39 // display button
40 if(isset($_POST['pf_show_list'])){
41 if($_POST['pf_show_list']=="all" || $_POST['pf_show_list']=="single" || $_POST['pf_show_list']=="manual"){
42 update_option('pf_show_list',$_POST['pf_show_list']);
43 }else{
44 // something isn't right
45 $error[] = 'Invalid entry for the "Display Button" field. That isn\'t an option to select from! Quit messing with the DOM.';
46 }
47 }
48
49 // now on to the right side
50
51 // placement
52 if(isset($_POST['pf_content_placement'])){
53 if($_POST['pf_content_placement']=="before" || $_POST['pf_content_placement']=="after"){
54 if($_POST['pf_content_placement']=='before'){
55 update_option('pf_content_placement','before');
56 }else{
57 update_option('pf_content_placement',null);
58 }
59 }else{
60 // something isn't right
61 $error[] = 'Invalid entry for the "Placement" field. That isn\'t an option to select from! Quit messing with the DOM.';
62 }
63 }
64
65 // position
66 if(isset($_POST['pf_content_position'])){
67
68 if($_POST['pf_content_position']=="left" || $_POST['pf_content_position']=="right" || $_POST['pf_content_position']=="center"){
69 if($_POST['pf_content_position']=='left'){
70 update_option('pf_content_position',null);
71 }else{
72 update_option('pf_content_position',$_POST['pf_content_position']);
73 }
74 }else{
75 // something isn't right
76 $error[] = 'Invalid entry for the "Position" field. That isn\'t an option to select from! Quit messing with the DOM.';
77 }
78 }
79
80 //margin-top
81 if(isset($_POST['pf_margin_top'])){
82 if(is_numeric($_POST['pf_margin_top'])){
83 update_option('pf_margin_top',$_POST['pf_margin_top']);
84 }else{
85 $error[] ='The value for "Margin Top" must be a number!';
86 }
87 }
88 //margin-right
89 if(isset($_POST['pf_margin_right'])){
90 if(is_numeric($_POST['pf_margin_right'])){
91 update_option('pf_margin_right',$_POST['pf_margin_right']);
92 }else{
93 $error[] ='The value for "Margin Right" must be a number!';
94 }
95 }
96 //margin-bottom
97 if(isset($_POST['pf_margin_bottom'])){
98 if(is_numeric($_POST['pf_margin_bottom'])){
99 update_option('pf_margin_bottom',$_POST['pf_margin_bottom']);
100 }else{
101 $error[] ='The value for "Margin Bottom" must be a number!';
102 }
103 }
104 //margin-left
105 if(isset($_POST['pf_margin_left'])){
106 if(is_numeric($_POST['pf_margin_left'])){
107 update_option('pf_margin_left',$_POST['pf_margin_left']);
108 }else{
109 $error[] ='The value for "Margin Left" must be a number!';
110 }
111 }
112
113 //font color
114 if(isset($_POST['pf_text_color'])){
115 if(preg_match('/^#[a-f0-9]{6}$/i', $_POST['pf_text_color'])){
116 update_option('pf_text_color',$_POST['pf_text_color']);
117 }else{
118 $error[] ='The value for "Font Color" must be a valid hex code!';
119 }
120 }
121
122 //font size
123 if(isset($_POST['pf_text_size'])){
124 if(is_numeric($_POST['pf_text_size'])){
125 update_option('pf_text_size',$_POST['pf_text_size']);
126 }else{
127 $error[] ='The value for "Font Size" must be a number!';
128 }
129 }
130 }
131
132 ?>
133 <div class="wrap">
134 <h2>PrintFriendly: Settings</h2>
135 <?php
136 if(isset($error)){
137 if(is_array($error)){
138 echo '<div class="error"><strong>Settings were not saved, The following problems exist:</strong>';
139 foreach($error as $e){
140 echo '<p>'.$e.'</p>';
141 }
142 echo '</div>';
143 }else{
144 echo '<div class="updated"><p><strong>Settings saved.</strong></p></div>';
145 }
146 }
147 ?>
148 <form action="" method="post" id="pf_admin">
149 <div class="pf_box">
150 <span>Feedback, questions, request a feature? <a href="mailto:support@printfriendly.com?subject=WordPress:"> Email PrintFriendly</a></span>
151 <h3>Button Style</h3>
152 <div class="pf_c">
153 <div id="pf_buttons">
154 <div class="buttongroup">
155 <p><label class="preview_button">
156 <?php echo pf_radio('pf-button.gif'); ?>
157 </label></p>
158 <p><label class="preview_button">
159 <?php echo pf_radio('pf-button-big.gif'); ?>
160 </label></p>
161 <p><label class="preview_button">
162 <?php echo pf_radio('pf-icon-small.gif'); ?>
163 </label></p>
164 </div>
165 <div class="buttongroup">
166 <p><label class="preview_button">
167 <?php echo pf_radio('pf-icon.gif'); ?>
168 </label></p>
169 <p><label class="preview_button">
170 <?php echo pf_radio('pf-button-both.gif'); ?>
171 </label></p>
172 <p><label class="preview_button">
173 <?php echo pf_radio('pf-icon-both.gif'); ?>
174 </label></p>
175 </div>
176 <div class="buttongroup larger">
177 <p><label class="preview_button">
178 <?php echo pf_radio('text-only'); ?> <span class="pf_tip">(text only)</span>
179 </label></p>
180 <p><label class="preview_button" id="pf_custom_image_label">
181 <?php echo pf_radio('custom-image'); ?>
182 <?php if(get_option('pf_custom_image') == false){
183 echo '<img src="'.plugins_url().'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'/images/noimage.png" alt="No Image"/>';
184 } ?> <span class="pf_tip">(Custom Image)</span>
185 </label></p>
186 </div>
187 </div>
188 <div id="pf_button_options">
189 <p>
190 <label class="pf_label">Text Options</label>
191 <div style="clear: both; overflow: hidden;">
192 <div style="float:left; margin-right:5px;">
193 <div id="colorSelector"><div style="background-color: <?php echo get_option('pf_text_color'); ?>;"></div></div>
194 </div>
195 <div style="float:left;">
196 <input type="hidden" name="pf_text_color" id="pf_text_color" value="<?php echo get_option('pf_text_color'); ?>"/>
197 <label class="pf_check"><input type="text" class="pf_px" id="pf_text_size" name="pf_text_size" value="<?php echo get_option('pf_text_size'); ?>"/><span>px <span class="pf_tip">(font size)</span></span></label>
198 </div>
199 </div>
200 </p>
201 <p>
202 <label class="pf_label">Custom Text</label>
203 <input type="text" name="custom_text" id="pf_custom_text" value="<?php echo get_option('pf_custom_text'); ?>"> <span class="pf_tip"> (optional, leave blank for default text)</span>
204 </p>
205 <p>
206 <div id="pf_uploader">
207 <label for="upload_image" class="pf_label">Custom Image URL: </label>
208 <input id="upload_image" type="text" size="36" name="upload_image" value="<?php echo get_option('pf_custom_image'); ?>" />
209 <input id="upload_image_button" type="button" value="Upload Image" class="button-primary"/>
210 <p>Enter an URL or click "Upload Image" to Upload an Image.</p>
211 </div>
212 </p>
213 </div>
214
215 </div> <!-- end box c -->
216 </div> <!-- end box -->
217
218 <div class="pf_box">
219 <h3>Button Position</h3>
220 <div class="pf_c">
221 <p class="pf_float">
222 <label class="pf_label">Vertical Position</label>
223 <label class="pf_check"><input type="radio" class="pf_content_placement" name="pf_content_placement" value="after"<?php if(get_option('pf_content_placement')==null){echo ' checked="checked"';} if(get_option('pf_show_list')=='manual'){echo ' disabled="disabled"';} ?>/><span>After Post/Page Content</span></label>
224 <label class="pf_check"><input type="radio" class="pf_content_placement" name="pf_content_placement" value="before"<?php if(get_option('pf_content_placement')=='before'){echo ' checked="checked"';} if(get_option('pf_show_list')=='manual'){echo ' disabled="disabled"';} ?>/><span>Before Post/Page Content</span></label>
225 </p>
226 <p class="pf_float">
227 <label class="pf_label">Horizontal Position</label>
228 <label class="pf_check"><input type="radio" name="pf_content_position" value="left"<?php if(get_option('pf_content_position')==null){echo ' checked="checked"';} ?>/><span>Left</span></label>
229 <label class="pf_check"><input type="radio" name="pf_content_position" value="center"<?php if(get_option('pf_content_position')=='center'){echo ' checked="checked"';} ?>/><span>Center</span></label>
230 <label class="pf_check"><input type="radio" name="pf_content_position" value="right"<?php if(get_option('pf_content_position')=='right'){echo ' checked="checked"';} ?>/><span>Right</span></label>
231 </p>
232 <p class="pf_float">
233 <label class="pf_label">Margin</label>
234 <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_top" value="<?php echo pf_margin_down('top'); ?>"/><span>px Top</span></label>
235 <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_right" value="<?php echo pf_margin_down('right'); ?>"/><span>px Right</span></label>
236 <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_bottom" value="<?php echo pf_margin_down('bottom'); ?>"/><span>px Bottom</span></label>
237 <label class="pf_check"><input type="text" class="pf_px" name="pf_margin_left" value="<?php echo pf_margin_down('left'); ?>"/><span>px Left</span></label>
238 </p>
239 </div> <!-- end box c -->
240 </div> <!-- end box -->
241
242 <div class="pf_box">
243 <h3>Pages</h3>
244 <div class="pf_c">
245 <p>
246 <label class="pf_label">Display Button:</label>
247 <label class="pf_check"><input type="radio" class="pf_show_list" name="pf_show_list" value="all"<?php if(get_option('pf_show_list')=='all' || get_option('pf_show_list')==null ){echo ' checked="checked"';} ?>/> <span>All Posts and Pages</span></label>
248 <label class="pf_check"><input type="radio" class="pf_show_list" name="pf_show_list" value="single"<?php if(get_option('pf_show_list')=='single' || get_option('pf_show_list')==1){echo ' checked="checked"';} ?>/> <span>Individual Posts and Pages <span class="pf_tip">(Not on frontpage / latest posts) </span></span></label>
249 <label class="pf_check"><input type="radio" class="pf_show_list" name="pf_show_list" value="manual"<?php if(get_option('pf_show_list')=='manual'){echo ' checked="checked"';} ?>/> <span>Manual <span class="pf_tip">(see explaination below) </span></span></label>
250 </p>
251 <p>
252 PrintFriendly, by default, automatically inserts itself into your blog/site. When Manual mode is enabled this allows you to add the button wherever you like. Simply paste the following code into your template file. <br/><span class="pf_tip">WARNING: You need to know how to edit your Theme files or you might cause errors on your page.</span>
253 <h4>Code</h4>
254 <code style="display:block;">&lt;?php if(function_exists('pf_show_link')){echo pf_show_link();} ?&gt;</code>
255 </p>
256 </div> <!-- end box c -->
257 </div> <!-- end Box -->
258 <div style="clear:both;">
259 <input type="submit" class="button-primary" value="Save Options" name="pf_save"/>
260 <input type="reset" class="button-secondary" value="Cancel"/>
261 </div>
262 <br/><br/>
263 </form>
264 </div>