Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/slim-seo/js/build/redirection.asset.php
+++ b/slim-seo/js/build/redirection.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '6b42043a7d971a7c2877');
+<?php return array('dependencies' => array('react', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '190477669e3487c20753');
--- a/slim-seo/slim-seo.php
+++ b/slim-seo/slim-seo.php
@@ -5,7 +5,7 @@
* Description: A fast and automated SEO plugin for WordPress.
* Author: Slim SEO
* Author URI: https://wpslimseo.com/?utm_source=plugin_links&utm_medium=link&utm_campaign=slim_seo
- * Version: 4.6.2
+ * Version: 4.7.0
* License: GPL v3
*
* Copyright (C) 2010-2025 Tran Ngoc Tuan Anh. All rights reserved.
@@ -32,7 +32,7 @@
define( 'SLIM_SEO_URL', plugin_dir_url( __FILE__ ) );
define( 'SLIM_SEO_REDIRECTS', 'ss_redirects' );
define( 'SLIM_SEO_DELETE_404_LOGS_ACTION', 'delete_404_logs' );
-define( 'SLIM_SEO_VER', '4.6.2' );
+define( 'SLIM_SEO_VER', '4.7.0' );
define( 'SLIM_SEO_DB_VER', 1 );
require __DIR__ . '/vendor/autoload.php';
--- a/slim-seo/src/Container.php
+++ b/slim-seo/src/Container.php
@@ -1,6 +1,9 @@
<?php
namespace SlimSEO;
+use eLightUpSlimSEOCommonSettingsPage as SettingsPage;
+use eLightUpSlimSEOCommonSettingsPost as SettingsPost;
+
class Container {
private $services = [];
@@ -119,8 +122,11 @@
public function init() {
do_action( 'slim_seo_init', $this );
- SettingsPage::setup();
+ SettingsPage::setup();
+ SettingsPost::setup();
+
$settings = $this->services['settings'];
+
foreach ( $this->services as $id => $service ) {
if ( ! $settings->is_feature_active( $id ) ) {
if ( method_exists( $service, 'deactivate' ) ) {
--- a/slim-seo/src/Helpers/Data.php
+++ b/slim-seo/src/Helpers/Data.php
@@ -1,21 +1,9 @@
<?php
namespace SlimSEOHelpers;
-class Data {
- public static function get_post_types() {
- $post_types = get_post_types( [ 'public' => true ], 'objects' );
- unset( $post_types['attachment'] );
- return apply_filters( 'slim_seo_post_types', $post_types );
- }
-
- public static function get_taxonomies() {
- $taxonomies = get_taxonomies( [
- 'public' => true,
- 'show_ui' => true,
- ], 'objects' );
- return apply_filters( 'slim_seo_taxonomies', $taxonomies );
- }
+use eLightUpSlimSEOCommonHelpersData as CommonHelpersData;
+class Data {
public static function get_post_type_archive_page( string $post_type ) {
$post_type_object = get_post_type_object( $post_type );
if ( ! $post_type_object || ! is_string( $post_type_object->has_archive ) ) {
@@ -47,11 +35,22 @@
public static function get_posts( array $args = [] ): array {
$posts = get_posts( array_merge( [
- 'post_type' => array_keys( self::get_post_types() ),
+ 'post_type' => array_keys( CommonHelpersData::get_post_types() ),
'post_status' => [ 'publish' ],
'posts_per_page' => -1,
], $args ) );
return $posts;
}
+
+ public static function get_meta_box_post_types(): array {
+ $post_types = array_keys( CommonHelpersData::get_post_types() );
+ $post_types = apply_filters( 'slim_seo_meta_box_post_types', $post_types );
+
+ return $post_types;
+ }
+
+ public static function has_static_homepage(): bool {
+ return get_option( 'show_on_front' ) === 'page' && get_option( 'page_on_front' );
+ }
}
--- a/slim-seo/src/Integrations/ACF/ACF.php
+++ b/slim-seo/src/Integrations/ACF/ACF.php
@@ -23,15 +23,22 @@
}
public function add_data( array $data, int $post_id, int $term_id ): array {
- $post_id = $post_id ?: ( is_singular() ? get_queried_object_id() : get_the_ID() );
-
- if ( empty( $post_id ) ) {
- return $data;
+ $field_objects = [];
+ if ( $post_id ) {
+ // Specify a post ID.
+ $field_objects = $this->get_post_field_objects( $post_id );
+ } elseif ( $term_id ) {
+ // Specify a term ID.
+ $field_objects = $this->get_term_field_objects( $term_id );
+ } elseif ( is_tax() || is_category() || is_tag() ) {
+ // On a term archive page.
+ $field_objects = $this->get_term_field_objects( get_queried_object_id() );
+ } else {
+ // Fallback to get post field objects from the current post.
+ $post_id = is_singular() ? get_queried_object_id() : (int) get_the_ID();
+ $field_objects = $this->get_post_field_objects( $post_id );
}
- $post = get_post( $post_id );
- $field_objects = get_field_objects( $post->ID ) ?: [];
-
// Option fields.
if ( function_exists( 'acf_add_options_page' ) ) {
$option_field_objects = get_field_objects( 'option' );
@@ -41,13 +48,6 @@
}
}
- // Post author fields.
- $author_field_objects = get_field_objects( 'user_' . $post->post_author );
-
- if ( ! empty( $author_field_objects ) ) {
- $field_objects = array_merge( $author_field_objects, $field_objects );
- }
-
if ( ! empty( $field_objects ) ) {
$data['acf'] = new Renderer( $field_objects );
}
@@ -55,6 +55,32 @@
return $data;
}
+ private function get_post_field_objects( int $post_id ): array {
+ if ( ! $post_id ) {
+ return [];
+ }
+
+ $field_objects = get_field_objects( $post_id ) ?: [];
+
+ // Post author fields.
+ $post = get_post( $post_id );
+ if ( ! $post ) {
+ return $field_objects;
+ }
+
+ $author_field_objects = get_field_objects( 'user_' . $post->post_author ) ?: [];
+
+ return array_merge( $author_field_objects, $field_objects );
+ }
+
+ private function get_term_field_objects( int $term_id ): array {
+ if ( ! $term_id ) {
+ return [];
+ }
+
+ return get_field_objects( "term_$term_id" ) ?: [];
+ }
+
private function add_group( array $field_group ): void {
$this->variables[] = [
// Translators: %s - field group title.
--- a/slim-seo/src/Integrations/MultilingualSitemapTrait.php
+++ b/slim-seo/src/Integrations/MultilingualSitemapTrait.php
@@ -0,0 +1,104 @@
+<?php
+namespace SlimSEOIntegrations;
+
+use WP_Post;
+use WP_Term;
+
+trait MultilingualSitemapTrait {
+ private function setup_sitemap_hooks(): void {
+ $types = [ 'post', 'term', 'homepage', 'post_type_archive' ];
+ foreach ( $types as $type ) {
+ add_action( "slim_seo_sitemap_$type", [ $this, "add_{$type}_links" ] );
+ }
+ }
+
+ public function add_post_links( WP_Post $post ): void {
+ $url = get_permalink( $post );
+ $translations = $this->get_post_translations( $post );
+ $this->add_links( $url, $translations );
+ }
+
+ public function add_term_links( WP_Term $term ): void {
+ $url = get_term_link( $term );
+ $translations = $this->get_term_translations( $term );
+ $this->add_links( $url, $translations );
+ }
+
+ public function add_homepage_links(): void {
+ $url = home_url( '/' );
+ $translations = $this->get_homepage_translations();
+ $this->add_links( $url, $translations );
+ }
+
+ public function add_post_type_archive_links( string $post_type ): void {
+ $url = get_post_type_archive_link( $post_type );
+ $translations = $this->get_post_type_archive_translations( $post_type );
+ $this->add_links( $url, $translations );
+ }
+
+ private function add_links( string $url, array $translations ): void {
+ $hreflang_links = $this->get_hreflang_links( $translations );
+ echo $hreflang_links; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+
+ // Google requires each translation to be in a separate <url> element with all the hreflang links.
+ $translations = array_filter( $translations, function( array $translation ) use ( $url ): bool {
+ return $translation['url'] !== $url;
+ } );
+ if ( empty( $translations ) ) {
+ return;
+ }
+
+ echo "t</url>n"; // Close the default URL.
+
+ $translations = array_values( $translations );
+ $count = count( $translations );
+ foreach ( $translations as $index => $translation ) {
+ echo "t<url>n";
+ echo "tt<loc>", esc_url( $translation['url'] ), "</loc>n";
+
+ unset( $translation['language'], $translation['url'] );
+
+ // Output the extra attributes: lastmod, etc.
+ foreach ( $translation as $key => $value ) {
+ printf( "tt<%1$s>%2$s</%1$s>n", esc_html( $key ), esc_html( $value ) );
+ }
+
+ echo $hreflang_links; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+
+ // Do not close the last translation.
+ if ( $index < $count - 1 ) {
+ echo "t</url>n";
+ }
+ }
+ }
+
+ private function get_hreflang_links( array $translations ): string {
+ $links = '';
+ $default_url = '';
+ $default_language = $this->get_default_language();
+
+ foreach ( $translations as $translation ) {
+ $links .= $this->get_hreflang_link( $translation['language'], $translation['url'] );
+
+ if ( $translation['language'] === $default_language ) {
+ $default_url = $translation['url'];
+ }
+ }
+
+ if ( $default_url ) {
+ $links .= $this->get_hreflang_link( 'x-default', $default_url );
+ }
+
+ return $links;
+ }
+
+ private function get_hreflang_link( string $language, string $url ): string {
+ $language = str_replace( '_', '-', $language );
+
+ return sprintf(
+ "tt<xhtml:link rel="alternate" hreflang="%s" href="%s"/>n",
+ esc_attr( $language ),
+ esc_url( $url )
+ );
+ }
+}
No newline at end of file
--- a/slim-seo/src/Integrations/Polylang.php
+++ b/slim-seo/src/Integrations/Polylang.php
@@ -2,17 +2,20 @@
namespace SlimSEOIntegrations;
use WP_Post;
+use WP_Term;
+use PLL_Language;
class Polylang {
+ use MultilingualSitemapTrait;
+
public function is_active(): bool {
return defined( 'POLYLANG_VERSION' );
}
public function setup(): void {
+ $this->setup_sitemap_hooks();
add_filter( 'slim_seo_sitemap_post_type_query_args', [ $this, 'query_all_translations' ] );
add_filter( 'slim_seo_sitemap_post_ignore', [ $this, 'ignore_translations' ], 10, 2 );
- add_action( 'slim_seo_sitemap_post', [ $this, 'add_post_links' ] );
- add_action( 'slim_seo_sitemap_term', [ $this, 'add_term_links' ] );
add_action( 'slim_seo_settings_enqueue', [ $this, 'add_language_for_js' ] );
// Register translatable options
@@ -39,26 +42,87 @@
return $ignore || $is_translation;
}
- public function add_post_links( WP_Post $post ): void {
+ private function get_post_translations( WP_Post $post ): array {
$translations = pll_get_post_translations( $post->ID );
+ $return = [];
foreach ( $translations as $code => $post_id ) {
- printf(
- "tt<xhtml:link rel="alternate" hreflang="%s" href="%s"/>n",
- esc_attr( $code ),
- esc_url( get_permalink( $post_id ) )
- );
+ $return[] = [
+ 'language' => $this->from_code_to_locale( $code ),
+ 'url' => get_permalink( $post_id ),
+ 'lastmod' => get_post_modified_time( 'c', true, $post_id ),
+ ];
}
+
+ return $return;
}
- public function add_term_links( WP_Term $term ): void {
+ private function get_term_translations( WP_Term $term ): array {
$translations = pll_get_term_translations( $term->term_id );
+ $return = [];
foreach ( $translations as $code => $term_id ) {
- printf(
- "tt<xhtml:link rel="alternate" hreflang="%s" href="%s"/>n",
- esc_attr( $code ),
- esc_url( get_term_link( $term_id ) )
- );
+ $return[] = [
+ 'language' => $this->from_code_to_locale( $code ),
+ 'url' => get_term_link( $term_id ),
+ ];
+ }
+
+ return $return;
+ }
+
+ private function get_homepage_translations(): array {
+ $languages = $this->get_languages();
+ $return = [];
+ foreach ( $languages as $language ) {
+ $return[] = [
+ 'language' => $language->locale,
+ 'url' => pll_home_url( $language->slug ),
+ ];
}
+ return $return;
+ }
+
+ private function get_post_type_archive_translations( string $post_type ): array {
+ $languages = $this->get_languages();
+ $return = [];
+ foreach ( $languages as $language ) {
+ PLL()->curlang = $language; // Switch the language to get the correct archive link.
+ $url = get_post_type_archive_link( $post_type );
+ if ( ! $url ) {
+ continue;
+ }
+ $return[] = [
+ 'language' => $language->locale,
+ 'url' => $url,
+ ];
+ }
+ return $return;
+ }
+
+ /**
+ * Get list of language objects. Need to pass empty 'fields' parameter to get the objects.
+ *
+ * @return PLL_Language[]
+ */
+ private function get_languages(): array {
+ return wp_list_filter( PLL()->model->get_languages_list(), [ 'active' => false ], 'NOT' );
+ }
+
+ private function get_default_language(): string {
+ return pll_default_language( 'locale' );
+ }
+
+ private function from_code_to_locale( string $code ): string {
+ static $map = [];
+ if ( ! empty( $map ) ) {
+ return $map[ $code ] ?? '';
+ }
+
+ $languages = $this->get_languages();
+ foreach ( $languages as $language ) {
+ $map[ $language->slug ] = $language->locale;
+ }
+
+ return $map[ $code ] ?? '';
}
public function add_language_for_js(): void {
--- a/slim-seo/src/Integrations/TranslatePress.php
+++ b/slim-seo/src/Integrations/TranslatePress.php
@@ -1,62 +1,74 @@
<?php
namespace SlimSEOIntegrations;
+use WP_Post;
+use WP_Term;
+
class TranslatePress {
- private $trp;
+ use MultilingualSitemapTrait;
+ private $url_converter;
+ private $settings;
public function is_active(): bool {
return defined( 'TRP_PLUGIN_VERSION' );
}
- public function setup() {
- $this->trp = TRP_Translate_Press::get_trp_instance();
+ public function setup(): void {
+ $trp = TRP_Translate_Press::get_trp_instance();
+ $this->url_converter = $trp->get_component( 'url_converter' );
+ $this->settings = $trp->get_component( 'settings' );
+
+ $this->setup_sitemap_hooks();
+ }
+
+ private function get_post_translations( WP_Post $post ): array {
+ return $this->get_translations( get_permalink( $post ), $post );
+ }
- add_action( 'slim_seo_sitemap_post', [ $this, 'add_post_links' ] );
- add_action( 'slim_seo_sitemap_term', [ $this, 'add_term_links' ] );
- add_filter( 'wpseo_sitemap_url', [ $this, 'get_url' ], 0, 2 ); // phpcs:ignore
+ private function get_term_translations( WP_Term $term ): array {
+ return $this->get_translations( get_term_link( $term ) );
}
- public function add_post_links( WP_Post $post ): void {
- $this->add_links( get_permalink( $post ) );
+ private function get_homepage_translations(): array {
+ return $this->get_translations( home_url( '/' ) );
}
- public function add_term_links( WP_Term $term ): void {
- $this->add_links( get_term_link( $term ) );
+ private function get_post_type_archive_translations( string $post_type ): array {
+ return $this->get_translations( get_post_type_archive_link( $post_type ) );
}
- private function add_links( string $url ): void {
+ private function get_translations( string $url, ?WP_Post $post = null ): array {
$languages = $this->get_languages();
+ $translations = [];
+
foreach ( $languages as $language ) {
- /**
- * Hack: TranslatePress checks current filter to bypass translating URLs in sitemaps.
- * We have to use the Yoast SEO's filter name to make it work.
- * This will be removed when TranslatePress adds support for Slim SEO's hooks.
- */
- $translated_url = apply_filters( 'wpseo_sitemap_url', $url, $language ); // phpcs:ignore
- if ( $translated_url === $url ) {
- continue;
+ $translated_url = $this->get_url( $url, $language );
+ $translation = [
+ 'language' => $language,
+ 'url' => $translated_url,
+ ];
+ if ( $post ) {
+ $translation['lastmod'] = wp_date( 'c', strtotime( $post->post_modified_gmt ) );
}
-
- printf(
- "tt<xhtml:link rel="alternate" hreflang="%s" href="%s"/>n",
- esc_attr( $language ),
- esc_url( $translated_url )
- );
+ $translations[] = $translation;
}
- }
- public function get_url( string $url, string $language ): string {
- // Remove TranslatePress callback for this hook to avoid potential errors.
- remove_all_actions( 'wpseo_sitemap_url' );
+ return $translations;
+ }
- $url_converter = $this->trp->get_component( 'url_converter' );
- return $url_converter->get_url_for_language( $language, $url, '' );
+ private function get_url( string $url, string $language ): string {
+ return $this->url_converter->get_url_for_language( $language, $url, '' );
}
private function get_languages(): array {
- $trp_settings = $this->trp->get_component( 'settings' );
- $settings = $trp_settings->get_settings();
+ $settings = $this->settings->get_settings();
+
+ return $settings['publish-languages'];
+ }
+
+ private function get_default_language(): string {
+ $settings = $this->settings->get_settings();
- return array_diff( $settings['publish-languages'], [ $settings['default-language'] ] );
+ return $settings['default-language'];
}
}
--- a/slim-seo/src/Integrations/WPML.php
+++ b/slim-seo/src/Integrations/WPML.php
@@ -1,72 +1,95 @@
<?php
namespace SlimSEOIntegrations;
+use WP_Post;
+use WP_Term;
+
class WPML {
+ use MultilingualSitemapTrait;
+
public function is_active(): bool {
return defined( 'ICL_SITEPRESS_VERSION' );
}
- public function setup() {
- add_action( 'slim_seo_sitemap_post', [ $this, 'add_post_links' ] );
- add_action( 'slim_seo_sitemap_term', [ $this, 'add_term_links' ] );
+ public function setup(): void {
+ $this->setup_sitemap_hooks();
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'wpml_multilingual_options', 'slim_seo' );
add_filter( 'wpml_tm_adjust_translation_fields', [ $this, 'adjust_fields' ] );
}
- public function add_post_links( WP_Post $post ): void {
- $original_url = get_permalink( $post );
+ private function get_post_translations( WP_Post $post ): array {
+ return $this->get_translations( get_permalink( $post ), $post->ID, 'post', $post->post_type );
+ }
+
+ private function get_term_translations( WP_Term $term ): array {
+ return $this->get_translations( get_term_link( $term ), $term->term_id, 'term', $term->taxonomy );
+ }
+
+ private function get_homepage_translations(): array {
$languages = $this->get_languages();
+ $translations = [];
+ $home_url = home_url( '/' );
foreach ( $languages as $language ) {
- // @codingStandardsIgnoreLine.
- $post_id = apply_filters( 'wpml_object_id', $post->ID, $post->post_type, false, $language );
- if ( ! $post_id ) {
+ $url = apply_filters( 'wpml_permalink', $home_url, $language, true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
+ if ( ! $url || $url === $home_url ) {
continue;
}
+ $translation = compact( 'language', 'url' );
+ $translations[] = $translation;
+ }
+
+ return $translations;
+ }
+
+ private function get_post_type_archive_translations( string $post_type ): array {
+ $languages = $this->get_languages();
+ $translations = [];
+ $archive_url = get_post_type_archive_link( $post_type );
- // @codingStandardsIgnoreLine.
- $url = apply_filters( 'wpml_permalink', $original_url, $language, true );
- if ( $url === $original_url ) {
+ foreach ( $languages as $language ) {
+ $url = apply_filters( 'wpml_permalink', $archive_url, $language, true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
+ if ( ! $url || $url === $archive_url ) {
continue;
}
-
- printf(
- "tt<xhtml:link rel="alternate" hreflang="%s" href="%s"/>n",
- esc_attr( $language ),
- esc_url( $url )
- );
+ $translation = compact( 'language', 'url' );
+ $translations[] = $translation;
}
+
+ return $translations;
}
- public function add_term_links( WP_Term $term ): void {
- $original_url = get_term_link( $term );
+ private function get_translations( string $url, int $object_id, string $object_type, string $type ): array {
$languages = $this->get_languages();
+ $translations = [];
foreach ( $languages as $language ) {
- // @codingStandardsIgnoreLine.
- $term_id = apply_filters( 'wpml_object_id', $term->term_id, $term->taxonomy, false, $language );
- if ( ! $term_id ) {
+ $translated_id = apply_filters( 'wpml_object_id', $object_id, $type, true, $language );
+ if ( ! $translated_id ) {
continue;
}
-
- // @codingStandardsIgnoreLine.
- $url = apply_filters( 'wpml_permalink', $original_url, $language, true );
- if ( $url === $original_url ) {
- continue;
+ $translation = [
+ 'language' => $language,
+ 'url' => apply_filters( 'wpml_permalink', $url, $language, true ), // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
+ ];
+ if ( $object_type === 'post' ) {
+ $translation['lastmod'] = get_post_modified_time( 'c', true, $translated_id );
}
-
- printf(
- "tt<xhtml:link rel="alternate" hreflang="%s" href="%s"/>n",
- esc_attr( $language ),
- esc_url( $url )
- );
+ $translations[] = $translation;
}
+
+ return $translations;
+ }
+
+ private function get_languages(): array {
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
+ return array_keys( apply_filters( 'wpml_active_languages', [], [ 'skip_missing' => true ] ) );
}
- private function get_languages() {
- // @codingStandardsIgnoreLine.
- return array_keys( apply_filters( 'wpml_active_languages', null, [ 'skip_missing' => true ] ) );
+ private function get_default_language(): string {
+ return apply_filters( 'wpml_default_language', '' );
}
public function adjust_fields( array $fields ): array {
--- a/slim-seo/src/MetaTags/Context.php
+++ b/slim-seo/src/MetaTags/Context.php
@@ -9,7 +9,7 @@
public function get_value() {
if ( is_front_page() ) {
- if ( ! $this->is_static_homepage() ) {
+ if ( ! Data::has_static_homepage() ) {
return $this->get_home_value();
}
@@ -77,8 +77,4 @@
private function get_queried_object_id() {
return QueriedObject::get_id();
}
-
- private function is_static_homepage(): bool {
- return get_option( 'show_on_front' ) === 'page' && get_option( 'page_on_front' );
- }
}
--- a/slim-seo/src/MetaTags/Settings/Base.php
+++ b/slim-seo/src/MetaTags/Settings/Base.php
@@ -25,41 +25,7 @@
] );
}
- public function render(): void {
- $tabs = apply_filters( 'slim_seo_metabox_tabs', [] );
-
- if ( empty( $tabs ) ) {
- $this->general_tab();
- return;
- }
- ?>
-
- <nav class="ss-tab-list">
- <a href="#general" class="ss-tab"><?php esc_html_e( 'General', 'slim-seo' ); ?></a>
- <?php
- foreach ( $tabs as $key => $label ) {
- printf( '<a href="#%s" class="ss-tab">%s</a>', esc_attr( $key ), esc_html( $label ) );
- }
- ?>
- </nav>
-
- <div id="general" class="ss-tab-pane">
- <?php $this->general_tab(); ?>
- </div>
-
- <?php
- $panes = apply_filters( 'slim_seo_metabox_panels', [] );
- echo implode( '', $panes ); // phpcs:ignore
- }
-
- public function general_tab(): void {
- wp_nonce_field( 'save', 'ss_nonce' );
- ?>
- <div id="ss-single"></div>
- <?php
- }
-
- public function save( $object_id ) {
+ public function save( int $object_id ): void {
if ( ! check_ajax_referer( 'save', 'ss_nonce', false ) || empty( $_POST ) ) {
return;
}
@@ -82,7 +48,7 @@
}
}
- private function sanitize( $data ) {
+ private function sanitize( array $data ): array {
$data = array_merge( $this->defaults, $data );
$data['title'] = sanitize_text_field( $data['title'] );
@@ -95,13 +61,13 @@
return array_filter( $data );
}
- private function get_data() {
+ private function get_data(): array {
$data = get_metadata( $this->object_type, $this->get_object_id(), 'slim_seo', true );
$data = is_array( $data ) && ! empty( $data ) ? $data : [];
return array_merge( $this->defaults, $data );
}
- abstract public function get_types();
- abstract protected function get_object_id();
+ abstract public function get_types(): array;
+ abstract protected function get_object_id(): int;
}
--- a/slim-seo/src/MetaTags/Settings/Post.php
+++ b/slim-seo/src/MetaTags/Settings/Post.php
@@ -6,39 +6,38 @@
class Post extends Base {
public function setup(): void {
$this->object_type = 'post';
- add_action( 'admin_print_styles-post.php', [ $this, 'enqueue' ] );
- add_action( 'admin_print_styles-post-new.php', [ $this, 'enqueue' ] );
- add_action( 'add_meta_boxes', [ $this, 'add_meta_box' ] );
+
+ add_action( 'slim_seo_meta_box_enqueue', [ $this, 'enqueue' ] );
+ add_filter( 'slim_seo_meta_box_tabs', [ $this, 'tabs' ], 10 );
+ add_filter( 'slim_seo_meta_box_panels', [ $this, 'panels' ], 10 );
add_action( 'save_post', [ $this, 'save' ] );
}
- public function enqueue(): void {
- $post_types = $this->get_types();
- $screen = get_current_screen();
-
- if ( in_array( $screen->post_type, $post_types ) ) {
- parent::enqueue();
- }
- }
+ public function tabs( array $tabs ): array {
+ $tabs['general'] = esc_html__( 'General', 'slim-seo' );
- public function add_meta_box() {
- $context = apply_filters( 'slim_seo_meta_box_context', 'normal' );
- $priority = apply_filters( 'slim_seo_meta_box_priority', 'low' );
-
- $post_types = $this->get_types();
- foreach ( $post_types as $post_type ) {
- add_meta_box( 'slim-seo', __( 'Search Engine Optimization', 'slim-seo' ), [ $this, 'render' ], $post_type, $context, $priority );
- }
+ return $tabs;
}
- public function get_types() {
- $post_types = array_keys( Data::get_post_types() );
- $post_types = apply_filters( 'slim_seo_meta_box_post_types', $post_types );
+ public function panels( array $panels ): array {
+ ob_start();
+
+ wp_nonce_field( 'save', 'ss_nonce' );
+ ?>
+
+ <div id="ss-single"></div>
+
+ <?php
+ $panels['general'] = ob_get_clean();
+
+ return $panels;
+ }
- return $post_types;
+ public function get_types(): array {
+ return Data::get_meta_box_post_types();
}
- protected function get_object_id() {
- return get_the_ID();
+ protected function get_object_id(): int {
+ return (int) get_the_ID();
}
}
--- a/slim-seo/src/MetaTags/Settings/Preview.php
+++ b/slim-seo/src/MetaTags/Settings/Preview.php
@@ -19,35 +19,41 @@
register_rest_route( 'slim-seo', 'meta-tags/render_post_title', [
'methods' => WP_REST_Server::EDITABLE,
'callback' => [ $this, 'render_post_title' ],
- 'permission_callback' => [ $this, 'has_permission' ],
+ 'permission_callback' => [ $this, 'has_post_permission' ],
] );
register_rest_route( 'slim-seo', 'meta-tags/render_term_title', [
'methods' => WP_REST_Server::EDITABLE,
'callback' => [ $this, 'render_term_title' ],
- 'permission_callback' => [ $this, 'has_permission' ],
+ 'permission_callback' => [ $this, 'has_term_permission' ],
] );
register_rest_route( 'slim-seo', 'meta-tags/render_post_description', [
'methods' => WP_REST_Server::EDITABLE,
'callback' => [ $this, 'render_post_description' ],
- 'permission_callback' => [ $this, 'has_permission' ],
+ 'permission_callback' => [ $this, 'has_post_permission' ],
] );
register_rest_route( 'slim-seo', 'meta-tags/render_term_description', [
'methods' => WP_REST_Server::EDITABLE,
'callback' => [ $this, 'render_term_description' ],
- 'permission_callback' => [ $this, 'has_permission' ],
+ 'permission_callback' => [ $this, 'has_term_permission' ],
] );
register_rest_route( 'slim-seo', 'meta-tags/render_text', [
'methods' => WP_REST_Server::EDITABLE,
'callback' => [ $this, 'render_text' ],
- 'permission_callback' => [ $this, 'has_permission' ],
+ 'permission_callback' => [ $this, 'has_post_permission' ],
] );
}
- public function has_permission(): bool {
+ public function has_post_permission( WP_REST_Request $request ): bool {
+ $post_id = (int) $request->get_param('ID');
+
+ return $post_id && current_user_can( 'edit_posts' ) && current_user_can( 'read_post', $post_id );
+ }
+
+ public function has_term_permission(): bool {
return current_user_can( 'edit_posts' );
}
--- a/slim-seo/src/MetaTags/Settings/Term.php
+++ b/slim-seo/src/MetaTags/Settings/Term.php
@@ -9,24 +9,32 @@
add_action( 'init', [ $this, 'register_hooks' ], 99 );
}
+ public function render(): void {
+ wp_nonce_field( 'save', 'ss_nonce' );
+ ?>
+ <div id="ss-single"></div>
+ <?php
+ }
+
public function register_hooks(): void {
add_action( 'admin_print_styles-term.php', [ $this, 'enqueue' ] );
$taxonomies = $this->get_types();
+
foreach ( $taxonomies as $taxonomy ) {
add_action( "{$taxonomy}_edit_form", [ $this, 'render' ] );
add_action( "edited_$taxonomy", [ $this, 'save' ] );
}
}
- public function get_types() {
+ public function get_types(): array {
$taxonomies = get_taxonomies( [ 'public' => true ] );
$taxonomies = apply_filters( 'slim_seo_meta_box_taxonomies', $taxonomies );
return $taxonomies;
}
- protected function get_object_id() {
- return filter_input( INPUT_GET, 'tag_ID', FILTER_SANITIZE_NUMBER_INT );
+ protected function get_object_id(): int {
+ return (int) filter_input( INPUT_GET, 'tag_ID', FILTER_SANITIZE_NUMBER_INT );
}
}
--- a/slim-seo/src/Migration/Migration.php
+++ b/slim-seo/src/Migration/Migration.php
@@ -1,6 +1,7 @@
<?php
namespace SlimSEOMigration;
+use eLightUpSlimSEOCommonHelpersData as CommonHelpersData;
use SlimSEOHelpersData;
use SlimSEOMigrationSourcesSource;
@@ -151,7 +152,7 @@
private function get_posts(): array {
$query = new WP_Query( [
- 'post_type' => array_keys( Data::get_post_types() ),
+ 'post_type' => array_keys( CommonHelpersData::get_post_types() ),
'post_status' => 'any',
'posts_per_page' => $this->threshold,
'no_found_rows' => true,
@@ -164,7 +165,7 @@
private function get_terms(): array {
return get_terms( [
- 'taxonomy' => array_keys( Data::get_taxonomies() ),
+ 'taxonomy' => array_keys( CommonHelpersData::get_taxonomies() ),
'hide_empty' => false,
'fields' => 'ids',
'number' => $this->threshold,
--- a/slim-seo/src/Redirection/Api/Log404.php
+++ b/slim-seo/src/Redirection/Api/Log404.php
@@ -19,36 +19,36 @@
return;
}
- register_rest_route( 'slim-seo-redirection', 'total_logs', [
+ register_rest_route( 'slim-seo-redirection', 'records/total', [
'methods' => WP_REST_Server::READABLE,
- 'callback' => [ $this, 'get_total' ],
+ 'callback' => [ $this, 'total' ],
'permission_callback' => [ $this, 'has_permission' ],
] );
- register_rest_route( 'slim-seo-redirection', 'logs', [
+ register_rest_route( 'slim-seo-redirection', 'records/list', [
'methods' => WP_REST_Server::READABLE,
- 'callback' => [ $this, 'get_logs' ],
+ 'callback' => [ $this, 'list' ],
'permission_callback' => [ $this, 'has_permission' ],
] );
- register_rest_route( 'slim-seo-redirection', 'delete_log', [
+ register_rest_route( 'slim-seo-redirection', 'records/delete', [
'methods' => WP_REST_Server::READABLE,
- 'callback' => [ $this, 'delete_log' ],
+ 'callback' => [ $this, 'delete' ],
'permission_callback' => [ $this, 'has_permission' ],
] );
- register_rest_route( 'slim-seo-redirection', 'delete_logs', [
+ register_rest_route( 'slim-seo-redirection', 'records/delete-all', [
'methods' => WP_REST_Server::READABLE,
- 'callback' => [ $this, 'delete_logs' ],
+ 'callback' => [ $this, 'delete_all' ],
'permission_callback' => [ $this, 'has_permission' ],
] );
}
- public function get_total(): int {
+ public function total(): int {
return $this->db_log->get_total();
}
- public function get_logs( WP_REST_Request $request ): array {
+ public function list( WP_REST_Request $request ): array {
$order_by = sanitize_text_field( $request->get_param( 'orderBy' ) );
$sort = sanitize_text_field( $request->get_param( 'sort' ) );
$limit = (int) $request->get_param( 'limit' );
@@ -67,7 +67,7 @@
return $this->db_log->list( $order_by, $sort, $limit, $offset );
}
- public function delete_log( WP_REST_Request $request ) {
+ public function delete( WP_REST_Request $request ) {
$id = (int) $request->get_param( 'id' );
$this->db_log->delete( $id );
@@ -75,7 +75,7 @@
return true;
}
- public function delete_logs() {
+ public function delete_all() {
$this->db_log->delete_all();
return true;
--- a/slim-seo/src/Redirection/ExportImport.php
+++ b/slim-seo/src/Redirection/ExportImport.php
@@ -91,6 +91,10 @@
$added = false;
for ( $i = 1; $i < $redirects_amount; $i++ ) {
+ if ( empty( $rows[ $i ] ) ) {
+ continue;
+ }
+
$redirect = array_combine( [
'type',
'condition',
--- a/slim-seo/src/Redirection/Settings.php
+++ b/slim-seo/src/Redirection/Settings.php
@@ -30,7 +30,6 @@
public function enqueue() {
$this->db_log->create_table();
- wp_enqueue_style( 'slim-seo-react-tabs', SLIM_SEO_URL . 'css/react-tabs.css', [], filemtime( SLIM_SEO_DIR . '/css/react-tabs.css' ) );
wp_enqueue_style( 'slim-seo-redirection', SLIM_SEO_URL . 'css/redirection.css', [ 'wp-components' ], filemtime( SLIM_SEO_DIR . 'css/redirection.css' ) );
Assets::enqueue_build_js( 'redirection', 'SSRedirection', [
--- a/slim-seo/src/Schema/Types/WebPage.php
+++ b/slim-seo/src/Schema/Types/WebPage.php
@@ -15,7 +15,7 @@
'description' => $this->description->get_description(),
];
- if ( is_post_type_archive() || is_tax() || is_category() || is_tag() || is_date() ) {
+ if ( is_post_type_archive() || is_tax() || is_category() || is_tag() || is_date() || is_home() ) {
$schema['@type'] = 'CollectionPage';
}
--- a/slim-seo/src/Settings/MetaTags/Manager.php
+++ b/slim-seo/src/Settings/MetaTags/Manager.php
@@ -1,6 +1,7 @@
<?php
namespace SlimSEOSettingsMetaTags;
+use eLightUpSlimSEOCommonHelpersData as CommonHelpersData;
use SlimSEOHelpersAssets;
use SlimSEOHelpersData;
use SlimSEOMetaTagsDescription;
@@ -17,13 +18,12 @@
public function enqueue(): void {
wp_enqueue_media();
- wp_enqueue_style( 'slim-seo-react-tabs', SLIM_SEO_URL . 'css/react-tabs.css', [], filemtime( SLIM_SEO_DIR . '/css/react-tabs.css' ) );
wp_enqueue_style( 'slim-seo-meta-tags', SLIM_SEO_URL . 'css/meta-tags.css', [ 'wp-components' ], filemtime( SLIM_SEO_DIR . '/css/meta-tags.css' ) );
Assets::enqueue_build_js( 'meta-tags', 'ss', [
- 'hasHomepageSettings' => $this->has_homepage_settings(),
+ 'hasHomepageSettings' => ! Data::has_static_homepage(),
'homepage' => $this->get_home_data(),
- 'postTypes' => Data::get_post_types(),
- 'taxonomies' => Data::get_taxonomies(),
+ 'postTypes' => CommonHelpersData::get_post_types(),
+ 'taxonomies' => CommonHelpersData::get_taxonomies(),
'postTypesWithArchivePage' => $this->get_post_types_with_archive_page(),
'defaultPostMetas' => $this->get_default_post_metas(),
'defaultTermMetas' => $this->get_default_term_metas(),
@@ -32,10 +32,6 @@
] );
}
- private function has_homepage_settings(): bool {
- return 'page' !== get_option( 'show_on_front' ) || ! get_option( 'page_on_front' );
- }
-
private function get_home_data(): array {
return array_merge( $this->defaults, [
'link' => get_home_url(),
@@ -47,8 +43,8 @@
}
private function get_content_items(): array {
- $taxonomies = array_keys( array_filter( Data::get_taxonomies() ) );
- $post_types = array_keys( array_filter( Data::get_post_types() ) );
+ $taxonomies = array_keys( array_filter( CommonHelpersData::get_taxonomies() ) );
+ $post_types = array_keys( array_filter( CommonHelpersData::get_post_types() ) );
$post_types_archive = array_map( function ( $post_type ) {
return "{$post_type}_archive";
@@ -94,7 +90,7 @@
}
private function get_post_types_with_archive_page(): array {
- $post_types = Data::get_post_types();
+ $post_types = CommonHelpersData::get_post_types();
if ( ! $post_types ) {
return [];
--- a/slim-seo/src/Settings/MetaTags/RestApi.php
+++ b/slim-seo/src/Settings/MetaTags/RestApi.php
@@ -2,7 +2,7 @@
namespace SlimSEOSettingsMetaTags;
use WP_REST_Server;
-use SlimSEOHelpersData;
+use eLightUpSlimSEOCommonHelpersData as CommonHelpersData;
class RestApi {
public function setup(): void {
@@ -59,7 +59,7 @@
}
public function get_variables() {
- $taxonomies = Data::get_taxonomies();
+ $taxonomies = CommonHelpersData::get_taxonomies();
unset( $taxonomies['category'], $taxonomies['post_tag'] );
$taxonomy_options = [];
--- a/slim-seo/src/Settings/Page.php
+++ b/slim-seo/src/Settings/Page.php
@@ -1,125 +0,0 @@
-<?php
-namespace SlimSEOSettings;
-
-class Page {
- public static function setup(): void {
- add_action( 'admin_menu', [ __CLASS__, 'add_menu' ] );
- }
-
- public static function add_menu(): void {
- $page_hook = add_options_page(
- __( 'Slim SEO', 'slim-seo' ),
- __( 'Slim SEO', 'slim-seo' ),
- 'manage_options',
- 'slim-seo',
- [ __CLASS__, 'render' ]
- );
- add_action( "load-{$page_hook}", [ __CLASS__, 'save' ] );
- }
-
- public static function render(): void {
- ?>
- <div class="wrap">
- <h1 class="ss-title">
- <svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="M472 0H40C17.9086 0 0 17.9086 0 40V472C0 494.091 17.9086 512 40 512H472C494.091 512 512 494.091 512 472V40C512 17.9086 494.091 0 472 0Z" fill="url(#paint0_linear)"/><path d="M259.353 398.8C238.82 398.8 220.42 395.467 204.153 388.8C187.886 382.133 174.82 372.267 164.953 359.2C155.353 346.133 150.286 330.4 149.753 312H222.553C223.62 322.4 227.22 330.4 233.353 336C239.486 341.333 247.486 344 257.353 344C267.486 344 275.486 341.733 281.353 337.2C287.22 332.4 290.153 325.867 290.153 317.6C290.153 310.667 287.753 304.933 282.953 300.4C278.42 295.867 272.686 292.133 265.753 289.2C259.086 286.267 249.486 282.933 236.953 279.2C218.82 273.6 204.02 268 192.553 262.4C181.086 256.8 171.22 248.533 162.953 237.6C154.686 226.667 150.553 212.4 150.553 194.8C150.553 168.667 160.02 148.267 178.953 133.6C197.886 118.667 222.553 111.2 252.953 111.2C283.886 111.2 308.82 118.667 327.753 133.6C346.686 148.267 356.82 168.8 358.153 195.2H284.153C283.62 186.133 280.286 179.067 274.153 174C268.02 168.667 260.153 166 250.553 166C242.286 166 235.62 168.267 230.553 172.8C225.486 177.067 222.953 183.333 222.953 191.6C222.953 200.667 227.22 207.733 235.753 212.8C244.286 217.867 257.62 223.333 275.753 229.2C293.886 235.333 308.553 241.2 319.753 246.8C331.22 252.4 341.086 260.533 349.353 271.2C357.62 281.867 361.753 295.6 361.753 312.4C361.753 328.4 357.62 342.933 349.353 356C341.353 369.067 329.62 379.467 314.153 387.2C298.686 394.933 280.42 398.8 259.353 398.8Z" fill="#fff"/><defs><linearGradient id="paint0_linear" x1="0" y1="0" x2="512" y2="512" gradientUnits="userSpaceOnUse"><stop stop-color="#C21500"/><stop offset="1" stop-color="#FFC500"/></linearGradient></defs></svg>
- <?php echo esc_html( get_admin_page_title() ); ?>
-
- <?php if ( ! defined( 'SLIM_SEO_PRO_VER' ) ) : ?>
- <a href="https://elu.to/ssp" target="_blank" class="ss-title__upgrade">
- <span class="dashicons dashicons-awards"></span>
- <strong><?php esc_html_e( 'Pro', 'slim-seo' ); ?></strong>
- </a>
- <?php endif ?>
-
- <a href="https://elu.to/ssd" target="_blank">
- <span class="dashicons dashicons-editor-help"></span>
- <?php esc_html_e( 'Documentation', 'slim-seo' ); ?>
- </a>
- <a href="https://elu.to/ssfb" target="_blank">
- <span class="dashicons dashicons-groups"></span>
- <?php esc_html_e( 'Facebook Group', 'slim-seo' ); ?>
- </a>
- </h1>
-
- <div class="ss-content" id="poststuff">
-
- <form action="" method="post" class="ss-tabs">
- <nav class="ss-tab-list">
- <?php
- $tabs = apply_filters( 'slim_seo_settings_tabs', [] );
- foreach ( $tabs as $key => $label ) {
- printf( '<a href="#%s" class="ss-tab">%s</a>', esc_attr( $key ), esc_html( $label ) );
- }
- ?>
- </nav>
- <?php
- wp_nonce_field( 'save' );
- $panes = apply_filters( 'slim_seo_settings_panes', [] );
- echo implode( '', $panes ); // @codingStandardsIgnoreLine.
- ?>
- </form>
-
- <aside class="ss-sidebar">
- <?php if ( ! defined( 'SLIM_SEO_PRO_VER' ) ) : ?>
- <div class="ss-upgrade postbox">
- <h3 class="hndle"><?php esc_html_e( 'Advanced SEO features', 'slim-seo' ); ?></h3>
- <div class="inside">
- <p>
- <?php
- // Translators: %1$s - plugin URL, %2$s - plugin name.
- echo wp_kses_post( sprintf( __( 'Wanna advanced SEO features without complexity? Check out <a href="%1$s"><strong>%2$s</strong></a>, our powerful & lightweight pro version that has:', 'slim-seo' ), 'https://elu.to/ssp', 'Slim SEO Pro' ) );
- ?>
- </p>
- <ul>
- <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Visual schema builder', 'slim-seo' ) ?></li>
- <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( '30+ pre-built schema types', 'slim-seo' ) ?></li>
- <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Custom schema with JSON-LD', 'slim-seo' ) ?></li>
- <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Contextual link suggestions', 'slim-seo' ) ?></li>
- <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Real-time link health monitoring', 'slim-seo' ) ?></li>
- <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Broken link repair', 'slim-seo' ) ?></li>
- <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Link updater', 'slim-seo' ) ?></li>
- <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'And more in the future...', 'slim-seo' ) ?></li>
- </ul>
- <a class="button button-primary" href="https://elu.to/ssp" target="_blank">
- <?php // Translators: %s - plugin name ?>
- <?php echo esc_html( sprintf( __( 'Get %s', 'slim-seo' ), 'Slim SEO Pro' ) ); ?> →
- </a>
- </div>
- </div>
- <?php endif ?>
-
- <div class="postbox">
- <h3 class="hndle"><?php esc_html_e( 'Our WordPress products', 'slim-seo' ) ?></h3>
- <div class="inside">
- <p><?php esc_html_e( 'Like this plugin? Check out our other WordPress products:', 'slim-seo' ) ?></p>
- <p><a href="https://elu.to/ssm" target="_blank"><strong>Meta Box</strong></a>: <?php esc_html_e( 'A framework for dynamic WordPress websites', 'slim-seo' ) ?></p>
- <p><a href="https://wordpress.org/plugins/falcon/" target="_blank"><strong>Falcon</strong></a>: <?php esc_html_e( 'WordPress optimization & tweaks', 'slim-seo' ) ?></p>
- </div>
- </div>
-
- <div class="postbox">
- <h3 class="hndle">
- <span><?php esc_html_e( 'Write a review for Slim SEO', 'slim-seo' ) ?></span>
- </h3>
- <div class="inside">
- <p><?php esc_html_e( 'If you like Slim SEO, please write a review on WordPress.org to help us spread the word. We really appreciate that!', 'slim-seo' ) ?></p>
- <p><a href="https://elu.to/ssr" target="_blank"><?php esc_html_e( 'Write a review', 'slim-seo' ) ?> →</a></p>
- </div>
- </div>
- </aside>
- </div>
-
- </div>
- <?php
- }
-
- public static function save(): void {
- if ( empty( $_POST['submit'] ) || ! check_ajax_referer( 'save', false, false ) ) {
- return;
- }
-
- do_action( 'slim_seo_save' );
-
- add_settings_error( null, 'slim-seo', __( 'Settings updated.', 'slim-seo' ), 'success' );
- }
-}
--- a/slim-seo/src/Settings/Settings.php
+++ b/slim-seo/src/Settings/Settings.php
@@ -58,12 +58,9 @@
return $panes;
}
- public function enqueue() {
- wp_enqueue_style( 'slim-seo-settings', SLIM_SEO_URL . 'css/settings.css', [], filemtime( SLIM_SEO_DIR . '/css/settings.css' ) );
+ public function enqueue(): void {
$this->meta_tags->enqueue();
- wp_enqueue_script( 'slim-seo-settings', SLIM_SEO_URL . 'js/settings.js', [], filemtime( SLIM_SEO_DIR . '/js/settings.js' ), true );
-
wp_enqueue_script( 'slim-seo-migrate', SLIM_SEO_URL . 'js/migrate.js', [], filemtime( SLIM_SEO_DIR . '/js/migrate.js' ), true );
wp_localize_script( 'slim-seo-migrate', 'ssMigration', [
'nonce' => wp_create_nonce( 'migrate' ),
--- a/slim-seo/src/Sitemaps/Manager.php
+++ b/slim-seo/src/Sitemaps/Manager.php
@@ -1,7 +1,7 @@
<?php
namespace SlimSEOSitemaps;
-use SlimSEOHelpersData;
+use eLightUpSlimSEOCommonHelpersData as CommonHelpersData;
class Manager {
private $post_types = [];
@@ -119,7 +119,7 @@
private function get_post_types(): void {
$option = get_option( 'slim_seo' );
- $post_types = array_keys( Data::get_post_types() );
+ $post_types = array_keys( CommonHelpersData::get_post_types() );
$post_types = array_filter( $post_types, function ( $post_type ) use ( $option ): bool {
return empty( $option[ $post_type ]['noindex'] );
} );
@@ -129,7 +129,7 @@
private function get_taxonomies(): void {
$option = get_option( 'slim_seo' );
- $taxonomies = array_keys( Data::get_taxonomies() );
+ $taxonomies = array_keys( CommonHelpersData::get_taxonomies() );
$taxonomies = array_filter( $taxonomies, function ( $taxonomy ) use ( $option ): bool {
return empty( $option[ $taxonomy ]['noindex'] );
} );
--- a/slim-seo/src/Sitemaps/PostType.php
+++ b/slim-seo/src/Sitemaps/PostType.php
@@ -74,11 +74,13 @@
}
private function output_homepage(): void {
- if ( 'page' !== $this->post_type || 'posts' !== get_option( 'show_on_front' ) ) {
+ if ( $this->post_type !== 'page' || Data::has_static_homepage() ) {
return;
}
echo "t<url>n";
echo "tt<loc>", esc_url( home_url( '/' ) ), "</loc>n";
+
+ do_action( 'slim_seo_sitemap_homepage' );
echo "t</url>n";
}
@@ -100,6 +102,8 @@
}
echo "t<url>n";
echo "tt<loc>", esc_url( $url ), "</loc>n";
+
+ do_action( 'slim_seo_sitemap_post_type_archive', $this->post_type );
echo "t</url>n";
}
--- a/slim-seo/vendor/autoload.php
+++ b/slim-seo/vendor/autoload.php
@@ -19,4 +19,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
-return ComposerAutoloaderInitae064411106ee768a4eef1e325d4d977::getLoader();
+return ComposerAutoloaderInit22b2089a9ad06b3b423db439c0900d7f::getLoader();
--- a/slim-seo/vendor/composer/autoload_psr4.php
+++ b/slim-seo/vendor/composer/autoload_psr4.php
@@ -6,6 +6,7 @@
$baseDir = dirname($vendorDir);
return array(
+ 'eLightUp\SlimSEO\Common\' => array($vendorDir . '/elightup/slim-seo-common/src'),
'SlimTwig\' => array($vendorDir . '/elightup/slim-twig/src'),
'SlimSEO\' => array($baseDir . '/src'),
);
--- a/slim-seo/vendor/composer/autoload_real.php
+++ b/slim-seo/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
-class ComposerAutoloaderInitae064411106ee768a4eef1e325d4d977
+class ComposerAutoloaderInit22b2089a9ad06b3b423db439c0900d7f
{
private static $loader;
@@ -24,12 +24,12 @@
require __DIR__ . '/platform_check.php';
- spl_autoload_register(array('ComposerAutoloaderInitae064411106ee768a4eef1e325d4d977', 'loadClassLoader'), true, true);
+ spl_autoload_register(array('ComposerAutoloaderInit22b2089a9ad06b3b423db439c0900d7f', 'loadClassLoader'), true, true);
self::$loader = $loader = new ComposerAutoloadClassLoader(dirname(__DIR__));
- spl_autoload_unregister(array('ComposerAutoloaderInitae064411106ee768a4eef1e325d4d977', 'loadClassLoader'));
+ spl_autoload_unregister(array('ComposerAutoloaderInit22b2089a9ad06b3b423db439c0900d7f', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
- call_user_func(ComposerAutoloadComposerStaticInitae064411106ee768a4eef1e325d4d977::getInitializer($loader));
+ call_user_func(ComposerAutoloadComposerStaticInit22b2089a9ad06b3b423db439c0900d7f::getInitializer($loader));
$loader->register(true);
--- a/slim-seo/vendor/composer/autoload_static.php
+++ b/slim-seo/vendor/composer/autoload_static.php
@@ -4,9 +4,13 @@
namespace ComposerAutoload;
-class ComposerStaticInitae064411106ee768a4eef1e325d4d977
+class ComposerStaticInit22b2089a9ad06b3b423db439c0900d7f
{
public static $prefixLengthsPsr4 = array (
+ 'e' =>
+ array (
+ 'eLightUp\SlimSEO\Common\' => 24,
+ ),
'S' =>
array (
'SlimTwig\' => 9,
@@ -15,6 +19,10 @@
);
public static $prefixDirsPsr4 = array (
+ 'eLightUp\SlimSEO\Common\' =>
+ array (
+ 0 => __DIR__ . '/..' . '/elightup/slim-seo-common/src',
+ ),
'SlimTwig\' =>
array (
0 => __DIR__ . '/..' . '/elightup/slim-twig/src',
@@ -32,9 +40,9 @@
public static function getInitializer(ClassLoader $loader)
{
return Closure::bind(function () use ($loader) {
- $loader->prefixLengthsPsr4 = ComposerStaticInitae064411106ee768a4eef1e325d4d977::$prefixLengthsPsr4;
- $loader->prefixDirsPsr4 = ComposerStaticInitae064411106ee768a4eef1e325d4d977::$prefixDirsPsr4;
- $loader->classMap = ComposerStaticInitae064411106ee768a4eef1e325d4d977::$classMap;
+ $loader->prefixLengthsPsr4 = ComposerStaticInit22b2089a9ad06b3b423db439c0900d7f::$prefixLengthsPsr4;
+ $loader->prefixDirsPsr4 = ComposerStaticInit22b2089a9ad06b3b423db439c0900d7f::$prefixDirsPsr4;
+ $loader->classMap = ComposerStaticInit22b2089a9ad06b3b423db439c0900d7f::$classMap;
}, null, ClassLoader::class);
}
--- a/slim-seo/vendor/composer/installed.php
+++ b/slim-seo/vendor/composer/installed.php
@@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'elightup/slim-seo',
- 'pretty_version' => '4.6.2',
- 'version' => '4.6.2.0',
- 'reference' => '9615b4ce2cbb54fffc569882064f23a8fcd182b3',
+ 'pretty_version' => '4.7.0',
+ 'version' => '4.7.0.0',
+ 'reference' => 'd9e9720a0e27ee6a4bb54c975dc0bad840f3f9a8',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -11,14 +11,25 @@
),
'versions' => array(
'elightup/slim-seo' => array(
- 'pretty_version' => '4.6.2',
- 'version' => '4.6.2.0',
- 'reference' => '9615b4ce2cbb54fffc569882064f23a8fcd182b3',
+ 'pretty_version' => '4.7.0',
+ 'version' => '4.7.0.0',
+ 'reference' => 'd9e9720a0e27ee6a4bb54c975dc0bad840f3f9a8',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
+ 'elightup/slim-seo-common' => array(
+ 'pretty_version' => 'dev-master',
+ 'version' => 'dev-master',
+ 'reference' => '5033b1bbc10f29f50de95d3c6574e0d863cdf2bf',
+ 'type' => 'library',
+ 'install_path' => __DIR__ . '/../elightup/slim-seo-common',
+ 'aliases' => array(
+ 0 => '9999999-dev',
+ ),
+ 'dev_requirement' => false,
+ ),
'elightup/slim-twig' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
--- a/slim-seo/vendor/elightup/slim-seo-common/src/Helpers/Data.php
+++ b/slim-seo/vendor/elightup/slim-seo-common/src/Helpers/Data.php
@@ -0,0 +1,21 @@
+<?php
+namespace eLightUpSlimSEOCommonHelpers;
+
+class Data {
+ public static function get_post_types(): array {
+ $post_types = get_post_types( [ 'public' => true ], 'objects' );
+
+ unset( $post_types['attachment'] );
+
+ return apply_filters( 'slim_seo_post_types', $post_types );
+ }
+
+ public static function get_taxonomies(): array {
+ $taxonomies = get_taxonomies( [
+ 'public' => true,
+ 'show_ui' => true,
+ ], 'objects' );
+
+ return apply_filters( 'slim_seo_taxonomies', $taxonomies );
+ }
+}
--- a/slim-seo/vendor/elightup/slim-seo-common/src/Settings/Page.php
+++ b/slim-seo/vendor/elightup/slim-seo-common/src/Settings/Page.php
@@ -0,0 +1,132 @@
+<?php
+namespace eLightUpSlimSEOCommonSettings;
+
+class Page {
+ public static function setup(): void {
+ add_action( 'admin_menu', [ __CLASS__, 'add_menu' ] );
+ }
+
+ public static function add_menu(): void {
+ $page_hook = add_options_page(
+ __( 'Slim SEO', 'slim-seo' ),
+ __( 'Slim SEO', 'slim-seo' ),
+ 'manage_options',
+ 'slim-seo',
+ [ __CLASS__, 'render' ]
+ );
+ add_action( "admin_print_styles-{$page_hook}", [ __CLASS__, 'enqueue' ] );
+ add_action( "load-{$page_hook}", [ __CLASS__, 'save' ] );
+ }
+
+ public static function render(): void {
+ ?>
+ <div class="wrap">
+ <h1 class="ss-title">
+ <svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="M472 0H40C17.9086 0 0 17.9086 0 40V472C0 494.091 17.9086 512 40 512H472C494.091 512 512 494.091 512 472V40C512 17.9086 494.091 0 472 0Z" fill="url(#paint0_linear)"/><path d="M259.353 398.8C238.82 398.8 220.42 395.467 204.153 388.8C187.886 382.133 174.82 372.267 164.953 359.2C155.353 346.133 150.286 330.4 149.753 312H222.553C223.62 322.4 227.22 330.4 233.353 336C239.486 341.333 247.486 344 257.353 344C267.486 344 275.486 341.733 281.353 337.2C287.22 332.4 290.153 325.867 290.153 317.6C290.153 310.667 287.753 304.933 282.953 300.4C278.42 295.867 272.686 292.133 265.753 289.2C259.086 286.267 249.486 282.933 236.953 279.2C218.82 273.6 204.02 268 192.553 262.4C181.086 256.8 171.22 248.533 162.953 237.6C154.686 226.667 150.553 212.4 150.553 194.8C150.553 168.667 160.02 148.267 178.953 133.6C197.886 118.667 222.553 111.2 252.953 111.2C283.886 111.2 308.82 118.667 327.753 133.6C346.686 148.267 356.82 168.8 358.153 195.2H284.153C283.62 186.133 280.286 179.067 274.153 174C268.02 168.667 260.153 166 250.553 166C242.286 166 235.62 168.267 230.553 172.8C225.486 177.067 222.953 183.333 222.953 191.6C222.953 200.667 227.22 207.733 235.753 212.8C244.286 217.867 257.62 223.333 275.753 229.2C293.886 235.333 308.553 241.2 319.753 246.8C331.22 252.4 341.086 260.533 349.353 271.2C357.62 281.867 361.753 295.6 361.753 312.4C361.753 328.4 357.62 342.933 349.353 356C341.353 369.067 329.62 379.467 314.153 387.2C298.686 394.933 280.42 398.8 259.353 398.8Z" fill="#fff"/><defs><linearGradient id="paint0_linear" x1="0" y1="0" x2="512" y2="512" gradientUnits="userSpaceOnUse"><stop stop-color="#C21500"/><stop offset="1" stop-color="#FFC500"/></linearGradient></defs></svg>
+ <?php echo esc_html( get_admin_page_title() ); ?>
+
+ <?php if ( ! defined( 'SLIM_SEO_PRO_VER' ) ) : ?>
+ <a href="https://elu.to/ssp" target="_blank" class="ss-title__upgrade">
+ <span class="dashicons dashicons-awards"></span>
+ <strong><?php esc_html_e( 'Pro', 'slim-seo' ); ?></strong>
+ </a>
+ <?php endif ?>
+
+ <a href="https://elu.to/ssd" target="_blank">
+ <span class="dashicons dashicons-editor-help"></span>
+ <?php esc_html_e( 'Documentation', 'slim-seo' ); ?>
+ </a>
+ <a href="https://elu.to/ssfb" target="_blank">
+ <span class="dashicons dashicons-groups"></span>
+ <?php esc_html_e( 'Facebook Group', 'slim-seo' ); ?>
+ </a>
+ </h1>
+
+ <div class="ss-content" id="poststuff">
+
+ <form action="" method="post" class="ss-tabs">
+ <nav class="ss-tab-list">
+ <?php
+ $tabs = apply_filters( 'slim_seo_settings_tabs', [] );
+ foreach ( $tabs as $key => $label ) {
+ printf( '<a href="#%s" class="ss-tab">%s</a>', esc_attr( $key ), esc_html( $label ) );
+ }
+ ?>
+ </nav>
+ <?php
+ wp_nonce_field( 'save' );
+ $panes = apply_filters( 'slim_seo_settings_panes', [] );
+ echo implode( '', $panes ); // @codingStandardsIgnoreLine.
+ ?>
+ </form>
+
+ <aside class="ss-sidebar">
+ <?php if ( ! defined( 'SLIM_SEO_PRO_VER' ) ) : ?>
+ <div class="ss-upgrade postbox">
+ <h3 class="hndle"><?php esc_html_e( 'Advanced SEO features', 'slim-seo' ); ?></h3>
+ <div class="inside">
+ <p>
+ <?php
+ // Translators: %1$s - plugin URL, %2$s - plugin name.
+ echo wp_kses_post( sprintf( __( 'Wanna advanced SEO features without complexity? Check out <a href="%1$s"><strong>%2$s</strong></a>, our powerful & lightweight pro version that has:', 'slim-seo' ), 'https://elu.to/ssp', 'Slim SEO Pro' ) );
+ ?>
+ </p>
+ <ul>
+ <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Visual schema builder', 'slim-seo' ) ?></li>
+ <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( '30+ pre-built schema types', 'slim-seo' ) ?></li>
+ <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Custom schema with JSON-LD', 'slim-seo' ) ?></li>
+ <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Contextual link suggestions', 'slim-seo' ) ?></li>
+ <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Real-time link health monitoring', 'slim-seo' ) ?></li>
+ <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Broken link repair', 'slim-seo' ) ?></li>
+ <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Link updater', 'slim-seo' ) ?></li>
+ <li><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'And more in the future...', 'slim-seo' ) ?></li>
+ </ul>
+ <a class="button button-primary" href="https://elu.to/ssp" target="_blank">
+ <?php // Translators: %s - plugin name ?>
+ <?php echo esc_html( sprintf( __( 'Get %s', 'slim-seo' ), 'Slim SEO Pro' ) ); ?> →
+ </a>
+ </div>
+ </div>
+ <?php endif ?>
+
+ <div class="postbox">
+ <h3 class="hndle"><?php esc_html_e( 'Our WordPress products', 'slim-seo' ) ?></h3>
+ <div class="inside">
+ <p><?php esc_html_e( 'Like this plugin? Check out our other WordPress products:', 'slim-seo' ) ?></p>
+ <p><a href="https://elu.to/ssm" target="_blank"><strong>Meta Box</strong></a>: <?php esc_html_e( 'A framework for dynamic WordPress websites', 'slim-seo' ) ?></p>
+ <p><a href="https://wordpress.org/plugins/falcon/" target="_blank"><strong>Falcon</strong></a>: <?php esc_html_e( 'WordPress optimization & tweaks', 'slim-seo' ) ?></p>
+ </div>
+ </div>
+
+ <div class="postbox">
+ <h3 class="hndle">
+ <span><?php esc_html_e( 'Write a review for Slim SEO', 'slim-seo' ) ?></span>
+ </h3>
+ <div class="inside">
+ <p><?php esc_html_e( 'If you like Slim SEO, please write a review on WordPress.org to help us spread the word. We really appreciate that!', 'slim-seo' ) ?></p>
+ <p><a href="https://elu.to/ssr" target="_blank"><?php esc_html_e( 'Write a review', 'slim-seo' ) ?> →</a></p>
+ </div>
+ </div>
+ </aside>
+ </div>
+
+ </div>
+ <?php
+ }
+
+ public static function enqueue(): void {
+ wp_enqueue_style( 'slim-seo-components', 'https://cdn.jsdelivr.net/gh/elightup/slim-seo@master/css/components.css', [], '1.0.0' );
+ wp_enqueue_style( 'slim-seo-settings', 'https://cdn.jsdelivr.net/gh/elightup/slim-seo@master/css/settings.css', [], '1.0.0' );
+ wp_enqueue_script( 'slim-seo-settings', 'https://cdn.jsdelivr.net/gh/elightup/slim-seo@master/js/settings.js', [], '1.0.0', true );
+ }
+
+ public static function save(): void {
+ if ( empty( $_POST['submit'] ) || ! check_ajax_referer( 'save', false, false ) ) {
+ return;
+ }
+
+ do_action( 'slim_seo_save' );
+
+ add_settings_error( null, 'slim-seo', __( 'Sett