Commit 493d608a authored by Simonas's avatar Simonas

small fixes added

parent 5303bfdc
......@@ -40,6 +40,8 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
// Rewrites next and previous post links when not automatically done by WordPress
add_filter( 'get_pagenum_link', array( $this, 'archive_link' ), 20 );
add_filter( 'get_shortlink', array( $this, 'shortlink' ), 20, 2 );
// Rewrites ajax url
add_filter( 'admin_url', array( $this, 'admin_url' ), 10, 2 );
}
......@@ -147,6 +149,20 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
return $_link;
}
/**
* Modifies the post short link when using one domain or subdomain per language.
*
* @since 2.6.9
*
* @param string $link Post permalink.
* @param int $post_id Post id.
* @return Post permalink with the correct domain.
*/
public function shortlink( $link, $post_id ) {
$post_type = get_post_type( $post_id );
return $this->model->is_translated_post_type( $post_type ) ? $this->links_model->switch_language_in_link( $link, $this->model->post->get_language( $post_id ) ) : $link;
}
/**
* Outputs references to translated pages ( if exists ) in the html head section
*
......
......@@ -10,6 +10,7 @@
* links_model => inherited, reference to PLL_Links_Model object
* links => reference to PLL_Admin_Links object
* static_pages => reference to PLL_Static_Pages object
* filters => reference to PLL_Frontend_Filters object
* filters_links => reference to PLL_Filters_Links object
* posts => reference to PLL_CRUD_Posts object
* terms => reference to PLL_CRUD_Terms object
......@@ -18,7 +19,7 @@
* @since 2.6
*/
class PLL_REST_Request extends PLL_Base {
public $links, $posts, $terms, $filters_links, $sync;
public $links, $static_pages, $posts, $terms, $filters, $filters_links, $sync;
/**
* Setup filters
......@@ -34,6 +35,7 @@ class PLL_REST_Request extends PLL_Base {
do_action( 'pll_no_language_defined' ); // To load overridden textdomains.
$this->filters_links = new PLL_Filters_Links( $this );
$this->filters = new PLL_Filters( $this );
// Static front page and page for posts
if ( 'page' === get_option( 'show_on_front' ) ) {
......
......@@ -110,11 +110,6 @@ class PLL_Plugins_Compat {
$this->divi_builder = new PLL_Divi_Builder();
}
// Admin Columns & Admin Columns Pro
if ( ( defined( 'AC_FILE' ) || defined( 'ACP_FILE' ) ) && class_exists( 'PLL_CPAC' ) ) {
add_action( 'admin_init', array( $this->cpac = new PLL_CPAC(), 'init' ) );
}
// WP Offload Media Lite
if ( function_exists( 'as3cf_init' ) && class_exists( 'PLL_AS3CF' ) ) {
add_action( 'pll_init', array( $this->as3cf = new PLL_AS3CF(), 'init' ) );
......@@ -136,6 +131,11 @@ class PLL_Plugins_Compat {
if ( defined( 'ACF_VERSION' ) && version_compare( ACF_VERSION, '5.7.11', '>=' ) && class_exists( 'PLL_ACF' ) ) {
add_action( 'init', array( $this->acf = new PLL_ACF(), 'init' ) );
}
// Admin Columns & Admin Columns Pro
if ( did_action( 'pll_init' ) && ( defined( 'AC_FILE' ) || defined( 'ACP_FILE' ) ) && class_exists( 'PLL_CPAC' ) ) {
add_action( 'admin_init', array( $this->cpac = new PLL_CPAC(), 'init' ) );
}
}
/**
......
......@@ -3,7 +3,7 @@
/**
Plugin Name: Polylang
Plugin URI: https://polylang.pro
Version: 2.6.8
Version: 2.6.9
Author: WP SYNTEX
Author uri: https://polylang.pro
Description: Adds multilingual capability to WordPress
......@@ -13,7 +13,7 @@ Domain Path: /languages
/*
* Copyright 2011-2019 Frédéric Demarle
* Copyright 2019 WP SYNTEX
* Copyright 2019-2020 WP SYNTEX
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -51,7 +51,7 @@ if ( defined( 'POLYLANG_BASENAME' ) ) {
}
} else {
// Go on loading the plugin
define( 'POLYLANG_VERSION', '2.6.8' );
define( 'POLYLANG_VERSION', '2.6.9' );
define( 'PLL_MIN_WP_VERSION', '4.7' );
define( 'PLL_MIN_PHP_VERSION', '5.6' );
......
......@@ -5,7 +5,7 @@ Tags: multilingual, bilingual, translate, translation, language, multilanguage,
Requires at least: 4.7
Tested up to: 5.3
Requires PHP: 5.6
Stable tag: 2.6.8
Stable tag: 2.6.9
License: GPLv3 or later
Making WordPress multilingual
......@@ -77,6 +77,14 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
== Changelog ==
= 2.6.9 (2020-01-15) =
* Pro: Use 'parse_query' rather than 'rest_{$type}_query' to filter REST requests.
* Pro: Filter the comments REST endpoint.
* Pro: Fix duplication of terms without language.
* Pro: Fix fatal error when Admin Columns is activated and no language is defined yet.
* Fix shortlink when using one subdomain or domain per language
= 2.6.8 (2019-12-11) =
* Pro: Fix conflict with JetThemesCore from Crocoblock
......
......@@ -35,6 +35,10 @@ class WPSEO_Capability_Utils {
public static function get_applicable_users( $capability ) {
$applicable_roles = self::get_applicable_roles( $capability );
if ( $applicable_roles === [] ) {
return [];
}
return get_users( [ 'role__in' => $applicable_roles ] );
}
......@@ -46,14 +50,20 @@ class WPSEO_Capability_Utils {
* @return array The names of the roles that have the capability.
*/
public static function get_applicable_roles( $capability ) {
$roles = wp_roles();
$roles = wp_roles();
$role_names = $roles->get_names();
$applicable_roles = [];
foreach ( $roles->get_names() as $role_name ) {
foreach ( array_keys( $role_names ) as $role_name ) {
$role = $roles->get_role( $role_name );
if ( ! $role ) {
continue;
}
// Add role if it has the capability.
if ( $role && in_array( $capability, $role['capabilities'], true ) ) {
$applicable_roles[] = $role['name'];
if ( array_key_exists( $capability, $role->capabilities ) && $role->capabilities[ $capability ] === true ) {
$applicable_roles[] = $role_name;
}
}
......
......@@ -40,26 +40,6 @@ final class WPSEO_Admin_Asset_SEO_Location implements WPSEO_Admin_Asset_Location
return '';
}
if ( YOAST_ENVIRONMENT !== 'development' && ! $asset->get_suffix() ) {
$plugin_path = plugin_dir_path( $this->plugin_file );
if ( ! file_exists( $plugin_path . $path ) ) {
// Give a notice to the user in the console (only once).
WPSEO_Utils::javascript_console_notification(
'Development Files',
sprintf(
/* translators: %1$s resolves to https://github.com/Yoast/wordpress-seo */
__( 'You are trying to load non-minified files. These are only available in our development package. Check out %1$s to see all the source files.', 'wordpress-seo' ),
'https://github.com/Yoast/wordpress-seo'
),
true
);
// Just load the .min file.
$path = $this->get_path( $asset, $type, '.min' );
}
}
return plugins_url( $path, $this->plugin_file );
}
......@@ -69,20 +49,16 @@ final class WPSEO_Admin_Asset_SEO_Location implements WPSEO_Admin_Asset_Location
* @param WPSEO_Admin_Asset $asset The asset to determine the path
* for.
* @param string $type The type of asset.
* @param string|null $force_suffix The suffix to force, or null when
* to use the default suffix.
*
* @return string The path to the asset file.
*/
protected function get_path( WPSEO_Admin_Asset $asset, $type, $force_suffix = null ) {
protected function get_path( WPSEO_Admin_Asset $asset, $type ) {
$relative_path = '';
$rtl_suffix = '';
$suffix = ( $force_suffix === null ) ? $asset->get_suffix() : $force_suffix;
switch ( $type ) {
case WPSEO_Admin_Asset::TYPE_JS:
$relative_path = 'js/dist/' . $asset->get_src() . $suffix . '.js';
$relative_path = 'js/dist/' . $asset->get_src() . $asset->get_suffix() . '.js';
break;
case WPSEO_Admin_Asset::TYPE_CSS:
......@@ -90,7 +66,7 @@ final class WPSEO_Admin_Asset_SEO_Location implements WPSEO_Admin_Asset_Location
if ( function_exists( 'is_rtl' ) && is_rtl() && $asset->has_rtl() ) {
$rtl_suffix = '-rtl';
}
$relative_path = 'css/dist/' . $asset->get_src() . $rtl_suffix . $suffix . '.css';
$relative_path = 'css/dist/' . $asset->get_src() . $rtl_suffix . $asset->get_suffix() . '.css';
break;
}
......
......@@ -204,18 +204,6 @@ class WPSEO_Admin_Init {
}
}
/**
* Shows a notice to the user if they have Google Analytics for WordPress 5.4.3 installed because it causes an error
* on the google search console page.
*
* @deprecated 12.5
*
* @codeCoverageIgnore
*/
public function ga_compatibility_notice() {
_deprecated_function( __METHOD__, 'WPSEO 12.5' );
}
/**
* Determines whether a suggested plugins notification needs to be displayed.
*
......@@ -598,6 +586,18 @@ class WPSEO_Admin_Init {
_deprecated_function( __METHOD__, 'WPSEO 12.5' );
}
/**
* Shows a notice to the user if they have Google Analytics for WordPress 5.4.3 installed because it causes an error
* on the google search console page.
*
* @deprecated 12.5
*
* @codeCoverageIgnore
*/
public function ga_compatibility_notice() {
_deprecated_function( __METHOD__, 'WPSEO 12.5' );
}
/**
* Display notice to disable comment pagination.
*
......
......@@ -146,7 +146,6 @@ class WPSEO_Admin_Asset {
'in_footer' => true,
'rtl' => true,
'media' => 'all',
'suffix' => WPSEO_CSSJS_SUFFIX,
];
/**
......@@ -174,7 +173,7 @@ class WPSEO_Admin_Asset {
$this->media = $args['media'];
$this->in_footer = $args['in_footer'];
$this->rtl = $args['rtl'];
$this->suffix = $args['suffix'];
$this->suffix = isset( $args['suffix'] ) ? $args['suffix'] : '';
}
/**
......
......@@ -15,14 +15,14 @@ class WPSEO_Gutenberg_Compatibility {
*
* @var string
*/
const CURRENT_RELEASE = '7.1.0';
const CURRENT_RELEASE = '7.2.0';
/**
* The minimally supported version of Gutenberg by the plugin.
*
* @var string
*/
const MINIMUM_SUPPORTED = '7.1.0';
const MINIMUM_SUPPORTED = '7.2.0';
/**
* Holds the current version.
......
......@@ -112,6 +112,6 @@ class WPSEO_Import_Settings {
$this->status->set_status( true );
// Reset the cached option values.
WPSEO_Options::fill_cache();
WPSEO_Options::clear_cache();
}
}
......@@ -11,8 +11,10 @@
class WPSEO_Tracking_Settings_Data implements WPSEO_Collection {
/**
* @var array $anonymous_settings contains all of the option_names which need to be
* anonimized before they can be sent elsewhere.
* The options that need to be anonymized before they can be sent elsewhere.
*
* @var array $anonymous_settings All of the option_names which need to be
* anonymized before they can be sent elsewhere.
*/
private $anonymous_settings = [
'baiduverify',
......@@ -47,7 +49,9 @@ class WPSEO_Tracking_Settings_Data implements WPSEO_Collection {
];
/**
* @var array $include_list contains the option_names for the options we want to track.
* The options we want to track.
*
* @var array $include_list The option_names for the options we want to track.
*/
private $include_list = [
'ms_defaults_set',
......
......@@ -88,7 +88,7 @@ class Yoast_View_Utils {
$this->form->show_hide_switch(
'showdate-' . $post_type->name,
__( 'Date in Snippet Preview', 'wordpress-seo' )
__( 'Date in Google Preview', 'wordpress-seo' )
);
$this->form->show_hide_switch(
......
......@@ -135,10 +135,12 @@ $new_tab_message = WPSEO_Admin_Utils::get_new_tab_message();
?>
</p>
<p>
<a href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/3t6' ); ?>" target="_blank"><?php
<a href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/3t6' ); ?>" target="_blank">
<?php
/* translators: %1$s expands to Yoast SEO academy */
printf( esc_html__( 'Check out %1$s', 'wordpress-seo' ), 'Yoast SEO academy' );
?></a>
?>
</a>
</p>
</div>
<div class="yoast-sidebar__section">
......
......@@ -23,7 +23,7 @@ $yform->index_switch(
$yform->show_hide_switch(
'showdate-' . $wpseo_post_type->name,
__( 'Date in Snippet Preview', 'wordpress-seo' )
__( 'Date in Google Preview', 'wordpress-seo' )
);
$yform->show_hide_switch(
......
......@@ -18,6 +18,8 @@ use PhpParser\NodeVisitorAbstract;
class Remove_Vendor_Prefixing_Array_Key_Visitor extends NodeVisitorAbstract {
/**
* Removes vendor prefixes from array keys.
*
* @param \PhpParser\Node $node The node being visited.
*
* @return \PhpParser\Node The possibly modified node.
......
......@@ -17,6 +17,8 @@ use PhpParser\NodeVisitorAbstract;
class Remove_Vendor_Prefixing_Comment_Visitor extends NodeVisitorAbstract {
/**
* Removes vendor prefixes from comments.
*
* @param \PhpParser\Node $node The node being visited.
*
* @return \PhpParser\Node The possibly modified node.
......
......@@ -17,6 +17,8 @@ use PhpParser\NodeVisitorAbstract;
class Remove_Vendor_Prefixing_Visitor extends NodeVisitorAbstract {
/**
* Removes vendor prefixes from use statements.
*
* @param \PhpParser\Node $node The node being visited.
*
* @return \PhpParser\Node The possibly modified node.
......
......@@ -11,16 +11,22 @@
abstract class WPSEO_Health_Check {
/**
* The health check section in which 'good' results should be shown.
*
* @var string
*/
const STATUS_GOOD = 'good';
/**
* The health check section in which 'recommended' results should be shown.
*
* @var string
*/
const STATUS_RECOMMENDED = 'recommended';
/**
* The health check section in which 'critical' results should be shown.
*
* @var string
*/
const STATUS_CRITICAL = 'critical';
......
......@@ -160,6 +160,9 @@ abstract class WPSEO_Option {
add_action( 'add_option', [ $this, 'add_default_filters' ] ); // Adding back after INSERT.
add_action( 'update_option', [ $this, 'add_default_filters' ] );
// Refills the cache when the option has been updated.
add_action( 'update_option_' . $this->option_name, [ 'WPSEO_Options', 'clear_cache' ], 10 );
}
elseif ( is_multisite() ) {
/*
......@@ -173,6 +176,8 @@ abstract class WPSEO_Option {
add_action( 'add_site_option_' . $this->option_name, [ $this, 'add_default_filters' ] );
add_action( 'update_site_option_' . $this->option_name, [ $this, 'add_default_filters' ] );
// Refills the cache when the option has been updated.
add_action( 'update_site_option_' . $this->option_name, [ 'WPSEO_Options', 'clear_cache' ], 1, 0 );
}
......
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Internals\Options
*/
/**
* Backfill the removed options.
*
* @since 7.0.2
*/
class WPSEO_Options_Backfill implements WPSEO_WordPress_Integration {
/**
* Are the filters hooked or not.
*
* @var bool
*/
protected $hooked = false;
/**
* Registers all hooks to WordPress.
*/
public function register_hooks() {
// Make sure we don't hook multiple times.
if ( $this->hooked ) {
return;
}
$this->hooked = true;
// Backfill options that were removed.
foreach ( $this->get_lookups() as $option ) {
add_filter( 'pre_option_' . $option, [ $this, 'backfill_option' ], 10, 2 );
}
// Make sure renamed meta key is backfilled.
add_filter( 'get_user_metadata', [ $this, 'backfill_usermeta' ], 10, 3 );
// Extend the options that have removed items.
add_filter( 'option_wpseo_titles', [ $this, 'extend_wpseo_titles' ], 10, 1 );
add_filter( 'option_wpseo', [ $this, 'extend_wpseo' ], 10, 1 );
}
/**
* Removes the option filters.
*/
public function remove_hooks() {
// Remove backfill options filter.
foreach ( $this->get_lookups() as $option ) {
remove_filter( 'pre_option_' . $option, [ $this, 'backfill_option' ], 10 );
}
// Remove user meta filter.
remove_filter( 'get_user_metadata', [ $this, 'backfill_usermeta' ], 10 );
// Remove option extending filters.
remove_filter( 'option_wpseo_titles', [ $this, 'extend_wpseo_titles' ], 10 );
remove_filter( 'option_wpseo', [ $this, 'extend_wpseo' ], 10 );
$this->hooked = false;
}
/**
* Retrieves the options that need to be backfilled.
*
* @since 7.0.2
*
* @return array List of options that need to be backfilled.
*/
protected function get_lookups() {
return [
'wpseo_internallinks',
'wpseo_rss',
'wpseo_xml',
'wpseo_permalinks',
];
}
/**
* Retrieves the settings for the specified option.
*
* @since 7.0.2
*
* @param string $option The option to get the settings for.
*
* @return array The settings for the provided option.
*/
protected function get_settings( $option ) {
$settings = [
'wpseo' => [
'website_name' => 'website_name',
'alternate_website_name' => 'alternate_website_name',
'company_logo' => 'company_logo',
'company_name' => 'company_name',
'company_or_person' => 'company_or_person',
'person_name' => 'person_name',
],
'wpseo_internallinks' => [
'breadcrumbs-404crumb' => 'breadcrumbs-404crumb',
'breadcrumbs-blog-remove' => 'breadcrumbs-display-blog-page',
'breadcrumbs-boldlast' => 'breadcrumbs-boldlast',
'breadcrumbs-archiveprefix' => 'breadcrumbs-archiveprefix',
'breadcrumbs-enable' => 'breadcrumbs-enable',
'breadcrumbs-home' => 'breadcrumbs-home',
'breadcrumbs-prefix' => 'breadcrumbs-prefix',
'breadcrumbs-searchprefix' => 'breadcrumbs-searchprefix',
'breadcrumbs-sep' => 'breadcrumbs-sep',
],
'wpseo_rss' => [
'rssbefore' => 'rssbefore',
'rssafter' => 'rssafter',
],
'wpseo_xml' => [
'enablexmlsitemap' => 'enable_xml_sitemap',
'disable_author_sitemap' => 'noindex-author-wpseo',
'disable_author_noposts' => 'noindex-author-noposts-wpseo',
],
'wpseo_permalinks' => [
'redirectattachment' => 'disable-attachment',
'stripcategorybase' => 'stripcategorybase',
],
];
if ( ! isset( $settings[ $option ] ) ) {
return [];
}
return $settings[ $option ];
}
/**
* Extends the WPSEO option with the removed option values.
*
* @since 7.0.2
*
* @param array $data The data of the option.
*
* @return array Modified data.
*/
public function extend_wpseo( $data ) {
// Make sure we don't get stuck in an infinite loop.
static $running = false;
// If we are already running, don't run again.
if ( $running ) {
return $data;
}
$running = true;
foreach ( $this->get_settings( 'wpseo' ) as $old_key => $new_key ) {
$data[ $old_key ] = WPSEO_Options::get( $new_key );
}
// Ended running.
$running = false;
return $data;
}
/**
* Extends the WPSEO Title with removed attributes.
*
* @since 7.0.2
*
* @param array $data Data of the option.
*
* @return array Extended data.
*/
public function extend_wpseo_titles( $data ) {
// Make sure we don't get stuck in an infinite loop.
static $running = false;
// If we are already running, don't run again.
if ( $running ) {
return $data;
}
$running = true;
$data['breadcrumbs-blog-remove'] = ! WPSEO_Options::get( 'breadcrumbs-display-blog-page' );
$running = false;
$data = $this->add_hideeditbox( $data );
return $data;
}
/**
* Backfills the options that have been removed with the current values.
*
* @since 7.0.2
*
* @param mixed $value Current value for the option.
* @param string $option Name of the option.
*
* @return array Option data.
*/
public function backfill_option( $value, $option ) {
$output = [];
foreach ( $this->get_settings( $option ) as $old_key => $new_key ) {
$output[ $old_key ] = WPSEO_Options::get( $new_key );
}
$output = $this->apply_permalinks_settings( $output, $option );
$output = $this->apply_xml_settings( $output, $option );
return $output;
}
/**
* Backfills removed user meta fields.
*
* @since 7.0.2
*
* @param mixed $value The current value.
* @param int $object_id The user ID.
* @param string $meta_key The meta key.
*
* @return mixed The backfilled value if applicable.
*/
public function backfill_usermeta( $value, $object_id, $meta_key ) {
if ( $meta_key !== 'wpseo_excludeauthorsitemap' ) {
return $value;
}
return get_user_meta( $object_id, 'wpseo_noindex_author' );
}
/**
* Extends the data of the option with the deprecated values.
*
* @since 7.0.2
*
* @param array $data Current data of the option.
*
* @return array Extended data.
*/
protected function add_hideeditbox( $data ) {
foreach ( $data as $key => $value ) {
if ( strpos( $key, 'display-metabox-tax-' ) === 0 ) {
$taxonomy = substr( $key, strlen( 'display-metabox-tax-' ) );
$data[ 'hideeditbox-tax-' . $taxonomy ] = ! $value;
continue;
}
if ( strpos( $key, 'display-metabox-pt-' ) === 0 ) {
$post_type = substr( $key, strlen( 'display-metabox-pt-' ) );
$data[ 'hideeditbox-' . $post_type ] = ! $value;
continue;
}
}
return $data;
}
/**
* Adds the permalinks specific data to the option when requested.
*
* @since 7.0.2
*
* @param array $data Current data.
* @param string $option The option that is being parsed.
*
* @return array Extended data.
*/
protected function apply_permalinks_settings( $data, $option ) {
if ( $option !== 'wpseo_permalinks' ) {
return $data;
}
// Add defaults for completely removed settings in the option.
return array_merge(
$data,
[
'cleanpermalinks' => false,
'cleanpermalink-extravars' => '',
'cleanpermalink-googlecampaign' => false,
'cleanpermalink-googlesitesearch' => false,
'cleanreplytocom' => false,
'cleanslugs' => false,
'trailingslash' => false,
]
);
}
/**
* Adds the XML specific data to the option when requested.
*
* @since 7.0.2
*
* @param array $data Current data.
* @param string $option The option that is being parsed.
*
* @return array Extended data.
*/
protected function apply_xml_settings( $data, $option ) {
if ( $option !== 'wpseo_xml' ) {
return $data;
}
// Add dynamic implementations for settings that are not in any option anymore.
return array_merge(
$data,
[
'entries-per-page' => (int) apply_filters( 'wpseo_sitemap_entries_per_page', 1000 ),
'excluded-posts' => apply_filters( 'wpseo_exclude_from_sitemap_by_post_ids', [] ),
]
);
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment