Changeset 758
- Timestamp:
- 12/12/2012 02:34:11 AM (6 months ago)
- Location:
- trunk/WordPress/plugin/transposh/wp
- Files:
-
- 2 edited
-
transposh_admin.php (modified) (19 diffs)
-
transposh_options.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/wp/transposh_admin.php
r755 r758 29 29 private $localeleft = 'left'; 30 30 private $pages = array(); 31 private $contains_settings = false;32 31 private $page = ''; 33 32 … … 54 53 add_action('wp_ajax_tp_comment_lang', array(&$this, 'on_ajax_tp_comment_lang')); 55 54 55 // key is page name, first is description, second is side menu description, third is if this contains settings 56 56 $this->pages = array( 57 57 'tp_main' => array(__('Dashboard', TRANSPOSH_TEXT_DOMAIN)), 58 'tp_langs' => array(__('Languages', TRANSPOSH_TEXT_DOMAIN) ),59 'tp_settings' => array(__('Settings', TRANSPOSH_TEXT_DOMAIN) ),60 'tp_engines' => array(__('Translation Engines', TRANSPOSH_TEXT_DOMAIN) ),61 'tp_widget' => array(__('Widgets settings', TRANSPOSH_TEXT_DOMAIN) ),62 'tp_advanced' => array(__('Advanced', TRANSPOSH_TEXT_DOMAIN) ),58 'tp_langs' => array(__('Languages', TRANSPOSH_TEXT_DOMAIN), '', true), 59 'tp_settings' => array(__('Settings', TRANSPOSH_TEXT_DOMAIN), '', true), 60 'tp_engines' => array(__('Translation Engines', TRANSPOSH_TEXT_DOMAIN), '', true), 61 'tp_widget' => array(__('Widgets settings', TRANSPOSH_TEXT_DOMAIN), '', true), 62 'tp_advanced' => array(__('Advanced', TRANSPOSH_TEXT_DOMAIN), '', true), 63 63 'tp_utils' => array(__('Utilities', TRANSPOSH_TEXT_DOMAIN)), 64 64 'tp_about' => array(__('About', TRANSPOSH_TEXT_DOMAIN)), 65 65 'tp_support' => array(__('Support', TRANSPOSH_TEXT_DOMAIN)), 66 66 ); 67 if (isset($_GET['page']) && isset($this->pages[$_GET['page']])) $this->page = $_GET['page']; 67 if (isset($_GET['page']) && isset($this->pages[$_GET['page']])) 68 $this->page = $_GET['page']; 68 69 } 69 70 … … 114 115 foreach ($GLOBALS['wp_roles']->get_names() as $role_name => $something) { 115 116 $role = $GLOBALS['wp_roles']->get_role($role_name); 116 if ($_POST[$role_name] == "1") $role->add_cap(TRANSLATOR); 117 if (isset($_POST[$role_name]) && $_POST[$role_name] == "1") 118 $role->add_cap(TRANSLATOR); 117 119 else $role->remove_cap(TRANSLATOR); 118 120 } … … 128 130 // We will need to refresh rewrite rules for the case someone enabled in wordpress first after transposh 129 131 // install and then went on to transposh and enabled, and this keeps us safe ;) 130 if ($this->transposh->options->enable_permalinks != $_POST[$this->transposh->options->enable_permalinks ->get_name()]) {132 if ($this->transposh->options->enable_permalinks != $_POST[$this->transposh->options->enable_permalinks_o->get_name()]) { 131 133 $this->transposh->options->enable_permalinks = TP_FROM_POST; 132 134 $GLOBALS['wp_rewrite']->flush_rules(); … … 195 197 $submenu_pages = array(); 196 198 foreach ($this->pages as $slug => $titles) { 197 if (!isset($titles[1]) ) {198 array_push($titles, $titles[0]);199 if (!isset($titles[1]) || !$titles[1]) { 200 $titles[1] = $titles[0]; 199 201 } 200 202 $submenu_pages[] = add_submenu_page('tp_main', $titles[0] . ' | Transposh', $titles[1], 'manage_options', $slug, array(&$this, 'options')); … … 279 281 if ($this->page == 'tp_main') { 280 282 add_screen_option('layout_columns', array('max' => 4, 'default' => 2)); 281 add_meta_box('transposh-sidebox-about', __('About this plugin', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_sidebox_about_content'), '', 'side', 'core');282 283 add_meta_box('transposh-sidebox-news', __('Plugin news', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_sidebox_news_content'), '', 'normal', 'core'); 283 284 add_meta_box('transposh-sidebox-stats', __('Plugin stats', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_sidebox_stats_content'), '', 'column3', 'core'); … … 288 289 function options() { 289 290 echo '<div class="wrap">'; 290 echo '<form action="admin-post.php" method="post">';291 echo '<input type="hidden" name="action" value="save_transposh"/>';292 echo '<input type="hidden" name="page" value="' . $this->page . '"/>';293 echo wp_nonce_field(TR_NONCE);294 291 screen_icon('transposh-logo'); 295 292 … … 303 300 echo '</h2>'; 304 301 302 // do we need a form? 303 if (isset($this->pages[$this->page][2]) && $this->pages[$this->page][2]) { //$this->contains_settings) { 304 echo '<form action="admin-post.php" method="post">'; 305 echo '<input type="hidden" name="action" value="save_transposh"/>'; 306 echo '<input type="hidden" name="page" value="' . $this->page . '"/>'; 307 echo wp_nonce_field(TR_NONCE); 308 } 309 310 // the page content 305 311 if ($this->page) call_user_func(array(&$this, $this->page)); 306 312 307 313 // Add submission for pages that can be modified 308 if ( $this->contains_settings) {314 if (isset($this->pages[$this->page][2]) && $this->pages[$this->page][2]) { //$this->contains_settings) { 309 315 echo '<p>'; 310 316 echo'<input type="submit" value="' . esc_attr__('Save Changes', TRANSPOSH_TEXT_DOMAIN) . '" class="button-primary" name="Submit"/>'; 311 317 echo'</p>'; 318 echo'</form>'; 312 319 } 313 320 … … 320 327 } 321 328 322 // will be executed if wordpress core detects this page has to be rendered323 /* function on_load_page() {324 325 //add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore326 add_meta_box('transposh-sidebox-translate', __('Translate all', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_sidebox_translate_content'), $this->pagehook, 'side', 'core');327 add_meta_box('transposh-contentbox-languages', __('Supported languages', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_contentbox_languages_content'), $this->pagehook, 'normal', 'core');328 add_meta_box('transposh-contentbox-translation', __('Translation settings', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_contentbox_translation_content'), $this->pagehook, 'normal', 'core');329 add_meta_box('transposh-contentbox-autotranslation', __('Automatic translation settings', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_contentbox_auto_translation_content'), $this->pagehook, 'normal', 'core');330 add_meta_box('transposh-contentbox-protranslation', __('Professional translation settings', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_contentbox_professional_translation_content'), $this->pagehook, 'normal', 'core');331 add_meta_box('transposh-contentbox-frontend', __('Frontend settings', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_contentbox_frontend_content'), $this->pagehook, 'normal', 'core');332 add_meta_box('transposh-contentbox-general', __('Generic settings', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_contentbox_generic_content'), $this->pagehook, 'normal', 'core');333 add_meta_box('transposh-contentbox-database', __('Database maintenance', TRANSPOSH_TEXT_DOMAIN), array(&$this, 'on_contentbox_database_content'), $this->pagehook, 'normal', 'core');334 }335 */336 329 //executed to show the plugins complete admin page 337 330 function tp_main() { 338 339 340 // add some user warnings that leads to some FAQs341 342 331 echo '<div id="dashboard-widgets-wrap">'; 343 332 … … 359 348 */ 360 349 function tp_langs() { 361 $this->contains_settings = true;362 350 // we need some styles 363 351 global $wp_locale; … … 417 405 // Show normal settings 418 406 function tp_settings() { 419 $this->contains_settings = true; 420 421 $this->section(__('Translation related settings', TRANSPOSH_TEXT_DOMAIN), ''); 407 $this->section(__('Translation related settings', TRANSPOSH_TEXT_DOMAIN)); 422 408 423 409 /* … … 444 430 $this->sectionstop(); 445 431 446 $this->section(__('General settings', TRANSPOSH_TEXT_DOMAIN) , '');432 $this->section(__('General settings', TRANSPOSH_TEXT_DOMAIN)); 447 433 $this->checkbox($this->transposh->options->enable_permalinks_o, __('Rewrite URLs', TRANSPOSH_TEXT_DOMAIN) 448 434 , __('Rewrite URLs to be search engine friendly, ' . … … 462 448 $this->sectionstop(); 463 449 464 $this->section(__('Backup service settings', TRANSPOSH_TEXT_DOMAIN) , '');450 $this->section(__('Backup service settings', TRANSPOSH_TEXT_DOMAIN)); 465 451 echo '<input type="radio" value="1" name="' . $this->transposh->options->transposh_backup_schedule_o->get_name() . '" ' . checked($this->transposh->options->transposh_backup_schedule, 1, false) . '/>' . __('Enable daily backup', TRANSPOSH_TEXT_DOMAIN) . '<br/>'; 466 452 echo '<input type="radio" value="2" name="' . $this->transposh->options->transposh_backup_schedule_o->get_name() . '" ' . checked($this->transposh->options->transposh_backup_schedule, 2, false) . '/>' . __('Enable live backup', TRANSPOSH_TEXT_DOMAIN) . '<br/>'; … … 471 457 472 458 function tp_engines() { 473 $this->contains_settings = true; 474 475 $this->section(__('Automatic Translation Settings', TRANSPOSH_TEXT_DOMAIN), ''); 459 $this->section(__('Automatic Translation Settings', TRANSPOSH_TEXT_DOMAIN)); 476 460 $this->checkbox($this->transposh->options->enable_autotranslate_o, __('Enable automatic translation', TRANSPOSH_TEXT_DOMAIN) 477 461 , __('Allow automatic translation of pages', TRANSPOSH_TEXT_DOMAIN)); … … 519 503 520 504 function tp_widget() { 521 $this->contains_settings = true;522 523 505 $this->checkbox($this->transposh->options->widget_progressbar_o, __('Show progress bar', TRANSPOSH_TEXT_DOMAIN) 524 506 , __('Show progress bar when a client triggers automatic translation', TRANSPOSH_TEXT_DOMAIN)); … … 534 516 535 517 function tp_advanced() { 536 $this->contains_settings = true;537 /**538 * Insert the option to enable translation of urls539 * Disbaled by default.540 * @since 0.5.3541 */542 518 $this->checkbox($this->transposh->options->enable_url_translate_o, __('Enable url translation', TRANSPOSH_TEXT_DOMAIN) . ' (' . __('experimental', TRANSPOSH_TEXT_DOMAIN) . ')', __('Allow translation of permalinks and urls', TRANSPOSH_TEXT_DOMAIN)); 543 519 … … 588 564 589 565 function tp_about() { 590 /* wp_enqueue_style( 'wp-pointer' ); 591 wp_enqueue_script( 'wp-pointer' ); 592 593 $content = '<h3>' . __( 'New Feature: Toolbar' ) . '</h3>'; 594 $content .= '<p>' . __( 'We’ve combined the admin bar and the old Dashboard header into one persistent toolbar. Hover over the toolbar items to see what’s new.' ) . '</p>'; 595 596 if ( is_multisite() && is_super_admin() ) 597 $content .= '<p>' . __( 'Network Admin is now located in the My Sites menu.' ) . '</p>'; 598 599 $this->print_js( 'tp_toolbar', '#icon-options-general', array( 600 'content' => $content, 601 'position' => array( 'edge' => 'top', 'align' => 'center' ), 602 ) ); */ 566 567 $this->section(__('About Transposh', TRANSPOSH_TEXT_DOMAIN)); 568 echo __('Transposh was started at 2008 and is dedicated to provide tools to ease website translation.', TRANSPOSH_TEXT_DOMAIN); 569 echo '<br/>'; 570 echo __('Learn more about us in the following online presenses', TRANSPOSH_TEXT_DOMAIN); 571 echo '<ul style="list-style-type:disc;margin-' . $this->localeleft . ':20px;">'; 572 echo '<li><a href="http://transposh.org">'; 573 echo __('Our website', TRANSPOSH_TEXT_DOMAIN); 574 echo '</a></li><li><a href="http://blog.transposh.com">'; 575 echo __('Our blog', TRANSPOSH_TEXT_DOMAIN); 576 echo '</a></li><li><a href="http://twitter.com/transposh">'; 577 echo __('Our twitter account (feel free to follow!)', TRANSPOSH_TEXT_DOMAIN); 578 echo '</a></li><li><a href="https://www.facebook.com/transposh">'; 579 echo __('Our facebook page (feel free to like!)', TRANSPOSH_TEXT_DOMAIN); 580 echo '</a></li><li><a href="https://plus.google.com/103680503574339351392/posts">'; 581 echo __('Our google plus page (add us to your circles!)', TRANSPOSH_TEXT_DOMAIN); 582 echo '</a></li><li><a href="http://www.youtube.com/user/transposh">'; 583 echo __('Our youtube channel', TRANSPOSH_TEXT_DOMAIN); 584 echo '</a></li></ul>'; 585 586 587 $this->sectionstop(); 603 588 } 604 589 605 590 function tp_support() { 606 591 echo '<p>'; 592 $this->section(__('Transposh support', TRANSPOSH_TEXT_DOMAIN), 593 __('Have you encountered any problem with our plugin and need our help?', TRANSPOSH_TEXT_DOMAIN) . '<br>'. 594 __('Do you need to ask us any question?', TRANSPOSH_TEXT_DOMAIN) . '<br>'. 595 __('You have two options:', TRANSPOSH_TEXT_DOMAIN) . '<br>'); 596 $this->sectionstop(); 597 $this->header(__('Our free support', TRANSPOSH_TEXT_DOMAIN)); 598 echo '<div class="col-wrap">'; 599 echo __('There are many channels to reach us and we do try to help as fast as we can', TRANSPOSH_TEXT_DOMAIN) . '<br>'; 600 echo __('You can contact us through our contact form on our web site', TRANSPOSH_TEXT_DOMAIN) . '<br>'; 601 echo __('Create a ticket for us if you have found any bugs', TRANSPOSH_TEXT_DOMAIN) . '<br>'; 602 echo __('Reach us via different forums:', TRANSPOSH_TEXT_DOMAIN); 603 echo '<ul style="list-style-type:disc;margin-' . $this->localeleft . ':20px;">'; 604 echo '<li><a href="http://wordpress.org/support/plugin/transposh-translation-filter-for-wordpress">'; 605 echo __('Our support forum on wordpress.org', TRANSPOSH_TEXT_DOMAIN); 606 echo '<li><a href="http://trac.transposh.org">'; 607 echo __('Our internal development site, with wiki and tickets', TRANSPOSH_TEXT_DOMAIN); 608 echo '</a></li><li><a href="https://www.facebook.com/transposh">'; 609 echo __('Our facebook page', TRANSPOSH_TEXT_DOMAIN); 610 echo '</a></li><li><a href="https://plus.google.com/103680503574339351392/posts">'; 611 echo __('Our google plus page', TRANSPOSH_TEXT_DOMAIN); 612 echo '</a></li></ul>'; 613 echo __('Contact us directly via:', TRANSPOSH_TEXT_DOMAIN); 614 echo '<ul style="list-style-type:disc;margin-' . $this->localeleft . ':20px;">'; 615 echo '<li><a href="http://transposh.org/contact-us/">' . __('Our contact form', TRANSPOSH_TEXT_DOMAIN) . '</a></li>'; 616 echo '<li><a href="http://transposh.org/redir/newfeature">' . __('Suggest a Feature', TRANSPOSH_TEXT_DOMAIN) . '</a></li>'; 617 echo '<li><a href="http://transposh.org/redir/newticket">' . __('Report a Bug', TRANSPOSH_TEXT_DOMAIN) . '</a></li>'; 618 echo '</ul>'; 619 620 echo '</div>'; 621 $this->header(__('Professional support option', TRANSPOSH_TEXT_DOMAIN)); 622 echo '<div class="col-wrap">'; 623 echo __('For the low low price of $99, we will take express action on your request. By express we mean that your issue will become our top priority, and will resolve ASAP', TRANSPOSH_TEXT_DOMAIN) . '<br>'; 624 echo __('This includes helping with various bugs, basic theme/plugins conflicts, or just telling you where the ON button is', TRANSPOSH_TEXT_DOMAIN) . '<br>'; 625 echo __('Full money back guarentee! If your problem remains unresolved or you are simply unhappy we will refund your paypal account as soon as you ask (as long as paypal allows it, don\'t come to us three years later!)', TRANSPOSH_TEXT_DOMAIN) . '<br>'; 626 echo __('So hit the following button. Thanks!', TRANSPOSH_TEXT_DOMAIN) . '<br>'; 627 echo '<br/> 628 <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 629 <input type="hidden" name="cmd" value="_s-xclick"> 630 <input type="hidden" name="hosted_button_id" value="KCCE87P7B2MG8"> 631 <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 632 <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> 633 </form> 634 '; 635 echo '</div>'; 636 $this->header(__('Donations', TRANSPOSH_TEXT_DOMAIN)); 637 echo '<div class="col-wrap">'; 638 echo __('If you just want to show that you care, this is the button for you. But please think twice before doing this. It will make us happier if you just do something nice for someone in your area, contribute to a local charity, and let us know that you did that :)', TRANSPOSH_TEXT_DOMAIN) . '<br>'; 639 echo '<br/> 640 <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 641 <input type="hidden" name="cmd" value="_s-xclick"> 642 <input type="hidden" name="hosted_button_id" value="4E52WJ8WDK79J"> 643 <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 644 <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> 645 </form>'; 646 echo '</div>'; 607 647 } 608 648 … … 625 665 // i did not describe each callback dedicated, what they do can be easily inspected and compare with the admin page displayed 626 666 627 function on_sidebox_about_content() {628 echo '<ul style="list-style-type:disc;margin-' . $this->localeleft . ':20px;">';629 echo '<li><a href="http://transposh.org/">' . __('Plugin Homepage', TRANSPOSH_TEXT_DOMAIN) . '</a></li>';630 echo '<li><a href="http://transposh.org/redir/newfeature">' . __('Suggest a Feature', TRANSPOSH_TEXT_DOMAIN) . '</a></li>';631 // support Forum632 echo '<li><a href="http://transposh.org/redir/newticket">' . __('Report a Bug', TRANSPOSH_TEXT_DOMAIN) . '</a></li>';633 // donate with PayPal634 echo '</ul>';635 }636 637 /* private static function print_js($pointer_id, $selector, $args) {638 if (empty($pointer_id) || empty($selector) || empty($args) || empty($args['content']))639 return;640 ?>641 <script type="text/javascript">642 //<![CDATA[643 (function($){644 var options = <?php echo json_encode($args); ?>, setup;645 646 if ( ! options )647 return;648 649 options = $.extend( options, {650 close: function() {651 $.post( ajaxurl, {652 pointer: '<?php echo $pointer_id; ?>',653 action: 'dismiss-wp-pointer'654 });655 }656 });657 658 setup = function() {659 $('<?php echo $selector; ?>').pointer( options ).pointer('open');660 };661 662 if ( options.position && options.position.defer_loading )663 $(window).bind( 'load.wp-pointers', setup );664 else665 $(document).ready( setup );666 667 })( jQuery );668 //]]>669 </script>670 <?php671 } */672 673 667 function on_sidebox_news_content() { 674 668 echo '<div style="margin:6px">'; … … 682 676 683 677 /** UTILITY FUNCTIONS * */ 684 private function section($head, $text ) {678 private function section($head, $text = '') { 685 679 echo '<h2>' . $head . '</h2>'; 686 680 echo '<div class="col-wrap">'; 687 if ( isset($text)) echo '<p>' . $text . '</p>';681 if ($text) echo '<p>' . $text . '</p>'; 688 682 } 689 683 -
trunk/WordPress/plugin/transposh/wp/transposh_options.php
r755 r758 185 185 186 186 function __set($name, $value) { 187 if ($value == TP_FROM_POST ) {187 if ($value == TP_FROM_POST && isset($_POST[$name])) { 188 188 $value = $_POST[$name]; 189 189 } … … 201 201 202 202 function __construct() { 203 204 203 205 204 // can't tp_logger("creating options");
Note: See TracChangeset
for help on using the changeset viewer.
