Hot answers tagged

11

It's not mandatory per se, but you should always use that and should consider it as mandatory. Consider the scenario when two Wordpress site has been setup in the same database. One with prefix wp_ and another with wp2_. If you install your plugin in both of the sites with the prefix, you created database will be wp_liveshoutbox for first site and ...


4

Consider the following: Your plugin is used on a wordpress network, which uses different table prefixes for each site. Your plugin could be running simultaneously on 836 different sites, all in the same database. wp_385677_liveshoutbox is a perfectly reasonable table name. Your plugin is installed by a user who has some concept of security, and has changed ...


4

You've just discovered an important feature of the core test suite: it forces any tables created during the test to be temporary tables. If you look in the WP_UnitTestCase::setUp() method you'll see that it calls a method called start_transaction(). That start_transaction() method starts a MySQL database transaction: function start_transaction() { ...


3

You pretty much answered it - legacy code. WordPress is the result of years of code evolution, refactoring and (most importantly) multiple developers/coders/authors - whilst they're getting pretty good at enforcing coding standards/consistency, there will always be a trail of the past.


2

When I started out with Wordpress I was anti-plugin. I wanted to add everything in my theme's functions.php. When I looked at the bigger picture it began making sense having and leaving some functionalities inside a plugin. There are many write-ups on the subject of what should go into a plugin and what should go into a theme. I, for one, have done one or ...


2

This is actually not that hard, but you will have to excuse me for keeping it high level because this is just a stupid thing to do as all things which are security by obscurity. All you need to do is write your WPDB driver, which inherits the WPDB class. Place it in /wp-content/db.php file and make sure to initialize the global $wpdb object with your class. ...


1

You should get total and result array separately. Total is to create the page numbers and result array will give you limited data for each pages. Refer the below code. if (isset($_POST['list_position']) && $_POST['list_position'] != 'Select by Position'){ $list_position= $_POST['list_position']; $totalPosition= $wpdb->get_var("SELECT ...


1

register_activation_hook() only attaches a function to run on activation of your plugin, not on updating. See the docs for full details, particularly this part: 3.1 : This hook is now fired only when the user activates the plugin and not when an automatic plugin update occurs (#14915). Of course, you could force your hook to run by deactivating and ...


1

My choice would be to use WP_List_Table. If you continue reading the Codex it makes it clear that it is commonly used by third party code. "Someday" it might go away, but I doubt it will happen abruptly (if at all). If it does change, there will probably be a newer solution to replace it. EDIT: Another thought. if you feel really can't use WP_List_Table ...


1

Why not extend WP_List_Table? It creates responsive tables that collapse to an accordion when the table width exceeds the screen size. See Class Reference/WP List Table. You might take a look at the code in this plugin to get started: Custom List Table Example


1

<?php $mydb = new wpdb('uid','passwd','database','localhost'); $mydb->show_errors(); $query = "SELECT DATE_FORMAT(col1, '%d-%b') AS Pdate, DATE_FORMAT(col1, '%Y') AS Pyear, col2, col3, col4, col5 AS fname FROM table ORDER BY col1 DESC LIMIT 50"; $result = $mydb->get_results($query); echo $mydb->num_rows . ' in table '; ?>


1

Heyaa..., I've found a final answer, hufft... Yeah, first I include the necessary classes just like in this thread : Fatal error after 4.4 upgrade class-wp-list-table And second, I added up this line in the display_tablenav method in WP_List_Table class : $this->screen = get_current_screen(); before this line : $this->pagination( $which ); ...


1

When we call get_the_title(), then the post title is taken through the wptexturize() function via the the_title filter: add_filter( 'the_title', 'wptexturize' ); The en-dash and em-dash are replaced with /* translators: en dash */ $en_dash = _x( '&#8211;', 'en dash' ); /* translators: em dash */ $em_dash = _x( '&#8212;', 'em dash' ); A simple ...


1

First of all you are trying to combine both of the tables by post_parent. $wpdb->posts.post_parent = $wpdb->ftcalendar_events.post_parent I guess data in the ftcalendar_events has children of posts table, try $wpdb->posts.ID = $wpdb->ftcalendar_events.post_parent Also you can try joining tables: SELECT * FROM $wpdb->posts JOIN ...


1

can I just create one using PHPMYADMIN ? Yes.You can. And its a shortest way to do it.


1

I didn't do this recently but in 2014, in a few WordPress projects that I need additional tables I used Laravel components. In WordPress, if you want to create your own tables by using wpdb and mysql queries. But with the Laravel database classes I managed to do this much more elegantly. A quick rundown how I do this: (note: At the time, I used Laravel 4 ...


1

Try edit Privileges for your wordpress database user from phpMyAdmin.


1

You can use these filters: add_filter( 'request', 'users_orderby_column' ); function users_orderby_column( $vars ) { // Your code goes here }



Only top voted, non community-wiki answers of a minimum length are eligible