• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / dd6e866a9e6d253114633104d9e3858d807178ba

19 Jun 2024 10:03AM UTC coverage: 48.628% (-4.3%) from 52.936%
dd6e866a9e6d253114633104d9e3858d807178ba

push

github

web-flow
Merge pull request #21431 from Yoast/21429-update-copy-in-the-introduction-and-consent-modals

Updates the copy for the introduction and consent modals

7441 of 13454 branches covered (55.31%)

Branch coverage included in aggregate %.

0 of 3 new or added lines in 2 files covered. (0.0%)

3718 existing lines in 107 files now uncovered.

25100 of 53464 relevant lines covered (46.95%)

62392.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/admin/import/plugins/class-import-smartcrawl.php
1
<?php
2
/**
3
 * File with the class to handle data from Smartcrawl SEO.
4
 *
5
 * @package WPSEO\Admin\Import\Plugins
6
 */
7

8
/**
9
 * Class with functionality to import & clean Smartcrawl SEO post metadata.
10
 */
11
class WPSEO_Import_Smartcrawl_SEO extends WPSEO_Plugin_Importer {
12

13
        /**
14
         * The plugin name.
15
         *
16
         * @var string
17
         */
18
        protected $plugin_name = 'Smartcrawl SEO';
19

20
        /**
21
         * Meta key, used in SQL LIKE clause for delete query.
22
         *
23
         * @var string
24
         */
25
        protected $meta_key = '_wds_%';
26

27
        /**
28
         * Array of meta keys to detect and import.
29
         *
30
         * @var array
31
         */
32
        protected $clone_keys = [
33
                [
34
                        'old_key' => '_wds_metadesc',
35
                        'new_key' => 'metadesc',
36
                ],
37
                [
38
                        'old_key' => '_wds_title',
39
                        'new_key' => 'title',
40
                ],
41
                [
42
                        'old_key' => '_wds_canonical',
43
                        'new_key' => 'canonical',
44
                ],
45
                [
46
                        'old_key' => '_wds_focus-keywords',
47
                        'new_key' => 'focuskw',
48
                ],
49
                [
50
                        'old_key' => '_wds_meta-robots-noindex',
51
                        'new_key' => 'meta-robots-noindex',
52
                ],
53
                [
54
                        'old_key' => '_wds_meta-robots-nofollow',
55
                        'new_key' => 'meta-robots-nofollow',
56
                ],
57
        ];
58

59
        /**
60
         * Used for importing Twitter and Facebook meta's.
61
         *
62
         * @var array
63
         */
64
        protected $social_keys = [];
65

66
        /**
67
         * Handles post meta data to import.
68
         *
69
         * @return bool Import success status.
70
         */
UNCOV
71
        protected function import() {
×
UNCOV
72
                $return = parent::import();
×
UNCOV
73
                if ( $return ) {
×
UNCOV
74
                        $this->import_opengraph();
×
UNCOV
75
                        $this->import_twitter();
×
76
                }
77

UNCOV
78
                return $return;
×
79
        }
80

81
        /**
82
         * Imports the OpenGraph meta keys saved by Smartcrawl.
83
         *
84
         * @return bool Import status.
85
         */
UNCOV
86
        protected function import_opengraph() {
×
UNCOV
87
                $this->social_keys = [
×
UNCOV
88
                        'title'       => 'opengraph-title',
×
UNCOV
89
                        'description' => 'opengraph-description',
×
UNCOV
90
                        'images'      => 'opengraph-image',
×
UNCOV
91
                ];
×
UNCOV
92
                return $this->post_find_import( '_wds_opengraph' );
×
93
        }
94

95
        /**
96
         * Imports the Twitter meta keys saved by Smartcrawl.
97
         *
98
         * @return bool Import status.
99
         */
UNCOV
100
        protected function import_twitter() {
×
UNCOV
101
                $this->social_keys = [
×
UNCOV
102
                        'title'       => 'twitter-title',
×
UNCOV
103
                        'description' => 'twitter-description',
×
UNCOV
104
                ];
×
UNCOV
105
                return $this->post_find_import( '_wds_twitter' );
×
106
        }
107

108
        /**
109
         * Imports a post's serialized post meta values.
110
         *
111
         * @param int    $post_id Post ID.
112
         * @param string $key     The meta key to import.
113
         *
114
         * @return void
115
         */
UNCOV
116
        protected function import_serialized_post_meta( $post_id, $key ) {
×
UNCOV
117
                $data = get_post_meta( $post_id, $key, true );
×
UNCOV
118
                $data = maybe_unserialize( $data );
×
UNCOV
119
                foreach ( $this->social_keys as $key => $meta_key ) {
×
UNCOV
120
                        if ( ! isset( $data[ $key ] ) ) {
×
UNCOV
121
                                return;
×
122
                        }
UNCOV
123
                        $value = $data[ $key ];
×
UNCOV
124
                        if ( is_array( $value ) ) {
×
UNCOV
125
                                $value = $value[0];
×
126
                        }
UNCOV
127
                        $this->maybe_save_post_meta( $meta_key, $value, $post_id );
×
128
                }
129
        }
130

131
        /**
132
         * Finds all the posts with a certain meta key and imports its values.
133
         *
134
         * @param string $key The meta key to search for.
135
         *
136
         * @return bool Import status.
137
         */
UNCOV
138
        protected function post_find_import( $key ) {
×
UNCOV
139
                $query_posts = new WP_Query( 'post_type=any&meta_key=' . $key . '&order=ASC&fields=ids&nopaging=true' );
×
140

UNCOV
141
                if ( empty( $query_posts->posts ) ) {
×
UNCOV
142
                        return false;
×
143
                }
144

UNCOV
145
                foreach ( array_values( $query_posts->posts ) as $post_id ) {
×
UNCOV
146
                        $this->import_serialized_post_meta( $post_id, $key );
×
147
                }
148

UNCOV
149
                return true;
×
150
        }
151
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc