Plugin Directory

Changeset 2307493


Ignore:
Timestamp:
05/18/2020 09:51:43 PM (5 years ago)
Author:
Darken-x
Message:

Updated the code to remove Yoast HTML Comments from version 14.1, plus other minor improvements. Removed some outdated or redundant metas.

Location:
dublin-core-metadata-generator/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • dublin-core-metadata-generator/trunk/dcmg_metadata.php

    r2143274 r2307493  
    11<?php
    22/**
    3 * Here we get the Dublin Core and Open Graph metadata
    4 ***/
    5 
    6 function dcmg_function_doctype_opengraph($output) {
    7     $options = get_option( 'dublincore_metadata_generator_settings' );
    8     $opengraph_html = $options['dublincore_metadata_generator_html_opengraph'];
    9         if (!empty($opengraph_html)) {
    10     return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://developers.facebook.com/schema/"';
    11         } else {
    12     return $output;
    13         }
     3 * Here we get the Dublin Core and Open Graph metadata
     4 **
     5 */
     6function dcmg_function_doctype_opengraph($output)
     7{
     8    $options = get_option('dublincore_metadata_generator_settings');
     9    $opengraph_html = $options['dublincore_metadata_generator_html_opengraph'];
     10    if (!empty($opengraph_html))
     11    {
     12        return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://developers.facebook.com/schema/"';
     13    }
     14    else
     15    {
     16        return $output;
     17    }
    1418}
    15 
    1619add_filter('language_attributes', 'dcmg_function_doctype_opengraph');
    17 
    18 function add_extra_dcmg_tags() {
    19     $options = get_option( 'dublincore_metadata_generator_settings' );
     20function add_extra_dcmg_tags()
     21{
     22    $options = get_option('dublincore_metadata_generator_settings');
    2023    $description = $options['dublincore_metadata_generator_description'];
    2124    $cleanmetas = $options['dublincore_metadata_generator_cleanmetas'];
    22 
    23 // clean useless generator metas
    24 if ( !empty($cleanmetas) ) :
    25     remove_action('wp_head', 'rsd_link');
    26     remove_action('wp_head', 'wlwmanifest_link');
    27     remove_action('wp_head', 'wp_generator');
    28     remove_action('wp_head', 'wp_shortlink_wp_head');
    29 
    30     if ( class_exists( 'Vc_Manager' ) ) {
    31         remove_action('wp_head', array(visual_composer(), 'addMetaData'));
    32         add_filter( 'addMetaData', 'addMetaData2' );
    33         function addMetaData2() {
    34             return false;
    35         }
    36     }
    37 
    38     function remove_revslider_meta_tag() {
    39     return '';
    40     }
    41     add_filter( 'revslider_meta_generator', 'remove_revslider_meta_tag' );
    42 
    43     function remove_layerslider_meta_tag() {
    44     return '';
    45     }
    46     add_filter('ls_meta_generator', 'remove_layerslider_meta_tag' );
    47 
    48     function remove_woocommerce_version()
    49     {
    50     return true;
    51     }
    52     add_filter ('wf_disable_generator_tags', 'remove_woocommerce_version');
    53    
    54     global $sitepress;
    55     remove_action( 'wp_head', array( $sitepress, 'meta_generator_tag' ) );
    56 
     25    // clean useless generator metas
     26    if (!empty($cleanmetas)):
     27        remove_action('wp_head', 'rsd_link');
     28        remove_action('wp_head', 'wlwmanifest_link');
     29        remove_action('wp_head', 'wp_generator');
     30        remove_action('wp_head', 'wp_shortlink_wp_head');
     31        if (class_exists('Vc_Manager'))
     32        {
     33            remove_action('wp_head', array(
     34                visual_composer() ,
     35                'addMetaData'
     36            ));
     37            add_filter('addMetaData', 'addMetaData2');
     38            function addMetaData2()
     39            {
     40                return false;
     41            }
     42        }
     43        function remove_revslider_meta_tag()
     44        {
     45            return '';
     46        }
     47        add_filter('revslider_meta_generator', 'remove_revslider_meta_tag');
     48        function remove_layerslider_meta_tag()
     49        {
     50            return '';
     51        }
     52        add_filter('ls_meta_generator', 'remove_layerslider_meta_tag');
     53        function remove_woocommerce_version()
     54        {
     55            return true;
     56        }
     57        add_filter('wf_disable_generator_tags', 'remove_woocommerce_version');
     58        global $sitepress;
     59        remove_action('wp_head', array(
     60            $sitepress,
     61            'meta_generator_tag'
     62        ));
    5763?>
    58 <meta name="title" content="<?php
    59 // get correct SEO title
    60     function customyoastseotitle() {
    61         return get_post_meta(get_the_ID(), '_yoast_wpseo_title', true) ?: get_the_title();
    62     }
    63 
    64     $yoasttitle = customyoastseotitle();
    65     if (($yoasttitle != "") && ($yoasttitle != "%%title%%")){
    66         $metatitle = $yoasttitle;
    67     } else {
    68         $metatitle = the_title();
    69     }
    70 echo $metatitle; ?>" />
    7164<meta name="Distribution" content="global" />
    7265<meta name="language" content="<?php
    73     $language = get_bloginfo( 'language' );
    74         if ( ($language == 'en-US') || ($language == 'en-GB') ){
    75     $thelanguage = 'English';
    76         }
    77         if ($language == 'fr-FR') {
    78     $thelanguage = 'French';
    79         }
    80         if ($language == 'de-DE') {
    81     $thelanguage = 'German';
    82         }
    83         if ($language == 'es-ES') {
    84     $thelanguage = 'Spanish';
    85         }
    86         if ($language == 'ro-RO') {
    87     $thelanguage = 'Romanian';
    88         }
    89 echo $thelanguage; ?>" />
     66        $language = get_bloginfo('language');
     67        if (($language == 'en-US') || ($language == 'en-GB'))
     68        {
     69            $thelanguage = 'English';
     70        }
     71        if ($language == 'fr-FR')
     72        {
     73            $thelanguage = 'French';
     74        }
     75        if ($language == 'de-DE')
     76        {
     77            $thelanguage = 'German';
     78        }
     79        if ($language == 'es-ES')
     80        {
     81            $thelanguage = 'Spanish';
     82        }
     83        if ($language == 'ro-RO')
     84        {
     85            $thelanguage = 'Romanian';
     86        }
     87        echo $thelanguage; ?>" />
    9088<meta name="rating" content="General" />
    9189<meta name="Robots" content="index, all" />
     
    9593<meta http-equiv="ImageToolbar" content="No" />
    9694<meta name="MSSmartTagsPreventParsing" content="True" />
    97 <?php endif;
    98     $keywords = $options['dublincore_metadata_generator_keywords'];
    99         if (!empty($description)) : ?>
     95<?php
     96    endif;
     97    $keywords = $options['dublincore_metadata_generator_keywords'];
     98    if (!empty($description)): ?>
    10099<meta name="description" content="<?php echo $description; ?>" />
    101     <?php endif; ?>
    102 <?php if (is_single()) {
    103 global $post;
    104     $tags = get_the_terms( $post, 'post_tag'); // UPDATED
    105     $keywordsfromtags = $tags;
    106 } else {
    107     $titlestring = strip_tags( get_the_title() );
    108     $keywordsfromtitle = preg_replace("/[^\w\ _]+/", '', $titlestring); // strip all punctuation characters, news lines, etc.
    109     $keywordsfromtitle = preg_split("/\s+/", $keywordsfromtitle); // split by left over spaces
    110     $keywordsfromtitles = ''; // UPDATED
    111 foreach ( $keywordsfromtitle as $keywordfromtitle ) {
    112     $keywordsfromtitles .= $keywordfromtitle;
    113     $keywordsfromtitles .= ', ';
     100    <?php
     101    endif; ?>
     102<?php if (is_single())
     103    {
     104        global $post;
     105        $tags = get_the_terms($post, 'post_tag'); // UPDATED
     106        $keywordsfromtags = $tags;
     107    }
     108    else
     109    {
     110        $titlestring = strip_tags(get_the_title());
     111        $keywordsfromtitle = preg_replace("/[^\w\ _]+/", '', $titlestring); // strip all punctuation characters, news lines, etc.
     112        $keywordsfromtitle = preg_split("/\s+/", $keywordsfromtitle); // split by left over spaces
     113        $keywordsfromtitles = ''; // UPDATED
     114        foreach ($keywordsfromtitle as $keywordfromtitle)
     115        {
     116            $keywordsfromtitles .= $keywordfromtitle;
     117            $keywordsfromtitles .= ', ';
     118        }
     119    }
     120    if (class_exists('WooCommerce'))
     121    {
     122        if (is_woocommerce())
     123        {
     124            global $product;
     125            $terms = get_the_terms($values['product_id'], 'product_tag');
     126            if (!empty($terms))
     127            {
     128                foreach ($terms as $term)
     129                {
     130                    $keywordsfromproducttags .= $term->name;
     131                    $keywordsfromproducttags .= ', ';
     132                }
     133            }
     134            $categories = get_the_terms($values['product_id'], 'product_cat');
     135            if (!empty($categories))
     136            {
     137                foreach ($categories as $category)
     138                {
     139                    $keywordsfromproductcats .= $category->name;
     140                    $keywordsfromproductcats .= ', ';
     141                }
     142
     143            }
     144        }
     145    }
     146    // preparing keywords
     147    if (empty($thekeywords)) // UPDATED
     148    $thekeywords = ''; // UPDATED
     149    if (!empty($keywordsfromproducttags))
     150    {
     151        $thekeywords .= $keywordsfromproducttags;
     152    }
     153    if (!empty($keywordsfromproductcats))
     154    {
     155        $thekeywords .= $keywordsfromproductcats;
     156    }
     157    if (!empty($keywordsfromtags))
     158    {
     159        foreach ($keywordsfromtags as $tag) // UPDATED
     160        $thekeywords .= $tag->name . ' '; // UPDATED
     161       
     162    }
     163    if (!empty($keywordsfromtitles))
     164    {
     165        $thekeywords .= $keywordsfromtitles;
     166    }
     167    if (!empty($keywords))
     168    {
     169        $thekeywords .= $keywords;
     170    }
     171    if (!empty($thekeywords))
     172    {
     173        // decided initially to completely remove the generation of keywords meta, but if you really want to have it, just uncomment the next line
     174        //      echo '<meta name="keywords" content="' . $thekeywords . '" />' . "\xA";
     175       
     176    }
    114177}
    115 }
    116     if ( class_exists( 'WooCommerce' ) ) {
    117     if (is_woocommerce()) {
    118 global $product;
    119     $terms = get_the_terms( $values['product_id'], 'product_tag' );
    120 if (!empty($terms)) {
    121 foreach ( $terms as $term ) {   
    122     $keywordsfromproducttags .= $term->name;
    123     $keywordsfromproducttags .= ', ';
    124 }
    125 }
    126     $categories = get_the_terms( $values['product_id'], 'product_cat' );
    127 if (!empty($categories)) {
    128 foreach ( $categories as $category ) { 
    129     $keywordsfromproductcats .= $category->name;
    130     $keywordsfromproductcats .= ', ';
    131 }
    132 }
    133     }
    134 }
    135 // preparing keywords
    136     if ( empty($thekeywords) ) // UPDATED
    137         $thekeywords = ''; // UPDATED
    138     if (!empty($keywordsfromproducttags)) {
    139         $thekeywords .= $keywordsfromproducttags;
    140     }
    141     if (!empty($keywordsfromproductcats)) {
    142         $thekeywords .= $keywordsfromproductcats;
    143     }
    144     if (!empty($keywordsfromtags)) {
    145         foreach ( $keywordsfromtags as $tag ) // UPDATED
    146             $thekeywords .= $tag->name . ' '; // UPDATED
    147     }
    148     if (!empty($keywordsfromtitles)) {
    149         $thekeywords .= $keywordsfromtitles;
    150     }
    151     if (!empty($keywords)) {
    152         $thekeywords .= $keywords;
    153     }
    154 
    155 if (!empty($thekeywords)) {
    156 // decided to remove the generation of keywords meta, but if you really want to have it, just uncomment the next line
    157 //      echo '<meta name="keywords" content="' . $thekeywords . '" />' . "\xA";
    158 }
    159 }
    160 
    161 add_action( 'wp_head', 'add_extra_dcmg_tags', 1 );
    162 function add_extra_dcmg_metadata() {
     178add_action('wp_head', 'add_extra_dcmg_tags', 1);
     179function add_extra_dcmg_metadata()
     180{
    163181    global $post;
    164     $options = get_option( 'dublincore_metadata_generator_settings' );
     182    $options = get_option('dublincore_metadata_generator_settings');
    165183    $opengraph = $options['dublincore_metadata_generator_opengraph'];
    166184    $dublincore = $options['dublincore_metadata_generator_dublincore'];
    167     $cardtype =  is_array( $options ) && array_key_exists( 'dublincore_metadata_generator_image_format', $options ) ? $options['dublincore_metadata_generator_image_format'] : 0; // UPDATED
     185    $cardtype = is_array($options) && array_key_exists('dublincore_metadata_generator_image_format', $options) ? $options['dublincore_metadata_generator_image_format'] : 0; // UPDATED
    168186    $fbadm = $options['dublincore_metadata_generator_fb_admins'];
    169187    $defaultimg = $options['dublincore_metadata_generator_default_image'];
    170188    $site_lang = get_bloginfo('language');
    171         if (has_category()):
    172             $category = get_the_category();
    173             $cat = $category[0]->cat_name;
    174         endif;
    175         if ($cardtype == 1) :
    176             $type ='summary';
    177                 else :
    178                     $type = 'summary_large_image';
    179         endif;
    180 
    181 // Metadata for single page
    182 
    183     if (is_single() && !is_404() && !is_home() ) :
    184         if (has_excerpt()) :
    185             $abstract = wp_strip_all_tags( get_the_excerpt(), true );
    186                 else :
    187                     $abstract = strip_tags($post->post_content);
    188                     $abstract_more = '';
    189                         if (strlen($abstract) > 155) :
    190                             $abstract = substr($abstract,0,155);
    191                             $abstract_more = ' ...';
    192                         endif;
    193                     $abstract = str_replace('"', '', $abstract);
    194                     $abstract = str_replace("'", '', $abstract);
    195                     $abstractwords = preg_split('/[\n\r\t ]+/', $abstract, -1, PREG_SPLIT_NO_EMPTY);
    196                     array_pop($abstractwords);
    197                     $abstract = implode(' ', $abstractwords) . $abstract_more;
    198         endif;
    199                 $fname = get_the_author_meta('first_name');
    200                 $lname = get_the_author_meta('last_name');
    201                 $author = trim( "$fname $lname" );
    202                 if (get_the_post_thumbnail($post->ID, 'thumbnail')) :
    203                     $thumbnail_id = get_post_thumbnail_id($post->ID);
    204                     $thumbnail_object = get_post($thumbnail_id);
    205                     $image = $thumbnail_object->guid;
    206                 else : 
    207                     $image = $defaultimg;
    208                 endif;
    209     endif;
    210        
    211         if ( !is_single() && !empty ($defaultimg) ) :
     189    if (has_category()):
     190        $category = get_the_category();
     191        $cat = $category[0]->cat_name;
     192    endif;
     193    if ($cardtype == 1):
     194        $type = 'summary';
     195    else:
     196        $type = 'summary_large_image';
     197    endif;
     198    // Metadata for single page
     199   
     200    if (is_single() && !is_404() && !is_home()):
     201        if (has_excerpt()):
     202            $abstract = wp_strip_all_tags(get_the_excerpt() , true);
     203        else:
     204            $abstract = strip_tags($post->post_content);
     205            $abstract_more = '';
     206            if (strlen($abstract) > 155):
     207                $abstract = substr($abstract, 0, 155);
     208                $abstract_more = ' ...';
     209            endif;
     210            $abstract = str_replace('"', '', $abstract);
     211            $abstract = str_replace("'", '', $abstract);
     212            $abstractwords = preg_split('/[\n\r\t ]+/', $abstract, -1, PREG_SPLIT_NO_EMPTY);
     213            array_pop($abstractwords);
     214            $abstract = implode(' ', $abstractwords) . $abstract_more;
     215        endif;
     216        $fname = get_the_author_meta('first_name');
     217        $lname = get_the_author_meta('last_name');
     218        $author = trim("$fname $lname");
     219        if (get_the_post_thumbnail($post->ID, 'thumbnail')):
     220            $thumbnail_id = get_post_thumbnail_id($post->ID);
     221            $thumbnail_object = get_post($thumbnail_id);
     222            $image = $thumbnail_object->guid;
     223        else:
    212224            $image = $defaultimg;
    213225        endif;
     226    endif;
     227    if (!is_single() && !empty($defaultimg)):
     228        $image = $defaultimg;
     229    endif;
     230    // Open Graph Metadata
    214231   
    215 // Open Graph Metadata
    216 
    217 if ( !empty($opengraph) ) :
    218     if ( is_single() ) : ?>
     232    if (!empty($opengraph)):
     233        if (is_single()): ?>
    219234<meta property="og:title" content="<?php the_title(); ?>" />
    220     <?php endif;
    221       if (!empty ($abstract) && is_single() ) : ?>
    222 <meta property="og:description" content="<?php echo $abstract;  ?>" />
    223     <?php endif; ?>
     235    <?php
     236        endif;
     237        if (!empty($abstract) && is_single()): ?>
     238<meta property="og:description" content="<?php echo $abstract; ?>" />
     239    <?php
     240        endif; ?>
    224241<meta property="og:type" content="article" />
    225     <?php if (is_single()) : ?>
     242    <?php if (is_single()): ?>
    226243<meta property="og:url" content="<?php the_permalink(); ?>" />
    227     <?php endif;
    228     if (!empty($image) ) { ?>
     244    <?php
     245        endif;
     246        if (!empty($image))
     247        { ?>
    229248<meta property="og:image" content="<?php echo $image; ?>" />
    230     <?php } elseif (has_post_thumbnail() ) { ?>
     249    <?php
     250        }
     251        elseif (has_post_thumbnail())
     252        { ?>
    231253<meta property="og:image" content="' . wp_get_attachment_url( get_post_thumbnail_id() ) . '" />
    232     <?php } ?>
     254    <?php
     255        } ?>
    233256<meta property="og:site_name" content="<?php echo get_bloginfo('name'); ?>" />
    234257<meta property="og:determiner" content="auto" />
    235258<meta property="og:locale" content="<?php echo $site_lang; ?>" />
    236     <?php if ( !empty ($author) ) : ?>
     259    <?php if (!empty($author)): ?>
    237260<meta property="og:profile" content="<?php echo $author; ?>" />
    238     <?php endif;
    239     if ( !empty ($fname) ) : ?>
     261    <?php
     262        endif;
     263        if (!empty($fname)): ?>
    240264<meta property="profile:first_name" content="<?php echo $fname; ?>" />
    241     <?php endif;
    242     if ( !empty ($lname) ) : ?>
     265    <?php
     266        endif;
     267        if (!empty($lname)): ?>
    243268<meta property="profile:last_name" content="<?php echo lname; ?>" />
    244     <?php endif; ?>
     269    <?php
     270        endif; ?>
    245271<meta property="og:website" content="<?php echo get_site_url(); ?>" />
    246     <?php if ( !empty ($fbadm) ) : ?>
     272    <?php if (!empty($fbadm)): ?>
    247273<meta property="fb:admins" content="<?php echo $fbadm; ?>"/>
    248     <?php endif;
    249 endif;
    250 
    251 // Dublin Core
    252 
    253 if ( !empty($dublincore) ) : ?>
    254 <?php if ( (is_single()) || (is_page()) ) : ?>
     274    <?php
     275        endif;
     276    endif;
     277    // Dublin Core
     278   
     279    if (!empty($dublincore)): ?>
     280<?php if ((is_single()) || (is_page())): ?>
    255281<meta name="DC.Title" content="<?php
    256 // get correct SEO title
    257     function customyoastseotitle2() {
    258         return get_post_meta(get_the_ID(), '_yoast_wpseo_title', true) ?: get_the_title();
    259     }
    260 
    261     $yoasttitle = customyoastseotitle2();
    262     if (($yoasttitle != "") && ($yoasttitle != "%%title%%")){
    263         $metatitle = $yoasttitle;
    264     } else {
    265         $metatitle = the_title();
    266     }
    267 
    268 echo $metatitle; ?>" />
    269 <?php endif; ?>
     282            // get correct SEO title
     283            function customyoastseotitle2()
     284            {
     285                return get_post_meta(get_the_ID() , '_yoast_wpseo_title', true) ? : get_the_title();
     286            }
     287            $yoasttitle = customyoastseotitle2();
     288            if (($yoasttitle != "") && ($yoasttitle != "%%title%%"))
     289            {
     290                $metatitle = $yoasttitle;
     291            }
     292            else
     293            {
     294                $metatitle = the_title();
     295            }
     296            echo $metatitle; ?>" />
     297<?php
     298        endif; ?>
    270299<meta name="DC.Publisher" content="<?php echo get_bloginfo('name'); ?>" />
    271300<meta name="DC.Language" scheme="UTF-8" content="<?php echo $site_lang; ?>" />
    272 <?php if (!empty ($author)) : ?>
     301<?php if (!empty($author)): ?>
    273302<meta name="DC.Creator" content="<?php the_author(); ?>" />
    274 <?php endif; ?>
    275 <?php if (empty ($author)) : ?>
     303<?php
     304        endif; ?>
     305<?php if (empty($author)): ?>
    276306<meta name="DC.Creator" content="<?php echo get_bloginfo('name'); ?>" />
    277 <?php endif; ?>
    278 <?php if (!empty ($abstract) && is_single() ) : ?>
    279 <meta name="DC.Description" content="<?php echo $abstract;  ?>" />
    280 <?php endif;  ?>
     307<?php
     308        endif; ?>
     309<?php if (!empty($abstract) && is_single()): ?>
     310<meta name="DC.Description" content="<?php echo $abstract; ?>" />
     311<?php
     312        endif; ?>
    281313<meta name="DC.Type" scheme="DCMIType" content="Text" />
    282314<meta name="DC.Format" scheme="IMT" content="text/html" />
    283315<meta name="DC.Format.MIME" content="text/html" />
    284316<meta name="DC.Format.SysReq" content="Internet browser" />
    285 <meta name="DC.Source" content="<?php echo network_site_url( '/' );?>">
     317<meta name="DC.Source" content="<?php echo network_site_url('/'); ?>">
    286318<meta name="DC.Coverage" content="World">
    287 <?php if ( is_single() ) : ?>
     319<?php if (is_single()): ?>
    288320<meta name="DC.Identifier" content="<?php the_permalink(); ?>" />
    289321<meta name="DC.Date" content="<?php the_time('Y-m-d'); ?>" />
    290 <?php else : ?>
     322<?php
     323        else: ?>
    291324<meta name="DC.Identifier" content="<?php echo get_site_url(); ?>" />
    292 <?php endif; if (has_category()): ?>
     325<?php
     326        endif;
     327        if (has_category()): ?>
    293328<meta name="DC.Subject" content="<?php echo $cat; ?>" />
    294 <?php endif; ?>
    295 <?php if ( !empty($options['dublincore_metadata_generator_keywords']) || !empty($thekeywords) ) : ?>
    296 <meta name="DC.Subject.Keyword" content="<?php
    297     if (!empty($thekeywords)) {
    298         echo $thekeywords . ', ';
    299     }
    300     if (!empty($options['dublincore_metadata_generator_keywords'])) {
    301     echo $options['dublincore_metadata_generator_keywords'];
    302     }
     329<?php
     330        endif; ?>
     331<?php if (!empty($options['dublincore_metadata_generator_keywords']) || !empty($thekeywords)): ?>
     332<meta name="DC.Subject.Keyword" content="<?php
     333            if (!empty($thekeywords))
     334            {
     335                echo $thekeywords . ', ';
     336            }
     337            if (!empty($options['dublincore_metadata_generator_keywords']))
     338            {
     339                echo $options['dublincore_metadata_generator_keywords'];
     340            }
    303341?>" />
    304 <?php endif;
    305     endif;
    306 
     342<?php
     343        endif;
     344    endif;
    307345}
    308 add_action( 'wp_head', 'add_extra_dcmg_metadata', 1 );
     346add_action('wp_head', 'add_extra_dcmg_metadata', 1);
    309347
    310348// Here be dragons
    311349
    312 class removeyoastcomments {
    313     private $version = '3.1';
    314     private $debug_marker_removed = false;
    315     private $head_marker_removed = false;
    316     private $backup_plan_active = false;
    317    
    318     public function __construct() {
    319         add_action( 'init', array( $this, 'bundle' ), 1);
    320     }
    321    
    322     public function bundle() {
    323         if(defined( 'WPSEO_VERSION' )) {
    324             $debug_marker = ( version_compare( WPSEO_VERSION, '4.4', '>=' ) ) ? 'debug_mark' : 'debug_marker';
     350// Disable Yoast source code comments
    325351
    326             // main function to unhook the debug msg
    327             if(class_exists( 'WPSEO_Frontend' ) && method_exists( 'WPSEO_Frontend', $debug_marker )) {
    328                 remove_action( 'wpseo_head', array( WPSEO_Frontend::get_instance(), $debug_marker ) , 2);
    329                
    330                 $this->debug_marker_removed = true;
    331                
    332                 // also removes the end debug msg as of 5.9
    333                 if(version_compare( WPSEO_VERSION, '5.9', '>=' )) $this->head_marker_removed = true;
    334             }
    335            
    336             // compatible solution for everything below 5.8
    337             if(class_exists( 'WPSEO_Frontend' ) && method_exists( 'WPSEO_Frontend', 'head' ) && version_compare( WPSEO_VERSION, '5.8', '<' )) {
    338                 remove_action( 'wp_head', array( WPSEO_Frontend::get_instance(), 'head' ) , 1);
    339                 add_action( 'wp_head', array($this, 'rewrite'), 1);
    340                 $this->head_marker_removed = true;
    341             }
    342            
    343             // temp solution for all installations on 5.8
    344             if(version_compare( WPSEO_VERSION, '5.8', '==' )) {
    345                 add_action('get_header', array( $this, 'buffer_header' ));
    346                 add_action('wp_head', array( $this, 'buffer_head' ), 999);
    347                 $this->head_marker_removed = true;
    348             }
    349            
    350             // backup solution
    351             if($this->operating_status() == 2) {
    352                 add_action('get_header', array( $this, 'buffer_header' ));
    353                 add_action('wp_head', array( $this, 'buffer_head' ), 999);
    354             }
    355            
    356         }
    357        
    358     }
    359    
    360     public function operating_status() {
    361         if($this->debug_marker_removed && $this->head_marker_removed) {
    362             return 1;
    363         } elseif(!$this->debug_marker_removed && $this->head_marker_removed || $this->debug_marker_removed && !$this->head_marker_removed) {
    364             return 2;
    365         } else {
    366             return 3;
    367         }
    368     }
    369    
    370     // compatible solution for everything below 5.8
    371     public function rewrite() {
    372         $rewrite = new ReflectionMethod( 'WPSEO_Frontend', 'head' );
    373        
    374         $filename = $rewrite->getFileName();
    375         $start_line = $rewrite->getStartLine();
    376         $end_line = $rewrite->getEndLine()-1;
    377 
    378         $length = $end_line - $start_line;
    379         $source = file( $filename );
    380         $body = implode( '', array_slice($source, $start_line, $length) );
    381         $body = preg_replace( '/echo \'\<\!(.*?)\n/', '', $body);
    382 
    383         eval($body);
    384     }
    385    
    386     // temporary solution for all installations on 5.8, and also the backup solution for future Yoasts versions
    387     public function buffer_header() {
    388         ob_start(function ($o) {
    389             return preg_replace('/\n?<.*?yoast.*?>/mi','',$o);
    390         });
    391     }
    392    
    393     public function buffer_head() {
    394         ob_end_flush();
    395     }
    396    
     352$options = get_option('dublincore_metadata_generator_settings');
     353$cleanyoast = is_array($options) && array_key_exists('dublincore_metadata_generator_cleanyoast', $options) ? $options['dublincore_metadata_generator_cleanyoast'] : 0; // UPDATED
     354if (!empty($cleanyoast)) {
     355    add_filter( 'wpseo_debug_markers', '__return_false' );
    397356}
    398 
    399     $options = get_option( 'dublincore_metadata_generator_settings' );
    400     $cleanyoast = is_array( $options ) && array_key_exists( 'dublincore_metadata_generator_cleanyoast', $options ) ? $options['dublincore_metadata_generator_cleanyoast'] : 0; // UPDATED
    401     if ( !empty($cleanyoast) ) {
    402         new removeyoastcomments;
    403     }
    404 
    405357?>
  • dublin-core-metadata-generator/trunk/dcmg_options.php

    r1873687 r2307493  
    178178
    179179function dublincore_metadata_generator_keywords_render(  ) {
     180// the meta keywords are obsolete in 2020, but here they are in case you really want to use them
    180181    $options = get_option( 'dublincore_metadata_generator_settings' );
    181182        if ( empty ( $options['dublincore_metadata_generator_keywords'] ) ) : $keywords = '';
     
    184185    ?>
    185186    <textarea style='width:66%;' type='text' name='dublincore_metadata_generator_settings[dublincore_metadata_generator_keywords]'><?php echo $keywords; ?></textarea>
    186     <p><em><?php _e('Enter maximum 20 keywords, separated by a comma. These should be the top, most important keywords that you want your website to be optimised for.', 'dublincoremetadatagenerator'); ?> </em></p>
     187    <p><strong><?php _e('The meta keywords are obsolete in 2020, but here they are in case you really want to use them for Dublin Core.', 'dublincoremetadatagenerator'); ?></strong><br />
     188    <em><?php _e('Enter maximum 20 keywords, separated by a comma. These should be the top, most important keywords that you want your website to be optimized for. This is a global field, so in case you would like to have different individual keywords per page, it is recommended you leave this field empty, in which case each page/post will have its own keywords meta, autogenerated from the page/post title, tags and categories. It works for WooCommerce products as well.', 'dublincoremetadatagenerator'); ?> </em></p>
    187189    <?php
    188190}
     
    195197    ?>
    196198    <textarea style='width:66%;' type='text' name='dublincore_metadata_generator_settings[dublincore_metadata_generator_description]'><?php echo $description; ?></textarea>
    197     <p><em><?php _e('The description should contain less than 200 characters and ideally it should contain your SEO keywords displayed in a natural sentence and a readable form.', 'dublincoremetadatagenerator'); ?> </em></p>
     199    <p><em><?php _e('The description should contain less than 200 characters and ideally it should contain your SEO keywords displayed in a natural sentence and readable form. However, for optimal performance and customization, we advise you to use Yoast to set up descriptions. This is a global field, which means it will serve as the same description for all pages and posts.', 'dublincoremetadatagenerator'); ?> </em></p>
    198200    <?php
    199201}
     
    208210    <input name='dublincore_metadata_generator_settings[dublincore_metadata_generator_cleanmetas]' value='0' type='hidden'>
    209211    <input type='checkbox' name='dublincore_metadata_generator_settings[dublincore_metadata_generator_cleanmetas]' <?php checked( $options['dublincore_metadata_generator_cleanmetas'], 1 ); ?> value='1'>
    210     <p><em><?php _e('This option will clean up your code by eliminating all useless meta tags, <abbr title="Example: <meta name=”generator” content=”WordPress 3.0.1” />">generators</abbr> and advertising comments left by Wordpress, WooCommerce, Slider Revolution, LayerSlider, WPML and WPBakery Page Builder (Visual Composer) plugins in just one click.'); ?> </em></p>
     212    <p><em><?php _e('This option will clean up your code by eliminating all useless meta tags, <abbr title="Example: <meta name=”generator” content=”WordPress 5.4.1” />">generators</abbr> and advertising comments left by Wordpress, WooCommerce, Slider Revolution, LayerSlider, WPML and WPBakery Page Builder (Visual Composer) plugins in just one click.'); ?> </em></p>
    211213    <?php
    212214}
  • dublin-core-metadata-generator/trunk/dublin-core-metadata-generator.php

    r2143288 r2307493  
    44Plugin URI: https://www.seolus.com
    55Description: Automatically generate Dublin Core and Open Graph metadata in your website pages.
    6 Version: 1.3.1
     6Version: 1.3.2
    77Author: Seolus
    88Author URI: https://www.seolus.com
  • dublin-core-metadata-generator/trunk/readme.txt

    r2143289 r2307493  
    44Tags: metadata, Dublin Core, Open Graph, SEO, Search Engine Optimisation, DC, keywords, Meta Tags, MetaData, Generator, Search Engine Optimization, SEM
    55Requires at least: 4.2.3
    6 Tested up to: 5.2.2
    7 Stable tag: 5.2
     6Tested up to: 5.4.1
     7Stable tag: 5.4.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3838== Changelog ==
    3939
     40= 1.3.2 = Updated the code to remove Yoast HTML Comments from version 14.1, plus other minor improvements. Removed some outdated or redundant metas.
    4041= 1.3.1 = Minor update. User KTS915 pointed out there's a warning on PHP 7.3, which is now fixed.
    4142= 1.3 = John Jackson from johnridesa.bike fixed a couple of PHP notices that were being shown on PHP 7.1. Thank you, John!
Note: See TracChangeset for help on using the changeset viewer.