Performance with autoload and the options table

I am playing around with the autoload column of the options table. I didn't find much information about how the autoloaded values are used. I tried a print_r($GLOBALS) and saw that the autoloaded options are stored in $GLOBALS['wp_object_cache']->cache['options']['alloptions']. Is there another way to access those variables? Suppose I need to access an option my_option, which was set to autoload, multiple times in different templates (eg. once in header.php, once in footer.php), which method is recommended? Is it okay that I …
Category: Web

Wordpress Unit Testing - Cannot Create Tables

I'm using PHPUnit to Unit Test my WP plugin on top of the WP testing suite. Everything works fine except that when I try to create a table via the setUp method, the table doesn't get created. Here's my code: class Test_Db extends PAO_UnitTestCase { function setUp() { parent::setUp(); global $wpdb; $sql = "CREATE TABLE {$wpdb->prefix}mytest ( id bigint(20) NOT NULL AUTO_INCREMENT, column_1 varchar(255) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $this->el(dbDelta($sql)); } function tearDown() { …
Category: Web

CSS for Table Rows and Columns

I have a simple table layout as per below: <table> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> <tr> <td>5</td> <td>6</td> </tr> </table> And the following CSS: table td:nth-child(1), table tr:nth-child(1) { font-weight: bold; } The first column is bolded but the first row remains as normal text. I don't want to use headers as TinyMCE in Wordpress creates tables automatically in the above format so I'd rather just stick with that rather than then have to change the HTML. …
Category: Web

Create multiple pages with tables from json file

I have this problem on Wordpress. I have a json file with a structure like this { "obj": [ "obj1": { "field1": "..", "field2": [ { "field": "" } ] }, "obj2": { "field1": "..", "field2": [ { "field": "" } ] }, ... ] } Now I need to create a page for each obj in the json by using Wordpress Rest API. I know I can do it, but the problem is that in each page I need …
Category: Web

Insert double entry in DB

I created plugin and my plugin create new Table in DB. My problem is when user type something in field firstname, lastname... and click on button Submit, that go to my table and that is ok.. but then when user do a refresh page, then again i get the same imports in my table. And if field are empty and I do refresh I get the new row in table with empty firstname and lastname.. Here is my code.. http://pastebin.com/RJcFXeUV …
Category: Web

Show a table from data submitted by a form from a user

I would like to show a table on my wordpress site, which is filled by registered users. How can I realize this? So my thoughts are: Registered users should be able to submit 2 variables through a contact form (1 should be a category, and 2 some text) The variables will be pushed to a database so that there is 1 table for every category which is holding the different texts, accompanied with the username who submitted it. Now there …
Category: Web

Wordpress Multisite - can I somehow merge the tables?

First of all, I need to say I'm not a fan of WordPress at all and I have never fully understood it. But I have inherited a multisite wordpress where anyone can register his own site. All in all, we have thousands of sites. Every site has 10 database tables. Every single mysql table has 3 files (MYD, MYI and sdi). It means meaybe 200 000 files in single directory, which is absolutely insane. Needless to say that working with …
Category: Web

Table Sorter sort by span title?

I'm using table sorter plugin to sort a table on my website. One column has only unsortable signs as content. However I'm trying to sort this column by value. It's the column IMDb here: https://flimmerzimmer.eu/filmothek/ So I added span title to the span with corresponding value but it's not sortable. Any ideas how to sort this column?
Category: Web

How to add a sortable date column in an admin page?

I'm trying to add a date column to an admin table (to woocommerce order page, just to be specific, but this code is not plugin dependent). The code works for adding the column, but whenever I try to sort the column tapping the sorting triangle button on the order page it returns 'No record found'. Maybe there is a problem with date format in the function returning the date? The rest of the code is pretty standard // Adding a …
Category: Web

Dynamic data table from external json feed

First of all, while I'm fairly comfortable with code, I'm also quite new to Wordpress development, JS, and PHP so please forgive me if this is not explained very well, or a real rookie-type question. I'd like to add the data from this JSON feed: http://ebird.org/ws1.1/data/obs/geo/recent?lng=-112.53&lat=53.38&dist=10&back=30&maxResults=500&locale=en_US&fmt=json (documentation by searching for "eBird API 1.1" ) into a table with "Common Name" "How Many" "Date" and "Location Name" columns. I'd also love to be able to "fancy the table up" with jquery …
Category: Web

Some error in mysql script ? Can't working to create table

Has some wrong in my code ??? please help <?php global $lots_db_version; $lots_db_version = '1.0'; function lots_install() { global $wpdb; global $lots_db_version; $table_name = $wpdb->prefix . 'auction_lots'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, product_id mediumint(9) UNSIGNED NOT NULL, finish_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, user_id mediumint(9) UNSIGNED, start_price decimal(10,2), v_min_price decimal(10,2), last_bid_price decimal(10,2), last_price decimal(10,2), status tinyint(1), PRIMARY KEY (id) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); add_option( …
Category: Web

Clone wp-admin/users.php (Users Admin Page)

I have created a new page in admin. I need to show all the users in this page(like Users admin page). The reason for this is because i want to show certain custom user roles only on this page. I tried using WP_List_Table but no luck in figuring out on how to implement. This is the function i have, i need to put the code inside here. add_action( 'admin_menu', 'cypolicy_users_admin_menu' ); function cypolicy_users_admin_page_contents() { echo "<h1>" . esc_html_e( 'CyPolicy Users', …
Category: Web

How to get user ID during registration and add it to a custom table

I am trying to get the user ID during registration and automatically add that ID to my custom table. I am using the WP-Members plugin for registration. Is it possible to get user ID on the fly while registering and add that ID to another custom table with WP-Members plugin. Or I could use a custom registration page if required; but I need some guidance how to get user ID on the fly during registration. Anyone please help me...
Category: Web

Wordpress search on a custom table

I have set up a custom table in my WP DB and have it all working in the admin backend of WP with WP_List_Table where I can edit and add new entries perfectly. I have now moved on to the front-end side of things and what I am wanting to achieve is users being able to search for a name in that custom table from a page on the WP site which has a searchbox. They should be able to …
Category: Web

I am trying to display information from a custom table from my wordpress users pages

to preface this I know my way around a computer but I'm no coder by any means. I have a site where users can purchase points/credits to be used for a service on the site. Each customer has their balance displayed in their account in a transactions page, this page gets it's figures from a custom table from what I gather. What I'm essentially trying to do is have the 'remaining balance' figures displayed on each of my users pages, …
Category: Web

WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?

Desired outcome I want display: none to be applied to the entire table after form submit button is clicked, because once I got the order number ( $order->get_id() ), in a second step I want to display the order details and a second form table to edit the weights of each item (and the initial form table with the list of orders would take too much space). (if required or helpful I can post screenshots of the two form tables). …
Category: Web

Register custom table for WP to use in a plugin

I am trying to add a custom table handler to $wpdb. public function __construct() { $this->register_tables(); } public function register_tables() { global $wpdb; $wpdb->tables[] = 'my_new_tablename'; } public function testing() { global $wpdb; wp_die($wpdb->my_new_tablename); } But when running the testing() method, I realize that $wpdb->my_new_tablename is not defined. How may I register my own table name and make it available at $wpdb->my_new_tablename, just like as if it was a native WP table?
Category: Web

The plugin generated x characters of unexpected output, $wpdb not defined

I've written a simple Wordpress plugin to create a new database table. The new table ought to be created when the plugin is activated. When I try to activate the plugin, I get the following error: The plugin generated 3989 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin. emphasized text This is obviously a result of the fact the $wbdb is not …
Category: Web

Is classical wordpress eidtor a good option for me to include a large table with a large number of images on my webpage?

I am a beginner at using WordPress for my website. I generally design my website using the classical editor provided by WordPress and by installing very few plugins such as Beaver Builder and code syntax highlighter. I am not well aware of doing coding in PHP, CSS, etc. Currently, I need to include a large table of (thousands of) rows with at least 7 columns. Some of the columns include images and the others include strings are numbers. I can …
Category: Web

Table block - Wrap table

I am using Gutenberg to create tables. Gutenberg tables have the following front-end structure : <figure class="wp-block-table"> <table> ... </table> </figure> I'd like to add a drop-shadow to my table but it doesn't work due to overflow-x : auto on the parent element figure. One fix would be to wrap the table like this : <figure class="wp-block-table"> <div class="table-wrapper"> <table> ... </table> </div> </figure> Is there a way to easily wrap the table ? I've seen a way to wrap …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.