array( 'no_css_minify' => 'Do not minify CSS', 'no_css_optimize' => 'Do not combine CSS', 'no_js_minify' => 'Do not minify JS', 'no_js_optimize' => 'Do not combine JS', 'no_assets_settings' => 'Do not apply any CSS & JavaScript settings (including preloading, "async", "defer" & any unload rules)', 'no_wpacu_load' => 'Do not load %s on this page' ) ); /** * Overview constructor. */ public function __construct() { // The code initiated in this function is relevant only in the "Overview" page if (Misc::getVar('request', 'page') !== WPACU_PLUGIN_ID . '_overview') { return; } $this->data['page_options_to_text']['no_wpacu_load'] = sprintf(__($this->data['page_options_to_text']['no_wpacu_load'], 'wp-asset-clean-up'), WPACU_PLUGIN_TITLE); // [START] Clear load exceptions for a handle $transientName = 'wpacu_load_exceptions_cleared'; if ( isset( $_POST['wpacu_action'], $_POST['wpacu_handle'], $_POST['wpacu_asset_type'] ) && ( $wpacuAction = $_POST['wpacu_action'] ) && ( $wpacuHandle = $_POST['wpacu_handle'] ) && ( $wpacuAssetType = $_POST['wpacu_asset_type'] ) && $wpacuAction === 'clear_load_exceptions' ) { check_admin_referer('wpacu_clear_load_exceptions', 'wpacu_clear_load_exceptions_nonce'); Maintenance::removeAllLoadExceptionsFor($wpacuHandle, $wpacuAssetType); set_transient($transientName, array('handle' => $wpacuHandle, 'type' => $wpacuAssetType)); wp_redirect(admin_url('admin.php?page=wpassetcleanup_overview&wpacu_load_exceptions_cleared=1')); exit(); } if (Misc::getVar('get', 'wpacu_load_exceptions_cleared') && $transientData = get_transient($transientName)) { add_action('admin_notices', static function() use ($transientData, $transientName) { $wpacuAssetTypeToPrint = ($transientData['type'] === 'styles') ? 'CSS' : 'JavaScript'; ?>

%s` %s handle have been removed.', 'wp-asset-clean-up'), $transientData['handle'], $wpacuAssetTypeToPrint); ?>

$wpacuHandle, 'type' => $wpacuAssetType)); wp_redirect(admin_url('admin.php?page=wpassetcleanup_overview&wpacu_all_rules_cleared=1')); exit(); } if (Misc::getVar('get', 'wpacu_all_rules_cleared') && $transientData = get_transient($transientName)) { add_action('admin_notices', static function() use ($transientData, $transientName) { $wpacuAssetTypeToPrint = ($transientData['type'] === 'styles') ? 'CSS' : 'JavaScript'; ?>

%s` %s handle.', 'wp-asset-clean-up'), $transientData['handle'], $wpacuAssetTypeToPrint); ?>

$wpacuHandle, 'type' => $wpacuAssetType)); wp_redirect(admin_url('admin.php?page=wpassetcleanup_overview&wpacu_all_redundant_unload_rules_cleared=1')); exit(); } if (Misc::getVar('get', 'wpacu_all_redundant_unload_rules_cleared') && $transientData = get_transient($transientName)) { add_action('admin_notices', static function() use ($transientData, $transientName) { $wpacuAssetTypeToPrint = ($transientData['type'] === 'styles') ? 'CSS' : 'JavaScript'; ?>

%s` %s handle, leaving the only one relevant: `site-wide (everywhere)`.', 'wp-asset-clean-up'), $transientData['handle'], $wpacuAssetTypeToPrint); ?>

$assetData) { if (isset($assetData['attributes']) && ! empty($assetData['attributes'])) { // async, defer attributes $allHandles['scripts'][ $assetHandle ]['script_attrs']['home_page'] = $assetData['attributes']; } } } // Do not apply "async", "defer" exceptions (e.g. "defer" is applied site-wide, except the home page) if (isset($wpacuFrontPageDataArray['scripts_attributes_no_load']) && ! empty($wpacuFrontPageDataArray['scripts_attributes_no_load'])) { foreach ($wpacuFrontPageDataArray['scripts_attributes_no_load'] as $assetHandle => $assetAttrsNoLoad) { $allHandles['scripts'][$assetHandle]['attrs_no_load']['home_page'] = $assetAttrsNoLoad; } } } // Custom Post Type Load Exceptions // e.g. the asset could be unloaded site-wide and loaded on all pages belonging to a post type such as WooCommerce single 'product' page $wpacuPostTypeLoadExceptions = get_option(WPACU_PLUGIN_ID . '_post_type_load_exceptions'); if ($wpacuPostTypeLoadExceptions) { $wpacuPostTypeLoadExceptionsArray = @json_decode( $wpacuPostTypeLoadExceptions, ARRAY_A ); foreach ( $wpacuPostTypeLoadExceptionsArray as $wpacuPostType => $dbAssetHandles ) { foreach ( array('styles', 'scripts') as $assetType ) { if (isset($dbAssetHandles[$assetType]) && $dbAssetHandles[$assetType]) { foreach ($dbAssetHandles[$assetType] as $assetHandle => $assetValue) { if ($assetValue !== '') { $allHandles[ $assetType ][ $assetHandle ]['load_exception_post_type'][] = $wpacuPostType; } } } } } } // Get all Asset CleanUp (Pro) meta keys from all WordPress meta tables where it can be possibly used foreach (array($wpdb->postmeta, $wpdb->termmeta, $wpdb->usermeta) as $tableName) { $wpacuGetValuesQuery = <<get_results( $wpacuGetValuesQuery, ARRAY_A ); foreach ( $wpacuMetaData as $wpacuValues ) { $decodedValues = @json_decode( $wpacuValues['meta_value'], ARRAY_A ); if ( empty( $decodedValues ) ) { continue; } // $refId is the ID for the targeted element from the meta table which could be: post, taxonomy ID or user ID if ($tableName === $wpdb->postmeta) { $refId = $wpacuValues['post_id']; $refKey = 'post'; } elseif ($tableName === $wpdb->termmeta) { $refId = $wpacuValues['term_id']; $refKey = 'term'; } else { $refId = $wpacuValues['user_id']; $refKey = 'user'; } if ( $wpacuValues['meta_key'] === '_' . $wpacuPluginId . '_no_load' ) { foreach ( $decodedValues as $assetType => $assetHandles ) { foreach ( $assetHandles as $assetHandle ) { // Unload it on this page $allHandles[ $assetType ][ $assetHandle ]['unload_on_this_page'][$refKey][] = $refId; } } } elseif ( $wpacuValues['meta_key'] === '_' . $wpacuPluginId . '_load_exceptions' ) { foreach ( $decodedValues as $assetType => $assetHandles ) { foreach ( $assetHandles as $assetHandle ) { // If bulk unloaded, 'Load it on this page' $allHandles[ $assetType ][ $assetHandle ]['load_exception_on_this_page'][$refKey][] = $refId; } } } elseif ( $wpacuValues['meta_key'] === '_' . $wpacuPluginId . '_data' ) { if ( isset( $decodedValues['scripts'] ) && ! empty( $decodedValues['scripts'] ) ) { foreach ( $decodedValues['scripts'] as $assetHandle => $scriptData ) { if ( isset( $scriptData['attributes'] ) && ! empty( $scriptData['attributes'] ) ) { // async, defer attributes $allHandles['scripts'][ $assetHandle ]['script_attrs'][$refKey][$refId] = $scriptData['attributes']; } } } if ( isset( $decodedValues['scripts_attributes_no_load'] ) && ! empty( $decodedValues['scripts_attributes_no_load'] ) ) { foreach ( $decodedValues['scripts_attributes_no_load'] as $assetHandle => $scriptNoLoadAttrs ) { $allHandles['scripts'][$assetHandle]['attrs_no_load'][$refKey][$refId] = $scriptNoLoadAttrs; } } } } } /* * Global (Site-wide) Rules: Preloading, Position changing, Unload via RegEx, etc. */ $wpacuGlobalData = get_option(WPACU_PLUGIN_ID . '_global_data'); $wpacuGlobalDataArray = @json_decode($wpacuGlobalData, ARRAY_A); $allPossibleDataTypes = array( 'load_it_logged_in', 'preloads', 'notes', 'ignore_child', 'everywhere' ); foreach (array('styles', 'scripts') as $assetType) { if ($assetType === 'scripts' && isset( $wpacuGlobalDataArray[ $assetType ])) { foreach (array_keys($wpacuGlobalDataArray[ $assetType ]) as $dataType) { if ( strpos( $dataType, 'custom_post_type_archive_' ) !== false ) { $allPossibleDataTypes[] = $dataType; } } } foreach ($allPossibleDataTypes as $dataType) { if ( isset( $wpacuGlobalDataArray[ $assetType ][$dataType] ) && ! empty( $wpacuGlobalDataArray[ $assetType ][$dataType] ) ) { foreach ( $wpacuGlobalDataArray[ $assetType ][$dataType] as $assetHandle => $dataValue ) { if ($dataType === 'everywhere' && $assetType === 'scripts' && isset($dataValue['attributes'])) { if (count($dataValue['attributes']) === 0) { continue; } // async/defer applied site-wide $allHandles[ $assetType ][ $assetHandle ]['script_site_wide_attrs'] = $dataValue['attributes']; } elseif ($dataType !== 'everywhere' && $assetType === 'scripts' && isset($dataValue['attributes'])) { // For date, 404, search pages $allHandles[ $assetType ][ $assetHandle ]['script_attrs'][$dataType] = $dataValue['attributes']; } else { $allHandles[ $assetType ][ $assetHandle ][ $dataType ] = $dataValue; } } } } foreach (array('unload_regex', 'load_regex') as $unloadType) { if (isset($wpacuGlobalDataArray[$assetType][$unloadType]) && ! empty($wpacuGlobalDataArray[$assetType][$unloadType])) { foreach ($wpacuGlobalDataArray[$assetType][$unloadType] as $assetHandle => $unloadData) { if (isset($unloadData['enable'], $unloadData['value']) && $unloadData['enable'] && $unloadData['value']) { $allHandles[ $assetType ][ $assetHandle ][$unloadType] = $unloadData['value']; } } } } } // Do not apply "async", "defer" exceptions (e.g. "defer" is applied site-wide, except the 404, search, date) if (isset($wpacuGlobalDataArray['scripts_attributes_no_load']) && ! empty($wpacuGlobalDataArray['scripts_attributes_no_load'])) { foreach ($wpacuGlobalDataArray['scripts_attributes_no_load'] as $unloadedIn => $unloadedInValues) { foreach ($unloadedInValues as $assetHandle => $assetAttrsNoLoad) { $allHandles['scripts'][$assetHandle]['attrs_no_load'][$unloadedIn] = $assetAttrsNoLoad; } } } /* * Unload Site-Wide (Everywhere) Rules: Preloading, Position changing, Unload via RegEx, etc. */ $wpacuGlobalUnloadData = get_option(WPACU_PLUGIN_ID . '_global_unload'); $wpacuGlobalUnloadDataArray = @json_decode($wpacuGlobalUnloadData, ARRAY_A); foreach (array('styles', 'scripts') as $assetType) { if (isset($wpacuGlobalUnloadDataArray[$assetType]) && ! empty($wpacuGlobalUnloadDataArray[$assetType])) { foreach ($wpacuGlobalUnloadDataArray[$assetType] as $assetHandle) { $allHandles[ $assetType ][ $assetHandle ]['unload_site_wide'] = 1; } } } /* * Bulk Unload Rules - post, page, custom post type (e.g. product, download), taxonomy (e.g. category), 404, date, archive (for custom post type) with pagination etc. */ $wpacuBulkUnloadData = get_option(WPACU_PLUGIN_ID . '_bulk_unload'); $wpacuBulkUnloadDataArray = @json_decode($wpacuBulkUnloadData, ARRAY_A); foreach (array('styles', 'scripts') as $assetType) { if (isset($wpacuBulkUnloadDataArray[$assetType]) && ! empty($wpacuBulkUnloadDataArray[$assetType])) { foreach ($wpacuBulkUnloadDataArray[$assetType] as $unloadBulkType => $unloadBulkValues) { if (empty($unloadBulkValues)) { continue; } // $unloadBulkType could be 'post_type', 'post_type_via_tax', 'date', '404', 'taxonomy', 'search', 'custom_post_type_archive_[post_type_name_here]', etc. if ($unloadBulkType === 'post_type') { foreach ($unloadBulkValues as $postType => $assetHandles) { foreach ($assetHandles as $assetHandle) { $allHandles[ $assetType ][ $assetHandle ]['unload_bulk'][$unloadBulkType][] = $postType; } } } } } } if (isset($allHandles['styles'])) { ksort($allHandles['styles']); } if (isset($allHandles['scripts'])) { ksort($allHandles['scripts']); } return $allHandles; } /** * */ public function pageOverview() { $allHandles = self::handlesWithAtLeastOneRule(); $this->data['handles'] = $allHandles; if (isset($this->data['handles']['styles']) || isset($this->data['handles']['scripts'])) { // Only fetch the assets information if there is something to be shown // to avoid useless queries to the database $this->data['assets_info'] = Main::getHandlesInfo(); } // [PAGE OPTIONS] // 1) For posts, pages and custom post types global $wpdb; $this->data['page_options_results'] = array(); $pageOptionsResults = $wpdb->get_results('SELECT post_id, meta_value FROM `'.$wpdb->postmeta."` WHERE meta_key='_".WPACU_PLUGIN_ID."_page_options' && meta_value !=''", ARRAY_A); foreach ($pageOptionsResults as $pageOptionResult) { $postId = $pageOptionResult['post_id']; $optionsDecoded = @json_decode( $pageOptionResult['meta_value'], ARRAY_A ); if (is_array($optionsDecoded) && ! empty($optionsDecoded)) { $this->data['page_options_results']['posts'][] = array('post_id' => $postId, 'options' => $optionsDecoded); } } // 2) For the homepage set as latest posts (e.g. not a single page set as the front page, this is included in the previous check) $globalPageOptions = get_option(WPACU_PLUGIN_ID . '_global_data'); if ($globalPageOptions) { $globalPageOptionsList = @json_decode( $globalPageOptions, true ); if ( isset( $globalPageOptionsList['page_options']['homepage'] ) && ! empty( $globalPageOptionsList['page_options']['homepage'] ) ) { $this->data['page_options_results']['homepage'] = array('options' => $globalPageOptionsList['page_options']['homepage']); } } // [/PAGE OPTIONS] Main::instance()->parseTemplate('admin-page-overview', $this->data, true); } /** * @param $handle * @param $assetType * @param $data * @param string $for ('default': bulk unloads, regex unloads) */ public static function renderHandleTd($handle, $assetType, $data, $for = 'default') { global $wp_version; $handleData = ''; $isCoreFile = false; // default if (isset($data['handles'][$assetType][$handle]) && $data['handles'][$assetType][$handle]) { $handleData = $data['handles'][$assetType][$handle]; } if ( $for === 'default' ) { // Show the original "src" and "ver, not the altered one // (in case filters such as "wpacu_{$handle}_(css|js)_handle_obj" were used to load alternative versions of the file, depending on the situation) $srcKey = isset($data['assets_info'][ $assetType ][ $handle ]['src_origin']) ? 'src_origin' : 'src'; $verKey = isset($data['assets_info'][ $assetType ][ $handle ]['ver_origin']) ? 'ver_origin' : 'ver'; $src = (isset( $data['assets_info'][ $assetType ][ $handle ][$srcKey] ) && $data['assets_info'][ $assetType ][ $handle ][$srcKey]) ? $data['assets_info'][ $assetType ][ $handle ][$srcKey] : false; $isExternalSrc = true; if (Misc::getLocalSrc($src) || strpos($src, '/?') !== false // Dynamic Local URL || strpos(str_replace(site_url(), '', $src), '?') === 0 // Starts with ? right after the site url (it's a local URL) ) { $isExternalSrc = false; $isCoreFile = Misc::isCoreFile($data['assets_info'][$assetType][$handle]); } if (strpos($src, '/') === 0 && strpos($src, '//') !== 0) { $src = site_url() . $src; } if (strpos($src, '/wp-content/plugins/') !== false) { $src = str_replace('/wp-content/plugins/', '/'.Misc::getPluginsDir().'/', $src); } $ver = $wp_version; // default if (isset($data['assets_info'][ $assetType ][ $handle ][$verKey] ) && $data['assets_info'][ $assetType ][ $handle ][$verKey] ) { $ver = is_array($data['assets_info'][ $assetType ][ $handle ][$verKey] ) ? implode(',', $data['assets_info'][ $assetType ][ $handle ][$verKey] ) : $data['assets_info'][ $assetType ][ $handle ][$verKey] ; } ?> v "Preloads" $preloadedStatus = isset($data['assets_info'][ $assetType ][ $handle ]['preloaded_status']) ? $data['assets_info'][ $assetType ][ $handle ]['preloaded_status'] : false; if ($preloadedStatus === 'async') { echo ' ('.$preloadedStatus.')'; } // [/wpacu_pro] $handleExtras = array(); // If called from "Overview" if (isset($handleData['preloads']) && $handleData['preloads']) { $handleExtras[0] = 'Preloaded'; if ($handleData['preloads'] === 'async') { $handleExtras[0] .= ' (async)'; } } if (isset($handleData['positions']) && $handleData['positions']) { $handleExtras[1] = 'Moved to <'.esc_html($handleData['positions']).'>'; } /* * 1) Per page (homepage, a post, a category, etc.) * Async, Defer attributes */ // Per home page if (isset($handleData['script_attrs']['home_page']) && ! empty($handleData['script_attrs']['home_page'])) { ksort($handleData['script_attrs']['home_page']); $handleExtras[2] = 'Homepage attributes: '.esc_html(implode(', ', $handleData['script_attrs']['home_page'])).''; } // Date archive pages if (isset($handleData['script_attrs']['date']) && ! empty($handleData['script_attrs']['date'])) { ksort($handleData['script_attrs']['date']); $handleExtras[22] = 'Date archive attributes: '.esc_html(implode(', ', $handleData['script_attrs']['date'])).''; } // 404 page if (isset($handleData['script_attrs']['404']) && ! empty($handleData['script_attrs']['404'])) { ksort($handleData['script_attrs']['404']); $handleExtras[23] = '404 Not Found attributes: '.esc_html(implode(', ', $handleData['script_attrs']['404'])).''; } // Search results page if (isset($handleData['script_attrs']['search']) && ! empty($handleData['script_attrs']['search'])) { ksort($handleData['script_attrs']['search']); $handleExtras[24] = '404 Not Found attributes: '.esc_html(implode(', ', $handleData['script_attrs']['search'])).''; } // Archive page for Custom Post Type (those created via theme editing or via plugins such as "Custom Post Type UI") $scriptAttrsStr = (isset($handleData['script_attrs']) && is_array($handleData['script_attrs'])) ? implode('', array_keys($handleData['script_attrs'])) : ''; if (strpos($scriptAttrsStr, 'custom_post_type_archive_') !== false) { $keyNo = 225; foreach ($handleData['script_attrs'] as $scriptAttrsKey => $scriptAttrsValue) { $customPostTypeName = str_replace('custom_post_type_archive_', '', $scriptAttrsKey); $handleExtras[$keyNo] = 'Archive custom post type page "'.$customPostTypeName.'" attributes: '.esc_html(implode(', ', $handleData['script_attrs'][$scriptAttrsKey])).''; $keyNo++; } } // Per post page if (isset($handleData['script_attrs']['post']) && ! empty($handleData['script_attrs']['post'])) { $handleExtras[3] = 'Per post attributes: '; $postsList = ''; ksort($handleData['script_attrs']['post']); foreach ($handleData['script_attrs']['post'] as $postId => $attrList) { $postData = get_post($postId); if (isset($postData->post_title, $postData->post_type)) { $postTitle = $postData->post_title; $postType = $postData->post_type; $postsList .= '' . $postId . ' - ' . esc_html( implode( ', ', $attrList ) ) . ' / '; } else { $postsList .= ''.$postId.' / '; } } $handleExtras[3] .= rtrim($postsList, ' / '); } // User archive page (specific author) if (isset($handleData['script_attrs']['user']) && ! empty($handleData['script_attrs']['user'])) { $handleExtras[31] = 'Per author page attributes: '; $authorPagesList = ''; ksort($handleData['script_attrs']['user']); foreach ($handleData['script_attrs']['user'] as $userId => $attrList) { $authorLink = get_author_posts_url(get_the_author_meta('ID', $userId)); $authorRelLink = str_replace(site_url(), '', $authorLink); $authorPagesList .= ''.$authorRelLink.' - '.implode(', ', $attrList).' | '; } $authorPagesList = trim($authorPagesList, ' | '); $handleExtras[31] .= rtrim($authorPagesList, ' / '); } // Per category page if (isset($handleData['script_attrs']['term']) && ! empty($handleData['script_attrs']['term'])) { $handleExtras[33] = 'Per taxonomy attributes: '; $taxPagesList = ''; foreach ($handleData['script_attrs']['term'] as $termId => $attrList) { $taxData = term_exists( (int)$termId ) ? get_term( $termId ) : false; if ( ! $taxData || ( isset($taxData->errors['invalid_taxonomy']) && ! empty($taxData->errors['invalid_taxonomy']) ) ) { $taxPagesList .= 'Error: Taxonomy with ID '.$termId.' does not exist anymore (rule does not apply) | '; } else { $taxonomy = $taxData->taxonomy; $termLink = get_term_link( $taxData, $taxonomy ); $termRelLink = str_replace( site_url(), '', $termLink ); $taxPagesList .= '' . esc_html($termRelLink) . ' - ' . esc_html(implode( ', ', $attrList )) . ' | '; } } $taxPagesList = trim($taxPagesList, ' | '); $handleExtras[33] .= rtrim($taxPagesList, ' / '); } /* * 2) Site-wide type * Any async, defer site-wide attributes? Exceptions will be also shown */ if (isset($handleData['script_site_wide_attrs'])) { $handleExtras[4] = 'Site-wide attributes: '; foreach ( $handleData['script_site_wide_attrs'] as $attrValue ) { $handleExtras[4] .= '' . esc_html($attrValue) . ''; // Are there any exceptions? e.g. async, defer unloaded site-wide, but loaded on the homepage if ( isset( $handleData['attrs_no_load'] ) && ! empty( $handleData['attrs_no_load'] ) ) { // $attrSetIn could be 'home_page', 'term', 'user', 'date', '404', 'search' $handleExtras[4] .= ' (with exceptions from applying added for these pages: '; $handleAttrsExceptionsList = ''; foreach ( $handleData['attrs_no_load'] as $attrSetIn => $attrSetValues ) { if ( $attrSetIn === 'home_page' && in_array($attrValue, $attrSetValues) ) { $handleAttrsExceptionsList .= ' Homepage, '; } if ( $attrSetIn === 'date' && in_array($attrValue, $attrSetValues) ) { $handleAttrsExceptionsList .= ' Date Archive, '; } if ( (int)$attrSetIn === 404 && in_array($attrValue, $attrSetValues) ) { $handleAttrsExceptionsList .= ' 404 Not Found, '; } if ( $attrSetIn === 'search' && in_array($attrValue, $attrSetValues) ) { $handleAttrsExceptionsList .= ' Search Results, '; } if (strpos($attrSetIn, 'custom_post_type_archive_') !== false) { $customPostTypeName = str_replace('custom_post_type_archive_', '', $attrSetIn); $handleAttrsExceptionsList .= ' Archive "'.$customPostTypeName.'" custom post type, '; } // Post pages such as posts, pages, product (WooCommerce), download (Easy Digital Downloads), etc. if ( $attrSetIn === 'post' ) { $postPagesList = ''; foreach ( $attrSetValues as $postId => $attrSetValuesTwo ) { if (! in_array($attrValue, $attrSetValuesTwo)) { continue; } $postData = get_post($postId); if (isset($postData->post_title, $postData->post_type)) { $postTitle = $postData->post_title; $postType = $postData->post_type; $postPagesList .= '' . $postId . ' | '; } else { $postPagesList .= ''.$postId.' N/A (post deleted) | '; } } if ($postPagesList) { $postPagesList = trim( $postPagesList, ' | ' ).', '; $handleAttrsExceptionsList .= $postPagesList; } } // Taxonomy pages such as category archive, product category in WooCommerce if ( $attrSetIn === 'term' ) { $taxPagesList = ''; foreach ( $attrSetValues as $termId => $attrSetValuesTwo ) { if (! in_array($attrValue, $attrSetValuesTwo)) { continue; } $taxData = term_exists((int)$termId) ? get_term( $termId ) : false; if ( ! $taxData || (isset($taxData->errors['invalid_taxonomy']) && ! empty($taxData->errors['invalid_taxonomy'])) ) { $taxPagesList .= 'Error: Taxonomy with ID '.(int)$termId.' does not exist anymore (rule does not apply) | '; } else { $taxonomy = $taxData->taxonomy; $termLink = get_term_link( $taxData, $taxonomy ); $termRelLink = str_replace( site_url(), '', $termLink ); $taxPagesList .= '' . esc_url($termRelLink) . ' | '; } } if ($taxPagesList) { $taxPagesList = trim( $taxPagesList, ' | ' ) . ', '; $handleAttrsExceptionsList .= $taxPagesList; } } // Author archive pages (e.g. /author/john/page/2/) if ($attrSetIn === 'user') { $authorPagesList = ''; foreach ( $attrSetValues as $userId => $attrSetValuesTwo ) { if (! in_array($attrValue, $attrSetValuesTwo)) { continue; } $authorLink = get_author_posts_url(get_the_author_meta('ID', $userId)); $authorRelLink = str_replace(site_url(), '', $authorLink); $authorPagesList .= ''.esc_html($authorRelLink).' | '; } if ($authorPagesList) { $authorPagesList = trim( $authorPagesList, ' | ' ).', '; $handleAttrsExceptionsList .= $authorPagesList; } } } $handleAttrsExceptionsList = trim($handleAttrsExceptionsList, ', '); $handleExtras[4] .= $handleAttrsExceptionsList; $handleExtras[4] .= '), '; } $handleExtras[4] .= ', '; } $handleExtras[4] = trim($handleExtras[4], ', '); } if (! empty($handleExtras)) { echo '' . implode( ' / ', $handleExtras ) . ''; } if ( $src ) { $verDb = (isset($data['assets_info'][ $assetType ][ $handle ][$verKey]) && $data['assets_info'][ $assetType ][ $handle ][$verKey]) ? $data['assets_info'][ $assetType ][ $handle ][$verKey] : false; $appendAfterSrc = (strpos($src, '?') === false) ? '?' : '&'; if ( $verDb ) { if (is_array($verDb)) { $appendAfterSrc .= http_build_query(array('ver' => $data['assets_info'][ $assetType ][ $handle ][$verKey])); } else { $appendAfterSrc .= 'ver='.$ver; } } else { $appendAfterSrc .= 'ver='.$wp_version; // default } ?>
data-wpacu-external-source="" href="" target="_blank">
Note: The plugin `` seems to be inactive, thus any rules set are also inactive & irrelevant, unless you re-activate the plugin. Note: The theme `` seems to be inactive, thus any rules set are also inactive & irrelevant, unless you re-activate the theme.
Note:
Unloaded site-wide (everywhere)'; $anyUnloadRule = true; } // Bulk unload (on all posts, categories, etc.) if (isset($handleData['unload_bulk'])) { $handleChangesOutput['bulk'] = ''; if (isset($handleData['unload_bulk']['post_type'])) { foreach ($handleData['unload_bulk']['post_type'] as $postType) { $textToShow = 'Unloaded on all pages of ' . $postType . ' post type'; $handleChangesOutput['bulk'] .= ' '.$textToShow.''. self::anyNoPostTypeEntriesMsg($postType).', '; $anyUnloadRule = true; } } $handleChangesOutput['bulk'] = rtrim($handleChangesOutput['bulk'], ', '); if (isset($handleChangesOutput['site_wide'])) { $handleChangesOutput['bulk'] .= ' * unnecessary, as it\'s already unloaded site-wide'; $hasRedundantUnloadRules = true; } } if (isset($handleData['unload_on_home_page']) && $handleData['unload_on_home_page']) { $handleChangesOutput['on_home_page'] = 'Unloaded on the homepage'; if (isset($handleChangesOutput['site_wide'])) { $handleChangesOutput['on_home_page'] .= ' * unnecessary, as it\'s already unloaded site-wide'; $hasRedundantUnloadRules = true; } $anyUnloadRule = true; } if (isset($handleData['load_exception_on_home_page']) && $handleData['load_exception_on_home_page']) { $handleChangesOutput['load_exception_on_home_page'] = 'Loaded (as an exception) on the homepage'; $anyLoadExceptionRule = true; } // On this page: post, page, custom post type if (isset($handleData['unload_on_this_page']['post'])) { $handleChangesOutput['on_this_post'] = 'Unloaded in the following posts: '; $postsList = ''; sort($handleData['unload_on_this_page']['post']); foreach ($handleData['unload_on_this_page']['post'] as $postId) { $postData = get_post($postId); if (isset($postData->post_title, $postData->post_type)) { $postTitle = $postData->post_title; $postType = $postData->post_type; $postStatus = $postData->post_status; $postsList .= '' . $postId . ''; if ($postStatus === 'trash') { $postsList .= ' '; } $postsList .= ', '; } else { $postsList .= ''.$postId.', '; } } $handleChangesOutput['on_this_post'] .= rtrim($postsList, ', '); if (isset($handleChangesOutput['site_wide'])) { $handleChangesOutput['on_this_post'] .= ' * unnecessary, as it\'s already unloaded site-wide'; $hasRedundantUnloadRules = true; } $anyUnloadRule = true; } // Maybe it has other unload rules on top of the site-wide one (which covers everything) if ($hasRedundantUnloadRules) { $uniqueDelimiter = md5($handleData['handle'] . $handleData['asset_type']); $clearRedundantUnloadRulesConfirmMsg = sprintf(esc_js(__('This will clear all redundant (useless) unload rules for the `%s` CSS handle as there\'s already a site-wide rule applied.', 'wp-asset-clean-up')), $handleData['handle']) . '\n\n' . esc_js(__('Click `OK` to confirm the action', 'wp-asset-clean-up')).'!'; $wpacuNonceField = wp_nonce_field('wpacu_clear_all_redundant_rules', 'wpacu_clear_all_redundant_rules_nonce'); $clearRedundantUnloadRulesArea = << {$wpacuNonceField} HTML; $handleChangesOutput['has_redundant_unload_rules'] = $clearRedundantUnloadRulesArea; } if (isset($handleData['ignore_child']) && $handleData['ignore_child']) { $handleChangesOutput['ignore_child'] = 'If unloaded by any rule, ignore dependencies and keep its "children" loaded'; } // Load exceptions? Per page, via RegEx, if user is logged-in if (isset($handleData['load_exception_on_this_page']['post'])) { $handleChangesOutput['load_exception_on_this_post'] = 'Loaded (as an exception) in the following posts: '; $postsList = ''; sort($handleData['load_exception_on_this_page']['post']); foreach ($handleData['load_exception_on_this_page']['post'] as $postId) { $postData = get_post($postId); if (isset($postData->post_title, $postData->post_type)) { $postTitle = $postData->post_title; $postType = $postData->post_type; $postsList .= ''.$postId.', '; } else { $postsList .= ''.$postId.', '; } } $handleChangesOutput['load_exception_on_this_post'] .= rtrim($postsList, ', '); $anyLoadExceptionRule = true; } // e.g. Unloaded site-wide, but loaded on all 'product' (WooCommerce) pages if (isset($handleData['load_exception_post_type'])) { $handleChangesOutput['load_exception_post_type'] = 'Loaded (as an exception) in all pages of the following post types: '; $postTypesList = ''; sort($handleData['load_exception_post_type']); foreach ($handleData['load_exception_post_type'] as $postType) { $postTypesList .= ''.$postType.''.self::anyNoPostTypeEntriesMsg($postType).', '; } $handleChangesOutput['load_exception_post_type'] .= rtrim($postTypesList, ', '); $anyLoadExceptionRule = true; } if (isset($handleData['load_it_logged_in']) && $handleData['load_it_logged_in']) { if ($anyLoadExceptionRule) { $textToShow = ' or if the user is logged-in'; } else { $textToShow = 'Loaded (as an exception) if the user is logged-in'; } $handleChangesOutput['load_it_logged_in'] = $textToShow; $anyLoadExceptionRule = true; } // Since more than one load exception rule is set, merge them on the same row to save space and avoid duplicated words if (isset($handleChangesOutput['load_exception_on_this_post'], $handleChangesOutput['load_exception_regex'])) { $handleChangesOutput['load_exception_all'] = $handleChangesOutput['load_exception_on_this_post'] . $handleChangesOutput['load_exception_regex']; unset($handleChangesOutput['load_exception_on_this_post'], $handleChangesOutput['load_exception_regex']); } if (! $anyUnloadRule && $anyLoadExceptionRule) { $handleType = ($handleData['asset_type'] === 'styles') ? 'CSS' : 'JS'; $clearLoadExceptionsConfirmMsg = sprintf( esc_attr(__('This will clear all load exceptions for the `%s` %s handle', 'wp-asset-clean-up')), $handleData['handle'], $handleType).'.' . '\n\n' . esc_js(__('Click `OK` to confirm the action', 'wp-asset-clean-up')).'!'; $wpacuNonceField = wp_nonce_field('wpacu_clear_load_exceptions', 'wpacu_clear_load_exceptions_nonce'); $uniqueDelimiter = md5($handleData['handle'].$handleData['asset_type']); $clearLoadExceptionsArea = << {$wpacuNonceField} HTML; $handleChangesOutput['load_exception_notice'] = '
Note: Although a load exception rule is added, it is not relevant as there are no rules that would work together with it (e.g. unloaded site-wide, on all posts). This exception can be removed as the file is loaded anyway in all pages. '. ' '.$clearLoadExceptionsArea.'
'; } return $handleChangesOutput; } /** * @param $postType * * @return string */ public static function anyNoPostTypeEntriesMsg($postType) { $appendAfter = ''; $postTypeStatus = Misc::isValidPostType($postType); if ( ! $postTypeStatus['has_records'] ) { $appendAfter = ' '; } return $appendAfter; } }