• From the wp-config.php file….

    $table_prefix = ‘WHATEVER’;

    How do you make a plugin check for a $table_prefix like WHATEVERposts?

    https://wordpress.pastebin.com/LegUYW2L

    It works just fine if you don’t have a $table_prefix, but not if you do have one.

    $wpdb->prefix
    doesn’t work since there’s
    $wpdb->query

    How do you make it work both with and with out a prefix?

Viewing 1 replies (of 1 total)
  • Thread Starter Ragnar1337

    (@ragnar1337)

    I got it…

    <?php
    /*
    yacka yacka yacks

    */

    function simpleDP(){
    global $wpdb;
    $wpdb->query(“DELETE FROM $wpdb->posts
    USING $wpdb->posts, $wpdb->posts as vtable
    WHERE ($wpdb->posts.ID > vtable.ID)
    AND ($wpdb->posts.post_title=vtable.post_title)”);

    }
    add_action(‘publish_post’, ‘simpleDP’);

    function OptimizeDaDatabase(){
    global $wpdb;
    $wpdb->query(“OPTIMIZE TABLE $wpdb->wp_smartfeed”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->ak_twitter”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->comments”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->links”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->options”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->postmeta”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->posts”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->term_relationships”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->term_taxonomy”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->terms”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->users”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->wp_smartfeed”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->wpo_campaign”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->wpo_campaign_category”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->wpo_campaign_feed”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->wpo_campaign_post”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->wpo_campaign_word”);
    $wpdb->query(“OPTIMIZE TABLE $wpdb->wpo_log”);
    }
    add_action(‘publish_post’, ‘OptimizeDaDatabase’);
    ?>

    and optimizes the tables at the same time.

Viewing 1 replies (of 1 total)
  • The topic ‘How do you search for the $table_prefix in a Plugin??’ is closed to new replies.