Changeset 522924
- Timestamp:
- 03/24/2012 05:22:20 AM (14 years ago)
- Location:
- wedgeprint/trunk
- Files:
-
- 2 added
- 5 edited
-
common/wedgeprint_inner.php (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
-
sample/wedgeprint_static_sample.html (added)
-
uninstall.php (added)
-
wedgeprint.php (modified) (8 diffs)
-
wedgeprint_admin.php (modified) (4 diffs)
-
wedgeprint_maintenance.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wedgeprint/trunk/common/wedgeprint_inner.php
r519916 r522924 22 22 return $string_s; 23 23 } 24 25 /** 26 * lets serialize the wedgeprint versioning... 27 */ 28 function serialize_version( $version ){ 29 30 if( $version === '0.1.0' ) { 31 //first release - beta 32 return 1; 33 } else if ( $version === '0.2.0' ) { 34 //second release - beta 35 return 2; 36 } else { 37 //unknown 38 return 0; 39 } 40 41 } 24 42 ?> -
wedgeprint/trunk/readme.txt
r519916 r522924 2 2 Contributors: dweius 3 3 Donate link: http://www.wedgeprint.net/contact/ 4 Tags: ad, spot, com ercial, banner, visual message, screenshot, wedge4 Tags: ad, spot, commercial, banner, visual message, screenshot, wedge 5 5 Requires at least: 3.2.1 6 6 Tested up to: 3.3.1 7 Stable tag: trunk7 Stable tag: 0.2.0 8 8 9 9 WedgePrint plugin for WordPress is an easy way to show your readers short-time visual screenshots while loading the requested blog page. … … 14 14 Messages can be funny, commercial or whatever you want. This plugin is in 'beta' phase at the moment, so 'handle with care', which translates into: 15 15 be careful in its use. It is recommended to try it first in a *pre-production environment* and closely inspect blog statistics for undesirable effects 16 the first days in production mode. The plugin controls through 'cookies' the number of messages a reader gets per hour: ** one**, so readers don't feel saturated ;)16 the first days in production mode. The plugin controls through 'cookies' the number of messages a reader gets per hour: **now variable!**, so readers don't feel saturated ;) 17 17 Visit our web page [WedgePrint.net](http://www.wedgeprint.net "wedgeprint.net") and please follow our **guidelines** and **warnings**. 18 18 You are welcome to give us feedback about this project, feel free to take a look at the code. … … 34 34 == Screenshots == 35 35 36 1. Pending.36 1. Overview of the new 'WedgePrint Manager', `/tags/4.3/wedgeprint-manager-sht-020.png` 37 37 38 38 == Changelog == 39 40 = 0.1.5 = 41 * Improved presentation speed. 42 * Added useful features to the WedgePrint Manager page. 43 * Improved starter version - beta release. 39 44 40 45 = 0.1.0 = … … 43 48 == Upgrade Notice == 44 49 50 = 0.1.5 = 51 Manage several Wedges trough an improved and more intuitive Manager page. Now you can decide the visualization ratio (1- 99 minutes) between Wedges and store many of them!. 52 45 53 = 0.1.0 = 46 *The starter version - try it!54 The starter version - try it! 47 55 -
wedgeprint/trunk/wedgeprint.php
r519916 r522924 3 3 Plugin Name: WedgePrint 4 4 Plugin URI: http://www.wedgeprint.net 5 Description: WedgePrint plugin for WordPress is an easy way to show your readers short-time visual screenshots while loading your requested blog page , once per hour.5 Description: WedgePrint plugin for WordPress is an easy way to show your readers short-time visual screenshots while loading your requested blog page. 6 6 Author: Dweius 7 Version: 0. 1.07 Version: 0.2.0 8 8 Author URI: http://www.wedgeprint.net/dweius/ 9 9 License: GPL2 … … 54 54 55 55 56 if( get_option( 'wedgeprint_cookie_time' ) < floor( time() / ( 3600 ) ) ) {56 if( get_option( 'wedgeprint_cookie_time' ) < floor( time() / ( get_option ( 'wedgeprint_interval' ) * 60 ) ) ) { 57 57 58 58 //if more than an hour has passed since... 59 59 //change cookie name and update time -in hours-. 60 60 update_option( 'wedgeprint_cookie_name', generate_random( 12 ) ); 61 update_option( 'wedgeprint_cookie_time', floor( time() / ( 3600 ) ) );61 update_option( 'wedgeprint_cookie_time', floor( time() / ( get_option ( 'wedgeprint_interval' ) * 60 ) ) ); 62 62 63 63 } … … 68 68 $cookie_rand_name = get_option( 'wedgeprint_cookie_name' ); 69 69 //set cookie expiration time 70 $cookie_time = time() + 3600;70 $cookie_time = time() + (get_option ( 'wedgeprint_interval' ) * 60); 71 71 //construct cookie name as a concatenation 72 72 $cookie_name = $cookie_prefix_name . $cookie_rand_name; … … 83 83 setcookie( $cookie_hash_name, $cookie_hash_value, $cookie_time, COOKIEPATH, COOKIE_DOMAIN, false ); 84 84 //and run the script. 85 add_action( 'wp_print_footer_scripts', 'wedgeprint_script' ); 86 85 //we place it under wp_footer() when possible 86 if( function_exists( 'wp_footer' ) ){ 87 add_action( 'wp_footer', 'wedgeprint_script' ); 88 } else{ 89 //wp_footer() does not exists. 90 add_action( 'wp_print_footer_scripts', 'wedgeprint_script' ); 91 } 87 92 } else { 88 93 //if we find an older cookie from ours... … … 92 97 //if not, set the new cookie and run the script. 93 98 setcookie( $cookie_hash_name, $cookie_hash_value, $cookie_time, COOKIEPATH, COOKIE_DOMAIN, false ); 94 add_action( 'wp_print_footer_scripts', 'wedgeprint_script' ); 99 if( function_exists( 'wp_footer' ) ){ 100 add_action( 'wp_footer', 'wedgeprint_script' ); 101 } else{ 102 //wp_footer() does not exists. 103 add_action( 'wp_print_footer_scripts', 'wedgeprint_script' ); 104 } 95 105 } 96 106 } … … 105 115 //get the saved options... 106 116 $wedge_time = get_option( 'wedgeprint_time' ); 107 $wedge_source = get_option( 'wedgeprint_source' ); 117 $wedge_source = esc_url( get_option( 'wedgeprint_source' ) ); 118 $wedgeprint_closeid = get_option( 'wedgeprint_closeid' ); 108 119 //generate a random name to cancel the show... 109 120 $wedgeprint_frame_id = generate_random( 12 ); 110 121 $wedgeprint_frameset_id = generate_random( 12 ); 122 $wedgeprint_script_id = generate_random( 12 ); 111 123 112 124 //the magic starts... 113 echo "<script type='text/javascript' >(function(){fs = document.createElement('frameset'); fs.framespacing = '0px'; fs.rows='*'; fs.cols='*'; fs.id='$wedgeprint_frameset_id';125 echo "<script type='text/javascript' id='$wedgeprint_script_id'>(function(){fs = document.createElement('frameset'); fs.framespacing = '0px'; fs.rows='*'; fs.cols='*'; fs.id='$wedgeprint_frameset_id'; 114 126 f=document.createElement('frame'); f.src= '$wedge_source'; 115 127 f.frameBorder = '0'; f.scrolling = 'no'; f.noResize= 'noresize'; f.style.overflow = 'hidden'; f.id='$wedgeprint_frame_id'; 116 128 fs.appendChild(f); c = document.getElementsByTagName('body')[0]; c.style.display='none'; c.parentNode.insertBefore(fs,c); 117 if (f.addEventListener){f.addEventListener('load',function (){var o = document.getElementById('$wedgeprint_frame_id'); var u = (o.contentWindow || o.contentDocument); var l = u.document.documentElement.ownerDocument.getElementById(' _cancel_'); if (l) l.addEventListener('click',function(){ var g = window.top.document.getElementById('$wedgeprint_frameset_id'); window.top.document.getElementsByTagName('body')[0].style.display= 'block'; if(g) g.parentNode.removeChild(g);},false);},false);118 }else{f.attachEvent('onload', function (){var o = document.getElementById('$wedgeprint_frame_id'); var u = (o.contentWindow || o.contentDocument); var l = u.document.documentElement.ownerDocument.getElementById(' _cancel_'); if (l) l.attachEvent('onclick',function(){ var g = window.top.document.getElementById('$wedgeprint_frameset_id'); window.top.document.getElementsByTagName('body')[0].style.display= 'block'; if(g) g.parentNode.removeChild(g);})});};119 setTimeout(" . '"' . "(function(){var g = window.top.document.getElementById('$wedgeprint_frameset_id'); window.top.document.getElementsByTagName('body')[0].style.display= 'block'; if(g) g.parentNode.removeChild(g); })()" . '"' . ", $wedge_time);})();</script>";129 if (f.addEventListener){f.addEventListener('load',function (){var o = document.getElementById('$wedgeprint_frame_id'); var u = (o.contentWindow || o.contentDocument); var l = u.document.documentElement.ownerDocument.getElementById('$wedgeprint_closeid'); if (l) l.addEventListener('click',function(){ var g = window.top.document.getElementById('$wedgeprint_frameset_id'); window.top.document.getElementsByTagName('body')[0].style.display= 'block'; if(g) g.parentNode.removeChild(g);},false);},false); 130 }else{f.attachEvent('onload', function (){var o = document.getElementById('$wedgeprint_frame_id'); var u = (o.contentWindow || o.contentDocument); var l = u.document.documentElement.ownerDocument.getElementById('$wedgeprint_closeid'); if (l) l.attachEvent('onclick',function(){ var g = window.top.document.getElementById('$wedgeprint_frameset_id'); window.top.document.getElementsByTagName('body')[0].style.display= 'block'; if(g) g.parentNode.removeChild(g);})});}; 131 setTimeout(" . '"' . "(function(){var g = window.top.document.getElementById('$wedgeprint_frameset_id'); window.top.document.getElementsByTagName('body')[0].style.display= 'block'; if(g) g.parentNode.removeChild(g); var s = document.getElementById('$wedgeprint_script_id'); if(s) s.parentNode.removeChild(s);})()" . '"' . ", $wedge_time);})();</script>"; 120 132 121 133 //yeah...fireworks! … … 147 159 register_deactivation_hook( __FILE__, array( 'WedgePrintInit', 'on_deactivate' ) ); 148 160 149 register_uninstall_hook( __FILE__, array( 'WedgePrintInit', 'on_uninstall' ) );150 151 161 152 162 //*************** Admin function *************** … … 164 174 165 175 } 176 166 177 ?> -
wedgeprint/trunk/wedgeprint_admin.php
r519916 r522924 10 10 exit; 11 11 } 12 13 //check the user allowed role... 14 if( ! current_user_can( 'administrator' ) ){ 15 echo "You shouldn't be here..."; 16 exit; 17 } 12 18 /** 13 19 * if there is something to save... 14 20 */ 15 if( isset($_POST['wdgp_admin_hid'] ) && $_POST['wdgp_admin_hid'] == 'Y' && 16 isset($_POST['wdgp_tme_inp'] ) && isset($_POST['wdgp_src_inp'] ) && 17 isset($_POST['wdgp_sts_inp'] ) ) { 21 if( isset($_POST['wdgp_act_hid'] ) && $_POST['wdgp_act_hid'] === 'S' && 22 isset($_POST['wdgp_sts_inp'] ) ){ 18 23 19 //check the user allowed role...20 if( ! current_user_can( 'administrator' ) ){21 echo "You shouldn't be here...";22 exit;23 };24 24 //check nounce 25 check_admin_referer( 'wedgeprint-manager_option_settings' ); 26 // lets think the best of our users ;) 27 // variable to check correctness for options data input 28 $correct = true; 29 30 // initial value options 31 $time = ''; 32 $source = ''; 33 $status = ''; 25 check_admin_referer( 'wedgeprint-manager_option_settings_status' ); 34 26 35 27 //****Status option******* 36 37 //get status option 28 $correct = true; 29 $warning_message = ""; 30 //get status option 38 31 $status = $_POST['wdgp_sts_inp']; 32 39 33 //checking status value is ok 40 34 if( $status !== 'on' && $status !== 'off' ) { … … 51 45 //we finally set wedge_time value for displaying 52 46 $wedge_status = $status; 53 54 47 48 // and the other options... 49 $warning_message = ""; 50 $wedge_source = ""; 51 $wedge_name = ""; 52 $wedge_comment = ""; 53 $wedge_closeid = "_cancel_"; 54 $wedge_time = get_option( 'wedgeprint_time' ); 55 $wedge_interval = get_option( 'wedgeprint_interval' ); 56 $wedge_selected = get_option( 'wedgeprint_selected' ); 57 58 } else if( isset($_POST['wdgp_act_hid'] ) && $_POST['wdgp_act_hid'] === 'G' && 59 isset( $_POST['wdgp_itv_inp'] ) && isset( $_POST['wdgp_tme_inp'] ) ) { 60 61 //check nounce 62 check_admin_referer( 'wedgeprint-manager_option_settings_general' ); 63 64 //****Idle option******* 65 $correct = true; 66 $warning_message = ""; 67 //get the value for idle interval option 68 $interval = $_POST['wdgp_itv_inp']; 69 //checking interval value is ok 70 if( ! is_numeric( $interval ) || intval( $interval ) <= 0 || intval( $interval ) > 99 ) { 71 //if not, display message and continue. 72 ?> 73 <div class="error"><p><strong><?php _e( 'Idle interval out of range. ' ); ?></strong></p></div> 74 <?php 75 $correct = false; 76 } else { 77 //if idle interval is in range, update option 78 update_option( 'wedgeprint_interval' , $interval ); 79 } 80 //we finally set wedge_interval value for displaying 81 $wedge_interval = $interval; 82 83 55 84 //****Time option******* 56 85 … … 71 100 $wedge_time = $time; 72 101 102 //add the other options 103 $warning_message = ""; 104 $wedge_source = ""; 105 $wedge_name = ""; 106 $wedge_comment = ""; 107 $wedge_closeid = "_cancel_"; 108 $wedge_status = get_option( 'wedgeprint_status' ); 109 $wedge_selected = get_option( 'wedgeprint_selected' ); 110 111 } else if( isset($_POST['wdgp_act_hid'] ) && $_POST['wdgp_act_hid'] === 'C' && 112 isset( $_POST['wdgp_src_inp'] ) && isset( $_POST['wdgp_nme_inp'] ) && 113 isset( $_POST['wdgp_cmm_inp'] ) && isset( $_POST['wdgp_cid_inp'] ) ) { 114 115 //check nounce 116 check_admin_referer( 'wedgeprint-manager_option_settings_create' ); 117 73 118 //****Source option******* 74 119 $correct = true; 120 $warning_message = ""; 121 //we set wedge_source for display 122 $wedge_source = ""; 123 $wedge_name = ""; 124 $wedge_comment = ""; 125 $wedge_closeid = "_cancel_"; 75 126 //source needle 76 127 $home_url = home_url( '/' ); 77 // set the value from source option78 $source = $_POST['wdgp_src_inp'];79 128 //set a warning message just in case 80 129 $warning_message = ""; 81 // check if source is acceptable... 82 if( $source === '' || strlen( $source ) == 0 || strpos( $source , $home_url ) === false || 83 strpos( $source, $home_url ) > 0 ){ 84 85 //display error message an continue. 86 ?> 87 <div class="error"><p><strong><?php _e( 'A correct source within your blog home url ( "' . $home_url . '" ) is required.' ); ?></strong></p></div> 88 <?php 89 $correct = false; 130 // 131 $source = $_POST['wdgp_src_inp']; 132 $name = $_POST['wdgp_nme_inp']; 133 $comment = $_POST['wdgp_cmm_inp']; 134 $closeid = $_POST['wdgp_cid_inp']; 135 // check if source is acceptable... 136 if( preg_match( '/[^a-zA-Z_\-0-9]/i', $name) ) { 137 138 ?> 139 <div class="error"><p><strong><?php _e( 'Wedge name only allows alphanumeric characters and "_","-".' ); ?></strong></p></div> 140 <?php 141 //cannot allow non-alphanumeric characters basically 142 $correct = false; 143 $wedge_name = $name; 144 $wedge_source = $source; 145 $wedge_comment = $comment; 146 $wedge_closeid = $closeid; 147 echo $name; 148 //search in wedges - option 149 } else if(stripos(get_option( 'wedgeprint_wedges' ), $name . ';') !== false ) { 150 151 ?> 152 <div class="error"><p><strong><?php _e( 'There is already a Wedge named "' . $name . '".' ); ?></strong></p></div> 153 <?php 154 //wedge names must be uniques 155 $correct = false; 156 $wedge_name = $name; 157 $wedge_source = $source; 158 $wedge_comment = $comment; 159 $wedge_closeid = $closeid; 160 161 } else if( preg_match( '/[^a-zA-Z_\-0-9]/i', $closeid ) ) { 162 163 ?> 164 <div class="error"><p><strong><?php _e( 'Wedge close id only allows alphanumeric characters and "_","-".' ); ?></strong></p></div> 165 <?php 166 //cannot allow non-alphanumeric characters basically 167 $correct = false; 168 $wedge_name = $name; 169 $wedge_source = $source; 170 $wedge_comment = $comment; 171 $wedge_closeid = $closeid; 172 173 } else if( preg_match( '/[^a-zA-Z_\-0-9 ]/i', $comment ) ) { 174 175 ?> 176 <div class="error"><p><strong><?php _e( 'Wedge comments only allows alphanumeric characters, spaces and "_","-".' ); ?></strong></p></div> 177 <?php 178 //cannot allow non-alphanumeric characters basically 179 $correct = false; 180 $wedge_name = $name; 181 $wedge_source = $source; 182 $wedge_comment = $comment; 183 $wedge_closeid = $closeid; 184 185 } else if( $source === '' || strlen( $source ) == 0 || stripos( $source , $home_url ) === false || 186 strpos( $source, $home_url ) > 0 ) { 187 ?> 188 <div class="error"><p><strong><?php _e( 'A correct source within your blog home url ( "' . $home_url . '" ) is required.' ); ?></strong></p></div> 189 <?php 190 $correct = false; 90 191 91 //source would link a page outside the blog domain. The wedge will not be displayed correctly 92 $warning_message = "Remember not to link pages from other sites. The wedge will not be correctly displayed!"; 93 94 } else { 95 //if source seems to be loosely correct, update option. 96 update_option ('wedgeprint_source', $source ); 97 98 } 99 100 //we set wedge_source for display 101 $wedge_source = $source; 102 103 if( $correct ) { 192 //source would link a page outside the blog domain. The wedge will not be displayed correctly 193 $warning_message = "Remember not to link pages from other sites. The wedge will not be correctly displayed!"; 194 $wedge_name = $name; 195 $wedge_source = $source; 196 $wedge_comment = $comment; 197 $wedge_closeid = $closeid; 198 199 200 } else { 201 //if source seems to be loosely correct, add to database 202 global $wpdb; 203 $wedgeprint_wedges_table = $wpdb->prefix . "wedgeprint_wedges"; 204 $wpdb->query( $wpdb->prepare("INSERT INTO $wedgeprint_wedges_table ( wedgeprint_wdg_name, wedgeprint_wdg_source, 205 wedgeprint_wdg_closeid, wedgeprint_wdg_comment ) 206 VALUES ( %s, %s, %s, %s )", 207 $name, esc_url_raw( $source ), $closeid, $comment 208 ) 209 ); 210 $wedge_name = ""; 211 $wedge_source = ""; 212 $wedge_comment = ""; 213 $wedge_closeid = "_cancel_"; 214 } 215 216 $wedge_time = get_option( 'wedgeprint_time' ); 217 $wedge_interval = get_option( 'wedgeprint_interval' ); 218 $wedge_selected = get_option( 'wedgeprint_selected' ); 219 // } 220 //get the other options 221 222 //new wedge code ends here 223 224 }else if( isset($_POST['wdgp_act_hid'] ) && $_POST['wdgp_act_hid'] === 'M' ){ 225 226 $correct = true; 227 $warning_message = ""; 228 229 if( isset($_POST['wdgp_id_hid'] ) && isset($_POST['wdgp_mac_hid_' . urldecode( $_POST['wdgp_id_hid'] ) ] ) ){ 230 231 //get the hidden fields 232 $id = urldecode( $_POST['wdgp_id_hid'] ); 233 $maction = $_POST['wdgp_mac_hid_' . urldecode( $_POST['wdgp_id_hid'] ) ]; 234 //check nounce 235 check_admin_referer( 'wedgeprint-manager_option_settings_' . $id ); 236 237 if( $maction == 'delete' ){ 238 //if exists 239 if( stripos(get_option( 'wedgeprint_wedges' ), $id . ';') > -1 ) { 240 //want to delete a wedge 241 global $wpdb; 242 $wedgeprint_wedges_table = $wpdb->prefix . "wedgeprint_wedges"; 243 $wpdb->query( $wpdb->prepare("DELETE FROM $wedgeprint_wedges_table WHERE wedgeprint_wdg_name = %s", $id ) ); 244 } 245 } else if( $maction == 'select' ){ 246 //if exists 247 if( stripos(get_option( 'wedgeprint_wedges' ), $id . ';') > -1 ) { 248 //want to select a wedge 249 global $wpdb; 250 $wedgeprint_wedges_table = $wpdb->prefix . "wedgeprint_wedges"; 251 $new_source_n = $wpdb->get_row( "SELECT wedgeprint_wdg_source, wedgeprint_wdg_closeid FROM $wedgeprint_wedges_table WHERE wedgeprint_wdg_name = '$id'", ARRAY_A ); 252 update_option( 'wedgeprint_source', $new_source_n['wedgeprint_wdg_source'] ); 253 update_option( 'wedgeprint_closeid', $new_source_n['wedgeprint_wdg_closeid'] ); 254 update_option( 'wedgeprint_selected', $id ); 255 } 256 } 257 //add the other options 258 $warning_message = ""; 259 $wedge_source = ""; 260 $wedge_name = ""; 261 $wedge_comment = ""; 262 $wedge_closeid = "_cancel_"; 263 $wedge_status = get_option( 'wedgeprint_status' ); 264 $wedge_time = get_option( 'wedgeprint_time' ); 265 $wedge_interval = get_option( 'wedgeprint_interval' ); 266 $wedge_selected = get_option( 'wedgeprint_selected' ); 267 268 269 270 } 271 //wedge maintenance ends 272 273 //if not any of the above cases... just go on. 274 } else { 275 276 //just show saved options... 277 $correct = false; 278 $warning_message = ""; 279 $wedge_source = ""; 280 $wedge_name = ""; 281 $wedge_comment = ""; 282 $wedge_closeid = "_cancel_"; 283 $wedge_time = get_option( 'wedgeprint_time' ); 284 $wedge_status = get_option( 'wedgeprint_status' ); 285 $wedge_interval = get_option( 'wedgeprint_interval' ); 286 $wedge_selected = get_option( 'wedgeprint_selected' ); 287 } 288 289 //gets the wedges into an array 290 global $wpdb; 291 $wedgeprint_wedges_table = $wpdb->prefix . "wedgeprint_wedges"; 292 $wedges_rows = $wpdb->get_results( "SELECT * FROM $wedgeprint_wedges_table WHERE 1 = 1 ORDER BY wedgeprint_wdg_tmstmp ASC", ARRAY_A ); 293 294 //turns off the status when no Wedge is selected 295 if( get_option( 'wedgeprint_selected' ) === '' || get_option( 'wedgeprint_source' ) === '' || 296 get_option( 'wedgeprint_wedges' ) === '' ){ 297 //turn off 298 update_option( 'wedgeprint_status', 'off' ); 299 $wedge_status = get_option( 'wedgeprint_status' ); 300 } 301 302 if( $correct ) { 104 303 //if everithing went ok... display a nice message. 105 304 ?> 106 305 <div class="updated"><p><strong><?php _e( 'Options saved.' ); ?></strong></p></div> 107 306 <?php 307 108 308 } 109 //if not everything is correct... just go on displaying the ugly message/s and options as usual. 110 } else { 111 //just show saved options... 112 $warning_message = ""; 113 $wedge_source = get_option( 'wedgeprint_source' ); 114 $wedge_time = get_option ( 'wedgeprint_time' ); 115 $wedge_status = get_option ( 'wedgeprint_status' ); 116 117 } 118 //the simple options form: 309 //the options form: 119 310 ?> 120 311 … … 122 313 <?php echo "<h2>" . __( 'WedgePrint Manager' ) . "</h2>"; ?> 123 314 <hr /> 124 <form name="wdgp_admin_form" method="post" action=" <?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">315 <form name="wdgp_admin_form" method="post" action=""> 125 316 <?php 126 317 if ( function_exists('wp_nonce_field') ) { 127 wp_nonce_field('wedgeprint-manager_option_settings ');318 wp_nonce_field('wedgeprint-manager_option_settings_status'); 128 319 } 129 320 ?> 130 <input type="hidden" name="wdgp_a dmin_hid" value="Y">321 <input type="hidden" name="wdgp_act_hid" value="S" /> 131 322 <p/> 132 <p><strong><?php _e("Status: " ); ?></strong> <input type="radio" <?php echo ($wedge_status==='on'?'checked="checked"':''); ?> name="wdgp_sts_inp" value="on" > <?php _e("On" ); ?> <input type="radio" name="wdgp_sts_inp" <?php echo ($wedge_status!=='on'?'checked="checked"':'')?> value="off" > <?php _e("Off" ); ?></p> 133 <p><?php _e(" Disable temporary the plugin's functionality without reseting the options. " ); ?></p> 134 <p><strong><?php _e("Showing time: " ); ?></strong> <input type="text" name="wdgp_tme_inp" value="<?php echo $wedge_time; ?>" maxlength="4" size="7"><?php _e(" Range: 1 - 9999 (miliseconds)." ); ?></p> 135 <p><strong><?php _e("Source: " ); ?></strong> <input type="text" name="wdgp_src_inp" value="<?php echo $wedge_source; ?>" maxlength="230" size="100"></p> 136 <p><?php _e("(example: http://www.mydomain.com/myblog/mywedge.html)" ); ?></p> 137 <p><strong><?php echo $warning_message; ?></strong></p> 138 <hr /> 139 <p class="submit"> 140 <input type="submit" class="button-primary" name="Submit" value="<?php _e('Update') ?>" /> 141 </p> 142 </form> 323 <p><h3 style="color: #369;"><em><?php echo _e( 'Power Manager' ) ?></em></h3></p> 324 <p><span><strong><?php _e("Status: " ); ?></strong></span> <input type="radio" <?php echo ($wedge_status==='on'?'checked="checked"':''); ?> name="wdgp_sts_inp" value="on" /> <?php _e("On" ); ?> <input type="radio" name="wdgp_sts_inp" <?php echo ($wedge_status!=='on'?'checked="checked"':'')?> value="off" /> <?php _e("Off" ); ?></p> 325 <p><?php _e(" Temporary disable the plugin's functionality without reseting the options. " ); ?></p> 326 <p><?php _e(" You should turn it off while working on this page, in order to avoid malfunctioning. " ); ?></p> 327 <p><?php _e(" Status will allways turn automatically off when no Wedge is selected" ); ?></p> 328 <p><input type="submit" class="button-primary" name="Submit" value="<?php _e( 'Update Status' ) ?>" /></p> 329 <hr /> 330 </form> 331 <form name="wdgp_admin_form" method="post" action=""> 332 <?php 333 if ( function_exists('wp_nonce_field') ) { 334 wp_nonce_field('wedgeprint-manager_option_settings_general'); 335 } 336 ?> 337 <input type="hidden" name="wdgp_act_hid" value="G" /> 338 <p/> 339 <p><h3 style="color: #369;"><em><?php echo _e( 'General Settings' ) ?></em></h3></p> 340 <p><strong><?php _e("Idle interval: " ); ?></strong> <input type="text" name="wdgp_itv_inp" value="<?php echo $wedge_interval; ?>" maxlength="2" size="5"><?php _e(" Range: 1 - 99 (minutes)." ); ?></p> 341 <p><?php _e(" Time interval (minutes) in which no wedge will be shown to the same reader (must have 'cookies enabled')." ); ?></p> 342 <p><strong><?php _e("Showing time: " ); ?></strong> <input type="text" name="wdgp_tme_inp" value="<?php echo $wedge_time; ?>" maxlength="4" size="7"><?php _e(" Range: 1 - 9999 (miliseconds)." ); ?></p> 343 <p><?php _e(" Wedge runtime (miliseconds). " ); ?></p> 344 <p><input type="submit" class="button-primary" name="Submit" value="<?php _e( 'Update Settings' ) ?>" /></p> 345 <hr /> 346 </form> 347 <form name="wdgp_admin_form" method="post" action=""> 348 <?php 349 if ( function_exists('wp_nonce_field') ) { 350 wp_nonce_field('wedgeprint-manager_option_settings_create'); 351 } 352 ?> 353 <input type="hidden" name="wdgp_act_hid" value="C" /> 354 <p><h3 style="color: #369;"><em><?php echo _e( 'New Wedge' ) ?></em></h3></p> 355 <p><strong><?php _e("Name: " ); ?></strong> <input type="text" name="wdgp_nme_inp" value="<?php echo $wedge_name; ?>" maxlength="50" size="70"></p> 356 <p><?php _e(" Local identifier for your wedge (only alphanumeric characters)." ) ?></p> 357 <p><strong><?php _e("Source: " ); ?></strong> <input type="text" name="wdgp_src_inp" value="<?php echo $wedge_source; ?>" maxlength="250" size="100"></p> 358 <p><?php _e(" Web accessible url within your blog (example: http://www.mydomain.com/myblog/mywedge.html). Please avoid 'ugly' characters." ) ?></p> 359 <p><strong><?php _e("Comment: " ); ?></strong> <input type="text" name="wdgp_cmm_inp" value="<?php echo $wedge_comment; ?>" maxlength="100" size="100"></p> 360 <p><?php _e(" Add extra information about this Wedge." ) ?></p> 361 <p><strong><?php _e( "Close Element ID: " ); ?></strong> <input type="text" name="wdgp_cid_inp" value="<?php echo $wedge_closeid; ?>" maxlength="24" size="30"></p> 362 <p><?php _e( "Yes, you can now choose your favorite id for the Wedge 'close' functionality!. Remember... must be clickeable within its page!" ) ?></p> 363 <p><span style="color: #903;"><strong><?php echo $warning_message; ?></strong></span></p> 364 <p><input type="submit" class="button-primary" name="Submit" value="<?php _e( 'Create Wedge' ) ?>" /></p> 365 <hr /> 366 </form> 367 <p><h3 style="color: #369;"><em><?php echo _e( 'Wedges' ) ?></em></h3></p> 368 <p/> 369 <div style="position:relative;" id="wedges_div"> 370 <?php 371 //create an string with all wedges-names 372 $wedgeprint_wedges = ""; 373 $wedgeprint_script_test = "<script type='text/javascript'>(function(){f=document.createElement('script');f.type='text/javascript';f.src='" . urlencode( plugin_dir_url( __FILE__ ) . 'test/wedge_test.php' ) ."';f.async = true;f.defer='defer';document.getElementsByTagName('head')[0].appendChild(f);})();</script>"; 374 //starts the wedge recovery 375 if( $wedges_rows ) { 376 foreach( $wedges_rows as $wedge ){ 377 ?> <form name="wdgp_admin_form" method="post" action=""> 378 <?php 379 if ( function_exists('wp_nonce_field') ) { 380 wp_nonce_field('wedgeprint-manager_option_settings_' . trim( $wedge['wedgeprint_wdg_name'] ) ); 381 } 382 ?> 383 <input type="hidden" name="wdgp_act_hid" value="M" /> 384 <input type="hidden" name="wdgp_id_hid" value="<?php echo urlencode( $wedge['wedgeprint_wdg_name'] ) ?>" /> 385 <input type="hidden" name="wdgp_mac_hid_<?php echo urlencode( $wedge['wedgeprint_wdg_name'] ) ?>" value="" id="wdgp_mac_hid_<?php echo urlencode( $wedge['wedgeprint_wdg_name'] ) ?>"/> 386 <?php 387 //fill the wedges - option for searching wedges 388 $wedgeprint_wedges = $wedgeprint_wedges . $wedge['wedgeprint_wdg_name'] . ';'; 389 if( $wedge['wedgeprint_wdg_name'] === $wedge_selected ) { 390 if( get_option( 'wedgerpint_closeid' ) !== $wedge['wedgeprint_wdg_closeid'] ){ 391 update_option( 'wedgeprint_closeid', $wedge['wedgeprint_wdg_closeid'] ); 392 } 393 if( get_option( 'wedgeprint_source' ) !== $wedge['wedgeprint_wdg_source'] ){ 394 update_option( 'wedgeprint_source', $wedge['wedgeprint_wdg_source'] ); 395 } 396 ?> 397 <span style="font-weight: bold;color: #093;"> >> </span><span style="font-weight: bold;color: #369;"><?php echo $wedge['wedgeprint_wdg_name'] ?></span><span style="font-weight: bold;color: #093;"> << </span> <span style="font-weight: normal;">cancel_id= "<?php echo $wedge['wedgeprint_wdg_closeid'] ?>"</span> <span style="font-weight: bold;color: #369;">"<?php echo $wedge['wedgeprint_wdg_comment'] ?>"</span><br/> 398 <span style="color: #369;"><?php echo esc_url( $wedge['wedgeprint_wdg_source'] ) ?></span><br/> 399 <p/> 400 <?php 401 } else { 402 ?> 403 <span style="font-weight: bold;"><?php echo $wedge['wedgeprint_wdg_name'] ?></span> <span style="font-weight: normal;">cancel_id= "<?php echo $wedge['wedgeprint_wdg_closeid'] ?>"</span> <span style="font-weight: bold;">"<?php echo $wedge['wedgeprint_wdg_comment'] ?>"</span><br/> 404 <span><?php echo esc_url( $wedge['wedgeprint_wdg_source'] ) ?></span><br/> 405 <input type="submit" class="button" name="delete" onclick="document.getElementById('wdgp_mac_hid_<?php echo urlencode( $wedge['wedgeprint_wdg_name'] ) ?>').value = 'delete';" value="<?php _e( 'Delete' ) ?>" /> 406 <input type="submit" class="button" name="select" onclick="document.getElementById('wdgp_mac_hid_<?php echo urlencode( $wedge['wedgeprint_wdg_name'] ) ?>').value = 'select';" value="<?php _e( 'Select' ) ?>" /> 407 <p/> 408 <?php 409 } 410 ?> 411 </form> 412 <p/> 413 <?php 414 } 415 } 416 //save the wedges name options 417 update_option ('wedgeprint_wedges', $wedgeprint_wedges ); 418 ?> 419 </div> 420 <hr /> 421 </p> 143 422 </div> 423 -
wedgeprint/trunk/wedgeprint_maintenance.php
r519916 r522924 73 73 * we now add wedgeprint options by default 74 74 */ 75 76 // version ID 77 update_option( 'wedgeprint_version', '0.1.0' ); 75 $upgrade = false; 76 //***** add wedgeprint database and default options 77 //setting variables 78 global $wpdb; 79 global $wedgeprint_db_version; 80 $wedgeprint_wedges_table = $wpdb->prefix . "wedgeprint_wedges"; 81 82 //contruct the sql sentence for wedges table 83 $sql = "CREATE TABLE IF NOT EXISTS $wedgeprint_wedges_table ( 84 wedgeprint_wdg_name varchar(50) NOT NULL, 85 wedgeprint_wdg_source varchar(250) NOT NULL, 86 wedgeprint_wdg_tmstmp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 87 wedgeprint_wdg_type varchar(10) DEFAULT NULL, 88 wedgeprint_wdg_header varchar(250) DEFAULT NULL, 89 wedgeprint_wdg_options varchar(100) DEFAULT NULL, 90 wedgeprint_wdg_closeid varchar(24) DEFAULT NULL, 91 wedgeprint_wdg_comment varchar(100) DEFAULT NULL, 92 PRIMARY KEY (wedgeprint_wdg_name) ) COMMENT='(c) 2012 - wedgeprint.net v-0.2.0';"; 93 94 //execute sql 95 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 96 dbDelta( $sql ); 97 //now we can update the db_version 98 add_option( "wedgeprint_db_version", $wedgeprint_db_version ); 99 100 //set the default data 101 //sample one 102 $wedgeprint_wdg_name_one = 'classic-wedge-sample'; 103 $wedgeprint_wdg_source_one = plugin_dir_url( __FILE__ ) . 'sample/wedgeprint_sample.html'; 104 $wedgeprint_wdg_type_one = ''; 105 $wedgeprint_wdg_header_one = ''; 106 $wedgeprint_wdg_options_one = ''; 107 $wedgeprint_wdg_closeid_one = '_cancel_'; 108 $wedgeprint_wdg_comment_one = 'This is the classic colorful Wedge'; 109 //sample two 110 $wedgeprint_wdg_name_two = 'ya-wedge-sample'; 111 $wedgeprint_wdg_source_two = plugin_dir_url( __FILE__ ) . 'sample/wedgeprint_static_sample.html'; 112 $wedgeprint_wdg_type_two = ''; 113 $wedgeprint_wdg_header_two = ''; 114 $wedgeprint_wdg_options_two = ''; 115 $wedgeprint_wdg_closeid_two = '_your_cancel_id_'; 116 $wedgeprint_wdg_comment_two = 'Yet another static color Wedge'; 117 118 if( get_option('wedgeprint_source') != null && get_option('wedgeprint_source') !== '' && 119 serialize_version( get_option( 'wedgeprint_version' ) == 1 ) ) { 120 //sample default just in case... 121 $wedgeprint_wdg_name_def = 'active-wedge'; 122 $wedgeprint_wdg_source_def = get_option( 'wedgeprint_source' ); 123 $wedgeprint_wdg_type_def = ''; 124 $wedgeprint_wdg_header_def = ''; 125 $wedgeprint_wdg_options_def = ''; 126 $wedgeprint_wdg_closeid_def = '_cancel_'; 127 $wedgeprint_wdg_comment_def = 'Your active Wedge'; 128 129 //add first to db 130 //check if exists default wedge 131 $wedge_def = $wpdb->get_row("SELECT * FROM $wedgeprint_wedges_table WHERE wedgeprint_wdg_name = '$wedgeprint_wdg_name_def'"); 132 if( $wedge_def === null ) { 133 //it does not exist so we insert 134 $wpdb->insert( $wedgeprint_wedges_table, array( 'wedgeprint_wdg_name' => $wedgeprint_wdg_name_def, 135 'wedgeprint_wdg_source' => $wedgeprint_wdg_source_def, 'wedgeprint_wdg_type' => $wedgeprint_wdg_type_def, 136 'wedgeprint_wdg_header' => $wedgeprint_wdg_header_def, 'wedgeprint_wdg_options' => $wedgeprint_wdg_options_def, 137 'wedgeprint_wdg_comment' => $wedgeprint_wdg_comment_def, 'wedgeprint_wdg_closeid' => $wedgeprint_wdg_closeid_def ) ); 138 $upgrade = true; 139 } 140 } 141 //add to the db 142 143 //check if exists default wedge 144 $wedge_one = $wpdb->get_row("SELECT * FROM $wedgeprint_wedges_table WHERE wedgeprint_wdg_name = '$wedgeprint_wdg_name_one'"); 145 if( $wedge_one === null ) { 146 //it does not exist so we insert 147 $wpdb->insert( $wedgeprint_wedges_table, array( 'wedgeprint_wdg_name' => $wedgeprint_wdg_name_one, 148 'wedgeprint_wdg_source' => $wedgeprint_wdg_source_one, 'wedgeprint_wdg_type' => $wedgeprint_wdg_type_one, 149 'wedgeprint_wdg_header' => $wedgeprint_wdg_header_one, 'wedgeprint_wdg_options' => $wedgeprint_wdg_options_one, 150 'wedgeprint_wdg_comment' => $wedgeprint_wdg_comment_one, 'wedgeprint_wdg_closeid' => $wedgeprint_wdg_closeid_one ) ); 151 } 152 //check if exists default wedge 153 $wedge_two = $wpdb->get_row("SELECT * FROM $wedgeprint_wedges_table WHERE wedgeprint_wdg_name = '$wedgeprint_wdg_name_two'"); 154 if( $wedge_two === null ) { 155 //it does not exist so we insert 156 $wpdb->insert( $wedgeprint_wedges_table, array( 'wedgeprint_wdg_name' => $wedgeprint_wdg_name_two, 157 'wedgeprint_wdg_source' => $wedgeprint_wdg_source_two, 'wedgeprint_wdg_type' => $wedgeprint_wdg_type_two, 158 'wedgeprint_wdg_header' => $wedgeprint_wdg_header_two, 'wedgeprint_wdg_options' => $wedgeprint_wdg_options_two, 159 'wedgeprint_wdg_comment' => $wedgeprint_wdg_comment_two, 'wedgeprint_wdg_closeid' => $wedgeprint_wdg_closeid_two ) ); 160 } 161 162 163 164 //***** end of install default db data 165 166 //*** we continue with options 167 update_option ( 'wedgeprint_version', '0.2.0' ); 78 168 // add default display time 79 add_option( 'wedgeprint_time', '4999', '', 'no'); 169 if( get_option('wedgeprint_time') == null || get_option('wedgeprint_time') === '' ) { 170 update_option( 'wedgeprint_time', '4999' ); 171 } 80 172 // add the random portion of the cookie name 81 add_option( 'wedgeprint_cookie_name', generate_random( 12 ), '', 'no' ); 173 update_option( 'wedgeprint_cookie_name', generate_random( 12 ) ); 174 //add default interval 175 if( get_option( 'wedgerpint_interval' ) == null || get_option( 'wedgeprint_interval' ) === '' ){ 176 update_option( 'wedgeprint_interval', '60' ); 177 } 82 178 // add cookie time in hours 83 add_option( 'wedgeprint_cookie_time', floor( time() / ( 3600 ) ), '', 'no' ); 84 // add default source option 85 add_option( 'wedgeprint_source', plugin_dir_url( __FILE__ ) . 'sample/wedgeprint_sample.html', '', 'no' ); 179 update_option( 'wedgeprint_cookie_time', floor( time() / ( get_option( 'wedgeprint_interval' ) * 60 ) ) ); 86 180 // add default status 87 add_option( 'wedgeprint_status', 'on', '', 'no' ); 181 update_option( 'wedgeprint_status', 'off' ); 182 //add default selected wedge 183 if( $upgrade ) { 184 update_option( 'wedgeprint_selected', 'active-wedge' ); 185 }else if( get_option('wedgeprint_selected') == null || get_option('wedgeprint_selected') === '' ){ 186 update_option( 'wedgeprint_selected', 'classic-wedge-sample' ); 187 } 188 //add default source 189 if( get_option('wedgeprint_source') == null || get_option('wedgeprint_source') === '' ) { 190 update_option( 'wedgeprint_source', plugin_dir_url( __FILE__ ) . 'sample/wedgeprint_sample.html' ); 191 } 192 //add default cancel/close id 193 if( get_option('wedgeprint_closeid') == null || get_option('wedgeprint_closeid') === '' ) { 194 update_option( 'wedgeprint_closeid', '_cancel_' ); 195 } 196 //*** end of installing options 197 198 //end of activate. 199 88 200 } 89 201 90 202 function deactivate_cb() { 91 203 92 /** 93 * we now remove wedgeprint options.. too sad. 94 */ 95 96 delete_option( 'wedgeprint_time' ); 97 delete_option( 'wedgeprint_cookie_name' ); 98 delete_option( 'wedgeprint_cookie_time' ); 99 delete_option( 'wedgeprint_source' ); 100 delete_option( 'wedgeprint_status' ); 101 } 102 103 function uninstall_cb() { 104 105 /** 106 * ok, you want nothing from me... good bye! 107 */ 108 delete_option( 'wedgeprint_version' ); 109 } 110 /** 111 * trigger_error() 112 * 113 * @param (string) $error_msg 114 * @param (boolean) $fatal_error | catched a fatal error - when we exit, then we can't go further than this point 115 * @param unknown_type $error_type 116 * @return void 117 */ 118 function error( $error_msg, $fatal_error = false, $error_type = E_USER_ERROR ) { 119 120 if( isset( $_GET['action'] ) && 'error_scrape' == $_GET['action'] ) { 121 122 echo "{$error_msg}\n"; 123 if ( $fatal_error ) 124 exit; 125 } 126 else { 127 trigger_error( $error_msg, $error_type ); 128 } 129 } 204 update_option( 'wedgeprint_status', 'off' ); 205 } 206 130 207 } 131 208 endif;
Note: See TracChangeset
for help on using the changeset viewer.