Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QTS: added deactivation handling, removed widget, cleanup #1111

Merged
merged 6 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 0 additions & 140 deletions modules/slugs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,143 +59,3 @@ Original plugin
Integration into qTranslate-XT
* [Giovanni Cascione](https://github.com/spleen1981)
* [HerrVigg](https://github.com/herrvigg)

## Changelog (original plugin)

= New in 1.1.18 =

* widget is now compatible with wp 4.3. thanks to @adnanoner ( #111) and @gitmad (#112)
* saving taxonomies wont print warning. thanks to @jmarceli ( #113)
* saving post quick edit wont print warnings. thanks again to jmarceli ( #114 )
* Code from wp.org is now been merged with the github account
* Some notices are fixed. Thanks to @rafa-aguilar ( #89 )
* custom post types are fixed! thanks to @MicheleBertoli ( #102 )
* lots of other stuff has been fixed by me thanks to your awesome bug reports!

= New in 1.1.17 =
* Fixed dangerous security exploit!
* Hability to filter the position of the Metabox

= New in 1.1.16 =
Minor fix for the language menu using qtranslate's function

= New in 1.1.15 =
* Fixes the duplicated hreflang links in <head>

= New in 1.1.14 =

The menu widget didn't allow the visitors to change to the default language if qtranslate-x was being used. So, adjusted the Language Menu widget to play nice with qtranslate-x.
Hope to bring some nice changes that were made in the github repository in the next version. For now, enjoy.

= 1.1.13 =
== Thanks to returning @pedro-mendonca for these commits: ==
* Cleaned duplicated label in widget
* Bug fix in "Slug (%s)" string translation
* Changed text strings with no text-domain and with text-domain 'qtranlate' to text-domain 'qts'
* pot catalog updated with current strings, including last found is "More information about".
== Thanks to @johnclause for these : ==
* Convenience links in notice_dependences
* Menu compatibility with qTranslate-X
* Fixed extra characters in widget
== Thanks to vbkun for casting this much wanted function ==
* Added a global qts_get_slug( $id, $lang)
== and sadly: ==
* removed the menu admin box until better implementation

= 1.1.12 =

* fixed warnings in settings
* replace qtranslate with our own for taxonomies

= 1.1.10 and 1.1.11 =
* Fixing wrong commit to wp.org
* Clean deleted files

= 1.1.9 =

Lots of bug fixes! Thanks again to everyone that contributed to this project, with commits, bug reports and suggestions.

* Compatibility with qtranslate-X! ( thanks @beheist, pull #85, fixing most of #80 )
* More updates to the portuguese translation ( thanks pedro-mendonca, pull #86)
* Corrected the link to language files ( thanks pedro-mendonca )
* Added translation for some hardcoded texts ( thanks pedro-mendonca )
* Corrected a link from 'qtranslate' to 'qts' language files ( thanks pedro-mendonca )
* Fixed taxonomies slugs ( thanks to [eirikv's bug report](https://wordpress.org/support/topic/categories-slug-dont-work) )
* Fixed many warnings ( thanks piffpaffpuff, issue #78 and to [pedrodu1](https://wordpress.org/support/topic/warnings-qtranslate-slugphp) )
* 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!! )
* 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).
* Minor fixes, etc.

See you next Version!

= 1.1.8 =

Many thanks to everyone that contributed to this update, both for their commits and bug reports )

* Portuguese translation and fixed some translation bugs ( thanks pedro-mendonca )
* removed mqtranslate switcher widget hook
* Updated the plugin structure and coding style
* solve some conflicts with search and pagination queries
* Settings php errors, syntax indent and fixed settings assets url
* Change titles when there is a click on pagination on show all pages tab ( thanks juanfran-granados )
* Formatted dependency notice message ( thanks arildm )
* Updated the deprecated jquery 'live' function and solve php strict standards error ( thanks rafitaFCB )
* Fixed error showing if PHP was newer than 5.3 ( thanks rafitaFCB )
* Strict standard advise prevented ( thanks rafitaFCB )
* php notices are prevented in post edit, when using adding new translated tags ( thanks rafitaFCB )
* fixed the hreflang issue! 'bout time!
* As discussed in issue #25, the flags are now img tags, intead of background-url.
* Added another option to include the css style in a minified file. ( and also showing in the option screen the styles we would use.)

= 1.1.7 =
* removed styles from html elements and added options to use .css file or print inline styles
* fixed tag creation on post edit.
* fixed earlier bad post slug introduced in 1.1.6

= 1.1.6 =
* compatible with mqtranslate
* php5.4+ compatible

= 1.1.5 =
* bugfixes

= 1.1 =
* added multisite support
* fixed some parse url bugs
* fixed slug bases validation

= 1.0 =
* 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.
* structural changes:
* no ID for slug type, then don't install qtrasnlate_slug table.
* 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/).
* some automation:
* the plugin generates translated slug automatically from title in empty cases (like wordpress).
* the plugin checks if the slug already exists (per each language and type / taxonomy), and adds a progressive number in this case (like wordpress).
* works on ajax requests like creatig new taxonomies on edit post page.
* possibility to translate the base of permastructs for 'post_types' and 'taxonomies' (uses $wp_rewrite).
* added some filters:
* 'qts_validate_post_slug' : args( $post (object), $slug (string), $lang (string) ) / filter to process the post slug before is saved on the database.
* 'qts_validate_term_slug' : args( $term (object), $slug (string), $lang (string) ) / filter to process the term slug before is saved on the database.
* 'qts_current_url' : args ( $url (string), $lang (string) ) / filter to process the entire url after it has been generated.
* 'qts_permastruct' : args ( $permastruct (string), $name (string) ) / filter to process the permastruct, used for change the base.
* added plugin language textdomain (.pot file)
* new admin options page for save the base permastructs.
* import process when the plugin updates older versions.
* some bug fixes.
* some Qtranslate patches.

= 0.9 =
* some wordpress qTranslate bug fixes
* adds a javascript solution for qTranslate Nav Menus

= 0.8 =
* added support por Categories
* added support por Tags
* added support por Taxonomies
* added support por Custom Post Types

= 0.7 ( enhanced by Zapo (http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=4&t=1049&start=50#p7499) ) =
* added suport for qTranslate TLD domain mode (en: domain.com | fr: domain.fr) visit

= 0.5 and 0.6 enhanched by Marco Del Percio =
94 changes: 0 additions & 94 deletions modules/slugs/includes/class-qtranslate-slug-widget.php

This file was deleted.

32 changes: 3 additions & 29 deletions modules/slugs/includes/class-qtranslate-slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class QtranslateSlug {
* Slug in meta_key name in meta tables.
* @var string
*/
private $meta_key = "_qts_slug_%s";
private $meta_key = QTS_META_PREFIX . "%s";

/**
* Array of translated versions of the current url.
Expand Down Expand Up @@ -307,7 +307,6 @@ function init() {

add_filter( 'single_term_title', 'qtranxf_useTermLib', 805 );
add_filter( 'get_blogs_of_user', array( &$this, 'blog_names' ), 1 );
add_action( 'widgets_init', array( &$this, 'widget_init' ), 100 );
// Add specific CSS class to body class based on current lang
add_filter( 'body_class', array( $this, 'qts_body_class' ), 600, 1 );

Expand Down Expand Up @@ -365,7 +364,7 @@ public function qts_body_class( $classes ) {
* @return string the slug or empty if not found
*/
public function get_slug( $id, $lang ) {
$slugArray = get_post_meta( $id, '_qts_slug_' . $lang );
$slugArray = get_post_meta( $id, QTS_META_PREFIX . $lang );

return ! empty( $slugArray ) ? $slugArray[0] : "";
}
Expand All @@ -384,6 +383,7 @@ public function qts_quickuse( $text, $lang = '' ) {
if ( ! empty( $parsed_text[ $lang ] ) ) {
return $parsed_text[ $lang ];
}

// TODO: check what to do if lang not found in ML values
return $text;
}
Expand Down Expand Up @@ -1660,32 +1660,6 @@ public function blog_names( $blogs ) {
return $blogs;
}

/**
* Initialise the Language Widget selector.
*/
public function widget_init() {

if ( class_exists( 'qTranslateWidget' ) ) {
unregister_widget( 'qTranslateWidget' );
}
if ( class_exists( 'mqTranslateWidget' ) ) {
unregister_widget( 'mqTranslateWidget' );
}
if ( class_exists( 'ppqTranslateWidget' ) ) {
unregister_widget( 'ppqTranslateWidget' );
}
register_widget( 'QtranslateSlugWidget' );
}

/**
* Remove some default dashboard Widgets on Desktop.
* @deprecated
*/
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'] );
}

/**
* Adds support for qtranslate nav menus.
*/
Expand Down
31 changes: 7 additions & 24 deletions modules/slugs/slugs.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<?php

include_once( dirname( __FILE__ ) . '/includes/class-qtranslate-slug-widget.php' );
include_once( dirname( __FILE__ ) . '/includes/class-qtranslate-slug.php' );

if ( ! defined( "QTS_VERSION" ) ) {
define( "QTS_VERSION", '1.1.18' );
}
if ( ! defined( "QTS_PREFIX" ) ) {
define( "QTS_PREFIX", '_qts_' );
}
Expand All @@ -15,17 +11,20 @@
if ( ! defined( "QTS_OPTIONS_NAME" ) ) {
define( "QTS_OPTIONS_NAME", 'qts_options' );
}
if ( ! defined( "QTS_META_PREFIX" ) ) {
define( "QTS_META_PREFIX", QTS_PREFIX . 'slug_' );
}

// Init the module
global $qtranslate_slug;

$qtranslate_slug = new QtranslateSlug();

add_action( 'qtranslate_edit_config', array( $qtranslate_slug, 'qtranslate_updated_settings' ) );
// TODO: check if something to do when QTX deactivated
//add_action( 'qtranslate_slug_deactivate',array($qtranslate_slug, 'deactivate'));
add_action( 'qtranslate_slug_deactivate', array( $qtranslate_slug, 'deactivate' ) );

// plugin uninstall
// plugin deactivation/uninstall
register_deactivation_hook( QTRANSLATE_FILE, array( $qtranslate_slug, 'deactivate' ) );
register_uninstall_hook( QTRANSLATE_FILE, 'qts_uninstall' );

// plugin init
Expand All @@ -48,22 +47,6 @@ function qts_get_url( $lang = false ) {
return $qtranslate_slug->get_current_url( $lang );
}

/**
* Add a "Settings" link to the plugins.php page for Qtranslate Slug.
*/
function qts_add_settings_link( $links, $file ) {

$this_plugin = plugin_basename( __FILE__ );
if ( $file == $this_plugin ) {
$settings_link = "<a href=\"options-general.php?page=" . QTS_PAGE_BASENAME . "\">" . __( 'Settings', 'qts' ) . '</a>';
array_unshift( $links, $settings_link );
}

return $links;
}

add_filter( 'plugin_action_links', 'qts_add_settings_link', 10, 2 );

/**
* Delete plugin stored data ( options and postmeta data ).
*/
Expand All @@ -74,7 +57,7 @@ function qts_uninstall() {

$meta_keys = array();
foreach ( $q_config['enabled_languages'] as $lang ) {
$meta_keys[] = sprintf( "_qts_slug_%s", $lang );
$meta_keys[] = sprintf( QTS_META_PREFIX . "%s", $lang );
}
$meta_keys = "'" . implode( "','", $meta_keys ) . "'";
$wpdb->query( "DELETE from $wpdb->postmeta WHERE meta_key IN ($meta_keys)" );
Expand Down
2 changes: 1 addition & 1 deletion qtranslate_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ function qtranxf_convertURL( $url = '', $lang = '', $forceadmin = false, $showDe
}
if ( empty( $url ) ) {
// TODO refactor this hack for qtranslate-slug! We might need a hook here.
if ( $q_config['url_info']['doing_front_end'] && defined( 'QTS_VERSION' ) && $q_config['url_mode'] != QTX_URL_QUERY ) {
if ( $q_config['url_info']['doing_front_end'] && function_exists( 'qts_get_url' ) && $q_config['url_mode'] != QTX_URL_QUERY ) {
// quick workaround, but need a permanent solution
$url = qts_get_url( $lang );
if ( ! empty( $url ) ) {
Expand Down