コード例 #1
0
        function import_page()
        {
            $msg = '';
            if (isset($_POST['import'])) {
                global $wpdb;
                $msg = '';
                $replace = false;
                $deletekw = false;
                if (isset($_POST['wpseo']['deleteolddata']) && $_POST['wpseo']['deleteolddata'] == 'on') {
                    $replace = true;
                }
                if (isset($_POST['wpseo']['importheadspace'])) {
                    $this->replace_meta('_headspace_description', '_yoast_wpseo_metadesc', $replace);
                    $this->replace_meta('_headspace_keywords', '_yoast_wpseo_metakeywords', $replace);
                    $this->replace_meta('_headspace_page_title', '_yoast_wpseo_title', $replace);
                    $this->replace_meta('_headspace_noindex', '_yoast_wpseo_meta-robots-noindex', $replace);
                    $this->replace_meta('_headspace_nofollow', '_yoast_wpseo_meta-robots-nofollow', $replace);
                    $posts = $wpdb->get_results("SELECT ID FROM {$wpdb->posts}");
                    foreach ($posts as $post) {
                        $custom = get_post_custom($post->ID);
                        $robotsmeta_adv = '';
                        if (isset($custom['_headspace_noarchive'])) {
                            $robotsmeta_adv .= 'noarchive,';
                        }
                        if (isset($custom['_headspace_noodp'])) {
                            $robotsmeta_adv .= 'noodp,';
                        }
                        if (isset($custom['_headspace_noydir'])) {
                            $robotsmeta_adv .= 'noydir';
                        }
                        $robotsmeta_adv = preg_replace('/,$/', '', $robotsmeta_adv);
                        wpseo_set_value('meta-robots-adv', $robotsmeta_adv, $post->ID);
                        if ($replace) {
                            foreach (array('noindex', 'nofollow', 'noarchive', 'noodp', 'noydir') as $meta) {
                                delete_post_meta($post->ID, '_headspace_' . $meta);
                            }
                        }
                    }
                    $msg .= '<p>HeadSpace2 data successfully imported.</p>';
                }
                if (isset($_POST['wpseo']['importaioseo'])) {
                    $this->replace_meta('_aioseop_description', '_yoast_wpseo_metadesc', $replace);
                    $this->replace_meta('_aioseop_keywords', '_yoast_wpseo_metakeywords', $replace);
                    $this->replace_meta('_aioseop_title', '_yoast_wpseo_title', $replace);
                    $msg .= '<p>All in One SEO data successfully imported.</p>';
                }
                if (isset($_POST['wpseo']['importaioseoold'])) {
                    $this->replace_meta('description', '_yoast_wpseo_metadesc', $replace);
                    $this->replace_meta('keywords', '_yoast_wpseo_metakeywords', $replace);
                    $this->replace_meta('title', '_yoast_wpseo_title', $replace);
                    $msg .= '<p>' . __('All in One SEO (Old version) data successfully imported.') . '</p>';
                }
                if (isset($_POST['wpseo']['importrobotsmeta'])) {
                    $posts = $wpdb->get_results("SELECT ID, robotsmeta FROM {$wpdb->posts}");
                    foreach ($posts as $post) {
                        if (strpos($post->robotsmeta, 'noindex') !== false) {
                            wpseo_set_value('meta-robots-noindex', true, $post->ID);
                        }
                        if (strpos($post->robotsmeta, 'nofollow') !== false) {
                            wpseo_set_value('meta-robots-nofollow', true, $post->ID);
                        }
                    }
                    $msg .= '<p>' . __('Robots Meta values imported.') . '</p>';
                }
                if (isset($_POST['wpseo']['importrssfooter'])) {
                    $optold = get_option('RSSFooterOptions');
                    $optnew = get_option('wpseo_rss');
                    if ($optold['position'] == 'after') {
                        if (empty($optnew['rssafter'])) {
                            $optnew['rssafter'] = $optold['footerstring'];
                        }
                    } else {
                        if (empty($optnew['rssbefore'])) {
                            $optnew['rssbefore'] = $optold['footerstring'];
                        }
                    }
                    update_option('wpseo_rss', $optnew);
                    $msg .= '<p>' . __('RSS Footer options imported successfully.') . '</p>';
                }
                if (isset($_POST['wpseo']['importbreadcrumbs'])) {
                    $optold = get_option('yoast_breadcrumbs');
                    $optnew = get_option('wpseo_internallinks');
                    if (is_array($optold)) {
                        foreach ($optold as $opt => $val) {
                            if (is_bool($val) && $val == true) {
                                $optnew['breadcrumbs-' . $opt] = 'on';
                            } else {
                                $optnew['breadcrumbs-' . $opt] = $val;
                            }
                        }
                        update_option('wpseo_internallinks', $optnew);
                        $msg .= '<p>' . __('Yoast Breadcrumbs options imported successfully.') . '</p>';
                    } else {
                        $msg .= '<p>' . __('Yoast Breadcrumbs options could not be found') . '</p>';
                    }
                }
                if ($replace) {
                    $msg .= __(', and old data deleted');
                }
                if ($deletekw) {
                    $msg .= __(', and meta keywords data deleted');
                }
            }
            $this->admin_header('Import', false, false);
            if ($msg != '') {
                echo '<div id="message" class="message updated" style="width:94%;">' . $msg . '</div>';
            }
            $content = "<p>" . __("No doubt you've used an SEO plugin before if this site isn't new. Let's make it easy on you, you can import the data below. If you want, you can import first, check if it was imported correctly, and then import &amp; delete. No duplicate data will be imported.") . "</p>";
            $content .= '<p>' . __("If you've used another SEO plugin, try the <a href='http://wordpress.org/extend/plugins/seo-data-transporter/'>SEO Data Transporter</a> plugin to move your data into this plugin, it rocks!") . '</p>';
            $content .= '<form action="" method="post">';
            $content .= $this->checkbox('importheadspace', __('Import from HeadSpace2?', 'yoast-wpseo'));
            $content .= $this->checkbox('importaioseo', __('Import from All-in-One SEO?', 'yoast-wpseo'));
            $content .= $this->checkbox('importaioseoold', __('Import from OLD All-in-One SEO?', 'yoast-wpseo'));
            $content .= '<br/>';
            $content .= $this->checkbox('deleteolddata', __('Delete the old data after import? (recommended)', 'yoast-wpseo'));
            $content .= '<input type="submit" class="button-primary" name="import" value="Import" />';
            $content .= '<br/><br/>';
            $content .= '<form action="" method="post">';
            $content .= '<h2>Import settings from other plugins</h2>';
            $content .= $this->checkbox('importrobotsmeta', __('Import from Robots Meta (by Yoast)?', 'yoast-wpseo'));
            $content .= $this->checkbox('importrssfooter', __('Import from RSS Footer (by Yoast)?', 'yoast-wpseo'));
            $content .= $this->checkbox('importbreadcrumbs', __('Import from Yoast Breadcrumbs?', 'yoast-wpseo'));
            $content .= '<input type="submit" class="button-primary" name="import" value="Import" />';
            $content .= '</form>';
            $this->postbox('import', __('Import', 'yoast-wpseo'), $content);
            do_action('wpseo_import', $this);
            $content = '</form>';
            $content .= '<strong>Export</strong><br/>';
            $content .= '<form method="post">';
            $content .= '<p>' . __('Export your WordPress SEO settings here, to import them again later or to import them on another site.') . '</p>';
            if (phpversion() > 5.2) {
                $content .= $this->checkbox('include_taxonomy_meta', __('Include Taxonomy Metadata'));
            }
            $content .= '<input type="submit" class="button" name="wpseo_export" value="' . __('Export settings') . '"/>';
            $content .= '</form>';
            if (isset($_POST['wpseo_export'])) {
                $include_taxonomy = false;
                if (isset($_POST['wpseo']['include_taxonomy_meta'])) {
                    $include_taxonomy = true;
                }
                $url = wpseo_export_settings($include_taxonomy);
                if ($url) {
                    $content .= '<script type="text/javascript">
						document.location = \'' . $url . '\';
					</script>';
                } else {
                    $content .= 'Error: ' . $url;
                }
            }
            $content .= '<br class="clear"/><br/><strong>Import</strong><br/>';
            if (!isset($_FILES['settings_import_file']) || empty($_FILES['settings_import_file'])) {
                $content .= '<p>' . __('Import settings by locating <em>settings.zip</em> and clicking') . ' "' . __('Import settings') . '":</p>';
                $content .= '<form method="post" enctype="multipart/form-data">';
                $content .= '<input type="file" name="settings_import_file"/>';
                $content .= '<input type="hidden" name="action" value="wp_handle_upload"/>';
                $content .= '<input type="submit" class="button" value="' . __('Import settings') . '"/>';
                $content .= '</form>';
            } else {
                $file = wp_handle_upload($_FILES['settings_import_file']);
                if (isset($file['file']) && !is_wp_error($file)) {
                    require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
                    $zip = new PclZip($file['file']);
                    $unzipped = $zip->extract($p_path = WP_CONTENT_DIR . '/wpseo-import/');
                    if ($unzipped[0]['stored_filename'] == 'settings.ini') {
                        $options = parse_ini_file(WP_CONTENT_DIR . '/wpseo-import/settings.ini', true);
                        foreach ($options as $name => $optgroup) {
                            if ($name != 'wpseo_taxonomy_meta') {
                                update_option($name, $optgroup);
                            } else {
                                update_option($name, json_decode(urldecode($optgroup['wpseo_taxonomy_meta']), true));
                            }
                        }
                        @unlink(WP_CONTENT_DIR . '/wpseo-import/');
                        $content .= '<p><strong>' . __('Settings successfully imported.') . '</strong></p>';
                    } else {
                        $content .= '<p><strong>' . __('Settings could not be imported:') . ' ' . __('Unzipping failed.') . '</strong></p>';
                    }
                } else {
                    if (is_wp_error($file)) {
                        $content .= '<p><strong>' . __('Settings could not be imported:') . ' ' . $file['error'] . '</strong></p>';
                    } else {
                        $content .= '<p><strong>' . __('Settings could not be imported:') . ' ' . __('Upload failed.') . '</strong></p>';
                    }
                }
            }
            $this->postbox('wpseo_export', __('Export & Import SEO Settings', 'yoast-wpseo'), $content);
            $this->admin_footer('Import', false);
        }
コード例 #2
0
ファイル: class-metabox.php プロジェクト: macosxvn/techheroes
 /**
  * Calculate the page analysis results for post.
  *
  * @param object $post Post to calculate the results for.
  * @return array
  */
 function calculate_results($post)
 {
     $options = get_wpseo_options();
     if (!class_exists('DOMDocument')) {
         $result = new WP_Error('no-domdocument', sprintf(__("Your hosting environment does not support PHP's %sDocument Object Model%s.", 'wordpress-seo'), '<a href="http://php.net/manual/en/book.dom.php">', '</a>') . ' ' . __("To enjoy all the benefits of the page analysis feature, you'll need to (get your host to) install it.", 'wordpress-seo'));
         return $result;
     }
     if (!wpseo_get_value('focuskw', $post->ID)) {
         $result = new WP_Error('no-focuskw', sprintf(__('No focus keyword was set for this %s. If you do not set a focus keyword, no score can be calculated.', 'wordpress-seo'), $post->post_type));
         wpseo_set_value('linkdex', 0, $post->ID);
         return $result;
     }
     $results = array();
     $job = array();
     $sampleurl = get_sample_permalink($post);
     $job["pageUrl"] = preg_replace('/%(post|page)name%/', $sampleurl[1], $sampleurl[0]);
     $job["pageSlug"] = urldecode($post->post_name);
     $job["keyword"] = trim(wpseo_get_value('focuskw'));
     $job["keyword_folded"] = $this->strip_separators_and_fold($job["keyword"]);
     $job["post_id"] = $post->ID;
     $dom = new domDocument();
     $dom->strictErrorChecking = false;
     $dom->preserveWhiteSpace = false;
     @$dom->loadHTML($post->post_content);
     $xpath = new DOMXPath($dom);
     $statistics = new Yoast_TextStatistics();
     // Check if this focus keyword has been used already.
     $this->check_double_focus_keyword($job, $results);
     // Keyword
     $this->score_keyword($job['keyword'], $results);
     // Title
     if (wpseo_get_value('title')) {
         $job['title'] = wpseo_get_value('title');
     } else {
         if (isset($options['title-' . $post->post_type]) && $options['title-' . $post->post_type] != '') {
             $title_template = $options['title-' . $post->post_type];
         } else {
             $title_template = '%%title%% - %%sitename%%';
         }
         $job['title'] = wpseo_replace_vars($title_template, (array) $post);
     }
     $this->score_title($job, $results, $statistics);
     // Meta description
     $description = '';
     if (wpseo_get_value('metadesc')) {
         $description = wpseo_get_value('metadesc');
     } else {
         if (isset($options['metadesc-' . $post->post_type]) && !empty($options['metadesc-' . $post->post_type])) {
             $description = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post);
         }
     }
     $meta_length = apply_filters('wpseo_metadesc_length', 156, $post);
     $this->score_description($job, $results, $description, $statistics, $meta_length);
     unset($description);
     // Body
     $body = $this->get_body($post);
     $firstp = $this->get_first_paragraph($post);
     $this->score_body($job, $results, $body, $firstp, $statistics);
     unset($body);
     unset($firstp);
     // URL
     $this->score_url($job, $results, $statistics);
     // Headings
     $headings = $this->get_headings($post->post_content);
     $this->score_headings($job, $results, $headings);
     unset($headings);
     // Images
     $imgs = array();
     $imgs['count'] = substr_count($post->post_content, '<img');
     $imgs = $this->get_images_alt_text($post, $imgs);
     $this->score_images_alt_text($job, $results, $imgs);
     unset($imgs);
     // Anchors
     $anchors = $this->get_anchor_texts($xpath);
     $count = $this->get_anchor_count($xpath);
     $this->score_anchor_texts($job, $results, $anchors, $count);
     unset($anchors, $count, $dom);
     $results = apply_filters('wpseo_linkdex_results', $results, $job, $post);
     $this->aasort($results, 'val');
     $overall = 0;
     $overall_max = 0;
     foreach ($results as $result) {
         $overall += $result['val'];
         $overall_max += 9;
     }
     if ($overall < 1) {
         $overall = 1;
     }
     $score = round($overall / $overall_max * 100);
     wpseo_set_value('linkdex', absint($score), $post->ID);
     return $results;
 }
コード例 #3
0
ファイル: dashboard.php プロジェクト: jeetututeja/Ingenia
/**
 * Handle deactivation & import of Robots Meta data
 *
 * @ since 1.4.8
 */
function robots_meta_handler()
{
    global $wpdb;
    // check if robots meta is running
    if (is_plugin_active('robots-meta/robots-meta.php')) {
        // deactivate robots meta
        if (isset($_GET['deactivate_robots_meta']) && $_GET['deactivate_robots_meta'] == 1) {
            deactivate_plugins('robots-meta/robots-meta.php');
            // show notice that robots meta has been deactivated
            add_action('wpseo_all_admin_notices', 'wpseo_deactivate_robots_meta_notice');
            // import the settings
        } else {
            if (isset($_GET['import_robots_meta']) && $_GET['import_robots_meta'] == 1) {
                // import robots meta setting for each post
                $posts = $wpdb->get_results("SELECT ID, robotsmeta FROM {$wpdb->posts}");
                foreach ($posts as $post) {
                    // sync all possible settings
                    if ($post->robotsmeta) {
                        $pieces = explode(',', $post->robotsmeta);
                        foreach ($pieces as $meta) {
                            switch ($meta) {
                                case 'noindex':
                                    wpseo_set_value('meta-robots-noindex', true, $post->ID);
                                    break;
                                case 'index':
                                    wpseo_set_value('meta-robots-noindex', 2, $post->ID);
                                    break;
                                case 'nofollow':
                                    wpseo_set_value('meta-robots-nofollow', true, $post->ID);
                                    break;
                                case 'follow':
                                    wpseo_set_value('meta-robots-nofollow', 0, $post->ID);
                                    break;
                                default:
                                    // do nothing
                            }
                        }
                    }
                }
                // show notice to deactivate robots meta plugin
                add_action('wpseo_all_admin_notices', 'wpseo_deactivate_link_robots_meta_notice');
                // show notice to import robots meta settings
            } else {
                add_action('wpseo_all_admin_notices', 'wpseo_import_robots_meta_notice');
            }
        }
    }
}
コード例 #4
0
ファイル: import.php プロジェクト: gumbysgoo/bestilblomster
     $msg .= __('All in One SEO data successfully imported.', 'wordpress-seo');
 }
 if (isset($_POST['wpseo']['importaioseoold'])) {
     replace_meta('description', '_yoast_wpseo_metadesc', $replace);
     replace_meta('keywords', '_yoast_wpseo_metakeywords', $replace);
     replace_meta('title', '_yoast_wpseo_title', $replace);
     $msg .= __('All in One SEO (Old version) data successfully imported.', 'wordpress-seo');
 }
 if (isset($_POST['wpseo']['importrobotsmeta'])) {
     $posts = $wpdb->get_results("SELECT ID, robotsmeta FROM {$wpdb->posts}");
     foreach ($posts as $post) {
         if (strpos($post->robotsmeta, 'noindex') !== false) {
             wpseo_set_value('meta-robots-noindex', true, $post->ID);
         }
         if (strpos($post->robotsmeta, 'nofollow') !== false) {
             wpseo_set_value('meta-robots-nofollow', true, $post->ID);
         }
     }
     $msg .= __('Robots Meta values imported.', 'wordpress-seo');
 }
 if (isset($_POST['wpseo']['importrssfooter'])) {
     $optold = get_option('RSSFooterOptions');
     $optnew = get_option('wpseo_rss');
     if ($optold['position'] == 'after') {
         if (empty($optnew['rssafter'])) {
             $optnew['rssafter'] = $optold['footerstring'];
         }
     } else {
         if (empty($optnew['rssbefore'])) {
             $optnew['rssbefore'] = $optold['footerstring'];
         }
コード例 #5
0
ファイル: pvc_class.php プロジェクト: selectSIFISO/.comsite
 public static function fixed_wordpress_seo_plugin($ogdesc = '')
 {
     if (function_exists('wpseo_set_value')) {
         global $post;
         $postid = $post->ID;
         wpseo_set_value('opengraph-description', $ogdesc, $postid);
     }
     return $ogdesc;
 }