metaboxes
5 months ago
settings
5 months ago
admin.php
5 months ago
advanced.php
6 months ago
ajax.php
5 months ago
columns.php
9 months ago
generatesitemap.php
5 months ago
googleanalytics.php
9 months ago
imageseo.php
8 months ago
import.php
5 months ago
install.php
8 months ago
instantindexing.php
5 months ago
primarycategory.php
9 months ago
socialmetas.php
5 months ago
tableofcontent.php
1 year ago
titlesmetas.php
5 months ago
columns.php
201 lines
| 1 | <?php |
| 2 | /* |
| 3 | * SITESEO |
| 4 | * https://siteseo.io |
| 5 | * (c) SiteSEO Team |
| 6 | */ |
| 7 | |
| 8 | namespace SiteSEO; |
| 9 | |
| 10 | if(!defined('ABSPATH')){ |
| 11 | die('HACKING ATTEMPT!'); |
| 12 | } |
| 13 | |
| 14 | class Columns{ |
| 15 | |
| 16 | static function add_columns($colums){ |
| 17 | global $siteseo; |
| 18 | |
| 19 | if(empty($siteseo->setting_enabled['toggle-advanced'])){ |
| 20 | return $colums; // toggle disable |
| 21 | } |
| 22 | |
| 23 | $options = $siteseo->advanced_settings; |
| 24 | |
| 25 | if(!empty($options['appearance_title_col'])){ |
| 26 | $colums['seo_title'] = __('Title tag', 'siteseo'); |
| 27 | } |
| 28 | |
| 29 | if(!empty($options['appearance_meta_desc_col'])){ |
| 30 | $colums['meta_description'] = __('Meta Desc' , 'siteseo'); |
| 31 | } |
| 32 | |
| 33 | if(!empty($options['appearance_redirect_enable_col'])){ |
| 34 | $colums['redirect_enabled'] = __('Redirect?', 'siteseo'); |
| 35 | } |
| 36 | |
| 37 | if(!empty($options['appearance_redirect_url_col'])){ |
| 38 | $colums['redirect_url'] = __('Redirect URL', 'siteseo'); |
| 39 | } |
| 40 | |
| 41 | if(!empty($options['appearance_canonical'])){ |
| 42 | $colums['canonical_url'] = __('Canonical', 'siteseo'); |
| 43 | } |
| 44 | |
| 45 | if(!empty($options['appearance_target_kw_col'])){ |
| 46 | $colums['target_keyword'] = __('Target Kw', 'siteseo'); |
| 47 | } |
| 48 | |
| 49 | if(!empty($options['appearance_noindex_col'])){ |
| 50 | $colums['noindex'] = __('noindex?', 'siteseo'); |
| 51 | } |
| 52 | |
| 53 | if(!empty($options['appearance_nofollow_col'])){ |
| 54 | $colums['nofollow'] = __('nofollow?', 'siteseo'); |
| 55 | } |
| 56 | |
| 57 | if(!empty($options['appearance_words_col'])){ |
| 58 | $colums['word_count'] = __('Words', 'siteseo'); |
| 59 | } |
| 60 | |
| 61 | if(!empty($options['appearance_score_col'])){ |
| 62 | $colums['seo_score'] = __('Score', 'siteseo'); |
| 63 | } |
| 64 | |
| 65 | return $colums; |
| 66 | } |
| 67 | |
| 68 | static function populate_custom_seo_columns($column, $post_id){ |
| 69 | global $siteseo; |
| 70 | |
| 71 | if(empty($siteseo->setting_enabled['toggle-advanced'])){ |
| 72 | return; // toggle disable |
| 73 | } |
| 74 | |
| 75 | $options = $siteseo->advanced_settings; |
| 76 | |
| 77 | switch($column){ |
| 78 | |
| 79 | case 'seo_title': |
| 80 | if(!empty($options['appearance_title_col'])){ |
| 81 | $title = get_post_meta($post_id, '_siteseo_titles_title', true); |
| 82 | echo esc_html(\SiteSEO\TitlesMetas::replace_variables($title)); |
| 83 | } |
| 84 | break; |
| 85 | |
| 86 | case 'meta_description': |
| 87 | if(!empty($options['appearance_meta_desc_col'])){ |
| 88 | $desc = get_post_meta($post_id, '_siteseo_titles_desc', true); |
| 89 | $replaced_desc = \SiteSEO\TitlesMetas::replace_variables($desc); |
| 90 | echo esc_html($replaced_desc); |
| 91 | } |
| 92 | break; |
| 93 | |
| 94 | case 'redirect_enabled': |
| 95 | if(!empty($options['appearance_meta_desc_col'])){ |
| 96 | $redirect_enabled = get_post_meta($post_id, 'siteseo_redirections_enabled', true); |
| 97 | echo $redirect_enabled ? esc_html__('Yes', 'siteseo') : esc_html__('No', 'siteseo'); |
| 98 | } |
| 99 | break; |
| 100 | |
| 101 | case 'redirect_url': |
| 102 | if(!empty($options['appearance_redirect_enable_col'])){ |
| 103 | echo esc_url(get_post_meta($post_id, '_siteseo_redirections_value', true)); |
| 104 | } |
| 105 | break; |
| 106 | |
| 107 | case 'canonical_url': |
| 108 | if(!empty($options['appearance_redirect_url_col'])){ |
| 109 | echo esc_url(get_post_meta($post_id, '_siteseo_robots_canonical', true)); |
| 110 | } |
| 111 | break; |
| 112 | |
| 113 | case 'target_keyword': |
| 114 | if(!empty($options['appearance_canonical'])){ |
| 115 | $keywords = esc_html(get_post_meta($post_id, '_siteseo_analysis_target_kw', true)); |
| 116 | echo !empty($keywords) ? esc_html($keywords) : ''; |
| 117 | } |
| 118 | break; |
| 119 | |
| 120 | case 'noindex': |
| 121 | if(!empty($options['appearance_noindex_col'])){ |
| 122 | $noindex = get_post_meta($post_id, '_siteseo_robots_index', true); |
| 123 | echo $noindex ? esc_html__('Yes', 'siteseo') : esc_html__('No', 'siteseo'); |
| 124 | } |
| 125 | break; |
| 126 | |
| 127 | case 'nofollow': |
| 128 | if(!empty($options['appearance_nofollow_col'])){ |
| 129 | $nofollow = get_post_meta($post_id, '_siteseo_robots_follow', true); |
| 130 | echo $nofollow ? esc_html__('Yes', 'siteseo') : esc_html__('No', 'siteseo'); |
| 131 | } |
| 132 | break; |
| 133 | |
| 134 | case 'word_count': |
| 135 | if(!empty($options['appearance_words_col'])){ |
| 136 | $content = get_post_field('post_content', $post_id); |
| 137 | echo esc_html(str_word_count(wp_strip_all_tags($content))); |
| 138 | } |
| 139 | break; |
| 140 | |
| 141 | case 'seo_score': |
| 142 | if(!empty($options['appearance_score_col'])){ |
| 143 | $score = get_post_meta($post_id, '_siteseo_score', true); |
| 144 | echo !empty($score) ? esc_html($score) : ''; |
| 145 | } |
| 146 | break; |
| 147 | } |
| 148 | |
| 149 | } |
| 150 | |
| 151 | static function make_seo_columns_sortable($columns){ |
| 152 | global $siteseo; |
| 153 | |
| 154 | if(empty($siteseo->setting_enabled['toggle-advanced'])){ |
| 155 | return $columns; // toggle disable |
| 156 | } |
| 157 | |
| 158 | $options = $siteseo->advanced_settings; |
| 159 | |
| 160 | if(!empty($options['appearance_title_col'])){ |
| 161 | $columns['seo_title'] = 'seo_title'; |
| 162 | } |
| 163 | |
| 164 | if(!empty($options['appearance_meta_desc_col'])){ |
| 165 | $columns['meta_description'] = 'meta_description'; |
| 166 | } |
| 167 | |
| 168 | if(!empty($options['appearance_target_kw_col'])){ |
| 169 | $columns['target_keyword'] = 'target_keyword'; |
| 170 | } |
| 171 | |
| 172 | if(!empty($options['appearance_words_col'])){ |
| 173 | $columns['word_count'] = 'word_count'; |
| 174 | } |
| 175 | |
| 176 | if(!empty($options['appearance_score_col'])){ |
| 177 | $columns['seo_score'] = 'seo_score'; |
| 178 | } |
| 179 | |
| 180 | return $columns; |
| 181 | |
| 182 | } |
| 183 | |
| 184 | static function hide_genesis_seo(){ |
| 185 | global $siteseo; |
| 186 | |
| 187 | if(empty($siteseo->setting_enabled['toggle-advanced'])){ |
| 188 | return; // toggle disable |
| 189 | } |
| 190 | |
| 191 | $options = $siteseo->advanced_settings; |
| 192 | |
| 193 | if(!empty($options['appearance_genesis_seo_menu'])){ |
| 194 | remove_theme_support('genesis-seo-settings-menu'); |
| 195 | } |
| 196 | |
| 197 | if(!empty($options['appearance_genesis_seo_metaboxe'])){ |
| 198 | remove_action('admin_menu', 'genesis_add_inpost_seo_box'); |
| 199 | } |
| 200 | } |
| 201 | } |