Version Description
- added multisite support
- fixed some parse url bugs
- fixed slug bases validation
Download this release
Release Info
Developer | carlos_a_sanz |
Plugin | Qtranslate Slug |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.1
- README.md +0 -160
- README.txt +21 -24
- qtranslate-slug-settings.php +13 -66
- qtranslate-slug.php +32 -125
README.md
DELETED
@@ -1,160 +0,0 @@
|
|
1 |
-
=== Qtranslate Slug ===
|
2 |
-
Contributors: Carlos Sanz García
|
3 |
-
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SYC46KSLRC4Q8
|
4 |
-
Tags: qtranslate, slug, multilanguage
|
5 |
-
Requires at least: 3.3
|
6 |
-
Tested up to: 3.4
|
7 |
-
Version: 1.0
|
8 |
-
License: GPLv2 or later
|
9 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
|
11 |
-
Adds support for permalink translations and fix some QTranslate deficiencies since wordpress 3.0
|
12 |
-
|
13 |
-
== Description ==
|
14 |
-
|
15 |
-
[Qtranslate](http://wordpress.org/extend/plugins/qtranslate/) is a nice plugin but unfortunately today is **outdated**. **Qtranslate Slug** is an addon to QTranslate, which adds support for permalinks translations and fix some QTranslate deficiencies since wordpress 3.0.
|
16 |
-
|
17 |
-
**Version 1.0** has been written from scratch using OOP. The code has been structured better, the functions have been marked and commented and everything is better integrated with Wordpress API.
|
18 |
-
|
19 |
-
This plugin works with **Qtranslate** since **2.5.8**.
|
20 |
-
|
21 |
-
= What is new? =
|
22 |
-
|
23 |
-
* **works** with any permalink combination and qtranslate mode.
|
24 |
-
* new branch, the plugin has been rewritten: now the code is commented and wrapped inside a class, much code has change and the performance has been increased (use caches).
|
25 |
-
* data system changed, no ID for slug type, then it don't needs install `qtrasnlate_slug` table. That means slugs now are stored on meta tables and installation creates a termmeta table with some new *core functions* to access/save data, based on [simple term meta](http://wordpress.org/extend/plugins/simple-term-meta/). Upgrade process when the plugin updates from older versions.
|
26 |
-
* the plugin generates translated slug automatically from title in empty cases.
|
27 |
-
* the plugin checks if the slug already exists (per each language and `post_type`/`taxonomy`), and adds a progressive number in this case. Works on ajax requests for example when new taxonomies are created in edit post page.
|
28 |
-
* possibility to translate the base of permastructs for *post_types* and *taxonomies*, uses [$wp_rewrite](http://codex.wordpress.org/Class_Reference/WP_Rewrite). New admin options page for save the base permastructs.
|
29 |
-
* added some filters, see in [other notes](http://wordpress.org/extend/plugins/qtranslate-slug/other_notes/).
|
30 |
-
* added plugin language textdomain (.pot file).
|
31 |
-
* updated **Language selector Widget**, and some new conventions like accessible functions for templating.
|
32 |
-
* some bug fixes.
|
33 |
-
* some Qtranslate patches.
|
34 |
-
|
35 |
-
|
36 |
-
You can also check the [project website](http://not-only-code.github.com/qtranslate-slug/) hosted on [GitHub](http://not-only-code.github.com).
|
37 |
-
Thanks for use this plugin!
|
38 |
-
|
39 |
-
== Installation ==
|
40 |
-
|
41 |
-
**This plugins requires [Qtranslate](http://wordpress.org/extend/plugins/qtranslate/) installed previously, if not, it will not activate.**
|
42 |
-
|
43 |
-
1. Upload `qtranslate-slug` to the `/wp-content/plugins/` directory.
|
44 |
-
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
45 |
-
1. That's all!
|
46 |
-
|
47 |
-
= Changing base permastructs =
|
48 |
-
|
49 |
-
1. In admin: navigate to *Settings/Slug options*.
|
50 |
-
1. Set the base permastructs for **post types** and **taxonomies** (If you setup a base permastruct for *categories* or *tags* in *Settings/Permalinks*, these will be overwritten by the translated ones).
|
51 |
-
1. Save settings and that's all!
|
52 |
-
|
53 |
-
== Frequently Asked Questions ==
|
54 |
-
|
55 |
-
= It works with posts and pages, but with other content type? =
|
56 |
-
|
57 |
-
This plugin allows to translate slugs of: posts, pages, custom post types, categories, tags and custom taxonomies.
|
58 |
-
|
59 |
-
= Do I have to configure anything? =
|
60 |
-
|
61 |
-
If you want to translate also the base permastructs (ex. *category*, *tag*, etc). Visit the plugin settings page in the admin *Settings/Slug options*
|
62 |
-
|
63 |
-
= How can i insert a language selector in my theme ? =
|
64 |
-
|
65 |
-
You can choose to:
|
66 |
-
* use **Qtranslate Slug Widget** in your sidebar.
|
67 |
-
* place in your template `<?php if (function_exists('qts_language_menu') ) qts_language_menu('text'); ?>`. Options are: `dropdown`, `text`, `image`, and `both`.
|
68 |
-
|
69 |
-
= Appears an error 404, what can i do? =
|
70 |
-
|
71 |
-
In the admin go to *Settings/Permalinks* or *Settings/Slug options* and save.
|
72 |
-
|
73 |
-
= I can't manage translations in Nav Menus. =
|
74 |
-
|
75 |
-
That's because language selector metabox is hidden, if you are in admin *nav menus* screen, press the button **Screen options** (on top and right) and after, check the option *Languages*. It will appear a **Language** meta box on top of the left sidebar.
|
76 |
-
|
77 |
-
== Screenshots ==
|
78 |
-
|
79 |
-
1. Edit page for: post / page / post_type, you can see the meta box for translated slugs on top and right.
|
80 |
-
2. Add new taxonomy page
|
81 |
-
3. Edit taxonomy page
|
82 |
-
4. Qtranslate Slug options page for translate base permastructs of post_types and taxonomies.
|
83 |
-
|
84 |
-
== Changelog ==
|
85 |
-
|
86 |
-
= 1.0 =
|
87 |
-
* **works** with any permalink combination and qtranslate mode.
|
88 |
-
* new branch, the plugin has been rewritten: now the code is commented and wrapped inside a class, much code has change and the performance has been increased (use caches).
|
89 |
-
* data system changed, no ID for slug type, then it don't needs install `qtrasnlate_slug` table. That means slugs now are stored on meta tables and installation creates a termmeta table with some new *core functions* to access/save data, based on [simple term meta](http://wordpress.org/extend/plugins/simple-term-meta/). Upgrade process when the plugin updates from older versions.
|
90 |
-
* the plugin generates translated slug automatically from title in empty cases.
|
91 |
-
* the plugin checks if the slug already exists (per each language and `post_type`/`taxonomy`), and adds a progressive number in this case. Works on ajax requests for example when new taxonomies are created in edit post page.
|
92 |
-
* possibility to translate the base of permastructs for *post_types* and *taxonomies*, uses [$wp_rewrite](http://codex.wordpress.org/Class_Reference/WP_Rewrite). New admin options page for save the base permastructs.
|
93 |
-
* added some filters, see in [other notes](http://wordpress.org/extend/plugins/qtranslate-slug/other_notes/).
|
94 |
-
* added plugin language textdomain (.pot file).
|
95 |
-
* updated **Language selector Widget**, and some new conventions like accessible functions for templating.
|
96 |
-
* some bug fixes.
|
97 |
-
* some Qtranslate patches.
|
98 |
-
|
99 |
-
= 0.9 =
|
100 |
-
* some wordpress qTranslate bug fixes
|
101 |
-
* adds a javascript solution for qTranslate Nav Menus
|
102 |
-
|
103 |
-
= 0.8 =
|
104 |
-
* added support por Categories
|
105 |
-
* added support por Tags
|
106 |
-
* added support por Taxonomies
|
107 |
-
* added support por Custom Post Types
|
108 |
-
|
109 |
-
= 0.7 = [Zapo](http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=4&t=1049&start=50#p7499)
|
110 |
-
* added suport for qTranslate TLD domain mode (en: domain.com | fr: domain.fr) visit
|
111 |
-
|
112 |
-
= 0.5 and 0.6 enhanched by Marco Del Percio =
|
113 |
-
|
114 |
-
== Upgrade Notice ==
|
115 |
-
|
116 |
-
= 1.0 =
|
117 |
-
Major version, the plugin has been rewritten. Better performance, and some enhancements.
|
118 |
-
|
119 |
-
= 0.9 =
|
120 |
-
This version fix some bugs and allow multilanguage in nav-menus.
|
121 |
-
|
122 |
-
= 0.8 =
|
123 |
-
A lot of slugs content allowed
|
124 |
-
|
125 |
-
= 0.7 =
|
126 |
-
This version allows TLD domain option for a different Qtranslate fork maded by Zappo
|
127 |
-
|
128 |
-
|
129 |
-
== Other notes ==
|
130 |
-
|
131 |
-
Plugin filters reference:
|
132 |
-
|
133 |
-
= qts_validate_post_slug =
|
134 |
-
|
135 |
-
filter to process the post slug before is saved on the database.
|
136 |
-
`args: $post (object), $slug (string), $lang (string)`
|
137 |
-
|
138 |
-
= qts_validate_term_slug =
|
139 |
-
|
140 |
-
filter to process the term slug before is saved on the database.
|
141 |
-
`args: $term (object), $slug (string), $lang (string)`
|
142 |
-
|
143 |
-
= qts_url_args =
|
144 |
-
|
145 |
-
filter to process the entire url after it has been generated.
|
146 |
-
`args: $url (string), $lang (string)`
|
147 |
-
|
148 |
-
= qts_permastruct =
|
149 |
-
|
150 |
-
filter to process the permastruct, used for change the base.
|
151 |
-
`args: $permastruct (string), $name (string)`
|
152 |
-
|
153 |
-
|
154 |
-
= Todo =
|
155 |
-
|
156 |
-
* detect Slug for each language and redirect accordingly in parse_query.
|
157 |
-
* expand qtranslate for translate attachment names and descriptions ( useful for galleries )
|
158 |
-
* translate other slugs like attachments.
|
159 |
-
* multisite: add suport as network plugin enhancing the request, some qtranslate patches.
|
160 |
-
* qtranslate integration with other plugins like Jigoshop, e-commerce, etc. Addapt **$wp_rewrite**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: qtranslate, slug, multilanguage
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 3.4
|
7 |
-
Version: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -16,21 +16,18 @@ Adds support for permalink translations and fix some QTranslate deficiencies sin
|
|
16 |
|
17 |
**Version 1.0** has been written from scratch using OOP. The code has been structured better, the functions have been marked and commented and everything is better integrated with Wordpress API.
|
18 |
|
19 |
-
|
20 |
|
21 |
-
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
|
29 |
-
|
30 |
-
* added plugin language textdomain (.pot file).
|
31 |
-
* updated **Language selector Widget**, and some new conventions like accessible functions for templating.
|
32 |
-
* some bug fixes.
|
33 |
-
* some Qtranslate patches.
|
34 |
|
35 |
|
36 |
You can also check the [project website](http://not-only-code.github.com/qtranslate-slug/) hosted on [GitHub](http://not-only-code.github.com).
|
@@ -83,6 +80,11 @@ That's because language selector metabox is hidden, if you are in admin *nav men
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
|
|
|
|
|
|
|
|
|
|
86 |
= 1.0 =
|
87 |
* **works** with any permalink combination and qtranslate mode.
|
88 |
* new branch, the plugin has been rewritten: now the code is commented and wrapped inside a class, much code has change and the performance has been increased (use caches).
|
@@ -128,25 +130,21 @@ This version allows TLD domain option for a different Qtranslate fork maded by Z
|
|
128 |
|
129 |
== Other notes ==
|
130 |
|
131 |
-
Plugin filters reference:
|
132 |
-
|
133 |
-
= qts_validate_post_slug =
|
134 |
|
|
|
135 |
filter to process the post slug before is saved on the database.
|
136 |
`args: $post (object), $slug (string), $lang (string)`
|
137 |
|
138 |
-
= qts_validate_term_slug =
|
139 |
-
|
140 |
filter to process the term slug before is saved on the database.
|
141 |
`args: $term (object), $slug (string), $lang (string)`
|
142 |
|
143 |
-
= qts_url_args =
|
144 |
-
|
145 |
filter to process the entire url after it has been generated.
|
146 |
`args: $url (string), $lang (string)`
|
147 |
|
148 |
-
= qts_permastruct =
|
149 |
-
|
150 |
filter to process the permastruct, used for change the base.
|
151 |
`args: $permastruct (string), $name (string)`
|
152 |
|
@@ -156,5 +154,4 @@ filter to process the permastruct, used for change the base.
|
|
156 |
* detect Slug for each language and redirect accordingly in parse_query.
|
157 |
* expand qtranslate for translate attachment names and descriptions ( useful for galleries )
|
158 |
* translate other slugs like attachments.
|
159 |
-
* multisite: add suport as network plugin enhancing the request, some qtranslate patches.
|
160 |
* qtranslate integration with other plugins like Jigoshop, e-commerce, etc. Addapt **$wp_rewrite**.
|
4 |
Tags: qtranslate, slug, multilanguage
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 3.4
|
7 |
+
Version: 1.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
16 |
|
17 |
**Version 1.0** has been written from scratch using OOP. The code has been structured better, the functions have been marked and commented and everything is better integrated with Wordpress API.
|
18 |
|
19 |
+
= Requirements: =
|
20 |
|
21 |
+
* Wordpress 3.3 (PHP 5.2 and MySQL 5)
|
22 |
+
* Qtranslate 2.5.8
|
23 |
|
24 |
+
= New in version 1.1 =
|
25 |
+
|
26 |
+
* added multisite support
|
27 |
+
* fixed some parse url bugs
|
28 |
+
* fixed slug bases validation
|
29 |
+
|
30 |
+
**Advice: If you're using a multisite installation, you will must activate qtranslate plugins by sepparetly on each site.**
|
|
|
|
|
|
|
|
|
31 |
|
32 |
|
33 |
You can also check the [project website](http://not-only-code.github.com/qtranslate-slug/) hosted on [GitHub](http://not-only-code.github.com).
|
80 |
|
81 |
== Changelog ==
|
82 |
|
83 |
+
= 1.1 =
|
84 |
+
* added multisite support
|
85 |
+
* fixed some parse url bugs
|
86 |
+
* fixed slug bases validation
|
87 |
+
|
88 |
= 1.0 =
|
89 |
* **works** with any permalink combination and qtranslate mode.
|
90 |
* new branch, the plugin has been rewritten: now the code is commented and wrapped inside a class, much code has change and the performance has been increased (use caches).
|
130 |
|
131 |
== Other notes ==
|
132 |
|
133 |
+
Plugin filters reference:
|
|
|
|
|
134 |
|
135 |
+
= qts_validate_post_slug =
|
136 |
filter to process the post slug before is saved on the database.
|
137 |
`args: $post (object), $slug (string), $lang (string)`
|
138 |
|
139 |
+
= qts_validate_term_slug =
|
|
|
140 |
filter to process the term slug before is saved on the database.
|
141 |
`args: $term (object), $slug (string), $lang (string)`
|
142 |
|
143 |
+
= qts_url_args =
|
|
|
144 |
filter to process the entire url after it has been generated.
|
145 |
`args: $url (string), $lang (string)`
|
146 |
|
147 |
+
= qts_permastruct =
|
|
|
148 |
filter to process the permastruct, used for change the base.
|
149 |
`args: $permastruct (string), $name (string)`
|
150 |
|
154 |
* detect Slug for each language and redirect accordingly in parse_query.
|
155 |
* expand qtranslate for translate attachment names and descriptions ( useful for galleries )
|
156 |
* translate other slugs like attachments.
|
|
|
157 |
* qtranslate integration with other plugins like Jigoshop, e-commerce, etc. Addapt **$wp_rewrite**.
|
qtranslate-slug-settings.php
CHANGED
@@ -486,77 +486,24 @@ function qts_sanitize_bases($base_slugs = false) {
|
|
486 |
if ( !$base_slugs || empty($base_slugs) ) return;
|
487 |
|
488 |
$base_slugs_processed = array();
|
489 |
-
$
|
490 |
-
$taxonomies = array();
|
491 |
|
492 |
// changing array structure
|
493 |
-
foreach ($base_slugs as $type => $
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
// matching taxonomies..
|
502 |
-
preg_match('/(\b_qts_taxonomy_)\w+\b/', $type, $matches);
|
503 |
-
|
504 |
-
if (!empty($matches))
|
505 |
-
foreach ($value as $lang => $base) $taxonomies[$lang][$type] = $base;
|
506 |
-
}
|
507 |
-
|
508 |
-
// processing post_types
|
509 |
-
if ( count($post_types) > 1 )
|
510 |
-
$post_types = qts_prevent_duplicates($post_types);
|
511 |
-
|
512 |
-
// processing taxonomies
|
513 |
-
if ( count($taxonomies) > 1 )
|
514 |
-
$taxonomies = qts_prevent_duplicates($taxonomies);
|
515 |
-
|
516 |
-
foreach ($post_types as $lang => $array_)
|
517 |
-
foreach ($array_ as $key => $value) $base_slugs_processed[$key][$lang] = $value;
|
518 |
-
|
519 |
-
foreach ($taxonomies as $lang => $array_)
|
520 |
-
foreach ($array_ as $key => $value) $base_slugs_processed[$key][$lang] = $value;
|
521 |
-
|
522 |
-
return $base_slugs_processed;
|
523 |
-
}
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
/**
|
528 |
-
* Helper that prevents duplicates items on an array
|
529 |
-
*
|
530 |
-
* @package Qtranslate Slug
|
531 |
-
* @subpackage Settings
|
532 |
-
* @version 1.0
|
533 |
-
*
|
534 |
-
* @return array processed
|
535 |
-
*/
|
536 |
-
|
537 |
-
function qts_prevent_duplicates($array) {
|
538 |
-
|
539 |
-
foreach ($array as $lang_ => $lang):
|
540 |
-
|
541 |
-
$values = array();
|
542 |
-
$processed = array_unique($lang);
|
543 |
-
|
544 |
-
while ( count($processed) != count($lang) ) {
|
545 |
-
$diff = count($lang) - count($processed);
|
546 |
-
foreach ($lang as $key => $value) {
|
547 |
-
if (!in_array($value, $values)) {
|
548 |
-
$values[] = $value;
|
549 |
-
} else {
|
550 |
-
$lang[$key] = "$value-$diff";
|
551 |
}
|
552 |
-
|
553 |
-
|
554 |
}
|
555 |
-
|
556 |
-
|
557 |
-
endforeach;
|
558 |
|
559 |
-
return $
|
560 |
}
|
561 |
|
562 |
|
486 |
if ( !$base_slugs || empty($base_slugs) ) return;
|
487 |
|
488 |
$base_slugs_processed = array();
|
489 |
+
$base_founded = array();
|
|
|
490 |
|
491 |
// changing array structure
|
492 |
+
foreach ($base_slugs as $type => $base) {
|
493 |
+
foreach ($base as $lang => $value) {
|
494 |
+
if ($value != ""):
|
495 |
+
$base_value = $value;
|
496 |
+
$count = 2;
|
497 |
+
while (in_array($value, $base_founded)) {
|
498 |
+
$value = "$base_value-$count";
|
499 |
+
$count++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
}
|
501 |
+
$base_founded[] = $base_slugs[$type][$lang] = $value;
|
502 |
+
endif;
|
503 |
}
|
504 |
+
}
|
|
|
|
|
505 |
|
506 |
+
return $base_slugs;
|
507 |
}
|
508 |
|
509 |
|
qtranslate-slug.php
CHANGED
@@ -3,84 +3,14 @@
|
|
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.
|
7 |
Author: Carlos Sanz Garcia
|
8 |
Author URI: http://github.com/not-only-code
|
9 |
-
|
10 |
-
|
11 |
-
This plugin (version 1.0) has been written from scratch using OOP. The code has been structured better, the functions have been marked and commented and everything is better integrated with Wordpress API. Previous versions of this plugin was based on Qtranslate Slug with Widget plugin (http://wordpress.org/extend/plugins/qtranslate-slug-with-widget/).
|
12 |
-
|
13 |
-
--------------------------------------------------------------------------------------------------------
|
14 |
-
|
15 |
-
version 1.0
|
16 |
-
* new branch, the plugin has been rewrited: now the code is commented and wrapped inside a class, much code has change and the performance has been increased. √
|
17 |
-
* structural changes:
|
18 |
-
* no ID for slug type, then don't install qtrasnlate_slug table. √
|
19 |
-
* slugs now are stored on meta tables, installation creates a termmeta table with some new 'core functions' to access/save data, based on [simple term meta](http://wordpress.org/extend/plugins/simple-term-meta/) √
|
20 |
-
* some automation:
|
21 |
-
* the plugin generates translated slug automatically from title in empty cases (like wordpress) √
|
22 |
-
* the plugin checks if the slug already exists (per each language and type / taxonomy), and adds a progressive number in this case (like wordpress) √
|
23 |
-
* works on ajax requests like creatig new taxonomies on edit post page √
|
24 |
-
* possibility to translate the base of permastructs for 'post_types' and 'taxonomies' (uses $wp_rewrite) √
|
25 |
-
* added some filters:
|
26 |
-
* 'qts_validate_post_slug' : args( $post (object), $slug (string), $lang (string) ) / filter to process the post slug before is saved on the database.
|
27 |
-
* 'qts_validate_term_slug' : args( $term (object), $slug (string), $lang (string) ) / filter to process the term slug before is saved on the database.
|
28 |
-
* 'qts_current_url' : args ( $url (string), $lang (string) ) / filter to process the entire url after it has been generated.
|
29 |
-
* 'qts_permastruct' : args ( $permastruct (string), $name (string) ) / filter to process the permastruct, used for change the base.
|
30 |
-
* added plugin language textdomain (.pot file) √
|
31 |
-
* new admin options page for save the base permastructs √
|
32 |
-
* import process when the plugin updates older versions
|
33 |
-
* updated Language selector Widget
|
34 |
-
* some bug fixes √
|
35 |
-
* some Qtranslate patches
|
36 |
-
|
37 |
-
version 0.9
|
38 |
-
* some wordpress qTranslate bug fixes
|
39 |
-
* adds a javascript solution for qTranslate Nav Menus
|
40 |
-
|
41 |
-
version 0.8
|
42 |
-
* added support for Categories
|
43 |
-
* added support for Tags
|
44 |
-
* added support for Taxonomies
|
45 |
-
* added support for Custom Post Types
|
46 |
-
|
47 |
-
version 0.7 enhanced by [Zapo](http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=4&t=1049&start=50#p7499)
|
48 |
-
* added suport for qTranslate TLD domain mode (en: domain.com | fr: domain.fr) visit
|
49 |
-
|
50 |
-
Version 0.5 and 0.6 enhanched by Marco Del Percio
|
51 |
-
|
52 |
-
--------------------------------------------------------------------------------------------------------
|
53 |
-
|
54 |
-
TODO:
|
55 |
-
|
56 |
-
* add support to translate attachment slugs
|
57 |
-
* expand qtranslate for translate attachment names and descriptions ( useful for galleries )
|
58 |
-
* qtranslate integration with other plugins like Jigoshop, e-commerce, etc.
|
59 |
-
|
60 |
-
--------------------------------------------------------------------------------------------------------
|
61 |
-
|
62 |
-
This program is free software; you can redistribute it and/or
|
63 |
-
modify it under the terms of the GNU General Public License
|
64 |
-
as published by the Free Software Foundation; either version 2
|
65 |
-
of the License, or (at your option) any later version.
|
66 |
-
|
67 |
-
This program is distributed in the hope that it will be useful,
|
68 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
69 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
70 |
-
GNU General Public License for more details.
|
71 |
-
|
72 |
-
You should have received a copy of the GNU General Public License
|
73 |
-
along with this program; if not, write to the Free Software
|
74 |
-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
75 |
-
|
76 |
-
|
77 |
-
The full copy of the GNU General Public License is available here: http://www.gnu.org/licenses/gpl.txt
|
78 |
*/
|
79 |
|
80 |
|
81 |
////////////////////////////////////////////////////////////////////////////////////////
|
82 |
|
83 |
-
|
84 |
if ( !function_exists('_debug') ):
|
85 |
function _debug( $message ) {
|
86 |
|
@@ -98,7 +28,6 @@ function _debug( $message ) {
|
|
98 |
endif;
|
99 |
}
|
100 |
endif;
|
101 |
-
|
102 |
////////////////////////////////////////////////////////////////////////////////////////
|
103 |
|
104 |
|
@@ -293,9 +222,6 @@ class QtranslateSlug {
|
|
293 |
if (!$new_options || empty($new_options)) return;
|
294 |
|
295 |
if (count($this->options) != count($new_options)) return;
|
296 |
-
|
297 |
-
_debug('SAVINNGGGG');
|
298 |
-
_debug($new_options);
|
299 |
|
300 |
update_option(QTS_OPTIONS_NAME, $new_options);
|
301 |
$this->options = $new_options;
|
@@ -328,7 +254,9 @@ class QtranslateSlug {
|
|
328 |
static function block_activate() {
|
329 |
global $wp_version;
|
330 |
|
331 |
-
|
|
|
|
|
332 |
}
|
333 |
|
334 |
|
@@ -488,7 +416,6 @@ class QtranslateSlug {
|
|
488 |
* @since 1.0
|
489 |
*/
|
490 |
function init() {
|
491 |
-
global $pagenow;
|
492 |
|
493 |
load_plugin_textdomain( 'qts', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
494 |
|
@@ -527,14 +454,12 @@ class QtranslateSlug {
|
|
527 |
add_action( 'admin_head', array($this, 'hide_quick_edit'), 600 );
|
528 |
add_action( 'admin_init', array($this, 'fix_nav_menu') );
|
529 |
|
530 |
-
if ( $pagenow == 'options-permalink.php' )
|
531 |
-
add_filter( 'query_vars', array($this, 'query_vars'));
|
532 |
-
|
533 |
} else {
|
534 |
|
535 |
add_filter( 'request', array($this, 'filter_request') );
|
536 |
}
|
537 |
|
|
|
538 |
add_action( 'generate_rewrite_rules', array($this, 'modify_rewrite_rules') );
|
539 |
|
540 |
// remove some Qtranslate filters
|
@@ -710,16 +635,9 @@ class QtranslateSlug {
|
|
710 |
public function query_vars( $query_vars ) {
|
711 |
global $wp, $wp_rewrite;
|
712 |
|
713 |
-
$wp
|
714 |
$post_type_query_vars = array();
|
715 |
|
716 |
-
if ( is_array($extra_query_vars) )
|
717 |
-
$wp->extra_query_vars = & $extra_query_vars;
|
718 |
-
else if (! empty($extra_query_vars))
|
719 |
-
parse_str($extra_query_vars, $wp->extra_query_vars);
|
720 |
-
|
721 |
-
// Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
|
722 |
-
|
723 |
// Fetch the rewrite rules.
|
724 |
$rewrite = $wp_rewrite->wp_rewrite_rules();
|
725 |
|
@@ -739,6 +657,7 @@ class QtranslateSlug {
|
|
739 |
$req_uri = $req_uri_array[0];
|
740 |
$self = $_SERVER['PHP_SELF'];
|
741 |
$home_path = parse_url(home_url());
|
|
|
742 |
if ( isset($home_path['path']) )
|
743 |
$home_path = $home_path['path'];
|
744 |
else
|
@@ -770,7 +689,7 @@ class QtranslateSlug {
|
|
770 |
$req_uri = '';
|
771 |
$request = $req_uri;
|
772 |
}
|
773 |
-
|
774 |
$wp->request = $request;
|
775 |
|
776 |
// Look for matches.
|
@@ -793,8 +712,11 @@ class QtranslateSlug {
|
|
793 |
|
794 |
if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
|
795 |
// this is a verbose page match, lets check to be sure about it
|
796 |
-
if ( ! $this->get_page_by_path( $matches[ $varmatch[1] ] ) )
|
797 |
-
|
|
|
|
|
|
|
798 |
}
|
799 |
|
800 |
// Got a match.
|
@@ -848,50 +770,36 @@ class QtranslateSlug {
|
|
848 |
* @since 1.0
|
849 |
*/
|
850 |
function filter_request( $query ) {
|
851 |
-
global $q_config, $wp_query;
|
|
|
|
|
|
|
|
|
|
|
|
|
852 |
|
853 |
-
// special conditional for /%postname%/ post structure
|
854 |
$page_foundit = false;
|
855 |
-
if ( $this->permalink_structure == '/%postname%/' ):
|
856 |
-
// post or page
|
857 |
-
if ( isset($query['name']) && !isset($query['post_type']) ) {
|
858 |
-
$page = $this->get_page_by_path($query['name']);
|
859 |
-
if ( !is_null($page) ) {
|
860 |
-
$id = $page->ID;
|
861 |
-
$cache_array = array($page);
|
862 |
-
update_post_caches($cache_array, 'page'); // caching query :)
|
863 |
-
unset($query['name']);
|
864 |
-
$query['pagename'] = get_page_uri($page);
|
865 |
-
$function = 'get_page_link';
|
866 |
-
$page_foundit = true;
|
867 |
-
} else {
|
868 |
-
$page = $this->get_page_by_path($query['name'], OBJECT, 'post');
|
869 |
-
if (!$page) return $query;
|
870 |
-
$query['name'] = $page->post_name;
|
871 |
-
$id = $page->ID;
|
872 |
-
$cache_array = array($page);
|
873 |
-
update_post_caches($cache_array); // caching query :)
|
874 |
-
$function = 'get_permalink';
|
875 |
-
$page_foundit = true;
|
876 |
-
}
|
877 |
-
}
|
878 |
-
endif;
|
879 |
|
880 |
// -> page
|
881 |
-
if (
|
|
|
|
|
|
|
|
|
882 |
|
883 |
-
$page = isset($query['page_id']) ? get_page($query['page_id']) : $this->get_page_by_path($query['pagename']);
|
884 |
if (!$page) return $query;
|
885 |
$id = $page->ID;
|
886 |
$cache_array = array($page);
|
887 |
-
update_post_caches($cache_array, 'page');
|
|
|
888 |
$query['pagename'] = get_page_uri($page);
|
889 |
$function = 'get_page_link';
|
890 |
|
891 |
// -> custom post type
|
892 |
elseif ( isset($query['post_type']) ):
|
893 |
|
894 |
-
$
|
|
|
895 |
if (!$page) return $query;
|
896 |
$id = $page->ID;
|
897 |
$cache_array = array($page);
|
@@ -900,7 +808,7 @@ class QtranslateSlug {
|
|
900 |
$function = 'get_post_permalink';
|
901 |
|
902 |
// -> post
|
903 |
-
elseif (
|
904 |
|
905 |
$post = isset($query['p']) ? get_post($query['p']) : $this->get_page_by_path($query['name'], OBJECT, 'post');
|
906 |
if (!$post) return $query;
|
@@ -1037,7 +945,6 @@ class QtranslateSlug {
|
|
1037 |
$parts = explode( '/', trim( $page_path, '/' ) );
|
1038 |
$parts = array_map( 'esc_sql', $parts );
|
1039 |
$parts = array_map( 'sanitize_title_for_query', $parts );
|
1040 |
-
|
1041 |
$in_string = "'". implode( "','", $parts ) . "'";
|
1042 |
$meta_key = $this->get_meta_key();
|
1043 |
$post_type_sql = $post_type;
|
@@ -1068,7 +975,6 @@ class QtranslateSlug {
|
|
1068 |
}
|
1069 |
|
1070 |
if ( $foundid ) {
|
1071 |
-
|
1072 |
return $foundid;
|
1073 |
|
1074 |
} else {
|
@@ -1097,6 +1003,7 @@ class QtranslateSlug {
|
|
1097 |
* @since 1.0
|
1098 |
*/
|
1099 |
private function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
|
|
|
1100 |
$foundid = $this->get_page_id_by_path($page_path, $output, $post_type);
|
1101 |
if ( $foundid )
|
1102 |
return get_page( $foundid, $output );
|
@@ -1117,7 +1024,7 @@ class QtranslateSlug {
|
|
1117 |
|
1118 |
$backtrace = debug_backtrace();
|
1119 |
|
1120 |
-
$ignore_functions = array('mod_rewrite_rules', 'save_mod_rewrite_rules', 'flush_rules', 'rewrite_rules', 'wp_rewrite_rules');
|
1121 |
|
1122 |
if ( isset($backtrace['function']) ) {
|
1123 |
if (in_array($backtrace['function'], $ignore_functions)) return true;
|
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
|
7 |
Author: Carlos Sanz Garcia
|
8 |
Author URI: http://github.com/not-only-code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
|
12 |
////////////////////////////////////////////////////////////////////////////////////////
|
13 |
|
|
|
14 |
if ( !function_exists('_debug') ):
|
15 |
function _debug( $message ) {
|
16 |
|
28 |
endif;
|
29 |
}
|
30 |
endif;
|
|
|
31 |
////////////////////////////////////////////////////////////////////////////////////////
|
32 |
|
33 |
|
222 |
if (!$new_options || empty($new_options)) return;
|
223 |
|
224 |
if (count($this->options) != count($new_options)) return;
|
|
|
|
|
|
|
225 |
|
226 |
update_option(QTS_OPTIONS_NAME, $new_options);
|
227 |
$this->options = $new_options;
|
254 |
static function block_activate() {
|
255 |
global $wp_version;
|
256 |
|
257 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
258 |
+
|
259 |
+
return ( version_compare($wp_version, "3.3", "<" ) || !is_plugin_active('qtranslate/qtranslate.php') );
|
260 |
}
|
261 |
|
262 |
|
416 |
* @since 1.0
|
417 |
*/
|
418 |
function init() {
|
|
|
419 |
|
420 |
load_plugin_textdomain( 'qts', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
421 |
|
454 |
add_action( 'admin_head', array($this, 'hide_quick_edit'), 600 );
|
455 |
add_action( 'admin_init', array($this, 'fix_nav_menu') );
|
456 |
|
|
|
|
|
|
|
457 |
} else {
|
458 |
|
459 |
add_filter( 'request', array($this, 'filter_request') );
|
460 |
}
|
461 |
|
462 |
+
add_filter( 'query_vars', array($this, 'query_vars'));
|
463 |
add_action( 'generate_rewrite_rules', array($this, 'modify_rewrite_rules') );
|
464 |
|
465 |
// remove some Qtranslate filters
|
635 |
public function query_vars( $query_vars ) {
|
636 |
global $wp, $wp_rewrite;
|
637 |
|
638 |
+
$wp->query_vars = array();
|
639 |
$post_type_query_vars = array();
|
640 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
641 |
// Fetch the rewrite rules.
|
642 |
$rewrite = $wp_rewrite->wp_rewrite_rules();
|
643 |
|
657 |
$req_uri = $req_uri_array[0];
|
658 |
$self = $_SERVER['PHP_SELF'];
|
659 |
$home_path = parse_url(home_url());
|
660 |
+
|
661 |
if ( isset($home_path['path']) )
|
662 |
$home_path = $home_path['path'];
|
663 |
else
|
689 |
$req_uri = '';
|
690 |
$request = $req_uri;
|
691 |
}
|
692 |
+
|
693 |
$wp->request = $request;
|
694 |
|
695 |
// Look for matches.
|
712 |
|
713 |
if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
|
714 |
// this is a verbose page match, lets check to be sure about it
|
715 |
+
if ( ! $page_foundid = $this->get_page_by_path( $matches[ $varmatch[1] ] ) ) {
|
716 |
+
continue;
|
717 |
+
} else {
|
718 |
+
wp_cache_set('qts_page_request', $page_foundid); // caching query :)
|
719 |
+
}
|
720 |
}
|
721 |
|
722 |
// Got a match.
|
770 |
* @since 1.0
|
771 |
*/
|
772 |
function filter_request( $query ) {
|
773 |
+
global $q_config, $wp_query, $wp;
|
774 |
+
|
775 |
+
if (isset($wp->matched_query))
|
776 |
+
$query = wp_parse_args($wp->matched_query);
|
777 |
+
|
778 |
+
foreach (get_post_types() as $post_type)
|
779 |
+
if ( array_key_exists($post_type, $query) && !in_array($post_type, array('post', 'page')) ) $query['post_type'] = $post_type;
|
780 |
|
|
|
781 |
$page_foundit = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
782 |
|
783 |
// -> page
|
784 |
+
if ( isset($query['pagename']) || isset($query['page_id']) ):
|
785 |
+
|
786 |
+
$page = wp_cache_get('qts_page_request');
|
787 |
+
if (!$page)
|
788 |
+
$page = isset($query['page_id']) ? get_page($query['page_id']) : $this->get_page_by_path($query['pagename']);
|
789 |
|
|
|
790 |
if (!$page) return $query;
|
791 |
$id = $page->ID;
|
792 |
$cache_array = array($page);
|
793 |
+
update_post_caches($cache_array, 'page'); // caching query :)
|
794 |
+
wp_cache_delete('qts_page_request');
|
795 |
$query['pagename'] = get_page_uri($page);
|
796 |
$function = 'get_page_link';
|
797 |
|
798 |
// -> custom post type
|
799 |
elseif ( isset($query['post_type']) ):
|
800 |
|
801 |
+
$page_slug = ( isset($query['name']) && !empty($query['name']) ) ? $query['name'] : $query[$query['post_type']];
|
802 |
+
$page = $this->get_page_by_path($page_slug, OBJECT, $query['post_type']);
|
803 |
if (!$page) return $query;
|
804 |
$id = $page->ID;
|
805 |
$cache_array = array($page);
|
808 |
$function = 'get_post_permalink';
|
809 |
|
810 |
// -> post
|
811 |
+
elseif ( isset($query['name']) || isset($query['p']) ):
|
812 |
|
813 |
$post = isset($query['p']) ? get_post($query['p']) : $this->get_page_by_path($query['name'], OBJECT, 'post');
|
814 |
if (!$post) return $query;
|
945 |
$parts = explode( '/', trim( $page_path, '/' ) );
|
946 |
$parts = array_map( 'esc_sql', $parts );
|
947 |
$parts = array_map( 'sanitize_title_for_query', $parts );
|
|
|
948 |
$in_string = "'". implode( "','", $parts ) . "'";
|
949 |
$meta_key = $this->get_meta_key();
|
950 |
$post_type_sql = $post_type;
|
975 |
}
|
976 |
|
977 |
if ( $foundid ) {
|
|
|
978 |
return $foundid;
|
979 |
|
980 |
} else {
|
1003 |
* @since 1.0
|
1004 |
*/
|
1005 |
private function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
|
1006 |
+
|
1007 |
$foundid = $this->get_page_id_by_path($page_path, $output, $post_type);
|
1008 |
if ( $foundid )
|
1009 |
return get_page( $foundid, $output );
|
1024 |
|
1025 |
$backtrace = debug_backtrace();
|
1026 |
|
1027 |
+
$ignore_functions = array('mod_rewrite_rules', 'save_mod_rewrite_rules', 'flush_rules', 'rewrite_rules', 'wp_rewrite_rules', 'query_vars');
|
1028 |
|
1029 |
if ( isset($backtrace['function']) ) {
|
1030 |
if (in_array($backtrace['function'], $ignore_functions)) return true;
|