Plugin Directory

Changeset 2920896


Ignore:
Timestamp:
06/03/2023 12:02:12 AM (3 years ago)
Author:
zuda
Message:

REmoving unique link and alt image seo, for the time being. These features did not work in previous versions.

Location:
redirect-editor/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • redirect-editor/trunk/readme.txt

    r2920073 r2920896  
    1 === Search Engine Optimization redirect editor ===
     1=== SEO & redirect ===
    22Contributors: PlanetZuda, justincwatt, weskoop, thehackerrosey
    33website link: https://planetzuda.com
    44security-flaw:security@planetzuda.com
    5 Tags: SEO, xml sitemap, content analysis,ADA, image optimization, image seo, alt tag seo, alt seo, ADA SEO
     5Tags: SEO, xml sitemap, content analysis,
    66Requires at least: 3.0
    77Tested up to: 6.2.2
     
    5050It adds in some protection from certain SEO software that has flaws which we patched.
    5151== Screenshots ==
     52==3.1.8==
     53Removed unique link feature and image alt text seo for the time being. These features did not work in previous versions.  The attempt to automatically make images blind friendly has been removed, for the time being. We are working on coming up with the best solutions. In no way is trying to make images blind friendly and helpful for SEO legal compliance with the ADA, if that ever occurs that would be a random unintentional side effect that would be on a site by site basis, based on your dataset, which is completely  outside of our control.
    5254== 3.1.7 ==
    5355patches for bugs possibly going all the way back to 1.x, redirect editor feature working better than ever. We are no longer under settings we have our own icon in wp backend menu bar called seo plugin
  • redirect-editor/trunk/redirect-editor.php

    r2920073 r2920896  
    3333Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3434*/
    35 define( 'WP_DEBUG', true );
    36 define( 'WP_DEBUG_LOG', true );
    37 define( 'WP_DEBUG_DISPLAY', false );
    3835class Redirect_Editor_Plugin {
    3936
     
    328325//echo $unique_slug; // Output: "example-post-slug-2" (if the initial slug exists)
    329326
    330 
    331 class ImageAltTagOptimization {
    332     public function __construct() {
    333         add_filter('wp_get_attachment_image_attributes', array($this, 'optimize_image_alt_tags'), 10, 2);
    334     }
    335 
    336     public function optimize_image_alt_tags($attr, $attachment) {
    337         // Get the image caption
    338         $caption = get_post_field('post_excerpt', $attachment->ID);
    339 
    340         // Check if a caption exists
    341         if ($caption) {
    342             // Use the caption for alt text
    343             $alt_text = $caption;
    344         } else {
    345             // Fallback to the post title
    346             $alt_text = get_the_title($attachment->post_parent);
    347         }
    348 
    349         // Update the alt attribute
    350         $attr['alt'] = $alt_text;
    351 
    352         return $attr;
    353     }
    354 }
    355 
    356 $image_alt_tag_optimization = new ImageAltTagOptimization();
     327/**
     328 * Function to get the post title or image caption for alt tag content.
     329 *
     330 * @param int $post_id The ID of the post.
     331 * @return string|bool Alt tag content on success, false on failure.
     332 */
     333function get_post_title_or_image_caption($post_id) {
     334    $post_title = get_the_title($post_id);
     335    $image_caption = get_the_post_thumbnail_caption($post_id);
     336
     337    if (!empty($image_caption)) {
     338        // Limit caption to 140 characters.
     339        $caption = substr($image_caption, 0, 140);
     340
     341        // Remove HTML tags and extra spaces from the caption.
     342        $caption = wp_strip_all_tags($caption);
     343        $caption = trim($caption);
     344
     345        // Remove stop words from the caption.
     346        $stop_words = array(
     347            'a', 'an', 'the', 'and', 'but', 'or', 'nor', 'for', 'so', 'yet', 'not',
     348            'in', 'on', 'at', 'to', 'from', 'by', 'with', 'about', 'above', 'below',
     349            'over', 'under', 'among', 'between', 'through', 'during', 'before', 'after',
     350            'up', 'down', 'out', 'off', 'on', 'in', 'into', 'onto', 'after', 'before',
     351            'behind', 'above', 'below', 'under', 'over', 'between', 'among', 'throughout',
     352            'underneath', 'beside', 'around', 'amongst', 'upon'
     353        ); // Add more stop words as needed.
     354
     355        $caption_words = preg_split("/[\s,]+/", $caption);
     356        $filtered_words = array_diff($caption_words, $stop_words);
     357
     358        // Define an exhaustive list of action, expressive, and descriptive words.
     359        $action_words = array(
     360            'accomplish', 'achieve', 'act', 'animate', 'apply', 'arrange', 'ascend', 'assemble',
     361            'assert', 'assess', 'assign', 'attain', 'awaken', 'balance', 'breathe', 'build',
     362            'calculate', 'capture', 'celebrate', 'challenge', 'change', 'characterize', 'choose',
     363            'collaborate', 'combine', 'command', 'communicate', 'complete', 'compose', 'concentrate',
     364            'conclude', 'connect', 'conquer', 'construct', 'contribute', 'control', 'coordinate',
     365            'create', 'cultivate', 'decide', 'dedicate', 'define', 'deliver', 'design', 'develop',
     366            'discover', 'display', 'diversify', 'do', 'document', 'draw', 'drive', 'earn',
     367            'educate', 'elevate', 'embrace', 'emerge', 'encourage', 'enhance', 'enjoy', 'enlighten',
     368            'enrich', 'envision', 'establish', 'evaluate', 'evolve', 'examine', 'excel', 'execute',
     369            'explore', 'express', 'extend', 'extract', 'facilitate', 'foster', 'generate', 'give',
     370            'guide', 'harmonize', 'harness', 'highlight', 'identify', 'ignite', 'illustrate', 'implement',
     371            'improve', 'incorporate', 'increase', 'influence', 'initiate', 'innovate', 'inspect', 'inspire',
     372            'integrate', 'interact', 'interpret', 'introduce', 'investigate', 'invigorate', 'join', 'journey',
     373            'justify', 'launch', 'lead', 'learn', 'listen', 'manage', 'maximize', 'measure', 'merge',
     374            'motivate', 'navigate', 'observe', 'operate', 'organize', 'overcome', 'participate', 'perform',
     375            'persuade', 'plan', 'play', 'practice', 'prepare', 'present', 'produce', 'promote', 'propose',
     376            'protect', 'provide', 'pursue', 'question', 'realize', 'reconcile', 'record', 'recruit', 'reflect',
     377            'reinforce', 'relate', 'release', 'remodel', 'renovate', 'research', 'resolve', 'revitalize',
     378            'revive', 'reward', 'satisfy', 'schedule', 'share', 'show', 'simplify', 'solve', 'spark',
     379            'succeed', 'support', 'surpass', 'synthesize', 'take', 'teach', 'test', 'transform', 'travel',
     380            'uncover', 'unite', 'utilize', 'validate', 'value', 'visualize', 'win', 'witness'
     381        );
     382
     383        $expressive_words = array(
     384            'adventurous', 'amazing', 'awe-inspiring', 'beautiful', 'breathtaking', 'brilliant',
     385            'captivating', 'charming', 'colorful', 'creative', 'delightful', 'dramatic', 'dynamic',
     386            'elegant', 'enchanting', 'energetic', 'enthralling', 'entertaining', 'exhilarating',
     387            'extraordinary', 'fascinating', 'fun', 'gorgeous', 'impressive', 'innovative', 'inspiring',
     388            'intriguing', 'joyful', 'lively', 'lovely', 'magical', 'mesmerizing', 'mind-blowing', 'mysterious',
     389            'outstanding', 'passionate', 'powerful', 'remarkable', 'sensational', 'spectacular', 'stunning',
     390            'surprising', 'thrilling', 'vibrant', 'wonderful'
     391        );
     392
     393        $descriptive_words = array(
     394            'ancient', 'beautiful', 'charismatic', 'cozy', 'elegant', 'enchanting', 'exotic',
     395            'fascinating', 'fragrant', 'grand', 'historic', 'majestic', 'magnificent', 'mystical',
     396            'peaceful', 'picturesque', 'quaint', 'rustic', 'scenic', 'serene', 'soothing', 'splendid',
     397            'tranquil', 'unique', 'vibrant', 'vivid'
     398        );
     399
     400        $valuable_words = array();
     401        foreach ($filtered_words as $word) {
     402            if (in_array($word, $action_words) || in_array($word, $expressive_words) || in_array($word, $descriptive_words)) {
     403                $valuable_words[] = $word;
     404            }
     405        }
     406
     407        // Use the valuable words to create the alt tag content.
     408        $alt_content = implode(' ', $valuable_words);
     409
     410        if (!empty($alt_content)) {
     411            return $alt_content;
     412        }
     413    }
     414
     415    // If no valuable words are found or caption is empty, return the post title.
     416    if (!empty($post_title)) {
     417        return $post_title;
     418    }
     419
     420    return false;
     421}
     422
     423
    357424
    358425?>
Note: See TracChangeset for help on using the changeset viewer.