Qtranslate Slug - Version 1.1.18

Version Description

= 1.0 = Major version, the plugin has been rewritten. Better performance, and some enhancements.

= 0.9 = This version fix some bugs and allow multilanguage in nav-menus.

= 0.8 = A lot of slugs content allowed

= 0.7 = This version allows TLD domain option for a different Qtranslate fork maded by Zappo

Download this release

Release Info

Developer pedroghandi
Plugin Icon wp plugin Qtranslate Slug
Version 1.1.18
Comparing to
See all releases

Code changes from version 1.1.17 to 1.1.18

assets/css/qts-settings.css CHANGED
@@ -1,22 +1,22 @@
1
  /*messages*/
2
  .error {color:#cc0000;}
3
 
4
- .form-table th {
5
  width: 15%;
6
  min-width: 15% !important;
7
  }
8
 
9
- .form-table td > span {
10
  display: inline-block;
11
  min-width: 100px;
12
  }
13
 
14
- .form-table label {
15
  display: block;
16
  margin-bottom: 8px;
17
  }
18
 
19
- .qts-slug {
20
  width: 35%;
21
  }
22
 
@@ -39,4 +39,15 @@ div.updated.success{
39
 
40
  .ko {
41
  color: #c00;
42
- }
 
 
 
 
 
 
 
 
 
 
 
1
  /*messages*/
2
  .error {color:#cc0000;}
3
 
4
+ .settings_page_qtranslate-slug-settings .form-table th {
5
  width: 15%;
6
  min-width: 15% !important;
7
  }
8
 
9
+ .settings_page_qtranslate-slug-settings .form-table td > span {
10
  display: inline-block;
11
  min-width: 100px;
12
  }
13
 
14
+ .settings_page_qtranslate-slug-settings .form-table label {
15
  display: block;
16
  margin-bottom: 8px;
17
  }
18
 
19
+ .settings_page_qtranslate-slug-settings .qts-slug {
20
  width: 35%;
21
  }
22
 
39
 
40
  .ko {
41
  color: #c00;
42
+ }
43
+ /* v1.1.18 */
44
+ #edittag #qts_term_slugs { display: none; }
45
+ .term-slug-wrap .qts_term_block input {
46
+ width: 86.5%;
47
+ }
48
+
49
+ .qts_term_block label {
50
+ display: inline-block;
51
+ min-width: 120px;
52
+ }
53
+
includes/class-qtranslate-slug-widget.php CHANGED
@@ -9,7 +9,7 @@ class QtranslateSlugWidget extends WP_Widget {
9
 
10
  function QtranslateSlugWidget() {
11
  $widget_ops = array('classname' => 'qts_widget', 'description' => __('Allows your visitors to choose a Language.','qts') );
12
- $this->WP_Widget('qtranslateslug', __('Language selector', 'qts'), $widget_ops);
13
  }
14
 
15
  function widget($args, $instance) {
9
 
10
  function QtranslateSlugWidget() {
11
  $widget_ops = array('classname' => 'qts_widget', 'description' => __('Allows your visitors to choose a Language.','qts') );
12
+ parent::__construct('qtranslateslug', __('Language selector (QTS)', 'qts'), $widget_ops);
13
  }
14
 
15
  function widget($args, $instance) {
includes/class-qtranslate-slug.php CHANGED
@@ -10,9 +10,7 @@ class QtranslateSlug {
10
 
11
  /**
12
  * array with old data system
13
- *
14
  * @var bool
15
- *
16
  * @since 1.0
17
  */
18
  private $old_data = null;
@@ -21,9 +19,7 @@ class QtranslateSlug {
21
 
22
  /**
23
  * stores permalink_structure option, for save queries to db
24
- *
25
  * @var string
26
- *
27
  * @since 1.0
28
  */
29
  private $permalink_structure;
@@ -32,9 +28,7 @@ class QtranslateSlug {
32
 
33
  /**
34
  * Stores options slugs from database
35
- *
36
  * @var array
37
- *
38
  * @since 1.0
39
  */
40
  protected $options;
@@ -43,115 +37,93 @@ class QtranslateSlug {
43
 
44
  /**
45
  * Variable used to override the language
46
- *
47
  * @var string
48
- *
49
  * @since 1.0
50
  */
51
  private $lang = false;
52
 
53
- /**
54
- * variable for current language
55
- */
56
  private $current_lang = false;
57
 
58
  /**
59
- * variable for default language
60
- */
61
  private $default_language = false;
62
 
63
- /**
64
  * Array of enabled languages
65
- *
66
  * @var array
67
- *
68
  * @since 1.0
69
  */
70
  private $enabled_languages = array();
71
- /**
 
72
  * Array of enabled languages
73
- *
74
  * @var array
75
- *
76
  * @since 1.0
77
  */
78
  private $url_path_mode = "";
79
-
80
-
81
-
82
  /**
83
  * slug in meta_key name in meta tables
84
- *
85
  * @var string
86
- *
87
  * @since 1.0
88
  */
89
  private $meta_key = "_qts_slug_%s";
90
-
91
-
92
-
93
  /**
94
  * Array of translated versions of the current url
95
- *
96
  * @var array
97
- *
98
  * @since 1.0
99
  */
100
  private $current_url = array();
101
-
102
-
103
  /**
104
  * Variable that contains the prefix for base plugin function names (qtranslate/qtranslate-x)
105
- *
106
  * @var string
107
- *
108
  * @since ?
109
  */
110
  private $plugin_prefix = "";
111
 
112
-
113
  /**
114
  * return the current / temp language
115
- *
116
  * @since 1.0
117
  */
118
  private function get_lang() {
119
- global $q_config;
120
-
121
- return ($this->lang) ? $this->lang : $q_config['language'];
122
  }
 
123
  /**
124
  * return the current / temp language
125
- * we store and use it all the way!
126
- *
127
  * @since 1.1.9
128
  */
129
  private function get_currentlang() {
130
  return $this->current_lang;
131
  }
 
132
  /**
133
  * return the enabled languages
134
- * we store and use it all the way!
135
- *
136
  * @since 1.1.9
137
  */
138
  private function get_enabled_languages() {
139
  return $this->enabled_languages;
140
  }
 
141
  /**
142
  * return the enabled languages
143
- * we store and use it all the way!
144
- *
145
  * @since 1.1.9
146
  */
147
  private function get_url_path_mode() {
148
  return $this->url_path_mode;
149
  }
150
 
151
-
152
  /**
153
  * getter: options
154
- *
155
  * @since 1.0
156
  */
157
  public function get_options() {
@@ -200,7 +172,7 @@ class QtranslateSlug {
200
  */
201
  private function set_plugin_prefix(){
202
  if ('' === $this->plugin_prefix){
203
- if (is_plugin_active('qtranslate-x/qtranslate.php')){
204
  $this->plugin_prefix = 'qtranxf_';
205
  } else {
206
  $this->plugin_prefix = 'qtrans_';
@@ -215,7 +187,7 @@ class QtranslateSlug {
215
 
216
  private function set_url_path_mode(){
217
  if ('' === $this->url_path_mode){
218
- if (is_plugin_active('qtranslate-x/qtranslate.php')){
219
  $this->url_path_mode = QTX_URL_PATH;
220
  } else {
221
  $this->url_path_mode = QT_URL_PATH;
@@ -249,7 +221,6 @@ class QtranslateSlug {
249
  * @since 1.0
250
  */
251
  public function get_meta_key( $force_lang = false ) {
252
- global $q_config;
253
 
254
  $lang = $this->get_lang();
255
 
@@ -269,14 +240,14 @@ class QtranslateSlug {
269
  */
270
  static function block_activate() {
271
  global $wp_version;
272
-
273
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
274
-
275
  return (
276
- version_compare($wp_version, "3.3", "<" ) ||
277
- ( !is_plugin_active('qtranslate/qtranslate.php') &&
278
- !is_plugin_active('mqtranslate/mqtranslate.php') &&
279
- !is_plugin_active('qtranslate-x/qtranslate.php'))
 
 
280
  );
281
  }
282
 
@@ -292,7 +263,9 @@ class QtranslateSlug {
292
  global $wpdb;
293
 
294
  if ( self::block_activate() ) {
295
- return;
 
 
296
  }
297
 
298
  if ( function_exists('is_multisite') && is_multisite() ) {
@@ -429,13 +402,17 @@ class QtranslateSlug {
429
  * @since 1.0
430
  */
431
  function notice_dependences(){
432
- global $current_screen;
433
- $ornewer=__('or newer','qts');
434
  $info_url=admin_url('plugin-install.php?tab=plugin-information');
435
  echo '<div class="error">' . PHP_EOL;
436
  echo '<p><strong>Qtranslate Slug:</strong></p>' . PHP_EOL;
437
  echo '<p>';
438
- printf(__('This plugin requires at least %s and either %s, or %s, or %s', 'qts'),'<strong>WordPress 3.3</strong>','<a href="'.$info_url.'&plugin=qtranslate-x&TB_iframe=true" class="thickbox" aria-label="'.__('More information about', 'qts').' '.'qTranslate-X" data-title="qTranslate-X"><strong>qTranslate-X</strong></a> (2.9 '.$ornewer.')','<a href="'.$info_url.'&plugin=mqtranslate&TB_iframe=true" class="thickbox" aria-label="'.__('More information about', 'qts').' '.'mqTranslate" data-title="mqTranslate"><strong>mqTranslate</strong></a> (2.6.2.4 '.$ornewer.')','<a href="'.$info_url.'&plugin=qtranslate&TB_iframe=true" class="thickbox" aria-label="'.__('More information about', 'qts').' '.'qTranslate" data-title="qTranslate"><strong>qTranslate</strong></a> (2.5.8 '.$ornewer.')');
 
 
 
 
439
  echo '</p>' . PHP_EOL;
440
  echo '</div>' . PHP_EOL;
441
  }
@@ -492,29 +469,31 @@ class QtranslateSlug {
492
  */
493
  function init() {
494
 
495
- load_plugin_textdomain( 'qts', false, basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/languages' );
496
 
497
- // checking plugin activate
498
- if ( self::block_activate() ) {
499
  if (is_admin()) {
500
  add_action('admin_notices', array(&$this, 'notice_dependences'));
501
  }
502
- return;
503
- }
504
-
505
- // caching qts options
506
- $this->set_options();
507
-
508
- global $q_config;
 
 
509
 
510
- // until we get a proper function, this will make it for it.
511
- $this->current_lang = $q_config['language'];
512
  $this->enabled_languages = $q_config['enabled_languages'];
513
- $this->default_language = $q_config['default_language'];
514
- $this->set_plugin_prefix();
515
- $this->set_url_path_mode();
516
 
517
- if ( is_admin() ) {
518
 
519
  $this->check_old_versions();
520
 
@@ -529,6 +508,7 @@ class QtranslateSlug {
529
 
530
  // admin actions
531
  add_action( 'admin_menu', array(&$this, 'add_slug_meta_box') );
 
532
  add_action( 'save_post', array(&$this, 'save_postdata'), 605, 2 );
533
  add_action( 'delete_term', array(&$this, 'delete_term'), 0, 3);
534
  add_action( 'created_term', array(&$this, 'save_term'), 605, 3);
@@ -537,7 +517,6 @@ class QtranslateSlug {
537
 
538
  add_action( 'init', array(&$this, 'taxonomies_hooks'), 805 );
539
 
540
- add_action( 'wp_dashboard_setup', array(&$this, 'remove_dashboard_widgets') );
541
  add_action( 'admin_head', array(&$this, 'hide_quick_edit'), 600 );
542
  if(!defined('QTRANSLATE_FILE'))
543
  add_action( 'admin_init', array(&$this, 'fix_nav_menu') );
@@ -556,7 +535,7 @@ class QtranslateSlug {
556
  add_action( 'wp_print_styles', array( &$this, 'print_plugin_styles' ), 20 );
557
  }
558
  }
559
-
560
  add_filter( 'query_vars', array(&$this, 'query_vars'));
561
  add_action( 'generate_rewrite_rules', array(&$this, 'modify_rewrite_rules') );
562
 
@@ -565,7 +544,7 @@ class QtranslateSlug {
565
 
566
  remove_action('wp_head', $this->get_plugin_prefix() . 'header');
567
  if( "qtranxf_" === $this->get_plugin_prefix() ) {
568
- remove_action('wp_head', $this->get_plugin_prefix() . 'head');
569
  }
570
 
571
  // add proper hreflang links
@@ -577,6 +556,7 @@ class QtranslateSlug {
577
  remove_filter( 'category_link', $this->get_plugin_prefix() . 'convertURL' );
578
  remove_filter( 'tag_link', $this->get_plugin_prefix() . 'convertURL' );
579
 
 
580
  add_filter( 'qts_permastruct' , array(&$this, 'get_extra_permastruct'), 0, 2);
581
  add_filter( 'qts_url_args', array(&$this, 'parse_url_args'), 0, 1);
582
  add_filter( 'home_url', array(&$this, 'home_url'), 10, 4);
@@ -616,14 +596,13 @@ class QtranslateSlug {
616
  * @since 1.1.8
617
  */
618
  public function qtranslate_slug_header_extended(){
619
- if(is_404()) return;
620
 
621
- //taken from qtx
622
- echo '<link hreflang="x-default" href="'.$this->get_current_url($this->default_language) .'" rel="alternate" />'.PHP_EOL;
623
  foreach($this->get_enabled_languages() as $language) {
624
 
625
- if($language != $this->get_currentlang() )
626
- echo '<link hreflang="'.$language.'" href="'.$this->get_current_url($language).'" rel="alternate" />'."\n";
627
  }
628
  }
629
 
@@ -633,10 +612,7 @@ class QtranslateSlug {
633
  * @param array $classes list of classes
634
  */
635
  public function qts_body_class( $classes ) {
636
- // add 'class-name' to the $classes array
637
  $classes[] = call_user_func($this->get_plugin_prefix() . 'getLanguage');
638
-
639
- // return the $classes array
640
  return $classes;
641
  }
642
 
@@ -665,8 +641,7 @@ class QtranslateSlug {
665
  * @return array the text in the required language
666
  */
667
  public function qts_quickuse( $text,$lang='' ){
668
- global $q_config;
669
- $lang = '' == $lang ? $q_config['language'] : $lang;
670
  $parsed_text = call_user_func($this->get_plugin_prefix() . 'getSortedLanguages',$text);
671
  if( !empty($parsed_text[$lang])){
672
  return $parsed_text[$lang];
@@ -683,8 +658,6 @@ class QtranslateSlug {
683
  * @since 1.0
684
  */
685
  public function modify_rewrite_rules() {
686
- // do we need this global?
687
- //global $wp_rewrite;
688
 
689
  // post types rules
690
  $post_types = get_post_types( array('_builtin' => false ), 'objects');
@@ -802,7 +775,7 @@ class QtranslateSlug {
802
  * @since 1.0
803
  */
804
  public function parse_url_args( $url ) {
805
- global $q_config;
806
 
807
  if (is_admin()) {
808
  return $url;
@@ -812,6 +785,7 @@ class QtranslateSlug {
812
 
813
  // if no permalink structure ads ?lang=en
814
  $base_query = parse_url($q_config['url_info']['original_url']);
 
815
  $base_args = isset($base_query['query']) ? wp_parse_args($base_query['query']) : array();
816
 
817
  if ( empty($this->permalink_structure) || $q_config['url_mode'] == 1 ) {
@@ -984,6 +958,8 @@ class QtranslateSlug {
984
  */
985
  function filter_request( $query ) {
986
  global $wp_query, $wp;
 
 
987
  if ((isset($wp->matched_query) || empty($query)) && ! isset($query['s']) ) {
988
  $query = wp_parse_args($wp->matched_query);
989
  }
@@ -1000,10 +976,14 @@ class QtranslateSlug {
1000
  if ( isset($query['pagename']) || isset($query['page_id']) ):
1001
 
1002
  $page = wp_cache_get('qts_page_request');
1003
- if (!$page)
1004
  $page = isset($query['page_id']) ? get_post($query['page_id']) : $this->get_page_by_path($query['pagename']);
 
 
 
 
 
1005
 
1006
- if (!$page) return $query;
1007
  $id = $page->ID;
1008
  $cache_array = array($page);
1009
  update_post_caches($cache_array, 'page'); // caching query :)
@@ -1013,16 +993,19 @@ class QtranslateSlug {
1013
 
1014
  // -> custom post type
1015
  elseif ( isset($query['post_type']) ):
1016
-
1017
- $page_slug = ( isset($query['name']) && !empty($query['name']) ) ? $query['name'] : $query[$query['post_type']];
1018
- $page = $this->get_page_by_path($page_slug, OBJECT, $query['post_type']);
1019
- if (!$page) return $query;
1020
- $id = $page->ID;
1021
- $cache_array = array($page);
1022
- update_post_caches($cache_array, $query['post_type']); // caching query :)
1023
- $query['name'] = $query[$query['post_type']] = get_page_uri($page);
1024
- $function = 'get_post_permalink';
1025
-
 
 
 
1026
  // -> post
1027
  elseif ( isset($query['name']) || isset($query['p']) ):
1028
 
@@ -1128,15 +1111,14 @@ class QtranslateSlug {
1128
  * @since 1.0
1129
  */
1130
  public function get_current_url( $lang = false ) {
1131
-
1132
  if (!$lang) {
1133
  $lang = $this->get_lang();
1134
  }
1135
-
1136
  if (isset($this->current_url[$lang]) && !empty($this->current_url[$lang])) {
1137
  return $this->current_url[$lang];
1138
  }
1139
-
1140
  return '';
1141
  }
1142
 
@@ -1159,9 +1141,9 @@ class QtranslateSlug {
1159
 
1160
  return array_pop( $exploded_slug );
1161
  }
1162
-
1163
-
1164
-
1165
  /**
1166
  * Retrieves a page id given its path.
1167
  *
@@ -1322,7 +1304,7 @@ class QtranslateSlug {
1322
 
1323
 
1324
  /**
1325
- * Filter that changes the permastruct depending
1326
  *
1327
  * @param string $permastruct default permastruct given b wp_rewrite
1328
  * @param string $name the name of the extra permastruct
@@ -1408,8 +1390,8 @@ class QtranslateSlug {
1408
  * @since 1.0
1409
  */
1410
  public function post_link( $link, $post, $leavename ) {
1411
- global $q_config;
1412
-
1413
  $rewritecode = array(
1414
  '%year%',
1415
  '%monthnum%',
@@ -1560,7 +1542,7 @@ class QtranslateSlug {
1560
  * @since 1.0
1561
  */
1562
  public function _get_page_link( $link, $id ) {
1563
- global $post, $wp_rewrite, $q_config;
1564
 
1565
  $current_post = $post;
1566
 
@@ -1654,7 +1636,7 @@ class QtranslateSlug {
1654
  global $wp_rewrite;
1655
 
1656
  // parse normal term names for ?tag=tagname
1657
- if (empty($this->permalink_structure)) return $link;
1658
 
1659
  if ( !is_object($term) ) {
1660
  if ( is_int($term) ) {
@@ -1684,12 +1666,13 @@ class QtranslateSlug {
1684
  $t = get_taxonomy($taxonomy);
1685
 
1686
  if ( empty($termlink) ) {
1687
- if ( 'category' == $taxonomy )
1688
  $termlink = '?cat=' . $term->term_id;
1689
- elseif ( $t->query_var )
1690
  $termlink = "?$t->query_var=$slug";
1691
- else
1692
  $termlink = "?taxonomy=$taxonomy&term=$slug";
 
1693
  $termlink = home_url($termlink);
1694
  } else {
1695
  if ( $t->rewrite['hierarchical'] ) {
@@ -1699,7 +1682,9 @@ class QtranslateSlug {
1699
  $ancestor_term = get_term($ancestor, $taxonomy);
1700
 
1701
  $ancestor_slug = get_term_meta( $ancestor_term->term_id, $this->get_meta_key(), true );
1702
- if (!$ancestor_slug) $ancestor_slug = $ancestor_term->slug;
 
 
1703
 
1704
  $hierarchical_slugs[] = $ancestor_slug;
1705
  }
@@ -1798,8 +1783,7 @@ class QtranslateSlug {
1798
  function get_terms($terms, $taxonomy) {
1799
 
1800
  global $pagenow;
1801
-
1802
-
1803
  if ( $pagenow != 'admin-ajax.php' ) {
1804
 
1805
  $meta = get_option('qtranslate_term_name');
@@ -1810,15 +1794,14 @@ class QtranslateSlug {
1810
  foreach ($terms as $term_index => $term) {
1811
  // after saving, dont do anything
1812
  if( ( isset($_POST['action'] ) && $_POST['action'] == "editedtag") ||
1813
- !is_object( $term ) ) {
1814
  return $terms;
1815
  }
1816
- $termname = $term->name;
1817
- if( isset( $meta[$termname][$lang] ) ) {
1818
- $term->name = $meta[$termname][$lang];
1819
  }
1820
- };
1821
- };
1822
  }
1823
  return $terms;
1824
  }
@@ -1853,6 +1836,7 @@ class QtranslateSlug {
1853
  // make the output valid
1854
  $tax = str_replace("'", "", $taxonomy);
1855
 
 
1856
  $meta = get_option('qtranslate_term_name');
1857
  $lang = call_user_func($this->get_plugin_prefix() . 'getLanguage');
1858
 
@@ -1861,8 +1845,8 @@ class QtranslateSlug {
1861
  if( isset( $meta[$term->name][$lang] ) ) {
1862
  $term->name = $meta[$term->name][$lang];
1863
  }
1864
- };
1865
- };
1866
 
1867
  }
1868
  return $terms;
@@ -1885,13 +1869,12 @@ class QtranslateSlug {
1885
 
1886
 
1887
  /**
1888
- * Hide auttomatically the wordpress slug blog in edit posts page
1889
  *
1890
  * @since 1.0
1891
  */
1892
  public function hide_slug_box() {
1893
  global $pagenow;
1894
-
1895
  switch ( $pagenow ):
1896
  case 'edit-tags.php':
1897
 
@@ -1903,19 +1886,30 @@ class QtranslateSlug {
1903
  echo " });" . PHP_EOL;
1904
  echo "</script>" . PHP_EOL;
1905
  break;
1906
-
1907
  case 'post.php':
1908
 
1909
  echo "<!-- QTS remove slug box -->" . PHP_EOL;
1910
  echo "<style type=\"text/css\" media=\"screen\">" . PHP_EOL;
1911
- echo " #edit-slug-box { display: none !important}" . PHP_EOL;
1912
  echo "</style>" . PHP_EOL;
1913
- break;
1914
  endswitch;
1915
  }
1916
-
1917
-
1918
-
 
 
 
 
 
 
 
 
 
 
 
1919
  /**
1920
  * Creates a metabox for every post, page and post type avaiable
1921
  *
@@ -1928,11 +1922,12 @@ class QtranslateSlug {
1928
  $context = apply_filters("qts_admin_meta_box_context","side");
1929
  $priority = apply_filters("qts_admin_meta_box_priority","high");
1930
 
1931
- add_meta_box( 'qts_sectionid', __('Slug', 'qts'), array(&$this, 'draw_meta_box'), 'post', $context, $priority);
1932
- add_meta_box( 'qts_sectionid', __('Slug', 'qts'), array(&$this, 'draw_meta_box'), 'page', $context, $priority);
1933
 
1934
- foreach ( get_post_types( array('_builtin' => false ) ) as $ptype )
1935
- add_meta_box( 'qts_sectionid', __('Slug', 'qts'), array(&$this, 'draw_meta_box'), $ptype, $context, $priority );
 
1936
  }
1937
  }
1938
 
@@ -1946,13 +1941,13 @@ class QtranslateSlug {
1946
  * @since 1.0
1947
  */
1948
  public function draw_meta_box( $post ) {
1949
- global $q_config;
1950
-
1951
  // Use nonce for verification
1952
  echo "<table style=\"width:100%\">" . PHP_EOL;
1953
  echo "<input type=\"hidden\" name=\"qts_nonce\" id=\"qts_nonce\" value=\"" . wp_create_nonce( 'qts_nonce' ) . "\" />" . PHP_EOL;
1954
 
1955
- foreach ($q_config['enabled_languages'] as $lang):
1956
 
1957
  $slug = get_post_meta( $post->ID, $this->get_meta_key($lang), true);
1958
 
@@ -1960,7 +1955,7 @@ class QtranslateSlug {
1960
 
1961
  echo "<tr>" . PHP_EOL;
1962
  echo "<th style=\"text-align:left; width:10%; color:#555 \"><label for=\"qts_{$lang}_slug\">".__($q_config['language_name'][$lang], 'qtranslate')."</label></th>" . PHP_EOL;
1963
- echo "<td><input type=\"text\" id=\"qts_{$lang}_slug\" name=\"qts_{$lang}_slug\" value=\"$value\" style=\"width:90%; margin-left:10%; color:#777\" /></td>" . PHP_EOL;
1964
  echo "</tr>" . PHP_EOL;
1965
 
1966
  endforeach;
@@ -1988,14 +1983,14 @@ class QtranslateSlug {
1988
  $post_name = $post->post_name;
1989
  }
1990
 
 
 
1991
  $name = ( $post_title == '' || strlen($post_title) == 0 ) ? $post_name : $post_title;
1992
 
1993
  $slug = trim($slug);
1994
 
1995
  $slug = (empty($slug)) ? sanitize_title($name) : sanitize_title($slug);
1996
-
1997
-
1998
-
1999
  return htmlspecialchars( $slug , ENT_QUOTES );
2000
  }
2001
 
@@ -2061,6 +2056,7 @@ class QtranslateSlug {
2061
  if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
2062
  $suffix = 2;
2063
  do {
 
2064
  $alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
2065
  $post_name_check = $wpdb->get_var( $wpdb->prepare($check_sql, $alt_post_name, $post_ID ) );
2066
  $suffix++;
@@ -2068,13 +2064,16 @@ class QtranslateSlug {
2068
  $slug = $alt_post_name;
2069
  }
2070
  } else {
 
2071
  // Post slugs must be unique across all posts.
2072
  $check_sql = "SELECT $wpdb->postmeta.meta_value FROM $wpdb->posts,$wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '%s' AND $wpdb->postmeta.meta_value = '%s' AND $wpdb->posts.post_type = %s AND ID != %d LIMIT 1";
2073
  $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $meta_key, $slug, $post_type, $post_ID ) );
2074
 
 
2075
  if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) {
2076
  $suffix = 2;
2077
  do {
 
2078
  $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
2079
  $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $meta_key, $alt_post_name, $post_type, $post_ID ) );
2080
  $suffix++;
@@ -2104,17 +2103,19 @@ class QtranslateSlug {
2104
 
2105
  if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) // check autosave
2106
  || (!isset($_POST['post_ID']) || $post_id != $_POST['post_ID']) // check revision
2107
- || (!wp_verify_nonce( $_POST['qts_nonce'], 'qts_nonce')) // verify nonce
2108
  || (!current_user_can($post_type_object->cap->edit_post, $post_id))) { // check permission
2109
  return $post_id;
2110
  }
2111
  foreach ($this->get_enabled_languages() as $lang) {
2112
-
 
 
2113
  $meta_name = $this->get_meta_key($lang);
2114
  $meta_value = apply_filters( 'qts_validate_post_slug', $_POST["qts_{$lang}_slug"], $post, $lang);
2115
  delete_post_meta($post_id, $meta_name);
2116
  update_post_meta($post_id, $meta_name, $meta_value);
2117
-
2118
  }
2119
  }
2120
 
@@ -2128,7 +2129,7 @@ class QtranslateSlug {
2128
  * @since 1.0
2129
  */
2130
  public function show_term_fields( $term ) {
2131
- global $q_config;
2132
 
2133
  // prints the fields in edit page
2134
  if (isset($_GET['action']) && $_GET['action'] == 'edit' ):
@@ -2136,7 +2137,7 @@ class QtranslateSlug {
2136
  echo "<table class=\"form-table\">" . PHP_EOL;
2137
  echo "<input type=\"hidden\" name=\"qts_nonce\" id=\"qts_nonce\" value=\"" . wp_create_nonce( 'qts_nonce' ) . "\" />" . PHP_EOL;
2138
 
2139
- foreach( $q_config['enabled_languages'] as $lang ) {
2140
 
2141
  $slug = (is_object($term)) ? get_term_meta( $term->term_id, $this->get_meta_key($lang), true ) : '';
2142
 
@@ -2144,7 +2145,7 @@ class QtranslateSlug {
2144
 
2145
  echo "<tr class=\"form-field form-required\">" . PHP_EOL;
2146
  echo "<th scope=\"row\" valig=\"top\"><label for=\"qts_{$lang}_slug\">".sprintf( __('Slug (%s)', 'qts'), $q_config['language_name'][$lang] )."</label></th>" . PHP_EOL;
2147
- echo "<td><input type=\"text\" name=\"qts_{$lang}_slug\" value=\"$value\" /></td></tr>" . PHP_EOL;
2148
 
2149
  }
2150
 
@@ -2153,8 +2154,8 @@ class QtranslateSlug {
2153
  // prints the fields in new page
2154
  else:
2155
  echo "<input type=\"hidden\" name=\"qts_nonce\" id=\"qts_nonce\" value=\"" . wp_create_nonce( 'qts_nonce' ) . "\" />" . PHP_EOL;
2156
-
2157
- foreach( $q_config['enabled_languages'] as $lang ) {
2158
 
2159
  echo "<div class=\"form-field\">" . PHP_EOL;
2160
 
@@ -2163,12 +2164,12 @@ class QtranslateSlug {
2163
  $value = ( $slug ) ? htmlspecialchars( $slug , ENT_QUOTES ) : '';
2164
 
2165
  echo "<label for=\"qts_{$lang}_slug\">".sprintf( __('Slug (%s)', 'qts'), $q_config['language_name'][$lang] )."</label>" . PHP_EOL;
2166
- echo "<input type=\"text\" name=\"qts_{$lang}_slug\" value=\"$value\" aria-required=\"true\">" . PHP_EOL;
2167
-
2168
  echo '</div>';
 
2169
 
2170
  }
2171
-
2172
  endif;
2173
  }
2174
 
@@ -2186,26 +2187,26 @@ class QtranslateSlug {
2186
  */
2187
  public function validate_term_slug( $slug, $term, $lang ) {
2188
 
2189
- global $q_config;
 
 
 
2190
 
2191
- $lang_name = $q_config['term_name'][$term->name][$lang];
2192
 
2193
- $ajax_name = 'new' . $term->taxonomy;
2194
 
 
2195
  $post_name = isset($_POST['name']) ? $_POST['name'] : '';
2196
-
2197
  $term_name = isset($_POST[$ajax_name]) ? trim($_POST[$ajax_name]) : $post_name;
2198
 
2199
  if (empty($term_name)) {
2200
  return $slug;
2201
  }
2202
 
2203
- $name = ( $lang_name == '' || strlen($lang_name) == 0 ) ? $term_name : $lang_name;
2204
-
2205
  $slug = trim($slug);
2206
-
2207
  $slug = (empty($slug)) ? sanitize_title($name) : sanitize_title($slug);
2208
-
2209
  return htmlspecialchars( $slug , ENT_QUOTES );
2210
  }
2211
 
@@ -2316,28 +2317,37 @@ class QtranslateSlug {
2316
  * @param object $term the term object
2317
  * @since 1.1.12
2318
  *
2319
- * TODO: merge with our own form.
2320
  * TODO: move code into js file
2321
  *
2322
  */
2323
  public function qts_modify_term_form($term) {
2324
  echo "<script type=\"text/javascript\">\n// <![CDATA[\r\n";
2325
- if(is_object($term)&&isset($term->name)) {
 
2326
  $termname = $term->name;
2327
  } else {
2328
  $termname = "";
2329
  }
2330
  if(isset($_GET['action']) && $_GET['action']=='edit') {
2331
  foreach($this->get_enabled_languages() as $language) {
2332
- echo $this->qts_insert_term_input('name', __('Name','qts'), $termname, $language,"edit");
 
2333
  }
2334
  } else {
2335
  foreach($this->get_enabled_languages() as $language) {
2336
- echo $this->qts_insert_term_input('tag-name', __('Name','qts'), $termname, $language,"new");
2337
  }
2338
  }
 
2339
  // hide real category text
2340
- echo "if (ins != null) ins.style.display='none';\n";
 
 
 
 
 
 
2341
  echo "// ]]>\n</script>\n";
2342
  }
2343
 
@@ -2351,8 +2361,8 @@ class QtranslateSlug {
2351
  * @since 1.1.12
2352
  * TODO: use DocumentFragment
2353
  */
2354
- private function qts_insert_term_input($id,$name, $language,$action){
2355
- global $q_config;
2356
  $html = "";
2357
  if( $action === "new") {
2358
  $html ="
@@ -2451,7 +2461,7 @@ class QtranslateSlug {
2451
  foreach ($taxonomies as $taxonomy ) {
2452
  add_action( $taxonomy->name.'_add_form', array(&$this, 'qts_modify_term_form'));
2453
  add_action( $taxonomy->name.'_edit_form', array(&$this, 'qts_modify_term_form'));
2454
- add_action( $taxonomy->name.'_add_form', array(&$this, 'show_term_fields'));
2455
  add_action( $taxonomy->name.'_edit_form_fields', array(&$this, 'show_term_fields') );
2456
  add_filter('manage_edit-'.$taxonomy->name.'_columns', array(&$this, 'taxonomy_columns'));
2457
  add_filter('manage_'.$taxonomy->name.'_custom_column', array(&$this, 'taxonomy_custom_column'), 0, 3);
@@ -2542,6 +2552,7 @@ class QtranslateSlug {
2542
  * remove some default dashboard Widgets on Desktop
2543
  *
2544
  * @since 1.0
 
2545
  */
2546
  function remove_dashboard_widgets() {
2547
  global $wp_meta_boxes;
10
 
11
  /**
12
  * array with old data system
 
13
  * @var bool
 
14
  * @since 1.0
15
  */
16
  private $old_data = null;
19
 
20
  /**
21
  * stores permalink_structure option, for save queries to db
 
22
  * @var string
 
23
  * @since 1.0
24
  */
25
  private $permalink_structure;
28
 
29
  /**
30
  * Stores options slugs from database
 
31
  * @var array
 
32
  * @since 1.0
33
  */
34
  protected $options;
37
 
38
  /**
39
  * Variable used to override the language
 
40
  * @var string
 
41
  * @since 1.0
42
  */
43
  private $lang = false;
44
 
45
+ /**
46
+ * variable for current language
47
+ */
48
  private $current_lang = false;
49
 
50
  /**
51
+ * variable for default language
52
+ */
53
  private $default_language = false;
54
 
55
+ /**
56
  * Array of enabled languages
 
57
  * @var array
 
58
  * @since 1.0
59
  */
60
  private $enabled_languages = array();
61
+
62
+ /**
63
  * Array of enabled languages
 
64
  * @var array
 
65
  * @since 1.0
66
  */
67
  private $url_path_mode = "";
68
+
 
 
69
  /**
70
  * slug in meta_key name in meta tables
 
71
  * @var string
 
72
  * @since 1.0
73
  */
74
  private $meta_key = "_qts_slug_%s";
75
+
 
 
76
  /**
77
  * Array of translated versions of the current url
 
78
  * @var array
 
79
  * @since 1.0
80
  */
81
  private $current_url = array();
82
+
 
83
  /**
84
  * Variable that contains the prefix for base plugin function names (qtranslate/qtranslate-x)
 
85
  * @var string
 
86
  * @since ?
87
  */
88
  private $plugin_prefix = "";
89
 
 
90
  /**
91
  * return the current / temp language
 
92
  * @since 1.0
93
  */
94
  private function get_lang() {
95
+ return ($this->lang) ? $this->lang : $this->current_lang;
 
 
96
  }
97
+
98
  /**
99
  * return the current / temp language
100
+ * we store and use it all the way!
 
101
  * @since 1.1.9
102
  */
103
  private function get_currentlang() {
104
  return $this->current_lang;
105
  }
106
+
107
  /**
108
  * return the enabled languages
109
+ * we store and use it all the way!
 
110
  * @since 1.1.9
111
  */
112
  private function get_enabled_languages() {
113
  return $this->enabled_languages;
114
  }
115
+
116
  /**
117
  * return the enabled languages
118
+ * we store and use it all the way!
 
119
  * @since 1.1.9
120
  */
121
  private function get_url_path_mode() {
122
  return $this->url_path_mode;
123
  }
124
 
 
125
  /**
126
  * getter: options
 
127
  * @since 1.0
128
  */
129
  public function get_options() {
172
  */
173
  private function set_plugin_prefix(){
174
  if ('' === $this->plugin_prefix){
175
+ if (is_plugin_active('qtranslate-x/qtranslate.php') || defined( 'QTRANSLATE_FILE' ) ){
176
  $this->plugin_prefix = 'qtranxf_';
177
  } else {
178
  $this->plugin_prefix = 'qtrans_';
187
 
188
  private function set_url_path_mode(){
189
  if ('' === $this->url_path_mode){
190
+ if (is_plugin_active('qtranslate-x/qtranslate.php') || defined( 'QTRANSLATE_FILE' ) ){
191
  $this->url_path_mode = QTX_URL_PATH;
192
  } else {
193
  $this->url_path_mode = QT_URL_PATH;
221
  * @since 1.0
222
  */
223
  public function get_meta_key( $force_lang = false ) {
 
224
 
225
  $lang = $this->get_lang();
226
 
240
  */
241
  static function block_activate() {
242
  global $wp_version;
 
243
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
 
244
  return (
245
+ version_compare($wp_version, "4.0", "<" ) ||
246
+ !( defined( 'QTRANSLATE_FILE' ) ||
247
+ ( is_plugin_active('qtranslate/qtranslate.php') ||
248
+ is_plugin_active('qtranslate/qtranslate-x.php') ||
249
+ is_plugin_active('mqtranslate/mqtranslate.php') ||
250
+ is_plugin_active('qtranslate-x/qtranslate.php')) )
251
  );
252
  }
253
 
263
  global $wpdb;
264
 
265
  if ( self::block_activate() ) {
266
+ if (is_admin()) {
267
+ add_action('admin_notices', array(&$this, 'notice_dependences'));
268
+ }
269
  }
270
 
271
  if ( function_exists('is_multisite') && is_multisite() ) {
402
  * @since 1.0
403
  */
404
  function notice_dependences(){
405
+
406
+ $ornewer=__('or newer','qts');
407
  $info_url=admin_url('plugin-install.php?tab=plugin-information');
408
  echo '<div class="error">' . PHP_EOL;
409
  echo '<p><strong>Qtranslate Slug:</strong></p>' . PHP_EOL;
410
  echo '<p>';
411
+ printf(__('This plugin requires at least %s and either %s, or %s, or %s', 'qts'),
412
+ '<strong>WordPress 4.0</strong>',
413
+ '<a href="'.$info_url.'&plugin=qtranslate-x&TB_iframe=true" class="thickbox" aria-label="'.__('More information about', 'qts').' '.'qTranslate-X" data-title="qTranslate-X"><strong>qTranslate-X</strong></a> (2.9 '.$ornewer.')',
414
+ '<a href="'.$info_url.'&plugin=mqtranslate&TB_iframe=true" class="thickbox" aria-label="'.__('More information about', 'qts').' '.'mqTranslate" data-title="mqTranslate"><strong>mqTranslate</strong></a> (2.6.2.4 '.$ornewer.')',
415
+ '<a href="'.$info_url.'&plugin=qtranslate&TB_iframe=true" class="thickbox" aria-label="'.__('More information about', 'qts').' '.'qTranslate" data-title="qTranslate"><strong>qTranslate</strong></a> (2.5.8 '.$ornewer.')');
416
  echo '</p>' . PHP_EOL;
417
  echo '</div>' . PHP_EOL;
418
  }
469
  */
470
  function init() {
471
 
472
+ load_plugin_textdomain( 'qts', false, basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/languages' );
473
 
474
+ // checking plugin activate
475
+ if ( self::block_activate() ) {
476
  if (is_admin()) {
477
  add_action('admin_notices', array(&$this, 'notice_dependences'));
478
  }
479
+ return;
480
+ } else {
481
+ remove_action('admin_notices', array(&$this, 'notice_dependences'));
482
+ }
483
+ if ( is_admin() ) {
484
+ include_once(dirname(__FILE__).'/qtranslate-slug-settings.php');
485
+ }
486
+
487
+ global $q_config;
488
 
489
+ // until we get a proper function, this will make it for it.
490
+ $this->current_lang = $q_config['language'];
491
  $this->enabled_languages = $q_config['enabled_languages'];
492
+ $this->default_language = $q_config['default_language'];
493
+ $this->set_plugin_prefix();
494
+ $this->set_url_path_mode();
495
 
496
+ if ( is_admin() ) {
497
 
498
  $this->check_old_versions();
499
 
508
 
509
  // admin actions
510
  add_action( 'admin_menu', array(&$this, 'add_slug_meta_box') );
511
+ add_action( 'admin_menu', array(&$this, 'remove_defaultslug_meta_box') );
512
  add_action( 'save_post', array(&$this, 'save_postdata'), 605, 2 );
513
  add_action( 'delete_term', array(&$this, 'delete_term'), 0, 3);
514
  add_action( 'created_term', array(&$this, 'save_term'), 605, 3);
517
 
518
  add_action( 'init', array(&$this, 'taxonomies_hooks'), 805 );
519
 
 
520
  add_action( 'admin_head', array(&$this, 'hide_quick_edit'), 600 );
521
  if(!defined('QTRANSLATE_FILE'))
522
  add_action( 'admin_init', array(&$this, 'fix_nav_menu') );
535
  add_action( 'wp_print_styles', array( &$this, 'print_plugin_styles' ), 20 );
536
  }
537
  }
538
+ //FIXME: query vars are broken
539
  add_filter( 'query_vars', array(&$this, 'query_vars'));
540
  add_action( 'generate_rewrite_rules', array(&$this, 'modify_rewrite_rules') );
541
 
544
 
545
  remove_action('wp_head', $this->get_plugin_prefix() . 'header');
546
  if( "qtranxf_" === $this->get_plugin_prefix() ) {
547
+ remove_action('wp_head', $this->get_plugin_prefix() . 'wp_head');
548
  }
549
 
550
  // add proper hreflang links
556
  remove_filter( 'category_link', $this->get_plugin_prefix() . 'convertURL' );
557
  remove_filter( 'tag_link', $this->get_plugin_prefix() . 'convertURL' );
558
 
559
+ //FIXME: query vars are broken
560
  add_filter( 'qts_permastruct' , array(&$this, 'get_extra_permastruct'), 0, 2);
561
  add_filter( 'qts_url_args', array(&$this, 'parse_url_args'), 0, 1);
562
  add_filter( 'home_url', array(&$this, 'home_url'), 10, 4);
596
  * @since 1.1.8
597
  */
598
  public function qtranslate_slug_header_extended(){
599
+ if(is_404()) { return; }
600
 
601
+ //taken from qtx but see our #341 ticket for clarification
602
+ echo '<link hreflang="x-default" href="'.esc_url($this->get_current_url($this->default_language)) .'" rel="alternate" />'.PHP_EOL;
603
  foreach($this->get_enabled_languages() as $language) {
604
 
605
+ echo '<link hreflang="'.$language.'" href="'.esc_url($this->get_current_url($language)).'" rel="alternate" />'."\n";
 
606
  }
607
  }
608
 
612
  * @param array $classes list of classes
613
  */
614
  public function qts_body_class( $classes ) {
 
615
  $classes[] = call_user_func($this->get_plugin_prefix() . 'getLanguage');
 
 
616
  return $classes;
617
  }
618
 
641
  * @return array the text in the required language
642
  */
643
  public function qts_quickuse( $text,$lang='' ){
644
+ $lang = '' == $lang ? $this->current_lang : $lang;
 
645
  $parsed_text = call_user_func($this->get_plugin_prefix() . 'getSortedLanguages',$text);
646
  if( !empty($parsed_text[$lang])){
647
  return $parsed_text[$lang];
658
  * @since 1.0
659
  */
660
  public function modify_rewrite_rules() {
 
 
661
 
662
  // post types rules
663
  $post_types = get_post_types( array('_builtin' => false ), 'objects');
775
  * @since 1.0
776
  */
777
  public function parse_url_args( $url ) {
778
+ global $q_config; //TODO: q_config : url_info, url_mode
779
 
780
  if (is_admin()) {
781
  return $url;
785
 
786
  // if no permalink structure ads ?lang=en
787
  $base_query = parse_url($q_config['url_info']['original_url']);
788
+ // FIXME: why we do this :
789
  $base_args = isset($base_query['query']) ? wp_parse_args($base_query['query']) : array();
790
 
791
  if ( empty($this->permalink_structure) || $q_config['url_mode'] == 1 ) {
958
  */
959
  function filter_request( $query ) {
960
  global $wp_query, $wp;
961
+ // FIXME: why is this here? it breaks custom variables getter
962
+ // https://wordpress.org/support/topic/cant-retrieve-public-query-variables
963
  if ((isset($wp->matched_query) || empty($query)) && ! isset($query['s']) ) {
964
  $query = wp_parse_args($wp->matched_query);
965
  }
976
  if ( isset($query['pagename']) || isset($query['page_id']) ):
977
 
978
  $page = wp_cache_get('qts_page_request');
979
+ if (!$page) {
980
  $page = isset($query['page_id']) ? get_post($query['page_id']) : $this->get_page_by_path($query['pagename']);
981
+ }
982
+
983
+ if (!$page) {
984
+ return $query;
985
+ }
986
 
 
987
  $id = $page->ID;
988
  $cache_array = array($page);
989
  update_post_caches($cache_array, 'page'); // caching query :)
993
 
994
  // -> custom post type
995
  elseif ( isset($query['post_type']) ):
996
+ if (count($query) == 1) {
997
+ $function = 'get_post_type_archive_link';
998
+ $id = $query['post_type'];
999
+ } else {
1000
+ $page_slug = ( isset($query['name']) && !empty($query['name']) ) ? $query['name'] : $query[$query['post_type']];
1001
+ $page = $this->get_page_by_path($page_slug, OBJECT, $query['post_type']);
1002
+ if (!$page) return $query;
1003
+ $id = $page->ID;
1004
+ $cache_array = array($page);
1005
+ update_post_caches($cache_array, $query['post_type']); // caching query :)
1006
+ $query['name'] = $query[$query['post_type']] = get_page_uri($page);
1007
+ $function = 'get_post_permalink';
1008
+ }
1009
  // -> post
1010
  elseif ( isset($query['name']) || isset($query['p']) ):
1011
 
1111
  * @since 1.0
1112
  */
1113
  public function get_current_url( $lang = false ) {
1114
+
1115
  if (!$lang) {
1116
  $lang = $this->get_lang();
1117
  }
1118
+
1119
  if (isset($this->current_url[$lang]) && !empty($this->current_url[$lang])) {
1120
  return $this->current_url[$lang];
1121
  }
 
1122
  return '';
1123
  }
1124
 
1141
 
1142
  return array_pop( $exploded_slug );
1143
  }
1144
+
1145
+
1146
+
1147
  /**
1148
  * Retrieves a page id given its path.
1149
  *
1304
 
1305
 
1306
  /**
1307
+ * Filter that changes the permastruct depending .. on what?
1308
  *
1309
  * @param string $permastruct default permastruct given b wp_rewrite
1310
  * @param string $name the name of the extra permastruct
1390
  * @since 1.0
1391
  */
1392
  public function post_link( $link, $post, $leavename ) {
1393
+ global $q_config; //TODO: q_config : url_mode
1394
+
1395
  $rewritecode = array(
1396
  '%year%',
1397
  '%monthnum%',
1542
  * @since 1.0
1543
  */
1544
  public function _get_page_link( $link, $id ) {
1545
+ global $post, $wp_rewrite, $q_config; //TODO: q_config : url_mode
1546
 
1547
  $current_post = $post;
1548
 
1636
  global $wp_rewrite;
1637
 
1638
  // parse normal term names for ?tag=tagname
1639
+ if (empty($this->permalink_structure)) { return $link; }
1640
 
1641
  if ( !is_object($term) ) {
1642
  if ( is_int($term) ) {
1666
  $t = get_taxonomy($taxonomy);
1667
 
1668
  if ( empty($termlink) ) {
1669
+ if ( 'category' == $taxonomy ) {
1670
  $termlink = '?cat=' . $term->term_id;
1671
+ } elseif ( $t->query_var ) {
1672
  $termlink = "?$t->query_var=$slug";
1673
+ } else {
1674
  $termlink = "?taxonomy=$taxonomy&term=$slug";
1675
+ }
1676
  $termlink = home_url($termlink);
1677
  } else {
1678
  if ( $t->rewrite['hierarchical'] ) {
1682
  $ancestor_term = get_term($ancestor, $taxonomy);
1683
 
1684
  $ancestor_slug = get_term_meta( $ancestor_term->term_id, $this->get_meta_key(), true );
1685
+ if (!$ancestor_slug) {
1686
+ $ancestor_slug = $ancestor_term->slug;
1687
+ }
1688
 
1689
  $hierarchical_slugs[] = $ancestor_slug;
1690
  }
1783
  function get_terms($terms, $taxonomy) {
1784
 
1785
  global $pagenow;
1786
+
 
1787
  if ( $pagenow != 'admin-ajax.php' ) {
1788
 
1789
  $meta = get_option('qtranslate_term_name');
1794
  foreach ($terms as $term_index => $term) {
1795
  // after saving, dont do anything
1796
  if( ( isset($_POST['action'] ) && $_POST['action'] == "editedtag") ||
1797
+ !is_object( $term ) ) {
1798
  return $terms;
1799
  }
1800
+ if( isset( $meta[$term->name][$lang] ) ) {
1801
+ $term->name = $meta[$term->name][$lang];
 
1802
  }
1803
+ }
1804
+ }
1805
  }
1806
  return $terms;
1807
  }
1836
  // make the output valid
1837
  $tax = str_replace("'", "", $taxonomy);
1838
 
1839
+ // get the name from qtx
1840
  $meta = get_option('qtranslate_term_name');
1841
  $lang = call_user_func($this->get_plugin_prefix() . 'getLanguage');
1842
 
1845
  if( isset( $meta[$term->name][$lang] ) ) {
1846
  $term->name = $meta[$term->name][$lang];
1847
  }
1848
+ }
1849
+ }
1850
 
1851
  }
1852
  return $terms;
1869
 
1870
 
1871
  /**
1872
+ * Hide auttomatically the wordpress slug box in edit terms page
1873
  *
1874
  * @since 1.0
1875
  */
1876
  public function hide_slug_box() {
1877
  global $pagenow;
 
1878
  switch ( $pagenow ):
1879
  case 'edit-tags.php':
1880
 
1886
  echo " });" . PHP_EOL;
1887
  echo "</script>" . PHP_EOL;
1888
  break;
1889
+ /*
1890
  case 'post.php':
1891
 
1892
  echo "<!-- QTS remove slug box -->" . PHP_EOL;
1893
  echo "<style type=\"text/css\" media=\"screen\">" . PHP_EOL;
1894
+ echo " #slugdiv2 { display: none !important}" . PHP_EOL;
1895
  echo "</style>" . PHP_EOL;
1896
+ break;*/
1897
  endswitch;
1898
  }
1899
+ /**
1900
+ * Hide auttomatically the wordpress slug box in edit posts page
1901
+ * User should still be able to use it if needed
1902
+ * @since 1.0
1903
+ */
1904
+ public function remove_defaultslug_meta_box() {
1905
+
1906
+ if (is_admin()) {
1907
+ if( !current_user_can('manage_options') ) {
1908
+ remove_meta_box('slugdiv', 'post', 'normal');
1909
+ }
1910
+ }
1911
+ }
1912
+
1913
  /**
1914
  * Creates a metabox for every post, page and post type avaiable
1915
  *
1922
  $context = apply_filters("qts_admin_meta_box_context","side");
1923
  $priority = apply_filters("qts_admin_meta_box_priority","high");
1924
 
1925
+ add_meta_box( 'qts_sectionid', __('Slug QTS', 'qts'), array(&$this, 'draw_meta_box'), 'post', $context, $priority);
1926
+ add_meta_box( 'qts_sectionid', __('Slug QTS', 'qts'), array(&$this, 'draw_meta_box'), 'page', $context, $priority);
1927
 
1928
+ foreach ( get_post_types( array('_builtin' => false ) ) as $ptype ) {
1929
+ add_meta_box( 'qts_sectionid', __('Slug QTS', 'qts'), array(&$this, 'draw_meta_box'), $ptype, $context, $priority );
1930
+ }
1931
  }
1932
  }
1933
 
1941
  * @since 1.0
1942
  */
1943
  public function draw_meta_box( $post ) {
1944
+ global $q_config; // //TODO: q_config : language_name
1945
+
1946
  // Use nonce for verification
1947
  echo "<table style=\"width:100%\">" . PHP_EOL;
1948
  echo "<input type=\"hidden\" name=\"qts_nonce\" id=\"qts_nonce\" value=\"" . wp_create_nonce( 'qts_nonce' ) . "\" />" . PHP_EOL;
1949
 
1950
+ foreach ($this->enabled_languages as $lang):
1951
 
1952
  $slug = get_post_meta( $post->ID, $this->get_meta_key($lang), true);
1953
 
1955
 
1956
  echo "<tr>" . PHP_EOL;
1957
  echo "<th style=\"text-align:left; width:10%; color:#555 \"><label for=\"qts_{$lang}_slug\">".__($q_config['language_name'][$lang], 'qtranslate')."</label></th>" . PHP_EOL;
1958
+ echo "<td><input type=\"text\" id=\"qts_{$lang}_slug\" name=\"qts_{$lang}_slug\" value=\"" . urldecode($value) . "\" style=\"width:90%; margin-left:10%; color:#777\" /></td>" . PHP_EOL;
1959
  echo "</tr>" . PHP_EOL;
1960
 
1961
  endforeach;
1983
  $post_name = $post->post_name;
1984
  }
1985
 
1986
+ //TODO: if has a slug, test and use it
1987
+ //TODO: and then replace the default slug with the dafault language slug
1988
  $name = ( $post_title == '' || strlen($post_title) == 0 ) ? $post_name : $post_title;
1989
 
1990
  $slug = trim($slug);
1991
 
1992
  $slug = (empty($slug)) ? sanitize_title($name) : sanitize_title($slug);
1993
+
 
 
1994
  return htmlspecialchars( $slug , ENT_QUOTES );
1995
  }
1996
 
2056
  if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
2057
  $suffix = 2;
2058
  do {
2059
+ // TODO: update unique_slug :: differs from current wp func ( 4.3.1 )
2060
  $alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
2061
  $post_name_check = $wpdb->get_var( $wpdb->prepare($check_sql, $alt_post_name, $post_ID ) );
2062
  $suffix++;
2064
  $slug = $alt_post_name;
2065
  }
2066
  } else {
2067
+ // TODO: update unique_slug :: missing hieararchical from current wp func ( 4.3.1 )
2068
  // Post slugs must be unique across all posts.
2069
  $check_sql = "SELECT $wpdb->postmeta.meta_value FROM $wpdb->posts,$wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '%s' AND $wpdb->postmeta.meta_value = '%s' AND $wpdb->posts.post_type = %s AND ID != %d LIMIT 1";
2070
  $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $meta_key, $slug, $post_type, $post_ID ) );
2071
 
2072
+ // TODO: update unique_slug :: missing check for conflict with dates archive from current wp func ( 4.3.1 )
2073
  if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) {
2074
  $suffix = 2;
2075
  do {
2076
+ // TODO: update unique_slug :: same as above: differs from current wp func ( 4.3.1 )
2077
  $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
2078
  $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $meta_key, $alt_post_name, $post_type, $post_ID ) );
2079
  $suffix++;
2103
 
2104
  if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) // check autosave
2105
  || (!isset($_POST['post_ID']) || $post_id != $_POST['post_ID']) // check revision
2106
+ || (isset($_POST['qts_nonce']) && !wp_verify_nonce( $_POST['qts_nonce'], 'qts_nonce')) // verify nonce
2107
  || (!current_user_can($post_type_object->cap->edit_post, $post_id))) { // check permission
2108
  return $post_id;
2109
  }
2110
  foreach ($this->get_enabled_languages() as $lang) {
2111
+
2112
+ // check required because it is not available inside quick edit
2113
+ if (isset($_POST["qts_{$lang}_slug"])) {
2114
  $meta_name = $this->get_meta_key($lang);
2115
  $meta_value = apply_filters( 'qts_validate_post_slug', $_POST["qts_{$lang}_slug"], $post, $lang);
2116
  delete_post_meta($post_id, $meta_name);
2117
  update_post_meta($post_id, $meta_name, $meta_value);
2118
+ }
2119
  }
2120
  }
2121
 
2129
  * @since 1.0
2130
  */
2131
  public function show_term_fields( $term ) {
2132
+ global $q_config; //TODO: q_config : language_name
2133
 
2134
  // prints the fields in edit page
2135
  if (isset($_GET['action']) && $_GET['action'] == 'edit' ):
2137
  echo "<table class=\"form-table\">" . PHP_EOL;
2138
  echo "<input type=\"hidden\" name=\"qts_nonce\" id=\"qts_nonce\" value=\"" . wp_create_nonce( 'qts_nonce' ) . "\" />" . PHP_EOL;
2139
 
2140
+ foreach( $this->enabled_languages as $lang ) {
2141
 
2142
  $slug = (is_object($term)) ? get_term_meta( $term->term_id, $this->get_meta_key($lang), true ) : '';
2143
 
2145
 
2146
  echo "<tr class=\"form-field form-required\">" . PHP_EOL;
2147
  echo "<th scope=\"row\" valig=\"top\"><label for=\"qts_{$lang}_slug\">".sprintf( __('Slug (%s)', 'qts'), $q_config['language_name'][$lang] )."</label></th>" . PHP_EOL;
2148
+ echo "<td><input type=\"text\" name=\"qts_{$lang}_slug\" value=\"". urldecode($value) . "\" /></td></tr>" . PHP_EOL;
2149
 
2150
  }
2151
 
2154
  // prints the fields in new page
2155
  else:
2156
  echo "<input type=\"hidden\" name=\"qts_nonce\" id=\"qts_nonce\" value=\"" . wp_create_nonce( 'qts_nonce' ) . "\" />" . PHP_EOL;
2157
+ echo "<div id=\"qts_term_slugs\"><div class=\"qts_term_block\">" . PHP_EOL;
2158
+ foreach( $this->enabled_languages as $lang ) {
2159
 
2160
  echo "<div class=\"form-field\">" . PHP_EOL;
2161
 
2164
  $value = ( $slug ) ? htmlspecialchars( $slug , ENT_QUOTES ) : '';
2165
 
2166
  echo "<label for=\"qts_{$lang}_slug\">".sprintf( __('Slug (%s)', 'qts'), $q_config['language_name'][$lang] )."</label>" . PHP_EOL;
2167
+ echo "<input type=\"text\" name=\"qts_{$lang}_slug\" value=\"". urldecode($value) . "\" aria-required=\"true\">" . PHP_EOL;
 
2168
  echo '</div>';
2169
+
2170
 
2171
  }
2172
+ echo '</div></div>';
2173
  endif;
2174
  }
2175
 
2187
  */
2188
  public function validate_term_slug( $slug, $term, $lang ) {
2189
 
2190
+ global $q_config; //TODO: q_config : term_name
2191
+
2192
+ $term_key = call_user_func($this->get_plugin_prefix() . 'split',$term->name);
2193
+ // after split we will get array (with language code as a key )
2194
 
2195
+ $term_key = $term_key[$this->default_language];
2196
 
2197
+ $name_in_lang = $q_config['term_name'][$term_key][$lang];
2198
 
2199
+ $ajax_name = 'new' . $term->taxonomy;
2200
  $post_name = isset($_POST['name']) ? $_POST['name'] : '';
 
2201
  $term_name = isset($_POST[$ajax_name]) ? trim($_POST[$ajax_name]) : $post_name;
2202
 
2203
  if (empty($term_name)) {
2204
  return $slug;
2205
  }
2206
 
2207
+ $name = ( $name_in_lang == '' || strlen($name_in_lang) == 0 ) ? $term_name : $name_in_lang;
 
2208
  $slug = trim($slug);
 
2209
  $slug = (empty($slug)) ? sanitize_title($name) : sanitize_title($slug);
 
2210
  return htmlspecialchars( $slug , ENT_QUOTES );
2211
  }
2212
 
2317
  * @param object $term the term object
2318
  * @since 1.1.12
2319
  *
2320
+ * TODO: change Slug column and View link
2321
  * TODO: move code into js file
2322
  *
2323
  */
2324
  public function qts_modify_term_form($term) {
2325
  echo "<script type=\"text/javascript\">\n// <![CDATA[\r\n";
2326
+ /*
2327
+ if( is_object($term) && isset($term->name) ) {
2328
  $termname = $term->name;
2329
  } else {
2330
  $termname = "";
2331
  }
2332
  if(isset($_GET['action']) && $_GET['action']=='edit') {
2333
  foreach($this->get_enabled_languages() as $language) {
2334
+
2335
+ //echo $this->qts_insert_term_input('name', __('Name','qts'), $termname, $language,"edit");
2336
  }
2337
  } else {
2338
  foreach($this->get_enabled_languages() as $language) {
2339
+ //echo $this->qts_insert_term_input('tag-name', __('Name','qts'), $termname, $language,"edit");
2340
  }
2341
  }
2342
+ */
2343
  // hide real category text
2344
+ //echo "if (ins != null) ins.style.display='none';\n";
2345
+ echo "
2346
+ var slugforms = jQuery('#qts_term_slugs').html();
2347
+ jQuery('#slug').parent().html(slugforms)\n;
2348
+ console.log(slugforms);
2349
+
2350
+ ";
2351
  echo "// ]]>\n</script>\n";
2352
  }
2353
 
2361
  * @since 1.1.12
2362
  * TODO: use DocumentFragment
2363
  */
2364
+ private function qts_insert_term_input($id,$name, $termname, $language,$action){
2365
+ global $q_config; //TODO: q_config : language_name, term_name
2366
  $html = "";
2367
  if( $action === "new") {
2368
  $html ="
2461
  foreach ($taxonomies as $taxonomy ) {
2462
  add_action( $taxonomy->name.'_add_form', array(&$this, 'qts_modify_term_form'));
2463
  add_action( $taxonomy->name.'_edit_form', array(&$this, 'qts_modify_term_form'));
2464
+ add_action( $taxonomy->name.'_add_form_fields', array(&$this, 'show_term_fields'));
2465
  add_action( $taxonomy->name.'_edit_form_fields', array(&$this, 'show_term_fields') );
2466
  add_filter('manage_edit-'.$taxonomy->name.'_columns', array(&$this, 'taxonomy_columns'));
2467
  add_filter('manage_'.$taxonomy->name.'_custom_column', array(&$this, 'taxonomy_custom_column'), 0, 3);
2552
  * remove some default dashboard Widgets on Desktop
2553
  *
2554
  * @since 1.0
2555
+ * @deprecated
2556
  */
2557
  function remove_dashboard_widgets() {
2558
  global $wp_meta_boxes;
includes/qtranslate-slug-settings.php CHANGED
@@ -296,12 +296,15 @@ function qts_settings_scripts() {
296
  wp_enqueue_style('qts_theme_settings_css', plugins_url( 'assets/css/qts-settings.css' , dirname(__FILE__) ) );
297
  wp_enqueue_script( 'qts_theme_settings_js', plugins_url( 'assets/js/qts-settings.js' , dirname(__FILE__) ), array('jquery'));
298
 
 
 
 
299
  if ($qtranslate_slug->check_old_data()) {
300
  wp_enqueue_script('qts_theme_settings_upgrade_js', plugins_url( 'assets/js/qts-settings-upgrade.js' , dirname(__FILE__) ), array('jquery') );
301
  }
302
  }
303
 
304
-
305
 
306
  /**
307
  * The Admin menu page
@@ -320,15 +323,6 @@ function qts_add_menu() {
320
 
321
  // Display Settings Page link under the "Appearance" Admin Menu
322
  $qts_settings_page = add_options_page(__('Qtranslate Slug options', 'qts'), __('Slug options', 'qts'), 'manage_options', QTS_PAGE_BASENAME, 'qts_show_settings_page');
323
- // contextual help
324
- /*
325
- if ($qts_settings_page) {
326
- $current_screen = get_current_screen();
327
- //$current_screen->add_help_tab( array( $qts_settings_page, $qts_contextual_help ));
328
- }
329
- */
330
- // css & js
331
- add_action( 'load-'. $qts_settings_page, 'qts_settings_scripts' );
332
  }
333
  add_action( 'admin_menu', 'qts_add_menu' );
334
 
@@ -422,8 +416,9 @@ function qts_show_form_field($args = array()) {
422
  } else {
423
  $value = '';
424
  }
425
-
426
- echo "<span>$item[0]:</span> <input class='$field_class' type='text' id='$id|$item[1]' name='" . QTS_OPTIONS_NAME . "[$id|$item[1]]' value='$value' /><br/>";
 
427
  }
428
  echo ($desc != '') ? "<span class='description'>$desc</span>" : "";
429
  break;
@@ -578,7 +573,7 @@ function qts_show_settings_page() {
578
  // rewrite rules
579
  flush_rewrite_rules();
580
  ?>
581
- <?php $css_path = plugin_dir_url(dirname(__FILE__)).'/assets/css/qts-default.css';
582
  $file_styles = file_get_contents($css_path);
583
 
584
 
296
  wp_enqueue_style('qts_theme_settings_css', plugins_url( 'assets/css/qts-settings.css' , dirname(__FILE__) ) );
297
  wp_enqueue_script( 'qts_theme_settings_js', plugins_url( 'assets/js/qts-settings.js' , dirname(__FILE__) ), array('jquery'));
298
 
299
+ /**
300
+ * @deprecated
301
+ */
302
  if ($qtranslate_slug->check_old_data()) {
303
  wp_enqueue_script('qts_theme_settings_upgrade_js', plugins_url( 'assets/js/qts-settings-upgrade.js' , dirname(__FILE__) ), array('jquery') );
304
  }
305
  }
306
 
307
+ add_action( 'admin_head', 'qts_settings_scripts' );
308
 
309
  /**
310
  * The Admin menu page
323
 
324
  // Display Settings Page link under the "Appearance" Admin Menu
325
  $qts_settings_page = add_options_page(__('Qtranslate Slug options', 'qts'), __('Slug options', 'qts'), 'manage_options', QTS_PAGE_BASENAME, 'qts_show_settings_page');
 
 
 
 
 
 
 
 
 
326
  }
327
  add_action( 'admin_menu', 'qts_add_menu' );
328
 
416
  } else {
417
  $value = '';
418
  }
419
+ echo "<span>" . $item[0] . ":</span> " .
420
+ "<input class='$field_class' type='text' id='$id|${item[1]}' name='" . QTS_OPTIONS_NAME . "[$id|${item[1]}]' value='". urldecode($value) ."' /><br/>";
421
+ //echo "<span>$item[0]:</span> <input class='$field_class' type='text' id='$id|$item[1]' name='" . QTS_OPTIONS_NAME . "[$id|$item[1]]' value='$value' /><br/>";
422
  }
423
  echo ($desc != '') ? "<span class='description'>$desc</span>" : "";
424
  break;
573
  // rewrite rules
574
  flush_rewrite_rules();
575
  ?>
576
+ <?php $css_path = plugin_dir_url(dirname(__FILE__)).'assets/css/qts-default.css';
577
  $file_styles = file_get_contents($css_path);
578
 
579
 
includes/termmeta-core.php CHANGED
@@ -18,7 +18,10 @@ function install_term_meta_table() {
18
  `term_id` bigint(20) NOT NULL DEFAULT '0',
19
  `meta_key` varchar(255) NULL,
20
  `meta_value` longtext NULL,
21
- PRIMARY KEY id (`meta_id`)) $collate;";
 
 
 
22
  $wpdb->query($sql);
23
  }
24
  endif;
18
  `term_id` bigint(20) NOT NULL DEFAULT '0',
19
  `meta_key` varchar(255) NULL,
20
  `meta_value` longtext NULL,
21
+ PRIMARY KEY id (`meta_id`),
22
+ KEY term_id (term_id),
23
+ KEY meta_key (meta_key($max_index_length))
24
+ ) $collate;";
25
  $wpdb->query($sql);
26
  }
27
  endif;
qtranslate-slug.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: qTranslate slug
4
  Plugin URI: http://not-only-code.github.com/qtranslate-slug/
5
  Description: Allows to define a slug for each language and some qTranslate bug fixes
6
- Version: 1.1.17
7
  Author: Carlos Sanz Garcia, Pedro Carvalho
8
  Author URI: http://github.com/not-only-code
9
  */
@@ -40,6 +40,7 @@ endif;
40
  */
41
  include_once(dirname(__FILE__).'/includes/class-qtranslate-slug-widget.php');
42
  include_once(dirname(__FILE__).'/includes/class-qtranslate-slug.php');
 
43
 
44
  ////////////////////////////////////////////////////////////////////////////////////////
45
 
@@ -50,29 +51,16 @@ include_once(dirname(__FILE__).'/includes/class-qtranslate-slug.php');
50
  *
51
  * @since 1.0
52
  */
53
- if (!defined("QTS_VERSION")) define("QTS_VERSION", '1.1.12');
54
  if (!defined("QTS_PREFIX")) define("QTS_PREFIX", '_qts_');
55
- if (!defined("QTS_PAGE_BASENAME")) define('QTS_PAGE_BASENAME', 'qtranslate-slug-settings');
56
- if (!defined("QTS_OPTIONS_NAME")) define("QTS_OPTIONS_NAME", 'qts_options');
57
- if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");
58
 
59
  ////////////////////////////////////////////////////////////////////////////////////////
60
 
61
 
62
 
63
- /**
64
- * Includes
65
- *
66
- * @since 1.0
67
- */
68
- if ( is_admin() && !QtranslateSlug::block_activate() ) { // setting options page
69
- include_once(dirname(__FILE__).'/includes/qtranslate-slug-settings.php');
70
- }
71
-
72
- include_once(dirname(__FILE__).'/includes/termmeta-core.php'); // termmeta install and core functions
73
-
74
- ////////////////////////////////////////////////////////////////////////////////////////
75
-
76
 
77
 
78
  /**
@@ -176,14 +164,16 @@ add_filter( 'plugin_action_links', 'qts_add_settings_link', 10, 2 );
176
  *
177
  */
178
  function qts_uninstall() {
179
- global $q_config, $wpdb;
180
-
181
  // options
182
  delete_option(QTS_OPTIONS_NAME);
183
  delete_option('qts_version');
184
-
185
- // delete termmeta table
186
- $wpdb->query("DROP TABLE IF EXISTS $wpdb->termmeta");
 
 
187
 
188
  // delete postmeta data
189
  $meta_keys = array();
3
  Plugin Name: qTranslate slug
4
  Plugin URI: http://not-only-code.github.com/qtranslate-slug/
5
  Description: Allows to define a slug for each language and some qTranslate bug fixes
6
+ Version: 1.1.18
7
  Author: Carlos Sanz Garcia, Pedro Carvalho
8
  Author URI: http://github.com/not-only-code
9
  */
40
  */
41
  include_once(dirname(__FILE__).'/includes/class-qtranslate-slug-widget.php');
42
  include_once(dirname(__FILE__).'/includes/class-qtranslate-slug.php');
43
+ include_once(dirname(__FILE__).'/includes/termmeta-core.php');
44
 
45
  ////////////////////////////////////////////////////////////////////////////////////////
46
 
51
  *
52
  * @since 1.0
53
  */
54
+ if (!defined("QTS_VERSION")) define("QTS_VERSION", '1.1.18');
55
  if (!defined("QTS_PREFIX")) define("QTS_PREFIX", '_qts_');
56
+ if (!defined("QTS_PAGE_BASENAME")) define('QTS_PAGE_BASENAME', 'qtranslate-slug-settings');
57
+ if (!defined("QTS_OPTIONS_NAME")) define("QTS_OPTIONS_NAME", 'qts_options');
58
+ if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");
59
 
60
  ////////////////////////////////////////////////////////////////////////////////////////
61
 
62
 
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
 
66
  /**
164
  *
165
  */
166
  function qts_uninstall() {
167
+ global $q_config, $wpdb, $wp_version;
168
+
169
  // options
170
  delete_option(QTS_OPTIONS_NAME);
171
  delete_option('qts_version');
172
+
173
+ // don't delete termmeta table as it will be used by wp beginning 4.4
174
+ if( version_compare($wp_version, "4.4", "<" ) ) {
175
+ $wpdb->query("DROP TABLE IF EXISTS $wpdb->termmeta");
176
+ }
177
 
178
  // delete postmeta data
179
  $meta_keys = array();
readme.txt CHANGED
@@ -1,26 +1,44 @@
1
  === Qtranslate Slug ===
2
  Contributors: carlos_a_sanz, pedroghandi
3
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SYC46KSLRC4Q8
4
  Tags: qtranslate, slug, multilanguage, widget
5
- Requires at least: 3.3
6
- Tested up to: 4.2.4
7
- Stable tag: 1.1.17
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Adds support for permalink translations to QTranslate-X since wordpress 3.0
12
 
13
  == Description ==
14
 
15
  [Qtranslate-X](http://wordpress.org/plugins/qtranslate-x/) is a nice plugin for Multilingual Websites. **Qtranslate Slug** is an addon to QTranslate, which adds support for permalinks translations.
16
 
 
 
 
 
17
  1.1.17 fixes a dangerous Security Exploit. Please update right now!
18
 
19
  = Requirements: =
20
 
21
- * Wordpress 3.3 (PHP 5.4 and MySQL 5)
22
  * mQtranslate 2.6.2.4 or Qtranslate 2.5.8 or qtranslate-x ( 2.9.1 )
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  = New in 1.1.17 =
25
  * Hability to filter the position of the Metabox
26
  * Fixed dangerous security exploit!
1
  === Qtranslate Slug ===
2
  Contributors: carlos_a_sanz, pedroghandi
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=GYS2L7627B4F8&lc=GB&item_name=Qtranslate%2dSlug%20Improvement%20Fund&item_number=qts%2dpaypal&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted
4
  Tags: qtranslate, slug, multilanguage, widget
5
+ Requires at least: 4.0
6
+ Tested up to: 4.5
7
+ Stable tag: 1.1.18
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Adds support for permalink translations to QTranslate-X
12
 
13
  == Description ==
14
 
15
  [Qtranslate-X](http://wordpress.org/plugins/qtranslate-x/) is a nice plugin for Multilingual Websites. **Qtranslate Slug** is an addon to QTranslate, which adds support for permalinks translations.
16
 
17
+
18
+
19
+
20
+
21
  1.1.17 fixes a dangerous Security Exploit. Please update right now!
22
 
23
  = Requirements: =
24
 
25
+ * Wordpress 4.0 (PHP 5.4 and MySQL 5)
26
  * mQtranslate 2.6.2.4 or Qtranslate 2.5.8 or qtranslate-x ( 2.9.1 )
27
 
28
+ = New in 1.1.18 =
29
+
30
+ * works with upcomming wp 4.5! thats new for a change!
31
+ * widget is now compatible with wp 4.3. thanks to @adnanoner ( #111) and @gitmad (#112)
32
+ * saving taxonomies wont print warning. thanks to @jmarceli ( #113)
33
+ * saving post quick edit wont print warnings. thanks again to jmarceli ( #114 )
34
+ * Code from wp.org is now been merged with the github account
35
+ * Some notices are fixed. Thanks to @rafa-aguilar ( #89 )
36
+ * custom post types are fixed! thanks to @MicheleBertoli ( #102 )
37
+ * slug box now shows the utf8 chars instead of the enconded ones.
38
+ * you can now toggle the default slug box, in case you want to edit it.
39
+ * edit term has been re-worked, so no more errors and notices! ( hopefully!)
40
+ * couple of other stuff has been fixed by me thanks to your awesome bug reports!
41
+
42
  = New in 1.1.17 =
43
  * Hability to filter the position of the Metabox
44
  * Fixed dangerous security exploit!
version.txt CHANGED
@@ -1,3 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  = New in 1.1.17 =
2
  * Fixed dangerous security exploit!
3
  * Hability to filter the position of the Metabox
1
+ = New in 1.1.18 =
2
+
3
+ Let's start with what has been fixed:
4
+
5
+
6
+ * widget is now compatible with wp 4.3. thanks to @adnanoner ( #111) and @gitmad (#112)
7
+ * saving taxonomies wont print warning. thanks to @jmarceli ( #113)
8
+ * saving post quick edit wont print warnings. thanks again to jmarceli ( #114 )
9
+ * Code from wp.org is now been merged with the github account
10
+ * Some notices are fixed. Thanks to @rafa-aguilar ( #89 )
11
+ * custom post types are fixed! thanks to @MicheleBertoli ( #102 )
12
+ * lots of other stuff has been fixed by me thanks to your awesome bug reports!
13
+
14
+
15
+
16
+ and now, what isn't working:
17
+ In QTS slug options you can change the bases for taxonomies and custom post types.
18
+
19
+ So, for example, you can change /category/ for /category/ for english and /categoria/ for spanish version.
20
+ But these won't work:
21
+ * slug with UTF8 charactes in taxonomies bases: example: /類別/.. instead of /category/..
22
+ utf8 in taxonomies works just fine: /category_zh/魚/
23
+ * slug with UTF8 charactes in custom post type bases : example: /圖書/.. instead of /books/..
24
+ utf8 in custom post slugs works just fine: /tushu/彩繪中國經典名著/
25
+ * translating custom post types archives with custom base name /tushu/ isnt working. but using utf8 in the the default slug, as expected : /中國/
26
+
27
+
28
+
29
+
30
+
31
+
32
+ Thanks for using, enjoy 1.1.18.
33
+
34
+ If anything breaks, let me know!
35
+
36
  = New in 1.1.17 =
37
  * Fixed dangerous security exploit!
38
  * Hability to filter the position of the Metabox