Creating table with plugin is not working

Your dot and quote notation is funky. Try this: if($wpdb->get_var(“SHOW TABLES LIKE ‘$table_name'” ) != $table_name){ $sql= “CREATE TABLE $table_name ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), reg_date TIMESTAMP );”; require_once (ABSPATH. ‘wp-admin/includes/upgrade.php’ ); dbDelta($sql); }

Current user in plugin returns NULL

Wait for the action plugins_loaded before you create the class instance. The pluggable functions are loaded at this time. From wp-settings.php: /** * Fires once activated plugins have loaded. * * Pluggable functions are also available at this point in the loading order. * * @since 1.5.0 */ do_action( ‘plugins_loaded’ ); I would even wait … Read more

Add version query tag to all images

Don’t know why you want to do it when there’s update_post_thumbnail_cache() in WordPress and set expire headers on server side. But you can try this in your functions.php: add_filter(‘wp_get_attachment_image_src’, function($img, $id, $size, $icon) { $img[0] = $img[0] . ‘?v={$some_version}’; return $img; }, PHP_INT_MAX, 4);

Customize permalink when creating a post

This can be done using the wp_insert_post_data hook. function house_post_slug( $data ) { if ( $data[‘post_type’] == ‘houses’ ) { $permalink = ”; if ( isset ( $_POST[‘ACF Code Field’] ) ) { $permalink = $_POST[‘ACF Code Field’]; } if ( isset ( $_POST[‘post_title’] ) ) { $permalink .= ‘-‘ . $_POST[‘post_title’]; } $data[‘post_name’] = … Read more