declarations' => array(
* 'color' => 'gray',
* 'width' => '3em',
* ),
* ),
* );
*
* $css = wp_style_engine_get_stylesheet_from_css_rules( $css_rules );
*
* Returns:
*
* .elephant-are-cool{color:gray;width:3em}
*
* @since 6.1.0
* @since 6.6.0 Added support for `$rules_group` in the `$css_rules` array.
*
* @param array $css_rules {
* Required. A collection of CSS rules.
*
* @type array ...$0 {
* @type string $rules_group A parent CSS selector in the case of nested CSS,
* or a CSS nested @rule, such as `@media (min-width: 80rem)` or `@layer module`.
* @type string $selector A CSS selector.
* @type string[] $declarations An associative array of CSS definitions,
* e.g. `array( "$property" => "$value", "$property" => "$value" )`.
* }
* }
* @param array $options {
* Optional. An array of options. Default empty array.
*
* @type string|null $context An identifier describing the origin of the style object,
* e.g. 'block-supports' or 'global-styles'. Default 'block-supports'.
* When set, the style engine will attempt to store the CSS rules.
* @type bool $optimize Whether to optimize the CSS output, e.g. combine rules.
* Default false.
* @type bool $prettify Whether to add new lines and indents to output.
* Defaults to whether the `SCRIPT_DEBUG` constant is defined.
* }
* @return string A string of compiled CSS declarations, or empty string.
*/
function wp_style_engine_get_stylesheet_from_css_rules( $css_rules, $options = array() ) {
if ( empty( $css_rules ) ) {
return '';
}
$options = wp_parse_args(
$options,
array(
'context' => null,
)
);
$css_rule_objects = array();
foreach ( $css_rules as $css_rule ) {
if ( empty( $css_rule['selector'] ) || empty( $css_rule['declarations'] ) || ! is_array( $css_rule['declarations'] ) ) {
continue;
}
$rules_group = $css_rule['rules_group'] ?? null;
if ( ! empty( $options['context'] ) ) {
WP_Style_Engine::store_css_rule( $options['context'], $css_rule['selector'], $css_rule['declarations'], $rules_group );
}
$css_rule_objects[] = new WP_Style_Engine_CSS_Rule( $css_rule['selector'], $css_rule['declarations'], $rules_group );
}
if ( empty( $css_rule_objects ) ) {
return '';
}
return WP_Style_Engine::compile_stylesheet_from_css_rules( $css_rule_objects, $options );
}
/**
* Returns compiled CSS from a store, if found.
*
* @since 6.1.0
*
* @param string $context A valid context name, corresponding to an existing store key.
* @param array $options {
* Optional. An array of options. Default empty array.
*
* @type bool $optimize Whether to optimize the CSS output, e.g. combine rules.
* Default false.
* @type bool $prettify Whether to add new lines and indents to output.
* Defaults to whether the `SCRIPT_DEBUG` constant is defined.
* }
* @return string A compiled CSS string.
*/
function wp_style_engine_get_stylesheet_from_context( $context, $options = array() ) {
return WP_Style_Engine::compile_stylesheet_from_css_rules( WP_Style_Engine::get_store( $context )->get_all_rules(), $options );
}
al->advancedSettings->enable &&
in_array( 'staticSitemap', aioseo()->internalOptions->internal->deprecatedOptions, true ) &&
! aioseo()->options->deprecated->sitemap->general->advancedSettings->dynamic;
if ( $isGeneralSitemapStatic ) {
Models\Notification::deleteNotificationByName( 'sitemap-static-files' );
return;
}
require_once ABSPATH . 'wp-admin/includes/file.php';
$files = list_files( get_home_path(), 1 );
if ( ! count( $files ) ) {
return;
}
$detectedFiles = [];
if ( ! $isGeneralSitemapStatic ) {
foreach ( $files as $filename ) {
if ( preg_match( '#.*sitemap.*#', (string) $filename ) ) {
// We don't want to delete the video sitemap here at all.
$isVideoSitemap = preg_match( '#.*video.*#', (string) $filename ) ? true : false;
if ( ! $isVideoSitemap ) {
$detectedFiles[] = $filename;
}
}
}
}
$this->maybeShowStaticSitemapNotification( $detectedFiles );
}
/**
* If there are files, show a notice, otherwise delete it.
*
* @since 4.0.0
*
* @param array $detectedFiles An array of detected files.
* @return void
*/
protected function maybeShowStaticSitemapNotification( $detectedFiles ) {
if ( ! count( $detectedFiles ) ) {
Models\Notification::deleteNotificationByName( 'sitemap-static-files' );
return;
}
$notification = Models\Notification::getNotificationByName( 'sitemap-static-files' );
if ( $notification->notification_name ) {
return;
}
Models\Notification::addNotification( [
'slug' => uniqid(),
'notification_name' => 'sitemap-static-files',
'title' => __( 'Static sitemap files detected', 'all-in-one-seo-pack' ),
'content' => sprintf(
// Translators: 1 - The plugin short name ("AIOSEO"), 2 - Same as previous.
__( '%1$s has detected static sitemap files in the root folder of your WordPress installation.
As long as these files are present, %2$s is not able to dynamically generate your sitemap.', 'all-in-one-seo-pack' ),
AIOSEO_PLUGIN_SHORT_NAME,
AIOSEO_PLUGIN_SHORT_NAME
),
'type' => 'error',
'level' => [ 'all' ],
'button1_label' => __( 'Delete Static Files', 'all-in-one-seo-pack' ),
'button1_action' => 'http://action#sitemap/delete-static-files',
'start' => gmdate( 'Y-m-d H:i:s' )
] );
}
/**
* Regenerates the static sitemap files when a post is updated.
*
* @since 4.0.0
*
* @param integer $postId The post ID.
* @return void
*/
public function regenerateOnUpdate( $postId ) {
if ( aioseo()->helpers->isValidPost( $postId ) ) {
$this->scheduleRegeneration();
}
}
/**
* Schedules an action to regenerate the static sitemap files.
*
* @since 4.0.5
*
* @return void
*/
public function scheduleRegeneration() {
try {
if (
! aioseo()->options->deprecated->sitemap->general->advancedSettings->dynamic &&
! as_next_scheduled_action( 'aioseo_static_sitemap_regeneration' )
) {
as_schedule_single_action( time() + 60, 'aioseo_static_sitemap_regeneration', [], 'aioseo' );
}
} catch ( \Exception $e ) {
// Do nothing.
}
}
/**
* Regenerates the static sitemap files.
*
* @since 4.0.5
*
* @return void
*/
public function regenerateStaticSitemap() {
aioseo()->sitemap->file->generate();
}
/**
* Generates the requested sitemap.
*
* @since 4.0.0
*
* @return void
*/
public function generate() {
if ( empty( $this->type ) ) {
return;
}
// This is a hack to prevent WordPress from running it's default stuff during our processing.
global $wp_query; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
$wp_query->is_home = false; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
// This prevents the sitemap from including terms twice when WPML is active.
if ( class_exists( 'SitePress' ) ) {
global $sitepress_settings; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
// Before building the sitemap make sure links aren't translated.
// The setting should not be updated in the DB.
$sitepress_settings['auto_adjust_ids'] = 0; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
}
// If requested sitemap should be static and doesn't exist, then generate it.
// We'll then serve it dynamically for the current request so that we don't serve a blank page.
$this->doesFileExist();
$options = aioseo()->options->noConflict();
if ( ! $options->sitemap->{aioseo()->sitemap->type}->enable ) {
aioseo()->helpers->notFoundPage();
return;
}
$entries = aioseo()->sitemap->content->get();
$total = aioseo()->sitemap->content->getTotal();
if ( ! $entries ) {
$addonsEntries = aioseo()->addons->doAddonFunction( 'content', 'get' );
$addonTotals = aioseo()->addons->doAddonFunction( 'content', 'getTotal' );
foreach ( $addonsEntries as $addonSlug => $addonEntries ) {
if ( ! empty( $addonEntries ) ) {
$entries = $addonEntries;
$total = ! empty( $addonTotals[ $addonSlug ] ) ? $addonTotals[ $addonSlug ] : count( $entries );
break;
}
}
}
if ( 0 === $total && empty( $entries ) ) {
status_header( 404 );
}
$this->xsl->saveXslData(
aioseo()->sitemap->requestParser->slug,
$entries,
$total
);
$this->headers();
aioseo()->sitemap->output->output( $entries );
aioseo()->addons->doAddonFunction( 'output', 'output', [ $entries ] );
exit;
}
/**
* Checks if static file should be served and generates it if it doesn't exist.
*
* This essentially acts as a safety net in case a file doesn't exist yet or has been deleted.
*
* @since 4.0.0
*
* @return void
*/
protected function doesFileExist() {
aioseo()->addons->doAddonFunction( 'sitemap', 'doesFileExist' );
if (
'general' !== $this->type ||
! aioseo()->options->sitemap->general->advancedSettings->enable ||
! in_array( 'staticSitemap', aioseo()->internalOptions->internal->deprecatedOptions, true ) ||
aioseo()->options->sitemap->general->advancedSettings->dynamic
) {
return;
}
require_once ABSPATH . 'wp-admin/includes/file.php';
if ( isset( $_SERVER['REQUEST_URI'] ) && ! aioseo()->core->fs->exists( get_home_path() . sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ) {
$this->scheduleRegeneration();
}
}
/**
* Sets the HTTP headers for the sitemap.
*
* @since 4.0.0
*
* @return void
*/
public function headers() {
$charset = aioseo()->helpers->getCharset();
header( "Content-Type: text/xml; charset=$charset", true );
header( 'X-Robots-Tag: noindex, follow', true );
}
/**
* Registers an active sitemap addon and its classes.
* NOTE: This is deprecated and only there for users who already were using the previous sitemap addons version.
*
* @final 4.2.7
* @since 4.0.0
*
* @return void
*/
public function addAddon() {}
}
Fatal error: Uncaught Error: Class 'AIOSEO\Plugin\Common\Sitemap\Sitemap' not found in /home/kordian1/domains/klekociaki.pl/public_html/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php:319
Stack trace:
#0 /home/kordian1/domains/klekociaki.pl/public_html/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php(106): AIOSEO\Plugin\AIOSEO->load()
#1 /home/kordian1/domains/klekociaki.pl/public_html/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php(85): AIOSEO\Plugin\AIOSEO->init()
#2 /home/kordian1/domains/klekociaki.pl/public_html/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php(398): AIOSEO\Plugin\AIOSEO::instance()
#3 /home/kordian1/domains/klekociaki.pl/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php(98): aioseo()
#4 /home/kordian1/domains/klekociaki.pl/public_html/wp-settings.php(545): include_once('/home/kordian1/...')
#5 /home/kordian1/domains/klekociaki.pl/public_html/wp-config.php(81): require_once('/home/kordian1/...')
#6 /home/kordian1/domains/klekociaki.pl/public_html/wp-load. in /home/kordian1/domains/klekociaki.pl/public_html/wp-content/plugins/all-in-one-seo-pack/app/AIOSEO.php on line 319