Skip to content

Commit

Permalink
move cleanupHead to Html class
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefelipe committed Nov 14, 2020
1 parent a5d8885 commit f7ab8ac
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
9 changes: 6 additions & 3 deletions src/App/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ protected function htmlSettings()
if ($this->html->enable_rss) {
Html::enableRss();
}
if ($this->html->reset_body_classes) {
Html::resetBodyClasses();
}
if ($this->html->cleanup_head) {
Html::cleanupHead();
}
if ($this->html->disable_emojis) {
Html::disableEmojis();
}
Expand All @@ -208,9 +214,6 @@ protected function htmlSettings()
if ($this->html->disable_block_library) {
Html::disableBlockLibrary();
}
if ($this->html->reset_body_classes) {
Html::resetBodyClasses();
}
if ($this->html->disable_jetpack_includes) {
Html::disableJetpackIncludes();
}
Expand Down
21 changes: 3 additions & 18 deletions src/Services/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,15 @@ public function __construct()

// do not initialize when it is on WP admin
// nor when programatically loading WP
if (!is_admin() && (!defined('WP_USE_THEMES') || \WP_USE_THEMES)) {
if (!Wp::isAdminWithTheme()) {
$this->init();
}
}

protected function init()
{
add_action('wp', [$this, 'setDefaults'], 2);
add_action('wp_head', [$this, 'printAllTags'], 99);

$this->cleanupHead();
\add_action('wp', [$this, 'setDefaults'], 2);
\add_action('wp_head', [$this, 'printAllTags'], 99);
}

public function separator()
Expand Down Expand Up @@ -195,19 +193,6 @@ public function setDefaults()
//implement http://ogp.me/#type_article
}

public function cleanupHead()
{

remove_action('wp_head', 'wp_generator'); // WP version
remove_action('wp_head', 'wp_shortlink_wp_head'); // shortlinks
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); //prev/next urls
remove_action('wp_head', 'feed_links_extra', 3); // links to the extra feeds such as category feeds
remove_action('wp_head', 'feed_links', 2); // the links to the general feeds: Post and Comment Feed
remove_action('wp_head', 'rsd_link'); // EditURI link
remove_action('wp_head', 'wlwmanifest_link'); // windows live writer

// find more on /wp-includes/default-filters.php
}

public function printAllTags()
{
Expand Down
27 changes: 27 additions & 0 deletions src/Settings/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@ public static function sanitizeCaptionShortcode()



public static function cleanupHead()
{
// WP version
\remove_action('wp_head', 'wp_generator');

// shortlinks
\remove_action('wp_head', 'wp_shortlink_wp_head');

// prev/next urls
\remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');

// links to the extra feeds such as category feeds
\remove_action('wp_head', 'feed_links_extra', 3);

// the links to the general feeds: Post and Comment Feed
\remove_action('wp_head', 'feed_links', 2);

// EditURI link
\remove_action('wp_head', 'rsd_link');

// windows live writer
\remove_action('wp_head', 'wlwmanifest_link');

// find more on /wp-includes/default-filters.php
}


// public static function removeGalleryShortcode()
// {
// \remove_shortcode('gallery');
Expand Down

0 comments on commit f7ab8ac

Please sign in to comment.