wpacuFor = sanitize_text_field(Misc::getVar('request', 'wpacu_for', $this->wpacuFor)); $this->wpacuPostType = sanitize_text_field(Misc::getVar('request', 'wpacu_post_type', $this->wpacuPostType)); if (Misc::getVar('request', 'wpacu_update') == 1) { $this->update(); } } /** * @return array */ public function getCount() { $values = array(); if ($this->wpacuFor === 'everywhere') { $values = Main::instance()->getGlobalUnload(); } elseif ($this->wpacuFor === 'post_types') { $values = Main::instance()->getBulkUnload('post_type', $this->wpacuPostType); } if (isset($values['styles']) && ! empty($values['styles'])) { sort($values['styles']); } if (isset($values['scripts']) && ! empty($values['scripts'])) { sort($values['scripts']); } return $values; } /** * */ public function pageBulkUnloads() { $this->data['assets_info'] = Main::getHandlesInfo(); $this->data['for'] = $this->wpacuFor; if ($this->wpacuFor === 'post_types') { $this->data['post_type'] = $this->wpacuPostType; // Get All Post Types $postTypes = get_post_types(array('public' => true)); $this->data['post_types_list'] = Misc::filterPostTypesList( $postTypes ); } $this->data['values'] = $this->getCount(); $this->data['nonce_name'] = Update::NONCE_FIELD_NAME; $this->data['nonce_action'] = Update::NONCE_ACTION_NAME; $this->data['plugin_settings'] = Main::instance()->settings; Main::instance()->parseTemplate('admin-page-settings-bulk-changes', $this->data, true); } /** * @param $postTypes * * @return mixed */ public function filterPostTypesList($postTypes) { foreach ($postTypes as $postTypeKey => $postTypeValue) { // Exclude irrelevant custom post types if (in_array($postTypeKey, MetaBoxes::$noMetaBoxesForPostTypes)) { unset($postTypes[$postTypeKey]); } // Polish existing values if ($postTypeKey === 'product' && Misc::isPluginActive('woocommerce/woocommerce.php')) { $postTypes[$postTypeKey] = 'product ⟶ WooCommerce'; } } return $postTypes; } /** * @param $postTypesList * @param $currentPostType */ public static function buildPostTypesListDd($postTypesList, $currentPostType) { $ddList = array(); foreach ($postTypesList as $postTypeKey => $postTypeValue) { if (in_array($postTypeKey, array('post', 'page', 'attachment'))) { $ddList['WordPress (default)'][$postTypeKey] = $postTypeValue; } else { $ddList['Custom Post Types (Singular pages)'][$postTypeKey] = $postTypeValue; $list = Main::instance()->getBulkUnload('custom_post_type_archive_'.$postTypeKey); // At least one of the buckets ('styles' or 'scripts') needs to contain something if (! empty($list['styles']) || ! empty($list['scripts'])) { $ddList['Custom Post Types (Archive pages)'][ 'wpacu_custom_post_type_archive_'.$postTypeKey ] = $postTypeValue. ' (archive page)'; } } } ?> wpacuFor === 'everywhere') { $removed = $wpacuUpdate->removeEverywhereUnloads(array(), array(), 'post'); if ($removed) { add_action('wpacu_admin_notices', array($this, 'noticeGlobalsRemoved')); } } if ($this->wpacuFor === 'post_types') { $removed = $wpacuUpdate->removeBulkUnloads($this->wpacuPostType); if ($removed) { add_action('wpacu_admin_notices', array($this, 'noticePostTypesRemoved')); } } } /** * */ public function noticeGlobalsRemoved() { ?>

%s post type and they will now load in the pages/posts, unless you have other rules that would prevent them from loading.', 'wp-asset-clean-up'), $this->wpacuPostType ); ?>