Reply
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • [email protected]
    Participant

    First, thanks for an awesome plugin.

    We used it on our site willysmoke.com and have over 50 shortcodes in play.

    We want to update the affiliate tag on these sites. So it is very time consuming to go through each code and update. So I was hoping we can update all the links in bulk from the back end.

    I read through forum posts and learnt that the data is available in wp_options table with option name ‘shortcoder_data’.

    I attempted to update the data there. The moment I touch anything there, the entire data in the shortcoder app is wiped out.

    I rand a query like below and tested that the change in the value is exactly as intended. But the outcome on wordpress is not. Can you please help?

    Query:
    UPDATE wp_options
    SET option_value=REPLACE(option_value,’amzn.to/2uuptqy’,’www.amazon.com/Victorinox-Fibrox-Chefs-Knife-8-Inch/dp/B008M5U1C2?&tag=willysmoke-20′)
    WHERE option_name=’shortcoder_data’

    Hi Rohit,

    Sorry for the late reply.

    I don’t think it will work as the the DB value is serialized and saved by PHP. Find and replace on it won’t work as the length of the value changes.

    The best option would be to write a PHP code and execute it once.
    You can try the script I wrote for now.

    1) Take a backup of the shortcoder data first.
    2) Paste the bwlow code in theme’s function.php file and refresh any wordpress page once.

    function replace_sc_data(){
        
        $scs = get_option( 'shortcoder_data' );
    
        foreach($scs as $sc_name => $sc_prop){
            $sc_content = $sc_prop['content'];
            $replaced = str_replace('TO SEARCH TEXT', 'TO REPLACE TEXT', $sc_content);
            $scs[$sc_name]['content'] = $replaced;
        }
    
    }
    add_action('init', 'replace_sc_data');

    3) Delete the code later and save the file.

    Thanks,
    Aakash

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.