diff --git a/modules/slugs/includes/class-qtranslate-slug-widget.php b/modules/slugs/includes/class-qtranslate-slug-widget.php index feaa8c66..fa6d504a 100644 --- a/modules/slugs/includes/class-qtranslate-slug-widget.php +++ b/modules/slugs/includes/class-qtranslate-slug-widget.php @@ -18,7 +18,7 @@ function widget( $args, $instance ) { $title = empty( $instance['title'] ) ? __( 'Language', 'qts' ) : apply_filters( 'widget_title', $instance['title'] ); $hide_title = empty( $instance['hide-title'] ) ? false : 'on'; $type = $instance['type']; - $short_text = ( $instance['short_text'] == 'on' ) ? true : false; + $short_text = $instance['short_text'] == 'on'; if ( $type != 'text' && $type != 'image' && $type != 'both' && $type != 'dropdown' ) { $type = 'text'; diff --git a/modules/slugs/includes/class-qtranslate-slug.php b/modules/slugs/includes/class-qtranslate-slug.php index 2cd90343..73cd98fb 100644 --- a/modules/slugs/includes/class-qtranslate-slug.php +++ b/modules/slugs/includes/class-qtranslate-slug.php @@ -316,17 +316,21 @@ function init() { /** * Filters menu link attribute. + * + * @param string $item_title The menu item title attribute. + * + * @return string */ - function qts_filter_attr_title( $attr_title ) { - return $this->qts_quickuse( $attr_title ); + function qts_filter_attr_title( $item_title ) { + return $this->qts_quickuse( $item_title ); } /** * Adds proper links to the content with available translations. * Fixes issue #25 * - * @global $qtranslate_slug used to convert the url - * @global $q_config available languages + * @global QtranslateSlug $qtranslate_slug used to convert the url + * @global array $q_config available languages */ public function qtranslate_slug_header_extended() { if ( is_404() ) { @@ -372,7 +376,7 @@ public function get_slug( $id, $lang ) { * @param string $text the whole text * @param string $lang (optional) get the text in this language, or if empty, the current * - * @return array the text in the required language + * @return string the text in the required language */ public function qts_quickuse( $text, $lang = '' ) { $lang = '' == $lang ? $this->current_lang : $lang; @@ -380,6 +384,8 @@ public function qts_quickuse( $text, $lang = '' ) { if ( ! empty( $parsed_text[ $lang ] ) ) { return $parsed_text[ $lang ]; } + // TODO improve this, a value must be returned! + assert( false, 'Language not found in qts_quickuse' ); } /** @@ -592,15 +598,16 @@ public function query_vars( $query_vars ) { } } + // TODO check this call, looks bug-prone return count( array_diff( $query_vars, $wp->public_query_vars ) ) > 0 ? $query_vars : $wp->public_query_vars; } /** * Function called when query parameters are processed by Wordpress. * - * @param $query query parameters + * @param array $query query parameters * - * @return array() $query processed + * @return array $query processed */ function filter_request( $query ) { global $wp; @@ -817,11 +824,11 @@ public function get_extra_permastruct( $permastruct = false, $name = false ) { * Filter that translates the slug parts in a page link. * * @param string $link the link for the page generated by Wordpress - * @param WP_Post $post + * @param WP_Post|WP_Error $post * @param bool $leavename * @param bool $sample * - * @return string the link translated + * @return string|WP_Error the link translated */ public function post_type_link( $link, $post, $leavename, $sample ) { global $wp_rewrite; @@ -1172,7 +1179,7 @@ function get_object_terms( $terms, $obj_id, $taxonomy, $args ) { */ public function hide_quick_edit() { echo "" . PHP_EOL; - echo "" . PHP_EOL; } @@ -1275,9 +1282,9 @@ public function draw_meta_box( $post ) { */ public function validate_post_slug( $slug, $post, $lang ) { - $post_title = trim( qtranxf_use( $lang, $post->post_title) ); + $post_title = trim( qtranxf_use( $lang, $post->post_title ) ); - $post_name = get_post_meta( $post->ID, $this->get_meta_key( $lang ), true ); + $post_name = get_post_meta( $post->ID, $this->get_meta_key( $lang ), true ); if ( ! $post_name ) { $post_name = $post->post_name; } @@ -1383,6 +1390,8 @@ public function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, * * @param $post_id int the post id * @param $post object the post object + * + * @return void */ public function save_postdata( $post_id, $post ) { $post_type_object = get_post_type_object( $post->post_type ); @@ -1391,7 +1400,7 @@ public function save_postdata( $post_id, $post ) { || ( ! isset( $_POST['post_ID'] ) || $post_id != $_POST['post_ID'] ) // check revision || ( isset( $_POST['qts_nonce'] ) && ! wp_verify_nonce( $_POST['qts_nonce'], 'qts_nonce' ) ) // verify nonce || ( ! current_user_can( $post_type_object->cap->edit_post, $post_id ) ) ) { // check permission - return $post_id; + return; } foreach ( $this->get_enabled_languages() as $lang ) { @@ -1425,7 +1434,7 @@ public function show_term_fields( $term ) { $value = ( $slug ) ? htmlspecialchars( $slug, ENT_QUOTES ) : ''; echo "
http://example.org/%s/some-%s/
', 'qts' ), $post_type->name, $post_type->name ),
+ "desc" => sprintf( __( 'https://example.org/%s/some-%s/
', 'qts' ), $post_type->name, $post_type->name ),
'class' => 'qts-slug',
"type" => "multi-text",
"choices" => get_multi_txt_choices( $post_type->name ),
@@ -90,7 +90,7 @@ function qts_options_page_fields() {
"section" => "taxonomies",
"id" => QTS_PREFIX . "taxonomy_category",
"title" => __( 'Categories', 'qts' ),
- "desc" => __( 'http://example.org/category/some-category/
', 'qts' ),
+ "desc" => __( 'https://example.org/category/some-category/
', 'qts' ),
"type" => "multi-text",
'class' => 'qts-slug',
"choices" => get_multi_txt_choices( 'category' ),
@@ -101,7 +101,7 @@ function qts_options_page_fields() {
"section" => "taxonomies",
"id" => QTS_PREFIX . "taxonomy_post_tag",
"title" => __( 'Tags', 'qts' ),
- "desc" => __( 'http://example.org/tag/some-tag/
', 'qts' ),
+ "desc" => __( 'https://example.org/tag/some-tag/
', 'qts' ),
"type" => "multi-text",
'class' => 'qts-slug',
"choices" => get_multi_txt_choices( 'post_tag' ),
@@ -116,7 +116,7 @@ function qts_options_page_fields() {
"section" => "taxonomies",
"id" => QTS_PREFIX . "taxonomy_" . $taxonomy->name,
"title" => $taxonomy->labels->singular_name,
- "desc" => sprintf( __( 'http://example.org/%s/some-%s/
', 'qts' ), $taxonomy->name, $taxonomy->name ),
+ "desc" => sprintf( __( 'https://example.org/%s/some-%s/
', 'qts' ), $taxonomy->name, $taxonomy->name ),
"type" => "multi-text",
'class' => 'qts-slug',
"choices" => get_multi_txt_choices( $taxonomy->name ),
diff --git a/modules/slugs/includes/qtranslate-slug-settings.php b/modules/slugs/includes/qtranslate-slug-settings.php
index 30693b65..85d10cc7 100644
--- a/modules/slugs/includes/qtranslate-slug-settings.php
+++ b/modules/slugs/includes/qtranslate-slug-settings.php
@@ -9,8 +9,7 @@
* @return array
*/
function qts_get_settings() {
- $output = array();
- // put together the output array
+ $output = array();
$output['qts_option_name'] = QTS_OPTIONS_NAME; // the option name as used in the get_option() call.
$output['qts_page_title'] = __( 'Qtranslate Slug options', 'qts' ); // the settings page title
$output['qts_page_sections'] = qts_options_page_sections(); // the settings sections
@@ -27,10 +26,9 @@ function qts_get_settings() {
*
* @param (array) $args The array of arguments to be used in creating the field
*
- * @return function call
+ * @return void
*/
function qts_create_settings_field( $args = array() ) {
- // default array to overwrite when calling the function
$defaults = array(
'id' => 'default_field',
// the ID of the setting in our options array, and the ID of the HTML form element
@@ -70,29 +68,22 @@ function qts_create_settings_field( $args = array() ) {
* Register our setting, settings sections and settings fields
*/
function qts_register_settings() {
- // get the settings sections array
$settings_output = qts_get_settings();
$qts_option_name = $settings_output['qts_option_name'];
- //setting
register_setting( $qts_option_name, $qts_option_name, 'qts_validate_options' );
-
- //sections
if ( ! empty( $settings_output['qts_page_sections'] ) ) {
// call the "add_settings_section" for each!
foreach ( $settings_output['qts_page_sections'] as $id => $title ) {
add_settings_section( $id, $title, 'qts_section_fn', __FILE__ );
}
}
-
- //fields
if ( ! empty( $settings_output['qts_page_fields'] ) ) {
// call the "add_settings_field" for each!
foreach ( $settings_output['qts_page_fields'] as $option ) {
qts_create_settings_field( $option );
}
}
- //style
if ( ! empty( $settings_output['qts_page_styles'] ) ) {
// call the "add_settings_field" for each
foreach ( $settings_output['qts_page_styles'] as $styleoption ) {
@@ -152,12 +143,12 @@ function qts_section_fn( $page_section = false ) {
switch ( $page_section['id'] ) {
case 'post_types':
- echo "" . __( 'For example, the post_type books, in Spanish would be displayed as http://example.org/es/libros/post-type-name/
. If you leave this blank will use the default option when you registered the post_type.', 'qts' ) . "
" . __( 'For example, the post_type books, in Spanish would be displayed as https://example.org/es/libros/post-type-name/
. If you leave this blank will use the default option when you registered the post_type.', 'qts' ) . "
" . __( 'For example, the taxonomy category, in Spanish would be displayed as http://example.org/es/categoria/taxonomy-name/
. If you leave this blank will use the default option when you registered the taxonomy (if you previously setup a base permastruct for categories or tags in permalinks page, these bases will be overwritten by the translated ones).', 'qts' ) . "
" . __( 'For example, the taxonomy category, in Spanish would be displayed as https://example.org/es/categoria/taxonomy-name/
. If you leave this blank will use the default option when you registered the taxonomy (if you previously setup a base permastruct for categories or tags in permalinks page, these bases will be overwritten by the translated ones).', 'qts' ) . "