Changeset 2824975
- Timestamp:
- 11/27/2022 10:55:02 PM (3 years ago)
- Location:
- seo-lite/trunk
- Files:
-
- 7 added
- 3 edited
-
README.txt (modified) (3 diffs)
-
admin (added)
-
admin/class-seo-lite-admin.php (added)
-
admin/index.php (added)
-
admin/scripts.js (added)
-
admin/styles.css (added)
-
admin/styles.scss (added)
-
index.php (added)
-
seo-lite.php (modified) (2 diffs)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
seo-lite/trunk/README.txt
r2820656 r2824975 2 2 Contributors: aPEDESTRIAN 3 3 Donate link: https://www.paypal.com/donate/?hosted_button_id=JTBPY8ZWAXG6N 4 Stable tag: 2. 0.04 Stable tag: 2.1.0 5 5 Tested up to: 6.1.1 6 6 Tags: seo, open graph, og 7 License: GPL v2 or later7 License: GPL-2.0+ 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html 9 9 … … 12 12 == Description == 13 13 14 SEO Lite is meant to be that: lite. In under 100 lines of code, SEO Lite adds the following tags:14 SEO Lite is meant to be that: lite. In under 80 lines of code on the frontend, SEO Lite adds the following tags: 15 15 16 16 * og:locale - Uses get_locale() … … 24 24 * og:image - Uses featured image on posts/pages and the site icon on the front page 25 25 * og:image:{type/width/height/alt} - Added if we have an 'og:image' (only adds 'alt' if availble) 26 27 Additionally, SEO Lite has a settings page (Dashboard > Settings > SEO Lite) where you can add custom tags for all pages (ie, google analytics, AdSense, etc). 28 29 == Changelog == 30 31 = 2.1.0 = 32 * Added Custom Tags section to SEO Lite settings page 33 34 = 2.0.0 = 35 * Greatly simplified code to live up to the name "Lite" -
seo-lite/trunk/seo-lite.php
r2820668 r2824975 5 5 Plugin URI: https://github.com/apedestrian/SEO-Lite 6 6 Description: Adds all of the basic Open Graph meta tags to the site head. 7 Version: 2. 0.07 Version: 2.1.0 8 8 Author: aPEDESTRIAN 9 9 Author URI: https://github.com/apedestrian … … 12 12 */ 13 13 14 // Remove all options. SEO Lite just adds og tags and nothing else from now on; Nothing lite about all those options :( 15 add_action('upgrader_process_complete', function ($upgrader_object, $options) { 16 if ($options['action'] == 'update' && $options['type'] == 'plugin') { 17 foreach($options['plugins'] as $each_plugin) { 18 if ($each_plugin == plugin_basename(__FILE__)) { 19 delete_option('seo_lite_add_title_tag'); 20 delete_option('seo_lite_site_description'); 21 delete_option('seo_lite_google_code'); 22 delete_option('seo_lite_bing_code'); 23 delete_option('seo_lite_facebook_app_id'); 24 delete_option('seo_lite_twitter_username'); 25 } 26 } 27 } 28 }, 10, 2); 14 // Only load admin pages on backend 15 if (is_admin()) { 16 require_once plugin_dir_path(__FILE__) . 'admin/class-seo-lite-admin.php'; 17 $plugin_admin = new SEO_Lite_Admin(); 18 } 29 19 30 20 add_action('wp_head', function () { 31 21 ?> 32 <!------------ <SEO> ------------> 33 <meta property="og:locale" content="<?php echo esc_attr(get_locale()); ?>"> 34 <meta property="og:site_name" content="<?php echo esc_attr(get_bloginfo('name')); ?>"> 35 <meta property="og:title" content="<?php echo esc_attr(wp_get_document_title()); ?>"> 36 <?php // Front page 37 if (is_front_page()): ?> 38 <?php if ($description = get_bloginfo('description')): ?> 22 <!------------ <seo-lite> ------------> 23 <meta property="og:locale" content="<?php echo esc_attr(get_locale()); ?>"> 24 <meta property="og:site_name" content="<?php echo esc_attr(get_bloginfo('name')); ?>"> 25 <meta property="og:title" content="<?php echo esc_attr(wp_get_document_title()); ?>"> 26 <?php // Front page 27 if (is_front_page()): ?> 28 <?php if ($description = get_bloginfo('description')): ?> 29 <meta property="og:description" content="<?php echo esc_attr((strlen($description) > 200 ? substr($description, 0, 197) . '...' : $description)); ?>"> 30 <?php endif; ?> 31 <meta property="og:url" content="<?php echo esc_url(home_url()); ?>"> 32 <meta property="og:type" content="website"> 33 <?php if ($attachment_id = get_option('site_icon')): $attachment_meta = wp_get_attachment_metadata($attachment_id); ?> 34 <meta property="og:image" content="<?php echo esc_url(wp_get_attachment_url($attachment_id)); ?>"> 35 <meta property="og:image:type" content="<?php echo esc_attr(get_post_mime_type($attachment_id)); ?>"> 36 <meta property="og:image:width" content="<?php echo esc_attr($attachment_meta['width']); ?>"> 37 <meta property="og:image:height" content="<?php echo esc_attr($attachment_meta['height']); ?>"> 38 <meta property="og:image:alt" content="<?php echo esc_attr(get_bloginfo('name')); ?>"> 39 <?php endif; ?> 40 <?php // Single Post and Page 41 elseif (is_single() || is_page()): ?> 42 <?php if ($description = get_the_excerpt()): ?> 43 <meta property="og:description" content="<?php echo esc_attr((strlen($description) > 200 ? substr($description, 0, 197) . '...' : $description)); ?>"> 44 <?php endif; ?> 45 <meta property="og:url" content="<?php echo esc_url(get_the_permalink()); ?>"> 46 <meta property="og:type" content="article"> 47 <meta property="article:published_time" content="<?php echo esc_attr(get_the_date('c')); ?>"> 48 <meta property="article:modified_time" content="<?php echo esc_attr(get_the_modified_date('c')); ?>"> 49 <?php if ($attachment_id = get_post_thumbnail_id()): $attachment_meta = wp_get_attachment_metadata($attachment_id); ?> 50 <meta property="og:image" content="<?php echo esc_url(wp_get_attachment_url($attachment_id)); ?>"> 51 <meta property="og:image:type" content="<?php echo esc_attr(get_post_mime_type($attachment_id)); ?>"> 52 <meta property="og:image:width" content="<?php echo esc_attr($attachment_meta['width']); ?>"> 53 <meta property="og:image:height" content="<?php echo esc_attr($attachment_meta['height']); ?>"> 54 <?php if ($attachment_alt == get_post_meta($attachment_id, '_wp_attachment_image_alt', true)): ?> 55 <meta property="og:image:alt" content="<?php echo esc_attr($attachment_alt); ?>"> 56 <?php endif; ?> 57 <?php endif; ?> 58 <?php // Everything Else 59 else: global $wp; ?> 60 <?php if (is_archive()): ?> 61 <?php if ($description = get_the_archive_description()): ?> 39 62 <meta property="og:description" content="<?php echo esc_attr((strlen($description) > 200 ? substr($description, 0, 197) . '...' : $description)); ?>"> 40 63 <?php endif; ?> 41 <meta property="og:url" content="<?php echo esc_url(home_url()); ?>">42 <meta property="og:type" content="website">43 <?php if ($attachment_id = get_option('site_icon')): $attachment_meta = wp_get_attachment_metadata($attachment_id); ?>44 <meta property="og:image" content="<?php echo esc_url(wp_get_attachment_url($attachment_id)); ?>">45 <meta property="og:image:type" content="<?php echo esc_attr(get_post_mime_type($attachment_id)); ?>">46 <meta property="og:image:width" content="<?php echo esc_attr($attachment_meta['width']); ?>">47 <meta property="og:image:height" content="<?php echo esc_attr($attachment_meta['height']); ?>">48 <meta property="og:image:alt" content="<?php echo esc_attr(get_bloginfo('name')); ?>">49 <?php endif; ?>50 <?php // Single Post and Page51 elseif (is_single() || is_page()): ?>52 <?php if ($description = get_the_excerpt()): ?>53 <meta property="og:description" content="<?php echo esc_attr((strlen($description) > 200 ? substr($description, 0, 197) . '...' : $description)); ?>">54 <?php endif; ?>55 <meta property="og:url" content="<?php echo esc_url(get_the_permalink()); ?>">56 <meta property="og:type" content="article">57 <meta property="article:published_time" content="<?php echo esc_attr(get_the_date('c')); ?>">58 <meta property="article:modified_time" content="<?php echo esc_attr(get_the_modified_date('c')); ?>">59 <?php if ($attachment_id = get_post_thumbnail_id()): $attachment_meta = wp_get_attachment_metadata($attachment_id); ?>60 <meta property="og:image" content="<?php echo esc_url(wp_get_attachment_url($attachment_id)); ?>">61 <meta property="og:image:type" content="<?php echo esc_attr(get_post_mime_type($attachment_id)); ?>">62 <meta property="og:image:width" content="<?php echo esc_attr($attachment_meta['width']); ?>">63 <meta property="og:image:height" content="<?php echo esc_attr($attachment_meta['height']); ?>">64 <?php if ($attachment_alt == get_post_meta($attachment_id, '_wp_attachment_image_alt', true)): ?>65 <meta property="og:image:alt" content="<?php echo esc_attr($attachment_alt); ?>">66 <?php endif; ?>67 <?php endif; ?>68 <?php // Everything Else69 else: global $wp; ?>70 <?php if (is_archive()): ?>71 <?php if ($description = get_the_archive_description()): ?>72 <meta property="og:description" content="<?php echo esc_attr((strlen($description) > 200 ? substr($description, 0, 197) . '...' : $description)); ?>">73 <?php endif; ?>74 <?php endif; ?>75 <meta property="og:url" content="<?php echo esc_url(get_option('permalink_structure') == '' ? add_query_arg($wp->query_vars, home_url()) : home_url($wp->request)); ?>">76 <meta property="og:type" content="website">77 64 <?php endif; ?> 78 <!------------ </SEO> -----------> 65 <meta property="og:url" content="<?php echo esc_url(get_option('permalink_structure') == '' ? add_query_arg($wp->query_vars, home_url()) : home_url($wp->request)); ?>"> 66 <meta property="og:type" content="website"> 67 <?php endif; ?> 68 <?php foreach (json_decode(get_option('seo_lite_custom_tags', '[]')) as $property => $content): ?> 69 <meta property="<?php echo esc_attr($property); ?>" content="<?php echo esc_attr($content); ?>"> 70 <?php endforeach; ?> 71 <!------------ </seo-lite> -----------> 79 72 <?php 80 73 }); -
seo-lite/trunk/uninstall.php
r2820656 r2824975 1 <?php 2 3 // If uninstall not called from WordPress, then exit. 4 if (!defined('WP_UNINSTALL_PLUGIN')) { 5 die; 6 } else { 7 delete_option('seo_lite_add_title_tag'); 8 delete_option('seo_lite_site_description'); 9 delete_option('seo_lite_google_code'); 10 delete_option('seo_lite_bing_code'); 11 delete_option('seo_lite_facebook_app_id'); 12 delete_option('seo_lite_twitter_username'); 13 } 1 <?php (defined('WP_UNINSTALL_PLUGIN') && delete_option('seo_lite_custom_tags')) || die;
Note: See TracChangeset
for help on using the changeset viewer.