Plugin Directory

Changeset 3209381


Ignore:
Timestamp:
12/17/2024 04:55:55 PM (14 months ago)
Author:
obmarketingtech
Message:

minor fix

Location:
outbrain-feed
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • outbrain-feed/tags/1.0.1/includes/Frontend.php

    r3209068 r3209381  
    2323        if ($snippet === false) {
    2424            // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    25             $snippet = $wpdb->get_row($wpdb->prepare("SELECT * FROM `{$table_name}` LIMIT 1"));
     25            $snippet = $wpdb->get_row($wpdb->prepare("SELECT * FROM %s LIMIT 1", $table_name));
    2626            if ($snippet) {
    2727                wp_cache_set($cache_key, $snippet);
  • outbrain-feed/trunk/includes/DB.php

    r3209068 r3209381  
    88        global $wpdb;
    99        $this->wpdb = $wpdb;
    10         $this->create_tables();
    1110    }
    1211
    1312    public static function create_tables() {
    1413        global $wpdb;
     14        $charset_collate = $wpdb->get_charset_collate();
     15
     16        // Create the obfeed_snippets table
    1517        $table_name = $wpdb->prefix . 'obfeed_snippets';
    16         $charset_collate = $wpdb->get_charset_collate();
    17         $cache_key = 'obfeed_snippets_db_exists';
    18         $table_exists_1 = wp_cache_get( $cache_key );
    19 
    20         if ( false === $table_exists_1 ) {
    21             // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
    22             $table_exists_1 = $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table_name)) === $table_name;
    23             wp_cache_set( $cache_key, $table_exists_1 );
    24         }
    25 
    26         if ( $table_exists_1 ) {
    27             $sql = "CREATE TABLE $table_name (
     18        $sql = "CREATE TABLE $table_name (
    2819            id INT NOT NULL AUTO_INCREMENT,
    2920            widget_id VARCHAR(50) NOT NULL,
     
    3223            PRIMARY KEY (id)
    3324        ) $charset_collate;";
    34             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    35             dbDelta( $sql );
    36         }
    3725
    38         // Insert default data using prepared statements
    39         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
     26        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     27        dbDelta($sql);
     28
    4029        $wpdb->insert(
    4130            $table_name,
     
    5443    public static function cleanup() {
    5544        global $wpdb;
    56         $table_name = $wpdb->prefix . 'obfeed_snippets';
    57         $table_name = esc_sql($table_name); // Sanitize the table name properly
    58 
    59         // Construct the SQL query safely
    60         $sql = 'DROP TABLE IF EXISTS `' . $table_name . '`';
    61 
    62         // Suppress the warnings for direct database calls, no caching, and schema changes
    63         // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    64         $wpdb->query($sql);
    65 
     45        $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}obfeed_snippets");
    6646        delete_option('obfeed_plugin_mode');
    6747        delete_option('obfeed_plugin_status');
  • outbrain-feed/trunk/includes/Frontend.php

    r3209068 r3209381  
    1717        $table_name = $wpdb->prefix . 'obfeed_snippets';
    1818
    19         // Use caching to avoid repeated database queries
    20         $cache_key = 'obfeed_snippet';
    21         $snippet = wp_cache_get($cache_key);
    22 
    23         if ($snippet === false) {
    24             // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    25             $snippet = $wpdb->get_row($wpdb->prepare("SELECT * FROM `{$table_name}` LIMIT 1"));
    26             if ($snippet) {
    27                 wp_cache_set($cache_key, $snippet);
    28             }
    29         }
     19        $snippet = $wpdb->get_row("SELECT * FROM `{$table_name}` LIMIT 1");
    3020
    3121        if ($snippet) {
  • outbrain-feed/trunk/outbrain-feed.php

    r3209068 r3209381  
    44 * Plugin URI: https://developer.outbrain.com/outbrain-wordpress-implementation-guide/
    55 * Description: Dynamically inserts Outbrain feed widgets into articles, with flexible configuration.
    6  * Version: 1.0.1
     6 * Version: 1.0.2
    77 * Author: Outbrain Dev Team
    88 * Author URI:
     
    1919define('OBFEED_PLUGIN_URL', plugin_dir_url(__FILE__));
    2020
     21
    2122// Include necessary files
    2223require_once OBFEED_PLUGIN_DIR . 'includes/Loader.php';
     
    3031add_action('plugins_loaded', 'obfeed_initialize_plugin');
    3132
     33function obfeed_admin_styles() {
     34    wp_enqueue_style('obfeed_admin_styles', plugin_dir_url(__FILE__) . 'assets/css/admin-styles.css');
     35}
     36add_action('admin_enqueue_scripts', 'obfeed_admin_styles');
     37
    3238// Activation and Uninstall hooks
    33 //register_activation_hook(__FILE__, ['OBFEED\DB', 'create_tables']);
     39register_activation_hook(__FILE__, ['OBFEED\DB', 'create_tables']);
    3440register_uninstall_hook(__FILE__, ['OBFEED\DB', 'cleanup']);
  • outbrain-feed/trunk/readme.txt

    r3209068 r3209381  
    44Requires at least: 6.1
    55Tested up to: 6.7
    6 Stable tag: 1.0.1
     6Stable tag: 1.0.2
    77Requires PHP: 7.1
    88License: GPLv2 or later
Note: See TracChangeset for help on using the changeset viewer.