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 | Qtranslate Slug |
Version | 1.1.9 |
Comparing to | |
See all releases |
Code changes from version 1.1.8 to 1.1.9
- qtranslate-slug.php +182 -184
- readme.txt +38 -19
- trunk/README.txt +0 -175
- trunk/assets/css/qts-default.css +0 -16
- trunk/assets/css/qts-default.min.css +0 -1
- trunk/assets/css/qts-settings.css +0 -42
- trunk/assets/js/qts-nav-menu-min.js +0 -1
- trunk/assets/js/qts-nav-menu.js +0 -100
- trunk/assets/js/qts-settings-upgrade.js +0 -69
- trunk/assets/js/qts-settings.js +0 -19
- trunk/includes/class-qtranslate-slug-widget.php +0 -63
- trunk/includes/class-qtranslate-slug.php +0 -2378
- trunk/includes/qtranslate-slug-settings-options.php +0 -182
- trunk/includes/qtranslate-slug-settings.php +0 -978
- trunk/includes/termmeta-core.php +0 -222
- trunk/languages/qts-es_ES.mo +0 -0
- trunk/languages/qts-es_ES.po +0 -142
- trunk/languages/qts-pt_PT.mo +0 -0
- trunk/languages/qts-pt_PT.po +0 -199
- trunk/languages/qts.pot +0 -145
- trunk/phpunit.xml +0 -14
- trunk/qtranslate-slug-settings-options.php +0 -178
- trunk/qtranslate-slug-settings.php +0 -972
- trunk/qtranslate-slug.php +0 -184
- trunk/readme.md +0 -209
- trunk/readme.txt +0 -213
- trunk/screenshot-1.png +0 -0
- trunk/screenshot-2.png +0 -0
- trunk/screenshot-3.png +0 -0
- trunk/screenshot-4.png +0 -0
- trunk/termmeta-core.php +0 -222
- trunk/version.txt +0 -71
- version.txt +17 -0
qtranslate-slug.php
CHANGED
@@ -1,184 +1,182 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
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 |
-
|
17 |
-
if ( WP_DEBUG === true ):
|
18 |
-
|
19 |
-
if ( is_array( $message ) || is_object( $message ) ) {
|
20 |
-
|
21 |
-
error_log( print_r( $message, true ) );
|
22 |
-
|
23 |
-
} else {
|
24 |
-
|
25 |
-
error_log( $message );
|
26 |
-
}
|
27 |
-
|
28 |
-
endif;
|
29 |
-
}
|
30 |
-
endif;
|
31 |
-
|
32 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Includes
|
38 |
-
*
|
39 |
-
* @since 1.1.8
|
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 |
-
|
46 |
-
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Define Constants
|
50 |
-
*
|
51 |
-
* @since 1.0
|
52 |
-
*/
|
53 |
-
if (!defined("QTS_VERSION")) define("QTS_VERSION", '1.1.8');
|
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 |
-
/**
|
79 |
-
* Init the plugin
|
80 |
-
*
|
81 |
-
* @since 1.0
|
82 |
-
*/
|
83 |
-
global $qtranslate_slug;
|
84 |
-
|
85 |
-
$qtranslate_slug = new QtranslateSlug();
|
86 |
-
|
87 |
-
// plugin activation
|
88 |
-
register_activation_hook( __FILE__, array($qtranslate_slug, 'install') );
|
89 |
-
|
90 |
-
// plugin deactivation
|
91 |
-
register_deactivation_hook( __FILE__, array($qtranslate_slug, 'deactivate') );
|
92 |
-
|
93 |
-
// plugin uninstall
|
94 |
-
register_uninstall_hook( __FILE__, 'qts_uninstall' );
|
95 |
-
|
96 |
-
// plugin init
|
97 |
-
add_action('plugins_loaded', array($qtranslate_slug, 'init') );
|
98 |
-
|
99 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
*
|
105 |
-
*
|
106 |
-
* @
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
*
|
120 |
-
*
|
121 |
-
* @
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
*
|
139 |
-
*
|
140 |
-
* @
|
141 |
-
*
|
142 |
-
* @
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
*
|
163 |
-
*
|
164 |
-
* @
|
165 |
-
*
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
$meta_keys =
|
181 |
-
|
182 |
-
|
183 |
-
$wpdb->query("DELETE from $wpdb->postmeta WHERE meta_key IN ($meta_keys)");
|
184 |
-
}
|
1 |
+
<?php
|
2 |
+
/*
|
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.9
|
7 |
+
Author: Carlos Sanz Garcia, Pedro Carvalho
|
8 |
+
Author URI: http://github.com/not-only-code
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
13 |
+
|
14 |
+
if ( !function_exists('_debug') ):
|
15 |
+
function _debug( $message ) {
|
16 |
+
|
17 |
+
if ( WP_DEBUG === true ):
|
18 |
+
|
19 |
+
if ( is_array( $message ) || is_object( $message ) ) {
|
20 |
+
|
21 |
+
error_log( print_r( $message, true ) );
|
22 |
+
|
23 |
+
} else {
|
24 |
+
|
25 |
+
error_log( $message );
|
26 |
+
}
|
27 |
+
|
28 |
+
endif;
|
29 |
+
}
|
30 |
+
endif;
|
31 |
+
|
32 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Includes
|
38 |
+
*
|
39 |
+
* @since 1.1.8
|
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 |
+
|
46 |
+
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Define Constants
|
50 |
+
*
|
51 |
+
* @since 1.0
|
52 |
+
*/
|
53 |
+
if (!defined("QTS_VERSION")) define("QTS_VERSION", '1.1.8');
|
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 |
+
/**
|
79 |
+
* Init the plugin
|
80 |
+
*
|
81 |
+
* @since 1.0
|
82 |
+
*/
|
83 |
+
global $qtranslate_slug;
|
84 |
+
|
85 |
+
$qtranslate_slug = new QtranslateSlug();
|
86 |
+
|
87 |
+
// plugin activation
|
88 |
+
register_activation_hook( __FILE__, array($qtranslate_slug, 'install') );
|
89 |
+
|
90 |
+
// plugin deactivation
|
91 |
+
register_deactivation_hook( __FILE__, array($qtranslate_slug, 'deactivate') );
|
92 |
+
|
93 |
+
// plugin uninstall
|
94 |
+
register_uninstall_hook( __FILE__, 'qts_uninstall' );
|
95 |
+
|
96 |
+
// plugin init
|
97 |
+
add_action('plugins_loaded', array($qtranslate_slug, 'init') );
|
98 |
+
|
99 |
+
////////////////////////////////////////////////////////////////////////////////////////
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Language Selector Code for templating
|
103 |
+
*
|
104 |
+
* @package Qtranslate Slug
|
105 |
+
* @subpackage Core
|
106 |
+
* @since 1.0
|
107 |
+
*/
|
108 |
+
function qts_language_menu ($type = "text", $args = array()) {
|
109 |
+
global $qtranslate_slug;
|
110 |
+
|
111 |
+
$qtranslate_slug->language_menu($type, $args);
|
112 |
+
}
|
113 |
+
|
114 |
+
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Adds support for old plugin function
|
118 |
+
*
|
119 |
+
* @package Qtranslate Slug
|
120 |
+
* @subpackage Core
|
121 |
+
* @since 1.1.5
|
122 |
+
*/
|
123 |
+
function qTranslateSlug_getSelfUrl ($lang = false) { // bad naming, I'll keep just in case
|
124 |
+
return qts_get_url($lang);
|
125 |
+
}
|
126 |
+
|
127 |
+
function qts_get_url($lang = false) {
|
128 |
+
global $qtranslate_slug;
|
129 |
+
|
130 |
+
return $qtranslate_slug->get_current_url($lang);
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Add a "Settings" link to the plugins.php page for Qtranslate Slug
|
137 |
+
*
|
138 |
+
* @package Qtranslate Slug
|
139 |
+
* @subpackage Settings
|
140 |
+
* @version 1.0
|
141 |
+
*
|
142 |
+
* @return calls qts_show_msg()
|
143 |
+
*/
|
144 |
+
function qts_add_settings_link( $links, $file ) {
|
145 |
+
|
146 |
+
if (QtranslateSlug::block_activate()) return $links;
|
147 |
+
|
148 |
+
$this_plugin = plugin_basename( __FILE__ );
|
149 |
+
if( $file == $this_plugin ) {
|
150 |
+
$settings_link = "<a href=\"options-general.php?page=" . QTS_PAGE_BASENAME . "\">" . __( 'Settings' ) . '</a>';
|
151 |
+
array_unshift($links, $settings_link);
|
152 |
+
}
|
153 |
+
return $links;
|
154 |
+
}
|
155 |
+
add_filter( 'plugin_action_links', 'qts_add_settings_link', 10, 2 );
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Delete plugin stored data ( options, termmeta table and postmeta data )
|
161 |
+
*
|
162 |
+
* @package Qtranslate Slug
|
163 |
+
* @subpackage Settings
|
164 |
+
* @version 1.0
|
165 |
+
*
|
166 |
+
*/
|
167 |
+
function qts_uninstall() {
|
168 |
+
global $q_config, $wpdb;
|
169 |
+
|
170 |
+
// options
|
171 |
+
delete_option(QTS_OPTIONS_NAME);
|
172 |
+
delete_option('qts_version');
|
173 |
+
|
174 |
+
// delete termmeta table
|
175 |
+
$wpdb->query("DROP TABLE IF EXISTS $wpdb->termmeta");
|
176 |
+
|
177 |
+
// delete postmeta data
|
178 |
+
$meta_keys = array();
|
179 |
+
foreach ($q_config['enabled_languages'] as $lang) $meta_keys[] = sprintf("_qts_slug_%s", $lang);
|
180 |
+
$meta_keys = "'". implode( "','", $meta_keys ) . "'";
|
181 |
+
$wpdb->query("DELETE from $wpdb->postmeta WHERE meta_key IN ($meta_keys)");
|
182 |
+
}
|
|
|
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Qtranslate Slug ===
|
2 |
-
Contributors:
|
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: 4.1
|
7 |
-
Stable tag: 1.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -21,24 +21,24 @@ Adds support for permalink translations and fix some QTranslate deficiencies sin
|
|
21 |
* Wordpress 3.3 (PHP 5.2 and MySQL 5)
|
22 |
* mQtranslate 2.6.2.4 or Qtranslate 2.5.8 ( soon qtranslate-x too )
|
23 |
|
24 |
-
= New in
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
Many thanks to everyone that contributed to this update, for their commits, bug reports and for simply using it
|
27 |
|
28 |
-
* Portuguese translation and fixed some translation bugs ( thanks pedro-mendonca )
|
29 |
-
* removed mqtranslate switcher widget hook
|
30 |
-
* Updated the plugin structure and coding style
|
31 |
-
* solve some conflicts with search and pagination queries
|
32 |
-
* Settings php errors, syntax indent and fixed settings assets url
|
33 |
-
* Change titles when there is a click on pagination on show all pages tab ( thanks juanfran-granados )
|
34 |
-
* Formatted dependency notice message ( thanks arildm )
|
35 |
-
* Updated the deprecated jquery 'live' function and solve php strict standards error ( thanks rafitaFCB )
|
36 |
-
* Fixed error showing if PHP was newer than 5.3 ( thanks rafitaFCB )
|
37 |
-
* Strict standard advise prevented ( thanks rafitaFCB )
|
38 |
-
* php notices are prevented in post edit, when using adding new translated tags ( thanks rafitaFCB )
|
39 |
-
* fixed the hreflang issue! 'bout time!
|
40 |
-
* As discussed in issue #25, the flags are now img tags, intead of background-url.
|
41 |
-
* Added another option to include the css style in a minified file. ( and also showing in the option screen the styles we would use.)
|
42 |
|
43 |
|
44 |
**Advice: If you're using a multisite installation, you will must activate qtranslate plugins by separately on each site.**
|
@@ -57,6 +57,7 @@ Thanks for use this plugin!
|
|
57 |
* [Juanfran](https://github.com/juanfran-granados)
|
58 |
* [Arild](https://github.com/arildm)
|
59 |
* [Rafa Aguilar](https://github.com/rafitaFCB)
|
|
|
60 |
|
61 |
|
62 |
== Installation ==
|
@@ -105,6 +106,24 @@ That's because language selector metabox is hidden, if you are in admin *nav men
|
|
105 |
|
106 |
== Changelog ==
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
= 1.1.8 =
|
109 |
|
110 |
Many thanks to everyone that contributed to this update, for their commits, bug reports and for simply using it
|
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
|
5 |
Requires at least: 3.3
|
6 |
+
Tested up to: 4.1
|
7 |
+
Stable tag: 1.1.9
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
21 |
* Wordpress 3.3 (PHP 5.2 and MySQL 5)
|
22 |
* mQtranslate 2.6.2.4 or Qtranslate 2.5.8 ( soon qtranslate-x too )
|
23 |
|
24 |
+
= New in Version 1.1.9 =
|
25 |
+
|
26 |
+
Lots of bug fixes! Thanks again to everyone that contributed to this project, with commits, bug reports and suggestions.
|
27 |
+
|
28 |
+
* Compatibility with qtranslate-X! ( thanks @beheist, pull #85, fixing most of #80 )
|
29 |
+
* More updates to the portuguese translation ( thanks pedro-mendonca, pull #86)
|
30 |
+
* Corrected the link to language files ( thanks pedro-mendonca )
|
31 |
+
* Added translation for some hardcoded texts ( thanks pedro-mendonca )
|
32 |
+
* Corrected a link from 'qtranslate' to 'qts' language files ( thanks pedro-mendonca )
|
33 |
+
* Fixed taxonomies slugs ( thanks to [eirikv's bug report](https://wordpress.org/support/topic/categories-slug-dont-work) )
|
34 |
+
* Fixed many warnings ( thanks piffpaffpuff, issue #78 and to [pedrodu1](https://wordpress.org/support/topic/warnings-qtranslate-slugphp) )
|
35 |
+
* Changed the behaviour of "Quick Edit", from the wp forums [1](https://wordpress.org/support/topic/categories-tags-and-quick-edit-dont-show-in-admin) [2](https://wordpress.org/support/topic/quick-edit-inhibited-by-qtranslate-slug-with-wp-41-mqtranslate) ( thanks everyone!! )
|
36 |
+
* Fixed the menus! Now you can properly use one menu for every language. Use the dropdown section "Languages", and for each item, change the "Navigation Label" and "Title Attribute". Select "All languages", to make sure everything is awesome! All these features were a consequence of fixing all the warnings based on [Gery's bug report)[https://wordpress.org/support/topic/qtranslate-slug-conflicting-with-ubermenu).
|
37 |
+
* Minor fixes, etc.
|
38 |
+
|
39 |
+
See you next Version!
|
40 |
|
|
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
|
44 |
**Advice: If you're using a multisite installation, you will must activate qtranslate plugins by separately on each site.**
|
57 |
* [Juanfran](https://github.com/juanfran-granados)
|
58 |
* [Arild](https://github.com/arildm)
|
59 |
* [Rafa Aguilar](https://github.com/rafitaFCB)
|
60 |
+
* [Bastian Heist](https://github.com/beheist)
|
61 |
|
62 |
|
63 |
== Installation ==
|
106 |
|
107 |
== Changelog ==
|
108 |
|
109 |
+
= New in Version 1.1.9 =
|
110 |
+
|
111 |
+
Lots of bug fixes! Thanks again to everyone that contributed to this project, with commits, bug reports and suggestions.
|
112 |
+
|
113 |
+
* Compatibility with qtranslate-X! ( thanks @beheist, pull #85, fixing most of #80 )
|
114 |
+
* More updates to the portuguese translation ( thanks pedro-mendonca, pull #86)
|
115 |
+
* Corrected the link to language files ( thanks pedro-mendonca )
|
116 |
+
* Added translation for some hardcoded texts ( thanks pedro-mendonca )
|
117 |
+
* Corrected a link from 'qtranslate' to 'qts' language files ( thanks pedro-mendonca )
|
118 |
+
* Fixed taxonomies slugs ( thanks to [eirikv's bug report](https://wordpress.org/support/topic/categories-slug-dont-work)
|
119 |
+
* Fixed many warnings ( thanks piffpaffpuff, issue #78 and to [pedrodu1](https://wordpress.org/support/topic/warnings-qtranslate-slugphp) )
|
120 |
+
* Changed the behaviour of "Quick Edit", from the wp forums [1](https://wordpress.org/support/topic/categories-tags-and-quick-edit-dont-show-in-admin) [2](https://wordpress.org/support/topic/quick-edit-inhibited-by-qtranslate-slug-with-wp-41-mqtranslate) ( thanks everyone!! )
|
121 |
+
* Fixed the menus! Now you can properly use one menu for every language. Use the dropdown section "Languages", and for each item, change the "Navigation Label" and "Title Attribute". Select "All languages", to make sure everything is awesome! All these features were a consequence of fixing all the warnings based on [Gery's bug report)[https://wordpress.org/support/topic/qtranslate-slug-conflicting-with-ubermenu).
|
122 |
+
* Minor fixes, etc.
|
123 |
+
|
124 |
+
See you next Version!
|
125 |
+
|
126 |
+
|
127 |
= 1.1.8 =
|
128 |
|
129 |
Many thanks to everyone that contributed to this update, for their commits, bug reports and for simply using it
|
trunk/README.txt
DELETED
@@ -1,175 +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.9.1
|
7 |
-
Version: 1.1.7
|
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 |
-
= Requirements: =
|
20 |
-
|
21 |
-
* Wordpress 3.3 (PHP 5.2 and MySQL 5)
|
22 |
-
* mQtranslate 2.6.2.4 or Qtranslate 2.5.8
|
23 |
-
|
24 |
-
= New in version 1.1.7 =
|
25 |
-
* removed styles from html elements and added options to use .css file or print inline styles
|
26 |
-
* fixed tag creation on post edit.
|
27 |
-
* fixed earlier bad post slug introduced in 1.1.6
|
28 |
-
|
29 |
-
**Advice: If you're using a multisite installation, you will must activate qtranslate plugins by separately on each site.**
|
30 |
-
|
31 |
-
You can also check the [project website](http://not-only-code.github.com/qtranslate-slug/) hosted on [GitHub](http://not-only-code.github.com).
|
32 |
-
Thanks for use this plugin!
|
33 |
-
|
34 |
-
= Contributors =
|
35 |
-
|
36 |
-
* [Pedro de Carvalho](https://github.com/LC43/)
|
37 |
-
* [Risto Niinemets](https://github.com/RistoNiinemets)
|
38 |
-
* [Pedro Mendonça](https://github.com/pedro-mendonca)
|
39 |
-
* [codep0et](https://github.com/codep0et)
|
40 |
-
* [Giraldi Maggio](https://github.com/bedex78)
|
41 |
-
* [jinoOM](https://github.com/jinoOM)
|
42 |
-
|
43 |
-
|
44 |
-
== Installation ==
|
45 |
-
**This plugins requires [Qtranslate](http://wordpress.org/extend/plugins/qtranslate/) or [mqTranslate](https://wordpress.org/plugins/mqtranslate/) installed previously, if not, it will not activate.**
|
46 |
-
|
47 |
-
1. Upload `qtranslate-slug` to the `/wp-content/plugins/` directory.
|
48 |
-
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
49 |
-
1. That's all!
|
50 |
-
|
51 |
-
= Changing base permastructs =
|
52 |
-
|
53 |
-
1. In admin: navigate to *Settings/Slug options*.
|
54 |
-
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).
|
55 |
-
1. Save settings and that's all!
|
56 |
-
|
57 |
-
== Frequently Asked Questions ==
|
58 |
-
|
59 |
-
= It works with posts and pages, but with other content type? =
|
60 |
-
|
61 |
-
This plugin allows to translate slugs of: posts, pages, custom post types, categories, tags and custom taxonomies.
|
62 |
-
|
63 |
-
= Do I have to configure anything? =
|
64 |
-
|
65 |
-
If you want to translate also the base permastructs (ex. *category*, *tag*, etc). Visit the plugin settings page in the admin *Settings/Slug options*
|
66 |
-
|
67 |
-
= How can i insert a language selector in my theme ? =
|
68 |
-
|
69 |
-
You can choose to:
|
70 |
-
* use **Qtranslate Slug Widget** in your sidebar.
|
71 |
-
* place in your template `<?php if (function_exists('qts_language_menu') ) qts_language_menu('text'); ?>`. Options are: `dropdown`, `text`, `image`, and `both`.
|
72 |
-
|
73 |
-
= Appears an error 404, what can i do? =
|
74 |
-
|
75 |
-
In the admin go to *Settings/Permalinks* or *Settings/Slug options* and save.
|
76 |
-
|
77 |
-
= I can't manage translations in Nav Menus. =
|
78 |
-
|
79 |
-
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.
|
80 |
-
|
81 |
-
== Screenshots ==
|
82 |
-
|
83 |
-
1. Edit page for: post / page / post_type, you can see the meta box for translated slugs on top and right.
|
84 |
-
2. Add new taxonomy page
|
85 |
-
3. Edit taxonomy page
|
86 |
-
4. Qtranslate Slug options page for translate base permastructs of post_types and taxonomies.
|
87 |
-
|
88 |
-
== Changelog ==
|
89 |
-
= 1.1.7 =
|
90 |
-
* removed styles from html elements and added options to use .css file or print inline styles
|
91 |
-
* fixed tag creation on post edit.
|
92 |
-
* fixed earlier bad post slug introduced in 1.1.6
|
93 |
-
|
94 |
-
= 1.1.6 =
|
95 |
-
* compatible with mqtranslate
|
96 |
-
* php5.4+ compatible
|
97 |
-
|
98 |
-
= 1.1.5 =
|
99 |
-
* bugfixes
|
100 |
-
|
101 |
-
= 1.1 =
|
102 |
-
* added multisite support
|
103 |
-
* fixed some parse url bugs
|
104 |
-
* fixed slug bases validation
|
105 |
-
|
106 |
-
= 1.0 =
|
107 |
-
* **works** with any permalink combination and qtranslate mode.
|
108 |
-
* 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).
|
109 |
-
* 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.
|
110 |
-
* the plugin generates translated slug automatically from title in empty cases.
|
111 |
-
* 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.
|
112 |
-
* 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.
|
113 |
-
* added some filters, see in [other notes](http://wordpress.org/extend/plugins/qtranslate-slug/other_notes/).
|
114 |
-
* added plugin language textdomain (.pot file).
|
115 |
-
* updated **Language selector Widget**, and some new conventions like accessible functions for templating.
|
116 |
-
* some bug fixes.
|
117 |
-
* some Qtranslate patches.
|
118 |
-
|
119 |
-
= 0.9 =
|
120 |
-
* some wordpress qTranslate bug fixes
|
121 |
-
* adds a javascript solution for qTranslate Nav Menus
|
122 |
-
|
123 |
-
= 0.8 =
|
124 |
-
* added support por Categories
|
125 |
-
* added support por Tags
|
126 |
-
* added support por Taxonomies
|
127 |
-
* added support por Custom Post Types
|
128 |
-
|
129 |
-
= 0.7 = [Zapo](http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=4&t=1049&start=50#p7499)
|
130 |
-
* added suport for qTranslate TLD domain mode (en: domain.com | fr: domain.fr) visit
|
131 |
-
|
132 |
-
= 0.5 and 0.6 enhanched by Marco Del Percio =
|
133 |
-
|
134 |
-
== Upgrade Notice ==
|
135 |
-
|
136 |
-
= 1.0 =
|
137 |
-
Major version, the plugin has been rewritten. Better performance, and some enhancements.
|
138 |
-
|
139 |
-
= 0.9 =
|
140 |
-
This version fix some bugs and allow multilanguage in nav-menus.
|
141 |
-
|
142 |
-
= 0.8 =
|
143 |
-
A lot of slugs content allowed
|
144 |
-
|
145 |
-
= 0.7 =
|
146 |
-
This version allows TLD domain option for a different Qtranslate fork maded by Zappo
|
147 |
-
|
148 |
-
|
149 |
-
== Other notes ==
|
150 |
-
|
151 |
-
Plugin filters reference:
|
152 |
-
|
153 |
-
= qts_validate_post_slug =
|
154 |
-
filter to process the post slug before is saved on the database.
|
155 |
-
`args: $post (object), $slug (string), $lang (string)`
|
156 |
-
|
157 |
-
= qts_validate_term_slug =
|
158 |
-
filter to process the term slug before is saved on the database.
|
159 |
-
`args: $term (object), $slug (string), $lang (string)`
|
160 |
-
|
161 |
-
= qts_url_args =
|
162 |
-
filter to process the entire url after it has been generated.
|
163 |
-
`args: $url (string), $lang (string)`
|
164 |
-
|
165 |
-
= qts_permastruct =
|
166 |
-
filter to process the permastruct, used for change the base.
|
167 |
-
`args: $permastruct (string), $name (string)`
|
168 |
-
|
169 |
-
|
170 |
-
= Todo =
|
171 |
-
|
172 |
-
* detect Slug for each language and redirect accordingly in parse_query.
|
173 |
-
* expand qtranslate for translate attachment names and descriptions ( useful for galleries )
|
174 |
-
* translate other slugs like attachments.
|
175 |
-
* qtranslate integration with other plugins like Jigoshop, e-commerce, etc. Addapt **$wp_rewrite**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/assets/css/qts-default.css
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
.qts_type_image .qts_lang_item {
|
2 |
-
float: left;
|
3 |
-
margin-right: 7px;
|
4 |
-
}
|
5 |
-
.qts_type_image .qts_lang_item.last-child {
|
6 |
-
margin-right: 0;
|
7 |
-
}
|
8 |
-
.qts_lang_item{
|
9 |
-
margin-top: 7px;
|
10 |
-
margin-bottom: 7px;
|
11 |
-
}
|
12 |
-
.qts_both {
|
13 |
-
white-space: nowrap;
|
14 |
-
line-height:1em;
|
15 |
-
}
|
16 |
-
.qts_both img { margin-right: 4px }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/assets/css/qts-default.min.css
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
.qts_type_image .qts_lang_item{float:left;margin-right:7px}.qts_type_image .qts_lang_item.last-child{margin-right:0}.qts_lang_item{margin-top:7px;margin-bottom:7px}.qts_both{white-space:nowrap;line-height:1em}.qts_both img{margin-right:4px}
|
|
trunk/assets/css/qts-settings.css
DELETED
@@ -1,42 +0,0 @@
|
|
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 |
-
|
23 |
-
#qts-loading {
|
24 |
-
display: none;
|
25 |
-
position: relative;
|
26 |
-
margin-left: 5px;
|
27 |
-
vertical-align: middle;
|
28 |
-
}
|
29 |
-
|
30 |
-
div.updated.success{
|
31 |
-
border-color: #298e00;
|
32 |
-
background-color: #D4EDC9;
|
33 |
-
}
|
34 |
-
|
35 |
-
.error a.button-primary {
|
36 |
-
color: white !important;
|
37 |
-
text-decoration: none !important;
|
38 |
-
}
|
39 |
-
|
40 |
-
.ko {
|
41 |
-
color: #c00;
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/assets/js/qts-nav-menu-min.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function(t){function e(){regexp=new RegExp("<!--:"+u+"-->(.*?)<!--:-->","i"),t(".item-title").each(function(){void 0==t(this).data("qt-value")&&t(this).data("qt-value",t(this).html()),(matches=t(this).data("qt-value").match(regexp))&&(t(this).html(matches[1]),t(this).closest("li").find(".link-to-original a").text(matches[1]))}),regexp=new RegExp("<!--:"+u+"-->(.*?)<!--:-->","i"),t("input.edit-menu-item-title").each(function(){void 0==t(this).data("qt-value")&&t(this).data("qt-value",t(this).val()),(matches=t(this).data("qt-value").match(regexp))&&t(this).val(matches[1])}),t("label.menu-item-title").each(function(){var e=t(this).contents().get(1);void 0==t(this).data("qt-value")&&t(this).data("qt-value",e.nodeValue),(matches=t(this).data("qt-value").match(regexp))&&(e.nodeValue=" "+matches[1])})}function a(){t("input.edit-menu-item-title").each(function(){t(this).val(t(this).data("qt-value"))})}var i=wpNavMenu.addMenuItemToBottom;wpNavMenu.addMenuItemToBottom=function(t,a){i(t,a),e()};var n=wpNavMenu.addMenuItemToTop;wpNavMenu.addMenuItemToTop=function(t,a){n(t,a),e()};var u=t("#qt-languages :radio:checked").val();e(),t(document).ajaxComplete(function(){u=t("#qt-languages :radio:checked").val(),e()}),t("#qt-languages :radio").change(function(){u=t("#qt-languages :radio:checked").val(),e()}),t(".submit-add-to-menu").click(function(){u=t("#qt-languages :radio:checked").val(),e()}),t(document.body).on("change","input.edit-menu-item-title",null,function(){regexp=new RegExp("(<!--:"+u+"-->)(.*?)(<!--:-->)","i"),regexp.test(t(this).data("qt-value"))?t(this).data("qt-value",t(this).data("qt-value").replace(regexp,"$1"+t(this).val()+"$3")):t(this).data("qt-value",t(this).val())}),t(".menu-save").click(function(){a()}),window.onbeforeunload=function(){a()}});
|
|
trunk/assets/js/qts-nav-menu.js
DELETED
@@ -1,100 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function($){
|
2 |
-
|
3 |
-
// Change titles (and values) when user add new item to the menu:
|
4 |
-
var oldAddMenuItemToBottom = wpNavMenu.addMenuItemToBottom;
|
5 |
-
wpNavMenu.addMenuItemToBottom = function( menuMarkup, req ) {
|
6 |
-
oldAddMenuItemToBottom( menuMarkup, req );
|
7 |
-
changeTitles();
|
8 |
-
};
|
9 |
-
var oldAddMenuItemToTop = wpNavMenu.addMenuItemToTop;
|
10 |
-
wpNavMenu.addMenuItemToTop = function( menuMarkup, req ) {
|
11 |
-
oldAddMenuItemToTop( menuMarkup, req );
|
12 |
-
changeTitles();
|
13 |
-
};
|
14 |
-
|
15 |
-
// Change titles (and values) when document is ready:
|
16 |
-
var lang = $('#qt-languages :radio:checked').val();
|
17 |
-
changeTitles();
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Change titles when there is a click on pagination
|
21 |
-
* on show all pages tab.
|
22 |
-
*
|
23 |
-
* It happens when there are a large number of pages.
|
24 |
-
*/
|
25 |
-
$( document ).ajaxComplete(function() {
|
26 |
-
lang = $('#qt-languages :radio:checked').val();
|
27 |
-
changeTitles();
|
28 |
-
});
|
29 |
-
|
30 |
-
// Change titles (and values) when language is changed:
|
31 |
-
$('#qt-languages :radio').change( function() {
|
32 |
-
lang = $('#qt-languages :radio:checked').val();
|
33 |
-
changeTitles();
|
34 |
-
});
|
35 |
-
|
36 |
-
// Change titles (and values) when new menu is added:
|
37 |
-
$('.submit-add-to-menu').click( function() {
|
38 |
-
lang = $('#qt-languages :radio:checked').val();
|
39 |
-
changeTitles();
|
40 |
-
});
|
41 |
-
|
42 |
-
// Update original value when user changed a value:
|
43 |
-
$(document.body).on('change', 'input.edit-menu-item-title', null, function() {
|
44 |
-
regexp = new RegExp('(<!--:' + lang + '-->)(.*?)(<!--:-->)', 'i');
|
45 |
-
if( regexp.test( $(this).data( 'qt-value' ) ) )
|
46 |
-
$(this).data( 'qt-value', $(this).data('qt-value').replace( regexp, '$1' + $(this).val() + '$3' ) );
|
47 |
-
else
|
48 |
-
$(this).data( 'qt-value', $(this).val() );
|
49 |
-
});
|
50 |
-
|
51 |
-
// Change titles (and values):
|
52 |
-
function changeTitles() {
|
53 |
-
// Change menu item titles and links (on the right side):
|
54 |
-
regexp = new RegExp('<!--:' + lang + '-->(.*?)<!--:-->', 'i');
|
55 |
-
$('.item-title').each( function() {
|
56 |
-
if ($(this).data('qt-value') == undefined) $(this).data('qt-value', $(this).html());
|
57 |
-
if (matches = $(this).data('qt-value').match(regexp)) {
|
58 |
-
$(this).html( matches[1] );
|
59 |
-
$(this).closest('li').find('.link-to-original a').text( matches[1] );
|
60 |
-
}
|
61 |
-
});
|
62 |
-
|
63 |
-
// Change menu item title inputs (on the right side):
|
64 |
-
regexp = new RegExp('<!--:' + lang + '-->(.*?)<!--:-->', 'i');
|
65 |
-
$('input.edit-menu-item-title').each( function() {
|
66 |
-
if ($(this).data('qt-value') == undefined) $(this).data('qt-value', $(this).val());
|
67 |
-
if (matches = $(this).data('qt-value').match(regexp)) {
|
68 |
-
$(this).val( matches[1] );
|
69 |
-
}
|
70 |
-
});
|
71 |
-
|
72 |
-
// Change menu item checkbox labels (on the left side):
|
73 |
-
$('label.menu-item-title').each( function() {
|
74 |
-
var textNode = $(this).contents().get(1);
|
75 |
-
if ($(this).data('qt-value') == undefined) $(this).data('qt-value', textNode.nodeValue);
|
76 |
-
if (matches = $(this).data('qt-value').match(regexp)) {
|
77 |
-
textNode.nodeValue = ' ' + matches[1];
|
78 |
-
}
|
79 |
-
});
|
80 |
-
}
|
81 |
-
|
82 |
-
// Restore the original input values:
|
83 |
-
function restoreValues(){
|
84 |
-
$('input.edit-menu-item-title').each( function() {
|
85 |
-
$(this).val( $(this).data( 'qt-value') );
|
86 |
-
});
|
87 |
-
}
|
88 |
-
|
89 |
-
// Just before saving restore the original input values:
|
90 |
-
$('.menu-save').click(function() {
|
91 |
-
restoreValues();
|
92 |
-
});
|
93 |
-
|
94 |
-
// Just before leaving the page (or refresh) restore the original input values:
|
95 |
-
window.onbeforeunload = function(){
|
96 |
-
restoreValues();
|
97 |
-
return;
|
98 |
-
};
|
99 |
-
|
100 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/assets/js/qts-settings-upgrade.js
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function($) {
|
2 |
-
|
3 |
-
function _debug(msg) {
|
4 |
-
if(window.console) {
|
5 |
-
console.debug(msg);
|
6 |
-
}
|
7 |
-
}
|
8 |
-
var upgrade_box = $('#qts-upgrade-box'),
|
9 |
-
upgrade_form = $('#qts-upgrade-form'),
|
10 |
-
upgrade_button = $('#qts-upgrade-button'),
|
11 |
-
notice_status = function(_status) {
|
12 |
-
upgrade_box.removeClass().addClass(_status);
|
13 |
-
},
|
14 |
-
block_form = function(_block) {
|
15 |
-
if (_block) {
|
16 |
-
$('#qts-loading').show();
|
17 |
-
upgrade_button.attr('disabled', true);
|
18 |
-
} else {
|
19 |
-
$('#qts-loading').hide();
|
20 |
-
upgrade_button.attr('disabled', false);
|
21 |
-
}
|
22 |
-
|
23 |
-
},
|
24 |
-
check_types = function(_response) {
|
25 |
-
|
26 |
-
block_form(false);
|
27 |
-
upgrade_form.find('.message').remove();
|
28 |
-
|
29 |
-
switch (_response.status) {
|
30 |
-
default:
|
31 |
-
case 0:
|
32 |
-
upgrade_form.prepend('<p class=\'message ko\'>'+_response.message+'</p>');
|
33 |
-
break;
|
34 |
-
case 1:
|
35 |
-
notice_status('updated success');
|
36 |
-
upgrade_form.remove();
|
37 |
-
upgrade_box.append('<p><strong>'+_response.message+'</strong></p>');
|
38 |
-
upgrade_box.delay(2500).fadeTo(1300, 0, function(){ upgrade_box.remove(); });
|
39 |
-
break;
|
40 |
-
case 2:
|
41 |
-
var data_ = '<p class=\'message\'>'+_response.message+'</p>';
|
42 |
-
data_ += '<select id=\'qts-slug-type\' class=\'message\'>';
|
43 |
-
|
44 |
-
for (opt in _response.options)
|
45 |
-
data_ += '<option value=\''+opt+'\'>'+_response.options[opt]+'</option>';
|
46 |
-
data_ += '</select>';
|
47 |
-
|
48 |
-
upgrade_form.prepend(data_);
|
49 |
-
|
50 |
-
break;
|
51 |
-
}
|
52 |
-
},
|
53 |
-
start_upgrade = function(_event) {
|
54 |
-
_event.preventDefault();
|
55 |
-
|
56 |
-
notice_status('updated');
|
57 |
-
block_form(true);
|
58 |
-
|
59 |
-
var package_ = {};
|
60 |
-
package_.action = $('#qts-upgrade-action').val();
|
61 |
-
package_.nonce = $('#qts-upgrade-nonce').val();
|
62 |
-
if ( $('#qts-slug-type').length )
|
63 |
-
package_.type = $('#qts-slug-type').val();
|
64 |
-
|
65 |
-
$.post(ajaxurl, package_, check_types);
|
66 |
-
};
|
67 |
-
|
68 |
-
upgrade_button.bind('click', start_upgrade);
|
69 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/assets/js/qts-settings.js
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
/*############### Error messages ######################*/
|
2 |
-
jQuery(function(){
|
3 |
-
|
4 |
-
var error_msg = jQuery("#message p[class='setting-error-message']");
|
5 |
-
// look for admin messages with the "setting-error-message" error class
|
6 |
-
if (error_msg.length != 0) {
|
7 |
-
// get the title
|
8 |
-
var error_setting = error_msg.attr('title');
|
9 |
-
|
10 |
-
// look for the label with the "for" attribute=setting title and give it an "error" class (style this in the css file!)
|
11 |
-
jQuery("label[for='" + error_setting + "']").addClass('error');
|
12 |
-
|
13 |
-
// look for the input with id=setting title and add a red border to it.
|
14 |
-
jQuery("input[id='" + error_setting + "']").attr('style', 'border-color: red');
|
15 |
-
}
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/includes/class-qtranslate-slug-widget.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* QtranslateSlug_Widget class
|
5 |
-
*
|
6 |
-
* @since 1.0
|
7 |
-
*/
|
8 |
-
class QtranslateSlugWidget extends WP_Widget {
|
9 |
-
|
10 |
-
function QtranslateSlugWidget() {
|
11 |
-
$widget_ops = array('classname' => 'qts_widget', 'description' => __('Allows your visitors to choose a Language.','qtranslate') );
|
12 |
-
$this->WP_Widget('qtranslateslug', __('Language selector', 'qts'), $widget_ops);
|
13 |
-
}
|
14 |
-
|
15 |
-
function widget($args, $instance) {
|
16 |
-
extract($args);
|
17 |
-
|
18 |
-
echo $before_widget;
|
19 |
-
$title = empty($instance['title']) ? __('Language', 'qtranslate') : apply_filters('widget_title', $instance['title']);
|
20 |
-
$hide_title = empty($instance['hide-title']) ? false : 'on';
|
21 |
-
$type = $instance['type'];
|
22 |
-
$short_text = ($instance['short_text'] == 'on') ? true : false ;
|
23 |
-
|
24 |
-
if( $type!='text' && $type!='image' && $type!='both' && $type!='dropdown' ) $type='text';
|
25 |
-
|
26 |
-
if( $hide_title!='on')
|
27 |
-
echo $before_title . $title . $after_title;
|
28 |
-
|
29 |
-
qts_language_menu($type, array( 'id' => $this->id, 'short' => $short_text ) );
|
30 |
-
|
31 |
-
echo $after_widget;
|
32 |
-
}
|
33 |
-
|
34 |
-
function update($new_instance, $old_instance) {
|
35 |
-
$instance = $old_instance;
|
36 |
-
$instance['title'] = $new_instance['title'];
|
37 |
-
$instance['hide-title'] = $new_instance['hide-title'];
|
38 |
-
$instance['type'] = $new_instance['type'];
|
39 |
-
$instance['short_text'] = $new_instance['short_text'];
|
40 |
-
|
41 |
-
return $instance;
|
42 |
-
}
|
43 |
-
|
44 |
-
function form($instance) {
|
45 |
-
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'hide-title' => false, 'type' => 'text' ) );
|
46 |
-
$title = $instance['title'];
|
47 |
-
$hide_title = $instance['hide-title'];
|
48 |
-
$type = $instance['type'];
|
49 |
-
$short_text = $instance['short_text'];
|
50 |
-
?>
|
51 |
-
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'qtranslate'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
|
52 |
-
<p><label for="<?php echo $this->get_field_id('hide-title'); ?>"><?php _e('Hide Title:', 'qtranslate'); ?> <input type="checkbox" id="<?php echo $this->get_field_id('hide-title'); ?>" name="<?php echo $this->get_field_name('hide-title'); ?>" <?php echo ($hide_title=='on')?'checked="checked"':''; ?>/></label></p>
|
53 |
-
<p><?php _e('Display:', 'qtranslate'); ?></p>
|
54 |
-
<p><label for="<?php echo $this->get_field_id('type'); ?>1"><input type="radio" name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>1" value="text"<?php echo ($type=='text')?' checked="checked"':'' ?>/> <?php _e('Text only', 'qtranslate'); ?></label></p>
|
55 |
-
<p><label for="<?php echo $this->get_field_id('type'); ?>2"><input type="radio" name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>2" value="image"<?php echo ($type=='image')?' checked="checked"':'' ?>/> <?php _e('Image only', 'qtranslate'); ?></label></p>
|
56 |
-
<p><label for="<?php echo $this->get_field_id('type'); ?>3"><input type="radio" name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>3" value="both"<?php echo ($type=='both')?' checked="checked"':'' ?>/> <?php _e('Text and Image', 'qtranslate'); ?></label></p>
|
57 |
-
<p><label for="<?php echo $this->get_field_id('type'); ?>4"><input type="radio" name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>4" value="dropdown"<?php echo ($type=='dropdown')?' checked="checked"':'' ?>/> <?php _e('Dropdown Box', 'qtranslate'); ?></label></p>
|
58 |
-
<p><label for="<?php echo $this->get_field_id('short_text'); ?>"><?php _e('Show short name (en):', 'qts'); ?> <input type="checkbox" id="<?php echo $this->get_field_id('short_text'); ?>" name="<?php echo $this->get_field_name('short_text'); ?>" <?php checked($short_text, 'on') ?>/></label></p>
|
59 |
-
<p><?php _e('Display:', 'qtranslate'); ?></p>
|
60 |
-
|
61 |
-
<?php
|
62 |
-
}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/includes/class-qtranslate-slug.php
DELETED
@@ -1,2378 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* QtranslateSlug class
|
5 |
-
*
|
6 |
-
* @since 1.0
|
7 |
-
*/
|
8 |
-
class QtranslateSlug {
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* array with old data system
|
13 |
-
*
|
14 |
-
* @var bool
|
15 |
-
*
|
16 |
-
* @since 1.0
|
17 |
-
*/
|
18 |
-
private $old_data = null;
|
19 |
-
|
20 |
-
|
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;
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Stores options slugs from database
|
35 |
-
*
|
36 |
-
* @var array
|
37 |
-
*
|
38 |
-
* @since 1.0
|
39 |
-
*/
|
40 |
-
protected $options;
|
41 |
-
|
42 |
-
|
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 |
-
|
55 |
-
/**
|
56 |
-
* slug in meta_key name in meta tables
|
57 |
-
*
|
58 |
-
* @var string
|
59 |
-
*
|
60 |
-
* @since 1.0
|
61 |
-
*/
|
62 |
-
private $meta_key = "_qts_slug_%s";
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Array of translated versions of the current url
|
68 |
-
*
|
69 |
-
* @var array
|
70 |
-
*
|
71 |
-
* @since 1.0
|
72 |
-
*/
|
73 |
-
private $current_url = array();
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
/**
|
78 |
-
* return the current / temp language
|
79 |
-
*
|
80 |
-
* @since 1.0
|
81 |
-
*/
|
82 |
-
private function get_lang() {
|
83 |
-
global $q_config;
|
84 |
-
|
85 |
-
return ($this->lang) ? $this->lang : $q_config['language'];
|
86 |
-
}
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
/**
|
91 |
-
* getter: options
|
92 |
-
*
|
93 |
-
* @since 1.0
|
94 |
-
*/
|
95 |
-
public function get_options() {
|
96 |
-
$this->set_options();
|
97 |
-
return $this->options;
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
/**
|
103 |
-
* setter: options | permalink_structure
|
104 |
-
*
|
105 |
-
* @since 1.0
|
106 |
-
*/
|
107 |
-
public function set_options() {
|
108 |
-
|
109 |
-
if (empty($this->options)) {
|
110 |
-
$this->options = get_option(QTS_OPTIONS_NAME);
|
111 |
-
}
|
112 |
-
|
113 |
-
if (!$this->options) {
|
114 |
-
add_option(QTS_OPTIONS_NAME, array());
|
115 |
-
}
|
116 |
-
|
117 |
-
if (is_null($this->permalink_structure)) {
|
118 |
-
$this->permalink_structure = get_option('permalink_structure');
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
/**
|
125 |
-
* setter: options | permalink_structure
|
126 |
-
*
|
127 |
-
* @since 1.0
|
128 |
-
*/
|
129 |
-
public function save_options($new_options = false) {
|
130 |
-
if (!$new_options || empty($new_options)) {
|
131 |
-
return;
|
132 |
-
}
|
133 |
-
|
134 |
-
if (count($this->options) != count($new_options)) {
|
135 |
-
return;
|
136 |
-
}
|
137 |
-
|
138 |
-
update_option(QTS_OPTIONS_NAME, $new_options);
|
139 |
-
$this->options = $new_options;
|
140 |
-
}
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
/**
|
145 |
-
* getter: meta key
|
146 |
-
*
|
147 |
-
* @since 1.0
|
148 |
-
*/
|
149 |
-
public function get_meta_key( $force_lang = false ) {
|
150 |
-
global $q_config;
|
151 |
-
|
152 |
-
$lang = $this->get_lang();
|
153 |
-
|
154 |
-
if ($force_lang) {
|
155 |
-
$lang = $force_lang;
|
156 |
-
}
|
157 |
-
|
158 |
-
return sprintf($this->meta_key, $lang); // returns: _qts_slug_en
|
159 |
-
}
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
/**
|
164 |
-
* check dependences for activation
|
165 |
-
*
|
166 |
-
* @since 1.0
|
167 |
-
*/
|
168 |
-
static function block_activate() {
|
169 |
-
global $wp_version;
|
170 |
-
|
171 |
-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
172 |
-
|
173 |
-
return ( version_compare($wp_version, "3.3", "<" ) || (!is_plugin_active('qtranslate/qtranslate.php') && !is_plugin_active('mqtranslate/mqtranslate.php')) );
|
174 |
-
}
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
/**
|
179 |
-
* check if exists qtranslate and do the installation, support multisite
|
180 |
-
*
|
181 |
-
* @since 1.0
|
182 |
-
*/
|
183 |
-
public function install() {
|
184 |
-
global $wpdb;
|
185 |
-
|
186 |
-
if ( self::block_activate() ) {
|
187 |
-
return;
|
188 |
-
}
|
189 |
-
|
190 |
-
if ( function_exists('is_multisite') && is_multisite() ) {
|
191 |
-
|
192 |
-
if (isset($_GET['networkwide']) && ($_GET['networkwide'] == 1)) {
|
193 |
-
|
194 |
-
$old_blog = $wpdb->blogid;
|
195 |
-
$blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs"));
|
196 |
-
foreach ($blogids as $blog_id) {
|
197 |
-
switch_to_blog($blog_id);
|
198 |
-
$this->activate();
|
199 |
-
}
|
200 |
-
switch_to_blog($old_blog);
|
201 |
-
return;
|
202 |
-
}
|
203 |
-
}
|
204 |
-
|
205 |
-
$this->activate();
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
/**
|
211 |
-
* activates and do the installation
|
212 |
-
*
|
213 |
-
* @since 1.0
|
214 |
-
*/
|
215 |
-
private function activate() {
|
216 |
-
global $wp_rewrite;
|
217 |
-
|
218 |
-
$this->set_options();
|
219 |
-
|
220 |
-
$qts_version = get_option('qts_version');
|
221 |
-
|
222 |
-
// checks version and do the installation
|
223 |
-
if ( !$qts_version || $qts_version != QTS_VERSION ) {
|
224 |
-
|
225 |
-
// install termmeta table using functions from Simple-Term-Meta
|
226 |
-
// ( http://wordpress.org/extend/plugins/simple-term-meta/ )
|
227 |
-
install_term_meta_table();
|
228 |
-
|
229 |
-
// update installed option
|
230 |
-
update_option('qts_version', QTS_VERSION);
|
231 |
-
}
|
232 |
-
|
233 |
-
// regenerate rewrite rules in db
|
234 |
-
add_action( 'generate_rewrite_rules', array(&$this, 'modify_rewrite_rules') );
|
235 |
-
flush_rewrite_rules();
|
236 |
-
}
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
/**
|
241 |
-
* register front end styles and enqueue
|
242 |
-
*
|
243 |
-
* @since 1.1.7
|
244 |
-
*/
|
245 |
-
public function register_plugin_styles() {
|
246 |
-
wp_register_style( 'qts_front_styles', plugins_url( '/assets/css/qts-default.css', dirname(__FILE__ ) ) );
|
247 |
-
wp_enqueue_style( 'qts_front_styles' );
|
248 |
-
}
|
249 |
-
/**
|
250 |
-
* register minified front end styles and enqueue
|
251 |
-
* 43LC: easier duplicating the function :|
|
252 |
-
* @since 1.1.8
|
253 |
-
*/
|
254 |
-
public function register_plugin_styles_min() {
|
255 |
-
wp_register_style( 'qts_front_styles', plugins_url( '/assets/css/qts-default.min.css', dirname(__FILE__ ) ) );
|
256 |
-
wp_enqueue_style( 'qts_front_styles' );
|
257 |
-
}
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
/**
|
262 |
-
* print front end styles
|
263 |
-
*
|
264 |
-
* @since 1.1.7
|
265 |
-
*/
|
266 |
-
public function print_plugin_styles() {
|
267 |
-
|
268 |
-
$css_path = dirname(__FILE__).'/assets/css/qts-default.css';
|
269 |
-
|
270 |
-
if (!file_exists($css_path) || !is_readable($css_path)) {
|
271 |
-
return;
|
272 |
-
}
|
273 |
-
|
274 |
-
$default_css_file = file_get_contents($css_path, FILE_USE_INCLUDE_PATH);
|
275 |
-
|
276 |
-
$css = "<style media=\"screen\">\n";
|
277 |
-
$css .= "$default_css_file\n";
|
278 |
-
$css .="</style>\n";
|
279 |
-
echo $css;
|
280 |
-
}
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
/**
|
285 |
-
* actions when deactivating the plugin
|
286 |
-
*
|
287 |
-
* @since 1.0
|
288 |
-
*/
|
289 |
-
public function deactivate() {
|
290 |
-
global $wp_rewrite;
|
291 |
-
|
292 |
-
// regenerate rewrite rules in db
|
293 |
-
remove_action( 'generate_rewrite_rules', array(&$this, 'modify_rewrite_rules') );
|
294 |
-
$wp_rewrite->flush_rules();
|
295 |
-
}
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
/**
|
300 |
-
* admin notice: update your old data
|
301 |
-
*
|
302 |
-
* @since 1.0
|
303 |
-
*/
|
304 |
-
function notice_update(){
|
305 |
-
global $current_screen;
|
306 |
-
|
307 |
-
if ($current_screen->id != 'settings_page_qtranslate-slug-settings') {
|
308 |
-
|
309 |
-
echo "<div class=\"updated\">" . PHP_EOL;
|
310 |
-
echo "<p><strong>Qtranslate Slug:</strong></p>" . PHP_EOL;
|
311 |
-
printf("<p>%s <a href=\"%s\" class=\"button\">%s</a></p>", __('Please update your old data to the new system.', 'qts'), add_query_arg(array('page' => 'qtranslate-slug-settings'), 'options-general.php'), __('upgrade now', 'qts')) . PHP_EOL;
|
312 |
-
echo "</div>" . PHP_EOL;
|
313 |
-
}
|
314 |
-
}
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
/**
|
319 |
-
* admin notice: update your old data
|
320 |
-
*
|
321 |
-
* @since 1.0
|
322 |
-
*/
|
323 |
-
function notice_dependences(){
|
324 |
-
global $current_screen;
|
325 |
-
|
326 |
-
echo "<div class=\"error\">" . PHP_EOL;
|
327 |
-
echo "<p><strong>Qtranslate Slug:</strong></p>" . PHP_EOL;
|
328 |
-
echo "<p>" . __('This plugin requires at least <strong>WordPress 3.3</strong> and either <strong>mqTranslate 2.6.2.4 (or newer)</strong> or <strong>qTranslate 2.5.8 (or newer)</strong>', 'qts') . "</p>" . PHP_EOL;
|
329 |
-
echo "</div>" . PHP_EOL;
|
330 |
-
}
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
/**
|
335 |
-
* checks if old table 'qtranslate_slug' exists and is not empty
|
336 |
-
*
|
337 |
-
* @return object | false
|
338 |
-
*
|
339 |
-
* @since 1.0
|
340 |
-
*/
|
341 |
-
public function check_old_data() {
|
342 |
-
global $wpdb;
|
343 |
-
|
344 |
-
if ($this->old_data === false) {
|
345 |
-
return false;
|
346 |
-
}
|
347 |
-
|
348 |
-
$table_name = $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}qtranslate_slug'");
|
349 |
-
|
350 |
-
if (!empty($table_name)) {
|
351 |
-
$this->old_data = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}qtranslate_slug");
|
352 |
-
}
|
353 |
-
|
354 |
-
if ( empty($table_name) || empty($this->old_data) ) {
|
355 |
-
$this->old_data = false;
|
356 |
-
}
|
357 |
-
|
358 |
-
return $this->old_data;
|
359 |
-
}
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
/**
|
364 |
-
* actions when deactivating the plugin
|
365 |
-
*
|
366 |
-
* @since 1.0
|
367 |
-
*/
|
368 |
-
private function check_old_versions() {
|
369 |
-
|
370 |
-
if ( $this->check_old_data() ) {
|
371 |
-
add_action('admin_notices', array(&$this, 'notice_update'));
|
372 |
-
}
|
373 |
-
}
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
/**
|
378 |
-
* Initialise the Class with all hooks
|
379 |
-
*
|
380 |
-
* @since 1.0
|
381 |
-
*/
|
382 |
-
function init() {
|
383 |
-
|
384 |
-
load_plugin_textdomain( 'qts', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
385 |
-
|
386 |
-
// checking plugin activate
|
387 |
-
if ( self::block_activate() ) {
|
388 |
-
if (is_admin()) {
|
389 |
-
add_action('admin_notices', array(&$this, 'notice_dependences'));
|
390 |
-
}
|
391 |
-
return;
|
392 |
-
}
|
393 |
-
|
394 |
-
// caching qts options
|
395 |
-
$this->set_options();
|
396 |
-
|
397 |
-
if ( is_admin() ) {
|
398 |
-
|
399 |
-
$this->check_old_versions();
|
400 |
-
|
401 |
-
// add filters
|
402 |
-
add_filter( 'qts_validate_post_slug', array(&$this, 'validate_post_slug'), 0, 3 );
|
403 |
-
add_filter( 'qts_validate_post_slug', array(&$this, 'unique_post_slug'), 1, 3 );
|
404 |
-
add_filter( 'qts_validate_term_slug', array(&$this, 'validate_term_slug'), 0, 3 );
|
405 |
-
add_filter( 'qts_validate_term_slug', array(&$this, 'unique_term_slug'), 1, 3 );
|
406 |
-
add_filter( 'wp_get_object_terms', array(&$this, 'get_object_terms'), 0, 4 );
|
407 |
-
add_filter( 'get_terms', array(&$this, 'get_terms'), 0, 3 );
|
408 |
-
|
409 |
-
// admin actions
|
410 |
-
add_action( 'admin_menu', array(&$this, 'add_slug_meta_box') );
|
411 |
-
add_action( 'save_post', array(&$this, 'save_postdata'), 605, 2 );
|
412 |
-
add_action( 'delete_term', array(&$this, 'delete_term'), 0, 3);
|
413 |
-
add_action( 'created_term', array(&$this, 'save_term'), 605, 3);
|
414 |
-
add_action( 'edited_term', array(&$this, 'save_term'), 605, 3 );
|
415 |
-
add_action( 'admin_head', array(&$this, 'hide_slug_box'), 900 );
|
416 |
-
|
417 |
-
add_action( 'init', array(&$this, 'taxonomies_hooks'), 805 );
|
418 |
-
|
419 |
-
add_action( 'wp_dashboard_setup', array(&$this, 'remove_dashboard_widgets') );
|
420 |
-
add_action( 'admin_head', array(&$this, 'hide_quick_edit'), 600 );
|
421 |
-
add_action( 'admin_init', array(&$this, 'fix_nav_menu') );
|
422 |
-
|
423 |
-
} else {
|
424 |
-
|
425 |
-
add_filter( 'request', array(&$this, 'filter_request') );
|
426 |
-
|
427 |
-
// adds external style file
|
428 |
-
$qts_options = $this->get_options();
|
429 |
-
if ( !isset($qts_options[QTS_PREFIX.'styles']) || $qts_options[QTS_PREFIX.'styles'] == "file" ) {
|
430 |
-
add_action( 'wp_enqueue_scripts', array( &$this, 'register_plugin_styles' ) );
|
431 |
-
} elseif ($qts_options[QTS_PREFIX.'styles'] == "minified" ) {
|
432 |
-
add_action( 'wp_enqueue_scripts', array( &$this, 'register_plugin_styles_min' ) );
|
433 |
-
} elseif ($qts_options[QTS_PREFIX.'styles'] == "inline" ) {
|
434 |
-
add_action( 'wp_print_styles', array( &$this, 'print_plugin_styles' ), 20 );
|
435 |
-
}
|
436 |
-
}
|
437 |
-
|
438 |
-
add_filter( 'query_vars', array(&$this, 'query_vars'));
|
439 |
-
add_action( 'generate_rewrite_rules', array(&$this, 'modify_rewrite_rules') );
|
440 |
-
|
441 |
-
// remove from qtranslate the discouraged meta http-equiv, inline styles
|
442 |
-
// (including flag URLs) and wrong hreflang links
|
443 |
-
remove_action('wp_head','qtrans_header');
|
444 |
-
// add proper hreflang links
|
445 |
-
add_action('wp_head',array(&$this, 'qtranslate_slug_header_extended'));
|
446 |
-
|
447 |
-
// remove some Qtranslate filters
|
448 |
-
remove_filter( 'page_link', 'qtrans_convertURL' );
|
449 |
-
remove_filter( 'post_link', 'qtrans_convertURL' );
|
450 |
-
remove_filter( 'category_link', 'qtrans_convertURL' );
|
451 |
-
remove_filter( 'tag_link', 'qtrans_convertURL' );
|
452 |
-
|
453 |
-
add_filter( 'qts_permastruct' , array(&$this, 'get_extra_permastruct'), 0, 2);
|
454 |
-
add_filter( 'qts_url_args', array(&$this, 'parse_url_args'), 0, 1);
|
455 |
-
add_filter( 'home_url', array(&$this, 'home_url'), 10, 4);
|
456 |
-
add_filter( 'post_type_link', array(&$this, 'post_type_link'), 600, 4 );
|
457 |
-
add_filter( 'post_link', array(&$this, 'post_link'), 0, 3 );
|
458 |
-
add_filter( '_get_page_link', array(&$this, '_get_page_link'), 0, 2 );
|
459 |
-
add_filter( 'term_link', array(&$this, 'term_link'), 600, 3 );
|
460 |
-
|
461 |
-
add_filter( 'single_term_title', 'qtrans_useTermLib', 805 );
|
462 |
-
add_filter( 'get_blogs_of_user', array(&$this, 'blog_names'), 1 );
|
463 |
-
add_action( 'widgets_init', array(&$this, 'widget_init'), 100 );
|
464 |
-
// Add specific CSS class to body class based on current lang
|
465 |
-
add_filter('body_class', array($this, 'qts_body_class'), 600, 1 );
|
466 |
-
}
|
467 |
-
|
468 |
-
|
469 |
-
/**
|
470 |
-
* Adds proper links to the content with available translations.
|
471 |
-
* Fixes issue #25
|
472 |
-
*
|
473 |
-
* @global $qtranslate_slug used to convert the url
|
474 |
-
* @global $q_config available languages
|
475 |
-
*
|
476 |
-
* @since 1.1.8
|
477 |
-
*/
|
478 |
-
public function qtranslate_slug_header_extended(){
|
479 |
-
global $qtranslate_slug;
|
480 |
-
global $q_config;
|
481 |
-
if(is_404()) return;
|
482 |
-
|
483 |
-
foreach($q_config['enabled_languages'] as $language) {
|
484 |
-
if($language != $q_config['language'] )
|
485 |
-
echo '<link hreflang="'.$language.'" href="'.$qtranslate_slug->get_current_url($language).'" rel="alternate" />'."\n";
|
486 |
-
}
|
487 |
-
}
|
488 |
-
|
489 |
-
|
490 |
-
/**
|
491 |
-
* Add a class based on the current language
|
492 |
-
* @param array $classes list of classes
|
493 |
-
*/
|
494 |
-
public function qts_body_class( $classes ) {
|
495 |
-
// add 'class-name' to the $classes array
|
496 |
-
$classes[] = qtrans_getLanguage();
|
497 |
-
|
498 |
-
// return the $classes array
|
499 |
-
return $classes;
|
500 |
-
}
|
501 |
-
|
502 |
-
/**
|
503 |
-
* Adds news rules to translate the URL bases,
|
504 |
-
* this function must be called on flush_rewrite or 'flush_rewrite_rules'
|
505 |
-
*
|
506 |
-
* @param object $wp_rewrite
|
507 |
-
*
|
508 |
-
* @since 1.0
|
509 |
-
*/
|
510 |
-
public function modify_rewrite_rules() {
|
511 |
-
global $wp_rewrite;
|
512 |
-
|
513 |
-
// post types rules
|
514 |
-
$post_types = get_post_types( array('_builtin' => false ), 'objects');
|
515 |
-
foreach ( $post_types as $post_type ) {
|
516 |
-
$this->generate_extra_rules( $post_type->name );
|
517 |
-
}
|
518 |
-
|
519 |
-
// taxonomies rules
|
520 |
-
$taxonomies = $this->get_public_taxonomies();
|
521 |
-
foreach ( $taxonomies as $taxonomy ) {
|
522 |
-
$this->generate_extra_rules( $taxonomy->name );
|
523 |
-
}
|
524 |
-
}
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
/**
|
529 |
-
* Helper: news rules to translate the URL bases
|
530 |
-
*
|
531 |
-
* @param string $name name of extra permastruct
|
532 |
-
* @param string $type 'post_type' or 'taxonomy'
|
533 |
-
*
|
534 |
-
* @since 1.0
|
535 |
-
*/
|
536 |
-
private function generate_extra_rules( $name = false ) {
|
537 |
-
global $wp_rewrite, $q_config;
|
538 |
-
|
539 |
-
foreach ($q_config['enabled_languages'] as $lang):
|
540 |
-
|
541 |
-
if ( $base = $this->get_base_slug( $name, $lang) ):
|
542 |
-
|
543 |
-
$struct = $wp_rewrite->extra_permastructs[$name];
|
544 |
-
|
545 |
-
if ( is_array( $struct ) ) {
|
546 |
-
if ( count( $struct ) == 2 )
|
547 |
-
$rules = $wp_rewrite->generate_rewrite_rules( "/$base/%$name%", $struct[1] );
|
548 |
-
else
|
549 |
-
$rules = $wp_rewrite->generate_rewrite_rules( "/$base/%$name%", $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] );
|
550 |
-
} else {
|
551 |
-
$rules = $wp_rewrite->generate_rewrite_rules( "/$base/%$name%" );
|
552 |
-
}
|
553 |
-
|
554 |
-
$wp_rewrite->rules = array_merge($rules, $wp_rewrite->rules);
|
555 |
-
|
556 |
-
endif;
|
557 |
-
|
558 |
-
endforeach;
|
559 |
-
}
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
/**
|
564 |
-
* Helper that gets a base slug stored in options
|
565 |
-
*
|
566 |
-
* @param string $name of extra permastruct
|
567 |
-
* @return string base slug for 'post_type' and 'language' or false
|
568 |
-
*
|
569 |
-
* @since 1.0
|
570 |
-
*/
|
571 |
-
public function get_base_slug($name = false, $lang = false) {
|
572 |
-
|
573 |
-
if ( !$name || !$lang ) {
|
574 |
-
return false;
|
575 |
-
}
|
576 |
-
|
577 |
-
if ( taxonomy_exists($name) ) {
|
578 |
-
$type = 'taxonomy';
|
579 |
-
} else if ( post_type_exists($name) ) {
|
580 |
-
$type = 'post_type';
|
581 |
-
} else {
|
582 |
-
return false;
|
583 |
-
}
|
584 |
-
|
585 |
-
$qts_options = $this->get_options();
|
586 |
-
|
587 |
-
$option_name = QTS_PREFIX . $type . '_' . $name;
|
588 |
-
|
589 |
-
if ( !isset($qts_options[$option_name]) || empty($qts_options[$option_name]) ) {
|
590 |
-
return false;
|
591 |
-
}
|
592 |
-
|
593 |
-
$option = $qts_options[$option_name][$lang];
|
594 |
-
|
595 |
-
if (isset($option)) {
|
596 |
-
return $option;
|
597 |
-
}
|
598 |
-
|
599 |
-
return false;
|
600 |
-
}
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
/**
|
605 |
-
* Helper: returns public built-in and not built-in taxonomies
|
606 |
-
*
|
607 |
-
* @return array of public taxonomies objects
|
608 |
-
*
|
609 |
-
* @since 1.0
|
610 |
-
*/
|
611 |
-
private function get_public_taxonomies() {
|
612 |
-
|
613 |
-
$builtin = get_taxonomies( array( 'public' => true, 'show_ui' => true, '_builtin' => true ), 'object');
|
614 |
-
$taxonomies = get_taxonomies( array( 'public' => true, 'show_ui' => true, '_builtin' => false ), 'object' );
|
615 |
-
|
616 |
-
return array_merge( $builtin, $taxonomies );
|
617 |
-
}
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
/**
|
622 |
-
* parse and adds $_GET args passed to an url
|
623 |
-
*
|
624 |
-
* @param string $url parameters
|
625 |
-
* @param string $lang processed
|
626 |
-
* @return string converted url
|
627 |
-
*
|
628 |
-
* @since 1.0
|
629 |
-
*/
|
630 |
-
public function parse_url_args( $url ) {
|
631 |
-
global $q_config;
|
632 |
-
|
633 |
-
if (is_admin()) {
|
634 |
-
return $url;
|
635 |
-
}
|
636 |
-
|
637 |
-
$url = preg_replace('/&/', '&', $url);
|
638 |
-
|
639 |
-
// if no permalink structure ads ?lang=en
|
640 |
-
$base_query = parse_url($q_config['url_info']['original_url']);
|
641 |
-
$base_args = isset($base_query['query']) ? wp_parse_args($base_query['query']) : array();
|
642 |
-
|
643 |
-
if ( empty($this->permalink_structure) || $q_config['url_mode'] == 1 ) {
|
644 |
-
$base_args['lang'] = $this->get_lang();
|
645 |
-
}
|
646 |
-
|
647 |
-
// rebuild query with all args
|
648 |
-
$url = add_query_arg($base_args, $url);
|
649 |
-
|
650 |
-
$url = str_replace('/?', '?', $url); // TODO: hack: improve this code
|
651 |
-
$url = str_replace('?', '/?', $url); // TODO: hack: improve this code
|
652 |
-
|
653 |
-
return $url;
|
654 |
-
}
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
/**
|
659 |
-
* Fix get_page_by_path when querying vars
|
660 |
-
*
|
661 |
-
* @param $query_vars objec query vars founded
|
662 |
-
* @return object $query_vars processed
|
663 |
-
*
|
664 |
-
* @since 1.0
|
665 |
-
*/
|
666 |
-
public function query_vars( $query_vars ) {
|
667 |
-
global $wp, $wp_rewrite;
|
668 |
-
|
669 |
-
$wp->query_vars = array();
|
670 |
-
$post_type_query_vars = array();
|
671 |
-
|
672 |
-
// Fetch the rewrite rules.
|
673 |
-
$rewrite = $wp_rewrite->wp_rewrite_rules();
|
674 |
-
|
675 |
-
if ( ! empty($rewrite) ) {
|
676 |
-
// If we match a rewrite rule, this will be cleared.
|
677 |
-
$error = '404';
|
678 |
-
$wp->did_permalink = true;
|
679 |
-
|
680 |
-
if ( isset($_SERVER['PATH_INFO']) ) {
|
681 |
-
$pathinfo = $_SERVER['PATH_INFO'];
|
682 |
-
} else {
|
683 |
-
$pathinfo = '';
|
684 |
-
}
|
685 |
-
$pathinfo_array = explode('?', $pathinfo);
|
686 |
-
$pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
|
687 |
-
$req_uri = $_SERVER['REQUEST_URI'];
|
688 |
-
$req_uri_array = explode('?', $req_uri);
|
689 |
-
$req_uri = $req_uri_array[0];
|
690 |
-
$self = $_SERVER['PHP_SELF'];
|
691 |
-
$home_path = parse_url(home_url());
|
692 |
-
|
693 |
-
if ( isset($home_path['path']) ) {
|
694 |
-
$home_path = $home_path['path'];
|
695 |
-
} else {
|
696 |
-
$home_path = '';
|
697 |
-
}
|
698 |
-
$home_path = trim($home_path, '/');
|
699 |
-
|
700 |
-
// Trim path info from the end and the leading home path from the
|
701 |
-
// front. For path info requests, this leaves us with the requesting
|
702 |
-
// filename, if any. For 404 requests, this leaves us with the
|
703 |
-
// requested permalink.
|
704 |
-
$req_uri = str_replace($pathinfo, '', $req_uri);
|
705 |
-
$req_uri = trim($req_uri, '/');
|
706 |
-
$req_uri = preg_replace("|^$home_path|", '', $req_uri);
|
707 |
-
$req_uri = trim($req_uri, '/');
|
708 |
-
if ($GLOBALS['q_config']['url_mode'] == QT_URL_PATH) {
|
709 |
-
$req_uri = preg_replace("/^{$GLOBALS['q_config']['language']}(\/|$)/", '', $req_uri);
|
710 |
-
}
|
711 |
-
$pathinfo = trim($pathinfo, '/');
|
712 |
-
$pathinfo = preg_replace("|^$home_path|", '', $pathinfo);
|
713 |
-
$pathinfo = trim($pathinfo, '/');
|
714 |
-
$self = trim($self, '/');
|
715 |
-
$self = preg_replace("|^$home_path|", '', $self);
|
716 |
-
$self = trim($self, '/');
|
717 |
-
|
718 |
-
// The requested permalink is in $pathinfo for path info requests and
|
719 |
-
// $req_uri for other requests.
|
720 |
-
if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) {
|
721 |
-
$request = $pathinfo;
|
722 |
-
} else {
|
723 |
-
// If the request uri is the index, blank it out so that
|
724 |
-
// we don't try to match it against a rule.
|
725 |
-
if ( $req_uri == $wp_rewrite->index )
|
726 |
-
$req_uri = '';
|
727 |
-
$request = $req_uri;
|
728 |
-
}
|
729 |
-
|
730 |
-
$wp->request = $request;
|
731 |
-
|
732 |
-
// Look for matches.
|
733 |
-
$request_match = $request;
|
734 |
-
if ( empty( $request_match ) ) {
|
735 |
-
// An empty request could only match against ^$ regex
|
736 |
-
if ( isset( $rewrite['$'] ) ) {
|
737 |
-
$wp->matched_rule = '$';
|
738 |
-
$query = $rewrite['$'];
|
739 |
-
$matches = array('');
|
740 |
-
}
|
741 |
-
} else if ( $req_uri != 'wp-app.php' ) {
|
742 |
-
foreach ( (array) $rewrite as $match => $query ) {
|
743 |
-
// If the requesting file is the anchor of the match, prepend it to the path info.
|
744 |
-
if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request ) {
|
745 |
-
$request_match = $req_uri . '/' . $request;
|
746 |
-
}
|
747 |
-
|
748 |
-
if ( preg_match("#^$match#", $request_match, $matches) || preg_match("#^$match#", urldecode($request_match), $matches) ) {
|
749 |
-
|
750 |
-
if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
|
751 |
-
// this is a verbose page match, lets check to be sure about it
|
752 |
-
if ( ! $page_foundid = $this->get_page_by_path( $matches[ $varmatch[1] ] ) ) {
|
753 |
-
continue;
|
754 |
-
} else {
|
755 |
-
wp_cache_set('qts_page_request', $page_foundid); // caching query :)
|
756 |
-
}
|
757 |
-
}
|
758 |
-
|
759 |
-
// Got a match.
|
760 |
-
$wp->matched_rule = $match;
|
761 |
-
break;
|
762 |
-
}
|
763 |
-
}
|
764 |
-
}
|
765 |
-
|
766 |
-
if ( isset( $wp->matched_rule ) ) {
|
767 |
-
// Trim the query of everything up to the '?'.
|
768 |
-
$query = preg_replace("!^.+\?!", '', $query);
|
769 |
-
|
770 |
-
// Substitute the substring matches into the query.
|
771 |
-
$query = addslashes(WP_MatchesMapRegex::apply($query, $matches));
|
772 |
-
|
773 |
-
$wp->matched_query = $query;
|
774 |
-
|
775 |
-
// Parse the query.
|
776 |
-
parse_str($query, $perma_query_vars);
|
777 |
-
|
778 |
-
// If we're processing a 404 request, clear the error var
|
779 |
-
// since we found something.
|
780 |
-
unset( $_GET['error'] );
|
781 |
-
unset( $error );
|
782 |
-
}
|
783 |
-
|
784 |
-
// If req_uri is empty or if it is a request for ourself, unset error.
|
785 |
-
if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) {
|
786 |
-
unset( $_GET['error'] );
|
787 |
-
unset( $error );
|
788 |
-
|
789 |
-
if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) {
|
790 |
-
unset( $perma_query_vars );
|
791 |
-
}
|
792 |
-
|
793 |
-
$wp->did_permalink = false;
|
794 |
-
}
|
795 |
-
}
|
796 |
-
|
797 |
-
return count(array_diff($query_vars, $wp->public_query_vars)) > 0 ? $query_vars : $wp->public_query_vars;
|
798 |
-
}
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
/**
|
803 |
-
* Function called when query parameters are processed by Wordpress.
|
804 |
-
*
|
805 |
-
* @param $query query parameters
|
806 |
-
* @return array() $query processed
|
807 |
-
*
|
808 |
-
* @since 1.0
|
809 |
-
*/
|
810 |
-
function filter_request( $query ) {
|
811 |
-
global $q_config, $wp_query, $wp;
|
812 |
-
|
813 |
-
if ((isset($wp->matched_query) || empty($query)) && ! isset($query['s']) ) {
|
814 |
-
$query = wp_parse_args($wp->matched_query);
|
815 |
-
}
|
816 |
-
|
817 |
-
foreach (get_post_types() as $post_type) {
|
818 |
-
if ( array_key_exists($post_type, $query) && !in_array($post_type, array('post', 'page')) ) {
|
819 |
-
$query['post_type'] = $post_type;
|
820 |
-
}
|
821 |
-
}
|
822 |
-
|
823 |
-
$page_foundit = false;
|
824 |
-
|
825 |
-
// -> page
|
826 |
-
if ( isset($query['pagename']) || isset($query['page_id']) ):
|
827 |
-
|
828 |
-
$page = wp_cache_get('qts_page_request');
|
829 |
-
if (!$page)
|
830 |
-
$page = isset($query['page_id']) ? get_post($query['page_id']) : $this->get_page_by_path($query['pagename']);
|
831 |
-
|
832 |
-
if (!$page) return $query;
|
833 |
-
$id = $page->ID;
|
834 |
-
$cache_array = array($page);
|
835 |
-
update_post_caches($cache_array, 'page'); // caching query :)
|
836 |
-
wp_cache_delete('qts_page_request');
|
837 |
-
$query['pagename'] = get_page_uri($page);
|
838 |
-
$function = 'get_page_link';
|
839 |
-
|
840 |
-
// -> custom post type
|
841 |
-
elseif ( isset($query['post_type']) ):
|
842 |
-
|
843 |
-
$page_slug = ( isset($query['name']) && !empty($query['name']) ) ? $query['name'] : $query[$query['post_type']];
|
844 |
-
$page = $this->get_page_by_path($page_slug, OBJECT, $query['post_type']);
|
845 |
-
if (!$page) return $query;
|
846 |
-
$id = $page->ID;
|
847 |
-
$cache_array = array($page);
|
848 |
-
update_post_caches($cache_array, $query['post_type']); // caching query :)
|
849 |
-
$query['name'] = $query[$query['post_type']] = get_page_uri($page);
|
850 |
-
$function = 'get_post_permalink';
|
851 |
-
|
852 |
-
// -> post
|
853 |
-
elseif ( isset($query['name']) || isset($query['p']) ):
|
854 |
-
|
855 |
-
$post = isset($query['p']) ? get_post($query['p']) : $this->get_page_by_path($query['name'], OBJECT, 'post');
|
856 |
-
if (!$post) {
|
857 |
-
return $query;
|
858 |
-
}
|
859 |
-
$query['name'] = $post->post_name;
|
860 |
-
$id = $post->ID;
|
861 |
-
$cache_array = array($post);
|
862 |
-
update_post_caches($cache_array);
|
863 |
-
$function = 'get_permalink';
|
864 |
-
|
865 |
-
// -> category
|
866 |
-
elseif ( ( isset($query['category_name']) || isset($query['cat'])) ):
|
867 |
-
if ( isset($query['category_name']) ) {
|
868 |
-
$term_slug = $this->get_last_slash( $query['category_name'] );
|
869 |
-
}
|
870 |
-
$term = isset($query['cat']) ? get_term($query['cat'], 'category') : $this->get_term_by('slug', $term_slug, 'category');
|
871 |
-
if (!$term) {
|
872 |
-
return $query;
|
873 |
-
}
|
874 |
-
$cache_array = array($term);
|
875 |
-
update_term_cache($cache_array, 'category'); // caching query :)
|
876 |
-
$id = $term->term_id;
|
877 |
-
$query['category_name'] = $term->slug; // uri
|
878 |
-
$function = 'get_category_link';
|
879 |
-
|
880 |
-
// -> tag
|
881 |
-
elseif ( isset($query['tag']) ):
|
882 |
-
|
883 |
-
$term = $this->get_term_by('slug', $query['tag'], 'post_tag');
|
884 |
-
if (!$term) {
|
885 |
-
return $query;
|
886 |
-
}
|
887 |
-
$cache_array = array($term);
|
888 |
-
update_term_cache($cache_array, 'post_tag'); // caching query :)
|
889 |
-
$id = $term->term_id;
|
890 |
-
$query['tag'] = $term->slug;
|
891 |
-
$function = 'get_tag_link';
|
892 |
-
|
893 |
-
endif;
|
894 |
-
|
895 |
-
|
896 |
-
// -> taxonomy
|
897 |
-
$taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) );
|
898 |
-
foreach ($taxonomies as $term_name):
|
899 |
-
if ( isset($query[$term_name]) ) {
|
900 |
-
|
901 |
-
$term_slug = $this->get_last_slash( $query[$term_name] );
|
902 |
-
$term = $this->get_term_by('slug', $term_slug, $term_name);
|
903 |
-
if (!$term) {
|
904 |
-
return $query;
|
905 |
-
}
|
906 |
-
$cache_array = array($term);
|
907 |
-
update_term_cache($cache_array, $term_name); // caching query :)
|
908 |
-
$id = $term;
|
909 |
-
$query[$term_name] = $term->slug;
|
910 |
-
$function = 'get_term_link';
|
911 |
-
|
912 |
-
}
|
913 |
-
endforeach;
|
914 |
-
|
915 |
-
// -> home url
|
916 |
-
if ( empty($query) ) {
|
917 |
-
|
918 |
-
$function = 'home_url';
|
919 |
-
$id = '';
|
920 |
-
|
921 |
-
}
|
922 |
-
|
923 |
-
// -> search
|
924 |
-
if (isset($query['s'])) {
|
925 |
-
|
926 |
-
$id = $query['s'];
|
927 |
-
$function="get_search_link";
|
928 |
-
|
929 |
-
}
|
930 |
-
|
931 |
-
if ( isset($function) ) {
|
932 |
-
|
933 |
-
// parse all languages links
|
934 |
-
foreach( $q_config['enabled_languages'] as $lang ) {
|
935 |
-
|
936 |
-
$this->lang = $lang;
|
937 |
-
$this->current_url[$lang] = apply_filters('qts_url_args', call_user_func($function, $id));
|
938 |
-
}
|
939 |
-
|
940 |
-
$this->lang = false;
|
941 |
-
}
|
942 |
-
|
943 |
-
return $query;
|
944 |
-
}
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
/**
|
949 |
-
* Parse a hierarquical name and extract the last one
|
950 |
-
*
|
951 |
-
* @param string $lang Page path
|
952 |
-
* @return string
|
953 |
-
*
|
954 |
-
* @since 1.0
|
955 |
-
*/
|
956 |
-
public function get_current_url( $lang = false ) {
|
957 |
-
global $q_config;
|
958 |
-
|
959 |
-
if (!$lang) {
|
960 |
-
$lang = $this->get_lang();
|
961 |
-
}
|
962 |
-
|
963 |
-
if (isset($this->current_url[$lang]) && !empty($this->current_url[$lang])) {
|
964 |
-
return $this->current_url[$lang];
|
965 |
-
}
|
966 |
-
|
967 |
-
return '';
|
968 |
-
}
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
/**
|
973 |
-
* Parse a hierarquical name and extract the last one
|
974 |
-
*
|
975 |
-
* @param string $slug Page path
|
976 |
-
* @return string
|
977 |
-
*
|
978 |
-
* @since 1.0
|
979 |
-
*/
|
980 |
-
private function get_last_slash($slug) {
|
981 |
-
|
982 |
-
$slug = rawurlencode( urldecode( $slug ) );
|
983 |
-
$slug = str_replace('%2F', '/', $slug);
|
984 |
-
$slug = str_replace('%20', ' ', $slug);
|
985 |
-
$exploded_slug = explode('/', $slug);
|
986 |
-
|
987 |
-
return array_pop( $exploded_slug );
|
988 |
-
}
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
/**
|
993 |
-
* Retrieves a page id given its path.
|
994 |
-
*
|
995 |
-
* @param string $page_path Page path
|
996 |
-
* @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
|
997 |
-
* @param string $post_type Optional. Post type. Default page.
|
998 |
-
* @return mixed Null when complete.
|
999 |
-
*
|
1000 |
-
* @since 1.0
|
1001 |
-
*/
|
1002 |
-
private function get_page_id_by_path($page_path, $output = OBJECT, $post_type = 'page') {
|
1003 |
-
global $wpdb;
|
1004 |
-
|
1005 |
-
$page_path = rawurlencode(urldecode($page_path));
|
1006 |
-
$page_path = str_replace('%2F', '/', $page_path);
|
1007 |
-
$page_path = str_replace('%20', ' ', $page_path);
|
1008 |
-
$parts = explode( '/', trim( $page_path, '/' ) );
|
1009 |
-
$parts = array_map( 'esc_sql', $parts );
|
1010 |
-
$parts = array_map( 'sanitize_title_for_query', $parts );
|
1011 |
-
$in_string = "'". implode( "','", $parts ) . "'";
|
1012 |
-
$meta_key = $this->get_meta_key();
|
1013 |
-
$post_type_sql = $post_type;
|
1014 |
-
$wpdb->escape_by_ref( $post_type_sql );
|
1015 |
-
|
1016 |
-
$pages = $wpdb->get_results( "SELECT $wpdb->posts.ID, $wpdb->posts.post_parent, $wpdb->postmeta.meta_value FROM $wpdb->posts,$wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value IN ($in_string) AND ($wpdb->posts.post_type = '$post_type_sql' OR $wpdb->posts.post_type = 'attachment')", OBJECT_K );
|
1017 |
-
|
1018 |
-
$revparts = array_reverse( $parts );
|
1019 |
-
|
1020 |
-
$foundid = 0;
|
1021 |
-
foreach ( (array) $pages as $page ) {
|
1022 |
-
if ( $page->meta_value == $revparts[0] ) {
|
1023 |
-
$count = 0;
|
1024 |
-
$p = $page;
|
1025 |
-
while ( $p->post_parent != 0 && isset( $pages[ $p->post_parent ] ) ) {
|
1026 |
-
$count++;
|
1027 |
-
$parent = $pages[ $p->post_parent ];
|
1028 |
-
if ( ! isset( $revparts[ $count ] ) || $parent->meta_value != $revparts[ $count ] ) {
|
1029 |
-
break;
|
1030 |
-
}
|
1031 |
-
$p = $parent;
|
1032 |
-
}
|
1033 |
-
|
1034 |
-
if ( $p->post_parent == 0 && $count+1 == count( $revparts ) && $p->meta_value == $revparts[ $count ] ) {
|
1035 |
-
$foundid = $page->ID;
|
1036 |
-
break;
|
1037 |
-
}
|
1038 |
-
}
|
1039 |
-
}
|
1040 |
-
|
1041 |
-
if ( $foundid ) {
|
1042 |
-
return $foundid;
|
1043 |
-
|
1044 |
-
} else {
|
1045 |
-
|
1046 |
-
$last_part = array_pop($parts);
|
1047 |
-
$page_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_name = '$last_part' AND (post_type = '$post_type_sql' OR post_type = 'attachment')" );
|
1048 |
-
|
1049 |
-
if ( $page_id ) {
|
1050 |
-
return $page_id;
|
1051 |
-
}
|
1052 |
-
}
|
1053 |
-
|
1054 |
-
return null;
|
1055 |
-
}
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
/**
|
1061 |
-
* Retrieves a page given its path.
|
1062 |
-
*
|
1063 |
-
* @param string $page_path Page path
|
1064 |
-
* @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
|
1065 |
-
* @param string $post_type Optional. Post type. Default page.
|
1066 |
-
* @return mixed Null when complete.
|
1067 |
-
*
|
1068 |
-
* @since 1.0
|
1069 |
-
*/
|
1070 |
-
private function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
|
1071 |
-
|
1072 |
-
$foundid = $this->get_page_id_by_path($page_path, $output, $post_type);
|
1073 |
-
if ( $foundid ) {
|
1074 |
-
return get_post( $foundid, $output );
|
1075 |
-
}
|
1076 |
-
|
1077 |
-
return null;
|
1078 |
-
}
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
/**
|
1083 |
-
* Ignores if the mod_rewrite func is the caller
|
1084 |
-
*
|
1085 |
-
* @return boolean
|
1086 |
-
*
|
1087 |
-
* @since 1.0
|
1088 |
-
*/
|
1089 |
-
private function ignore_rewrite_caller() {
|
1090 |
-
|
1091 |
-
$backtrace = debug_backtrace();
|
1092 |
-
|
1093 |
-
$ignore_functions = array('mod_rewrite_rules', 'save_mod_rewrite_rules', 'flush_rules', 'rewrite_rules', 'wp_rewrite_rules', 'query_vars');
|
1094 |
-
|
1095 |
-
if ( isset($backtrace['function']) ) {
|
1096 |
-
if (in_array($backtrace['function'], $ignore_functions)) {
|
1097 |
-
return true;
|
1098 |
-
}
|
1099 |
-
} else {
|
1100 |
-
foreach ($backtrace as $trace) {
|
1101 |
-
if ( isset($trace['function']) && in_array($trace['function'], $ignore_functions) ) {
|
1102 |
-
return true;
|
1103 |
-
}
|
1104 |
-
}
|
1105 |
-
}
|
1106 |
-
|
1107 |
-
return false;
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
|
1111 |
-
/**
|
1112 |
-
* Retrieve the home url for a given site.
|
1113 |
-
*
|
1114 |
-
* @param int $blog_id (optional) Blog ID. Defaults to current blog.
|
1115 |
-
* @param string $path (optional) Path relative to the home url.
|
1116 |
-
* @param string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https'.
|
1117 |
-
* @return string Home url link with optional path appended.
|
1118 |
-
*
|
1119 |
-
* @since 1.0
|
1120 |
-
*/
|
1121 |
-
public function home_url($url, $path, $scheme, $blog_id) {
|
1122 |
-
|
1123 |
-
if ( !in_array( $scheme, array( 'http', 'https' ) ) ) {
|
1124 |
-
$scheme = is_ssl() && !is_admin() ? 'https' : 'http';
|
1125 |
-
}
|
1126 |
-
|
1127 |
-
if ( empty( $blog_id ) || !is_multisite() ) {
|
1128 |
-
$url = get_option( 'home' );
|
1129 |
-
} else {
|
1130 |
-
$url = get_blog_option( $blog_id, 'home' );
|
1131 |
-
}
|
1132 |
-
|
1133 |
-
if ( 'http' != $scheme ) {
|
1134 |
-
$url = str_replace( 'http://', "$scheme://", $url );
|
1135 |
-
}
|
1136 |
-
|
1137 |
-
$ignore_caller = $this->ignore_rewrite_caller();
|
1138 |
-
|
1139 |
-
if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false ) {
|
1140 |
-
$url .= '/' . ltrim( $path, '/' );
|
1141 |
-
}
|
1142 |
-
|
1143 |
-
if ( !$ignore_caller ) {
|
1144 |
-
$url = qtrans_convertURL($url, $this->get_lang(), true);
|
1145 |
-
}
|
1146 |
-
|
1147 |
-
return $url;
|
1148 |
-
}
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
/**
|
1153 |
-
* Filter that changes the permastruct depending
|
1154 |
-
*
|
1155 |
-
* @param string $permastruct default permastruct given b wp_rewrite
|
1156 |
-
* @param string $name the name of the extra permastruct
|
1157 |
-
* @return string processed permastruct
|
1158 |
-
*
|
1159 |
-
* @since 1.0
|
1160 |
-
*/
|
1161 |
-
public function get_extra_permastruct( $permastruct = false, $name = false ) {
|
1162 |
-
|
1163 |
-
if ( !$name || !$permastruct ) {
|
1164 |
-
return '';
|
1165 |
-
}
|
1166 |
-
|
1167 |
-
if ( $base = $this->get_base_slug($name, $this->get_lang()) ) {
|
1168 |
-
return "/$base/%$name%";
|
1169 |
-
}
|
1170 |
-
|
1171 |
-
return $permastruct;
|
1172 |
-
}
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
/**
|
1177 |
-
* Filter that translates the slug parts in a page link
|
1178 |
-
*
|
1179 |
-
* @param $link the link for the page generated by Wordpress
|
1180 |
-
* @param $id the id of the page
|
1181 |
-
* @return the link translated
|
1182 |
-
*
|
1183 |
-
* @since 1.0
|
1184 |
-
*/
|
1185 |
-
public function post_type_link( $link, $post, $leavename, $sample ) {
|
1186 |
-
global $wp_rewrite;
|
1187 |
-
|
1188 |
-
if ( is_wp_error( $post ) ) {
|
1189 |
-
return $post;
|
1190 |
-
}
|
1191 |
-
|
1192 |
-
$post_link = apply_filters( 'qts_permastruct', $wp_rewrite->get_extra_permastruct($post->post_type), $post->post_type);
|
1193 |
-
|
1194 |
-
$slug = get_post_meta( $post->ID, $this->get_meta_key(), true );
|
1195 |
-
if (!$slug) {
|
1196 |
-
$slug = $post->post_name;
|
1197 |
-
}
|
1198 |
-
|
1199 |
-
$draft_or_pending = isset($post->post_status) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
|
1200 |
-
|
1201 |
-
$post_type = get_post_type_object($post->post_type);
|
1202 |
-
|
1203 |
-
if ( !empty($post_link) && ( !$draft_or_pending || $sample ) ) {
|
1204 |
-
if ( ! $leavename ) {
|
1205 |
-
if ( $post_type->hierarchical )
|
1206 |
-
$slug = $this->get_page_uri($post->ID);
|
1207 |
-
$post_link = str_replace("%$post->post_type%", $slug, $post_link);
|
1208 |
-
}
|
1209 |
-
|
1210 |
-
$post_link = home_url( user_trailingslashit($post_link) );
|
1211 |
-
|
1212 |
-
} else {
|
1213 |
-
|
1214 |
-
if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) ) {
|
1215 |
-
$post_link = add_query_arg($post_type->query_var, $slug, '');
|
1216 |
-
} else {
|
1217 |
-
$post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
|
1218 |
-
}
|
1219 |
-
|
1220 |
-
$post_link = home_url($post_link);
|
1221 |
-
}
|
1222 |
-
|
1223 |
-
return $post_link;
|
1224 |
-
}
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
/**
|
1229 |
-
* Filter that translates the slug in a post link
|
1230 |
-
*
|
1231 |
-
* @param $link the link generated by wordpress
|
1232 |
-
* @param $post the post data
|
1233 |
-
* @param $leavename parameter used by get_permalink. Whether to keep post name or page name.
|
1234 |
-
* @return the link translated
|
1235 |
-
*
|
1236 |
-
* @since 1.0
|
1237 |
-
*/
|
1238 |
-
public function post_link( $link, $post, $leavename ) {
|
1239 |
-
global $q_config;
|
1240 |
-
|
1241 |
-
$rewritecode = array(
|
1242 |
-
'%year%',
|
1243 |
-
'%monthnum%',
|
1244 |
-
'%day%',
|
1245 |
-
'%hour%',
|
1246 |
-
'%minute%',
|
1247 |
-
'%second%',
|
1248 |
-
$leavename? '' : '%postname%',
|
1249 |
-
'%post_id%',
|
1250 |
-
'%category%',
|
1251 |
-
'%author%',
|
1252 |
-
$leavename? '' : '%pagename%',
|
1253 |
-
);
|
1254 |
-
|
1255 |
-
if ( empty($post->ID) ) {
|
1256 |
-
return false;
|
1257 |
-
}
|
1258 |
-
|
1259 |
-
$permalink = $this->permalink_structure;
|
1260 |
-
|
1261 |
-
if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) {
|
1262 |
-
$unixtime = strtotime($post->post_date);
|
1263 |
-
|
1264 |
-
$category = '';
|
1265 |
-
if ( strpos($permalink, '%category%') !== false ) {
|
1266 |
-
$cats = get_the_category($post->ID);
|
1267 |
-
if ( $cats ) {
|
1268 |
-
usort($cats, '_usort_terms_by_ID'); // order by ID
|
1269 |
-
|
1270 |
-
$category = get_term_meta($cats[0]->term_id, $this->get_meta_key(), true );
|
1271 |
-
if (!$category) $category = $cats[0]->slug;
|
1272 |
-
|
1273 |
-
if ( $parent = $cats[0]->parent )
|
1274 |
-
$category = $this->get_category_parents($parent, false, '/', true) . $category;
|
1275 |
-
}
|
1276 |
-
// show default category in permalinks, without
|
1277 |
-
// having to assign it explicitly
|
1278 |
-
if ( empty($category) ) {
|
1279 |
-
$default_category = get_category( get_option( 'default_category' ) );
|
1280 |
-
|
1281 |
-
$default_category_slug = get_term_meta($default_category->term_id, $this->get_meta_key(), true );
|
1282 |
-
if (!$default_category_slug) $default_category_slug = $default_category->slug;
|
1283 |
-
|
1284 |
-
$category = is_wp_error( $default_category ) ? '' : $default_category_slug;
|
1285 |
-
}
|
1286 |
-
}
|
1287 |
-
|
1288 |
-
$author = '';
|
1289 |
-
if ( strpos($permalink, '%author%') !== false ) {
|
1290 |
-
$authordata = get_userdata($post->post_author);
|
1291 |
-
$author = $authordata->user_nicename;
|
1292 |
-
}
|
1293 |
-
|
1294 |
-
$date = explode(" ",date('Y m d H i s', $unixtime));
|
1295 |
-
|
1296 |
-
$post_slug = get_post_meta($post->ID, $this->get_meta_key(), true );
|
1297 |
-
if (!$post_slug) {
|
1298 |
-
$post_slug = $post->post_name;
|
1299 |
-
}
|
1300 |
-
|
1301 |
-
$rewritereplace =
|
1302 |
-
array(
|
1303 |
-
$date[0],
|
1304 |
-
$date[1],
|
1305 |
-
$date[2],
|
1306 |
-
$date[3],
|
1307 |
-
$date[4],
|
1308 |
-
$date[5],
|
1309 |
-
$post_slug,
|
1310 |
-
$post->ID,
|
1311 |
-
$category,
|
1312 |
-
$author,
|
1313 |
-
$post_slug,
|
1314 |
-
);
|
1315 |
-
$permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink));
|
1316 |
-
if ($q_config['url_mode'] != 1) {
|
1317 |
-
$permalink = user_trailingslashit($permalink, 'single');
|
1318 |
-
}
|
1319 |
-
} else { // if they're not using the fancy permalink option
|
1320 |
-
$permalink = home_url('?p=' . $post->ID);
|
1321 |
-
}
|
1322 |
-
|
1323 |
-
return $permalink;
|
1324 |
-
}
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
/**
|
1329 |
-
* Retrieve category parents with separator.
|
1330 |
-
*
|
1331 |
-
* @param int $id Category ID.
|
1332 |
-
* @param bool $link Optional, default is false. Whether to format with link.
|
1333 |
-
* @param string $separator Optional, default is '/'. How to separate categories.
|
1334 |
-
* @param bool $nicename Optional, default is false. Whether to use nice name for display.
|
1335 |
-
* @param array $visited Optional. Already linked to categories to prevent duplicates.
|
1336 |
-
* @return string
|
1337 |
-
*
|
1338 |
-
* @since 1.0
|
1339 |
-
*/
|
1340 |
-
private function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {
|
1341 |
-
|
1342 |
-
$chain = '';
|
1343 |
-
if(phpversion() >= 5.4) {
|
1344 |
-
$parent = get_category( $id );
|
1345 |
-
} else {
|
1346 |
-
$parent = &get_category( $id );
|
1347 |
-
}
|
1348 |
-
|
1349 |
-
if ( is_wp_error( $parent ) ) {
|
1350 |
-
return $parent;
|
1351 |
-
}
|
1352 |
-
|
1353 |
-
if ( $nicename ) {
|
1354 |
-
|
1355 |
-
$name = get_term_meta($parent->term_id, $this->get_meta_key(), true );
|
1356 |
-
if (!$name) {
|
1357 |
-
$name = $parent->slug;
|
1358 |
-
}
|
1359 |
-
} else {
|
1360 |
-
$name = $parent->name;
|
1361 |
-
}
|
1362 |
-
|
1363 |
-
if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) {
|
1364 |
-
$visited[] = $parent->parent;
|
1365 |
-
$chain .= $this->get_category_parents( $parent->parent, $link, $separator, $nicename, $visited );
|
1366 |
-
}
|
1367 |
-
|
1368 |
-
if ( $link ) {
|
1369 |
-
$chain .= '<a href="' . get_category_link( $parent->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $parent->name ) ) . '">'.$name.'</a>' . $separator;
|
1370 |
-
} else {
|
1371 |
-
$chain .= $name.$separator;
|
1372 |
-
}
|
1373 |
-
|
1374 |
-
return $chain;
|
1375 |
-
}
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
/**
|
1382 |
-
* Filter that translates the slug parts in a page link
|
1383 |
-
*
|
1384 |
-
* @param $link the link for the page generated by Wordpress
|
1385 |
-
* @param $id the id of the page
|
1386 |
-
* @return the link translated
|
1387 |
-
*
|
1388 |
-
* @since 1.0
|
1389 |
-
*/
|
1390 |
-
public function _get_page_link( $link, $id ) {
|
1391 |
-
global $post, $wp_rewrite, $q_config;
|
1392 |
-
|
1393 |
-
$current_post = $post;
|
1394 |
-
|
1395 |
-
if ( !$id ) {
|
1396 |
-
$id = (int) $post->ID;
|
1397 |
-
} else {
|
1398 |
-
if(phpversion() >= 5.4) {
|
1399 |
-
$current_post = get_post($id);
|
1400 |
-
} else {
|
1401 |
-
$current_post = &get_post($id);
|
1402 |
-
}
|
1403 |
-
}
|
1404 |
-
|
1405 |
-
$draft_or_pending = in_array( $current_post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
|
1406 |
-
|
1407 |
-
$link = $wp_rewrite->get_page_permastruct();
|
1408 |
-
|
1409 |
-
if ( !empty($link) && ( isset($current_post->post_status) && !$draft_or_pending ) ) {
|
1410 |
-
|
1411 |
-
$link = str_replace('%pagename%', $this->get_page_uri($id), $link);
|
1412 |
-
|
1413 |
-
$link = trim($link, '/'); // hack
|
1414 |
-
$link = home_url("/$link/"); // hack
|
1415 |
-
|
1416 |
-
if ($q_config['url_mode'] != 1)
|
1417 |
-
$link = user_trailingslashit($link, 'page');
|
1418 |
-
|
1419 |
-
} else {
|
1420 |
-
|
1421 |
-
$link = home_url("?page_id=$id");
|
1422 |
-
}
|
1423 |
-
|
1424 |
-
return $link;
|
1425 |
-
}
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
/**
|
1430 |
-
* Builds URI for a page.
|
1431 |
-
*
|
1432 |
-
* Sub pages will be in the "directory" under the parent page post name.
|
1433 |
-
*
|
1434 |
-
* @param mixed $page Page object or page ID.
|
1435 |
-
* @return string Page URI.
|
1436 |
-
*
|
1437 |
-
* @since 1.0
|
1438 |
-
*/
|
1439 |
-
private function get_page_uri($page) {
|
1440 |
-
|
1441 |
-
if ( ! is_object($page) ) {
|
1442 |
-
$page = get_post($page);
|
1443 |
-
}
|
1444 |
-
|
1445 |
-
$uri = get_post_meta( $page->ID, $this->get_meta_key(), true );
|
1446 |
-
if (!$uri) {
|
1447 |
-
$uri = $page->post_name;
|
1448 |
-
}
|
1449 |
-
|
1450 |
-
// A page cannot be it's own parent.
|
1451 |
-
if ( $page->post_parent == $page->ID ) {
|
1452 |
-
return $uri;
|
1453 |
-
}
|
1454 |
-
|
1455 |
-
while ($page->post_parent != 0) {
|
1456 |
-
$page = get_post($page->post_parent);
|
1457 |
-
|
1458 |
-
$page_name = get_post_meta( $page->ID, $this->get_meta_key(), true );
|
1459 |
-
if (!$page_name) {
|
1460 |
-
$page_name = $page->post_name;
|
1461 |
-
}
|
1462 |
-
|
1463 |
-
$uri = $page_name . "/" . $uri;
|
1464 |
-
}
|
1465 |
-
|
1466 |
-
return $uri;
|
1467 |
-
}
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
/**
|
1472 |
-
* Filter that translates the slug parts in a term link
|
1473 |
-
*
|
1474 |
-
* @param $link the link for the page generated by Wordpress
|
1475 |
-
* @param $term object
|
1476 |
-
* @param $taxonomy object
|
1477 |
-
* @return the link translated
|
1478 |
-
*
|
1479 |
-
* @since 1.0
|
1480 |
-
*/
|
1481 |
-
public function term_link( $link, $term, $taxonomy ) {
|
1482 |
-
global $wp_rewrite;
|
1483 |
-
|
1484 |
-
// parse normal term names for ?tag=tagname
|
1485 |
-
if (empty($this->permalink_structure)) return $link;
|
1486 |
-
|
1487 |
-
if ( !is_object($term) ) {
|
1488 |
-
if ( is_int($term) ) {
|
1489 |
-
$term = &get_term($term, $taxonomy);
|
1490 |
-
} else {
|
1491 |
-
$term = $this->get_term_by('slug', $term, $taxonomy);
|
1492 |
-
}
|
1493 |
-
}
|
1494 |
-
|
1495 |
-
if ( !is_object($term) ) {
|
1496 |
-
$term = new WP_Error('invalid_term', __('Empty Term'));
|
1497 |
-
}
|
1498 |
-
|
1499 |
-
if ( is_wp_error( $term ) ) {
|
1500 |
-
return $term;
|
1501 |
-
}
|
1502 |
-
|
1503 |
-
$taxonomy = $term->taxonomy;
|
1504 |
-
|
1505 |
-
$termlink = apply_filters( 'qts_permastruct', $wp_rewrite->get_extra_permastruct($taxonomy), $taxonomy);
|
1506 |
-
|
1507 |
-
$slug = get_term_meta( $term->term_id, $this->get_meta_key(), true );
|
1508 |
-
if (!$slug) {
|
1509 |
-
$slug = $term->slug;
|
1510 |
-
}
|
1511 |
-
|
1512 |
-
$t = get_taxonomy($taxonomy);
|
1513 |
-
|
1514 |
-
if ( empty($termlink) ) {
|
1515 |
-
if ( 'category' == $taxonomy )
|
1516 |
-
$termlink = '?cat=' . $term->term_id;
|
1517 |
-
elseif ( $t->query_var )
|
1518 |
-
$termlink = "?$t->query_var=$slug";
|
1519 |
-
else
|
1520 |
-
$termlink = "?taxonomy=$taxonomy&term=$slug";
|
1521 |
-
$termlink = home_url($termlink);
|
1522 |
-
} else {
|
1523 |
-
if ( $t->rewrite['hierarchical'] ) {
|
1524 |
-
$hierarchical_slugs = array();
|
1525 |
-
$ancestors = get_ancestors($term->term_id, $taxonomy);
|
1526 |
-
foreach ( (array)$ancestors as $ancestor ) {
|
1527 |
-
$ancestor_term = get_term($ancestor, $taxonomy);
|
1528 |
-
|
1529 |
-
$ancestor_slug = get_term_meta( $ancestor_term->term_id, $this->get_meta_key(), true );
|
1530 |
-
if (!$ancestor_slug) $ancestor_slug = $ancestor_term->slug;
|
1531 |
-
|
1532 |
-
$hierarchical_slugs[] = $ancestor_slug;
|
1533 |
-
}
|
1534 |
-
$hierarchical_slugs = array_reverse($hierarchical_slugs);
|
1535 |
-
$hierarchical_slugs[] = $slug;
|
1536 |
-
$termlink = str_replace("%$taxonomy%", implode('/', $hierarchical_slugs), $termlink);
|
1537 |
-
} else {
|
1538 |
-
$termlink = str_replace("%$taxonomy%", $slug, $termlink);
|
1539 |
-
}
|
1540 |
-
$termlink = home_url( user_trailingslashit($termlink, 'category') );
|
1541 |
-
}
|
1542 |
-
return $termlink;
|
1543 |
-
}
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
/**
|
1548 |
-
* Get all Term data from database by Term field and data.
|
1549 |
-
*
|
1550 |
-
* @param (string) $field Either 'slug', 'name', or 'id'
|
1551 |
-
* @param (string|int) $value Search for this term value
|
1552 |
-
* @param (string) $taxonomy Taxonomy Name
|
1553 |
-
* @param (string) $output Constant OBJECT, ARRAY_A, or ARRAY_N
|
1554 |
-
* @param (string) $filter Optional, default is raw or no WordPress defined filter will applied.
|
1555 |
-
* @return (mixed) Term Row from database. Will return false if $taxonomy does not exist or $term was not found.
|
1556 |
-
*
|
1557 |
-
* @since 1.0
|
1558 |
-
*/
|
1559 |
-
private function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw') {
|
1560 |
-
global $wpdb;
|
1561 |
-
|
1562 |
-
$original_field = $field;
|
1563 |
-
|
1564 |
-
if ( ! taxonomy_exists($taxonomy) ) {
|
1565 |
-
return false;
|
1566 |
-
}
|
1567 |
-
|
1568 |
-
if ( 'slug' == $field ) {
|
1569 |
-
$field = 'm.meta_key = \''.$this->get_meta_key().'\' AND m.meta_value';
|
1570 |
-
$value = sanitize_title($value);
|
1571 |
-
if ( empty($value) )
|
1572 |
-
return false;
|
1573 |
-
} else if ( 'name' == $field ) {
|
1574 |
-
// Assume already escaped
|
1575 |
-
$value = stripslashes($value);
|
1576 |
-
$field = 't.name';
|
1577 |
-
} else {
|
1578 |
-
$term = get_term( (int) $value, $taxonomy, $output, $filter);
|
1579 |
-
if ( is_wp_error( $term ) )
|
1580 |
-
$term = false;
|
1581 |
-
return $term;
|
1582 |
-
}
|
1583 |
-
|
1584 |
-
$term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t, $wpdb->term_taxonomy AS tt, $wpdb->termmeta AS m WHERE t.term_id = tt.term_id AND tt.term_id = m.term_id AND tt.taxonomy = %s AND $field = %s LIMIT 1", $taxonomy, $value) );
|
1585 |
-
|
1586 |
-
if ( !$term && 'slug' == $original_field ) {
|
1587 |
-
$field = 't.slug';
|
1588 |
-
$term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND $field = %s LIMIT 1", $taxonomy, $value) );
|
1589 |
-
}
|
1590 |
-
|
1591 |
-
if ( !$term ) {
|
1592 |
-
return false;
|
1593 |
-
}
|
1594 |
-
|
1595 |
-
wp_cache_add($term->term_id, $term, $taxonomy);
|
1596 |
-
|
1597 |
-
$term = apply_filters('get_term', $term, $taxonomy);
|
1598 |
-
$term = apply_filters("get_$taxonomy", $term, $taxonomy);
|
1599 |
-
$term = sanitize_term($term, $taxonomy, $filter);
|
1600 |
-
|
1601 |
-
if ( $output == OBJECT ) {
|
1602 |
-
return $term;
|
1603 |
-
} elseif ( $output == ARRAY_A ) {
|
1604 |
-
return get_object_vars($term);
|
1605 |
-
} elseif ( $output == ARRAY_N ) {
|
1606 |
-
return array_values(get_object_vars($term));
|
1607 |
-
} else {
|
1608 |
-
return $term;
|
1609 |
-
}
|
1610 |
-
}
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
/**
|
1615 |
-
* Fix for:
|
1616 |
-
* - Taxonomy names in Taxonomy Manage page
|
1617 |
-
* - 'Popular Tags' in Taxonomy (Tags) Manage page
|
1618 |
-
* - Category filter dropdown menu in Post Manage page
|
1619 |
-
* - Category list in Post Edit page
|
1620 |
-
* - 'Most Used' tags list in Post Edit page (but have issues when saving)
|
1621 |
-
*
|
1622 |
-
* @param (array) $terms
|
1623 |
-
* @param (string|array) $taxonomy
|
1624 |
-
* @since 1.2
|
1625 |
-
*/
|
1626 |
-
function get_terms($terms, $taxonomy) {
|
1627 |
-
|
1628 |
-
global $pagenow;
|
1629 |
-
|
1630 |
-
// Although in post edit page the tags in 'most
|
1631 |
-
// used' list are translated, but when saving the
|
1632 |
-
// post Wordpress considers the translated tags as
|
1633 |
-
// new tags. Due to this issue I skip this 'hack'
|
1634 |
-
// for tags in post edit page.
|
1635 |
-
if ( $pagenow != 'admin-ajax.php' ) {
|
1636 |
-
|
1637 |
-
$meta = get_option('qtranslate_term_name');
|
1638 |
-
$lang = qtrans_getLanguage();
|
1639 |
-
|
1640 |
-
if ( !empty( $terms ) ) {
|
1641 |
-
foreach ($terms as $term) {
|
1642 |
-
if( isset( $meta[$term->name][$lang] ) ) {
|
1643 |
-
$term->name = $meta[$term->name][$lang];
|
1644 |
-
}
|
1645 |
-
};
|
1646 |
-
};
|
1647 |
-
}
|
1648 |
-
|
1649 |
-
return $terms;
|
1650 |
-
}
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
/**
|
1655 |
-
* Fix for:
|
1656 |
-
* - Taxonomy & custom taxonomy names in Post Manage page
|
1657 |
-
* - List of tags already added to the post in Post
|
1658 |
-
* - Edit page (but have issues when saving)
|
1659 |
-
*
|
1660 |
-
* @param (array) $terms
|
1661 |
-
* @param (int|array) $obj_id
|
1662 |
-
* @param (string|array) $taxonomy
|
1663 |
-
* @param (array) $taxonomy
|
1664 |
-
* @since 1.2
|
1665 |
-
*/
|
1666 |
-
function get_object_terms($terms, $obj_id, $taxonomy, $args) {
|
1667 |
-
|
1668 |
-
global $pagenow;
|
1669 |
-
|
1670 |
-
// Although in post edit page the tags are translated,
|
1671 |
-
// but when saving/updating the post Wordpress considers
|
1672 |
-
// the translated tags as new tags. Due to this
|
1673 |
-
// issue I limit this 'hack' to the post manage
|
1674 |
-
// page only.
|
1675 |
-
if ( $pagenow == 'edit.php' ) {
|
1676 |
-
|
1677 |
-
// $taxonomy output seems to be wrapped
|
1678 |
-
// in single quotes, thus remove them to
|
1679 |
-
// make the output valid
|
1680 |
-
$tax = str_replace("'", "", $taxonomy);
|
1681 |
-
|
1682 |
-
$meta = get_option('qtranslate_term_name');
|
1683 |
-
$lang = qtrans_getLanguage();
|
1684 |
-
|
1685 |
-
if ( !empty( $terms ) ) {
|
1686 |
-
foreach ($terms as $term) {
|
1687 |
-
if( isset( $meta[$term->name][$lang] ) ) {
|
1688 |
-
$term->name = $meta[$term->name][$lang];
|
1689 |
-
}
|
1690 |
-
};
|
1691 |
-
};
|
1692 |
-
|
1693 |
-
}
|
1694 |
-
return $terms;
|
1695 |
-
}
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
/**
|
1700 |
-
* hide quickedit button ( functionality not supported by qTranslate )
|
1701 |
-
*
|
1702 |
-
* @since 1.0
|
1703 |
-
*/
|
1704 |
-
public function hide_quick_edit() {
|
1705 |
-
echo "<!-- QTS remove quick edit box -->" . PHP_EOL;
|
1706 |
-
echo "<style type=\"text/css\" media=\"screen\">" . PHP_EOL;
|
1707 |
-
echo " .row-actions .inline.inline.hide-if-no-js { display: none !important }" . PHP_EOL;
|
1708 |
-
echo "</style>" . PHP_EOL;
|
1709 |
-
}
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
/**
|
1714 |
-
* Hide auttomatically the wordpress slug blog in edit posts page
|
1715 |
-
*
|
1716 |
-
* @since 1.0
|
1717 |
-
*/
|
1718 |
-
public function hide_slug_box() {
|
1719 |
-
global $pagenow;
|
1720 |
-
|
1721 |
-
switch ( $pagenow ):
|
1722 |
-
case 'edit-tags.php':
|
1723 |
-
|
1724 |
-
echo "<!-- QTS remove slug box -->" . PHP_EOL;
|
1725 |
-
echo "<script type=\"text/javascript\" charset=\"utf-8\">" . PHP_EOL;
|
1726 |
-
echo " jQuery(document).ready(function($){" . PHP_EOL;
|
1727 |
-
echo " $(\"#tag-slug\").parent().hide();" . PHP_EOL;
|
1728 |
-
echo " $(\".form-field td #slug\").parent().parent().hide();" . PHP_EOL;
|
1729 |
-
echo " });" . PHP_EOL;
|
1730 |
-
echo "</script>" . PHP_EOL;
|
1731 |
-
break;
|
1732 |
-
|
1733 |
-
case 'post.php':
|
1734 |
-
|
1735 |
-
echo "<!-- QTS remove slug box -->" . PHP_EOL;
|
1736 |
-
echo "<style type=\"text/css\" media=\"screen\">" . PHP_EOL;
|
1737 |
-
echo " #edit-slug-box { display: none !important}" . PHP_EOL;
|
1738 |
-
echo "</style>" . PHP_EOL;
|
1739 |
-
break;
|
1740 |
-
endswitch;
|
1741 |
-
}
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
/**
|
1746 |
-
* Creates a metabox for every post, page and post type avaiable
|
1747 |
-
*
|
1748 |
-
* @since 1.0
|
1749 |
-
*/
|
1750 |
-
public function add_slug_meta_box() {
|
1751 |
-
|
1752 |
-
if ( function_exists( 'add_meta_box' ) ) {
|
1753 |
-
|
1754 |
-
add_meta_box( 'qts_sectionid', __('Slug', 'qts'), array(&$this, 'draw_meta_box'), 'post', 'side', 'high');
|
1755 |
-
add_meta_box( 'qts_sectionid', __('Slug', 'qts'), array(&$this, 'draw_meta_box'), 'page', 'side', 'high' );
|
1756 |
-
|
1757 |
-
foreach ( get_post_types( array('_builtin' => false ) ) as $ptype )
|
1758 |
-
add_meta_box( 'qts_sectionid', __('Slug', 'qts'), array(&$this, 'draw_meta_box'), $ptype, 'side', 'high' );
|
1759 |
-
}
|
1760 |
-
}
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
/**
|
1765 |
-
* Shows the fields where insert the translated slugs in the post and page edit form.
|
1766 |
-
*
|
1767 |
-
* @param $post (object) current post object
|
1768 |
-
*
|
1769 |
-
* @since 1.0
|
1770 |
-
*/
|
1771 |
-
public function draw_meta_box( $post ) {
|
1772 |
-
global $q_config;
|
1773 |
-
|
1774 |
-
// Use nonce for verification
|
1775 |
-
echo "<table style=\"width:100%\">" . PHP_EOL;
|
1776 |
-
echo "<input type=\"hidden\" name=\"qts_nonce\" id=\"qts_nonce\" value=\"" . wp_create_nonce( 'qts_nonce' ) . "\" />" . PHP_EOL;
|
1777 |
-
|
1778 |
-
foreach ($q_config['enabled_languages'] as $lang):
|
1779 |
-
|
1780 |
-
$slug = get_post_meta( $post->ID, $this->get_meta_key($lang), true);
|
1781 |
-
|
1782 |
-
$value = ( $slug ) ? htmlspecialchars( $slug , ENT_QUOTES ) : '';
|
1783 |
-
|
1784 |
-
echo "<tr>" . PHP_EOL;
|
1785 |
-
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;
|
1786 |
-
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;
|
1787 |
-
echo "</tr>" . PHP_EOL;
|
1788 |
-
|
1789 |
-
endforeach;
|
1790 |
-
|
1791 |
-
echo '</table>' . PHP_EOL;
|
1792 |
-
}
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
/**
|
1797 |
-
* Sanitize title as slug, if empty slug
|
1798 |
-
*
|
1799 |
-
* @param $post (object) the post object
|
1800 |
-
* @param $slug (string) the slug name
|
1801 |
-
* @param $lang (string) the language
|
1802 |
-
* @return the slug validated
|
1803 |
-
*
|
1804 |
-
* @since 1.0
|
1805 |
-
*/
|
1806 |
-
public function validate_post_slug( $slug, $post, $lang ) {
|
1807 |
-
|
1808 |
-
$post_title = trim(qtrans_use($lang, $_POST['post_title']));
|
1809 |
-
$post_name = get_post_meta($post->ID, $this->get_meta_key($lang), true);
|
1810 |
-
if (!$post_name) {
|
1811 |
-
$post_name = $post->post_name;
|
1812 |
-
}
|
1813 |
-
|
1814 |
-
$name = ( $post_title == '' || strlen($post_title) == 0 ) ? $post_name : $post_title;
|
1815 |
-
|
1816 |
-
$slug = trim($slug);
|
1817 |
-
|
1818 |
-
$slug = (empty($slug)) ? sanitize_title($name) : sanitize_title($slug);
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
return htmlspecialchars( $slug , ENT_QUOTES );
|
1823 |
-
}
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
/**
|
1828 |
-
* Validates post slug against repetitions per language
|
1829 |
-
*
|
1830 |
-
* @param $post (object) the post object
|
1831 |
-
* @param $slug (string) the slug name
|
1832 |
-
* @param $lang (string) the language
|
1833 |
-
* @return the slug validated
|
1834 |
-
*
|
1835 |
-
* @since 1.0
|
1836 |
-
*/
|
1837 |
-
public function unique_post_slug( $slug, $post, $lang ) {
|
1838 |
-
|
1839 |
-
$original_status = $post->post_status;
|
1840 |
-
|
1841 |
-
if ( in_array($post->post_status, array('draft', 'pending')) ) {
|
1842 |
-
$post->post_status = 'publish';
|
1843 |
-
}
|
1844 |
-
|
1845 |
-
$slug = $this->wp_unique_post_slug( $slug, $post->ID, $post->post_status, $post->post_type, $post->post_parent, $lang );
|
1846 |
-
|
1847 |
-
$post->post_status = $original_status;
|
1848 |
-
|
1849 |
-
return $slug;
|
1850 |
-
}
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
/**
|
1855 |
-
* Computes a unique slug for the post and language, when given the desired slug and some post details.
|
1856 |
-
*
|
1857 |
-
* @param string $slug the desired slug (post_name)
|
1858 |
-
* @param integer $post_ID
|
1859 |
-
* @param string $post_status no uniqueness checks are made if the post is still draft or pending
|
1860 |
-
* @param string $post_type
|
1861 |
-
* @param integer $post_parent
|
1862 |
-
* @return string unique slug for the post, based on language meta_value (with a -1, -2, etc. suffix)
|
1863 |
-
*
|
1864 |
-
* @since 1.0
|
1865 |
-
*/
|
1866 |
-
public function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $lang ) {
|
1867 |
-
if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
|
1868 |
-
return $slug;
|
1869 |
-
}
|
1870 |
-
|
1871 |
-
global $wpdb, $wp_rewrite;
|
1872 |
-
|
1873 |
-
$feeds = $wp_rewrite->feeds;
|
1874 |
-
if ( ! is_array( $feeds ) ) {
|
1875 |
-
$feeds = array();
|
1876 |
-
}
|
1877 |
-
|
1878 |
-
$meta_key = $this->get_meta_key($lang);
|
1879 |
-
if ( 'attachment' == $post_type ) {
|
1880 |
-
// Attachment slugs must be unique across all types.
|
1881 |
-
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
|
1882 |
-
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
|
1883 |
-
|
1884 |
-
if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
|
1885 |
-
$suffix = 2;
|
1886 |
-
do {
|
1887 |
-
$alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
|
1888 |
-
$post_name_check = $wpdb->get_var( $wpdb->prepare($check_sql, $alt_post_name, $post_ID ) );
|
1889 |
-
$suffix++;
|
1890 |
-
} while ( $post_name_check );
|
1891 |
-
$slug = $alt_post_name;
|
1892 |
-
}
|
1893 |
-
} else {
|
1894 |
-
// Post slugs must be unique across all posts.
|
1895 |
-
$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";
|
1896 |
-
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $meta_key, $slug, $post_type, $post_ID ) );
|
1897 |
-
|
1898 |
-
if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) {
|
1899 |
-
$suffix = 2;
|
1900 |
-
do {
|
1901 |
-
$alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
|
1902 |
-
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $meta_key, $alt_post_name, $post_type, $post_ID ) );
|
1903 |
-
$suffix++;
|
1904 |
-
} while ( $post_name_check );
|
1905 |
-
$slug = $alt_post_name;
|
1906 |
-
}
|
1907 |
-
}
|
1908 |
-
|
1909 |
-
return $slug;
|
1910 |
-
}
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
/**
|
1916 |
-
* Saves the translated slug when the page is saved
|
1917 |
-
*
|
1918 |
-
* @param $post_id the post id
|
1919 |
-
* @param $post the post object
|
1920 |
-
*
|
1921 |
-
* @since 1.0
|
1922 |
-
*/
|
1923 |
-
public function save_postdata( $post_id, $post ) {
|
1924 |
-
global $q_config;
|
1925 |
-
|
1926 |
-
$post_type_object = get_post_type_object( $post->post_type);
|
1927 |
-
|
1928 |
-
|
1929 |
-
if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) // check autosave
|
1930 |
-
|| (!isset($_POST['post_ID']) || $post_id != $_POST['post_ID']) // check revision
|
1931 |
-
|| (!wp_verify_nonce( $_POST['qts_nonce'], 'qts_nonce')) // verify nonce
|
1932 |
-
|| (!current_user_can($post_type_object->cap->edit_post, $post_id))) { // check permission
|
1933 |
-
return $post_id;
|
1934 |
-
}
|
1935 |
-
|
1936 |
-
foreach ($q_config['enabled_languages'] as $lang) {
|
1937 |
-
|
1938 |
-
$meta_name = $this->get_meta_key($lang);
|
1939 |
-
$meta_value = apply_filters( 'qts_validate_post_slug', $_POST["qts_{$lang}_slug"], $post, $lang);
|
1940 |
-
|
1941 |
-
delete_post_meta($post_id, $meta_name);
|
1942 |
-
update_post_meta($post_id, $meta_name, $meta_value);
|
1943 |
-
|
1944 |
-
}
|
1945 |
-
}
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
/**
|
1950 |
-
* Display multiple input fields, one per language
|
1951 |
-
*
|
1952 |
-
* @param $term the term object
|
1953 |
-
*
|
1954 |
-
* @since 1.0
|
1955 |
-
*/
|
1956 |
-
public function show_term_fields( $term ) {
|
1957 |
-
global $q_config;
|
1958 |
-
|
1959 |
-
// prints the fields in edit page
|
1960 |
-
if (isset($_GET['action']) && $_GET['action'] == 'edit' ):
|
1961 |
-
|
1962 |
-
echo "<table class=\"form-table\">" . PHP_EOL;
|
1963 |
-
echo "<input type=\"hidden\" name=\"qts_nonce\" id=\"qts_nonce\" value=\"" . wp_create_nonce( 'qts_nonce' ) . "\" />" . PHP_EOL;
|
1964 |
-
|
1965 |
-
foreach( $q_config['enabled_languages'] as $lang ) {
|
1966 |
-
|
1967 |
-
$slug = (is_object($term)) ? get_term_meta( $term->term_id, $this->get_meta_key($lang), true ) : '';
|
1968 |
-
|
1969 |
-
$value = ( $slug ) ? htmlspecialchars( $slug , ENT_QUOTES ) : '';
|
1970 |
-
|
1971 |
-
echo "<tr class=\"form-field form-required\">" . PHP_EOL;
|
1972 |
-
echo "<th scope=\"row\" valig=\"top\"><label for=\"qts_term_{$lang}_slug\">Slug (".__($q_config['language_name'][$lang], 'qtranslate').")</label></th>" . PHP_EOL;
|
1973 |
-
echo "<td><input type=\"text\" name=\"qts_{$lang}_slug\" value=\"$value\" /></td></tr>" . PHP_EOL;
|
1974 |
-
|
1975 |
-
}
|
1976 |
-
|
1977 |
-
echo '</table>';
|
1978 |
-
|
1979 |
-
// prints the fields in new page
|
1980 |
-
else:
|
1981 |
-
echo "<input type=\"hidden\" name=\"qts_nonce\" id=\"qts_nonce\" value=\"" . wp_create_nonce( 'qts_nonce' ) . "\" />" . PHP_EOL;
|
1982 |
-
|
1983 |
-
foreach( $q_config['enabled_languages'] as $lang ) {
|
1984 |
-
|
1985 |
-
echo "<div class=\"form-field\">" . PHP_EOL;
|
1986 |
-
|
1987 |
-
$slug = (is_object($term)) ? get_term_meta( $term->term_id, $this->get_meta_key($lang), true ) : '';
|
1988 |
-
|
1989 |
-
$value = ( $slug ) ? htmlspecialchars( $slug , ENT_QUOTES ) : '';
|
1990 |
-
|
1991 |
-
|
1992 |
-
echo "<label for=\"qts_{$lang}_slug\">Slug (".__($q_config['language_name'][$lang], 'qtranslate').")</label>" . PHP_EOL;
|
1993 |
-
echo "<input type=\"text\" name=\"qts_term_{$lang}_slug\" value=\"$value\" aria-required=\"true\">" . PHP_EOL;
|
1994 |
-
|
1995 |
-
echo '</div>';
|
1996 |
-
|
1997 |
-
}
|
1998 |
-
|
1999 |
-
endif;
|
2000 |
-
}
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
/**
|
2005 |
-
* Sanitize title as slug, if empty slug
|
2006 |
-
*
|
2007 |
-
* @param $term (object) the term object
|
2008 |
-
* @param $slug (string) the slug name
|
2009 |
-
* @param $lang (string) the language
|
2010 |
-
* @return the slug validated
|
2011 |
-
*
|
2012 |
-
* @since 1.0
|
2013 |
-
*/
|
2014 |
-
public function validate_term_slug( $slug, $term, $lang ) {
|
2015 |
-
|
2016 |
-
global $q_config;
|
2017 |
-
|
2018 |
-
$lang_name = $q_config['term_name'][$term->name][$lang];
|
2019 |
-
|
2020 |
-
$ajax_name = 'new' . $term->taxonomy;
|
2021 |
-
|
2022 |
-
$post_name = isset($_POST['name']) ? $_POST['name'] : '';
|
2023 |
-
|
2024 |
-
$term_name = isset($_POST[$ajax_name]) ? trim($_POST[$ajax_name]) : $post_name;
|
2025 |
-
|
2026 |
-
if (empty($term_name)) {
|
2027 |
-
return $slug;
|
2028 |
-
}
|
2029 |
-
|
2030 |
-
$name = ( $lang_name == '' || strlen($lang_name) == 0 ) ? $term_name : $lang_name;
|
2031 |
-
|
2032 |
-
$slug = trim($slug);
|
2033 |
-
|
2034 |
-
$slug = (empty($slug)) ? sanitize_title($name) : sanitize_title($slug);
|
2035 |
-
|
2036 |
-
return htmlspecialchars( $slug , ENT_QUOTES );
|
2037 |
-
}
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
/**
|
2042 |
-
* Will make slug unique per language, if it isn't already.
|
2043 |
-
*
|
2044 |
-
* @param string $slug The string that will be tried for a unique slug
|
2045 |
-
* @param object $term The term object that the $slug will belong too
|
2046 |
-
* @param object $lang The language reference
|
2047 |
-
* @return string Will return a true unique slug.
|
2048 |
-
*
|
2049 |
-
* @since 1.0
|
2050 |
-
*/
|
2051 |
-
public function unique_term_slug($slug, $term, $lang) {
|
2052 |
-
|
2053 |
-
global $wpdb;
|
2054 |
-
|
2055 |
-
$meta_key_name = $this->get_meta_key($lang);
|
2056 |
-
$query = $wpdb->prepare("SELECT term_id FROM $wpdb->termmeta WHERE meta_key = '%s' AND meta_value = '%s' AND term_id != %d ", $meta_key_name, $slug, $term->term_id);
|
2057 |
-
$exists_slug = $wpdb->get_results($query);
|
2058 |
-
|
2059 |
-
if ( empty($exists_slug) ) {
|
2060 |
-
return $slug;
|
2061 |
-
}
|
2062 |
-
|
2063 |
-
// If we didn't get a unique slug, try appending a number to make it unique.
|
2064 |
-
$query = $wpdb->prepare("SELECT meta_value FROM $wpdb->termmeta WHERE meta_key = '%s' AND meta_value = '%s' AND term_id != %d", $meta_key_name, $slug, $term->term_id);
|
2065 |
-
|
2066 |
-
if ( $wpdb->get_var( $query ) ) {
|
2067 |
-
$num = 2;
|
2068 |
-
do {
|
2069 |
-
$alt_slug = $slug . "-$num";
|
2070 |
-
$num++;
|
2071 |
-
$slug_check = $wpdb->get_var(
|
2072 |
-
$wpdb->prepare(
|
2073 |
-
"SELECT meta_value FROM $wpdb->termmeta WHERE meta_key = '%s' AND meta_value = '%s'",
|
2074 |
-
$meta_key_name,
|
2075 |
-
$alt_slug) );
|
2076 |
-
} while ( $slug_check );
|
2077 |
-
$slug = $alt_slug;
|
2078 |
-
}
|
2079 |
-
|
2080 |
-
return $slug;
|
2081 |
-
}
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
/**
|
2086 |
-
* Display multiple input fields, one per language
|
2087 |
-
*
|
2088 |
-
* @param $term_id the term id
|
2089 |
-
* @param $tt_id the term taxonomy id
|
2090 |
-
* @param $taxonomy the term object
|
2091 |
-
*
|
2092 |
-
* @since 1.0
|
2093 |
-
*/
|
2094 |
-
public function save_term( $term_id, $tt_id, $taxonomy ) {
|
2095 |
-
global $q_config;
|
2096 |
-
|
2097 |
-
if ( (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) // check autosave
|
2098 |
-
|| ( !current_user_can('edit_posts') ) ) { // check permission
|
2099 |
-
return $term_id;
|
2100 |
-
}
|
2101 |
-
|
2102 |
-
$term = get_term( $term_id, $taxonomy);
|
2103 |
-
|
2104 |
-
foreach( $q_config['enabled_languages'] as $lang ) {
|
2105 |
-
|
2106 |
-
$meta_name = $this->get_meta_key($lang);
|
2107 |
-
|
2108 |
-
//LC43: when at the post edit screen and creating a new tag
|
2109 |
-
// the $slug comes from $_POST with the value of the post slug,
|
2110 |
-
// not with the term slug.
|
2111 |
-
if ($_POST['action'] == "editpost") {
|
2112 |
-
// so we use the slug wp gave it
|
2113 |
-
$term_slug = $term->slug;
|
2114 |
-
} else {
|
2115 |
-
// otherwise, its the edit term screen
|
2116 |
-
$term_slug = $_POST["qts_term_{$lang}_slug"];
|
2117 |
-
}
|
2118 |
-
|
2119 |
-
$meta_value = apply_filters( 'qts_validate_term_slug', $term_slug, $term, $lang);
|
2120 |
-
|
2121 |
-
delete_term_meta($term_id, $meta_name);
|
2122 |
-
update_term_meta($term_id, $meta_name, $meta_value);
|
2123 |
-
}
|
2124 |
-
}
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
/**
|
2129 |
-
* deletes termmeta rows associated with the term
|
2130 |
-
*
|
2131 |
-
* @since 1.0
|
2132 |
-
*/
|
2133 |
-
public function delete_term($term_id, $tt_id, $taxonomy) {
|
2134 |
-
global $wpdb;
|
2135 |
-
|
2136 |
-
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->termmeta WHERE term_id = %d", $term_id ) );
|
2137 |
-
}
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
/**
|
2142 |
-
* adds support for qtranslate in taxonomies
|
2143 |
-
*
|
2144 |
-
* @since 1.0
|
2145 |
-
*/
|
2146 |
-
public function taxonomies_hooks() {
|
2147 |
-
|
2148 |
-
$taxonomies = $this->get_public_taxonomies();
|
2149 |
-
|
2150 |
-
if ($taxonomies) {
|
2151 |
-
foreach ($taxonomies as $taxonomy ) {
|
2152 |
-
add_action( $taxonomy->name.'_add_form', 'qtrans_modifyTermFormFor');
|
2153 |
-
add_action( $taxonomy->name.'_edit_form', 'qtrans_modifyTermFormFor');
|
2154 |
-
add_action( $taxonomy->name.'_add_form', array(&$this, 'show_term_fields'));
|
2155 |
-
add_action( $taxonomy->name.'_edit_form_fields', array(&$this, 'show_term_fields') );
|
2156 |
-
add_filter('manage_edit-'.$taxonomy->name.'_columns', array(&$this, 'taxonomy_columns'));
|
2157 |
-
add_filter('manage_'.$taxonomy->name.'_custom_column', array(&$this, 'taxonomy_custom_column'), 0, 3);
|
2158 |
-
}
|
2159 |
-
}
|
2160 |
-
}
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
/*
|
2165 |
-
* Bug fix for slug column in taxonomies
|
2166 |
-
*
|
2167 |
-
* @since 1.0
|
2168 |
-
*/
|
2169 |
-
public function taxonomy_columns($columns) {
|
2170 |
-
unset($columns['slug']);
|
2171 |
-
unset($columns['posts']);
|
2172 |
-
|
2173 |
-
$columns['qts-slug'] = __('Slug', 'qts');
|
2174 |
-
$columns['posts'] = __('Posts');
|
2175 |
-
|
2176 |
-
return $columns;
|
2177 |
-
}
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
/*
|
2182 |
-
* Bug fix for slug column in taxonomies
|
2183 |
-
*
|
2184 |
-
* @since 1.0
|
2185 |
-
*/
|
2186 |
-
public function taxonomy_custom_column($str, $column_name, $term_id) {
|
2187 |
-
|
2188 |
-
switch ($column_name) {
|
2189 |
-
case 'qts-slug':
|
2190 |
-
echo get_term_meta($term_id, $this->get_meta_key(), true);
|
2191 |
-
break;
|
2192 |
-
}
|
2193 |
-
return false;
|
2194 |
-
}
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
/**
|
2200 |
-
* Bug fix for multisite blog names
|
2201 |
-
*
|
2202 |
-
* @since 1.0
|
2203 |
-
*/
|
2204 |
-
public function blog_names($blogs) {
|
2205 |
-
|
2206 |
-
foreach ($blogs as $blog) {
|
2207 |
-
$blog->blogname = __($blog->blogname);
|
2208 |
-
}
|
2209 |
-
|
2210 |
-
return $blogs;
|
2211 |
-
}
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
/**
|
2216 |
-
* Initialise the Language Widget selector
|
2217 |
-
*
|
2218 |
-
* @since 1.0
|
2219 |
-
*/
|
2220 |
-
public function widget_init() {
|
2221 |
-
|
2222 |
-
if (class_exists('qTranslateWidget')) {
|
2223 |
-
unregister_widget('qTranslateWidget');
|
2224 |
-
}
|
2225 |
-
if (class_exists('mqTranslateWidget')) {
|
2226 |
-
unregister_widget('mqTranslateWidget');
|
2227 |
-
}
|
2228 |
-
|
2229 |
-
register_widget('QtranslateSlugWidget');
|
2230 |
-
}
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
/**
|
2235 |
-
* remove some default dashboard Widgets on Desktop
|
2236 |
-
*
|
2237 |
-
* @since 1.0
|
2238 |
-
*/
|
2239 |
-
function remove_dashboard_widgets() {
|
2240 |
-
global $wp_meta_boxes;
|
2241 |
-
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
|
2242 |
-
}
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
/**
|
2247 |
-
* adds support for qtranslate nav menus
|
2248 |
-
*
|
2249 |
-
* @since 1.0
|
2250 |
-
*/
|
2251 |
-
public function fix_nav_menu() {
|
2252 |
-
global $pagenow;
|
2253 |
-
|
2254 |
-
if( $pagenow != 'nav-menus.php' ) {
|
2255 |
-
return;
|
2256 |
-
}
|
2257 |
-
|
2258 |
-
wp_enqueue_script( 'nav-menu-query', plugins_url( 'assets/js/qts-nav-menu-min.js' , dirname(__FILE__ ) ), 'nav-menu', '1.0' );
|
2259 |
-
add_meta_box( 'qt-languages', __('Languages'), array(&$this, 'nav_menu_meta_box'), 'nav-menus', 'side', 'default' );
|
2260 |
-
}
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
/**
|
2265 |
-
* draws meta box for select language
|
2266 |
-
*
|
2267 |
-
* @since 1.0
|
2268 |
-
*/
|
2269 |
-
public function nav_menu_meta_box() {
|
2270 |
-
global $q_config;
|
2271 |
-
echo '<p>';
|
2272 |
-
foreach($q_config['enabled_languages'] as $id => $language) {
|
2273 |
-
$checked = ($language == $q_config['language']) ? ' checked="checked"' : '';
|
2274 |
-
echo '<p style="margin:0 0 5px 0"><input type="radio" style="margin-right:5px" name="wa_qt_lang" value="' . $language . '" id="wa_gt_lang_' . $id . '" ' . $checked . '/>';
|
2275 |
-
echo '<label for="wa_gt_lang_' . $id . '">';
|
2276 |
-
echo '<img src="' . trailingslashit(WP_CONTENT_URL).$q_config['flag_location'].$q_config['flag'][$language] . '"/> ';
|
2277 |
-
echo __($q_config['language_name'][$language], 'qtranslate');
|
2278 |
-
echo '</label></p>';
|
2279 |
-
}
|
2280 |
-
echo '</p>';
|
2281 |
-
}
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
/**
|
2286 |
-
* Language select function for templating
|
2287 |
-
*
|
2288 |
-
* @param $type (string) choose the type of menu: 'text', 'image', 'both', 'dropdown'
|
2289 |
-
* @param $args (array) some args for draw the menu: array( 'id', 'class', 'short' );
|
2290 |
-
*
|
2291 |
-
* @since 1.0
|
2292 |
-
*/
|
2293 |
-
public function language_menu( $type = "text", $args = array() ) {
|
2294 |
-
global $q_config;
|
2295 |
-
|
2296 |
-
// default arguments
|
2297 |
-
$defaults = array(
|
2298 |
-
'id' => "qts-lang-menu",
|
2299 |
-
'class' => "qts-lang-menu",
|
2300 |
-
'short' => false
|
2301 |
-
);
|
2302 |
-
$args = wp_parse_args( $args, $defaults );
|
2303 |
-
|
2304 |
-
$languages = qtrans_getSortedLanguages();
|
2305 |
-
|
2306 |
-
// every type
|
2307 |
-
switch ( $type ) {
|
2308 |
-
|
2309 |
-
case 'image':
|
2310 |
-
case 'text':
|
2311 |
-
case 'both':
|
2312 |
-
|
2313 |
-
$baseurl = dirname(plugins_url());
|
2314 |
-
$num_languages = count($languages);
|
2315 |
-
echo "<ul id=\"{$args['id']}\" class=\"qts_type_{$type} {$args['class']}\">". PHP_EOL;
|
2316 |
-
|
2317 |
-
foreach( $languages as $index => $lang ):
|
2318 |
-
|
2319 |
-
$url = $this->get_current_url($lang);
|
2320 |
-
|
2321 |
-
$item_class = array();
|
2322 |
-
if ( (string)$q_config['language'] == (string)$lang ) $item_class[] = 'current-menu-item';
|
2323 |
-
if ( $index == ( $num_languages - 1) ) $item_class[] = 'last-child';
|
2324 |
-
|
2325 |
-
|
2326 |
-
$item_class = ' class="qts_lang_item ' . implode(' ', $item_class) . '"';
|
2327 |
-
|
2328 |
-
$language_name = ($args['short']) ? $lang : $q_config['language_name'][$lang];
|
2329 |
-
|
2330 |
-
if ( $type == 'image' ) {
|
2331 |
-
$link_class = " class=\"qtrans_flag qtrans_flag_$lang\"";
|
2332 |
-
$link_content = "<span style=\"display:none\">$language_name</span>";
|
2333 |
-
} else if ( $type == 'both' ) {
|
2334 |
-
$link_class = " class=\"qts_both qtrans_flag qtrans_flag_$lang\"";
|
2335 |
-
$link_content = "$language_name";
|
2336 |
-
} else {
|
2337 |
-
$link_class = '';
|
2338 |
-
$link_content = $language_name;
|
2339 |
-
}
|
2340 |
-
if( $type == 'image' || $type == 'both' ) {
|
2341 |
-
$link_flag_url = $baseurl . '/'.$q_config['flag_location'].$q_config['flag'][$lang];
|
2342 |
-
|
2343 |
-
//TODO: add i18n for alt attribute
|
2344 |
-
//43LC: hardcoding height and width
|
2345 |
-
$link_flag = "<img widht=\"18\" height=\"12\" src=\"$link_flag_url\" alt=\"$language_name\" />";
|
2346 |
-
}
|
2347 |
-
echo "<li$item_class><a href=\"$url\" lang=\"$lang\" hreflang=\"$lang\"$link_class>$link_flag$link_content</a></li>" . PHP_EOL;
|
2348 |
-
|
2349 |
-
endforeach;
|
2350 |
-
|
2351 |
-
echo "</ul>". PHP_EOL;
|
2352 |
-
|
2353 |
-
break;
|
2354 |
-
|
2355 |
-
case 'dropdown':
|
2356 |
-
|
2357 |
-
echo "<select id=\"{$args['id']}\" class=\"{$args['class']}\" onchange=\"window.location.href=this.options[this.selectedIndex].value\">". PHP_EOL;
|
2358 |
-
|
2359 |
-
foreach( $languages as $index => $lang ):
|
2360 |
-
|
2361 |
-
$url = $this->get_current_url($lang);
|
2362 |
-
|
2363 |
-
$item_class = '';
|
2364 |
-
if ( (string)$q_config['language'] == (string)$lang ) $item_class = 'selected="selected"';
|
2365 |
-
|
2366 |
-
$language_name = ($args['short']) ? $lang : $q_config['language_name'][$lang];
|
2367 |
-
|
2368 |
-
echo "<option value=\"$url\" $item_class>$language_name</option>" . PHP_EOL;
|
2369 |
-
|
2370 |
-
endforeach;
|
2371 |
-
|
2372 |
-
echo "</select>". PHP_EOL;
|
2373 |
-
|
2374 |
-
break;
|
2375 |
-
}
|
2376 |
-
|
2377 |
-
}
|
2378 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/includes/qtranslate-slug-settings-options.php
DELETED
@@ -1,182 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Define our settings sections
|
4 |
-
*
|
5 |
-
* @package Qtranslate Slug
|
6 |
-
* @subpackage Settings
|
7 |
-
* @version 1.0
|
8 |
-
*
|
9 |
-
* @return array key=$id, array value=$title in: add_settings_section( $id, $title, $callback, $page );
|
10 |
-
*/
|
11 |
-
function qts_options_page_sections() {
|
12 |
-
|
13 |
-
$sections = array();
|
14 |
-
$sections['post_types'] = __('Post types', 'qts');
|
15 |
-
$sections['taxonomies'] = __('Taxonomies', 'qts');
|
16 |
-
$sections['styles'] = __('Styles', 'qts');
|
17 |
-
|
18 |
-
return $sections;
|
19 |
-
}
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Helper for create arrays of choices
|
25 |
-
*
|
26 |
-
* @package Qtranslate Slug
|
27 |
-
* @subpackage Settings
|
28 |
-
* @version 1.0
|
29 |
-
*
|
30 |
-
* @return array
|
31 |
-
*/
|
32 |
-
function get_multi_txt_choices($name = false) {
|
33 |
-
global $q_config;
|
34 |
-
|
35 |
-
if (!$name) return array();
|
36 |
-
|
37 |
-
$choices = array();
|
38 |
-
foreach( $q_config['enabled_languages'] as $key => $lang) {
|
39 |
-
$label = sprintf( __('Slug (%s)', 'qts'), $q_config['language_name'][$lang] );
|
40 |
-
$choices[] = "$label|$lang"; // prints: 'Slug (English)|en' ( $name = books )
|
41 |
-
}
|
42 |
-
|
43 |
-
return $choices;
|
44 |
-
}
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Define our form fields (settings) for displaying the default styles
|
50 |
-
*
|
51 |
-
* @package Qtranslate Slug
|
52 |
-
* @subpackage Settings
|
53 |
-
* @version 1.1.7
|
54 |
-
*
|
55 |
-
* @return array
|
56 |
-
*/
|
57 |
-
function qts_options_page_styles() {
|
58 |
-
global $q_config;
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
$options[] = array(
|
63 |
-
"section" => "styles",
|
64 |
-
"id" => QTS_PREFIX . "styles",
|
65 |
-
"title" => __('Change styles type', 'qts'),
|
66 |
-
"desc" => array(
|
67 |
-
__("adds a file (qts-default.css) to the theme's header.", "qts"),
|
68 |
-
__("adds a minified ( slighlty faster) file (qts-default.min.css) to the theme's header.", "qts"),
|
69 |
-
__("prints the styles directly into the theme's header.", "qts"),
|
70 |
-
__("neither include not print the default style.", "qts")
|
71 |
-
),
|
72 |
-
"type" => "multi-radio",
|
73 |
-
'class' => 'qts-style',
|
74 |
-
"choices" => array(
|
75 |
-
"file",
|
76 |
-
"minified",
|
77 |
-
"inline",
|
78 |
-
"none"
|
79 |
-
),
|
80 |
-
"std" => "file"
|
81 |
-
);
|
82 |
-
|
83 |
-
return $options;
|
84 |
-
}
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Define our form fields (settings)
|
90 |
-
*
|
91 |
-
* @package Qtranslate Slug
|
92 |
-
* @subpackage Settings
|
93 |
-
* @version 1.0
|
94 |
-
*
|
95 |
-
* @return array
|
96 |
-
*/
|
97 |
-
function qts_options_page_fields() {
|
98 |
-
global $q_config;
|
99 |
-
|
100 |
-
$post_types = get_post_types( array('_builtin' => false, 'public' => true ), 'objects');
|
101 |
-
|
102 |
-
// each post type
|
103 |
-
foreach ($post_types as $post_type):
|
104 |
-
|
105 |
-
$options[] = array(
|
106 |
-
"section" => "post_types",
|
107 |
-
"id" => QTS_PREFIX . "post_type_" . $post_type->name,
|
108 |
-
"title" => $post_type->labels->singular_name,
|
109 |
-
"desc" => sprintf( __( '<code>http://example.org/<u>%s</u>/some-%s/</code>', 'qts' ), $post_type->name, $post_type->name),
|
110 |
-
'class' => 'qts-slug',
|
111 |
-
"type" => "multi-text",
|
112 |
-
"choices" => get_multi_txt_choices( $post_type->name),
|
113 |
-
"std" => ""
|
114 |
-
);
|
115 |
-
|
116 |
-
endforeach;
|
117 |
-
// end each post type
|
118 |
-
|
119 |
-
$options[] = array(
|
120 |
-
"section" => "taxonomies",
|
121 |
-
"id" => QTS_PREFIX . "taxonomy_category",
|
122 |
-
"title" => __('Categories'),
|
123 |
-
"desc" => __( '<code>http://example.org/<u>category</u>/some-category/</code>', 'qts' ),
|
124 |
-
"type" => "multi-text",
|
125 |
-
'class' => 'qts-slug',
|
126 |
-
"choices" => get_multi_txt_choices('category'),
|
127 |
-
"std" => ""
|
128 |
-
);
|
129 |
-
|
130 |
-
$options[] = array(
|
131 |
-
"section" => "taxonomies",
|
132 |
-
"id" => QTS_PREFIX . "taxonomy_post_tag",
|
133 |
-
"title" => __('Tags'),
|
134 |
-
"desc" => __( '<code>http://example.org/<u>tag</u>/some-tag/</code>', 'qts' ),
|
135 |
-
"type" => "multi-text",
|
136 |
-
'class' => 'qts-slug',
|
137 |
-
"choices" => get_multi_txt_choices('post_tag'),
|
138 |
-
"std" => ""
|
139 |
-
);
|
140 |
-
|
141 |
-
|
142 |
-
$taxonomies = get_taxonomies( array( 'public' => true, 'show_ui' => true, '_builtin' => false ), 'object' );
|
143 |
-
|
144 |
-
// each extra taxonomy
|
145 |
-
foreach ($taxonomies as $taxonomy):
|
146 |
-
|
147 |
-
$options[] = array(
|
148 |
-
"section" => "taxonomies",
|
149 |
-
"id" => QTS_PREFIX . "taxonomy_" . $taxonomy->name,
|
150 |
-
"title" => $taxonomy->labels->singular_name,
|
151 |
-
"desc" => sprintf( __( '<code>http://example.org/<u>%s</u>/some-%s/</code>', 'qts' ), $taxonomy->name, $taxonomy->name ),
|
152 |
-
"type" => "multi-text",
|
153 |
-
'class' => 'qts-slug',
|
154 |
-
"choices" => get_multi_txt_choices( $taxonomy->name),
|
155 |
-
"std" => ""
|
156 |
-
);
|
157 |
-
|
158 |
-
endforeach;
|
159 |
-
// end each extra taxonomy
|
160 |
-
|
161 |
-
|
162 |
-
return $options;
|
163 |
-
}
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Contextual Help
|
169 |
-
*
|
170 |
-
* @package Qtranslate Slug
|
171 |
-
* @subpackage Settings
|
172 |
-
* @version 1.0
|
173 |
-
*
|
174 |
-
*/
|
175 |
-
function qts_options_page_contextual_help() {
|
176 |
-
|
177 |
-
|
178 |
-
$text = "<h3>" . __('Qtranslate Settings - Contextual Help','qts') . "</h3>";
|
179 |
-
$text .= "<p>" . __('Contextual help goes here. You may want to use different html elements to format your text as you want.','qts') . "</p>";
|
180 |
-
|
181 |
-
return $text;
|
182 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/includes/qtranslate-slug-settings.php
DELETED
@@ -1,978 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// page settings sections & fields as well as the contextual help text.
|
4 |
-
include_once('qtranslate-slug-settings-options.php');
|
5 |
-
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Prints upgrade form in Qtranslate Slug admin page
|
9 |
-
*
|
10 |
-
* @package Qtranslate Slug
|
11 |
-
* @subpackage Settings
|
12 |
-
* @version 1.0
|
13 |
-
*
|
14 |
-
* @return array
|
15 |
-
*/
|
16 |
-
function qts_upgrade() {
|
17 |
-
global $qtranslate_slug;
|
18 |
-
|
19 |
-
if ( !$qtranslate_slug->check_old_data() ) return;
|
20 |
-
|
21 |
-
echo "<div id=\"qts-upgrade-box\" class=\"updated\" style=\"margin: 15px 0; margin-bottom:25px; padding: 10px\">" . PHP_EOL;
|
22 |
-
|
23 |
-
echo "<h3>" . __('Upgrade your data', 'qts') . "</h3>" . PHP_EOL;
|
24 |
-
echo "<p>" . __('There are slugs stored with old data system. Please upgrade your data pressing upgrade button:', 'qts') . "</p>" . PHP_EOL;
|
25 |
-
|
26 |
-
echo "<div id=\"qts-upgrade-form\">" . PHP_EOL;
|
27 |
-
echo "<input type=\"hidden\" id=\"qts-upgrade-action\" name=\"qts-upgrade-action\" value=\"qts-upgrade-check\" />" .PHP_EOL;
|
28 |
-
echo "<input type=\"hidden\" id=\"qts-upgrade-nonce\" name=\"qts-upgrade-nonce\" value=\"". wp_create_nonce('qts-upgrade') . "\" />" .PHP_EOL;
|
29 |
-
echo "<p><a id=\"qts-upgrade-button\" href=\"#\" class=\"button-primary\">" . __('upgrade now', 'qts') . "</a><img src=\"".admin_url('images/wpspin_light.gif')."\" class=\"qts-loading\" id=\"qts-loading\" alt=\"\"></p>" . PHP_EOL;
|
30 |
-
echo "</div></div>" . PHP_EOL;
|
31 |
-
}
|
32 |
-
|
33 |
-
|
34 |
-
/**
|
35 |
-
* AJAX: upgrade old database to new system
|
36 |
-
*
|
37 |
-
* @package Qtranslate Slug
|
38 |
-
* @subpackage Settings
|
39 |
-
* @version 1.0
|
40 |
-
*
|
41 |
-
* @return boolean
|
42 |
-
*/
|
43 |
-
function qts_process_old_data( $old_data = null, $type = 'post' ) {
|
44 |
-
global $wpdb, $qtranslate_slug;
|
45 |
-
|
46 |
-
if ( is_null($old_data) || empty($old_data) ) return 0;
|
47 |
-
foreach ($old_data as $row) {
|
48 |
-
switch ($row->qts_type) {
|
49 |
-
case 1:
|
50 |
-
case 2:
|
51 |
-
update_post_meta( $row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
|
52 |
-
break;
|
53 |
-
case 3:
|
54 |
-
case 4:
|
55 |
-
update_term_meta( $row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
|
56 |
-
break;
|
57 |
-
case 5:
|
58 |
-
if ($type == 'post')
|
59 |
-
update_post_meta( $row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
|
60 |
-
|
61 |
-
if ($type == 'term')
|
62 |
-
update_term_meta( $row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
|
63 |
-
break;
|
64 |
-
};
|
65 |
-
}
|
66 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}qtranslate_slug");
|
67 |
-
|
68 |
-
return 1;
|
69 |
-
}
|
70 |
-
|
71 |
-
function qts_upgrade_response($type = 0, $slug = null) {
|
72 |
-
switch ( $type ) {
|
73 |
-
default:
|
74 |
-
case 0:
|
75 |
-
$response = array(
|
76 |
-
'status' => 0,
|
77 |
-
'message' => __('Sorry, some error happened. Refresh this page and try again please.', 'qts'),
|
78 |
-
);
|
79 |
-
break;
|
80 |
-
|
81 |
-
case 1:
|
82 |
-
$response = array(
|
83 |
-
'status' => 1,
|
84 |
-
'message' => __('Congratulations, your data has been upgraded, you are up to date.', 'qts'),
|
85 |
-
);
|
86 |
-
break;
|
87 |
-
case 2:
|
88 |
-
$response = array(
|
89 |
-
'status' => 2,
|
90 |
-
'message' => sprintf(__('One step more, select what type of slug is this: <strong>%s</strong>', 'qts'), $slug),
|
91 |
-
'options' => array( 'post' => __('Post, Page or Custom post type', 'qts'), 'term' => __('Category, tag or custom taxonomy') )
|
92 |
-
);
|
93 |
-
break;
|
94 |
-
}
|
95 |
-
|
96 |
-
return $response;
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
/**
|
102 |
-
* AJAX: upgrade old database to new system
|
103 |
-
*
|
104 |
-
* @package Qtranslate Slug
|
105 |
-
* @subpackage Settings
|
106 |
-
* @version 1.0
|
107 |
-
*
|
108 |
-
* @return JSON object
|
109 |
-
*/
|
110 |
-
function qts_upgrade_check() {
|
111 |
-
global $qtranslate_slug;
|
112 |
-
|
113 |
-
$old_data = $qtranslate_slug->check_old_data();
|
114 |
-
|
115 |
-
if ( wp_verify_nonce( $_POST['nonce'], 'qts-upgrade') ):
|
116 |
-
|
117 |
-
// if data process to save...
|
118 |
-
if ($old_data) {
|
119 |
-
|
120 |
-
// if defined data type 5, process to upgrade
|
121 |
-
if ( isset($_POST['type']) ):
|
122 |
-
|
123 |
-
$res = qts_process_old_data($old_data, $_POST['type']);
|
124 |
-
|
125 |
-
$response = qts_upgrade_response($res);
|
126 |
-
|
127 |
-
else :
|
128 |
-
|
129 |
-
// define wich type of data is 5
|
130 |
-
$array_of_5 = array();
|
131 |
-
foreach ( $old_data as $row )
|
132 |
-
if ( $row->qts_type == 5 ) $array_of_5[] = $row->qts_slug;
|
133 |
-
|
134 |
-
if (!empty($array_of_5)) $response = qts_upgrade_response(2, implode(', ', $array_of_5));
|
135 |
-
|
136 |
-
// if no data type 5, process to upgrade
|
137 |
-
if (!isset($response)) {
|
138 |
-
$res = qts_process_old_data($old_data);
|
139 |
-
$response = qts_upgrade_response($res);
|
140 |
-
}
|
141 |
-
|
142 |
-
endif;
|
143 |
-
|
144 |
-
|
145 |
-
// if not continue
|
146 |
-
} else {
|
147 |
-
|
148 |
-
$response = qts_upgrade_response();
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
else:
|
153 |
-
|
154 |
-
$response = qts_upgrade_response();
|
155 |
-
|
156 |
-
endif;
|
157 |
-
|
158 |
-
// response output
|
159 |
-
header( "Content-Type: application/json" );
|
160 |
-
echo json_encode($response);
|
161 |
-
exit;
|
162 |
-
}
|
163 |
-
add_action('wp_ajax_qts-upgrade-check', 'qts_upgrade_check');
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Helper function for defining variables for the current page
|
169 |
-
*
|
170 |
-
* @package Qtranslate Slug
|
171 |
-
* @subpackage Settings
|
172 |
-
* @version 1.0
|
173 |
-
*
|
174 |
-
* @return array
|
175 |
-
*/
|
176 |
-
function qts_get_settings() {
|
177 |
-
|
178 |
-
$output = array();
|
179 |
-
|
180 |
-
// put together the output array
|
181 |
-
$output['qts_option_name'] = QTS_OPTIONS_NAME; // the option name as used in the get_option() call.
|
182 |
-
$output['qts_page_title'] = __('Qtranslate Slug options', 'qts'); // the settings page title
|
183 |
-
$output['qts_page_sections'] = qts_options_page_sections(); // the settings sections
|
184 |
-
$output['qts_page_fields'] = qts_options_page_fields(); // the settings fields
|
185 |
-
$output['qts_page_styles'] = qts_options_page_styles(); // the settings for style
|
186 |
-
|
187 |
-
|
188 |
-
$output['qts_contextual_help'] = qts_options_page_contextual_help(); // the contextual help
|
189 |
-
|
190 |
-
return $output;
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Helper function for registering our form field settings
|
197 |
-
*
|
198 |
-
* @package Qtranslate Slug
|
199 |
-
* @subpackage Settings
|
200 |
-
* @version 1.0
|
201 |
-
*
|
202 |
-
* src: http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
|
203 |
-
* @param (array) $args The array of arguments to be used in creating the field
|
204 |
-
* @return function call
|
205 |
-
*/
|
206 |
-
function qts_create_settings_field( $args = array() ) {
|
207 |
-
// default array to overwrite when calling the function
|
208 |
-
$defaults = array(
|
209 |
-
'id' => 'default_field', // the ID of the setting in our options array, and the ID of the HTML form element
|
210 |
-
'title' => 'Default Field', // the label for the HTML form element
|
211 |
-
'desc' => 'This is a default description.', // the description displayed under the HTML form element
|
212 |
-
'std' => '', // the default value for this setting
|
213 |
-
'type' => 'text', // the HTML form element to use
|
214 |
-
'section' => 'main_section', // the section this setting belongs to must match the array key of a section in qts_options_page_sections()
|
215 |
-
'choices' => array(), // (optional): the values in radio buttons or a drop-down menu
|
216 |
-
'class' => '' // the HTML form element class. Is used for validation purposes and may be also use for styling if needed.
|
217 |
-
);
|
218 |
-
|
219 |
-
// "extract" to be able to use the array keys as variables in our function output below
|
220 |
-
extract( wp_parse_args( $args, $defaults ) );
|
221 |
-
|
222 |
-
// additional arguments for use in form field output in the function qts_show_form_field!
|
223 |
-
$field_args = array(
|
224 |
-
'type' => $type,
|
225 |
-
'id' => $id,
|
226 |
-
'desc' => $desc,
|
227 |
-
'std' => $std,
|
228 |
-
'choices' => $choices,
|
229 |
-
'label_for' => $id,
|
230 |
-
'class' => $class
|
231 |
-
);
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
add_settings_field( $id, $title, 'qts_show_form_field', __FILE__, $section, $field_args );
|
236 |
-
|
237 |
-
}
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Register our setting, settings sections and settings fields
|
243 |
-
*
|
244 |
-
* @package Qtranslate Slug
|
245 |
-
* @subpackage Settings
|
246 |
-
* @version 1.0
|
247 |
-
*
|
248 |
-
*/
|
249 |
-
function qts_register_settings(){
|
250 |
-
|
251 |
-
// get the settings sections array
|
252 |
-
$settings_output = qts_get_settings();
|
253 |
-
$qts_option_name = $settings_output['qts_option_name'];
|
254 |
-
|
255 |
-
//setting
|
256 |
-
register_setting($qts_option_name, $qts_option_name, 'qts_validate_options' );
|
257 |
-
|
258 |
-
//sections
|
259 |
-
if(!empty($settings_output['qts_page_sections'])){
|
260 |
-
// call the "add_settings_section" for each!
|
261 |
-
foreach ( $settings_output['qts_page_sections'] as $id => $title ) {
|
262 |
-
add_settings_section( $id, $title, 'qts_section_fn', __FILE__);
|
263 |
-
}
|
264 |
-
}
|
265 |
-
|
266 |
-
//fields
|
267 |
-
if(!empty($settings_output['qts_page_fields'])){
|
268 |
-
// call the "add_settings_field" for each!
|
269 |
-
foreach ($settings_output['qts_page_fields'] as $option) {
|
270 |
-
qts_create_settings_field($option);
|
271 |
-
}
|
272 |
-
}
|
273 |
-
//style
|
274 |
-
if(!empty($settings_output['qts_page_styles'])){
|
275 |
-
// call the "add_settings_field" for each
|
276 |
-
foreach ($settings_output['qts_page_styles'] as $styleoption) {
|
277 |
-
qts_create_settings_field($styleoption);
|
278 |
-
}
|
279 |
-
}
|
280 |
-
}
|
281 |
-
add_action( 'admin_init', 'qts_register_settings' );
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
/**
|
286 |
-
* Group scripts (js & css)
|
287 |
-
*
|
288 |
-
* @package Qtranslate Slug
|
289 |
-
* @subpackage Settings
|
290 |
-
* @version 1.0
|
291 |
-
*
|
292 |
-
*/
|
293 |
-
function qts_settings_scripts() {
|
294 |
-
global $qtranslate_slug;
|
295 |
-
|
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
|
308 |
-
*
|
309 |
-
* @package Qtranslate Slug
|
310 |
-
* @subpackage Settings
|
311 |
-
* @version 1.0
|
312 |
-
*
|
313 |
-
*/
|
314 |
-
function qts_add_menu() {
|
315 |
-
global $current_screen;
|
316 |
-
|
317 |
-
$settings_output = qts_get_settings();
|
318 |
-
// collect our contextual help text
|
319 |
-
$qts_contextual_help = $settings_output['qts_contextual_help'];
|
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 |
-
|
335 |
-
|
336 |
-
|
337 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
338 |
-
|
339 |
-
// Callback functions
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
/**
|
344 |
-
* Section HTML, displayed before the first option
|
345 |
-
*
|
346 |
-
* @package Qtranslate Slug
|
347 |
-
* @subpackage Settings
|
348 |
-
* @version 1.0
|
349 |
-
*
|
350 |
-
* @return echoes output
|
351 |
-
*/
|
352 |
-
function qts_section_fn($page_section = false) {
|
353 |
-
|
354 |
-
if ( !$page_section || !isset($page_section['id']) ) return;
|
355 |
-
|
356 |
-
switch ($page_section['id']) {
|
357 |
-
case 'post_types':
|
358 |
-
|
359 |
-
echo "<p>" . __('For example, the post_type <kbd>books</kbd>, in Spanish would be displayed as <code>http://example.org/es/libros/post-type-name/</code>. If you leave this blank will use the default option when you <a href="http://codex.wordpress.org/Function_Reference/register_post_type">registered</a> the post_type.', 'qts') . "</p>";
|
360 |
-
break;
|
361 |
-
|
362 |
-
case 'taxonomies':
|
363 |
-
|
364 |
-
echo "<p>" . __('For example, the taxonomy <kbd>category</kbd>, in Spanish would be displayed as <code>http://example.org/es/categoria/taxonomy-name/</code>. If you leave this blank will use the default option when you <a href="http://codex.wordpress.org/Function_Reference/register_taxonomy">registered</a> the taxonomy (if you previously setup a base permastruct for <u>categories</u> or <u>tags</u> in <a href="options-permalink.php">permalinks</a> page, these bases will be overwritten by the translated ones).', 'qts') . "</p>";
|
365 |
-
break;
|
366 |
-
case 'styles':
|
367 |
-
|
368 |
-
echo "<p>" . __('The default styles are very minimal, and you can include them or not.', 'qts') . "</p>\n";
|
369 |
-
break;
|
370 |
-
}
|
371 |
-
}
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
/**
|
376 |
-
* Form Fields HTML: all form field types share the same function
|
377 |
-
*
|
378 |
-
* @package Qtranslate Slug
|
379 |
-
* @subpackage Settings
|
380 |
-
* @version 1.0
|
381 |
-
*
|
382 |
-
* @return echoes output
|
383 |
-
*/
|
384 |
-
function qts_show_form_field($args = array()) {
|
385 |
-
global $qtranslate_slug;
|
386 |
-
|
387 |
-
extract( $args );
|
388 |
-
|
389 |
-
// get the settings sections array
|
390 |
-
$settings_output = qts_get_settings();
|
391 |
-
$options = $qtranslate_slug->get_options();
|
392 |
-
|
393 |
-
// pass the standard value if the option is not yet set in the database
|
394 |
-
if ( !isset( $options[$id] ) && 'type' != 'checkbox' ) {
|
395 |
-
$options[$id] = $std;
|
396 |
-
}
|
397 |
-
|
398 |
-
// additional field class. output only if the class is defined in the create_setting arguments
|
399 |
-
$field_class = ($class != '') ? ' ' . $class : '';
|
400 |
-
|
401 |
-
// switch html display based on the setting type.
|
402 |
-
switch ( $type ) {
|
403 |
-
case 'text':
|
404 |
-
$options[$id] = stripslashes($options[$id]);
|
405 |
-
$options[$id] = esc_attr( $options[$id]);
|
406 |
-
echo "<input class='regular-text$field_class' type='text' id='$id' name='" . QTS_OPTIONS_NAME . "[$id]' value='$options[$id]' />";
|
407 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
408 |
-
break;
|
409 |
-
|
410 |
-
case "multi-text":
|
411 |
-
foreach($choices as $item) {
|
412 |
-
|
413 |
-
$item = explode("|",$item); // cat_name|cat_slug
|
414 |
-
$item[0] = esc_html__($item[0], 'qts');
|
415 |
-
|
416 |
-
if (!empty($options[$id])) {
|
417 |
-
foreach ($options[$id] as $option_key => $option_val){
|
418 |
-
if ($item[1] == $option_key) {
|
419 |
-
$value = $option_val;
|
420 |
-
}
|
421 |
-
}
|
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;
|
430 |
-
|
431 |
-
case 'textarea':
|
432 |
-
$options[$id] = stripslashes($options[$id]);
|
433 |
-
$options[$id] = esc_html( $options[$id]);
|
434 |
-
echo "<textarea class='textarea$field_class' type='text' id='$id' name='" . QTS_OPTIONS_NAME . "[$id]' rows='5' cols='30'>$options[$id]</textarea>";
|
435 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
436 |
-
break;
|
437 |
-
|
438 |
-
case 'select':
|
439 |
-
echo "<select id='$id' class='select$field_class' name='" . QTS_OPTIONS_NAME . "[$id]'>";
|
440 |
-
foreach($choices as $item) {
|
441 |
-
$value = esc_attr($item, 'qts');
|
442 |
-
$item = esc_html($item, 'qts');
|
443 |
-
|
444 |
-
$selected = ($options[$id]==$value) ? 'selected="selected"' : '';
|
445 |
-
echo "<option value='$value' $selected>$item</option>";
|
446 |
-
}
|
447 |
-
echo "</select>";
|
448 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
449 |
-
break;
|
450 |
-
|
451 |
-
case 'select2':
|
452 |
-
echo "<select id='$id' class='select$field_class' name='" . QTS_OPTIONS_NAME . "[$id]'>";
|
453 |
-
foreach($choices as $item) {
|
454 |
-
|
455 |
-
$item = explode("|",$item);
|
456 |
-
$item[0] = esc_html($item[0], 'qts');
|
457 |
-
|
458 |
-
$selected = ($options[$id]==$item[1]) ? 'selected="selected"' : '';
|
459 |
-
echo "<option value='$item[1]' $selected>$item[0]</option>";
|
460 |
-
}
|
461 |
-
echo "</select>";
|
462 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
463 |
-
break;
|
464 |
-
|
465 |
-
case 'checkbox':
|
466 |
-
echo "<input class='checkbox$field_class' type='checkbox' id='$id' name='" . QTS_OPTIONS_NAME . "[$id]' value='1' " . checked( $options[$id], 1, false ) . " />";
|
467 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
468 |
-
break;
|
469 |
-
|
470 |
-
case "multi-checkbox":
|
471 |
-
foreach($choices as $item) {
|
472 |
-
|
473 |
-
$item = explode("|",$item);
|
474 |
-
$item[0] = esc_html($item[0], 'qts');
|
475 |
-
|
476 |
-
$checked = '';
|
477 |
-
|
478 |
-
if ( isset($options[$id][$item[1]]) ) {
|
479 |
-
if ( $options[$id][$item[1]] == 'true') {
|
480 |
-
$checked = 'checked="checked"';
|
481 |
-
}
|
482 |
-
}
|
483 |
-
|
484 |
-
echo "<input class='checkbox$field_class' type='checkbox' id='$id|$item[1]' name='" . QTS_OPTIONS_NAME . "[$id|$item[1]]' value='1' $checked /> $item[0] <br/>";
|
485 |
-
}
|
486 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
487 |
-
break;
|
488 |
-
|
489 |
-
case "multi-radio":
|
490 |
-
foreach($choices as $index => $item) {
|
491 |
-
|
492 |
-
$item = explode("|",$item);
|
493 |
-
$item_key = (count($item) > 1) ? esc_html($item[0], 'qts') : esc_html(end($item), 'qts');
|
494 |
-
$item_value = (count($item) > 1) ? esc_html($item[1], 'qts') : esc_html(end($item), 'qts');
|
495 |
-
|
496 |
-
$checked = '';
|
497 |
-
|
498 |
-
if ( isset($options[$id]) && $options[$id] === $item_value) {
|
499 |
-
$checked = 'checked="checked"';
|
500 |
-
}
|
501 |
-
|
502 |
-
echo "<label for='$id|$item_value'><input class='radio$field_class' type='radio' id='$id|$item_value' name='" . QTS_OPTIONS_NAME . "[$id]' value='$item_value' $checked /> <strong>$item_key</strong>";
|
503 |
-
if (isset($desc[$index]) && !empty($desc[$index])) {
|
504 |
-
echo ": " . $desc[$index];
|
505 |
-
}
|
506 |
-
echo "</label>";
|
507 |
-
}
|
508 |
-
echo (!is_array($desc) && $desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
509 |
-
break;
|
510 |
-
}
|
511 |
-
}
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
/**
|
516 |
-
* Validates base slugs per 'type' (post_type | taxonomy) and 'language'
|
517 |
-
*
|
518 |
-
* @package Qtranslate Slug
|
519 |
-
* @subpackage Settings
|
520 |
-
* @version 1.0
|
521 |
-
*
|
522 |
-
*/
|
523 |
-
function qts_sanitize_bases($base_slugs = false) {
|
524 |
-
|
525 |
-
if ( !$base_slugs || empty($base_slugs) ) return;
|
526 |
-
|
527 |
-
$base_slugs_processed = array();
|
528 |
-
$base_founded = array();
|
529 |
-
|
530 |
-
// changing array structure
|
531 |
-
foreach ($base_slugs as $type => $base) {
|
532 |
-
foreach ($base as $lang => $value) {
|
533 |
-
if ($value != ""):
|
534 |
-
$base_value = $value;
|
535 |
-
$count = 2;
|
536 |
-
while (in_array($value, $base_founded)) {
|
537 |
-
$value = "$base_value-$count";
|
538 |
-
$count++;
|
539 |
-
}
|
540 |
-
$base_founded[] = $base_slugs[$type][$lang] = $value;
|
541 |
-
endif;
|
542 |
-
}
|
543 |
-
}
|
544 |
-
|
545 |
-
return $base_slugs;
|
546 |
-
}
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
/**
|
551 |
-
* Admin Settings Page HTML
|
552 |
-
*
|
553 |
-
* @package Qtranslate Slug
|
554 |
-
* @subpackage Settings
|
555 |
-
* @version 1.0
|
556 |
-
*
|
557 |
-
* @return echoes output
|
558 |
-
*/
|
559 |
-
function qts_show_settings_page() {
|
560 |
-
// get the settings sections array
|
561 |
-
$settings_output = qts_get_settings();
|
562 |
-
?>
|
563 |
-
<div class="wrap">
|
564 |
-
<div class="icon32" id="icon-options-general"></div>
|
565 |
-
<h2><?php echo $settings_output['qts_page_title']; ?></h2>
|
566 |
-
|
567 |
-
<p><?php _e('If you activated previously the <a href="options-permalink.php">pretty permalinks</a>, in this section you can translate the <abbr title="en inglés, Universal Resource Locator">URLs</abbr> <strong>bases</strong> for <a href="http://codex.wordpress.org/Function_Reference/register_post_type#Arguments">public</a> post_types, categories, tags and taxonomies.', 'qts'); ?> </p>
|
568 |
-
|
569 |
-
<form action="options.php" method="post">
|
570 |
-
<?php
|
571 |
-
// upgrade notify
|
572 |
-
qts_upgrade();
|
573 |
-
// http://codex.wordpress.org/Function_Reference/settings_fields
|
574 |
-
settings_fields($settings_output['qts_option_name']);
|
575 |
-
|
576 |
-
// http://codex.wordpress.org/Function_Reference/do_settings_sections
|
577 |
-
do_settings_sections(__FILE__);
|
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 |
-
|
585 |
-
?>
|
586 |
-
<p>If you selected "none", copy and use these styles as you see fit:</p>
|
587 |
-
<textarea name="textarea" rows="10" cols="80"><?php echo $file_styles; ?></textarea>;
|
588 |
-
<p class="submit">
|
589 |
-
<input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes','qts'); ?>" />
|
590 |
-
</p>
|
591 |
-
|
592 |
-
</form>
|
593 |
-
</div><!-- wrap -->
|
594 |
-
<?php }
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
/**
|
599 |
-
* Validate input
|
600 |
-
*
|
601 |
-
* @package Qtranslate Slug
|
602 |
-
* @subpackage Settings
|
603 |
-
* @version 1.0
|
604 |
-
*
|
605 |
-
* @return array
|
606 |
-
*/
|
607 |
-
function qts_validate_options($input) {
|
608 |
-
|
609 |
-
// for enhanced security, create a new empty array
|
610 |
-
$valid_input = array();
|
611 |
-
|
612 |
-
// collect only the values we expect and fill the new $valid_input array
|
613 |
-
// i.e. whitelist our option IDs
|
614 |
-
|
615 |
-
// get the settings sections array
|
616 |
-
$settings_output = qts_get_settings();
|
617 |
-
|
618 |
-
$styleoptions = $settings_output['qts_page_styles'];
|
619 |
-
|
620 |
-
$slugoptions = $settings_output['qts_page_fields'];
|
621 |
-
|
622 |
-
$options = array_merge($styleoptions,$slugoptions);
|
623 |
-
|
624 |
-
// run a foreach and switch on option type
|
625 |
-
foreach ($options as $option):
|
626 |
-
|
627 |
-
switch ( $option['type'] ):
|
628 |
-
case 'text':
|
629 |
-
//switch validation based on the class!
|
630 |
-
switch ( $option['class'] ) {
|
631 |
-
//for numeric
|
632 |
-
case 'numeric':
|
633 |
-
//accept the input only when numeric!
|
634 |
-
$input[$option['id']] = trim($input[$option['id']]); // trim whitespace
|
635 |
-
$valid_input[$option['id']] = (is_numeric($input[$option['id']])) ? $input[$option['id']] : 'Expecting a Numeric value!';
|
636 |
-
|
637 |
-
// register error
|
638 |
-
if(is_numeric($input[$option['id']]) == FALSE) {
|
639 |
-
add_settings_error(
|
640 |
-
$option['id'], // setting title
|
641 |
-
QTS_PREFIX . '_txt_numeric_error', // error ID
|
642 |
-
__('Expecting a Numeric value! Please fix.', 'qts'), // error message
|
643 |
-
'error' // type of message
|
644 |
-
);
|
645 |
-
}
|
646 |
-
break;
|
647 |
-
|
648 |
-
//for multi-numeric values (separated by a comma)
|
649 |
-
case 'multinumeric':
|
650 |
-
//accept the input only when the numeric values are comma separated
|
651 |
-
$input[$option['id']] = trim($input[$option['id']]); // trim whitespace
|
652 |
-
|
653 |
-
if($input[$option['id']] !=''){
|
654 |
-
// /^-?\d+(?:,\s?-?\d+)*$/ matches: -1 | 1 | -12,-23 | 12,23 | -123, -234 | 123, 234 | etc.
|
655 |
-
$valid_input[$option['id']] = (preg_match('/^-?\d+(?:,\s?-?\d+)*$/', $input[$option['id']]) == 1) ? $input[$option['id']] : __('Expecting comma separated numeric values','qts');
|
656 |
-
}else{
|
657 |
-
$valid_input[$option['id']] = $input[$option['id']];
|
658 |
-
}
|
659 |
-
|
660 |
-
// register error
|
661 |
-
if($input[$option['id']] !='' && preg_match('/^-?\d+(?:,\s?-?\d+)*$/', $input[$option['id']]) != 1) {
|
662 |
-
add_settings_error(
|
663 |
-
$option['id'], // setting title
|
664 |
-
QTS_PREFIX . '_txt_multinumeric_error', // error ID
|
665 |
-
__('Expecting comma separated numeric values! Please fix.','qts'), // error message
|
666 |
-
'error' // type of message
|
667 |
-
);
|
668 |
-
}
|
669 |
-
break;
|
670 |
-
|
671 |
-
//for no html
|
672 |
-
case 'nohtml':
|
673 |
-
//accept the input only after stripping out all html, extra white space etc!
|
674 |
-
$input[$option['id']] = sanitize_text_field($input[$option['id']]); // need to add slashes still before sending to the database
|
675 |
-
$valid_input[$option['id']] = addslashes($input[$option['id']]);
|
676 |
-
break;
|
677 |
-
|
678 |
-
//for url
|
679 |
-
case 'url':
|
680 |
-
//accept the input only when the url has been sanited for database usage with esc_url_raw()
|
681 |
-
$input[$option['id']] = trim($input[$option['id']]); // trim whitespace
|
682 |
-
$valid_input[$option['id']] = esc_url_raw($input[$option['id']]);
|
683 |
-
break;
|
684 |
-
|
685 |
-
//for email
|
686 |
-
case 'email':
|
687 |
-
//accept the input only after the email has been validated
|
688 |
-
$input[$option['id']] = trim($input[$option['id']]); // trim whitespace
|
689 |
-
if($input[$option['id']] != ''){
|
690 |
-
$valid_input[$option['id']] = (is_email($input[$option['id']])!== FALSE) ? $input[$option['id']] : __('Invalid email', 'qts');
|
691 |
-
}elseif($input[$option['id']] == ''){
|
692 |
-
$valid_input[$option['id']] = __('This setting field cannot be empty! Please enter a valid email address.', 'qts');
|
693 |
-
}
|
694 |
-
|
695 |
-
// register error
|
696 |
-
if(is_email($input[$option['id']])== FALSE || $input[$option['id']] == '') {
|
697 |
-
add_settings_error(
|
698 |
-
$option['id'], // setting title
|
699 |
-
QTS_PREFIX . '_txt_email_error', // error ID
|
700 |
-
__('Please enter a valid email address.', 'qts'), // error message
|
701 |
-
'error' // type of message
|
702 |
-
);
|
703 |
-
}
|
704 |
-
break;
|
705 |
-
|
706 |
-
// a "cover-all" fall-back when the class argument is not set
|
707 |
-
default:
|
708 |
-
// accept only a few inline html elements
|
709 |
-
$allowed_html = array(
|
710 |
-
'a' => array('href' => array (),'title' => array ()),
|
711 |
-
'b' => array(),
|
712 |
-
'em' => array (),
|
713 |
-
'i' => array (),
|
714 |
-
'strong' => array()
|
715 |
-
);
|
716 |
-
// trim whitespace
|
717 |
-
$input[$option['id']] = trim($input[$option['id']]);
|
718 |
-
// find incorrectly nested or missing closing tags and fix markup
|
719 |
-
$input[$option['id']] = force_balance_tags($input[$option['id']]);
|
720 |
-
// need to add slashes still before sending to the database
|
721 |
-
$input[$option['id']] = wp_kses( $input[$option['id']], $allowed_html);
|
722 |
-
|
723 |
-
$valid_input[$option['id']] = addslashes($input[$option['id']]);
|
724 |
-
break;
|
725 |
-
}
|
726 |
-
break;
|
727 |
-
|
728 |
-
case "multi-text":
|
729 |
-
// this will hold the text values as an array of 'key' => 'value'
|
730 |
-
unset($textarray);
|
731 |
-
|
732 |
-
$text_values = array();
|
733 |
-
foreach ($option['choices'] as $k => $v ) {
|
734 |
-
// explode the connective
|
735 |
-
$pieces = explode("|", $v);
|
736 |
-
|
737 |
-
$text_values[] = $pieces[1];
|
738 |
-
}
|
739 |
-
|
740 |
-
foreach ($text_values as $v ) {
|
741 |
-
|
742 |
-
// Check that the option isn't empty
|
743 |
-
if (!empty($input[$option['id'] . '|' . $v])) {
|
744 |
-
// If it's not null, make sure it's sanitized, add it to an array
|
745 |
-
switch ($option['class']) {
|
746 |
-
// different sanitation actions based on the class create you own cases as you need them
|
747 |
-
|
748 |
-
//for numeric input
|
749 |
-
case 'numeric':
|
750 |
-
//accept the input only if is numberic!
|
751 |
-
$input[$option['id'] . '|' . $v]= trim($input[$option['id'] . '|' . $v]); // trim whitespace
|
752 |
-
$input[$option['id'] . '|' . $v]= (is_numeric($input[$option['id'] . '|' . $v])) ? $input[$option['id'] . '|' . $v] : '';
|
753 |
-
break;
|
754 |
-
|
755 |
-
case 'qts-slug':
|
756 |
-
// strip all html tags and white-space.
|
757 |
-
$type_ = end( explode('_', $option['id']) );
|
758 |
-
$input[$option['id'] . '|' . $v]= sanitize_title( sanitize_text_field( $input[$option['id'] . '|' . $v] ) );
|
759 |
-
$input[$option['id'] . '|' . $v]= addslashes($input[$option['id'] . '|' . $v]);
|
760 |
-
break;
|
761 |
-
|
762 |
-
// a "cover-all" fall-back when the class argument is not set
|
763 |
-
default:
|
764 |
-
// strip all html tags and white-space.
|
765 |
-
$input[$option['id'] . '|' . $v]= sanitize_text_field($input[$option['id'] . '|' . $v]); // need to add slashes still before sending to the database
|
766 |
-
$input[$option['id'] . '|' . $v]= addslashes($input[$option['id'] . '|' . $v]);
|
767 |
-
break;
|
768 |
-
}
|
769 |
-
// pass the sanitized user input to our $textarray array
|
770 |
-
$textarray[$v] = $input[$option['id'] . '|' . $v];
|
771 |
-
|
772 |
-
} else {
|
773 |
-
$textarray[$v] = '';
|
774 |
-
}
|
775 |
-
}
|
776 |
-
// pass the non-empty $textarray to our $valid_input array
|
777 |
-
if (!empty($textarray)) {
|
778 |
-
$valid_input[$option['id']] = $textarray;
|
779 |
-
}
|
780 |
-
break;
|
781 |
-
|
782 |
-
case 'textarea':
|
783 |
-
//switch validation based on the class!
|
784 |
-
switch ( $option['class'] ) {
|
785 |
-
//for only inline html
|
786 |
-
case 'inlinehtml':
|
787 |
-
// accept only inline html
|
788 |
-
// trim whitespace
|
789 |
-
$input[$option['id']] = trim($input[$option['id']]);
|
790 |
-
// find incorrectly nested or missing closing tags and fix markup
|
791 |
-
$input[$option['id']] = force_balance_tags($input[$option['id']]);
|
792 |
-
//wp_filter_kses expects content to be escaped!
|
793 |
-
$input[$option['id']] = addslashes($input[$option['id']]);
|
794 |
-
//calls stripslashes then addslashes
|
795 |
-
$valid_input[$option['id']] = wp_filter_kses($input[$option['id']]);
|
796 |
-
break;
|
797 |
-
|
798 |
-
//for no html
|
799 |
-
case 'nohtml':
|
800 |
-
//accept the input only after stripping out all html, extra white space etc!
|
801 |
-
// need to add slashes still before sending to the database
|
802 |
-
$input[$option['id']] = sanitize_text_field($input[$option['id']]);
|
803 |
-
$valid_input[$option['id']] = addslashes($input[$option['id']]);
|
804 |
-
break;
|
805 |
-
|
806 |
-
//for allowlinebreaks
|
807 |
-
case 'allowlinebreaks':
|
808 |
-
//accept the input only after stripping out all html, extra white space etc!
|
809 |
-
// need to add slashes still before sending to the database
|
810 |
-
$input[$option['id']] = wp_strip_all_tags($input[$option['id']]);
|
811 |
-
$valid_input[$option['id']] = addslashes($input[$option['id']]);
|
812 |
-
break;
|
813 |
-
|
814 |
-
// a "cover-all" fall-back when the class argument is not set
|
815 |
-
default:
|
816 |
-
// accept only limited html
|
817 |
-
//my allowed html
|
818 |
-
$allowed_html = array(
|
819 |
-
'a' => array('href' => array (),'title' => array ()),
|
820 |
-
'b' => array(),
|
821 |
-
'blockquote' => array('cite' => array ()),
|
822 |
-
'br' => array(),
|
823 |
-
'dd' => array(),
|
824 |
-
'dl' => array(),
|
825 |
-
'dt' => array(),
|
826 |
-
'em' => array (),
|
827 |
-
'i' => array (),
|
828 |
-
'li' => array(),
|
829 |
-
'ol' => array(),
|
830 |
-
'p' => array(),
|
831 |
-
'q' => array('cite' => array ()),
|
832 |
-
'strong' => array(),
|
833 |
-
'ul' => array(),
|
834 |
-
'h1' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ()),
|
835 |
-
'h2' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ()),
|
836 |
-
'h3' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ()),
|
837 |
-
'h4' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ()),
|
838 |
-
'h5' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ()),
|
839 |
-
'h6' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ())
|
840 |
-
);
|
841 |
-
|
842 |
-
$input[$option['id']] = trim($input[$option['id']]); // trim whitespace
|
843 |
-
$input[$option['id']] = force_balance_tags($input[$option['id']]); // find incorrectly nested or missing closing tags and fix markup
|
844 |
-
$input[$option['id']] = wp_kses( $input[$option['id']], $allowed_html); // need to add slashes still before sending to the database
|
845 |
-
$valid_input[$option['id']] = addslashes($input[$option['id']]);
|
846 |
-
break;
|
847 |
-
}
|
848 |
-
break;
|
849 |
-
|
850 |
-
case 'select':
|
851 |
-
// check to see if the selected value is in our approved array of values!
|
852 |
-
$valid_input[$option['id']] = (in_array( $input[$option['id']], $option['choices']) ? $input[$option['id']] : '' );
|
853 |
-
break;
|
854 |
-
|
855 |
-
case 'select2':
|
856 |
-
// process $select_values
|
857 |
-
$select_values = array();
|
858 |
-
foreach ($option['choices'] as $k => $v) {
|
859 |
-
// explode the connective
|
860 |
-
$pieces = explode("|", $v);
|
861 |
-
|
862 |
-
$select_values[] = $pieces[1];
|
863 |
-
}
|
864 |
-
// check to see if selected value is in our approved array of values!
|
865 |
-
$valid_input[$option['id']] = (in_array( $input[$option['id']], $select_values) ? $input[$option['id']] : '' );
|
866 |
-
break;
|
867 |
-
|
868 |
-
case 'checkbox':
|
869 |
-
// if it's not set, default to null!
|
870 |
-
if (!isset($input[$option['id']])) {
|
871 |
-
$input[$option['id']] = null;
|
872 |
-
}
|
873 |
-
// Our checkbox value is either 0 or 1
|
874 |
-
$valid_input[$option['id']] = ( $input[$option['id']] == 1 ? 1 : 0 );
|
875 |
-
break;
|
876 |
-
|
877 |
-
case 'multi-checkbox':
|
878 |
-
unset($checkboxarray);
|
879 |
-
$check_values = array();
|
880 |
-
foreach ($option['choices'] as $k => $v ) {
|
881 |
-
// explode the connective
|
882 |
-
$pieces = explode("|", $v);
|
883 |
-
|
884 |
-
$check_values[] = $pieces[1];
|
885 |
-
}
|
886 |
-
|
887 |
-
foreach ($check_values as $v ) {
|
888 |
-
|
889 |
-
// Check that the option isn't null
|
890 |
-
if (!empty($input[$option['id'] . '|' . $v])) {
|
891 |
-
// If it's not null, make sure it's true, add it to an array
|
892 |
-
$checkboxarray[$v] = 'true';
|
893 |
-
}
|
894 |
-
else {
|
895 |
-
$checkboxarray[$v] = 'false';
|
896 |
-
}
|
897 |
-
}
|
898 |
-
// Take all the items that were checked, and set them as the main option
|
899 |
-
if (!empty($checkboxarray)) {
|
900 |
-
$valid_input[$option['id']] = $checkboxarray;
|
901 |
-
}
|
902 |
-
break;
|
903 |
-
|
904 |
-
case 'multi-radio':
|
905 |
-
$valid_input[$option['id']] = (empty($input) || !isset($input[$option['id']])) ? $option['std'] : $input[$option['id']];
|
906 |
-
break;
|
907 |
-
|
908 |
-
endswitch;
|
909 |
-
|
910 |
-
if (!empty($valid_input) && $valid_input[$option['id']] === "qts-slug" ) {
|
911 |
-
$valid_input = qts_sanitize_bases($valid_input);
|
912 |
-
} else {
|
913 |
-
$valid_input= $valid_input;
|
914 |
-
}
|
915 |
-
|
916 |
-
endforeach;
|
917 |
-
|
918 |
-
return $valid_input;
|
919 |
-
}
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
/**
|
924 |
-
* Helper function for creating admin messages
|
925 |
-
*
|
926 |
-
* @package Qtranslate Slug
|
927 |
-
* @subpackage Settings
|
928 |
-
* @version 1.0
|
929 |
-
*
|
930 |
-
* src: http://www.wprecipes.com/how-to-show-an-urgent-message-in-the-wordpress-admin-area
|
931 |
-
*
|
932 |
-
* @param (string) $message The message to echo
|
933 |
-
* @param (string) $msgclass The message class
|
934 |
-
* @return echoes the message
|
935 |
-
*/
|
936 |
-
function qts_show_msg($message, $msgclass = 'info') {
|
937 |
-
echo "<div id='message' class='$msgclass'>$message</div>";
|
938 |
-
}
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
/**
|
943 |
-
* Callback function for displaying admin messages
|
944 |
-
*
|
945 |
-
* @package Qtranslate Slug
|
946 |
-
* @subpackage Settings
|
947 |
-
* @version 1.0
|
948 |
-
*
|
949 |
-
* @return calls qts_show_msg()
|
950 |
-
*/
|
951 |
-
function qts_admin_msgs() {
|
952 |
-
global $current_screen;
|
953 |
-
|
954 |
-
// check for our settings page - need this in conditional further down
|
955 |
-
$qts_settings_pg = isset($_GET['page']) ? strpos($_GET['page'], QTS_PAGE_BASENAME) : '';
|
956 |
-
// collect setting errors/notices:
|
957 |
-
// http://codex.wordpress.org/Function_Reference/get_settings_errors
|
958 |
-
$set_errors = get_settings_errors();
|
959 |
-
|
960 |
-
// display admin message only for the admin to see, only on our settings page
|
961 |
-
// and only when setting errors/notices are returned!
|
962 |
-
if(current_user_can ('manage_options') && $qts_settings_pg !== false && !empty($set_errors)){
|
963 |
-
|
964 |
-
// have our settings succesfully been updated?
|
965 |
-
if($set_errors[0]['code'] == 'settings_updated' && isset($_GET['settings-updated'])){
|
966 |
-
qts_show_msg("<p>" . $set_errors[0]['message'] . "</p>", 'updated');
|
967 |
-
|
968 |
-
// have errors been found?
|
969 |
-
}else{
|
970 |
-
// there maybe more than one so run a foreach loop.
|
971 |
-
foreach($set_errors as $set_error){
|
972 |
-
// set the title attribute to match the error "setting title" - need this in js file
|
973 |
-
qts_show_msg("<p class='setting-error-message' title='" . $set_error['setting'] . "'>" . $set_error['message'] . "</p>", 'error');
|
974 |
-
}
|
975 |
-
}
|
976 |
-
}
|
977 |
-
}
|
978 |
-
add_action('admin_notices', 'qts_admin_msgs');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/includes/termmeta-core.php
DELETED
@@ -1,222 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Install Term meta table - setup table, store db version for future updates
|
4 |
-
*/
|
5 |
-
if ( !function_exists('install_term_meta_table') ):
|
6 |
-
function install_term_meta_table() {
|
7 |
-
global $wpdb;
|
8 |
-
|
9 |
-
$collate = '';
|
10 |
-
if($wpdb->supports_collation()) {
|
11 |
-
if(!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
12 |
-
if(!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
|
13 |
-
}
|
14 |
-
|
15 |
-
$sql = "CREATE TABLE IF NOT EXISTS ". $wpdb->prefix . "termmeta" ." (
|
16 |
-
`meta_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
17 |
-
`term_id` bigint(20) NOT NULL DEFAULT '0',
|
18 |
-
`meta_key` varchar(255) NULL,
|
19 |
-
`meta_value` longtext NULL,
|
20 |
-
PRIMARY KEY id (`meta_id`)) $collate;";
|
21 |
-
$wpdb->query($sql);
|
22 |
-
}
|
23 |
-
endif;
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
function simple_post_meta_define_table() {
|
28 |
-
global $wpdb;
|
29 |
-
$wpdb->termmeta = $wpdb->prefix . 'termmeta';
|
30 |
-
}
|
31 |
-
add_action( 'init', 'simple_post_meta_define_table' );
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Updates metadata cache for list of term IDs.
|
37 |
-
*
|
38 |
-
* Performs SQL query to retrieve the metadata for the term IDs and updates the
|
39 |
-
* metadata cache for the terms. Therefore, the functions, which call this
|
40 |
-
* function, do not need to perform SQL queries on their own.
|
41 |
-
*
|
42 |
-
* @param array $term_ids List of post IDs.
|
43 |
-
* @return bool|array Returns false if there is nothing to update or an array of metadata.
|
44 |
-
*/
|
45 |
-
if ( !function_exists('update_termmeta_cache') ):
|
46 |
-
function update_termmeta_cache($term_ids) {
|
47 |
-
return update_meta_cache('term', $term_ids);
|
48 |
-
}
|
49 |
-
endif;
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Add meta data field to a term.
|
55 |
-
*
|
56 |
-
* @param int $term_id Term ID.
|
57 |
-
* @param string $key Metadata name.
|
58 |
-
* @param mixed $value Metadata value.
|
59 |
-
* @param bool $unique Optional, default is false. Whether the same key should not be added.
|
60 |
-
* @return bool False for failure. True for success.
|
61 |
-
*/
|
62 |
-
if ( !function_exists('add_term_meta') ):
|
63 |
-
function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) {
|
64 |
-
return add_metadata('term', $term_id, $meta_key, $meta_value, $unique);
|
65 |
-
}
|
66 |
-
endif;
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Remove metadata matching criteria from a term.
|
72 |
-
*
|
73 |
-
* You can match based on the key, or key and value. Removing based on key and
|
74 |
-
* value, will keep from removing duplicate metadata with the same key. It also
|
75 |
-
* allows removing all metadata matching key, if needed.
|
76 |
-
*
|
77 |
-
* @param int $term_id Term ID
|
78 |
-
* @param string $meta_key Metadata name.
|
79 |
-
* @param mixed $meta_value Optional. Metadata value.
|
80 |
-
* @return bool False for failure. True for success.
|
81 |
-
*/
|
82 |
-
if ( !function_exists('delete_term_meta') ):
|
83 |
-
function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) {
|
84 |
-
return delete_metadata('term', $term_id, $meta_key, $meta_value);
|
85 |
-
}
|
86 |
-
endif;
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Retrieve term meta field for a term.
|
92 |
-
*
|
93 |
-
* @param int $term_id Term ID.
|
94 |
-
* @param string $key The meta key to retrieve.
|
95 |
-
* @param bool $single Whether to return a single value.
|
96 |
-
* @return mixed Will be an array if $single is false. Will be value of meta data field if $single
|
97 |
-
* is true.
|
98 |
-
*/
|
99 |
-
if ( !function_exists('get_term_meta') ):
|
100 |
-
function get_term_meta( $term_id, $key, $single = false ) {
|
101 |
-
return get_metadata('term', $term_id, $key, $single);
|
102 |
-
}
|
103 |
-
endif;
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Update term meta field based on term ID.
|
109 |
-
*
|
110 |
-
* Use the $prev_value parameter to differentiate between meta fields with the
|
111 |
-
* same key and term ID.
|
112 |
-
*
|
113 |
-
* If the meta field for the term does not exist, it will be added.
|
114 |
-
*
|
115 |
-
* @param int $term_id Term ID.
|
116 |
-
* @param string $key Metadata key.
|
117 |
-
* @param mixed $value Metadata value.
|
118 |
-
* @param mixed $prev_value Optional. Previous value to check before removing.
|
119 |
-
* @return bool False on failure, true if success.
|
120 |
-
*/
|
121 |
-
if ( !function_exists('update_term_meta') ):
|
122 |
-
function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) {
|
123 |
-
return update_metadata('term', $term_id, $meta_key, $meta_value, $prev_value);
|
124 |
-
}
|
125 |
-
endif;
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Delete everything from term meta matching meta key.
|
131 |
-
*
|
132 |
-
* @param string $term_meta_key Key to search for when deleting.
|
133 |
-
* @return bool Whether the term meta key was deleted from the database
|
134 |
-
*/
|
135 |
-
if ( !function_exists('delete_term_meta_by_key') ):
|
136 |
-
function delete_term_meta_by_key($term_meta_key) {
|
137 |
-
if ( !$term_meta_key )
|
138 |
-
return false;
|
139 |
-
|
140 |
-
global $wpdb;
|
141 |
-
$term_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT term_id FROM $wpdb->termmeta WHERE meta_key = %s", $term_meta_key));
|
142 |
-
if ( $term_ids ) {
|
143 |
-
$termmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE meta_key = %s", $term_meta_key ) );
|
144 |
-
$in = implode( ',', array_fill(1, count($termmetaids), '%d'));
|
145 |
-
do_action( 'delete_termmeta', $termmetaids );
|
146 |
-
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->termmeta WHERE meta_id IN($in)", $termmetaids ));
|
147 |
-
do_action( 'deleted_termmeta', $termmetaids );
|
148 |
-
foreach ( $term_ids as $term_id )
|
149 |
-
wp_cache_delete($term_id, 'term_meta');
|
150 |
-
return true;
|
151 |
-
}
|
152 |
-
return false;
|
153 |
-
}
|
154 |
-
endif;
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Retrieve term meta fields, based on term ID.
|
160 |
-
*
|
161 |
-
* The term meta fields are retrieved from the cache, so the function is
|
162 |
-
* optimized to be called more than once. It also applies to the functions, that
|
163 |
-
* use this function.
|
164 |
-
*
|
165 |
-
* @param int $term_id term ID
|
166 |
-
* @return array
|
167 |
-
*/
|
168 |
-
if ( !function_exists('add_term_meta') ):
|
169 |
-
function get_term_custom( $term_id ) {
|
170 |
-
$term_id = (int) $term_id;
|
171 |
-
|
172 |
-
if ( ! wp_cache_get($term_id, 'term_meta') )
|
173 |
-
update_termmeta_cache($term_id);
|
174 |
-
|
175 |
-
return wp_cache_get($term_id, 'term_meta');
|
176 |
-
}
|
177 |
-
endif;
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Retrieve meta field names for a term.
|
183 |
-
*
|
184 |
-
* If there are no meta fields, then nothing (null) will be returned.
|
185 |
-
*
|
186 |
-
* @param int $term_id term ID
|
187 |
-
* @return array|null Either array of the keys, or null if keys could not be retrieved.
|
188 |
-
*/
|
189 |
-
if ( !function_exists('get_term_custom_keys') ):
|
190 |
-
function get_term_custom_keys( $term_id ) {
|
191 |
-
$custom = get_term_custom( $term_id );
|
192 |
-
|
193 |
-
if ( !is_array($custom) )
|
194 |
-
return;
|
195 |
-
|
196 |
-
if ( $keys = array_keys($custom) )
|
197 |
-
return $keys;
|
198 |
-
}
|
199 |
-
endif;
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Retrieve values for a custom term field.
|
205 |
-
*
|
206 |
-
* The parameters must not be considered optional. All of the term meta fields
|
207 |
-
* will be retrieved and only the meta field key values returned.
|
208 |
-
*
|
209 |
-
* @param string $key Meta field key.
|
210 |
-
* @param int $term_id Term ID
|
211 |
-
* @return array Meta field values.
|
212 |
-
*/
|
213 |
-
if ( !function_exists('get_term_custom_values') ):
|
214 |
-
function get_term_custom_values( $key = '', $term_id ) {
|
215 |
-
if ( !$key )
|
216 |
-
return null;
|
217 |
-
|
218 |
-
$custom = get_term_custom($term_id);
|
219 |
-
|
220 |
-
return isset($custom[$key]) ? $custom[$key] : null;
|
221 |
-
}
|
222 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/languages/qts-es_ES.mo
DELETED
Binary file
|
trunk/languages/qts-es_ES.po
DELETED
@@ -1,142 +0,0 @@
|
|
1 |
-
# Copyright (C) 2012 qTranslate slug
|
2 |
-
# This file is distributed under the same license as the qTranslate slug package.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"Project-Id-Version: qTranslate slug 1.0\n"
|
6 |
-
"Report-Msgid-Bugs-To: http://wordpress.org/tag/qtranslate-slug\n"
|
7 |
-
"POT-Creation-Date: 2012-05-27 20:27:55+00:00\n"
|
8 |
-
"MIME-Version: 1.0\n"
|
9 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
-
"Content-Transfer-Encoding: 8bit\n"
|
11 |
-
"PO-Revision-Date: 2012-06-17 03:37+0100\n"
|
12 |
-
"Last-Translator: Carlos Sanz <carlos.sanz@gmail.com>\n"
|
13 |
-
"Language-Team: Carlos Sanz Garcia <carlos.sanz@gmail.com>\n"
|
14 |
-
|
15 |
-
# qtranslate-slug.php
|
16 |
-
msgid "Language selector"
|
17 |
-
msgstr "Selector de idioma"
|
18 |
-
|
19 |
-
# qtranslate-slug.php
|
20 |
-
msgid "Title:"
|
21 |
-
msgstr "Título:"
|
22 |
-
|
23 |
-
# qtranslate-slug.php
|
24 |
-
msgid "<p style=\"color:red\">This plugin requires qTranslate to be installed and activated.</p>"
|
25 |
-
msgstr "<p style=\"color:red\">Este plugin necesita qTranslate instalado y activado previamente.</p>"
|
26 |
-
|
27 |
-
# qtranslate-slug.php
|
28 |
-
msgid "Slug"
|
29 |
-
msgstr "Enlace permanente"
|
30 |
-
|
31 |
-
# qtranslate-slug.php
|
32 |
-
msgid "Show short name (en):"
|
33 |
-
msgstr "Mostrar nombre corto (en):"
|
34 |
-
|
35 |
-
# qtranslate-slug-settings-options.php
|
36 |
-
msgid "Post types"
|
37 |
-
msgstr "Post types"
|
38 |
-
|
39 |
-
# qtranslate-slug-settings-options.php
|
40 |
-
msgid "Taxonomies"
|
41 |
-
msgstr "Taxonomias"
|
42 |
-
|
43 |
-
# qtranslate-slug-settings-options.php
|
44 |
-
msgid "Slug (%s)"
|
45 |
-
msgstr "URL (%s)"
|
46 |
-
|
47 |
-
# qtranslate-slug-settings-options.php
|
48 |
-
msgid "<code>http://example.org/<u>%s</u>/some-%s/</code>"
|
49 |
-
msgstr "<code>http://ejemplo.org/<u>%s</u>/algun-%s/</code>"
|
50 |
-
|
51 |
-
# qtranslate-slug-settings-options.php
|
52 |
-
msgid "<code>http://example.org/<u>category</u>/some-category/</code>"
|
53 |
-
msgstr "<code>http://ejemplo.org/<u>categoria</u>/alguna-categoria/</code>"
|
54 |
-
|
55 |
-
# qtranslate-slug-settings-options.php
|
56 |
-
msgid "<code>http://example.org/<u>tag</u>/some-tag/</code>"
|
57 |
-
msgstr "<code>http://ejemplo.org/<u>etiqueta</u>/alguna-etiqueta/</code>"
|
58 |
-
|
59 |
-
# qtranslate-slug-settings.php
|
60 |
-
msgid "Qtranslate Slug options"
|
61 |
-
msgstr "Opciones de Qtranslate Slug"
|
62 |
-
|
63 |
-
# qtranslate-slug-settings.php
|
64 |
-
msgid "Slug options"
|
65 |
-
msgstr "Opciones de URL"
|
66 |
-
|
67 |
-
# qtranslate-slug-settings.php
|
68 |
-
msgid "Save Changes"
|
69 |
-
msgstr "Guardar cambios"
|
70 |
-
|
71 |
-
# qtranslate-slug-settings.php
|
72 |
-
msgid "Expecting a Numeric value! Please fix."
|
73 |
-
msgstr "Se espera un valor numérico! Por favor, corrígelo."
|
74 |
-
|
75 |
-
# qtranslate-slug-settings.php
|
76 |
-
msgid "Expecting comma separated numeric values! Please fix."
|
77 |
-
msgstr "Se esperan valores numéricos separados por coma! Por favor, corrígelo."
|
78 |
-
|
79 |
-
# qtranslate-slug-settings.php
|
80 |
-
msgid "Invalid email"
|
81 |
-
msgstr "E-mail incorrecto"
|
82 |
-
|
83 |
-
# qtranslate-slug-settings.php
|
84 |
-
msgid "This setting field cannot be empty! Please enter a valid email address."
|
85 |
-
msgstr "Este campo no puede estar vacío! Por favor introduce una dirección de e-mail válida."
|
86 |
-
|
87 |
-
# qtranslate-slug-settings.php
|
88 |
-
msgid "Please enter a valid email address."
|
89 |
-
msgstr "Por favor introduce una dirección de e-mail válida."
|
90 |
-
|
91 |
-
# qtranslate-slug-settings.php
|
92 |
-
msgid "upgrade now"
|
93 |
-
msgstr "actualizar ahora"
|
94 |
-
|
95 |
-
# qtranslate-slug.php
|
96 |
-
msgid "Please update your old data to the new system."
|
97 |
-
msgstr "Por favor actualiza tu antiguo sistema de datos al nuevo."
|
98 |
-
|
99 |
-
# qtranslate-slug-settings.php
|
100 |
-
msgid "Upgrade your data"
|
101 |
-
msgstr "Actualiza tus datos"
|
102 |
-
|
103 |
-
# qtranslate-slug-settings.php
|
104 |
-
msgid "There are slugs stored with old data system. Please upgrade your data pressing upgrade button:"
|
105 |
-
msgstr "Hay slugs almacenados en el antiguo sistema. Por favor actualiza tus datos aprentando el botón actualizar:"
|
106 |
-
|
107 |
-
# qtranslate-slug-settings.php
|
108 |
-
msgid "Sorry, some error happened. Refresh this page and try again please."
|
109 |
-
msgstr "Lo sentimos, algún tipo de error ha ocurrido. Por favor recarga esta página y prueba otra vez."
|
110 |
-
|
111 |
-
# qtranslate-slug-settings.php
|
112 |
-
msgid "Congratulations, your data has been upgraded, you are up to date."
|
113 |
-
msgstr "Felicidades, tus datos se han actualizado, ahora estás al día."
|
114 |
-
|
115 |
-
# qtranslate-slug-settings.php
|
116 |
-
msgid "One step more, select what type of slug is this: <strong>%s</strong>"
|
117 |
-
msgstr "Un paso más, selecction qué tipo de slug es este: <strong>%s</strong>"
|
118 |
-
|
119 |
-
# qtranslate-slug-settings.php
|
120 |
-
msgid "Post, Page or Custom post type"
|
121 |
-
msgstr "Entrada, Página o Custom post type"
|
122 |
-
|
123 |
-
# qtranslate-slug-settings.php
|
124 |
-
msgid "Category, tag or custom taxonomy"
|
125 |
-
msgstr "Categoria, tag o taxonomía"
|
126 |
-
|
127 |
-
# qtranslate-slug.php
|
128 |
-
msgid "This plugin requires at least <strong>Wordpress 3.3</strong> and <strong>Qtranslate(2.5.8 or newer)</strong>"
|
129 |
-
msgstr "Este plugin requiere al menos <strong>Wordpress 3.3</strong> y <strong>Qtranslate(2.5.8 o mayor)</strong>"
|
130 |
-
|
131 |
-
# qtranslate-slug-settings.php
|
132 |
-
msgid "If you activated previously the <a href=\"options-permalink.php\">pretty permalinks</a>, in this section you can translate the <abbr title=\"en inglés, Universal Resource Locator\">URLs</abbr> <strong>bases</strong> for <a href=\"http://codex.wordpress.org/Function_Reference/register_post_type#Arguments\">public</a> post_types, categories, tags and taxonomies."
|
133 |
-
msgstr "Si has activado previamente los <a href=\"options-permalink.php\">enlaces permanentes</a>, en esta sección podrás traducir las <strong>bases</strong> de las <abbr title=\"en inglés, Universal Resource Locator\">URLs</abbr> para post_types, categorías, etiquetas y taxonomias <a href=\"http://codex.wordpress.org/Function_Reference/register_post_type#Arguments\">públicas</a>."
|
134 |
-
|
135 |
-
# qtranslate-slug-settings.php
|
136 |
-
msgid "For example, the post_type <kbd>books</kbd>, in Spanish would be displayed as <code>http://example.org/es/libros/post-type-name/</code>. If you leave this blank will use the default option when you <a href=\"http://codex.wordpress.org/Function_Reference/register_post_type\">registered</a> the post_type."
|
137 |
-
msgstr "Por ejemplo, para el post_type <kbd>books</kbd> en Español se mostraría como <code>http://example.org/es/libros/post-type-name/</code>. Si dejas esto en blanco se usará la opción predeterminada cuando <a href=\"http://codex.wordpress.org/Function_Reference/register_post_type\">registraste</a> el post_type."
|
138 |
-
|
139 |
-
# qtranslate-slug-settings.php
|
140 |
-
msgid "For example, the taxonomy <kbd>category</kbd>, in Spanish would be displayed as <code>http://example.org/es/categoria/taxonomy-name/</code>. If you leave this blank will use the default option when you <a href=\"http://codex.wordpress.org/Function_Reference/register_taxonomy\">registered</a> the taxonomy (if you previously setup a base permastruct for <u>categories</u> or <u>tags</u> in <a href=\"options-permalink.php\">permalinks</a> page, these bases will be overwritten by the translated ones)."
|
141 |
-
msgstr "Por ejemplo, la taxonomia <kbd>category</kbd>, en Español se mostraría como <code>http://example.org/es/categoria/taxonomy-name/</code>. Si dejas esto en blanco se usará la opción predeterminada cuando <a href=\"http://codex.wordpress.org/Function_Reference/register_taxonomy\">registraste</a> la texonomia (si previamente configuraste la base de las estructuraas de <u>categorías</u> o <u>tags</u> en la página <a href=\"options-permalink.php\">enlaces permanentes</a>, estas bases serán reemplazadas por las traducidas)."
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/languages/qts-pt_PT.mo
DELETED
Binary file
|
trunk/languages/qts-pt_PT.po
DELETED
@@ -1,199 +0,0 @@
|
|
1 |
-
# Copyright (C) 2012 qTranslate slug
|
2 |
-
# This file is distributed under the same license as the qTranslate slug package.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"Project-Id-Version: qTranslate slug 1.0\n"
|
6 |
-
"Report-Msgid-Bugs-To: http://wordpress.org/tag/qtranslate-slug\n"
|
7 |
-
"POT-Creation-Date: 2012-05-27 20:27:55+00:00\n"
|
8 |
-
"PO-Revision-Date: 2014-05-22 12:29-0000\n"
|
9 |
-
"Last-Translator: Pedro Mendonça <ped.gaspar@gmail.com>\n"
|
10 |
-
"Language-Team: Pedro Mendonça <ped.gaspar@gmail.com>\n"
|
11 |
-
"Language: pt_PT\n"
|
12 |
-
"MIME-Version: 1.0\n"
|
13 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
-
"Content-Transfer-Encoding: 8bit\n"
|
15 |
-
"X-Generator: Poedit 1.6.4\n"
|
16 |
-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
17 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
18 |
-
|
19 |
-
#: qtranslate-slug.php
|
20 |
-
msgid "Language selector"
|
21 |
-
msgstr "Selector de idioma"
|
22 |
-
|
23 |
-
#: qtranslate-slug.php
|
24 |
-
msgid "Title:"
|
25 |
-
msgstr "Título:"
|
26 |
-
|
27 |
-
#: qtranslate-slug.php
|
28 |
-
msgid ""
|
29 |
-
"<p style=\"color:red\">This plugin requires qTranslate to be installed and "
|
30 |
-
"activated.</p>"
|
31 |
-
msgstr ""
|
32 |
-
"<p style=\"color:red\">Este plugin necessita do qTranslate instalado e "
|
33 |
-
"activado previamente.</p>"
|
34 |
-
|
35 |
-
#: qtranslate-slug.php
|
36 |
-
msgid "Slug"
|
37 |
-
msgstr "URL"
|
38 |
-
|
39 |
-
#: qtranslate-slug.php
|
40 |
-
msgid "Show short name (en):"
|
41 |
-
msgstr "Mostrar abreviatura (pt):"
|
42 |
-
|
43 |
-
#: qtranslate-slug-settings-options.php
|
44 |
-
msgid "Post types"
|
45 |
-
msgstr "Tipos de artigos"
|
46 |
-
|
47 |
-
#: qtranslate-slug-settings-options.php
|
48 |
-
msgid "Taxonomies"
|
49 |
-
msgstr "Taxonomias"
|
50 |
-
|
51 |
-
#: qtranslate-slug-settings-options.php
|
52 |
-
msgid "Slug (%s)"
|
53 |
-
msgstr "URL (%s)"
|
54 |
-
|
55 |
-
#: qtranslate-slug-settings-options.php
|
56 |
-
msgid "<code>http://example.org/<u>%s</u>/some-%s/</code>"
|
57 |
-
msgstr "<code>http://exemplo.org/<u>%s</u>/qualquer-%s/</code>"
|
58 |
-
|
59 |
-
#: qtranslate-slug-settings-options.php
|
60 |
-
msgid "<code>http://example.org/<u>category</u>/some-category/</code>"
|
61 |
-
msgstr "<code>http://exemplo.org/<u>categoria</u>/qualquer-categoria/</code>"
|
62 |
-
|
63 |
-
#: qtranslate-slug-settings-options.php
|
64 |
-
msgid "<code>http://example.org/<u>tag</u>/some-tag/</code>"
|
65 |
-
msgstr "<code>http://exemplo.org/<u>etiqueta</u>/qualquer-etiqueta/</code>"
|
66 |
-
|
67 |
-
#: qtranslate-slug-settings.php
|
68 |
-
msgid "Qtranslate Slug options"
|
69 |
-
msgstr "Opções do Qtranslate Slug"
|
70 |
-
|
71 |
-
#: qtranslate-slug-settings.php
|
72 |
-
msgid "Slug options"
|
73 |
-
msgstr "Opções do URL"
|
74 |
-
|
75 |
-
#: qtranslate-slug-settings.php
|
76 |
-
msgid "Save Changes"
|
77 |
-
msgstr "Guardar alterações"
|
78 |
-
|
79 |
-
#: qtranslate-slug-settings.php
|
80 |
-
msgid "Expecting a Numeric value! Please fix."
|
81 |
-
msgstr "É necessário um valor numérico! Por favor, corrija."
|
82 |
-
|
83 |
-
#: qtranslate-slug-settings.php
|
84 |
-
msgid "Expecting comma separated numeric values! Please fix."
|
85 |
-
msgstr ""
|
86 |
-
"São necessários valores numéricos separados por vírgulas! Por favor, corrija."
|
87 |
-
|
88 |
-
#: qtranslate-slug-settings.php
|
89 |
-
msgid "Invalid email"
|
90 |
-
msgstr "Email incorrecto"
|
91 |
-
|
92 |
-
#: qtranslate-slug-settings.php
|
93 |
-
msgid "This setting field cannot be empty! Please enter a valid email address."
|
94 |
-
msgstr ""
|
95 |
-
"Este campo não pode estar vazio! Por favor introduza um endereço de email "
|
96 |
-
"válido."
|
97 |
-
|
98 |
-
#: qtranslate-slug-settings.php
|
99 |
-
msgid "Please enter a valid email address."
|
100 |
-
msgstr "Por favor introduza um endereço de email válido."
|
101 |
-
|
102 |
-
#: qtranslate-slug-settings.php
|
103 |
-
msgid "upgrade now"
|
104 |
-
msgstr "actualizar agora"
|
105 |
-
|
106 |
-
#: qtranslate-slug.php
|
107 |
-
msgid "Please update your old data to the new system."
|
108 |
-
msgstr "Por favor actualize os seus dados antigos para o novo sistema."
|
109 |
-
|
110 |
-
#: qtranslate-slug-settings.php
|
111 |
-
msgid "Upgrade your data"
|
112 |
-
msgstr "Actualize os seus dados"
|
113 |
-
|
114 |
-
#: qtranslate-slug-settings.php
|
115 |
-
msgid ""
|
116 |
-
"There are slugs stored with old data system. Please upgrade your data "
|
117 |
-
"pressing upgrade button:"
|
118 |
-
msgstr ""
|
119 |
-
"Existem URLs com sistema de dados antigo. Por favor actualize os seus dados "
|
120 |
-
"através do botão actualizar:"
|
121 |
-
|
122 |
-
#: qtranslate-slug-settings.php
|
123 |
-
msgid "Sorry, some error happened. Refresh this page and try again please."
|
124 |
-
msgstr ""
|
125 |
-
"Lamentavelmente mas ocorreu um erro. Por favor refresque esta página e tente "
|
126 |
-
"novamente."
|
127 |
-
|
128 |
-
#: qtranslate-slug-settings.php
|
129 |
-
msgid "Congratulations, your data has been upgraded, you are up to date."
|
130 |
-
msgstr ""
|
131 |
-
"Parabéns, os seus dados foram actualizados e o sistema está agora actual."
|
132 |
-
|
133 |
-
#: qtranslate-slug-settings.php
|
134 |
-
msgid "One step more, select what type of slug is this: <strong>%s</strong>"
|
135 |
-
msgstr "Um passo mais, seleccione que tipo de URL é este: <strong>%s</strong>"
|
136 |
-
|
137 |
-
#: qtranslate-slug-settings.php
|
138 |
-
msgid "Post, Page or Custom post type"
|
139 |
-
msgstr "Artigo, Página ou Tipo de Artigo Personalizado"
|
140 |
-
|
141 |
-
#: qtranslate-slug-settings.php
|
142 |
-
msgid "Category, tag or custom taxonomy"
|
143 |
-
msgstr "Categoria, etiqueta ou taxonomia personalizada"
|
144 |
-
|
145 |
-
#: qtranslate-slug.php
|
146 |
-
msgid ""
|
147 |
-
"This plugin requires at least <strong>Wordpress 3.3</strong> and "
|
148 |
-
"<strong>Qtranslate(2.5.8 or newer)</strong>"
|
149 |
-
msgstr ""
|
150 |
-
"Este plugin requer no mínimo o <strong>Wordpress 3.3</strong> e "
|
151 |
-
"<strong>Qtranslate (2.5.8 ou superior)</strong>"
|
152 |
-
|
153 |
-
#: qtranslate-slug-settings.php
|
154 |
-
msgid ""
|
155 |
-
"If you activated previously the <a href=\"options-permalink.php\">pretty "
|
156 |
-
"permalinks</a>, in this section you can translate the <abbr title=\"en "
|
157 |
-
"inglés, Universal Resource Locator\">URLs</abbr> <strong>bases</strong> for "
|
158 |
-
"<a href=\"http://codex.wordpress.org/Function_Reference/"
|
159 |
-
"register_post_type#Arguments\">public</a> post_types, categories, tags and "
|
160 |
-
"taxonomies."
|
161 |
-
msgstr ""
|
162 |
-
"Se activou previamente as <a href=\"options-permalink.php\">ligações "
|
163 |
-
"permanentes</a>, nesta secção poderá traduzir as <strong>bases</strong> das "
|
164 |
-
"<abbr title=\"em inglês, Universal Resource Locator\">URLs</abbr> para tipos "
|
165 |
-
"de artigo, categorias, etiquetas e taxonomias <a href=\"http://codex."
|
166 |
-
"wordpress.org/Function_Reference/register_post_type#Arguments\">públicas</a>."
|
167 |
-
|
168 |
-
#: qtranslate-slug-settings.php
|
169 |
-
msgid ""
|
170 |
-
"For example, the post_type <kbd>books</kbd>, in Spanish would be displayed "
|
171 |
-
"as <code>http://example.org/es/libros/post-type-name/</code>. If you leave "
|
172 |
-
"this blank will use the default option when you <a href=\"http://codex."
|
173 |
-
"wordpress.org/Function_Reference/register_post_type\">registered</a> the "
|
174 |
-
"post_type."
|
175 |
-
msgstr ""
|
176 |
-
"Por exemplo, o tipo de artigo <kbd>livros</kbd>, em português seria mostrado "
|
177 |
-
"como <code>http://exemplo.org/pt/livros/nome-de-tipo-de-artigo/</code>. Se "
|
178 |
-
"deixar isto em branco, será usada a opção por omissão <a href=\"http://codex."
|
179 |
-
"wordpress.org/Function_Reference/register_post_type\">registada</a> no tipo "
|
180 |
-
"de artigo."
|
181 |
-
|
182 |
-
#: qtranslate-slug-settings.php
|
183 |
-
msgid ""
|
184 |
-
"For example, the taxonomy <kbd>category</kbd>, in Spanish would be displayed "
|
185 |
-
"as <code>http://example.org/es/categoria/taxonomy-name/</code>. If you leave "
|
186 |
-
"this blank will use the default option when you <a href=\"http://codex."
|
187 |
-
"wordpress.org/Function_Reference/register_taxonomy\">registered</a> the "
|
188 |
-
"taxonomy (if you previously setup a base permastruct for <u>categories</u> "
|
189 |
-
"or <u>tags</u> in <a href=\"options-permalink.php\">permalinks</a> page, "
|
190 |
-
"these bases will be overwritten by the translated ones)."
|
191 |
-
msgstr ""
|
192 |
-
"Por exemplo, a taxonomia <kbd>categoria</kbd>, em português seria mostrado "
|
193 |
-
"como <code>http://exemplo.org/pt/categoria/nome-de-taxonomia/</code>. Se "
|
194 |
-
"deixar isto em branco, será usada a opção por omissão <a href=\"http://codex."
|
195 |
-
"wordpress.org/Function_Reference/register_taxonomy\">registada</a> na "
|
196 |
-
"taxonomia (se previamente configurou a base das ligações permanentes para "
|
197 |
-
"<u>categorias</u> ou <u>etiquetas</u> na página <a href=\"options-permalink."
|
198 |
-
"php\">ligações permanentes</a>, estas bases serão sobrepostas pelas "
|
199 |
-
"traduzidas)."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/languages/qts.pot
DELETED
@@ -1,145 +0,0 @@
|
|
1 |
-
# Copyright (C) 2012 qTranslate slug
|
2 |
-
# This file is distributed under the same license as the qTranslate slug package.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"Project-Id-Version: qTranslate slug 1.0\n"
|
6 |
-
"Report-Msgid-Bugs-To: http://wordpress.org/tag/qtranslate-slug\n"
|
7 |
-
"POT-Creation-Date: 2012-05-27 20:27:55+00:00\n"
|
8 |
-
"MIME-Version: 1.0\n"
|
9 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
-
"Content-Transfer-Encoding: 8bit\n"
|
11 |
-
"PO-Revision-Date: 2012-MO-DA HO:MI+ZONE\n"
|
12 |
-
"Last-Translator: Carlos Sanz Garcia <carlos.sanz@gmail.com>\n"
|
13 |
-
"Language-Team: Carlos Sanz Garcia <carlos.sanz@gmail.com>\n"
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
#: qtranslate-slug.php
|
20 |
-
msgid "Language selector"
|
21 |
-
msgstr ""
|
22 |
-
|
23 |
-
#: qtranslate-slug.php
|
24 |
-
msgid "Title:"
|
25 |
-
msgstr ""
|
26 |
-
|
27 |
-
#: qtranslate-slug.php
|
28 |
-
msgid "<p style=\"color:red\">This plugin requires qTranslate to be installed and activated.</p>"
|
29 |
-
msgstr ""
|
30 |
-
|
31 |
-
#: qtranslate-slug.php
|
32 |
-
msgid "Slug"
|
33 |
-
msgstr ""
|
34 |
-
|
35 |
-
#: qtranslate-slug.php
|
36 |
-
msgid "Show short name (en):"
|
37 |
-
msgstr ""
|
38 |
-
|
39 |
-
#: qtranslate-slug-settings-options.php
|
40 |
-
msgid "Post types"
|
41 |
-
msgstr ""
|
42 |
-
|
43 |
-
#: qtranslate-slug-settings-options.php
|
44 |
-
msgid "Taxonomies"
|
45 |
-
msgstr ""
|
46 |
-
|
47 |
-
#: qtranslate-slug-settings-options.php
|
48 |
-
msgid "Slug (%s)"
|
49 |
-
msgstr ""
|
50 |
-
|
51 |
-
#: qtranslate-slug-settings-options.php
|
52 |
-
msgid "<code>http://example.org/<u>%s</u>/some-%s/</code>"
|
53 |
-
msgstr ""
|
54 |
-
|
55 |
-
#: qtranslate-slug-settings-options.php
|
56 |
-
msgid "<code>http://example.org/<u>category</u>/some-category/</code>"
|
57 |
-
msgstr ""
|
58 |
-
|
59 |
-
#: qtranslate-slug-settings-options.php
|
60 |
-
msgid "<code>http://example.org/<u>tag</u>/some-tag/</code>"
|
61 |
-
msgstr ""
|
62 |
-
|
63 |
-
#: qtranslate-slug-settings.php
|
64 |
-
msgid "Qtranslate Slug options"
|
65 |
-
msgstr ""
|
66 |
-
|
67 |
-
#: qtranslate-slug-settings.php
|
68 |
-
msgid "Slug options"
|
69 |
-
msgstr ""
|
70 |
-
|
71 |
-
#: qtranslate-slug-settings.php
|
72 |
-
msgid "Save Changes"
|
73 |
-
msgstr ""
|
74 |
-
|
75 |
-
#: qtranslate-slug-settings.php
|
76 |
-
msgid "Expecting a Numeric value! Please fix."
|
77 |
-
msgstr ""
|
78 |
-
|
79 |
-
#: qtranslate-slug-settings.php
|
80 |
-
msgid "Expecting comma separated numeric values! Please fix."
|
81 |
-
msgstr ""
|
82 |
-
|
83 |
-
#: qtranslate-slug-settings.php
|
84 |
-
msgid "Invalid email"
|
85 |
-
msgstr ""
|
86 |
-
|
87 |
-
#: qtranslate-slug-settings.php
|
88 |
-
msgid "This setting field cannot be empty! Please enter a valid email address."
|
89 |
-
msgstr ""
|
90 |
-
|
91 |
-
#: qtranslate-slug-settings.php
|
92 |
-
msgid "Please enter a valid email address."
|
93 |
-
msgstr ""
|
94 |
-
|
95 |
-
#: qtranslate-slug-settings.php
|
96 |
-
msgid "upgrade now"
|
97 |
-
msgstr ""
|
98 |
-
|
99 |
-
#: qtranslate-slug.php
|
100 |
-
msgid "Please update your old data to the new system."
|
101 |
-
msgstr ""
|
102 |
-
|
103 |
-
#: qtranslate-slug-settings.php
|
104 |
-
msgid "Upgrade your data"
|
105 |
-
msgstr ""
|
106 |
-
|
107 |
-
#: qtranslate-slug-settings.php
|
108 |
-
msgid "There are slugs stored with old data system. Please upgrade your data pressing upgrade button:"
|
109 |
-
msgstr ""
|
110 |
-
|
111 |
-
#: qtranslate-slug-settings.php
|
112 |
-
msgid "Sorry, some error happened. Refresh this page and try again please."
|
113 |
-
msgstr ""
|
114 |
-
|
115 |
-
#: qtranslate-slug-settings.php
|
116 |
-
msgid "Congratulations, your data has been upgraded, you are up to date."
|
117 |
-
msgstr ""
|
118 |
-
|
119 |
-
#: qtranslate-slug-settings.php
|
120 |
-
msgid "One step more, select what type of slug is this: <strong>%s</strong>"
|
121 |
-
msgstr ""
|
122 |
-
|
123 |
-
#: qtranslate-slug-settings.php
|
124 |
-
msgid "Post, Page or Custom post type"
|
125 |
-
msgstr ""
|
126 |
-
|
127 |
-
#: qtranslate-slug-settings.php
|
128 |
-
msgid "Category, tag or custom taxonomy"
|
129 |
-
msgstr ""
|
130 |
-
|
131 |
-
#: qtranslate-slug.php
|
132 |
-
msgid "This plugin requires at least <strong>Wordpress 3.3</strong> and <strong>Qtranslate(2.5.8 or newer)</strong>"
|
133 |
-
msgstr ""
|
134 |
-
|
135 |
-
#: qtranslate-slug-settings.php
|
136 |
-
msgid "If you activated previously the <a href=\"options-permalink.php\">pretty permalinks</a>, in this section you can translate the <abbr title=\"en inglés, Universal Resource Locator\">URLs</abbr> <strong>bases</strong> for <a href=\"http://codex.wordpress.org/Function_Reference/register_post_type#Arguments\">public</a> post_types, categories, tags and taxonomies."
|
137 |
-
msgstr ""
|
138 |
-
|
139 |
-
#: qtranslate-slug-settings.php
|
140 |
-
msgid "For example, the post_type <kbd>books</kbd>, in Spanish would be displayed as <code>http://example.org/es/libros/post-type-name/</code>. If you leave this blank will use the default option when you <a href=\"http://codex.wordpress.org/Function_Reference/register_post_type\">registered</a> the post_type."
|
141 |
-
msgstr ""
|
142 |
-
|
143 |
-
#: qtranslate-slug-settings.php
|
144 |
-
msgid "For example, the taxonomy <kbd>category</kbd>, in Spanish would be displayed as <code>http://example.org/es/categoria/taxonomy-name/</code>. If you leave this blank will use the default option when you <a href=\"http://codex.wordpress.org/Function_Reference/register_taxonomy\">registered</a> the taxonomy (if you previously setup a base permastruct for <u>categories</u> or <u>tags</u> in <a href=\"options-permalink.php\">permalinks</a> page, these bases will be overwritten by the translated ones)."
|
145 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/phpunit.xml
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
<phpunit
|
2 |
-
bootstrap="tests/bootstrap.php"
|
3 |
-
backupGlobals="false"
|
4 |
-
colors="true"
|
5 |
-
convertErrorsToExceptions="true"
|
6 |
-
convertNoticesToExceptions="true"
|
7 |
-
convertWarningsToExceptions="true"
|
8 |
-
>
|
9 |
-
<testsuites>
|
10 |
-
<testsuite>
|
11 |
-
<directory prefix="test-" suffix=".php">./tests</directory>
|
12 |
-
</testsuite>
|
13 |
-
</testsuites>
|
14 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/qtranslate-slug-settings-options.php
DELETED
@@ -1,178 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Define our settings sections
|
4 |
-
*
|
5 |
-
* @package Qtranslate Slug
|
6 |
-
* @subpackage Settings
|
7 |
-
* @version 1.0
|
8 |
-
*
|
9 |
-
* @return array key=$id, array value=$title in: add_settings_section( $id, $title, $callback, $page );
|
10 |
-
*/
|
11 |
-
function qts_options_page_sections() {
|
12 |
-
|
13 |
-
$sections = array();
|
14 |
-
$sections['post_types'] = __('Post types', 'qts');
|
15 |
-
$sections['taxonomies'] = __('Taxonomies', 'qts');
|
16 |
-
$sections['styles'] = __('Styles', 'qts');
|
17 |
-
|
18 |
-
return $sections;
|
19 |
-
}
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Helper for create arrays of choices
|
25 |
-
*
|
26 |
-
* @package Qtranslate Slug
|
27 |
-
* @subpackage Settings
|
28 |
-
* @version 1.0
|
29 |
-
*
|
30 |
-
* @return array
|
31 |
-
*/
|
32 |
-
function get_multi_txt_choices($name = false) {
|
33 |
-
global $q_config;
|
34 |
-
|
35 |
-
if (!$name) return array();
|
36 |
-
|
37 |
-
$choices = array();
|
38 |
-
foreach( $q_config['enabled_languages'] as $key => $lang) {
|
39 |
-
$label = sprintf( __('Slug (%s)', 'qts'), $q_config['language_name'][$lang] );
|
40 |
-
$choices[] = "$label|$lang"; // prints: 'Slug (English)|en' ( $name = books )
|
41 |
-
}
|
42 |
-
|
43 |
-
return $choices;
|
44 |
-
}
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Define our form fields (settings) for displaying the default styles
|
50 |
-
*
|
51 |
-
* @package Qtranslate Slug
|
52 |
-
* @subpackage Settings
|
53 |
-
* @version 1.1.7
|
54 |
-
*
|
55 |
-
* @return array
|
56 |
-
*/
|
57 |
-
function qts_options_page_styles() {
|
58 |
-
global $q_config;
|
59 |
-
|
60 |
-
$options[] = array(
|
61 |
-
"section" => "styles",
|
62 |
-
"id" => QTS_PREFIX . "styles",
|
63 |
-
"title" => __('Change styles type', 'qts'),
|
64 |
-
"desc" => array(
|
65 |
-
__("adds a file (qts-default.css) file to the theme's header.", "qts"),
|
66 |
-
__("prints the styles directly into the theme's header.", "qts"),
|
67 |
-
__("neither include not print the default style.", "qts")
|
68 |
-
),
|
69 |
-
"type" => "multi-radio",
|
70 |
-
'class' => 'qts-style',
|
71 |
-
"choices" => array(
|
72 |
-
"file",
|
73 |
-
"inline",
|
74 |
-
"none"
|
75 |
-
),
|
76 |
-
"std" => "file"
|
77 |
-
);
|
78 |
-
|
79 |
-
return $options;
|
80 |
-
}
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Define our form fields (settings)
|
86 |
-
*
|
87 |
-
* @package Qtranslate Slug
|
88 |
-
* @subpackage Settings
|
89 |
-
* @version 1.0
|
90 |
-
*
|
91 |
-
* @return array
|
92 |
-
*/
|
93 |
-
function qts_options_page_fields() {
|
94 |
-
global $q_config;
|
95 |
-
|
96 |
-
$post_types = get_post_types( array('_builtin' => false, 'public' => true ), 'objects');
|
97 |
-
|
98 |
-
// each post type
|
99 |
-
foreach ($post_types as $post_type):
|
100 |
-
|
101 |
-
$options[] = array(
|
102 |
-
"section" => "post_types",
|
103 |
-
"id" => QTS_PREFIX . "post_type_" . $post_type->name,
|
104 |
-
"title" => $post_type->labels->singular_name,
|
105 |
-
"desc" => sprintf( __( '<code>http://example.org/<u>%s</u>/some-%s/</code>', 'qts' ), $post_type->name, $post_type->name),
|
106 |
-
'class' => 'qts-slug',
|
107 |
-
"type" => "multi-text",
|
108 |
-
"choices" => get_multi_txt_choices( $post_type->name),
|
109 |
-
"std" => ""
|
110 |
-
);
|
111 |
-
|
112 |
-
endforeach;
|
113 |
-
// end each post type
|
114 |
-
|
115 |
-
$options[] = array(
|
116 |
-
"section" => "taxonomies",
|
117 |
-
"id" => QTS_PREFIX . "taxonomy_category",
|
118 |
-
"title" => __('Categories'),
|
119 |
-
"desc" => __( '<code>http://example.org/<u>category</u>/some-category/</code>', 'qts' ),
|
120 |
-
"type" => "multi-text",
|
121 |
-
'class' => 'qts-slug',
|
122 |
-
"choices" => get_multi_txt_choices('category'),
|
123 |
-
"std" => ""
|
124 |
-
);
|
125 |
-
|
126 |
-
$options[] = array(
|
127 |
-
"section" => "taxonomies",
|
128 |
-
"id" => QTS_PREFIX . "taxonomy_post_tag",
|
129 |
-
"title" => __('Tags'),
|
130 |
-
"desc" => __( '<code>http://example.org/<u>tag</u>/some-tag/</code>', 'qts' ),
|
131 |
-
"type" => "multi-text",
|
132 |
-
'class' => 'qts-slug',
|
133 |
-
"choices" => get_multi_txt_choices('post_tag'),
|
134 |
-
"std" => ""
|
135 |
-
);
|
136 |
-
|
137 |
-
|
138 |
-
$taxonomies = get_taxonomies( array( 'public' => true, 'show_ui' => true, '_builtin' => false ), 'object' );
|
139 |
-
|
140 |
-
// each extra taxonomy
|
141 |
-
foreach ($taxonomies as $taxonomy):
|
142 |
-
|
143 |
-
$options[] = array(
|
144 |
-
"section" => "taxonomies",
|
145 |
-
"id" => QTS_PREFIX . "taxonomy_" . $taxonomy->name,
|
146 |
-
"title" => $taxonomy->labels->singular_name,
|
147 |
-
"desc" => sprintf( __( '<code>http://example.org/<u>%s</u>/some-%s/</code>', 'qts' ), $taxonomy->name, $taxonomy->name ),
|
148 |
-
"type" => "multi-text",
|
149 |
-
'class' => 'qts-slug',
|
150 |
-
"choices" => get_multi_txt_choices( $taxonomy->name),
|
151 |
-
"std" => ""
|
152 |
-
);
|
153 |
-
|
154 |
-
endforeach;
|
155 |
-
// end each extra taxonomy
|
156 |
-
|
157 |
-
|
158 |
-
return $options;
|
159 |
-
}
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Contextual Help
|
165 |
-
*
|
166 |
-
* @package Qtranslate Slug
|
167 |
-
* @subpackage Settings
|
168 |
-
* @version 1.0
|
169 |
-
*
|
170 |
-
*/
|
171 |
-
function qts_options_page_contextual_help() {
|
172 |
-
|
173 |
-
|
174 |
-
$text = "<h3>" . __('Qtranslate Settings - Contextual Help','qts') . "</h3>";
|
175 |
-
$text .= "<p>" . __('Contextual help goes here. You may want to use different html elements to format your text as you want.','qts') . "</p>";
|
176 |
-
|
177 |
-
return $text;
|
178 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/qtranslate-slug-settings.php
DELETED
@@ -1,972 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// page settings sections & fields as well as the contextual help text.
|
4 |
-
include_once('qtranslate-slug-settings-options.php');
|
5 |
-
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Prints upgrade form in Qtranslate Slug admin page
|
9 |
-
*
|
10 |
-
* @package Qtranslate Slug
|
11 |
-
* @subpackage Settings
|
12 |
-
* @version 1.0
|
13 |
-
*
|
14 |
-
* @return array
|
15 |
-
*/
|
16 |
-
function qts_upgrade() {
|
17 |
-
global $qtranslate_slug;
|
18 |
-
|
19 |
-
if ( !$qtranslate_slug->check_old_data() ) return;
|
20 |
-
|
21 |
-
echo "<div id=\"qts-upgrade-box\" class=\"updated\" style=\"margin: 15px 0; margin-bottom:25px; padding: 10px\">" . PHP_EOL;
|
22 |
-
|
23 |
-
echo "<h3>" . __('Upgrade your data', 'qts') . "</h3>" . PHP_EOL;
|
24 |
-
echo "<p>" . __('There are slugs stored with old data system. Please upgrade your data pressing upgrade button:', 'qts') . "</p>" . PHP_EOL;
|
25 |
-
|
26 |
-
echo "<div id=\"qts-upgrade-form\">" . PHP_EOL;
|
27 |
-
echo "<input type=\"hidden\" id=\"qts-upgrade-action\" name=\"qts-upgrade-action\" value=\"qts-upgrade-check\" />" .PHP_EOL;
|
28 |
-
echo "<input type=\"hidden\" id=\"qts-upgrade-nonce\" name=\"qts-upgrade-nonce\" value=\"". wp_create_nonce('qts-upgrade') . "\" />" .PHP_EOL;
|
29 |
-
echo "<p><a id=\"qts-upgrade-button\" href=\"#\" class=\"button-primary\">" . __('upgrade now', 'qts') . "</a><img src=\"".admin_url('images/wpspin_light.gif')."\" class=\"qts-loading\" id=\"qts-loading\" alt=\"\"></p>" . PHP_EOL;
|
30 |
-
echo "</div></div>" . PHP_EOL;
|
31 |
-
}
|
32 |
-
|
33 |
-
|
34 |
-
/**
|
35 |
-
* AJAX: upgrade old database to new system
|
36 |
-
*
|
37 |
-
* @package Qtranslate Slug
|
38 |
-
* @subpackage Settings
|
39 |
-
* @version 1.0
|
40 |
-
*
|
41 |
-
* @return boolean
|
42 |
-
*/
|
43 |
-
function qts_process_old_data( $old_data = null, $type = 'post' ) {
|
44 |
-
global $wpdb, $qtranslate_slug;
|
45 |
-
|
46 |
-
if ( is_null($old_data) || empty($old_data) ) return 0;
|
47 |
-
foreach ($old_data as $row) {
|
48 |
-
switch ($row->qts_type) {
|
49 |
-
case 1:
|
50 |
-
case 2:
|
51 |
-
update_post_meta( $row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
|
52 |
-
break;
|
53 |
-
case 3:
|
54 |
-
case 4:
|
55 |
-
update_term_meta( $row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
|
56 |
-
break;
|
57 |
-
case 5:
|
58 |
-
if ($type == 'post')
|
59 |
-
update_post_meta( $row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
|
60 |
-
|
61 |
-
if ($type == 'term')
|
62 |
-
update_term_meta( $row->qts_id, $qtranslate_slug->get_meta_key($row->qts_lang), $row->qts_slug);
|
63 |
-
break;
|
64 |
-
};
|
65 |
-
}
|
66 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}qtranslate_slug");
|
67 |
-
|
68 |
-
return 1;
|
69 |
-
}
|
70 |
-
|
71 |
-
function qts_upgrade_response($type = 0, $slug = null) {
|
72 |
-
switch ( $type ) {
|
73 |
-
default:
|
74 |
-
case 0:
|
75 |
-
$response = array(
|
76 |
-
'status' => 0,
|
77 |
-
'message' => __('Sorry, some error happened. Refresh this page and try again please.', 'qts'),
|
78 |
-
);
|
79 |
-
break;
|
80 |
-
|
81 |
-
case 1:
|
82 |
-
$response = array(
|
83 |
-
'status' => 1,
|
84 |
-
'message' => __('Congratulations, your data has been upgraded, you are up to date.', 'qts'),
|
85 |
-
);
|
86 |
-
break;
|
87 |
-
case 2:
|
88 |
-
$response = array(
|
89 |
-
'status' => 2,
|
90 |
-
'message' => sprintf(__('One step more, select what type of slug is this: <strong>%s</strong>', 'qts'), $slug),
|
91 |
-
'options' => array( 'post' => __('Post, Page or Custom post type', 'qts'), 'term' => __('Category, tag or custom taxonomy') )
|
92 |
-
);
|
93 |
-
break;
|
94 |
-
}
|
95 |
-
|
96 |
-
return $response;
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
/**
|
102 |
-
* AJAX: upgrade old database to new system
|
103 |
-
*
|
104 |
-
* @package Qtranslate Slug
|
105 |
-
* @subpackage Settings
|
106 |
-
* @version 1.0
|
107 |
-
*
|
108 |
-
* @return JSON object
|
109 |
-
*/
|
110 |
-
function qts_upgrade_check() {
|
111 |
-
global $qtranslate_slug;
|
112 |
-
|
113 |
-
$old_data = $qtranslate_slug->check_old_data();
|
114 |
-
|
115 |
-
if ( wp_verify_nonce( $_POST['nonce'], 'qts-upgrade') ):
|
116 |
-
|
117 |
-
// if data process to save...
|
118 |
-
if ($old_data) {
|
119 |
-
|
120 |
-
// if defined data type 5, process to upgrade
|
121 |
-
if ( isset($_POST['type']) ):
|
122 |
-
|
123 |
-
$res = qts_process_old_data($old_data, $_POST['type']);
|
124 |
-
|
125 |
-
$response = qts_upgrade_response($res);
|
126 |
-
|
127 |
-
else :
|
128 |
-
|
129 |
-
// define wich type of data is 5
|
130 |
-
$array_of_5 = array();
|
131 |
-
foreach ( $old_data as $row )
|
132 |
-
if ( $row->qts_type == 5 ) $array_of_5[] = $row->qts_slug;
|
133 |
-
|
134 |
-
if (!empty($array_of_5)) $response = qts_upgrade_response(2, implode(', ', $array_of_5));
|
135 |
-
|
136 |
-
// if no data type 5, process to upgrade
|
137 |
-
if (!isset($response)) {
|
138 |
-
$res = qts_process_old_data($old_data);
|
139 |
-
$response = qts_upgrade_response($res);
|
140 |
-
}
|
141 |
-
|
142 |
-
endif;
|
143 |
-
|
144 |
-
|
145 |
-
// if not continue
|
146 |
-
} else {
|
147 |
-
|
148 |
-
$response = qts_upgrade_response();
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
else:
|
153 |
-
|
154 |
-
$response = qts_upgrade_response();
|
155 |
-
|
156 |
-
endif;
|
157 |
-
|
158 |
-
// response output
|
159 |
-
header( "Content-Type: application/json" );
|
160 |
-
echo json_encode($response);
|
161 |
-
exit;
|
162 |
-
}
|
163 |
-
add_action('wp_ajax_qts-upgrade-check', 'qts_upgrade_check');
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Helper function for defining variables for the current page
|
169 |
-
*
|
170 |
-
* @package Qtranslate Slug
|
171 |
-
* @subpackage Settings
|
172 |
-
* @version 1.0
|
173 |
-
*
|
174 |
-
* @return array
|
175 |
-
*/
|
176 |
-
function qts_get_settings() {
|
177 |
-
|
178 |
-
$output = array();
|
179 |
-
|
180 |
-
// put together the output array
|
181 |
-
$output['qts_option_name'] = QTS_OPTIONS_NAME; // the option name as used in the get_option() call.
|
182 |
-
$output['qts_page_title'] = __('Qtranslate Slug options', 'qts'); // the settings page title
|
183 |
-
$output['qts_page_sections'] = qts_options_page_sections(); // the settings sections
|
184 |
-
$output['qts_page_fields'] = qts_options_page_fields(); // the settings fields
|
185 |
-
$output['qts_page_styles'] = qts_options_page_styles(); // the settings for style
|
186 |
-
|
187 |
-
|
188 |
-
$output['qts_contextual_help'] = qts_options_page_contextual_help(); // the contextual help
|
189 |
-
|
190 |
-
return $output;
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Helper function for registering our form field settings
|
197 |
-
*
|
198 |
-
* @package Qtranslate Slug
|
199 |
-
* @subpackage Settings
|
200 |
-
* @version 1.0
|
201 |
-
*
|
202 |
-
* src: http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
|
203 |
-
* @param (array) $args The array of arguments to be used in creating the field
|
204 |
-
* @return function call
|
205 |
-
*/
|
206 |
-
function qts_create_settings_field( $args = array() ) {
|
207 |
-
// default array to overwrite when calling the function
|
208 |
-
$defaults = array(
|
209 |
-
'id' => 'default_field', // the ID of the setting in our options array, and the ID of the HTML form element
|
210 |
-
'title' => 'Default Field', // the label for the HTML form element
|
211 |
-
'desc' => 'This is a default description.', // the description displayed under the HTML form element
|
212 |
-
'std' => '', // the default value for this setting
|
213 |
-
'type' => 'text', // the HTML form element to use
|
214 |
-
'section' => 'main_section', // the section this setting belongs to must match the array key of a section in qts_options_page_sections()
|
215 |
-
'choices' => array(), // (optional): the values in radio buttons or a drop-down menu
|
216 |
-
'class' => '' // the HTML form element class. Is used for validation purposes and may be also use for styling if needed.
|
217 |
-
);
|
218 |
-
|
219 |
-
// "extract" to be able to use the array keys as variables in our function output below
|
220 |
-
extract( wp_parse_args( $args, $defaults ) );
|
221 |
-
|
222 |
-
// additional arguments for use in form field output in the function qts_show_form_field!
|
223 |
-
$field_args = array(
|
224 |
-
'type' => $type,
|
225 |
-
'id' => $id,
|
226 |
-
'desc' => $desc,
|
227 |
-
'std' => $std,
|
228 |
-
'choices' => $choices,
|
229 |
-
'label_for' => $id,
|
230 |
-
'class' => $class
|
231 |
-
);
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
add_settings_field( $id, $title, 'qts_show_form_field', __FILE__, $section, $field_args );
|
236 |
-
|
237 |
-
}
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Register our setting, settings sections and settings fields
|
243 |
-
*
|
244 |
-
* @package Qtranslate Slug
|
245 |
-
* @subpackage Settings
|
246 |
-
* @version 1.0
|
247 |
-
*
|
248 |
-
*/
|
249 |
-
function qts_register_settings(){
|
250 |
-
|
251 |
-
// get the settings sections array
|
252 |
-
$settings_output = qts_get_settings();
|
253 |
-
$qts_option_name = $settings_output['qts_option_name'];
|
254 |
-
|
255 |
-
//setting
|
256 |
-
register_setting($qts_option_name, $qts_option_name, 'qts_validate_options' );
|
257 |
-
|
258 |
-
//sections
|
259 |
-
if(!empty($settings_output['qts_page_sections'])){
|
260 |
-
// call the "add_settings_section" for each!
|
261 |
-
foreach ( $settings_output['qts_page_sections'] as $id => $title ) {
|
262 |
-
add_settings_section( $id, $title, 'qts_section_fn', __FILE__);
|
263 |
-
}
|
264 |
-
}
|
265 |
-
|
266 |
-
//fields
|
267 |
-
if(!empty($settings_output['qts_page_fields'])){
|
268 |
-
// call the "add_settings_field" for each!
|
269 |
-
foreach ($settings_output['qts_page_fields'] as $option) {
|
270 |
-
qts_create_settings_field($option);
|
271 |
-
}
|
272 |
-
}
|
273 |
-
//style
|
274 |
-
if(!empty($settings_output['qts_page_styles'])){
|
275 |
-
// call the "add_settings_field" for each
|
276 |
-
foreach ($settings_output['qts_page_styles'] as $styleoption) {
|
277 |
-
qts_create_settings_field($styleoption);
|
278 |
-
}
|
279 |
-
}
|
280 |
-
}
|
281 |
-
add_action( 'admin_init', 'qts_register_settings' );
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
/**
|
286 |
-
* Group scripts (js & css)
|
287 |
-
*
|
288 |
-
* @package Qtranslate Slug
|
289 |
-
* @subpackage Settings
|
290 |
-
* @version 1.0
|
291 |
-
*
|
292 |
-
*/
|
293 |
-
function qts_settings_scripts() {
|
294 |
-
global $qtranslate_slug;
|
295 |
-
|
296 |
-
wp_enqueue_style('qts_theme_settings_css', plugins_url( 'assets/css/qts-settings.css' , __FILE__ ) );
|
297 |
-
wp_enqueue_script( 'qts_theme_settings_js', plugins_url( 'assets/js/qts-settings.js' , __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' , __FILE__ ), array('jquery') );
|
301 |
-
}
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
/**
|
306 |
-
* The Admin menu page
|
307 |
-
*
|
308 |
-
* @package Qtranslate Slug
|
309 |
-
* @subpackage Settings
|
310 |
-
* @version 1.0
|
311 |
-
*
|
312 |
-
*/
|
313 |
-
function qts_add_menu() {
|
314 |
-
global $current_screen;
|
315 |
-
|
316 |
-
$settings_output = qts_get_settings();
|
317 |
-
// collect our contextual help text
|
318 |
-
$qts_contextual_help = $settings_output['qts_contextual_help'];
|
319 |
-
|
320 |
-
// Display Settings Page link under the "Appearance" Admin Menu
|
321 |
-
$qts_settings_page = add_options_page(__('Qtranslate Slug options', 'qts'), __('Slug options', 'qts'), 'manage_options', QTS_PAGE_BASENAME, 'qts_show_settings_page');
|
322 |
-
// contextual help
|
323 |
-
/*
|
324 |
-
if ($qts_settings_page) {
|
325 |
-
$current_screen = get_current_screen();
|
326 |
-
//$current_screen->add_help_tab( array( $qts_settings_page, $qts_contextual_help ));
|
327 |
-
}
|
328 |
-
*/
|
329 |
-
// css & js
|
330 |
-
add_action( 'load-'. $qts_settings_page, 'qts_settings_scripts' );
|
331 |
-
}
|
332 |
-
add_action( 'admin_menu', 'qts_add_menu' );
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
337 |
-
|
338 |
-
// Callback functions
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
/**
|
343 |
-
* Section HTML, displayed before the first option
|
344 |
-
*
|
345 |
-
* @package Qtranslate Slug
|
346 |
-
* @subpackage Settings
|
347 |
-
* @version 1.0
|
348 |
-
*
|
349 |
-
* @return echoes output
|
350 |
-
*/
|
351 |
-
function qts_section_fn($page_section = false) {
|
352 |
-
|
353 |
-
if ( !$page_section || !isset($page_section['id']) ) return;
|
354 |
-
|
355 |
-
switch ($page_section['id']) {
|
356 |
-
case 'post_types':
|
357 |
-
|
358 |
-
echo "<p>" . __('For example, the post_type <kbd>books</kbd>, in Spanish would be displayed as <code>http://example.org/es/libros/post-type-name/</code>. If you leave this blank will use the default option when you <a href="http://codex.wordpress.org/Function_Reference/register_post_type">registered</a> the post_type.', 'qts') . "</p>";
|
359 |
-
break;
|
360 |
-
|
361 |
-
case 'taxonomies':
|
362 |
-
|
363 |
-
echo "<p>" . __('For example, the taxonomy <kbd>category</kbd>, in Spanish would be displayed as <code>http://example.org/es/categoria/taxonomy-name/</code>. If you leave this blank will use the default option when you <a href="http://codex.wordpress.org/Function_Reference/register_taxonomy">registered</a> the taxonomy (if you previously setup a base permastruct for <u>categories</u> or <u>tags</u> in <a href="options-permalink.php">permalinks</a> page, these bases will be overwritten by the translated ones).', 'qts') . "</p>";
|
364 |
-
break;
|
365 |
-
case 'styles':
|
366 |
-
|
367 |
-
echo "<p>" . __('The default styles are very minimal, and you can include them or not.', 'qts') . "</p>\n";
|
368 |
-
break;
|
369 |
-
}
|
370 |
-
}
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
/**
|
375 |
-
* Form Fields HTML: all form field types share the same function
|
376 |
-
*
|
377 |
-
* @package Qtranslate Slug
|
378 |
-
* @subpackage Settings
|
379 |
-
* @version 1.0
|
380 |
-
*
|
381 |
-
* @return echoes output
|
382 |
-
*/
|
383 |
-
function qts_show_form_field($args = array()) {
|
384 |
-
global $qtranslate_slug;
|
385 |
-
|
386 |
-
extract( $args );
|
387 |
-
|
388 |
-
// get the settings sections array
|
389 |
-
$settings_output = qts_get_settings();
|
390 |
-
$options = $qtranslate_slug->get_options();
|
391 |
-
|
392 |
-
// pass the standard value if the option is not yet set in the database
|
393 |
-
if ( !isset( $options[$id] ) && 'type' != 'checkbox' ) {
|
394 |
-
$options[$id] = $std;
|
395 |
-
}
|
396 |
-
|
397 |
-
// additional field class. output only if the class is defined in the create_setting arguments
|
398 |
-
$field_class = ($class != '') ? ' ' . $class : '';
|
399 |
-
|
400 |
-
// switch html display based on the setting type.
|
401 |
-
switch ( $type ) {
|
402 |
-
case 'text':
|
403 |
-
$options[$id] = stripslashes($options[$id]);
|
404 |
-
$options[$id] = esc_attr( $options[$id]);
|
405 |
-
echo "<input class='regular-text$field_class' type='text' id='$id' name='" . QTS_OPTIONS_NAME . "[$id]' value='$options[$id]' />";
|
406 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
407 |
-
break;
|
408 |
-
|
409 |
-
case "multi-text":
|
410 |
-
foreach($choices as $item) {
|
411 |
-
|
412 |
-
$item = explode("|",$item); // cat_name|cat_slug
|
413 |
-
$item[0] = esc_html__($item[0], 'qts');
|
414 |
-
|
415 |
-
if (!empty($options[$id])) {
|
416 |
-
foreach ($options[$id] as $option_key => $option_val){
|
417 |
-
if ($item[1] == $option_key) {
|
418 |
-
$value = $option_val;
|
419 |
-
}
|
420 |
-
}
|
421 |
-
} else {
|
422 |
-
$value = '';
|
423 |
-
}
|
424 |
-
|
425 |
-
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/>";
|
426 |
-
}
|
427 |
-
echo ($desc != '') ? "<span class='description'>$desc</span>" : "";
|
428 |
-
break;
|
429 |
-
|
430 |
-
case 'textarea':
|
431 |
-
$options[$id] = stripslashes($options[$id]);
|
432 |
-
$options[$id] = esc_html( $options[$id]);
|
433 |
-
echo "<textarea class='textarea$field_class' type='text' id='$id' name='" . QTS_OPTIONS_NAME . "[$id]' rows='5' cols='30'>$options[$id]</textarea>";
|
434 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
435 |
-
break;
|
436 |
-
|
437 |
-
case 'select':
|
438 |
-
echo "<select id='$id' class='select$field_class' name='" . QTS_OPTIONS_NAME . "[$id]'>";
|
439 |
-
foreach($choices as $item) {
|
440 |
-
$value = esc_attr($item, 'qts');
|
441 |
-
$item = esc_html($item, 'qts');
|
442 |
-
|
443 |
-
$selected = ($options[$id]==$value) ? 'selected="selected"' : '';
|
444 |
-
echo "<option value='$value' $selected>$item</option>";
|
445 |
-
}
|
446 |
-
echo "</select>";
|
447 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
448 |
-
break;
|
449 |
-
|
450 |
-
case 'select2':
|
451 |
-
echo "<select id='$id' class='select$field_class' name='" . QTS_OPTIONS_NAME . "[$id]'>";
|
452 |
-
foreach($choices as $item) {
|
453 |
-
|
454 |
-
$item = explode("|",$item);
|
455 |
-
$item[0] = esc_html($item[0], 'qts');
|
456 |
-
|
457 |
-
$selected = ($options[$id]==$item[1]) ? 'selected="selected"' : '';
|
458 |
-
echo "<option value='$item[1]' $selected>$item[0]</option>";
|
459 |
-
}
|
460 |
-
echo "</select>";
|
461 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
462 |
-
break;
|
463 |
-
|
464 |
-
case 'checkbox':
|
465 |
-
echo "<input class='checkbox$field_class' type='checkbox' id='$id' name='" . QTS_OPTIONS_NAME . "[$id]' value='1' " . checked( $options[$id], 1, false ) . " />";
|
466 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
467 |
-
break;
|
468 |
-
|
469 |
-
case "multi-checkbox":
|
470 |
-
foreach($choices as $item) {
|
471 |
-
|
472 |
-
$item = explode("|",$item);
|
473 |
-
$item[0] = esc_html($item[0], 'qts');
|
474 |
-
|
475 |
-
$checked = '';
|
476 |
-
|
477 |
-
if ( isset($options[$id][$item[1]]) ) {
|
478 |
-
if ( $options[$id][$item[1]] == 'true') {
|
479 |
-
$checked = 'checked="checked"';
|
480 |
-
}
|
481 |
-
}
|
482 |
-
|
483 |
-
echo "<input class='checkbox$field_class' type='checkbox' id='$id|$item[1]' name='" . QTS_OPTIONS_NAME . "[$id|$item[1]]' value='1' $checked /> $item[0] <br/>";
|
484 |
-
}
|
485 |
-
echo ($desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
486 |
-
break;
|
487 |
-
|
488 |
-
case "multi-radio":
|
489 |
-
foreach($choices as $index => $item) {
|
490 |
-
|
491 |
-
$item = explode("|",$item);
|
492 |
-
$item_key = (count($item) > 1) ? esc_html($item[0], 'qts') : esc_html(end($item), 'qts');
|
493 |
-
$item_value = (count($item) > 1) ? esc_html($item[1], 'qts') : esc_html(end($item), 'qts');
|
494 |
-
|
495 |
-
$checked = '';
|
496 |
-
|
497 |
-
if ( isset($options[$id]) && $options[$id] === $item_value) {
|
498 |
-
$checked = 'checked="checked"';
|
499 |
-
}
|
500 |
-
|
501 |
-
echo "<label for='$id|$item_value'><input class='radio$field_class' type='radio' id='$id|$item_value' name='" . QTS_OPTIONS_NAME . "[$id]' value='$item_value' $checked /> <strong>$item_key</strong>";
|
502 |
-
if (isset($desc[$index]) && !empty($desc[$index])) {
|
503 |
-
echo ": " . $desc[$index];
|
504 |
-
}
|
505 |
-
echo "</label>";
|
506 |
-
}
|
507 |
-
echo (!is_array($desc) && $desc != '') ? "<br /><span class='description'>$desc</span>" : "";
|
508 |
-
break;
|
509 |
-
}
|
510 |
-
}
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
/**
|
515 |
-
* Validates base slugs per 'type' (post_type | taxonomy) and 'language'
|
516 |
-
*
|
517 |
-
* @package Qtranslate Slug
|
518 |
-
* @subpackage Settings
|
519 |
-
* @version 1.0
|
520 |
-
*
|
521 |
-
*/
|
522 |
-
function qts_sanitize_bases($base_slugs = false) {
|
523 |
-
|
524 |
-
if ( !$base_slugs || empty($base_slugs) ) return;
|
525 |
-
|
526 |
-
$base_slugs_processed = array();
|
527 |
-
$base_founded = array();
|
528 |
-
|
529 |
-
// changing array structure
|
530 |
-
foreach ($base_slugs as $type => $base) {
|
531 |
-
foreach ($base as $lang => $value) {
|
532 |
-
if ($value != ""):
|
533 |
-
$base_value = $value;
|
534 |
-
$count = 2;
|
535 |
-
while (in_array($value, $base_founded)) {
|
536 |
-
$value = "$base_value-$count";
|
537 |
-
$count++;
|
538 |
-
}
|
539 |
-
$base_founded[] = $base_slugs[$type][$lang] = $value;
|
540 |
-
endif;
|
541 |
-
}
|
542 |
-
}
|
543 |
-
|
544 |
-
return $base_slugs;
|
545 |
-
}
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
/**
|
550 |
-
* Admin Settings Page HTML
|
551 |
-
*
|
552 |
-
* @package Qtranslate Slug
|
553 |
-
* @subpackage Settings
|
554 |
-
* @version 1.0
|
555 |
-
*
|
556 |
-
* @return echoes output
|
557 |
-
*/
|
558 |
-
function qts_show_settings_page() {
|
559 |
-
// get the settings sections array
|
560 |
-
$settings_output = qts_get_settings();
|
561 |
-
?>
|
562 |
-
<div class="wrap">
|
563 |
-
<div class="icon32" id="icon-options-general"></div>
|
564 |
-
<h2><?php echo $settings_output['qts_page_title']; ?></h2>
|
565 |
-
|
566 |
-
<p><?php _e('If you activated previously the <a href="options-permalink.php">pretty permalinks</a>, in this section you can translate the <abbr title="en inglés, Universal Resource Locator">URLs</abbr> <strong>bases</strong> for <a href="http://codex.wordpress.org/Function_Reference/register_post_type#Arguments">public</a> post_types, categories, tags and taxonomies.', 'qts'); ?> </p>
|
567 |
-
|
568 |
-
<form action="options.php" method="post">
|
569 |
-
<?php
|
570 |
-
// upgrade notify
|
571 |
-
qts_upgrade();
|
572 |
-
// http://codex.wordpress.org/Function_Reference/settings_fields
|
573 |
-
settings_fields($settings_output['qts_option_name']);
|
574 |
-
|
575 |
-
// http://codex.wordpress.org/Function_Reference/do_settings_sections
|
576 |
-
do_settings_sections(__FILE__);
|
577 |
-
// rewrite rules
|
578 |
-
flush_rewrite_rules();
|
579 |
-
?>
|
580 |
-
|
581 |
-
<p class="submit">
|
582 |
-
<input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes','qts'); ?>" />
|
583 |
-
</p>
|
584 |
-
|
585 |
-
</form>
|
586 |
-
</div><!-- wrap -->
|
587 |
-
<?php }
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
/**
|
592 |
-
* Validate input
|
593 |
-
*
|
594 |
-
* @package Qtranslate Slug
|
595 |
-
* @subpackage Settings
|
596 |
-
* @version 1.0
|
597 |
-
*
|
598 |
-
* @return array
|
599 |
-
*/
|
600 |
-
function qts_validate_options($input) {
|
601 |
-
|
602 |
-
// for enhanced security, create a new empty array
|
603 |
-
$valid_input = array();
|
604 |
-
|
605 |
-
// collect only the values we expect and fill the new $valid_input array
|
606 |
-
// i.e. whitelist our option IDs
|
607 |
-
|
608 |
-
// get the settings sections array
|
609 |
-
$settings_output = qts_get_settings();
|
610 |
-
|
611 |
-
$styleoptions = $settings_output['qts_page_styles'];
|
612 |
-
|
613 |
-
$slugoptions = $settings_output['qts_page_fields'];
|
614 |
-
|
615 |
-
$options = array_merge($styleoptions,$slugoptions);
|
616 |
-
|
617 |
-
// run a foreach and switch on option type
|
618 |
-
foreach ($options as $option):
|
619 |
-
|
620 |
-
switch ( $option['type'] ):
|
621 |
-
case 'text':
|
622 |
-
//switch validation based on the class!
|
623 |
-
switch ( $option['class'] ) {
|
624 |
-
//for numeric
|
625 |
-
case 'numeric':
|
626 |
-
//accept the input only when numeric!
|
627 |
-
$input[$option['id']] = trim($input[$option['id']]); // trim whitespace
|
628 |
-
$valid_input[$option['id']] = (is_numeric($input[$option['id']])) ? $input[$option['id']] : 'Expecting a Numeric value!';
|
629 |
-
|
630 |
-
// register error
|
631 |
-
if(is_numeric($input[$option['id']]) == FALSE) {
|
632 |
-
add_settings_error(
|
633 |
-
$option['id'], // setting title
|
634 |
-
QTS_PREFIX . '_txt_numeric_error', // error ID
|
635 |
-
__('Expecting a Numeric value! Please fix.', 'qts'), // error message
|
636 |
-
'error' // type of message
|
637 |
-
);
|
638 |
-
}
|
639 |
-
break;
|
640 |
-
|
641 |
-
//for multi-numeric values (separated by a comma)
|
642 |
-
case 'multinumeric':
|
643 |
-
//accept the input only when the numeric values are comma separated
|
644 |
-
$input[$option['id']] = trim($input[$option['id']]); // trim whitespace
|
645 |
-
|
646 |
-
if($input[$option['id']] !=''){
|
647 |
-
// /^-?\d+(?:,\s?-?\d+)*$/ matches: -1 | 1 | -12,-23 | 12,23 | -123, -234 | 123, 234 | etc.
|
648 |
-
$valid_input[$option['id']] = (preg_match('/^-?\d+(?:,\s?-?\d+)*$/', $input[$option['id']]) == 1) ? $input[$option['id']] : __('Expecting comma separated numeric values','qts');
|
649 |
-
}else{
|
650 |
-
$valid_input[$option['id']] = $input[$option['id']];
|
651 |
-
}
|
652 |
-
|
653 |
-
// register error
|
654 |
-
if($input[$option['id']] !='' && preg_match('/^-?\d+(?:,\s?-?\d+)*$/', $input[$option['id']]) != 1) {
|
655 |
-
add_settings_error(
|
656 |
-
$option['id'], // setting title
|
657 |
-
QTS_PREFIX . '_txt_multinumeric_error', // error ID
|
658 |
-
__('Expecting comma separated numeric values! Please fix.','qts'), // error message
|
659 |
-
'error' // type of message
|
660 |
-
);
|
661 |
-
}
|
662 |
-
break;
|
663 |
-
|
664 |
-
//for no html
|
665 |
-
case 'nohtml':
|
666 |
-
//accept the input only after stripping out all html, extra white space etc!
|
667 |
-
$input[$option['id']] = sanitize_text_field($input[$option['id']]); // need to add slashes still before sending to the database
|
668 |
-
$valid_input[$option['id']] = addslashes($input[$option['id']]);
|
669 |
-
break;
|
670 |
-
|
671 |
-
//for url
|
672 |
-
case 'url':
|
673 |
-
//accept the input only when the url has been sanited for database usage with esc_url_raw()
|
674 |
-
$input[$option['id']] = trim($input[$option['id']]); // trim whitespace
|
675 |
-
$valid_input[$option['id']] = esc_url_raw($input[$option['id']]);
|
676 |
-
break;
|
677 |
-
|
678 |
-
//for email
|
679 |
-
case 'email':
|
680 |
-
//accept the input only after the email has been validated
|
681 |
-
$input[$option['id']] = trim($input[$option['id']]); // trim whitespace
|
682 |
-
if($input[$option['id']] != ''){
|
683 |
-
$valid_input[$option['id']] = (is_email($input[$option['id']])!== FALSE) ? $input[$option['id']] : __('Invalid email', 'qts');
|
684 |
-
}elseif($input[$option['id']] == ''){
|
685 |
-
$valid_input[$option['id']] = __('This setting field cannot be empty! Please enter a valid email address.', 'qts');
|
686 |
-
}
|
687 |
-
|
688 |
-
// register error
|
689 |
-
if(is_email($input[$option['id']])== FALSE || $input[$option['id']] == '') {
|
690 |
-
add_settings_error(
|
691 |
-
$option['id'], // setting title
|
692 |
-
QTS_PREFIX . '_txt_email_error', // error ID
|
693 |
-
__('Please enter a valid email address.', 'qts'), // error message
|
694 |
-
'error' // type of message
|
695 |
-
);
|
696 |
-
}
|
697 |
-
break;
|
698 |
-
|
699 |
-
// a "cover-all" fall-back when the class argument is not set
|
700 |
-
default:
|
701 |
-
// accept only a few inline html elements
|
702 |
-
$allowed_html = array(
|
703 |
-
'a' => array('href' => array (),'title' => array ()),
|
704 |
-
'b' => array(),
|
705 |
-
'em' => array (),
|
706 |
-
'i' => array (),
|
707 |
-
'strong' => array()
|
708 |
-
);
|
709 |
-
// trim whitespace
|
710 |
-
$input[$option['id']] = trim($input[$option['id']]);
|
711 |
-
// find incorrectly nested or missing closing tags and fix markup
|
712 |
-
$input[$option['id']] = force_balance_tags($input[$option['id']]);
|
713 |
-
// need to add slashes still before sending to the database
|
714 |
-
$input[$option['id']] = wp_kses( $input[$option['id']], $allowed_html);
|
715 |
-
|
716 |
-
$valid_input[$option['id']] = addslashes($input[$option['id']]);
|
717 |
-
break;
|
718 |
-
}
|
719 |
-
break;
|
720 |
-
|
721 |
-
case "multi-text":
|
722 |
-
// this will hold the text values as an array of 'key' => 'value'
|
723 |
-
unset($textarray);
|
724 |
-
|
725 |
-
$text_values = array();
|
726 |
-
foreach ($option['choices'] as $k => $v ) {
|
727 |
-
// explode the connective
|
728 |
-
$pieces = explode("|", $v);
|
729 |
-
|
730 |
-
$text_values[] = $pieces[1];
|
731 |
-
}
|
732 |
-
|
733 |
-
foreach ($text_values as $v ) {
|
734 |
-
|
735 |
-
// Check that the option isn't empty
|
736 |
-
if (!empty($input[$option['id'] . '|' . $v])) {
|
737 |
-
// If it's not null, make sure it's sanitized, add it to an array
|
738 |
-
switch ($option['class']) {
|
739 |
-
// different sanitation actions based on the class create you own cases as you need them
|
740 |
-
|
741 |
-
//for numeric input
|
742 |
-
case 'numeric':
|
743 |
-
//accept the input only if is numberic!
|
744 |
-
$input[$option['id'] . '|' . $v]= trim($input[$option['id'] . '|' . $v]); // trim whitespace
|
745 |
-
$input[$option['id'] . '|' . $v]= (is_numeric($input[$option['id'] . '|' . $v])) ? $input[$option['id'] . '|' . $v] : '';
|
746 |
-
break;
|
747 |
-
|
748 |
-
case 'qts-slug':
|
749 |
-
// strip all html tags and white-space.
|
750 |
-
$type_ = end( explode('_', $option['id']) );
|
751 |
-
$input[$option['id'] . '|' . $v]= sanitize_title( sanitize_text_field( $input[$option['id'] . '|' . $v] ) );
|
752 |
-
$input[$option['id'] . '|' . $v]= addslashes($input[$option['id'] . '|' . $v]);
|
753 |
-
break;
|
754 |
-
|
755 |
-
// a "cover-all" fall-back when the class argument is not set
|
756 |
-
default:
|
757 |
-
// strip all html tags and white-space.
|
758 |
-
$input[$option['id'] . '|' . $v]= sanitize_text_field($input[$option['id'] . '|' . $v]); // need to add slashes still before sending to the database
|
759 |
-
$input[$option['id'] . '|' . $v]= addslashes($input[$option['id'] . '|' . $v]);
|
760 |
-
break;
|
761 |
-
}
|
762 |
-
// pass the sanitized user input to our $textarray array
|
763 |
-
$textarray[$v] = $input[$option['id'] . '|' . $v];
|
764 |
-
|
765 |
-
} else {
|
766 |
-
$textarray[$v] = '';
|
767 |
-
}
|
768 |
-
}
|
769 |
-
// pass the non-empty $textarray to our $valid_input array
|
770 |
-
if (!empty($textarray)) {
|
771 |
-
$valid_input[$option['id']] = $textarray;
|
772 |
-
}
|
773 |
-
break;
|
774 |
-
|
775 |
-
case 'textarea':
|
776 |
-
//switch validation based on the class!
|
777 |
-
switch ( $option['class'] ) {
|
778 |
-
//for only inline html
|
779 |
-
case 'inlinehtml':
|
780 |
-
// accept only inline html
|
781 |
-
// trim whitespace
|
782 |
-
$input[$option['id']] = trim($input[$option['id']]);
|
783 |
-
// find incorrectly nested or missing closing tags and fix markup
|
784 |
-
$input[$option['id']] = force_balance_tags($input[$option['id']]);
|
785 |
-
//wp_filter_kses expects content to be escaped!
|
786 |
-
$input[$option['id']] = addslashes($input[$option['id']]);
|
787 |
-
//calls stripslashes then addslashes
|
788 |
-
$valid_input[$option['id']] = wp_filter_kses($input[$option['id']]);
|
789 |
-
break;
|
790 |
-
|
791 |
-
//for no html
|
792 |
-
case 'nohtml':
|
793 |
-
//accept the input only after stripping out all html, extra white space etc!
|
794 |
-
// need to add slashes still before sending to the database
|
795 |
-
$input[$option['id']] = sanitize_text_field($input[$option['id']]);
|
796 |
-
$valid_input[$option['id']] = addslashes($input[$option['id']]);
|
797 |
-
break;
|
798 |
-
|
799 |
-
//for allowlinebreaks
|
800 |
-
case 'allowlinebreaks':
|
801 |
-
//accept the input only after stripping out all html, extra white space etc!
|
802 |
-
// need to add slashes still before sending to the database
|
803 |
-
$input[$option['id']] = wp_strip_all_tags($input[$option['id']]);
|
804 |
-
$valid_input[$option['id']] = addslashes($input[$option['id']]);
|
805 |
-
break;
|
806 |
-
|
807 |
-
// a "cover-all" fall-back when the class argument is not set
|
808 |
-
default:
|
809 |
-
// accept only limited html
|
810 |
-
//my allowed html
|
811 |
-
$allowed_html = array(
|
812 |
-
'a' => array('href' => array (),'title' => array ()),
|
813 |
-
'b' => array(),
|
814 |
-
'blockquote' => array('cite' => array ()),
|
815 |
-
'br' => array(),
|
816 |
-
'dd' => array(),
|
817 |
-
'dl' => array(),
|
818 |
-
'dt' => array(),
|
819 |
-
'em' => array (),
|
820 |
-
'i' => array (),
|
821 |
-
'li' => array(),
|
822 |
-
'ol' => array(),
|
823 |
-
'p' => array(),
|
824 |
-
'q' => array('cite' => array ()),
|
825 |
-
'strong' => array(),
|
826 |
-
'ul' => array(),
|
827 |
-
'h1' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ()),
|
828 |
-
'h2' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ()),
|
829 |
-
'h3' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ()),
|
830 |
-
'h4' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ()),
|
831 |
-
'h5' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ()),
|
832 |
-
'h6' => array('align' => array (),'class' => array (),'id' => array (), 'style' => array ())
|
833 |
-
);
|
834 |
-
|
835 |
-
$input[$option['id']] = trim($input[$option['id']]); // trim whitespace
|
836 |
-
$input[$option['id']] = force_balance_tags($input[$option['id']]); // find incorrectly nested or missing closing tags and fix markup
|
837 |
-
$input[$option['id']] = wp_kses( $input[$option['id']], $allowed_html); // need to add slashes still before sending to the database
|
838 |
-
$valid_input[$option['id']] = addslashes($input[$option['id']]);
|
839 |
-
break;
|
840 |
-
}
|
841 |
-
break;
|
842 |
-
|
843 |
-
case 'select':
|
844 |
-
// check to see if the selected value is in our approved array of values!
|
845 |
-
$valid_input[$option['id']] = (in_array( $input[$option['id']], $option['choices']) ? $input[$option['id']] : '' );
|
846 |
-
break;
|
847 |
-
|
848 |
-
case 'select2':
|
849 |
-
// process $select_values
|
850 |
-
$select_values = array();
|
851 |
-
foreach ($option['choices'] as $k => $v) {
|
852 |
-
// explode the connective
|
853 |
-
$pieces = explode("|", $v);
|
854 |
-
|
855 |
-
$select_values[] = $pieces[1];
|
856 |
-
}
|
857 |
-
// check to see if selected value is in our approved array of values!
|
858 |
-
$valid_input[$option['id']] = (in_array( $input[$option['id']], $select_values) ? $input[$option['id']] : '' );
|
859 |
-
break;
|
860 |
-
|
861 |
-
case 'checkbox':
|
862 |
-
// if it's not set, default to null!
|
863 |
-
if (!isset($input[$option['id']])) {
|
864 |
-
$input[$option['id']] = null;
|
865 |
-
}
|
866 |
-
// Our checkbox value is either 0 or 1
|
867 |
-
$valid_input[$option['id']] = ( $input[$option['id']] == 1 ? 1 : 0 );
|
868 |
-
break;
|
869 |
-
|
870 |
-
case 'multi-checkbox':
|
871 |
-
unset($checkboxarray);
|
872 |
-
$check_values = array();
|
873 |
-
foreach ($option['choices'] as $k => $v ) {
|
874 |
-
// explode the connective
|
875 |
-
$pieces = explode("|", $v);
|
876 |
-
|
877 |
-
$check_values[] = $pieces[1];
|
878 |
-
}
|
879 |
-
|
880 |
-
foreach ($check_values as $v ) {
|
881 |
-
|
882 |
-
// Check that the option isn't null
|
883 |
-
if (!empty($input[$option['id'] . '|' . $v])) {
|
884 |
-
// If it's not null, make sure it's true, add it to an array
|
885 |
-
$checkboxarray[$v] = 'true';
|
886 |
-
}
|
887 |
-
else {
|
888 |
-
$checkboxarray[$v] = 'false';
|
889 |
-
}
|
890 |
-
}
|
891 |
-
// Take all the items that were checked, and set them as the main option
|
892 |
-
if (!empty($checkboxarray)) {
|
893 |
-
$valid_input[$option['id']] = $checkboxarray;
|
894 |
-
}
|
895 |
-
break;
|
896 |
-
|
897 |
-
case 'multi-radio':
|
898 |
-
$valid_input[$option['id']] = $input[$option['id']];
|
899 |
-
break;
|
900 |
-
|
901 |
-
endswitch;
|
902 |
-
|
903 |
-
if( $valid_input[$option['class']] === "qts-slug" )
|
904 |
-
$valid_input = qts_sanitize_bases($valid_input);
|
905 |
-
else
|
906 |
-
$valid_input= $valid_input;
|
907 |
-
|
908 |
-
endforeach;
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
return $valid_input;
|
913 |
-
}
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
/**
|
918 |
-
* Helper function for creating admin messages
|
919 |
-
*
|
920 |
-
* @package Qtranslate Slug
|
921 |
-
* @subpackage Settings
|
922 |
-
* @version 1.0
|
923 |
-
*
|
924 |
-
* src: http://www.wprecipes.com/how-to-show-an-urgent-message-in-the-wordpress-admin-area
|
925 |
-
*
|
926 |
-
* @param (string) $message The message to echo
|
927 |
-
* @param (string) $msgclass The message class
|
928 |
-
* @return echoes the message
|
929 |
-
*/
|
930 |
-
function qts_show_msg($message, $msgclass = 'info') {
|
931 |
-
echo "<div id='message' class='$msgclass'>$message</div>";
|
932 |
-
}
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
/**
|
937 |
-
* Callback function for displaying admin messages
|
938 |
-
*
|
939 |
-
* @package Qtranslate Slug
|
940 |
-
* @subpackage Settings
|
941 |
-
* @version 1.0
|
942 |
-
*
|
943 |
-
* @return calls qts_show_msg()
|
944 |
-
*/
|
945 |
-
function qts_admin_msgs() {
|
946 |
-
global $current_screen;
|
947 |
-
|
948 |
-
// check for our settings page - need this in conditional further down
|
949 |
-
$qts_settings_pg = isset($_GET['page']) ? strpos($_GET['page'], QTS_PAGE_BASENAME) : '';
|
950 |
-
// collect setting errors/notices:
|
951 |
-
// http://codex.wordpress.org/Function_Reference/get_settings_errors
|
952 |
-
$set_errors = get_settings_errors();
|
953 |
-
|
954 |
-
// display admin message only for the admin to see, only on our settings page
|
955 |
-
// and only when setting errors/notices are returned!
|
956 |
-
if(current_user_can ('manage_options') && $qts_settings_pg !== false && !empty($set_errors)){
|
957 |
-
|
958 |
-
// have our settings succesfully been updated?
|
959 |
-
if($set_errors[0]['code'] == 'settings_updated' && isset($_GET['settings-updated'])){
|
960 |
-
qts_show_msg("<p>" . $set_errors[0]['message'] . "</p>", 'updated');
|
961 |
-
|
962 |
-
// have errors been found?
|
963 |
-
}else{
|
964 |
-
// there maybe more than one so run a foreach loop.
|
965 |
-
foreach($set_errors as $set_error){
|
966 |
-
// set the title attribute to match the error "setting title" - need this in js file
|
967 |
-
qts_show_msg("<p class='setting-error-message' title='" . $set_error['setting'] . "'>" . $set_error['message'] . "</p>", 'error');
|
968 |
-
}
|
969 |
-
}
|
970 |
-
}
|
971 |
-
}
|
972 |
-
add_action('admin_notices', 'qts_admin_msgs');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/qtranslate-slug.php
DELETED
@@ -1,184 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
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.8
|
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 |
-
|
17 |
-
if ( WP_DEBUG === true ):
|
18 |
-
|
19 |
-
if ( is_array( $message ) || is_object( $message ) ) {
|
20 |
-
|
21 |
-
error_log( print_r( $message, true ) );
|
22 |
-
|
23 |
-
} else {
|
24 |
-
|
25 |
-
error_log( $message );
|
26 |
-
}
|
27 |
-
|
28 |
-
endif;
|
29 |
-
}
|
30 |
-
endif;
|
31 |
-
|
32 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Includes
|
38 |
-
*
|
39 |
-
* @since 1.1.8
|
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 |
-
|
46 |
-
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Define Constants
|
50 |
-
*
|
51 |
-
* @since 1.0
|
52 |
-
*/
|
53 |
-
if (!defined("QTS_VERSION")) define("QTS_VERSION", '1.1.8');
|
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 |
-
/**
|
79 |
-
* Init the plugin
|
80 |
-
*
|
81 |
-
* @since 1.0
|
82 |
-
*/
|
83 |
-
global $qtranslate_slug;
|
84 |
-
|
85 |
-
$qtranslate_slug = new QtranslateSlug();
|
86 |
-
|
87 |
-
// plugin activation
|
88 |
-
register_activation_hook( __FILE__, array($qtranslate_slug, 'install') );
|
89 |
-
|
90 |
-
// plugin deactivation
|
91 |
-
register_deactivation_hook( __FILE__, array($qtranslate_slug, 'deactivate') );
|
92 |
-
|
93 |
-
// plugin uninstall
|
94 |
-
register_uninstall_hook( __FILE__, 'qts_uninstall' );
|
95 |
-
|
96 |
-
// plugin init
|
97 |
-
add_action('plugins_loaded', array($qtranslate_slug, 'init') );
|
98 |
-
|
99 |
-
////////////////////////////////////////////////////////////////////////////////////////
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Language Selector Code for templating
|
105 |
-
*
|
106 |
-
* @package Qtranslate Slug
|
107 |
-
* @subpackage Core
|
108 |
-
* @since 1.0
|
109 |
-
*/
|
110 |
-
function qts_language_menu ($type = "text", $args = array()) {
|
111 |
-
global $qtranslate_slug;
|
112 |
-
|
113 |
-
$qtranslate_slug->language_menu($type, $args);
|
114 |
-
}
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Adds support for old plugin function
|
120 |
-
*
|
121 |
-
* @package Qtranslate Slug
|
122 |
-
* @subpackage Core
|
123 |
-
* @since 1.1.5
|
124 |
-
*/
|
125 |
-
function qTranslateSlug_getSelfUrl ($lang = false) { // bad naming, I'll keep just in case
|
126 |
-
return qts_get_url($lang);
|
127 |
-
}
|
128 |
-
|
129 |
-
function qts_get_url($lang = false) {
|
130 |
-
global $qtranslate_slug;
|
131 |
-
|
132 |
-
return $qtranslate_slug->get_current_url($lang);
|
133 |
-
}
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Add a "Settings" link to the plugins.php page for Qtranslate Slug
|
139 |
-
*
|
140 |
-
* @package Qtranslate Slug
|
141 |
-
* @subpackage Settings
|
142 |
-
* @version 1.0
|
143 |
-
*
|
144 |
-
* @return calls qts_show_msg()
|
145 |
-
*/
|
146 |
-
function qts_add_settings_link( $links, $file ) {
|
147 |
-
|
148 |
-
if (QtranslateSlug::block_activate()) return $links;
|
149 |
-
|
150 |
-
$this_plugin = plugin_basename( __FILE__ );
|
151 |
-
if( $file == $this_plugin ) {
|
152 |
-
$settings_link = "<a href=\"options-general.php?page=" . QTS_PAGE_BASENAME . "\">" . __( 'Settings' ) . '</a>';
|
153 |
-
array_unshift($links, $settings_link);
|
154 |
-
}
|
155 |
-
return $links;
|
156 |
-
}
|
157 |
-
add_filter( 'plugin_action_links', 'qts_add_settings_link', 10, 2 );
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Delete plugin stored data ( options, termmeta table and postmeta data ) ################################################ TODO: test this function
|
163 |
-
*
|
164 |
-
* @package Qtranslate Slug
|
165 |
-
* @subpackage Settings
|
166 |
-
* @version 1.0
|
167 |
-
*
|
168 |
-
*/
|
169 |
-
function qts_uninstall() {
|
170 |
-
global $q_config, $wpdb;
|
171 |
-
|
172 |
-
// options
|
173 |
-
delete_option(QTS_OPTIONS_NAME);
|
174 |
-
delete_option('qts_version');
|
175 |
-
|
176 |
-
// delete termmeta table
|
177 |
-
$wpdb->query("DROP TABLE IF EXISTS $wpdb->termmeta");
|
178 |
-
|
179 |
-
// delete postmeta data
|
180 |
-
$meta_keys = array();
|
181 |
-
foreach ($q_config['enabled_languages'] as $lang) $meta_keys[] = sprintf("_qts_slug_%s", $lang);
|
182 |
-
$meta_keys = "'". implode( "','", $meta_keys ) . "'";
|
183 |
-
$wpdb->query("DELETE from $wpdb->postmeta WHERE meta_key IN ($meta_keys)");
|
184 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/readme.md
DELETED
@@ -1,209 +0,0 @@
|
|
1 |
-
# Qtranslate Slug
|
2 |
-
|
3 |
-
![Qtranslate Slug logo](http://codingsomething.files.wordpress.com/2013/01/qts-logo.png?w=200)
|
4 |
-
|
5 |
-
Adds support for permalink translations and fix some QTranslate deficiencies since wordpress 3.0
|
6 |
-
|
7 |
-
## Description
|
8 |
-
|
9 |
-
[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.
|
10 |
-
|
11 |
-
**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 integrated with Wordpress API.
|
12 |
-
|
13 |
-
**Requirements:**
|
14 |
-
|
15 |
-
* Wordpress 3.3 (PHP 5.2 and MySQL 5)
|
16 |
-
* mQtranslate 2.6.2.4 or Qtranslate 2.5.8
|
17 |
-
|
18 |
-
## New in Version 1.1.8
|
19 |
-
|
20 |
-
Many thanks to everyone that contributed to this update, for their commits, bug reports and for simply using it
|
21 |
-
|
22 |
-
* Portuguese translation and fixed some translation bugs ( thanks pedro-mendonca )
|
23 |
-
* removed mqtranslate switcher widget hook
|
24 |
-
* Updated the plugin structure and coding style
|
25 |
-
* solve some conflicts with search and pagination queries
|
26 |
-
* Settings php errors, syntax indent and fixed settings assets url
|
27 |
-
* Change titles when there is a click on pagination on show all pages tab ( thanks juanfran-granados )
|
28 |
-
* Formatted dependency notice message ( thanks arildm )
|
29 |
-
* Updated the deprecated jquery 'live' function and solve php strict standards error ( thanks rafitaFCB )
|
30 |
-
* Fixed error showing if PHP was newer than 5.3 ( thanks rafitaFCB )
|
31 |
-
* Strict standard advise prevented ( thanks rafitaFCB )
|
32 |
-
* php notices are prevented in post edit, when using adding new translated tags ( thanks rafitaFCB )
|
33 |
-
* fixed the hreflang issue! 'bout time!
|
34 |
-
* As discussed in issue #25, the flags are now img tags, intead of background-url.
|
35 |
-
* Added another option to include the css style in a minified file. ( and also showing in the option screen the styles we would use.)
|
36 |
-
|
37 |
-
## New in version 1.1.7
|
38 |
-
* removed styles from html elements and added options to use .css file or print inline styles
|
39 |
-
* fixed tag creation on post edit.
|
40 |
-
* fixed earlier bad post slug introduced in 1.1.6
|
41 |
-
|
42 |
-
**Advice: If you're using a multisite installation, you will must activate qtranslate plugins by separately on each site.**
|
43 |
-
|
44 |
-
You can also check the [project website](http://not-only-code.github.com/qtranslate-slug/) hosted on [GitHub](http://not-only-code.github.com).
|
45 |
-
Thanks for use this plugin!
|
46 |
-
|
47 |
-
## Contributors
|
48 |
-
|
49 |
-
* [Pedro de Carvalho](https://github.com/LC43/)
|
50 |
-
* [Risto Niinemets](https://github.com/RistoNiinemets)
|
51 |
-
* [Pedro Mendonça](https://github.com/pedro-mendonca)
|
52 |
-
* [codep0et](https://github.com/codep0et)
|
53 |
-
* [Giraldi Maggio](https://github.com/gmaggio)
|
54 |
-
* [jinoOM](https://github.com/jinoOM)
|
55 |
-
* [Juanfran](https://github.com/juanfran-granados)
|
56 |
-
* [Arild](https://github.com/arildm)
|
57 |
-
* [Rafa Aguilar](https://github.com/rafitaFCB)
|
58 |
-
|
59 |
-
|
60 |
-
## Installation
|
61 |
-
|
62 |
-
**This plugins requires [Qtranslate](http://wordpress.org/extend/plugins/qtranslate/) or [mqTranslate](https://wordpress.org/plugins/mqtranslate/) installed previously, if not, it will not activate.**
|
63 |
-
|
64 |
-
1. Upload `qtranslate-slug` to the `/wp-content/plugins/` directory.
|
65 |
-
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
66 |
-
1. That's all!
|
67 |
-
|
68 |
-
## Testing
|
69 |
-
|
70 |
-
1. Install [wp-cli](http://wp-cli.org/)
|
71 |
-
1. Follow this instrucctions **ommiting 2nd step**: [Plugin Unit Tests](https://github.com/wp-cli/wp-cli/wiki/Plugin-Unit-Tests).
|
72 |
-
|
73 |
-
## Changing base permastructs
|
74 |
-
|
75 |
-
1. In admin: navigate to *Settings/Slug options*.
|
76 |
-
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).
|
77 |
-
1. Save settings and that's all!
|
78 |
-
|
79 |
-
## Frequently Asked Questions
|
80 |
-
|
81 |
-
**It works with posts and pages, but with other content type?**
|
82 |
-
|
83 |
-
This plugin allows to translate slugs of: posts, pages, custom post types, categories, tags and custom taxonomies.
|
84 |
-
|
85 |
-
**Do I have to configure anything?**
|
86 |
-
|
87 |
-
If you want to translate also the base permastructs (ex. *category*, *tag*, etc). Visit the plugin settings page in the admin *Settings/Slug options*
|
88 |
-
|
89 |
-
**How can i insert a language selector in my theme ?**
|
90 |
-
|
91 |
-
You can choose to:
|
92 |
-
* use **Qtranslate Slug Widget** in your sidebar.
|
93 |
-
* place in your template `<?php if (function_exists('qts_language_menu') ) qts_language_menu('text'); ?>`. Options are: `dropdown`, `text`, `image`, and `both`.
|
94 |
-
|
95 |
-
**Appears an error 404, what can i do?**
|
96 |
-
|
97 |
-
In the admin go to *Settings/Permalinks* or *Settings/Slug options* and save.
|
98 |
-
|
99 |
-
**I can't manage translations in Nav Menus.**
|
100 |
-
|
101 |
-
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.
|
102 |
-
|
103 |
-
## Screenshots
|
104 |
-
|
105 |
-
![Edit page](https://github.com/not-only-code/qtranslate-slug/raw/trunk/screenshot-1.png)
|
106 |
-
*Edit page for: post / page / post_type, you can see the meta box for translated slugs on top and right*
|
107 |
-
|
108 |
-
![Taxonomy page](https://github.com/not-only-code/qtranslate-slug/raw/trunk/screenshot-2.png)
|
109 |
-
*Add new taxonomy page*
|
110 |
-
|
111 |
-
![Edit taxonomy page](https://github.com/not-only-code/qtranslate-slug/raw/trunk/screenshot-3.png)
|
112 |
-
*Edit taxonomy page*
|
113 |
-
|
114 |
-
![Options page](https://github.com/not-only-code/qtranslate-slug/raw/trunk/screenshot-4.png)
|
115 |
-
*Qtranslate Slug options page for translate base permastructs of post_types and taxonomies*
|
116 |
-
|
117 |
-
## Changelog
|
118 |
-
|
119 |
-
**1.1.7**
|
120 |
-
* removed styles from html elements and added options to use .css file or print inline styles
|
121 |
-
* fixed tag creation on post edit.
|
122 |
-
* fixed earlier bad post slug introduced in 1.1.6
|
123 |
-
|
124 |
-
**1.1.6**
|
125 |
-
* compatible with mqtranslate
|
126 |
-
* php5.4+ compatible
|
127 |
-
|
128 |
-
**1.1.5**
|
129 |
-
* bugfixes
|
130 |
-
|
131 |
-
**1.1**
|
132 |
-
* added multisite support
|
133 |
-
* fixed some parse url bugs
|
134 |
-
* fixed slug bases validation
|
135 |
-
|
136 |
-
**1.0**
|
137 |
-
* **works** with any permalink combination and qtranslate mode.
|
138 |
-
* 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).
|
139 |
-
* 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.
|
140 |
-
* the plugin generates translated slug automatically from title in empty cases.
|
141 |
-
* 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.
|
142 |
-
* 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.
|
143 |
-
* added some filters, see in [other notes](http://wordpress.org/extend/plugins/qtranslate-slug/other_notes/).
|
144 |
-
* added plugin language textdomain (.pot file).
|
145 |
-
* updated **Language selector Widget**, and some new conventions like accessible functions for templating.
|
146 |
-
* some bug fixes.
|
147 |
-
* some Qtranslate patches.
|
148 |
-
|
149 |
-
**0.9**
|
150 |
-
* some wordpress qTranslate bug fixes
|
151 |
-
* adds a javascript solution for qTranslate Nav Menus
|
152 |
-
|
153 |
-
**0.8**
|
154 |
-
* added support por Categories
|
155 |
-
* added support por Tags
|
156 |
-
* added support por Taxonomies
|
157 |
-
* added support por Custom Post Types
|
158 |
-
|
159 |
-
**0.7** [Zapo](http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=4&t=1049&start=50#p7499)
|
160 |
-
* added suport for qTranslate TLD domain mode (en: domain.com | fr: domain.fr) visit
|
161 |
-
|
162 |
-
**0.5 and 0.6 enhanched by Marco Del Percio**
|
163 |
-
|
164 |
-
## Upgrade Notice
|
165 |
-
|
166 |
-
**1.0**
|
167 |
-
Major version, the plugin has been rewritten. Better performance, and some enhancements.
|
168 |
-
|
169 |
-
**0.9**
|
170 |
-
This version fix some bugs and allow multilanguage in nav-menus.
|
171 |
-
|
172 |
-
**0.8**
|
173 |
-
A lot of slugs content allowed
|
174 |
-
|
175 |
-
**0.7**
|
176 |
-
This version allows TLD domain option for a different Qtranslate fork maded by Zappo
|
177 |
-
|
178 |
-
|
179 |
-
## Other notes
|
180 |
-
|
181 |
-
Plugin filters reference:
|
182 |
-
|
183 |
-
**qts_validate_post_slug**
|
184 |
-
filter to process the post slug before is saved on the database.
|
185 |
-
|
186 |
-
args: $post (object), $slug (string), $lang (string)
|
187 |
-
|
188 |
-
**qts_validate_term_slug**
|
189 |
-
filter to process the term slug before is saved on the database.
|
190 |
-
|
191 |
-
args: $term (object), $slug (string), $lang (string)
|
192 |
-
|
193 |
-
**qts_url_args**
|
194 |
-
filter to process the entire url after it has been generated.
|
195 |
-
|
196 |
-
args: $url (string), $lang (string)
|
197 |
-
|
198 |
-
**qts_permastruct**
|
199 |
-
filter to process the permastruct, used for change the base.
|
200 |
-
|
201 |
-
args: $permastruct (string), $name (string)
|
202 |
-
|
203 |
-
|
204 |
-
**Todo**
|
205 |
-
|
206 |
-
* detect Slug for each language and redirect accordingly in parse_query.
|
207 |
-
* expand qtranslate for translate attachment names and descriptions ( useful for galleries )
|
208 |
-
* translate other slugs like attachments.
|
209 |
-
* qtranslate integration with other plugins like Jigoshop, e-commerce, etc. Addapt **$wp_rewrite**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/readme.txt
DELETED
@@ -1,213 +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: 4.1.0
|
7 |
-
Stable tag: 1.1.8
|
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 |
-
= Requirements: =
|
20 |
-
|
21 |
-
* Wordpress 3.3 (PHP 5.2 and MySQL 5)
|
22 |
-
* mQtranslate 2.6.2.4 or Qtranslate 2.5.8 ( soon qtranslate-x too )
|
23 |
-
|
24 |
-
= New in version 1.1.8 =
|
25 |
-
|
26 |
-
Many thanks to everyone that contributed to this update, for their commits, bug reports and for simply using it
|
27 |
-
|
28 |
-
* Portuguese translation and fixed some translation bugs ( thanks pedro-mendonca )
|
29 |
-
* removed mqtranslate switcher widget hook
|
30 |
-
* Updated the plugin structure and coding style
|
31 |
-
* solve some conflicts with search and pagination queries
|
32 |
-
* Settings php errors, syntax indent and fixed settings assets url
|
33 |
-
* Change titles when there is a click on pagination on show all pages tab ( thanks juanfran-granados )
|
34 |
-
* Formatted dependency notice message ( thanks arildm )
|
35 |
-
* Updated the deprecated jquery 'live' function and solve php strict standards error ( thanks rafitaFCB )
|
36 |
-
* Fixed error showing if PHP was newer than 5.3 ( thanks rafitaFCB )
|
37 |
-
* Strict standard advise prevented ( thanks rafitaFCB )
|
38 |
-
* php notices are prevented in post edit, when using adding new translated tags ( thanks rafitaFCB )
|
39 |
-
* fixed the hreflang issue! 'bout time!
|
40 |
-
* As discussed in issue #25, the flags are now img tags, intead of background-url.
|
41 |
-
* Added another option to include the css style in a minified file. ( and also showing in the option screen the styles we would use.)
|
42 |
-
|
43 |
-
|
44 |
-
**Advice: If you're using a multisite installation, you will must activate qtranslate plugins by separately on each site.**
|
45 |
-
|
46 |
-
You can also check the [project website](http://not-only-code.github.com/qtranslate-slug/) hosted on [GitHub](http://not-only-code.github.com).
|
47 |
-
Thanks for use this plugin!
|
48 |
-
|
49 |
-
= Contributors =
|
50 |
-
|
51 |
-
* [Pedro de Carvalho](https://github.com/LC43/)
|
52 |
-
* [Risto Niinemets](https://github.com/RistoNiinemets)
|
53 |
-
* [Pedro Mendonça](https://github.com/pedro-mendonca)
|
54 |
-
* [codep0et](https://github.com/codep0et)
|
55 |
-
* [Giraldi Maggio](https://github.com/bedex78)
|
56 |
-
* [jinoOM](https://github.com/jinoOM)
|
57 |
-
* [Juanfran](https://github.com/juanfran-granados)
|
58 |
-
* [Arild](https://github.com/arildm)
|
59 |
-
* [Rafa Aguilar](https://github.com/rafitaFCB)
|
60 |
-
|
61 |
-
|
62 |
-
== Installation ==
|
63 |
-
**This plugins requires [Qtranslate](http://wordpress.org/extend/plugins/qtranslate/) or [mqTranslate](https://wordpress.org/plugins/mqtranslate/) installed previously, if not, it will not activate.**
|
64 |
-
|
65 |
-
1. Upload `qtranslate-slug` to the `/wp-content/plugins/` directory.
|
66 |
-
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
67 |
-
1. That's all!
|
68 |
-
|
69 |
-
= Changing base permastructs =
|
70 |
-
|
71 |
-
1. In admin: navigate to *Settings/Slug options*.
|
72 |
-
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).
|
73 |
-
1. Save settings and that's all!
|
74 |
-
|
75 |
-
== Frequently Asked Questions ==
|
76 |
-
|
77 |
-
= It works with posts and pages, but with other content type? =
|
78 |
-
|
79 |
-
This plugin allows to translate slugs of: posts, pages, custom post types, categories, tags and custom taxonomies.
|
80 |
-
|
81 |
-
= Do I have to configure anything? =
|
82 |
-
|
83 |
-
If you want to translate also the base permastructs (ex. *category*, *tag*, etc). Visit the plugin settings page in the admin *Settings/Slug options*
|
84 |
-
|
85 |
-
= How can i insert a language selector in my theme ? =
|
86 |
-
|
87 |
-
You can choose to:
|
88 |
-
* use **Qtranslate Slug Widget** in your sidebar.
|
89 |
-
* place in your template `<?php if (function_exists('qts_language_menu') ) qts_language_menu('text'); ?>`. Options are: `dropdown`, `text`, `image`, and `both`.
|
90 |
-
|
91 |
-
= Appears an error 404, what can i do? =
|
92 |
-
|
93 |
-
In the admin go to *Settings/Permalinks* or *Settings/Slug options* and save.
|
94 |
-
|
95 |
-
= I can't manage translations in Nav Menus. =
|
96 |
-
|
97 |
-
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.
|
98 |
-
|
99 |
-
== Screenshots ==
|
100 |
-
|
101 |
-
1. Edit page for: post / page / post_type, you can see the meta box for translated slugs on top and right.
|
102 |
-
2. Add new taxonomy page
|
103 |
-
3. Edit taxonomy page
|
104 |
-
4. Qtranslate Slug options page for translate base permastructs of post_types and taxonomies.
|
105 |
-
|
106 |
-
== Changelog ==
|
107 |
-
|
108 |
-
= 1.1.8 =
|
109 |
-
|
110 |
-
Many thanks to everyone that contributed to this update, for their commits, bug reports and for simply using it
|
111 |
-
|
112 |
-
* Portuguese translation and fixed some translation bugs ( thanks pedro-mendonca )
|
113 |
-
* removed mqtranslate switcher widget hook
|
114 |
-
* Updated the plugin structure and coding style
|
115 |
-
* solve some conflicts with search and pagination queries
|
116 |
-
* Settings php errors, syntax indent and fixed settings assets url
|
117 |
-
* Change titles when there is a click on pagination on show all pages tab ( thanks juanfran-granados )
|
118 |
-
* Formatted dependency notice message ( thanks arildm )
|
119 |
-
* Updated the deprecated jquery 'live' function and solve php strict standards error ( thanks rafitaFCB )
|
120 |
-
* Fixed error showing if PHP was newer than 5.3 ( thanks rafitaFCB )
|
121 |
-
* Strict standard advise prevented ( thanks rafitaFCB )
|
122 |
-
* php notices are prevented in post edit, when using adding new translated tags ( thanks rafitaFCB )
|
123 |
-
* fixed the hreflang issue! 'bout time!
|
124 |
-
* As discussed in issue #25, the flags are now img tags, intead of background-url.
|
125 |
-
* Added another option to include the css style in a minified file. ( and also showing in the option screen the styles we would use.)
|
126 |
-
|
127 |
-
= 1.1.7 =
|
128 |
-
* removed styles from html elements and added options to use .css file or print inline styles
|
129 |
-
* fixed tag creation on post edit.
|
130 |
-
* fixed earlier bad post slug introduced in 1.1.6
|
131 |
-
|
132 |
-
= 1.1.6 =
|
133 |
-
* compatible with mqtranslate
|
134 |
-
* php5.4+ compatible
|
135 |
-
|
136 |
-
= 1.1.5 =
|
137 |
-
* bugfixes
|
138 |
-
|
139 |
-
= 1.1 =
|
140 |
-
* added multisite support
|
141 |
-
* fixed some parse url bugs
|
142 |
-
* fixed slug bases validation
|
143 |
-
|
144 |
-
= 1.0 =
|
145 |
-
* **works** with any permalink combination and qtranslate mode.
|
146 |
-
* 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).
|
147 |
-
* 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.
|
148 |
-
* the plugin generates translated slug automatically from title in empty cases.
|
149 |
-
* 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.
|
150 |
-
* 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.
|
151 |
-
* added some filters, see in [other notes](http://wordpress.org/extend/plugins/qtranslate-slug/other_notes/).
|
152 |
-
* added plugin language textdomain (.pot file).
|
153 |
-
* updated **Language selector Widget**, and some new conventions like accessible functions for templating.
|
154 |
-
* some bug fixes.
|
155 |
-
* some Qtranslate patches.
|
156 |
-
|
157 |
-
= 0.9 =
|
158 |
-
* some wordpress qTranslate bug fixes
|
159 |
-
* adds a javascript solution for qTranslate Nav Menus
|
160 |
-
|
161 |
-
= 0.8 =
|
162 |
-
* added support por Categories
|
163 |
-
* added support por Tags
|
164 |
-
* added support por Taxonomies
|
165 |
-
* added support por Custom Post Types
|
166 |
-
|
167 |
-
= 0.7 = [Zapo](http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=4&t=1049&start=50#p7499)
|
168 |
-
* added suport for qTranslate TLD domain mode (en: domain.com | fr: domain.fr) visit
|
169 |
-
|
170 |
-
= 0.5 and 0.6 enhanched by Marco Del Percio =
|
171 |
-
|
172 |
-
== Upgrade Notice ==
|
173 |
-
|
174 |
-
= 1.0 =
|
175 |
-
Major version, the plugin has been rewritten. Better performance, and some enhancements.
|
176 |
-
|
177 |
-
= 0.9 =
|
178 |
-
This version fix some bugs and allow multilanguage in nav-menus.
|
179 |
-
|
180 |
-
= 0.8 =
|
181 |
-
A lot of slugs content allowed
|
182 |
-
|
183 |
-
= 0.7 =
|
184 |
-
This version allows TLD domain option for a different Qtranslate fork maded by Zappo
|
185 |
-
|
186 |
-
|
187 |
-
== Other notes ==
|
188 |
-
|
189 |
-
Plugin filters reference:
|
190 |
-
|
191 |
-
= qts_validate_post_slug =
|
192 |
-
filter to process the post slug before is saved on the database.
|
193 |
-
`args: $post (object), $slug (string), $lang (string)`
|
194 |
-
|
195 |
-
= qts_validate_term_slug =
|
196 |
-
filter to process the term slug before is saved on the database.
|
197 |
-
`args: $term (object), $slug (string), $lang (string)`
|
198 |
-
|
199 |
-
= qts_url_args =
|
200 |
-
filter to process the entire url after it has been generated.
|
201 |
-
`args: $url (string), $lang (string)`
|
202 |
-
|
203 |
-
= qts_permastruct =
|
204 |
-
filter to process the permastruct, used for change the base.
|
205 |
-
`args: $permastruct (string), $name (string)`
|
206 |
-
|
207 |
-
|
208 |
-
= Todo =
|
209 |
-
|
210 |
-
* detect Slug for each language and redirect accordingly in parse_query.
|
211 |
-
* expand qtranslate for translate attachment names and descriptions ( useful for galleries )
|
212 |
-
* translate other slugs like attachments.
|
213 |
-
* qtranslate integration with other plugins like Jigoshop, e-commerce, etc. Addapt **$wp_rewrite**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/screenshot-1.png
DELETED
Binary file
|
trunk/screenshot-2.png
DELETED
Binary file
|
trunk/screenshot-3.png
DELETED
Binary file
|
trunk/screenshot-4.png
DELETED
Binary file
|
trunk/termmeta-core.php
DELETED
@@ -1,222 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Install Term meta table - setup table, store db version for future updates
|
4 |
-
*/
|
5 |
-
if ( !function_exists('install_term_meta_table') ):
|
6 |
-
function install_term_meta_table() {
|
7 |
-
global $wpdb;
|
8 |
-
|
9 |
-
$collate = '';
|
10 |
-
if($wpdb->supports_collation()) {
|
11 |
-
if(!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
12 |
-
if(!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
|
13 |
-
}
|
14 |
-
|
15 |
-
$sql = "CREATE TABLE IF NOT EXISTS ". $wpdb->prefix . "termmeta" ." (
|
16 |
-
`meta_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
17 |
-
`term_id` bigint(20) NOT NULL DEFAULT '0',
|
18 |
-
`meta_key` varchar(255) NULL,
|
19 |
-
`meta_value` longtext NULL,
|
20 |
-
PRIMARY KEY id (`meta_id`)) $collate;";
|
21 |
-
$wpdb->query($sql);
|
22 |
-
}
|
23 |
-
endif;
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
function simple_post_meta_define_table() {
|
28 |
-
global $wpdb;
|
29 |
-
$wpdb->termmeta = $wpdb->prefix . 'termmeta';
|
30 |
-
}
|
31 |
-
add_action( 'init', 'simple_post_meta_define_table' );
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Updates metadata cache for list of term IDs.
|
37 |
-
*
|
38 |
-
* Performs SQL query to retrieve the metadata for the term IDs and updates the
|
39 |
-
* metadata cache for the terms. Therefore, the functions, which call this
|
40 |
-
* function, do not need to perform SQL queries on their own.
|
41 |
-
*
|
42 |
-
* @param array $term_ids List of post IDs.
|
43 |
-
* @return bool|array Returns false if there is nothing to update or an array of metadata.
|
44 |
-
*/
|
45 |
-
if ( !function_exists('update_termmeta_cache') ):
|
46 |
-
function update_termmeta_cache($term_ids) {
|
47 |
-
return update_meta_cache('term', $term_ids);
|
48 |
-
}
|
49 |
-
endif;
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Add meta data field to a term.
|
55 |
-
*
|
56 |
-
* @param int $term_id Term ID.
|
57 |
-
* @param string $key Metadata name.
|
58 |
-
* @param mixed $value Metadata value.
|
59 |
-
* @param bool $unique Optional, default is false. Whether the same key should not be added.
|
60 |
-
* @return bool False for failure. True for success.
|
61 |
-
*/
|
62 |
-
if ( !function_exists('add_term_meta') ):
|
63 |
-
function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) {
|
64 |
-
return add_metadata('term', $term_id, $meta_key, $meta_value, $unique);
|
65 |
-
}
|
66 |
-
endif;
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Remove metadata matching criteria from a term.
|
72 |
-
*
|
73 |
-
* You can match based on the key, or key and value. Removing based on key and
|
74 |
-
* value, will keep from removing duplicate metadata with the same key. It also
|
75 |
-
* allows removing all metadata matching key, if needed.
|
76 |
-
*
|
77 |
-
* @param int $term_id Term ID
|
78 |
-
* @param string $meta_key Metadata name.
|
79 |
-
* @param mixed $meta_value Optional. Metadata value.
|
80 |
-
* @return bool False for failure. True for success.
|
81 |
-
*/
|
82 |
-
if ( !function_exists('delete_term_meta') ):
|
83 |
-
function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) {
|
84 |
-
return delete_metadata('term', $term_id, $meta_key, $meta_value);
|
85 |
-
}
|
86 |
-
endif;
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Retrieve term meta field for a term.
|
92 |
-
*
|
93 |
-
* @param int $term_id Term ID.
|
94 |
-
* @param string $key The meta key to retrieve.
|
95 |
-
* @param bool $single Whether to return a single value.
|
96 |
-
* @return mixed Will be an array if $single is false. Will be value of meta data field if $single
|
97 |
-
* is true.
|
98 |
-
*/
|
99 |
-
if ( !function_exists('get_term_meta') ):
|
100 |
-
function get_term_meta( $term_id, $key, $single = false ) {
|
101 |
-
return get_metadata('term', $term_id, $key, $single);
|
102 |
-
}
|
103 |
-
endif;
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Update term meta field based on term ID.
|
109 |
-
*
|
110 |
-
* Use the $prev_value parameter to differentiate between meta fields with the
|
111 |
-
* same key and term ID.
|
112 |
-
*
|
113 |
-
* If the meta field for the term does not exist, it will be added.
|
114 |
-
*
|
115 |
-
* @param int $term_id Term ID.
|
116 |
-
* @param string $key Metadata key.
|
117 |
-
* @param mixed $value Metadata value.
|
118 |
-
* @param mixed $prev_value Optional. Previous value to check before removing.
|
119 |
-
* @return bool False on failure, true if success.
|
120 |
-
*/
|
121 |
-
if ( !function_exists('update_term_meta') ):
|
122 |
-
function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) {
|
123 |
-
return update_metadata('term', $term_id, $meta_key, $meta_value, $prev_value);
|
124 |
-
}
|
125 |
-
endif;
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Delete everything from term meta matching meta key.
|
131 |
-
*
|
132 |
-
* @param string $term_meta_key Key to search for when deleting.
|
133 |
-
* @return bool Whether the term meta key was deleted from the database
|
134 |
-
*/
|
135 |
-
if ( !function_exists('delete_term_meta_by_key') ):
|
136 |
-
function delete_term_meta_by_key($term_meta_key) {
|
137 |
-
if ( !$term_meta_key )
|
138 |
-
return false;
|
139 |
-
|
140 |
-
global $wpdb;
|
141 |
-
$term_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT term_id FROM $wpdb->termmeta WHERE meta_key = %s", $term_meta_key));
|
142 |
-
if ( $term_ids ) {
|
143 |
-
$termmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE meta_key = %s", $term_meta_key ) );
|
144 |
-
$in = implode( ',', array_fill(1, count($termmetaids), '%d'));
|
145 |
-
do_action( 'delete_termmeta', $termmetaids );
|
146 |
-
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->termmeta WHERE meta_id IN($in)", $termmetaids ));
|
147 |
-
do_action( 'deleted_termmeta', $termmetaids );
|
148 |
-
foreach ( $term_ids as $term_id )
|
149 |
-
wp_cache_delete($term_id, 'term_meta');
|
150 |
-
return true;
|
151 |
-
}
|
152 |
-
return false;
|
153 |
-
}
|
154 |
-
endif;
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Retrieve term meta fields, based on term ID.
|
160 |
-
*
|
161 |
-
* The term meta fields are retrieved from the cache, so the function is
|
162 |
-
* optimized to be called more than once. It also applies to the functions, that
|
163 |
-
* use this function.
|
164 |
-
*
|
165 |
-
* @param int $term_id term ID
|
166 |
-
* @return array
|
167 |
-
*/
|
168 |
-
if ( !function_exists('add_term_meta') ):
|
169 |
-
function get_term_custom( $term_id ) {
|
170 |
-
$term_id = (int) $term_id;
|
171 |
-
|
172 |
-
if ( ! wp_cache_get($term_id, 'term_meta') )
|
173 |
-
update_termmeta_cache($term_id);
|
174 |
-
|
175 |
-
return wp_cache_get($term_id, 'term_meta');
|
176 |
-
}
|
177 |
-
endif;
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Retrieve meta field names for a term.
|
183 |
-
*
|
184 |
-
* If there are no meta fields, then nothing (null) will be returned.
|
185 |
-
*
|
186 |
-
* @param int $term_id term ID
|
187 |
-
* @return array|null Either array of the keys, or null if keys could not be retrieved.
|
188 |
-
*/
|
189 |
-
if ( !function_exists('get_term_custom_keys') ):
|
190 |
-
function get_term_custom_keys( $term_id ) {
|
191 |
-
$custom = get_term_custom( $term_id );
|
192 |
-
|
193 |
-
if ( !is_array($custom) )
|
194 |
-
return;
|
195 |
-
|
196 |
-
if ( $keys = array_keys($custom) )
|
197 |
-
return $keys;
|
198 |
-
}
|
199 |
-
endif;
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Retrieve values for a custom term field.
|
205 |
-
*
|
206 |
-
* The parameters must not be considered optional. All of the term meta fields
|
207 |
-
* will be retrieved and only the meta field key values returned.
|
208 |
-
*
|
209 |
-
* @param string $key Meta field key.
|
210 |
-
* @param int $term_id Term ID
|
211 |
-
* @return array Meta field values.
|
212 |
-
*/
|
213 |
-
if ( !function_exists('get_term_custom_values') ):
|
214 |
-
function get_term_custom_values( $key = '', $term_id ) {
|
215 |
-
if ( !$key )
|
216 |
-
return null;
|
217 |
-
|
218 |
-
$custom = get_term_custom($term_id);
|
219 |
-
|
220 |
-
return isset($custom[$key]) ? $custom[$key] : null;
|
221 |
-
}
|
222 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/version.txt
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
= 1.1.8 =
|
2 |
-
|
3 |
-
Many thanks to everyone that contributed to this update, both for their commits and bug reports )
|
4 |
-
|
5 |
-
* Portuguese translation and fixed some translation bugs ( thanks pedro-mendonca )
|
6 |
-
* removed mqtranslate switcher widget hook
|
7 |
-
* Updated the plugin structure and coding style
|
8 |
-
* solve some conflicts with search and pagination queries
|
9 |
-
* Settings php errors, syntax indent and fixed settings assets url
|
10 |
-
* Change titles when there is a click on pagination on show all pages tab ( thanks juanfran-granados )
|
11 |
-
* Formatted dependency notice message ( thanks arildm )
|
12 |
-
* Updated the deprecated jquery 'live' function and solve php strict standards error ( thanks rafitaFCB )
|
13 |
-
* Fixed error showing if PHP was newer than 5.3 ( thanks rafitaFCB )
|
14 |
-
* Strict standard advise prevented ( thanks rafitaFCB )
|
15 |
-
* php notices are prevented in post edit, when using adding new translated tags ( thanks rafitaFCB )
|
16 |
-
* fixed the hreflang issue! 'bout time!
|
17 |
-
* As discussed in issue #25, the flags are now img tags, intead of background-url.
|
18 |
-
* Added another option to include the css style in a minified file. ( and also showing in the option screen the styles we would use.)
|
19 |
-
|
20 |
-
= 1.1.7 =
|
21 |
-
* removed styles from html elements and added options to use .css file or print inline styles
|
22 |
-
* fixed tag creation on post edit.
|
23 |
-
* fixed earlier bad post slug introduced in 1.1.6
|
24 |
-
|
25 |
-
= 1.1.6 =
|
26 |
-
* compatible with mqtranslate
|
27 |
-
* php5.4+ compatible
|
28 |
-
|
29 |
-
= 1.1.5 =
|
30 |
-
* bugfixes
|
31 |
-
|
32 |
-
= 1.1 =
|
33 |
-
* added multisite support
|
34 |
-
* fixed some parse url bugs
|
35 |
-
* fixed slug bases validation
|
36 |
-
|
37 |
-
= 1.0 =
|
38 |
-
* new branch, the plugin has been rewrited: now the code is commented and wrapped inside a class, also all code has change and the performance has been increased.
|
39 |
-
* structural changes:
|
40 |
-
* no ID for slug type, then don't install qtrasnlate_slug table.
|
41 |
-
* 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/).
|
42 |
-
* some automation:
|
43 |
-
* the plugin generates translated slug automatically from title in empty cases (like wordpress).
|
44 |
-
* the plugin checks if the slug already exists (per each language and type / taxonomy), and adds a progressive number in this case (like wordpress).
|
45 |
-
* works on ajax requests like creatig new taxonomies on edit post page.
|
46 |
-
* possibility to translate the base of permastructs for 'post_types' and 'taxonomies' (uses $wp_rewrite).
|
47 |
-
* added some filters:
|
48 |
-
* 'qts_validate_post_slug' : args( $post (object), $slug (string), $lang (string) ) / filter to process the post slug before is saved on the database.
|
49 |
-
* 'qts_validate_term_slug' : args( $term (object), $slug (string), $lang (string) ) / filter to process the term slug before is saved on the database.
|
50 |
-
* 'qts_current_url' : args ( $url (string), $lang (string) ) / filter to process the entire url after it has been generated.
|
51 |
-
* 'qts_permastruct' : args ( $permastruct (string), $name (string) ) / filter to process the permastruct, used for change the base.
|
52 |
-
* added plugin language textdomain (.pot file)
|
53 |
-
* new admin options page for save the base permastructs.
|
54 |
-
* import process when the plugin updates older versions.
|
55 |
-
* some bug fixes.
|
56 |
-
* some Qtranslate patches.
|
57 |
-
|
58 |
-
= 0.9 =
|
59 |
-
* some wordpress qTranslate bug fixes
|
60 |
-
* adds a javascript solution for qTranslate Nav Menus
|
61 |
-
|
62 |
-
= 0.8 =
|
63 |
-
* added support por Categories
|
64 |
-
* added support por Tags
|
65 |
-
* added support por Taxonomies
|
66 |
-
* added support por Custom Post Types
|
67 |
-
|
68 |
-
= 0.7 ( enhanced by Zapo (http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=4&t=1049&start=50#p7499) ) =
|
69 |
-
* added suport for qTranslate TLD domain mode (en: domain.com | fr: domain.fr) visit
|
70 |
-
|
71 |
-
= 0.5 and 0.6 enhanched by Marco Del Percio =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
version.txt
CHANGED
@@ -1,3 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 1.1.8 =
|
2 |
|
3 |
Many thanks to everyone that contributed to this update, both for their commits and bug reports )
|
1 |
+
= 1.1.9 =
|
2 |
+
|
3 |
+
Lots of bug fixes! Thanks again to everyone that contributed to this project, with commits, bug reports and suggestions.
|
4 |
+
|
5 |
+
* Compatibility with qtranslate-X! ( thanks @beheist, pull #85, fixing most of #80 )
|
6 |
+
* More updates to the portuguese translation ( thanks pedro-mendonca, pull #86)
|
7 |
+
* Corrected the link to language files ( thanks pedro-mendonca )
|
8 |
+
* Added translation for some hardcoded texts ( thanks pedro-mendonca )
|
9 |
+
* Corrected a link from 'qtranslate' to 'qts' language files ( thanks pedro-mendonca )
|
10 |
+
* Fixed taxonomies slugs ( thanks to [eirikv's bug report](https://wordpress.org/support/topic/categories-slug-dont-work) )
|
11 |
+
* Fixed many warnings ( thanks piffpaffpuff, issue #78 and to [pedrodu1](https://wordpress.org/support/topic/warnings-qtranslate-slugphp) )
|
12 |
+
* Changed the behaviour of "Quick Edit", from the wp forums [1](https://wordpress.org/support/topic/categories-tags-and-quick-edit-dont-show-in-admin) [2](https://wordpress.org/support/topic/quick-edit-inhibited-by-qtranslate-slug-with-wp-41-mqtranslate) ( thanks everyone!! )
|
13 |
+
* Fixed the menus! Now you can properly use one menu for every language. Use the dropdown section "Languages", and for each item, change the "Navigation Label" and "Title Attribute". Select "All languages", to make sure everything is awesome! All these features were a consequence of fixing all the warnings based on [Gery's bug report)[https://wordpress.org/support/topic/qtranslate-slug-conflicting-with-ubermenu).
|
14 |
+
* Minor fixes, etc.
|
15 |
+
|
16 |
+
See you next Version!
|
17 |
+
|
18 |
= 1.1.8 =
|
19 |
|
20 |
Many thanks to everyone that contributed to this update, both for their commits and bug reports )
|