Ejemplo n.º 1
0
/**
 * Function that adds the help tabs for the options.
 */
function amt_options_page()
{
    // Permission Check
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    // Default Add-Meta-Tags Settings
    $default_options = amt_get_default_options();
    if (isset($_POST['info_update'])) {
        // Save the Add-Meta-Tags settings
        amt_save_settings($_POST);
        // Also, since it may happen that the rewrite rules have not been flushed
        // this is a good place to do it.
        flush_rewrite_rules();
        // Also, clear the metadata cache automatically on every save.
        $result = amt_delete_all_transient_metadata_cache();
        if (intval($result) > 0) {
            amt_show_info_msg(sprintf(__('Deleted %d transient metadata cache entries.', 'add-meta-tags'), $result));
        }
    } elseif (isset($_POST["info_reset"])) {
        amt_reset_settings();
    }
    // Get the options from the DB.
    $options = get_option("add_meta_tags_opts");
    //var_dump($options);
    /*
    Configuration Page
    */
    print '
    <!-- #add-meta-tags-settings is required by the media selector -->
    <span id="add-meta-tags-settings">    
    ';
    print '
    <div class="wrap">
        <div id="icon-options-general" class="icon32"><br /></div>
        <h2>' . __('Metadata Settings', 'add-meta-tags') . '</h2>

        <p>' . __('Welcome to the administration panel of the Add-Meta-Tags plugin.', 'add-meta-tags') . '</p>

    </div>

    <div class="wrap amt-settings-notice">

        <!-- <h3>' . __('Notice', 'add-meta-tags') . '</h3> -->

        <p>' . __('Press the <code>Help</code> button on the top right corner for an introduction to metadata and also for detailed <strong>documentation</strong> about the available settings and the metadata generators. All help texts will gradually be moved to this integrated WordPress help system in order to reduce the size of this page and make it more user-friendly.', 'add-meta-tags') . '</p>

    </div>

    <!--
    <div class="wrap amt-settings-notice">

        <p>' . __('It is no longer possible to enter the URLs of the Publisher\'s social media profiles in the WordPress user profile page. Instead, this information should be entered in the relevant fields of the <strong>Publisher Settings</strong> section below.', 'add-meta-tags') . '</p>

    </div>
    -->

    <div class="wrap amt-settings-donations-msg" style="' . ($options["i_have_donated"] == "1" ? 'display: none;' : '') . '">

        <h3>' . __('Message from the author', 'add-meta-tags') . '</h3>

        <p><em>Add-Meta-Tags</em> is released under the terms of the <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License version 2</a> and, therefore, is <strong>Free software</strong>. It is actively maintained and supported free of charge since 2006.</p>

        <p>However, a significant amount of <strong>time</strong> and <strong>energy</strong> has been put into the development of this plugin, so, its production has not been free from cost. If you find this plugin useful and if it has helped your blog get indexed better and rank higher, I would appreciate an <a href="http://bit.ly/HvUakt">extra cup of coffee</a>.</p>
        <!--
        <p">Donations in BitCoin (BTC) are also accepted and welcome. Send the donated coin to the following address:</p>
        <ul>
            <li style="margin-left: 1em;">BitCoin (BTC): <code>1KkgpmaBKqQVk643VRhFRkL19Bbci4Mwn9</code></li>
        </ul>
        -->
        <p>Thank you in advance,<br />George Notaras</p>
        <div style="text-align: right;"><small>' . __('This message can be deactivated in the settings below.', 'add-meta-tags') . '</small></div>
    </div>

    <div class="wrap">
        <h2>' . __('Configuration', 'add-meta-tags') . '</h2>

        <p>' . __('This section contains global configuration options for the metadata that is added to your web site.', 'add-meta-tags') . '</p>

        <form name="formamt" method="post" action="' . admin_url('options-general.php?page=add-meta-tags-options') . '">

        <table class="form-table">
        <tbody>
    ';
    // General Settings
    if (amt_has_page_on_front()) {
        /* Options:
        
                    Example No pages
                    +-----------+----------------+--------------+----------+
                    | option_id | option_name    | option_value | autoload |
                    +-----------+----------------+--------------+----------+
                    |        58 | show_on_front  | posts        | yes      |
                    |        93 | page_for_posts | 0            | yes      |
                    |        94 | page_on_front  | 0            | yes      |
                    +-----------+----------------+--------------+----------+
        
                    Example pages as front page and posts page
                    +-----------+----------------+--------------+----------+
                    | option_id | option_name    | option_value | autoload |
                    +-----------+----------------+--------------+----------+
                    |        58 | show_on_front  | page         | yes      |
                    |        93 | page_for_posts | 28           | yes      |
                    |        94 | page_on_front  | 25           | yes      |
                    +-----------+----------------+--------------+----------+
        
                */
        print '
            <tr valign="top">
            <th scope="row">' . __('Front Page Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Front Page Metadata', 'add-meta-tags') . '</span></legend>
                ' . __('It appears that you use static pages on the <em>front page</em> and the <em>latest posts page</em> of this web site. Please visit the editing panel of these pages and set the <code>description</code> and the <code>keywords</code> meta tags in the relevant Metadata box.', 'add-meta-tags') . '
                ';
        print '<ul>';
        $front_page_id = get_option('page_on_front');
        if (intval($front_page_id) > 0) {
            printf('<li>&raquo; ' . __('Edit the <a href="%s">front page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($front_page_id)));
        }
        $posts_page_id = get_option('page_for_posts');
        if (intval($posts_page_id) > 0) {
            printf('<li>&raquo; ' . __('Edit the <a href="%s">posts page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($posts_page_id)));
        }
        print '</ul>';
        print '
            </fieldset>
            </td>
            </tr>
        ';
    } else {
        print '
            <tr valign="top">
            <th scope="row">' . __('Front Page Description', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Front Page Description', 'add-meta-tags') . '</span></legend>
                
                <textarea name="site_description" id="site_description" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_description($options))) . '</textarea>
                <br />
                <label for="site_description">
                    ' . __('Enter a short description of your web site.', 'add-meta-tags') . '
                </label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Front Page Keywords', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Front Page Keywords', 'add-meta-tags') . '</span></legend>
                
                <textarea name="site_keywords" id="site_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_keywords($options))) . '</textarea>
                <br />
                <label for="site_keywords">' . __('Enter a comma-delimited list of keywords for your web site.', 'add-meta-tags') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>
        ';
    }
    print '
            <tr valign="top">
            <th scope="row">' . __('Global Keywords', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Global Keywords', 'add-meta-tags') . '</span></legend>
                
                <textarea name="global_keywords" id="global_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_global_keywords($options))) . '</textarea>
                <br />
                <label for="global_keywords">' . __('Enter a comma-delimited list of global keywords. Please consult the integrated help for more information.', 'add-meta-tags') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Site-wide META tags', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Site-wide META tags', 'add-meta-tags') . '</span></legend>

                <textarea name="site_wide_meta" id="site_wide_meta" cols="100" rows="10" class="code">' . stripslashes($options["site_wide_meta"]) . '</textarea>
                <br />
                <label for="site_wide_meta">
                ' . __('Enter complete <a href="http://en.wikipedia.org/wiki/Meta_element" target="_blank">meta tags</a> which will appear on all web pages.', 'add-meta-tags') . '
                ' . __('Please, do not enter keywords here.', 'add-meta-tags') . '
                </label>
                <br />
            </fieldset>
            </td>
            </tr>

    ';
    // Publisher Settings
    print '
            <tr valign="top">
            <th scope="row">' . __('Publisher Settings', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Publisher Settings', 'add-meta-tags') . '</span></legend>

                <p>' . __('This section contains options related to your web site; the publisher of the content.', 'add-meta-tags') . '</p>
                <p>' . __('The following publisher related settings are shared among all users. Filling in these settings is entirely optional.', 'add-meta-tags') . '</p>

                <h4>' . __('Facebook publisher profile URL', 'add-meta-tags') . ':</h4>

                <input name="social_main_facebook_publisher_profile_url" type="text" id="social_main_facebook_publisher_profile_url" class="code" value="' . esc_url_raw(stripslashes($options["social_main_facebook_publisher_profile_url"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="social_main_facebook_publisher_profile_url">
                ' . __('Enter an absolute URL to the Facebook profile of the publisher. If this is filled in, it will be used in the <code>article:publisher</code> meta tag.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>https://www.facebook.com/awesome.editors</code></p>
                <br />

                <!-- We currently let users add the full meta tags for fb:app_id and fb:admins in the site wide meta tags box.

                <h4>' . __('Facebook App ID', 'add-meta-tags') . ':</h4>

                <input name="social_main_facebook_app_id" type="text" id="social_main_facebook_app_id" class="code" value=" . esc_url_raw( stripslashes( $options["social_main_facebook_app_id"] ) ) . " size="100" maxlength="1024" />
                <br />
                <label for="social_main_facebook_app_id">
                ' . __('Enter the App ID for <a target="_blank" href="https://developers.facebook.com/docs/platforminsights">Facebook Insights</a>.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>1234567890</code></p>
                <br />

                <h4>' . __('Facebook Admin ID list', 'add-meta-tags') . ':</h4>

                <input name="social_main_facebook_admins" type="text" id="social_main_facebook_admins" class="code" value=" . esc_url_raw( stripslashes( $options["social_main_facebook_admins"] ) ) . " size="100" maxlength="1024" />
                <br />
                <label for="social_main_facebook_admins">
                ' . __('Enter a comma delimited list of numerical Facebook user IDs which will have access to <a target="_blank" href="https://developers.facebook.com/docs/platforminsights">Facebook Insights</a>.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>1111111111,2222222222</code></p>
                <br />

                -->

                <h4>' . __('Google+ publisher profile URL', 'add-meta-tags') . ':</h4>

                <input name="social_main_googleplus_publisher_profile_url" type="text" id="social_main_googleplus_publisher_profile_url" class="code" value="' . esc_url_raw(stripslashes($options["social_main_googleplus_publisher_profile_url"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="social_main_googleplus_publisher_profile_url">
                ' . __('Enter an absolute URL to the Google+ profile of the publisher. If this is filled in, it will be used in the link with <code>rel="publisher"</code> in the HEAD area of the web page.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>https://plus.google.com/+AwesomeEditors/</code></p>
                <br />

                <h4>' . __('Twitter publisher username', 'add-meta-tags') . ':</h4>

                <input name="social_main_twitter_publisher_username" type="text" id="social_main_twitter_publisher_username" class="code" value="' . esc_attr(stripslashes($options["social_main_twitter_publisher_username"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="social_main_twitter_publisher_username">
                ' . __('Enter the Twitter username of the publisher (without @).', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>AwesomeEditors</code></p>
                <br />

            </fieldset>
            </td>
            </tr>
    ';
    // Author Settings
    print '
            <tr valign="top">
            <th scope="row">' . __('Author Settings', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Author Settings', 'add-meta-tags') . '</span></legend>

                <p>' . __('This section contains options related to the authors of the content.', 'add-meta-tags') . '</p>

                <h4>' . __('URLs of author profiles on social networks', 'add-meta-tags') . ':</h4>

                <p>' . __('Each author may fill in the the URLs of the profiles on external social networks in the WordPress user profile page (fields marked with <em>AMT</em>).', 'add-meta-tags') . '</p>

                <h4>' . __('Main source of local author profiles', 'add-meta-tags') . ':</h4>

                <select name="author_profile_source" type="text" id="author_profile_source" class="code">
                    <option ' . ($options["author_profile_source"] == "default" ? 'selected="selected"' : '') . ' value="default">' . __('First page of the author archive', 'add-meta-tags') . ' ' . __('(default)', 'add-meta-tags') . ' &mdash; ' . __('Organization web site', 'add-meta-tags') . '</option>
                    <option ' . ($options["author_profile_source"] == "frontpage" ? 'selected="selected"' : '') . ' value="frontpage">' . __('Front page (with static page only)', 'add-meta-tags') . ' &mdash; ' . __('Personal web site', 'add-meta-tags') . '</option>
                    <option ' . ($options["author_profile_source"] == "buddypress" ? 'selected="selected"' : '') . ' value="buddypress">' . __('BuddyPress member page', 'add-meta-tags') . ' &mdash; ' . __('Organization web site', 'add-meta-tags') . '</option>
                    <option ' . ($options["author_profile_source"] == "url" ? 'selected="selected"' : '') . ' value="url">' . __('Author\'s external web site URL', 'add-meta-tags') . ' &mdash; ' . __('Organization web site', 'add-meta-tags') . '</option>
                </select> 

                <br /><br />
                <p>' . __('This is an advanced option and should not be changed, unless you have consulted the integrated help for more information.', 'add-meta-tags') . '</p>
                <br />

            </fieldset>
            </td>
            </tr>
    ';
    // Basic Metadata
    print '
            <tr valign="top">
            <th scope="row">' . __('Basic Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Basic Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_description" type="checkbox" value="1" name="auto_description" ' . ($options["auto_description"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_description">' . __('Automatically generate the <em>description</em> meta tag.', 'add-meta-tags') . '</label>
                <br />

                <input id="auto_keywords" type="checkbox" value="1" name="auto_keywords" ' . ($options["auto_keywords"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_keywords">' . __('Automatically generate the <em>keywords</em> meta tag.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Opengraph Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Opengraph Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_opengraph" type="checkbox" value="1" name="auto_opengraph" ' . ($options["auto_opengraph"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_opengraph">' . __('Automatically generate Opengraph meta tags.', 'add-meta-tags') . '</label>
                <br />

                <input id="og_add_xml_namespaces" type="checkbox" value="1" name="og_add_xml_namespaces" ' . ($options["og_add_xml_namespaces"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="og_add_xml_namespaces">' . __('Add Facebook\'s XML namespaces.', 'add-meta-tags') . '</label>
                <br />

                <input id="og_omit_video_metadata" type="checkbox" value="1" name="og_omit_video_metadata" ' . ($options["og_omit_video_metadata"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="og_omit_video_metadata">' . __('Omit <code>og:video</code> meta tags.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Twitter Cards Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Twitter Cards Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_twitter" type="checkbox" value="1" name="auto_twitter" ' . ($options["auto_twitter"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_twitter">' . __('Automatically generate Twitter Cards meta tags.', 'add-meta-tags') . '</label>
                <br />

                <input id="tc_enforce_summary_large_image" type="checkbox" value="1" name="tc_enforce_summary_large_image" ' . ($options["tc_enforce_summary_large_image"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="tc_enforce_summary_large_image">' . __('Enforce the use of <code>summary_large_image</code> as default card type.', 'add-meta-tags') . '</label>
                <br />

                <input id="tc_enable_player_card_local" type="checkbox" value="1" name="tc_enable_player_card_local" ' . ($options["tc_enable_player_card_local"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="tc_enable_player_card_local">' . __('Enable the generation of <em>player</em> cards for local media.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Dublin Core Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Dublin Core Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_dublincore" type="checkbox" value="1" name="auto_dublincore" ' . ($options["auto_dublincore"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_dublincore">' . __('Automatically generate Dublin Core metadata.', 'add-meta-tags') . '</label>
                <br />

                <input id="dc_add_xml_namespaces" type="checkbox" value="1" name="dc_add_xml_namespaces" ' . ($options["dc_add_xml_namespaces"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="dc_add_xml_namespaces">' . __('Add the Dublin Core XML namespace.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Schema.org Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Schema.org Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_schemaorg" type="checkbox" value="1" name="auto_schemaorg" ' . ($options["auto_schemaorg"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_schemaorg">' . __('Automatically generate and embed Schema.org Microdata.', 'add-meta-tags') . '</label>
                <br />

                <input id="schemaorg_force_jsonld" type="checkbox" value="1" name="schemaorg_force_jsonld" ' . ($options["schemaorg_force_jsonld"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="schemaorg_force_jsonld">' . __('Enforce the generation of schema.org metadata as JSON-LD data.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Locale', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Locale', 'add-meta-tags') . '</span></legend>

                <input name="global_locale" type="text" id="global_locale" class="code" value="' . esc_attr(stripslashes($options["global_locale"])) . '" size="20" maxlength="32" />
                <br />
                <label for="global_locale">
                ' . __('Enter a locale, for example <code>en_US</code> or <code>zh_Hans_TW</code>, which will be used globally in the generated metadata overriding the default locale as returned by WordPress.', 'add-meta-tags') . '
                ' . __('The locale can be overridden on a per post basis. For this purpose, enabling the relevant metabox feature below is required.', 'add-meta-tags') . '
                </label>
                <br />

                <input id="manage_html_lang_attribute" type="checkbox" value="1" name="manage_html_lang_attribute" ' . ($options["manage_html_lang_attribute"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="manage_html_lang_attribute">' . __('Automatically set the HTML document\'s <code>lang</code> attribute according to the locale of the content.', 'add-meta-tags') . '</label>
                <br />

                <input id="generate_hreflang_links" type="checkbox" value="1" name="generate_hreflang_links" ' . ($options["generate_hreflang_links"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="generate_hreflang_links">' . __('Enable the generation of a <code>link</code> element with the <code>hreflang</code> attribute.', 'add-meta-tags') . '</label>
                <br />

                <input id="hreflang_strip_region" type="checkbox" value="1" name="hreflang_strip_region" ' . ($options["hreflang_strip_region"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="hreflang_strip_region">' . __('Strip region code from the hreflang attribute.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Metabox Features', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Metabox Features', 'add-meta-tags') . '</span></legend>

                <p>' . __('It is possible to partially customize the generated metadata on a per post basis through the <em>Metadata</em> metabox which exists in the post editing screen. Below you can choose which metabox features should be enabled. Enabling or disabling these features has no effect on the custom data that has been stored for each post.', 'add-meta-tags') . '</p>

                <p><input id="metabox_enable_description" type="checkbox" value="1" name="metabox_enable_description" ' . ($options["metabox_enable_description"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_description">
                ' . __('Custom description.', 'add-meta-tags') . ' (' . __('Recommended', 'add-meta-tags') . ')
                </label></p>

                <p><input id="metabox_enable_keywords" type="checkbox" value="1" name="metabox_enable_keywords" ' . ($options["metabox_enable_keywords"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_keywords">
                ' . __('Custom keywords.', 'add-meta-tags') . ' (' . __('Recommended', 'add-meta-tags') . ')
                </label></p>

                <p><input id="metabox_enable_title" type="checkbox" value="1" name="metabox_enable_title" ' . ($options["metabox_enable_title"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_title">
                ' . __('Custom content of the <code>title</code> HTML element.', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_news_keywords" type="checkbox" value="1" name="metabox_enable_news_keywords" ' . ($options["metabox_enable_news_keywords"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_news_keywords">
                ' . __('Custom news keywords. (<a target="_blank" href="http://support.google.com/news/publisher/bin/answer.py?hl=en&answer=68297">more info</a>)', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_full_metatags" type="checkbox" value="1" name="metabox_enable_full_metatags" ' . ($options["metabox_enable_full_metatags"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_full_metatags">
                ' . __('Full meta tags box.', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_image_url" type="checkbox" value="1" name="metabox_enable_image_url" ' . ($options["metabox_enable_image_url"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_image_url">
                ' . __('Global image override.', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_content_locale" type="checkbox" value="1" name="metabox_enable_content_locale" ' . ($options["metabox_enable_content_locale"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_content_locale">
                ' . __('Content locale override. (Not to be used in conjunction with a multilingual plugin.) ', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_express_review" type="checkbox" value="1" name="metabox_enable_express_review" ' . ($options["metabox_enable_express_review"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_express_review">
                ' . __('Express review.', 'add-meta-tags') . ' (' . __('For advanced users only', 'add-meta-tags') . ')
                </label></p>

                <p><input id="metabox_enable_referenced_list" type="checkbox" value="1" name="metabox_enable_referenced_list" ' . ($options["metabox_enable_referenced_list"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_referenced_list">
                ' . __('Referenced items.', 'add-meta-tags') . ' (' . __('Not recommended', 'add-meta-tags') . ')
                </label></p>

            ';
    // The term meta API was implemented in 4.4
    if (version_compare(get_bloginfo('version'), '4.4', '>=')) {
        print '
                    <h4>' . __('Taxonomy terms', 'add-meta-tags') . ':</h4>

                    <p><input id="metabox_term_enable_full_metatags" type="checkbox" value="1" name="metabox_term_enable_full_metatags" ' . ($options["metabox_term_enable_full_metatags"] == "1" ? 'checked="checked"' : '') . '" />
                    <label for="metabox_term_enable_full_metatags">
                    ' . __('Full meta tags box.', 'add-meta-tags') . '
                    </label></p>

                    <p><input id="metabox_term_enable_image_url" type="checkbox" value="1" name="metabox_term_enable_image_url" ' . ($options["metabox_term_enable_image_url"] == "1" ? 'checked="checked"' : '') . '" />
                    <label for="metabox_term_enable_image_url">
                    ' . __('Global image override.', 'add-meta-tags') . '
                    </label></p>

                ';
    }
    print '

                <h4>' . __('WordPress user profiles', 'add-meta-tags') . ':</h4>

                <p><input id="metabox_user_enable_full_metatags" type="checkbox" value="1" name="metabox_user_enable_full_metatags" ' . ($options["metabox_user_enable_full_metatags"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_user_enable_full_metatags">
                ' . __('Full meta tags box.', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_user_enable_image_url" type="checkbox" value="1" name="metabox_user_enable_image_url" ' . ($options["metabox_user_enable_image_url"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_user_enable_image_url">
                ' . __('Global image override.', 'add-meta-tags') . '
                </label></p>

                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Extra SEO Options', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Extra SEO Options', 'add-meta-tags') . '</span></legend>

                <input id="noodp_description" type="checkbox" value="1" name="noodp_description" ' . ($options["noodp_description"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noodp_description">' . __('Add <code>NOODP</code> and <code>NOYDIR</code> to the <em>robots</em> meta tag.', 'add-meta-tags') . '</label>
                <br />
                <br />

                <p>' . __('Add <code>NOINDEX,FOLLOW</code> to the <em>robots</em> meta tag on following types of archives:', 'add-meta-tags') . '</p>

                <p><input id="noindex_search_results" type="checkbox" value="1" name="noindex_search_results" ' . ($options["noindex_search_results"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_search_results">
                ' . __('Search results.', 'add-meta-tags') . ' (' . __('Highly recommended', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_date_archives" type="checkbox" value="1" name="noindex_date_archives" ' . ($options["noindex_date_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_date_archives">
                ' . __('Date based archives.', 'add-meta-tags') . ' (' . __('Recommended', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_category_archives" type="checkbox" value="1" name="noindex_category_archives" ' . ($options["noindex_category_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_category_archives">
                ' . __('Category based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_tag_archives" type="checkbox" value="1" name="noindex_tag_archives" ' . ($options["noindex_tag_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_tag_archives">
                ' . __('Tag based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_taxonomy_archives" type="checkbox" value="1" name="noindex_taxonomy_archives" ' . ($options["noindex_taxonomy_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_taxonomy_archives">
                ' . __('Custom taxonomy based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_author_archives" type="checkbox" value="1" name="noindex_author_archives" ' . ($options["noindex_author_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_author_archives">
                ' . __('Author based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <br />

                <p><input id="enforce_custom_title_in_metadata" type="checkbox" value="1" name="enforce_custom_title_in_metadata" ' . ($options["enforce_custom_title_in_metadata"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="enforce_custom_title_in_metadata">
                ' . __('Enforce the use of the content\'s custom title in the generated metadata.', 'add-meta-tags') . '
                </label></p>

                <br />

                <p><input id="enable_advanced_title_management" type="checkbox" value="1" name="enable_advanced_title_management" ' . ($options["enable_advanced_title_management"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="enable_advanced_title_management">
                ' . __('Enable advanced title management.', 'add-meta-tags') . '
                (<a target="_blank" href="http://www.codetrax.org/projects/wp-add-meta-tags/wiki/Advanced_Title_Management">' . __('Learn more', 'add-meta-tags') . '</a>)
                </label>

                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Copyright URL', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Copyright URL', 'add-meta-tags') . '</span></legend>

                <input name="copyright_url" type="text" id="copyright_url" class="code" value="' . esc_url(stripslashes(amt_get_site_copyright_url($options))) . '" size="100" maxlength="1024" />
                <br />
                <label for="copyright_url">
                ' . __('Enter an absolute URL to a document containing copyright and licensing information about your work.', 'add-meta-tags') . '
                </label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Default Image', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Default Image', 'add-meta-tags') . '</span></legend>

                <input name="default_image_url" type="text" id="default_image_url" class="code" value="' . amt_esc_id_or_url_notation(stripslashes($options["default_image_url"])) . '" size="100" maxlength="1024" />
                <br />

                <span id="amt-default-image-selector-button" class="amt-default-image-selector-button wp-media-buttons-icon loadmediawindow button updatemeta button-small">Select image</span>
                <br />

                <label for="default_image_url">
                ' . __('Enter an absolute URL to an image that represents your website, for instance the logo. To specify the image dimensions you can use the special notation <code>URL,WIDTHxHEIGHT</code>.', 'add-meta-tags') . '
                </label>
                <br />
        ';
    // Default image preview
    $image_data = amt_get_default_image_data();
    $img_html = '';
    if (is_numeric($image_data['id'])) {
        $main_size_meta = wp_get_attachment_image_src($image_data['id'], 'medium');
        $img_html = '<img src="' . esc_url($main_size_meta[0]) . '" width="' . esc_attr($main_size_meta[1]) . '" height="' . esc_attr($main_size_meta[2]) . '" />';
    } elseif (!is_null($image_data['url'])) {
        $img_html = '<img src="' . esc_url($image_data['url']) . '" width="' . esc_attr($image_data['width']) . '" height="' . esc_attr($image_data['height']) . '" />';
    }
    if (!empty($img_html)) {
        print '
                <p>' . __('Image preview', 'add-meta-tags') . ':</p>
                <br />
                <div id="amt-image-preview" class="amt-image-preview">' . $img_html . '</div>
                ';
    }
    print '
            </fieldset>
            </td>
            </tr>


            <tr valign="top">
            <th scope="row">' . __('Shortcodes', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Shortcodes', 'add-meta-tags') . '</span></legend>

                <input id="expand_shortcodes" type="checkbox" value="1" name="expand_shortcodes" ' . ($options["expand_shortcodes"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="expand_shortcodes">' . __('Enforce the expansion of shortcodes before generating a description.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Secure Access', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Secure Access', 'add-meta-tags') . '</span></legend>

                <input id="has_https_access" type="checkbox" value="1" name="has_https_access" ' . ($options["has_https_access"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="has_https_access">' . __('Media are accessible over HTTPS.', 'add-meta-tags') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Media Limit', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Media Limit', 'add-meta-tags') . '</span></legend>

                <input id="force_media_limit" type="checkbox" value="1" name="force_media_limit" ' . ($options["force_media_limit"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="force_media_limit">' . __('Do not generate metadata for more than one media file of each type (image, video, audio).', 'add-meta-tags') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Review Mode', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Review Mode', 'add-meta-tags') . '</span></legend>

                <input id="review_mode" type="checkbox" value="1" name="review_mode" ' . ($options["review_mode"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="review_mode">' . __('Enable <em>Metadata Review Mode</em>.', 'add-meta-tags') . '</label>
                <br />

                <input id="review_mode_metadata_report" type="checkbox" value="1" name="review_mode_metadata_report" ' . ($options["review_mode_metadata_report"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="review_mode_metadata_report">' . __('Enable keyword analysis and statistics.', 'add-meta-tags') . '</label>
                (<a target="_blank" href="http://www.codetrax.org/projects/wp-add-meta-tags/wiki/Metadata_Overview">' . __('Learn more', 'add-meta-tags') . '</a>)
                (<span style="color:red;">' . __('Experimental', 'add-meta-tags') . '</span>)
                <br />

                <input id="review_mode_omit_notices" type="checkbox" value="1" name="review_mode_omit_notices" ' . ($options["review_mode_omit_notices"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="review_mode_omit_notices">' . __('Omit help messages and notices. I have read, understood and agreed to them.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Extended Metadata Support', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Extended Metadata Support', 'add-meta-tags') . '</span></legend>

                <p>' . __('Add-Meta-Tags supports the generation of metadata for products and other post types. Please enable any of the following generators of extended metadata.', 'add-meta-tags') . '</p>

                <br />

                <p><input id="extended_support_woocommerce" type="checkbox" value="1" name="extended_support_woocommerce" ' . ($options["extended_support_woocommerce"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="extended_support_woocommerce">
                ' . __('Metadata for WooCommerce products and product groups.', 'add-meta-tags') . '
                </label></p>

                <p><input id="extended_support_edd" type="checkbox" value="1" name="extended_support_edd" ' . ($options["extended_support_edd"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="extended_support_edd">
                ' . __('Metadata for Easy-Digital-Downloads products and product groups.', 'add-meta-tags') . ' (<span style="color:red;">' . __('Work in progress', 'add-meta-tags') . '</span>)
                </label></p>

                <p><input id="extended_support_buddypress" type="checkbox" value="1" name="extended_support_buddypress" ' . ($options["extended_support_buddypress"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="extended_support_buddypress">
                ' . __('Metadata for BuddyPress profiles.', 'add-meta-tags') . '
                </label></p>

                <p><input id="extended_support_bbpress" type="checkbox" value="1" name="extended_support_bbpress" ' . ($options["extended_support_bbpress"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="extended_support_bbpress">
                ' . __('Metadata for bbPress.', 'add-meta-tags') . ' (<span style="color:red;">' . __('Work in progress', 'add-meta-tags') . '</span>)
                </label></p>

                <br />

                <p>' . __('Please consult the integrated help for more information about these features.', 'add-meta-tags') . '</p>

                <br />

            </fieldset>
            </td>
            </tr>
    ';
    // Metadata Caching
    if (apply_filters('amt_enable_metadata_cache', true)) {
        print '
            <tr valign="top">
            <th scope="row">' . __('Metadata Caching', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Metadata Caching', 'add-meta-tags') . '</span></legend>

                <input id="enable_timings" type="checkbox" value="1" name="enable_timings" ' . ($options["enable_timings"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="enable_timings">' . __('Show timing information.', 'add-meta-tags') . '</label>
                <br /><br />

                <label for="transient_cache_expiration">' . __('Cache metadata for this number of seconds:', 'add-meta-tags') . '</label>
                <input id="transient_cache_expiration" type="text" name="transient_cache_expiration" value="' . esc_attr($options["transient_cache_expiration"]) . '" size="10" maxlength="16" class="code" />
                <br /><br />

                <p>' . __('Metadata caching is an advanced feature and should only be used after you have read and fully understood the <em>Metadata caching</em> section of the integrated help.', 'add-meta-tags') . '</p>
                <br />
        ';
        // Metadata cache status
        if (absint($options["transient_cache_expiration"]) > 0) {
            // Get the number of cached entries
            // This only works when the database is used as the Transient Data storage backend.
            // If external storage backends are used for the transient data, this is always going to be zeo.
            $nr_cached_blocks = amt_count_transient_metadata_cache_entries();
            if (absint($nr_cached_blocks) > 0) {
                print '
                    <p>' . __('<strong>Metadata cache status</strong>: <em>Activated</em>, <strong style="color: green;">' . esc_attr($nr_cached_blocks) . '</strong> metadata blocks have been cached. All cached metadata blocks will be automatically purged the next time these settings are saved.', 'add-meta-tags') . '</p>
                    <br />
                ';
            } else {
                print '
                    <p>' . __('<strong>Metadata cache status</strong>: <em>Activated</em>, but no cached metadata blocks have been detected. This means that either no metadata blocks have been cached yet in the database or your WordPress installation uses an external storage backend for the transient data.', 'add-meta-tags') . '</p>
                    <br />
                ';
            }
        } else {
            print '
                <p>' . __('<strong>Metadata cache status</strong>: <em>Deactivated</em>. The caching timeout is set to zero, so metadata blocks are not cached.', 'add-meta-tags') . '</p>
                <br />
            ';
        }
        print '
            </fieldset>
            </td>
            </tr>
        ';
    }
    print '
            <tr valign="top">
            <th scope="row">' . __('Vendor HTML comments', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Vendor HTML comments', 'add-meta-tags') . '</span></legend>

                <p>
                    ' . __('Add-Meta-Tags has always been enclosing its output in <a target="_blank" href="http://www.codetrax.org/projects/wp-add-meta-tags/wiki/Screenshots#Vendor-HTML-comments">HTML comments</a>, which contain the plugin\'s name. This is common practice among WordPress plugin developers as it makes it easier for users to identify the output of a specific plugin and also lets those who check the HTML source code of the page know which plugin has generated this specific output. For a free product with limited resources like Add-Meta-Tags this practice is also its only means of exposure in a safe and non intrusive way.', 'add-meta-tags') . '
                </p>
                <br />

                <p>
                    ' . __('Although we don\'t like it, we have added the following option which deactivates the generation of those HTML comments*. We do not recommend checking the following box, but, if for whatever reason you have to turn these comments off, please go ahead and do it. To make it a little harder for you, an artificial requirement of a one time donation for any number of web sites you own has been added. Please keep in mind that there are no special donation links for this purpose. We do not force or keep track of your donations. You are free to go ahead and check this box without donating. What you do is totally your own decision and has nothing to do with us.', 'add-meta-tags') . '
                </p>
                <br />

                <input id="omit_vendor_html_comments" type="checkbox" value="1" name="omit_vendor_html_comments" ' . ($options["omit_vendor_html_comments"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="omit_vendor_html_comments">' . sprintf(__('I have made a one time <a target="_blank" href="%s">donation</a> of 5 USD or more for all the web sites I own.', 'add-meta-tags'), 'http://bit.ly/HvUakt') . '</label> **
                <br />

                <p>
                    ' . __('<em>* HTML comments that are generated as part of the Schema.org microdata are always retained.</em>', 'add-meta-tags') . '
                </p>
                <p>
                    ' . __('<em>** All Add-Meta-Tags contributors should feel free to check the option above without donating.</em>', 'add-meta-tags') . '
                </p>
                <br />

            </fieldset>
            </td>
            </tr>
    ';
    print '
            <tr valign="top">
            <th scope="row">' . __('Donations', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Donations', 'add-meta-tags') . '</span></legend>

                <input id="i_have_donated" type="checkbox" value="1" name="i_have_donated" ' . ($options["i_have_donated"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="i_have_donated">' . sprintf(__('If checked, the <em>message from the author</em> above goes away. Thanks for <a target="_blank" href="%s">donating</a>!', 'add-meta-tags'), 'http://bit.ly/HvUakt') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>

        </tbody>
        </table>

        <!-- Submit Buttons -->
        <table class="form-table">
        <tbody>
            <tr valign="top">
                <th scope="row">
                    <input id="submit" class="button-primary" type="submit" value="' . __('Save Changes', 'add-meta-tags') . '" name="info_update" />
                </th>

<!--
                <th scope="row">
                    <input id="reset" class="button-primary" type="submit" value="' . __('Reset to defaults', 'add-meta-tags') . '" name="info_reset" />
                </th>
-->

                <th></th><th></th><th></th><th></th>
            </tr>
        </tbody>
        </table>

        <br /><br /><br />

        <h2 class="title">' . __('Notes', 'add-meta-tags') . '</h2>

        <p>' . __('More management tools are available via the <code>amt</code> command of <code>wp-cli</code>. Learn more about the <a target="_blank" href="http://www.codetrax.org/projects/wp-add-meta-tags/wiki/Command_Line_Interface">Add-Meta-Tags command line interface</a>.', 'add-meta-tags') . '</p>


        </form>
        
    </div>

    ';
    print '
    </span> <!-- #add-meta-tags-settings -->
    ';
}
Ejemplo n.º 2
0
/**
 * Generates basic metadata for the head area.
 *
 */
function amt_add_basic_metadata_head($post, $attachments, $embedded_media, $options)
{
    $do_description = $options["auto_description"] == "1" ? true : false;
    $do_keywords = $options["auto_keywords"] == "1" ? true : false;
    $do_noodp_description = $options["noodp_description"] == "1" ? true : false;
    // Array to store metadata
    $metadata_arr = array();
    // Robots Meta Tag.
    $robots_content = '';
    if ($do_noodp_description && (is_front_page() || is_singular())) {
        // Add NOODP on posts and pages
        $robots_content = 'NOODP,NOYDIR';
        // Allow filtering of the robots meta tag content.
        $robots_content = apply_filters('amt_robots_data', $robots_content);
    }
    // Add a robots meta tag if its content is not empty.
    if (!empty($robots_content)) {
        $metadata_arr[] = '<meta name="robots" content="' . $robots_content . '" />';
    }
    // hreflang link element
    if ($options['generate_hreflang_links'] == '1') {
        if (is_singular()) {
            $locale = amt_get_language_content($options, $post);
            $hreflang = amt_get_the_hreflang($locale, $options);
            $hreflang_url = amt_get_permalink_for_multipage($post);
        } else {
            $locale = amt_get_language_site($options);
            $hreflang = amt_get_the_hreflang($locale, $options);
            $hreflang_url = '';
            if (amt_is_default_front_page()) {
                $hreflang_url = trailingslashit(get_bloginfo('url'));
            } elseif (is_category() || is_tag() || is_tax()) {
                // $post is a term object
                $hreflang_url = get_term_link($post);
            } elseif (is_author()) {
                // $post is an author object
                $hreflang_url = get_author_posts_url($post->ID);
            } elseif (is_year()) {
                $archive_year = get_the_time('Y');
                $hreflang_url = get_year_link($archive_year);
            } elseif (is_month()) {
                $archive_year = get_the_time('Y');
                $archive_month = get_the_time('m');
                $hreflang_url = get_month_link($archive_year, $archive_month);
            } elseif (is_day()) {
                $archive_year = get_the_time('Y');
                $archive_month = get_the_time('m');
                $archive_day = get_the_time('d');
                $hreflang_url = get_day_link($archive_year, $archive_month, $archive_day);
            }
            // If paged information is available
            if (is_paged()) {
                //$hreflang_url = trailingslashit( $hreflang_url ) . get_query_var('paged') . '/';
                $hreflang_url = get_pagenum_link(get_query_var('paged'));
            }
        }
        // hreflang links array
        $hreflang_arr = array();
        // Add link element
        if (!empty($hreflang) && !empty($hreflang_url)) {
            $hreflang_arr[] = '<link rel="alternate" hreflang="' . esc_attr($hreflang) . '" href="' . esc_url_raw($hreflang_url) . '" />';
        }
        // Allow filtering of the hreflang array
        $hreflang_arr = apply_filters('amt_hreflang_links', $hreflang_arr, $hreflang, $hreflang_url);
        // Add to to metadata array
        foreach ($hreflang_arr as $hreflang_link) {
            $metadata_arr[] = $hreflang_link;
        }
    }
    // Basic Meta Tags
    // Default front page displaying latest posts
    if (amt_is_default_front_page()) {
        // Description and Keywords from the Add-Meta-Tags settings override
        // default behaviour.
        // Description
        if ($do_description) {
            // Use the site description from the Add-Meta-Tags settings.
            // Fall back to the blog description.
            $site_description = amt_get_site_description($options);
            if (empty($site_description)) {
                // Alternatively, use the blog description
                // Here we sanitize the provided description for safety
                $site_description = sanitize_text_field(amt_sanitize_description(get_bloginfo('description')));
            }
            // If we have a description, use it in the description meta-tag of the front page
            if (!empty($site_description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($site_description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            // Use the site keywords from the Add-Meta-Tags settings.
            // Fall back to the blog categories.
            $site_keywords = amt_get_site_keywords($options);
            if (empty($site_keywords)) {
                // Alternatively, use the blog categories
                // Here we sanitize the provided keywords for safety
                $site_keywords = sanitize_text_field(amt_sanitize_keywords(amt_get_all_categories()));
            }
            // If we have keywords, use them in the keywords meta-tag of the front page
            if (!empty($site_keywords)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($site_keywords) . '" />';
            }
        }
        // Attachments
    } elseif (is_attachment()) {
        // has to be before is_singular() since is_singular() is true for attachments.
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // No keywords
        // Content pages and static pages used as "front page" and "posts page"
        // This also supports products via is_singular()
    } elseif (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            $keywords = amt_get_content_keywords($post, $auto = $do_keywords);
            if (!empty($keywords)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($keywords) . '" />';
                // Static Posts Index Page
                // If no keywords have been set in the metabox and this is the static page,
                // which displayes the latest posts, use the categories of the posts in the loop.
            } elseif (amt_is_static_home()) {
                // Here we sanitize the provided keywords for safety
                $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
                if (!empty($cats_from_loop)) {
                    $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
                }
            }
        }
        // 'news_keywords'
        $newskeywords = amt_get_post_meta_newskeywords($post->ID);
        if (!empty($newskeywords)) {
            $metadata_arr[] = '<meta name="news_keywords" content="' . esc_attr($newskeywords) . '" />';
        }
        // per post full meta tags
        $full_metatags_for_content = amt_get_post_meta_full_metatags($post->ID);
        if (!empty($full_metatags_for_content)) {
            $metadata_arr[] = html_entity_decode(stripslashes($full_metatags_for_content));
        }
        // Category based archives
    } elseif (is_category()) {
        if ($do_description) {
            // If set, the description of the category is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(category_description()));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_category_archive', __('Content filed under the %s category.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_cat_title($prefix = '', $display = false));
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The category name alone is included in the 'keywords' metatag
            // Here we sanitize the provided keywords for safety
            $cur_cat_name = sanitize_text_field(amt_sanitize_keywords(single_cat_title($prefix = '', $display = false)));
            if (!empty($cur_cat_name)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cur_cat_name) . '" />';
            }
        }
    } elseif (is_tag()) {
        if ($do_description) {
            // If set, the description of the tag is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(tag_description()));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_tag_archive', __('Content tagged with %s.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_tag_title($prefix = '', $display = false));
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The tag name alone is included in the 'keywords' metatag
            // Here we sanitize the provided keywords for safety
            $cur_tag_name = sanitize_text_field(amt_sanitize_keywords(single_tag_title($prefix = '', $display = false)));
            if (!empty($cur_tag_name)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cur_tag_name) . '" />';
            }
        }
        // Custom taxonomies - Should be after is_category() and is_tag(), as it would catch those taxonomies as well.
        // This also supports product groups via is_tax(). Only product groups that are WordPress custom taxonomies are supported.
    } elseif (is_tax()) {
        // Taxonomy term object.
        // When viewing taxonomy archives, the $post object is the taxonomy term object. Check with: var_dump($post);
        $tax_term_object = $post;
        //var_dump($tax_term_object);
        if ($do_description) {
            // If set, the description of the custom taxonomy term is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(term_description($tax_term_object->term_id, $tax_term_object->taxonomy)));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                // Construct the filter name. Template: ``amt_generic_description_TAXONOMYSLUG_archive``
                $taxonomy_description_filter_name = sprintf('amt_generic_description_%s_archive', $tax_term_object->taxonomy);
                // var_dump($taxonomy_description_filter_name);
                $generic_description = apply_filters($taxonomy_description_filter_name, __('Content filed under the %s taxonomy.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_term_title($prefix = '', $display = false));
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The taxonomy term name alone is included in the 'keywords' metatag.
            // Here we sanitize the provided keywords for safety.
            $cur_tax_term_name = sanitize_text_field(amt_sanitize_keywords(single_term_title($prefix = '', $display = false)));
            if (!empty($cur_tax_term_name)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cur_tax_term_name) . '" />';
            }
        }
    } elseif (is_author()) {
        // Author object
        // NOTE: Inside the author archives `$post->post_author` does not contain the author object.
        // In this case the $post (get_queried_object()) contains the author object itself.
        // We also can get the author object with the following code. Slug is what WP uses to construct urls.
        // $author = get_user_by( 'slug', get_query_var( 'author_name' ) );
        // Also, ``get_the_author_meta('....', $author)`` returns nothing under author archives.
        // Access user meta with:  $author->description, $author->user_email, etc
        // $author = get_queried_object();
        $author = $post;
        // If a bio has been set in the user profile, use it in the description metatag of the
        // first page of the author archive *ONLY*. The other pages of the author archive use a generic description.
        // This happens because the 1st page of the author archive is considered the profile page
        // by the other metadata modules.
        // Otherwise use a generic meta tag.
        if ($do_description) {
            // Here we sanitize the provided description for safety
            $author_description = sanitize_text_field(amt_sanitize_description($author->description));
            if (empty($author_description) || is_paged()) {
                // Note: Contains multipage information through amt_process_paged()
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_author_archive', __('Content published by %s.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, $author->display_name);
                $metadata_arr[] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr[] = '<meta name="description" content="' . esc_attr($author_description) . '" />';
            }
        }
        // For the keywords metatag use the categories of the posts the author has written and are displayed in the current page.
        if ($do_keywords) {
            // Here we sanitize the provided keywords for safety
            $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
            if (!empty($cats_from_loop)) {
                $metadata_arr[] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
            }
        }
    }
    // Add site wide meta tags
    if (!empty($options["site_wide_meta"])) {
        $metadata_arr[] = html_entity_decode(stripslashes($options["site_wide_meta"]));
    }
    // On every page print the copyright head link
    $copyright_url = amt_get_site_copyright_url($options);
    //if ( empty($copyright_url)) {
    //    $copyright_url = trailingslashit( get_bloginfo('url') );
    //}
    if (!empty($copyright_url)) {
        $metadata_arr[] = '<link rel="copyright" type="text/html" title="' . esc_attr(get_bloginfo('name')) . ' Copyright Information" href="' . esc_url_raw($copyright_url) . '" />';
    }
    // Filtering of the generated basic metadata
    $metadata_arr = apply_filters('amt_basic_metadata_head', $metadata_arr);
    return $metadata_arr;
}
Ejemplo n.º 3
0
/**
 * Function that adds the help tabs for the options.
 */
function amt_options_page()
{
    // Permission Check
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    // Default Add-Meta-Tags Settings
    $default_options = amt_get_default_options();
    if (isset($_POST['info_update'])) {
        // Save the Add-Meta-Tags settings
        amt_save_settings($_POST);
        // Also, since it may happen that the rewrite rules have not been flushed
        // this is a good place to do it.
        flush_rewrite_rules();
    } elseif (isset($_POST["info_reset"])) {
        amt_reset_settings();
    }
    // Get the options from the DB.
    $options = get_option("add_meta_tags_opts");
    //var_dump($options);
    /*
    Configuration Page
    */
    print '
    <div class="wrap">
        <div id="icon-options-general" class="icon32"><br /></div>
        <h2>' . __('Metadata Settings', 'add-meta-tags') . '</h2>

        <p>' . __('Welcome to the administration panel of the Add-Meta-Tags plugin.', 'add-meta-tags') . '</p>

    </div>

    <div class="wrap amt-settings-notice">

        <!-- <h3>' . __('Notice', 'add-meta-tags') . '</h3> -->

        <p>' . __('Press the <code>Help</code> button on the top right corner for an introduction to metadata and also for detailed <strong>documentation</strong> about the available settings and the metadata generators. All help texts will gradually be moved to this integrated WordPress help system in order to reduce the size of this page and make it more user-friendly.', 'add-meta-tags') . '</p>

    </div>

    <div class="wrap amt-settings-notice">

        <p>' . __('It is no longer possible to enter the URLs of the Publisher\'s social media profiles in the WordPress user profile page. Instead, this information should be entered in the relevant fields of the <strong>Publisher Settings</strong> section below.', 'add-meta-tags') . '</p>

    </div>

    <div class="wrap amt-settings-donations-msg" style="' . ($options["i_have_donated"] == "1" ? 'display: none;' : '') . '">

        <h3>' . __('Message from the author', 'add-meta-tags') . '</h3>

        <p><em>Add-Meta-Tags</em> is released under the terms of the <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License version 2</a> and, therefore, is <strong>Free software</strong>. It is actively maintained and supported free of charge since 2006.</p>

        <p>However, a significant amount of <strong>time</strong> and <strong>energy</strong> has been put into the development of this plugin, so, its production has not been free from cost. If you find this plugin useful and if it has helped your blog get indexed better and rank higher, I would appreciate an <a href="http://bit.ly/HvUakt">extra cup of coffee</a>.</p>
        <!--
        <p">Donations in BitCoin (BTC) are also accepted and welcome. Send the donated coin to the following address:</p>
        <ul>
            <li style="margin-left: 1em;">BitCoin (BTC): <code>1KkgpmaBKqQVk643VRhFRkL19Bbci4Mwn9</code></li>
        </ul>
        -->
        <p>Thank you in advance,<br />George Notaras</p>
        <div style="text-align: right;"><small>' . __('This message can be deactivated in the settings below.', 'add-meta-tags') . '</small></div>
    </div>

    <div class="wrap">
        <h2>' . __('Configuration', 'add-meta-tags') . '</h2>

        <p>' . __('This section contains global configuration options for the metadata that is added to your web site.', 'add-meta-tags') . '</p>

        <form name="formamt" method="post" action="' . admin_url('options-general.php?page=add-meta-tags-options') . '">

        <table class="form-table">
        <tbody>
    ';
    // General Settings
    if (amt_has_page_on_front()) {
        /* Options:
        
                    Example No pages
                    +-----------+----------------+--------------+----------+
                    | option_id | option_name    | option_value | autoload |
                    +-----------+----------------+--------------+----------+
                    |        58 | show_on_front  | posts        | yes      |
                    |        93 | page_for_posts | 0            | yes      |
                    |        94 | page_on_front  | 0            | yes      |
                    +-----------+----------------+--------------+----------+
        
                    Example pages as front page and posts page
                    +-----------+----------------+--------------+----------+
                    | option_id | option_name    | option_value | autoload |
                    +-----------+----------------+--------------+----------+
                    |        58 | show_on_front  | page         | yes      |
                    |        93 | page_for_posts | 28           | yes      |
                    |        94 | page_on_front  | 25           | yes      |
                    +-----------+----------------+--------------+----------+
        
                */
        print '
            <tr valign="top">
            <th scope="row">' . __('Front Page Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Front Page Metadata', 'add-meta-tags') . '</span></legend>
                ' . __('It appears that you use static pages on the <em>front page</em> and the <em>latest posts page</em> of this web site. Please visit the editing panel of these pages and set the <code>description</code> and the <code>keywords</code> meta tags in the relevant Metadata box.', 'add-meta-tags') . '
                ';
        print '<ul>';
        $front_page_id = get_option('page_on_front');
        if (intval($front_page_id) > 0) {
            printf('<li>&raquo; ' . __('Edit the <a href="%s">front page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($front_page_id)));
        }
        $posts_page_id = get_option('page_for_posts');
        if (intval($posts_page_id) > 0) {
            printf('<li>&raquo; ' . __('Edit the <a href="%s">posts page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($posts_page_id)));
        }
        print '</ul>';
        print '
            </fieldset>
            </td>
            </tr>
        ';
    } else {
        print '
            <tr valign="top">
            <th scope="row">' . __('Front Page Description', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Front Page Description', 'add-meta-tags') . '</span></legend>
                
                <textarea name="site_description" id="site_description" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_description($options))) . '</textarea>
                <br />
                <label for="site_description">
                    ' . __('Enter a short description of your blog (150-250 characters).', 'add-meta-tags') . '
                </label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Front Page Keywords', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Front Page Keywords', 'add-meta-tags') . '</span></legend>
                
                <textarea name="site_keywords" id="site_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_keywords($options))) . '</textarea>
                <br />
                <label for="site_keywords">' . __('Enter a comma-delimited list of keywords for your blog.', 'add-meta-tags') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>
        ';
    }
    print '
            <tr valign="top">
            <th scope="row">' . __('Global Keywords', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Global Keywords', 'add-meta-tags') . '</span></legend>
                
                <textarea name="global_keywords" id="global_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_global_keywords($options))) . '</textarea>
                <br />
                <label for="global_keywords">' . __('Enter a comma-delimited list of global keywords.', 'add-meta-tags') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Site-wide META tags', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Site-wide META tags', 'add-meta-tags') . '</span></legend>

                <textarea name="site_wide_meta" id="site_wide_meta" cols="100" rows="10" class="code">' . stripslashes($options["site_wide_meta"]) . '</textarea>
                <br />
                <label for="site_wide_meta">
                ' . __('Enter complete <a href="http://en.wikipedia.org/wiki/Meta_element" target="_blank">meta tags</a> which will appear on all web pages.', 'add-meta-tags') . '
                </label>
                <br />
            </fieldset>
            </td>
            </tr>

    ';
    // Publisher Settings
    print '
            <tr valign="top">
            <th scope="row">' . __('Publisher Settings', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Publisher Settings', 'add-meta-tags') . '</span></legend>

                <p>' . __('This section contains options related to your web site; the publisher of the content.', 'add-meta-tags') . '</p>
                <p>' . __('The following publisher related settings are shared among all users. Filling in these settings is entirely optional.', 'add-meta-tags') . '</p>

                <h4>' . __('Facebook publisher profile URL', 'add-meta-tags') . ':</h4>

                <input name="social_main_facebook_publisher_profile_url" type="text" id="social_main_facebook_publisher_profile_url" class="code" value="' . esc_url_raw(stripslashes($options["social_main_facebook_publisher_profile_url"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="social_main_facebook_publisher_profile_url">
                ' . __('Enter an absolute URL to the Facebook profile of the publisher. If this is filled in, it will be used in the <code>article:publisher</code> meta tag.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>https://www.facebook.com/awesome.editors</code></p>
                <br />

                <!-- We currently let users add the full meta tags for fb:app_id and fb:admins in the site wide meta tags box.

                <h4>' . __('Facebook App ID', 'add-meta-tags') . ':</h4>

                <input name="social_main_facebook_app_id" type="text" id="social_main_facebook_app_id" class="code" value=" . esc_url_raw( stripslashes( $options["social_main_facebook_app_id"] ) ) . " size="100" maxlength="1024" />
                <br />
                <label for="social_main_facebook_app_id">
                ' . __('Enter the App ID for <a target="_blank" href="https://developers.facebook.com/docs/platforminsights">Facebook Insights</a>.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>1234567890</code></p>
                <br />

                <h4>' . __('Facebook Admin ID list', 'add-meta-tags') . ':</h4>

                <input name="social_main_facebook_admins" type="text" id="social_main_facebook_admins" class="code" value=" . esc_url_raw( stripslashes( $options["social_main_facebook_admins"] ) ) . " size="100" maxlength="1024" />
                <br />
                <label for="social_main_facebook_admins">
                ' . __('Enter a comma delimited list of numerical Facebook user IDs which will have access to <a target="_blank" href="https://developers.facebook.com/docs/platforminsights">Facebook Insights</a>.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>1111111111,2222222222</code></p>
                <br />

                -->

                <h4>' . __('Google+ publisher profile URL', 'add-meta-tags') . ':</h4>

                <input name="social_main_googleplus_publisher_profile_url" type="text" id="social_main_googleplus_publisher_profile_url" class="code" value="' . esc_url_raw(stripslashes($options["social_main_googleplus_publisher_profile_url"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="social_main_googleplus_publisher_profile_url">
                ' . __('Enter an absolute URL to the Google+ profile of the publisher. If this is filled in, it will be used in the link with <code>rel="publisher"</code> in the HEAD area of the web page.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>https://plus.google.com/+AwesomeEditors/</code></p>
                <br />

                <h4>' . __('Twitter publisher username', 'add-meta-tags') . ':</h4>

                <input name="social_main_twitter_publisher_username" type="text" id="social_main_twitter_publisher_username" class="code" value="' . esc_attr(stripslashes($options["social_main_twitter_publisher_username"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="social_main_twitter_publisher_username">
                ' . __('Enter the Twitter username of the publisher (without @).', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>AwesomeEditors</code></p>
                <br />

            </fieldset>
            </td>
            </tr>
    ';
    // Basic Metadata
    print '
            <tr valign="top">
            <th scope="row">' . __('Basic Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Basic Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_description" type="checkbox" value="1" name="auto_description" ' . ($options["auto_description"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_description">' . __('Automatically generate the <em>description</em> meta tag.', 'add-meta-tags') . '</label>
                <br />

                <input id="auto_keywords" type="checkbox" value="1" name="auto_keywords" ' . ($options["auto_keywords"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_keywords">' . __('Automatically generate the <em>keywords</em> meta tag.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Opengraph Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Opengraph Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_opengraph" type="checkbox" value="1" name="auto_opengraph" ' . ($options["auto_opengraph"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_opengraph">' . __('Automatically generate Opengraph meta tags.', 'add-meta-tags') . '</label>
                <br />

                <input id="og_omit_video_metadata" type="checkbox" value="1" name="og_omit_video_metadata" ' . ($options["og_omit_video_metadata"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="og_omit_video_metadata">' . __('Omit <code>og:video</code> meta tags.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Twitter Cards Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Twitter Cards Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_twitter" type="checkbox" value="1" name="auto_twitter" ' . ($options["auto_twitter"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_twitter">' . __('Automatically generate Twitter Cards meta tags.', 'add-meta-tags') . '</label>
                <br />

                <input id="tc_enforce_summary_large_image" type="checkbox" value="1" name="tc_enforce_summary_large_image" ' . ($options["tc_enforce_summary_large_image"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="tc_enforce_summary_large_image">' . __('Enforce the use of <code>summary_large_image</code> as default card type.', 'add-meta-tags') . '</label>
                <br />

                <input id="tc_enable_player_card_local" type="checkbox" value="1" name="tc_enable_player_card_local" ' . ($options["tc_enable_player_card_local"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="tc_enable_player_card_local">' . __('Enable the generation of <em>player</em> cards for local media.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Dublin Core Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Dublin Core Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_dublincore" type="checkbox" value="1" name="auto_dublincore" ' . ($options["auto_dublincore"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_dublincore">' . __('Automatically generate Dublin Core metadata.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Schema.org Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Schema.org Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_schemaorg" type="checkbox" value="1" name="auto_schemaorg" ' . ($options["auto_schemaorg"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_schemaorg">' . __('Automatically generate and embed Schema.org Microdata.', 'add-meta-tags') . '</label> (Experimental feature)
                <br />

                <input id="schemaorg_force_jsonld" type="checkbox" value="1" name="schemaorg_force_jsonld" ' . ($options["schemaorg_force_jsonld"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="schemaorg_force_jsonld">' . __('Enforce the generation of schema.org metadata as JSON-LD data.', 'add-meta-tags') . '</label> (<span style="color:red;">For testing only</span>)
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Locale', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Locale', 'add-meta-tags') . '</span></legend>

                <input name="global_locale" type="text" id="global_locale" class="code" value="' . esc_attr(stripslashes($options["global_locale"])) . '" size="20" maxlength="32" />
                <br />
                <label for="global_locale">
                ' . __('Enter a locale, for example <code>en_US</code> or <code>zh_Hans_TW</code>, which will be used globally in the generated metadata overriding the default locale as returned by WordPress.', 'add-meta-tags') . '
                </label>
                <br />

                <input id="manage_html_lang_attribute" type="checkbox" value="1" name="manage_html_lang_attribute" ' . ($options["manage_html_lang_attribute"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="manage_html_lang_attribute">' . __('Automatically set the HTML document\'s <code>lang</code> attribute according to the locale of the content.', 'add-meta-tags') . '</label>
                <br />

                <input id="generate_hreflang_links" type="checkbox" value="1" name="generate_hreflang_links" ' . ($options["generate_hreflang_links"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="generate_hreflang_links">' . __('Enable the generation of a <code>link</code> element with the <code>hreflang</code> attribute.', 'add-meta-tags') . '</label>
                <br />

                <input id="hreflang_strip_region" type="checkbox" value="1" name="hreflang_strip_region" ' . ($options["hreflang_strip_region"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="hreflang_strip_region">' . __('Strip region code from the hreflang attribute.', 'add-meta-tags') . '</label>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Metabox Features', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Metabox Features', 'add-meta-tags') . '</span></legend>

                <p>' . __('It is possible to partially customize the generated metadata on a per post basis through the <em>Metadata</em> metabox which exists in the post editing screen. Below you can choose which metabox features should be enabled. Enabling or disabling these features has no effect on the custom data that has been stored for each post.', 'add-meta-tags') . '</p>

                <p><input id="metabox_enable_description" type="checkbox" value="1" name="metabox_enable_description" ' . ($options["metabox_enable_description"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_description">
                ' . __('Custom description (<em>Recommended</em>).', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_keywords" type="checkbox" value="1" name="metabox_enable_keywords" ' . ($options["metabox_enable_keywords"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_keywords">
                ' . __('Custom keywords (<em>Recommended</em>).', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_title" type="checkbox" value="1" name="metabox_enable_title" ' . ($options["metabox_enable_title"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_title">
                ' . __('Custom content of the <code>title</code> HTML element.', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_news_keywords" type="checkbox" value="1" name="metabox_enable_news_keywords" ' . ($options["metabox_enable_news_keywords"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_news_keywords">
                ' . __('Custom news keywords. (<a target="_blank" href="http://support.google.com/news/publisher/bin/answer.py?hl=en&answer=68297">more info</a>)', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_full_metatags" type="checkbox" value="1" name="metabox_enable_full_metatags" ' . ($options["metabox_enable_full_metatags"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_full_metatags">
                ' . __('Full meta tags box.', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_image_url" type="checkbox" value="1" name="metabox_enable_image_url" ' . ($options["metabox_enable_image_url"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_image_url">
                ' . __('Global image override.', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_content_locale" type="checkbox" value="1" name="metabox_enable_content_locale" ' . ($options["metabox_enable_content_locale"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_content_locale">
                ' . __('Content locale override. (Not to be used in conjunction with a multilingual plugin.) ', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_express_review" type="checkbox" value="1" name="metabox_enable_express_review" ' . ($options["metabox_enable_express_review"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_express_review">
                ' . __('Express review. (Experimental feature. For advanced users only.)', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_referenced_list" type="checkbox" value="1" name="metabox_enable_referenced_list" ' . ($options["metabox_enable_referenced_list"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_referenced_list">
                ' . __('Referenced items. (Experimental feature. Not recommended.)', 'add-meta-tags') . '
                </label></p>

                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Extra SEO Options', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Extra SEO Options', 'add-meta-tags') . '</span></legend>

                <input id="noodp_description" type="checkbox" value="1" name="noodp_description" ' . ($options["noodp_description"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noodp_description">' . __('Add <code>NOODP</code> and <code>NOYDIR</code> to the <em>robots</em> meta tag.', 'add-meta-tags') . '</label>
                <br />

                <p>' . __('Add <code>NOINDEX,FOLLOW</code> to the <em>robots</em> meta tag on following types of archives:', 'add-meta-tags') . '</p>

                <p><input id="noindex_search_results" type="checkbox" value="1" name="noindex_search_results" ' . ($options["noindex_search_results"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_search_results">
                ' . __('Search results. (<em>Highly recommended</em>)', 'add-meta-tags') . '
                </label></p>

                <p><input id="noindex_date_archives" type="checkbox" value="1" name="noindex_date_archives" ' . ($options["noindex_date_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_date_archives">
                ' . __('Date based archives. (<em>Recommended</em>)', 'add-meta-tags') . '
                </label></p>

                <p><input id="noindex_category_archives" type="checkbox" value="1" name="noindex_category_archives" ' . ($options["noindex_category_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_category_archives">
                ' . __('Category based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_tag_archives" type="checkbox" value="1" name="noindex_tag_archives" ' . ($options["noindex_tag_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_tag_archives">
                ' . __('Tag based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_taxonomy_archives" type="checkbox" value="1" name="noindex_taxonomy_archives" ' . ($options["noindex_taxonomy_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_taxonomy_archives">
                ' . __('Custom taxonomy based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_author_archives" type="checkbox" value="1" name="noindex_author_archives" ' . ($options["noindex_author_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_author_archives">
                ' . __('Author based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Copyright URL', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Copyright URL', 'add-meta-tags') . '</span></legend>

                <input name="copyright_url" type="text" id="copyright_url" class="code" value="' . esc_url_raw(stripslashes(amt_get_site_copyright_url($options))) . '" size="100" maxlength="1024" />
                <br />
                <label for="copyright_url">
                ' . __('Enter an absolute URL to a document containing copyright and licensing information about your work.', 'add-meta-tags') . '
                </label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Default Image', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Default Image', 'add-meta-tags') . '</span></legend>

                <input name="default_image_url" type="text" id="default_image_url" class="code" value="' . esc_url_raw(stripslashes($options["default_image_url"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="default_image_url">
                ' . __('Enter an absolute URL to an image that represents your website, for instance the logo.', 'add-meta-tags') . '
                </label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Secure Access', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Secure Access', 'add-meta-tags') . '</span></legend>

                <input id="has_https_access" type="checkbox" value="1" name="has_https_access" ' . ($options["has_https_access"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="has_https_access">' . __('Media are accessible over HTTPS.', 'add-meta-tags') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Media Limit', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Media Limit', 'add-meta-tags') . '</span></legend>

                <input id="force_media_limit" type="checkbox" value="1" name="force_media_limit" ' . ($options["force_media_limit"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="force_media_limit">' . __('Do not generate metadata for more than one media file of each type (image, video, audio).', 'add-meta-tags') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Extended Metadata Support', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Extended Metadata Support', 'add-meta-tags') . '</span></legend>

                <p>' . __('Add-Meta-Tags supports the generation of metadata for products and other post types. Please enable any of the following generators of extended metadata.', 'add-meta-tags') . '</p>

                <p><input id="extended_support_woocommerce" type="checkbox" value="1" name="extended_support_woocommerce" ' . ($options["extended_support_woocommerce"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="extended_support_woocommerce">
                ' . __('Metadata for WooCommerce products and product groups.', 'add-meta-tags') . ' (<span style="color:red;">Work in progress</span>)
                </label></p>

                <p><input id="extended_support_edd" type="checkbox" value="1" name="extended_support_edd" ' . ($options["extended_support_edd"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="extended_support_edd">
                ' . __('Metadata for Easy-Digital-Downloads products and product groups.', 'add-meta-tags') . ' (<span style="color:red;">Work in progress</span>)
                </label></p>

                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Review Mode', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Review Mode', 'add-meta-tags') . '</span></legend>

                <input id="review_mode" type="checkbox" value="1" name="review_mode" ' . ($options["review_mode"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="review_mode">' . __('Enable <em>Metadata Review Mode</em>.') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Donations', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Donations', 'add-meta-tags') . '</span></legend>

                <input id="i_have_donated" type="checkbox" value="1" name="i_have_donated" ' . ($options["i_have_donated"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="i_have_donated">' . sprintf(__('If checked, the <em>message from the author</em> above goes away. Thanks for <a href="%s">donating</a>!', 'add-meta-tags'), 'http://bit.ly/HvUakt') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>

        </tbody>
        </table>

        <!-- Submit Buttons -->
        <table class="form-table">
        <tbody>
            <tr valign="top">
                <th scope="row">
                    <input id="submit" class="button-primary" type="submit" value="' . __('Save Changes', 'add-meta-tags') . '" name="info_update" />
                </th>
                <th scope="row">
                    <input id="reset" class="button-primary" type="submit" value="' . __('Reset to defaults', 'add-meta-tags') . '" name="info_reset" />
                </th>
                <th></th><th></th><th></th><th></th>
            </tr>
        </tbody>
        </table>

        </form>
        
    </div>

    ';
}
Ejemplo n.º 4
0
function amt_options_page()
{
    // Permission Check
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    // Default Add-Meta-Tags Settings
    $default_options = amt_get_default_options();
    if (isset($_POST['info_update'])) {
        // Save the Add-Meta-Tags settings
        amt_save_settings($_POST);
        // Also, since it may happen that the rewrite rules have not been flushed
        // this is a good place to do it.
        flush_rewrite_rules();
    } elseif (isset($_POST["info_reset"])) {
        amt_reset_settings();
    }
    // Get the options from the DB.
    $options = get_option("add_meta_tags_opts");
    //var_dump($options);
    /*
    Configuration Page
    */
    print '
    <div class="wrap">
        <div id="icon-options-general" class="icon32"><br /></div>
        <h2>' . __('Metadata Settings', 'add-meta-tags') . '</h2>
        <p>' . __('Welcome to the administration panel of the Add-Meta-Tags plugin.', 'add-meta-tags') . '</p>
        <p>' . __('<em>Metadata</em> refers to information that describes the content in a machine-friendly way. Search engines and other online services use this metadata to better understand your content. Keep in mind that metadata itself does not automatically make your blog rank better. For this to happen the content is still required to meet various quality standards. However, the presence of accurate and adequate metadata gives search engines and other services the chance to make less guesses about your content, index and categorize it better and, eventually, deliver it to an audience that finds it useful.  Good metadata facilitates this process and thus plays a significant role in achieving better rankings. This is what the Add-Meta-Tags plugin does.', 'add-meta-tags') . '</p>
    </div>

    <div class="wrap" style="background: #EEF6E6; padding: 1em 2em; border: 1px solid #E4E4E4;' . ($options["i_have_donated"] == "1" ? ' display: none;' : '') . '">
        <h2>' . __('Message from the author', 'add-meta-tags') . '</h2>
        <p style="font-size: 1.2em; padding-left: 2em;"><em>Add-Meta-Tags</em> is released under the terms of the <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License version 2</a> and, therefore, is <strong>Free software</strong>.</p>
        <p style="font-size: 1.2em; padding-left: 2em;">However, a significant amount of <strong>time</strong> and <strong>energy</strong> has been put into developing this plugin, so, its production has not been free from cost. If you find this plugin useful and if it has helped your blog get indexed better and rank higher, I would appreciate an <a href="http://bit.ly/HvUakt">extra cup of coffee</a>.</p>
        <!--
        <p style="font-size: 1.2em; padding-left: 2em;">Donations in the following crypto currencies are also accepted and welcome. Send coins to the following addresses:</p>
        <ul style="font-size: 1.2em; padding-left: 2em;">
            <li style="padding-left: 1em;">- BitCoin (BTC): <code style="font-size: 1.2em;">1KkgpmaBKqQVk643VRhFRkL19Bbci4Mwn9</code></li>
            <li style="padding-left: 1em;">- LiteCoin (LTC): <code style="font-size: 1.2em;">LS8UF39LfLahzGo49y736ooRYBVT1zZ2Fa</code></li>
        </ul>
        -->
        <p style="font-size: 1.2em; padding-left: 2em;">Thank you in advance,<br />George Notaras</p>
        <div style="text-align: right;"><small>' . __('This message can be deactivated in the settings below.', 'add-meta-tags') . '</small></div>
    </div>

    <div class="wrap">
        <h2>' . __('How it works', 'add-meta-tags') . '</h2>
        
        <p>' . __('Add-Meta-Tags tries to follow the "<em>It just works</em>" principal. By default, the <em>description</em> and <em>keywords</em> meta tags are added to the front page, posts, pages, public custom post types, attachment pages, category, tag, custom taxonomy and author based archives. Furthermore, it is possible to enable the generation of <em>Opengraph</em>, <em>Dublin Core</em>, <em>Twitter Cards</em> and <em>Schema.org</em> metadata. The plugin also supports some extra SEO related functionality that helps you fine tune your web site.', 'add-meta-tags') . '</p>
        
        <p>' . __('The automatically generated metadata can be further customized for each individual post, page, or any public custom post type directly from the <em>Metadata</em> box inside the post editing panel. If the <em>Metadata</em> box is not visible, you probably need to enable it at the <a href="http://en.support.wordpress.com/screen-options/">Screen Options</a> of the post editing panel.', 'add-meta-tags') . '</p>

        <p>' . __('Apart from the customization through the WordPress administration interface, the generated metadata and specific aspects of the plugin\'s functionality can be further customized to a great extent programmatically. Read the technical notes at the <a href="http://www.codetrax.org/projects/wp-add-meta-tags/wiki" title="Add-Meta-Tags Development web site">development web site</a> and find ready sample code snippets for commonly needed customizations in the <a href="http://www.codetrax.org/projects/wp-add-meta-tags/wiki/Add-Meta-Tags_Cookbook" title="Add-Meta-Tags Cookbook">Add-Meta-Tags Cookbook</a>.', 'add-meta-tags') . '</p>

    </div>

    <div class="wrap">
        <h2>' . __('Configuration', 'add-meta-tags') . '</h2>

        <p>' . __('This section contains global configuration options for the metadata that is added to your web site.', 'add-meta-tags') . '</p>

        

        <form name="formamt" method="post" action="' . admin_url('options-general.php?page=add-meta-tags-options') . '">

        <table class="form-table">
        <tbody>
    ';
    if (amt_has_page_on_front()) {
        /* Options:
        
                    Example No pages
                    +-----------+----------------+--------------+----------+
                    | option_id | option_name    | option_value | autoload |
                    +-----------+----------------+--------------+----------+
                    |        58 | show_on_front  | posts        | yes      |
                    |        93 | page_for_posts | 0            | yes      |
                    |        94 | page_on_front  | 0            | yes      |
                    +-----------+----------------+--------------+----------+
        
                    Example pages as front page and posts page
                    +-----------+----------------+--------------+----------+
                    | option_id | option_name    | option_value | autoload |
                    +-----------+----------------+--------------+----------+
                    |        58 | show_on_front  | page         | yes      |
                    |        93 | page_for_posts | 28           | yes      |
                    |        94 | page_on_front  | 25           | yes      |
                    +-----------+----------------+--------------+----------+
        
                */
        print '
            <tr valign="top">
            <th scope="row">' . __('Front Page Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Front Page Metadata', 'add-meta-tags') . '</span></legend>
                ' . __('It appears that you use static pages on the <em>front page</em> and the <em>latest posts page</em> of this web site. Please visit the editing panel of these pages and set the <code>description</code> and the <code>keywords</code> meta tags in the relevant Metadata box.', 'add-meta-tags') . '
                ';
        print '<ul>';
        $front_page_id = get_option('page_on_front');
        if (intval($front_page_id) > 0) {
            printf('<li>&raquo; ' . __('Edit the <a href="%s">front page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($front_page_id)));
        }
        $posts_page_id = get_option('page_for_posts');
        if (intval($posts_page_id) > 0) {
            printf('<li>&raquo; ' . __('Edit the <a href="%s">posts page</a>', 'add-meta-tags') . '</li>', get_edit_post_link(intval($posts_page_id)));
        }
        print '</ul>';
        print '
            </fieldset>
            </td>
            </tr>
        ';
    } else {
        print '
            <tr valign="top">
            <th scope="row">' . __('Front Page Description', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Front Page Description', 'add-meta-tags') . '</span></legend>
                
                <textarea name="site_description" id="site_description" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_description($options))) . '</textarea>
                <br />
                <label for="site_description">
                    ' . __('Enter a short (150-250 characters long) description of your blog. This text will be used in the <em>description</em> and other similar metatags on the <strong>front page</strong>. If this is left empty, then the blog\'s <em>Tagline</em> from the <a href="options-general.php">General Options</a> will be used.', 'add-meta-tags') . '
                </label>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Front Page Keywords', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Front Page Keywords', 'add-meta-tags') . '</span></legend>
                
                <textarea name="site_keywords" id="site_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_keywords($options))) . '</textarea>
                <br />
                <label for="site_keywords">' . __('Enter a comma-delimited list of keywords for your blog. These keywords will be used in the <em>keywords</em> meta tag on the <strong>front page</strong>. If this field is left empty, then all of your blog\'s <a href="edit-tags.php?taxonomy=category">categories</a> will be used as keywords for the <em>keywords</em> meta tag.', 'add-meta-tags') . '</label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>' . __('keyword1, keyword2, keyword3', 'add-meta-tags') . '</code></p>
                <br />
            </fieldset>
            </td>
            </tr>
        ';
    }
    print '
            <tr valign="top">
            <th scope="row">' . __('Global Keywords', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Global Keywords', 'add-meta-tags') . '</span></legend>
                
                <textarea name="global_keywords" id="global_keywords" cols="100" rows="2" class="code">' . esc_attr(stripslashes(amt_get_site_global_keywords($options))) . '</textarea>
                <br />
                <label for="global_keywords">' . __('Enter a comma-delimited list of global keywords which will be added before the keywords of <strong>all</strong> posts and pages.', 'add-meta-tags') . '</label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>' . __('keyword1, keyword2, keyword3', 'add-meta-tags') . '</code></p>
                <br />
                <p>' . __('By default, these keywords are prepended to the post/page\'s keywords. For enhanced flexibility, it is possible to use the <code>%contentkw%</code> placeholder, which will be populated with the post/page\'s autogenerated or user-defined keywords. This way you can globally both prepend and append keywords to the <em>keywords</em> of your content.', 'add-meta-tags') . '</p>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>' . __('keyword1, keyword2, %contentkw%, keyword3', 'add-meta-tags') . '</code></p>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Site-wide META tags', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Site-wide META tags', 'add-meta-tags') . '</span></legend>

                <textarea name="site_wide_meta" id="site_wide_meta" cols="100" rows="10" class="code">' . stripslashes($options["site_wide_meta"]) . '</textarea>
                <br />
                <label for="site_wide_meta">
                ' . __('Provide the full XHTML code of extra META elements you would like to add to all the pages of your web site (read more about the <a href="http://en.wikipedia.org/wiki/Meta_element" target="_blank">META HTML element</a> on Wikipedia).', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Examples', 'add-meta-tags') . '</strong>:</p>
                <p><code>&lt;meta name="google-site-verification" content="1234567890" /&gt;</code></p>
                <p><code>&lt;meta name="msvalidate.01" content="1234567890" /&gt;</code></p>
                <p><code>&lt;meta name="robots" content="noimageindex" /&gt;</code></p>
                <p><code>&lt;meta property="fb:admins" content="1234" /&gt;</code></p>
                <p><code>&lt;meta property="fb:app_id" content="4321" /&gt;</code></p>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Publisher Settings', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Publisher Settings', 'add-meta-tags') . '</span></legend>

                <p>' . __('This section contains options related to your web site; the publisher of the content.', 'add-meta-tags') . '</p>
                <p>' . __('The following publisher related settings are shared among all users. Filling in these settings is entirely optional.', 'add-meta-tags') . '</p>

                <h4>' . __('Facebook publisher profile URL', 'add-meta-tags') . ':</h4>

                <input name="social_main_facebook_publisher_profile_url" type="text" id="social_main_facebook_publisher_profile_url" class="code" value="' . esc_url_raw(stripslashes($options["social_main_facebook_publisher_profile_url"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="social_main_facebook_publisher_profile_url">
                ' . __('Enter an absolute URL to the Facebook profile of the publisher. If this is filled in, it will be used in the <code>article:publisher</code> meta tag.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>https://www.facebook.com/awesome.editors</code></p>
                <br />

                <!-- We currently let users add the full meta tags for fb:app_id and fb:admins in the site wide meta tags box.

                <h4>' . __('Facebook App ID', 'add-meta-tags') . ':</h4>

                <input name="social_main_facebook_app_id" type="text" id="social_main_facebook_app_id" class="code" value=" . esc_url_raw( stripslashes( $options["social_main_facebook_app_id"] ) ) . " size="100" maxlength="1024" />
                <br />
                <label for="social_main_facebook_app_id">
                ' . __('Enter the App ID for <a target="_blank" href="https://developers.facebook.com/docs/platforminsights">Facebook Insights</a>.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>1234567890</code></p>
                <br />

                <h4>' . __('Facebook Admin ID list', 'add-meta-tags') . ':</h4>

                <input name="social_main_facebook_admins" type="text" id="social_main_facebook_admins" class="code" value=" . esc_url_raw( stripslashes( $options["social_main_facebook_admins"] ) ) . " size="100" maxlength="1024" />
                <br />
                <label for="social_main_facebook_admins">
                ' . __('Enter a comma delimited list of numerical Facebook user IDs which will have access to <a target="_blank" href="https://developers.facebook.com/docs/platforminsights">Facebook Insights</a>.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>1111111111,2222222222</code></p>
                <br />

                -->

                <h4>' . __('Google+ publisher profile URL', 'add-meta-tags') . ':</h4>

                <input name="social_main_googleplus_publisher_profile_url" type="text" id="social_main_googleplus_publisher_profile_url" class="code" value="' . esc_url_raw(stripslashes($options["social_main_googleplus_publisher_profile_url"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="social_main_googleplus_publisher_profile_url">
                ' . __('Enter an absolute URL to the Google+ profile of the publisher. If this is filled in, it will be used in the link with <code>rel="publisher"</code> in the HEAD area of the web page.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>https://plus.google.com/+AwesomeEditors/</code></p>
                <br />

                <h4>' . __('Twitter publisher username', 'add-meta-tags') . ':</h4>

                <input name="social_main_twitter_publisher_username" type="text" id="social_main_twitter_publisher_username" class="code" value="' . esc_attr(stripslashes($options["social_main_twitter_publisher_username"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="social_main_twitter_publisher_username">
                ' . __('Enter the Twitter username of the publisher (without @).', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>AwesomeEditors</code></p>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Basic Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Basic Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_description" type="checkbox" value="1" name="auto_description" ' . ($options["auto_description"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_description">' . __('Automatically generate the <em>description</em> meta tag.', 'add-meta-tags') . '</label>
                <p>' . __('If this option is enabled, the <em>description</em> meta tag is automatically generated for the content, attachments and archives. Customization of the <em>description</em> meta tag is possible through the <em>Metadata</em> box in the post editing screen.', 'add-meta-tags') . '</p>
                <br />

                <input id="auto_keywords" type="checkbox" value="1" name="auto_keywords" ' . ($options["auto_keywords"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_keywords">' . __('Automatically generate the <em>keywords</em> meta tag.', 'add-meta-tags') . '</label>
                <p>' . __('If this option is enabled, the <em>keywords</em> meta tag is automatically generated for the content and archives. Keywords are not generated automatically on pages and attachments. Customization of the <em>keywords</em> meta tag is possible through the <em>Metadata</em> box in the post editing screen.', 'add-meta-tags') . '</p>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Opengraph Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Opengraph Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_opengraph" type="checkbox" value="1" name="auto_opengraph" ' . ($options["auto_opengraph"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_opengraph">' . __('Automatically generate Opengraph meta tags.', 'add-meta-tags') . '</label>
                <p>' . __('If this option is enabled, Opengraph metadata is automatically generated for content, attachments and archives. For more information, please refer to the <a href="http://ogp.me">Opengraph specification</a>.', 'add-meta-tags') . '</p>
                <br />

                <input id="og_omit_video_metadata" type="checkbox" value="1" name="og_omit_video_metadata" ' . ($options["og_omit_video_metadata"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="og_omit_video_metadata">' . __('Omit <code>og:video</code> meta tags.', 'add-meta-tags') . '</label>
                <p>' . __('When a post containing a video is shared on Facebook, Facebook uses its own player to embed the video in the timeline. If this setting is enabled, <code>og:video</code> meta tags are no longer generated and Facebook, instead of embedding your video, links to your actual video post.', 'add-meta-tags') . '</p>
                <br />

                <h4>' . __('Important Note', 'add-meta-tags') . '</h4>

                <p>' . __('By default, this feature sets the URL of the front page of your web site to the <code>article:publisher</code> meta tag and the URL of the author archive to the <code>article:author</code> meta tag. In order to link to the publisher page and the author profile on Facebook, it is required to provide the respective URLs. These settings can be added to your WordPress user <a href="profile.php">profile page</a> under the section <em>Contact Info</em>. Filling in the publisher profile URL is not required, if it has already been entered in the <em>Publisher Settings</em> above. For example:', 'add-meta-tags') . '</p>
                <blockquote>Facebook author profile URL (AMT): <code>https://www.facebook.com/john.smith</code></blockquote>
                <blockquote>Facebook publisher profile URL (AMT): <code>https://www.facebook.com/awesome.editors</code></blockquote>
                <p>' . __('It is possible to control the value of the <code>og:type</code> meta tag either by changing the post format or programmatically via a filter. By default, the <code>og:type</code> is set to <code>article</code> for all content, except for video attachment pages and posts whose post format has been set to <code>video</code>, on which <code>og:type</code> is set to <code>video.other</code>.', 'add-meta-tags') . '</p>
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Twitter Cards Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Twitter Cards Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_twitter" type="checkbox" value="1" name="auto_twitter" ' . ($options["auto_twitter"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_twitter">' . __('Automatically generate Twitter Cards meta tags.', 'add-meta-tags') . '</label>
                <p>' . __('If this option is enabled, Twitter Cards metadata is automatically generated for content and attachments. For more information, please refer to the <a href="https://dev.twitter.com/docs/cards">Twitter Cards specification</a>.', 'add-meta-tags') . '</p>
                <br />

                <input id="tc_enforce_summary_large_image" type="checkbox" value="1" name="tc_enforce_summary_large_image" ' . ($options["tc_enforce_summary_large_image"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="tc_enforce_summary_large_image">' . __('Enforce the use of <code>summary_large_image</code> as default card type.', 'add-meta-tags') . '</label>
                <p>' . __('If this setting is enabled, <code>summary_large_image</code> will be used as the default Twitter Card type instead of the <code>summary</code> card type.', 'add-meta-tags') . '</p>
                <br />

                <input id="tc_enable_player_card_local" type="checkbox" value="1" name="tc_enable_player_card_local" ' . ($options["tc_enable_player_card_local"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="tc_enable_player_card_local">' . __('Enable the generation of <em>player</em> cards for local media.', 'add-meta-tags') . '</label>
                <p>' . __('Enable the generation of <em>player</em> cards for locally hosted audio and video attachments or for posts with their post format set to audio or video. In the latter case, an audio or video is expected to be attached to the post respectively. A mandatory requirement for this feature, as outlined in the Twitter Cards specifications, is secure access to your web site over the HTTPS protocol. If secure access to your web site has not been configured properly, the player cards will not be rendered by the Twitter service. Moreover, using self-signed certificates could cause problems which might be hard to identify. This feature should be considered experimental.', 'add-meta-tags') . '</p>

                <h4>' . __('Important Notes', 'add-meta-tags') . '</h4>

                <p>' . __('In order to generate the <code>twitter:site</code> and <code>twitter:creator</code> meta tags, it is required to provide the respective usernames of the Twitter account of the author and/or the publisher of the content. Update your WordPress user\'s <a href="profile.php">profile page</a> and fill in the relevant usernames under the section <em>Contact Info</em>. Filling in the publisher username is not required, if it has already been entered in the <em>Publisher Settings</em> above.', 'add-meta-tags') . '</p>
                <blockquote>Twitter author username (AMT): <code>JohnSmith</code></blockquote>
                <blockquote>Twitter publisher username (AMT): <code>AwesomeEditors</code></blockquote>

                <p>' . __('By default, a Twitter Card of type <em>summary</em> is generated for your content. If your theme supports <a href="http://codex.wordpress.org/Post_Formats">post formats</a>, then it is possible to generate Twitter Cards of various types according to the specified post format. More specifically:', 'add-meta-tags') . '</p>
                <blockquote>A <code>summary</code> card is generated for posts with one of the <code>standard</code>, <code>aside</code>, <code>link</code>, <code>quote</code>, <code>status</code> and <code>chat</code> formats.</blockquote>
                <blockquote>A <code>summary_large_image</code> card is generated for posts with the <code>image</code> format. An image is expected to be attached or embedded to the post.</blockquote>
                <blockquote>A <code>gallery</code> card is generated for posts with the <code>gallery</code> format. At least one image is expected to be attached or embedded to the post.</blockquote>
                <blockquote>A <code>photo</code> card is generated for image attachment pages.</blockquote>
                <blockquote>A <code>player</code> card is generated for posts with the <code>audio</code> or <code>video</code> format and for audio or video attachment pages. Regarding posts, an audio or video is expected to be attached or embedded to the post.</blockquote>
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Dublin Core Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Dublin Core Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_dublincore" type="checkbox" value="1" name="auto_dublincore" ' . ($options["auto_dublincore"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_dublincore">' . __('Automatically generate Dublin Core metadata.', 'add-meta-tags') . '</label>
                <p>' . __('If this option is enabled, Dublin Core metadata is automatically generated for your content and attachments. For more information, please refer to <a href="http://dublincore.org">Dublin Core Metadata Initiative</a>.', 'add-meta-tags') . '</p>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Schema.org Metadata', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Schema.org Metadata', 'add-meta-tags') . '</span></legend>

                <input id="auto_schemaorg" type="checkbox" value="1" name="auto_schemaorg" ' . ($options["auto_schemaorg"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="auto_schemaorg">' . __('Automatically generate and embed Schema.org Microdata.', 'add-meta-tags') . '</label> (Experimental feature)
                <p>' . __('Automatically generate Schema.org Microdata and embed it to your content. This feature embeds <code>meta</code> elements inside the body of the web page. This is compatible with the HTML 5 standard, so, before enabling it, make sure your theme is HTML 5 ready. For information about Microdata please refer to <a href="http://schema.org">Schema.org</a>.', 'add-meta-tags') . '</p>
                <br />
                <p>' . __('This metadata generator actually adds schema.org microdata around the post\'s content, because marking up the exact contents of the page in an automatic manner is technically impossible. Make no mistake, this is not the ideal way to insert microdata to your web pages. This generator should be considered as a workaround in case your theme lacks schema.org microdata markup in its templates and not as a replacement of schema.org enhanced themes.', 'add-meta-tags') . '</p>

                <h4>' . __('Important Notes', 'add-meta-tags') . '</h4>

                <p>' . __('By default, this feature links the author and publisher objects to the author archive and to the front page of your web site respectively. In order to link to the author\'s profile and publisher\'s page on Google+, it is required to provide the respective URLs. These settings can be added to your WordPress user <a href="profile.php">profile page</a> under the section <em>Contact Info</em>. Filling in the publisher profile URL is not required, if it has already been entered in the <em>Publisher Settings</em> above.', 'add-meta-tags') . '</p>
                <blockquote>Google+ author profile URL (AMT): <code>https://plus.google.com/+JohnSmith/</code></blockquote>
                <blockquote>Google+ publisher page URL (AMT): <code>https://plus.google.com/+AwesomeEditors/</code></blockquote>

                <p>' . __('Once you have filled in the URLs to the author profile and the publisher page on Google+, the relevant link elements with the attributes <code>rel="author"</code> and <code>rel="publisher"</code> are automatically added to the head area of the web page.', 'add-meta-tags') . '</p>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Metabox Features', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Metabox Features', 'add-meta-tags') . '</span></legend>

                <p>' . __('It is possible to partially customize the generated metadata on a per post basis through the <em>Metadata</em> metabox which exists in the post editing screen. Below you can choose which metabox features should be enabled. Enabling or disabling these features has no effect on the custom data that has been stored for each post.', 'add-meta-tags') . '</p>

                <p><input id="metabox_enable_description" type="checkbox" value="1" name="metabox_enable_description" ' . ($options["metabox_enable_description"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_description">
                ' . __('Custom description (<em>Recommended</em>).', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_keywords" type="checkbox" value="1" name="metabox_enable_keywords" ' . ($options["metabox_enable_keywords"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_keywords">
                ' . __('Custom keywords (<em>Recommended</em>).', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_title" type="checkbox" value="1" name="metabox_enable_title" ' . ($options["metabox_enable_title"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_title">
                ' . __('Custom content of the <code>title</code> HTML element.', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_news_keywords" type="checkbox" value="1" name="metabox_enable_news_keywords" ' . ($options["metabox_enable_news_keywords"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_news_keywords">
                ' . __('Custom news keywords. (<a target="_blank" href="http://support.google.com/news/publisher/bin/answer.py?hl=en&answer=68297">more info</a>)', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_full_metatags" type="checkbox" value="1" name="metabox_enable_full_metatags" ' . ($options["metabox_enable_full_metatags"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_full_metatags">
                ' . __('Full meta tags box.', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_image_url" type="checkbox" value="1" name="metabox_enable_image_url" ' . ($options["metabox_enable_image_url"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_image_url">
                ' . __('Global image override.', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_content_locale" type="checkbox" value="1" name="metabox_enable_content_locale" ' . ($options["metabox_enable_content_locale"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_content_locale">
                ' . __('Content locale override. (Not to be used in conjunction with a multilingual plugin.) ', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_express_review" type="checkbox" value="1" name="metabox_enable_express_review" ' . ($options["metabox_enable_express_review"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_express_review">
                ' . __('Express review. (Experimental feature. For advanced users only.)', 'add-meta-tags') . '
                </label></p>

                <p><input id="metabox_enable_referenced_list" type="checkbox" value="1" name="metabox_enable_referenced_list" ' . ($options["metabox_enable_referenced_list"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="metabox_enable_referenced_list">
                ' . __('Referenced items. (Experimental feature. Not recommended.)', 'add-meta-tags') . '
                </label></p>

                <p>' . __('The metabox feature selection above affects all users. Advanced customization of the availability of these features on a per user basis or depending upon each user\'s permissions, is possible through the <code>amt_metadata_metabox_permissions</code> filter.', 'add-meta-tags') . '</p>

                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Extra SEO Options', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Extra SEO Options', 'add-meta-tags') . '</span></legend>

                <input id="noodp_description" type="checkbox" value="1" name="noodp_description" ' . ($options["noodp_description"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noodp_description">' . __('Add <code>NOODP</code> and <code>NOYDIR</code> to the <em>robots</em> meta tag.', 'add-meta-tags') . '</label>
                <p>' . __('If checked, <code>NOODP</code> and <code>NOYDIR</code> are added to the <em>robots</em> meta tag on the front page, content and attachments. This setting will prevent all search engines (at least those that support the meta tag) from displaying information from the <a href="http://www.dmoz.org/">Open Directory Project</a> or the <a href="http://dir.yahoo.com/">Yahoo Directory</a> instead of the description you set in the <em>description</em> meta tag.', 'add-meta-tags') . '</p>
                <br />

                <p>' . __('Add <code>NOINDEX,FOLLOW</code> to the <em>robots</em> meta tag on following types of archives. This is an advanced setting that aims at reducing the amount of duplicate content that gets indexed by search engines:', 'add-meta-tags') . '</p>

                <p><input id="noindex_search_results" type="checkbox" value="1" name="noindex_search_results" ' . ($options["noindex_search_results"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_search_results">
                ' . __('Search results. (<em>Highly recommended</em>)', 'add-meta-tags') . '
                </label></p>

                <p><input id="noindex_date_archives" type="checkbox" value="1" name="noindex_date_archives" ' . ($options["noindex_date_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_date_archives">
                ' . __('Date based archives. (<em>Recommended</em>)', 'add-meta-tags') . '
                </label></p>

                <p><input id="noindex_category_archives" type="checkbox" value="1" name="noindex_category_archives" ' . ($options["noindex_category_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_category_archives">
                ' . __('Category based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_tag_archives" type="checkbox" value="1" name="noindex_tag_archives" ' . ($options["noindex_tag_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_tag_archives">
                ' . __('Tag based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_taxonomy_archives" type="checkbox" value="1" name="noindex_taxonomy_archives" ' . ($options["noindex_taxonomy_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_taxonomy_archives">
                ' . __('Custom taxonomy based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <p><input id="noindex_author_archives" type="checkbox" value="1" name="noindex_author_archives" ' . ($options["noindex_author_archives"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="noindex_author_archives">
                ' . __('Author based archives.', 'add-meta-tags') . ' (' . __('Even if checked, the first page of this type of archive is always indexed.', 'add-meta-tags') . ')
                </label></p>

                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Locale', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Locale', 'add-meta-tags') . '</span></legend>

                <input name="global_locale" type="text" id="global_locale" class="code" value="' . esc_attr(stripslashes($options["global_locale"])) . '" size="20" maxlength="32" />
                <br />
                <label for="global_locale">
                ' . __('Enter a locale which will be used globally in the generated metadata overriding the default locale as returned by WordPress. Filling in this setting is only recommended if WordPress does not return a locale in the form of <code>language_TERRITORY</code>. This feature should not be used in conjunction with a multilingual plugin in order to avoid the potential generation of meta tags with invalid locale.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>en_US</code></p>
                <br />

                <input id="manage_html_lang_attribute" type="checkbox" value="1" name="manage_html_lang_attribute" ' . ($options["manage_html_lang_attribute"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="manage_html_lang_attribute">' . __('Automatically set the HTML document\'s <code>lang</code> attribute according to the locale of the content.', 'add-meta-tags') . '</label>
                <p>' . __('By enabling this feature, Add-Meta-Tags will automatically set the HTML document\'s <code>lang</code> attribute according to the content\'s locale. This feature should not be used in conjunction with a multilingual plugin in order to avoid the potential generation of an invalid <code>lang</code> attribute.', 'add-meta-tags') . '</p>
                <br />

                <input id="generate_hreflang_links" type="checkbox" value="1" name="generate_hreflang_links" ' . ($options["generate_hreflang_links"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="generate_hreflang_links">' . __('Enable the generation of a <code>link</code> element with the <code>hreflang</code> attribute.', 'add-meta-tags') . '</label>
                <p>' . __('If this feature is enabled, an HTML <code>link</code> element containing the proper hreflang attribute is added to the head section of the HTML page. The value of the hreflang attribute is determined by the locale of the content. This feature should not be used in conjunction with a multilingual plugin in order to avoid the potential generation of invalid hreflang links.)', 'add-meta-tags') . '</p>
                <br />

                <input id="hreflang_strip_region" type="checkbox" value="1" name="hreflang_strip_region" ' . ($options["hreflang_strip_region"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="hreflang_strip_region">' . __('Strip region code from the hreflang attribute.', 'add-meta-tags') . '</label>
                <p>' . __('By default, Add-Meta-Tags uses the locale, which is usually required to be set in the form <code>language_TERRITORY</code> so as to comply with the various metadata specifications, as the value of the hreflang attribute. However, Google and possibly other services might interpret the regional information of the hreflang attribute as region targeting. If your content is not targeted to users in a specific region, it might be a good idea to strip regional information from this attribute by enabling this option.', 'add-meta-tags') . '</p>
                <p>' . __('For instance, if your locale is <code>en_US</code>, by enabling this option you force the hreflang attribute to be <code>en</code>. In the same way, if the locale is in the form <code>language_Script_TERRITORY</code>, for example <code>zh_Hans_TW</code>, by enabling this option the hreflang attribute becomes <code>zh-Hans</code>.', 'add-meta-tags') . '</p>
                <br />

            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Secure Access', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Secure Access', 'add-meta-tags') . '</span></legend>

                <input id="has_https_access" type="checkbox" value="1" name="has_https_access" ' . ($options["has_https_access"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="has_https_access">' . __('Media are accessible over HTTPS.') . '</label>
                <p>' . __('Currently this option, if enabled, lets the plugin make decisions about whether to generate additional secure links even if the active connection does not use HTTPS. For instance, if the web site is accessed over HTTP and this options is enabled, additional <code>og:image:secure_url</code> meta tags will be generated for your local media. If the current connection uses HTTPS, then secure links are always generated.', 'add-meta-tags') . '</p>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Copyright URL', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Copyright URL', 'add-meta-tags') . '</span></legend>

                <input name="copyright_url" type="text" id="copyright_url" class="code" value="' . esc_url_raw(stripslashes(amt_get_site_copyright_url($options))) . '" size="100" maxlength="1024" />
                <br />
                <label for="copyright_url">
                ' . __('Enter an absolute URL to a document containing copyright and licensing information about your work. If this URL is set, the relevant meta tags will be added automatically on all the pages of your web site.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>http://example.org/copyright.html</code></p>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Default Image', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Default Image', 'add-meta-tags') . '</span></legend>

                <input name="default_image_url" type="text" id="default_image_url" class="code" value="' . esc_url_raw(stripslashes($options["default_image_url"])) . '" size="100" maxlength="1024" />
                <br />
                <label for="default_image_url">
                ' . __('Enter an absolute URL to an image that represents your website, for instance the logo. This image will be used in the metadata of the front page and also in the metadata of the content, in case no featured image or other images have been attached or embedded.', 'add-meta-tags') . '
                </label>
                <p><strong>' . __('Example', 'add-meta-tags') . '</strong>: <code>http://example.org/images/logo.png</code></p>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Extended Metadata Support', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Extended Metadata Support', 'add-meta-tags') . '</span></legend>

                <p>' . __('Add-Meta-Tags supports the generation of metadata for products and other post types. Please enable any of the following generators of extended metadata.', 'add-meta-tags') . '</p>

                <p><input id="extended_support_woocommerce" type="checkbox" value="1" name="extended_support_woocommerce" ' . ($options["extended_support_woocommerce"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="extended_support_woocommerce">
                ' . __('Metadata for WooCommerce products and product groups.', 'add-meta-tags') . ' (<span style="color:red;">Work in progress</span>)
                </label></p>

                <p><input id="extended_support_edd" type="checkbox" value="1" name="extended_support_edd" ' . ($options["extended_support_edd"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="extended_support_edd">
                ' . __('Metadata for Easy-Digital-Downloads products and product groups.', 'add-meta-tags') . ' (<span style="color:red;">Work in progress</span>)
                </label></p>

                <p>' . __('Please note that if none of the supported products or other supported post types can be detected, the above settings do not affect the plugin\'s normal functionality.', 'add-meta-tags') . '</p>

                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Review Mode', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Review Mode', 'add-meta-tags') . '</span></legend>

                <input id="review_mode" type="checkbox" value="1" name="review_mode" ' . ($options["review_mode"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="review_mode">' . __('Enable <em>Metadata Review Mode</em>.') . '</label>
                <p>' . __('If enabled, WordPress users with administrator privileges see a box (right above the post\'s content) containing the metadata exactly as it is added in the HTML head and body. The box is displayed for posts, pages, attachments and custom post types.', 'add-meta-tags') . '</p>
                <br />
            </fieldset>
            </td>
            </tr>

            <tr valign="top">
            <th scope="row">' . __('Donations', 'add-meta-tags') . '</th>
            <td>
            <fieldset>
                <legend class="screen-reader-text"><span>' . __('Donations', 'add-meta-tags') . '</span></legend>

                <input id="i_have_donated" type="checkbox" value="1" name="i_have_donated" ' . ($options["i_have_donated"] == "1" ? 'checked="checked"' : '') . '" />
                <label for="i_have_donated">' . sprintf(__('If checked, the <em>message from the author</em> above goes away. Thanks for <a href="%s">donating</a>!', 'add-meta-tags'), 'http://bit.ly/HvUakt') . '</label>
                <br />
            </fieldset>
            </td>
            </tr>

        </tbody>
        </table>

        <!-- Submit Buttons -->
        <table class="form-table">
        <tbody>
            <tr valign="top">
                <th scope="row">
                    <input id="submit" class="button-primary" type="submit" value="' . __('Save Changes', 'add-meta-tags') . '" name="info_update" />
                </th>
                <th scope="row">
                    <input id="reset" class="button-primary" type="submit" value="' . __('Reset to defaults', 'add-meta-tags') . '" name="info_reset" />
                </th>
                <th></th><th></th><th></th><th></th>
            </tr>
        </tbody>
        </table>

        </form>
        
    </div>

    ';
}
Ejemplo n.º 5
0
/**
 * Generates basic metadata for the head area.
 *
 */
function amt_add_basic_metadata_head($post, $attachments, $embedded_media, $options)
{
    if (apply_filters('amt_exclude_basic_metadata', false)) {
        return array();
    }
    $do_description = $options["auto_description"] == "1" ? true : false;
    $do_keywords = $options["auto_keywords"] == "1" ? true : false;
    $do_noodp_description = $options["noodp_description"] == "1" ? true : false;
    // Array to store metadata
    $metadata_arr = array();
    // Pre-processing
    // Store hreflang links in array
    $hreflang_links_arr = array();
    // Store base robots options
    $robots_options = array();
    if ($do_noodp_description && (is_front_page() || is_singular() || is_category() || is_tag() || is_tax() || is_author())) {
        // Add NOODP on posts and pages
        $robots_options[] = 'noodp';
        $robots_options[] = 'noydir';
    }
    // Store full meta tags (site wide and post specific)
    // Add site wide meta tags
    $full_metatags_as_string = '';
    if (!empty($options['site_wide_meta'])) {
        $full_metatags_for_site = html_entity_decode(stripslashes($options['site_wide_meta']));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_site', $full_metatags_for_site);
        $full_metatags_as_string .= PHP_EOL;
    }
    // Full meta tags
    if (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        // per post full meta tags
        $full_metatags_for_content = amt_get_post_meta_full_metatags($post->ID);
        $full_metatags_for_content = html_entity_decode(stripslashes($full_metatags_for_content));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_post', $full_metatags_for_content);
    } elseif (is_category() || is_tag() || is_tax()) {
        // Term specific full meta tags ($post is a term object)
        $full_metatags_for_term = amt_get_term_meta_full_metatags($post->term_id);
        $full_metatags_for_term = html_entity_decode(stripslashes($full_metatags_for_term));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_term', $full_metatags_for_term);
    } elseif (is_author()) {
        // User specific full meta tags ($post is a user object)
        $full_metatags_for_user = amt_get_user_meta_full_metatags($post->ID);
        $full_metatags_for_user = html_entity_decode(stripslashes($full_metatags_for_user));
        $full_metatags_as_string .= apply_filters('amt_full_metatags_term', $full_metatags_for_user);
    }
    // Sanitize
    //$full_metatags_as_string = esc_textarea( wp_kses( $full_metatags_as_string, amt_get_allowed_html_kses() ) );
    $full_metatags_as_string = wp_kses($full_metatags_as_string, amt_get_allowed_html_kses());
    // Make array of full meta tags
    $full_meta_tags = preg_split('#\\R#', $full_metatags_as_string, NULL, PREG_SPLIT_NO_EMPTY);
    // Process
    if (apply_filters('amt_full_metatags_processor_enable', true)) {
        // Store processed meta tags here
        $processed_full_meta_tags = array();
        // Field substitutions currently take place only on content pages.
        // TODO: See if this can be expanded to terms, authors.
        // Store the post's custom fields
        $custom_fields = null;
        // Store the post object's custom fields.
        //
        if (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
            // Get an array of all custom fields names of the post object.
            $custom_fields = get_post_custom_keys($post->ID);
        }
        // Iterate over full meta tags
        foreach ($full_meta_tags as $single_meta_tag) {
            // Note: Field value substitutions take place first, outside the elseif clauses.
            // Process substitutions of special notation with data from Custom Fields
            // Supported special notation:
            //   [field=Field Name]
            // Notes:
            // - 'Field Name' is the name of custom field.
            // - If the custom field with name 'Field Name' does not exist, the meta tag
            //   that contains it is omitted.
            // - If the value of the field is an empty string, then the substitution
            //   takes place normally.
            //
            // The regex pattern fo our special notation.
            $special_notation_pattern = '#(?:\\[field\\=)([^\\]]+)(?:\\])#';
            // The following covers content pages, as $custom_fields is only set on content pages. See above.
            if (!empty($custom_fields) && isset($post->ID)) {
                // This also assumes that we have a post object since custom fields
                // are set only on content pages, otherwise it is null.
                // Check for special notation
                if (preg_match($special_notation_pattern, $single_meta_tag, $matches)) {
                    //var_dump($matches);
                    // If the field name of the special notation does not match
                    // any custom field name, omit the meta tag as per the rules above.
                    if (!in_array($matches[1], $custom_fields)) {
                        continue;
                    }
                    // Since there is special notation and the field name from the special
                    // notation exists in the $custom_fields array, iterate over the available
                    // custom fields and perform the substitutions.
                    foreach ($custom_fields as $custom_field) {
                        // Check if it matches the field name of the special notation
                        if ($custom_field == $matches[1]) {
                            // Fetch the custom field's value
                            $field_value = get_post_meta($post->ID, $custom_field, true);
                            // Sanitize value
                            // TODO: this can be a problem depending on the value and the used sanitization function.
                            $field_value = esc_attr(sanitize_text_field($field_value));
                            // Perform the substitution even if the the value is an empty string as per the rules above
                            $single_meta_tag = str_replace(sprintf('[field=%s]', $custom_field), $field_value, $single_meta_tag);
                        }
                    }
                }
            } else {
                // In any other case, just remove the meta tags which contain the special notation.
                if (preg_match($special_notation_pattern, $single_meta_tag, $tmp)) {
                    continue;
                }
            }
            // Process the PAGEINFO variable.
            // If the current page is the 1st page of any archive or of multipage content,
            // PAGEINFO is just stripped. For subsequent pages of archives or multipage
            // content, PAGEINFO is replaced with page based path (page/N/ for archives or N/ for multipage content)
            //
            // For paginated archives or paginated main page with latest posts.
            $has_paging_info = false;
            if (is_paged()) {
                $paged = get_query_var('paged');
                // paged
                if ($paged && $paged >= 2) {
                    $single_meta_tag = str_replace('PAGEINFO', 'page/' . $paged . '/', $single_meta_tag);
                    $has_paging_info = true;
                }
                // For a Post or Page that has been divided into pages using the <!--nextpage--> QuickTag
            } else {
                $paged = get_query_var('page');
                // page
                if ($paged && $paged >= 2) {
                    $single_meta_tag = str_replace('PAGEINFO', $paged . '/', $single_meta_tag);
                    $has_paging_info = true;
                }
            }
            // If this is not paged, strip PAGEINFO
            if ($has_paging_info === false) {
                $single_meta_tag = str_replace('PAGEINFO', '', $single_meta_tag);
            }
            // Process custom canonical link
            // If a rel="canonical" meta tags exists, we deactivate WordPress' 'rel_canonical' action,
            // Since it is assumed that a custom canonical link has been added.
            //if ( preg_match( '# rel="canonical" #', $post_full_meta_tags, $tmp ) ) {
            if (strpos($single_meta_tag, ' rel="canonical" ') !== false) {
                // Remove default WordPress action
                remove_action('wp_head', 'rel_canonical');
            } elseif (strpos($single_meta_tag, ' name="robots" ') !== false) {
                if (preg_match('# content="([^"]+)" #', $single_meta_tag, $matches)) {
                    $tmp_robots_opts = explode(',', $matches[1]);
                    foreach ($tmp_robots_opts as $single_robots_option) {
                        $single_robots_option_cleaned = strtolower(trim($single_robots_option));
                        if (!empty($single_robots_option_cleaned)) {
                            $robots_options[] = $single_robots_option_cleaned;
                        }
                    }
                }
                // We simply collect options. Do not add any robots meta tags to the processed meta tags array.
                continue;
            } elseif (strpos($single_meta_tag, ' hreflang="') !== false) {
                // Simply add to the hreflang links array for later processing
                $hreflang_links_arr[] = $single_meta_tag;
                // We simply collect hreflang links for later processing. Do not add them to the processed meta tags array.
                continue;
            }
            // If we have reached here, add the meta tags to the array with processed meta tags.
            $processed_full_meta_tags[] = $single_meta_tag;
        }
    } else {
        // Full meta tags processor not enabled
        $processed_full_meta_tags = $full_meta_tags;
    }
    //var_dump($full_meta_tags);
    //var_dump($processed_full_meta_tags);
    // Add Meta Tags
    // Add a robots meta tag if robots options exist.
    // Backwards compatible filter. TODO: This is deprecated. Needs to be deleted after a while.
    $old_options_as_string = apply_filters('amt_robots_data', '');
    if (!empty($old_options_as_string)) {
        foreach (explode(',', $old_options_as_string) as $single_robots_option) {
            $single_robots_option_cleaned = strtolower(trim($single_robots_option));
            if (!empty($single_robots_option_cleaned)) {
                $robots_options[] = $single_robots_option_cleaned;
            }
        }
    }
    // Add robot_options filtering
    $robots_options = apply_filters('amt_robots_options', $robots_options);
    if (version_compare(PHP_VERSION, '5.3', '<')) {
        // The flag is not supported
        $robots_options = array_unique($robots_options);
    } else {
        $robots_options = array_unique($robots_options, SORT_STRING);
    }
    if (!empty($robots_options)) {
        $metadata_arr['basic:robots'] = '<meta name="robots" content="' . esc_attr(implode(',', $robots_options)) . '" />';
    }
    // Add full meta tags
    // Merge meta tags
    $processed_full_meta_tags = apply_filters('amt_full_metatags_processed', $processed_full_meta_tags);
    if (!empty($processed_full_meta_tags)) {
        $metadata_arr = array_merge($metadata_arr, $processed_full_meta_tags);
    }
    // Add copyright link
    // On every page print the copyright head link
    $copyright_url = amt_get_site_copyright_url($options);
    //if ( empty($copyright_url)) {
    //    $copyright_url = trailingslashit( get_bloginfo('url') );
    //}
    if (!empty($copyright_url)) {
        $metadata_arr['basic:copyright'] = '<link rel="copyright" type="text/html" title="' . esc_attr(get_bloginfo('name')) . ' ' . __('copyright information', 'add-meta-tags') . '" href="' . esc_url($copyright_url) . '" />';
    }
    // hreflang link element
    // This section also expects an array of extra hreflang links that may have
    // been collected from the full meta tags boxes.
    if ($options['generate_hreflang_links'] == '1') {
        if (is_singular()) {
            $locale = amt_get_language_content($options, $post);
            $hreflang = amt_get_the_hreflang($locale, $options);
            $hreflang_url = amt_get_permalink_for_multipage($post);
        } else {
            $locale = amt_get_language_site($options);
            $hreflang = amt_get_the_hreflang($locale, $options);
            $hreflang_url = '';
            if (amt_is_default_front_page()) {
                $hreflang_url = trailingslashit(get_bloginfo('url'));
            } elseif (is_category() || is_tag() || is_tax()) {
                // $post is a term object
                $hreflang_url = get_term_link($post);
            } elseif (is_author()) {
                // $post is an author object
                $hreflang_url = get_author_posts_url($post->ID);
            } elseif (is_year()) {
                $archive_year = get_the_time('Y');
                $hreflang_url = get_year_link($archive_year);
            } elseif (is_month()) {
                $archive_year = get_the_time('Y');
                $archive_month = get_the_time('m');
                $hreflang_url = get_month_link($archive_year, $archive_month);
            } elseif (is_day()) {
                $archive_year = get_the_time('Y');
                $archive_month = get_the_time('m');
                $archive_day = get_the_time('d');
                $hreflang_url = get_day_link($archive_year, $archive_month, $archive_day);
            }
            // If paged information is available
            if (is_paged()) {
                //$hreflang_url = trailingslashit( $hreflang_url ) . get_query_var('paged') . '/';
                $hreflang_url = get_pagenum_link(get_query_var('paged'));
            }
        }
        // hreflang links array
        $hreflang_arr = array();
        // Add link element
        if (!empty($hreflang) && !empty($hreflang_url)) {
            $hreflang_arr[] = '<link rel="alternate" hreflang="' . esc_attr($hreflang) . '" href="' . esc_url_raw($hreflang_url) . '" />';
        }
        // Add extra hreflang links that have been collected from the full meta tags boxes
        if (!empty($hreflang_links_arr)) {
            $hreflang_arr = array_merge($hreflang_arr, $hreflang_links_arr);
        }
        // Allow filtering of the hreflang array
        $hreflang_arr = apply_filters('amt_hreflang_links', $hreflang_arr);
        // Add to to metadata array
        foreach ($hreflang_arr as $hreflang_link) {
            if (preg_match('# hreflang="([^"]+)" #', $hreflang_link, $matches)) {
                $metadata_arr['basic:hreflang:' . $matches[1]] = $hreflang_link;
            }
        }
    }
    // Basic Meta Tags
    // Custom content override
    if (amt_is_custom($post, $options)) {
        // Return metadata with:
        // add_filter( 'amt_custom_metadata_basic', 'my_function', 10, 5 );
        // Return an array of meta tags. Array item format: ['key_can_be_whatever'] = '<meta name="foo" content="bar" />'
        $metadata_arr = apply_filters('amt_custom_metadata_basic', $metadata_arr, $post, $options, $attachments, $embedded_media);
        // Default front page displaying latest posts
    } elseif (amt_is_default_front_page()) {
        // Description and Keywords from the Add-Meta-Tags settings override
        // default behaviour.
        // Description
        if ($do_description) {
            // Use the site description from the Add-Meta-Tags settings.
            // Fall back to the blog description.
            $site_description = amt_get_site_description($options);
            if (empty($site_description)) {
                // Alternatively, use the blog description
                // Here we sanitize the provided description for safety
                $site_description = sanitize_text_field(amt_sanitize_description(get_bloginfo('description')));
            }
            // If we have a description, use it in the description meta-tag of the front page
            if (!empty($site_description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($site_description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            // Use the site keywords from the Add-Meta-Tags settings.
            // Fall back to the blog categories.
            $site_keywords = amt_get_site_keywords($options);
            if (empty($site_keywords)) {
                // Alternatively, use the blog categories
                // Here we sanitize the provided keywords for safety
                $site_keywords = sanitize_text_field(amt_sanitize_keywords(amt_get_all_categories()));
            }
            // If we have keywords, use them in the keywords meta-tag of the front page
            if (!empty($site_keywords)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($site_keywords) . '" />';
            }
        }
        // Attachments
    } elseif (is_attachment()) {
        // has to be before is_singular() since is_singular() is true for attachments.
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // No keywords
        // Content pages and static pages used as "front page" and "posts page"
        // This also supports products via is_singular()
    } elseif (is_singular() || amt_is_static_front_page() || amt_is_static_home()) {
        // Description
        if ($do_description) {
            $description = amt_get_content_description($post, $auto = $do_description);
            if (!empty($description)) {
                // Note: Contains multipage information through amt_process_paged()
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description)) . '" />';
            }
        }
        // Keywords
        if ($do_keywords) {
            $keywords = amt_get_content_keywords($post, $auto = $do_keywords);
            if (!empty($keywords)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($keywords) . '" />';
                // Static Posts Index Page
                // If no keywords have been set in the metabox and this is the static page,
                // which displayes the latest posts, use the categories of the posts in the loop.
            } elseif (amt_is_static_home()) {
                // Here we sanitize the provided keywords for safety
                $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
                if (!empty($cats_from_loop)) {
                    $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
                }
            }
        }
        // 'news_keywords'
        $newskeywords = amt_get_post_meta_newskeywords($post->ID);
        if (!empty($newskeywords)) {
            $metadata_arr['basic:news_keywords'] = '<meta name="news_keywords" content="' . esc_attr($newskeywords) . '" />';
        }
        // Category based archives
    } elseif (is_category()) {
        if ($do_description) {
            // If set, the description of the category is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(category_description()));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_category_archive', __('Content filed under the %s category.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_cat_title($prefix = '', $display = false));
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The category name alone is included in the 'keywords' metatag
            // Here we sanitize the provided keywords for safety
            $cur_cat_name = sanitize_text_field(amt_sanitize_keywords(single_cat_title($prefix = '', $display = false)));
            if (!empty($cur_cat_name)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cur_cat_name) . '" />';
            }
        }
    } elseif (is_tag()) {
        if ($do_description) {
            // If set, the description of the tag is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(tag_description()));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_tag_archive', __('Content tagged with %s.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_tag_title($prefix = '', $display = false));
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The tag name alone is included in the 'keywords' metatag
            // Here we sanitize the provided keywords for safety
            $cur_tag_name = sanitize_text_field(amt_sanitize_keywords(single_tag_title($prefix = '', $display = false)));
            if (!empty($cur_tag_name)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cur_tag_name) . '" />';
            }
        }
        // Custom taxonomies - Should be after is_category() and is_tag(), as it would catch those taxonomies as well.
        // This also supports product groups via is_tax(). Only product groups that are WordPress custom taxonomies are supported.
    } elseif (is_tax()) {
        // Taxonomy term object.
        // When viewing taxonomy archives, the $post object is the taxonomy term object. Check with: var_dump($post);
        $tax_term_object = $post;
        //var_dump($tax_term_object);
        if ($do_description) {
            // If set, the description of the custom taxonomy term is used in the 'description' metatag.
            // Otherwise, a generic description is used.
            // Here we sanitize the provided description for safety
            $description_content = sanitize_text_field(amt_sanitize_description(term_description($tax_term_object->term_id, $tax_term_object->taxonomy)));
            // Note: Contains multipage information through amt_process_paged()
            if (empty($description_content)) {
                // Add a filtered generic description.
                // Construct the filter name. Template: ``amt_generic_description_TAXONOMYSLUG_archive``
                $taxonomy_description_filter_name = sprintf('amt_generic_description_%s_archive', $tax_term_object->taxonomy);
                // var_dump($taxonomy_description_filter_name);
                $generic_description = apply_filters($taxonomy_description_filter_name, __('Content filed under the %s taxonomy.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, single_term_title($prefix = '', $display = false));
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($description_content)) . '" />';
            }
        }
        if ($do_keywords) {
            // The taxonomy term name alone is included in the 'keywords' metatag.
            // Here we sanitize the provided keywords for safety.
            $cur_tax_term_name = sanitize_text_field(amt_sanitize_keywords(single_term_title($prefix = '', $display = false)));
            if (!empty($cur_tax_term_name)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cur_tax_term_name) . '" />';
            }
        }
    } elseif (is_author()) {
        // Author object
        // NOTE: Inside the author archives `$post->post_author` does not contain the author object.
        // In this case the $post (get_queried_object()) contains the author object itself.
        // We also can get the author object with the following code. Slug is what WP uses to construct urls.
        // $author = get_user_by( 'slug', get_query_var( 'author_name' ) );
        // Also, ``get_the_author_meta('....', $author)`` returns nothing under author archives.
        // Access user meta with:  $author->description, $author->user_email, etc
        // $author = get_queried_object();
        $author = $post;
        // If a bio has been set in the user profile, use it in the description metatag of the
        // first page of the author archive *ONLY*. The other pages of the author archive use a generic description.
        // This happens because the 1st page of the author archive is considered the profile page
        // by the other metadata modules.
        // Otherwise use a generic meta tag.
        if ($do_description) {
            // Here we sanitize the provided description for safety
            $author_description = sanitize_text_field(amt_sanitize_description($author->description));
            if (empty($author_description) || is_paged()) {
                // Note: Contains multipage information through amt_process_paged()
                // Add a filtered generic description.
                $generic_description = apply_filters('amt_generic_description_author_archive', __('Content published by %s.', 'add-meta-tags'));
                $generic_description = sprintf($generic_description, $author->display_name);
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
            } else {
                $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr($author_description) . '" />';
            }
        }
        // For the keywords metatag use the categories of the posts the author has written and are displayed in the current page.
        if ($do_keywords) {
            // Here we sanitize the provided keywords for safety
            $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
            if (!empty($cats_from_loop)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
            }
        }
        // Custom Post Type Archive
    } elseif (is_post_type_archive()) {
        // Custom post type object.
        // When viewing custom post type archives, the $post object is the custom post type object. Check with: var_dump($post);
        $post_type_object = $post;
        //var_dump($post_type_object);
        if ($do_description) {
            // Description
            // Note: Contains multipage information through amt_process_paged()
            // Add a filtered generic description.
            // Construct the filter name. Template: ``amt_generic_description_posttype_POSTTYPESLUG_archive``
            $custom_post_type_description_filter_name = sprintf('amt_generic_description_posttype_%s_archive', $post_type_object->name);
            // var_dump($custom_post_type_description_filter_name);
            // Generic description
            $generic_description = apply_filters($custom_post_type_description_filter_name, __('%s archive.', 'add-meta-tags'));
            // Final generic description
            $generic_description = sprintf($generic_description, post_type_archive_title($prefix = '', $display = false));
            $metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr(amt_process_paged($generic_description)) . '" />';
        }
        // For the keywords metatag use the categories of the posts that are listed in the current page.
        if ($do_keywords) {
            // Here we sanitize the provided keywords for safety
            $cats_from_loop = sanitize_text_field(amt_sanitize_keywords(implode(', ', amt_get_categories_from_loop())));
            if (!empty($cats_from_loop)) {
                $metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr($cats_from_loop) . '" />';
            }
        }
    }
    // Filtering of the generated basic metadata
    $metadata_arr = apply_filters('amt_basic_metadata_head', $metadata_arr);
    return $metadata_arr;
}
Ejemplo n.º 6
0
function amt_add_dublin_core_metadata_head($post, $attachments, $embedded_media, $options)
{
    if (apply_filters('amt_exclude_dublin_core_metadata', false)) {
        return array();
    }
    $metadata_arr = array();
    $do_auto_dublincore = $options["auto_dublincore"] == "1" ? true : false;
    if (!$do_auto_dublincore) {
        return $metadata_arr;
    }
    // Custom content override
    if (amt_is_custom($post, $options)) {
        // Return metadata with:
        // add_filter( 'amt_custom_metadata_dublin_core', 'my_function', 10, 5 );
        // Return an array of meta tags. Array item format: ['key_can_be_whatever'] = '<meta name="foo" content="bar" />'
        $metadata_arr = apply_filters('amt_custom_metadata_dublin_core', $metadata_arr, $post, $options, $attachments, $embedded_media);
        return $metadata_arr;
    }
    if (!is_singular() || is_front_page()) {
        // is_front_page() is used for the case in which a static page is used as the front page.
        // Dublin Core metadata has a meaning for content only.
        return array();
    }
    // The Dublin Core metadata generator does not support products or product groups.
    if (amt_is_product() || amt_is_product_group()) {
        return array();
    }
    // Title
    // Note: Contains multipage information through amt_process_paged()
    $metadata_arr['dcterms.title'] = '<meta name="dcterms.title" content="' . esc_attr(amt_get_title_for_metadata($options, $post)) . '" />';
    // Resource identifier - Uses amt_get_permalink_for_multipage()
    $metadata_arr[] = '<meta name="dcterms.identifier" content="' . esc_url_raw(amt_get_permalink_for_multipage($post)) . '" />';
    $metadata_arr[] = '<meta name="dcterms.creator" content="' . esc_attr(amt_get_dublin_core_author_notation($post)) . '" />';
    //$metadata_arr[] = '<meta name="dcterms.date" content="' . esc_attr( amt_iso8601_date($post->post_date) ) . '" />';
    $metadata_arr[] = '<meta name="dcterms.created" content="' . esc_attr(amt_iso8601_date($post->post_date)) . '" />';
    $metadata_arr[] = '<meta name="dcterms.available" content="' . esc_attr(amt_iso8601_date($post->post_date)) . '" />';
    //$metadata_arr[] = '<meta name="dcterms.issued" content="' . esc_attr( amt_iso8601_date($post->post_date) ) . '" />';
    $metadata_arr[] = '<meta name="dcterms.modified" content="' . esc_attr(amt_iso8601_date($post->post_modified)) . '" />';
    // Description
    // We use the same description as the ``description`` meta tag.
    // Note: Contains multipage information through amt_process_paged()
    $content_desc = amt_get_content_description($post);
    if (!empty($content_desc)) {
        $metadata_arr[] = '<meta name="dcterms.description" content="' . esc_attr(amt_process_paged($content_desc)) . '" />';
    }
    // Keywords
    if (!is_attachment()) {
        // Attachments do not support keywords
        // dcterms.subject - one for each keyword.
        $keywords = explode(',', amt_get_content_keywords($post));
        foreach ($keywords as $subject) {
            $subject = trim($subject);
            if (!empty($subject)) {
                $metadata_arr[] = '<meta name="dcterms.subject" content="' . esc_attr($subject) . '" />';
            }
        }
    }
    $metadata_arr[] = '<meta name="dcterms.language" content="' . esc_attr(amt_get_language_content($options, $post)) . '" />';
    $metadata_arr[] = '<meta name="dcterms.publisher" content="' . esc_url_raw(trailingslashit(get_bloginfo('url'))) . '" />';
    // Copyright page
    $copyright_url = amt_get_site_copyright_url($options);
    if (empty($copyright_url)) {
        $copyright_url = trailingslashit(get_bloginfo('url'));
    }
    if (!empty($copyright_url)) {
        $metadata_arr[] = '<meta name="dcterms.rights" content="' . esc_url_raw($copyright_url) . '" />';
    }
    // License
    $license_url = '';
    // The following requires creative commons configurator
    if (function_exists('bccl_get_license_url')) {
        $license_url = bccl_get_license_url();
    }
    // Allow filtering of the license URL
    $license_url = apply_filters('amt_dublin_core_license', $license_url, $post->ID);
    // Add metatag if $license_url is not empty.
    if (!empty($license_url)) {
        $metadata_arr[] = '<meta name="dcterms.license" content="' . esc_url_raw($license_url) . '" />';
    }
    // Coverage
    $metadata_arr[] = '<meta name="dcterms.coverage" content="World" />';
    if (is_attachment()) {
        $mime_type = get_post_mime_type($post->ID);
        //$attachment_type = strstr( $mime_type, '/', true );
        // See why we do not use strstr(): http://www.codetrax.org/issues/1091
        $attachment_type = preg_replace('#\\/[^\\/]*$#', '', $mime_type);
        $metadata_arr[] = '<meta name="dcterms.isPartOf" content="' . esc_url_raw(get_permalink($post->post_parent)) . '" />';
        if ('image' == $attachment_type) {
            $metadata_arr[] = '<meta name="dcterms.type" content="Image" />';
            $metadata_arr[] = '<meta name="dcterms.format" content="' . $mime_type . '" />';
        } elseif ('video' == $attachment_type) {
            $metadata_arr[] = '<meta name="dcterms.type" content="MovingImage" />';
            $metadata_arr[] = '<meta name="dcterms.format" content="' . $mime_type . '" />';
        } elseif ('audio' == $attachment_type) {
            $metadata_arr[] = '<meta name="dcterms.type" content="Sound" />';
            $metadata_arr[] = '<meta name="dcterms.format" content="' . $mime_type . '" />';
        }
        // Finally add the hasFormat
        $metadata_arr[] = '<meta name="dcterms.hasFormat" content="' . esc_url_raw(wp_get_attachment_url($post->ID)) . '" />';
    } else {
        // Default: Text
        $metadata_arr[] = '<meta name="dcterms.type" content="Text" />';
        $metadata_arr[] = '<meta name="dcterms.format" content="text/html" />';
        // Add media files
        // Media Limits
        $image_limit = amt_metadata_get_image_limit($options);
        $video_limit = amt_metadata_get_video_limit($options);
        $audio_limit = amt_metadata_get_audio_limit($options);
        // Counters
        $ic = 0;
        // image counter
        $vc = 0;
        // video counter
        $ac = 0;
        // audio counter
        // List attachments
        foreach ($attachments as $attachment) {
            $mime_type = get_post_mime_type($attachment->ID);
            //$attachment_type = strstr( $mime_type, '/', true );
            // See why we do not use strstr(): http://www.codetrax.org/issues/1091
            $attachment_type = preg_replace('#\\/[^\\/]*$#', '', $mime_type);
            if ('image' == $attachment_type && $ic < $image_limit) {
                $metadata_arr[] = '<meta name="dcterms.hasPart" content="' . esc_url_raw(get_permalink($attachment->ID)) . '" />';
                // Increase image counter
                $ic++;
            } elseif ('video' == $attachment_type && $vc < $video_limit) {
                $metadata_arr[] = '<meta name="dcterms.hasPart" content="' . esc_url_raw(get_permalink($attachment->ID)) . '" />';
                // Increase video counter
                $vc++;
            } elseif ('audio' == $attachment_type && $ac < $audio_limit) {
                $metadata_arr[] = '<meta name="dcterms.hasPart" content="' . esc_url_raw(get_permalink($attachment->ID)) . '" />';
                // Increase audio counter
                $ac++;
            }
        }
        // Embedded Media
        foreach ($embedded_media['images'] as $embedded_item) {
            if ($ic == $image_limit) {
                break;
            }
            $metadata_arr[] = '<meta name="dcterms.hasPart" content="' . esc_url_raw($embedded_item['page']) . '" />';
            // Increase image counter
            $ic++;
        }
        foreach ($embedded_media['videos'] as $embedded_item) {
            if ($vc == $video_limit) {
                break;
            }
            $metadata_arr[] = '<meta name="dcterms.hasPart" content="' . esc_url_raw($embedded_item['page']) . '" />';
            // Increase video counter
            $vc++;
        }
        foreach ($embedded_media['sounds'] as $embedded_item) {
            if ($ac == $audio_limit) {
                break;
            }
            $metadata_arr[] = '<meta name="dcterms.hasPart" content="' . esc_url_raw($embedded_item['page']) . '" />';
            // Increase audio counter
            $ac++;
        }
    }
    /**
     * WordPress Post Formats: http://codex.wordpress.org/Post_Formats
     * Dublin Core Format: http://dublincore.org/documents/dcmi-terms/#terms-format
     * Dublin Core DCMIType: http://dublincore.org/documents/dcmi-type-vocabulary/
     */
    /**
     * TREAT ALL POST FORMATS AS TEXT (for now)
     */
    /**
    $format = get_post_format( $post->id );
    if ( empty($format) || $format=="aside" || $format=="link" || $format=="quote" || $format=="status" || $format=="chat") {
        // Default format
        $metadata_arr[] = '<meta name="dcterms.type" content="Text" />';
        $metadata_arr[] = '<meta name="dcterms.format" content="text/html" />';
    } elseif ($format=="gallery") {
        $metadata_arr[] = '<meta name="dcterms.type" content="Collection" />';
        // $metadata_arr[] = '<meta name="dcterms.format" content="image" />';
    } elseif ($format=="image") {
        $metadata_arr[] = '<meta name="dcterms.type" content="Image" />';
        // $metadata_arr[] = '<meta name="dcterms.format" content="image/png" />';
    } elseif ($format=="video") {
        $metadata_arr[] = '<meta name="dcterms.type" content="Moving Image" />';
        $metadata_arr[] = '<meta name="dcterms.format" content="application/x-shockwave-flash" />';
    } elseif ($format=="audio") {
        $metadata_arr[] = '<meta name="dcterms.type" content="Sound" />';
        $metadata_arr[] = '<meta name="dcterms.format" content="audio/mpeg" />';
    }
    */
    // Filtering of the generated Dublin Core metadata
    $metadata_arr = apply_filters('amt_dublin_core_metadata_head', $metadata_arr);
    return $metadata_arr;
}