示例#1
0
 function newSocial()
 {
     $schemaModel = new KcSeoSchemaModel();
     $id = $_REQUEST['id'] ? $_REQUEST['id'] + 1 : 0;
     $html = null;
     $html = "<div class='sfield'>";
     $html .= "<select name='social[{$id}][id]'>";
     foreach ($schemaModel->socialList() as $skey => $social) {
         $html .= "<option value='{$skey}'>{$social}</option>";
     }
     $html .= "</select>";
     $html .= "<input type='text' name='social[{$id}][link]'>";
     $html .= '<span class="dashicons dashicons-trash social-remove"></span>';
     $html .= "</div>";
     wp_send_json(array('data' => $html));
     die;
 }
示例#2
0
 function save_KcSeo_schema_data($post_id, $post, $update)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     global $KcSeoWPSchema;
     if (!wp_verify_nonce(@$_REQUEST['_kcseo_nonce'], $KcSeoWPSchema->nonceText())) {
         return;
     }
     // Check permissions
     if (@$_GET['post_type']) {
         if (!current_user_can('edit_' . @$_GET['post_type'], $post_id)) {
             return;
         }
     }
     if (!in_array(@$post->post_type, $this->postType)) {
         return;
     }
     $meta = array();
     $schemaModel = new KcSeoSchemaModel();
     foreach ($schemaModel->schemaTypes() as $schemaID => $schema) {
         $schemaMetaId = $KcSeoWPSchema->KcSeoPrefix . $schemaID;
         $data = array();
         foreach ($schema['fields'] as $fieldId => $fieldData) {
             $value = isset($_REQUEST[$schemaMetaId][$fieldId]) ? $_REQUEST[$schemaMetaId][$fieldId] ? sanitize_text_field($_REQUEST[$schemaMetaId][$fieldId]) : null : null;
             if ($value) {
                 $data[$fieldId] = $value;
             }
         }
         if (!empty($data)) {
             $meta[$schemaMetaId] = serialize($data);
         }
     }
     foreach ($meta as $mKey => $mValue) {
         update_post_meta($post_id, $mKey, $mValue);
     }
 }
示例#3
0
<?php

global $KcSeoWPSchema;
$settings = get_option($KcSeoWPSchema->options['settings']);
$schemaModel = new KcSeoSchemaModel();
?>
<div class="wrap">
    <div id="upf-icon-edit-pages" class="icon32 icon32-posts-page"><br /></div>
    <h2><?php 
_e('WP SEO Structured Data Schema', KCSEO_WP_SCHEMA_SLUG);
?>
</h2>
    <form id="kcseo-settings" onsubmit="wpSchemaSettings(this); return false;">

        <h3><?php 
_e('General settings for WP SEO Structured Data Schema by <a href="http://kcseopro.com/">KCSEOPro.com</a>', KCSEO_WP_SCHEMA_SLUG);
?>
</h3>
        <div class="setting-holder">
            <table width="40%" cellpadding="10" class="form-table">
                <tr class="default">
                    <th>Enable Site link Search Box</th>
                    <td scope="row">
                        <div class="with-tooltip">
                            <input type="checkbox" name="homeonly" id="homeonly" <?php 
echo @$settings['homeonly'] ? "checked" : null;
?>
 value="1" />

                            <div class="schema-tooltip-holder">
                                <span class="schema-tooltip"></span>
示例#4
0
 function load_schema()
 {
     global $KcSeoWPSchema, $post;
     $schemaModel = new KcSeoSchemaModel();
     $html = null;
     $settings = get_option($KcSeoWPSchema->options['settings']);
     if (is_home() || is_front_page()) {
         $metaData = array();
         $metaData["@context"] = "http://schema.org/";
         $metaData["@type"] = "WebSite";
         if ($settings['homeonly']) {
             $author_url = $settings['siteurl'] ? $settings['siteurl'] : get_home_url();
             $to_remove = array('http://', 'https://', 'www.');
             foreach ($to_remove as $item) {
                 $author_url = str_replace($item, '', $author_url);
                 // to: www.example.com
             }
             $metaData["url"] = $author_url;
             $metaData["name"] = $settings['sitename'];
             $metaData["alternateName"] = $settings['siteaname'];
             $html .= $schemaModel->get_jsonEncode($metaData);
         } else {
             $metaData["url"] = get_home_url();
             $metaData["potentialAction"] = array("@type" => "SearchAction", "target" => get_home_url() . "/?s={query}", "query-input" => "required name=query");
             $html .= $schemaModel->get_jsonEncode($metaData);
         }
     }
     $webMeta = array();
     $webMeta["@context"] = "http://schema.org";
     $webMeta["@type"] = esc_attr($settings['site_type']);
     if ($settings['additionalType']) {
         $aType = explode("\r\n", $settings['additionalType']);
         if (!empty($aType) && is_array($aType)) {
             if (count($aType) == 1) {
                 $webMeta["additionalType"] = $aType[0];
             } else {
                 if (count($aType) > 1) {
                     $webMeta["additionalType"] = $aType;
                 }
             }
         }
     }
     if (esc_attr($settings['site_type']) == 'Person') {
         $webMeta["name"] = esc_attr($settings['person']['name']);
         $webMeta["worksFor"] = esc_attr($settings['person']['worksFor']);
         $webMeta["jobTitle"] = esc_attr($settings['person']['jobTitle']);
         $webMeta["image"] = esc_attr($settings['person']['image']);
         $webMeta["description"] = esc_attr($settings['person']['description']);
         $webMeta["birthDate"] = esc_attr($settings['person']['birthDate']);
     } else {
         $webMeta["name"] = esc_attr($settings['type_name']);
         $webMeta["logo"] = esc_attr($settings['logo_url']);
     }
     if (esc_attr($settings['site_type']) != "Organization" && esc_attr($settings['site_type']) != "Person") {
         $webMeta["description"] = esc_attr($settings['business_info']['description']);
         if ($settings['business_info']['openingHours']) {
             $aOhour = explode("\r\n", $settings['business_info']['openingHours']);
             if (!empty($aOhour) && is_array($aOhour)) {
                 if (count($aOhour) == 1) {
                     $webMeta["openingHours"] = $aOhour[0];
                 } else {
                     if (count($aOhour) > 1) {
                         $webMeta["openingHours"] = $aOhour;
                     }
                 }
             }
         }
         $webMeta["geo"] = array("@type" => "GeoCoordinates", "longitude" => esc_attr($settings['business_info']['longitude']), "latitude" => esc_attr($settings['business_info']['latitude']));
     }
     $webMeta["url"] = esc_attr($settings['web_url']);
     if (!empty($settings['social']) && is_array($settings['social'])) {
         $link = array();
         foreach ($settings['social'] as $socialD) {
             if ($socialD['link']) {
                 $link[] = $socialD['link'];
             }
         }
         if (!empty($link)) {
             $webMeta["sameAs"] = $link;
         }
     }
     $webMeta["contactPoint"] = array("@type" => "ContactPoint", "telephone" => esc_attr($settings['contact']['telephone']), "contactType" => esc_attr($settings['contact']['contactType']), "contactOption" => esc_attr($settings['contact']['contactOption']), "areaServed" => esc_attr(@implode(',', $settings['area_served'])), "availableLanguage" => esc_attr($settings['availableLanguage']));
     $webMeta["address"] = array("@type" => "PostalAddress", "addressCountry" => esc_attr($settings['address']['country']), "addressLocality" => esc_attr($settings['address']['locality']), "addressRegion" => esc_attr($settings['address']['region']), "postalCode" => esc_attr($settings['address']['postalcode']), "streetAddress" => esc_attr($settings['address']['street']));
     if ($webMeta["@type"]) {
         $html .= $schemaModel->get_jsonEncode($webMeta);
     }
     if (is_single() || is_page()) {
         foreach ($schemaModel->schemaTypes() as $schemaID => $schema) {
             $schemaMetaId = $KcSeoWPSchema->KcSeoPrefix . $schemaID;
             $metaData = unserialize(get_post_meta($post->ID, $schemaMetaId, true));
             $firstItem = @current($metaData);
             if (!empty($metaData) && is_array($metaData) && isset($firstItem)) {
                 $html .= $schemaModel->schemaOutput($schemaID, $metaData);
             }
         }
     }
     echo $html;
 }