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
install.php
130 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 Install{ |
| 15 | |
| 16 | static function activate(){ |
| 17 | self::default_settings(); |
| 18 | update_option('siteseo_version', SITESEO_VERSION); |
| 19 | } |
| 20 | |
| 21 | static function deactivate(){ |
| 22 | flush_rewrite_rules(); |
| 23 | } |
| 24 | |
| 25 | static function uninstall(){ |
| 26 | flush_rewrite_rules(); |
| 27 | delete_option('siteseo_version'); |
| 28 | delete_option('siteseo_toggle'); |
| 29 | delete_option('siteseo_titles_option_name'); |
| 30 | delete_option('siteseo_social_option_name'); |
| 31 | delete_option('siteseo_advanced_option_name'); |
| 32 | delete_option('siteseo_instant_indexing_option_name'); |
| 33 | delete_option('siteseo_xml_sitemap_option_name'); |
| 34 | delete_option('siteseo_google_analytics_option_name'); |
| 35 | delete_option('siteseo_dismiss_intro'); |
| 36 | } |
| 37 | |
| 38 | static function action_links($links, $file){ |
| 39 | |
| 40 | if($file === plugin_basename(SITESEO_FILE)){ |
| 41 | |
| 42 | $links['siteseo-settings'] = '<a href="'.admin_url('admin.php?page=siteseo').'">'. __('Settings', 'siteseo').'</a>'; |
| 43 | $links['siteseo-wizard'] = '<a href="'.admin_url('?page=siteseo-onboarding').'">'. __('Configuration Wizard', 'siteseo').'</a>'; |
| 44 | $links['siteseo-docs-link'] = '<a href="https://siteseo.io/docs/" target="_blank"">'. __('Docs', 'siteseo').'</a>'; |
| 45 | |
| 46 | } |
| 47 | |
| 48 | return $links; |
| 49 | } |
| 50 | |
| 51 | static function default_settings(){ |
| 52 | // We do not need to set defaults if we just upgrading the plugin |
| 53 | $current_version = get_option('siteseo_version'); |
| 54 | if(!empty($current_version)){ |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | $titles_metas = get_option('siteseo_titles_option_name', []); |
| 59 | $social_settings = get_option('siteseo_social_option_name', []); |
| 60 | $advanced_settings = get_option('siteseo_advanced_option_name', []); |
| 61 | $sitemap_settings = get_option('siteseo_xml_sitemap_option_name', []); |
| 62 | |
| 63 | $toggle_settings = [ |
| 64 | 'toggle-titles' => true, |
| 65 | 'toggle-xml-sitemap' => true, |
| 66 | 'toggle-instant-indexing' => true, |
| 67 | 'toggle-advanced' => true, |
| 68 | 'toggle-social' => true, |
| 69 | 'toggle-google-analytics' => true |
| 70 | ]; |
| 71 | |
| 72 | // Titles and Metas |
| 73 | $titles_metas['titles_sep'] = '-'; |
| 74 | $titles_metas['titles_home_site_title'] = !isset($titles_metas['titles_home_site_title']) ? '%%sitetitle%%' : $titles_metas['titles_home_site_title']; |
| 75 | $titles_metas['titles_home_site_desc'] = !isset($titles_metas['titles_home_site_desc']) ? '%%tagline%%' : $titles_metas['titles_home_site_desc']; |
| 76 | |
| 77 | $post_types = siteseo_post_types(); |
| 78 | if(!empty($post_types) && is_array($post_types)){ |
| 79 | $post_types = array_keys($post_types); |
| 80 | |
| 81 | foreach($post_types as $post_type){ |
| 82 | $titles_metas['titles_single_titles'][$post_type]['title'] = !isset($titles_metas['titles_single_titles'][$post_type]['title']) ? '%%post_title%% %%sep%% %%sitetitle%%' : $titles_metas['titles_single_titles'][$post_type]['title']; |
| 83 | $titles_metas['titles_single_titles'][$post_type]['description'] = !isset($titles_metas['titles_single_titles'][$post_type]['description']) ? '%%post_excerpt%% ' : $titles_metas['titles_single_titles'][$post_type]['description']; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | $taxonomies = get_taxonomies(array('public' => true), 'objects'); |
| 88 | if(!empty($taxonomies) && is_array($taxonomies)){ |
| 89 | $taxonomies = array_keys($taxonomies); |
| 90 | |
| 91 | foreach($taxonomies as $taxonomy){ |
| 92 | $titles_metas['titles_tax_titles'][$taxonomy]['title'] = !isset($titles_metas['titles_tax_titles'][$taxonomy]['title']) ? '%%_category_title%% %%sep%% %%sitetitle%%' : $titles_metas['titles_tax_titles'][$taxonomy]['title']; |
| 93 | $titles_metas['titles_tax_titles'][$taxonomy]['description'] = !isset($titles_metas['titles_tax_titles'][$taxonomy]['description']) ? '%%_category_description%%' : $titles_metas['titles_tax_titles'][$taxonomy]['description']; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | $titles_metas['titles_archives_author_title'] = !isset($titles_metas['titles_archives_author_title']) ? '%%post_author%% %%sep%% %%sitetitle%%' : $titles_metas['titles_archives_author_title']; |
| 98 | $titles_metas['titles_archives_author_noindex'] = !isset($titles_metas['titles_archives_author_noindex']) ? true : ''; |
| 99 | $titles_metas['titles_archives_date_title'] = !isset($titles_metas['titles_archives_date_title']) ? '%%archive_date%% %%sep%% %%sitetitle%%' : ''; |
| 100 | $titles_metas['titles_archives_date_noindex'] = !isset($titles_metas['titles_archives_date_noindex']) ? true : ''; |
| 101 | $titles_metas['titles_archives_search_title_noindex'] = !isset($titles_metas['titles_archives_search_title_noindex']) ? true : ''; |
| 102 | $titles_metas['titles_nositelinkssearchbox'] = !isset($titles_metas['titles_nositelinkssearchbox']) ? true : ''; |
| 103 | $titles_metas['titles_archives_search_title'] = !isset($titles_metas['titles_archives_search_title']) ? '%%search_keywords%% %%sep%% %%sitetitle%%' : ''; |
| 104 | $titles_metas['titles_archives_404_title'] = !isset($titles_metas['titles_archives_404_title']) ? '404 - Page not found %%sep%% %%sitetitle%%' : $titles_metas['titles_archives_404_title']; |
| 105 | |
| 106 | // Social |
| 107 | $social_settings['social_twitter_card'] = true; |
| 108 | $social_settings['social_facebook_og'] = true; |
| 109 | |
| 110 | // Sitemap |
| 111 | $sitemap_settings['xml_sitemap_general_enable'] = true; |
| 112 | $sitemap_settings['xml_sitemap_post_types_list']['post']['include'] = true; |
| 113 | $sitemap_settings['xml_sitemap_post_types_list']['page']['include'] = true; |
| 114 | $sitemap_settings['xml_sitemap_taxonomies_list']['category']['include'] = true; |
| 115 | $sitemap_settings['xml_sitemap_img_enable'] = true; |
| 116 | |
| 117 | // Advanced |
| 118 | $advanced_settings['advanced_attachments'] = true; |
| 119 | $advanced_settings['appearance_universal_metabox'] = true; |
| 120 | |
| 121 | update_option('siteseo_toggle', $toggle_settings); |
| 122 | update_option('siteseo_titles_option_name', $titles_metas); |
| 123 | update_option('siteseo_social_option_name', $social_settings); |
| 124 | update_option('siteseo_xml_sitemap_option_name', $sitemap_settings); |
| 125 | update_option('siteseo_advanced_option_name', $advanced_settings); |
| 126 | |
| 127 | } |
| 128 | |
| 129 | } |
| 130 |