popoveradmin.php
794 lines
| 1 | <?php |
| 2 | |
| 3 | if(!class_exists('popoveradmin')) { |
| 4 | |
| 5 | class popoveradmin { |
| 6 | |
| 7 | var $build = 3; |
| 8 | |
| 9 | var $db; |
| 10 | |
| 11 | function __construct() { |
| 12 | |
| 13 | global $wpdb; |
| 14 | |
| 15 | $this->db =& $wpdb; |
| 16 | |
| 17 | add_action( 'admin_menu', array(&$this, 'add_menu_pages' ) ); |
| 18 | add_action( 'network_admin_menu', array(&$this, 'add_menu_pages' ) ); |
| 19 | |
| 20 | add_action( 'plugins_loaded', array(&$this, 'load_textdomain')); |
| 21 | |
| 22 | // Add header files |
| 23 | add_action('load-settings_page_popoverssadmin', array(&$this, 'add_admin_header_popover')); |
| 24 | add_action('load-tools_page_popoverssadmin', array(&$this, 'add_admin_header_popover')); |
| 25 | } |
| 26 | |
| 27 | function popoveradmin() { |
| 28 | $this->__construct(); |
| 29 | } |
| 30 | |
| 31 | function load_textdomain() { |
| 32 | |
| 33 | $locale = apply_filters( 'popover_locale', get_locale() ); |
| 34 | $mofile = popover_dir( "popoverincludes/languages/popover-$locale.mo" ); |
| 35 | |
| 36 | if ( file_exists( $mofile ) ) |
| 37 | load_textdomain( 'popover', $mofile ); |
| 38 | |
| 39 | } |
| 40 | |
| 41 | function add_menu_pages() { |
| 42 | if(is_multisite() && defined('PO_GLOBAL')) { |
| 43 | if(function_exists('is_network_admin') && is_network_admin()) { |
| 44 | // On 3.1 and in the network admin area. |
| 45 | add_submenu_page('settings.php', __('Pop Overs','popover'), __('Pop Overs','popover'), 'manage_options', 'popoverssadmin', array(&$this,'handle_admin_panel')); |
| 46 | } else { |
| 47 | // Not on 3.1 |
| 48 | add_submenu_page('ms-admin.php', __('Pop Overs','popover'), __('Pop Overs','popover'), 'manage_options', 'popoverssadmin', array(&$this,'handle_admin_panel')); |
| 49 | } |
| 50 | } else { |
| 51 | add_submenu_page('options-general.php', __('Pop Overs','popover'), __('Pop Overs','popover'), 'manage_options', 'popoverssadmin', array(&$this,'handle_admin_panel')); |
| 52 | } |
| 53 | |
| 54 | } |
| 55 | |
| 56 | function sanitise_array($arrayin) { |
| 57 | |
| 58 | foreach($arrayin as $key => $value) { |
| 59 | $arrayin[$key] = htmlentities(stripslashes($value) ,ENT_QUOTES, 'UTF-8'); |
| 60 | } |
| 61 | |
| 62 | return $arrayin; |
| 63 | } |
| 64 | |
| 65 | function update_admin_header_popover() { |
| 66 | |
| 67 | global $action, $page, $allowedposttags; |
| 68 | |
| 69 | wp_reset_vars( array('action', 'page') ); |
| 70 | |
| 71 | if($action == 'updated') { |
| 72 | check_admin_referer('update-popover'); |
| 73 | |
| 74 | $usemsg = 1; |
| 75 | |
| 76 | if(function_exists('get_site_option') && defined('PO_GLOBAL')) { |
| 77 | $updateoption = 'update_site_option'; |
| 78 | $getoption = 'get_site_option'; |
| 79 | } else { |
| 80 | $updateoption = 'update_option'; |
| 81 | $getoption = 'get_option'; |
| 82 | } |
| 83 | |
| 84 | if(isset($_POST['popovercontent'])) { |
| 85 | if ( !current_user_can('unfiltered_html') ) { |
| 86 | if(wp_kses($_POST['popovercontent'], $allowedposttags) != $_POST['popovercontent']) { |
| 87 | $usemsg = 2; |
| 88 | } |
| 89 | $updateoption('popover_content', wp_kses($_POST['popovercontent'], $allowedposttags)); |
| 90 | } else { |
| 91 | $updateoption('popover_content', $_POST['popovercontent']); |
| 92 | } |
| 93 | |
| 94 | } |
| 95 | |
| 96 | if(isset($_POST['popoverwidth']) || isset($_POST['popoverheight'])) { |
| 97 | |
| 98 | $width = $_POST['popoverwidth']; |
| 99 | $height = $_POST['popoverheight']; |
| 100 | |
| 101 | if($width == '') $width = '500px'; |
| 102 | if($height == '') $height = '200px'; |
| 103 | |
| 104 | $updateoption('popover_size', array("width" => $width, "height" => $height)); |
| 105 | } |
| 106 | |
| 107 | if(isset($_POST['popoverleft']) || isset($_POST['popovertop'])) { |
| 108 | |
| 109 | $left = $_POST['popoverleft']; |
| 110 | $top = $_POST['popovertop']; |
| 111 | |
| 112 | if($left == '') $left = '100px'; |
| 113 | if($top == '') $top = '100px'; |
| 114 | |
| 115 | $updateoption('popover_location', array("left" => $left, "top" => $top)); |
| 116 | } |
| 117 | |
| 118 | if(isset($_POST['popovermargintop']) || isset($_POST['popovermarginleft']) || isset($_POST['popovermarginright']) || isset($_POST['popovermarginbottom'])) { |
| 119 | |
| 120 | $mleft = $_POST['popovermarginleft']; |
| 121 | $mtop = $_POST['popovermargintop']; |
| 122 | $mright = $_POST['popovermarginright']; |
| 123 | $mbottom = $_POST['popovermarginbottom']; |
| 124 | |
| 125 | if($mleft == '') $mleft = '0px'; |
| 126 | if($mtop == '') $mtop = '0px'; |
| 127 | if($mright == '') $mright = '0px'; |
| 128 | if($mbottom == '') $mbottom = '0px'; |
| 129 | |
| 130 | $updateoption('popover_margin', array('left' => $mleft, 'top' => $mtop, 'right' => $mright, 'bottom' => $mbottom)); |
| 131 | |
| 132 | } |
| 133 | |
| 134 | if(isset($_POST['popoverbackground']) || isset($_POST['popoverforeground'])) { |
| 135 | |
| 136 | $back = $_POST['popoverbackground']; |
| 137 | $fore = $_POST['popoverforeground']; |
| 138 | |
| 139 | if($back == '') $back = 'FFFFFF'; |
| 140 | if($fore == '') $fore = '000000'; |
| 141 | |
| 142 | $updateoption('popover_colour', array("back" => $back, "fore" => $fore)); |
| 143 | } |
| 144 | |
| 145 | if(isset($_POST['popovercheck'])) { |
| 146 | |
| 147 | $updateoption('popover_check', $_POST['popovercheck']); |
| 148 | |
| 149 | if(isset($_POST['popoverereg'])) { |
| 150 | $updateoption('popover_ereg', $_POST['popoverereg']); |
| 151 | } |
| 152 | |
| 153 | if(isset($_POST['popovercount'])) { |
| 154 | $updateoption('popover_count', intval($_POST['popovercount']) ); |
| 155 | } |
| 156 | |
| 157 | } |
| 158 | |
| 159 | if(isset($_POST['popoverusejs'])) { |
| 160 | $updateoption('popover_usejs', 'yes' ); |
| 161 | } else { |
| 162 | $updateoption('popover_usejs', 'no' ); |
| 163 | } |
| 164 | |
| 165 | wp_safe_redirect( add_query_arg( array('msg' => $usemsg), wp_get_referer() ) ); |
| 166 | |
| 167 | } |
| 168 | |
| 169 | } |
| 170 | |
| 171 | function add_admin_header_popover() { |
| 172 | |
| 173 | wp_enqueue_script('popoveradminjs', popover_url('popoverincludes/js/popoveradmin.js'), array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), $this->build); |
| 174 | wp_enqueue_style('popoveradmincss', popover_url('popoverincludes/css/popoveradmin.css'), array('widgets'), $this->build); |
| 175 | |
| 176 | $this->update_admin_header_popover(); |
| 177 | } |
| 178 | |
| 179 | function handle_admin_panel() { |
| 180 | |
| 181 | global $page; |
| 182 | |
| 183 | if(function_exists('get_site_option') && defined('PO_GLOBAL')) { |
| 184 | $updateoption = 'update_site_option'; |
| 185 | $getoption = 'get_site_option'; |
| 186 | } else { |
| 187 | $updateoption = 'update_option'; |
| 188 | $getoption = 'get_option'; |
| 189 | } |
| 190 | |
| 191 | $popover_content = stripslashes($getoption('popover_content', '')); |
| 192 | $popover_size = $getoption('popover_size', array('width' => '500px', 'height' => '200px')); |
| 193 | $popover_location = $getoption('popover_location', array('left' => '100px', 'top' => '100px')); |
| 194 | $popover_colour = $getoption('popover_colour', array('back' => 'FFFFFF', 'fore' => '000000')); |
| 195 | $popover_margin = $getoption('popover_margin', array('left' => '0px', 'top' => '0px', 'right' => '0px', 'bottom' => '0px')); |
| 196 | |
| 197 | $popover_size = $this->sanitise_array($popover_size); |
| 198 | $popover_location = $this->sanitise_array($popover_location); |
| 199 | $popover_colour = $this->sanitise_array($popover_colour); |
| 200 | $popover_margin = $this->sanitise_array($popover_margin); |
| 201 | |
| 202 | $popover_check = $getoption('popover_check', array()); |
| 203 | $popover_ereg = $getoption('popover_ereg', ''); |
| 204 | $popover_count = $getoption('popover_count', '3'); |
| 205 | |
| 206 | $popover_usejs = $getoption('popover_usejs', 'no' ); |
| 207 | |
| 208 | $messages = array(); |
| 209 | |
| 210 | $messages[1] = __('Your settings have been saved.','popover'); |
| 211 | $messages[2] = __('Your popover content has been modified by the built in filter, you need to allow unfiltered html.','popover'); |
| 212 | |
| 213 | ?> |
| 214 | <div class='wrap nosubsub'> |
| 215 | <div class="icon32" id="icon-themes"><br></div> |
| 216 | <h2><?php echo __('Pop Over content settings','popover'); ?></h2> |
| 217 | |
| 218 | |
| 219 | |
| 220 | <div class='popover-liquid-left'> |
| 221 | |
| 222 | <div id='popover-left'> |
| 223 | <form action='?page=<?php echo $page; ?>' name='popoveredit' method='post'> |
| 224 | |
| 225 | <input type='hidden' name='beingdragged' id='beingdragged' value='' /> |
| 226 | |
| 227 | <input type='hidden' name='popovercheck[order]' id='in-positive-rules' value='<? echo esc_attr($popover_check['order']); ?>' /> |
| 228 | |
| 229 | <div id='edit-popover' class='popover-holder-wrap'> |
| 230 | <div class='sidebar-name no-movecursor'> |
| 231 | <h3><?php echo _e('Edit Popover settings','popover'); ?></h3> |
| 232 | </div> |
| 233 | <div class='popover-holder'> |
| 234 | |
| 235 | <div class='popover-details'> |
| 236 | |
| 237 | <?php |
| 238 | if ( isset($_GET['msg']) ) { |
| 239 | echo '<div id="upmessage" class="updatedmessage"><p>' . $messages[(int) $_GET['msg']]; |
| 240 | echo '<a href="#close" id="closemessage">' . __('close', 'popover') . '</a>'; |
| 241 | echo '</p></div>'; |
| 242 | $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); |
| 243 | } |
| 244 | ?> |
| 245 | |
| 246 | <label for='popovercontent'><?php _e('Popover content','popover'); ?></label><br/> |
| 247 | <textarea name='popovercontent' id='popovercontent' style='width: 98%' rows='5' cols='10'><?php echo stripslashes($popover_content); ?></textarea> |
| 248 | |
| 249 | </div> |
| 250 | |
| 251 | <h3><?php _e('Active rules','popover'); ?></h3> |
| 252 | <p class='description'><?php _e('These are the rules that will determine if a popover should show when a visitor arrives at your website.','popover'); ?></p> |
| 253 | <div id='positive-rules-holder'> |
| 254 | <?php |
| 255 | |
| 256 | $order = explode(',', $popover_check['order']); |
| 257 | |
| 258 | foreach($order as $key) { |
| 259 | |
| 260 | switch($key) { |
| 261 | |
| 262 | case 'supporter': if( function_exists('is_supporter') ) $this->admin_main('supporter','Blog is not a supporter', 'Shows the popover if the blog is not a supporter.', true); |
| 263 | break; |
| 264 | |
| 265 | case 'isloggedin': $this->admin_main('isloggedin','Visitor is logged in', 'Shows the popover if the user is logged in to your site.', true); |
| 266 | break; |
| 267 | case 'loggedin': $this->admin_main('loggedin','Visitor is not logged in', 'Shows the popover if the user is <strong>not</strong> logged in to your site.', true); |
| 268 | break; |
| 269 | case 'commented': $this->admin_main('commented','Visitor has never commented', 'Shows the popover if the user has never left a comment.', true); |
| 270 | break; |
| 271 | case 'internal': $this->admin_main('internal','Visit not via an Internal link', 'Shows the popover if the user did not arrive on this page via another page on your site.', true); |
| 272 | break; |
| 273 | case 'count': $this->admin_viewcount('count','Popover shown less than', 'Shows the popover if the user has only seen it less than the following number of times:', $popover_count); |
| 274 | break; |
| 275 | |
| 276 | } |
| 277 | |
| 278 | } |
| 279 | |
| 280 | |
| 281 | ?> |
| 282 | </div> |
| 283 | <div id='positive-rules' class='droppable-rules popovers-sortable'> |
| 284 | <?php _e('Drop here','membership'); ?> |
| 285 | </div> |
| 286 | |
| 287 | |
| 288 | <h3><?php _e('Appearance settings','popover'); ?></h3> |
| 289 | <table class='form-table' style=''> |
| 290 | <tr> |
| 291 | <th valign='top' scope='row' style='width: 25%;'><strong><?php _e('Pop Over Size','popover'); ?></strong></th> |
| 292 | <td valign='top'> |
| 293 | <?php _e('Width:','popover'); ?> |
| 294 | <input type='text' name='popoverwidth' id='popoverwidth' style='width: 5em;' value='<?php echo $popover_size['width']; ?>' /> |
| 295 | <?php _e('Height:','popover'); ?> |
| 296 | <input type='text' name='popoverheight' id='popoverheight' style='width: 5em;' value='<?php echo $popover_size['height']; ?>' /> |
| 297 | </td> |
| 298 | </tr> |
| 299 | |
| 300 | <tr> |
| 301 | <th valign='top' scope='row' style='width: 25%;'><strong><?php _e('Pop Over Position','popover'); ?></strong></th> |
| 302 | <td valign='top'> |
| 303 | <?php _e('Left:','popover'); ?> |
| 304 | <input type='text' name='popoverleft' id='popoverleft' style='width: 5em;' value='<?php echo $popover_location['left']; ?>' /> |
| 305 | <?php _e('Top:','popover'); ?> |
| 306 | <input type='text' name='popovertop' id='popovertop' style='width: 5em;' value='<?php echo $popover_location['top']; ?>' /> |
| 307 | </td> |
| 308 | </tr> |
| 309 | |
| 310 | <tr> |
| 311 | <th valign='top' scope='row' style='width: 25%;'><strong><?php _e('Pop Over Margins','popover'); ?></strong></th> |
| 312 | <td valign='top'> |
| 313 | <?php _e('Left:','popover'); ?> |
| 314 | <input type='text' name='popovermarginleft' style='width: 5em;' value='<?php echo $popover_margin['left']; ?>' /> |
| 315 | <?php _e('Right:','popover'); ?> |
| 316 | <input type='text' name='popovermarginright' style='width: 5em;' value='<?php echo $popover_margin['right']; ?>' /><br/> |
| 317 | <?php _e('Top:','popover'); ?> |
| 318 | <input type='text' name='popovermargintop' style='width: 5em;' value='<?php echo $popover_margin['top']; ?>' /> |
| 319 | <?php _e('Bottom:','popover'); ?> |
| 320 | <input type='text' name='popovermarginbottom' style='width: 5em;' value='<?php echo $popover_margin['bottom']; ?>' /> |
| 321 | </td> |
| 322 | </tr> |
| 323 | |
| 324 | <tr> |
| 325 | <th valign='top' scope='row' style='width: 25%;'> </th> |
| 326 | <td valign='top'> |
| 327 | <?php _e('or just override the above with JS','popover'); ?> <input type='checkbox' name='popoverusejs' id='popoverusejs' value='yes' <?php if($popover_usejs == 'yes') echo "checked='checked'"; ?> /> |
| 328 | </td> |
| 329 | </tr> |
| 330 | |
| 331 | </table> |
| 332 | <table class='form-table'> |
| 333 | |
| 334 | <tr> |
| 335 | <th valign='top' scope='row' style='width: 25%;'><strong><?php _e('Background Colour','popover'); ?></strong></th> |
| 336 | <td valign='top'> |
| 337 | <?php _e('Hex:','popover'); ?> # |
| 338 | <input type='text' name='popoverbackground' id='popoverbackground' style='width: 10em;' value='<?php echo $popover_colour['back']; ?>' /> |
| 339 | </td> |
| 340 | </tr> |
| 341 | |
| 342 | <tr> |
| 343 | <th valign='top' scope='row' style='width: 25%;'><strong><?php _e('Font Colour','popover'); ?></strong></th> |
| 344 | <td valign='top'> |
| 345 | <?php _e('Hex:','popover'); ?> # |
| 346 | <input type='text' name='popoverforeground' id='popoverforeground' style='width: 10em;' value='<?php echo $popover_colour['fore']; ?>' /> |
| 347 | </td> |
| 348 | </tr> |
| 349 | |
| 350 | </table> |
| 351 | |
| 352 | |
| 353 | <div class='buttons'> |
| 354 | <?php |
| 355 | wp_original_referer_field(true, 'previous'); wp_nonce_field('update-popover'); |
| 356 | ?> |
| 357 | <input type='submit' value='<?php _e('Update', 'membership'); ?>' class='button' /> |
| 358 | <input type='hidden' name='action' value='updated' /> |
| 359 | </div> |
| 360 | |
| 361 | </div> |
| 362 | </div> |
| 363 | </form> |
| 364 | </div> |
| 365 | |
| 366 | |
| 367 | <div id='hiden-actions'> |
| 368 | <?php |
| 369 | |
| 370 | if(!isset($popover_check['supporter']) && function_exists('is_supporter')) { |
| 371 | $this->admin_main('supporter','Blog is not a supporter', 'Shows the popover if the blog is not a supporter.', true); |
| 372 | } |
| 373 | |
| 374 | if(!isset($popover_check['isloggedin'])) { |
| 375 | $this->admin_main('isloggedin','Visitor is logged in', 'Shows the popover if the user is logged in to your site.', true); |
| 376 | } |
| 377 | |
| 378 | if(!isset($popover_check['loggedin'])) { |
| 379 | $this->admin_main('loggedin','Visitor is not logged in', 'Shows the popover if the user is <strong>not</strong> logged in to your site.', true); |
| 380 | } |
| 381 | |
| 382 | if(!isset($popover_check['commented'])) { |
| 383 | $this->admin_main('commented','Visitor has never commented', 'Shows the popover if the user has never left a comment.', true); |
| 384 | } |
| 385 | |
| 386 | if(!isset($popover_check['internal'])) { |
| 387 | $this->admin_main('internal','Visit not via an Internal link', 'Shows the popover if the user did not arrive on this page via another page on your site.', true); |
| 388 | } |
| 389 | |
| 390 | //$popover_count |
| 391 | if(!isset($popover_check['count'])) { |
| 392 | $this->admin_viewcount('count','Popover shown less than', 'Shows the popover if the user has only seen it less than the following number of times:', $popover_count); |
| 393 | } |
| 394 | |
| 395 | ?> |
| 396 | </div> <!-- hidden-actions --> |
| 397 | |
| 398 | </div> <!-- popover-liquid-left --> |
| 399 | |
| 400 | <div class='popover-liquid-right'> |
| 401 | <div class="popover-holder-wrap"> |
| 402 | |
| 403 | <div class="sidebar-name no-movecursor"> |
| 404 | <h3><?php _e('Rules', 'popover'); ?></h3> |
| 405 | </div> |
| 406 | <div class="section-holder" id="sidebar-rules" style="min-height: 98px;"> |
| 407 | <ul class='popovers popovers-draggable'> |
| 408 | <?php |
| 409 | if(isset($popover_check['supporter']) && function_exists('is_supporter')) { |
| 410 | $this->admin_sidebar('supporter','Blog is not a supporter', true); |
| 411 | } elseif(function_exists('is_supporter')) { |
| 412 | $this->admin_sidebar('supporter','Blog is not a supporter', false); |
| 413 | } |
| 414 | |
| 415 | |
| 416 | if(isset($popover_check['isloggedin'])) { |
| 417 | $this->admin_sidebar('isloggedin','Visitor is logged in', true); |
| 418 | } else { |
| 419 | $this->admin_sidebar('isloggedin','Visitor is logged in', false); |
| 420 | } |
| 421 | |
| 422 | if(isset($popover_check['loggedin'])) { |
| 423 | $this->admin_sidebar('loggedin','Visitor is not logged in', true); |
| 424 | } else { |
| 425 | $this->admin_sidebar('loggedin','Visitor is not logged in', false); |
| 426 | } |
| 427 | |
| 428 | if(isset($popover_check['commented'])) { |
| 429 | $this->admin_sidebar('commented','Visitor has never commented', true); |
| 430 | } else { |
| 431 | $this->admin_sidebar('commented','Visitor has never commented', false); |
| 432 | } |
| 433 | |
| 434 | if(isset($popover_check['internal'])) { |
| 435 | $this->admin_sidebar('internal','Visit not via an Internal link', true); |
| 436 | } else { |
| 437 | $this->admin_sidebar('internal','Visit not via an Internal link', false); |
| 438 | } |
| 439 | |
| 440 | //$popover_count |
| 441 | if(isset($popover_check['count'])) { |
| 442 | $this->admin_sidebar('count','Popover shown less than', true); |
| 443 | } else { |
| 444 | $this->admin_sidebar('count','Popover shown less than', false); |
| 445 | } |
| 446 | |
| 447 | ?> |
| 448 | </ul> |
| 449 | </div> |
| 450 | |
| 451 | </div> <!-- popover-holder-wrap --> |
| 452 | |
| 453 | </div> <!-- popover-liquid-left --> |
| 454 | |
| 455 | </div> <!-- wrap --> |
| 456 | |
| 457 | <?php |
| 458 | } |
| 459 | |
| 460 | function admin_sidebar($id, $title, $data = false) { |
| 461 | ?> |
| 462 | <li class='popover-draggable' id='<?php echo $id; ?>' <?php if($data === true) echo "style='display:none;'"; ?>> |
| 463 | <div class='action action-draggable'> |
| 464 | <div class='action-top'> |
| 465 | <?php _e($title,'popover'); ?> |
| 466 | </div> |
| 467 | </div> |
| 468 | </li> |
| 469 | <?php |
| 470 | } |
| 471 | |
| 472 | function admin_main($id, $title, $message, $data = false) { |
| 473 | if(!$data) $data = array(); |
| 474 | ?> |
| 475 | <div class='popover-operation' id='main-<?php echo $id; ?>'> |
| 476 | <h2 class='sidebar-name'><?php _e($title, 'popover');?><span><a href='#remove' class='removelink' id='remove-<?php echo $id; ?>' title='<?php _e("Remove $title tag from this rules area.",'popover'); ?>'><?php _e('Remove','popover'); ?></a></span></h2> |
| 477 | <div class='inner-operation'> |
| 478 | <p><? _e($message, 'popover'); ?></p> |
| 479 | <input type='hidden' name='popovercheck[<?php echo $id; ?>]' value='yes' /> |
| 480 | </div> |
| 481 | </div> |
| 482 | <?php |
| 483 | } |
| 484 | |
| 485 | function admin_referer($id, $title, $message, $data = false) { |
| 486 | if(!$data) $data = array(); |
| 487 | ?> |
| 488 | <div class='popover-operation' id='main-<?php echo $id; ?>'> |
| 489 | <h2 class='sidebar-name'><?php _e($title, 'popover');?><span><a href='#remove' class='removelink' id='remove-<?php echo $id; ?>' title='<?php _e("Remove $title tag from this rules area.",'popover'); ?>'><?php _e('Remove','popover'); ?></a></span></h2> |
| 490 | <div class='inner-operation'> |
| 491 | <p><? _e($message, 'popover'); ?></p> |
| 492 | <input type='text' name='popoverereg' id='popoverereg' style='width: 10em;' value='<?php echo esc_html($data); ?>' /> |
| 493 | <input type='hidden' name='popovercheck[<?php echo $id; ?>]' value='yes' /> |
| 494 | </div> |
| 495 | </div> |
| 496 | <?php |
| 497 | } |
| 498 | |
| 499 | function admin_viewcount($id, $title, $message, $data = false) { |
| 500 | if(!$data) $data = array(); |
| 501 | ?> |
| 502 | <div class='popover-operation' id='main-<?php echo $id; ?>'> |
| 503 | <h2 class='sidebar-name'><?php _e($title, 'popover');?><span><a href='#remove' class='removelink' id='remove-<?php echo $id; ?>' title='<?php _e("Remove $title tag from this rules area.",'popover'); ?>'><?php _e('Remove','popover'); ?></a></span></h2> |
| 504 | <div class='inner-operation'> |
| 505 | <p><? _e($message, 'popover'); ?></p> |
| 506 | <input type='text' name='popovercount' id='popovercount' style='width: 2em;' value='<?php echo esc_html($data); ?>' /> |
| 507 | <?php _e('times','popover'); ?> |
| 508 | <input type='hidden' name='popovercheck[<?php echo $id; ?>]' value='yes' /> |
| 509 | </div> |
| 510 | </div> |
| 511 | <?php |
| 512 | } |
| 513 | |
| 514 | function handle_admin_panelold() { |
| 515 | |
| 516 | global $allowedposttags; |
| 517 | |
| 518 | if(is_multisite() && defined('PO_GLOBAL')) { |
| 519 | $updateoption = 'update_site_option'; |
| 520 | $getoption = 'get_site_option'; |
| 521 | } else { |
| 522 | $updateoption = 'update_option'; |
| 523 | $getoption = 'get_option'; |
| 524 | } |
| 525 | |
| 526 | if(isset($_POST['action']) && addslashes($_POST['action']) == 'updatepopover') { |
| 527 | |
| 528 | //print_r($_POST); |
| 529 | |
| 530 | if(isset($_POST['popovercontent'])) { |
| 531 | if(defined('PO_USEKSES')) { |
| 532 | $updateoption('popover_content', wp_kses($_POST['popovercontent'], $allowedposttags)); |
| 533 | } else { |
| 534 | $updateoption('popover_content', $_POST['popovercontent']); |
| 535 | } |
| 536 | |
| 537 | } |
| 538 | |
| 539 | if(isset($_POST['popoverwidth']) || isset($_POST['popoverheight'])) { |
| 540 | |
| 541 | $width = $_POST['popoverwidth']; |
| 542 | $height = $_POST['popoverheight']; |
| 543 | |
| 544 | if($width == '') $width = '500px'; |
| 545 | if($height == '') $height = '200px'; |
| 546 | |
| 547 | $updateoption('popover_size', array("width" => $width, "height" => $height)); |
| 548 | } |
| 549 | |
| 550 | if(isset($_POST['popoverleft']) || isset($_POST['popovertop'])) { |
| 551 | |
| 552 | $left = $_POST['popoverleft']; |
| 553 | $top = $_POST['popovertop']; |
| 554 | |
| 555 | if($left == '') $left = '100px'; |
| 556 | if($top == '') $top = '100px'; |
| 557 | |
| 558 | $updateoption('popover_location', array("left" => $left, "top" => $top)); |
| 559 | } |
| 560 | |
| 561 | if(isset($_POST['popovermargintop']) || isset($_POST['popovermarginleft']) || isset($_POST['popovermarginright']) || isset($_POST['popovermarginbottom'])) { |
| 562 | |
| 563 | $mleft = $_POST['popovermarginleft']; |
| 564 | $mtop = $_POST['popovermargintop']; |
| 565 | $mright = $_POST['popovermarginright']; |
| 566 | $mbottom = $_POST['popovermarginbottom']; |
| 567 | |
| 568 | if($mleft == '') $mleft = '0px'; |
| 569 | if($mtop == '') $mtop = '0px'; |
| 570 | if($mright == '') $mright = '0px'; |
| 571 | if($mbottom == '') $mbottom = '0px'; |
| 572 | |
| 573 | $updateoption('popover_margin', array('left' => $mleft, 'top' => $mtop, 'right' => $mright, 'bottom' => $mbottom)); |
| 574 | |
| 575 | } |
| 576 | |
| 577 | if(isset($_POST['popoverbackground']) || isset($_POST['popoverforeground'])) { |
| 578 | |
| 579 | $back = $_POST['popoverbackground']; |
| 580 | $fore = $_POST['popoverforeground']; |
| 581 | |
| 582 | if($back == '') $back = 'FFFFFF'; |
| 583 | if($fore == '') $fore = '000000'; |
| 584 | |
| 585 | $updateoption('popover_colour', array("back" => $back, "fore" => $fore)); |
| 586 | } |
| 587 | |
| 588 | if(isset($_POST['popovercheck'])) { |
| 589 | |
| 590 | $updateoption('popover_check', $_POST['popovercheck']); |
| 591 | |
| 592 | if(isset($_POST['popoverereg'])) { |
| 593 | $updateoption('popover_ereg', $_POST['popoverereg']); |
| 594 | } |
| 595 | |
| 596 | if(isset($_POST['popovercount'])) { |
| 597 | $updateoption('popover_count', intval($_POST['popovercount']) ); |
| 598 | } |
| 599 | |
| 600 | } |
| 601 | |
| 602 | if(isset($_POST['popoverusejs'])) { |
| 603 | $updateoption('popover_usejs', 'yes' ); |
| 604 | } else { |
| 605 | $updateoption('popover_usejs', 'no' ); |
| 606 | } |
| 607 | |
| 608 | echo '<div id="message" class="updated fade"><p>' . __('Your settings have been saved.', 'popover') . '</p></div>'; |
| 609 | |
| 610 | } |
| 611 | |
| 612 | $popover_content = stripslashes($getoption('popover_content', '')); |
| 613 | $popover_size = $getoption('popover_size', array('width' => '500px', 'height' => '200px')); |
| 614 | $popover_location = $getoption('popover_location', array('left' => '100px', 'top' => '100px')); |
| 615 | $popover_colour = $getoption('popover_colour', array('back' => 'FFFFFF', 'fore' => '000000')); |
| 616 | $popover_margin = $getoption('popover_margin', array('left' => '0px', 'top' => '0px', 'right' => '0px', 'bottom' => '0px')); |
| 617 | |
| 618 | $popover_size = $this->sanitise_array($popover_size); |
| 619 | $popover_location = $this->sanitise_array($popover_location); |
| 620 | $popover_colour = $this->sanitise_array($popover_colour); |
| 621 | $popover_margin = $this->sanitise_array($popover_margin); |
| 622 | |
| 623 | $popover_check = $getoption('popover_check', array()); |
| 624 | $popover_ereg = $getoption('popover_ereg', ''); |
| 625 | $popover_count = $getoption('popover_count', '3'); |
| 626 | |
| 627 | $popover_usejs = $getoption('popover_usejs', 'no' ); |
| 628 | |
| 629 | ?> |
| 630 | |
| 631 | <div class='wrap'> |
| 632 | |
| 633 | <form action='' method='post'> |
| 634 | <input type='hidden' name='action' value='updatepopover' /> |
| 635 | <?php wp_nonce_field('updatepopover'); ?> |
| 636 | |
| 637 | <h2><?php _e('Pop Over content settings','popover'); ?></h2> |
| 638 | <p><?php _e('Use the settings below to modify the content of your pop over and the rules that will determine when, or if, it will be displayed.','popover'); ?></p> |
| 639 | |
| 640 | <h3><?php _e('Pop Over content','popover'); ?></h3> |
| 641 | <p><?php _e('Enter the content for your pop over in the text area below. HTML is allowed.','popover'); ?></p> |
| 642 | <textarea name='popovercontent' id='popovercontent' style='width: 90%' rows='10' cols='10'><?php echo stripslashes($popover_content); ?></textarea> |
| 643 | |
| 644 | <p class="submit"> |
| 645 | <input class="button" type="submit" name="go" value="<?php _e('Update content', 'popover'); ?>" /> |
| 646 | </p> |
| 647 | |
| 648 | <h3><?php _e('Pop Over display settings','popover'); ?></h3> |
| 649 | <p><?php _e('Use the options below to determine the look, and display settings for the Pop Over.','popover'); ?></p> |
| 650 | |
| 651 | <table class='form-table'> |
| 652 | |
| 653 | <tr> |
| 654 | <td valign='top' width='49%'> |
| 655 | <h3><?php _e('Appearance Settings','popover'); ?></h3> |
| 656 | |
| 657 | <table class='form-table' style='border: 1px solid #ccc; padding-top: 10px; padding-bottom: 10px; margin-bottom: 10px;'> |
| 658 | <tr> |
| 659 | <th valign='top' scope='row' style='width: 25%;'><?php _e('Pop Over Size','popover'); ?></th> |
| 660 | <td valign='top'> |
| 661 | <?php _e('Width:','popover'); ?> |
| 662 | <input type='text' name='popoverwidth' id='popoverwidth' style='width: 5em;' value='<?php echo $popover_size['width']; ?>' /> |
| 663 | <?php _e('Height:','popover'); ?> |
| 664 | <input type='text' name='popoverheight' id='popoverheight' style='width: 5em;' value='<?php echo $popover_size['height']; ?>' /> |
| 665 | </td> |
| 666 | </tr> |
| 667 | |
| 668 | <tr> |
| 669 | <th valign='top' scope='row' style='width: 25%;'><?php _e('Pop Over Position','popover'); ?></th> |
| 670 | <td valign='top'> |
| 671 | <?php _e('Left:','popover'); ?> |
| 672 | <input type='text' name='popoverleft' id='popoverleft' style='width: 5em;' value='<?php echo $popover_location['left']; ?>' /> |
| 673 | <?php _e('Top:','popover'); ?> |
| 674 | <input type='text' name='popovertop' id='popovertop' style='width: 5em;' value='<?php echo $popover_location['top']; ?>' /> |
| 675 | </td> |
| 676 | </tr> |
| 677 | |
| 678 | <tr> |
| 679 | <th valign='top' scope='row' style='width: 25%;'><?php _e('Pop Over Margins','popover'); ?></th> |
| 680 | <td valign='top'> |
| 681 | <?php _e('Left:','popover'); ?> |
| 682 | <input type='text' name='popovermarginleft' style='width: 5em;' value='<?php echo $popover_margin['left']; ?>' /> |
| 683 | <?php _e('Right:','popover'); ?> |
| 684 | <input type='text' name='popovermarginright' style='width: 5em;' value='<?php echo $popover_margin['right']; ?>' /><br/> |
| 685 | <?php _e('Top:','popover'); ?> |
| 686 | <input type='text' name='popovermargintop' style='width: 5em;' value='<?php echo $popover_margin['top']; ?>' /> |
| 687 | <?php _e('Bottom:','popover'); ?> |
| 688 | <input type='text' name='popovermarginbottom' style='width: 5em;' value='<?php echo $popover_margin['bottom']; ?>' /> |
| 689 | </td> |
| 690 | </tr> |
| 691 | |
| 692 | <tr> |
| 693 | <th valign='top' scope='row' style='width: 25%;'> </th> |
| 694 | <td valign='top'> |
| 695 | <?php _e('or just override the above with JS','popover'); ?> <input type='checkbox' name='popoverusejs' id='popoverusejs' value='yes' <?php if($popover_usejs == 'yes') echo "checked='checked'"; ?> /> |
| 696 | </td> |
| 697 | </tr> |
| 698 | |
| 699 | </table> |
| 700 | <table class='form-table'> |
| 701 | |
| 702 | |
| 703 | |
| 704 | <tr> |
| 705 | <th valign='top' scope='row' style='width: 25%;'><?php _e('Background Colour','popover'); ?></th> |
| 706 | <td valign='top'> |
| 707 | <?php _e('Hex:','popover'); ?> # |
| 708 | <input type='text' name='popoverbackground' id='popoverbackground' style='width: 10em;' value='<?php echo $popover_colour['back']; ?>' /> |
| 709 | </td> |
| 710 | </tr> |
| 711 | |
| 712 | <tr> |
| 713 | <th valign='top' scope='row' style='width: 25%;'><?php _e('Font Colour','popover'); ?></th> |
| 714 | <td valign='top'> |
| 715 | <?php _e('Hex:','popover'); ?> # |
| 716 | <input type='text' name='popoverforeground' id='popoverforeground' style='width: 10em;' value='<?php echo $popover_colour['fore']; ?>' /> |
| 717 | </td> |
| 718 | </tr> |
| 719 | |
| 720 | </table> |
| 721 | |
| 722 | </td> |
| 723 | |
| 724 | <td valign='top' width='49%'> |
| 725 | <h3><?php _e('Display Rules','popover'); ?></h3> |
| 726 | |
| 727 | <p><?php _e('Show the Pop Over if <strong>one</strong> of the following checked rules is true.','popover'); ?></p> |
| 728 | <input type='hidden' name='popovercheck[none]' value='none' /> |
| 729 | <table class='form-table'> |
| 730 | <?php |
| 731 | if(function_exists('is_supporter')) { |
| 732 | ?> |
| 733 | <tr> |
| 734 | <td valign='middle' style='width: 5%;'> |
| 735 | <input type='checkbox' name='popovercheck[notsupporter]' <?php if(isset($popover_check['notsupporter'])) echo "checked='checked'"; ?> /> |
| 736 | </td> |
| 737 | <th valign='bottom' scope='row'><?php _e('Visitor is not a supporter.','popover'); ?></th> |
| 738 | </tr> |
| 739 | <?php |
| 740 | } |
| 741 | ?> |
| 742 | <tr> |
| 743 | <td valign='middle' style='width: 5%;'> |
| 744 | <input type='checkbox' name='popovercheck[isloggedin]' <?php if(isset($popover_check['isloggedin'])) echo "checked='checked'"; ?> /> |
| 745 | </td> |
| 746 | <th valign='bottom' scope='row'><?php _e('Visitor is logged in.','popover'); ?></th> |
| 747 | </tr> |
| 748 | <tr> |
| 749 | <td valign='middle' style='width: 5%;'> |
| 750 | <input type='checkbox' name='popovercheck[loggedin]' <?php if(isset($popover_check['loggedin'])) echo "checked='checked'"; ?> /> |
| 751 | </td> |
| 752 | <th valign='bottom' scope='row'><?php _e('Visitor is not logged in.','popover'); ?></th> |
| 753 | </tr> |
| 754 | <tr> |
| 755 | <td valign='middle' style='width: 5%;'> |
| 756 | <input type='checkbox' name='popovercheck[commented]' <?php if(isset($popover_check['commented'])) echo "checked='checked'"; ?> /> |
| 757 | </td> |
| 758 | <th valign='bottom' scope='row'><?php _e('Visitor has never commented here before.','popover'); ?></th> |
| 759 | </tr> |
| 760 | |
| 761 | <tr> |
| 762 | <td valign='middle' style='width: 5%;'> |
| 763 | <input type='checkbox' name='popovercheck[internal]' <?php if(isset($popover_check['internal'])) echo "checked='checked'"; ?> /> |
| 764 | </td> |
| 765 | <th valign='bottom' scope='row'><?php _e('Visitor did not come from an internal page.','popover'); ?></th> |
| 766 | </tr> |
| 767 | |
| 768 | </table> |
| 769 | |
| 770 | <p><?php _e('And the visitor has seen the pop over less than','popover'); ?> |
| 771 | <input type='text' name='popovercount' id='popovercount' style='width: 2em;' value='<?php echo htmlentities($popover_count,ENT_QUOTES, 'UTF-8'); ?>' /> |
| 772 | <?php _e('times','popover'); ?></p> |
| 773 | |
| 774 | </td> |
| 775 | </tr> |
| 776 | |
| 777 | </table> |
| 778 | |
| 779 | <p class="submit"> |
| 780 | <input class="button" type="submit" name="goagain" value="<?php _e('Update settings', 'popover'); ?>" /> |
| 781 | </p> |
| 782 | |
| 783 | </form> |
| 784 | |
| 785 | </div> |
| 786 | |
| 787 | <?php |
| 788 | } |
| 789 | |
| 790 | } |
| 791 | |
| 792 | } |
| 793 | |
| 794 | ?> |